Index: code/branches/gui/src/orxonox/gamestates/GSClient.cc
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSClient.cc	(revision 1670)
+++ code/branches/gui/src/orxonox/gamestates/GSClient.cc	(revision 1672)
@@ -78,10 +78,10 @@
     }
 
-    void GSClient::ticked(float dt)
+    void GSClient::ticked(float dt, uint64_t time)
     {
-        GSLevel::ticked(dt);
+        GSLevel::ticked(dt, time);
         client_->tick(dt);
 
-        this->tickChild(dt);
+        this->tickChild(dt, time);
     }
 }
Index: code/branches/gui/src/orxonox/gamestates/GSClient.h
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSClient.h	(revision 1670)
+++ code/branches/gui/src/orxonox/gamestates/GSClient.h	(revision 1672)
@@ -46,5 +46,5 @@
         void enter();
         void leave();
-        void ticked(float dt);
+        void ticked(float dt, uint64_t time);
 
         network::Client* client_;
Index: code/branches/gui/src/orxonox/gamestates/GSGUI.cc
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSGUI.cc	(revision 1670)
+++ code/branches/gui/src/orxonox/gamestates/GSGUI.cc	(revision 1672)
@@ -58,10 +58,10 @@
     }
 
-    void GSGUI::ticked(float dt)
+    void GSGUI::ticked(float dt, uint64_t time)
     {
         // tick CEGUI
         GUIManager::getInstance().tick(dt);
 
-        this->tickChild(dt);
+        this->tickChild(dt, time);
     }
 }
Index: code/branches/gui/src/orxonox/gamestates/GSGUI.h
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSGUI.h	(revision 1670)
+++ code/branches/gui/src/orxonox/gamestates/GSGUI.h	(revision 1672)
@@ -44,5 +44,5 @@
         void enter();
         void leave();
-        void ticked(float dt);
+        void ticked(float dt, uint64_t time);
 
     };
Index: code/branches/gui/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSGraphics.cc	(revision 1670)
+++ code/branches/gui/src/orxonox/gamestates/GSGraphics.cc	(revision 1672)
@@ -34,9 +34,9 @@
 #include <OgreTimer.h>
 #include <OgreWindowEventUtilities.h>
+#include <OgreRenderWindow.h>
 
 #include "core/ConsoleCommand.h"
 #include "core/ConfigValueIncludes.h"
 #include "core/input/InputManager.h"
-#include "core/TclThreadManager.h"
 //#include "core/Core.h"
 #include "overlays/console/InGameConsole.h"
@@ -48,9 +48,9 @@
     GSGraphics::GSGraphics()
         : GameState("graphics")
-        , timer_(0)
         , debugRefreshTime_(0.0f)
         , inputManager_(0)
         , console_(0)
         , guiManager_(0)
+        , frameCount_(0)
     {
     }
@@ -67,4 +67,5 @@
     void GSGraphics::enter()
     {
+        this->ogreRoot_ = Ogre::Root::getSingletonPtr();
         this->graphicsEngine_ = GraphicsEngine::getInstancePtr();
 
@@ -87,13 +88,8 @@
         guiManager_ = new GUIManager();
         guiManager_->initialise();
-
-        // use the ogre timer class to measure time.
-        timer_ = new Ogre::Timer();
     }
 
     void GSGraphics::leave()
     {
-        delete this->timer_;
-
         delete this->guiManager_;
 
@@ -102,4 +98,7 @@
         delete this->inputManager_;
 
+        this->ogreRoot_->detachRenderTarget(GraphicsEngine::getInstance().getRenderWindow());
+        delete GraphicsEngine::getInstance().getRenderWindow();
+        this->ogreRoot_->shutdown
         // TODO: destroy render window
     }
@@ -118,88 +117,58 @@
         need the time. So we shouldn't run into problems.
     */
-    void GSGraphics::ticked(float dt)
+    void GSGraphics::ticked(float dt, uint64_t time)
     {
-        // note: paramter 'dt' is of no meaning
+        this->inputManager_->tick(dt);
 
-        Ogre::Root& ogreRoot = Ogre::Root::getSingleton();
+        this->tickChild(dt, time);
 
-        unsigned long frameCount = 0;
+        // tick console
+        this->console_->tick(dt);
 
-        const unsigned long refreshTime = (unsigned long)(debugRefreshTime_ * 1000000.0f);
-        unsigned long refreshStartTime = 0;
-        unsigned long tickTime = 0;
-        unsigned long oldFrameCount = 0;
+        //// get current time once again
+        //timeAfterTick = timer_->getMicroseconds();
 
-        unsigned long timeBeforeTick = 0;
-        unsigned long timeBeforeTickOld = 0;
-        unsigned long timeAfterTick = 0;
+        //tickTime += timeAfterTick - timeBeforeTick;
+        //if (timeAfterTick > refreshStartTime + refreshTime)
+        //{
+        //    GraphicsEngine::getInstance().setAverageTickTime(
+        //        (float)tickTime * 0.001 / (frameCount - oldFrameCount));
+        //    float avgFPS = (float)(frameCount - oldFrameCount) / (timeAfterTick - refreshStartTime) * 1000000.0;
+        //    GraphicsEngine::getInstance().setAverageFramesPerSecond(avgFPS);
 
-        // TODO: Update time in seconds every 7 seconds to avoid any overflow (7 secs is very tight)
+        //    oldFrameCount = frameCount;
+        //    tickTime = 0;
+        //    refreshStartTime = timeAfterTick;
+        //}
 
-        COUT(3) << "Orxonox: Starting the main loop." << std::endl;
+        // don't forget to call _fireFrameStarted in ogre to make sure
+        // everything goes smoothly
+        Ogre::FrameEvent evt;
+        evt.timeSinceLastFrame = dt;
+        evt.timeSinceLastEvent = dt; // note: same time, but shouldn't matter anyway
+        ogreRoot_->_fireFrameStarted(evt);
 
-        try
-        {
-            timer_->reset();
-            while (!this->hasScheduledTransition())
-            {
-                // get current time
-                timeBeforeTickOld = timeBeforeTick;
-                timeBeforeTick    = timer_->getMicroseconds();
-                float dt = (timeBeforeTick - timeBeforeTickOld) / 1000000.0;
+        // Pump messages in all registered RenderWindows
+        // This calls the WindowEventListener objects.
+        Ogre::WindowEventUtilities::messagePump();
+        // make sure the window stays active even when not focused
+        // (probably only necessary on windows)
+        GraphicsEngine::getInstance().setWindowActivity(true);
 
-                this->inputManager_->tick(dt);
-                TclThreadManager::getInstance().tick(dt);
+        // render
+        ogreRoot_->_updateAllRenderTargets();
 
-                this->tickChild(dt);
+        // again, just to be sure ogre works fine
+        ogreRoot_->_fireFrameEnded(evt); // note: uses the same time as _fireFrameStarted
 
-                // tick console
-                this->console_->tick(dt);
+        ++frameCount_;
 
-                // get current time once again
-                timeAfterTick = timer_->getMicroseconds();
-
-                tickTime += timeAfterTick - timeBeforeTick;
-                if (timeAfterTick > refreshStartTime + refreshTime)
-                {
-                    GraphicsEngine::getInstance().setAverageTickTime(
-                        (float)tickTime * 0.001 / (frameCount - oldFrameCount));
-                    float avgFPS = (float)(frameCount - oldFrameCount) / (timeAfterTick - refreshStartTime) * 1000000.0;
-                    GraphicsEngine::getInstance().setAverageFramesPerSecond(avgFPS);
-
-                    oldFrameCount = frameCount;
-                    tickTime = 0;
-                    refreshStartTime = timeAfterTick;
-                }
-
-                // don't forget to call _fireFrameStarted in ogre to make sure
-                // everything goes smoothly
-                Ogre::FrameEvent evt;
-                evt.timeSinceLastFrame = dt;
-                evt.timeSinceLastEvent = dt; // note: same time, but shouldn't matter anyway
-                ogreRoot._fireFrameStarted(evt);
-
-                // Pump messages in all registered RenderWindows
-                // This calls the WindowEventListener objects.
-                Ogre::WindowEventUtilities::messagePump();
-                // make sure the window stays active even when not focused
-                // (probably only necessary on windows)
-                GraphicsEngine::getInstance().setWindowActivity(true);
-
-                // render
-                ogreRoot._updateAllRenderTargets();
-
-                // again, just to be sure ogre works fine
-                ogreRoot._fireFrameEnded(evt); // note: uses the same time as _fireFrameStarted
-
-                ++frameCount;
-            }
-        }
-        catch (std::exception& ex)
-        {
-            // something went wrong.
-            COUT(1) << ex.what() << std::endl;
-            COUT(1) << "Main loop was stopped by an unhandled exception. Shutting down." << std::endl;
-        }
+        //}
+        //catch (std::exception& ex)
+        //{
+        //    // something went wrong.
+        //    COUT(1) << ex.what() << std::endl;
+        //    COUT(1) << "Main loop was stopped by an unhandled exception. Shutting down." << std::endl;
+        //}
     }
 }
Index: code/branches/gui/src/orxonox/gamestates/GSGraphics.h
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSGraphics.h	(revision 1670)
+++ code/branches/gui/src/orxonox/gamestates/GSGraphics.h	(revision 1672)
@@ -48,15 +48,27 @@
         void enter();
         void leave();
-        void ticked(float dt);
-
-        Ogre::Timer*          timer_;            //!< Main loop timer
+        void ticked(float dt, uint64_t time);
 
         // config values
         float                 debugRefreshTime_;
 
+        Ogre::Root*           ogreRoot_;
         GraphicsEngine*       graphicsEngine_;   //!< our dearest graphics engine <3
         InputManager*         inputManager_;
         InGameConsole*        console_;
         GUIManager*           guiManager_;
+
+
+        // variables for time statistics
+        unsigned long         frameCount_;
+
+        //const unsigned long refreshTime = (unsigned long)(debugRefreshTime_ * 1000000.0f);
+        //unsigned long refreshStartTime;
+        //unsigned long tickTime;
+        //unsigned long oldFrameCount;
+
+        //unsigned long timeBeforeTick;
+        //unsigned long timeBeforeTickOld;
+        //unsigned long timeAfterTick;
     };
 }
Index: code/branches/gui/src/orxonox/gamestates/GSIO.cc
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSIO.cc	(revision 1670)
+++ code/branches/gui/src/orxonox/gamestates/GSIO.cc	(revision 1672)
@@ -58,7 +58,7 @@
     }
 
-    void GSIO::ticked(float dt)
+    void GSIO::ticked(float dt, uint64_t time)
     {
-        this->tickChild(dt);
+        this->tickChild(dt, time);
         //Ogre::Root& ogreRoot = Ogre::Root::getSingleton();
 
Index: code/branches/gui/src/orxonox/gamestates/GSIO.h
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSIO.h	(revision 1670)
+++ code/branches/gui/src/orxonox/gamestates/GSIO.h	(revision 1672)
@@ -45,5 +45,5 @@
         void enter();
         void leave();
-        void ticked(float dt);
+        void ticked(float dt, uint64_t time);
 
         //Ogre::Timer*          timer_;            //!< Main loop timer
Index: code/branches/gui/src/orxonox/gamestates/GSIOConsole.cc
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSIOConsole.cc	(revision 1670)
+++ code/branches/gui/src/orxonox/gamestates/GSIOConsole.cc	(revision 1672)
@@ -58,12 +58,11 @@
     }
 
-    void GSIOConsole::ticked(float dt)
+    void GSIOConsole::ticked(float dt, uint64_t time)
     {
-        while (!this->hasScheduledTransition())
-        {
-            std::string command;
-            std::cin >> command;
-            CommandExecutor::execute(command, true);
-        }
+        std::string command;
+        std::getline(std::cin, command);
+        CommandExecutor::execute(command, true);
+        
+        tickChild(dt, time);
     }
 }
Index: code/branches/gui/src/orxonox/gamestates/GSIOConsole.h
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSIOConsole.h	(revision 1670)
+++ code/branches/gui/src/orxonox/gamestates/GSIOConsole.h	(revision 1672)
@@ -45,5 +45,5 @@
         void enter();
         void leave();
-        void ticked(float dt);
+        void ticked(float dt, uint64_t time);
     };
 }
Index: code/branches/gui/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSLevel.cc	(revision 1670)
+++ code/branches/gui/src/orxonox/gamestates/GSLevel.cc	(revision 1672)
@@ -96,5 +96,5 @@
     }
 
-    void GSLevel::ticked(float dt)
+    void GSLevel::ticked(float dt, uint64_t time)
     {
         // Call those objects that need the real time
Index: code/branches/gui/src/orxonox/gamestates/GSLevel.h
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSLevel.h	(revision 1670)
+++ code/branches/gui/src/orxonox/gamestates/GSLevel.h	(revision 1672)
@@ -49,5 +49,5 @@
         virtual void enter();
         virtual void leave();
-        virtual void ticked(float dt);
+        virtual void ticked(float dt, uint64_t time);
 
         void loadLevel();
Index: code/branches/gui/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSRoot.cc	(revision 1670)
+++ code/branches/gui/src/orxonox/gamestates/GSRoot.cc	(revision 1672)
@@ -41,4 +41,5 @@
 #include "core/Core.h"
 #include "core/CommandLine.h"
+#include "core/TclThreadManager.h"
 #include "GraphicsEngine.h"
 #include "Settings.h"
@@ -49,8 +50,7 @@
 
     GSRoot::GSRoot()
-        : GameState("root")
+        : RootGameState("root")
         , settings_(0)
         , graphicsEngine_(0)
-        , bExit_(false)
     {
     }
@@ -113,4 +113,5 @@
         // initialise TCL
         TclBind::getInstance().setDataPath(Settings::getDataPath());
+        TclThreadManager::getInstance();
 
         // initialise graphics engine. Doesn't load the render window yet!
@@ -118,13 +119,13 @@
         graphicsEngine_->setup();       // creates ogre root and other essentials
 
-        // console commands
-        FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::loadGame);
-        functor->setObject(this);
-        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "loadGame"));
+        // add console commands
+        FunctorMember<GSRoot>* functor1 = createFunctor(&GSRoot::exitGame);
+        functor1->setObject(this);
+        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "exit"));
 
         // add console commands
-        functor = createFunctor(&GSRoot::exitGame);
-        functor->setObject(this);
-        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "exit"));
+        FunctorMember01<GameState, const std::string&>* functor2 = createFunctor(&GameState::requestState);
+        functor2->setObject(this);
+        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "selectGameState"));
     }
 
@@ -137,16 +138,9 @@
     }
 
-    void GSRoot::ticked(float dt)
+    void GSRoot::ticked(float dt, uint64_t time)
     {
-        this->tickChild(dt);
-    }
+        TclThreadManager::getInstance().tick(dt);
 
-    /**
-    @brief
-        Requests a state.
-    */
-    void GSRoot::loadGame(const std::string& name)
-    {
-        this->requestState(name);
+        this->tickChild(dt, time);
     }
 }
Index: code/branches/gui/src/orxonox/gamestates/GSRoot.h
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSRoot.h	(revision 1670)
+++ code/branches/gui/src/orxonox/gamestates/GSRoot.h	(revision 1672)
@@ -31,9 +31,9 @@
 
 #include "OrxonoxPrereqs.h"
-#include "core/GameState.h"
+#include "core/RootGameState.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSRoot : public GameState
+    class _OrxonoxExport GSRoot : public RootGameState
     {
     public:
@@ -42,20 +42,17 @@
 
         void feedCommandLine(int argc, char** argv);
-        void loadGame(const std::string& name);
 
         void exitGame()
         { requestState("root"); }
-        bool isGameFinished() { return (this->getActiveChild() == 0); }
 
     private:
         void enter();
         void leave();
-        void ticked(float dt);
+        void ticked(float dt, uint64_t time);
 
         Settings*             settings_;
-        GraphicsEngine*       graphicsEngine_;   //!< our dearest graphics engine <3
-        bool                  bExit_;
+        GraphicsEngine*       graphicsEngine_;   //!< Interface to Ogre
     };
 }
 
-#endif /* _GSGraphics_H__ */
+#endif /* _GSRoot_H__ */
Index: code/branches/gui/src/orxonox/gamestates/GSServer.cc
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSServer.cc	(revision 1670)
+++ code/branches/gui/src/orxonox/gamestates/GSServer.cc	(revision 1672)
@@ -83,9 +83,9 @@
     }
 
-    void GSServer::ticked(float dt)
+    void GSServer::ticked(float dt, uint64_t time)
     {
-        GSLevel::ticked(dt);
+        GSLevel::ticked(dt, time);
         server_->tick(dt);
-        this->tickChild(dt);
+        this->tickChild(dt, time);
     }
 }
Index: code/branches/gui/src/orxonox/gamestates/GSServer.h
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSServer.h	(revision 1670)
+++ code/branches/gui/src/orxonox/gamestates/GSServer.h	(revision 1672)
@@ -46,5 +46,5 @@
         void enter();
         void leave();
-        void ticked(float dt);
+        void ticked(float dt, uint64_t time);
 
         network::Server*      server_;
Index: code/branches/gui/src/orxonox/gamestates/GSStandalone.cc
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSStandalone.cc	(revision 1670)
+++ code/branches/gui/src/orxonox/gamestates/GSStandalone.cc	(revision 1672)
@@ -70,9 +70,9 @@
     }
 
-    void GSStandalone::ticked(float dt)
+    void GSStandalone::ticked(float dt, uint64_t time)
     {
-        GSLevel::ticked(dt);
+        GSLevel::ticked(dt, time);
 
-        this->tickChild(dt);
+        this->tickChild(dt, time);
     }
 }
Index: code/branches/gui/src/orxonox/gamestates/GSStandalone.h
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSStandalone.h	(revision 1670)
+++ code/branches/gui/src/orxonox/gamestates/GSStandalone.h	(revision 1672)
@@ -45,5 +45,5 @@
         void enter();
         void leave();
-        void ticked(float dt);
+        void ticked(float dt, uint64_t time);
     };
 }
