Index: /code/branches/gui/src/core/CorePrereqs.h
===================================================================
--- /code/branches/gui/src/core/CorePrereqs.h	(revision 1687)
+++ /code/branches/gui/src/core/CorePrereqs.h	(revision 1688)
@@ -163,4 +163,6 @@
   // game states
   class GameState;
+  template <class ParentType>
+  class GameStateTyped;
   class RootGameState;
 
Index: /code/branches/gui/src/core/GameState.cc
===================================================================
--- /code/branches/gui/src/core/GameState.cc	(revision 1687)
+++ /code/branches/gui/src/core/GameState.cc	(revision 1688)
@@ -45,7 +45,7 @@
     GameState::GameState(const std::string& name)
         : name_(name)
-        , parent_(0)
+        //, parent_(0)
         , activeChild_(0)
-        //, bPauseParent_(false)
+        //, bPausegetParent()(false)
     {
         Operations temp = {false, false, false, false, false};
@@ -103,5 +103,5 @@
 
         // mark us as parent
-        state->parent_ = this;
+        state->setParent(this);
     }
 
@@ -178,6 +178,6 @@
         this->allChildren_[grandchild->getName()] = grandchild;
         this->grandchildrenToChildren_[grandchild] = child;
-        if (this->parent_)
-            this->parent_->grandchildAdded(this, grandchild);
+        if (this->getParent())
+            this->getParent()->grandchildAdded(this, grandchild);
     }
 
@@ -196,6 +196,6 @@
         this->allChildren_.erase(grandchild->getName());
         this->grandchildrenToChildren_.erase(grandchild);
-        if (this->parent_)
-            this->parent_->grandchildRemoved(grandchild);
+        if (this->getParent())
+            this->getParent()->grandchildRemoved(grandchild);
     }
 
@@ -208,6 +208,6 @@
     GameState* GameState::getState(const std::string& name)
     {
-        if (this->parent_)
-            return this->parent_->getState(name);
+        if (this->getParent())
+            return this->getParent()->getState(name);
         else
         {
@@ -227,6 +227,6 @@
     GameState* GameState::getRoot()
     {
-        if (this->parent_)
-            return this->parent_->getRoot();
+        if (this->getParent())
+            return this->getParent()->getRoot();
         else
             return this;
Index: /code/branches/gui/src/core/GameState.h
===================================================================
--- /code/branches/gui/src/core/GameState.h	(revision 1687)
+++ /code/branches/gui/src/core/GameState.h	(revision 1688)
@@ -41,4 +41,5 @@
 #include <vector>
 #include <map>
+#include <cassert>
 #include "util/Integers.h"
 #include "Clock.h"
@@ -63,4 +64,6 @@
     {
         friend class RootGameState;
+        template <class ParentType>
+        friend class GameStateTyped;
 
     public:
@@ -79,5 +82,4 @@
 
     public:
-        GameState(const std::string& name);
         virtual ~GameState();
 
@@ -88,5 +90,4 @@
         GameState* getState(const std::string& name);
         GameState* getRoot();
-        GameState* getParent() const { return this->parent_; }
         //! Returns the currently active game state
         virtual GameState* getCurrentState();
@@ -107,5 +108,12 @@
         void tickChild(const Clock& time) { if (this->getActiveChild()) this->getActiveChild()->tick(time); }
 
+        virtual GameState* getParent() const = 0;
+        virtual void setParent(GameState* state) = 0;
+
     private:
+        // Making the constructor private ensures that game states
+        // are always derivates of GameStateTyped<T>. Note the friend declaration above.
+        GameState(const std::string& name);
+
         //! Performs a transition to 'destination'
         virtual void makeTransition(GameState* source, GameState* destination);
@@ -120,5 +128,4 @@
         const std::string                   name_;
         Operations                          operation_;
-        GameState*                          parent_;
         GameState*                          activeChild_;
         //bool                                bPauseParent_;
@@ -126,4 +133,25 @@
         std::map<GameState*, GameState*>    grandchildrenToChildren_;
     };
+
+    template <class ParentType>
+    class GameStateTyped : public GameState
+    {
+    public:
+        GameStateTyped(const std::string& name) : GameState(name) { }
+        virtual ~GameStateTyped() { }
+
+        ParentType* getParent() const
+            { return parent_; }
+
+    protected:
+        void setParent(GameState* state)
+        {
+            assert(dynamic_cast<ParentType*>(state) != 0);
+            this->parent_ = dynamic_cast<ParentType*>(state);
+        }
+
+    private:
+        ParentType* parent_;
+    };
 }
 
Index: /code/branches/gui/src/core/RootGameState.cc
===================================================================
--- /code/branches/gui/src/core/RootGameState.cc	(revision 1687)
+++ /code/branches/gui/src/core/RootGameState.cc	(revision 1688)
@@ -39,5 +39,5 @@
 
     RootGameState::RootGameState(const std::string& name)
-        : GameState(name)
+        : GameStateTyped<GameState>(name)
         , stateRequest_("")
     {
Index: /code/branches/gui/src/core/RootGameState.h
===================================================================
--- /code/branches/gui/src/core/RootGameState.h	(revision 1687)
+++ /code/branches/gui/src/core/RootGameState.h	(revision 1688)
@@ -35,5 +35,5 @@
 namespace orxonox
 {
-    class _CoreExport RootGameState : public GameState
+    class _CoreExport RootGameState : public GameStateTyped<GameState>
     {
     public:
Index: /code/branches/gui/src/orxonox/Main.cc
===================================================================
--- /code/branches/gui/src/orxonox/Main.cc	(revision 1687)
+++ /code/branches/gui/src/orxonox/Main.cc	(revision 1688)
@@ -130,5 +130,4 @@
     GSClient client;
     GSGUI gui;
-    GSIO io;
     GSIOConsole ioConsole;
 
@@ -139,6 +138,5 @@
     graphics.addChild(&gui);
 
-    root.addChild(&io);
-    io.addChild(&ioConsole);
+    root.addChild(&ioConsole);
 
     root.feedCommandLine(argc, argv);
Index: /code/branches/gui/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- /code/branches/gui/src/orxonox/OrxonoxPrereqs.h	(revision 1687)
+++ /code/branches/gui/src/orxonox/OrxonoxPrereqs.h	(revision 1688)
@@ -120,4 +120,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/gui/src/orxonox/gamestates/GSGUI.cc
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSGUI.cc	(revision 1687)
+++ /code/branches/gui/src/orxonox/gamestates/GSGUI.cc	(revision 1688)
@@ -39,5 +39,5 @@
 {
     GSGUI::GSGUI()
-        : GameState("gui")
+        : GameStateTyped<GSGraphics>("gui")
     {
     }
@@ -49,12 +49,14 @@
     void GSGUI::enter()
     {
+        guiManager_ = getParent()->getGUIManager();
+
         // show main menu
-        GUIManager::getInstance().showGUI("MainMenu", 0);
-        GraphicsEngine::getInstance().getViewport()->setCamera(GUIManager::getInstance().getCamera());
+        guiManager_->showGUI("MainMenu", 0);
+        getParent()->getViewport()->setCamera(guiManager_->getCamera());
     }
 
     void GSGUI::leave()
     {
-        GUIManager::getInstance().hideGUI();
+        guiManager_->hideGUI();
     }
 
@@ -62,5 +64,5 @@
     {
         // tick CEGUI
-        GUIManager::getInstance().tick(time.getDeltaTime());
+        guiManager_->tick(time.getDeltaTime());
 
         this->tickChild(time);
Index: /code/branches/gui/src/orxonox/gamestates/GSGUI.h
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSGUI.h	(revision 1687)
+++ /code/branches/gui/src/orxonox/gamestates/GSGUI.h	(revision 1688)
@@ -32,8 +32,9 @@
 #include "OrxonoxPrereqs.h"
 #include "core/GameState.h"
+#include "GSGraphics.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSGUI : public GameState
+    class _OrxonoxExport GSGUI : public GameStateTyped<GSGraphics>
     {
     public:
@@ -45,4 +46,6 @@
         void leave();
         void ticked(const Clock& time);
+
+        GUIManager* guiManager_;
     };
 }
Index: /code/branches/gui/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSGraphics.cc	(revision 1687)
+++ /code/branches/gui/src/orxonox/gamestates/GSGraphics.cc	(revision 1688)
@@ -57,5 +57,5 @@
 {
     GSGraphics::GSGraphics()
-        : GameState("graphics")
+        : GameStateTyped<GSRoot>("graphics")
         , ogreRoot_(0)
         , inputManager_(0)
@@ -77,5 +77,5 @@
     void GSGraphics::setConfigValues()
     {
-        SetConfigValue(resourceFile_,    "resources.cfg").description("Location of the resources file in the data path.");
+        SetConfigValue(resourceFile_, "resources.cfg").description("Location of the resources file in the data path.");
         SetConfigValue(statisticsRefreshCycle_, 200000).description("Sets the time in microseconds interval at which average fps, etc. get updated.");
     }
@@ -85,5 +85,5 @@
         setConfigValues();
 
-        this->ogreRoot_ = Ogre::Root::getSingletonPtr();
+        this->ogreRoot_ = getParent()->getOgreRoot();
 
         this->declareResources();
@@ -94,8 +94,8 @@
 
         // HACK: temporary:
-        GraphicsEngine& graphicsEngine = GraphicsEngine::getInstance();
-        graphicsEngine.renderWindow_ = this->renderWindow_;
-        graphicsEngine.root_ = this->ogreRoot_;
-        graphicsEngine.viewport_ = this->viewport_;
+        GraphicsEngine* graphicsEngine = getParent()->getGraphicsEngine();
+        graphicsEngine->renderWindow_  = this->renderWindow_;
+        graphicsEngine->root_          = this->ogreRoot_;
+        graphicsEngine->viewport_      = this->viewport_;
 
 
Index: /code/branches/gui/src/orxonox/gamestates/GSGraphics.h
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSGraphics.h	(revision 1687)
+++ /code/branches/gui/src/orxonox/gamestates/GSGraphics.h	(revision 1688)
@@ -35,8 +35,9 @@
 #include "core/GameState.h"
 #include "core/OrxonoxClass.h"
+#include "GSRoot.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSGraphics : public GameState, public OrxonoxClass, public Ogre::WindowEventListener
+    class _OrxonoxExport GSGraphics : public GameStateTyped<GSRoot>, public OrxonoxClass, public Ogre::WindowEventListener
     {
         friend class ClassIdentifier<GSGraphics>;
@@ -44,4 +45,7 @@
         GSGraphics();
         ~GSGraphics();
+
+        Ogre::Viewport* getViewport() { return this->viewport_; }
+        GUIManager* getGUIManager() { return this->guiManager_; }
 
     private:
Index: de/branches/gui/src/orxonox/gamestates/GSIO.cc
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSIO.cc	(revision 1687)
+++ 	(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:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-#include "OrxonoxStableHeaders.h"
-#include "GSIO.h"
-
-namespace orxonox
-{
-    GSIO::GSIO()
-        : GameState("io")
-    {
-    }
-
-    GSIO::~GSIO()
-    {
-    }
-
-    void GSIO::enter()
-    {
-    }
-
-    void GSIO::leave()
-    {
-    }
-
-    void GSIO::ticked(const Clock& time)
-    {
-        this->tickChild(time);
-    }
-}
Index: de/branches/gui/src/orxonox/gamestates/GSIO.h
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSIO.h	(revision 1687)
+++ 	(revision )
@@ -1,50 +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 _GSIO_H__
-#define _GSIO_H__
-
-#include "OrxonoxPrereqs.h"
-#include "core/GameState.h"
-
-namespace orxonox
-{
-    class _OrxonoxExport GSIO : public GameState
-    {
-    public:
-        GSIO();
-        ~GSIO();
-
-    private:
-        void enter();
-        void leave();
-        void ticked(const Clock& time);
-    };
-}
-
-#endif /* _GSIO_H__ */
Index: /code/branches/gui/src/orxonox/gamestates/GSIOConsole.cc
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSIOConsole.cc	(revision 1687)
+++ /code/branches/gui/src/orxonox/gamestates/GSIOConsole.cc	(revision 1688)
@@ -42,5 +42,5 @@
 {
     GSIOConsole::GSIOConsole()
-        : GameState("ioConsole")
+        : GameStateTyped<GSRoot>("ioConsole")
     {
     }
Index: /code/branches/gui/src/orxonox/gamestates/GSIOConsole.h
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSIOConsole.h	(revision 1687)
+++ /code/branches/gui/src/orxonox/gamestates/GSIOConsole.h	(revision 1688)
@@ -33,8 +33,9 @@
 #include <OgrePrerequisites.h>
 #include "core/GameState.h"
+#include "GSRoot.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSIOConsole : public GameState
+    class _OrxonoxExport GSIOConsole : public GameStateTyped<GSRoot>
     {
     public:
Index: /code/branches/gui/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSLevel.cc	(revision 1687)
+++ /code/branches/gui/src/orxonox/gamestates/GSLevel.cc	(revision 1688)
@@ -45,5 +45,5 @@
 {
     GSLevel::GSLevel(const std::string& name)
-        : GameState(name)
+        : GameStateTyped<GSGraphics>(name)
         , timeFactor_(1.0f)
         , sceneManager_(0)
@@ -68,7 +68,8 @@
 
         // create Ogre SceneManager for the level
-        this->sceneManager_ = GraphicsEngine::getInstance().getOgreRoot()->
-            createSceneManager(Ogre::ST_GENERIC, "LevelSceneManager");
+        this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC, "LevelSceneManager");
         COUT(4) << "Created SceneManager: " << sceneManager_->getName() << std::endl;
+
+        // temporary hack
         GraphicsEngine::getInstance().setLevelSceneManager(this->sceneManager_);
 
@@ -98,5 +99,5 @@
         delete this->radar_;
 
-        GraphicsEngine::getInstance().getOgreRoot()->destroySceneManager(this->sceneManager_);
+        Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
 
         inputState_->setHandler(0);
Index: /code/branches/gui/src/orxonox/gamestates/GSLevel.h
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSLevel.h	(revision 1687)
+++ /code/branches/gui/src/orxonox/gamestates/GSLevel.h	(revision 1688)
@@ -33,8 +33,9 @@
 #include <OgrePrerequisites.h>
 #include "core/GameState.h"
+#include "GSGraphics.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSLevel : public GameState
+    class _OrxonoxExport GSLevel : public GameStateTyped<GSGraphics>
     {
     public:
Index: /code/branches/gui/src/orxonox/gamestates/GSRoot.h
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSRoot.h	(revision 1687)
+++ /code/branches/gui/src/orxonox/gamestates/GSRoot.h	(revision 1688)
@@ -49,4 +49,7 @@
         { requestState("root"); }
 
+        Ogre::Root* getOgreRoot() { return this->ogreRoot_; }
+        GraphicsEngine* getGraphicsEngine() { return this->graphicsEngine_; }
+
     private:
         void enter();
Index: /code/branches/gui/visual_studio/vc8/orxonox.vcproj
===================================================================
--- /code/branches/gui/visual_studio/vc8/orxonox.vcproj	(revision 1687)
+++ /code/branches/gui/visual_studio/vc8/orxonox.vcproj	(revision 1688)
@@ -504,8 +504,4 @@
 				</File>
 				<File
-					RelativePath="..\..\src\orxonox\gamestates\GSIO.cc"
-					>
-				</File>
-				<File
 					RelativePath="..\..\src\orxonox\gamestates\GSIOConsole.cc"
 					>
@@ -759,8 +755,4 @@
 				<File
 					RelativePath="..\..\src\orxonox\gamestates\GSGUI.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\src\orxonox\gamestates\GSIO.h"
 					>
 				</File>
