Index: code/branches/questsystem5/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/questsystem5/src/orxonox/CMakeLists.txt	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/CMakeLists.txt	(revision 2908)
@@ -20,5 +20,5 @@
 SET_SOURCE_FILES(ORXONOX_SRC_FILES
   CameraManager.cc
-  GraphicsManager.cc
+  GraphicsEngine.cc
   LevelManager.cc
   Main.cc
Index: code/branches/questsystem5/src/orxonox/CameraManager.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/CameraManager.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/CameraManager.cc	(revision 2908)
@@ -35,5 +35,5 @@
 #include <OgreResource.h>
 
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "core/Iterator.h"
 #include "objects/worldentities/Camera.h"
@@ -41,5 +41,4 @@
 #include "tools/Shader.h"
 #include "util/String.h"
-#include "gui/GUIManager.h"
 
 namespace orxonox
@@ -75,5 +74,5 @@
     void CameraManager::requestFocus(Camera* camera)
     {
-        if (!GameMode::showsGraphics())
+        if (!Core::showsGraphics())
             return;
 
@@ -100,5 +99,5 @@
     void CameraManager::releaseFocus(Camera* camera)
     {
-        if (!GameMode::showsGraphics())
+        if (!Core::showsGraphics())
             return;
 
@@ -142,5 +141,4 @@
 
         this->viewport_->setCamera(camera);
-        GUIManager::getInstance().setCamera(camera);
 
         // reactivate all visible compositors
Index: code/branches/questsystem5/src/orxonox/GraphicsEngine.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/GraphicsEngine.cc	(revision 2908)
+++ code/branches/questsystem5/src/orxonox/GraphicsEngine.cc	(revision 2908)
@@ -0,0 +1,106 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
+ *   Co-authors:
+ *      Felix Schulthess
+ *
+ */
+
+/**
+@file
+@brief
+    Implementation of an partial interface to Ogre.
+*/
+
+#include "OrxonoxStableHeaders.h"
+#include "GraphicsEngine.h"
+
+#include <OgreRenderWindow.h>
+
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "util/Debug.h"
+
+#include "tools/ParticleInterface.h"
+
+namespace orxonox
+{
+    //SetConsoleCommand(GraphicsEngine, printScreen, true).setKeybindMode(KeybindMode::OnPress);
+
+    GraphicsEngine* GraphicsEngine::singletonRef_s = 0;
+
+    /**
+    @brief
+        Returns the singleton instance.
+    @return
+        The only instance of GraphicsEngine.
+    */
+    /*static*/ GraphicsEngine& GraphicsEngine::getInstance()
+    {
+        assert(singletonRef_s);
+        return *singletonRef_s;
+    }
+
+    /**
+    @brief
+        Non-initialising constructor.
+    */
+    GraphicsEngine::GraphicsEngine()
+//        : root_(0)
+//        , renderWindow_(0)
+//        , viewport_(0)
+    {
+        RegisterObject(GraphicsEngine);
+
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+
+        this->viewport_ = 0;
+
+        this->detailLevelParticle_ = 0;
+
+        this->setConfigValues();
+        CCOUT(4) << "Constructed" << std::endl;
+    }
+
+    void GraphicsEngine::setConfigValues()
+    {
+        SetConfigValue(detailLevelParticle_, 2).description("O: off, 1: low, 2: normal, 3: high").callback(this, &GraphicsEngine::detailLevelParticleChanged);
+    }
+
+    void GraphicsEngine::detailLevelParticleChanged()
+    {
+        for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it)
+            it->detailLevelChanged(this->detailLevelParticle_);
+    }
+
+    /**
+    @brief
+        Destroys all the Ogre related objects
+    */
+    GraphicsEngine::~GraphicsEngine()
+    {
+        singletonRef_s = 0;
+    }
+}
Index: code/branches/questsystem5/src/orxonox/GraphicsEngine.h
===================================================================
--- code/branches/questsystem5/src/orxonox/GraphicsEngine.h	(revision 2908)
+++ code/branches/questsystem5/src/orxonox/GraphicsEngine.h	(revision 2908)
@@ -0,0 +1,96 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
+ *   Co-authors:
+ *      Felix Schulthess
+ *
+ */
+
+/**
+  @file
+  @brief Declaration of GraphicsEngine Singleton.
+  @author Benjamin Knecht <beni_at_orxonox.net>
+ */
+
+#ifndef _GraphicsEngine_H__
+#define _GraphicsEngine_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+
+#include <OgrePrerequisites.h>
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+    /**
+    @brief Graphics engine manager class
+    */
+    class _OrxonoxExport GraphicsEngine : public OrxonoxClass
+    {
+        // HACK: temporary means
+        friend class GSGraphics;
+
+    public:
+        GraphicsEngine();
+        ~GraphicsEngine();
+
+        void setConfigValues();
+        void detailLevelParticleChanged();
+
+        float getAverageFramesPerSecond() const   { return this->avgFramesPerSecond_; }
+        float getAverageTickTime() const          { return this->avgTickTime_; }
+        void setAverageTickTime(float tickTime)   { this->avgTickTime_ = tickTime; }
+        void setAverageFramesPerSecond(float fps) { this->avgFramesPerSecond_ = fps; }
+
+        inline unsigned int getDetailLevelParticle() const
+        { return this->detailLevelParticle_; }
+
+        static GraphicsEngine& getInstance();
+        static GraphicsEngine* getInstancePtr() { return singletonRef_s; }
+
+        inline void setViewport(Ogre::Viewport* viewport)
+            { this->viewport_ = viewport; }
+        inline Ogre::Viewport* getViewport() const
+            { return this->viewport_; }
+
+    private:
+        // don't mess with singletons
+        GraphicsEngine(GraphicsEngine&);
+
+        Ogre::Viewport*     viewport_;              //!< default full size viewport
+
+        // stats
+        float               avgTickTime_;           //!< time in ms to tick() one frame
+        float               avgFramesPerSecond_;    //!< number of frames processed in one second
+
+        // config values
+        unsigned int        detailLevelParticle_;   //!< Detail level of particle effects (0: off, 1: low, 2: normal, 3: high)
+
+        static GraphicsEngine* singletonRef_s;      //!< Pointer to the Singleton
+    };
+}
+
+#endif /* _GraphicsEngine_H__ */
Index: code/branches/questsystem5/src/orxonox/GraphicsManager.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/GraphicsManager.cc	(revision 2907)
+++ 	(revision )
@@ -1,444 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
- *   Co-authors:
- *      Felix Schulthess
- *
- */
-
-/**
-@file
-@brief
-    Implementation of an partial interface to Ogre.
-*/
-
-#include "OrxonoxStableHeaders.h"
-#include "GraphicsManager.h"
-
-#include <fstream>
-#include <boost/filesystem.hpp>
-
-#include <OgreCompositorManager.h>
-#include <OgreConfigFile.h>
-#include <OgreFrameListener.h>
-#include <OgreRoot.h>
-#include <OgreLogManager.h>
-#include <OgreException.h>
-#include <OgreRenderWindow.h>
-#include <OgreRenderSystem.h>
-#include <OgreTextureManager.h>
-#include <OgreViewport.h>
-#include <OgreWindowEventUtilities.h>
-
-#include "SpecialConfig.h"
-#include "util/Debug.h"
-#include "util/Exception.h"
-#include "util/String.h"
-#include "util/SubString.h"
-#include "core/Clock.h"
-#include "core/ConsoleCommand.h"
-#include "core/ConfigValueIncludes.h"
-#include "core/CoreIncludes.h"
-#include "core/Core.h"
-#include "core/GameMode.h"
-#include "tools/WindowEventListener.h"
-#include "tools/ParticleInterface.h"
-
-namespace orxonox
-{
-    class _OrxonoxExport OgreWindowEventListener : public Ogre::WindowEventListener
-    {
-        void windowResized     (Ogre::RenderWindow* rw);
-        void windowFocusChange (Ogre::RenderWindow* rw);
-        void windowClosed      (Ogre::RenderWindow* rw);
-        //void windowMoved       (Ogre::RenderWindow* rw);
-    };
-
-    GraphicsManager* GraphicsManager::singletonRef_s = 0;
-
-    /**
-    @brief
-        Non-initialising constructor.
-    */
-    GraphicsManager::GraphicsManager()
-        : ogreRoot_(0)
-        , ogreLogger_(0)
-        , renderWindow_(0)
-        , viewport_(0)
-        , ogreWindowEventListener_(0)
-        , avgTickTime_(0.0f)
-        , avgFramesPerSecond_(0.0f)
-    {
-        RegisterObject(GraphicsManager);
-
-        assert(singletonRef_s == 0);
-        singletonRef_s = this;
-
-        this->loaded_ = false;
-
-        this->setConfigValues();
-    }
-
-    void GraphicsManager::initialise()
-    {
-        // Ogre setup procedure
-        setupOgre();
-        // load all the required plugins for Ogre
-        loadOgrePlugins();
-        // read resource declaration file
-        this->declareResources();
-        // Reads ogre config and creates the render window
-        this->loadRenderer();
-
-        // TODO: Spread this
-        this->initialiseResources();
-
-        // add console commands
-        FunctorMember<GraphicsManager>* functor1 = createFunctor(&GraphicsManager::printScreen);
-        functor1->setObject(this);
-        ccPrintScreen_ = createConsoleCommand(functor1, "printScreen");
-        CommandExecutor::addConsoleCommandShortcut(ccPrintScreen_);
-
-        this->loaded_ = true;
-    }
-
-    /**
-    @brief
-        Destroys all the Ogre related objects
-    */
-    GraphicsManager::~GraphicsManager()
-    {
-        if (this->loaded_)
-        {
-            delete this->ccPrintScreen_;
-
-            if (this->ogreWindowEventListener_)
-            {
-                // remove our WindowEventListener first to avoid bad calls after the window has been destroyed
-                Ogre::WindowEventUtilities::removeWindowEventListener(this->renderWindow_, this->ogreWindowEventListener_);
-                delete this->ogreWindowEventListener_;
-            }
-
-            // unload all compositors
-            Ogre::CompositorManager::getSingleton().removeAll();
-
-            // destroy render window
-            Ogre::RenderSystem* renderer = this->ogreRoot_->getRenderSystem();
-            renderer->destroyRenderWindow("Orxonox");
-
-            // Delete OGRE main control organ
-            delete this->ogreRoot_;
-
-            // delete the ogre log and the logManager (since we have created it in the first place).
-            this->ogreLogger_->getDefaultLog()->removeListener(this);
-            this->ogreLogger_->destroyLog(Ogre::LogManager::getSingleton().getDefaultLog());
-            delete this->ogreLogger_;
-        }
-
-        assert(singletonRef_s);
-        singletonRef_s = 0;
-    }
-
-    void GraphicsManager::setConfigValues()
-    {
-        SetConfigValue(resourceFile_,    "resources.cfg")
-            .description("Location of the resources file in the data path.");
-        SetConfigValue(ogreConfigFile_,  "ogre.cfg")
-            .description("Location of the Ogre config file");
-        SetConfigValue(ogrePluginsFolder_, ORXONOX_OGRE_PLUGINS_FOLDER)
-            .description("Folder where the Ogre plugins are located.");
-        SetConfigValue(ogrePlugins_, ORXONOX_OGRE_PLUGINS)
-            .description("Comma separated list of all plugins to load.");
-        SetConfigValue(ogreLogFile_,     "ogre.log")
-            .description("Logfile for messages from Ogre. Use \"\" to suppress log file creation.");
-        SetConfigValue(ogreLogLevelTrivial_ , 5)
-            .description("Corresponding orxonox debug level for ogre Trivial");
-        SetConfigValue(ogreLogLevelNormal_  , 4)
-            .description("Corresponding orxonox debug level for ogre Normal");
-        SetConfigValue(ogreLogLevelCritical_, 2)
-            .description("Corresponding orxonox debug level for ogre Critical");
-        SetConfigValue(detailLevelParticle_, 2)
-            .description("O: off, 1: low, 2: normal, 3: high").callback(this, &GraphicsManager::detailLevelParticleChanged);
-    }
-
-    void GraphicsManager::detailLevelParticleChanged()
-    {
-        for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it)
-            it->detailLevelChanged(this->detailLevelParticle_);
-    }
-
-    void GraphicsManager::update(const Clock& time)
-    {
-        if (this->loaded_)
-        {
-            Ogre::FrameEvent evt;
-            evt.timeSinceLastFrame = time.getDeltaTime();
-            evt.timeSinceLastEvent = time.getDeltaTime(); // note: same time, but shouldn't matter anyway
-
-            // don't forget to call _fireFrameStarted to OGRE to make sure
-            // everything goes smoothly
-            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)
-            this->renderWindow_->setActive(true);
-
-            // render
-            ogreRoot_->_updateAllRenderTargets();
-
-            // again, just to be sure OGRE works fine
-            ogreRoot_->_fireFrameEnded(evt); // note: uses the same time as _fireFrameStarted
-        }
-    }
-
-    void GraphicsManager::setCamera(Ogre::Camera* camera)
-    {
-        this->viewport_->setCamera(camera);
-    }
-
-    /**
-    @brief
-        Creates the Ogre Root object and sets up the ogre log.
-    */
-    void GraphicsManager::setupOgre()
-    {
-        COUT(3) << "Setting up Ogre..." << std::endl;
-
-        if (ogreConfigFile_ == "")
-        {
-            COUT(2) << "Warning: Ogre config file set to \"\". Defaulting to config.cfg" << std::endl;
-            ModifyConfigValue(ogreConfigFile_, tset, "config.cfg");
-        }
-        if (ogreLogFile_ == "")
-        {
-            COUT(2) << "Warning: Ogre log file set to \"\". Defaulting to ogre.log" << std::endl;
-            ModifyConfigValue(ogreLogFile_, tset, "ogre.log");
-        }
-
-        boost::filesystem::path ogreConfigFilepath(Core::getConfigPath() / this->ogreConfigFile_);
-        boost::filesystem::path ogreLogFilepath(Core::getLogPath() / this->ogreLogFile_);
-
-        // create a new logManager
-        // Ogre::Root will detect that we've already created a Log
-        ogreLogger_ = new Ogre::LogManager();
-        COUT(4) << "Ogre LogManager created" << std::endl;
-
-        // create our own log that we can listen to
-        Ogre::Log *myLog;
-        myLog = ogreLogger_->createLog(ogreLogFilepath.string(), true, false, false);
-        COUT(4) << "Ogre Log created" << std::endl;
-
-        myLog->setLogDetail(Ogre::LL_BOREME);
-        myLog->addListener(this);
-
-        COUT(4) << "Creating Ogre Root..." << std::endl;
-
-        // check for config file existence because Ogre displays (caught) exceptions if not
-        if (!boost::filesystem::exists(ogreConfigFilepath))
-        {
-            // create a zero sized file
-            std::ofstream creator;
-            creator.open(ogreConfigFilepath.string().c_str());
-            creator.close();
-        }
-
-        // Leave plugins file empty. We're going to do that part manually later
-        ogreRoot_ = new Ogre::Root("", ogreConfigFilepath.string(), ogreLogFilepath.string());
-
-        COUT(3) << "Ogre set up done." << std::endl;
-    }
-
-    void GraphicsManager::loadOgrePlugins()
-    {
-        // just to make sure the next statement doesn't segfault
-        if (ogrePluginsFolder_ == "")
-            ogrePluginsFolder_ = ".";
-
-        boost::filesystem::path folder(ogrePluginsFolder_);
-        // Do some SubString magic to get the comma separated list of plugins
-        SubString plugins(ogrePlugins_, ",", " ", false, 92, false, 34, false, 40, 41, false, '\0');
-        // Use backslash paths on Windows! file_string() already does that though.
-        for (unsigned int i = 0; i < plugins.size(); ++i)
-            ogreRoot_->loadPlugin((folder / plugins[i]).file_string());
-    }
-
-    void GraphicsManager::declareResources()
-    {
-        CCOUT(4) << "Declaring Resources" << std::endl;
-        //TODO: Specify layout of data file and maybe use xml-loader
-        //TODO: Work with ressource groups (should be generated by a special loader)
-
-        if (resourceFile_ == "")
-        {
-            COUT(2) << "Warning: Ogre resource file set to \"\". Defaulting to resources.cfg" << std::endl;
-            ModifyConfigValue(resourceFile_, tset, "resources.cfg");
-        }
-
-        // Load resource paths from data file using configfile ressource type
-        Ogre::ConfigFile cf;
-        try
-        {
-            cf.load((Core::getMediaPath() / resourceFile_).string());
-        }
-        catch (...)
-        {
-            //COUT(1) << ex.getFullDescription() << std::endl;
-            COUT(0) << "Have you forgotten to set the data path in orxnox.ini?" << std::endl;
-            throw;
-        }
-
-        // Go through all sections & settings in the file
-        Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
-
-        std::string secName, typeName, archName;
-        while (seci.hasMoreElements())
-        {
-            try
-            {
-                secName = seci.peekNextKey();
-                Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
-                Ogre::ConfigFile::SettingsMultiMap::iterator i;
-                for (i = settings->begin(); i != settings->end(); ++i)
-                {
-                    typeName = i->first; // for instance "FileSystem" or "Zip"
-                    archName = i->second; // name (and location) of archive
-
-                    Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
-                        (Core::getMediaPath() / archName).string(), typeName, secName);
-                }
-            }
-            catch (Ogre::Exception& ex)
-            {
-                COUT(1) << ex.getFullDescription() << std::endl;
-            }
-        }
-    }
-
-    void GraphicsManager::loadRenderer()
-    {
-        CCOUT(4) << "Configuring Renderer" << std::endl;
-
-        if (!ogreRoot_->restoreConfig())
-            if (!ogreRoot_->showConfigDialog())
-                ThrowException(InitialisationFailed, "Could not show Ogre configuration dialogue.");
-
-        CCOUT(4) << "Creating render window" << std::endl;
-
-        this->renderWindow_ = ogreRoot_->initialise(true, "Orxonox");
-
-        this->ogreWindowEventListener_ = new OgreWindowEventListener();
-        Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, ogreWindowEventListener_);
-
-        Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(0);
-
-        // create a full screen default viewport
-        this->viewport_ = this->renderWindow_->addViewport(0, 0);
-    }
-
-    void GraphicsManager::initialiseResources()
-    {
-        CCOUT(4) << "Initialising resources" << std::endl;
-        //TODO: Do NOT load all the groups, why are we doing that? And do we really do that? initialise != load...
-        //try
-        //{
-            Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
-            /*Ogre::StringVector str = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
-            for (unsigned int i = 0; i < str.size(); i++)
-            {
-            Ogre::ResourceGroupManager::getSingleton().loadResourceGroup(str[i]);
-            }*/
-        //}
-        //catch (...)
-        //{
-        //    CCOUT(2) << "Error: There was a serious error when initialising the resources." << std::endl;
-        //    throw;
-        //}
-    }
-
-    /**
-    @brief
-        Method called by the LogListener interface from Ogre.
-        We use it to capture Ogre log messages and handle it ourselves.
-    @param message
-        The message to be logged
-    @param lml
-        The message level the log is using
-    @param maskDebug
-        If we are printing to the console or not
-    @param logName
-        The name of this log (so you can have several listeners
-        for different logs, and identify them)
-    */
-    void GraphicsManager::messageLogged(const std::string& message,
-        Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName)
-    {
-        int orxonoxLevel;
-        switch (lml)
-        {
-        case Ogre::LML_TRIVIAL:
-            orxonoxLevel = this->ogreLogLevelTrivial_;
-            break;
-        case Ogre::LML_NORMAL:
-            orxonoxLevel = this->ogreLogLevelNormal_;
-            break;
-        case Ogre::LML_CRITICAL:
-            orxonoxLevel = this->ogreLogLevelCritical_;
-            break;
-        default:
-            orxonoxLevel = 0;
-        }
-        OutputHandler::getOutStream().setOutputLevel(orxonoxLevel)
-            << "Ogre: " << message << std::endl;
-    }
-
-    void GraphicsManager::printScreen()
-    {
-        assert(this->renderWindow_);
-       
-        this->renderWindow_->writeContentsToTimestampedFile(Core::getLogPathString() + "screenShot_", ".jpg");
-    }
-
-
-    /****** OgreWindowEventListener ******/
-
-    void OgreWindowEventListener::windowResized(Ogre::RenderWindow* rw)
-    {
-        for (ObjectList<orxonox::WindowEventListener>::iterator it
-            = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
-            it->windowResized(rw->getWidth(), rw->getHeight());
-    }
-    void OgreWindowEventListener::windowFocusChange(Ogre::RenderWindow* rw)
-    {
-        for (ObjectList<orxonox::WindowEventListener>::iterator it
-            = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
-            it->windowFocusChanged();
-    }
-    void OgreWindowEventListener::windowClosed(Ogre::RenderWindow* rw)
-    {
-        // TODO: Notify the right class to shut down the Game
-    }
-}
Index: code/branches/questsystem5/src/orxonox/GraphicsManager.h
===================================================================
--- code/branches/questsystem5/src/orxonox/GraphicsManager.h	(revision 2907)
+++ 	(revision )
@@ -1,125 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
- *   Co-authors:
- *      Felix Schulthess
- *
- */
-
-/**
-@file
-@brief
-    Declaration of GraphicsManager Singleton.
- */
-
-#ifndef _GraphicsManager_H__
-#define _GraphicsManager_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include <string>
-#include <cassert>
-#include <OgreLog.h>
-
-#include "core/OrxonoxClass.h"
-
-namespace orxonox
-{
-    /**
-    @brief
-        Graphics engine manager class
-    */
-    class _OrxonoxExport GraphicsManager : public OrxonoxClass, public Ogre::LogListener
-    {
-    public:
-        GraphicsManager();
-        ~GraphicsManager();
-
-        void setConfigValues();
-        void initialise();
-
-        void update(const Clock& time);
-
-        void detailLevelParticleChanged();
-        inline unsigned int getDetailLevelParticle() const
-            { return this->detailLevelParticle_; }
-
-        inline Ogre::Viewport* getViewport() const
-            { return this->viewport_; }
-        inline Ogre::RenderWindow* getRenderWindow()
-            { return this->renderWindow_; }
-
-        void setCamera(Ogre::Camera* camera);
-
-        static GraphicsManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
-
-    private:
-        GraphicsManager(GraphicsManager&); // don't mess with singletons
-
-        // OGRE initialisation
-        void setupOgre();
-        void loadOgrePlugins();
-        void declareResources();
-        void loadRenderer();
-        void initialiseResources();
-
-        // event from Ogre::LogListener
-        void messageLogged(const std::string& message, Ogre::LogMessageLevel lml,
-            bool maskDebug, const std::string& logName);
-
-        // console commands
-        void printScreen();
-
-    private:
-        bool                loaded_;
-
-        Ogre::Root*         ogreRoot_;                 //!< Ogre's root
-        Ogre::LogManager*   ogreLogger_;
-        Ogre::RenderWindow* renderWindow_;             //!< the one and only render window
-        Ogre::Viewport*     viewport_;                 //!< default full size viewport
-        OgreWindowEventListener* ogreWindowEventListener_;
-
-        // stats (Hack)
-        float               avgTickTime_;              //!< time in ms to tick() one frame
-        float               avgFramesPerSecond_;       //!< number of frames processed in one second
-
-        // config values
-        unsigned int        detailLevelParticle_;      //!< Detail level of particle effects (0: off, 1: low, 2: normal, 3: high)
-        std::string         resourceFile_;             //!< resources file name
-        std::string         ogreConfigFile_;           //!< ogre config file name
-        std::string         ogrePluginsFolder_;        //!< Folder where the Ogre plugins are located
-        std::string         ogrePlugins_;              //!< Comma separated list of all plugins to load
-        std::string         ogreLogFile_;              //!< log file name for Ogre log messages
-        int                 ogreLogLevelTrivial_;      //!< Corresponding Orxonx debug level for LL_TRIVIAL
-        int                 ogreLogLevelNormal_;       //!< Corresponding Orxonx debug level for LL_NORMAL
-        int                 ogreLogLevelCritical_;     //!< Corresponding Orxonx debug level for LL_CRITICAL
-
-        // console commands
-        ConsoleCommand*     ccPrintScreen_;
-
-        static GraphicsManager* singletonRef_s;        //!< Pointer to the Singleton
-    };
-}
-
-#endif /* _GraphicsManager_H__ */
Index: code/branches/questsystem5/src/orxonox/Main.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/Main.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/Main.cc	(revision 2908)
@@ -27,8 +27,4 @@
  *
  */
- 
- /**
- @mainpage Orxonox Documentation
- */
 
  /**
@@ -38,40 +34,124 @@
 
 #include "OrxonoxStableHeaders.h"
+
+#include <exception>
+#include <cassert>
+
 #include "OrxonoxConfig.h"
+#include "util/Debug.h"
+#include "util/SignalHandler.h"
+#include "core/ConfigFileManager.h"
+#include "core/CommandLine.h"
+#include "core/CommandExecutor.h"
+#include "core/Identifier.h"
+#include "core/Core.h"
+#include "core/Language.h"
 
-#include "util/Debug.h"
-#include "core/Identifier.h"
-#include "core/Game.h"
+#include "gamestates/GSRoot.h"
+#include "gamestates/GSGraphics.h"
+#include "gamestates/GSStandalone.h"
+#include "gamestates/GSServer.h"
+#include "gamestates/GSClient.h"
+#include "gamestates/GSDedicated.h"
+#include "gamestates/GSGUI.h"
+#include "gamestates/GSIOConsole.h"
 
-/*
-@brief
-    Main method. Game starts here (except for static initialisations).
-*/
+#ifdef ORXONOX_PLATFORM_APPLE
+#include <CoreFoundation/CoreFoundation.h>
+
+// This function will locate the path to our application on OS X,
+// unlike windows you can not rely on the curent working directory
+// for locating your configuration files and resources.
+             std::string macBundlePath()
+{
+    char path[1024];
+    CFBundleRef mainBundle = CFBundleGetMainBundle();
+    assert(mainBundle);
+
+    CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
+    assert(mainBundleURL);
+
+    CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);
+    assert(cfStringRef);
+
+    CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);
+
+    CFRelease(mainBundleURL);
+    CFRelease(cfStringRef);
+
+    return std::string(path);
+}
+#endif
+
+
+SetCommandLineArgument(settingsFile, "orxonox.ini");
+SetCommandLineArgument(configFileDirectory, "");
+
 int main(int argc, char** argv)
 {
+    using namespace orxonox;
+
+    // Parse command line arguments
+    try
     {
-        orxonox::Game orxonox(argc, argv);
+        CommandLine::parseAll(argc, argv);
+    }
+    catch (ArgumentException& ex)
+    {
+        COUT(1) << ex.what() << std::endl;
+        COUT(0) << "Usage:" << std::endl << "orxonox " << CommandLine::getUsageInformation() << std::endl;
+    }
 
-        orxonox.setStateHierarchy(
-        "root"
-        " graphics"
-        "  mainMenu"
-        "  standalone"
-        "   level"
-        "  server"
-        "   level"
-        "  client"
-        "   level"
-        " dedicated"
-        "  level"
-        " ioConsole"
-        );
+    // Do this after parsing the command line to allow customisation
+    Core::postMainInitialisation();
 
-        orxonox.run();
-    } // orxonox gets destroyed right here!
+    // create a signal handler (only active for linux)
+    SignalHandler signalHandler;
+    signalHandler.doCatch(argv[0], Core::getLogPathString() + "orxonox_crash.log");
+
+    // Create the ConfigFileManager before creating the GameStates in order to have
+    // setConfigValues() in the constructor (required).
+    ConfigFileManager* configFileManager = new ConfigFileManager();
+    configFileManager->setFilename(ConfigFileType::Settings, CommandLine::getValue("settingsFile").getString());
+    // create the Core settings to configure the output level
+    Language* language = new Language();
+    Core*     core     = new Core();
+
+    // put GameStates in its own scope so we can destroy the identifiers at the end of main().
+    {
+        // create the gamestates
+        GSRoot root;
+        GSGraphics graphics;
+        GSStandalone standalone;
+        GSServer server;
+        GSClient client;
+        GSDedicated dedicated;
+        GSGUI gui;
+        GSIOConsole ioConsole;
+
+        // make the hierarchy
+        root.addChild(&graphics);
+        graphics.addChild(&standalone);
+        graphics.addChild(&server);
+        graphics.addChild(&client);
+        graphics.addChild(&gui);
+        root.addChild(&ioConsole);
+        root.addChild(&dedicated);
+
+        // Here happens the game
+        root.start();
+    }
+
+    // destroy singletons
+    delete core;
+    delete language;
+    delete configFileManager;
 
     // Clean up class hierarchy stuff (identifiers, xmlport, configvalue, consolecommand)
-    // Needs to be done after Game destructor because of ~OrxonoxClass
-    orxonox::Identifier::destroyAllIdentifiers();
+    Identifier::destroyAllIdentifiers();
+    // destroy command line arguments
+    CommandLine::destroyAllArguments();
+    // Also delete external console command that don't belong to an Identifier
+    CommandExecutor::destroyExternalCommands();
 
     return 0;
Index: code/branches/questsystem5/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/branches/questsystem5/src/orxonox/OrxonoxPrereqs.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/OrxonoxPrereqs.h	(revision 2908)
@@ -77,4 +77,7 @@
     namespace MunitionType
     {
+
+
+
         enum Enum
         { laserGunMunition };
@@ -94,6 +97,5 @@
 
 
-    class GraphicsManager;
-    class OgreWindowEventListener;
+    class GraphicsEngine;
     class Settings;
 
@@ -101,6 +103,4 @@
     class Radar;
     class RadarListener;
-
-    class Teamcolourable;
 
     class CameraManager;
@@ -150,12 +150,7 @@
     class ParticleSpawner;
 
-    class PongCenterpoint;
-    class PongBall;
-    class PongBat;
-
     class Camera;
     class CameraPosition;
     class SpawnPoint;
-    class TeamSpawnPoint;
 
     class Spectator;
@@ -181,5 +176,4 @@
     class LaserGun;
     class LaserGunMunition;
-    class FusionMunition;
 
     class EventListener;
@@ -192,5 +186,4 @@
     class AIController;
     class ScriptController;
-    class PongAI;
 
     class Info;
@@ -198,11 +191,7 @@
     class HumanPlayer;
     class Bot;
-    class PongBot;
     class GametypeInfo;
 
     class Gametype;
-    class Deathmatch;
-    class TeamDeathmatch;
-    class Pong;
 
     class Scores;
@@ -250,4 +239,15 @@
     //gui
     class GUIManager;
+
+    // game states
+    class GSRoot;
+    class GSGraphics;
+    class GSIO;
+    class GSIOConsole;
+    class GSLevel;
+    class GSStandalone;
+    class GSServer;
+    class GSClient;
+    class GSGUI;
 }
 
Index: code/branches/questsystem5/src/orxonox/PlayerManager.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/PlayerManager.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/PlayerManager.cc	(revision 2908)
@@ -31,5 +31,5 @@
 
 #include "LevelManager.h"
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "core/CoreIncludes.h"
 #include "objects/Level.h"
@@ -58,5 +58,5 @@
     void PlayerManager::clientConnected(unsigned int clientID)
     {
-        if (GameMode::isMaster())
+        if (Core::isMaster())
         {
             COUT(3) << "client connected" << std::endl;
@@ -77,5 +77,5 @@
     void PlayerManager::clientDisconnected(unsigned int clientID)
     {
-        if (GameMode::isMaster())
+        if (Core::isMaster())
         {
             COUT(3) << "client disconnected" << std::endl;
@@ -97,5 +97,5 @@
     PlayerInfo* PlayerManager::getClient(unsigned int clientID) const
     {
-        if (GameMode::isMaster())
+        if (Core::isMaster())
         {
             std::map<unsigned int, PlayerInfo*>::const_iterator it = this->clients_.find(clientID);
Index: code/branches/questsystem5/src/orxonox/gamestates/CMakeLists.txt
===================================================================
--- code/branches/questsystem5/src/orxonox/gamestates/CMakeLists.txt	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/gamestates/CMakeLists.txt	(revision 2908)
@@ -1,9 +1,9 @@
 ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+  GSDedicated.cc
   GSClient.cc
-  GSDedicated.cc
   GSGraphics.cc
+  GSGUI.cc
   GSIOConsole.cc
   GSLevel.cc
-  GSMainMenu.cc
   GSRoot.cc
   GSServer.cc
Index: code/branches/questsystem5/src/orxonox/gamestates/GSClient.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/gamestates/GSClient.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/gamestates/GSClient.cc	(revision 2908)
@@ -31,18 +31,14 @@
 
 #include "core/input/InputManager.h"
-#include "core/Clock.h"
 #include "core/CommandLine.h"
-#include "core/Game.h"
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "network/Client.h"
 
 namespace orxonox
 {
-    AddGameState(GSClient, "client");
-
     SetCommandLineArgument(ip, "127.0.0.1").information("#.#.#.#");
 
-    GSClient::GSClient(const std::string& name)
-        : GameState(name)
+    GSClient::GSClient()
+        : GameState<GSGraphics>("client")
         , client_(0)
     {
@@ -53,7 +49,7 @@
     }
 
-    void GSClient::activate()
+    void GSClient::enter()
     {
-        GameMode::setIsClient(true);
+        Core::setIsClient(true);
 
         this->client_ = new Client(CommandLine::getValue("ip").getString(), CommandLine::getValue("port"));
@@ -62,9 +58,13 @@
             ThrowException(InitialisationFailed, "Could not establish connection with server.");
 
-        client_->update(Game::getInstance().getGameClock());
+        GSLevel::enter(this->getParent()->getViewport());
+
+        client_->tick(0);
     }
 
-    void GSClient::deactivate()
+    void GSClient::leave()
     {
+        GSLevel::leave();
+
         client_->closeConnection();
 
@@ -72,10 +72,13 @@
         delete this->client_;
 
-        GameMode::setIsClient(false);
+        Core::setIsClient(false);
     }
 
-    void GSClient::update(const Clock& time)
+    void GSClient::ticked(const Clock& time)
     {
-        client_->update(time);
+        GSLevel::ticked(time);
+        client_->tick(time.getDeltaTime());
+
+        this->tickChild(time);
     }
 }
Index: code/branches/questsystem5/src/orxonox/gamestates/GSClient.h
===================================================================
--- code/branches/questsystem5/src/orxonox/gamestates/GSClient.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/gamestates/GSClient.h	(revision 2908)
@@ -31,20 +31,22 @@
 
 #include "OrxonoxPrereqs.h"
-#include "core/GameState.h"
 #include "network/NetworkPrereqs.h"
+#include "GSLevel.h"
+#include "GSGraphics.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSClient : public GameState
+    class _OrxonoxExport GSClient : public GameState<GSGraphics>, public GSLevel
     {
     public:
-        GSClient(const std::string& name);
+        GSClient();
         ~GSClient();
 
-        void activate();
-        void deactivate();
-        void update(const Clock& time);
 
     private:
+        void enter();
+        void leave();
+        void ticked(const Clock& time);
+
         Client* client_;
     };
Index: code/branches/questsystem5/src/orxonox/gamestates/GSDedicated.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/gamestates/GSDedicated.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/gamestates/GSDedicated.cc	(revision 2908)
@@ -30,8 +30,6 @@
 #include "GSDedicated.h"
 
-#include "core/Clock.h"
 #include "core/CommandLine.h"
-#include "core/Game.h"
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "core/Iterator.h"
 #include "network/Server.h"
@@ -41,8 +39,6 @@
 namespace orxonox
 {
-    AddGameState(GSDedicated, "dedicated");
-
-    GSDedicated::GSDedicated(const std::string& name)
-        : GameState(name)
+    GSDedicated::GSDedicated()
+        : GameState<GSRoot>("dedicated")
         , server_(0)
         , timeSinceLastUpdate_(0)
@@ -54,23 +50,27 @@
     }
 
-    void GSDedicated::activate()
+    void GSDedicated::enter()
     {
-        GameMode::setHasServer(true);
+        Core::setHasServer(true);
 
         this->server_ = new Server(CommandLine::getValue("port"));
         COUT(0) << "Loading scene in server mode" << std::endl;
 
+        GSLevel::enter(0);
+
         server_->open();
     }
 
-    void GSDedicated::deactivate()
+    void GSDedicated::leave()
     {
+        GSLevel::leave();
+
         this->server_->close();
         delete this->server_;
 
-        GameMode::setHasServer(false);
+        Core::setHasServer(false);
     }
 
-    void GSDedicated::update(const Clock& time)
+    void GSDedicated::ticked(const Clock& time)
     {
 //        static float startTime = time.getSecondsPrecise();
@@ -82,5 +82,7 @@
 //            COUT(0) << "estimated ticks/sec: " << nrOfTicks/(time.getSecondsPrecise()-startTime) << endl;
             timeSinceLastUpdate_ -= static_cast<unsigned int>(timeSinceLastUpdate_ / NETWORK_PERIOD) * NETWORK_PERIOD;
-            server_->update(time);
+            GSLevel::ticked(time);
+            server_->tick(time.getDeltaTime());
+            this->tickChild(time);
         }
         else
Index: code/branches/questsystem5/src/orxonox/gamestates/GSDedicated.h
===================================================================
--- code/branches/questsystem5/src/orxonox/gamestates/GSDedicated.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/gamestates/GSDedicated.h	(revision 2908)
@@ -31,22 +31,23 @@
 
 #include "OrxonoxPrereqs.h"
-#include "core/GameState.h"
 #include "network/NetworkPrereqs.h"
+#include "GSLevel.h"
+#include "GSRoot.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSDedicated : public GameState
+    class _OrxonoxExport GSDedicated : public GameState<GSRoot>, public GSLevel
     {
     public:
-        GSDedicated(const std::string& name);
+        GSDedicated();
         ~GSDedicated();
 
-        void activate();
-        void deactivate();
-        void update(const Clock& time);
+    private:
+        void enter();
+        void leave();
+        void ticked(const Clock& time);
 
-    private:
-        Server* server_;
-        float   timeSinceLastUpdate_;
+        Server*      server_;
+        float        timeSinceLastUpdate_;
     };
 }
Index: code/branches/questsystem5/src/orxonox/gamestates/GSGUI.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/gamestates/GSGUI.cc	(revision 2908)
+++ code/branches/questsystem5/src/orxonox/gamestates/GSGUI.cc	(revision 2908)
@@ -0,0 +1,69 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "GSGUI.h"
+
+#include <OgreViewport.h>
+#include "core/input/InputManager.h"
+#include "core/input/SimpleInputState.h"
+#include "gui/GUIManager.h"
+
+namespace orxonox
+{
+    GSGUI::GSGUI()
+        : GameState<GSGraphics>("gui")
+    {
+    }
+
+    GSGUI::~GSGUI()
+    {
+    }
+
+    void GSGUI::enter()
+    {
+        guiManager_ = getParent()->getGUIManager();
+
+        // show main menu
+        guiManager_->showGUI("MainMenu", 0);
+        getParent()->getViewport()->setCamera(guiManager_->getCamera());
+    }
+
+    void GSGUI::leave()
+    {
+        guiManager_->hideGUI();
+    }
+
+    void GSGUI::ticked(const Clock& time)
+    {
+        // tick CEGUI
+        guiManager_->tick(time.getDeltaTime());
+
+        this->tickChild(time);
+    }
+}
Index: code/branches/questsystem5/src/orxonox/gamestates/GSGUI.h
===================================================================
--- code/branches/questsystem5/src/orxonox/gamestates/GSGUI.h	(revision 2908)
+++ code/branches/questsystem5/src/orxonox/gamestates/GSGUI.h	(revision 2908)
@@ -0,0 +1,53 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _GSGUI_H__
+#define _GSGUI_H__
+
+#include "OrxonoxPrereqs.h"
+#include "core/GameState.h"
+#include "GSGraphics.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport GSGUI : public GameState<GSGraphics>
+    {
+    public:
+        GSGUI();
+        ~GSGUI();
+
+    private:
+        void enter();
+        void leave();
+        void ticked(const Clock& time);
+
+        GUIManager* guiManager_;
+    };
+}
+
+#endif /* _GSGUI_H__ */
Index: code/branches/questsystem5/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/gamestates/GSGraphics.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/gamestates/GSGraphics.cc	(revision 2908)
@@ -23,11 +23,6 @@
  *      Reto Grieder
  *   Co-authors:
- *      Benjamin Knecht
- *
- */
-
-/**
-    @file
-    @brief Implementation of Graphics GameState class.
+ *      ...
+ *
  */
 
@@ -35,39 +30,58 @@
 #include "GSGraphics.h"
 
+#include <fstream>
 #include <boost/filesystem.hpp>
+
+#include <OgreCompositorManager.h>
+#include <OgreConfigFile.h>
+#include <OgreFrameListener.h>
+#include <OgreRoot.h>
+#include <OgreLogManager.h>
+#include <OgreException.h>
 #include <OgreRenderWindow.h>
-
+#include <OgreRenderSystem.h>
+#include <OgreTextureManager.h>
+#include <OgreViewport.h>
+#include <OgreWindowEventUtilities.h>
+
+#include "SpecialConfig.h"
 #include "util/Debug.h"
+#include "util/Exception.h"
+#include "util/String.h"
+#include "util/SubString.h"
+#include "core/ConsoleCommand.h"
 #include "core/ConfigValueIncludes.h"
-#include "core/Clock.h"
-#include "core/ConsoleCommand.h"
+#include "core/CoreIncludes.h"
 #include "core/Core.h"
-#include "core/CoreIncludes.h"
-#include "core/Game.h"
-#include "core/GameMode.h"
 #include "core/input/InputManager.h"
 #include "core/input/KeyBinder.h"
-#include "core/input/SimpleInputState.h"
+#include "core/input/ExtendedInputState.h"
 #include "core/Loader.h"
 #include "core/XMLFile.h"
 #include "overlays/console/InGameConsole.h"
 #include "gui/GUIManager.h"
-#include "GraphicsManager.h"
+#include "tools/WindowEventListener.h"
+
+// for compatibility
+#include "GraphicsEngine.h"
 
 namespace orxonox
 {
-    AddGameState(GSGraphics, "graphics");
-
-    GSGraphics::GSGraphics(const std::string& name)
-        : GameState(name)
+    GSGraphics::GSGraphics()
+        : GameState<GSRoot>("graphics")
+        , renderWindow_(0)
+        , viewport_(0)
+        , bWindowEventListenerUpdateRequired_(false)
         , inputManager_(0)
         , console_(0)
         , guiManager_(0)
-        , graphicsManager_(0)
+        , ogreRoot_(0)
+        , ogreLogger_(0)
+        , graphicsEngine_(0)
         , masterKeyBinder_(0)
-        , masterInputState_(0)
         , debugOverlay_(0)
     {
         RegisterRootObject(GSGraphics);
+        setConfigValues();
     }
 
@@ -76,37 +90,47 @@
     }
 
-    /**
-    @brief
-        this function does nothing
-
-        Indeed. Here goes nothing.
-    */
     void GSGraphics::setConfigValues()
     {
-    }
-
-    /**
-    @brief
-        This function is called when we enter this game state.
-
-        Since graphics is very important for our game this function does quite a lot:
-        \li starts graphics manager
-        \li loads debug overlay
-        \li manages render window
-        \li creates input manager
-        \li loads master key bindings
-        \li loads ingame console
-        \li loads GUI interface (GUIManager)
-        \li creates console command to toggle GUI
-    */
-    void GSGraphics::activate()
-    {
-        GameMode::setShowsGraphics(true);
-
-        setConfigValues();
-
-        // initialise graphics manager. Doesn't load the render window yet!
-        this->graphicsManager_ = new GraphicsManager();
-        this->graphicsManager_->initialise();
+        SetConfigValue(resourceFile_,    "resources.cfg")
+            .description("Location of the resources file in the data path.");
+        SetConfigValue(ogreConfigFile_,  "ogre.cfg")
+            .description("Location of the Ogre config file");
+        SetConfigValue(ogrePluginsFolder_, ORXONOX_OGRE_PLUGINS_FOLDER)
+            .description("Folder where the Ogre plugins are located.");
+        SetConfigValue(ogrePlugins_, ORXONOX_OGRE_PLUGINS)
+            .description("Comma separated list of all plugins to load.");
+        SetConfigValue(ogreLogFile_,     "ogre.log")
+            .description("Logfile for messages from Ogre. Use \"\" to suppress log file creation.");
+        SetConfigValue(ogreLogLevelTrivial_ , 5)
+            .description("Corresponding orxonox debug level for ogre Trivial");
+        SetConfigValue(ogreLogLevelNormal_  , 4)
+            .description("Corresponding orxonox debug level for ogre Normal");
+        SetConfigValue(ogreLogLevelCritical_, 2)
+            .description("Corresponding orxonox debug level for ogre Critical");
+    }
+
+    void GSGraphics::enter()
+    {
+        Core::setShowsGraphics(true);
+
+        // initialise graphics engine. Doesn't load the render window yet!
+        graphicsEngine_ = new GraphicsEngine();
+
+        // Ogre setup procedure
+        setupOgre();
+        // load all the required plugins for Ogre
+        loadOgrePlugins();
+        // read resource declaration file
+        this->declareResources();
+        // Reads ogre config and creates the render window
+        this->loadRenderer();
+
+        // TODO: Spread this so that this call only initialises things needed for the Console and GUI
+        this->initialiseResources();
+
+        // We want to get informed whenever an object of type WindowEventListener is created
+        // in order to later update the window size.
+        bWindowEventListenerUpdateRequired_ = false;
+        RegisterConstructionCallback(GSGraphics, orxonox::WindowEventListener, requestWindowEventListenerUpdate);
 
         // load debug overlay
@@ -115,80 +139,82 @@
         Loader::open(debugOverlay_);
 
+        // Calls the InputManager which sets up the input devices.
         // The render window width and height are used to set up the mouse movement.
+        inputManager_ = new InputManager();
         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();
-        inputManager_->initialise(windowHnd, renderWindow->getWidth(), renderWindow->getHeight(), true);
-
-        // load master key bindings
-        masterInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("master", true);
+        this->renderWindow_->getCustomAttribute("WINDOW", &windowHnd);
+        inputManager_->initialise(windowHnd, renderWindow_->getWidth(), renderWindow_->getHeight(), true);
+        // Configure master input state with a KeyBinder
         masterKeyBinder_ = new KeyBinder();
         masterKeyBinder_->loadBindings("masterKeybindings.ini");
-        masterInputState_->setKeyHandler(masterKeyBinder_);
+        inputManager_->getMasterInputState()->addKeyHandler(masterKeyBinder_);
 
         // Load the InGameConsole
         console_ = new InGameConsole();
-        console_->initialise(renderWindow->getWidth(), renderWindow->getHeight());
+        console_->initialise(this->renderWindow_->getWidth(), this->renderWindow_->getHeight());
 
         // load the CEGUI interface
         guiManager_ = new GUIManager();
-        guiManager_->initialise(renderWindow);
-
-        // add console command to toggle GUI
-        FunctorMember<GSGraphics>* functor = createFunctor(&GSGraphics::toggleGUI);
-        functor->setObject(this);
-        this->ccToggleGUI_ = createConsoleCommand(functor, "toggleGUI");
-        CommandExecutor::addConsoleCommandShortcut(this->ccToggleGUI_);
-
-        // enable master input
-        InputManager::getInstance().requestEnterState("master");
-    }
-
-    /**
-    @brief
-        This function is called when the game state is left
-
-        Created references, input states and console commands are deleted.
-    */
-    void GSGraphics::deactivate()
-    {
-
-        if (this->ccToggleGUI_)
-        {
-            delete this->ccToggleGUI_;
-            this->ccToggleGUI_ = 0;
-        }
-
-        masterInputState_->setHandler(0);
-        InputManager::getInstance().requestDestroyState("master");
+        guiManager_->initialise(this->renderWindow_);
+
+        // add console commands
+        FunctorMember<GSGraphics>* functor1 = createFunctor(&GSGraphics::printScreen);
+        functor1->setObject(this);
+        ccPrintScreen_ = createConsoleCommand(functor1, "printScreen");
+        CommandExecutor::addConsoleCommandShortcut(ccPrintScreen_);
+    }
+
+    void GSGraphics::leave()
+    {
+        using namespace Ogre;
+
+        delete this->ccPrintScreen_;
+
+        // remove our WindowEventListener first to avoid bad calls after the window has been destroyed
+        Ogre::WindowEventUtilities::removeWindowEventListener(this->renderWindow_, this);
+
+        delete this->guiManager_;
+
+        delete this->console_;
+
+        //inputManager_->getMasterInputState()->removeKeyHandler(this->masterKeyBinder_);
         delete this->masterKeyBinder_;
-
-        delete this->guiManager_;
-        delete this->console_;
+        delete this->inputManager_;
 
         Loader::unload(this->debugOverlay_);
         delete this->debugOverlay_;
 
-        delete this->inputManager_;
-        this->inputManager_ = 0;
-
-        delete graphicsManager_;
-
-        GameMode::setShowsGraphics(false);
-    }
-
-    /**
-    @brief
-        Toggles the visibility of the current GUI
-
-        This function just executes a Lua function in the main script of the GUI by accessing the GUIManager.
-        For more details on this function check out the Lua code.
-    */
-    void GSGraphics::toggleGUI()
-    {
-            GUIManager::getInstance().executeCode("toggleGUI()");
+        // unload all compositors
+        Ogre::CompositorManager::getSingleton().removeAll();
+
+        // destroy render window
+        RenderSystem* renderer = this->ogreRoot_->getRenderSystem();
+        renderer->destroyRenderWindow("Orxonox");
+
+        /*** CODE SNIPPET, UNUSED ***/
+        // Does the opposite of initialise()
+        //ogreRoot_->shutdown();
+        // Remove all resources and resource groups
+        //StringVector groups = ResourceGroupManager::getSingleton().getResourceGroups();
+        //for (StringVector::iterator it = groups.begin(); it != groups.end(); ++it)
+        //{
+        //    ResourceGroupManager::getSingleton().destroyResourceGroup(*it);
+        //}
+
+        //ParticleSystemManager::getSingleton().removeAllTemplates();
+
+        // Shutdown the render system
+        //this->ogreRoot_->setRenderSystem(0);
+
+        delete this->ogreRoot_;
+
+        // delete the ogre log and the logManager (since we have created it).
+        this->ogreLogger_->getDefaultLog()->removeListener(this);
+        this->ogreLogger_->destroyLog(Ogre::LogManager::getSingleton().getDefaultLog());
+        delete this->ogreLogger_;
+
+        delete graphicsEngine_;
+
+        Core::setShowsGraphics(false);
     }
 
@@ -201,26 +227,259 @@
         need the time. So we shouldn't run into problems.
     */
-    void GSGraphics::update(const Clock& time)
-    {
-        if (this->getActivity().topState)
-        {
-            // This state can not 'survive' on its own.
-            // Load a user interface therefore
-            Game::getInstance().requestState("mainMenu");
-        }
-
+    void GSGraphics::ticked(const Clock& time)
+    {
         uint64_t timeBeforeTick = time.getRealMicroseconds();
 
-        this->inputManager_->update(time);        // tick console
-        this->console_->update(time);
-        this->guiManager_->update(time);
+        float dt = time.getDeltaTime();
+
+        this->inputManager_->tick(dt);
+        // tick console
+        this->console_->tick(dt);
+        this->tickChild(time);
+
+        if (this->bWindowEventListenerUpdateRequired_)
+        {
+            // Update all WindowEventListeners for the case a new one was created.
+            this->windowResized(this->renderWindow_);
+            this->bWindowEventListenerUpdateRequired_ = false;
+        }
 
         uint64_t timeAfterTick = time.getRealMicroseconds();
 
-        // Also add our tick time
-        Game::getInstance().addTickTime(timeAfterTick - timeBeforeTick);
-
-        // Render
-        this->graphicsManager_->update(time);
+        // Also add our tick time to the list in GSRoot
+        this->getParent()->addTickTime(timeAfterTick - timeBeforeTick);
+
+        // Update statistics overlay. Note that the values only change periodically in GSRoot.
+        GraphicsEngine::getInstance().setAverageFramesPerSecond(this->getParent()->getAvgFPS());
+        GraphicsEngine::getInstance().setAverageTickTime(this->getParent()->getAvgTickTime());
+
+        // 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)
+        this->renderWindow_->setActive(true);
+
+        // render
+        ogreRoot_->_updateAllRenderTargets();
+
+        // again, just to be sure ogre works fine
+        ogreRoot_->_fireFrameEnded(evt); // note: uses the same time as _fireFrameStarted
+    }
+
+    /**
+    @brief
+        Creates the Ogre Root object and sets up the ogre log.
+    */
+    void GSGraphics::setupOgre()
+    {
+        COUT(3) << "Setting up Ogre..." << std::endl;
+
+        if (ogreConfigFile_ == "")
+        {
+            COUT(2) << "Warning: Ogre config file set to \"\". Defaulting to config.cfg" << std::endl;
+            ModifyConfigValue(ogreConfigFile_, tset, "config.cfg");
+        }
+        if (ogreLogFile_ == "")
+        {
+            COUT(2) << "Warning: Ogre log file set to \"\". Defaulting to ogre.log" << std::endl;
+            ModifyConfigValue(ogreLogFile_, tset, "ogre.log");
+        }
+
+        boost::filesystem::path ogreConfigFilepath(Core::getConfigPath() / this->ogreConfigFile_);
+        boost::filesystem::path ogreLogFilepath(Core::getLogPath() / this->ogreLogFile_);
+
+        // create a new logManager
+        // Ogre::Root will detect that we've already created a Log
+        ogreLogger_ = new Ogre::LogManager();
+        COUT(4) << "Ogre LogManager created" << std::endl;
+
+        // create our own log that we can listen to
+        Ogre::Log *myLog;
+        myLog = ogreLogger_->createLog(ogreLogFilepath.string(), true, false, false);
+        COUT(4) << "Ogre Log created" << std::endl;
+
+        myLog->setLogDetail(Ogre::LL_BOREME);
+        myLog->addListener(this);
+
+        COUT(4) << "Creating Ogre Root..." << std::endl;
+
+        // check for config file existence because Ogre displays (caught) exceptions if not
+        if (!boost::filesystem::exists(ogreConfigFilepath))
+        {
+            // create a zero sized file
+            std::ofstream creator;
+            creator.open(ogreConfigFilepath.string().c_str());
+            creator.close();
+        }
+
+        // Leave plugins file empty. We're going to do that part manually later
+        ogreRoot_ = new Ogre::Root("", ogreConfigFilepath.string(), ogreLogFilepath.string());
+
+        COUT(3) << "Ogre set up done." << std::endl;
+    }
+
+    void GSGraphics::loadOgrePlugins()
+    {
+        // just to make sure the next statement doesn't segfault
+        if (ogrePluginsFolder_ == "")
+            ogrePluginsFolder_ = ".";
+
+        boost::filesystem::path folder(ogrePluginsFolder_);
+        // Do some SubString magic to get the comma separated list of plugins
+        SubString plugins(ogrePlugins_, ",", " ", false, 92, false, 34, false, 40, 41, false, '\0');
+        // Use backslash paths on Windows! file_string() already does that though.
+        for (unsigned int i = 0; i < plugins.size(); ++i)
+            ogreRoot_->loadPlugin((folder / plugins[i]).file_string());
+    }
+
+    void GSGraphics::declareResources()
+    {
+        CCOUT(4) << "Declaring Resources" << std::endl;
+        //TODO: Specify layout of data file and maybe use xml-loader
+        //TODO: Work with ressource groups (should be generated by a special loader)
+
+        if (resourceFile_ == "")
+        {
+            COUT(2) << "Warning: Ogre resource file set to \"\". Defaulting to resources.cfg" << std::endl;
+            ModifyConfigValue(resourceFile_, tset, "resources.cfg");
+        }
+
+        // Load resource paths from data file using configfile ressource type
+        Ogre::ConfigFile cf;
+        try
+        {
+            cf.load((Core::getMediaPath() / resourceFile_).string());
+        }
+        catch (...)
+        {
+            //COUT(1) << ex.getFullDescription() << std::endl;
+            COUT(0) << "Have you forgotten to set the data path in orxnox.ini?" << std::endl;
+            throw;
+        }
+
+        // Go through all sections & settings in the file
+        Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
+
+        std::string secName, typeName, archName;
+        while (seci.hasMoreElements())
+        {
+            try
+            {
+                secName = seci.peekNextKey();
+                Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
+                Ogre::ConfigFile::SettingsMultiMap::iterator i;
+                for (i = settings->begin(); i != settings->end(); ++i)
+                {
+                    typeName = i->first; // for instance "FileSystem" or "Zip"
+                    archName = i->second; // name (and location) of archive
+
+                    Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
+                        (Core::getMediaPath() / archName).string(), typeName, secName);
+                }
+            }
+            catch (Ogre::Exception& ex)
+            {
+                COUT(1) << ex.getFullDescription() << std::endl;
+            }
+        }
+    }
+
+    void GSGraphics::loadRenderer()
+    {
+        CCOUT(4) << "Configuring Renderer" << std::endl;
+
+        if (!ogreRoot_->restoreConfig())
+            if (!ogreRoot_->showConfigDialog())
+                ThrowException(InitialisationFailed, "Could not show Ogre configuration dialogue.");
+
+        CCOUT(4) << "Creating render window" << std::endl;
+
+        this->renderWindow_ = ogreRoot_->initialise(true, "Orxonox");
+
+        Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, this);
+
+        Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(0);
+
+        // create a full screen default viewport
+        this->viewport_ = this->renderWindow_->addViewport(0, 0);
+
+        if (this->graphicsEngine_)
+            this->graphicsEngine_->setViewport(this->viewport_);
+    }
+
+    void GSGraphics::initialiseResources()
+    {
+        CCOUT(4) << "Initialising resources" << std::endl;
+        //TODO: Do NOT load all the groups, why are we doing that? And do we really do that? initialise != load...
+        //try
+        //{
+            Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
+            /*Ogre::StringVector str = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
+            for (unsigned int i = 0; i < str.size(); i++)
+            {
+            Ogre::ResourceGroupManager::getSingleton().loadResourceGroup(str[i]);
+            }*/
+        //}
+        //catch (...)
+        //{
+        //    CCOUT(2) << "Error: There was a serious error when initialising the resources." << std::endl;
+        //    throw;
+        //}
+    }
+
+    /**
+    @brief
+        Method called by the LogListener interface from Ogre.
+        We use it to capture Ogre log messages and handle it ourselves.
+    @param message
+        The message to be logged
+    @param lml
+        The message level the log is using
+    @param maskDebug
+        If we are printing to the console or not
+    @param logName
+        The name of this log (so you can have several listeners
+        for different logs, and identify them)
+    */
+    void GSGraphics::messageLogged(const std::string& message,
+        Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName)
+    {
+        int orxonoxLevel;
+        switch (lml)
+        {
+        case Ogre::LML_TRIVIAL:
+            orxonoxLevel = this->ogreLogLevelTrivial_;
+            break;
+        case Ogre::LML_NORMAL:
+            orxonoxLevel = this->ogreLogLevelNormal_;
+            break;
+        case Ogre::LML_CRITICAL:
+            orxonoxLevel = this->ogreLogLevelCritical_;
+            break;
+        default:
+            orxonoxLevel = 0;
+        }
+        OutputHandler::getOutStream().setOutputLevel(orxonoxLevel)
+            << "Ogre: " << message << std::endl;
+    }
+
+    /**
+    @brief
+        Window has moved.
+    @param rw
+        The render window it occured in
+    */
+    void GSGraphics::windowMoved(Ogre::RenderWindow *rw)
+    {
+        for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
+            it->windowMoved();
     }
 
@@ -231,12 +490,15 @@
         The render window it occured in
     @note
-        GraphicsManager has a render window stored itself. This is the same
+        GraphicsEngine has a render window stored itself. This is the same
         as rw. But we have to be careful when using multiple render windows!
     */
-    void GSGraphics::windowResized(unsigned int newWidth, unsigned int newHeight)
-    {
+    void GSGraphics::windowResized(Ogre::RenderWindow *rw)
+    {
+        for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
+            it->windowResized(this->renderWindow_->getWidth(), this->renderWindow_->getHeight());
+
         // OIS needs this under linux even if we only use relative input measurement.
         if (this->inputManager_)
-            this->inputManager_->setWindowExtents(newWidth, newHeight);
+            this->inputManager_->setWindowExtents(renderWindow_->getWidth(), renderWindow_->getHeight());
     }
 
@@ -247,6 +509,9 @@
         The render window it occured in
     */
-    void GSGraphics::windowFocusChanged()
-    {
+    void GSGraphics::windowFocusChange(Ogre::RenderWindow *rw)
+    {
+        for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
+            it->windowFocusChanged();
+
         // instruct InputManager to clear the buffers (core library so we cannot use the interface)
         if (this->inputManager_)
@@ -254,3 +519,21 @@
     }
 
+    /**
+    @brief
+        Window was closed.
+    @param rw
+        The render window it occured in
+    */
+    void GSGraphics::windowClosed(Ogre::RenderWindow *rw)
+    {
+        this->requestState("root");
+    }
+
+    void GSGraphics::printScreen()
+    {
+        if (this->renderWindow_)
+        {
+            this->renderWindow_->writeContentsToTimestampedFile("shot_", ".jpg");
+        }
+    }
 }
Index: code/branches/questsystem5/src/orxonox/gamestates/GSGraphics.h
===================================================================
--- code/branches/questsystem5/src/orxonox/gamestates/GSGraphics.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/gamestates/GSGraphics.h	(revision 2908)
@@ -23,12 +23,7 @@
  *      Reto Grieder
  *   Co-authors:
- *      Benjamin Knecht (documentation)
+ *      ...
  *
  */
-
- /**
-    @file
-    @brief Declaration of the Graphics GameState class.
-  */
 
 #ifndef _GSGraphics_H__
@@ -36,44 +31,82 @@
 
 #include "OrxonoxPrereqs.h"
+#include <OgrePrerequisites.h>
+#define NOMINMAX // required to stop windows.h screwing up std::min definition
+#include <OgreWindowEventUtilities.h>
 #include "core/GameState.h"
-#include "tools/WindowEventListener.h"
+#include "core/OrxonoxClass.h"
+#include "GSRoot.h"
 
 namespace orxonox
 {
-    /**
-    @class GSGraphics
-    @brief
-        Game state used when displaying graphics of any kind
+    class _OrxonoxExport GSGraphics : public GameState<GSRoot>, public OrxonoxClass,
+                                      public Ogre::WindowEventListener, public Ogre::LogListener
+    {
+        friend class ClassIdentifier<GSGraphics>;
 
-        This game state is only left out if we start a dedicated server where no graphics are present.
-    */
-    class _OrxonoxExport GSGraphics : public GameState, public WindowEventListener
-    {
     public:
-        GSGraphics(const std::string& name);
+        GSGraphics();
         ~GSGraphics();
+
+        Ogre::Root*     getOgreRoot()   { return this->ogreRoot_  ; }
+        Ogre::Viewport* getViewport()   { return this->viewport_  ; }
+        GUIManager*     getGUIManager() { return this->guiManager_; }
+
+    private: // functions
+        void enter();
+        void leave();
+        void ticked(const Clock& time);
+
         void setConfigValues();
 
-        void activate();
-        void deactivate();
-        void update(const Clock& time);
+        void setupOgre();
+        void loadOgrePlugins();
+        void declareResources();
+        void loadRenderer();
+        void initialiseResources();
 
-        void toggleGUI();
+        // console commands
+        void printScreen();
 
-    private:
-        // Window events from WindowEventListener
-        void windowResized(unsigned int newWidth, unsigned int newHeight);
-        void windowFocusChanged();
+        // event from Ogre::LogListener
+        void messageLogged(const std::string& message, Ogre::LogMessageLevel lml,
+            bool maskDebug, const std::string& logName);
+
+        // window events from Ogre::WindowEventListener
+        void windowMoved       (Ogre::RenderWindow* rw);
+        void windowResized     (Ogre::RenderWindow* rw);
+        void windowFocusChange (Ogre::RenderWindow* rw);
+        void windowClosed      (Ogre::RenderWindow* rw);
+
+        void requestWindowEventListenerUpdate() { this->bWindowEventListenerUpdateRequired_ = true; }
+
+    private: // variables
+        Ogre::RenderWindow*   renderWindow_;          //!< the current render window
+        Ogre::Viewport*       viewport_;              //!< default full size viewport
+        bool bWindowEventListenerUpdateRequired_;     //!< True if a new WindowEventListener was created but not yet updated.
 
         // managed singletons
-        InputManager*         inputManager_;        //!< Reference to input management
+        InputManager*         inputManager_;
         InGameConsole*        console_;
-        GUIManager*           guiManager_;          //!< Interface to GUI
-        GraphicsManager*      graphicsManager_;     //!< Interface to Ogre
+        GUIManager*           guiManager_;
+        Ogre::Root*           ogreRoot_;                  //!< Ogre's root
+        Ogre::LogManager*     ogreLogger_;
+        GraphicsEngine*       graphicsEngine_;   //!< Interface to Ogre
 
-        KeyBinder*            masterKeyBinder_;     //!< Key binder for master key bindings
-        SimpleInputState*     masterInputState_;    //!< Special input state for master input
+        KeyBinder*            masterKeyBinder_;
         XMLFile*              debugOverlay_;
-        ConsoleCommand*       ccToggleGUI_;         //!< Console command to toggle GUI
+
+        // config values
+        std::string           resourceFile_;             //!< resources file name
+        std::string           ogreConfigFile_;           //!< ogre config file name
+        std::string           ogrePluginsFolder_;        //!< Folder where the Ogre plugins are located
+        std::string           ogrePlugins_;              //!< Comma separated list of all plugins to load
+        std::string           ogreLogFile_;              //!< log file name for Ogre log messages
+        int                   ogreLogLevelTrivial_;      //!< Corresponding Orxonx debug level for LL_TRIVIAL
+        int                   ogreLogLevelNormal_;       //!< Corresponding Orxonx debug level for LL_NORMAL
+        int                   ogreLogLevelCritical_;     //!< Corresponding Orxonx debug level for LL_CRITICAL
+
+        // console commands
+        ConsoleCommand*       ccPrintScreen_;
     };
 }
Index: code/branches/questsystem5/src/orxonox/gamestates/GSIOConsole.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/gamestates/GSIOConsole.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/gamestates/GSIOConsole.cc	(revision 2908)
@@ -36,12 +36,9 @@
 
 #include "core/ConsoleCommand.h"
-#include "core/Game.h"
 
 namespace orxonox
 {
-    AddGameState(GSIOConsole, "ioConsole");
-
-    GSIOConsole::GSIOConsole(const std::string& name)
-        : GameState(name)
+    GSIOConsole::GSIOConsole()
+        : GameState<GSRoot>("ioConsole")
     {
     }
@@ -51,35 +48,19 @@
     }
 
-    void GSIOConsole::activate()
+    void GSIOConsole::enter()
     {
-        {
-            FunctorMember<GSIOConsole>* functor = createFunctor(&GSIOConsole::loadMenu);
-            functor->setObject(this);
-            this->ccLoadMenu_ = createConsoleCommand(functor, "loadMenu");
-            CommandExecutor::addConsoleCommandShortcut(this->ccLoadMenu_);
-        }
     }
 
-    void GSIOConsole::deactivate()
+    void GSIOConsole::leave()
     {
-        if (this->ccLoadMenu_)
-        {
-            delete this->ccLoadMenu_;
-            this->ccLoadMenu_ = 0;
-        }
     }
 
-    void GSIOConsole::update(const Clock& time)
+    void GSIOConsole::ticked(const Clock& time)
     {
-        std::cout << ">";
         std::string command;
         std::getline(std::cin, command);
         CommandExecutor::execute(command, true);
-    }
-
-    void GSIOConsole::loadMenu()
-    {
-        Game::getInstance().popState();
-        Game::getInstance().requestStates("graphics, mainMenu");
+        
+        tickChild(time);
     }
 }
Index: code/branches/questsystem5/src/orxonox/gamestates/GSIOConsole.h
===================================================================
--- code/branches/questsystem5/src/orxonox/gamestates/GSIOConsole.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/gamestates/GSIOConsole.h	(revision 2908)
@@ -31,23 +31,20 @@
 
 #include "OrxonoxPrereqs.h"
+#include <OgrePrerequisites.h>
 #include "core/GameState.h"
+#include "GSRoot.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSIOConsole : public GameState
+    class _OrxonoxExport GSIOConsole : public GameState<GSRoot>
     {
     public:
-        GSIOConsole(const std::string& name);
+        GSIOConsole();
         ~GSIOConsole();
 
-        void activate();
-        void deactivate();
-        void update(const Clock& time);
-
     private:
-        void loadMenu();
-
-        // console commands
-        ConsoleCommand* ccLoadMenu_;
+        void enter();
+        void leave();
+        void ticked(const Clock& time);
     };
 }
Index: code/branches/questsystem5/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/gamestates/GSLevel.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/gamestates/GSLevel.cc	(revision 2908)
@@ -24,5 +24,4 @@
  *   Co-authors:
  *      Fabian 'x3n' Landau
- *      Benjamin Knecht
  *
  */
@@ -40,31 +39,22 @@
 #include "core/CommandLine.h"
 #include "core/ConfigValueIncludes.h"
+#include "core/CoreIncludes.h"
 #include "core/Core.h"
-#include "core/CoreIncludes.h"
-#include "core/Game.h"
-#include "core/GameMode.h"
 #include "objects/Tickable.h"
 #include "objects/Radar.h"
 #include "CameraManager.h"
-#include "GraphicsManager.h"
 #include "LevelManager.h"
 #include "PlayerManager.h"
-#include "orxonox/objects/quest/QuestManager.h"
-#include "orxonox/overlays/notifications/NotificationManager.h"
-#include "gui/GUIManager.h"
+#include "objects/quest/QuestManager.h"
+#include "overlays/notifications/NotificationManager.h"
 
 namespace orxonox
 {
-    AddGameState(GSLevel, "level");
-
-    SetCommandLineArgument(level, "presentation_dm.oxw").shortcut("l");
-    SetConsoleCommand(GSLevel, showIngameGUI, true);
-
-    GSLevel::GSLevel(const std::string& name)
-        : GameState(name)
-        , keyBinder_(0)
-        , gameInputState_(0)
-        , guiMouseOnlyInputState_(0)
-        , guiKeysOnlyInputState_(0)
+    SetCommandLineArgument(level, "presentation.oxw").shortcut("l");
+
+    GSLevel::GSLevel()
+//        : GameState<GSGraphics>(name)
+        : keyBinder_(0)
+        , inputState_(0)
         , radar_(0)
         , startFile_(0)
@@ -76,4 +66,6 @@
         this->ccKeybind_ = 0;
         this->ccTkeybind_ = 0;
+
+        setConfigValues();
     }
 
@@ -87,23 +79,16 @@
     }
 
-    void GSLevel::activate()
-    {
-        setConfigValues();
-
-        if (GameMode::showsGraphics())
-        {
-            gameInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game");
+    void GSLevel::enter(Ogre::Viewport* viewport)
+    {
+        if (Core::showsGraphics())
+        {
+            inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game", 20);
             keyBinder_ = new KeyBinder();
             keyBinder_->loadBindings("keybindings.ini");
-            gameInputState_->setHandler(keyBinder_);
-
-            guiMouseOnlyInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("guiMouseOnly");
-            guiMouseOnlyInputState_->setMouseHandler(GUIManager::getInstancePtr());
-
-            guiKeysOnlyInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("guiKeysOnly");
-            guiKeysOnlyInputState_->setKeyHandler(GUIManager::getInstancePtr());
+            inputState_->setHandler(keyBinder_);
 
             // create the global CameraManager
-            this->cameraManager_ = new CameraManager(GraphicsManager::getInstance().getViewport());
+            assert(viewport);
+            this->cameraManager_ = new CameraManager(viewport);
 
             // Start the Radar
@@ -117,5 +102,5 @@
         this->notificationManager_ = new NotificationManager();
 
-        if (GameMode::isMaster())
+        if (Core::isMaster())
         {
             // create the global LevelManager
@@ -125,6 +110,9 @@
         }
 
-        if (GameMode::showsGraphics())
-        {
+        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);
@@ -144,21 +132,5 @@
     }
 
-    void GSLevel::showIngameGUI(bool show)
-    {
-        if (show)
-        {
-            GUIManager::getInstancePtr()->showGUI("inGameTest");
-            GUIManager::getInstancePtr()->executeCode("showCursor()");
-            InputManager::getInstance().requestEnterState("guiMouseOnly");
-        }
-        else
-        {
-            GUIManager::getInstancePtr()->executeCode("hideGUI(\"inGameTest\")");
-            GUIManager::getInstancePtr()->executeCode("hideCursor()");
-            InputManager::getInstance().requestLeaveState("guiMouseOnly");
-        }
-    }
-
-    void GSLevel::deactivate()
+    void GSLevel::leave()
     {
         // destroy console commands
@@ -173,5 +145,4 @@
             this->ccTkeybind_ = 0;
         }
-
 
         // this call will delete every BaseObject!
@@ -181,8 +152,8 @@
         //Loader::close();
 
-        if (GameMode::showsGraphics())
+        if (Core::showsGraphics())
             InputManager::getInstance().requestLeaveState("game");
 
-        if (GameMode::isMaster())
+        if (Core::isMaster())
             this->unloadLevel();
 
@@ -223,9 +194,7 @@
         }
 
-        if (GameMode::showsGraphics())
-        {
-            gameInputState_->setHandler(0);
-            guiMouseOnlyInputState_->setHandler(0);
-            guiKeysOnlyInputState_->setHandler(0);
+        if (Core::showsGraphics())
+        {
+            inputState_->setHandler(0);
             InputManager::getInstance().requestDestroyState("game");
             if (this->keyBinder_)
@@ -237,7 +206,7 @@
     }
 
-    void GSLevel::update(const Clock& time)
-    {
-        // Note: Temporarily moved to GSGraphics.
+    void GSLevel::ticked(const Clock& time)
+    {
+        // Commented by 1337: Temporarily moved to GSGraphics.
         //// Call the scene objects
         //for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
@@ -282,9 +251,9 @@
         Command string that can be executed by the CommandExecutor
         OR: Internal string "KeybindBindingStringKeyName=" used for the second call to identify
-        the key/button/axis that has been activated. This is configured above in activate().
+        the key/button/axis that has been activated. This is configured above in enter().
     */
     void GSLevel::keybindInternal(const std::string& command, bool bTemporary)
     {
-        if (GameMode::showsGraphics())
+        if (Core::showsGraphics())
         {
             static std::string bindingString = "";
Index: code/branches/questsystem5/src/orxonox/gamestates/GSLevel.h
===================================================================
--- code/branches/questsystem5/src/orxonox/gamestates/GSLevel.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/gamestates/GSLevel.h	(revision 2908)
@@ -23,5 +23,5 @@
  *      Reto Grieder
  *   Co-authors:
- *      Benjamin Knecht
+ *      ...
  *
  */
@@ -31,23 +31,21 @@
 
 #include "OrxonoxPrereqs.h"
+#include <OgrePrerequisites.h>
 #include "core/OrxonoxClass.h"
-#include "core/GameState.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSLevel : public GameState, public OrxonoxClass
+    class _OrxonoxExport GSLevel : public OrxonoxClass
     {
+        friend class ClassIdentifier<GSLevel>;
     public:
-        GSLevel(const std::string& name);
+        GSLevel();
         ~GSLevel();
-        void setConfigValues();
-
-        void activate();
-        void deactivate();
-        void update(const Clock& time);
-
-        static void showIngameGUI(bool show);
 
     protected:
+        void enter(Ogre::Viewport* viewport);
+        void leave();
+        void ticked(const Clock& time);
+
         void loadLevel();
         void unloadLevel();
@@ -58,15 +56,13 @@
         void keybindInternal(const std::string& command, bool bTemporary);
 
-        KeyBinder*            keyBinder_;               //!< tool that loads and manages the input bindings
-        SimpleInputState*     gameInputState_;          //!< input state for normal ingame playing
-        SimpleInputState*     guiMouseOnlyInputState_;  //!< input state if we only need the mouse to use the GUI
-        SimpleInputState*     guiKeysOnlyInputState_;   //!< input state if we only need the keys to use the GUI
-        Radar*                radar_;                   //!< represents the Radar (not the HUD part)
-        XMLFile*              startFile_;               //!< current hard coded default level
-        CameraManager*        cameraManager_;           //!< camera manager for this level
-        LevelManager*         levelManager_;            //!< global level manager
-        PlayerManager*        playerManager_;           //!< player manager for this level
-        QuestManager*         questManager_;            //!< quest manager for this level
-        NotificationManager*  notificationManager_;     //!< notification manager for this level
+        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
+        CameraManager*        cameraManager_;
+        LevelManager*         levelManager_;
+        PlayerManager*        playerManager_;
+        QuestManager*          questManager_;
+        NotificationManager*  notificationManager_;
 
         //##### ConfigValues #####
@@ -76,4 +72,8 @@
         ConsoleCommand*       ccKeybind_;
         ConsoleCommand*       ccTkeybind_;
+
+    private:
+        void setConfigValues();
+
     };
 }
Index: code/branches/questsystem5/src/orxonox/gamestates/GSMainMenu.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/gamestates/GSMainMenu.cc	(revision 2907)
+++ 	(revision )
@@ -1,107 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-#include "OrxonoxStableHeaders.h"
-#include "GSMainMenu.h"
-
-//#include <OgreViewport.h>
-#include <OgreSceneManager.h>
-#include "core/Clock.h"
-#include "core/ConsoleCommand.h"
-#include "core/Game.h"
-#include "core/input/InputManager.h"
-#include "core/input/SimpleInputState.h"
-#include "gui/GUIManager.h"
-#include "objects/Scene.h"
-#include "GraphicsManager.h"
-
-namespace orxonox
-{
-    AddGameState(GSMainMenu, "mainMenu");
-
-    GSMainMenu::GSMainMenu(const std::string& name)
-        : GameState(name)
-        , inputState_(0)
-    {
-    }
-
-    GSMainMenu::~GSMainMenu()
-    {
-    }
-
-    void GSMainMenu::activate()
-    {
-        inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("mainMenu");
-        inputState_->setHandler(GUIManager::getInstancePtr());
-        inputState_->setJoyStickHandler(&InputManager::EMPTY_HANDLER);
-
-        // create an empty Scene
-        this->scene_ = new Scene(0);
-        // and a Camera
-        this->camera_ = this->scene_->getSceneManager()->createCamera("mainMenu/Camera");
-
-        // show main menu
-        GUIManager::getInstance().showGUI("mainmenu");
-        GUIManager::getInstance().setCamera(this->camera_);
-        GraphicsManager::getInstance().setCamera(this->camera_);
-
-        {
-            FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startGame);
-            functor->setObject(this);
-            this->ccStartGame_ = createConsoleCommand(functor, "startGame");
-            CommandExecutor::addConsoleCommandShortcut(this->ccStartGame_);
-        }
-
-        InputManager::getInstance().requestEnterState("mainMenu");
-    }
-
-    void GSMainMenu::deactivate()
-    {
-        InputManager::getInstance().requestLeaveState("mainMenu");
-        InputManager::getInstance().requestDestroyState("mainMenu");
-
-/*
-        if (this->ccStartGame_)
-        {
-            delete this->ccStartGame_;
-            this->ccStartGame_ = 0;
-        }
-*/
-    }
-
-    void GSMainMenu::update(const Clock& time)
-    {
-    }
-
-    void GSMainMenu::startGame()
-    {
-        // HACK - HACK
-        Game::getInstance().popState();
-        Game::getInstance().requestStates("standalone, level");
-    }
-}
Index: code/branches/questsystem5/src/orxonox/gamestates/GSMainMenu.h
===================================================================
--- code/branches/questsystem5/src/orxonox/gamestates/GSMainMenu.h	(revision 2907)
+++ 	(revision )
@@ -1,60 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _GSMainMenu_H__
-#define _GSMainMenu_H__
-
-#include "OrxonoxPrereqs.h"
-#include <OgrePrerequisites.h>
-#include "core/GameState.h"
-
-namespace orxonox
-{
-    class _OrxonoxExport GSMainMenu : public GameState
-    {
-    public:
-        GSMainMenu(const std::string& name);
-        ~GSMainMenu();
-
-        void activate();
-        void deactivate();
-        void update(const Clock& time);
-
-        void startGame();
-
-    private:
-        SimpleInputState* inputState_;
-        Scene*            scene_;
-        Ogre::Camera*     camera_;
-
-        // console commands
-        ConsoleCommand* ccStartGame_;
-    };
-}
-
-#endif /* _GSMainMenu_H__ */
Index: code/branches/questsystem5/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/gamestates/GSRoot.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/gamestates/GSRoot.cc	(revision 2908)
@@ -32,29 +32,41 @@
 #include "util/Exception.h"
 #include "util/Debug.h"
-#include "core/Clock.h"
-#include "core/Game.h"
-#include "core/GameMode.h"
+#include "core/Core.h"
+#include "core/Factory.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/CoreIncludes.h"
+#include "core/ConsoleCommand.h"
 #include "core/CommandLine.h"
-#include "core/ConsoleCommand.h"
-#include "tools/TimeFactorListener.h"
+#include "core/Shell.h"
+#include "core/TclBind.h"
+#include "core/TclThreadManager.h"
+#include "core/LuaBind.h"
 #include "tools/Timer.h"
 #include "objects/Tickable.h"
 
+#ifdef ORXONOX_PLATFORM_WINDOWS
+#  ifndef WIN32_LEAN_AND_MEAN
+#    define WIN32_LEAN_AND_MEAN
+#  endif
+#  define NOMINMAX // required to stop windows.h screwing up std::min definition
+#  include "windows.h"
+#endif
+
 namespace orxonox
 {
-    AddGameState(GSRoot, "root");
-    SetCommandLineSwitch(console);
-    // Shortcuts for easy direct loading
-    SetCommandLineSwitch(server);
-    SetCommandLineSwitch(client);
-    SetCommandLineSwitch(dedicated);
-    SetCommandLineSwitch(standalone);
-
-    GSRoot::GSRoot(const std::string& name)
-        : GameState(name)
+    SetCommandLineArgument(limitToCPU, 1).information("0: off | #cpu");
+
+    GSRoot::GSRoot()
+        : RootGameState("root")
         , timeFactor_(1.0f)
         , bPaused_(false)
         , timeFactorPauseBackup_(1.0f)
-    {
+        , tclBind_(0)
+        , tclThreadManager_(0)
+        , shell_(0)
+    {
+        RegisterRootObject(GSRoot);
+        setConfigValues();
+
         this->ccSetTimeFactor_ = 0;
         this->ccPause_ = 0;
@@ -65,8 +77,59 @@
     }
 
-    void GSRoot::activate()
-    {
+    void GSRoot::setConfigValues()
+    {
+        SetConfigValue(statisticsRefreshCycle_, 250000)
+            .description("Sets the time in microseconds interval at which average fps, etc. get updated.");
+        SetConfigValue(statisticsAvgLength_, 1000000)
+            .description("Sets the time in microseconds interval at which average fps, etc. gets calculated.");
+    }
+
+    void GSRoot::enter()
+    {
+        // creates the class hierarchy for all classes with factories
+        Factory::createClassHierarchy();
+
         // reset game speed to normal
-        this->timeFactor_ = 1.0f;
+        timeFactor_ = 1.0f;
+
+        // reset frame counter
+        this->statisticsStartTime_ = 0;
+        this->statisticsTickTimes_.clear();
+        this->periodTickTime_ = 0;
+        this->avgFPS_ = 0.0f;
+        this->avgTickTime_ = 0.0f;
+
+        // Create the lua interface
+        this->luaBind_ = new LuaBind();
+
+        // initialise TCL
+        this->tclBind_ = new TclBind(Core::getMediaPathString());
+        this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter());
+
+        // create a shell
+        this->shell_ = new Shell();
+
+        // limit the main thread to the first core so that QueryPerformanceCounter doesn't jump
+        // do this after ogre has initialised. Somehow Ogre changes the settings again (not through
+        // the timer though).
+        int limitToCPU = CommandLine::getValue("limitToCPU");
+        if (limitToCPU > 0)
+            setThreadAffinity((unsigned int)(limitToCPU - 1));
+
+        {
+            // add console commands
+            FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::exitGame);
+            functor->setObject(this);
+            this->ccExit_ = createConsoleCommand(functor, "exit");
+            CommandExecutor::addConsoleCommandShortcut(this->ccExit_);
+        }
+
+        {
+            // add console commands
+            FunctorMember01<GameStateBase, const std::string&>* functor = createFunctor(&GameStateBase::requestState);
+            functor->setObject(this);
+            this->ccSelectGameState_ = createConsoleCommand(functor, "selectGameState");
+            CommandExecutor::addConsoleCommandShortcut(this->ccSelectGameState_);
+        }
 
         {
@@ -85,38 +148,18 @@
             CommandExecutor::addConsoleCommandShortcut(this->ccPause_).accessLevel(AccessLevel::Offline);
         }
-
-        // Load level directly?
-        bool loadLevel = false;
-        if (CommandLine::getValue("standalone").getBool())
-        {
-            Game::getInstance().requestStates("graphics, standalone, level");
-            loadLevel = true;
-        }
-        if (CommandLine::getValue("server").getBool())
-        {
-            Game::getInstance().requestStates("graphics, server, level");
-            loadLevel = true;
-        }
-        if (CommandLine::getValue("client").getBool())
-        {
-            Game::getInstance().requestStates("graphics, client, level");
-            loadLevel = true;
-        }
-        if (CommandLine::getValue("dedicated").getBool())
-        {
-            Game::getInstance().requestStates("dedicated, level");
-            loadLevel = true;
-        }
-        
-        // Determine where to start otherwise
-        if (!loadLevel && !CommandLine::getValue("console").getBool())
-        {
-            // Also load graphics
-            Game::getInstance().requestState("graphics");
-        }
-    }
-
-    void GSRoot::deactivate()
-    {
+    }
+
+    void GSRoot::leave()
+    {
+        // destroy console commands
+        delete this->ccExit_;
+        delete this->ccSelectGameState_;
+
+        delete this->shell_;
+        delete this->tclThreadManager_;
+        delete this->tclBind_;
+
+        delete this->luaBind_;
+
         if (this->ccSetTimeFactor_)
         {
@@ -132,14 +175,9 @@
     }
 
-    void GSRoot::update(const Clock& time)
-    {
-        if (this->getActivity().topState)
-        {
-            // This state can not 'survive' on its own.
-            // Load a user interface therefore
-            Game::getInstance().requestState("ioConsole");
-        }
-
+    void GSRoot::ticked(const Clock& time)
+    {
         uint64_t timeBeforeTick = time.getRealMicroseconds();
+
+        TclThreadManager::getInstance().tick(time.getDeltaTime());
 
         for (ObjectList<TimerBase>::iterator it = ObjectList<TimerBase>::begin(); it; ++it)
@@ -160,6 +198,79 @@
         uint64_t timeAfterTick = time.getRealMicroseconds();
 
-        // Also add our tick time
-        Game::getInstance().addTickTime(timeAfterTick - timeBeforeTick);
+        // STATISTICS
+        assert(timeAfterTick - timeBeforeTick >= 0 );
+        statisticsTickInfo tickInfo = {timeAfterTick, timeAfterTick - timeBeforeTick};
+        statisticsTickTimes_.push_back(tickInfo);
+        assert(statisticsTickTimes_.back().tickLength==tickInfo.tickLength);
+        this->periodTickTime_ += tickInfo.tickLength;
+
+        // Ticks GSGraphics or GSDedicated
+        this->tickChild(time);
+
+        if (timeAfterTick > statisticsStartTime_ + statisticsRefreshCycle_)
+        {
+            std::list<statisticsTickInfo>::iterator it = this->statisticsTickTimes_.begin();
+            assert(it != this->statisticsTickTimes_.end());
+            int64_t lastTime = timeAfterTick - statisticsAvgLength_;
+            if ((int64_t)it->tickTime < lastTime)
+            {
+                do
+                {
+                    assert(this->periodTickTime_ > it->tickLength);
+                    this->periodTickTime_ -= it->tickLength;
+                    ++it;
+                    assert(it != this->statisticsTickTimes_.end());
+                } while ((int64_t)it->tickTime < lastTime);
+                this->statisticsTickTimes_.erase(this->statisticsTickTimes_.begin(), it);
+            }
+
+            uint32_t framesPerPeriod = this->statisticsTickTimes_.size();
+            this->avgFPS_ = (float)framesPerPeriod / (timeAfterTick - this->statisticsTickTimes_.front().tickTime) * 1000000.0;
+            this->avgTickTime_ = (float)this->periodTickTime_ / framesPerPeriod / 1000.0;
+
+            statisticsStartTime_ = timeAfterTick;
+        }
+
+    }
+
+    /**
+    @note
+        The code of this function has been copied and adjusted from OGRE, an open source graphics engine.
+            (Object-oriented Graphics Rendering Engine)
+        For the latest info, see http://www.ogre3d.org/
+
+        Copyright (c) 2000-2008 Torus Knot Software Ltd
+
+        OGRE is licensed under the LGPL. For more info, see OGRE license.
+    */
+    void GSRoot::setThreadAffinity(unsigned int limitToCPU)
+    {
+#ifdef ORXONOX_PLATFORM_WINDOWS
+        // Get the current process core mask
+        DWORD procMask;
+        DWORD sysMask;
+#  if _MSC_VER >= 1400 && defined (_M_X64)
+        GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask);
+#  else
+        GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask);
+#  endif
+
+        // If procMask is 0, consider there is only one core available
+        // (using 0 as procMask will cause an infinite loop below)
+        if (procMask == 0)
+            procMask = 1;
+
+        // if the core specified with limitToCPU is not available, take the lowest one
+        if (!(procMask & (1 << limitToCPU)))
+            limitToCPU = 0;
+
+        // Find the lowest core that this process uses and limitToCPU suggests
+        DWORD threadMask = 1;
+        while ((threadMask & procMask) == 0 || (threadMask < (1u << limitToCPU)))
+            threadMask <<= 1;
+
+        // Set affinity to the first core
+        SetThreadAffinityMask(GetCurrentThread(), threadMask);
+#endif
     }
 
@@ -170,5 +281,5 @@
     void GSRoot::setTimeFactor(float factor)
     {
-        if (GameMode::isMaster())
+        if (Core::isMaster())
         {
             if (!this->bPaused_)
@@ -188,5 +299,5 @@
     void GSRoot::pause()
     {
-        if (GameMode::isMaster())
+        if (Core::isMaster())
         {
             if (!this->bPaused_)
@@ -203,3 +314,13 @@
         }
     }
+
+    ////////////////////////
+    // TimeFactorListener //
+    ////////////////////////
+    float TimeFactorListener::timefactor_s = 1.0f;
+
+    TimeFactorListener::TimeFactorListener()
+    {
+        RegisterRootObject(TimeFactorListener);
+    }
 }
Index: code/branches/questsystem5/src/orxonox/gamestates/GSRoot.h
===================================================================
--- code/branches/questsystem5/src/orxonox/gamestates/GSRoot.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/gamestates/GSRoot.h	(revision 2908)
@@ -31,18 +31,29 @@
 
 #include "OrxonoxPrereqs.h"
-#include "core/GameState.h"
+
+#include <list>
+#include <OgreLog.h>
+#include "core/RootGameState.h"
 #include "core/OrxonoxClass.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSRoot : public GameState
+    class _OrxonoxExport GSRoot : public RootGameState, public OrxonoxClass
     {
+        friend class ClassIdentifier<GSRoot>;
+
     public:
-        GSRoot(const std::string& name);
+        struct statisticsTickInfo
+        {
+            uint64_t    tickTime;
+            uint32_t    tickLength;
+        };
+    
+    public:
+        GSRoot();
         ~GSRoot();
 
-        void activate();
-        void deactivate();
-        void update(const Clock& time);
+        void exitGame()
+        { requestState("root"); }
 
         // this has to be public because proteced triggers a bug in msvc
@@ -52,12 +63,61 @@
         float getTimeFactor() { return this->timeFactor_; }
 
+        float getAvgTickTime() { return this->avgTickTime_; }
+        float getAvgFPS()      { return this->avgFPS_; }
+
+        inline void addTickTime(uint32_t length)
+            { assert(!this->statisticsTickTimes_.empty()); this->statisticsTickTimes_.back().tickLength += length;
+              this->periodTickTime_+=length; }
+
     private:
+        void enter();
+        void leave();
+        void ticked(const Clock& time);
+
+        void setConfigValues();
+        void setThreadAffinity(unsigned int limitToCPU);
+
         float                 timeFactor_;       //!< A factor that sets the gamespeed. 1 is normal.
         bool                  bPaused_;
         float                 timeFactorPauseBackup_;
+        TclBind*              tclBind_;
+        TclThreadManager*     tclThreadManager_;
+        Shell*                shell_;
+        LuaBind*              luaBind_;
+
+        // variables for time statistics
+        uint64_t              statisticsStartTime_;
+        std::list<statisticsTickInfo>
+                              statisticsTickTimes_;
+        uint32_t              periodTickTime_;
+        float                 avgFPS_;
+        float                 avgTickTime_;
+
+        // config values
+        unsigned int          statisticsRefreshCycle_;
+        unsigned int          statisticsAvgLength_;
 
         // console commands
+        ConsoleCommand*       ccExit_;
+        ConsoleCommand*       ccSelectGameState_;
         ConsoleCommand*       ccSetTimeFactor_;
         ConsoleCommand*       ccPause_;
+    };
+
+    class _OrxonoxExport TimeFactorListener : virtual public OrxonoxClass
+    {
+        friend class GSRoot;
+
+        public:
+            TimeFactorListener();
+            virtual ~TimeFactorListener() {}
+
+        protected:
+            virtual void changedTimeFactor(float factor_new, float factor_old) {}
+            inline float getTimeFactor() const
+                { return TimeFactorListener::timefactor_s; }
+
+        private:
+            static float timefactor_s;
     };
 }
Index: code/branches/questsystem5/src/orxonox/gamestates/GSServer.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/gamestates/GSServer.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/gamestates/GSServer.cc	(revision 2908)
@@ -31,16 +31,13 @@
 
 #include "core/CommandLine.h"
-#include "core/Game.h"
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "network/Server.h"
 
 namespace orxonox
 {
-    AddGameState(GSServer, "server");
-
     SetCommandLineArgument(port, 55556).shortcut("p").information("0-65535");
 
-    GSServer::GSServer(const std::string& name)
-        : GameState(name)
+    GSServer::GSServer()
+        : GameState<GSGraphics>("server")
         , server_(0)
     {
@@ -51,25 +48,31 @@
     }
 
-    void GSServer::activate()
+    void GSServer::enter()
     {
-        GameMode::setHasServer(true);
+        Core::setHasServer(true);
 
         this->server_ = new Server(CommandLine::getValue("port"));
         COUT(0) << "Loading scene in server mode" << std::endl;
 
+        GSLevel::enter(this->getParent()->getViewport());
+
         server_->open();
     }
 
-    void GSServer::deactivate()
+    void GSServer::leave()
     {
+        GSLevel::leave();
+
         this->server_->close();
         delete this->server_;
 
-        GameMode::setHasServer(false);
+        Core::setHasServer(false);
     }
 
-    void GSServer::update(const Clock& time)
+    void GSServer::ticked(const Clock& time)
     {
-        server_->update(time);
+        GSLevel::ticked(time);
+        server_->tick(time.getDeltaTime());
+        this->tickChild(time);
     }
 }
Index: code/branches/questsystem5/src/orxonox/gamestates/GSServer.h
===================================================================
--- code/branches/questsystem5/src/orxonox/gamestates/GSServer.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/gamestates/GSServer.h	(revision 2908)
@@ -31,21 +31,22 @@
 
 #include "OrxonoxPrereqs.h"
-#include "core/GameState.h"
 #include "network/NetworkPrereqs.h"
+#include "GSLevel.h"
+#include "GSGraphics.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSServer : public GameState
+    class _OrxonoxExport GSServer : public GameState<GSGraphics>, public GSLevel
     {
     public:
-        GSServer(const std::string& name);
+        GSServer();
         ~GSServer();
 
-        void activate();
-        void deactivate();
-        void update(const Clock& time);
+    private:
+        void enter();
+        void leave();
+        void ticked(const Clock& time);
 
-    private:
-        Server* server_;
+        Server*      server_;
     };
 }
Index: code/branches/questsystem5/src/orxonox/gamestates/GSStandalone.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/gamestates/GSStandalone.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/gamestates/GSStandalone.cc	(revision 2908)
@@ -30,18 +30,10 @@
 #include "GSStandalone.h"
 
-#include <OgreViewport.h>
-#include <OgreCamera.h>
-#include "core/Game.h"
-#include "core/GameMode.h"
-#include "core/ConsoleCommand.h"
-#include "gui/GUIManager.h"
-#include "GraphicsManager.h"
+#include "core/Core.h"
 
 namespace orxonox
 {
-    AddGameState(GSStandalone, "standalone");
-
-    GSStandalone::GSStandalone(const std::string& name)
-        : GameState(name)
+    GSStandalone::GSStandalone()
+        : GameState<GSGraphics>("standalone")
     {
     }
@@ -51,17 +43,22 @@
     }
 
+    void GSStandalone::enter()
+    {
+        Core::setIsStandalone(true);
 
-    void GSStandalone::activate()
-    {
-        GameMode::setIsStandalone(true);
+        GSLevel::enter(this->getParent()->getViewport());
     }
 
-    void GSStandalone::deactivate()
+    void GSStandalone::leave()
     {
-        GameMode::setIsStandalone(false);
+        GSLevel::leave();
+
+        Core::setIsStandalone(false);
     }
 
-    void GSStandalone::update(const Clock& time)
+    void GSStandalone::ticked(const Clock& time)
     {
+        GSLevel::ticked(time);
+        this->tickChild(time);
     }
 }
Index: code/branches/questsystem5/src/orxonox/gamestates/GSStandalone.h
===================================================================
--- code/branches/questsystem5/src/orxonox/gamestates/GSStandalone.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/gamestates/GSStandalone.h	(revision 2908)
@@ -31,19 +31,19 @@
 
 #include "OrxonoxPrereqs.h"
-#include "core/GameState.h"
+#include "GSLevel.h"
+#include "GSGraphics.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSStandalone : public GameState
+    class _OrxonoxExport GSStandalone : public GameState<GSGraphics>, public GSLevel
     {
     public:
-        GSStandalone(const std::string& name);
+        GSStandalone();
         ~GSStandalone();
 
-        void activate();
-        void deactivate();
-        void update(const Clock& time);
-
     private:
+        void enter();
+        void leave();
+        void ticked(const Clock& time);
     };
 }
Index: code/branches/questsystem5/src/orxonox/gui/GUIManager.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/gui/GUIManager.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/gui/GUIManager.cc	(revision 2908)
@@ -22,7 +22,6 @@
  *   Author:
  *      Reto Grieder
- *      Benjamin Knecht
  *   Co-authors:
- *
+ *      ...
  *
  */
@@ -37,6 +36,7 @@
 #include "GUIManager.h"
 
-#include <boost/filesystem/path.hpp>
+#include <boost/filesystem.hpp>
 #include <OgreRenderWindow.h>
+#include <OgreRoot.h>
 #include <CEGUI.h>
 #include <CEGUIDefaultLogger.h>
@@ -50,7 +50,8 @@
 
 #include "util/Exception.h"
+#include "core/input/InputManager.h"
+#include "core/input/SimpleInputState.h"
 #include "core/ConsoleCommand.h"
 #include "core/Core.h"
-#include "core/Clock.h"
 #include "ToluaBindCore.h"
 #include "ToluaBindOrxonox.h"
@@ -62,8 +63,15 @@
 namespace orxonox
 {
+    SetConsoleCommandShortcut(GUIManager, showGUI_s).keybindMode(KeybindMode::OnPress);
+
     GUIManager* GUIManager::singletonRef_s = 0;
 
     GUIManager::GUIManager()
-        : renderWindow_(0)
+        //: emptySceneManager_(0)
+        : backgroundSceneManager_(0)
+        //, emptyCamera_(0)
+        , backgroundCamera_(0)
+        //, viewport_(0)
+        , renderWindow_(0)
         , guiRenderer_(0)
         , resourceProvider_(0)
@@ -76,12 +84,20 @@
     }
 
-    /**
-    @brief
-        Deconstructor of the GUIManager
-
-        Basically shuts down CEGUI and destroys the Lua engine and afterwards the interface to the Ogre engine.
-    */
     GUIManager::~GUIManager()
     {
+        if (backgroundCamera_)
+            backgroundSceneManager_->destroyCamera(backgroundCamera_);
+
+        if (backgroundSceneManager_)
+        {
+            // We have to make sure the SceneManager is not anymore referenced.
+            // For the case that the target SceneManager was yet another one, it
+            // wouldn't matter anyway since this is the destructor.
+            guiRenderer_->setTargetSceneManager(0);
+            Ogre::Root::getSingleton().destroySceneManager(backgroundSceneManager_);
+        }
+
+        InputManager::getInstance().requestDestroyState("gui");
+
         if (guiSystem_)
             delete guiSystem_;
@@ -94,4 +110,8 @@
 	        lua_pushnil(luaState_);
 	        lua_setglobal(luaState_, "Core");
+            // TODO: deleting the script module fails an assertion.
+            // However there is not much we can do about it since it occurs too when
+            // we don't open Core or Orxonox. Might be a CEGUI issue.
+            // The memory leak is not a problem anyway..
             delete scriptModule_;
         }
@@ -103,18 +123,4 @@
     }
 
-    /**
-    @brief
-        Initialises the GUIManager by starting up CEGUI
-    @param renderWindow
-        Ogre's render window. Without this, the GUI cannot be displayed.
-    @return true if success, otherwise false
-
-        Before this call the GUIManager won't do anything, but can be accessed.
-
-        Creates the interface to Ogre, sets up the CEGUI renderer and the Lua script module together with the Lua engine.
-        The log is set up and connected to the CEGUILogger.
-        After Lua setup tolua++-elements are linked to Lua-state to give Lua access to C++-code.
-        Finally initial Lua code is executed (maybe we can do this with the CEGUI startup script automatically).
-    */
     bool GUIManager::initialise(Ogre::RenderWindow* renderWindow)
     {
@@ -129,6 +135,13 @@
                 renderWindow_ = renderWindow;
 
+                // Full screen viewport with Z order = 0 (top most). Don't yet feed a camera (so nothing gets rendered)
+                //this->viewport_ = renderWindow_->addViewport(0, 3);
+                //this->viewport_->setOverlaysEnabled(false);
+                //this->viewport_->setShadowsEnabled(false);
+                //this->viewport_->setSkiesEnabled(false);
+                //this->viewport_->setClearEveryFrame(false);
+
                 // Note: No SceneManager specified yet
-                this->guiRenderer_ = new OgreCEGUIRenderer(renderWindow_, Ogre::RENDER_QUEUE_OVERLAY, true, 3000);
+                this->guiRenderer_ = new OgreCEGUIRenderer(renderWindow_, Ogre::RENDER_QUEUE_MAIN, true, 3000);
                 this->resourceProvider_ = guiRenderer_->createResourceProvider();
                 this->resourceProvider_->setDefaultResourceGroup("GUI");
@@ -153,6 +166,13 @@
                 tolua_Orxonox_open(this->scriptModule_->getLuaState());
 
-                // initialise the basic lua code
-                loadLuaCode();
+                // register us as input handler
+                SimpleInputState* state = InputManager::getInstance().createInputState<SimpleInputState>("gui", 30);
+                state->setHandler(this);
+                state->setJoyStickHandler(&InputManager::EMPTY_HANDLER);
+
+                // load the background scene
+                loadScenes();
+                //CEGUI::KeyEventArgs e;
+                //e.codepoint
             }
             catch (CEGUI::Exception& ex)
@@ -172,24 +192,31 @@
     }
 
-    /**
-    @brief
-        Calls main Lua script
-    @todo
-        Replace loadGUI.lua with loadGUI_2.lua after merging this back to trunk.
-        However CEGUI is able to execute a startup script. We could maybe put this call in this startup code.
-
-        This function calls the main Lua script for our GUI.
-
-        Additionally we set the datapath variable in Lua. This is needed so Lua can access the data used for the GUI.
-    */
-    void GUIManager::loadLuaCode()
-    {
+    void GUIManager::loadScenes()
+    {
+        // first of all, we need to have our own SceneManager for the GUI. The reason
+        // is that we might have multiple viewports when in play mode (e.g. the view of
+        // a camera fixed at the back of the ship). That forces us to create our own
+        // full screen viewport that is on top of all the others, but doesn't clear the
+        // port before rendering, so everything from the GUI gets on top eventually.
+        // But in order to realise that, we also need a SceneManager with an empty scene,
+        // because the SceneManager is responsible for the render queue.
+        //this->emptySceneManager_ = Ogre::Root::getSingleton()
+        //    .createSceneManager(Ogre::ST_GENERIC, "GUI/EmptySceneManager");
+
+        // we also need a camera or we won't see anything at all.
+        // The camera settings don't matter at all for an empty scene since the GUI
+        // gets rendered on top of the screen rather than into the scene.
+        //this->emptyCamera_ = this->emptySceneManager_->createCamera("GUI/EmptyCamera");
+
+        // Create another SceneManager that enables to display some 3D
+        // scene in the background of the main menu.
+        this->backgroundSceneManager_ = Ogre::Root::getSingleton()
+            .createSceneManager(Ogre::ST_GENERIC, "GUI/BackgroundSceneManager");
+        this->backgroundCamera_ = backgroundSceneManager_->createCamera("GUI/BackgroundCamera");
+
+        // TODO: create something 3D
         try
         {
-            // call main Lua script
-            this->scriptModule_->executeScriptFile("loadGUI_2.lua", "GUI");
-            // set datapath for GUI data
-            lua_pushfstring(this->scriptModule_->getLuaState(), Core::getMediaPathString().c_str());
-            lua_setglobal(this->scriptModule_->getLuaState(), "datapath");
+            this->scriptModule_->executeScriptFile("loadGUI.lua", "GUI");
         }
         catch (CEGUI::Exception& ex)
@@ -204,72 +231,39 @@
     }
 
-    /**
-    @brief
-        used to tick the GUI
-    @param time
-        clock which provides time value for the GUI System
-
-        Ticking the GUI means updating it with a certain regularity.
-        The elapsed time since the last call is given in the time value provided by the clock.
-        This time value is then used to provide a fluent animation of the GUI.
-    */
-    void GUIManager::update(const Clock& time)
-    {
-        assert(guiSystem_);
-        guiSystem_->injectTimePulse(time.getDeltaTime());
-    }
-
-    /**
-    @brief
-        Executes Lua code
-    @param str
-        reference to string object holding the Lua code which is to be executed
-
-        This function gives total access to the GUI. You can execute ANY Lua code here.
-    */
-    void GUIManager::executeCode(const std::string& str)
-    {
-        try
-        {
-            this->scriptModule_->executeString(str);
-        }
-        catch (CEGUI::Exception& ex)
-        {
-            COUT(2) << "CEGUI Error: \"" << ex.getMessage() << "\" while executing code \"" << str << "\"" << std::endl;
-        }
-    }
-
-    /**
-    @brief
-        Tells the GUIManager which SceneManager to use
-    @param camera
-        The current camera on which the GUI should be displayed on.
-
-        In fact the GUIManager needs the SceneManager and not the Camera to display the GUI.
-        This means the GUI is not bound to a camera but rather to the SceneManager.
-        Hidding the GUI when needed can therefore not be solved by just NOT setting the current camera.
-    */
-    void GUIManager::setCamera(Ogre::Camera* camera)
-    {
-        this->guiRenderer_->setTargetSceneManager(camera->getSceneManager());
-    }
-
-    /**
-    @brief
-        Displays specified GUI on screen
-    @param name
-        The name of the GUI
-
-        The function executes the Lua function with the same name in case the GUIManager is ready.
-        For more details check out loadGUI_2.lua where the function presides.
-    */
-    void GUIManager::showGUI(const std::string& name)
+    void GUIManager::showGUI(const std::string& name, Ogre::SceneManager* sceneManager)// bool showBackground)
     {
         if (state_ != Uninitialised)
         {
-            //COUT(3) << "Loading GUI " << name << std::endl;
+            if (state_ == OnDisplay)
+                hideGUI();
+
+            COUT(3) << "Loading GUI " << name << std::endl;
             try
             {
-                this->scriptModule_->executeString(std::string("showGUI(\"") + name + "\")");
+                if (!sceneManager)
+                {
+                    // currently, only an image is loaded. We could do 3D, see loadBackground.
+                    //this->viewport_->setClearEveryFrame(true);
+                    this->guiRenderer_->setTargetSceneManager(this->backgroundSceneManager_);
+                    //this->viewport_->setCamera(this->backgroundCamera_);
+
+                    lua_pushboolean(this->scriptModule_->getLuaState(), true);
+                    lua_setglobal(this->scriptModule_->getLuaState(), "showBackground");
+                }
+                else
+                {
+                    //this->viewport_->setClearEveryFrame(false);
+                    this->guiRenderer_->setTargetSceneManager(sceneManager);
+                    //this->viewport_->setCamera(this->emptyCamera_);
+
+                    lua_pushboolean(this->scriptModule_->getLuaState(), false);
+                    lua_setglobal(this->scriptModule_->getLuaState(), "showBackground");
+                }
+
+                this->scriptModule_->executeScriptGlobal("showMainMenu");
+
+                InputManager::getInstance().requestEnterState("gui");
+
+                this->state_ = OnDisplay;
             }
             catch (CEGUI::Exception& ex)
@@ -288,13 +282,14 @@
     }
 
-    /**
-    @brief
-        Function receiving a mouse button pressed event.
-    @param id
-        ID of the mouse button which got pressed
-
-        This function is inherited by MouseHandler and injects the event into CEGUI.
-        It is for CEGUI to process the event.
-    */
+    void GUIManager::hideGUI()
+    {
+        if (this->state_ != OnDisplay)
+            return;
+        //this->viewport_->setCamera(0);
+        this->guiRenderer_->setTargetSceneManager(0);
+        this->state_ = Ready;
+        InputManager::getInstance().requestLeaveState("gui");
+    }
+
     void GUIManager::mouseButtonPressed(MouseButtonCode::ByEnum id)
     {
@@ -310,13 +305,4 @@
     }
 
-    /**
-    @brief
-        Function receiving a mouse button released event.
-    @param id
-        ID of the mouse button which got released
-
-        This function is inherited by MouseHandler and injects the event into CEGUI.
-        It is for CEGUI to process the event.
-    */
     void GUIManager::mouseButtonReleased(MouseButtonCode::ByEnum id)
     {
@@ -332,14 +318,5 @@
     }
 
-    /**
-    @brief
-        converts mouse event code to CEGUI event code
-    @param button
-        code of the mouse button as we use it in Orxonox
-    @return
-        code of the mouse button as it is used by CEGUI
-
-        Simple convertion from mouse event code in Orxonox to the one used in CEGUI.
-     */
+
     inline CEGUI::MouseButton GUIManager::convertButton(MouseButtonCode::ByEnum button)
     {
Index: code/branches/questsystem5/src/orxonox/gui/GUIManager.h
===================================================================
--- code/branches/questsystem5/src/orxonox/gui/GUIManager.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/gui/GUIManager.h	(revision 2908)
@@ -23,5 +23,5 @@
  *      Reto Grieder
  *   Co-authors:
- *      Benjamin Knecht
+ *      ...
  *
  */
@@ -49,13 +49,6 @@
 {
     /**
-    @class GUIManager
     @brief
-        Provides a simple interface to CEGUI with tolua methods and console commands. It also acts as a key and mouse handler.
-
-        The GUIManager is a singleton and can be called anywhere when access on the GUI is needed.
-        Creation of the GUIManager is therefore not possible and the cunstructor is private.
-
-        Since the GUI needs user input, the GUIManager implements the functions needed to act as a key and/or mouse handler.
-        Those input events are then injected into CEGUI in Lua.
+        Provides a simple interface to CEGUI with tolua methods and console commands
     */
     class _OrxonoxExport GUIManager
@@ -66,13 +59,9 @@
 // tolua_end
     public:
-        /**
-        @enum State
-            The current state of the GUIManager. There should maybe be more (or we can omit this totally).
-        */
         enum State
         {
-            Uninitialised,  //!< Initial state of the GUIManager
-            Ready,          //!< State after initialisation if ready
-            OnDisplay       //!< State if GUI is displayed
+            Uninitialised,
+            Ready,
+            OnDisplay
         };
 
@@ -81,11 +70,18 @@
 
         bool initialise(Ogre::RenderWindow* renderWindow);
+        void tick(float dt)
+        {
+            assert(guiSystem_);
+            guiSystem_->injectTimePulse(dt);
+        }
+        void showGUI(const std::string& name, Ogre::SceneManager* sceneManager);// bool showBackground); // tolua_export
+        void hideGUI(); // tolua_export
 
-        void update(const Clock& time);
+        Ogre::Camera* getCamera() { return this->backgroundCamera_; }
 
-        void showGUI(const std::string& name);
-        void executeCode(const std::string& str);
-
-        void setCamera(Ogre::Camera* camera);
+        static void showGUI_s(const std::string& name, Ogre::SceneManager* sceneManager)//bool showBackground)
+        {
+            getInstance().showGUI(name, sceneManager);
+        }
 
         static GUIManager& getInstance()    { assert(singletonRef_s); return *singletonRef_s; } // tolua_export
@@ -93,41 +89,47 @@
 
     private:
-        GUIManager(const GUIManager& instance);                 //!< private constructor (this is a singleton class)
+        GUIManager(const GUIManager& instance);
 
-        void loadLuaCode();
+        void keyPressed (const KeyEvent& evt)
+        { guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text); }
+        void keyReleased(const KeyEvent& evt)
+        { guiSystem_->injectKeyUp(evt.key); }
+        void keyHeld    (const KeyEvent& evt)
+        { }
 
-        // keyHandler functions
-        void keyPressed (const KeyEvent& evt)
-            { guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text); }
-        void keyReleased(const KeyEvent& evt)
-            { guiSystem_->injectKeyUp(evt.key); }
-        void keyHeld    (const KeyEvent& evt) { }
-
-        // mouseHandler functions
         void mouseButtonPressed (MouseButtonCode::ByEnum id);
         void mouseButtonReleased(MouseButtonCode::ByEnum id);
-        void mouseButtonHeld    (MouseButtonCode::ByEnum id) { }
+        void mouseButtonHeld    (MouseButtonCode::ByEnum id)
+        { }
         void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)
-            { guiSystem_->injectMouseMove(rel.x, rel.y); }
+        { guiSystem_->injectMouseMove(rel.x, rel.y); }
         void mouseScrolled      (int abs, int rel)
-            { guiSystem_->injectMouseWheelChange(rel);}
+        { guiSystem_->injectMouseWheelChange(rel);}
 
-        void updateInput(float dt)  { }
-        void updateKey  (float dt)  { }
-        void updateMouse(float dt)  { }
+        void tickInput(float dt) { }
+        void tickKey(float dt) { }
+        void tickMouse(float dt) { }
+
+        void loadScenes();
+
+        //Ogre::SceneManager*       emptySceneManager_;
+        Ogre::SceneManager*       backgroundSceneManager_;
+        //Ogre::Camera*             emptyCamera_;
+        Ogre::Camera*             backgroundCamera_;
+        //Ogre::Viewport*           viewport_;
+        Ogre::RenderWindow*       renderWindow_;
+        CEGUI::OgreCEGUIRenderer* guiRenderer_;
+        CEGUI::ResourceProvider*  resourceProvider_;
+        CEGUI::LuaScriptModule*   scriptModule_;
+        CEGUI::DefaultLogger*     ceguiLogger_;
+        CEGUI::System*            guiSystem_;
+        CEGUI::Imageset*          backgroundImage_;
+        lua_State*                luaState_;
+
+        State state_;
 
         static CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button);
 
-        Ogre::RenderWindow*         renderWindow_;      //!< Ogre's render window to give CEGUI access to it
-        CEGUI::OgreCEGUIRenderer*   guiRenderer_;       //!< CEGUI's interface to the Ogre Engine
-        CEGUI::ResourceProvider*    resourceProvider_;  //!< CEGUI's resource provider
-        CEGUI::LuaScriptModule*     scriptModule_;      //!< CEGUI's script module to use Lua
-        CEGUI::DefaultLogger*       ceguiLogger_;       //!< CEGUI's logger to be able to log CEGUI errors in our log
-        CEGUI::System*              guiSystem_;         //!< CEGUI's main system
-        lua_State*                  luaState_;          //!< Lua state, access point to the Lua engine
-
-        State                       state_;             //!< reflects state of the GUIManager
-
-        static GUIManager*          singletonRef_s;     //!< Singleton reference to GUIManager
+        static GUIManager*        singletonRef_s;
     }; // tolua_export
 } // tolua_export
Index: code/branches/questsystem5/src/orxonox/objects/CMakeLists.txt
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/CMakeLists.txt	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/CMakeLists.txt	(revision 2908)
@@ -8,5 +8,4 @@
   RadarListener.cc
   RadarViewable.cc
-  Teamcolourable.cc
   Tickable.cc
   Test.cc
Index: code/branches/questsystem5/src/orxonox/objects/EventTarget.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/EventTarget.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/EventTarget.cc	(revision 2908)
@@ -66,5 +66,5 @@
     void EventTarget::addAsEvent(BaseObject* object)
     {
-        if (object != static_cast<BaseObject*>(this))
+        if (object != (BaseObject*)this)
             object->addEvent(this, "");
     }
Index: code/branches/questsystem5/src/orxonox/objects/Level.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/Level.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/Level.cc	(revision 2908)
@@ -105,26 +105,17 @@
     {
         Identifier* identifier = ClassByString(gametype);
-
-        if (!identifier || !identifier->isA(Class(Gametype)))
+        if (identifier && identifier->isA(Class(Gametype)))
         {
-            COUT(0) << "Error: \"" << gametype << "\" is not a valid gametype." << std::endl;
-            identifier = Class(Gametype);
-            this->gametype_ = "Gametype";
-        }
-        else
             this->gametype_ = gametype;
 
-std::cout << "Load Gametype: " << this->gametype_ << std::endl;
+            Gametype* rootgametype = dynamic_cast<Gametype*>(identifier->fabricate(this));
+            this->setGametype(rootgametype);
 
-        Gametype* rootgametype = dynamic_cast<Gametype*>(identifier->fabricate(this));
-        this->setGametype(rootgametype);
+            for (std::list<BaseObject*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
+                (*it)->setGametype(rootgametype);
 
-std::cout << "root gametype: " << rootgametype->getIdentifier()->getName() << std::endl;
-
-        for (std::list<BaseObject*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
-            (*it)->setGametype(rootgametype);
-
-        if (LevelManager::getInstancePtr())
-            LevelManager::getInstance().requestActivity(this);
+            if (LevelManager::getInstancePtr())
+                LevelManager::getInstance().requestActivity(this);
+        }
     }
 
Index: code/branches/questsystem5/src/orxonox/objects/Radar.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/Radar.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/Radar.cc	(revision 2908)
@@ -144,5 +144,5 @@
             for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it)
             {
-                if (*it == static_cast<RadarViewable*>(this)->owner_)
+                if (*it == (RadarViewable*)this->owner_)
                     continue;
 
Index: code/branches/questsystem5/src/orxonox/objects/Scene.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/Scene.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/Scene.cc	(revision 2908)
@@ -41,5 +41,5 @@
 
 #include "core/CoreIncludes.h"
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "core/XMLPort.h"
 #include "tools/BulletConversions.h"
@@ -57,5 +57,5 @@
         this->bShadows_ = true;
 
-        if (GameMode::showsGraphics())
+        if (Core::showsGraphics())
         {
             if (Ogre::Root::getSingletonPtr())
@@ -99,5 +99,5 @@
                 Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
             }
-            else if (!GameMode::showsGraphics())
+            else if (!Core::showsGraphics())
             {
                 delete this->sceneManager_;
@@ -227,5 +227,5 @@
     void Scene::tick(float dt)
     {
-        if (!GameMode::showsGraphics())
+        if (!Core::showsGraphics())
         {
             // We need to update the scene nodes if we don't render
@@ -256,5 +256,5 @@
     void Scene::setSkybox(const std::string& skybox)
     {
-        if (GameMode::showsGraphics() && this->sceneManager_)
+        if (Core::showsGraphics() && this->sceneManager_)
             this->sceneManager_->setSkyBox(true, skybox);
 
@@ -264,5 +264,5 @@
     void Scene::setAmbientLight(const ColourValue& colour)
     {
-        if (GameMode::showsGraphics() && this->sceneManager_)
+        if (Core::showsGraphics() && this->sceneManager_)
             this->sceneManager_->setAmbientLight(colour);
 
@@ -272,5 +272,5 @@
     void Scene::setShadow(bool bShadow)
     {
-        if (GameMode::showsGraphics() && this->sceneManager_)
+        if (Core::showsGraphics() && this->sceneManager_)
         {
             if (bShadow)
Index: code/branches/questsystem5/src/orxonox/objects/Teamcolourable.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/Teamcolourable.cc	(revision 2907)
+++ 	(revision )
@@ -1,39 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#include "OrxonoxStableHeaders.h"
-#include "Teamcolourable.h"
-#include "core/CoreIncludes.h"
-
-namespace orxonox
-{
-    Teamcolourable::Teamcolourable()
-    {
-        RegisterRootObject(Teamcolourable);
-    }
-}
Index: code/branches/questsystem5/src/orxonox/objects/Teamcolourable.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/Teamcolourable.h	(revision 2907)
+++ 	(revision )
@@ -1,49 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _Teamcolourable_H__
-#define _Teamcolourable_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "util/Math.h"
-#include "core/OrxonoxClass.h"
-
-namespace orxonox
-{
-    class _OrxonoxExport Teamcolourable : virtual public OrxonoxClass
-    {
-        public:
-            virtual void setTeamColour(const ColourValue& colour) = 0;
-
-        protected:
-            Teamcolourable();
-    };
-}
-
-#endif /* _Teamcolourable_H__ */
Index: code/branches/questsystem5/src/orxonox/objects/controllers/AIController.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/controllers/AIController.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/controllers/AIController.cc	(revision 2908)
@@ -30,5 +30,5 @@
 #include "AIController.h"
 
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "core/CoreIncludes.h"
 #include "core/Executor.h"
@@ -45,5 +45,5 @@
         RegisterObject(AIController);
 
-        if (GameMode::isMaster())
+        if (Core::isMaster())
             this->actionTimer_.setTimer(ACTION_INTERVAL, true, this, createExecutor(createFunctor(&AIController::action)));
     }
Index: code/branches/questsystem5/src/orxonox/objects/controllers/CMakeLists.txt
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/controllers/CMakeLists.txt	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/controllers/CMakeLists.txt	(revision 2908)
@@ -5,4 +5,3 @@
   AIController.cc
   ScriptController.cc
-  PongAI.cc
 )
Index: code/branches/questsystem5/src/orxonox/objects/controllers/Controller.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/controllers/Controller.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/controllers/Controller.cc	(revision 2908)
@@ -43,8 +43,40 @@
         this->player_ = 0;
         this->controllableEntity_ = 0;
+        this->hud_ = 0;
+        this->bUpdateHUD_ = false;
     }
 
     Controller::~Controller()
     {
+        if (this->isInitialized() && this->hud_)
+            delete this->hud_;
+    }
+
+    void Controller::changedControllableEntity()
+    {
+        if (this->bUpdateHUD_)
+        {
+            this->updateHUD();
+            this->bUpdateHUD_ = false;
+        }
+
+        if (this->hud_)
+            this->hud_->setOwner(this->getControllableEntity());
+    }
+
+    void Controller::updateHUD()
+    {
+        if (this->hud_)
+        {
+            delete this->hud_;
+            this->hud_ = 0;
+        }
+
+        if (this->hudtemplate_ != "")
+        {
+            this->hud_ = new OverlayGroup(this);
+            this->hud_->addTemplate(this->hudtemplate_);
+            this->hud_->setOwner(this->getControllableEntity());
+        }
     }
 }
Index: code/branches/questsystem5/src/orxonox/objects/controllers/Controller.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/controllers/Controller.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/controllers/Controller.h	(revision 2908)
@@ -57,9 +57,31 @@
             inline ControllableEntity* getControllableEntity() const
                 { return this->controllableEntity_; }
-            virtual void changedControllableEntity() {}
+            virtual void changedControllableEntity();
+
+            inline void setHUDTemplate(const std::string& name)
+            {
+                if (name != this->hudtemplate_)
+                {
+                    this->hudtemplate_ = name;
+                    if (this->controllableEntity_)
+                        this->updateHUD();
+                    else
+                        this->bUpdateHUD_ = true;
+                }
+            }
+            inline const std::string& getHUDTemplate() const
+                { return this->hudtemplate_; }
+
+            inline OverlayGroup* getHUD() const
+                { return this->hud_; }
 
         protected:
+            void updateHUD();
+
             PlayerInfo* player_;
             ControllableEntity* controllableEntity_;
+            std::string hudtemplate_;
+            OverlayGroup* hud_;
+            bool bUpdateHUD_;
     };
 }
Index: code/branches/questsystem5/src/orxonox/objects/controllers/HumanController.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/controllers/HumanController.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/controllers/HumanController.cc	(revision 2908)
@@ -35,5 +35,4 @@
 #include "objects/worldentities/pawns/Pawn.h"
 #include "objects/gametypes/Gametype.h"
-#include "objects/infos/PlayerInfo.h"
 
 namespace orxonox
@@ -158,6 +157,4 @@
             if (pawn)
                 pawn->kill();
-            else if (HumanController::localController_s->player_)
-                HumanController::localController_s->player_->stopControl(HumanController::localController_s->controllableEntity_);
         }
     }
Index: code/branches/questsystem5/src/orxonox/objects/controllers/PongAI.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/controllers/PongAI.cc	(revision 2907)
+++ 	(revision )
@@ -1,254 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#include "OrxonoxStableHeaders.h"
-#include "PongAI.h"
-
-#include "core/CoreIncludes.h"
-#include "core/ConfigValueIncludes.h"
-#include "objects/worldentities/ControllableEntity.h"
-#include "objects/worldentities/PongBall.h"
-#include "tools/Timer.h"
-
-namespace orxonox
-{
-    CreateUnloadableFactory(PongAI);
-
-    const static float MAX_REACTION_TIME = 0.4;
-
-    PongAI::PongAI(BaseObject* creator) : Controller(creator)
-    {
-        RegisterObject(PongAI);
-
-        this->ball_ = 0;
-        this->ballDirection_ = Vector2::ZERO;
-        this->ballEndPosition_ = 0;
-        this->randomOffset_ = 0;
-        this->relHysteresisOffset_ = 0.02;
-        this->strength_ = 0.5;
-        this->movement_ = 0;
-        this->oldMove_ = 0;
-        this->bOscillationAvoidanceActive_ = false;
-
-        this->setConfigValues();
-    }
-
-    PongAI::~PongAI()
-    {
-        for (std::list<std::pair<Timer<PongAI>*, char> >::iterator it = this->reactionTimers_.begin(); it != this->reactionTimers_.end(); ++it)
-            delete (*it).first;
-    }
-
-    void PongAI::setConfigValues()
-    {
-        SetConfigValue(strength_, 0.5).description("A value from 0 to 1 where 0 is weak and 1 is strong.");
-    }
-
-    void PongAI::tick(float dt)
-    {
-        if (!this->ball_ || !this->getControllableEntity())
-            return;
-
-        Vector3 mypos = this->getControllableEntity()->getPosition();
-        Vector3 ballpos = this->ball_->getPosition();
-        Vector3 ballvel = this->ball_->getVelocity();
-        float hysteresisOffset = this->relHysteresisOffset_ * this->ball_->getFieldDimension().y;
-
-        char move = 0;
-        bool delay = false;
-
-        // Check in which direction the ball is flying
-        if ((mypos.x > 0 && ballvel.x < 0) || (mypos.x < 0 && ballvel.x > 0))
-        {
-            // The ball is flying away
-            this->ballDirection_.x = -1;
-            this->ballDirection_.y = 0;
-            this->bOscillationAvoidanceActive_ = false;
-
-            // Move to the middle
-            if (mypos.z > hysteresisOffset)
-                move = 1;
-            else if (mypos.z < -hysteresisOffset)
-                move = -1;
-        }
-        else if (ballvel.x == 0)
-        {
-            // The ball is standing still
-            this->ballDirection_.x = 0;
-            this->ballDirection_.y = 0;
-            this->bOscillationAvoidanceActive_ = false;
-        }
-        else
-        {
-            // The ball is approaching
-            if (this->ballDirection_.x != 1)
-            {
-                // The ball just startet to approach, initialize all values
-                this->ballDirection_.x = 1;
-                this->ballDirection_.y = sgn(ballvel.z);
-                this->ballEndPosition_ = 0;
-                this->randomOffset_ = 0;
-
-                this->calculateRandomOffset();
-                this->calculateBallEndPosition();
-                delay = true;
-                this->bOscillationAvoidanceActive_ = false;
-            }
-
-            if (this->ballDirection_.y != sgn(ballvel.z))
-            {
-                // The ball just bounced from a bound, recalculate the predicted end position
-                this->ballDirection_.y = sgn(ballvel.z);
-
-                this->calculateBallEndPosition();
-                delay = true;
-                this->bOscillationAvoidanceActive_ = false;
-            }
-
-            // Move to the predicted end position with an additional offset (to hit the ball with the side of the bat)
-            if (!this->bOscillationAvoidanceActive_)
-            {
-                float desiredZValue = this->ballEndPosition_ + this->randomOffset_;
-
-                if (mypos.z > desiredZValue + hysteresisOffset * (this->randomOffset_ < 0))
-                    move = 1;
-                else if (mypos.z < desiredZValue - hysteresisOffset * (this->randomOffset_ > 0))
-                    move = -1;
-            }
-
-            if (move != 0 && this->oldMove_ != 0 && move != this->oldMove_ && !delay)
-            {
-                // We had to correct our position because we moved too far
-                // (and delay ist false, so we're not in the wrong place because of a new end-position prediction)
-                if (fabs(mypos.z - this->ballEndPosition_) < 0.5 * this->ball_->getBatLength() * this->ball_->getFieldDimension().y)
-                {
-                    // We're not at the right position, but we still hit the ball, so just stay there to avoid oscillation
-                    move = 0;
-                    this->bOscillationAvoidanceActive_ = true;
-                }
-            }
-        }
-
-        this->oldMove_ = move;
-        this->move(move, delay);
-        this->getControllableEntity()->moveFrontBack(this->movement_);
-    }
-
-    void PongAI::calculateRandomOffset()
-    {
-        // Calculate the exponent for the position-formula
-        float exp = pow(10, 1 - 2*this->strength_); // strength: 0   -> exp = 10
-                                                    // strength: 0.5 -> exp = 1
-                                                    // strength: 1   -> exp = 0.1
-
-        // Calculate the relative position where to hit the ball with the bat
-        float position = pow(rnd(), exp); // exp > 1 -> position is more likely a small number
-                                          // exp < 1 -> position is more likely a large number
-
-        // The position shouln't be larger than 0.5 (50% of the bat-length from the middle is the end)
-        position *= 0.48;
-
-        // Both sides are equally probable
-        position *= rndsgn();
-
-        // Calculate the offset in world units
-        this->randomOffset_ = position * this->ball_->getBatLength() * this->ball_->getFieldDimension().y;
-    }
-
-    void PongAI::calculateBallEndPosition()
-    {
-        Vector3 position = this->ball_->getPosition();
-        Vector3 velocity = this->ball_->getVelocity();
-        Vector2 dimension = this->ball_->getFieldDimension();
-
-        // calculate end-height: current height + slope * distance
-        this->ballEndPosition_ = position.z + velocity.z / velocity.x * (-position.x + dimension.x / 2 * sgn(velocity.x));
-
-        // Calculate bounces
-        for (float limit = 0.35; limit < this->strength_ || this->strength_ > 0.99; limit += 0.4)
-        {
-            // Calculate a random prediction error, based on the vertical speed of the ball and the strength of the AI
-            float randomError = rnd(-1, 1) * dimension.y * (velocity.z / velocity.x / PongBall::MAX_REL_Z_VELOCITY) * (1 - this->strength_);
-
-            // Bounce from the lower bound
-            if (this->ballEndPosition_ > dimension.y / 2)
-            {
-                // Mirror the predicted position at the upper bound and add some random error
-                this->ballEndPosition_ = dimension.y - this->ballEndPosition_ + randomError;
-                continue;
-            }
-            // Bounce from the upper bound
-            if (this->ballEndPosition_ < -dimension.y / 2)
-            {
-                // Mirror the predicted position at the lower bound and add some random error
-                this->ballEndPosition_ = -dimension.y - this->ballEndPosition_ + randomError;
-                continue;
-            }
-            // No bounce - break
-            break;
-        }
-    }
-
-    void PongAI::move(char direction, bool bUseDelay)
-    {
-        // The current direction is either what we're doing right now (movement_) or what is last in the queue
-        char currentDirection = this->movement_;
-        if (this->reactionTimers_.size() > 0)
-            currentDirection = this->reactionTimers_.back().second;
-
-        // Only add changes of direction
-        if (direction == currentDirection)
-            return;
-
-        if (bUseDelay)
-        {
-            // Calculate delay
-            float delay = MAX_REACTION_TIME * (1 - this->strength_);
-
-            // Add a new Timer
-            Timer<PongAI>* timer = new Timer<PongAI>(delay, false, this, createExecutor(createFunctor(&PongAI::delayedMove)));
-            this->reactionTimers_.push_back(std::pair<Timer<PongAI>*, char>(timer, direction));
-        }
-        else
-        {
-            this->movement_ = direction;
-        }
-    }
-
-    void PongAI::delayedMove()
-    {
-        // Get the new movement direction from the timer list
-        this->movement_ = this->reactionTimers_.front().second;
-
-        // Destroy the timer and remove it from the list
-        Timer<PongAI>* timer = this->reactionTimers_.front().first;
-        delete timer;
-
-        this->reactionTimers_.pop_front();
-    }
-}
Index: code/branches/questsystem5/src/orxonox/objects/controllers/PongAI.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/controllers/PongAI.h	(revision 2907)
+++ 	(revision )
@@ -1,75 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _PongAI_H__
-#define _PongAI_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include <list>
-
-#include "Controller.h"
-#include "objects/Tickable.h"
-#include "util/Math.h"
-
-namespace orxonox
-{
-    class _OrxonoxExport PongAI : public Controller, public Tickable
-    {
-        public:
-            PongAI(BaseObject* creator);
-            virtual ~PongAI();
-
-            void setConfigValues();
-
-            virtual void tick(float dt);
-
-            void setPongBall(PongBall* ball)
-                { this->ball_ = ball; }
-
-        protected:
-            void calculateRandomOffset();
-            void calculateBallEndPosition();
-            void move(char direction, bool bUseDelay);
-            void delayedMove();
-
-            PongBall* ball_;
-            Vector2 ballDirection_;
-            float ballEndPosition_;
-            float randomOffset_;
-            float relHysteresisOffset_;
-            float strength_;
-
-            std::list<std::pair<Timer<PongAI>*, char> > reactionTimers_;
-            char movement_;
-            char oldMove_;
-            bool bOscillationAvoidanceActive_;
-    };
-}
-
-#endif /* _PongAI_H__ */
Index: code/branches/questsystem5/src/orxonox/objects/gametypes/CMakeLists.txt
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/gametypes/CMakeLists.txt	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/gametypes/CMakeLists.txt	(revision 2908)
@@ -1,6 +1,3 @@
 ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   Gametype.cc
-  Deathmatch.cc
-  TeamDeathmatch.cc
-  Pong.cc
 )
Index: code/branches/questsystem5/src/orxonox/objects/gametypes/Deathmatch.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/gametypes/Deathmatch.cc	(revision 2907)
+++ 	(revision )
@@ -1,135 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#include "OrxonoxStableHeaders.h"
-#include "Deathmatch.h"
-
-#include "core/CoreIncludes.h"
-#include "objects/infos/PlayerInfo.h"
-#include "objects/worldentities/pawns/Pawn.h"
-
-#include "network/Host.h"
-
-namespace orxonox
-{
-    CreateUnloadableFactory(Deathmatch);
-
-    Deathmatch::Deathmatch(BaseObject* creator) : Gametype(creator)
-    {
-        RegisterObject(Deathmatch);
-    }
-
-    void Deathmatch::start()
-    {
-        Gametype::start();
-
-        std::string message = "The match has started!";
-        COUT(0) << message << std::endl;
-        Host::Broadcast(message);
-    }
-
-    void Deathmatch::end()
-    {
-        Gametype::end();
-
-        std::string message = "The match has ended.";
-        COUT(0) << message << std::endl;
-        Host::Broadcast(message);
-    }
-
-    void Deathmatch::playerEntered(PlayerInfo* player)
-    {
-        Gametype::playerEntered(player);
-
-        std::string message = player->getName() + " entered the game";
-        COUT(0) << message << std::endl;
-        Host::Broadcast(message);
-    }
-
-    bool Deathmatch::playerLeft(PlayerInfo* player)
-    {
-        bool valid_player = Gametype::playerLeft(player);
-
-        if (valid_player)
-        {
-            std::string message = player->getName() + " left the game";
-            COUT(0) << message << std::endl;
-            Host::Broadcast(message);
-        }
-
-        return valid_player;
-    }
-
-    bool Deathmatch::playerChangedName(PlayerInfo* player)
-    {
-        bool valid_player = Gametype::playerChangedName(player);
-
-        if (valid_player)
-        {
-            std::string message = player->getOldName() + " changed name to " + player->getName();
-            COUT(0) << message << std::endl;
-            Host::Broadcast(message);
-        }
-
-        return valid_player;
-    }
-
-    void Deathmatch::pawnKilled(Pawn* victim, Pawn* killer)
-    {
-        if (victim && victim->getPlayer())
-        {
-            std::string message;
-            if (killer)
-            {
-                if (killer->getPlayer())
-                    message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName();
-                else
-                    message = victim->getPlayer()->getName() + " was killed";
-            }
-            else
-                message = victim->getPlayer()->getName() + " died";
-
-            COUT(0) << message << std::endl;
-            Host::Broadcast(message);
-        }
-
-        Gametype::pawnKilled(victim, killer);
-    }
-
-    void Deathmatch::playerScored(PlayerInfo* player)
-    {
-        Gametype::playerScored(player);
-
-        if (player)
-        {
-            std::string message = player->getName() + " scores!";
-            COUT(0) << message << std::endl;
-            Host::Broadcast(message);
-        }
-    }
-}
Index: code/branches/questsystem5/src/orxonox/objects/gametypes/Deathmatch.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/gametypes/Deathmatch.h	(revision 2907)
+++ 	(revision )
@@ -1,55 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _Deathmatch_H__
-#define _Deathmatch_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "Gametype.h"
-
-namespace orxonox
-{
-    class _OrxonoxExport Deathmatch : public Gametype
-    {
-        public:
-            Deathmatch(BaseObject* creator);
-            virtual ~Deathmatch() {}
-
-            virtual void start();
-            virtual void end();
-            virtual void playerEntered(PlayerInfo* player);
-            virtual bool playerLeft(PlayerInfo* player);
-            virtual bool playerChangedName(PlayerInfo* player);
-
-            virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
-            virtual void playerScored(PlayerInfo* player);
-    };
-}
-
-#endif /* _Deathmatch_H__ */
Index: code/branches/questsystem5/src/orxonox/objects/gametypes/Gametype.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/gametypes/Gametype.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/gametypes/Gametype.cc	(revision 2908)
@@ -36,5 +36,5 @@
 #include "core/ConfigValueIncludes.h"
 #include "core/Template.h"
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "overlays/OverlayGroup.h"
 #include "objects/infos/PlayerInfo.h"
@@ -44,4 +44,6 @@
 #include "objects/worldentities/Camera.h"
 
+#include "network/Host.h"
+
 namespace orxonox
 {
@@ -64,6 +66,8 @@
         this->setConfigValues();
 
+        this->addBots(this->numberOfBots_);
+
         // load the corresponding score board
-        if (GameMode::showsGraphics() && this->scoreboardTemplate_ != "")
+        if (Core::showsGraphics() && this->scoreboardTemplate_ != "")
         {
             this->scoreboard_ = new OverlayGroup(this);
@@ -101,6 +105,5 @@
     void Gametype::start()
     {
-        this->addBots(this->numberOfBots_);
-
+        COUT(0) << "game started" << std::endl;
         this->gtinfo_.bStarted_ = true;
 
@@ -110,4 +113,5 @@
     void Gametype::end()
     {
+        COUT(0) << "game ended" << std::endl;
         this->gtinfo_.bEnded_ = true;
     }
@@ -116,7 +120,11 @@
     {
         this->players_[player].state_ = PlayerState::Joined;
-    }
-
-    bool Gametype::playerLeft(PlayerInfo* player)
+
+        std::string message = player->getName() + " entered the game";
+        COUT(0) << message << std::endl;
+        Host::Broadcast(message);
+    }
+
+    void Gametype::playerLeft(PlayerInfo* player)
     {
         std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player);
@@ -124,7 +132,9 @@
         {
             this->players_.erase(it);
-            return true;
-        }
-        return false;
+
+            std::string message = player->getName() + " left the game";
+            COUT(0) << message << std::endl;
+            Host::Broadcast(message);
+        }
     }
 
@@ -137,5 +147,5 @@
     }
 
-    bool Gametype::playerChangedName(PlayerInfo* player)
+    void Gametype::playerChangedName(PlayerInfo* player)
     {
         if (this->players_.find(player) != this->players_.end())
@@ -143,8 +153,9 @@
             if (player->getName() != player->getOldName())
             {
-                return true;
-            }
-        }
-        return false;
+                std::string message = player->getOldName() + " changed name to " + player->getName();
+                COUT(0) << message << std::endl;
+                Host::Broadcast(message);
+            }
+        }
     }
 
@@ -157,37 +168,23 @@
     }
 
-    void Gametype::playerPreSpawn(PlayerInfo* player)
-    {
-    }
-
-    void Gametype::playerPostSpawn(PlayerInfo* player)
-    {
-    }
-
-    void Gametype::playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn)
-    {
-    }
-
-    void Gametype::playerStopsControllingPawn(PlayerInfo* player, Pawn* pawn)
-    {
-    }
-
-    bool Gametype::allowPawnHit(Pawn* victim, Pawn* originator)
-    {
-        return true;
-    }
-
-    bool Gametype::allowPawnDamage(Pawn* victim, Pawn* originator)
-    {
-        return true;
-    }
-
-    bool Gametype::allowPawnDeath(Pawn* victim, Pawn* originator)
-    {
-        return true;
-    }
-
     void Gametype::pawnKilled(Pawn* victim, Pawn* killer)
     {
+        if (victim && victim->getPlayer())
+        {
+            std::string message;
+            if (killer)
+            {
+                if (killer->getPlayer())
+                    message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName();
+                else
+                    message = victim->getPlayer()->getName() + " was killed";
+            }
+            else
+                message = victim->getPlayer()->getName() + " died";
+
+            COUT(0) << message << std::endl;
+            Host::Broadcast(message);
+        }
+
         if (victim && victim->getPlayer())
         {
@@ -201,7 +198,11 @@
                 if (killer)
                 {
-                    std::map<PlayerInfo*, Player>::iterator it = this->players_.find(killer->getPlayer());
-                    if (it != this->players_.end())
-                        it->second.frags_++;
+                    std::map<PlayerInfo*, Player>::iterator itKiller = this->players_.find(killer->getPlayer());
+                    if (itKiller != this->players_.end())
+                    {
+                        this->playerScored(itKiller->second);
+                    }
+                    else
+                        COUT(2) << "Warning: Killing Pawn was not in the playerlist" << std::endl;
                 }
 
@@ -224,18 +225,7 @@
     }
 
-    void Gametype::playerScored(PlayerInfo* player)
-    {
-        std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player);
-        if (it != this->players_.end())
-            it->second.frags_++;
-    }
-
-    int Gametype::getScore(PlayerInfo* player) const
-    {
-        std::map<PlayerInfo*, Player>::const_iterator it = this->players_.find(player);
-        if (it != this->players_.end())
-            return it->second.frags_;
-        else
-            return 0;
+    void Gametype::playerScored(Player& player)
+    {
+        player.frags_++;
     }
 
@@ -346,8 +336,6 @@
         if (spawnpoint)
         {
-            this->playerPreSpawn(player);
             player->startControl(spawnpoint->spawn());
             this->players_[player].state_ = PlayerState::Alive;
-            this->playerPostSpawn(player);
         }
         else
@@ -361,5 +349,5 @@
     {
         for (unsigned int i = 0; i < amount; ++i)
-            this->botclass_.fabricate(this);
+            new Bot(this);
     }
 
Index: code/branches/questsystem5/src/orxonox/objects/gametypes/Gametype.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/gametypes/Gametype.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/gametypes/Gametype.h	(revision 2908)
@@ -84,28 +84,17 @@
             virtual void end();
             virtual void playerEntered(PlayerInfo* player);
-            virtual bool playerLeft(PlayerInfo* player);
+            virtual void playerLeft(PlayerInfo* player);
             virtual void playerSwitched(PlayerInfo* player, Gametype* newgametype);
             virtual void playerSwitchedBack(PlayerInfo* player, Gametype* oldgametype);
-            virtual bool playerChangedName(PlayerInfo* player);
+            virtual void playerChangedName(PlayerInfo* player);
 
-            virtual void playerScored(PlayerInfo* player);
-
-            virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0);
-            virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0);
-            virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0);
+            virtual void playerScored(Player& player);
 
             virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
             virtual void pawnPreSpawn(Pawn* pawn);
             virtual void pawnPostSpawn(Pawn* pawn);
-            virtual void playerPreSpawn(PlayerInfo* player);
-            virtual void playerPostSpawn(PlayerInfo* player);
-
-            virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn);
-            virtual void playerStopsControllingPawn(PlayerInfo* player, Pawn* pawn);
 
             inline const std::map<PlayerInfo*, Player>& getPlayers() const
                 { return this->players_; }
-
-            int getScore(PlayerInfo* player) const;
 
             inline void registerSpawnPoint(SpawnPoint* spawnpoint)
@@ -117,9 +106,4 @@
                 { return this->gtinfo_.startCountdown_; }
 
-            inline void setHUDTemplate(const std::string& name)
-                { this->gtinfo_.hudtemplate_ = name; }
-            inline const std::string& getHUDTemplate() const
-                { return this->gtinfo_.hudtemplate_; }
-
             void addBots(unsigned int amount);
             void killBots(unsigned int amount = 0);
@@ -128,12 +112,15 @@
                 { return this->players_.size(); }
 
-        protected:
+        private:
             virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
 
-            virtual void assignDefaultPawnsIfNeeded();
-            virtual void checkStart();
-            virtual void spawnPlayer(PlayerInfo* player);
-            virtual void spawnPlayersIfRequested();
-            virtual void spawnDeadPlayersIfRequested();
+            void addPlayer(PlayerInfo* player);
+            void removePlayer(PlayerInfo* player);
+
+            void assignDefaultPawnsIfNeeded();
+            void checkStart();
+            void spawnPlayer(PlayerInfo* player);
+            void spawnPlayersIfRequested();
+            void spawnDeadPlayersIfRequested();
 
             GametypeInfo gtinfo_;
@@ -144,5 +131,4 @@
             float initialStartCountdown_;
             unsigned int numberOfBots_;
-            SubclassIdentifier<Bot> botclass_;
 
             std::map<PlayerInfo*, Player> players_;
Index: code/branches/questsystem5/src/orxonox/objects/gametypes/Pong.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/gametypes/Pong.cc	(revision 2907)
+++ 	(revision )
@@ -1,201 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#include "OrxonoxStableHeaders.h"
-#include "Pong.h"
-
-#include "core/CoreIncludes.h"
-#include "core/ConfigValueIncludes.h"
-#include "core/Executor.h"
-#include "objects/worldentities/Model.h"
-#include "objects/worldentities/PongCenterpoint.h"
-#include "objects/worldentities/PongBall.h"
-#include "objects/worldentities/PongBat.h"
-#include "objects/infos/HumanPlayer.h"
-#include "objects/infos/PongBot.h"
-#include "objects/controllers/PongAI.h"
-
-namespace orxonox
-{
-    CreateUnloadableFactory(Pong);
-
-    Pong::Pong(BaseObject* creator) : Deathmatch(creator)
-    {
-        RegisterObject(Pong);
-
-        this->center_ = 0;
-        this->ball_ = 0;
-        this->bat_[0] = 0;
-        this->bat_[1] = 0;
-
-        this->setHUDTemplate("PongHUD");
-
-        this->starttimer_.setTimer(1.0, false, this, createExecutor(createFunctor(&Pong::startBall)));
-        this->starttimer_.stopTimer();
-
-        this->botclass_ = Class(PongBot);
-    }
-
-    void Pong::start()
-    {
-        if (this->center_)
-        {
-            if (!this->ball_)
-            {
-                this->ball_ = new PongBall(this->center_);
-                this->ball_->addTemplate(this->center_->getBalltemplate());
-            }
-
-            this->center_->attach(this->ball_);
-            this->ball_->setPosition(0, 0, 0);
-            this->ball_->setFieldDimension(this->center_->getFieldDimension());
-            this->ball_->setSpeed(0);
-            this->ball_->setBatLength(this->center_->getBatLength());
-
-            if (!this->bat_[0])
-            {
-                this->bat_[0] = new PongBat(this->center_);
-                this->bat_[0]->addTemplate(this->center_->getBattemplate());
-            }
-            if (!this->bat_[1])
-            {
-                this->bat_[1] = new PongBat(this->center_);
-                this->bat_[1]->addTemplate(this->center_->getBattemplate());
-            }
-
-            this->center_->attach(this->bat_[0]);
-            this->center_->attach(this->bat_[1]);
-            this->bat_[0]->setPosition(-this->center_->getFieldDimension().x / 2, 0, 0);
-            this->bat_[1]->setPosition( this->center_->getFieldDimension().x / 2, 0, 0);
-            this->bat_[0]->yaw(Degree(-90));
-            this->bat_[1]->yaw(Degree(90));
-            this->bat_[0]->setSpeed(this->center_->getBatSpeed());
-            this->bat_[1]->setSpeed(this->center_->getBatSpeed());
-            this->bat_[0]->setFieldHeight(this->center_->getFieldDimension().y);
-            this->bat_[1]->setFieldHeight(this->center_->getFieldDimension().y);
-            this->bat_[0]->setLength(this->center_->getBatLength());
-            this->bat_[1]->setLength(this->center_->getBatLength());
-
-            this->ball_->setBats(this->bat_);
-        }
-        else
-        {
-            COUT(1) << "Error: No Centerpoint specified." << std::endl;
-        }
-
-        this->starttimer_.startTimer();
-
-
-        bool temp = this->bForceSpawn_;
-        this->bForceSpawn_ = true;
-
-        Deathmatch::start();
-
-        this->bForceSpawn_ = temp;
-    }
-
-    void Pong::end()
-    {
-        if (this->ball_)
-        {
-            delete this->ball_;
-            this->ball_ = 0;
-        }
-
-        Deathmatch::end();
-    }
-
-    void Pong::spawnPlayer(PlayerInfo* player)
-    {
-        if (!this->bat_[0]->getPlayer())
-        {
-            player->startControl(this->bat_[0]);
-            this->players_[player].state_ = PlayerState::Alive;
-        }
-        else if (!this->bat_[1]->getPlayer())
-        {
-            player->startControl(this->bat_[1]);
-            this->players_[player].state_ = PlayerState::Alive;
-        }
-        else
-            return;
-
-        if (player && player->getController() && player->getController()->isA(Class(PongAI)))
-        {
-            PongAI* ai = dynamic_cast<PongAI*>(player->getController());
-            ai->setPongBall(this->ball_);
-        }
-    }
-
-    void Pong::playerScored(PlayerInfo* player)
-    {
-        Deathmatch::playerScored(player);
-
-        if (this->center_)
-        {
-            this->center_->fireEvent();
-        }
-
-        if (this->ball_)
-        {
-            this->ball_->setPosition(Vector3::ZERO);
-            this->ball_->setVelocity(Vector3::ZERO);
-            this->ball_->setSpeed(0);
-        }
-
-        if (this->bat_[0] && this->bat_[1])
-        {
-            this->bat_[0]->setPosition(-this->center_->getFieldDimension().x / 2, 0, 0);
-            this->bat_[1]->setPosition( this->center_->getFieldDimension().x / 2, 0, 0);
-        }
-
-        this->starttimer_.startTimer();
-    }
-
-    void Pong::startBall()
-    {
-        if (this->ball_ && this->center_)
-            this->ball_->setSpeed(this->center_->getBallSpeed());
-    }
-
-    PlayerInfo* Pong::getLeftPlayer() const
-    {
-        if (this->bat_ && this->bat_[0])
-            return this->bat_[0]->getPlayer();
-        else
-            return 0;
-    }
-
-    PlayerInfo* Pong::getRightPlayer() const
-    {
-        if (this->bat_ && this->bat_[1])
-            return this->bat_[1]->getPlayer();
-        else
-            return 0;
-    }
-}
Index: code/branches/questsystem5/src/orxonox/objects/gametypes/Pong.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/gametypes/Pong.h	(revision 2907)
+++ 	(revision )
@@ -1,68 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _Pong_H__
-#define _Pong_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "Deathmatch.h"
-#include "tools/Timer.h"
-
-namespace orxonox
-{
-    class _OrxonoxExport Pong : public Deathmatch
-    {
-        public:
-            Pong(BaseObject* creator);
-            virtual ~Pong() {}
-
-            virtual void start();
-            virtual void end();
-
-            virtual void spawnPlayer(PlayerInfo* player);
-
-            virtual void playerScored(PlayerInfo* player);
-
-            void setCenterpoint(PongCenterpoint* center)
-                { this->center_ = center; }
-
-            PlayerInfo* getLeftPlayer() const;
-            PlayerInfo* getRightPlayer() const;
-
-        protected:
-            void startBall();
-
-            PongCenterpoint* center_;
-            PongBall* ball_;
-            PongBat* bat_[2];
-            Timer<Pong> starttimer_;
-    };
-}
-
-#endif /* _Pong_H__ */
Index: code/branches/questsystem5/src/orxonox/objects/gametypes/TeamDeathmatch.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/gametypes/TeamDeathmatch.cc	(revision 2907)
+++ 	(revision )
@@ -1,191 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#include "OrxonoxStableHeaders.h"
-#include "TeamDeathmatch.h"
-
-#include "core/CoreIncludes.h"
-#include "core/ConfigValueIncludes.h"
-#include "objects/Teamcolourable.h"
-#include "objects/worldentities/TeamSpawnPoint.h"
-
-namespace orxonox
-{
-    CreateUnloadableFactory(TeamDeathmatch);
-
-    TeamDeathmatch::TeamDeathmatch(BaseObject* creator) : Deathmatch(creator)
-    {
-        RegisterObject(TeamDeathmatch);
-
-        this->teams_ = 2;
-
-        this->setConfigValues();
-    }
-
-    void TeamDeathmatch::setConfigValues()
-    {
-        SetConfigValue(teams_, 2);
-
-        static ColourValue colours[] =
-        {
-            ColourValue(1.0, 0.3, 0.3),
-            ColourValue(0.3, 0.3, 1.0),
-            ColourValue(0.3, 1.0, 0.3),
-            ColourValue(1.0, 1.0, 0.0)
-        };
-        static std::vector<ColourValue> defaultcolours(colours, colours + sizeof(colours) / sizeof(ColourValue));
-
-        SetConfigValueVector(teamcolours_, defaultcolours);
-    }
-
-    void TeamDeathmatch::playerEntered(PlayerInfo* player)
-    {
-        Deathmatch::playerEntered(player);
-
-        std::vector<unsigned int> playersperteam(this->teams_, 0);
-
-        for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
-            if (it->second < this->teams_ && it->second >= 0)
-                playersperteam[it->second]++;
-
-        unsigned int minplayers = (unsigned int)-1;
-        size_t minplayersteam = 0;
-        for (size_t i = 0; i < this->teams_; ++i)
-        {
-            if (playersperteam[i] < minplayers)
-            {
-                minplayers = playersperteam[i];
-                minplayersteam = i;
-            }
-        }
-
-        this->teamnumbers_[player] = minplayersteam;
-    }
-
-    bool TeamDeathmatch::playerLeft(PlayerInfo* player)
-    {
-        bool valid_player = Deathmatch::playerLeft(player);
-
-        if (valid_player)
-            this->players_.erase(player);
-
-        return valid_player;
-    }
-
-    bool TeamDeathmatch::allowPawnHit(Pawn* victim, Pawn* originator)
-    {
-        return (!this->pawnsAreInTheSameTeam(victim, originator));
-    }
-
-    bool TeamDeathmatch::allowPawnDamage(Pawn* victim, Pawn* originator)
-    {
-        return (!this->pawnsAreInTheSameTeam(victim, originator));
-    }
-
-    bool TeamDeathmatch::allowPawnDeath(Pawn* victim, Pawn* originator)
-    {
-        return (!this->pawnsAreInTheSameTeam(victim, originator));
-    }
-
-    SpawnPoint* TeamDeathmatch::getBestSpawnPoint(PlayerInfo* player) const
-    {
-        int desiredTeamNr = -1;
-        std::map<PlayerInfo*, int>::const_iterator it_player = this->teamnumbers_.find(player);
-        if (it_player != this->teamnumbers_.end())
-            desiredTeamNr = it_player->second;
-
-        // Only use spawnpoints of the own team (or non-team-spawnpoints)
-        std::set<SpawnPoint*> teamSpawnPoints = this->spawnpoints_;
-        for (std::set<SpawnPoint*>::const_iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); )
-        {
-            if ((*it)->isA(Class(TeamSpawnPoint)))
-            {
-                TeamSpawnPoint* tsp = dynamic_cast<TeamSpawnPoint*>(*it);
-                if (tsp && tsp->getTeamNumber() != desiredTeamNr)
-                {
-                    teamSpawnPoints.erase(it++);
-                    continue;
-                }
-            }
-
-            ++it;
-        }
-
-        if (teamSpawnPoints.size() > 0)
-        {
-            unsigned int randomspawn = (unsigned int)rnd(teamSpawnPoints.size());
-            unsigned int index = 0;
-            for (std::set<SpawnPoint*>::const_iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); ++it)
-            {
-                if (index == randomspawn)
-                    return (*it);
-
-                ++index;
-            }
-        }
-
-        return 0;
-    }
-
-    void TeamDeathmatch::playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn)
-    {
-        if (!player)
-            return;
-
-        // Set the team colour
-        std::map<PlayerInfo*, int>::const_iterator it_player = this->teamnumbers_.find(player);
-        if (it_player != this->teamnumbers_.end() && it_player->second >= 0 && it_player->second < this->teamcolours_.size())
-        {
-            if (pawn)
-            {
-                std::set<WorldEntity*> pawnAttachments = pawn->getAttachedObjects();
-                for (std::set<WorldEntity*>::iterator it = pawnAttachments.begin(); it != pawnAttachments.end(); ++it)
-                {
-                    if ((*it)->isA(Class(Teamcolourable)))
-                    {
-                        Teamcolourable* tc = dynamic_cast<Teamcolourable*>(*it);
-                        tc->setTeamColour(this->teamcolours_[it_player->second]);
-                    }
-                }
-            }
-        }
-    }
-
-    bool TeamDeathmatch::pawnsAreInTheSameTeam(Pawn* pawn1, Pawn* pawn2)
-    {
-        if (pawn1 && pawn2)
-        {
-            std::map<PlayerInfo*, int>::const_iterator it1 = this->teamnumbers_.find(pawn1->getPlayer());
-            std::map<PlayerInfo*, int>::const_iterator it2 = this->teamnumbers_.find(pawn2->getPlayer());
-
-            if (it1 != this->teamnumbers_.end() && it2 != this->teamnumbers_.end())
-                return (it1->second == it2->second);
-        }
-        return false;
-    }
-}
Index: code/branches/questsystem5/src/orxonox/objects/gametypes/TeamDeathmatch.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/gametypes/TeamDeathmatch.h	(revision 2907)
+++ 	(revision )
@@ -1,67 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _TeamDeathmatch_H__
-#define _TeamDeathmatch_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include <vector>
-
-#include "Deathmatch.h"
-
-namespace orxonox
-{
-    class _OrxonoxExport TeamDeathmatch : public Deathmatch
-    {
-        public:
-            TeamDeathmatch(BaseObject* creator);
-            virtual ~TeamDeathmatch() {}
-
-            void setConfigValues();
-
-            virtual void playerEntered(PlayerInfo* player);
-            virtual bool playerLeft(PlayerInfo* player);
-
-            virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0);
-            virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0);
-            virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0);
-
-            virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn);
-
-        protected:
-            virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
-            bool pawnsAreInTheSameTeam(Pawn* pawn1, Pawn* pawn2);
-
-            std::map<PlayerInfo*, int> teamnumbers_;
-            std::vector<ColourValue> teamcolours_;
-            unsigned int teams_;
-    };
-}
-
-#endif /* _TeamDeathmatch_H__ */
Index: code/branches/questsystem5/src/orxonox/objects/infos/Bot.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/infos/Bot.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/infos/Bot.cc	(revision 2908)
@@ -30,5 +30,5 @@
 #include "Bot.h"
 
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
@@ -46,5 +46,5 @@
 
         this->bHumanPlayer_ = false;
-        this->bLocalPlayer_ = GameMode::isMaster();
+        this->bLocalPlayer_ = Core::isMaster();
         this->bSetUnreadyAfterSpawn_ = false;
         this->setReadyToSpawn(true);
Index: code/branches/questsystem5/src/orxonox/objects/infos/CMakeLists.txt
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/infos/CMakeLists.txt	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/infos/CMakeLists.txt	(revision 2908)
@@ -1,5 +1,4 @@
 ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   Bot.cc
-  PongBot.cc
   Info.cc
   PlayerInfo.cc
Index: code/branches/questsystem5/src/orxonox/objects/infos/GametypeInfo.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/infos/GametypeInfo.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/infos/GametypeInfo.cc	(revision 2908)
@@ -58,5 +58,4 @@
         registerVariable(this->startCountdown_,         variableDirection::toclient);
         registerVariable(this->bStartCountdownRunning_, variableDirection::toclient);
-        registerVariable(this->hudtemplate_,            variableDirection::toclient);
     }
 }
Index: code/branches/questsystem5/src/orxonox/objects/infos/GametypeInfo.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/infos/GametypeInfo.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/infos/GametypeInfo.h	(revision 2908)
@@ -56,7 +56,4 @@
                 { return this->startCountdown_; }
 
-            inline const std::string& getHUDTemplate() const
-                { return this->hudtemplate_; }
-
         private:
             bool bStarted_;
@@ -64,5 +61,4 @@
             bool bStartCountdownRunning_;
             float startCountdown_;
-            std::string hudtemplate_;
     };
 }
Index: code/branches/questsystem5/src/orxonox/objects/infos/HumanPlayer.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/infos/HumanPlayer.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/infos/HumanPlayer.cc	(revision 2908)
@@ -30,5 +30,5 @@
 #include "HumanPlayer.h"
 
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
@@ -47,12 +47,9 @@
         RegisterObject(HumanPlayer);
 
-        this->server_initialized_ = GameMode::isMaster();
+        this->server_initialized_ = Core::isMaster();
         this->client_initialized_ = false;
 
         this->bHumanPlayer_ = true;
         this->defaultController_ = Class(HumanController);
-
-        this->humanHud_ = 0;
-        this->gametypeHud_ = 0;
 
         this->setConfigValues();
@@ -62,12 +59,4 @@
     HumanPlayer::~HumanPlayer()
     {
-        if (this->BaseObject::isInitialized())
-        {
-            if (this->humanHud_)
-                delete this->humanHud_;
-
-            if (this->gametypeHud_)
-                delete this->gametypeHud_;
-        }
     }
 
@@ -93,5 +82,5 @@
             this->synchronize_nick_ = this->nick_;
 
-            if (GameMode::isMaster())
+            if (Core::isMaster())
                 this->setName(this->nick_);
         }
@@ -100,5 +89,5 @@
     void HumanPlayer::configvaluecallback_changedHUDTemplate()
     {
-        this->setHumanHUDTemplate(this->hudtemplate_);
+        this->changedController();
     }
 
@@ -116,5 +105,5 @@
             this->client_initialized_ = true;
 
-            if (!GameMode::isMaster())
+            if (!Core::isMaster())
                 this->setObjectMode(objectDirection::bidirectional);
             else
@@ -122,5 +111,4 @@
 
             this->createController();
-            this->updateHumanHUD();
         }
     }
@@ -158,50 +146,12 @@
     }
 
-    void HumanPlayer::changedGametype()
+    void HumanPlayer::changedController()
     {
-        PlayerInfo::changedGametype();
+        if (this->getController())
+        {
+            this->getController()->setHUDTemplate(this->hudtemplate_);
 
-        if (this->isInitialized() && this->isLocalPlayer())
-            if (this->getGametype()->getHUDTemplate() != "")
-                this->setGametypeHUDTemplate(this->getGametype()->getHUDTemplate());
-    }
-
-    void HumanPlayer::changedControllableEntity()
-    {
-        PlayerInfo::changedControllableEntity();
-
-        if (this->humanHud_)
-            this->humanHud_->setOwner(this->getControllableEntity());
-    }
-
-    void HumanPlayer::updateHumanHUD()
-    {
-        if (this->humanHud_)
-        {
-            delete this->humanHud_;
-            this->humanHud_ = 0;
-        }
-
-        if (this->isLocalPlayer() && this->humanHudTemplate_ != "")
-        {
-            this->humanHud_ = new OverlayGroup(this);
-            this->humanHud_->addTemplate(this->humanHudTemplate_);
-            this->humanHud_->setOwner(this->getControllableEntity());
-        }
-    }
-
-    void HumanPlayer::updateGametypeHUD()
-    {
-        if (this->gametypeHud_)
-        {
-            delete this->gametypeHud_;
-            this->gametypeHud_ = 0;
-        }
-
-        if (this->isLocalPlayer() && this->gametypeHudTemplate_ != "")
-        {
-            this->gametypeHud_ = new OverlayGroup(this);
-            this->gametypeHud_->addTemplate(this->gametypeHudTemplate_);
-            this->gametypeHud_->setOwner(this->getGametype());
+            if (this->getController() && this->getController()->getHUD())
+                this->getController()->getHUD()->setOwner(this->getControllableEntity());
         }
     }
Index: code/branches/questsystem5/src/orxonox/objects/infos/HumanPlayer.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/infos/HumanPlayer.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/infos/HumanPlayer.h	(revision 2908)
@@ -51,32 +51,5 @@
             void setClientID(unsigned int clientID);
 
-            virtual void changedGametype();
-            virtual void changedControllableEntity();
-
-            inline void setHumanHUDTemplate(const std::string& name)
-            {
-                if (name != this->humanHudTemplate_)
-                {
-                    this->humanHudTemplate_ = name;
-                    this->updateHumanHUD();
-                }
-            }
-            inline const std::string& getHumanHUDTemplate() const
-                { return this->humanHudTemplate_; }
-            inline OverlayGroup* getHumanHUD() const
-                { return this->humanHud_; }
-
-            inline void setGametypeHUDTemplate(const std::string& name)
-            {
-                if (name != this->gametypeHudTemplate_)
-                {
-                    this->gametypeHudTemplate_ = name;
-                    this->updateGametypeHUD();
-                }
-            }
-            inline const std::string& getGametypeHUDTemplate() const
-                { return this->gametypeHudTemplate_; }
-            inline OverlayGroup* getGametypeHUD() const
-                { return this->gametypeHud_; }
+            virtual void changedController();
 
         protected:
@@ -88,7 +61,4 @@
             void networkcallback_client_initialized();
 
-            void updateHumanHUD();
-            void updateGametypeHUD();
-
             std::string nick_;
             std::string synchronize_nick_;
@@ -96,9 +66,4 @@
             bool server_initialized_;
             bool client_initialized_;
-
-            std::string humanHudTemplate_;
-            OverlayGroup* humanHud_;
-            std::string gametypeHudTemplate_;
-            OverlayGroup* gametypeHud_;
     };
 }
Index: code/branches/questsystem5/src/orxonox/objects/infos/PlayerInfo.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/infos/PlayerInfo.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/infos/PlayerInfo.cc	(revision 2908)
@@ -110,9 +110,4 @@
     void PlayerInfo::createController()
     {
-        if (this->controller_)
-        {
-            delete this->controller_;
-            this->controller_ = 0;
-        }
         this->controller_ = this->defaultController_.fabricate(this);
         assert(this->controller_);
@@ -146,6 +141,4 @@
         if (this->controller_)
             this->controller_->setControllableEntity(entity);
-
-        this->changedControllableEntity();
     }
 
@@ -162,6 +155,4 @@
             if (callback)
                 entity->removePlayer();
-
-            this->changedControllableEntity();
         }
     }
Index: code/branches/questsystem5/src/orxonox/objects/infos/PlayerInfo.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/infos/PlayerInfo.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/infos/PlayerInfo.h	(revision 2908)
@@ -49,7 +49,4 @@
             virtual void changedGametype();
 
-            virtual void changedController() {}
-            virtual void changedControllableEntity() {}
-
             inline bool isHumanPlayer() const
                 { return this->bHumanPlayer_; }
@@ -76,4 +73,5 @@
             inline Controller* getController() const
                 { return this->controller_; }
+            virtual void changedController() {}
 
         protected:
Index: code/branches/questsystem5/src/orxonox/objects/infos/PongBot.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/infos/PongBot.cc	(revision 2907)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#include "OrxonoxStableHeaders.h"
-#include "PongBot.h"
-
-#include "core/CoreIncludes.h"
-#include "objects/controllers/PongAI.h"
-
-namespace orxonox
-{
-    CreateFactory(PongBot);
-
-    PongBot::PongBot(BaseObject* creator) : Bot(creator)
-    {
-        RegisterObject(PongBot);
-
-        this->defaultController_ = Class(PongAI);
-        this->createController();
-    }
-}
Index: code/branches/questsystem5/src/orxonox/objects/infos/PongBot.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/infos/PongBot.h	(revision 2907)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _PongBot_H__
-#define _PongBot_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "Bot.h"
-
-namespace orxonox
-{
-    class _OrxonoxExport PongBot : public Bot
-    {
-        public:
-            PongBot(BaseObject* creator);
-            virtual ~PongBot() {}
-    };
-}
-
-#endif /* _PongBot_H__ */
Index: code/branches/questsystem5/src/orxonox/objects/items/MultiStateEngine.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/items/MultiStateEngine.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/items/MultiStateEngine.cc	(revision 2908)
@@ -30,5 +30,5 @@
 #include "MultiStateEngine.h"
 
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
@@ -123,5 +123,5 @@
             }
 
-            if (GameMode::isMaster())
+            if (Core::isMaster())
             {
                 for (std::list<WorldEntity*>::const_iterator it = this->activeEffects_.begin(); it != this->activeEffects_.end(); ++it)
Index: code/branches/questsystem5/src/orxonox/objects/pickup/PickupSpawner.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/pickup/PickupSpawner.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/pickup/PickupSpawner.cc	(revision 2908)
@@ -89,5 +89,5 @@
 		ExecutorMember<BaseObject>* executor = createExecutor(createFunctor(&BaseObject::setActive));
 		executor->setDefaultValues(true);
-		RespawnTimer_.setTimer(this->respawntimer_, false, this, executor);
+		RespawnTimer_.setTimer(this->respawntimer_, false, (BaseObject*)this, executor);
 		COUT(0) << "TIMER SET" << std::endl;
 	}
Index: code/branches/questsystem5/src/orxonox/objects/quest/AddQuest.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/quest/AddQuest.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/quest/AddQuest.cc	(revision 2908)
@@ -42,5 +42,5 @@
 #include "orxonox/objects/infos/PlayerInfo.h"
 #include "QuestManager.h"
-#include "QuestDescription.h"
+#include "QuestDescription.h";
 #include "Quest.h"
 
Index: code/branches/questsystem5/src/orxonox/objects/weaponSystem/Munition.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/weaponSystem/Munition.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/weaponSystem/Munition.cc	(revision 2908)
@@ -105,4 +105,5 @@
     void Munition::fillBullets()
     {
+//COUT(0) << "Munition::fillBullets maxBullets_=" << this->maxBullets_ << std::endl;
         this->bullets_ = this->maxBullets_;
     }
Index: code/branches/questsystem5/src/orxonox/objects/weaponSystem/Weapon.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/weaponSystem/Weapon.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/weaponSystem/Weapon.cc	(revision 2908)
@@ -42,16 +42,13 @@
     {
         RegisterObject(Weapon);
-
         this->bulletReadyToShoot_ = true;
         this->magazineReadyToShoot_ = true;
         this->parentWeaponSystem_ = 0;
         this->attachedToWeaponSlot_ = 0;
+        this->munition_ = 0;
         this->bulletLoadingTime_ = 0;
         this->magazineLoadingTime_ = 0;
         this->bReloading_ = false;
-        this->bulletAmount_= 0;
-        this->magazineAmount_ = 0;
-        this->munition_ = 0;
-        this->unlimitedMunition_ = false;
+
         this->setObjectMode(0x0);
     }
@@ -68,7 +65,4 @@
         XMLPortParam(Weapon, "bulletLoadingTime", setBulletLoadingTime, getBulletLoadingTime, xmlelement, mode);
         XMLPortParam(Weapon, "magazineLoadingTime", setMagazineLoadingTime, getMagazineLoadingTime, xmlelement, mode);
-        XMLPortParam(Weapon, "bullets", setBulletAmount, getBulletAmount, xmlelement, mode);
-        XMLPortParam(Weapon, "magazines", setMagazineAmount, getMagazineAmount, xmlelement, mode);
-        XMLPortParam(Weapon, "unlimitedMunition", setUnlimitedMunition, getUnlimitedMunition, xmlelement, mode);
     }
 
@@ -79,46 +73,35 @@
     }
 
-    void Weapon::setMunition()
-    {
-        this->munition_->setMaxBullets(this->bulletAmount_);
-        this->munition_->setMaxMagazines(this->magazineAmount_);
-    }
 
     void Weapon::fire()
     {
+//COUT(0) << "LaserGun::fire, this=" << this << std::endl;
         if ( this->bulletReadyToShoot_ && this->magazineReadyToShoot_ && !this->bReloading_)
         {
+//COUT(0) << "LaserGun::fire - ready to shoot" << std::endl;
+//COUT(0) << "LaserGun::fire - bullets" << this->munition_->bullets() << std::endl;
             this->bulletReadyToShoot_ = false;
-            if ( this->unlimitedMunition_== true )
+            if ( this->munition_->bullets() > 0)
             {
                 //shoot
-                this->reloadBullet();
+                this->takeBullets();
                 this->createProjectile();
+            }
+            //if there are no bullets, but magazines
+            else if ( this->munition_->magazines() > 0 && this->munition_->bullets() == 0 )
+            {
+//COUT(0) << "LaserGun::fire - no bullets" << std::endl;
+                this->takeMagazines();
             }
             else
             {
-                if ( this->munition_->bullets() > 0)
-                {
-                    //shoot and reload
-                    this->takeBullets();
-                    this->reloadBullet();
-                    this->createProjectile();
-                }
-                //if there are no bullets, but magazines
-                else if ( this->munition_->magazines() > 0 && this->munition_->bullets() == 0 )
-                {
-                    //reload magazine
-                    this->takeMagazines();
-                    this->reloadMagazine();
-                }
-                else
-                {
-                    //no magazines
-                }
+//COUT(0) << "LaserGun::fire - no magazines" << std::endl;
+                //actions
             }
         }
         else
         {
-            //weapon not reloaded
+//COUT(0) << "LaserGun::fire - weapon not reloaded - bullets remaining:" << this->munition_->bullets() << std::endl;
+            //actions
         }
 
@@ -126,7 +109,7 @@
 
 
-    //weapon reloading
     void Weapon::bulletTimer(float bulletLoadingTime)
     {
+//COUT(0) << "Weapon::bulletTimer started" << std::endl;
         this->bReloading_ = true;
         this->bulletReloadTimer_.setTimer( bulletLoadingTime , false , this , createExecutor(createFunctor(&Weapon::bulletReloaded)));
@@ -134,4 +117,5 @@
     void Weapon::magazineTimer(float magazineLoadingTime)
     {
+//COUT(0) << "Weapon::magazineTimer started" << std::endl;
         this->bReloading_ = true;
         this->magazineReloadTimer_.setTimer( magazineLoadingTime , false , this , createExecutor(createFunctor(&Weapon::magazineReloaded)));
@@ -148,28 +132,26 @@
         this->bReloading_ = false;
         this->munition_->fillBullets();
+        this->magazineReadyToShoot_ = true;
+        this->bulletReadyToShoot_ = true;
     }
-
 
 
     void Weapon::attachNeededMunition(std::string munitionName)
     {
-        /*  if munition type already exists attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem
-        */
+//COUT(0) << "Weapon::attachNeededMunition, parentWeaponSystem=" << this->parentWeaponSystem_ << std::endl;
+        //if munition type already exists attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem
         if (this->parentWeaponSystem_)
         {
-            //getMunitionType returns 0 if there is no such munitionType
+//COUT(0) << "Weapon::attachNeededMunition " << munitionName << std::endl;
             Munition* munition = this->parentWeaponSystem_->getMunitionType(munitionName);
             if ( munition )
-            {
                 this->munition_ = munition;
-                this->setMunition();
-            }
             else
             {
-                //create new munition with identifier because there is no such munitionType
+                //create new munition with identifier
+//COUT(0) << "Weapon::attachNeededMunition, create new Munition of Type " << munitionName << std::endl;
                 this->munitionIdentifier_ = ClassByString(munitionName);
                 this->munition_ = this->munitionIdentifier_.fabricate(this);
                 this->parentWeaponSystem_->setNewMunition(munitionName, this->munition_);
-                this->setMunition();
             }
         }
@@ -177,20 +159,8 @@
 
 
-    Munition * Weapon::getAttachedMunition(std::string munitionType)
-    {
-        this->munition_ = this->parentWeaponSystem_->getMunitionType(munitionType);
-        return this->munition_;
-    }
+     /*get and set functions
+     *
+     */
 
-
-    //these function are defined in the weapon classes
-    void Weapon::takeBullets() { };
-    void Weapon::createProjectile() { };
-    void Weapon::takeMagazines() { };
-    void Weapon::reloadBullet() { };
-    void Weapon::reloadMagazine() { };
-
-
-    //get and set functions for XMLPort
     void Weapon::setMunitionType(std::string munitionType)
     {   this->munitionType_ = munitionType; }
@@ -211,21 +181,16 @@
     {   return this->magazineLoadingTime_;  }
 
-    void Weapon::setBulletAmount(unsigned int amount)
-    {   this->bulletAmount_ = amount; }
 
-    const unsigned int Weapon::getBulletAmount()
-    {   return this->bulletAmount_;  }
+    Munition * Weapon::getAttachedMunition(std::string munitionType)
+    {
+//COUT(0) << "Weapon::getAttachedMunition, parentWeaponSystem_="<< this->parentWeaponSystem_ << std::endl;
+        this->munition_ = this->parentWeaponSystem_->getMunitionType(munitionType);
+//COUT(0) << "Weapon::getAttachedMunition, munition_="<< this->munition_ << std::endl;
+        return this->munition_;
+    }
 
-    void Weapon::setMagazineAmount(unsigned int amount)
-    {   this->magazineAmount_ = amount; }
-
-    const unsigned int Weapon::getMagazineAmount()
-    {   return this->magazineAmount_;   }
-
-    void Weapon::setUnlimitedMunition(bool unlimitedMunition)
-    {   this->unlimitedMunition_ = unlimitedMunition;   }
-
-    const bool Weapon::getUnlimitedMunition()
-    {   return this->unlimitedMunition_;    }
+    void Weapon::takeBullets() { };
+    void Weapon::createProjectile() { };
+    void Weapon::takeMagazines() { };
 
 }
Index: code/branches/questsystem5/src/orxonox/objects/weaponSystem/Weapon.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/weaponSystem/Weapon.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/weaponSystem/Weapon.h	(revision 2908)
@@ -62,5 +62,4 @@
             void magazineReloaded();
 
-            //XMLPort functions
             virtual void setMunitionType(std::string munitionType);
             virtual const std::string getMunitionType();
@@ -69,22 +68,9 @@
             virtual void setMagazineLoadingTime(float loadingTime);
             virtual const float getMagazineLoadingTime();
-            virtual void setBulletAmount(unsigned int amount);
-            virtual const unsigned int getBulletAmount();
-            virtual void setMagazineAmount(unsigned int amount);
-            virtual const unsigned int getMagazineAmount();
-            virtual void setUnlimitedMunition(bool unlimitedMunition);
-            virtual const bool getUnlimitedMunition();
 
-            //weapon actions
             virtual void takeBullets();
             virtual void takeMagazines();
             virtual void createProjectile();
-            virtual void reloadBullet();
-            virtual void reloadMagazine();
 
-            //manually set or reset
-            virtual void setWeapon();
-            virtual void setMunition();
-            
             inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem)
                 { this->parentWeaponSystem_=parentWeaponSystem; };
@@ -97,4 +83,5 @@
                 { return this->attachedToWeaponSlot_; }
 
+            virtual void setWeapon();
 
         private:
@@ -104,9 +91,6 @@
             bool bulletReadyToShoot_;
             bool magazineReadyToShoot_;
-            bool unlimitedMunition_;
             float bulletLoadingTime_;
             float magazineLoadingTime_;
-            unsigned int bulletAmount_;
-            unsigned int magazineAmount_;
             std::string munitionType_;
 
Index: code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponPack.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponPack.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponPack.cc	(revision 2908)
@@ -63,4 +63,5 @@
         for (int i=0; i < (int) this->weapons_.size(); i++)
         {
+//COUT(0) << "WeaponPack::fire (attached from WeaponSet)  from Weapon: "<< i << std::endl;
             this->weapons_[i]->getAttachedToWeaponSlot()->fire();
         }
@@ -82,4 +83,5 @@
     void WeaponPack::setFireMode(unsigned int firemode)
     {
+//COUT(0) << "WeaponPack::setFireMode " << std::endl;
         this->firemode_ = firemode;
     }
@@ -92,4 +94,5 @@
     void WeaponPack::addWeapon(Weapon * weapon)
     {
+//COUT(0) << "WeaponPack::addWeapon:" << weapon << "   munition " << weapon->getMunitionType() << std::endl;
         this->weapons_.push_back(weapon);
     }
@@ -114,4 +117,5 @@
         {
             this->weapons_[i]->attachNeededMunition(weapons_[i]->getMunitionType());
+            //hack!
             this->weapons_[i]->setWeapon();
         }
Index: code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponPack.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponPack.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponPack.h	(revision 2908)
@@ -59,5 +59,4 @@
             const Weapon * getWeapon(unsigned int index);
 
-            //functions with effect to all weapons of the weaponPack
             //functions needed for creating Pointer to the right objects (-->Pawn.cc)
             void setParentWeaponSystemToAllWeapons(WeaponSystem * weaponSystem);
Index: code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponSet.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponSet.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponSet.cc	(revision 2908)
@@ -56,17 +56,20 @@
     void WeaponSet::attachWeaponPack(WeaponPack *wPack)
     {
+//COUT(0) << "WeaponSet::attachWeaponPack" << std::endl;
+//COUT(0) << "........ parentWeaponSystem_=" << this->parentWeaponSystem_ << std::endl;
+//COUT(0) << "........ this->parentWeaponSystem_->getWeaponSlotSize()" << this->parentWeaponSystem_->getWeaponSlotSize() << std::endl;
+//COUT(0) << "........ wPack->getSize()" << wPack->getSize() << std::endl;
         if ( this->parentWeaponSystem_->getWeaponSlotSize()>0 && wPack->getSize()>0 && ( wPack->getSize() <= this->parentWeaponSystem_->getWeaponSlotSize() ) )
         {
+//COUT(0) << "WeaponSet::attachWeaponPack after if" << std::endl;
             this->attachedWeaponPack_ = wPack;
             int wPackWeapon = 0;    //WeaponCounter for Attaching
-           
             //should be possible to choose which slot to use
-            //attach every weapon of the weaponPack to a weaponSlot
             for (  int i=0; i < wPack->getSize() ; i++  )
             {
                 //at the moment this function only works for one weaponPack in the entire WeaponSystem...
-                //it also takes the first free weaponSlot...
                 if ( this->parentWeaponSystem_->getWeaponSlotPointer(i)->getAttachedWeapon() == 0 && this->parentWeaponSystem_->getWeaponSlotPointer(i) != 0) //if slot not full
                 {
+//COUT(0) << "WeaponSet::attachWeaponPack attaching Weapon" << std::endl;
                     this->setWeaponSlots_.push_back( this->parentWeaponSystem_->getWeaponSlotPointer(i) );
                     this->parentWeaponSystem_->getWeaponSlotPointer(i)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) );
@@ -80,4 +83,5 @@
                         if ( this->parentWeaponSystem_->getWeaponSlotPointer(k)->getAttachedWeapon() == 0 )
                         {
+//COUT(0) << "WeaponSet::attachWeaponPack mode 2 k="<< k << std::endl;
                             this->setWeaponSlots_.push_back( this->parentWeaponSystem_->getWeaponSlotPointer(k) );
                             this->parentWeaponSystem_->getWeaponSlotPointer(k)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) );
@@ -95,4 +99,5 @@
     {
         //fires all WeaponSlots available for this weaponSet attached from the WeaponPack
+//COUT(0) << "WeaponSet::fire from Pack: " << this->attachedWeaponPack_ << std::endl;
         if (this->attachedWeaponPack_)
             this->attachedWeaponPack_->fire();
Index: code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponSystem.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponSystem.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponSystem.cc	(revision 2908)
@@ -38,7 +38,8 @@
 
 
-/* WeaponSystem
+/* WEAPONSYSTEM
+ * creates the WeaponSystem and the ability to use weapons and munition
+ * loads the weapon the whole weaponSystem setting from an xml file
  *
- *  www.orxonox.net/wiki/WeaponSystem
  */
 
@@ -51,4 +52,5 @@
         RegisterObject(WeaponSystem);
 
+        this->activeWeaponSet_ = 0;
         this->parentPawn_ = 0;
     }
@@ -82,8 +84,8 @@
     }
 
-
-    //returns the Pointer to the munitionType, if this munitionType doesn't exist returns 0, see Weapon::attachNeededMunition
+    //returns the Pointer to the munitionType
     Munition * WeaponSystem::getMunitionType(std::string munitionType)
     {
+//COUT(0) << "WeaponSystem::getMunitionType " << munitionType << std::endl;
         std::map<std::string, Munition *>::const_iterator it = this->munitionSet_.find(munitionType);
         if (it != this->munitionSet_.end())
@@ -94,7 +96,18 @@
 
 
+/*
+    //the first weaponSet is at n=0
+    void WeaponSystem::setActiveWeaponSet(unsigned int n)
+    {
+        if (n < this->weaponSets_.size())
+            this->activeWeaponSet_ = this->weaponSets_[n];
+        else
+            this->activeWeaponSet_ = this->weaponSets_[0];
+    }
+*/
+
+
     //n is the n'th weaponSet, starting with zero
-    //SpaceShip.cc only needs to have the keybinding to a specific Set-number n (=firemode)
-    //in future this could be well defined and not only for 3 different WeaponModes
+    //SpaceShip.cc only needs to have the keybinding to a specific Set-number n
     void WeaponSystem::fire(WeaponMode::Enum n)
     {
@@ -112,5 +125,7 @@
                 break;
         }
+//COUT(0) << "WeaponSystem::fire" << std::endl;
         if (set < (int)this->weaponSets_.size())
+//COUT(0) << "WeaponSystem::fire - after if" << std::endl;
             this->weaponSets_[set]->fire();
     }
Index: code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponSystem.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponSystem.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponSystem.h	(revision 2908)
@@ -53,4 +53,5 @@
             //void fire();
             void fire(WeaponMode::Enum fireMode);
+            //void setActiveWeaponSet(unsigned int n);
             void attachWeaponPack(WeaponPack * wPack, unsigned int firemode);
             WeaponSet * getWeaponSetPointer(unsigned int n);
@@ -58,5 +59,4 @@
             WeaponPack * getWeaponPackPointer(unsigned int n);
             void setNewMunition(std::string munitionType, Munition * munitionToAdd);
-            void setNewSharedMunition(std::string munitionType, Munition * munitionToAdd);
             Munition * getMunitionType(std::string munitionType);
 
@@ -74,4 +74,5 @@
             std::vector<WeaponPack *> weaponPacks_;
             std::map<std::string, Munition *> munitionSet_;
+            WeaponSet *activeWeaponSet_;
             Pawn *parentPawn_;
     };
Index: code/branches/questsystem5/src/orxonox/objects/weaponSystem/munitions/CMakeLists.txt
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/weaponSystem/munitions/CMakeLists.txt	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/weaponSystem/munitions/CMakeLists.txt	(revision 2908)
@@ -1,4 +1,3 @@
 ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   LaserGunMunition.cc
-  FusionMunition.cc
 )
Index: code/branches/questsystem5/src/orxonox/objects/weaponSystem/munitions/FusionMunition.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/weaponSystem/munitions/FusionMunition.cc	(revision 2907)
+++ 	(revision )
@@ -1,59 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Martin Polak
- *   Co-authors:
- *      ...
- *
- */
-
-#include "OrxonoxStableHeaders.h"
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "util/Debug.h"
-
-#include "FusionMunition.h"
-
-namespace orxonox
-{
-    CreateFactory(FusionMunition);
-
-    FusionMunition::FusionMunition(BaseObject* creator) : Munition(creator)
-    {
-        RegisterObject(FusionMunition);
-
-        //default if not defined in XML
-        this->maxBullets_ = 10;
-        this->maxMagazines_ = 100;
-    }
-
-    FusionMunition::~FusionMunition()
-    {
-    }
-
-    void FusionMunition::XMLPort(Element& xmlelement, XMLPort::Mode mode)
-    {
-
-    }
-
-}
Index: code/branches/questsystem5/src/orxonox/objects/weaponSystem/munitions/FusionMunition.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/weaponSystem/munitions/FusionMunition.h	(revision 2907)
+++ 	(revision )
@@ -1,54 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Martin Polak
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _FusionMunition_H__
-#define _FusionMunition_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "core/BaseObject.h"
-#include "../Munition.h"
-
-namespace orxonox
-{
-    class _OrxonoxExport FusionMunition : public Munition
-    {
-        public:
-            FusionMunition(BaseObject* creator);
-            virtual ~FusionMunition();
-
-            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-
-
-        private:
-
-
-    };
-}
-
-#endif /* _FusionMunition_H__ */
Index: code/branches/questsystem5/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc	(revision 2908)
@@ -43,5 +43,4 @@
         RegisterObject(LaserGunMunition);
 
-        //default if not defined in XML
         this->maxBullets_ = 40;
         this->maxMagazines_ = 100;
Index: code/branches/questsystem5/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.cc	(revision 2908)
@@ -32,5 +32,5 @@
 #include <OgreBillboardSet.h>
 
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "core/CoreIncludes.h"
 #include "objects/Scene.h"
@@ -44,5 +44,5 @@
         RegisterObject(BillboardProjectile);
 
-        if (GameMode::showsGraphics())
+        if (Core::showsGraphics())
         {
             assert(this->getScene()->getSceneManager()); // getScene() was already checked by WorldEntity
@@ -56,5 +56,5 @@
     BillboardProjectile::~BillboardProjectile()
     {
-        if (this->isInitialized() && GameMode::showsGraphics() && this->billboard_.getBillboardSet())
+        if (this->isInitialized() && Core::showsGraphics() && this->billboard_.getBillboardSet())
             this->detachOgreObject(this->billboard_.getBillboardSet());
     }
Index: code/branches/questsystem5/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.cc	(revision 2908)
@@ -33,5 +33,5 @@
 #include <OgreParticleEmitter.h>
 
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
@@ -46,5 +46,5 @@
         RegisterObject(ParticleProjectile);
 
-        if (GameMode::showsGraphics())
+        if (Core::showsGraphics())
         {
             this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/shot3_small", LODParticle::normal);
Index: code/branches/questsystem5/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc	(revision 2908)
@@ -41,5 +41,5 @@
 #include "objects/worldentities/ParticleSpawner.h"
 #include "objects/collisionshapes/SphereCollisionShape.h"
-#include "core/GameMode.h"
+#include "core/Core.h"
 
 namespace orxonox
@@ -55,5 +55,5 @@
         // Get notification about collisions
 
-        if (GameMode::isMaster())
+        if (Core::isMaster())
         {
             this->enableCollisionCallback();
@@ -93,5 +93,5 @@
     void Projectile::destroyObject()
     {
-        if (GameMode::isMaster())
+        if (Core::isMaster())
             delete this;
     }
@@ -99,5 +99,5 @@
     bool Projectile::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
     {
-        if (!this->bDestroy_ && GameMode::isMaster())
+        if (!this->bDestroy_ && Core::isMaster())
         {
             this->bDestroy_ = true;
Index: code/branches/questsystem5/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc	(revision 2908)
@@ -53,17 +53,9 @@
     }
 
-    void LaserGun::reloadBullet()
-    {
-        this->bulletTimer(this->bulletLoadingTime_);
-    }
-
-    void LaserGun::reloadMagazine()
-    {
-        this->magazineTimer(this->magazineLoadingTime_);
-    }
-
     void LaserGun::takeBullets()
     {
+//COUT(0) << "LaserGun::takeBullets" << std::endl;
         this->munition_->removeBullets(1);
+        this->bulletTimer(this->bulletLoadingTime_);
     }
 
@@ -71,8 +63,10 @@
     {
         this->munition_->removeMagazines(1);
+        this->magazineTimer(this->magazineLoadingTime_);
     }
 
     void LaserGun::createProjectile()
     {
+//COUT(0) << "LaserGun::createProjectile" << std::endl;
         BillboardProjectile* projectile = new ParticleProjectile(this);
         projectile->setOrientation(this->getWorldOrientation());
Index: code/branches/questsystem5/src/orxonox/objects/weaponSystem/weapons/LaserGun.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/weaponSystem/weapons/LaserGun.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/weaponSystem/weapons/LaserGun.h	(revision 2908)
@@ -51,6 +51,4 @@
             virtual void takeMagazines();
             virtual void createProjectile();
-            virtual void reloadBullet();
-            virtual void reloadMagazine();
 
         private:
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/Backlight.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/Backlight.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/worldentities/Backlight.cc	(revision 2908)
@@ -33,5 +33,5 @@
 #include <OgreSceneManager.h>
 
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "core/CoreIncludes.h"
 #include "core/Executor.h"
@@ -58,5 +58,5 @@
         this->tickcount_ = 0;
 
-        if (GameMode::showsGraphics())
+        if (Core::showsGraphics())
         {
             if (!this->getScene())
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/Backlight.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/Backlight.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/worldentities/Backlight.h	(revision 2908)
@@ -32,5 +32,5 @@
 #include "OrxonoxPrereqs.h"
 #include "FadingBillboard.h"
-#include "tools/TimeFactorListener.h"
+#include "gamestates/GSRoot.h"
 
 namespace orxonox
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/Billboard.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/Billboard.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/worldentities/Billboard.cc	(revision 2908)
@@ -34,5 +34,5 @@
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "objects/Scene.h"
 
@@ -81,5 +81,5 @@
         if (!this->billboard_.getBillboardSet())
         {
-            if (this->getScene() && GameMode::showsGraphics())
+            if (this->getScene() && Core::showsGraphics())
             {
                 this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1);
@@ -98,5 +98,5 @@
         {
 /*
-            if (this->getScene() && GameMode::showsGraphics() && (this->material_ != ""))
+            if (this->getScene() && Core::showsGraphics() && (this->material_ != ""))
             {
                 this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1);
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/Billboard.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/Billboard.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/worldentities/Billboard.h	(revision 2908)
@@ -34,9 +34,8 @@
 #include "util/Math.h"
 #include "tools/BillboardSet.h"
-#include "objects/Teamcolourable.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport Billboard : public StaticEntity, public Teamcolourable
+    class _OrxonoxExport Billboard : public StaticEntity
     {
         public:
@@ -62,7 +61,4 @@
                 { return this->colour_; }
 
-            virtual void setTeamColour(const ColourValue& colour)
-                { this->setColour(colour); }
-
         protected:
             inline BillboardSet& getBillboardSet()
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/BlinkingBillboard.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/BlinkingBillboard.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/worldentities/BlinkingBillboard.cc	(revision 2908)
@@ -30,5 +30,5 @@
 #include "BlinkingBillboard.h"
 
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
@@ -77,5 +77,5 @@
         SUPER(BlinkingBillboard, tick, dt);
 
-        if (GameMode::isMaster() && this->isActive())
+        if (Core::isMaster() && this->isActive())
         {
             this->time_ += dt;
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/CMakeLists.txt
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/CMakeLists.txt	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/worldentities/CMakeLists.txt	(revision 2908)
@@ -19,8 +19,4 @@
   Planet.cc
   SpawnPoint.cc
-  TeamSpawnPoint.cc
-  PongCenterpoint.cc
-  PongBall.cc
-  PongBat.cc
 )
 
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/CameraPosition.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/CameraPosition.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/worldentities/CameraPosition.cc	(revision 2908)
@@ -44,5 +44,4 @@
         this->bDrag_ = false;
         this->bAllowMouseLook_ = false;
-        this->bAbsolute_ = false;
 
         this->setObjectMode(0x0);
@@ -59,5 +58,4 @@
         XMLPortParam(CameraPosition, "drag", setDrag, getDrag, xmlelement, mode).defaultValues(false);
         XMLPortParam(CameraPosition, "mouselook", setAllowMouseLook, getAllowMouseLook, xmlelement, mode).defaultValues(false);
-        XMLPortParam(CameraPosition, "absolute", setIsAbsolute, getIsAbsolute, xmlelement, mode).defaultValues(false);
     }
 
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/CameraPosition.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/CameraPosition.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/worldentities/CameraPosition.h	(revision 2908)
@@ -54,9 +54,4 @@
                 { return this->bAllowMouseLook_; }
 
-            inline void setIsAbsolute(bool bAbsolute)
-                { this->bAbsolute_ = bAbsolute; }
-            inline bool getIsAbsolute() const
-                { return this->bAbsolute_; }
-
             void attachCamera(Camera* camera);
 
@@ -64,5 +59,4 @@
             bool bDrag_;
             bool bAllowMouseLook_;
-            bool bAbsolute_;
     };
 }
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/ControllableEntity.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/ControllableEntity.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/worldentities/ControllableEntity.cc	(revision 2908)
@@ -34,5 +34,5 @@
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "core/XMLPort.h"
 #include "core/Template.h"
@@ -144,17 +144,8 @@
     void ControllableEntity::addCameraPosition(CameraPosition* position)
     {
-        if (!position->getIsAbsolute())
-        {
-            if (position->getAllowMouseLook())
-                position->attachToNode(this->cameraPositionRootNode_);
-            else
-                this->attach(position);
-        }
+        if (position->getAllowMouseLook())
+            position->attachToNode(this->cameraPositionRootNode_);
         else
-        {
-            WorldEntity* parent = this->getParent();
-            if (parent)
-                parent->attach(position);
-        }
+            this->attach(position);
         this->cameraPositions_.push_back(position);
     }
@@ -245,5 +236,5 @@
             this->startLocalHumanControl();
 
-            if (!GameMode::isMaster())
+            if (!Core::isMaster())
             {
                 this->client_overwrite_ = this->server_overwrite_;
@@ -251,6 +242,4 @@
             }
         }
-
-        this->changedPlayer();
     }
 
@@ -265,6 +254,4 @@
         this->bHasHumanController_ = false;
         this->setObjectMode(objectDirection::toclient);
-
-        this->changedPlayer();
 
         if (this->bDestroyWhenPlayerLeft_)
@@ -335,17 +322,4 @@
     }
 
-    void ControllableEntity::parentChanged()
-    {
-        WorldEntity::parentChanged();
-
-        WorldEntity* parent = this->getParent();
-        if (parent)
-        {
-            for (std::list<CameraPosition*>::iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
-                if ((*it)->getIsAbsolute())
-                    parent->attach((*it));
-        }
-    }
-
     void ControllableEntity::tick(float dt)
     {
@@ -357,5 +331,5 @@
             if (!this->isDynamic())
             {
-                if (GameMode::isMaster())
+                if (Core::isMaster())
                 {
                     this->server_position_ = this->getPosition();
@@ -472,5 +446,5 @@
     void ControllableEntity::setPosition(const Vector3& position)
     {
-        if (GameMode::isMaster())
+        if (Core::isMaster())
         {
             MobileEntity::setPosition(position);
@@ -487,5 +461,5 @@
     void ControllableEntity::setOrientation(const Quaternion& orientation)
     {
-        if (GameMode::isMaster())
+        if (Core::isMaster())
         {
             MobileEntity::setOrientation(orientation);
@@ -502,5 +476,5 @@
     void ControllableEntity::setVelocity(const Vector3& velocity)
     {
-        if (GameMode::isMaster())
+        if (Core::isMaster())
         {
             MobileEntity::setVelocity(velocity);
@@ -517,5 +491,5 @@
     void ControllableEntity::setAngularVelocity(const Vector3& velocity)
     {
-        if (GameMode::isMaster())
+        if (Core::isMaster())
         {
             MobileEntity::setAngularVelocity(velocity);
@@ -533,5 +507,5 @@
     {
         MobileEntity::setWorldTransform(worldTrans);
-        if (GameMode::isMaster())
+        if (Core::isMaster())
         {
             this->server_position_ = this->getPosition();
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/ControllableEntity.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/ControllableEntity.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/worldentities/ControllableEntity.h	(revision 2908)
@@ -49,5 +49,4 @@
 
             virtual void changedGametype();
-            virtual void changedPlayer() {}
 
             virtual void setPlayer(PlayerInfo* player);
@@ -137,5 +136,4 @@
             virtual void startLocalHumanControl();
             virtual void stopLocalHumanControl();
-            virtual void parentChanged();
 
             inline void setHudTemplate(const std::string& name)
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/ExplosionChunk.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/ExplosionChunk.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/worldentities/ExplosionChunk.cc	(revision 2908)
@@ -32,5 +32,5 @@
 #include <OgreParticleSystem.h>
 
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "core/CoreIncludes.h"
 #include "core/Executor.h"
@@ -47,5 +47,5 @@
         RegisterObject(ExplosionChunk);
 
-        if ( GameMode::showsGraphics() && ( !this->getScene() || !this->getScene()->getSceneManager() ) )
+        if ( Core::showsGraphics() && ( !this->getScene() || !this->getScene()->getSceneManager() ) )
             ThrowException(AbortLoading, "Can't create ExplosionChunk, no scene or no scene manager given.");
 
@@ -53,5 +53,5 @@
         this->LOD_ = LODParticle::normal;
 
-        if ( GameMode::showsGraphics() )
+        if ( Core::showsGraphics() )
         {
             try
@@ -75,5 +75,5 @@
         }
 
-        if (GameMode::isMaster())
+        if (Core::isMaster())
         {
             Vector3 velocity(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1));
@@ -132,5 +132,5 @@
             this->smoke_->setEnabled(false);
 
-        if (GameMode::isMaster())
+        if (Core::isMaster())
         {
             this->bStop_ = true;
@@ -148,5 +148,5 @@
         static const unsigned int CHANGES_PER_SECOND = 5;
 
-        if (GameMode::isMaster() && rnd() < dt*CHANGES_PER_SECOND)
+        if (Core::isMaster() && rnd() < dt*CHANGES_PER_SECOND)
         {
             float length = this->getVelocity().length();
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/Light.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/Light.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/worldentities/Light.cc	(revision 2908)
@@ -37,5 +37,5 @@
 #include "util/String.h"
 #include "util/Exception.h"
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
@@ -57,5 +57,5 @@
         this->spotlightRange_ = Vector3(40.0f, 30.0f, 1.0f);
 
-        if (GameMode::showsGraphics())
+        if (Core::showsGraphics())
         {
             if (!this->getScene())
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/Light.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/Light.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/worldentities/Light.h	(revision 2908)
@@ -37,9 +37,8 @@
 
 #include "util/Math.h"
-#include "objects/Teamcolourable.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport Light : public StaticEntity, public Teamcolourable
+    class _OrxonoxExport Light : public StaticEntity
     {
         public:
@@ -69,7 +68,4 @@
             inline const ColourValue& getSpecularColour() const
                 { return this->specular_; }
-
-            virtual void setTeamColour(const ColourValue& colour)
-                { this->setDiffuseColour(colour); this->setSpecularColour(colour); }
 
             /**
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/MobileEntity.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/MobileEntity.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/worldentities/MobileEntity.cc	(revision 2908)
@@ -182,6 +182,5 @@
         // We use a dynamic body. So we translate our node accordingly.
         this->node_->setPosition(Vector3(worldTrans.getOrigin().x(), worldTrans.getOrigin().y(), worldTrans.getOrigin().z()));
-        btQuaternion temp(worldTrans.getRotation());
-        this->node_->setOrientation(Quaternion(temp.w(), temp.x(), temp.y(), temp.z()));
+        this->node_->setOrientation(Quaternion(worldTrans.getRotation().w(), worldTrans.getRotation().x(), worldTrans.getRotation().y(), worldTrans.getRotation().z()));
         this->linearVelocity_.x = this->physicalBody_->getLinearVelocity().x();
         this->linearVelocity_.y = this->physicalBody_->getLinearVelocity().y();
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/Model.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/Model.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/worldentities/Model.cc	(revision 2908)
@@ -31,5 +31,4 @@
 #include <OgreEntity.h>
 #include "Model.h"
-#include "core/GameMode.h"
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
@@ -71,5 +70,5 @@
     void Model::changedMesh()
     {
-        if (GameMode::showsGraphics())
+        if (Core::showsGraphics())
         {
             if (this->mesh_.getEntity())
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/MovableEntity.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/MovableEntity.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/worldentities/MovableEntity.cc	(revision 2908)
@@ -34,5 +34,5 @@
 #include "core/XMLPort.h"
 #include "core/Executor.h"
-#include "core/GameMode.h"
+#include "core/Core.h"
 
 namespace orxonox
@@ -89,5 +89,5 @@
     void MovableEntity::resynchronize()
     {
-        if (GameMode::isMaster() && !this->continuousResynchroTimer_)
+        if (Core::isMaster() && !this->continuousResynchroTimer_)
         {
             // Resynchronise every few seconds because we only work with velocities (no positions)
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/ParticleEmitter.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/ParticleEmitter.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/worldentities/ParticleEmitter.cc	(revision 2908)
@@ -39,5 +39,4 @@
 #include "tools/ParticleInterface.h"
 #include "util/Exception.h"
-#include "core/GameMode.h"
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
@@ -52,5 +51,5 @@
         RegisterObject(ParticleEmitter);
 
-        if (GameMode::showsGraphics() && (!this->getScene() || !this->getScene()->getSceneManager()))
+        if (Core::showsGraphics() && (!this->getScene() || !this->getScene()->getSceneManager()))
             ThrowException(AbortLoading, "Can't create ParticleEmitter, no scene or no scene manager given.");
 
@@ -108,5 +107,5 @@
         }
 
-        if (GameMode::showsGraphics() && this->getScene() && this->getScene()->getSceneManager())
+        if (Core::showsGraphics() && this->getScene() && this->getScene()->getSceneManager())
         {
             try
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/Planet.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/Planet.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/worldentities/Planet.cc	(revision 2908)
@@ -42,5 +42,5 @@
 #include "CameraManager.h"
 #include "Camera.h"
-#include "GraphicsManager.h"
+#include "GraphicsEngine.h"
 
 namespace orxonox
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/PongBall.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/PongBall.cc	(revision 2907)
+++ 	(revision )
@@ -1,138 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#include "OrxonoxStableHeaders.h"
-#include "PongBall.h"
-
-#include "core/CoreIncludes.h"
-#include "core/GameMode.h"
-#include "objects/worldentities/PongBat.h"
-#include "objects/gametypes/Gametype.h"
-
-namespace orxonox
-{
-    CreateFactory(PongBall);
-
-    const float PongBall::MAX_REL_Z_VELOCITY = 1.5;
-
-    PongBall::PongBall(BaseObject* creator) : MovableEntity(creator)
-    {
-        RegisterObject(PongBall);
-
-        this->speed_ = 0;
-        this->bat_ = 0;
-        this->relMercyOffset_ = 0.05;
-    }
-
-    void PongBall::tick(float dt)
-    {
-        SUPER(PongBall, tick, dt);
-
-        if (GameMode::isMaster())
-        {
-            Vector3 position = this->getPosition();
-            Vector3 velocity = this->getVelocity();
-
-            if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2)
-            {
-                velocity.z = -velocity.z;
-
-                if (position.z > this->fieldHeight_ / 2)
-                    position.z = this->fieldHeight_ / 2;
-                if (position.z < -this->fieldHeight_ / 2)
-                    position.z = -this->fieldHeight_ / 2;
-            }
-
-            if (position.x > this->fieldWidth_ / 2 || position.x < -this->fieldWidth_ / 2)
-            {
-                float distance = 0;
-
-                if (this->bat_)
-                {
-                    if (position.x > this->fieldWidth_ / 2 && this->bat_[1])
-                    {
-                        distance = (position.z - this->bat_[1]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10) / 2);
-                        if (fabs(distance) <= 1)
-                        {
-                            position.x = this->fieldWidth_ / 2;
-                            velocity.x = -velocity.x;
-                            velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
-                        }
-                        else if (position.x > this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
-                        {
-                            if (this->getGametype() && this->bat_[0])
-                            {
-                                this->getGametype()->playerScored(this->bat_[0]->getPlayer());
-                                return;
-                            }
-                        }
-                    }
-                    if (position.x < -this->fieldWidth_ / 2 && this->bat_[0])
-                    {
-                        distance = (position.z - this->bat_[0]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10) / 2);
-                        if (fabs(distance) <= 1)
-                        {
-                            position.x = -this->fieldWidth_ / 2;
-                            velocity.x = -velocity.x;
-                            velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
-                        }
-                        else if (position.x < -this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
-                        {
-                            if (this->getGametype() && this->bat_[1])
-                            {
-                                this->getGametype()->playerScored(this->bat_[1]->getPlayer());
-                                return;
-                            }
-                        }
-                    }
-                }
-            }
-
-            if (velocity != this->getVelocity())
-                this->setVelocity(velocity);
-            if (position != this->getPosition())
-                this->setPosition(position);
-        }
-    }
-
-    void PongBall::setSpeed(float speed)
-    {
-        if (speed != this->speed_)
-        {
-            this->speed_ = speed;
-
-            Vector3 velocity = this->getVelocity();
-            if (velocity.x != 0)
-                velocity.x = sgn(velocity.x) * this->speed_;
-            else
-                velocity.x = this->speed_ * sgn(rnd(-1,1));
-
-            this->setVelocity(velocity);
-        }
-    }
-}
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/PongBall.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/PongBall.h	(revision 2907)
+++ 	(revision )
@@ -1,77 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _PongBall_H__
-#define _PongBall_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "objects/worldentities/MovableEntity.h"
-
-namespace orxonox
-{
-    class _OrxonoxExport PongBall : public MovableEntity
-    {
-        public:
-            PongBall(BaseObject* creator);
-            virtual ~PongBall() {}
-
-            virtual void tick(float dt);
-
-            void setFieldDimension(float width, float height)
-                { this->fieldWidth_ = width; this->fieldHeight_ = height; }
-            void setFieldDimension(const Vector2& dimension)
-                { this->setFieldDimension(dimension.x, dimension.y); }
-            Vector2 getFieldDimension() const
-                { return Vector2(this->fieldWidth_, this->fieldHeight_); }
-
-            void setSpeed(float speed);
-            float getSpeed() const
-                { return this->speed_; }
-
-            void setBatLength(float batlength)
-                { this->batlength_ = batlength; }
-            float getBatLength() const
-                { return this->batlength_; }
-
-            void setBats(PongBat** bats)
-                { this->bat_ = bats; }
-
-            static const float MAX_REL_Z_VELOCITY;
-
-        private:
-            float fieldWidth_;
-            float fieldHeight_;
-            float speed_;
-            float batlength_;
-            PongBat** bat_;
-            float relMercyOffset_;
-    };
-}
-
-#endif /* _PongBall_H__ */
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/PongBat.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/PongBat.cc	(revision 2907)
+++ 	(revision )
@@ -1,112 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#include "OrxonoxStableHeaders.h"
-#include "PongBat.h"
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-
-namespace orxonox
-{
-    CreateFactory(PongBat);
-
-    PongBat::PongBat(BaseObject* creator) : ControllableEntity(creator)
-    {
-        RegisterObject(PongBat);
-
-        this->movement_ = 0;
-        this->bMoveLocal_ = false;
-        this->speed_ = 60;
-        this->length_ = 0.25;
-        this->fieldHeight_ = 100;
-        this->bSteadiedPosition_ = false;
-
-        this->registerVariables();
-    }
-
-    void PongBat::registerVariables()
-    {
-        registerVariable(this->speed_);
-        registerVariable(this->speed_);
-        registerVariable(this->speed_);
-    }
-
-    void PongBat::tick(float dt)
-    {
-        if (this->hasLocalController())
-        {
-            if (this->movement_ != 0)
-            {
-                this->movement_ = clamp(this->movement_, -1.0f, 1.0f) * this->speed_;
-
-                if (this->bMoveLocal_)
-                    this->setVelocity(this->getOrientation() * Vector3(this->movement_, 0, 0));
-                else
-                    this->setVelocity(0, 0, this->movement_);
-
-                this->movement_ = 0;
-                this->bSteadiedPosition_ = false;
-            }
-            else if (!this->bSteadiedPosition_)
-            {
-                // To ensure network synchronicity
-                this->setVelocity(0, 0, 0);
-                this->setPosition(this->getPosition());
-                this->bSteadiedPosition_ = true;
-            }
-        }
-
-        SUPER(PongBat, tick, dt);
-
-        Vector3 position = this->getPosition();
-        if (position.z > this->fieldHeight_ / 2 - this->fieldHeight_ * this->length_ / 2)
-            position.z = this->fieldHeight_ / 2 - this->fieldHeight_ * this->length_ / 2;
-        if (position.z < -this->fieldHeight_ / 2 + this->fieldHeight_ * this->length_ / 2)
-            position.z = -this->fieldHeight_ / 2 + this->fieldHeight_ * this->length_ / 2;
-        if (position != this->getPosition())
-            this->setPosition(position);
-    }
-
-    void PongBat::moveFrontBack(const Vector2& value)
-    {
-        this->bMoveLocal_ = false;
-        this->movement_ -= value.x;
-    }
-
-    void PongBat::moveRightLeft(const Vector2& value)
-    {
-        this->bMoveLocal_ = true;
-        this->movement_ = value.x;
-    }
-
-    void PongBat::changedPlayer()
-    {
-        this->setVelocity(0, 0, 0);
-    }
-}
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/PongBat.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/PongBat.h	(revision 2907)
+++ 	(revision )
@@ -1,77 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _PongBat_H__
-#define _PongBat_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "objects/worldentities/ControllableEntity.h"
-
-namespace orxonox
-{
-    class _OrxonoxExport PongBat : public ControllableEntity
-    {
-        public:
-            PongBat(BaseObject* creator);
-            virtual ~PongBat() {}
-
-            void registerVariables();
-            virtual void tick(float dt);
-
-            virtual void moveFrontBack(const Vector2& value);
-            virtual void moveRightLeft(const Vector2& value);
-
-            virtual void changedPlayer();
-
-            void setSpeed(float speed)
-                { this->speed_ = speed; }
-            float getSpeed() const
-                { return this->speed_; }
-
-            void setFieldHeight(float height)
-                { this->fieldHeight_ = height; }
-            float getFieldHeight() const
-                { return this->fieldHeight_; }
-
-            void setLength(float length)
-                { this->length_ = length; }
-            float getLength() const
-                { return this->length_; }
-
-        private:
-            float movement_;
-            bool bMoveLocal_;
-            float speed_;
-            float length_;
-            float fieldHeight_;
-            bool bSteadiedPosition_;
-    };
-}
-
-#endif /* _PongBat_H__ */
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/PongCenterpoint.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/PongCenterpoint.cc	(revision 2907)
+++ 	(revision )
@@ -1,80 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#include "OrxonoxStableHeaders.h"
-#include "PongCenterpoint.h"
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "objects/gametypes/Pong.h"
-
-namespace orxonox
-{
-    CreateFactory(PongCenterpoint);
-
-    PongCenterpoint::PongCenterpoint(BaseObject* creator) : StaticEntity(creator)
-    {
-        RegisterObject(PongCenterpoint);
-
-        this->width_ = 200;
-        this->height_ = 120;
-        this->ballspeed_ = 100;
-        this->batspeed_ = 60;
-        this->batlength_ = 0.25;
-
-        this->checkGametype();
-    }
-
-    void PongCenterpoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
-    {
-        SUPER(PongCenterpoint, XMLPort, xmlelement, mode);
-
-        XMLPortParam(PongCenterpoint, "dimension", setFieldDimension, getFieldDimension, xmlelement, mode);
-        XMLPortParam(PongCenterpoint, "balltemplate", setBalltemplate, getBalltemplate, xmlelement, mode);
-        XMLPortParam(PongCenterpoint, "battemplate", setBattemplate, getBattemplate, xmlelement, mode);
-        XMLPortParam(PongCenterpoint, "ballspeed", setBallSpeed, getBallSpeed, xmlelement, mode);
-        XMLPortParam(PongCenterpoint, "batspeed", setBatSpeed, getBatSpeed, xmlelement, mode);
-        XMLPortParam(PongCenterpoint, "batlength", setBatLength, getBatLength, xmlelement, mode);
-    }
-
-    void PongCenterpoint::changedGametype()
-    {
-        SUPER(PongCenterpoint, changedGametype);
-
-        this->checkGametype();
-    }
-
-    void PongCenterpoint::checkGametype()
-    {
-        if (this->getGametype() && this->getGametype()->isA(Class(Pong)))
-        {
-            Pong* pong_gametype = dynamic_cast<Pong*>(this->getGametype());
-            pong_gametype->setCenterpoint(this);
-        }
-    }
-}
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/PongCenterpoint.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/PongCenterpoint.h	(revision 2907)
+++ 	(revision )
@@ -1,93 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _PongCenterpoint_H__
-#define _PongCenterpoint_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "objects/worldentities/StaticEntity.h"
-
-namespace orxonox
-{
-    class _OrxonoxExport PongCenterpoint : public StaticEntity
-    {
-        public:
-            PongCenterpoint(BaseObject* creator);
-            virtual ~PongCenterpoint() {}
-
-            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-
-            virtual void changedGametype();
-
-            void setBalltemplate(const std::string& balltemplate)
-                { this->balltemplate_ = balltemplate; }
-            const std::string& getBalltemplate() const
-                { return this->balltemplate_; }
-
-            void setBattemplate(const std::string& battemplate)
-                { this->battemplate_ = battemplate; }
-            const std::string& getBattemplate() const
-                { return this->battemplate_; }
-
-            void setFieldDimension(const Vector2& dimension)
-                { this->width_ = dimension.x; this->height_ = dimension.y; }
-            Vector2 getFieldDimension() const
-                { return Vector2(this->width_, this->height_); }
-
-            void setBallSpeed(float ballspeed)
-                { this->ballspeed_ = ballspeed; }
-            float getBallSpeed() const
-                { return this->ballspeed_; }
-
-            void setBatSpeed(float batspeed)
-                { this->batspeed_ = batspeed; }
-            float getBatSpeed() const
-                { return this->batspeed_; }
-
-            void setBatLength(float batlength)
-                { this->batlength_ = batlength; }
-            float getBatLength() const
-                { return this->batlength_; }
-
-        private:
-            void checkGametype();
-
-            std::string balltemplate_;
-            std::string battemplate_;
-
-            float ballspeed_;
-            float batspeed_;
-            float batlength_;
-
-            float width_;
-            float height_;
-    };
-}
-
-#endif /* _PongCenterpoint_H__ */
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/TeamSpawnPoint.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/TeamSpawnPoint.cc	(revision 2907)
+++ 	(revision )
@@ -1,52 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#include "OrxonoxStableHeaders.h"
-#include "TeamSpawnPoint.h"
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-
-namespace orxonox
-{
-    CreateFactory(TeamSpawnPoint);
-
-    TeamSpawnPoint::TeamSpawnPoint(BaseObject* creator) : SpawnPoint(creator)
-    {
-        RegisterObject(TeamSpawnPoint);
-
-        this->teamNumber_ = 0;
-    }
-
-    void TeamSpawnPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
-    {
-        SUPER(TeamSpawnPoint, XMLPort, xmlelement, mode);
-
-        XMLPortParam(TeamSpawnPoint, "team", setTeamNumber, getTeamNumber, xmlelement, mode).defaultValues(0);
-    }
-}
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/TeamSpawnPoint.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/TeamSpawnPoint.h	(revision 2907)
+++ 	(revision )
@@ -1,56 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _TeamSpawnPoint_H__
-#define _TeamSpawnPoint_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "SpawnPoint.h"
-
-namespace orxonox
-{
-    class _OrxonoxExport TeamSpawnPoint : public SpawnPoint
-    {
-        public:
-            TeamSpawnPoint(BaseObject* creator);
-            virtual ~TeamSpawnPoint() {}
-
-            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-
-            void setTeamNumber(unsigned int team)
-                { this->teamNumber_ = team; }
-            unsigned int getTeamNumber() const
-                { return this->teamNumber_; }
-
-        private:
-            unsigned int teamNumber_;
-    };
-}
-
-#endif /* _TeamSpawnPoint_H__ */
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/WorldEntity.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/WorldEntity.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/worldentities/WorldEntity.cc	(revision 2908)
@@ -181,5 +181,5 @@
 
         // Attach to parent if necessary
-        registerVariable(this->parentID_,       variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::networkcallback_parentChanged));
+        registerVariable(this->parentID_,       variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::parentChanged));
     }
 
@@ -188,5 +188,5 @@
         Network function that object this instance to its correct parent.
     */
-    void WorldEntity::networkcallback_parentChanged()
+    void WorldEntity::parentChanged()
     {
         if (this->parentID_ != OBJECTID_UNKNOWN)
@@ -362,11 +362,9 @@
         this->parentID_ = newParent->getObjectID();
 
-        this->parentChanged();
-
         // apply transform to collision shape
         this->collisionShape_->setPosition(this->getPosition());
         this->collisionShape_->setOrientation(this->getOrientation());
         // TODO: Scale
-
+        
         return true;
     }
@@ -408,6 +406,4 @@
         this->parent_ = 0;
         this->parentID_ = OBJECTID_UNKNOWN;
-
-        this->parentChanged();
 
         // reset orientation of the collisionShape (cannot be set within a WE usually)
@@ -492,5 +488,5 @@
 
     // Note: These functions are placed in WorldEntity.h as inline functions for the release build.
-#ifndef NDEBUG
+#ifndef _NDEBUG
     const Vector3& WorldEntity::getPosition() const
     {
@@ -660,5 +656,4 @@
         case TransformSpace::World:
             ogreRelativeTo = Ogre::Node::TS_WORLD; break;
-        default: OrxAssert(false, "Faulty TransformSpace::Enum assigned.");
         }
         this->node_->setDirection(direction, ogreRelativeTo, localDirectionVector);
@@ -760,5 +755,5 @@
         {
         case Dynamic:
-            this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() & !btCollisionObject::CF_STATIC_OBJECT & !btCollisionObject::CF_KINEMATIC_OBJECT);
+            this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() & !(btCollisionObject::CF_STATIC_OBJECT | btCollisionObject::CF_KINEMATIC_OBJECT));
             break;
         case Kinematic:
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/WorldEntity.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/WorldEntity.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/worldentities/WorldEntity.h	(revision 2908)
@@ -33,5 +33,5 @@
 #include "OrxonoxPrereqs.h"
 
-#ifdef NDEBUG
+#ifdef _NDEBUG
 #include <OgreSceneNode.h>
 #else
@@ -176,6 +176,4 @@
 
         protected:
-            virtual void parentChanged() {}
-
             Ogre::SceneNode* node_;
 
@@ -193,5 +191,5 @@
 
             // network callbacks
-            void networkcallback_parentChanged();
+            void parentChanged();
             inline void scaleChanged()
                 { this->setScale3D(this->getScale3D()); }
@@ -271,5 +269,5 @@
             @brief
                 Sets how much reaction is applied in a collision.
-
+                
                 Consider two equal spheres colliding with equal velocities:
                 Restitution 1 means that both spheres simply reverse their velocity (no loss of energy)
@@ -421,9 +419,9 @@
 
     // Inline heavily used functions for release builds. In debug, we better avoid including OgreSceneNode here.
-#ifdef NDEBUG
+#ifdef _NDEBUG
     inline const Vector3& WorldEntity::getPosition() const
         { return this->node_->getPosition(); }
     inline const Quaternion& WorldEntity::getOrientation() const
-        { return this->node_->getOrientation(); }
+        { return this->node_->getrOrientation(); }
     inline const Vector3& WorldEntity::getScale3D(void) const
         { return this->node_->getScale(); }
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/pawns/Pawn.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/worldentities/pawns/Pawn.cc	(revision 2908)
@@ -30,5 +30,5 @@
 #include "Pawn.h"
 
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
@@ -63,5 +63,5 @@
         this->getPickUp().setPlayer(this);
 
-        if (GameMode::isMaster())
+        if (Core::isMaster())
         {
             this->weaponSystem_ = new WeaponSystem(this);
@@ -133,20 +133,4 @@
     }
 
-    void Pawn::setPlayer(PlayerInfo* player)
-    {
-        ControllableEntity::setPlayer(player);
-
-        if (this->getGametype())
-            this->getGametype()->playerStartsControllingPawn(player, this);
-    }
-
-    void Pawn::removePlayer()
-    {
-        if (this->getGametype())
-            this->getGametype()->playerStopsControllingPawn(this->getPlayer(), this);
-
-        ControllableEntity::removePlayer();
-    }
-
     void Pawn::setHealth(float health)
     {
@@ -156,22 +140,16 @@
     void Pawn::damage(float damage, Pawn* originator)
     {
-        if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
-        {
-            this->setHealth(this->health_ - damage);
-            this->lastHitOriginator_ = originator;
-
-            // play damage effect
-        }
+        this->setHealth(this->health_ - damage);
+        this->lastHitOriginator_ = originator;
+
+        // play damage effect
     }
 
     void Pawn::hit(Pawn* originator, const Vector3& force, float damage)
     {
-        if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator))
-        {
-            this->damage(damage, originator);
-            this->setVelocity(this->getVelocity() + force);
-
-            // play hit effect
-        }
+        this->damage(damage, originator);
+        this->setVelocity(this->getVelocity() + force);
+
+        // play hit effect
     }
 
@@ -198,22 +176,17 @@
     void Pawn::death()
     {
-        if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_))
-        {
-            // Set bAlive_ to false and wait for PawnManager to do the destruction
-            this->bAlive_ = false;
-
-            this->setDestroyWhenPlayerLeft(false);
-
-            if (this->getGametype())
-                this->getGametype()->pawnKilled(this, this->lastHitOriginator_);
-
-            if (this->getPlayer())
-                this->getPlayer()->stopControl(this);
-
-            if (GameMode::isMaster())
-                this->deatheffect();
-        }
-        else
-            this->setHealth(1);
+        // Set bAlive_ to false and wait for PawnManager to do the destruction
+        this->bAlive_ = false;
+
+        this->setDestroyWhenPlayerLeft(false);
+
+        if (this->getGametype())
+            this->getGametype()->pawnKilled(this, this->lastHitOriginator_);
+
+        if (this->getPlayer())
+            this->getPlayer()->stopControl(this);
+
+        if (Core::isMaster())
+            this->deatheffect();
     }
 
@@ -249,4 +222,5 @@
             ExplosionChunk* chunk = new ExplosionChunk(this->getCreator());
             chunk->setPosition(this->getPosition());
+
         }
     }
@@ -260,5 +234,5 @@
     {
         this->setHealth(this->initialHealth_);
-        if (GameMode::isMaster())
+        if (Core::isMaster())
             this->spawneffect();
     }
@@ -269,10 +243,4 @@
     }
 
-
-    /* WeaponSystem:
-    *   functions load Slot, Set, Pack from XML and make sure all parent-pointers are set.
-    *   with setWeaponPack you can not just load a Pack from XML but if a Pack already exists anywhere, you can attach it.
-    *       --> e.g. Pickup-Items
-    */
     void Pawn::setWeaponSlot(WeaponSlot * wSlot)
     {
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/pawns/Pawn.h
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/pawns/Pawn.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/worldentities/pawns/Pawn.h	(revision 2908)
@@ -47,7 +47,4 @@
             virtual void tick(float dt);
             void registerVariables();
-
-            virtual void setPlayer(PlayerInfo* player);
-            virtual void removePlayer();
 
             inline bool isAlive() const
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/pawns/Spectator.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/pawns/Spectator.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/worldentities/pawns/Spectator.cc	(revision 2908)
@@ -34,5 +34,5 @@
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "objects/worldentities/Model.h"
 #include "objects/Scene.h"
@@ -63,5 +63,5 @@
         this->setDestroyWhenPlayerLeft(true);
 
-        if (GameMode::showsGraphics())
+        if (Core::showsGraphics())
         {
             this->greetingFlare_ = new BillboardSet();
@@ -206,5 +206,5 @@
         this->bGreeting_ = !this->bGreeting_;
 
-        if (GameMode::isMaster())
+        if (Core::isMaster())
         {
             this->bGreetingFlareVisible_ = this->bGreeting_;
Index: code/branches/questsystem5/src/orxonox/objects/worldentities/triggers/Trigger.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/objects/worldentities/triggers/Trigger.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/objects/worldentities/triggers/Trigger.cc	(revision 2908)
@@ -36,5 +36,5 @@
 #include "core/ConsoleCommand.h"
 #include "core/XMLPort.h"
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "objects/Scene.h"
 
@@ -67,5 +67,5 @@
 //    this->bUpdating_ = false;
 
-    if (this->getScene() && GameMode::showsGraphics())
+    if (this->getScene() && Core::showsGraphics())
     {
       this->debugBillboard_.setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1);
Index: code/branches/questsystem5/src/orxonox/overlays/OrxonoxOverlay.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/overlays/OrxonoxOverlay.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/overlays/OrxonoxOverlay.cc	(revision 2908)
@@ -39,14 +39,11 @@
 #include <OgreOverlayManager.h>
 #include <OgrePanelOverlayElement.h>
-#include <OgreRenderWindow.h>
-
 #include "util/Convert.h"
 #include "util/Exception.h"
 #include "util/String.h"
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
 #include "core/ConsoleCommand.h"
-#include "GraphicsManager.h"
 
 namespace orxonox
@@ -67,5 +64,5 @@
         this->group_ = 0;
 
-        if (!GameMode::showsGraphics())
+        if (!Core::showsGraphics())
             ThrowException(NoGraphics, "Can't create OrxonoxOverlay, graphics engine not initialized");
 
@@ -80,7 +77,7 @@
         this->overlay_->add2D(this->background_);
 
-        // Get aspect ratio from the render window. Later on, we get informed automatically
-        Ogre::RenderWindow* defaultWindow = GraphicsManager::getInstance().getRenderWindow();
-        this->windowAspectRatio_ = (float)defaultWindow->getWidth() / defaultWindow->getHeight();
+        // We'll have to set the aspect ratio to a default value first.
+        // GSGraphics gets informed about our construction here and can update us in the next tick.
+        this->windowAspectRatio_ = 1.0;
         this->sizeCorrectionChanged();
 
@@ -178,8 +175,8 @@
     /**
     @brief
-        Called by the GraphicsManager whenever the window size changes.
+        Called by the GraphicsEngine whenever the window size changes.
         Calculates the aspect ratio only.
     */
-    void OrxonoxOverlay::windowResized(unsigned int newWidth, unsigned int newHeight)
+    void OrxonoxOverlay::windowResized(int newWidth, int newHeight)
     {
         this->windowAspectRatio_ = newWidth/(float)newHeight;
Index: code/branches/questsystem5/src/orxonox/overlays/OrxonoxOverlay.h
===================================================================
--- code/branches/questsystem5/src/orxonox/overlays/OrxonoxOverlay.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/overlays/OrxonoxOverlay.h	(revision 2908)
@@ -154,5 +154,5 @@
         virtual void changedVisibility();
 
-        inline void setOwner(BaseObject* owner)
+        inline void setOwner(ControllableEntity* owner)
         {
             if (this->owner_ != owner)
@@ -162,5 +162,5 @@
             }
         }
-        inline BaseObject* getOwner() const
+        inline ControllableEntity* getOwner() const
             { return this->owner_; }
         virtual void changedOwner() {}
@@ -200,5 +200,5 @@
 
     private:
-        void windowResized(unsigned int newWidth, unsigned int newHeight);
+        void windowResized(int newWidth, int newHeight);
 
         static unsigned int hudOverlayCounter_s;   //!< Static counter for hud elements
@@ -206,5 +206,5 @@
             We could also use the ObjectList, but that doesn't guarantee XMLPort(.) was called and is slower. */
         static std::map<std::string, OrxonoxOverlay*> overlays_s;
-        BaseObject* owner_;
+        ControllableEntity* owner_;
         OverlayGroup* group_;
   };
Index: code/branches/questsystem5/src/orxonox/overlays/OverlayGroup.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/overlays/OverlayGroup.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/overlays/OverlayGroup.cc	(revision 2908)
@@ -63,6 +63,6 @@
     OverlayGroup::~OverlayGroup()
     {
-        for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
-            delete (*it);
+        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+            delete it->second;
     }
 
@@ -83,17 +83,17 @@
     }
 
-    //! Scales every element in the set.
+    //! Scales every element in the map.
     void OverlayGroup::setScale(const Vector2& scale)
     {
-        for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
-            (*it)->scale(scale / this->scale_);
+        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+            (*it).second->scale(scale / this->scale_);
         this->scale_ = scale;
     }
 
-    //! Scrolls every element in the set.
+    //! Scrolls every element in the map.
     void OverlayGroup::setScroll(const Vector2& scroll)
     {
-        for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
-            (*it)->scroll(scroll - this->scroll_);
+        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+            (*it).second->scroll(scroll - this->scroll_);
         this->scroll_ = scroll;
     }
@@ -101,5 +101,5 @@
     /**
     @brief
-        Adds an element to the set (used when loading with XMLPort).
+        Adds an element to the map (used when loading with XMLPort).
     @remarks
         The names of the OrxonoxOverlays have to be unique!
@@ -107,21 +107,44 @@
     void OverlayGroup::addElement(OrxonoxOverlay* element)
     {
-        hudElements_.insert(element);
-        element->setVisible(this->isVisible());
-        if (this->owner_)
-            element->setOwner(this->owner_);
-    }
-
-    /**
+        this->insertElement(element, element->getName());
+    }
+
+	/**
+    @brief
+        Adds an element to the map.
+    @param element
+        The element to be added.
+    @param name
+        The name of the element.
+    @remarks
+        The names of the OrxonoxOverlays have to be unique!
+    */
+    void OverlayGroup::insertElement(OrxonoxOverlay* element, const std::string & name)
+    {
+        element->setName(name);
+        if (hudElements_.find(name) != hudElements_.end())
+        {
+            COUT(1) << "Ambiguous names encountered while load the HUD overlays" << std::endl;
+        }
+        else
+        {
+            hudElements_[name] = element;
+            element->setVisible(this->isVisible());
+			if (this->owner_)
+                element->setOwner(this->owner_);
+        }
+    }
+
+	/**
     @brief
         Removes an element from the map.
-    @param element
-        The element that is to be removed.
+    @param name
+        The name of the element that is removed.
     @return
         Returns true if there was such an element to remove, false if not.
     */
-    bool OverlayGroup::removeElement(OrxonoxOverlay* element)
-    {
-        if(this->hudElements_.erase(element) == 0)
+    bool OverlayGroup::removeElement(const std::string & name)
+    {
+        if(this->hudElements_.erase(name) == 0)
             return false;
         return true;
@@ -133,8 +156,8 @@
         if (index < this->hudElements_.size())
         {
-            std::set<OrxonoxOverlay*>::const_iterator it = hudElements_.begin();
+            std::map<std::string, OrxonoxOverlay*>::const_iterator it = hudElements_.begin();
             for (unsigned int i = 0; i != index; ++it, ++i)
                 ;
-            return (*it);
+            return (*it).second;
         }
         else
@@ -145,14 +168,14 @@
     void OverlayGroup::changedVisibility()
     {
-        for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
-            (*it)->setVisible(this->isVisible());
-    }
-
-    void OverlayGroup::setOwner(BaseObject* owner)
+        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+            (*it).second->setVisible(this->isVisible());
+    }
+
+    void OverlayGroup::setOwner(ControllableEntity* owner)
     {
         this->owner_ = owner;
 
-        for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
-            (*it)->setOwner(owner);
+        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+            (*it).second->setOwner(owner);
     }
 
Index: code/branches/questsystem5/src/orxonox/overlays/OverlayGroup.h
===================================================================
--- code/branches/questsystem5/src/orxonox/overlays/OverlayGroup.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/overlays/OverlayGroup.h	(revision 2908)
@@ -37,6 +37,5 @@
 #include "OrxonoxPrereqs.h"
 
-#include <set>
-#include <string>
+#include <map>
 #include <OgrePrerequisites.h>
 #include "core/BaseObject.h"
@@ -65,11 +64,11 @@
         static void scrollGroup(const std::string& name, const Vector2& scroll);
 
-        inline const std::set<OrxonoxOverlay*>& getOverlays() const
+        inline const std::map<std::string, OrxonoxOverlay*>& getOverlays() const
             { return this->hudElements_; }
 
         void changedVisibility();
 
-        void setOwner(BaseObject* owner);
-        inline BaseObject* getOwner() const
+        void setOwner(ControllableEntity* owner);
+        inline ControllableEntity* getOwner() const
             { return this->owner_; }
 
@@ -87,12 +86,13 @@
 
         void addElement(OrxonoxOverlay* element);
-        bool removeElement(OrxonoxOverlay* element);
+		void insertElement(OrxonoxOverlay* element, const std::string & name);
+        bool removeElement(const std::string & name);
         OrxonoxOverlay* getElement(unsigned int index);
 
     private:
-        std::set<OrxonoxOverlay*> hudElements_;    //!< Contains all the OrxonoxOverlays of the this group.
-        Vector2 scale_;                            //!< Current scale (independent of the elements).
-        Vector2 scroll_;                           //!< Current scrolling offset.
-        BaseObject* owner_;                        //!< The owner of this OverlayGroup
+        std::map<std::string, OrxonoxOverlay*> hudElements_;    //!< Contains all the OrxonoxOverlays of the this group.
+        Vector2 scale_;                                         //!< Current scale (independent of the elements).
+        Vector2 scroll_;                                        //!< Current scrolling offset.
+        ControllableEntity* owner_;                             //!< The owner of this OverlayGroup
     };
 }
Index: code/branches/questsystem5/src/orxonox/overlays/console/InGameConsole.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/overlays/console/InGameConsole.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/overlays/console/InGameConsole.cc	(revision 2908)
@@ -42,5 +42,4 @@
 #include "util/Convert.h"
 #include "util/Debug.h"
-#include "core/Clock.h"
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
@@ -173,5 +172,5 @@
     {
         // create the corresponding input state
-        inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("console", false, false, InputStatePriority::Console);
+        inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("console", 40);
         inputState_->setKeyHandler(Shell::getInstance().getInputBuffer());
         bHidesAllInputChanged();
@@ -348,5 +347,5 @@
         @brief Used to control the actual scrolling and the cursor.
     */
-    void InGameConsole::update(const Clock& time)
+    void InGameConsole::tick(float dt)
     {
         if (this->scroll_ != 0)
@@ -359,5 +358,5 @@
                 // enlarge oldTop a little bit so that this exponential function
                 // reaches 0 before infinite time has passed...
-                float deltaScroll = (oldTop - 0.01) * time.getDeltaTime() * this->scrollSpeed_;
+                float deltaScroll = (oldTop - 0.01) * dt * this->scrollSpeed_;
                 if (oldTop - deltaScroll >= 0)
                 {
@@ -374,5 +373,5 @@
                 // scrolling up
                 // note: +0.01 for the same reason as when scrolling down
-                float deltaScroll = (1.2 * this->relativeHeight + 0.01 + oldTop) * time.getDeltaTime() * this->scrollSpeed_;
+                float deltaScroll = (1.2 * this->relativeHeight + 0.01 + oldTop) * dt * this->scrollSpeed_;
                 if (oldTop - deltaScroll <= -1.2 * this->relativeHeight)
                 {
@@ -389,5 +388,5 @@
         if (this->bActive_)
         {
-            this->cursor_ += time.getDeltaTime();
+            this->cursor_ += dt;
             if (this->cursor_ >= this->blinkTime)
             {
@@ -410,5 +409,5 @@
         @brief Resizes the console elements. Call if window size changes.
     */
-    void InGameConsole::windowResized(unsigned int newWidth, unsigned int newHeight)
+    void InGameConsole::windowResized(int newWidth, int newHeight)
     {
         this->windowW_ = newWidth;
Index: code/branches/questsystem5/src/orxonox/overlays/console/InGameConsole.h
===================================================================
--- code/branches/questsystem5/src/orxonox/overlays/console/InGameConsole.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/overlays/console/InGameConsole.h	(revision 2908)
@@ -53,5 +53,5 @@
         void setConfigValues();
 
-        void update(const Clock& time);
+        virtual void tick(float dt);
 
         static InGameConsole& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
@@ -81,5 +81,5 @@
         void print(const std::string& text, int index, bool alwaysShift = false);
 
-        void windowResized(unsigned int newWidth, unsigned int newHeight);
+        void windowResized(int newWidth, int newHeight);
 
         // config value related
Index: code/branches/questsystem5/src/orxonox/overlays/debug/DebugFPSText.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/overlays/debug/DebugFPSText.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/overlays/debug/DebugFPSText.cc	(revision 2908)
@@ -30,7 +30,7 @@
 #include "DebugFPSText.h"
 #include <OgreTextAreaOverlayElement.h>
+#include "core/CoreIncludes.h"
+#include "GraphicsEngine.h"
 #include "util/Convert.h"
-#include "core/CoreIncludes.h"
-#include "core/Game.h"
 
 namespace orxonox
@@ -51,5 +51,5 @@
         SUPER(DebugFPSText, tick, dt);
 
-        float fps = Game::getInstance().getAvgFPS();
+        float fps = GraphicsEngine::getInstance().getAverageFramesPerSecond();
         this->setCaption(convertToString(fps));
     }
Index: code/branches/questsystem5/src/orxonox/overlays/debug/DebugRTRText.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/overlays/debug/DebugRTRText.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/overlays/debug/DebugRTRText.cc	(revision 2908)
@@ -32,5 +32,5 @@
 #include "core/CoreIncludes.h"
 #include "util/Convert.h"
-#include "core/Game.h"
+#include "GraphicsEngine.h"
 
 namespace orxonox
@@ -51,5 +51,5 @@
         SUPER(DebugRTRText, tick, dt);
 
-        float rtr = Game::getInstance().getAvgTickTime();
+        float rtr = GraphicsEngine::getInstance().getAverageTickTime();
         this->setCaption(convertToString(rtr));
     }
Index: code/branches/questsystem5/src/orxonox/overlays/hud/CMakeLists.txt
===================================================================
--- code/branches/questsystem5/src/orxonox/overlays/hud/CMakeLists.txt	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/overlays/hud/CMakeLists.txt	(revision 2908)
@@ -7,4 +7,3 @@
   ChatOverlay.cc
   GametypeStatus.cc
-  PongScore.cc
 )
Index: code/branches/questsystem5/src/orxonox/overlays/hud/HUDRadar.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/overlays/hud/HUDRadar.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/overlays/hud/HUDRadar.cc	(revision 2908)
@@ -94,5 +94,5 @@
     void HUDRadar::displayObject(RadarViewable* object, bool bIsMarked)
     {
-        if (object == static_cast<RadarViewable*>(this->owner_))
+        if (object == (RadarViewable*)this->owner_)
             return;
 
Index: code/branches/questsystem5/src/orxonox/overlays/hud/PongScore.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/overlays/hud/PongScore.cc	(revision 2907)
+++ 	(revision )
@@ -1,139 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#include "OrxonoxStableHeaders.h"
-#include "PongScore.h"
-
-#include <OgreTextAreaOverlayElement.h>
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "util/Convert.h"
-#include "objects/gametypes/Pong.h"
-#include "objects/infos/PlayerInfo.h"
-
-namespace orxonox
-{
-    CreateFactory(PongScore);
-
-    PongScore::PongScore(BaseObject* creator) : OverlayText(creator)
-    {
-        RegisterObject(PongScore);
-
-        this->owner_ = 0;
-
-        this->bShowName_ = false;
-        this->bShowScore_ = false;
-        this->bShowLeftPlayer_ = false;
-        this->bShowRightPlayer_ = false;
-    }
-
-    PongScore::~PongScore()
-    {
-    }
-
-    void PongScore::XMLPort(Element& xmlelement, XMLPort::Mode mode)
-    {
-        SUPER(PongScore, XMLPort, xmlelement, mode);
-
-        XMLPortParam(PongScore, "showname",        setShowName,        getShowName,        xmlelement, mode).defaultValues(false);
-        XMLPortParam(PongScore, "showscore",       setShowScore,       getShowScore,       xmlelement, mode).defaultValues(false);
-        XMLPortParam(PongScore, "showleftplayer",  setShowLeftPlayer,  getShowLeftPlayer,  xmlelement, mode).defaultValues(false);
-        XMLPortParam(PongScore, "showrightplayer", setShowRightPlayer, getShowRightPlayer, xmlelement, mode).defaultValues(false);
-    }
-
-    void PongScore::tick(float dt)
-    {
-        SUPER(PongScore, tick, dt);
-
-        if (this->owner_)
-        {
-            PlayerInfo* player1 = this->owner_->getLeftPlayer();
-            PlayerInfo* player2 = this->owner_->getRightPlayer();
-
-            std::string name1;
-            std::string name2;
-
-            std::string score1 = "0";
-            std::string score2 = "0";
-
-            if (player1)
-            {
-                name1 = player1->getName();
-                score1 = convertToString(this->owner_->getScore(player1));
-            }
-
-            if (player2)
-            {
-                name2 = player2->getName();
-                score2 = convertToString(this->owner_->getScore(player2));
-            }
-
-            std::string output1;
-            if (this->bShowLeftPlayer_)
-            {
-                if (this->bShowName_ && this->bShowScore_ && player1)
-                    output1 = name1 + " - " + score1;
-                else if (this->bShowScore_)
-                    output1 = score1;
-                else if (this->bShowName_)
-                    output1 = name1;
-            }
-
-            std::string output2;
-            if (this->bShowRightPlayer_)
-            {
-                if (this->bShowName_ && this->bShowScore_ && player2)
-                    output2 = score2 + " - " + name2;
-                else if (this->bShowScore_)
-                    output2 = score2;
-                else if (this->bShowName_)
-                    output2 = name2;
-            }
-
-            std::string output = "PONG";
-            if (this->bShowName_ || this->bShowScore_)
-            {
-                if (this->bShowLeftPlayer_ && this->bShowRightPlayer_)
-                    output = output1 + ":" + output2;
-                else if (this->bShowLeftPlayer_ || this->bShowRightPlayer_)
-                    output = output1 + output2;
-            }
-
-            this->setCaption(output);
-        }
-    }
-
-
-    void PongScore::changedOwner()
-    {
-        SUPER(PongScore, changedOwner);
-
-        this->owner_ = dynamic_cast<Pong*>(this->getOwner());
-    }
-}
Index: code/branches/questsystem5/src/orxonox/overlays/hud/PongScore.h
===================================================================
--- code/branches/questsystem5/src/orxonox/overlays/hud/PongScore.h	(revision 2907)
+++ 	(revision )
@@ -1,77 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _PongScore_H__
-#define _PongScore_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "overlays/OverlayText.h"
-#include "objects/Tickable.h"
-
-namespace orxonox
-{
-    class _OrxonoxExport PongScore : public OverlayText, public Tickable
-    {
-        public:
-            PongScore(BaseObject* creator);
-            ~PongScore();
-
-            virtual void tick(float dt);
-            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-            virtual void changedOwner();
-
-            inline void setShowName(bool value)
-                { this->bShowName_ = value; }
-            inline bool getShowName() const
-                { return this->bShowName_; }
-
-            inline void setShowScore(bool value)
-                { this->bShowScore_ = value; }
-            inline bool getShowScore() const
-                { return this->bShowScore_; }
-
-            inline void setShowLeftPlayer(bool value)
-                { this->bShowLeftPlayer_ = value; }
-            inline bool getShowLeftPlayer() const
-                { return this->bShowLeftPlayer_; }
-
-            inline void setShowRightPlayer(bool value)
-                { this->bShowRightPlayer_ = value; }
-            inline bool getShowRightPlayer() const
-                { return this->bShowRightPlayer_; }
-
-        private:
-            Pong* owner_;
-            bool bShowName_;
-            bool bShowScore_;
-            bool bShowLeftPlayer_;
-            bool bShowRightPlayer_;
-    };
-}
-#endif /* _PongScore_H__ */
Index: code/branches/questsystem5/src/orxonox/overlays/notifications/NotificationQueue.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/overlays/notifications/NotificationQueue.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/overlays/notifications/NotificationQueue.cc	(revision 2908)
@@ -410,5 +410,5 @@
         this->containers_.insert(container);
         this->overlays_[notification] = container;
-        this->addElement(container->overlay);
+        this->insertElement(container->overlay, container->name);
         this->size_= this->size_+1;
 
@@ -429,5 +429,5 @@
             return false;
         
-        this->removeElement(container->overlay);
+        this->removeElement(container->name);
         this->containers_.erase(container);
         this->overlays_.erase(container->notification);
Index: code/branches/questsystem5/src/orxonox/pch/havepch/OrxonoxStableHeaders.h
===================================================================
--- code/branches/questsystem5/src/orxonox/pch/havepch/OrxonoxStableHeaders.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/pch/havepch/OrxonoxStableHeaders.h	(revision 2908)
@@ -45,7 +45,5 @@
 #  define WIN32_LEAN_AND_MEAN
 #endif
-#ifndef NOMINMAX
-#  define NOMINMAX // required to stop windows.h screwing up std::min definition
-#endif
+#define NOMINMAX // required to stop windows.h screwing up std::min definition
 #include <Ogre.h>
 #include <CEGUI.h>
Index: code/branches/questsystem5/src/orxonox/tools/BillboardSet.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/tools/BillboardSet.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/tools/BillboardSet.cc	(revision 2908)
@@ -37,5 +37,5 @@
 #include <OgreBillboard.h>
 
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "util/Convert.h"
 #include "util/String.h"
@@ -72,5 +72,5 @@
         try
         {
-            if (GameMode::showsGraphics())
+            if (Core::showsGraphics())
             {
                 this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count);
@@ -95,5 +95,5 @@
         try
         {
-            if (GameMode::showsGraphics())
+            if (Core::showsGraphics())
             {
                 this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count);
Index: code/branches/questsystem5/src/orxonox/tools/CMakeLists.txt
===================================================================
--- code/branches/questsystem5/src/orxonox/tools/CMakeLists.txt	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/tools/CMakeLists.txt	(revision 2908)
@@ -5,5 +5,4 @@
   Shader.cc
   TextureGenerator.cc
-  TimeFactorListener.cc
   Timer.cc
   WindowEventListener.cc
Index: code/branches/questsystem5/src/orxonox/tools/Mesh.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/tools/Mesh.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/tools/Mesh.cc	(revision 2908)
@@ -35,5 +35,5 @@
 #include <cassert>
 
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "util/Convert.h"
 #include "util/String.h"
@@ -64,5 +64,5 @@
             this->scenemanager_->destroyEntity(this->entity_);
 
-        if (GameMode::showsGraphics())
+        if (Core::showsGraphics())
         {
             try
@@ -70,13 +70,4 @@
                 this->entity_ = this->scenemanager_->createEntity("Mesh" + convertToString(Mesh::meshCounter_s++), meshsource);
                 this->entity_->setCastShadows(this->bCastShadows_);
-
-                this->entity_->setNormaliseNormals(true);
-                /*
-                    Excerpt from Ogre forum:
-                    "Note that the above is only for the fixed function pipeline.
-                    If/when you get into shaders, you'll need to manually normalize() the normal inside the vertex or pixel shader."
-
-                    I don't know exactly what this means, but I put this here if there will be problems with shaders.
-                */
             }
             catch (...)
Index: code/branches/questsystem5/src/orxonox/tools/ParticleInterface.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/tools/ParticleInterface.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/tools/ParticleInterface.cc	(revision 2908)
@@ -40,6 +40,6 @@
 #include <cassert>
 
-#include "GraphicsManager.h"
-#include "core/GameMode.h"
+#include "GraphicsEngine.h"
+#include "core/Core.h"
 #include "core/CoreIncludes.h"
 #include "util/Convert.h"
@@ -64,5 +64,5 @@
         this->speedFactor_ = 1.0f;
 
-        if (GameMode::showsGraphics())
+        if (Core::showsGraphics())
         {
             try
@@ -178,6 +178,6 @@
     {
         this->detaillevel_ = level;
-        if (GameMode::showsGraphics())
-            this->detailLevelChanged(GraphicsManager::getInstance().getDetailLevelParticle());
+        if (GraphicsEngine::getInstancePtr())
+            this->detailLevelChanged(GraphicsEngine::getInstance().getDetailLevelParticle());
     }
 
Index: code/branches/questsystem5/src/orxonox/tools/ParticleInterface.h
===================================================================
--- code/branches/questsystem5/src/orxonox/tools/ParticleInterface.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/tools/ParticleInterface.h	(revision 2908)
@@ -37,5 +37,5 @@
 #include "core/OrxonoxClass.h"
 #include "util/Math.h"
-#include "tools/TimeFactorListener.h"
+#include "gamestates/GSRoot.h"
 
 #define getAllEmitters() \
Index: code/branches/questsystem5/src/orxonox/tools/Shader.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/tools/Shader.cc	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/tools/Shader.cc	(revision 2908)
@@ -36,8 +36,8 @@
 #include <OgrePlugin.h>
 
-#include "core/GameMode.h"
+#include "core/Core.h"
 #include "core/CoreIncludes.h"
 #include "core/Executor.h"
-#include "GraphicsManager.h"
+#include "GraphicsEngine.h"
 #include "util/Exception.h"
 
@@ -59,5 +59,5 @@
         this->compositorInstance_ = 0;
         this->bVisible_ = true;
-        this->bLoadCompositor_ = GameMode::showsGraphics();
+        this->bLoadCompositor_ = Core::showsGraphics() && GraphicsEngine::getInstancePtr();
         this->bViewportInitialized_ = false;
         this->compositor_ = "";
@@ -86,5 +86,5 @@
         if (this->bLoadCompositor_ && this->compositorInstance_)
         {
-            Ogre::Viewport* viewport = GraphicsManager::getInstance().getViewport();
+            Ogre::Viewport* viewport = GraphicsEngine::getInstance().getViewport();
             assert(viewport);
             Ogre::CompositorManager::getSingleton().removeCompositor(viewport, this->compositor_);
@@ -114,5 +114,5 @@
         if (this->bLoadCompositor_)
         {
-            Ogre::Viewport* viewport = GraphicsManager::getInstance().getViewport();
+            Ogre::Viewport* viewport = GraphicsEngine::getInstance().getViewport();
             assert(viewport);
             if (this->oldcompositor_ != "")
@@ -246,5 +246,5 @@
     Shader::ParameterPointer* Shader::getParameterPointer(const std::string& material, size_t technique, size_t pass, const std::string& parameter)
     {
-        if (!GameMode::showsGraphics() || !Shader::bLoadedCgPlugin_s)
+        if (!Core::showsGraphics() || !Shader::bLoadedCgPlugin_s)
             return 0;
 
Index: code/branches/questsystem5/src/orxonox/tools/TimeFactorListener.cc
===================================================================
--- code/branches/questsystem5/src/orxonox/tools/TimeFactorListener.cc	(revision 2907)
+++ 	(revision )
@@ -1,41 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-#include "OrxonoxStableHeaders.h"
-#include "TimeFactorListener.h"
-#include "core/CoreIncludes.h"
-
-namespace orxonox
-{
-    float TimeFactorListener::timefactor_s = 1.0f;
-
-    TimeFactorListener::TimeFactorListener()
-    {
-        RegisterRootObject(TimeFactorListener);
-    }
-}
Index: code/branches/questsystem5/src/orxonox/tools/TimeFactorListener.h
===================================================================
--- code/branches/questsystem5/src/orxonox/tools/TimeFactorListener.h	(revision 2907)
+++ 	(revision )
@@ -1,56 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _TimeFactorListener_H__
-#define _TimeFactorListener_H__
-
-#include "OrxonoxPrereqs.h"
-#include "core/OrxonoxClass.h"
-
-
-namespace orxonox
-{
-    class _OrxonoxExport TimeFactorListener : virtual public OrxonoxClass
-    {
-        friend class GSRoot;
-
-        public:
-            TimeFactorListener();
-            virtual ~TimeFactorListener() {}
-
-        protected:
-            virtual void changedTimeFactor(float factor_new, float factor_old) {}
-            inline float getTimeFactor() const
-                { return TimeFactorListener::timefactor_s; }
-
-        private:
-            static float timefactor_s;
-    };
-}
-
-#endif /* _TimeFactorListener_H__ */
Index: code/branches/questsystem5/src/orxonox/tools/Timer.h
===================================================================
--- code/branches/questsystem5/src/orxonox/tools/Timer.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/tools/Timer.h	(revision 2908)
@@ -64,5 +64,5 @@
 #include "core/Executor.h"
 #include "core/OrxonoxClass.h"
-#include "tools/TimeFactorListener.h"
+#include "gamestates/GSRoot.h"
 
 namespace orxonox
Index: code/branches/questsystem5/src/orxonox/tools/WindowEventListener.h
===================================================================
--- code/branches/questsystem5/src/orxonox/tools/WindowEventListener.h	(revision 2907)
+++ code/branches/questsystem5/src/orxonox/tools/WindowEventListener.h	(revision 2908)
@@ -49,5 +49,5 @@
 
             /** Window has resized */
-            virtual void windowResized(unsigned int newWidth, unsigned int newHeight) { }
+            virtual void windowResized(int newWidth, int newHeight) { }
 
             /** Window has lost/gained focus */
