Index: /code/branches/resource/src/core/Core.cc
===================================================================
--- /code/branches/resource/src/core/Core.cc	(revision 3348)
+++ /code/branches/resource/src/core/Core.cc	(revision 3349)
@@ -41,4 +41,5 @@
 #include <cstdio>
 #include <boost/filesystem.hpp>
+#include <OgreRenderWindow.h>
 
 #ifdef ORXONOX_PLATFORM_WINDOWS
@@ -69,4 +70,6 @@
 #include "Factory.h"
 #include "GameMode.h"
+#include "GraphicsManager.h"
+#include "GUIManager.h"
 #include "Identifier.h"
 #include "Language.h"
@@ -75,4 +78,5 @@
 #include "TclBind.h"
 #include "TclThreadManager.h"
+#include "input/InputManager.h"
 
 namespace orxonox
@@ -346,4 +350,18 @@
             return;
 
+        // Load OGRE including the render window
+        this->graphicsManager_ = new GraphicsManager();
+
+        // The render window width and height are used to set up the mouse movement.
+        size_t windowHnd = 0;
+        Ogre::RenderWindow* renderWindow = GraphicsManager::getInstance().getRenderWindow();
+        renderWindow->getCustomAttribute("WINDOW", &windowHnd);
+
+        // Calls the InputManager which sets up the input devices.
+        inputManager_ = new InputManager(windowHnd);
+
+        // load the CEGUI interface
+        guiManager_ = new GUIManager(renderWindow);
+
         GameMode::setShowsGraphics(true);
         bGraphicsLoaded_ = true;
@@ -354,4 +372,8 @@
         if (!bGraphicsLoaded_)
             return;
+
+        delete this->guiManager_;
+        delete this->inputManager_;
+        delete graphicsManager_;
 
         bGraphicsLoaded_ = false;
@@ -646,7 +668,48 @@
     }
 
-    void Core::update(const Clock& time)
-    {
-        this->tclThreadManager_->update(time);
+    bool Core::preUpdate(const Clock& time) throw()
+    {
+        std::string exceptionMessage;
+        try
+        {
+            // process input events
+            this->inputManager_->update(time);
+            // process gui events
+            this->guiManager_->update(time);
+            // process thread commands
+            this->tclThreadManager_->update(time);
+        }
+        catch (const std::exception& ex)
+        { exceptionMessage = ex.what(); }
+        catch (...)
+        { exceptionMessage = "Unknown exception"; }
+        if (!exceptionMessage.empty())
+        {
+            COUT(0) << "An exception occurred in the Core preUpdate: " << exceptionMessage << std::endl;
+            COUT(0) << "This should really never happen! Closing the program." << std::endl;
+            return false;
+        }
+        return true;
+    }
+
+    bool Core::postUpdate(const Clock& time) throw()
+    {
+        std::string exceptionMessage;
+        try
+        {
+            // Render (doesn't throw)
+            this->graphicsManager_->update(time);
+        }
+        catch (const std::exception& ex)
+        { exceptionMessage = ex.what(); }
+        catch (...)
+        { exceptionMessage = "Unknown exception"; }
+        if (!exceptionMessage.empty())
+        {
+            COUT(0) << "An exception occurred in the Core postUpdate: " << exceptionMessage << std::endl;
+            COUT(0) << "This should really never happen! Closing the program." << std::endl;
+            return false;
+        }
+        return true;
     }
 }
Index: /code/branches/resource/src/core/Core.h
===================================================================
--- /code/branches/resource/src/core/Core.h	(revision 3348)
+++ /code/branches/resource/src/core/Core.h	(revision 3349)
@@ -71,5 +71,6 @@
             void setConfigValues();
 
-            void update(const Clock& time);
+            bool preUpdate(const Clock& time) throw();
+            bool postUpdate(const Clock& time) throw();
 
             void loadGraphics();
@@ -119,4 +120,8 @@
             TclBind*              tclBind_;
             TclThreadManager*     tclThreadManager_;
+            // graphical
+            InputManager*         inputManager_;        //!< Interface to OIS
+            GUIManager*           guiManager_;          //!< Interface to GUI
+            GraphicsManager*      graphicsManager_;     //!< Interface to OGRE
 
             bool                  bDevRun_;             //!< True for runs in the build directory (not installed)
Index: /code/branches/resource/src/core/Game.cc
===================================================================
--- /code/branches/resource/src/core/Game.cc	(revision 3348)
+++ /code/branches/resource/src/core/Game.cc	(revision 3349)
@@ -245,23 +245,7 @@
             }
 
-            // UPDATE, Core first
-            bool threwException = false;
-            try
-            {
-                this->core_->update(*this->gameClock_);
-            }
-            catch (const std::exception& ex)
-            {
-                threwException = true;
-                COUT(0) << "Exception while ticking the Core: " << ex.what() << std::endl;
-            }
-            catch (...)
-            {
-                threwException = true;
-            }
-            if (threwException)
-            {
-                COUT(0) << "An exception occured while ticking the Core. This should really never happen!" << std::endl;
-                COUT(0) << "Closing the program." << std::endl;
+            // UPDATE, Core preUpdate (doesn't throw)
+            if (!this->core_->preUpdate(*this->gameClock_))
+            {
                 this->stop();
                 break;
@@ -273,27 +257,23 @@
                 it != this->activeStates_.end(); ++it)
             {
-                bool threwException = false;
+                std::string exceptionMessage;
                 try
                 {
                     // Add tick time for most of the states
                     uint64_t timeBeforeTick;
-                    if (!(*it)->ignoreTickTime())
+                    if ((*it)->ignoreTickTime())
                         timeBeforeTick = this->gameClock_->getRealMicroseconds();
                     (*it)->update(*this->gameClock_);
-                    if (!(*it)->ignoreTickTime())
-                        this->addTickTime(static_cast<uint32_t>(this->gameClock_->getRealMicroseconds() - timeBeforeTick));
+                    if ((*it)->ignoreTickTime())
+                        this->subtractTickTime(static_cast<int32_t>(this->gameClock_->getRealMicroseconds() - timeBeforeTick));
                 }
                 catch (const std::exception& ex)
+                { exceptionMessage = ex.what(); }
+                catch (...)
+                { exceptionMessage = "Unknown exception"; }
+                if (!exceptionMessage.empty())
                 {
-                    threwException = true;
-                    COUT(0) << "Exception while ticking: " << ex.what() << std::endl;
-                }
-                catch (...)
-                {
-                    threwException = true;
-                }
-                if (threwException)
-                {
-                    COUT(1) << "An exception occured while ticking GameState '" << (*it)->getName() << "'. This should really never happen!" << std::endl;
+                    COUT(1) << "An exception occurred while updating '" << (*it)->getName() << "': " << exceptionMessage << std::endl;
+                    COUT(1) << "This should really never happen!" << std::endl;
                     COUT(1) << "Unloading all GameStates depending on the one that crashed." << std::endl;
                     if ((*it)->getParent() != NULL)
@@ -304,4 +284,11 @@
                 }
 
+            }
+
+            // UPDATE, Core postUpdate (doesn't throw)
+            if (!this->core_->postUpdate(*this->gameClock_))
+            {
+                this->stop();
+                break;
             }
 
@@ -344,9 +331,9 @@
     }
 
-    void Game::addTickTime(uint32_t length)
+    void Game::subtractTickTime(int32_t length)
     {
         assert(!this->statisticsTickTimes_.empty());
-        this->statisticsTickTimes_.back().tickLength += length;
-        this->periodTickTime_+=length;
+        this->statisticsTickTimes_.back().tickLength -= length;
+        this->periodTickTime_ -= length;
     }
 
Index: /code/branches/resource/src/core/Game.h
===================================================================
--- /code/branches/resource/src/core/Game.h	(revision 3348)
+++ /code/branches/resource/src/core/Game.h	(revision 3349)
@@ -86,5 +86,5 @@
         float getAvgFPS()      { return this->avgFPS_; }
 
-        void addTickTime(uint32_t length);
+        void subtractTickTime(int32_t length);
 
         template <class T>
Index: /code/branches/resource/src/core/GraphicsManager.cc
===================================================================
--- /code/branches/resource/src/core/GraphicsManager.cc	(revision 3348)
+++ /code/branches/resource/src/core/GraphicsManager.cc	(revision 3349)
@@ -196,6 +196,13 @@
         this->renderWindow_->setActive(true);
 
-        // render
+        // Time before rendering
+        uint64_t timeBeforeTick = time.getRealMicroseconds();
+
+        // Render frame
         ogreRoot_->_updateAllRenderTargets();
+
+        uint64_t timeAfterTick = time.getRealMicroseconds();
+        // Subtract the time used for rendering from the tick time counter
+        Game::getInstance().subtractTickTime(timeAfterTick - timeBeforeTick);
 
         // again, just to be sure OGRE works fine
Index: /code/branches/resource/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- /code/branches/resource/src/orxonox/gamestates/GSGraphics.cc	(revision 3348)
+++ /code/branches/resource/src/orxonox/gamestates/GSGraphics.cc	(revision 3349)
@@ -35,7 +35,4 @@
 #include "GSGraphics.h"
 
-#include <boost/filesystem.hpp>
-#include <OgreRenderWindow.h>
-
 #include "util/Convert.h"
 #include "core/Clock.h"
@@ -44,6 +41,4 @@
 #include "core/Core.h"
 #include "core/Game.h"
-#include "core/GameMode.h"
-#include "core/GraphicsManager.h"
 #include "core/GUIManager.h"
 #include "core/input/InputManager.h"
@@ -60,12 +55,9 @@
 namespace orxonox
 {
-    DeclareGameState(GSGraphics, "graphics", true, true);
+    DeclareGameState(GSGraphics, "graphics", false, true);
 
     GSGraphics::GSGraphics(const GameStateConstrParams& params)
         : GameState(params)
-        , inputManager_(0)
         , console_(0)
-        , guiManager_(0)
-        , graphicsManager_(0)
         , soundManager_(0)
         , masterKeyBinder_(0)
@@ -99,20 +91,8 @@
         Core::getInstance().loadGraphics();
 
-        // Load OGRE including the render window
-        this->graphicsManager_ = new GraphicsManager();
-
         // load debug overlay
         COUT(3) << "Loading Debug Overlay..." << std::endl;
-        this->debugOverlay_ = new XMLFile((Core::getMediaPath() / "overlay" / "debug.oxo").string());
+        this->debugOverlay_ = new XMLFile(Core::getMediaPathString() + "overlay/debug.oxo");
         Loader::open(debugOverlay_);
-
-        // The render window width and height are used to set up the mouse movement.
-        size_t windowHnd = 0;
-        Ogre::RenderWindow* renderWindow = GraphicsManager::getInstance().getRenderWindow();
-        renderWindow->getCustomAttribute("WINDOW", &windowHnd);
-
-        // Calls the InputManager which sets up the input devices.
-        inputManager_ = new InputManager(windowHnd);
-
         // load master key bindings
         masterInputState_ = InputManager::getInstance().createInputState("master", true);
@@ -127,7 +107,4 @@
         console_ = new InGameConsole();
         console_->initialise();
-
-        // load the CEGUI interface
-        guiManager_ = new GUIManager(renderWindow);
 
         // add console command to toggle GUI
@@ -161,5 +138,4 @@
         delete this->masterKeyBinder_;
 
-        delete this->guiManager_;
         delete this->console_;
 
@@ -169,11 +145,6 @@
         delete this->soundManager_;
 
-        delete this->inputManager_;
-        this->inputManager_ = 0;
-
-        // HACK:
+        // HACK: (destroys a resource smart pointer)
         Map::hackDestroyMap();
-
-        delete graphicsManager_;
 
         // Unload OGRE, CEGUI and OIS
@@ -210,18 +181,5 @@
         }
 
-        uint64_t timeBeforeTick = time.getRealMicroseconds();
-
-        this->inputManager_->update(time);
         this->console_->update(time);
-
-        uint64_t timeAfterTick = time.getRealMicroseconds();
-
-        // Also add our tick time
-        Game::getInstance().addTickTime(timeAfterTick - timeBeforeTick);
-
-        // Process gui events
-        this->guiManager_->update(time);
-        // Render
-        this->graphicsManager_->update(time);
     }
 }
Index: /code/branches/resource/src/orxonox/gamestates/GSGraphics.h
===================================================================
--- /code/branches/resource/src/orxonox/gamestates/GSGraphics.h	(revision 3348)
+++ /code/branches/resource/src/orxonox/gamestates/GSGraphics.h	(revision 3349)
@@ -61,8 +61,5 @@
     private:
         // managed singletons
-        InputManager*         inputManager_;        //!< Reference to input management
         InGameConsole*        console_;
-        GUIManager*           guiManager_;          //!< Interface to GUI
-        GraphicsManager*      graphicsManager_;     //!< Interface to Ogre
         SoundManager*         soundManager_;        //!< Keeps track of SoundBase objects
 
Index: /code/branches/resource/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- /code/branches/resource/src/orxonox/gamestates/GSRoot.cc	(revision 3348)
+++ /code/branches/resource/src/orxonox/gamestates/GSRoot.cc	(revision 3349)
@@ -45,5 +45,5 @@
 namespace orxonox
 {
-    DeclareGameState(GSRoot, "root", true, false);
+    DeclareGameState(GSRoot, "root", false, false);
     SetCommandLineSwitch(console).information("Start in console mode (text IO only)");
     // Shortcuts for easy direct loading
@@ -155,6 +155,4 @@
         }
 
-        uint64_t timeBeforeTick = time.getRealMicroseconds();
-
         for (ObjectList<TimerBase>::iterator it = ObjectList<TimerBase>::begin(); it; ++it)
             it->tick(time);
@@ -171,9 +169,4 @@
             it->tick(leveldt * this->timeFactor_);
         /*** HACK *** HACK ***/
-
-        uint64_t timeAfterTick = time.getRealMicroseconds();
-
-        // Also add our tick time
-        Game::getInstance().addTickTime(timeAfterTick - timeBeforeTick);
     }
 
Index: /code/branches/resource/src/orxonox/objects/quest/QuestListener.cc
===================================================================
--- /code/branches/resource/src/orxonox/objects/quest/QuestListener.cc	(revision 3348)
+++ /code/branches/resource/src/orxonox/objects/quest/QuestListener.cc	(revision 3349)
@@ -81,5 +81,5 @@
     /**
     @brief
-        Makes all QuestListener in the list aware that a certain status change has occured and executes them if the status change affects them.
+        Makes all QuestListener in the list aware that a certain status change has occurred and executes them if the status change affects them.
     @param listeners
         The list of QuestListeners that have to be made aware of the status change.
@@ -182,5 +182,5 @@
         else
         {
-            COUT(1) << "An unforseen, never to happen, Error has occured. This is impossible!" << std::endl;
+            COUT(1) << "An unforseen, never to happen, Error has occurred. This is impossible!" << std::endl;
         return "";
         }
Index: /code/branches/resource/src/orxonox/objects/quest/QuestManager.cc
===================================================================
--- /code/branches/resource/src/orxonox/objects/quest/QuestManager.cc	(revision 3348)
+++ /code/branches/resource/src/orxonox/objects/quest/QuestManager.cc	(revision 3349)
@@ -323,5 +323,5 @@
         {
             container->status = "";
-            COUT(1) << "An error occured. A Quest of un-specified status wanted to be displayed." << std::endl;
+            COUT(1) << "An error occurred. A Quest of un-specified status wanted to be displayed." << std::endl;
         }
         
