diff --git a/HGamer3D.cabal b/HGamer3D.cabal
--- a/HGamer3D.cabal
+++ b/HGamer3D.cabal
@@ -1,32 +1,32 @@
-Name:                HGamer3D
-Version:             0.8.0
-Synopsis:            Toolset for the Haskell Game Programmer
-Description:         
-	HGamer3D is a toolset for developing 3D games in the programming 
-	language Haskell. 
-
-License:             OtherLicense
-License-file:        LICENSE
-Author:              Peter Althainz
-Maintainer:          althainz@gmail.com
-Build-Type:          Simple
-Cabal-Version:       >=1.4
-Homepage:            http://www.hgamer3d.org
-Category:            Game Engine
-Extra-source-files:  Setup.hs 
- 
-Library
-  Build-Depends:     base >= 3 && < 5, containers, bytestring, text, filepath, directory, vect >=0.4 && <0.5, messagepack >=0.5 && <0.6, clock >=0.6 && <0.7, cereal >=0.5 && < 0.6, fresco-binding >= 0.2.0 && < 0.3.0
-
-  Exposed-modules:   HGamer3D.Data.Angle, HGamer3D.Data.Colour, HGamer3D.Data.LMH, HGamer3D.Data.GameTime, HGamer3D.Data.Geometry2D, HGamer3D.Data.Transform3D, HGamer3D.Data.TypeSynonyms, HGamer3D.Data.Vector, HGamer3D.Data.Window, HGamer3D.Data.PlayCmd, HGamer3D.Data.Parent, HGamer3D.Data, HGamer3D.Util.FileLocation, HGamer3D.Util.UniqueName, HGamer3D.Util.Variable, HGamer3D.Util, HGamer3D.Graphics3D.Camera, HGamer3D.Graphics3D.Graphics3DCommand, HGamer3D.Graphics3D.Geometry, HGamer3D.Graphics3D.Graphics3DConfig, HGamer3D.Graphics3D.Light, HGamer3D.Graphics3D.Material, HGamer3D.Graphics3D.Window, HGamer3D.Input.Mouse, HGamer3D.Input.Keyboard, HGamer3D.Input.Joystick, HGamer3D.Input.InputEventHandler, HGamer3D.Input, HGamer3D.Graphics3D, HGamer3D.GUI.UIElement, HGamer3D.GUI.Button, HGamer3D.GUI.EditText, HGamer3D.GUI.DropDownList, HGamer3D.GUI.Slider, HGamer3D.GUI.Text, HGamer3D.GUI.CheckBox, HGamer3D.GUI, HGamer3D.Audio.SoundSource, HGamer3D.Audio.SoundListener, HGamer3D.Audio.Volume, HGamer3D.Audio, HGamer3D
-
-  Other-modules:     
-
-  c-sources:         
-  
-  ghc-options:       
-  cc-options:        -Wno-attributes 
-  hs-source-dirs:    .
-  Include-dirs:      .
-  build-depends:
-     
+Name:                HGamer3D
+Version:             0.9.0
+Synopsis:            Toolset for the Haskell Game Programmer
+Description:         
+	HGamer3D is a toolset for developing 3D games in the programming 
+	language Haskell. 
+
+License:             OtherLicense
+License-file:        LICENSE
+Author:              Peter Althainz
+Maintainer:          althainz@gmail.com
+Build-Type:          Simple
+Cabal-Version:       >=1.4
+Homepage:            http://www.hgamer3d.org
+Category:            Game Engine
+Extra-source-files:  Setup.hs 
+ 
+Library
+  Build-Depends:     base >= 4.9 && < 4.10, containers, bytestring, text, filepath, directory, vect, binary-serialise-cbor, clock, cereal, fresco-binding
+
+  Exposed-modules:   HGamer3D.Data.Angle, HGamer3D.Data.Colour, HGamer3D.Data.LMH, HGamer3D.Data.GameTime, HGamer3D.Data.ScreenRect, HGamer3D.Data.Transform3D, HGamer3D.Data.Visible, HGamer3D.Data.TypeSynonyms, HGamer3D.Data.Vector, HGamer3D.Data.Window, HGamer3D.Data.PlayCmd, HGamer3D.Data.Parent, HGamer3D.Data.Geometry2D, HGamer3D.Data, HGamer3D.Util.FileLocation, HGamer3D.Util.UniqueName, HGamer3D.Util.Variable, HGamer3D.Util, HGamer3D.Graphics3D.Camera, HGamer3D.Graphics3D.Graphics3DCommand, HGamer3D.Graphics3D.Geometry, HGamer3D.Graphics3D.Graphics3DConfig, HGamer3D.Graphics3D.Light, HGamer3D.Graphics3D.Material, HGamer3D.Input.Mouse, HGamer3D.Input.Keyboard, HGamer3D.Input.Joystick, HGamer3D.Input.InputEventHandler, HGamer3D.Input, HGamer3D.Graphics3D, HGamer3D.GUI.UIElement, HGamer3D.GUI.Button, HGamer3D.GUI.EditText, HGamer3D.GUI.DropDownList, HGamer3D.GUI.Slider, HGamer3D.GUI.Text, HGamer3D.GUI.CheckBox, HGamer3D.GUI, HGamer3D.Audio.SoundSource, HGamer3D.Audio.SoundListener, HGamer3D.Audio.Volume, HGamer3D.Audio, HGamer3D
+
+  Other-modules:     
+
+  c-sources:         
+  
+  ghc-options:       
+  cc-options:        -Wno-attributes 
+  hs-source-dirs:    .
+  Include-dirs:      .
+  build-depends:
+     
diff --git a/HGamer3D.hs b/HGamer3D.hs
--- a/HGamer3D.hs
+++ b/HGamer3D.hs
@@ -1,195 +1,194 @@
--- This source file is part of HGamer3D
--- (A project to enable 3D game development in Haskell)
--- For the latest info, see http://www.hgamer3d.org
--- 
--- (c) 2011 - 2015 Peter Althainz
--- 
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
--- 
---     http://www.apache.org/licenses/LICENSE-2.0
--- 
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
--- 
--- HGamer3D
--- 
-
--- | Main module, to include API
-module HGamer3D
-
-(
-    module Fresco,
-    module HGamer3D.Data,
-    module HGamer3D.Util,
-    module HGamer3D.Graphics3D,
-    module HGamer3D.Input,
-    module HGamer3D.GUI,
-    module HGamer3D.Audio,
-
-    HG3D,
-    GameLogicFunction,
-    runGame,
-
-    registerCallback,
-    isExitHG3D,
-    resetExitHG3D,
-    exitHG3D,
-    newE,
-
---    ctParent,
-    EntityTree (..),
-    newET,
-
-    (<:),
-    (<|),
-    (-:),
-    (-|),
-
-    (#)
-)
-
-where
-
-import Fresco hiding (newE)
-import qualified Fresco as F (newE) 
-import HGamer3D.Data
-import HGamer3D.Util
-import HGamer3D.Graphics3D
-import HGamer3D.Input
-import HGamer3D.GUI
-import HGamer3D.Audio
-
-import Control.Concurrent
-import Control.Monad
-import Control.Concurrent.MVar
-import Data.IORef
-
-import qualified Data.Map as M
-import Data.Word
-import Data.Maybe
-
--- Opaque Value to denote some game-loop data
-data HG3D = HG3D ObjectLibSystem CallbackSystem (Var Bool)
-
--- runHG3D runs the engine in the main loop (for Mac) and executes game logic
-type GameLogicFunction = HG3D -> IO ()
-
--- runGame, runs the game in the main loop, creates threads for GameLogicFunctions
-runGame :: Graphics3DConfig -> GameLogicFunction -> GameTime -> IO ()
-runGame conf glf loopSleepTime = do
-
-    ols <- createOLS
-    cbs <- createCBS
-    varExit <- makeVar False
-
-    let hg3d = HG3D ols cbs varExit
-
-    forkIO $ do
-
-        -- create graphics system
-        eG3D <- newE hg3d [
-            ctGraphics3DConfig #: conf,
-            ctGraphics3DCommand #: NoCmd
-            ]
-
-        eih <- newE hg3d [
-            ctInputEventHandler #: DefaultEventHandler,
-            ctExitRequestedEvent #: ExitRequestedEvent
-            ]
-
-        -- create callback loop, handle windows exit command
-        forkIO $ do
-            registerReceiverCBS cbs eih ctExitRequestedEvent (\_ -> writeVar varExit True >> return ())
-            forever $ (stepCBS cbs)
-
-        -- create game logic loop
-        forkIO $ glf hg3d
-
-        -- create game step loop
-        let gameStep = do
-            setC eG3D ctGraphics3DCommand Step
-            sleepFor loopSleepTime
-            gameStep
-
-        forkIO $ gameStep
-
-        return ()
-
-    -- enter into endless game loop
-    let loopGame = do
-        stepOLS ols
-        ex <- readVar varExit
-        if ex
-            then return ()
-            else loopGame
-
-    loopGame
-
-isExitHG3D (HG3D ols cbs varExit) = do
-    ise <- readVar varExit
-    return ise
-
-resetExitHG3D (HG3D ols cbs varExit) = writeVar varExit False
-
-exitHG3D (HG3D ols cbs varExit) = do
-    writeVar varExit True >> return ()
-
-registerCallback (HG3D ols cbs varExit) e ct f = do
-    registerReceiverCBS cbs e ct f
-
-newE (HG3D ols cbs varExit) creationList = do
-    e <- F.newE creationList
-    addEntityOLS ols e
-    return e
-
-
-
-data EntityTree = ETNode (Maybe String) [(Word64, Component)]
-        | ETChild (Maybe String) [(Word64, Component)] [EntityTree]
-        | ETList [EntityTree]
-
-createET ::  HG3D -> EntityTree -> Maybe Entity -> IO [(String, Entity)]
-
-createET hg3d (ETNode label clist) parent = do
-  clist' <- case parent of
-              Just p -> idE p >>= \id -> return ((ctParent #: id) : filter (\(ct, c) -> (ComponentType ct) /= ctParent) clist)
-              Nothing -> return clist
-  e <- newE hg3d clist'
-  case label of
-    Just l -> return [(l, e)]
-    Nothing -> return []
-
-createET hg3d (ETList tlist) parent = do
-  l <- mapM (\et -> createET hg3d et parent) tlist
-  return (Prelude.concat l)
-
-createET hg3d (ETChild label clist tlist) parent = do
-  [(_, e1)] <- createET hg3d (ETNode (Just "label") clist) parent
-  let l1 = case label of
-            Just l -> [(l, e1)]
-            Nothing -> [] 
-  l2 <- createET hg3d (ETList tlist) (Just e1)
-  return (l1 ++ l2)
-
-newET :: HG3D -> [EntityTree] -> IO (M.Map String Entity)
-newET hg3d et = createET hg3d (ETList et) Nothing >>= \l -> return (M.fromList l)
-
-(<:) :: String -> [(Word64, Component)] -> EntityTree
-label <: clist = ETNode (Just label) clist
-
-(<|) :: String -> ([(Word64, Component)], [EntityTree]) -> EntityTree
-label <| (clist, tlist) = ETChild (Just label) clist tlist
-
-(-:) :: () -> [(Word64, Component)] -> EntityTree
-() -: clist = ETNode Nothing clist
-
-(-|) :: () -> ([(Word64, Component)], [EntityTree]) -> EntityTree
-() -| (clist, tlist) = ETChild Nothing clist tlist
-
-(#) :: (M.Map String Entity) -> String -> Entity
+-- This source file is part of HGamer3D
+-- (A project to enable 3D game development in Haskell)
+-- For the latest info, see http://www.hgamer3d.org
+-- 
+-- (c) 2011 - 2017 Peter Althainz
+-- 
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+-- 
+--     http://www.apache.org/licenses/LICENSE-2.0
+-- 
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+-- 
+-- HGamer3D
+-- 
+
+-- | Main module, to include API
+module HGamer3D
+
+(
+    module Fresco,
+    module HGamer3D.Data,
+    module HGamer3D.Util,
+    module HGamer3D.Graphics3D,
+    module HGamer3D.Input,
+    module HGamer3D.GUI,
+    module HGamer3D.Audio,
+
+    HG3D,
+    GameLogicFunction,
+    runGame,
+
+    registerCallback,
+    isExitHG3D,
+    resetExitHG3D,
+    exitHG3D,
+    newE,
+
+--    ctParent,
+    EntityTree (..),
+    newET,
+
+    (<:),
+    (<|),
+    (-:),
+    (-|),
+
+    (#)
+)
+
+where
+
+import Fresco hiding (newE)
+import qualified Fresco as F (newE) 
+import HGamer3D.Data
+import HGamer3D.Util
+import HGamer3D.Graphics3D
+import HGamer3D.Input
+import HGamer3D.GUI
+import HGamer3D.Audio
+
+import Control.Concurrent
+import Control.Monad
+import Control.Concurrent.MVar
+import Data.IORef
+
+import qualified Data.Map as M
+import Data.Word
+import Data.Maybe
+
+-- Opaque Value to denote some game-loop data
+data HG3D = HG3D ObjectLibSystem CallbackSystem (Var Bool)
+
+-- runHG3D runs the engine in the main loop (for Mac) and executes game logic
+type GameLogicFunction = HG3D -> IO ()
+
+-- runGame, runs the game in the main loop, creates threads for GameLogicFunctions
+runGame :: Graphics3DConfig -> GameLogicFunction -> GameTime -> IO ()
+runGame conf glf loopSleepTime = do
+
+    ols <- createOLS
+    cbs <- createCBS
+    varExit <- makeVar False
+
+    let hg3d = HG3D ols cbs varExit
+
+    forkIO $ do
+        -- create graphics system
+        eG3D <- newE hg3d [
+            ctGraphics3DConfig #: conf,
+            ctGraphics3DCommand #: NoCmd
+            ]
+
+        eih <- newE hg3d [
+            ctInputEventHandler #: DefaultEventHandler,
+            ctExitRequestedEvent #: ()
+            ]
+
+        -- create callback loop, handle windows exit command
+        forkIO $ do
+            registerReceiverCBS cbs eih ctExitRequestedEvent (\_ -> writeVar varExit True >> return ())
+            forever $ (stepCBS cbs)
+
+        -- create game logic loop
+        forkIO $ glf hg3d
+
+        -- create game step loop
+        let gameStep = do
+            setC eG3D ctGraphics3DCommand Step
+            sleepFor loopSleepTime
+            gameStep
+
+        forkIO $ gameStep
+
+        return ()
+
+    -- enter into endless game loop
+    let loopGame = do
+            stepOLS ols
+            ex <- readVar varExit
+            if ex
+                then return ()
+                else loopGame
+
+    loopGame
+
+isExitHG3D (HG3D ols cbs varExit) = do
+    ise <- readVar varExit
+    return ise
+
+resetExitHG3D (HG3D ols cbs varExit) = writeVar varExit False
+
+exitHG3D (HG3D ols cbs varExit) = do
+    writeVar varExit True >> return ()
+
+registerCallback (HG3D ols cbs varExit) e ct f = do
+    registerReceiverCBS cbs e ct f
+
+newE (HG3D ols cbs varExit) creationList = do
+    e <- F.newE creationList
+    addEntityOLS ols e
+    return e
+
+
+
+data EntityTree = ETNode (Maybe String) [(Word64, Component)]
+        | ETChild (Maybe String) [(Word64, Component)] [EntityTree]
+        | ETList [EntityTree]
+
+createET ::  HG3D -> EntityTree -> Maybe Entity -> IO [(String, Entity)]
+
+createET hg3d (ETNode label clist) parent = do
+  clist' <- case parent of
+              Just p -> idE p >>= \id -> return ((ctParent #: id) : filter (\(ct, c) -> (ComponentType ct) /= ctParent) clist)
+              Nothing -> return clist
+  e <- newE hg3d clist'
+  case label of
+    Just l -> return [(l, e)]
+    Nothing -> return []
+
+createET hg3d (ETList tlist) parent = do
+  l <- mapM (\et -> createET hg3d et parent) tlist
+  return (Prelude.concat l)
+
+createET hg3d (ETChild label clist tlist) parent = do
+  [(_, e1)] <- createET hg3d (ETNode (Just "label") clist) parent
+  let l1 = case label of
+            Just l -> [(l, e1)]
+            Nothing -> [] 
+  l2 <- createET hg3d (ETList tlist) (Just e1)
+  return (l1 ++ l2)
+
+newET :: HG3D -> [EntityTree] -> IO (M.Map String Entity)
+newET hg3d et = createET hg3d (ETList et) Nothing >>= \l -> return (M.fromList l)
+
+(<:) :: String -> [(Word64, Component)] -> EntityTree
+label <: clist = ETNode (Just label) clist
+
+(<|) :: String -> ([(Word64, Component)], [EntityTree]) -> EntityTree
+label <| (clist, tlist) = ETChild (Just label) clist tlist
+
+(-:) :: () -> [(Word64, Component)] -> EntityTree
+() -: clist = ETNode Nothing clist
+
+(-|) :: () -> ([(Word64, Component)], [EntityTree]) -> EntityTree
+() -| (clist, tlist) = ETChild Nothing clist tlist
+
+(#) :: (M.Map String Entity) -> String -> Entity
 m # s = fromJust $ M.lookup s m
diff --git a/HGamer3D/Audio.hs b/HGamer3D/Audio.hs
--- a/HGamer3D/Audio.hs
+++ b/HGamer3D/Audio.hs
@@ -1,29 +1,29 @@
-{-
-    Sound and Music
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/Audio.hs
--}
-
-
--- | Audio for HGamer3D 
-module HGamer3D.Audio
-
-(
-    module HGamer3D.Audio.SoundSource
-    , module HGamer3D.Audio.SoundListener
-    , module HGamer3D.Audio.Volume
-)
-
-where
-
-import HGamer3D.Audio.SoundSource
-import HGamer3D.Audio.SoundListener
-import HGamer3D.Audio.Volume
-
-
+{-
+    Sound and Music
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2015 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/Audio.hs
+-}
+
+
+-- | Audio for HGamer3D 
+module HGamer3D.Audio
+
+(
+    module HGamer3D.Audio.SoundSource
+    , module HGamer3D.Audio.SoundListener
+    , module HGamer3D.Audio.Volume
+)
+
+where
+
+import HGamer3D.Audio.SoundSource
+import HGamer3D.Audio.SoundListener
+import HGamer3D.Audio.Volume
+
+
diff --git a/HGamer3D/Audio/SoundListener.hs b/HGamer3D/Audio/SoundListener.hs
--- a/HGamer3D/Audio/SoundListener.hs
+++ b/HGamer3D/Audio/SoundListener.hs
@@ -1,31 +1,22 @@
-{-
-	Audio: Listener for sound, specifies mainyl the position for 3D sound
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/Audio/SoundListener.hs
--}
-
--- | Sound Listener
-module HGamer3D.Audio.SoundListener
-(
-    ctSoundListener
-)
-
-where
-
-import Fresco
-import Data.MessagePack
-import Debug.Trace
-import Data.Text
-
-import HGamer3D.Data
-
-ctSoundListener :: ComponentType ()
-ctSoundListener = ComponentType 0x7aacf4ee5bd2f958
-  
-
+{-
+	Audio: Listener for sound, specifies mainyl the position for 3D sound
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2015 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/Audio/SoundListener.hs
+-}
+
+-- | Sound Listener
+module HGamer3D.Audio.SoundListener
+where
+
+import Fresco
+
+type SoundListener = ()
+
+ctSoundListener :: ComponentType SoundListener
+ctSoundListener = ComponentType 0x7aacf4ee5bd2f958
diff --git a/HGamer3D/Audio/SoundSource.hs b/HGamer3D/Audio/SoundSource.hs
--- a/HGamer3D/Audio/SoundSource.hs
+++ b/HGamer3D/Audio/SoundSource.hs
@@ -1,45 +1,58 @@
-{-
-	Sound Source
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/Audio/SoundSource.hs
--}
-
--- | Module providing a Sound Source
-module HGamer3D.Audio.SoundSource
-(
-    SoundSource (..),
-    ctSoundSource
-)
-
-where
-
-import Fresco
-import Data.MessagePack
-import Debug.Trace
-import Data.Text
-
-import HGamer3D.Data
-
-data SoundSource = Sound Text Float Bool Text -- resource, Volume, loop, volume group
-                   | Sound3D Text Float Bool Text
-                   | Music Text Float Bool Text
-                   deriving (Eq, Show)
-                   
-instance ComponentClass SoundSource where
-    toObj (Sound snd vol l g) = ObjectArray [ObjectInt 0, toObj snd, ObjectFloat vol, ObjectBool l, toObj g]
-    toObj (Sound3D snd vol l g) = ObjectArray [ObjectInt 1, toObj snd, ObjectFloat vol, ObjectBool l, toObj g]
-    toObj (Music snd vol l g) = ObjectArray [ObjectInt 2, toObj snd, ObjectFloat vol, ObjectBool l, toObj g]
-    fromObj (ObjectArray [ObjectInt 0, snd_o, ObjectFloat vol, ObjectBool l, g_o]) = Sound (fromObj snd_o) vol l (fromObj g_o)
-    fromObj (ObjectArray [ObjectInt 1, snd_o, ObjectFloat vol, ObjectBool l, g_o]) = Sound3D (fromObj snd_o) vol l (fromObj g_o)
-    fromObj (ObjectArray [ObjectInt 2, snd_o, ObjectFloat vol, ObjectBool l, g_o]) = Music (fromObj snd_o) vol l (fromObj g_o)
-
-ctSoundSource :: ComponentType SoundSource
-ctSoundSource = ComponentType 0xafcef7aa41d88c0d
-  
-
+{-
+	Sound Source
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2015 - 2017 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/Audio/SoundSource.hs
+-}
+
+-- | Module providing a Sound Source
+module HGamer3D.Audio.SoundSource
+where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Decoding
+import Data.Binary.Serialise.CBOR.Encoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+data SoundType = Sound                                                                                                             
+    | Sound3D                                                                                                                      
+    | Music                                                                                                                        
+    deriving (Eq, Read, Show)                                                                                                      
+                                                                                                                                   
+data SoundSource = SoundSource {                                                                                                   
+    soundSourceType::SoundType,                                                                                                    
+    soundSourceResource::Text,                                                                                                     
+    soundSourceLoop::Bool,                                                                                                         
+    soundSourceVolume::Float,                                                                                                      
+    soundSourceVolumeGroup::Text                                                                                                   
+    } deriving (Eq, Read, Show)                                                                                                    
+                                                                                                                                   
+ctSoundSource :: ComponentType SoundSource                                                                                         
+ctSoundSource = ComponentType 0xafcef7aa41d88c0d                                                                                   
+                                                                                                                                   
+instance Serialise SoundType where                                                                                                 
+    encode (Sound) = encodeListLen 1 <>  encode (0::Int)                                                                           
+    encode (Sound3D) = encodeListLen 1 <>  encode (1::Int)                                                                         
+    encode (Music) = encodeListLen 1 <>  encode (2::Int)                                                                           
+    decode = do                                                                                                                    
+        decodeListLen                                                                                                              
+        i <- decode :: Decoder s Int                                                                                               
+        case i of                                                                                                                  
+            0 -> (pure Sound)                                                                                                      
+            1 -> (pure Sound3D)                                                                                                    
+            2 -> (pure Music)                                                                                                      
+                                                                                                                                   
+instance Serialise SoundSource where                                                                                               
+    encode (SoundSource v1 v2 v3 v4 v5) = encodeListLen 5 <> encode v1 <> encode v2 <> encode v3 <> encode v4 <> encode v5         
+    decode = decodeListLenOf 5 >> SoundSource <$> decode <*> decode <*> decode <*> decode <*> decode                               
+                                                                                                                                   
+                                                                                                                                   
diff --git a/HGamer3D/Audio/Volume.hs b/HGamer3D/Audio/Volume.hs
--- a/HGamer3D/Audio/Volume.hs
+++ b/HGamer3D/Audio/Volume.hs
@@ -1,38 +1,41 @@
-{-
-	Audio: Master Volume for different categories
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/Audio/Volume.hs
--}
-
--- | Module providing the Mouse functionality and settings
-module HGamer3D.Audio.Volume
-(
-    Volume (..),
-    ctVolume
-)
-
-where
-
-import Fresco
-import Data.MessagePack
-import Debug.Trace
-import Data.Text
-
-import HGamer3D.Data
-
-data Volume = Volume Text Float deriving (Eq, Show)
-
-instance ComponentClass Volume where
-    toObj (Volume cat vol) = ObjectArray [toObj cat, ObjectFloat vol]
-    fromObj (ObjectArray [cat_o, ObjectFloat vol]) = Volume (fromObj cat_o) vol
-
-ctVolume :: ComponentType Volume
-ctVolume = ComponentType 0x659d20e6e65f85fe
-  
-
+{-
+	Audio: Master Volume for different categories
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2015 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/Audio/Volume.hs
+-}
+
+-- | Module providing the Mouse functionality and settings
+module HGamer3D.Audio.Volume
+where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+data Volume = Volume {
+    volumeGroup::Text,
+    volumeGain::Float
+    } deriving (Eq, Read, Show)
+
+ctVolume :: ComponentType Volume
+ctVolume = ComponentType 0x659d20e6e65f85fe
+
+instance Serialise Volume where
+    encode (Volume v1 v2) = encodeListLen 2 <> encode v1 <> encode v2
+    decode = decodeListLenOf 2 >> Volume <$> decode <*> decode
+
+
+
+
diff --git a/HGamer3D/Data.hs b/HGamer3D/Data.hs
--- a/HGamer3D/Data.hs
+++ b/HGamer3D/Data.hs
@@ -1,59 +1,63 @@
--- This source file is part of HGamer3D
--- (A project to enable 3D game development in Haskell)
--- For the latest info, see http://www.hgamer3d.org
--- 
--- (c) 2011 - 2015 Peter Althainz
--- 
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
--- 
---     http://www.apache.org/licenses/LICENSE-2.0
--- 
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
--- 
--- HGamer3D/Data.hs
--- 
-
--- | Common data definitions for HGamer3D 
-module HGamer3D.Data 
-
-(
-	-- * Baisc Datatypes 
-	module HGamer3D.Data.Angle,
-	module HGamer3D.Data.Colour,
-	module HGamer3D.Data.LMH,
-	module HGamer3D.Data.GameTime,
-
-	-- * Geometry Datatypes
-	module HGamer3D.Data.Vector,
-	module HGamer3D.Data.Geometry2D,
-	module HGamer3D.Data.Transform3D,
-	module HGamer3D.Data.TypeSynonyms,
-
-    -- * Misc
-    module HGamer3D.Data.PlayCmd, 
-    module HGamer3D.Data.Parent,
-    
-	-- * Implementation 
-	module HGamer3D.Data.Window
-)
-
-where
-
-import HGamer3D.Data.Angle
-import HGamer3D.Data.Colour
-import HGamer3D.Data.LMH
-import HGamer3D.Data.GameTime
-import HGamer3D.Data.Geometry2D
-import HGamer3D.Data.Transform3D
-import HGamer3D.Data.TypeSynonyms
-import HGamer3D.Data.Vector
-import HGamer3D.Data.Window
-import HGamer3D.Data.PlayCmd
-import HGamer3D.Data.Parent
-
+-- This source file is part of HGamer3D
+-- (A project to enable 3D game development in Haskell)
+-- For the latest info, see http://www.hgamer3d.org
+-- 
+-- (c) 2011 - 2015 Peter Althainz
+-- 
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+-- 
+--     http://www.apache.org/licenses/LICENSE-2.0
+-- 
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+-- 
+-- HGamer3D/Data.hs
+-- 
+
+-- | Common data definitions for HGamer3D 
+module HGamer3D.Data 
+
+(
+    -- * Baisc Datatypes 
+    module HGamer3D.Data.Angle,
+    module HGamer3D.Data.Colour,
+    module HGamer3D.Data.LMH,
+    module HGamer3D.Data.GameTime,
+    module HGamer3D.Data.Visible,
+
+    -- * Geometry Datatypes
+    module HGamer3D.Data.Vector,
+    module HGamer3D.Data.ScreenRect,
+    module HGamer3D.Data.Geometry2D,
+    module HGamer3D.Data.Transform3D,
+    module HGamer3D.Data.TypeSynonyms,
+
+    -- * Misc
+    module HGamer3D.Data.PlayCmd, 
+    module HGamer3D.Data.Parent,
+
+    -- * Implementation 
+    module HGamer3D.Data.Window
+)
+
+where
+
+import HGamer3D.Data.Angle
+import HGamer3D.Data.Colour
+import HGamer3D.Data.LMH
+import HGamer3D.Data.GameTime
+import HGamer3D.Data.Visible
+import HGamer3D.Data.ScreenRect
+import HGamer3D.Data.Geometry2D
+import HGamer3D.Data.Transform3D
+import HGamer3D.Data.TypeSynonyms
+import HGamer3D.Data.Vector
+import HGamer3D.Data.Window
+import HGamer3D.Data.PlayCmd
+import HGamer3D.Data.Parent
+
diff --git a/HGamer3D/Data/Angle.hs b/HGamer3D/Data/Angle.hs
--- a/HGamer3D/Data/Angle.hs
+++ b/HGamer3D/Data/Angle.hs
@@ -1,89 +1,102 @@
-{-
-	Datatypes to specify a geometric angle
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2011-2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/Data/Angle.hs
--}
-
--- | Angles as Degrees or Radians, based on Float datatype
-module HGamer3D.Data.Angle 
-
-(
-    -- * Data definitions and conversions
-    Angle (..),
-    asRad,
-    asDeg,
-        
-    -- * Mathematical functions
-    addA,
-    subA,
-    mulA,
-    divA,
-    sinA,
-    cosA,
-    tanA,
-    asinA,
-    acosA,
-    atanA,
-)
-
-where
-
-import Data.MessagePack
-import Fresco
-
--- | construct an Angle either by giving it in degrees or radians
-data Angle = Rad Float | Deg Float deriving (Eq, Ord, Show)
-
--- | value of an Angle as radiant
-asRad :: Angle -> Float
-asRad (Rad f) = f
-asRad (Deg d) = d/180*pi
-
--- | value of an Angle as degree
-asDeg :: Angle -> Float
-asDeg (Deg f) = f
-asDeg (Rad d) = d/pi*180
-
-
-sinA :: Angle -> Float
-sinA = sin . asRad
-
-cosA :: Angle -> Float
-cosA = cos . asRad
-
-tanA :: Angle -> Float
-tanA = tan . asRad
-
-asinA :: Float -> Angle
-asinA = Rad . asin
-
-acosA :: Float -> Angle
-acosA = Rad . acos
-
-atanA :: Float -> Angle
-atanA = Rad . atan
-
-addA :: Angle -> Angle -> Angle
-addA a b = Rad $ (asRad a) + (asRad b)
-
-subA :: Angle -> Angle -> Angle
-subA a b = Rad $ (asRad a) - (asRad b)
-
-mulA :: Angle -> Float -> Angle
-mulA a b = Rad $ (asRad a) * b
-
-divA :: Angle -> Float -> Angle
-divA a b = Rad $ (asRad a) / b
-
-instance ComponentClass Angle where
-    toObj (Rad v1) = ObjectArray [ObjectInt 0, ObjectArray [ObjectFloat v1]]
-    toObj (Deg v1) = ObjectArray [ObjectInt 1, ObjectArray [ObjectFloat v1]]
-    fromObj (ObjectArray [ObjectInt 0, ObjectArray [ObjectFloat v1]]) = Rad v1
-    fromObj (ObjectArray [ObjectInt 1, ObjectArray [ObjectFloat v1]]) = Deg v1
-
+{-
+	Datatypes to specify a geometric angle
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2011-2017 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/Data/Angle.hs
+-}
+
+-- | Angles as Degrees or Radians, based on Float datatype
+module HGamer3D.Data.Angle 
+
+(
+    -- * Data definitions and conversions
+    Angle (..),
+    asRad,
+    asDeg,
+        
+    -- * Mathematical functions
+    addA,
+    subA,
+    mulA,
+    divA,
+    sinA,
+    cosA,
+    tanA,
+    asinA,
+    acosA,
+    atanA,
+)
+
+where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+data Angle = Rad Float
+    | Deg Float
+    deriving (Eq, Read, Show)
+
+instance Serialise Angle where
+    encode (Rad v1) = encodeListLen 2 <>  encode (0::Int) <> encode v1
+    encode (Deg v1) = encodeListLen 2 <>  encode (1::Int) <> encode v1
+    decode = do
+        decodeListLen
+        i <- decode :: Decoder s Int
+        case i of
+            0 -> (Rad <$> decode)
+            1 -> (Deg <$> decode)
+
+
+-- | value of an Angle as radiant
+asRad :: Angle -> Float
+asRad (Rad f) = f
+asRad (Deg d) = d/180*pi
+
+-- | value of an Angle as degree
+asDeg :: Angle -> Float
+asDeg (Deg f) = f
+asDeg (Rad d) = d/pi*180
+
+
+sinA :: Angle -> Float
+sinA = sin . asRad
+
+cosA :: Angle -> Float
+cosA = cos . asRad
+
+tanA :: Angle -> Float
+tanA = tan . asRad
+
+asinA :: Float -> Angle
+asinA = Rad . asin
+
+acosA :: Float -> Angle
+acosA = Rad . acos
+
+atanA :: Float -> Angle
+atanA = Rad . atan
+
+addA :: Angle -> Angle -> Angle
+addA a b = Rad $ (asRad a) + (asRad b)
+
+subA :: Angle -> Angle -> Angle
+subA a b = Rad $ (asRad a) - (asRad b)
+
+mulA :: Angle -> Float -> Angle
+mulA a b = Rad $ (asRad a) * b
+
+divA :: Angle -> Float -> Angle
+divA a b = Rad $ (asRad a) / b
+
diff --git a/HGamer3D/Data/Colour.hs b/HGamer3D/Data/Colour.hs
--- a/HGamer3D/Data/Colour.hs
+++ b/HGamer3D/Data/Colour.hs
@@ -1,113 +1,121 @@
-{-
-	Datatypes to specify a geometric angle
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2011-2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/Data/Colour.hs
--}
-    
--- | The Colour type and some standard colours
-module HGamer3D.Data.Colour
-
-(
-    Colour (..),
-    ctColour,
-    white,
-    silver,
-    grey,
-    darkgrey,
-    black,
-    red,
-    maroon,
-    yellow,
-    olive,
-    lime,
-    green,
-    aqua,
-    teal,
-    blue,
-    navy,
-    fuchsia,
-    purple
-)
-
-where
-
-import Data.MessagePack
-import Fresco
-
--- generated
-
-data Colour = Colour {
-    cRed::Float,
-    cGreen::Float,
-    cBlue::Float,
-    cAlpha::Float
-}
-
-instance ComponentClass Colour where
-    toObj (Colour v1 v2 v3 v4) = ObjectArray [ObjectFloat v1, ObjectFloat v2, ObjectFloat v3, ObjectFloat v4]
-    fromObj (ObjectArray [ObjectFloat v1, ObjectFloat v2, ObjectFloat v3, ObjectFloat v4]) = Colour v1 v2 v3 v4
-
-ctColour :: ComponentType Colour
-ctColour = ComponentType 0xe202add0521cde41
-
--- generated
-
-white :: Colour
-white = Colour 1.0 1.0 1.0 1.0
-
-silver:: Colour
-silver  = Colour 0.75 0.75 0.75 1.0
-
-grey:: Colour
-grey = Colour 0.5 0.5 0.5 1.0
-
-darkgrey :: Colour
-darkgrey = Colour 0.25 0.25 0.25 1.0
-
-black :: Colour
-black = Colour 0.0 0.0 0.0 1.0
-
-red :: Colour
-red = Colour 1.0 0.0 0.0 1.0
-
-maroon :: Colour
-maroon = Colour 0.5 0.0 0.0 1.0
-
-yellow :: Colour
-yellow = Colour 1.0 1.0 0.0 1.0
-
-olive :: Colour
-olive = Colour 0.5 0.5 0.0 1.0
-
-lime :: Colour
-lime = Colour 0.0 1.0 0.0 1.0
-
-green :: Colour
-green = Colour 0.0 0.5 0.0 1.0
-
-aqua :: Colour
-aqua = Colour 0.0 1.0 1.0 1.0
-
-teal :: Colour
-teal = Colour 0.0 0.5 0.5 1.0
-
-blue :: Colour
-blue = Colour 0.0 0.0 1.0 1.0
-
-navy :: Colour
-navy = Colour 0.0 0.0 0.5 1.0
-
-fuchsia :: Colour
-fuchsia = Colour 1.0 0.0 1.0 1.0
-
-purple :: Colour
-purple = Colour 0.5 0.0 0.5 1.0
-
-
-
+{-
+	Datatypes to specify a geometric angle
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2011 - 2017 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/Data/Colour.hs
+-}
+    
+-- | The Colour type and some standard colours
+module HGamer3D.Data.Colour
+
+(
+    Colour (..),
+    ctColour,
+    white,
+    silver,
+    grey,
+    darkgrey,
+    black,
+    red,
+    maroon,
+    yellow,
+    olive,
+    lime,
+    green,
+    aqua,
+    teal,
+    blue,
+    navy,
+    fuchsia,
+    purple
+)
+
+where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Decoding
+import Data.Binary.Serialise.CBOR.Encoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+data Colour = Colour {
+    colourRed::Float,
+    colourGreen::Float,
+    colourBlue::Float,
+    colourAlpha::Float
+    } deriving (Eq, Read, Show)
+
+ctColour :: ComponentType Colour
+ctColour = ComponentType 0xe202add0521cde41
+
+
+instance Serialise Colour where
+    encode (Colour v1 v2 v3 v4) = encodeListLen 4 <> encode v1 <> encode v2 <> encode v3 <> encode v4
+    decode = decodeListLenOf 4 >> Colour <$> decode <*> decode <*> decode <*> decode
+
+
+
+-- generated
+
+white :: Colour
+white = Colour 1.0 1.0 1.0 1.0
+
+silver:: Colour
+silver  = Colour 0.75 0.75 0.75 1.0
+
+grey:: Colour
+grey = Colour 0.5 0.5 0.5 1.0
+
+darkgrey :: Colour
+darkgrey = Colour 0.25 0.25 0.25 1.0
+
+black :: Colour
+black = Colour 0.0 0.0 0.0 1.0
+
+red :: Colour
+red = Colour 1.0 0.0 0.0 1.0
+
+maroon :: Colour
+maroon = Colour 0.5 0.0 0.0 1.0
+
+yellow :: Colour
+yellow = Colour 1.0 1.0 0.0 1.0
+
+olive :: Colour
+olive = Colour 0.5 0.5 0.0 1.0
+
+lime :: Colour
+lime = Colour 0.0 1.0 0.0 1.0
+
+green :: Colour
+green = Colour 0.0 0.5 0.0 1.0
+
+aqua :: Colour
+aqua = Colour 0.0 1.0 1.0 1.0
+
+teal :: Colour
+teal = Colour 0.0 0.5 0.5 1.0
+
+blue :: Colour
+blue = Colour 0.0 0.0 1.0 1.0
+
+navy :: Colour
+navy = Colour 0.0 0.0 0.5 1.0
+
+fuchsia :: Colour
+fuchsia = Colour 1.0 0.0 1.0 1.0
+
+purple :: Colour
+purple = Colour 0.5 0.0 0.5 1.0
+
+
+
diff --git a/HGamer3D/Data/GameTime.hs b/HGamer3D/Data/GameTime.hs
--- a/HGamer3D/Data/GameTime.hs
+++ b/HGamer3D/Data/GameTime.hs
@@ -1,97 +1,97 @@
-{-
-	Time datatypes and functions
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2011-2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/Data/GameTime.hs
--}
-    
-
-{-# LANGUAGE TypeSynonymInstances, CPP #-}
-
--- | The time type for HGamer3D
-module HGamer3D.Data.GameTime
-
-(
-  GameTime,
-  
-  -- * functions, to convert time into a value 
-  sec,
-  msec,
-  usec,
-  
-  -- * functions to create a time from a value
-  secT,
-  msecT,
-  usecT,
-  
-  -- * functions, which handle different aspects of time
-  getTime,
-  getThreadCPUTime,
-  getProcessCPUTime,
-  sleepFor
-)
-
-where
-
-import Control.Concurrent
-import qualified System.Clock as C
-
-type GameTime = C.TimeSpec
-
-_toInteger :: C.TimeSpec -> Integer
-_toInteger ts = let
-  s = (fromIntegral (C.sec ts)) :: Integer
-  ns = (fromIntegral (C.nsec ts)) :: Integer
-  in s * 1000000000 + ns
-
-_fromInteger :: Integer -> C.TimeSpec
-_fromInteger i = let
-  s = fromIntegral (i `quot` 1000000000)
-  ns = fromIntegral (i `rem` 1000000000)
-  in C.TimeSpec s ns
-
--- | time to seconds
-sec :: C.TimeSpec -> Int
-sec ts = fromIntegral ((_toInteger ts) `quot` 1000000000)
-
--- | time to milliseconds
-msec :: C.TimeSpec -> Int
-msec ts = fromIntegral ((_toInteger ts) `quot` 1000000)
-
--- | time to microseconds
-usec :: C.TimeSpec -> Int
-usec ts = fromIntegral ((_toInteger ts) `quot` 1000)
-
--- | create time from seconds
-secT :: Int -> C.TimeSpec
-secT i = _fromInteger ((fromIntegral i) * 1000000000)
-
--- | create time from milliseconds
-msecT :: Int -> C.TimeSpec
-msecT i = _fromInteger ((fromIntegral i) * 1000000)
-
--- | create time from microseconds
-usecT :: Int -> C.TimeSpec
-usecT i = _fromInteger ((fromIntegral i) * 1000)
-
--- | get current time
-getTime :: IO GameTime
-getTime = C.getTime C.Realtime
-
--- | get thread time
-getThreadCPUTime :: IO GameTime
-getThreadCPUTime = C.getTime C.ThreadCPUTime
-
--- | get process cpu time
-getProcessCPUTime :: IO GameTime
-getProcessCPUTime = C.getTime C.ProcessCPUTime
-
--- | sleep for time intervall
-sleepFor :: GameTime -> IO ()
-sleepFor gt = threadDelay (usec gt)
-
+{-
+	Time datatypes and functions
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2011-2015 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/Data/GameTime.hs
+-}
+    
+
+{-# LANGUAGE TypeSynonymInstances, CPP #-}
+
+-- | The time type for HGamer3D
+module HGamer3D.Data.GameTime
+
+(
+  GameTime,
+  
+  -- * functions, to convert time into a value 
+  sec,
+  msec,
+  usec,
+  
+  -- * functions to create a time from a value
+  secT,
+  msecT,
+  usecT,
+  
+  -- * functions, which handle different aspects of time
+  getTime,
+  getThreadCPUTime,
+  getProcessCPUTime,
+  sleepFor
+)
+
+where
+
+import Control.Concurrent
+import qualified System.Clock as C
+
+type GameTime = C.TimeSpec
+
+_toInteger :: C.TimeSpec -> Integer
+_toInteger ts = let
+  s = (fromIntegral (C.sec ts)) :: Integer
+  ns = (fromIntegral (C.nsec ts)) :: Integer
+  in s * 1000000000 + ns
+
+_fromInteger :: Integer -> C.TimeSpec
+_fromInteger i = let
+  s = fromIntegral (i `quot` 1000000000)
+  ns = fromIntegral (i `rem` 1000000000)
+  in C.TimeSpec s ns
+
+-- | time to seconds
+sec :: C.TimeSpec -> Int
+sec ts = fromIntegral ((_toInteger ts) `quot` 1000000000)
+
+-- | time to milliseconds
+msec :: C.TimeSpec -> Int
+msec ts = fromIntegral ((_toInteger ts) `quot` 1000000)
+
+-- | time to microseconds
+usec :: C.TimeSpec -> Int
+usec ts = fromIntegral ((_toInteger ts) `quot` 1000)
+
+-- | create time from seconds
+secT :: Int -> C.TimeSpec
+secT i = _fromInteger ((fromIntegral i) * 1000000000)
+
+-- | create time from milliseconds
+msecT :: Int -> C.TimeSpec
+msecT i = _fromInteger ((fromIntegral i) * 1000000)
+
+-- | create time from microseconds
+usecT :: Int -> C.TimeSpec
+usecT i = _fromInteger ((fromIntegral i) * 1000)
+
+-- | get current time
+getTime :: IO GameTime
+getTime = C.getTime C.Realtime
+
+-- | get thread time
+getThreadCPUTime :: IO GameTime
+getThreadCPUTime = C.getTime C.ThreadCPUTime
+
+-- | get process cpu time
+getProcessCPUTime :: IO GameTime
+getProcessCPUTime = C.getTime C.ProcessCPUTime
+
+-- | sleep for time intervall
+sleepFor :: GameTime -> IO ()
+sleepFor gt = threadDelay (usec gt)
+
diff --git a/HGamer3D/Data/Geometry2D.hs b/HGamer3D/Data/Geometry2D.hs
--- a/HGamer3D/Data/Geometry2D.hs
+++ b/HGamer3D/Data/Geometry2D.hs
@@ -1,83 +1,46 @@
-{-
-	2D Geometry
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2011-2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/Data/Geometry2D.hs
--}
-  
-{-# LANGUAGE FlexibleInstances #-}
-
--- | Type definitions for 2D geometry 
-module HGamer3D.Data.Geometry2D
-(
-  -- * Geometry
-  Point (..),
-  Rectangle (..),
-  
-  ctScreenRect,
-  
-  rectFromPoints,
-  pointsFromRect
-  
-) where
-  
-import Data.MessagePack
-import Fresco
-
--- | A point has two coordinates an x and y one
-data Num a => Point a = Point {
-  ptX :: a,
-  ptY :: a
-  } deriving (Eq, Show)
-
-instance ComponentClass (Point Float) where
-  toObj (Point a b) = ObjectArray [ObjectFloat a, ObjectFloat b]
-  fromObj (ObjectArray [ObjectFloat a, ObjectFloat b]) = (Point a b)
-                      
-instance ComponentClass (Point Int) where
-  toObj (Point a b) = ObjectArray [ObjectInt (fromIntegral a), ObjectInt (fromIntegral b)]
-  fromObj (ObjectArray [ObjectInt a, ObjectInt b]) = (Point (fromIntegral a) (fromIntegral b))
-                      
--- | A rectangle has an a position as x and y and widht and height
-data Num a => Rectangle a = Rectangle {
-  xpos :: a,
-  ypos :: a,
-  width :: a,
-  height :: a } deriving (Eq, Show)
-
-ctScreenRect :: ComponentType (Rectangle Int)
-ctScreenRect = ComponentType 0x16877957e32da6b1  
-  
-instance ComponentClass (Rectangle Float) where
-  toObj (Rectangle x y w h) = ObjectArray [ObjectFloat x, ObjectFloat y, ObjectFloat w, ObjectFloat h]
-  fromObj (ObjectArray [ObjectFloat x, ObjectFloat y, ObjectFloat w, ObjectFloat h]) = (Rectangle x y w h)
-
-instance ComponentClass (Rectangle Int) where
-  toObj (Rectangle x y w h) = ObjectArray [ObjectInt (fromIntegral x), ObjectInt (fromIntegral y), ObjectInt (fromIntegral w), ObjectInt (fromIntegral h)]
-  fromObj (ObjectArray [ObjectInt x, ObjectInt y, ObjectInt w, ObjectInt h]) = Rectangle (fromIntegral x) (fromIntegral y) (fromIntegral w) (fromIntegral h)
-
-  
-  
--- | derive a rectangle from upper left and lower right points
-rectFromPoints :: Num a => Point a -> Point a -> Rectangle a
-rectFromPoints upperLeft lowerRight = Rectangle rx ry rw rh where
-  rx = ptX upperLeft
-  ry = ptY upperLeft
-  rw = (ptY lowerRight) - rx
-  rh = (ptY lowerRight) - ry
-  
--- | get upper left and lower right point from a rect
-pointsFromRect :: Num a => Rectangle a -> (Point a, Point a)
-pointsFromRect rect = (ul, lr) where
-  rx = xpos rect
-  ry = ypos rect
-  rx' = rx + (width rect)
-  ry' = ry + (height rect)
-  ul = Point rx ry
-  lr = Point rx' ry'
-  
+{-
+	2D Geometry
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2011-2015 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/Data/Geometry2D.hs
+-}
+  
+{-# LANGUAGE FlexibleInstances #-}
+
+-- | Type definitions for 2D geometry 
+module HGamer3D.Data.Geometry2D
+where
+  
+import HGamer3D.Data.ScreenRect
+import Fresco
+import Data.Int
+
+-- | A point has two coordinates an x and y one
+data Point = Point {
+  ptX :: Int,
+  ptY :: Int
+  } deriving (Eq, Show)
+
+-- | derive a rectangle from upper left and lower right points
+rectFromPoints :: (Point, Point) -> ScreenRect
+rectFromPoints (upperLeft, lowerRight) = ScreenRect rx ry rw rh where
+  rx = ptX upperLeft
+  ry = ptY upperLeft
+  rw = (ptY lowerRight) - rx
+  rh = (ptY lowerRight) - ry
+  
+-- | get upper left and lower right point from a rect
+pointsFromRect :: ScreenRect -> (Point, Point)
+pointsFromRect rect = (ul, lr) where
+  rx = screenRectX rect
+  ry = screenRectY rect
+  rx' = rx + (screenRectWidth rect)
+  ry' = ry + (screenRectHeight rect)
+  ul = Point rx ry
+  lr = Point rx' ry'
+  
diff --git a/HGamer3D/Data/LMH.hs b/HGamer3D/Data/LMH.hs
--- a/HGamer3D/Data/LMH.hs
+++ b/HGamer3D/Data/LMH.hs
@@ -1,47 +1,53 @@
-{-
-	Low, Medium, High Datatype
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2011-2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/Data/LMH.hs
--}
-
--- | Data type to specify a 3 choice volume of anything: Low, Medium, High
-module HGamer3D.Data.LMH
-(
-    ctOnOff,
-    QualityLMH (..),
-    ctLMH
-)
-
-where
-
-import Data.MessagePack
-import Fresco
-
-ctOnOff :: ComponentType Bool
-ctOnOff = ComponentType 0x30b235f8b63df8b0
-
-data QualityLMH = Low
-    | Medium
-    | High
-    deriving (Eq, Read, Show)
-
-instance ComponentClass QualityLMH where
-    toObj (Low) = ObjectArray [ObjectInt 0, ObjectArray []]
-    toObj (Medium) = ObjectArray [ObjectInt 1, ObjectArray []]
-    toObj (High) = ObjectArray [ObjectInt 2, ObjectArray []]
-    fromObj (ObjectArray [ObjectInt 0, ObjectArray []]) = Low
-    fromObj (ObjectArray [ObjectInt 1, ObjectArray []]) = Medium
-    fromObj (ObjectArray [ObjectInt 2, ObjectArray []]) = High
-
-
-ctLMH :: ComponentType QualityLMH
-ctLMH = ComponentType 0xd632bb5447a6c93c
-
-
-
+{-
+	Low, Medium, High Datatype
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2011-2017 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/Data/LMH.hs
+-}
+
+-- | Data type to specify a 3 choice volume of anything: Low, Medium, High
+module HGamer3D.Data.LMH
+where 
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+type Switch = Bool
+
+ctSwitch :: ComponentType Switch
+ctSwitch = ComponentType 0x30b235f8b63df8b0
+
+data LMH = Low
+    | Medium
+    | High
+    deriving (Eq, Read, Show)
+
+type QualityLMH = LMH
+
+ctQualityLMH :: ComponentType QualityLMH
+ctQualityLMH = ComponentType 0xd632bb5447a6c93c
+
+instance Serialise LMH where
+    encode (Low) = encodeListLen 1 <>  encode (0::Int) 
+    encode (Medium) = encodeListLen 1 <>  encode (1::Int) 
+    encode (High) = encodeListLen 1 <>  encode (2::Int) 
+    decode = do
+        decodeListLen
+        i <- decode :: Decoder s Int
+        case i of
+            0 -> (pure Low)
+            1 -> (pure Medium)
+            2 -> (pure High)
+
diff --git a/HGamer3D/Data/Parent.hs b/HGamer3D/Data/Parent.hs
--- a/HGamer3D/Data/Parent.hs
+++ b/HGamer3D/Data/Parent.hs
@@ -1,31 +1,32 @@
-{-
-	Datatypes to specify a parent by id
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2011-2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/Data/Colour.hs
--}
-    
--- | The Parent component type
-module HGamer3D.Data.Parent
-
-(
-    Parent,
-    ctParent 
-)
-
-where
-
-import Data.MessagePack
-import Data.ByteString
-import Fresco
-
-type Parent = ByteString
-
-ctParent :: ComponentType Parent
-ctParent = ComponentType 0xbadd24df00e737d8
-
+{-
+	Datatypes to specify a parent by id
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2011 - 2017 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/Data/Colour.hs
+-}
+    
+-- | The Parent component type
+module HGamer3D.Data.Parent
+
+(
+    Parent,
+    ctParent 
+)
+
+where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Decoding
+import Data.ByteString.Lazy
+
+type Parent = ByteString
+
+ctParent :: ComponentType Parent
+ctParent = ComponentType 0xbadd24df00e737d8
+
diff --git a/HGamer3D/Data/PlayCmd.hs b/HGamer3D/Data/PlayCmd.hs
--- a/HGamer3D/Data/PlayCmd.hs
+++ b/HGamer3D/Data/PlayCmd.hs
@@ -1,41 +1,49 @@
-{-
-	The Play Command
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2011-2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/Data/PlayCmd.hs
--}
-
--- | Type for a generic play command
-module HGamer3D.Data.PlayCmd
-(
-  PlayCmd (..),
-  ctPlayCmd
-    
-) where
-
-import Data.MessagePack
-import Fresco
-
-
-data PlayCmd = Play
-               | Pause
-               | Stop
-               deriving (Eq, Show)
-
-instance ComponentClass PlayCmd where
-    toObj Play = ObjectInt 1
-    toObj Pause = ObjectInt 2
-    toObj Stop = ObjectInt 3
-    fromObj (ObjectInt 1) = Play
-    fromObj (ObjectInt 2) = Pause
-    fromObj (ObjectInt 3) = Stop
-
-ctPlayCmd :: ComponentType PlayCmd
-ctPlayCmd = ComponentType 0x35f7752020f7f1cd
-
-
+{-
+	The Play Command
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2011 - 2017 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/Data/PlayCmd.hs
+-}
+
+-- | Type for a generic play command
+module HGamer3D.Data.PlayCmd
+where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+data PlayCmd = Play
+    | Pause
+    | Stop
+    deriving (Eq, Read, Show)
+
+ctPlayCmd :: ComponentType PlayCmd
+ctPlayCmd = ComponentType 0x35f7752020f7f1cd
+
+instance Serialise PlayCmd where
+    encode (Play) = encodeListLen 1 <>  encode (0::Int)
+    encode (Pause) = encodeListLen 1 <>  encode (1::Int)
+    encode (Stop) = encodeListLen 1 <>  encode (2::Int)
+    decode = do
+        decodeListLen
+        i <- decode :: Decoder s Int
+        case i of
+            0 -> (pure Play)
+            1 -> (pure Pause)
+            2 -> (pure Stop)
+
+
+
+
diff --git a/HGamer3D/Data/ScreenRect.hs b/HGamer3D/Data/ScreenRect.hs
new file mode 100644
--- /dev/null
+++ b/HGamer3D/Data/ScreenRect.hs
@@ -0,0 +1,39 @@
+{-
+	Datatypes to specify a geometric angle
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2011-2017 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/Data/ScreenRect.hs
+-}
+
+module HGamer3D.Data.ScreenRect
+
+where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+data ScreenRect = ScreenRect {
+    screenRectX::Int,
+    screenRectY::Int,
+    screenRectWidth::Int,
+    screenRectHeight::Int
+    } deriving (Eq, Read, Show)
+
+ctScreenRect :: ComponentType ScreenRect
+ctScreenRect = ComponentType 0x16877957e32da6b1
+
+instance Serialise ScreenRect where
+    encode (ScreenRect v1 v2 v3 v4) = encodeListLen 4 <> encode v1 <> encode v2 <> encode v3 <> encode v4
+    decode = decodeListLenOf 4 >> ScreenRect <$> decode <*> decode <*> decode <*> decode
diff --git a/HGamer3D/Data/Transform3D.hs b/HGamer3D/Data/Transform3D.hs
--- a/HGamer3D/Data/Transform3D.hs
+++ b/HGamer3D/Data/Transform3D.hs
@@ -1,60 +1,60 @@
-{-
-	Transformation of 3D entities by scale, position, ...
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2011-2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/Data/Transform3D.hs
--}
-  
--- | Functions for basic 3D transformations
-module HGamer3D.Data.Transform3D
-(
-  translate,
-  scale, 
-  yaw,
-  pitch,
-  roll
-)
-
-where
-
-import HGamer3D.Data.Vector
-import HGamer3D.Data.Angle
-
-type Position = Vec3
-type Orientation = UnitQuaternion
-type Size = Vec3
-
--- | move the position 
-translate :: Position -> Position -> Position
-translate = (&+)
-
--- | scale the size
-scale :: Size -> Vec3 -> Size
-scale  = (&!)
-
--- yaw, roll, pitch functions
--- functions, to rotate on axis, relative to object
-rotRelativeToObjectAxis :: Orientation -> Vec3 -> Float -> Orientation
-rotRelativeToObjectAxis ori axis val = let
-  odir = actU ori axis
-  qrot = rotU odir val
-  nrot = qrot .*. ori
-  in nrot
-	
--- | rotate object on own axis (yaw) by angle
-yaw :: Orientation -> Angle -> Orientation
-yaw ori val = rotRelativeToObjectAxis ori vec3Y (asRad val)
-
--- | rotate object on own axis (roll) by angle
-roll :: Orientation -> Angle -> Orientation
-roll ori val = rotRelativeToObjectAxis ori vec3Z (asRad val)
-
--- | rotate object on own axis (pitch) by angle
-pitch :: Orientation -> Angle -> Orientation
-pitch ori val = rotRelativeToObjectAxis ori vec3X (asRad val)
-
+{-
+	Transformation of 3D entities by scale, position, ...
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2011-2015 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/Data/Transform3D.hs
+-}
+  
+-- | Functions for basic 3D transformations
+module HGamer3D.Data.Transform3D
+(
+  translate,
+  scale, 
+  yaw,
+  pitch,
+  roll
+)
+
+where
+
+import HGamer3D.Data.Vector
+import HGamer3D.Data.Angle
+
+type Position = Vec3
+type Orientation = UnitQuaternion
+type Size = Vec3
+
+-- | move the position 
+translate :: Position -> Position -> Position
+translate = (&+)
+
+-- | scale the size
+scale :: Size -> Vec3 -> Size
+scale  = (&!)
+
+-- yaw, roll, pitch functions
+-- functions, to rotate on axis, relative to object
+rotRelativeToObjectAxis :: Orientation -> Vec3 -> Float -> Orientation
+rotRelativeToObjectAxis ori axis val = let
+  odir = actU ori axis
+  qrot = rotU odir val
+  nrot = qrot .*. ori
+  in nrot
+	
+-- | rotate object on own axis (yaw) by angle
+yaw :: Orientation -> Angle -> Orientation
+yaw ori val = rotRelativeToObjectAxis ori vec3Y (asRad val)
+
+-- | rotate object on own axis (roll) by angle
+roll :: Orientation -> Angle -> Orientation
+roll ori val = rotRelativeToObjectAxis ori vec3Z (asRad val)
+
+-- | rotate object on own axis (pitch) by angle
+pitch :: Orientation -> Angle -> Orientation
+pitch ori val = rotRelativeToObjectAxis ori vec3X (asRad val)
+
diff --git a/HGamer3D/Data/TypeSynonyms.hs b/HGamer3D/Data/TypeSynonyms.hs
--- a/HGamer3D/Data/TypeSynonyms.hs
+++ b/HGamer3D/Data/TypeSynonyms.hs
@@ -1,45 +1,42 @@
-{-
-	Transformation of 3D entities by scale, position, ...
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2011-2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/Data/TypeSynonyms.hs
--}
-
--- | Some common type synonyms
-module HGamer3D.Data.TypeSynonyms
-
-where
-
-import Fresco
-import HGamer3D.Data.Vector
-  
--- | Size implemented as a Vec3
-type Scale = Vec3
-
--- | Position implemented as a Vec3
-type Position = Vec3
-
--- | Orientation implemented as a UnitQuaternion
-type Orientation = UnitQuaternion
-
--- properties
-ctPosition :: ComponentType Position
-ctPosition = ComponentType 0x29aacbbb10c84016
-
-ctScale :: ComponentType Scale
-ctScale = ComponentType 0x2f9c124bc8fd41c4
-
--- HGamer3D website, entities and events, example ComponentType
-ctOrientation :: ComponentType Orientation
-ctOrientation = ComponentType 0x815eb4d9c7bfaa74
--- end of website text
-
-ctVisible :: ComponentType Bool
-ctVisible = ComponentType 0x98e7a78e949e1c6e
-
-
+{-
+	Transformation of 3D entities by scale, position, ...
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2011 - 2017 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/Data/TypeSynonyms.hs
+-}
+
+-- | Some common type synonyms
+module HGamer3D.Data.TypeSynonyms
+
+where
+
+import Fresco
+import HGamer3D.Data.Vector
+  
+-- | Size implemented as a Vec3
+type Scale = Vec3
+
+-- | Position implemented as a Vec3
+type Position = Vec3
+
+-- | Orientation implemented as a UnitQuaternion
+type Orientation = UnitQuaternion
+
+-- properties
+ctPosition :: ComponentType Position
+ctPosition = ComponentType 0x29aacbbb10c84016
+
+ctScale :: ComponentType Scale
+ctScale = ComponentType 0x2f9c124bc8fd41c4
+
+-- HGamer3D website, entities and events, example ComponentType
+ctOrientation :: ComponentType Orientation
+ctOrientation = ComponentType 0x815eb4d9c7bfaa74
+-- end of website text
+
+
diff --git a/HGamer3D/Data/Vector.hs b/HGamer3D/Data/Vector.hs
--- a/HGamer3D/Data/Vector.hs
+++ b/HGamer3D/Data/Vector.hs
@@ -1,77 +1,75 @@
-{-
-    Vector library, imported from package Vect 
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2011-2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/Data/Vector.hs
--}
-
-{-# LANGUAGE GeneralizedNewtypeDeriving, StandaloneDeriving #-}
-
--- | Vector library for HGamer3D
-module HGamer3D.Data.Vector
-(
-
-    -- * the Vect libray of Balazs Komuves, see: <http://hackage.haskell.org/package/vect>
-
-    module Data.Vect.Float,
-    module Data.Vect.Float.Util.Quaternion,
-
-    -- * some constants
-
-    zeroVec2,
-    unitVec2,
-
-    zeroVec3,
-    unitVec3
-
-)
-
-where
-
-import Data.Vect.Float
-import Data.Vect.Float.Util.Quaternion
-import Data.MessagePack
-import Fresco
-
-deriving instance Eq UnitQuaternion
-deriving instance Eq Vec2
-deriving instance Eq Vec3
-deriving instance Eq Vec4
-
-instance ComponentClass Vec2 where
-    toObj (Vec2 x y) = ObjectArray [ObjectFloat x, ObjectFloat y]
-    fromObj (ObjectArray [ObjectFloat x, ObjectFloat y]) = (Vec2 x y)
-
-instance ComponentClass Vec3 where
-    toObj (Vec3 x y z) = ObjectArray [ObjectFloat x, ObjectFloat y, ObjectFloat z]
-    fromObj (ObjectArray [ObjectFloat x, ObjectFloat y, ObjectFloat z]) = (Vec3 x y z)
-
-instance ComponentClass Vec4 where
-    toObj (Vec4 w x y z) = ObjectArray [ObjectFloat w, ObjectFloat x, ObjectFloat y, ObjectFloat z]
-    fromObj (ObjectArray [ObjectFloat w, ObjectFloat x, ObjectFloat y, ObjectFloat z]) = (Vec4 w x y z)
-
-instance ComponentClass Quaternion where
-    toObj (Q v) = toObj v
-    fromObj o = Q (fromObj o)
-
-instance ComponentClass UnitQuaternion where
-    toObj (U v) = toObj v
-    fromObj o = U (fromObj o)
-
--- | the 2d zero vector
-zeroVec2 = Vec2 0.0 0.0
-
--- | the 2d unity vector
-unitVec2 = Vec2 1.0 1.0
-
--- | the 3d Zero vector
-zeroVec3 = Vec3 0.0 0.0 0.0
-
--- | the 3d Unity vector
-unitVec3 = Vec3 1.0 1.0 1.0
-
+{-
+    Vector library, imported from package Vect 
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2011-2015 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/Data/Vector.hs
+-}
+
+{-# LANGUAGE GeneralizedNewtypeDeriving, StandaloneDeriving #-}
+
+-- | Vector library for HGamer3D
+module HGamer3D.Data.Vector
+(
+
+    -- * the Vect libray of Balazs Komuves, see: <http://hackage.haskell.org/package/vect>
+
+    module Data.Vect.Float,
+    module Data.Vect.Float.Util.Quaternion,
+
+    -- * some constants
+
+    zeroVec2,
+    unitVec2,
+
+    zeroVec3,
+    unitVec3
+
+)
+
+where
+
+import Data.Vect.Float
+import Data.Vect.Float.Util.Quaternion
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Decoding
+import Data.Binary.Serialise.CBOR.Encoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+deriving instance Eq UnitQuaternion
+deriving instance Eq Vec2
+deriving instance Eq Vec3
+deriving instance Eq Vec4
+
+
+-- | the 2d zero vector
+zeroVec2 = Vec2 0.0 0.0
+
+-- | the 2d unity vector
+unitVec2 = Vec2 1.0 1.0
+
+-- | the 3d Zero vector
+zeroVec3 = Vec3 0.0 0.0 0.0
+
+-- | the 3d Unity vector
+unitVec3 = Vec3 1.0 1.0 1.0
+
+instance Serialise Vec3 where
+    encode (Vec3 v1 v2 v3) = encodeListLen 3 <> encode v1 <> encode v2 <> encode v3
+    decode = decodeListLenOf 3 >> Vec3 <$> decode <*> decode <*> decode
+
+instance Serialise UnitQuaternion where
+    encode (U (Vec4 v1 v2 v3 v4)) = encodeListLen 4 <> encode v1 <> encode v2 <> encode v3 <> encode v4
+    decode = decodeListLenOf 4 >> do
+            v <- Vec4 <$> decode <*> decode <*> decode <*> decode
+            return $ U v
+
diff --git a/HGamer3D/Data/Visible.hs b/HGamer3D/Data/Visible.hs
new file mode 100644
--- /dev/null
+++ b/HGamer3D/Data/Visible.hs
@@ -0,0 +1,30 @@
+{-
+	Visible Datatype
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2011-2017 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/Data/Visible.hs
+-}
+
+-- | Data type to specify if something is visible
+module HGamer3D.Data.Visible
+where 
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+type Visible = Bool
+
+ctVisible :: ComponentType Visible
+ctVisible = ComponentType 0x98e7a78e949e1c6e
diff --git a/HGamer3D/Data/Window.hs b/HGamer3D/Data/Window.hs
--- a/HGamer3D/Data/Window.hs
+++ b/HGamer3D/Data/Window.hs
@@ -1,30 +1,30 @@
-{-
-	The Window Instance Type
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2011-2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/Data/Window.hs
--}
-
--- | Type for a system window as its window handle
-module HGamer3D.Data.Window
-(
-  -- * A Window Handle as Int
-  Window (..),
-  ctWindow
-    
-) where
-
-import Fresco
-
-type Window = Int
-
--- properties
-ctWindow :: ComponentType Window
-ctWindow = ComponentType 0xad5b3c63f7f7dd1b
-
-
+{-
+	The Window Instance Type
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2011-2015 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/Data/Window.hs
+-}
+
+-- | Type for a system window as its window handle
+module HGamer3D.Data.Window
+(
+  -- * A Window Handle as Int
+  Window (..),
+  ctWindow
+    
+) where
+
+import Fresco
+
+type Window = Int
+
+-- properties
+ctWindow :: ComponentType Window
+ctWindow = ComponentType 0xad5b3c63f7f7dd1b
+
+
diff --git a/HGamer3D/GUI.hs b/HGamer3D/GUI.hs
--- a/HGamer3D/GUI.hs
+++ b/HGamer3D/GUI.hs
@@ -1,36 +1,36 @@
-{-
-    Graphical User Interface - GUI
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/GUI.hs
--}
-
--- | GUI for HGamer3D 
-module HGamer3D.GUI
-
-(
-    module HGamer3D.GUI.Button
-    , module HGamer3D.GUI.EditText
-    , module HGamer3D.GUI.Text
-    , module HGamer3D.GUI.Slider
-    , module HGamer3D.GUI.DropDownList
-    , module HGamer3D.GUI.CheckBox
-)
-
-
-where
-
-import HGamer3D.GUI.UIElement
-import HGamer3D.GUI.Button
-import HGamer3D.GUI.EditText
-import HGamer3D.GUI.Text
-import HGamer3D.GUI.Slider
-import HGamer3D.GUI.DropDownList
-import HGamer3D.GUI.CheckBox
-
-
+{-
+    Graphical User Interface - GUI
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2015 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/GUI.hs
+-}
+
+-- | GUI for HGamer3D 
+module HGamer3D.GUI
+
+(
+    module HGamer3D.GUI.Button
+    , module HGamer3D.GUI.EditText
+    , module HGamer3D.GUI.Text
+    , module HGamer3D.GUI.Slider
+    , module HGamer3D.GUI.DropDownList
+    , module HGamer3D.GUI.CheckBox
+)
+
+
+where
+
+import HGamer3D.GUI.UIElement
+import HGamer3D.GUI.Button
+import HGamer3D.GUI.EditText
+import HGamer3D.GUI.Text
+import HGamer3D.GUI.Slider
+import HGamer3D.GUI.DropDownList
+import HGamer3D.GUI.CheckBox
+
+
diff --git a/HGamer3D/GUI/Button.hs b/HGamer3D/GUI/Button.hs
--- a/HGamer3D/GUI/Button.hs
+++ b/HGamer3D/GUI/Button.hs
@@ -1,41 +1,39 @@
-{-
-	GUI: Button functionality
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/GUI/Button.hs
--}
-
--- | Module providing the Button functionality and settings
-module HGamer3D.GUI.Button
-(
-	Button (..),
-    ctButton
-)
-
-where
-
-import Fresco
-import Debug.Trace
-import Data.Text
-import Data.MessagePack
-
-import HGamer3D.Data
-
-
-data Button = Button {
-    buttonPressed::Bool,
-    buttonLabel::Text
-} deriving (Eq, Show, Read)
-
-instance ComponentClass Button where
-    toObj (Button v1 v2) = ObjectArray [ObjectBool v1, (toObj v2)]
-    fromObj (ObjectArray [ObjectBool v1, v2]) = Button v1 (fromObj v2)
-
-ctButton :: ComponentType Button
-ctButton = ComponentType 0x68a1857c27690b30
-
+{-
+	GUI: Button functionality
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2015 - 2017 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/GUI/Button.hs
+-}
+
+-- | Module providing the Button functionality and settings
+module HGamer3D.GUI.Button
+where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+data Button = Button {
+    buttonPressed::Bool,
+    buttonLabel::Text
+    } deriving (Eq, Read, Show)
+
+ctButton :: ComponentType Button
+ctButton = ComponentType 0x68a1857c27690b30
+
+instance Serialise Button where
+    encode (Button v1 v2) = encodeListLen 2 <> encode v1 <> encode v2
+    decode = decodeListLenOf 2 >> Button <$> decode <*> decode
+
+
diff --git a/HGamer3D/GUI/CheckBox.hs b/HGamer3D/GUI/CheckBox.hs
--- a/HGamer3D/GUI/CheckBox.hs
+++ b/HGamer3D/GUI/CheckBox.hs
@@ -1,30 +1,30 @@
-{-
-	GUI: Checkbox functionality
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/GUI/CheckBox.hs
--}
-
--- | Module providing the CheckBox gui element
-module HGamer3D.GUI.CheckBox
-(
-    ctCheckBox
-)
-
-where
-
-import Fresco
-import Debug.Trace
-import Data.Text
-
-import HGamer3D.Data
-
-ctCheckBox :: ComponentType Bool
-ctCheckBox = ComponentType 0xd2425f880fcdd9a4  
-  
-
+{-
+	GUI: Checkbox functionality
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2015 - 2017 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/GUI/CheckBox.hs
+-}
+
+-- | Module providing the CheckBox gui element
+module HGamer3D.GUI.CheckBox
+where 
+
+import Fresco                                                                       
+import Data.Binary.Serialise.CBOR                                                     
+import Data.Binary.Serialise.CBOR.Encoding                                            
+import Data.Binary.Serialise.CBOR.Decoding                                              
+                                                                                         
+import Data.Text                                                                          
+import Data.Monoid                                                                          
+import Control.Applicative                                                                    
+                                                                                                
+                                                                                                    
+type CheckBox = Bool                                                                                   
+
+ctCheckBox :: ComponentType CheckBox
+ctCheckBox = ComponentType 0xd2425f880fcdd9a4
diff --git a/HGamer3D/GUI/DropDownList.hs b/HGamer3D/GUI/DropDownList.hs
--- a/HGamer3D/GUI/DropDownList.hs
+++ b/HGamer3D/GUI/DropDownList.hs
@@ -1,38 +1,53 @@
-{-
-	GUI: DropDownList functionality
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/GUI/DropDownList.hs
--}
-
--- | Module providing the Mouse functionality and settings
-module HGamer3D.GUI.DropDownList
-(
-    ctDropDownList,
-    DropDownList (..)
-)
-
-where
-
-import Fresco
-import Data.MessagePack
-import Debug.Trace
-import Data.Text
-
-import HGamer3D.Data
-
-data DropDownList = DropDownList [Text] (Maybe Int) deriving (Eq, Show)   -- int is selected item index, starting at 0
-
-instance ComponentClass DropDownList where
-    toObj (DropDownList textlist mb) = ObjectArray [ ObjectArray (Prelude.map toObj textlist), toObj mb]
-    fromObj (ObjectArray [ ObjectArray textlist_o, mb]) = DropDownList (Prelude.map fromObj textlist_o) (fromObj mb)
-
-ctDropDownList :: ComponentType DropDownList
-ctDropDownList = ComponentType 0x200de0e837a8e590
-  
-
+{-
+	GUI: DropDownList functionality
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2015 - 2017 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/GUI/DropDownList.hs
+-}
+
+-- | Module providing the Mouse functionality and settings
+module HGamer3D.GUI.DropDownList
+where
+
+import Fresco                                                                                                            
+import Data.Binary.Serialise.CBOR                                                                                        
+import Data.Binary.Serialise.CBOR.Encoding                                                                               
+import Data.Binary.Serialise.CBOR.Decoding                                                                               
+                                                                                                                         
+import Data.Text                                                                                                         
+import Data.Monoid                                                                                                       
+import Control.Applicative                                                                                               
+                                                                                                                         
+                                                                                                                         
+data TextSelection = Selection Int                                                                                       
+    | NoSelection                                                                                                        
+    deriving (Eq, Read, Show)                                                                                            
+                                                                                                                         
+data DropDownList = DropDownList {                                                                                       
+    dropDownListContent::[Text],                                                                                         
+    dropDownListSelected::TextSelection                                                                                  
+    } deriving (Eq, Read, Show)                                                                                          
+                                                                                                                         
+ctDropDownList :: ComponentType DropDownList                                                                             
+ctDropDownList = ComponentType 0x200de0e837a8e590                                                                        
+                                                                                                                         
+instance Serialise TextSelection where                                                                                   
+    encode (Selection v1) = encodeListLen 2 <>  encode (0::Int) <> encode v1                                             
+    encode (NoSelection) = encodeListLen 1 <>  encode (1::Int)                                                           
+    decode = do                                                                                                          
+        decodeListLen                                                                                                    
+        i <- decode :: Decoder s Int                                                                                       
+        case i of                                                                                                        
+            0 -> (Selection <$> decode)                                                                                  
+            1 -> (pure NoSelection)                                                                                      
+                                                                                                                         
+instance Serialise DropDownList where                                                                                    
+    encode (DropDownList v1 v2) = encodeListLen 2 <> encode v1 <> encode v2                                              
+    decode = decodeListLenOf 2 >> DropDownList <$> decode <*> decode                                                                                                                                          
+                                                                                         
+
diff --git a/HGamer3D/GUI/EditText.hs b/HGamer3D/GUI/EditText.hs
--- a/HGamer3D/GUI/EditText.hs
+++ b/HGamer3D/GUI/EditText.hs
@@ -1,29 +1,30 @@
-{-
-	GUI: EditText functionality
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/GUI/EditText.hs
--}
-
--- | Module providing the Mouse functionality and settings
-module HGamer3D.GUI.EditText
-(
-    ctEditText
-)
-
-where
-
-import Fresco
-import Data.MessagePack
-import Debug.Trace
-import Data.Text
-
-import HGamer3D.Data
-
-ctEditText :: ComponentType Text
-ctEditText = ComponentType 0x8c79de2199331f3a
+{-
+	GUI: EditText functionality
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2015 - 2017 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/GUI/EditText.hs
+-}
+
+-- | Module providing the Mouse functionality and settings
+module HGamer3D.GUI.EditText
+where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+type EditText = Text
+
+ctEditText :: ComponentType EditText
+ctEditText = ComponentType 0x8c79de2199331f3a
diff --git a/HGamer3D/GUI/Slider.hs b/HGamer3D/GUI/Slider.hs
--- a/HGamer3D/GUI/Slider.hs
+++ b/HGamer3D/GUI/Slider.hs
@@ -1,39 +1,47 @@
-{-
-	GUI: Slider functionality
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/GUI/Slider.hs
--}
-
--- | Module providing the Mouse functionality and settings
-module HGamer3D.GUI.Slider
-(
-    ctSlider,
-    Slider (..)
-)
-
-where
-
-import Fresco
-import Data.MessagePack
-import Debug.Trace
-import Data.Text
-
-import HGamer3D.Data
-
-data Slider = Slider Float Float        -- range end (start = 0) and value
-              deriving (Eq, Show)           
-
-instance ComponentClass Slider where
-    toObj (Slider range value) = ObjectArray [ObjectFloat range, ObjectFloat value]
-    fromObj (ObjectArray [ObjectFloat range, ObjectFloat value]) = Slider range value
-
-ctSlider :: ComponentType Slider
-ctSlider = ComponentType 0x60636b107c77a533
-  
-
+{-
+	GUI: Slider functionality
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2015 - 2017 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/GUI/Slider.hs
+-}
+
+-- | Module providing the Mouse functionality and settings
+module HGamer3D.GUI.Slider
+(
+    ctSlider,
+    Slider (..)
+)
+
+where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+data Slider = Slider {
+    sliderRange::Float,
+    sliderValue::Float
+    } deriving (Eq, Read, Show)
+
+ctSlider :: ComponentType Slider
+ctSlider = ComponentType 0x60636b107c77a533
+
+instance Serialise Slider where
+    encode (Slider v1 v2) = encodeListLen 2 <> encode v1 <> encode v2
+    decode = decodeListLenOf 2 >> Slider <$> decode <*> decode
+
+
+
+  
+
diff --git a/HGamer3D/GUI/Text.hs b/HGamer3D/GUI/Text.hs
--- a/HGamer3D/GUI/Text.hs
+++ b/HGamer3D/GUI/Text.hs
@@ -1,31 +1,32 @@
-{-
-	GUI: Text functionality
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/GUI/Text.hs
--}
-
--- | Module providing the Mouse functionality and settings
-module HGamer3D.GUI.Text
-(
-    ctText
-)
-
-where
-
-import Fresco
-import Data.MessagePack
-import Debug.Trace
-import Data.Text
-
-import HGamer3D.Data
-
-ctText :: ComponentType Text
-ctText = ComponentType 0xda9601eaf3319280
-  
-
+{-
+	GUI: Text functionality
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2015 - 2017 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/GUI/Text.hs
+-}
+
+-- | Module providing the Mouse functionality and settings
+module HGamer3D.GUI.Text
+where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+type StaticText = Text
+
+ctStaticText :: ComponentType StaticText
+ctStaticText = ComponentType 0xda9601eaf3319280
+
+
diff --git a/HGamer3D/GUI/UIElement.hs b/HGamer3D/GUI/UIElement.hs
--- a/HGamer3D/GUI/UIElement.hs
+++ b/HGamer3D/GUI/UIElement.hs
@@ -1,31 +1,31 @@
-{-
-	GUI: Button functionality
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/GUI/Button.hs
--}
-
--- | Module providing the Button functionality and settings
-module HGamer3D.GUI.UIElement
-(
-    ctUIElement
-)
-
-where
-
-import Fresco
-import Debug.Trace
-import Data.Text
-import Data.MessagePack
-
-import HGamer3D.Data
-
-ctUIElement :: ComponentType ()
-ctUIElement = ComponentType 0xd5b79f5837e52274;
-
-
+{-
+	GUI: Button functionality
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2015 - 2017 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/GUI/Button.hs
+-}
+
+-- | Module providing the Button functionality and settings
+module HGamer3D.GUI.UIElement
+where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+type UIElement = ()
+
+ctUIElement :: ComponentType UIElement
+ctUIElement = ComponentType 0xd5b79f5837e52274
+
diff --git a/HGamer3D/Graphics3D.hs b/HGamer3D/Graphics3D.hs
--- a/HGamer3D/Graphics3D.hs
+++ b/HGamer3D/Graphics3D.hs
@@ -1,45 +1,43 @@
--- This source file is part of HGamer3D
--- (A project to enable 3D game development in Haskell)
--- For the latest info, see http://www.hgamer3d.org
--- 
--- (c) 2015 Peter Althainz
--- 
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
--- 
---     http://www.apache.org/licenses/LICENSE-2.0
--- 
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
--- 
--- HGamer3D/Graphics3D.hs
--- 
-
--- | 3D Graphics for HGamer3D 
-module HGamer3D.Graphics3D
-
-(
-	module HGamer3D.Graphics3D.Camera,
-	module HGamer3D.Graphics3D.Geometry,
-	module HGamer3D.Graphics3D.Light,
-	module HGamer3D.Graphics3D.Material,
-	module HGamer3D.Graphics3D.Window,
-	module HGamer3D.Graphics3D.Graphics3DCommand,
-	module HGamer3D.Graphics3D.Graphics3DConfig,
-)
-
-where
-
-import HGamer3D.Graphics3D.Camera
-import HGamer3D.Graphics3D.Geometry
-import HGamer3D.Graphics3D.Light
-import HGamer3D.Graphics3D.Material
-import HGamer3D.Graphics3D.Window
-import HGamer3D.Graphics3D.Graphics3DCommand
-import HGamer3D.Graphics3D.Graphics3DConfig
-
-
+-- This source file is part of HGamer3D
+-- (A project to enable 3D game development in Haskell)
+-- For the latest info, see http://www.hgamer3d.org
+-- 
+-- (c) 2015 - 2017 Peter Althainz
+-- 
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+-- 
+--     http://www.apache.org/licenses/LICENSE-2.0
+-- 
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+-- 
+-- HGamer3D/Graphics3D.hs
+-- 
+
+-- | 3D Graphics for HGamer3D 
+module HGamer3D.Graphics3D
+
+(
+  module HGamer3D.Graphics3D.Camera,
+  module HGamer3D.Graphics3D.Geometry,
+  module HGamer3D.Graphics3D.Light,
+  module HGamer3D.Graphics3D.Material,
+  module HGamer3D.Graphics3D.Graphics3DCommand,
+  module HGamer3D.Graphics3D.Graphics3DConfig,
+)
+
+where
+
+import HGamer3D.Graphics3D.Camera
+import HGamer3D.Graphics3D.Geometry
+import HGamer3D.Graphics3D.Light
+import HGamer3D.Graphics3D.Material
+import HGamer3D.Graphics3D.Graphics3DCommand
+import HGamer3D.Graphics3D.Graphics3DConfig
+
+
diff --git a/HGamer3D/Graphics3D/Camera.hs b/HGamer3D/Graphics3D/Camera.hs
--- a/HGamer3D/Graphics3D/Camera.hs
+++ b/HGamer3D/Graphics3D/Camera.hs
@@ -1,62 +1,72 @@
-{-
-    Camera Datatype
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2011-2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/Graphics3D/Camera.hs
--}
-
--- | Module providing the Camera type
-module HGamer3D.Graphics3D.Camera
-
-(
-        Camera (..),
-        ctCamera,
-
-        Frustum (..),
-        ctFrustum
-)
-
-where
-
-import Data.MessagePack
-import HGamer3D.Data
-import Fresco
-
--- generated
-
-data Camera = FullViewCamera
-    | OverlayCamera (Rectangle Int) Float
-    deriving (Eq, Show)
-
-instance ComponentClass Camera where
-    toObj (FullViewCamera) = ObjectArray [ObjectInt 0, ObjectArray []]
-    toObj (OverlayCamera v1 v2) = ObjectArray [ObjectInt 1, ObjectArray [(toObj v1), ObjectFloat v2]]
-    fromObj (ObjectArray [ObjectInt 0, ObjectArray []]) = FullViewCamera
-    fromObj (ObjectArray [ObjectInt 1, ObjectArray [v1, ObjectFloat v2]]) = OverlayCamera (fromObj v1) v2
-
-ctCamera :: ComponentType Camera
-ctCamera = ComponentType 0xd3b0d455ab1f4716
-
--- generated
-
-data Frustum = Frustum {
-        frNearDistance :: Float,
-        frFarDistance :: Float,
-        frFieldOfViewHorizontal :: Angle
-} deriving (Eq, Show)
-
-instance ComponentClass Frustum where
-        toObj (Frustum nd fd fovh) = ObjectArray [ObjectFloat nd, ObjectFloat fd, toObj fovh]
-        fromObj (ObjectArray [ObjectFloat nd, ObjectFloat fd, fovh_o]) = Frustum nd fd (fromObj fovh_o)
-
-ctFrustum :: ComponentType Frustum
-ctFrustum = ComponentType 0xf3ce3235d4f8e73d
-
-
-
-
+{-
+    Camera Datatype
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2011-2015 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/Graphics3D/Camera.hs
+-}
+
+-- | Module providing the Camera type
+module HGamer3D.Graphics3D.Camera
+
+(
+        Camera (..),
+        ctCamera,
+
+        Frustum (..),
+        ctFrustum
+)
+
+where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+import HGamer3D.Data.Angle
+import HGamer3D.Data.ScreenRect
+
+data Camera = FullViewCamera
+    | OverlayCamera ScreenRect Float
+    deriving (Eq, Read, Show)
+
+ctCamera :: ComponentType Camera
+ctCamera = ComponentType 0xd3b0d455ab1f4716
+
+data Frustum = Frustum {
+    frustumNearDistance::Float,
+    frustumFarDistance::Float,
+    frustumFieldOfViewHorizontal::Angle
+    } deriving (Eq, Read, Show)
+
+ctFrustum :: ComponentType Frustum
+ctFrustum = ComponentType 0xf3ce3235d4f8e73d
+
+instance Serialise Camera where
+    encode (FullViewCamera) = encodeListLen 1 <>  encode (0::Int) 
+    encode (OverlayCamera v1 v2) = encodeListLen 3 <>  encode (1::Int) <> encode v1<> encode v2
+    decode = do
+        decodeListLen
+        i <- decode :: Decoder s Int
+        case i of
+            0 -> (pure FullViewCamera)
+            1 -> (OverlayCamera <$> decode <*> decode)
+
+instance Serialise Frustum where
+    encode (Frustum v1 v2 v3) = encodeListLen 3 <> encode v1 <> encode v2 <> encode v3
+    decode = decodeListLenOf 3 >> Frustum <$> decode <*> decode <*> decode
+
+
+
+
+
+
diff --git a/HGamer3D/Graphics3D/Geometry.hs b/HGamer3D/Graphics3D/Geometry.hs
--- a/HGamer3D/Graphics3D/Geometry.hs
+++ b/HGamer3D/Graphics3D/Geometry.hs
@@ -1,83 +1,89 @@
--- This source file is part of HGamer3D
--- (A project to enable 3D game development in Haskell)
--- For the latest info, see http://www.hgamer3d.org
---
--- (c) 2011 - 2015 Peter Althainz
---
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
---
---     http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
-
--- HGamer3D/Graphics3D/Geometry.hs
-
--- | Module providing the Geometry type
-module HGamer3D.Graphics3D.Geometry
-
-(
-        Shape (..),
-        Geometry (..),
-        ctGeometry,
-        ctGraphicsElement
-)
-
-where
-
-import Data.MessagePack
-
-import Fresco
-import Data.Text
-
-import HGamer3D.Data
-import HGamer3D.Graphics3D.Material
-
--- generated
-
--- HGamer3D website, entities and events, Geometry data type and component
--- | A shape is a basic geometric formd
-data Shape = Sphere
-    | Cube
-    | Plane
-    | Cylinder
-    | Pyramid
-    | Torus
-    deriving (Eq, Read, Show)
-
-instance ComponentClass Shape where
-    toObj (Sphere) = ObjectArray [ObjectInt 0, ObjectArray []]
-    toObj (Cube) = ObjectArray [ObjectInt 1, ObjectArray []]
-    toObj (Plane) = ObjectArray [ObjectInt 2, ObjectArray []]
-    toObj (Cylinder) = ObjectArray [ObjectInt 3, ObjectArray []]
-    toObj (Pyramid) = ObjectArray [ObjectInt 4, ObjectArray []]
-    toObj (Torus) = ObjectArray [ObjectInt 5, ObjectArray []]
-    fromObj (ObjectArray [ObjectInt 0, ObjectArray []]) = Sphere
-    fromObj (ObjectArray [ObjectInt 1, ObjectArray []]) = Cube
-    fromObj (ObjectArray [ObjectInt 2, ObjectArray []]) = Plane
-    fromObj (ObjectArray [ObjectInt 3, ObjectArray []]) = Cylinder
-    fromObj (ObjectArray [ObjectInt 4, ObjectArray []]) = Pyramid
-    fromObj (ObjectArray [ObjectInt 5, ObjectArray []]) = Torus
-
-data Geometry = ShapeGeometry Shape
-    | ResourceGeometry Text
-    deriving (Eq, Read, Show)
-
-instance ComponentClass Geometry where
-    toObj (ShapeGeometry v1) = ObjectArray [ObjectInt 0, ObjectArray [(toObj v1)]]
-    toObj (ResourceGeometry v1) = ObjectArray [ObjectInt 1, ObjectArray [(toObj v1)]]
-    fromObj (ObjectArray [ObjectInt 0, ObjectArray [v1]]) = ShapeGeometry (fromObj v1)
-    fromObj (ObjectArray [ObjectInt 1, ObjectArray [v1]]) = ResourceGeometry (fromObj v1)
-
-ctGeometry :: ComponentType Geometry
-ctGeometry = ComponentType 0xee433d1a4b964591
-
-ctGraphicsElement :: ComponentType ()
-ctGraphicsElement = ComponentType 0x65114ba821671643
--- end of website text
-
+-- This source file is part of HGamer3D
+-- (A project to enable 3D game development in Haskell)
+-- For the latest info, see http://www.hgamer3d.org
+--
+-- (c) 2011 - 2017 Peter Althainz
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+-- HGamer3D/Graphics3D/Geometry.hs
+
+-- | Module providing the Geometry type
+module HGamer3D.Graphics3D.Geometry
+
+(
+        Shape (..),
+        Geometry (..),
+        ctGeometry,
+        ctGraphicsElement
+)
+
+where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+data Shape = Sphere
+    | Cube
+    | Plane
+    | Cylinder
+    | Pyramid
+    | Torus
+    deriving (Eq, Read, Show)
+
+data Geometry = ShapeGeometry Shape
+    | ResourceGeometry Text
+    deriving (Eq, Read, Show)
+
+ctGeometry :: ComponentType Geometry
+ctGeometry = ComponentType 0xee433d1a4b964591
+
+ctGraphicsElement :: ComponentType ()
+ctGraphicsElement = ComponentType 0x65114ba821671643
+
+instance Serialise Shape where
+    encode (Sphere) = encodeListLen 1 <>  encode (0::Int) 
+    encode (Cube) = encodeListLen 1 <>  encode (1::Int) 
+    encode (Plane) = encodeListLen 1 <>  encode (2::Int) 
+    encode (Cylinder) = encodeListLen 1 <>  encode (3::Int) 
+    encode (Pyramid) = encodeListLen 1 <>  encode (4::Int) 
+    encode (Torus) = encodeListLen 1 <>  encode (5::Int) 
+    decode = do
+        decodeListLen
+        i <- decode :: Decoder s Int
+        case i of
+            0 -> (pure Sphere)
+            1 -> (pure Cube)
+            2 -> (pure Plane)
+            3 -> (pure Cylinder)
+            4 -> (pure Pyramid)
+            5 -> (pure Torus)
+
+instance Serialise Geometry where
+    encode (ShapeGeometry v1) = encodeListLen 2 <>  encode (0::Int) <> encode v1
+    encode (ResourceGeometry v1) = encodeListLen 2 <>  encode (1::Int) <> encode v1
+    decode = do
+        decodeListLen
+        i <- decode :: Decoder s Int
+        case i of
+            0 -> (ShapeGeometry <$> decode)
+            1 -> (ResourceGeometry <$> decode)
+
+
diff --git a/HGamer3D/Graphics3D/Graphics3DCommand.hs b/HGamer3D/Graphics3D/Graphics3DCommand.hs
--- a/HGamer3D/Graphics3D/Graphics3DCommand.hs
+++ b/HGamer3D/Graphics3D/Graphics3DCommand.hs
@@ -1,54 +1,53 @@
--- This source file is part of HGamer3D
--- (A project to enable 3D game development in Haskell)
--- For the latest info, see http://www.hgamer3d.org
---
--- (c) 2011 - 2015 Peter Althainz
---
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
---
---     http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
-
--- HGamer3D/Graphics3D/Graphics3DCommand.hs
-
--- | Module providing the CmdGraphics3D type
-module HGamer3D.Graphics3D.Graphics3DCommand
-
-(
-        Graphics3DCommand (..),
-        ctGraphics3DCommand
-)
-
-where
-
-import Data.MessagePack
-import Fresco
-import HGamer3D.Data
-
--- | Component Type of Graphics3DCommand
-ctGraphics3DCommand :: ComponentType Graphics3DCommand
-ctGraphics3DCommand = ComponentType 0xea06bc20a9334af3
-
--- OUTPUT SINOPIA START HERE
-
--- | Commands, which can be sent to graphics system
-data Graphics3DCommand = NoCmd
-    | Step
-    deriving (Eq, Read, Show)
-
-instance ComponentClass Graphics3DCommand where
-    toObj (NoCmd) = ObjectArray [ObjectInt 0, ObjectArray []]
-    toObj (Step) = ObjectArray [ObjectInt 1, ObjectArray []]
-    fromObj (ObjectArray [ObjectInt 0, ObjectArray []]) = NoCmd
-    fromObj (ObjectArray [ObjectInt 1, ObjectArray []]) = Step
-
--- OUTPUT SINOPIA ENDS HERE
-
-
+-- This source file is part of HGamer3D
+-- (A project to enable 3D game development in Haskell)
+-- For the latest info, see http://www.hgamer3d.org
+--
+-- (c) 2011 - 2017 Peter Althainz
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+-- HGamer3D/Graphics3D/Graphics3DCommand.hs
+
+-- | Module providing the CmdGraphics3D type
+module HGamer3D.Graphics3D.Graphics3DCommand
+where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+data Graphics3DCommand = NoCmd
+    | Step
+    deriving (Eq, Read, Show)
+
+
+instance Serialise Graphics3DCommand where
+    encode (NoCmd) = encodeListLen 1 <>  encode (0::Int) 
+    encode (Step) = encodeListLen 1 <>  encode (1::Int) 
+    decode = do
+        decodeListLen
+        i <- decode :: Decoder s Int
+        case i of
+            0 -> (pure NoCmd)
+            1 -> (pure Step)
+
+
+ctGraphics3DCommand :: ComponentType Graphics3DCommand
+ctGraphics3DCommand = ComponentType 0xea06bc20a9334af3
+
diff --git a/HGamer3D/Graphics3D/Graphics3DConfig.hs b/HGamer3D/Graphics3D/Graphics3DConfig.hs
--- a/HGamer3D/Graphics3D/Graphics3DConfig.hs
+++ b/HGamer3D/Graphics3D/Graphics3DConfig.hs
@@ -1,126 +1,135 @@
-{-# LANGUAGE OverloadedStrings #-}
--- This source file is part of HGamer3D
--- (A project to enable 3D game development in Haskell)
--- For the latest info, see http://www.hgamer3d.org
---
--- (c) 2011 - 2015 Peter Althainz
---
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
---
---     http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
-
--- HGamer3D/Graphics3D/Graphics3DConfig.hs
-
--- | Module providing the InitGraphics3D type
-module HGamer3D.Graphics3D.Graphics3DConfig
-
-(
-	    EngineConfig (..),
-
-        LogLevel (..),
-        Logging (..),
-        ctLogging,
-
-        GraphicsQuality(..),
-        ctGraphicsQuality,
-
-        Graphics3DConfig (..),
-        ctGraphics3DConfig,
-
-        standardGraphics3DConfig
-)
-
-where
-
-import Fresco
-import Data.MessagePack
-import Data.Text
-
-import HGamer3D.Data
-import HGamer3D.Graphics3D.Window
-
-
--- OUTPUT SINOPIA START HERE
-
-data EngineConfig = EngineConfig {
-    engineConfigHeadless::Bool,
-    engineConfigFlushGPU::Bool,
-    engineConfigThreads::Bool,
-    engineConfigForceGL2::Bool
-}
-
-instance ComponentClass EngineConfig where
-    toObj (EngineConfig v1 v2 v3 v4) = ObjectArray [ObjectBool v1, ObjectBool v2, ObjectBool v3, ObjectBool v4]
-    fromObj (ObjectArray [ObjectBool v1, ObjectBool v2, ObjectBool v3, ObjectBool v4]) = EngineConfig v1 v2 v3 v4
-
-data LogLevel = Warning
-    | Info
-    | Debug
-    deriving (Eq, Read, Show)
-
-instance ComponentClass LogLevel where
-    toObj (Warning) = ObjectArray [ObjectInt 0, ObjectArray []]
-    toObj (Info) = ObjectArray [ObjectInt 1, ObjectArray []]
-    toObj (Debug) = ObjectArray [ObjectInt 2, ObjectArray []]
-    fromObj (ObjectArray [ObjectInt 0, ObjectArray []]) = Warning
-    fromObj (ObjectArray [ObjectInt 1, ObjectArray []]) = Info
-    fromObj (ObjectArray [ObjectInt 2, ObjectArray []]) = Debug
-
-data Logging = Logging {
-    loggingLogLevel::LogLevel,
-    loggingQuietLogging::Bool,
-    loggingLogFileName::Text
-}
-
-instance ComponentClass Logging where
-    toObj (Logging v1 v2 v3) = ObjectArray [(toObj v1), ObjectBool v2, (toObj v3)]
-    fromObj (ObjectArray [v1, ObjectBool v2, v3]) = Logging (fromObj v1) v2 (fromObj v3)
-
-data GraphicsQuality = GraphicsQuality {
-    graphicsQualityShadow::QualityLMH,
-    graphicsQualityMaterial::QualityLMH,
-    graphicsQualityTexture::QualityLMH,
-    graphicsQualityMultisample::QualityLMH
-}
-
-instance ComponentClass GraphicsQuality where
-    toObj (GraphicsQuality v1 v2 v3 v4) = ObjectArray [(toObj v1), (toObj v2), (toObj v3), (toObj v4)]
-    fromObj (ObjectArray [v1, v2, v3, v4]) = GraphicsQuality (fromObj v1) (fromObj v2) (fromObj v3) (fromObj v4)
-
-data Graphics3DConfig = Graphics3DConfig {
-    graphics3DConfigEngine::EngineConfig,
-    graphics3DConfigQuality::GraphicsQuality,
-    graphics3DConfigLogging::Logging,
-    graphics3DConfigWindow::WindowG3D
-}
-
-instance ComponentClass Graphics3DConfig where
-    toObj (Graphics3DConfig v1 v2 v3 v4) = ObjectArray [(toObj v1), (toObj v2), (toObj v3), (toObj v4)]
-    fromObj (ObjectArray [v1, v2, v3, v4]) = Graphics3DConfig (fromObj v1) (fromObj v2) (fromObj v3) (fromObj v4)
-
--- OUTPUT SINOPIA ENDS HERE
-
-stdEngineConfig = EngineConfig False False True False
-
-ctLogging :: ComponentType Logging
-ctLogging = ComponentType 0x86bc15156976f061
-
-ctGraphicsQuality :: ComponentType GraphicsQuality
-ctGraphicsQuality = ComponentType 0x7d9cff864f27c6d2
-
-standardGraphics3DConfig = Graphics3DConfig stdEngineConfig (GraphicsQuality Medium Medium Medium Medium) (Logging Debug False "hgamer3d.log") (xyWindow 800 600) 
-
-ctGraphics3DConfig :: ComponentType Graphics3DConfig
-ctGraphics3DConfig = ComponentType 0x0884eb62b6674bff
-
-
-
-
+-- This source file is part of HGamer3D
+-- (A project to enable 3D game development in Haskell)
+-- For the latest info, see http://www.hgamer3d.org
+--
+-- (c) 2011 - 2017 Peter Althainz
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+-- file: HGamer3D/Graphics3D/Graphics3DConfig.hs
+
+{-# LANGUAGE OverloadedStrings #-}
+
+module HGamer3D.Graphics3D.Graphics3DConfig
+where
+
+-- output sinopia starts here
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Decoding
+import Data.Binary.Serialise.CBOR.Encoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+import HGamer3D.Data.LMH
+
+
+data EngineConfig = EngineConfig {
+    engineConfigHeadless::Bool,
+    engineConfigFlushGPU::Bool,
+    engineConfigThreads::Bool,
+    engineConfigForceGL2::Bool
+    } deriving (Eq, Read, Show)
+
+
+data LogLevel = Warning
+    | Info
+    | Debug
+    deriving (Eq, Read, Show)
+
+
+data Logging = Logging {
+    loggingLogLevel::LogLevel,
+    loggingQuietLogging::Bool,
+    loggingLogFileName::Text
+    } deriving (Eq, Read, Show)
+
+
+data WindowG3D = WindowG3D {
+    windowG3DWidth::Int,
+    windowG3DHeight::Int,
+    windowG3DBorderless::Bool,
+    windowG3DFullScreen::Bool,
+    windowG3DResizable::Bool
+    } deriving (Eq, Read, Show)
+
+
+data GraphicsQuality = GraphicsQuality {
+    graphicsQualityShadow::LMH,
+    graphicsQualityMaterial::LMH,
+    graphicsQualityTexture::LMH,
+    graphicsQualityMultisample::LMH
+    } deriving (Eq, Read, Show)
+
+
+data Graphics3DConfig = Graphics3DConfig {
+    graphics3DConfigEngine::EngineConfig,
+    graphics3DConfigQuality::GraphicsQuality,
+    graphics3DConfigLogging::Logging,
+    graphics3DConfigWindow::WindowG3D
+    } deriving (Eq, Read, Show)
+
+
+ctGraphics3DConfig :: ComponentType Graphics3DConfig
+ctGraphics3DConfig = ComponentType 0x884eb62b6674bff
+
+instance Serialise EngineConfig where
+    encode (EngineConfig v1 v2 v3 v4) = encodeListLen 4 <> encode v1 <> encode v2 <> encode v3 <> encode v4
+    decode = decodeListLenOf 4 >> EngineConfig <$> decode <*> decode <*> decode <*> decode
+
+instance Serialise LogLevel where
+    encode (Warning) = encodeListLen 1 <>  encode (0::Int) 
+    encode (Info) = encodeListLen 1 <>  encode (1::Int) 
+    encode (Debug) = encodeListLen 1 <>  encode (2::Int) 
+    decode = do
+        decodeListLen
+        i <- decode :: Decoder s Int
+        case i of
+            0 -> (pure Warning)
+            1 -> (pure Info)
+            2 -> (pure Debug)
+
+instance Serialise Logging where
+    encode (Logging v1 v2 v3) = encodeListLen 3 <> encode v1 <> encode v2 <> encode v3
+    decode = decodeListLenOf 3 >> Logging <$> decode <*> decode <*> decode
+
+instance Serialise WindowG3D where
+    encode (WindowG3D v1 v2 v3 v4 v5) = encodeListLen 5 <> encode v1 <> encode v2 <> encode v3 <> encode v4 <> encode v5
+    decode = decodeListLenOf 5 >> WindowG3D <$> decode <*> decode <*> decode <*> decode <*> decode
+
+instance Serialise GraphicsQuality where
+    encode (GraphicsQuality v1 v2 v3 v4) = encodeListLen 4 <> encode v1 <> encode v2 <> encode v3 <> encode v4
+    decode = decodeListLenOf 4 >> GraphicsQuality <$> decode <*> decode <*> decode <*> decode
+
+instance Serialise Graphics3DConfig where
+    encode (Graphics3DConfig v1 v2 v3 v4) = encodeListLen 4 <> encode v1 <> encode v2 <> encode v3 <> encode v4
+    decode = decodeListLenOf 4 >> Graphics3DConfig <$> decode <*> decode <*> decode <*> decode
+
+
+
+
+-- output sinopia ends here
+
+standardGraphics3DConfig = Graphics3DConfig 
+    (EngineConfig False False True False)
+    (GraphicsQuality Medium Medium Medium Medium) 
+    (Logging Debug False "hgamer3d.log") 
+    (WindowG3D 800 600 False False True) 
+
+
+
+
+
diff --git a/HGamer3D/Graphics3D/Light.hs b/HGamer3D/Graphics3D/Light.hs
--- a/HGamer3D/Graphics3D/Light.hs
+++ b/HGamer3D/Graphics3D/Light.hs
@@ -1,54 +1,59 @@
-{-
-    Light Datatype
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2011-2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/Graphics3D/Light.hs
--}
-
--- | Module providing the Light type
-module HGamer3D.Graphics3D.Light
-
-(
-    LightType (..),
-    Light (..),
-    ctLight
-)
-
-where
-
-import Data.MessagePack
-import Fresco
-import HGamer3D.Data
-
-data LightType =    PointLight              -- ^ casting light in all directions, from position 
-                    | DirectionalLight      -- ^ like a very far light source (the Sun)
-                    | SpotLight Angle Float -- ^ a light with a field of view (Angle) and an aspect-ratio (Float)
-                
-instance ComponentClass LightType where
-    toObj PointLight = ObjectArray [ObjectInt 0]
-    toObj DirectionalLight =  ObjectArray [ObjectInt 1]
-    toObj (SpotLight fov ar) = ObjectArray [ObjectInt 2, toObj fov, ObjectFloat ar]
-
-    fromObj (ObjectArray [ObjectInt 0]) = PointLight
-    fromObj (ObjectArray [ObjectInt 1]) = DirectionalLight 
-    fromObj (ObjectArray [ObjectInt 2, fov_o, ObjectFloat ar]) = SpotLight (fromObj fov_o) ar
-
-    
-data Light = Light 
-                LightType 
-                Float     
-                Float     
-                Float     -- ^ floats: brightness, range, specular intensity
-
-instance ComponentClass Light where
-    toObj (Light lt b r s) = ObjectArray [toObj lt, ObjectFloat b, ObjectFloat r, ObjectFloat s]
-    fromObj (ObjectArray [lt_o, ObjectFloat b, ObjectFloat r, ObjectFloat s]) = Light (fromObj lt_o) b r s
-    
-ctLight :: ComponentType Light
-ctLight = ComponentType 0x981e80e50d994ea9
-
+{-
+    Light Datatype
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2011 - 2017 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/Graphics3D/Light.hs
+-}
+
+-- | Module providing the Light type
+module HGamer3D.Graphics3D.Light
+where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+import HGamer3D.Data.Angle
+
+
+data LightType = PointLight
+    | DirectionalLight
+    | SpotLight Angle Float
+    deriving (Eq, Read, Show)
+
+data Light = Light {
+    lightType::LightType,
+    lightBrightness::Float,
+    lightRange::Float,
+    lightSpecularIntensity::Float
+    } deriving (Eq, Read, Show)
+
+ctLight :: ComponentType Light
+ctLight = ComponentType 0x981e80e50d994ea9
+
+instance Serialise LightType where
+    encode (PointLight) = encodeListLen 1 <>  encode (0::Int) 
+    encode (DirectionalLight) = encodeListLen 1 <>  encode (1::Int) 
+    encode (SpotLight v1 v2) = encodeListLen 3 <>  encode (2::Int) <> encode v1<> encode v2
+    decode = do
+        decodeListLen
+        i <- decode :: Decoder s Int
+        case i of
+            0 -> (pure PointLight)
+            1 -> (pure DirectionalLight)
+            2 -> (SpotLight <$> decode <*> decode)
+
+instance Serialise Light where
+    encode (Light v1 v2 v3 v4) = encodeListLen 4 <> encode v1 <> encode v2 <> encode v3 <> encode v4
+    decode = decodeListLenOf 4 >> Light <$> decode <*> decode <*> decode <*> decode
+
diff --git a/HGamer3D/Graphics3D/Material.hs b/HGamer3D/Graphics3D/Material.hs
--- a/HGamer3D/Graphics3D/Material.hs
+++ b/HGamer3D/Graphics3D/Material.hs
@@ -1,144 +1,150 @@
--- This source file is part of HGamer3D
--- (A project to enable 3D game development in Haskell)
--- For the latest info, see http://www.hgamer3d.org
---
--- (c) 2011 - 2015 Peter Althainz
---
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
---
---     http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
-
--- HGamer3D/Graphics3D/Camera.hs
-
-{-# LANGUAGE OverloadedStrings #-}
-
--- | Module providing the Material type
-module HGamer3D.Graphics3D.Material
-
-(
-		-- * The Material Type and ComponentType
-        Material (..),
-        ctMaterial,
-
-        -- * Some materials to play with
-		matOrangeCrossMetal,
-		matCrossMetal,
-		matCrossMetalBlue,
-		matMetal,
-		matMetalZigZag,
-		matMetalBumps,
-		matFishEye,
-		matMetalOrnament,
-		matMetalScratch,
-		matMetalLine,
-		matGreenGrass,
-		matBrownGrass,
-		matGreyGrass,
-		matSand,
-		matRedRock,
-		matBlackRock,
-		matBrownStone,
-		matStoneMetalWall,
-		matCoalWall,
-		matBrickWallGray,
-		matBrickWallRed,
-		matTilesOrange,
-		matWoodTiles,
-		matColourTiles,
-		matBlackTiles,
-
-		matWhite,
-		matSilver,
-		matGrey,
-		matDarkGrey,
-		matBlack,
-		matRed,
-		matMaroon,
-		matYellow,
-		matOlive,
-		matLime,
-		matGreen,
-		matAqua,
-		matTeal,
-		matBlue,
-		matNavy,
-		matFuchsia,
-		matPurple 
-)
-
-where
-
-import Data.MessagePack
-import Fresco
-import Data.Text
-
-import HGamer3D.Data
-
--- generated
-
-data Material = ResourceMaterial Text
-    deriving (Eq, Read, Show)
-
-instance ComponentClass Material where
-    toObj (ResourceMaterial v1) = ObjectArray [ObjectInt 0, ObjectArray [(toObj v1)]]
-    fromObj (ObjectArray [ObjectInt 0, ObjectArray [v1]]) = ResourceMaterial (fromObj v1)
-
-ctMaterial :: ComponentType Material
-ctMaterial = ComponentType 0xb4bae8b0d0d8c162
-
--- generated
-
--- some materials from the material folder
-matOrangeCrossMetal = ResourceMaterial "Materials/Pattern_01.xml"
-matCrossMetal = ResourceMaterial "Materials/Pattern_03.xml"
-matCrossMetalBlue = ResourceMaterial "Materials/Pattern_04.xml"
-matMetal = ResourceMaterial "Materials/Pattern_12.xml"
-matMetalZigZag = ResourceMaterial "Materials/Pattern_13.xml"
-matMetalBumps = ResourceMaterial "Materials/Pattern_14.xml"
-matFishEye = ResourceMaterial "Materials/Pattern_15.xml"
-matMetalOrnament = ResourceMaterial "Materials/Pattern_29.xml"
-matMetalScratch = ResourceMaterial "Materials/Pattern_30.xml"
-matMetalLine = ResourceMaterial "Materials/Pattern_31.xml"
-matGreenGrass = ResourceMaterial "Materials/Pattern_42.xml"
-matBrownGrass = ResourceMaterial "Materials/Pattern_43.xml"
-matGreyGrass = ResourceMaterial "Materials/Pattern_44.xml"
-matSand = ResourceMaterial "Materials/Pattern_45.xml"
-matRedRock = ResourceMaterial "Materials/Pattern_46.xml"
-matBlackRock = ResourceMaterial "Materials/Pattern_124.xml"
-matBrownStone = ResourceMaterial "Materials/Pattern_125.xml"
-matStoneMetalWall = ResourceMaterial "Materials/Pattern_126.xml"
-matCoalWall = ResourceMaterial "Materials/Pattern_127.xml"
-matBrickWallGray = ResourceMaterial "Materials/Pattern_100.xml"
-matBrickWallRed = ResourceMaterial "Materials/Pattern_102.xml"
-matTilesOrange = ResourceMaterial "Materials/Pattern_270.xml"
-matWoodTiles = ResourceMaterial "Materials/Pattern_271.xml"
-matColourTiles = ResourceMaterial "Materials/Pattern_272.xml"
-matBlackTiles = ResourceMaterial "Materials/Pattern_273.xml"
-
-matWhite = ResourceMaterial "Materials/ColourWhite.xml"
-matSilver  = ResourceMaterial "Materials/ColourSilver.xml"
-matGrey = ResourceMaterial "Materials/ColourGrey.xml" 
-matDarkGrey = ResourceMaterial "Materials/ColourDarkGrey.xml"
-matBlack = ResourceMaterial "Materials/ColourBlack.xml" 
-matRed = ResourceMaterial "Materials/ColourRed.xml"
-matMaroon = ResourceMaterial "Materials/ColourMaroon.xml"
-matYellow = ResourceMaterial "Materials/ColourYellow.xml"
-matOlive = ResourceMaterial "Materials/ColourOlive.xml" 
-matLime = ResourceMaterial "Materials/ColourLime.xml" 
-matGreen = ResourceMaterial "Materials/ColourGreen.xml"
-matAqua = ResourceMaterial "Materials/ColourAqua.xml" 
-matTeal = ResourceMaterial "Materials/ColourTeal.xml" 
-matBlue = ResourceMaterial "Materials/ColourBlue.xml"  
-matNavy = ResourceMaterial "Materials/ColourNavy.xml"
-matFuchsia = ResourceMaterial "Materials/ColourFuchsia.xml"
-matPurple = ResourceMaterial "Materials/ColourPurple.xml"
-
-
+-- This source file is part of HGamer3D
+-- (A project to enable 3D game development in Haskell)
+-- For the latest info, see http://www.hgamer3d.org
+--
+-- (c) 2011 - 2017 Peter Althainz
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+-- HGamer3D/Graphics3D/Camera.hs
+
+{-# LANGUAGE OverloadedStrings #-}
+
+-- | Module providing the Material type
+module HGamer3D.Graphics3D.Material
+
+(
+    -- * The Material Type and ComponentType
+    Material (..),
+    ctMaterial,
+
+    -- * Some materials to play with
+    matOrangeCrossMetal,
+    matCrossMetal,
+    matCrossMetalBlue,
+    matMetal,
+    matMetalZigZag,
+    matMetalBumps,
+    matFishEye,
+    matMetalOrnament,
+    matMetalScratch,
+    matMetalLine,
+    matGreenGrass,
+    matBrownGrass,
+    matGreyGrass,
+    matSand,
+    matRedRock,
+    matBlackRock,
+    matBrownStone,
+    matStoneMetalWall,
+    matCoalWall,
+    matBrickWallGray,
+    matBrickWallRed,
+    matTilesOrange,
+    matWoodTiles,
+    matColourTiles,
+    matBlackTiles,
+
+    matWhite,
+    matSilver,
+    matGrey,
+    matDarkGrey,
+    matBlack,
+    matRed,
+    matMaroon,
+    matYellow,
+    matOlive,
+    matLime,
+    matGreen,
+    matAqua,
+    matTeal,
+    matBlue,
+    matNavy,
+    matFuchsia,
+    matPurple 
+)
+
+where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+data Material = ResourceMaterial Text
+    deriving (Eq, Read, Show)
+
+ctMaterial :: ComponentType Material
+ctMaterial = ComponentType 0xb4bae8b0d0d8c162
+
+instance Serialise Material where
+    encode (ResourceMaterial v1) = encodeListLen 2 <>  encode (0::Int) <> encode v1
+    decode = do
+        decodeListLen
+        i <- decode :: Decoder s Int
+        case i of
+            0 -> (ResourceMaterial <$> decode)
+
+-- some materials from the material folder
+matOrangeCrossMetal = ResourceMaterial "Materials/Pattern_01.xml"
+matCrossMetal = ResourceMaterial "Materials/Pattern_03.xml"
+matCrossMetalBlue = ResourceMaterial "Materials/Pattern_04.xml"
+matMetal = ResourceMaterial "Materials/Pattern_12.xml"
+matMetalZigZag = ResourceMaterial "Materials/Pattern_13.xml"
+matMetalBumps = ResourceMaterial "Materials/Pattern_14.xml"
+matFishEye = ResourceMaterial "Materials/Pattern_15.xml"
+matMetalOrnament = ResourceMaterial "Materials/Pattern_29.xml"
+matMetalScratch = ResourceMaterial "Materials/Pattern_30.xml"
+matMetalLine = ResourceMaterial "Materials/Pattern_31.xml"
+matGreenGrass = ResourceMaterial "Materials/Pattern_42.xml"
+matBrownGrass = ResourceMaterial "Materials/Pattern_43.xml"
+matGreyGrass = ResourceMaterial "Materials/Pattern_44.xml"
+matSand = ResourceMaterial "Materials/Pattern_45.xml"
+matRedRock = ResourceMaterial "Materials/Pattern_46.xml"
+matBlackRock = ResourceMaterial "Materials/Pattern_124.xml"
+matBrownStone = ResourceMaterial "Materials/Pattern_125.xml"
+matStoneMetalWall = ResourceMaterial "Materials/Pattern_126.xml"
+matCoalWall = ResourceMaterial "Materials/Pattern_127.xml"
+matBrickWallGray = ResourceMaterial "Materials/Pattern_100.xml"
+matBrickWallRed = ResourceMaterial "Materials/Pattern_102.xml"
+matTilesOrange = ResourceMaterial "Materials/Pattern_270.xml"
+matWoodTiles = ResourceMaterial "Materials/Pattern_271.xml"
+matColourTiles = ResourceMaterial "Materials/Pattern_272.xml"
+matBlackTiles = ResourceMaterial "Materials/Pattern_273.xml"
+
+matWhite = ResourceMaterial "Materials/ColourWhite.xml"
+matSilver  = ResourceMaterial "Materials/ColourSilver.xml"
+matGrey = ResourceMaterial "Materials/ColourGrey.xml" 
+matDarkGrey = ResourceMaterial "Materials/ColourDarkGrey.xml"
+matBlack = ResourceMaterial "Materials/ColourBlack.xml" 
+matRed = ResourceMaterial "Materials/ColourRed.xml"
+matMaroon = ResourceMaterial "Materials/ColourMaroon.xml"
+matYellow = ResourceMaterial "Materials/ColourYellow.xml"
+matOlive = ResourceMaterial "Materials/ColourOlive.xml" 
+matLime = ResourceMaterial "Materials/ColourLime.xml" 
+matGreen = ResourceMaterial "Materials/ColourGreen.xml"
+matAqua = ResourceMaterial "Materials/ColourAqua.xml" 
+matTeal = ResourceMaterial "Materials/ColourTeal.xml" 
+matBlue = ResourceMaterial "Materials/ColourBlue.xml"  
+matNavy = ResourceMaterial "Materials/ColourNavy.xml"
+matFuchsia = ResourceMaterial "Materials/ColourFuchsia.xml"
+matPurple = ResourceMaterial "Materials/ColourPurple.xml"
+
+-- end of website text
+
+
diff --git a/HGamer3D/Graphics3D/Window.hs b/HGamer3D/Graphics3D/Window.hs
deleted file mode 100644
--- a/HGamer3D/Graphics3D/Window.hs
+++ /dev/null
@@ -1,56 +0,0 @@
--- This source file is part of HGamer3D
--- (A project to enable 3D game development in Haskell)
--- For the latest info, see http://www.hgamer3d.org
---
--- (c) 2011 - 2015 Peter Althainz
---
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
---
---     http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
-
--- HGamer3D/Graphics3D/Camera.hs
-
--- | Module providing the Window type
-module HGamer3D.Graphics3D.Window
-
-(
-        WindowG3D (..),
-        ctWGr,
-        xyWindow,
-        fullScreen
-)
-
-where
-
-import Data.MessagePack
-import Fresco
-import HGamer3D.Data
--- import HGamer3D.ECS
-
-data WindowG3D = WindowG3D {
-    windowWidth::Int,
-    windowHeight::Int,
-    windowBorderless::Bool,
-    windowFullScreen::Bool,
-    windowResizable::Bool
-}
-
-instance ComponentClass WindowG3D where
-    toObj (WindowG3D v1 v2 v3 v4 v5) = ObjectArray [(toObj v1), (toObj v2), ObjectBool v3, ObjectBool v4, ObjectBool v5]
-    fromObj (ObjectArray [v1, v2, ObjectBool v3, ObjectBool v4, ObjectBool v5]) = WindowG3D (fromObj v1) (fromObj v2) v3 v4 v5
-
-
-ctWGr :: ComponentType WindowG3D
-ctWGr = ComponentType 0xed96843bfb53d99e
-
-xyWindow x y = WindowG3D x y False False True
-fullScreen = WindowG3D 0 0 True True False
-
diff --git a/HGamer3D/Input.hs b/HGamer3D/Input.hs
--- a/HGamer3D/Input.hs
+++ b/HGamer3D/Input.hs
@@ -1,39 +1,39 @@
--- This source file is part of HGamer3D
--- (A project to enable 3D game development in Haskell)
--- For the latest info, see http://www.hgamer3d.org
--- 
--- (c) 2015 Peter Althainz
--- 
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
--- 
---     http://www.apache.org/licenses/LICENSE-2.0
--- 
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
--- 
--- HGamer3D/Input.hs
--- 
-
--- | Input Devices for HGamer3D 
-module HGamer3D.Input
-
-(
-    module HGamer3D.Input.Mouse,
-    module HGamer3D.Input.Keyboard,
-    module HGamer3D.Input.Joystick,
-    module HGamer3D.Input.InputEventHandler
-)
-
-where
-
-import HGamer3D.Input.Mouse
-import HGamer3D.Input.Keyboard
-import HGamer3D.Input.Joystick
-import HGamer3D.Input.InputEventHandler
-
-
+-- This source file is part of HGamer3D
+-- (A project to enable 3D game development in Haskell)
+-- For the latest info, see http://www.hgamer3d.org
+-- 
+-- (c) 2015 Peter Althainz
+-- 
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+-- 
+--     http://www.apache.org/licenses/LICENSE-2.0
+-- 
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+-- 
+-- HGamer3D/Input.hs
+-- 
+
+-- | Input Devices for HGamer3D 
+module HGamer3D.Input
+
+(
+    module HGamer3D.Input.Mouse,
+    module HGamer3D.Input.Keyboard,
+    module HGamer3D.Input.Joystick,
+    module HGamer3D.Input.InputEventHandler
+)
+
+where
+
+import HGamer3D.Input.Mouse
+import HGamer3D.Input.Keyboard
+import HGamer3D.Input.Joystick
+import HGamer3D.Input.InputEventHandler
+
+
diff --git a/HGamer3D/Input/InputEventHandler.hs b/HGamer3D/Input/InputEventHandler.hs
--- a/HGamer3D/Input/InputEventHandler.hs
+++ b/HGamer3D/Input/InputEventHandler.hs
@@ -1,88 +1,80 @@
-{-
-	Input Event handler and settings
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/Input/Mouse.hs
--}
-
--- | Module providing settings for all input events (Mouse, Keyboard, Joystick)
-module HGamer3D.Input.InputEventHandler
-(
-    InputEventType (..),
-    InputEventHandler (..),
-    ctInputEventHandler,
-    ExitRequestedEvent (..),
-    ctExitRequestedEvent
-)
-
-where
-
-import Fresco
-import Data.MessagePack
-import Debug.Trace
-import Data.Text
-
-import HGamer3D.Data
-
-data InputEventType  =  IEMouseButtonUp
-                        | IEMouseButtonDown
-                        | IEMouseMove
-                        | IEMouseButtonWheel
-                        | IEMouseButtonVisibleChanged
-                        | IEKeyUp
-                        | IEKeyDown
-                        | IEExitRequested
-
-                        deriving (Eq, Show)
-
-instance ComponentClass InputEventType where
-
-    toObj iet = case iet of
-        IEMouseButtonUp -> ObjectInt 1
-        IEMouseButtonDown -> ObjectInt 2
-        IEMouseMove -> ObjectInt 3
-        IEMouseButtonWheel -> ObjectInt 4
-        IEMouseButtonVisibleChanged -> ObjectInt 5
-        IEKeyUp -> ObjectInt 6
-        IEKeyDown -> ObjectInt 7
-        IEExitRequested -> ObjectInt 8
-    fromObj (ObjectInt n) = case n of
-        1 -> IEMouseButtonUp
-        2 -> IEMouseButtonDown
-        3 -> IEMouseMove
-        4 -> IEMouseButtonWheel
-        5 -> IEMouseButtonVisibleChanged
-        6 -> IEKeyUp
-        7 -> IEKeyDown
-        8 -> IEExitRequested
-        
-data InputEventHandler = DefaultEventHandler
-                         | SpecificEventHandler [InputEventType]
-
-instance ComponentClass InputEventHandler where
-    toObj DefaultEventHandler = ObjectArray [ObjectInt 0]
-    toObj (SpecificEventHandler iets) = ObjectArray [ObjectInt 1, ObjectArray (Prelude.map toObj iets)]
-
-    fromObj (ObjectArray [ObjectInt 0]) = DefaultEventHandler
-    fromObj (ObjectArray [ObjectInt 1, (ObjectArray iets_os)]) = SpecificEventHandler (Prelude.map fromObj iets_os)
-    
-ctInputEventHandler :: ComponentType InputEventHandler
-ctInputEventHandler = ComponentType 0xfc0edefcebcb5878
-
-
--- ExitRequestedEvent
-
-data ExitRequestedEvent = ExitRequestedEvent
-                      deriving (Eq, Show)
-
-instance ComponentClass ExitRequestedEvent where
-    toObj ExitRequestedEvent = ObjectArray [ObjectInt 0]
-    fromObj (ObjectArray [ObjectInt 0]) = ExitRequestedEvent
-    
-ctExitRequestedEvent :: ComponentType ExitRequestedEvent
-ctExitRequestedEvent = ComponentType 0x824517eb48d5c653
+{-
+	Input Event handler and settings
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2015 - 2017 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/Input/Mouse.hs
+-}
+
+-- | Module providing settings for all input events (Mouse, Keyboard, Joystick)
+module HGamer3D.Input.InputEventHandler
+where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+data InputEventType = IEMouseButtonUp
+    | IEMouseButtonDown
+    | IEMouseMove
+    | IEMouseButtonWheel
+    | IEMouseVisible
+    | IEKeyUp
+    | IEKeyDown
+    | IEExitRequested
+    deriving (Eq, Read, Show)
+
+data InputEventHandler = DefaultEventHandler
+    | SpecificEventHandler [InputEventType]
+    deriving (Eq, Read, Show)
+
+ctInputEventHandler :: ComponentType InputEventHandler
+ctInputEventHandler = ComponentType 0xfc0edefcebcb5878
+
+type ExitRequestedEvent = ()
+
+ctExitRequestedEvent :: ComponentType ExitRequestedEvent
+ctExitRequestedEvent = ComponentType 0x824517eb48d5c653
+
+instance Serialise InputEventType where
+    encode (IEMouseButtonUp) = encodeListLen 1 <>  encode (0::Int) 
+    encode (IEMouseButtonDown) = encodeListLen 1 <>  encode (1::Int) 
+    encode (IEMouseMove) = encodeListLen 1 <>  encode (2::Int) 
+    encode (IEMouseButtonWheel) = encodeListLen 1 <>  encode (3::Int) 
+    encode (IEMouseVisible) = encodeListLen 1 <>  encode (4::Int) 
+    encode (IEKeyUp) = encodeListLen 1 <>  encode (5::Int) 
+    encode (IEKeyDown) = encodeListLen 1 <>  encode (6::Int) 
+    encode (IEExitRequested) = encodeListLen 1 <>  encode (7::Int) 
+    decode = do
+        decodeListLen
+        i <- decode :: Decoder s Int
+        case i of
+            0 -> (pure IEMouseButtonUp)
+            1 -> (pure IEMouseButtonDown)
+            2 -> (pure IEMouseMove)
+            3 -> (pure IEMouseButtonWheel)
+            4 -> (pure IEMouseVisible)
+            5 -> (pure IEKeyUp)
+            6 -> (pure IEKeyDown)
+            7 -> (pure IEExitRequested)
+
+instance Serialise InputEventHandler where
+    encode (DefaultEventHandler) = encodeListLen 1 <>  encode (0::Int) 
+    encode (SpecificEventHandler v1) = encodeListLen 2 <>  encode (1::Int) <> encode v1
+    decode = do
+        decodeListLen
+        i <- decode :: Decoder s Int
+        case i of
+            0 -> (pure DefaultEventHandler)
+            1 -> (SpecificEventHandler <$> decode)
+
diff --git a/HGamer3D/Input/Joystick.hs b/HGamer3D/Input/Joystick.hs
--- a/HGamer3D/Input/Joystick.hs
+++ b/HGamer3D/Input/Joystick.hs
@@ -1,26 +1,22 @@
-{-
-	Joystick functionality and settings
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/Input/Joystick.hs
--}
-
--- | Module providing the Joystick functionality and settings
-module HGamer3D.Input.Joystick
-(
-)
-
-where
-
-import Fresco
-import Data.MessagePack
-import Debug.Trace
-import Data.Text
-
-import HGamer3D.Data
-
+{-
+	Joystick functionality and settings
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2015 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/Input/Joystick.hs
+-}
+
+-- | Module providing the Joystick functionality and settings
+module HGamer3D.Input.Joystick
+(
+)
+
+where
+
+import Fresco
+import HGamer3D.Data
+
diff --git a/HGamer3D/Input/Keyboard.hs b/HGamer3D/Input/Keyboard.hs
--- a/HGamer3D/Input/Keyboard.hs
+++ b/HGamer3D/Input/Keyboard.hs
@@ -1,48 +1,56 @@
-{-
-	Keyboard functionality and settings
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/Input/Keyboard.hs
--}
-
--- | Module providing the keyboard functionality and settings
-module HGamer3D.Input.Keyboard
-
-(
-    KeyEvent (..),
-    ctKeyEvent
-)
-
-where
-
-import Fresco
-import Data.MessagePack
-import Debug.Trace
-import Data.Text
-
-import HGamer3D.Data
-
-data KeyEvent =   NoKeyEvent
-                | KeyUp Int Int Text      -- Key, Scancode, Name
-                | KeyDown Int Int Text    -- Key, Scancode, Name
-                deriving (Eq, Show)
-                
-instance ComponentClass KeyEvent where
-    toObj NoKeyEvent = ObjectArray [ObjectInt 0]
-    toObj (KeyUp k s n) = ObjectArray [ObjectInt 1, ObjectInt (fromIntegral k), ObjectInt (fromIntegral s), toObj n]
-    toObj (KeyDown k s n) = ObjectArray [ObjectInt 2, ObjectInt (fromIntegral k), ObjectInt (fromIntegral s), toObj n]
-
-    fromObj (ObjectArray [ObjectInt 0]) = NoKeyEvent
-    fromObj (ObjectArray [ObjectInt 1, ObjectInt k, ObjectInt s, n_o]) = KeyUp (fromIntegral k) (fromIntegral s) (fromObj n_o)
-    fromObj (ObjectArray [ObjectInt 2, ObjectInt k, ObjectInt s, n_o]) = KeyDown (fromIntegral k) (fromIntegral s) (fromObj n_o)
-    
-ctKeyEvent :: ComponentType KeyEvent
-ctKeyEvent = ComponentType 0x5ba1617fb50e97e5
-
-
-    
+{-
+	Keyboard functionality and settings
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2015 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/Input/Keyboard.hs
+-}
+
+-- | Module providing the keyboard functionality and settings
+module HGamer3D.Input.Keyboard
+where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+import Debug.Trace
+
+data KeyData = KeyData {
+    keyDataKey::Int,
+    keyDataScancode::Int,
+    keyDataName::Text
+    } deriving (Eq, Read, Show)
+
+data KeyEvent = NoKeyEvent
+    | KeyUpEvent KeyData
+    | KeyDownEvent KeyData
+    deriving (Eq, Read, Show)
+
+ctKeyEvent :: ComponentType KeyEvent
+ctKeyEvent = ComponentType 0x5ba1617fb50e97e5
+
+instance Serialise KeyData where
+    encode (KeyData v1 v2 v3) = encodeListLen 3 <> encode v1 <> encode v2 <> encode v3
+    decode = decodeListLenOf 3 >> KeyData <$> decode <*> decode <*> decode
+
+instance Serialise KeyEvent where
+    encode (NoKeyEvent) = encodeListLen 1 <>  encode (0::Int) 
+    encode (KeyUpEvent v1) = encodeListLen 2 <>  encode (1::Int) <> encode v1
+    encode (KeyDownEvent v1) = encodeListLen 2 <>  encode (2::Int) <> encode v1
+    decode = do
+        decodeListLen
+        i <- (decode :: Decoder s Int) 
+        case i of
+            0 -> (pure NoKeyEvent)
+            1 -> (KeyUpEvent <$> decode)
+            2 -> (KeyDownEvent <$> decode)
diff --git a/HGamer3D/Input/Mouse.hs b/HGamer3D/Input/Mouse.hs
--- a/HGamer3D/Input/Mouse.hs
+++ b/HGamer3D/Input/Mouse.hs
@@ -1,84 +1,114 @@
-{-
-	Mouse functionality and settings
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2015 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/Input/Mouse.hs
--}
-
--- | Module providing the Mouse functionality and settings
-module HGamer3D.Input.Mouse
-(
-    MouseMode (..),
-    Mouse (..),
-    MouseEvent (..),
-    ctMouse,
-    ctMouseEvent
-)
-
-where
-
-import Fresco
-import Data.MessagePack
-import Debug.Trace
-import Data.Text
-
-import HGamer3D.Data
-
-
--- Mouse mode and Mouse datatype
-
-data MouseMode = MMAbsolute
-                | MMRelative
-                | MMWrap
-                deriving (Eq, Show)
-                
-instance ComponentClass MouseMode where
-    toObj MMAbsolute = ObjectInt 1
-    toObj MMRelative = ObjectInt 2
-    toObj MMWrap = ObjectInt 3
-    fromObj (ObjectInt 1) = MMAbsolute
-    fromObj (ObjectInt 2) = MMRelative
-    fromObj (ObjectInt 3) = MMWrap
-    
-data Mouse = Mouse MouseMode deriving (Eq, Show) 
-
-instance ComponentClass Mouse where
-    toObj (Mouse mm) = ObjectArray [ObjectInt 1, toObj mm]
-    fromObj (ObjectArray [ObjectInt 1, mm_o]) = Mouse (fromObj mm_o)
-
-ctMouse :: ComponentType Mouse
-ctMouse = ComponentType 0xa532f43b1c1c6bc7
-
--- Mouse Events
-
-data MouseEvent =   NoMouseEvent
-                    | MouseButtonUp Int Int Int         -- Button, Buttons, Qualifiers
-                    | MouseButtonDown Int Int Int       -- Button, Buttons, Qualifiers
-                    | MouseMove Int Int Int Int Int Int -- X, Y, DX, DY, Buttons, Qualifiers
-                    | MouseWheel Int Int Int            -- Wheel, Buttons, Qualifiers
-                    | MouseVisibleChanged Bool          -- Visible
-                      deriving (Eq, Show)
-
-instance ComponentClass MouseEvent where
-    toObj NoMouseEvent = ObjectArray [ObjectInt 0]
-    toObj (MouseButtonUp b bs qs) = ObjectArray [ObjectInt 1, ObjectInt (fromIntegral b), ObjectInt (fromIntegral bs), ObjectInt (fromIntegral qs)]
-    toObj (MouseButtonDown b bs qs) = ObjectArray [ObjectInt 2, ObjectInt (fromIntegral b), ObjectInt (fromIntegral bs), ObjectInt (fromIntegral qs)]
-    toObj (MouseMove x y dx dy bs qs) = ObjectArray [ObjectInt 3, ObjectInt (fromIntegral x), ObjectInt (fromIntegral y), ObjectInt (fromIntegral dx), ObjectInt (fromIntegral dy), ObjectInt (fromIntegral bs), ObjectInt (fromIntegral qs)]
-    toObj (MouseWheel w bs qs) = ObjectArray [ObjectInt 4, ObjectInt (fromIntegral w), ObjectInt (fromIntegral bs), ObjectInt (fromIntegral qs)]
-    toObj (MouseVisibleChanged v) = ObjectArray [ObjectInt 5, ObjectBool v]
-    
-    fromObj (ObjectArray [ObjectInt 0]) = NoMouseEvent
-    fromObj (ObjectArray [ObjectInt 1, ObjectInt b, ObjectInt bs, ObjectInt qs]) = MouseButtonUp (fromIntegral b) (fromIntegral bs) (fromIntegral qs)
-    fromObj (ObjectArray [ObjectInt 2, ObjectInt b, ObjectInt bs, ObjectInt qs]) = MouseButtonDown (fromIntegral b) (fromIntegral bs) (fromIntegral qs)
-    fromObj (ObjectArray [ObjectInt 3, ObjectInt x, ObjectInt y, ObjectInt dx, ObjectInt dy, ObjectInt bs, ObjectInt qs]) = MouseMove (fromIntegral x) (fromIntegral y) (fromIntegral dx) (fromIntegral dy) (fromIntegral bs) (fromIntegral qs)
-    fromObj (ObjectArray [ObjectInt 4, ObjectInt w, ObjectInt bs, ObjectInt qs]) = MouseWheel (fromIntegral w) (fromIntegral bs) (fromIntegral qs)
-    fromObj (ObjectArray [ObjectInt 5, ObjectBool v]) = MouseVisibleChanged v
-    
-ctMouseEvent :: ComponentType MouseEvent
-ctMouseEvent = ComponentType 0x27eaf3fd46595d08
-
+{-
+	Mouse functionality and settings
+	HGamer3D Library (A project to enable 3D game development in Haskell)
+	Copyright 2015 - 2017 Peter Althainz
+	
+	Distributed under the Apache License, Version 2.0
+	(See attached file LICENSE or copy at 
+	http://www.apache.org/licenses/LICENSE-2.0)
+ 
+	file: HGamer3D/Input/Mouse.hs
+-}
+
+-- | Module providing the Mouse functionality and settings
+module HGamer3D.Input.Mouse
+where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+data MouseMode = Absolute
+    | Relative
+    | Wrap
+    deriving (Eq, Read, Show)
+
+data MouseConfig = MouseConfig {
+    mouseConfigMode::MouseMode
+    } deriving (Eq, Read, Show)
+
+ctMouseConfig :: ComponentType MouseConfig
+ctMouseConfig = ComponentType 0xa532f43b1c1c6bc7
+
+data MouseButtonData = MouseButtonData {
+    mouseButtonDataButton::Int,
+    mouseButtonDataButtons::Int,
+    mouseButtonDataQualifiers::Int
+    } deriving (Eq, Read, Show)
+
+data MouseMoveData = MouseMoveData {
+    mouseMoveDataX::Int,
+    mouseMoveDataY::Int,
+    mouseMoveDataDx::Int,
+    mouseMoveDataDy::Int,
+    mouseMoveDataButtons::Int,
+    mouseMoveDataQualifiers::Int
+    } deriving (Eq, Read, Show)
+
+data MouseWheelData = MouseWheelData {
+    mouseWheelDataWheel::Int,
+    mouseWheelDataButtons::Int,
+    mouseWheelDataQualifiers::Int
+    } deriving (Eq, Read, Show)
+
+data MouseEvent = NoMouseEvent
+    | MouseButtonUpEvent MouseButtonData
+    | MouseButtonDownEvent MouseButtonData
+    | MouseMoveEvent MouseMoveData
+    | MouseWheelEvent MouseWheelData
+    deriving (Eq, Read, Show)
+
+ctMouseEvent :: ComponentType MouseEvent
+ctMouseEvent = ComponentType 0x27eaf3fd46595d08
+
+instance Serialise MouseMode where
+    encode (Absolute) = encodeListLen 1 <>  encode (0::Int) 
+    encode (Relative) = encodeListLen 1 <>  encode (1::Int) 
+    encode (Wrap) = encodeListLen 1 <>  encode (2::Int) 
+    decode = do
+        decodeListLen
+        i <- decode :: Decoder s Int
+        case i of
+            0 -> (pure Absolute)
+            1 -> (pure Relative)
+            2 -> (pure Wrap)
+
+instance Serialise MouseConfig where
+    encode (MouseConfig v1) = encodeListLen 1 <> encode v1
+    decode = decodeListLenOf 1 >> MouseConfig <$> decode
+
+instance Serialise MouseButtonData where
+    encode (MouseButtonData v1 v2 v3) = encodeListLen 3 <> encode v1 <> encode v2 <> encode v3
+    decode = decodeListLenOf 3 >> MouseButtonData <$> decode <*> decode <*> decode
+
+instance Serialise MouseMoveData where
+    encode (MouseMoveData v1 v2 v3 v4 v5 v6) = encodeListLen 6 <> encode v1 <> encode v2 <> encode v3 <> encode v4 <> encode v5 <> encode v6
+    decode = decodeListLenOf 6 >> MouseMoveData <$> decode <*> decode <*> decode <*> decode <*> decode <*> decode
+
+instance Serialise MouseWheelData where
+    encode (MouseWheelData v1 v2 v3) = encodeListLen 3 <> encode v1 <> encode v2 <> encode v3
+    decode = decodeListLenOf 3 >> MouseWheelData <$> decode <*> decode <*> decode
+
+instance Serialise MouseEvent where
+    encode (NoMouseEvent) = encodeListLen 1 <>  encode (0::Int) 
+    encode (MouseButtonUpEvent v1) = encodeListLen 2 <>  encode (1::Int) <> encode v1
+    encode (MouseButtonDownEvent v1) = encodeListLen 2 <>  encode (2::Int) <> encode v1
+    encode (MouseMoveEvent v1) = encodeListLen 2 <>  encode (3::Int) <> encode v1
+    encode (MouseWheelEvent v1) = encodeListLen 2 <>  encode (4::Int) <> encode v1
+    decode = do
+        decodeListLen
+        i <- decode :: Decoder s Int
+        case i of
+            0 -> (pure NoMouseEvent)
+            1 -> (MouseButtonUpEvent <$> decode)
+            2 -> (MouseButtonDownEvent <$> decode)
+            3 -> (MouseMoveEvent <$> decode)
+            4 -> (MouseWheelEvent <$> decode)
+
+
diff --git a/HGamer3D/Util.hs b/HGamer3D/Util.hs
--- a/HGamer3D/Util.hs
+++ b/HGamer3D/Util.hs
@@ -1,36 +1,36 @@
--- This source file is part of HGamer3D
--- (A project to enable 3D game development in Haskell)
--- For the latest info, see http://www.hgamer3d.org
--- 
--- (c) 2011 - 2015 Peter Althainz
--- 
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
--- 
---     http://www.apache.org/licenses/LICENSE-2.0
--- 
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
--- 
--- HGamer3D/Data.hs
--- 
-
--- | Common utilities for HGamer3D 
-module HGamer3D.Util
-
-(
-    module HGamer3D.Util.FileLocation,
-    module HGamer3D.Util.UniqueName,
-    module HGamer3D.Util.Variable
-)
-
-where
-
-import HGamer3D.Util.FileLocation
-import HGamer3D.Util.UniqueName
-import HGamer3D.Util.Variable
-
+-- This source file is part of HGamer3D
+-- (A project to enable 3D game development in Haskell)
+-- For the latest info, see http://www.hgamer3d.org
+-- 
+-- (c) 2011 - 2015 Peter Althainz
+-- 
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+-- 
+--     http://www.apache.org/licenses/LICENSE-2.0
+-- 
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+-- 
+-- HGamer3D/Data.hs
+-- 
+
+-- | Common utilities for HGamer3D 
+module HGamer3D.Util
+
+(
+    module HGamer3D.Util.FileLocation,
+    module HGamer3D.Util.UniqueName,
+    module HGamer3D.Util.Variable
+)
+
+where
+
+import HGamer3D.Util.FileLocation
+import HGamer3D.Util.UniqueName
+import HGamer3D.Util.Variable
+
diff --git a/HGamer3D/Util/FileLocation.hs b/HGamer3D/Util/FileLocation.hs
--- a/HGamer3D/Util/FileLocation.hs
+++ b/HGamer3D/Util/FileLocation.hs
@@ -1,50 +1,50 @@
--- This source file is part of HGamer3D
--- (A project to enable 3D game development in Haskell)
--- For the latest info, see http://www.hgamer3d.org
---
--- (c) 2011 - 2015 Peter Althainz
---
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
---
---     http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
-
--- Util.hs
-
--- | Utility to provide file location information to other parts of HGamer3D
-module HGamer3D.Util.FileLocation
-
-(
-  
-        -- * Directories relative to the user-related application directory for HGamer3D
-        getAppDirectory,
-        getMediaDirectory,
-        getConfigDirectory,
-        
-        -- * General utilities for path handling and finding files
-        pathSeparator
-)
-
-where
-
-import Control.Monad
-import Control.Exception
-import System.FilePath
-import System.Directory
-
--- | path of subdirectory within platform specific application directories
-getAppDirectory = getAppUserDataDirectory
-
--- | path of HGamer3D Media Directory
-getMediaDirectory = getAppDirectory ("HGamer3D" ++ [pathSeparator] ++ "media")
-
--- | path of HGamer3D configuration directory 
-getConfigDirectory = getAppDirectory ("HGamer3D" ++ [pathSeparator] ++ "config")
-
+-- This source file is part of HGamer3D
+-- (A project to enable 3D game development in Haskell)
+-- For the latest info, see http://www.hgamer3d.org
+--
+-- (c) 2011 - 2015 Peter Althainz
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+-- Util.hs
+
+-- | Utility to provide file location information to other parts of HGamer3D
+module HGamer3D.Util.FileLocation
+
+(
+  
+        -- * Directories relative to the user-related application directory for HGamer3D
+        getAppDirectory,
+        getMediaDirectory,
+        getConfigDirectory,
+        
+        -- * General utilities for path handling and finding files
+        pathSeparator
+)
+
+where
+
+import Control.Monad
+import Control.Exception
+import System.FilePath
+import System.Directory
+
+-- | path of subdirectory within platform specific application directories
+getAppDirectory = getAppUserDataDirectory
+
+-- | path of HGamer3D Media Directory
+getMediaDirectory = getAppDirectory ("HGamer3D" ++ [pathSeparator] ++ "media")
+
+-- | path of HGamer3D configuration directory 
+getConfigDirectory = getAppDirectory ("HGamer3D" ++ [pathSeparator] ++ "config")
+
diff --git a/HGamer3D/Util/UniqueName.hs b/HGamer3D/Util/UniqueName.hs
--- a/HGamer3D/Util/UniqueName.hs
+++ b/HGamer3D/Util/UniqueName.hs
@@ -1,48 +1,48 @@
--- This source file is part of HGamer3D
--- (A project to enable 3D game development in Haskell)
--- For the latest info, see http://www.hgamer3d.org
---
--- (c) 2011-2013 Peter Althainz
---
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
---
---     http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
-
--- UniqueName.hs
-
--- | Utility to provide a unique name, carries internal state in a IORef
-module HGamer3D.Util.UniqueName
-(
-  
-  UniqueName,
-  createUniqueName,
-  nextUniqueName
-  
-) where
-
-import Data.IORef
-
-data UniqueName = UniqueName String (IORef [Int])
-
--- | creates a unique name holder
-createUniqueName :: String -> IO UniqueName
-createUniqueName baseName = do
-  ref <- newIORef [0..]
-  return $ UniqueName baseName ref
-  
--- | delivers the next unique name from the name holder
-nextUniqueName :: UniqueName -> IO String
-nextUniqueName (UniqueName baseName ref) = do
-  name <- atomicModifyIORef ref (\ilist -> (tail ilist, baseName ++ (show (head ilist))))
-  return name
-  
-  
+-- This source file is part of HGamer3D
+-- (A project to enable 3D game development in Haskell)
+-- For the latest info, see http://www.hgamer3d.org
+--
+-- (c) 2011-2013 Peter Althainz
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+-- UniqueName.hs
+
+-- | Utility to provide a unique name, carries internal state in a IORef
+module HGamer3D.Util.UniqueName
+(
+  
+  UniqueName,
+  createUniqueName,
+  nextUniqueName
+  
+) where
+
+import Data.IORef
+
+data UniqueName = UniqueName String (IORef [Int])
+
+-- | creates a unique name holder
+createUniqueName :: String -> IO UniqueName
+createUniqueName baseName = do
+  ref <- newIORef [0..]
+  return $ UniqueName baseName ref
+  
+-- | delivers the next unique name from the name holder
+nextUniqueName :: UniqueName -> IO String
+nextUniqueName (UniqueName baseName ref) = do
+  name <- atomicModifyIORef ref (\ilist -> (tail ilist, baseName ++ (show (head ilist))))
+  return name
+  
+  
                    
diff --git a/HGamer3D/Util/Variable.hs b/HGamer3D/Util/Variable.hs
--- a/HGamer3D/Util/Variable.hs
+++ b/HGamer3D/Util/Variable.hs
@@ -1,55 +1,55 @@
--- This source file is part of HGamer3D
--- (A project to enable 3D game development in Haskell)
--- For the latest info, see http://www.hgamer3d.org
---
--- (c) 2011-2013 Peter Althainz
---
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
---
---     http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
-
--- Variable.hs
-
--- | :-) I'm fundamentally convinced this is missing in Haskell, urs of the backwoods
-
-module HGamer3D.Util.Variable
-(
-  Var,
-  makeVar,
-  readVar,
-  writeVar,
-  writeVar',
-  updateVar,
-  updateVar'
-) where
-
-import Data.IORef
-
-newtype Var a = Var (IORef a)
-
-makeVar :: a -> IO (Var a)
-makeVar v = Var <$> newIORef v
-
-readVar :: Var a -> IO a
-readVar (Var r) = readIORef r
-
-writeVar :: Var a -> a -> IO a
-writeVar (Var r) val = atomicModifyIORef r (\old -> (val, old)) 
-
-writeVar' :: Var a -> a -> IO a
-writeVar' (Var r) val = atomicModifyIORef' r (\old -> (val, old))
-
-updateVar :: Var a -> (a -> (a, b)) -> IO b
-updateVar (Var r) f = atomicModifyIORef r f
-
-updateVar' :: Var a -> (a -> (a, b)) -> IO b
-updateVar' (Var r) f = atomicModifyIORef' r f
-
+-- This source file is part of HGamer3D
+-- (A project to enable 3D game development in Haskell)
+-- For the latest info, see http://www.hgamer3d.org
+--
+-- (c) 2011-2013 Peter Althainz
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+-- Variable.hs
+
+-- | :-) I'm fundamentally convinced this is missing in Haskell, urs of the backwoods
+
+module HGamer3D.Util.Variable
+(
+  Var,
+  makeVar,
+  readVar,
+  writeVar,
+  writeVar',
+  updateVar,
+  updateVar'
+) where
+
+import Data.IORef
+
+newtype Var a = Var (IORef a)
+
+makeVar :: a -> IO (Var a)
+makeVar v = Var <$> newIORef v
+
+readVar :: Var a -> IO a
+readVar (Var r) = readIORef r
+
+writeVar :: Var a -> a -> IO a
+writeVar (Var r) val = atomicModifyIORef r (\old -> (val, old)) 
+
+writeVar' :: Var a -> a -> IO a
+writeVar' (Var r) val = atomicModifyIORef' r (\old -> (val, old))
+
+updateVar :: Var a -> (a -> (a, b)) -> IO b
+updateVar (Var r) f = atomicModifyIORef r f
+
+updateVar' :: Var a -> (a -> (a, b)) -> IO b
+updateVar' (Var r) f = atomicModifyIORef' r f
+
diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -1,42 +1,42 @@
-LICENSE
--------
-
-(c) 2011-2014 Peter Althainz
-
-
-HGamer3D (http://www.hgamer3d.org)
-----------------------------------
-
-HGamer3D is licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
- 
-Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
-
-Source Code
------------
-You can obtain the latest version of the source code under http://www.bitbucket.org/althainz/HGamer3D
-
-
-Open Source Software Used - Module HGamer3D
--------------------------------------------
-
-HGamer3D uses a number of open source software libraries. You are responsible to comply to the licenses of those packages and the licenses of software used by those packages if you use HGamer3D. 
-
-The HGamer3D module uses the following Haskell libraries from Hackage:
-
-base, license: BSD3
-containers, license: BSD3
-text,  license: BSD3
-directory, license: BSD3
-mtl, license: BSD3
-FindBin, license: BSD3
-monad-loops, license: PublicDomain, BSD3 similar
-split, license: BSD3
-netwire, license: BSD3
-HGamer3D-Data, license: Apache 2.0
-HGamer3D-Ogre-Binding, license: Apache 2.0 and dependencies see in that module
-HGamer3D-SFML-Binding, license: Apache 2.0 and dependencies see in that module 
-HGamer3D-CEGUI-Binding, license: Apache 2.0 and dependencies see in that module
-HGamer3D-Enet-Binding, license: Apache 2.0 and dependencies see in that module
+LICENSE
+-------
+
+(c) 2011-2014 Peter Althainz
+
+
+HGamer3D (http://www.hgamer3d.org)
+----------------------------------
+
+HGamer3D is licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+ 
+Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+
+
+Source Code
+-----------
+You can obtain the latest version of the source code under http://www.bitbucket.org/althainz/HGamer3D
+
+
+Open Source Software Used - Module HGamer3D
+-------------------------------------------
+
+HGamer3D uses a number of open source software libraries. You are responsible to comply to the licenses of those packages and the licenses of software used by those packages if you use HGamer3D. 
+
+The HGamer3D module uses the following Haskell libraries from Hackage:
+
+base, license: BSD3
+containers, license: BSD3
+text,  license: BSD3
+directory, license: BSD3
+mtl, license: BSD3
+FindBin, license: BSD3
+monad-loops, license: PublicDomain, BSD3 similar
+split, license: BSD3
+netwire, license: BSD3
+HGamer3D-Data, license: Apache 2.0
+HGamer3D-Ogre-Binding, license: Apache 2.0 and dependencies see in that module
+HGamer3D-SFML-Binding, license: Apache 2.0 and dependencies see in that module 
+HGamer3D-CEGUI-Binding, license: Apache 2.0 and dependencies see in that module
+HGamer3D-Enet-Binding, license: Apache 2.0 and dependencies see in that module
diff --git a/Setup.hs b/Setup.hs
--- a/Setup.hs
+++ b/Setup.hs
@@ -1,22 +1,22 @@
--- This source file is part of HGamer3D
--- (A project to enable 3D game development in Haskell)
--- For the latest info, see http://www.hgamer3d.org
---
--- (c) 2011-2013 Peter Althainz
---
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
---
---     http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
-
--- Setup.hs
-
-import Distribution.Simple
-main = defaultMain
+-- This source file is part of HGamer3D
+-- (A project to enable 3D game development in Haskell)
+-- For the latest info, see http://www.hgamer3d.org
+--
+-- (c) 2011-2013 Peter Althainz
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+-- Setup.hs
+
+import Distribution.Simple
+main = defaultMain
