Index: /code/branches/objecthierarchy/src/orxonox/GraphicsEngine.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/GraphicsEngine.cc	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/GraphicsEngine.cc	(revision 2023)
@@ -68,8 +68,7 @@
     */
     GraphicsEngine::GraphicsEngine()
-        : root_(0)
-        , renderWindow_(0)
-        , levelSceneManager_(0)
-        , viewport_(0)
+//        : root_(0)
+//        , renderWindow_(0)
+//        , viewport_(0)
     {
         RegisterObject(GraphicsEngine);
@@ -103,45 +102,3 @@
         singletonRef_s = 0;
     }
-
-    /**
-    @brief
-        Get the width of the render window
-    @return
-        The width of the render window
-    */
-    int GraphicsEngine::getWindowWidth() const
-    {
-        if (this->renderWindow_)
-            return this->renderWindow_->getWidth();
-        else
-            return 0;
-    }
-
-    /**
-    @brief
-        Get the height of the render window
-    @return
-        The height of the render window
-    */
-    int GraphicsEngine::getWindowHeight() const
-    {
-        if (this->renderWindow_)
-            return this->renderWindow_->getHeight();
-        else
-            return 0;
-    }
-
-    /**
-    @brief
-        Returns the window aspect ratio height/width.
-    @return
-        The window aspect ratio
-    */
-    float GraphicsEngine::getWindowAspectRatio() const
-    {
-        if (this->renderWindow_)
-            return (float)this->renderWindow_->getHeight() / (float)this->renderWindow_->getWidth();
-        else
-            return 1.0f;
-    }
 }
Index: /code/branches/objecthierarchy/src/orxonox/GraphicsEngine.h
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/GraphicsEngine.h	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/GraphicsEngine.h	(revision 2023)
@@ -61,14 +61,4 @@
         void detailLevelParticleChanged();
 
-        void setLevelSceneManager(Ogre::SceneManager* sceneMgr) { this->levelSceneManager_ = sceneMgr; }
-        Ogre::SceneManager* getLevelSceneManager() { return levelSceneManager_; }
-
-        Ogre::Viewport* getViewport() { return this->viewport_; }
-        Ogre::Root*     getOgreRoot() { return this->root_; }
-
-        // several window properties
-        int getWindowWidth() const;
-        int getWindowHeight() const;
-        float getWindowAspectRatio() const;
         float getAverageFramesPerSecond() const   { return this->avgFramesPerSecond_; }
         float getAverageTickTime() const          { return this->avgTickTime_; }
@@ -86,9 +76,4 @@
         GraphicsEngine(GraphicsEngine&);
 
-        Ogre::Root*         root_;                  //!< Ogre's root
-        Ogre::RenderWindow* renderWindow_;          //!< the current render window
-        Ogre::SceneManager* levelSceneManager_;     //!< scene manager of the game
-        Ogre::Viewport*     viewport_;              //!< default full size viewport
-
         // stats
         float               avgTickTime_;           //!< time in ms to tick() one frame
Index: /code/branches/objecthierarchy/src/orxonox/LevelManager.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/LevelManager.cc	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/LevelManager.cc	(revision 2023)
@@ -38,15 +38,20 @@
 namespace orxonox
 {
+    LevelManager* LevelManager::singletonRef_s = 0;
+
     LevelManager::LevelManager()
     {
         RegisterRootObject(LevelManager);
 
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+
         this->getConnectedClients();
     }
 
-    LevelManager& LevelManager::getInstance()
+    LevelManager::~LevelManager()
     {
-        static LevelManager instance;
-        return instance;
+        assert(singletonRef_s != 0);
+        singletonRef_s = 0;
     }
 
Index: /code/branches/objecthierarchy/src/orxonox/LevelManager.h
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/LevelManager.h	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/LevelManager.h	(revision 2023)
@@ -34,4 +34,5 @@
 #include <list>
 #include <map>
+#include <cassert>
 
 #include "network/ClientConnectionListener.h"
@@ -42,5 +43,6 @@
     {
         public:
-            static LevelManager& getInstance();
+            LevelManager();
+            virtual ~LevelManager();
 
             void requestActivity(Level* level);
@@ -52,7 +54,8 @@
                 { return this->clients_; }
 
+            static LevelManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
+
         private:
-            LevelManager();
-            virtual ~LevelManager() {}
+            LevelManager(const LevelManager&);
 
             void clientConnected(unsigned int clientID);
@@ -63,4 +66,6 @@
             std::list<Level*> levels_s;
             std::map<unsigned int, PlayerInfo*> clients_;
+
+            static LevelManager* singletonRef_s;
     };
 }
Index: /code/branches/objecthierarchy/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/OrxonoxPrereqs.h	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/OrxonoxPrereqs.h	(revision 2023)
@@ -80,4 +80,5 @@
     class RadarListener;
 
+    class CameraHandler;
     class LevelManager;
 
Index: /code/branches/objecthierarchy/src/orxonox/gamestates/GSClient.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/gamestates/GSClient.cc	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/gamestates/GSClient.cc	(revision 2023)
@@ -40,5 +40,5 @@
 
     GSClient::GSClient()
-        : GSLevel("client")
+        : GameState<GSGraphics>("client")
         , client_(0)
     {
@@ -53,6 +53,4 @@
         Core::setIsClient(true);
 
-        GSLevel::enter();
-
         this->client_ = new network::Client(CommandLine::getValue("ip").getString(), CommandLine::getValue("port"));
 
@@ -60,15 +58,12 @@
             ThrowException(InitialisationFailed, "Could not establish connection with server.");
 
+        GSLevel::enter(this->getParent()->getViewport());
+
         client_->tick(0);
-
-        // level is loaded: we can start capturing the input
-        InputManager::getInstance().requestEnterState("game");
     }
 
     void GSClient::leave()
     {
-        InputManager::getInstance().requestLeaveState("game");
-
-        // TODO: How do we unload the level in client mode?
+        GSLevel::leave();
 
         client_->closeConnection();
@@ -76,6 +71,4 @@
         // destroy client
         delete this->client_;
-
-        GSLevel::leave();
 
         Core::setIsClient(false);
Index: /code/branches/objecthierarchy/src/orxonox/gamestates/GSClient.h
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/gamestates/GSClient.h	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/gamestates/GSClient.h	(revision 2023)
@@ -33,8 +33,9 @@
 #include "network/NetworkPrereqs.h"
 #include "GSLevel.h"
+#include "GSGraphics.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSClient : public GSLevel
+    class _OrxonoxExport GSClient : public GameState<GSGraphics>, public GSLevel
     {
     public:
Index: /code/branches/objecthierarchy/src/orxonox/gamestates/GSDedicated.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/gamestates/GSDedicated.cc	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/gamestates/GSDedicated.cc	(revision 2023)
@@ -30,15 +30,7 @@
 #include "GSDedicated.h"
 
-#include <OgreRoot.h>
-#include <OgreSceneManager.h>
-#include "core/ConsoleCommand.h"
 #include "core/CommandLine.h"
-#include "core/Loader.h"
-#include "core/XMLFile.h"
 #include "core/Core.h"
 #include "network/Server.h"
-#include "objects/Tickable.h"
-#include "Settings.h"
-#include "GraphicsEngine.h"
 
 namespace orxonox
@@ -46,8 +38,5 @@
     GSDedicated::GSDedicated()
         : GameState<GSRoot>("dedicated")
-        , timeFactor_(0)
         , server_(0)
-        , sceneManager_(0)
-        , startFile_(0)
     {
     }
@@ -61,40 +50,18 @@
         Core::setHasServer(true);
 
-        // create Ogre SceneManager for the level
-        this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC, "LevelSceneManager");
-        COUT(4) << "Created SceneManager: " << sceneManager_->getName() << std::endl;
+        this->server_ = new network::Server(CommandLine::getValue("port"));
+        COUT(0) << "Loading scene in server mode" << std::endl;
 
-        // temporary hack
-        GraphicsEngine::getInstance().setLevelSceneManager(this->sceneManager_);
-
-        // reset game speed to normal
-        timeFactor_ = 1.0f;
-
-        this->server_ = new network::Server(CommandLine::getValue("port"));
-
-        // call the loader
-        COUT(0) << "Loading level..." << std::endl;
-        startFile_ = new XMLFile(Settings::getDataPath() + "levels/sample.oxw");
-        Loader::open(startFile_);
+        GSLevel::enter(0);
 
         server_->open();
-
-        // add console commands
-        FunctorMember01<GSDedicated, float>* functor = createFunctor(&GSDedicated::setTimeFactor);
-        functor->setObject(this);
-        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
     }
 
     void GSDedicated::leave()
     {
-        // TODO: Remove and destroy console command
-
-        Loader::unload(startFile_);
-        delete this->startFile_;
+        GSLevel::leave();
 
         this->server_->close();
         delete this->server_;
-
-        Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
 
         Core::setHasServer(false);
@@ -103,19 +70,7 @@
     void GSDedicated::ticked(const Clock& time)
     {
-        // Call the scene objects
-        for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
-            it->tick(time.getDeltaTime() * this->timeFactor_);
-
+        GSLevel::ticked(time);
         server_->tick(time.getDeltaTime());
         this->tickChild(time);
     }
-
-    /**
-    @brief
-        Changes the speed of Orxonox
-    */
-    void GSDedicated::setTimeFactor(float factor)
-    {
-        this->timeFactor_ = factor;
-    }
 }
Index: /code/branches/objecthierarchy/src/orxonox/gamestates/GSDedicated.h
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/gamestates/GSDedicated.h	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/gamestates/GSDedicated.h	(revision 2023)
@@ -32,16 +32,14 @@
 #include "OrxonoxPrereqs.h"
 #include "network/NetworkPrereqs.h"
+#include "GSLevel.h"
 #include "GSRoot.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSDedicated : public GameState<GSRoot>
+    class _OrxonoxExport GSDedicated : public GameState<GSRoot>, public GSLevel
     {
     public:
         GSDedicated();
         ~GSDedicated();
-
-        void setTimeFactor(float factor);
-        float getTimeFactor() { return this->timeFactor_; }
 
     private:
@@ -50,11 +48,5 @@
         void ticked(const Clock& time);
 
-        void loadLevel();
-        void unloadLevel();
-
-        float                 timeFactor_;       //!< A factor to change the gamespeed
         network::Server*      server_;
-        Ogre::SceneManager*   sceneManager_;
-        XMLFile*              startFile_;        //!< current hard coded default level
     };
 }
Index: /code/branches/objecthierarchy/src/orxonox/gamestates/GSGUI.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/gamestates/GSGUI.cc	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/gamestates/GSGUI.cc	(revision 2023)
@@ -31,5 +31,4 @@
 
 #include <OgreViewport.h>
-#include "GraphicsEngine.h"
 #include "core/input/InputManager.h"
 #include "core/input/SimpleInputState.h"
Index: /code/branches/objecthierarchy/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/gamestates/GSGraphics.cc	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/gamestates/GSGraphics.cc	(revision 2023)
@@ -116,7 +116,7 @@
 
         // HACK: temporary:
-        graphicsEngine_->renderWindow_  = this->renderWindow_;
-        graphicsEngine_->root_          = this->ogreRoot_;
-        graphicsEngine_->viewport_      = this->viewport_;
+        //graphicsEngine_->renderWindow_  = this->renderWindow_;
+        //graphicsEngine_->root_          = this->ogreRoot_;
+        //graphicsEngine_->viewport_      = this->viewport_;
 
 
@@ -134,5 +134,5 @@
         // Load the InGameConsole
         console_ = new InGameConsole();
-        console_->initialise();
+        console_->initialise(this->renderWindow_->getWidth(), this->renderWindow_->getHeight());
 
         // load the CEGUI interface
Index: /code/branches/objecthierarchy/src/orxonox/gamestates/GSIOConsole.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/gamestates/GSIOConsole.cc	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/gamestates/GSIOConsole.cc	(revision 2023)
@@ -36,5 +36,4 @@
 
 #include "core/ConsoleCommand.h"
-#include "GraphicsEngine.h"
 
 namespace orxonox
Index: /code/branches/objecthierarchy/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/gamestates/GSLevel.cc	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/gamestates/GSLevel.cc	(revision 2023)
@@ -30,6 +30,4 @@
 #include "GSLevel.h"
 
-#include <OgreSceneManager.h>
-#include <OgreRoot.h>
 #include "core/input/InputManager.h"
 #include "core/input/SimpleInputState.h"
@@ -41,21 +39,24 @@
 #include "core/ConfigValueIncludes.h"
 #include "core/CoreIncludes.h"
+#include "core/Core.h"
 //#include "objects/Backlight.h"
+#include "objects/CameraHandler.h"
 #include "objects/Tickable.h"
 #include "objects/Radar.h"
 //#include "tools/ParticleInterface.h"
-#include "GraphicsEngine.h"
+#include "LevelManager.h"
 #include "Settings.h"
 
 namespace orxonox
 {
-    GSLevel::GSLevel(const std::string& name)
-        : GameState<GSGraphics>(name)
-        , timeFactor_(1.0f)
-        , sceneManager_(0)
+    GSLevel::GSLevel()
+//        : GameState<GSGraphics>(name)
+        : timeFactor_(1.0f)
         , keyBinder_(0)
         , inputState_(0)
         , radar_(0)
         , startFile_(0)
+        , cameraHandler_(0)
+        , levelManager_(0)
     {
         RegisterObject(GSLevel);
@@ -72,38 +73,58 @@
     }
 
-    void GSLevel::enter()
-    {
-        inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game", 20);
-        keyBinder_ = new KeyBinder();
-        keyBinder_->loadBindings("keybindings.ini");
-        inputState_->setHandler(keyBinder_);
-
-        // create Ogre SceneManager for the level
-        this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC, "LevelSceneManager");
-        COUT(4) << "Created SceneManager: " << sceneManager_->getName() << std::endl;
-
-        this->sceneManager_->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
-
-        // temporary hack
-        GraphicsEngine::getInstance().setLevelSceneManager(this->sceneManager_);
-
-        // Start the Radar
-        this->radar_ = new Radar();
-
-        // reset game speed to normal
-        timeFactor_ = 1.0f;
-
-        // TODO: insert slomo console command with
-        // .accessLevel(AccessLevel::Offline).defaultValue(0, 1.0).axisParamIndex(0).isAxisRelative(false);
-
-        // keybind console command
-        FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind);
-        functor1->setObject(this);
-        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "keybind"));
-        FunctorMember<GSLevel>* functor2 = createFunctor(&GSLevel::tkeybind);
-        functor2->setObject(this);
-        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "tkeybind"));
-        // set our console command as callback for the key detector
-        InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_);
+    void GSLevel::enter(Ogre::Viewport* viewport)
+    {
+        if (Core::showsGraphics())
+        {
+            inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game", 20);
+            keyBinder_ = new KeyBinder();
+            keyBinder_->loadBindings("keybindings.ini");
+            inputState_->setHandler(keyBinder_);
+
+            // create the global CameraHandler
+            assert(viewport);
+            this->cameraHandler_ = new CameraHandler(viewport);
+
+            // Start the Radar
+            this->radar_ = new Radar();
+        }
+
+        if (Core::isMaster())
+        {
+            // create the global LevelManager
+            this->levelManager_ = new LevelManager();
+
+            // reset game speed to normal
+            timeFactor_ = 1.0f;
+
+            this->loadLevel();
+        }
+
+        if (Core::showsGraphics())
+        {
+            // TODO: insert slomo console command with
+            // .accessLevel(AccessLevel::Offline).defaultValue(0, 1.0).axisParamIndex(0).isAxisRelative(false);
+
+            // keybind console command
+            FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind);
+            functor1->setObject(this);
+            CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "keybind"));
+            FunctorMember<GSLevel>* functor2 = createFunctor(&GSLevel::tkeybind);
+            functor2->setObject(this);
+            CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "tkeybind"));
+            // set our console command as callback for the key detector
+            InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_);
+
+            // level is loaded: we can start capturing the input
+            InputManager::getInstance().requestEnterState("game");
+        }
+
+        if (Core::isMaster())
+        {
+            // time factor console command
+            FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);
+            functor->setObject(this);
+            CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
+        }
     }
 
@@ -116,11 +137,26 @@
         //Loader::close();
 
-        delete this->radar_;
-
-        Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
-
-        inputState_->setHandler(0);
-        InputManager::getInstance().requestDestroyState("game");
-        delete this->keyBinder_;
+        if (Core::showsGraphics())
+            InputManager::getInstance().requestLeaveState("game");
+
+        if (Core::isMaster())
+            this->unloadLevel();
+
+        if (this->radar_)
+            delete this->radar_;
+
+        if (this->cameraHandler_)
+            delete this->cameraHandler_;
+
+        if (this->levelManager_)
+            delete this->levelManager_;
+
+        if (Core::showsGraphics())
+        {
+            inputState_->setHandler(0);
+            InputManager::getInstance().requestDestroyState("game");
+            if (this->keyBinder_)
+                delete this->keyBinder_;
+        }
     }
 
@@ -185,33 +221,36 @@
     void GSLevel::keybindInternal(const std::string& command, bool bTemporary)
     {
-        static std::string bindingString = "";
-        static bool bTemporarySaved = false;
-        static bool bound = true;
-        // note: We use a long name to make 'sure' that the user doesn't use it accidentally.
-        // Howerver there will be no real issue if it happens anyway.
-        if (command.find(keyDetectorCallbackCode_) != 0)
-        {
-            if (bound)
+        if (Core::showsGraphics())
+        {
+            static std::string bindingString = "";
+            static bool bTemporarySaved = false;
+            static bool bound = true;
+            // note: We use a long name to make 'sure' that the user doesn't use it accidentally.
+            // Howerver there will be no real issue if it happens anyway.
+            if (command.find(keyDetectorCallbackCode_) != 0)
             {
-                COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
-                InputManager::getInstance().requestEnterState("detector");
-                bindingString = command;
-                bTemporarySaved = bTemporary;
-                bound = false;
+                if (bound)
+                {
+                    COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
+                    InputManager::getInstance().requestEnterState("detector");
+                    bindingString = command;
+                    bTemporarySaved = bTemporary;
+                    bound = false;
+                }
+                //else:  We're still in a keybind command. ignore this call.
             }
-            //else:  We're still in a keybind command. ignore this call.
-        }
-        else
-        {
-            if (!bound)
+            else
             {
-                // user has pressed the key
-                std::string name = command.substr(this->keyDetectorCallbackCode_.size());
-                COUT(0) << "Binding string \"" << bindingString << "\" on key '" << name << "'" << std::endl;
-                this->keyBinder_->setBinding(bindingString, name, bTemporarySaved);
-                InputManager::getInstance().requestLeaveState("detector");
-                bound = true;
+                if (!bound)
+                {
+                    // user has pressed the key
+                    std::string name = command.substr(this->keyDetectorCallbackCode_.size());
+                    COUT(0) << "Binding string \"" << bindingString << "\" on key '" << name << "'" << std::endl;
+                    this->keyBinder_->setBinding(bindingString, name, bTemporarySaved);
+                    InputManager::getInstance().requestLeaveState("detector");
+                    bound = true;
+                }
+                // else: A key was pressed within the same tick, ignore it.
             }
-            // else: A key was pressed within the same tick, ignore it.
         }
     }
Index: /code/branches/objecthierarchy/src/orxonox/gamestates/GSLevel.h
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/gamestates/GSLevel.h	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/gamestates/GSLevel.h	(revision 2023)
@@ -37,10 +37,10 @@
 namespace orxonox
 {
-    class _OrxonoxExport GSLevel : public GameState<GSGraphics>, public OrxonoxClass
+    class _OrxonoxExport GSLevel : public OrxonoxClass //,public GameState<GSGraphics>
     {
         friend class ClassIdentifier<GSLevel>;
     public:
-        GSLevel(const std::string& name);
-        virtual ~GSLevel();
+        GSLevel();
+        ~GSLevel();
 
         // this has to be public because proteced triggers a bug in msvc
@@ -50,12 +50,12 @@
 
     protected:
-        virtual void enter();
-        virtual void leave();
-        virtual void ticked(const Clock& time);
+        void enter(Ogre::Viewport* viewport);
+        void leave();
+        void ticked(const Clock& time);
 
         void loadLevel();
         void unloadLevel();
 
-        float timeFactor_;       //!< A factor to change the gamespeed
+        float timeFactor_;       //!< A factor that sets the gamespeed. 1 is normal.
 
         // console commands
@@ -64,9 +64,10 @@
         void keybindInternal(const std::string& command, bool bTemporary);
 
-        Ogre::SceneManager*   sceneManager_;
         KeyBinder*            keyBinder_;        //!< tool that loads and manages the input bindings
         SimpleInputState*     inputState_;
         Radar*                radar_;            //!< represents the Radar (not the HUD part)
         XMLFile*              startFile_;        //!< current hard coded default level
+        CameraHandler*        cameraHandler_;
+        LevelManager*         levelManager_;
 
         // config values
Index: /code/branches/objecthierarchy/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/gamestates/GSRoot.cc	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/gamestates/GSRoot.cc	(revision 2023)
@@ -41,5 +41,4 @@
 #include "core/TclThreadManager.h"
 #include "tools/Timer.h"
-#include "GraphicsEngine.h"
 #include "Settings.h"
 
Index: /code/branches/objecthierarchy/src/orxonox/gamestates/GSServer.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/gamestates/GSServer.cc	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/gamestates/GSServer.cc	(revision 2023)
@@ -30,6 +30,4 @@
 #include "GSServer.h"
 
-#include "core/ConsoleCommand.h"
-#include "core/input/InputManager.h"
 #include "core/CommandLine.h"
 #include "core/Core.h"
@@ -41,5 +39,5 @@
 
     GSServer::GSServer()
-        : GSLevel("server")
+        : GameState<GSGraphics>("server")
         , server_(0)
     {
@@ -54,34 +52,18 @@
         Core::setHasServer(true);
 
-        GSLevel::enter();
-
         this->server_ = new network::Server(CommandLine::getValue("port"));
         COUT(0) << "Loading scene in server mode" << std::endl;
 
-        this->loadLevel();
+        GSLevel::enter(this->getParent()->getViewport());
 
         server_->open();
-
-        // add console commands
-        FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);
-        functor->setObject(this);
-        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
-
-        // level is loaded: we can start capturing the input
-        InputManager::getInstance().requestEnterState("game");
     }
 
     void GSServer::leave()
     {
-        InputManager::getInstance().requestLeaveState("game");
-
-        // TODO: Remove and destroy console command
-
-        this->unloadLevel();
+        GSLevel::leave();
 
         this->server_->close();
         delete this->server_;
-
-        GSLevel::leave();
 
         Core::setHasServer(false);
Index: /code/branches/objecthierarchy/src/orxonox/gamestates/GSServer.h
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/gamestates/GSServer.h	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/gamestates/GSServer.h	(revision 2023)
@@ -33,13 +33,13 @@
 #include "network/NetworkPrereqs.h"
 #include "GSLevel.h"
+#include "GSGraphics.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSServer : public GSLevel
+    class _OrxonoxExport GSServer : public GameState<GSGraphics>, public GSLevel
     {
     public:
         GSServer();
         ~GSServer();
-
 
     private:
Index: /code/branches/objecthierarchy/src/orxonox/gamestates/GSStandalone.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/gamestates/GSStandalone.cc	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/gamestates/GSStandalone.cc	(revision 2023)
@@ -30,6 +30,4 @@
 #include "GSStandalone.h"
 
-#include "core/input/InputManager.h"
-#include "core/ConsoleCommand.h"
 #include "core/Core.h"
 
@@ -37,5 +35,5 @@
 {
     GSStandalone::GSStandalone()
-        : GSLevel("standalone")
+        : GameState<GSGraphics>("standalone")
     {
     }
@@ -47,26 +45,11 @@
     void GSStandalone::enter()
     {
-        GSLevel::enter();
+        Core::setIsStandalone(true);
 
-        Core::setIsStandalone(true);
-        this->loadLevel();
-
-        // add console commands
-        FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);
-        functor->setObject(this);
-        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
-
-        // level is loaded: we can start capturing the input
-        InputManager::getInstance().requestEnterState("game");
+        GSLevel::enter(this->getParent()->getViewport());
     }
 
     void GSStandalone::leave()
     {
-        InputManager::getInstance().requestLeaveState("game");
-
-        // TODO: Remove and destroy console command
-
-        this->unloadLevel();
-
         GSLevel::leave();
 
Index: /code/branches/objecthierarchy/src/orxonox/gamestates/GSStandalone.h
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/gamestates/GSStandalone.h	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/gamestates/GSStandalone.h	(revision 2023)
@@ -32,8 +32,9 @@
 #include "OrxonoxPrereqs.h"
 #include "GSLevel.h"
+#include "GSGraphics.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSStandalone : public GSLevel
+    class _OrxonoxExport GSStandalone : public GameState<GSGraphics>, public GSLevel
     {
     public:
Index: /code/branches/objecthierarchy/src/orxonox/gui/GUIManager.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/gui/GUIManager.cc	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/gui/GUIManager.cc	(revision 2023)
@@ -47,5 +47,4 @@
 #include "core/Core.h"
 #include "tolua/tolua_bind.h"
-#include "GraphicsEngine.h"
 #include "OgreCEGUIRenderer.h"
 
Index: /code/branches/objecthierarchy/src/orxonox/objects/Camera.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/objects/Camera.cc	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/objects/Camera.cc	(revision 2023)
@@ -29,23 +29,17 @@
 #include "OrxonoxStableHeaders.h"
 #include "Camera.h"
-#include "CameraHandler.h"
 
 #include <string>
 #include <cassert>
 
+#include <OgreCamera.h>
 #include <OgreSceneManager.h>
 #include <OgreSceneNode.h>
-#include <OgreRenderWindow.h>
 #include <OgreViewport.h>
 
-#include "tinyxml/tinyxml.h"
-#include "util/SubString.h"
-#include "util/Math.h"
-#include "util/String.h"
-#include "util/Debug.h"
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
-#include "GraphicsEngine.h"
 #include "objects/Scene.h"
+#include "objects/CameraHandler.h"
 
 namespace orxonox
Index: /code/branches/objecthierarchy/src/orxonox/objects/Camera.h
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/objects/Camera.h	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/objects/Camera.h	(revision 2023)
@@ -30,9 +30,7 @@
 #define _Camera_H__
 
+#include "OrxonoxPrereqs.h"
+
 #include <OgrePrerequisites.h>
-#include <OgreSceneNode.h>
-#include <OgreCamera.h>
-
-#include "OrxonoxPrereqs.h"
 #include "objects/worldentities/PositionableEntity.h"
 #include "objects/Tickable.h"
Index: /code/branches/objecthierarchy/src/orxonox/objects/CameraHandler.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/objects/CameraHandler.cc	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/objects/CameraHandler.cc	(revision 2023)
@@ -29,25 +29,25 @@
 #include "CameraHandler.h"
 
-#include <OgreSceneManager.h>
-#include <OgreRenderWindow.h>
+#include <OgreViewport.h>
 
-#include "core/ObjectList.h"
 #include "core/Core.h"
 #include "Camera.h"
-#include "GraphicsEngine.h"
 
-#include <OgreCamera.h>
 
 namespace orxonox
 {
-    CameraHandler::CameraHandler()
+    CameraHandler* CameraHandler::singletonRef_s = 0;
+
+    CameraHandler::CameraHandler(Ogre::Viewport* viewport)
+        : viewport_(viewport)
     {
-//        GraphicsEngine::getInstance().getViewport()->setCamera(this->cam_);
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
     }
 
-    CameraHandler& CameraHandler::getInstance()
+    CameraHandler::~CameraHandler()
     {
-        static CameraHandler instance;
-        return instance;
+        assert(singletonRef_s != 0);
+        singletonRef_s = 0;
     }
 
@@ -71,5 +71,5 @@
         // add to list
         this->cameraList_.push_front(camera);
-        camera->setFocus(GraphicsEngine::getInstance().getViewport());
+        camera->setFocus(this->viewport_);
     }
 
@@ -87,5 +87,5 @@
             // set new focus if necessary
             if (cameraList_.size() > 0)
-                cameraList_.front()->setFocus(GraphicsEngine::getInstance().getViewport());
+                cameraList_.front()->setFocus(this->viewport_);
         }
         else
Index: /code/branches/objecthierarchy/src/orxonox/objects/CameraHandler.h
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/objects/CameraHandler.h	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/objects/CameraHandler.h	(revision 2023)
@@ -38,8 +38,7 @@
 #include "OrxonoxPrereqs.h"
 
+#include <cassert>
 #include <list>
-#include <OgreCamera.h>
-
-#include "core/BaseObject.h"
+#include <OgrePrerequisites.h>
 
 namespace orxonox
@@ -48,5 +47,6 @@
     {
         public:
-            static CameraHandler& getInstance();
+            CameraHandler(Ogre::Viewport* viewport);
+            ~CameraHandler();
 
             Camera* getActiveCamera() const;
@@ -55,9 +55,13 @@
             void releaseFocus(Camera* camera);
 
+            static CameraHandler& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
+
         private:
-            CameraHandler();
-            ~CameraHandler() {}
+            CameraHandler(const CameraHandler&);
 
             std::list<Camera*> cameraList_;
+            Ogre::Viewport* viewport_;
+
+            static CameraHandler* singletonRef_s;
     };
 }
Index: /code/branches/objecthierarchy/src/orxonox/objects/Scene.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/objects/Scene.cc	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/objects/Scene.cc	(revision 2023)
@@ -31,9 +31,10 @@
 
 #include <OgreRoot.h>
-#include <OgreSceneManager.h>
+#include <OgreSceneManagerEnumerator.h>
 #include <OgreSceneNode.h>
 #include <OgreLight.h>
 
 #include "core/CoreIncludes.h"
+#include "core/Core.h"
 #include "core/XMLPort.h"
 
@@ -49,17 +50,26 @@
         this->bShadows_ = false;
 
-        if (Ogre::Root::getSingletonPtr())
+        if (Core::showsGraphics())
         {
-            this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC);
-            this->rootSceneNode_ = this->sceneManager_->getRootSceneNode();
+            if (Ogre::Root::getSingletonPtr())
+            {
+                this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC);
+                this->rootSceneNode_ = this->sceneManager_->getRootSceneNode();
+            }
+            else
+            {
+                this->sceneManager_ = 0;
+                this->rootSceneNode_ = 0;
+            }
         }
         else
         {
-            this->sceneManager_ = 0;
-            this->rootSceneNode_ = 0;
+            // create a dummy SceneManager of our own since we don't have Ogre::Root.
+            this->sceneManager_ = new Ogre::DefaultSceneManager("");
+            this->rootSceneNode_ = this->sceneManager_->getRootSceneNode();
         }
 
         // test test test
-        if (this->sceneManager_)
+        if (Core::showsGraphics() && this->sceneManager_)
         {
             Ogre::Light* light;
@@ -80,6 +90,7 @@
             Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
         }
-        else
+        else if (!Core::showsGraphics())
         {
+            delete this->sceneManager_;
         }
     }
@@ -104,5 +115,5 @@
     void Scene::setSkybox(const std::string& skybox)
     {
-        if (this->sceneManager_)
+        if (Core::showsGraphics() && this->sceneManager_)
             this->sceneManager_->setSkyBox(true, skybox);
 
@@ -112,5 +123,5 @@
     void Scene::setAmbientLight(const ColourValue& colour)
     {
-        if (this->sceneManager_)
+        if (Core::showsGraphics() && this->sceneManager_)
             this->sceneManager_->setAmbientLight(colour);
 
@@ -120,5 +131,5 @@
     void Scene::setShadow(bool bShadow)
     {
-        if (this->sceneManager_)
+        if (Core::showsGraphics() && this->sceneManager_)
         {
             if (bShadow)
Index: /code/branches/objecthierarchy/src/orxonox/objects/worldentities/WorldEntity.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/objects/worldentities/WorldEntity.cc	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/objects/worldentities/WorldEntity.cc	(revision 2023)
@@ -37,5 +37,4 @@
 #include "util/Convert.h"
 
-#include "GraphicsEngine.h"
 #include "objects/Scene.h"
 
Index: /code/branches/objecthierarchy/src/orxonox/overlays/OrxonoxOverlay.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/overlays/OrxonoxOverlay.cc	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/overlays/OrxonoxOverlay.cc	(revision 2023)
@@ -44,5 +44,4 @@
 #include "core/XMLPort.h"
 #include "core/ConsoleCommand.h"
-#include "GraphicsEngine.h"
 
 namespace orxonox
@@ -115,7 +114,9 @@
 
             // We'll have to get the aspect ratio manually for the first time. Afterwards windowResized() gets
-            // called automatically by the GraphicsEngine.
-            this->windowResized(GraphicsEngine::getInstance().getWindowWidth(),
-                GraphicsEngine::getInstance().getWindowHeight());
+            // called automatically by GSGraphics.
+            //this->windowResized(GraphicsEngine::getInstance().getWindowWidth(),
+            //    GraphicsEngine::getInstance().getWindowHeight());
+            this->windowAspectRatio_ = Ogre::OverlayManager::getSingleton().getViewportAspectRatio();
+            this->sizeCorrectionChanged();
 
             this->changedVisibility();
Index: /code/branches/objecthierarchy/src/orxonox/overlays/console/InGameConsole.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/overlays/console/InGameConsole.cc	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/overlays/console/InGameConsole.cc	(revision 2023)
@@ -48,5 +48,4 @@
 #include "core/input/SimpleInputState.h"
 #include "core/input/InputBuffer.h"
-#include "GraphicsEngine.h"
 
 namespace orxonox
@@ -170,5 +169,5 @@
         @brief Initializes the InGameConsole.
     */
-    void InGameConsole::initialise()
+    void InGameConsole::initialise(int windowWidth, int windowHeight)
     {
         // create the corresponding input state
@@ -246,5 +245,5 @@
         this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_);
 
-        this->windowResized(GraphicsEngine::getInstance().getWindowWidth(), GraphicsEngine::getInstance().getWindowHeight());
+        this->windowResized(windowWidth, windowHeight);
 
         // move overlay "above" the top edge of the screen
Index: /code/branches/objecthierarchy/src/orxonox/overlays/console/InGameConsole.h
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/overlays/console/InGameConsole.h	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/overlays/console/InGameConsole.h	(revision 2023)
@@ -49,5 +49,5 @@
         ~InGameConsole();
 
-        void initialise();
+        void initialise(int windowWidth, int windowHeight);
         void destroy();
         void setConfigValues();
Index: /code/branches/objecthierarchy/src/orxonox/overlays/hud/ChatOverlay.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/overlays/hud/ChatOverlay.cc	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/overlays/hud/ChatOverlay.cc	(revision 2023)
@@ -38,5 +38,4 @@
 #include "network/ClientInformation.h"
 
-#include "GraphicsEngine.h"
 #include "LevelManager.h"
 #include "objects/infos/PlayerInfo.h"
Index: /code/branches/objecthierarchy/src/orxonox/tools/BillboardSet.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/tools/BillboardSet.cc	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/tools/BillboardSet.cc	(revision 2023)
@@ -34,5 +34,4 @@
 #include <OgreSceneManager.h>
 
-#include "GraphicsEngine.h"
 #include "util/Math.h"
 
Index: /code/branches/objecthierarchy/src/orxonox/tools/Light.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/tools/Light.cc	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/tools/Light.cc	(revision 2023)
@@ -35,6 +35,4 @@
 #include <OgreSceneManager.h>
 
-#include "GraphicsEngine.h"
-
 namespace orxonox
 {
Index: /code/branches/objecthierarchy/src/orxonox/tools/Mesh.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/tools/Mesh.cc	(revision 2022)
+++ /code/branches/objecthierarchy/src/orxonox/tools/Mesh.cc	(revision 2023)
@@ -35,5 +35,4 @@
 
 #include "core/Core.h"
-#include "GraphicsEngine.h"
 #include "util/Convert.h"
 #include "util/String.h"
@@ -64,12 +63,15 @@
             this->scenemanager_->destroyEntity(this->entity_);
 
-        try
+        if (Core::showsGraphics())
         {
-            this->entity_ = this->scenemanager_->createEntity("Mesh" + convertToString(Mesh::meshCounter_s++), meshsource);
-            this->entity_->setCastShadows(this->bCastShadows_);
-        }
-        catch (...)
-        {
-            COUT(1) << "Error: Couln't load mesh \"" << meshsource << "\"" << std::endl;
+            try
+            {
+                this->entity_ = this->scenemanager_->createEntity("Mesh" + convertToString(Mesh::meshCounter_s++), meshsource);
+                this->entity_->setCastShadows(this->bCastShadows_);
+            }
+            catch (...)
+            {
+                COUT(1) << "Error: Couln't load mesh \"" << meshsource << "\"" << std::endl;
+            }
         }
     }
