Index: code/trunk/src/CMakeLists.txt
===================================================================
--- code/trunk/src/CMakeLists.txt	(revision 10622)
+++ code/trunk/src/CMakeLists.txt	(revision 10624)
@@ -39,4 +39,5 @@
 ADD_SUBDIRECTORY(orxonox)
 SET(ORXONOX_MODULES CACHE INTERNAL "")
+SET(ORXONOX_PLUGINS CACHE INTERNAL "")
 ADD_SUBDIRECTORY(modules)
 
@@ -72,5 +73,5 @@
   OUTPUT_NAME orxonox
 )
-# Main executable should depend on all modules
+# Main executable should depend on all modules (but not on plugins)
 ADD_DEPENDENCIES(orxonox-main ${ORXONOX_MODULES})
 
Index: code/trunk/src/SpecialConfig.h.in
===================================================================
--- code/trunk/src/SpecialConfig.h.in	(revision 10622)
+++ code/trunk/src/SpecialConfig.h.in	(revision 10624)
@@ -60,4 +60,5 @@
     const char defaultArchivePath[] = "@DEFAULT_ARCHIVE_PATH@";
     const char defaultModulePath[]  = "@DEFAULT_MODULE_PATH@";
+    const char defaultPluginPath[]  = "@DEFAULT_PLUGIN_PATH@";
     const char defaultDocPath[]     = "@DEFAULT_DOC_PATH@";
     const char defaultDataPath[]    = "@DEFAULT_DATA_PATH@";
@@ -69,4 +70,5 @@
     const char dataInstallDirectory[]       = "@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIRECTORY@";
     const char moduleInstallDirectory[]     = "@CMAKE_INSTALL_PREFIX@/@MODULE_INSTALL_DIRECTORY@";
+    const char pluginInstallDirectory[]     = "@CMAKE_INSTALL_PREFIX@/@PLUGIN_INSTALL_DIRECTORY@";
 #endif
 
@@ -76,8 +78,10 @@
 #ifdef CMAKE_CONFIGURATION_TYPES
     const char moduleDevDirectory[]         = "@CMAKE_MODULE_OUTPUT_DIRECTORY@/" CMAKE_INTDIR;
+    const char pluginDevDirectory[]         = "@CMAKE_PLUGIN_OUTPUT_DIRECTORY@/" CMAKE_INTDIR;
     const char configDevDirectory[]         = "@CMAKE_CONFIG_OUTPUT_DIRECTORY@/" CMAKE_INTDIR;
     const char logDevDirectory[]            = "@CMAKE_LOG_OUTPUT_DIRECTORY@/"    CMAKE_INTDIR;
 #else
     const char moduleDevDirectory[]         = "@CMAKE_MODULE_OUTPUT_DIRECTORY@";
+    const char pluginDevDirectory[]         = "@CMAKE_PLUGIN_OUTPUT_DIRECTORY@";
     const char configDevDirectory[]         = "@CMAKE_CONFIG_OUTPUT_DIRECTORY@";
     const char logDevDirectory[]            = "@CMAKE_LOG_OUTPUT_DIRECTORY@";
@@ -88,6 +92,7 @@
 #endif
 
-    // Module extension
+    // Module and plugin extension
     const char moduleExtension[] = "@ORXONOX_MODULE_EXTENSION@";
+    const char pluginExtension[] = "@ORXONOX_PLUGIN_EXTENSION@";
 
     // OGRE PLUGINS
Index: code/trunk/src/libraries/core/ApplicationPaths.cc
===================================================================
--- code/trunk/src/libraries/core/ApplicationPaths.cc	(revision 10624)
+++ code/trunk/src/libraries/core/ApplicationPaths.cc	(revision 10624)
@@ -0,0 +1,235 @@
+/*
+ *   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 "ApplicationPaths.h"
+
+#include <cassert>
+#include <cstdlib>
+#include <cstdio>
+#include <vector>
+#include <boost/filesystem.hpp>
+
+#ifdef ORXONOX_PLATFORM_WINDOWS
+#  ifndef WIN32_LEAN_AND_MEAN
+#    define WIN32_LEAN_AND_MEAN
+#  endif
+#  include <windows.h>
+#  undef min
+#  undef max
+#elif defined(ORXONOX_PLATFORM_APPLE)
+#  include <sys/param.h>
+#  include <mach-o/dyld.h>
+#else /* Linux */
+#  include <sys/types.h>
+#  include <unistd.h>
+#endif
+
+#include "SpecialConfig.h"
+#include "util/Output.h"
+#include "util/Exception.h"
+
+// Differentiate Boost Filesystem v2 and v3
+#if (BOOST_FILESYSTEM_VERSION < 3)
+#  define BF_LEAF leaf
+#  define BF_GENERIC_STRING string
+#else
+#  define BF_LEAF path().filename().string
+#  define BF_GENERIC_STRING generic_string
+#endif
+
+namespace orxonox
+{
+    namespace bf = boost::filesystem;
+
+    //! Static pointer to the singleton
+    ApplicationPaths* ApplicationPaths::singletonPtr_s  = 0;
+
+    ApplicationPaths::ApplicationPaths()
+        : rootPath_(*(new bf::path()))
+        , executablePath_(*(new bf::path()))
+        , modulePath_(*(new bf::path()))
+        , pluginPath_(*(new bf::path()))
+        , bBuildDirectoryRun_(false)
+    {
+        //////////////////////////
+        // FIND EXECUTABLE PATH //
+        //////////////////////////
+
+#ifdef ORXONOX_PLATFORM_WINDOWS
+        // get executable module
+        TCHAR buffer[1024];
+        if (GetModuleFileName(NULL, buffer, 1024) == 0)
+            ThrowException(General, "Could not retrieve executable path.");
+
+#elif defined(ORXONOX_PLATFORM_APPLE)
+        char buffer[1024];
+        uint32_t path_len = 1023;
+        if (_NSGetExecutablePath(buffer, &path_len))
+            ThrowException(General, "Could not retrieve executable path.");
+
+#else /* Linux */
+        /* written by Nicolai Haehnle <prefect_@gmx.net> */
+
+        /* Get our PID and build the name of the link in /proc */
+        char linkname[64]; /* /proc/<pid>/exe */
+        if (snprintf(linkname, sizeof(linkname), "/proc/%i/exe", getpid()) < 0)
+        {
+            /* This should only happen on large word systems. I'm not sure
+               what the proper response is here.
+               Since it really is an assert-like condition, aborting the
+               program seems to be in order. */
+            assert(false);
+        }
+
+        /* Now read the symbolic link */
+        char buffer[1024];
+        int ret;
+        ret = readlink(linkname, buffer, 1024);
+        /* In case of an error, leave the handling up to the caller */
+        if (ret == -1)
+            ThrowException(General, "Could not retrieve executable path.");
+
+        /* Ensure proper NUL termination */
+        buffer[ret] = 0;
+#endif
+
+        // Remove executable filename
+        executablePath_ = bf::path(buffer).branch_path();
+
+        /////////////////////////////////
+        // SET MODULE AND PLUGIN PATHS //
+        /////////////////////////////////
+
+        if (bf::exists(executablePath_ / "orxonox_dev_build.keep_me"))
+        {
+            orxout(internal_info) << "Running from the build tree." << endl;
+            ApplicationPaths::bBuildDirectoryRun_ = true;
+            modulePath_ = specialConfig::moduleDevDirectory;
+            pluginPath_ = specialConfig::pluginDevDirectory;
+        }
+        else
+        {
+
+#ifdef INSTALL_COPYABLE // --> relative paths
+
+            // Also set the root path
+            bf::path relativeExecutablePath(specialConfig::defaultRuntimePath);
+            rootPath_ = executablePath_;
+            while (!bf::equivalent(rootPath_ / relativeExecutablePath, executablePath_) && !rootPath_.empty())
+                rootPath_ = rootPath_.branch_path();
+            if (rootPath_.empty())
+                ThrowException(General, "Could not derive a root directory. Might the binary installation directory contain '..' when taken relative to the installation prefix path?");
+
+            // Module and plugin paths are fixed as well
+            modulePath_ = rootPath_ / specialConfig::defaultModulePath;
+            pluginPath_ = rootPath_ / specialConfig::defaultPluginPath;
+
+#else
+
+            // There is no root path, so don't set it at all
+            // Module and plugin paths are fixed as well
+            modulePath_ = specialConfig::moduleInstallDirectory;
+            pluginPath_ = specialConfig::pluginInstallDirectory;
+
+#endif
+        }
+    }
+
+    ApplicationPaths::~ApplicationPaths()
+    {
+        delete &rootPath_;
+        delete &executablePath_;
+        delete &modulePath_;
+        delete &pluginPath_;
+    }
+
+    std::vector<std::string> ApplicationPaths::getModulePaths()
+    {
+        return this->getModuleOrPluginPaths(modulePath_, specialConfig::moduleExtension);
+    }
+
+    std::vector<std::string> ApplicationPaths::getPluginPaths()
+    {
+        return this->getModuleOrPluginPaths(pluginPath_, specialConfig::pluginExtension);
+    }
+
+    std::vector<std::string> ApplicationPaths::getModuleOrPluginPaths(boost::filesystem::path& directory, const std::string& extension)
+    {
+        std::vector<std::string> paths;
+
+        // We search for helper files with the following extension
+        size_t extensionlength = extension.size();
+
+        // Make sure the path exists, otherwise don't load modules/plugins
+        if (!boost::filesystem::exists(directory))
+            return paths;
+
+        boost::filesystem::directory_iterator file(directory);
+        boost::filesystem::directory_iterator end;
+
+        // Iterate through all files
+        while (file != end)
+        {
+            std::string filename = file->BF_LEAF();
+
+            // Check if the file ends with the extension in question
+            if (filename.size() > extensionlength)
+            {
+                if (filename.substr(filename.size() - extensionlength) == extension)
+                {
+                    // We've found a helper file
+                    const std::string& library = filename.substr(0, filename.size() - extensionlength);
+                    paths.push_back(directory.BF_GENERIC_STRING() + '/' + library);
+                }
+            }
+            ++file;
+        }
+
+        return paths;
+    }
+
+    /*static*/ std::string ApplicationPaths::getRootPathString()
+    {
+        return getInstance().rootPath_.BF_GENERIC_STRING() + '/';
+    }
+
+    /*static*/ std::string ApplicationPaths::getExecutablePathString()
+    {
+        return getInstance().executablePath_.BF_GENERIC_STRING() + '/';
+    }
+
+    /*static*/ std::string ApplicationPaths::getModulePathString()
+    {
+        return getInstance().modulePath_.BF_GENERIC_STRING() + '/';
+    }
+
+    /*static*/ std::string ApplicationPaths::getPluginPathString()
+    {
+        return getInstance().pluginPath_.BF_GENERIC_STRING() + '/';
+    }
+}
Index: code/trunk/src/libraries/core/ApplicationPaths.h
===================================================================
--- code/trunk/src/libraries/core/ApplicationPaths.h	(revision 10624)
+++ code/trunk/src/libraries/core/ApplicationPaths.h	(revision 10624)
@@ -0,0 +1,121 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @ingroup Management Resources
+*/
+
+#ifndef _ApplicationPaths_H__
+#define _ApplicationPaths_H__
+
+#include "CorePrereqs.h"
+
+#include <string>
+#include <vector>
+#include "util/Singleton.h"
+
+//tolua_begin
+namespace orxonox
+{
+//tolua_end
+    /**
+    @brief
+        The ApplicationPaths class is a singleton which provides static paths of the application.
+    @details
+        The class provides information about the executable, root and module/plugin path.
+        It determines those by the use of platform specific functions.
+    @remarks
+        Not all paths are always available:
+        - root only when installed copyable
+    */
+    class _CoreExport ApplicationPaths //tolua_export
+        : public Singleton<ApplicationPaths>
+    { //tolua_export
+        friend class Singleton<ApplicationPaths>;
+
+        public:
+            /**
+            @brief
+                Retrieves the executable path and sets all hard coded fixed paths (currently only the module and the plugin paths)
+                Also checks for "orxonox_dev_build.keep_me" in the executable directory.
+                If found it means that this is not an installed run, hence we
+                don't write the logs and config files to ~/.orxonox
+            @throw
+                GeneralException
+            */
+            ApplicationPaths();
+            ~ApplicationPaths();
+
+            //! Returns the path to the root folder as boost::filesystem::path
+            static const boost::filesystem::path& getRootPath()
+                { return getInstance().rootPath_; }
+            //! Returns the path to the executable folder as boost::filesystem::path
+            static const boost::filesystem::path& getExecutablePath()
+                { return getInstance().executablePath_; }
+            //! Returns the path to the modules as boost::filesystem::path
+            static const boost::filesystem::path& getModulePath()
+                { return getInstance().modulePath_; }
+            //! Returns the path to the plugins as boost::filesystem::path
+            static const boost::filesystem::path& getPluginPath()
+                { return getInstance().pluginPath_; }
+
+            //! Returns the path to the root folder as std::string
+            static std::string getRootPathString();
+            //! Returns the path to the executable folder as std::string
+            static std::string getExecutablePathString();
+            //! Returns the path to the modules as std::string
+            static std::string getModulePathString();
+            //! Returns the path to the plugins as std::string
+            static std::string getPluginPathString();
+
+            //! Return true for runs in the build directory (not installed)
+            static bool buildDirectoryRun() { return getInstance().bBuildDirectoryRun_; }
+
+            //! Returns a list with all modules declared by a *.module file in the module folder.
+            std::vector<std::string> getModulePaths();
+            //! Returns a list with all plugins declared by a *.plugin file in the plugin folder.
+            std::vector<std::string> getPluginPaths();
+
+        private:
+            ApplicationPaths(const ApplicationPaths&); //!< Don't use (undefined symbol)
+
+            std::vector<std::string> getModuleOrPluginPaths(boost::filesystem::path& directory, const std::string& extension);
+
+            //! Path to the parent directory of the ones above if program was installed with relative paths
+            boost::filesystem::path& rootPath_;
+            boost::filesystem::path& executablePath_;        //!< Path to the executable
+            boost::filesystem::path& modulePath_;            //!< Path to the modules
+            boost::filesystem::path& pluginPath_;            //!< Path to the plugins
+
+            bool                     bBuildDirectoryRun_;    //!< True for runs in the build directory (not installed)
+            static ApplicationPaths* singletonPtr_s;
+    }; //tolua_export
+} //tolua_export
+
+#endif /* _ApplicationPaths_H__ */
Index: code/trunk/src/libraries/core/BaseObject.cc
===================================================================
--- code/trunk/src/libraries/core/BaseObject.cc	(revision 10622)
+++ code/trunk/src/libraries/core/BaseObject.cc	(revision 10624)
@@ -63,5 +63,4 @@
         this->bActive_ = true;
         this->bVisible_ = true;
-        this->oldGametype_ = 0;
         this->bRegisteredEventStates_ = false;
 
@@ -78,17 +77,15 @@
         {
             this->setFile(this->creator_->getFile());
-            this->setNamespace(this->creator_->getNamespace());
-            this->setScene(this->creator_->getScene(), this->creator_->getSceneID());
-            this->setGametype(this->creator_->getGametype());
-            this->setLevel(this->creator_->getLevel());
+
+            // store strong-pointers on all four base objects by default (can be overwritten with weak-ptr after the constructor if necessary)
+            this->setNamespace(this->creator_->namespace_.createStrongPtr());
+            this->setScene    (this->creator_->scene_    .createStrongPtr(), this->creator_->sceneID_);
+            this->setGametype (this->creator_->gametype_ .createStrongPtr());
+            this->setLevel    (this->creator_->level_    .createStrongPtr());
         }
         else
         {
             this->file_ = 0;
-            this->namespace_ = 0;
-            this->scene_ = 0;
             this->sceneID_ = OBJECTID_UNKNOWN;
-            this->gametype_ = 0;
-            this->level_ = 0;
         }
     }
Index: code/trunk/src/libraries/core/BaseObject.h
===================================================================
--- code/trunk/src/libraries/core/BaseObject.h	(revision 10622)
+++ code/trunk/src/libraries/core/BaseObject.h	(revision 10624)
@@ -51,5 +51,5 @@
 #include "class/OrxonoxClass.h"
 #include "class/Super.h"
-#include "object/SmartPtr.h"
+#include "object/StrongPtr.h"
 
 namespace orxonox
@@ -63,4 +63,21 @@
     {
         template <class T> friend class XMLPortClassParamContainer;
+
+        public:
+            template <class T>
+            class StrongOrWeakPtr
+            {
+                public:
+                    inline StrongOrWeakPtr();
+                    inline StrongOrWeakPtr(const StrongPtr<T>& ptr);
+                    inline StrongOrWeakPtr(const WeakPtr<T>& ptr);
+
+                    inline T* get() const;
+                    inline StrongPtr<T> createStrongPtr() const;
+
+                private:
+                    StrongPtr<T> strongPtr_;
+                    WeakPtr<T> weakPtr_;
+            };
 
         public:
@@ -138,37 +155,19 @@
                 { return this->templates_; }
 
-            inline void setNamespace(const SmartPtr<Namespace>& ns) { this->namespace_ = ns; }
-            inline const SmartPtr<Namespace>& getNamespace() const { return this->namespace_; }
+            inline void setNamespace(const StrongOrWeakPtr<Namespace>& ns) { this->namespace_ = ns; }
+            inline Namespace* getNamespace() const { return this->namespace_.get(); }
 
             inline void setCreator(BaseObject* creator) { this->creator_ = creator; }
             inline BaseObject* getCreator() const { return this->creator_; }
 
-            inline void setScene(const SmartPtr<Scene>& scene, uint32_t sceneID) { this->scene_ = scene; this->sceneID_=sceneID; }
-            inline const SmartPtr<Scene>& getScene() const { return this->scene_; }
+            inline void setScene(const StrongOrWeakPtr<Scene>& scene, uint32_t sceneID) { this->scene_ = scene; this->sceneID_=sceneID; }
+            inline Scene* getScene() const { return this->scene_.get(); }
             inline virtual uint32_t getSceneID() const { return this->sceneID_; }
 
-            inline void setGametype(const SmartPtr<Gametype>& gametype)
-            {
-                if (gametype != this->gametype_)
-                {
-                    this->oldGametype_ = this->gametype_;
-                    this->gametype_ = gametype;
-                    this->changedGametype();
-                }
-            }
-            inline const SmartPtr<Gametype>& getGametype() const { return this->gametype_; }
-            inline Gametype* getOldGametype() const { return this->oldGametype_; }
-            virtual void changedGametype() {}
-
-            inline void setLevel(const SmartPtr<Level>& level)
-            {
-                if (level != this->level_)
-                {
-                    this->level_ = level;
-                    this->changedLevel();
-                }
-            }
-            inline const SmartPtr<Level>& getLevel() const { return this->level_; }
-            virtual void changedLevel() {}
+            inline void setGametype(const StrongOrWeakPtr<Gametype>& gametype) { this->gametype_ = gametype; }
+            inline Gametype* getGametype() const { return this->gametype_.get(); }
+
+            inline void setLevel(const StrongOrWeakPtr<Level>& level) { this->level_ = level; }
+            inline Level* getLevel() const { return this->level_.get(); }
 
             void addEventSource(BaseObject* source, const std::string& state);
@@ -217,17 +216,16 @@
             void registerEventStates();
 
-            bool                   bInitialized_;              //!< True if the object was initialized (passed the object registration)
-            const XMLFile*         file_;                      //!< The XMLFile that loaded this object
-            Element*               lastLoadedXMLElement_;      //!< Non 0 if the TinyXML attributes have already been copied to our own lowercase map
+            bool                       bInitialized_;          //!< True if the object was initialized (passed the object registration)
+            const XMLFile*             file_;                  //!< The XMLFile that loaded this object
+            Element*                   lastLoadedXMLElement_;  //!< Non 0 if the TinyXML attributes have already been copied to our own lowercase map
             std::map<std::string, std::string> xmlAttributes_; //!< Lowercase XML attributes
-            std::string            loaderIndentation_;         //!< Indentation of the debug output in the Loader
-            SmartPtr<Namespace>    namespace_;
-            BaseObject*            creator_;
-            SmartPtr<Scene>        scene_;
-            uint32_t               sceneID_;
-            SmartPtr<Gametype>     gametype_;
-            Gametype*              oldGametype_;
-            SmartPtr<Level>        level_;
-            std::set<Template*>    templates_;
+            std::string                loaderIndentation_;     //!< Indentation of the debug output in the Loader
+            StrongOrWeakPtr<Namespace> namespace_;
+            BaseObject*                creator_;
+            StrongOrWeakPtr<Scene>     scene_;
+            uint32_t                   sceneID_;
+            StrongOrWeakPtr<Gametype>  gametype_;
+            StrongOrWeakPtr<Level>     level_;
+            std::set<Template*>        templates_;
 
             std::map<BaseObject*, std::string>  eventSources_;           //!< List of objects which send events to this object, mapped to the state which they affect
@@ -243,5 +241,39 @@
     SUPER_FUNCTION(4, BaseObject, XMLEventPort, false);
     SUPER_FUNCTION(8, BaseObject, changedName, false);
-    SUPER_FUNCTION(9, BaseObject, changedGametype, false);
+
+    template <class T>
+    BaseObject::StrongOrWeakPtr<T>::StrongOrWeakPtr()
+    {
+    }
+
+    template <class T>
+    BaseObject::StrongOrWeakPtr<T>::StrongOrWeakPtr(const StrongPtr<T>& ptr) : strongPtr_(ptr)
+    {
+    }
+
+    template <class T>
+    BaseObject::StrongOrWeakPtr<T>::StrongOrWeakPtr(const WeakPtr<T>& ptr) : weakPtr_(ptr)
+    {
+    }
+
+    template <class T>
+    T* BaseObject::StrongOrWeakPtr<T>::get() const
+    {
+        if (this->strongPtr_)
+            return this->strongPtr_;
+        else if (this->weakPtr_)
+            return this->weakPtr_;
+        else
+            return NULL;
+    }
+
+    template <class T>
+    StrongPtr<T> BaseObject::StrongOrWeakPtr<T>::createStrongPtr() const
+    {
+        if (this->strongPtr_)
+            return this->strongPtr_; // creates a copy
+        else
+            return this->weakPtr_; // converts automatically to StrongPtr
+    }
 }
 
Index: code/trunk/src/libraries/core/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/core/CMakeLists.txt	(revision 10622)
+++ code/trunk/src/libraries/core/CMakeLists.txt	(revision 10624)
@@ -22,8 +22,7 @@
 #BUILD_UNIT CoreStableBuildUnit.cc
   ClassTreeMask.cc
-  DynLib.cc
-  DynLibManager.cc
   Event.cc
   Game.cc
+  GameConfig.cc
   GameMode.cc
   GameState.cc
@@ -34,4 +33,5 @@
   NamespaceNode.cc
   Template.cc
+  UpdateListener.cc
   ViewportEventListener.cc
   WindowEventListener.cc
@@ -42,4 +42,6 @@
   BaseObject.cc
   Core.cc
+  CoreConfig.cc
+  CoreStaticInitializationHandler.cc
 
 BUILD_UNIT OgreBuildUnit.cc
@@ -52,5 +54,6 @@
   command/ArgumentCompletionFunctions.cc
   config/ConfigFile.cc
-  PathConfig.cc
+  ApplicationPaths.cc
+  ConfigurablePaths.cc
 END_BUILD_UNIT
 
@@ -64,7 +67,10 @@
 ADD_SUBDIRECTORY(class)
 ADD_SUBDIRECTORY(command)
+ADD_SUBDIRECTORY(commandline)
 ADD_SUBDIRECTORY(config)
 ADD_SUBDIRECTORY(input)
+ADD_SUBDIRECTORY(module)
 ADD_SUBDIRECTORY(object)
+ADD_SUBDIRECTORY(singleton)
 
 #Add the icon (for the renderwindow)
@@ -78,4 +84,6 @@
     command/CommandExecutor.h
     config/SettingsConfigFile.h
+    ApplicationPaths.h
+    ConfigurablePaths.h
     Game.h
     GameMode.h
@@ -84,5 +92,4 @@
     Loader.h
     LuaState.h
-    PathConfig.h
     input/InputManager.h
     input/KeyBinder.h
Index: code/trunk/src/libraries/core/ClassTreeMask.cc
===================================================================
--- code/trunk/src/libraries/core/ClassTreeMask.cc	(revision 10622)
+++ code/trunk/src/libraries/core/ClassTreeMask.cc	(revision 10624)
@@ -293,5 +293,5 @@
         {
             // No it's not: Search for classes inheriting from the given class and add the rules for them
-            for (std::set<const Identifier*>::const_iterator it = subclass->getDirectChildrenBegin(); it != subclass->getDirectChildrenEnd(); ++it)
+            for (std::set<const Identifier*>::const_iterator it = subclass->getDirectChildren().begin(); it != subclass->getDirectChildren().end(); ++it)
                 if ((*it)->isA(this->root_->getClass()))
                     if (overwrite || (!this->nodeExists(*it))) // If we don't want to overwrite, only add nodes that don't already exist
@@ -392,5 +392,5 @@
         if (!subclass)
             return;
-        for (std::set<const Identifier*>::const_iterator it = subclass->getDirectChildrenBegin(); it != subclass->getDirectChildrenEnd(); ++it)
+        for (std::set<const Identifier*>::const_iterator it = subclass->getDirectChildren().begin(); it != subclass->getDirectChildren().end(); ++it)
             this->add(*it, this->isIncluded(*it), false, false);
 
@@ -943,5 +943,5 @@
 
                                 // Insert all directChildren of the directChild
-                                directChildren.insert((*it2)->getDirectChildrenBegin(), (*it2)->getDirectChildrenEnd());
+                                directChildren.insert((*it2)->getDirectChildren().begin(), (*it2)->getDirectChildren().end());
 
                                 // Restart the scan with the expanded set of directChildren
Index: code/trunk/src/libraries/core/ConfigurablePaths.cc
===================================================================
--- code/trunk/src/libraries/core/ConfigurablePaths.cc	(revision 10624)
+++ code/trunk/src/libraries/core/ConfigurablePaths.cc	(revision 10624)
@@ -0,0 +1,183 @@
+/*
+ *   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 "ConfigurablePaths.h"
+
+#include <cassert>
+#include <cstdlib>
+#include <cstdio>
+#include <vector>
+#include <boost/filesystem.hpp>
+
+#ifdef ORXONOX_PLATFORM_WINDOWS
+#  ifndef WIN32_LEAN_AND_MEAN
+#    define WIN32_LEAN_AND_MEAN
+#  endif
+#  include <windows.h>
+#  undef min
+#  undef max
+#elif defined(ORXONOX_PLATFORM_APPLE)
+#  include <sys/param.h>
+#  include <mach-o/dyld.h>
+#else /* Linux */
+#  include <sys/types.h>
+#  include <unistd.h>
+#endif
+
+#include "SpecialConfig.h"
+#include "util/Output.h"
+#include "util/Exception.h"
+#include "commandline/CommandLineIncludes.h"
+
+// Differentiate Boost Filesystem v2 and v3
+#if (BOOST_FILESYSTEM_VERSION < 3)
+#  define BF_GENERIC_STRING string
+#else
+#  define BF_GENERIC_STRING generic_string
+#endif
+
+namespace orxonox
+{
+    namespace bf = boost::filesystem;
+
+    //! Static pointer to the singleton
+    ConfigurablePaths* ConfigurablePaths::singletonPtr_s  = 0;
+
+    SetCommandLineArgument(externalDataPath, "").information("Path to the external data files");
+    SetCommandLineArgument(writingPathSuffix, "").information("Additional subfolder for config and log files");
+
+    ConfigurablePaths::ConfigurablePaths()
+        : dataPath_(*(new bf::path()))
+        , externalDataPath_(*(new bf::path()))
+        , configPath_(*(new bf::path()))
+        , logPath_(*(new bf::path()))
+    {
+    }
+
+    ConfigurablePaths::~ConfigurablePaths()
+    {
+        delete &dataPath_;
+        delete &externalDataPath_;
+        delete &configPath_;
+        delete &logPath_;
+    }
+
+    void ConfigurablePaths::setConfigurablePaths(const ApplicationPaths& applicationPaths)
+    {
+        if (applicationPaths.buildDirectoryRun())
+        {
+            dataPath_         = specialConfig::dataDevDirectory;
+            configPath_       = specialConfig::configDevDirectory;
+            logPath_          = specialConfig::logDevDirectory;
+
+            // Check for data path override by the command line
+            if (!CommandLineParser::getArgument("externalDataPath")->hasDefaultValue())
+                externalDataPath_ = CommandLineParser::getValue("externalDataPath").get<std::string>();
+            else
+                externalDataPath_ = specialConfig::externalDataDevDirectory;
+        }
+        else
+        {
+
+#ifdef INSTALL_COPYABLE // --> relative paths
+
+            // Using paths relative to the install prefix, complete them
+            dataPath_   = applicationPaths.getRootPath() / specialConfig::defaultDataPath;
+            configPath_ = applicationPaths.getRootPath() / specialConfig::defaultConfigPath;
+            logPath_    = applicationPaths.getRootPath() / specialConfig::defaultLogPath;
+
+#else
+
+            dataPath_  = specialConfig::dataInstallDirectory;
+
+            // Get user directory
+#ifdef ORXONOX_PLATFORM_UNIX
+            char* userDataPathPtr(getenv("HOME"));
+#else
+            char* userDataPathPtr(getenv("APPDATA"));
+#endif
+            if (userDataPathPtr == NULL)
+                ThrowException(General, "Could not retrieve user data path.");
+            bf::path userDataPath(userDataPathPtr);
+            userDataPath /= ".orxonox";
+
+            configPath_ = userDataPath / specialConfig::defaultConfigPath;
+            logPath_    = userDataPath / specialConfig::defaultLogPath;
+
+#endif
+
+        }
+
+        // Option to put all the config and log files in a separate folder
+        if (!CommandLineParser::getArgument("writingPathSuffix")->hasDefaultValue())
+        {
+            const std::string& directory(CommandLineParser::getValue("writingPathSuffix").get<std::string>());
+            configPath_ = configPath_ / directory;
+            logPath_    = logPath_    / directory;
+        }
+
+        // Create directories to avoid problems when opening files in non existent folders.
+        std::vector<std::pair<bf::path, std::string> > directories;
+        directories.push_back(std::make_pair(bf::path(configPath_), std::string("config")));
+        directories.push_back(std::make_pair(bf::path(logPath_), std::string("log")));
+
+        for (std::vector<std::pair<bf::path, std::string> >::iterator it = directories.begin();
+            it != directories.end(); ++it)
+        {
+            if (bf::exists(it->first) && !bf::is_directory(it->first))
+            {
+                ThrowException(General, std::string("The ") + it->second + " directory has been preoccupied by a file! \
+                                         Please remove " + it->first.BF_GENERIC_STRING());
+            }
+            if (bf::create_directories(it->first)) // function may not return true at all (bug?)
+            {
+                orxout(internal_info) << "Created " << it->second << " directory" << endl;
+            }
+        }
+    }
+
+    /*static*/ std::string ConfigurablePaths::getDataPathString()
+    {
+        return getInstance().dataPath_.BF_GENERIC_STRING() + '/';
+    }
+
+    /*static*/ std::string ConfigurablePaths::getExternalDataPathString()
+    {
+        return getInstance().externalDataPath_.BF_GENERIC_STRING() + '/';
+    }
+
+    /*static*/ std::string ConfigurablePaths::getConfigPathString()
+    {
+        return getInstance().configPath_.BF_GENERIC_STRING() + '/';
+    }
+
+    /*static*/ std::string ConfigurablePaths::getLogPathString()
+    {
+        return getInstance().logPath_.BF_GENERIC_STRING() + '/';
+    }
+}
Index: code/trunk/src/libraries/core/ConfigurablePaths.h
===================================================================
--- code/trunk/src/libraries/core/ConfigurablePaths.h	(revision 10624)
+++ code/trunk/src/libraries/core/ConfigurablePaths.h	(revision 10624)
@@ -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
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @ingroup Management Resources
+*/
+
+#ifndef _ConfigurablePaths_H__
+#define _ConfigurablePaths_H__
+
+#include "CorePrereqs.h"
+
+#include <string>
+#include "util/Singleton.h"
+
+//tolua_begin
+namespace orxonox
+{
+//tolua_end
+    /**
+    @brief
+        The ConfigurablePaths class is a singleton used to configure different paths.
+    @details
+        The class provides information about the data, config, and log path.
+    @remarks
+        Not all paths are always available:
+        - externalData only for development builds in the build tree
+    */
+    class _CoreExport ConfigurablePaths //tolua_export
+        : public Singleton<ConfigurablePaths>
+    { //tolua_export
+        friend class Singleton<ConfigurablePaths>;
+
+        public:
+            ConfigurablePaths();
+            ~ConfigurablePaths();
+
+            //! Returns the path to the data files as boost::filesystem::path
+            static const boost::filesystem::path& getDataPath()
+                { return getInstance().dataPath_; }
+            //! Returns the path to the external data files as boost::filesystem::path
+            static const boost::filesystem::path& getExternalDataPath()
+                { return getInstance().externalDataPath_; }
+            //! Returns the path to the config files as boost::filesystem::path
+            static const boost::filesystem::path& getConfigPath()
+                { return getInstance().configPath_; }
+            //! Returns the path to the log files as boost::filesystem::path
+            static const boost::filesystem::path& getLogPath()
+                { return getInstance().logPath_; }
+
+            //! Returns the path to the data files as std::string
+            static std::string getDataPathString();
+            //! Returns the path to the external data files as std::string
+            static std::string getExternalDataPathString();
+            //! Returns the path to the config files as std::string
+            static std::string getConfigPathString(); //tolua_export
+            //! Returns the path to the log files as std::string
+            static std::string getLogPathString();
+
+            /**
+            @brief
+                Sets config, log and media path and creates the folders if necessary.
+            @throws
+                GeneralException
+            */
+            void setConfigurablePaths(const ApplicationPaths& applicationPaths);
+
+        private:
+            ConfigurablePaths(const ConfigurablePaths&); //!< Don't use (undefined symbol)
+
+            boost::filesystem::path& dataPath_;              //!< Path to the data files folder
+            boost::filesystem::path& externalDataPath_;      //!< Path to the external data files folder
+            boost::filesystem::path& configPath_;            //!< Path to the config files folder
+            boost::filesystem::path& logPath_;               //!< Path to the log files folder
+
+            static ConfigurablePaths* singletonPtr_s;
+    }; //tolua_export
+} //tolua_export
+
+#endif /* _ConfigurablePaths_H__ */
Index: code/trunk/src/libraries/core/Core.cc
===================================================================
--- code/trunk/src/libraries/core/Core.cc	(revision 10622)
+++ code/trunk/src/libraries/core/Core.cc	(revision 10624)
@@ -54,22 +54,18 @@
 #include "util/Output.h"
 #include "util/Exception.h"
+#include "util/SignalHandler.h"
 #include "util/output/LogWriter.h"
 #include "util/output/OutputManager.h"
-#include "util/Scope.h"
-#include "util/ScopedSingletonManager.h"
-#include "util/SignalHandler.h"
-#include "PathConfig.h"
-#include "config/CommandLineParser.h"
+#include "core/singleton/Scope.h"
+#include "ApplicationPaths.h"
+#include "ConfigurablePaths.h"
+#include "commandline/CommandLineIncludes.h"
 #include "config/ConfigFileManager.h"
-#include "config/ConfigValueIncludes.h"
-#include "CoreIncludes.h"
-#include "DynLibManager.h"
 #include "GameMode.h"
 #include "GraphicsManager.h"
 #include "GUIManager.h"
-#include "class/Identifier.h"
 #include "Language.h"
+#include "Loader.h"
 #include "LuaState.h"
-#include "command/ConsoleCommand.h"
 #include "command/IOConsole.h"
 #include "command/TclBind.h"
@@ -77,4 +73,10 @@
 #include "input/InputManager.h"
 #include "object/ObjectList.h"
+#include "module/DynLibManager.h"
+#include "module/ModuleInstance.h"
+#include "module/StaticInitializationManager.h"
+#include "module/PluginManager.h"
+#include "CoreStaticInitializationHandler.h"
+#include "UpdateListener.h"
 
 namespace orxonox
@@ -92,13 +94,12 @@
 #endif
 
-    // register Core as an abstract class to avoid problems if the class hierarchy is created within Core-constructor
-    RegisterAbstractClass(Core).inheritsFrom(Class(Configurable));
-
     Core::Core(const std::string& cmdLine)
-        : pathConfig_(NULL)
+        : applicationPaths_(NULL)
+        , configurablePaths_(NULL)
         , dynLibManager_(NULL)
         , signalHandler_(NULL)
         , configFileManager_(NULL)
         , languageInstance_(NULL)
+        , loaderInstance_(NULL)
         , ioConsole_(NULL)
         , tclBind_(NULL)
@@ -110,8 +111,8 @@
         , graphicsScope_(NULL)
         , bGraphicsLoaded_(false)
-        , bStartIOConsole_(true)
-        , lastLevelTimestamp_(0)
-        , ogreConfigTimestamp_(0)
-        , bDevMode_(false)
+        , staticInitHandler_(NULL)
+        , pluginManager_(NULL)
+        , rootModule_(NULL)
+        , config_(NULL)
         , destructionHelper_(this)
     {
@@ -119,23 +120,17 @@
 
         // Set the hard coded fixed paths
-        this->pathConfig_ = new PathConfig();
+        this->applicationPaths_ = new ApplicationPaths();
 
         // Create a new dynamic library manager
         this->dynLibManager_ = new DynLibManager();
 
-        // Load modules
-        orxout(internal_info) << "Loading modules:" << endl;
-        const std::vector<std::string>& modulePaths = this->pathConfig_->getModulePaths();
-        for (std::vector<std::string>::const_iterator it = modulePaths.begin(); it != modulePaths.end(); ++it)
-        {
-            try
-            {
-                this->dynLibManager_->load(*it);
-            }
-            catch (...)
-            {
-                orxout(user_error) << "Couldn't load module \"" << *it << "\": " << Exception::handleMessage() << endl;
-            }
-        }
+        // create handler for static initialization
+        new StaticInitializationManager(); // create singleton
+        this->staticInitHandler_ = new CoreStaticInitializationHandler();
+        StaticInitializationManager::getInstance().addHandler(this->staticInitHandler_);
+
+        // load root module (all libraries which are linked to the executable, including core, network, and orxonox)
+        this->rootModule_ = ModuleInstance::getCurrentModuleInstance();
+        StaticInitializationManager::getInstance().loadModule(this->rootModule_);
 
         // Parse command line arguments AFTER the modules have been loaded (static code!)
@@ -143,18 +138,21 @@
 
         // Set configurable paths like log, config and media
-        this->pathConfig_->setConfigurablePaths();
-
-        orxout(internal_info) << "Root path:       " << PathConfig::getRootPathString() << endl;
-        orxout(internal_info) << "Executable path: " << PathConfig::getExecutablePathString() << endl;
-        orxout(internal_info) << "Data path:       " << PathConfig::getDataPathString() << endl;
-        orxout(internal_info) << "Ext. data path:  " << PathConfig::getExternalDataPathString() << endl;
-        orxout(internal_info) << "Config path:     " << PathConfig::getConfigPathString() << endl;
-        orxout(internal_info) << "Log path:        " << PathConfig::getLogPathString() << endl;
-        orxout(internal_info) << "Modules path:    " << PathConfig::getModulePathString() << endl;
-
-        // create a signal handler (only active for Linux)
+        this->configurablePaths_ = new ConfigurablePaths();
+        this->configurablePaths_->setConfigurablePaths(ApplicationPaths::getInstance());
+
+        orxout(internal_info) << "Root path:       " << ApplicationPaths::getRootPathString() << endl;
+        orxout(internal_info) << "Executable path: " << ApplicationPaths::getExecutablePathString() << endl;
+        orxout(internal_info) << "Modules path:    " << ApplicationPaths::getModulePathString() << endl;
+        orxout(internal_info) << "Plugins path:    " << ApplicationPaths::getPluginPathString() << endl;
+
+        orxout(internal_info) << "Data path:       " << ConfigurablePaths::getDataPathString() << endl;
+        orxout(internal_info) << "Ext. data path:  " << ConfigurablePaths::getExternalDataPathString() << endl;
+        orxout(internal_info) << "Config path:     " << ConfigurablePaths::getConfigPathString() << endl;
+        orxout(internal_info) << "Log path:        " << ConfigurablePaths::getLogPathString() << endl;
+
+        // create a signal handler
         // This call is placed as soon as possible, but after the directories are set
         this->signalHandler_ = new SignalHandler();
-        this->signalHandler_->doCatch(PathConfig::getExecutablePathString(), PathConfig::getLogPathString() + "orxonox_crash.log");
+        this->signalHandler_->doCatch(ApplicationPaths::getExecutablePathString(), ConfigurablePaths::getLogPathString() + "orxonox_crash.log");
 
 #ifdef ORXONOX_PLATFORM_WINDOWS
@@ -177,20 +175,18 @@
         this->languageInstance_ = new Language();
 
+        // initialize root context
+        Context::setRootContext(new Context(NULL));
+
         // Do this soon after the ConfigFileManager has been created to open up the
         // possibility to configure everything below here
-        RegisterObject(Core);
         orxout(internal_info) << "configuring Core" << endl;
-        this->setConfigValues();
+        this->config_ = new CoreConfig();
 
         // Set the correct log path and rewrite the log file with the correct log levels
-        OutputManager::getInstance().getLogWriter()->setLogDirectory(PathConfig::getLogPathString());
+        OutputManager::getInstance().getLogWriter()->setLogDirectory(ConfigurablePaths::getLogPathString());
 
 #if !defined(ORXONOX_PLATFORM_APPLE) && !defined(ORXONOX_USE_WINMAIN)
         // Create persistent IO console
-        if (CommandLineParser::getValue("noIOConsole").get<bool>())
-        {
-            ModifyConfigValue(bStartIOConsole_, tset, false);
-        }
-        if (this->bStartIOConsole_)
+        if (CommandLineParser::getValue("noIOConsole").get<bool>() == false && this->config_->getStartIOConsole())
         {
             orxout(internal_info) << "creating IO console" << endl;
@@ -201,5 +197,13 @@
         // creates the class hierarchy for all classes with factories
         orxout(internal_info) << "creating class hierarchy" << endl;
-        IdentifierManager::getInstance().createClassHierarchy();
+        this->staticInitHandler_->initInstances(this->rootModule_);
+        this->staticInitHandler_->setInitInstances(true);
+
+        // Create plugin manager and search for plugins
+        this->pluginManager_ = new PluginManager();
+        this->pluginManager_->findPlugins();
+
+        // Loader
+        this->loaderInstance_ = new Loader();
 
         // Load OGRE excluding the renderer and the render window
@@ -208,10 +212,10 @@
 
         // initialise Tcl
-        this->tclBind_ = new TclBind(PathConfig::getDataPathString());
+        this->tclBind_ = new TclBind(ConfigurablePaths::getDataPathString());
         this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter());
 
         // Create singletons that always exist (in other libraries)
         orxout(internal_info) << "creating root scope:" << endl;
-        this->rootScope_ = new Scope<ScopeID::Root>();
+        this->rootScope_ = new Scope<ScopeID::ROOT>();
 
         // Generate documentation instead of normal run?
@@ -237,7 +241,4 @@
         orxout(internal_status) << "destroying Core object..." << endl;
 
-        // Remove us from the object lists again to avoid problems when destroying them
-        this->unregisterObject();
-
         safeObjectDelete(&graphicsScope_);
         safeObjectDelete(&guiManager_);
@@ -248,93 +249,82 @@
         safeObjectDelete(&tclBind_);
         safeObjectDelete(&ioConsole_);
+        safeObjectDelete(&loaderInstance_);
+        safeObjectDelete(&config_);
         safeObjectDelete(&languageInstance_);
         safeObjectDelete(&configFileManager_);
-        ConsoleCommand::destroyAll();
-        Context::setRootContext(NULL);
-        IdentifierManager::getInstance().destroyAllIdentifiers();
         safeObjectDelete(&signalHandler_);
+        safeObjectDelete(&pluginManager_);
+        Context::getRootContext()->unregisterObject(); // unregister context from object lists - otherwise the root context would be destroyed while unloading the root module
+        if (this->rootModule_)
+        {
+            StaticInitializationManager::getInstance().unloadModule(this->rootModule_);
+            this->rootModule_->deleteAllStaticallyInitializedInstances();
+        }
+        if (this->staticInitHandler_)
+            StaticInitializationManager::getInstance().removeHandler(this->staticInitHandler_);
+        Context::destroyRootContext();
+        safeObjectDelete(&rootModule_);
+        safeObjectDelete(&staticInitHandler_);
+        delete &StaticInitializationManager::getInstance();
         safeObjectDelete(&dynLibManager_);
-        safeObjectDelete(&pathConfig_);
+        safeObjectDelete(&configurablePaths_);
+        safeObjectDelete(&applicationPaths_);
 
         orxout(internal_status) << "finished destroying Core object" << endl;
     }
 
-    //! Function to collect the SetConfigValue-macro calls.
-    void Core::setConfigValues()
-    {
-        SetConfigValueExternal(OutputManager::getInstance().getLogWriter()->configurableMaxLevel_,
-                               OutputManager::getInstance().getLogWriter()->getConfigurableSectionName(),
-                               OutputManager::getInstance().getLogWriter()->getConfigurableMaxLevelName(),
-                               OutputManager::getInstance().getLogWriter()->configurableMaxLevel_)
-            .description("The maximum level of output shown in the log file")
-            .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableLevel);
-        SetConfigValueExternal(OutputManager::getInstance().getLogWriter()->configurableAdditionalContextsMaxLevel_,
-                               OutputManager::getInstance().getLogWriter()->getConfigurableSectionName(),
-                               OutputManager::getInstance().getLogWriter()->getConfigurableAdditionalContextsMaxLevelName(),
-                               OutputManager::getInstance().getLogWriter()->configurableAdditionalContextsMaxLevel_)
-            .description("The maximum level of output shown in the log file for additional contexts")
-            .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableAdditionalContextsLevel);
-        SetConfigValueExternal(OutputManager::getInstance().getLogWriter()->configurableAdditionalContexts_,
-                               OutputManager::getInstance().getLogWriter()->getConfigurableSectionName(),
-                               OutputManager::getInstance().getLogWriter()->getConfigurableAdditionalContextsName(),
-                               OutputManager::getInstance().getLogWriter()->configurableAdditionalContexts_)
-            .description("Additional output contexts shown in the log file")
-            .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableAdditionalContexts);
-
-        SetConfigValue(bDevMode_, PathConfig::buildDirectoryRun())
-            .description("Developer mode. If not set, hides some things from the user to not confuse him.")
-            .callback(this, &Core::devModeChanged);
-        SetConfigValue(language_, Language::getInstance().defaultLanguage_)
-            .description("The language of the in game text")
-            .callback(this, &Core::languageChanged);
-        SetConfigValue(bInitRandomNumberGenerator_, true)
-            .description("If true, all random actions are different each time you start the game")
-            .callback(this, &Core::initRandomNumberGenerator);
-        SetConfigValue(bStartIOConsole_, true)
-            .description("Set to false if you don't want to use the IOConsole (for Lua debugging for instance)");
-        SetConfigValue(lastLevelTimestamp_, 0)
-            .description("Timestamp when the last level was started.");
-        SetConfigValue(ogreConfigTimestamp_, 0)
-            .description("Timestamp when the ogre config file was changed.");
-    }
-
-    /** Callback function for changes in the dev mode that affect debug levels.
-        The function behaves according to these rules:
-        - 'normal' mode is defined based on where the program was launched: if
-          the launch path was the build directory, development mode \c on is
-          normal, otherwise normal means development mode \c off.
-        - Debug levels should not be hard configured (\c config instead of
-          \c tconfig) in non 'normal' mode to avoid strange behaviour.
-        - Changing the development mode from 'normal' to the other state will
-          immediately change the debug levels to predefined values which can be
-          reconfigured with \c tconfig.
-    @note
-        The debug levels for the IOConsole and the InGameConsole can be found
-        in the Shell class. The same rules apply.
-    */
-    void Core::devModeChanged()
-    {
-        // Inform listeners
-        ObjectList<DevModeListener>::iterator it = ObjectList<DevModeListener>::begin();
-        for (; it != ObjectList<DevModeListener>::end(); ++it)
-            it->devModeChanged(bDevMode_);
-    }
-
-    //! Callback function if the language has changed.
-    void Core::languageChanged()
-    {
-        // Read the translation file after the language was configured
-        Language::getInstance().readTranslatedLanguageFile();
-    }
-
-    void Core::initRandomNumberGenerator()
-    {
-        static bool bInitialized = false;
-        if (!bInitialized && this->bInitRandomNumberGenerator_)
-        {
-            srand(static_cast<unsigned int>(time(0)));
-            rand();
-            bInitialized = true;
-        }
+    void Core::loadModules()
+    {
+        orxout(internal_info) << "Loading modules:" << endl;
+
+        const std::vector<std::string>& modulePaths = ApplicationPaths::getInstance().getModulePaths();
+        for (std::vector<std::string>::const_iterator it = modulePaths.begin(); it != modulePaths.end(); ++it)
+        {
+            ModuleInstance* module = new ModuleInstance(*it);
+            this->loadModule(module);
+            this->modules_.push_back(module);
+        }
+
+        orxout(internal_info) << "finished loading modules" << endl;
+    }
+
+    void Core::loadModule(ModuleInstance* module)
+    {
+        orxout(internal_info) << "Loading module " << module->getLibraryName() << "..." << endl;
+
+        try
+        {
+            ModuleInstance::setCurrentModuleInstance(module);
+            DynLib* dynLib = this->dynLibManager_->load(module->getLibraryName());
+            module->setDynLib(dynLib);
+
+            StaticInitializationManager::getInstance().loadModule(module);
+        }
+        catch (...)
+        {
+            orxout(user_error) << "Couldn't load module \"" << module->getLibraryName() << "\": " << Exception::handleMessage() << endl;
+        }
+    }
+
+    void Core::unloadModules()
+    {
+        for (std::list<ModuleInstance*>::iterator it = this->modules_.begin(); it != this->modules_.end(); ++it)
+        {
+            ModuleInstance* module = (*it);
+            this->unloadModule(module);
+            delete module;
+        }
+        this->modules_.clear();
+    }
+
+    void Core::unloadModule(ModuleInstance* module)
+    {
+        orxout(internal_info) << "Unloading module " << module->getLibraryName() << "..." << endl;
+
+        StaticInitializationManager::getInstance().unloadModule(module);
+
+        module->deleteAllStaticallyInitializedInstances();
+        this->dynLibManager_->unload(module->getDynLib());
+        module->setDynLib(NULL);
     }
 
@@ -344,5 +334,5 @@
 
         // Any exception should trigger this, even in upgradeToGraphics (see its remarks)
-        Loki::ScopeGuard unloader = Loki::MakeObjGuard(*this, &Core::unloadGraphics);
+        Loki::ScopeGuard unloader = Loki::MakeObjGuard(*this, &Core::unloadGraphics, true);
 
         // Upgrade OGRE to receive a render window
@@ -385,5 +375,5 @@
         // Create singletons associated with graphics (in other libraries)
         orxout(internal_info) << "creating graphics scope:" << endl;
-        graphicsScope_ = new Scope<ScopeID::Graphics>();
+        graphicsScope_ = new Scope<ScopeID::GRAPHICS>();
 
         unloader.Dismiss();
@@ -392,7 +382,10 @@
     }
 
-    void Core::unloadGraphics()
+    void Core::unloadGraphics(bool loadGraphicsManagerWithoutRenderer)
     {
         orxout(internal_info) << "unloading graphics in Core" << endl;
+
+        if (this->graphicsManager_)
+            this->graphicsManager_->unloadDebugOverlay();
 
         safeObjectDelete(&graphicsScope_);
@@ -403,5 +396,8 @@
         // Load Ogre::Root again, but without the render system
         try
-            { this->graphicsManager_ = new GraphicsManager(false); }
+        {
+            if (loadGraphicsManagerWithoutRenderer)
+                this->graphicsManager_ = new GraphicsManager(false);
+        }
         catch (...)
         {
@@ -414,10 +410,4 @@
         bGraphicsLoaded_ = false;
         GameMode::bShowsGraphics_s = false;
-    }
-
-    //! Sets the language in the config-file back to the default.
-    void Core::resetLanguage()
-    {
-        ResetConfigValue(language_);
     }
 
@@ -470,6 +460,7 @@
     void Core::preUpdate(const Clock& time)
     {
-        // Update singletons before general ticking
-        ScopedSingletonManager::preUpdate<ScopeID::Root>(time);
+        // Update UpdateListeners before general ticking
+        for (ObjectList<UpdateListener>::iterator it = ObjectList<UpdateListener>::begin(); it != ObjectList<UpdateListener>::end(); ++it)
+            it->preUpdate(time);
         if (this->bGraphicsLoaded_)
         {
@@ -478,6 +469,4 @@
             // Update GUI
             this->guiManager_->preUpdate(time);
-            // Update singletons before general ticking
-            ScopedSingletonManager::preUpdate<ScopeID::Graphics>(time);
         }
         // Process console events and status line
@@ -490,31 +479,12 @@
     void Core::postUpdate(const Clock& time)
     {
-        // Update singletons just before rendering
-        ScopedSingletonManager::postUpdate<ScopeID::Root>(time);
+        // Update UpdateListeners just before rendering
+        for (ObjectList<UpdateListener>::iterator it = ObjectList<UpdateListener>::begin(); it != ObjectList<UpdateListener>::end(); ++it)
+            it->postUpdate(time);
         if (this->bGraphicsLoaded_)
         {
-            // Update singletons just before rendering
-            ScopedSingletonManager::postUpdate<ScopeID::Graphics>(time);
             // Render (doesn't throw)
             this->graphicsManager_->postUpdate(time);
         }
     }
-
-    void Core::updateLastLevelTimestamp()
-    {
-        ModifyConfigValue(lastLevelTimestamp_, set, static_cast<long long>(time(NULL)));
-    }
-
-    void Core::updateOgreConfigTimestamp()
-    {
-        ModifyConfigValue(ogreConfigTimestamp_, set, static_cast<long long>(time(NULL)));
-    }
-
-
-    RegisterAbstractClass(DevModeListener).inheritsFrom(Class(Listable));
-
-    DevModeListener::DevModeListener()
-    {
-        RegisterObject(DevModeListener);
-    }
 }
Index: code/trunk/src/libraries/core/Core.h
===================================================================
--- code/trunk/src/libraries/core/Core.h	(revision 10622)
+++ code/trunk/src/libraries/core/Core.h	(revision 10624)
@@ -47,17 +47,8 @@
 #include "util/DestructionHelper.h"
 #include "util/Singleton.h"
-#include "config/Configurable.h"
+#include "CoreConfig.h"
 
 namespace orxonox
 {
-    //! Informs about changes in the Development Mode.
-    class DevModeListener : virtual public Listable
-    {
-    public:
-        DevModeListener();
-        virtual ~DevModeListener() {}
-        virtual void devModeChanged(bool value) = 0;
-    };
-
     /**
     @brief
@@ -66,8 +57,7 @@
         You should only create this singleton once because it destroys the identifiers!
     */
-    class _CoreExport Core : public Singleton<Core>, public Configurable
+    class _CoreExport Core : public Singleton<Core>
     {
         friend class Singleton<Core>;
-        friend class Game;
 
         public:
@@ -86,65 +76,53 @@
             void destroy();
 
-            void setConfigValues();
+            void preUpdate(const Clock& time);
+            void postUpdate(const Clock& time);
 
-            //! Returns the configured language.
-            const std::string& getLanguage()
-                { return this->language_; }
-            void resetLanguage();
+            void loadGraphics();
+            void unloadGraphics(bool loadGraphicsManagerWithoutRenderer = true);
 
-            void updateLastLevelTimestamp();
-            inline long long getLastLevelTimestamp() const
-                { return this->lastLevelTimestamp_; }
+            void loadModules();
+            void unloadModules();
+            void loadModule(ModuleInstance* module);
+            void unloadModule(ModuleInstance* module);
 
-            void updateOgreConfigTimestamp();
-            inline long long getOgreConfigTimestamp() const
-                { return this->ogreConfigTimestamp_; }
-
-            //! Developers bit. If returns false, some options are not available as to not confuse the normal user.
-            inline bool inDevMode(void) const
-                { return this->bDevMode_; }
+            inline CoreConfig* getConfig() const
+                { return this->config_; }
 
         private:
             Core(const Core&); //!< Don't use (undefined symbol)
 
-            void devModeChanged();
-            void languageChanged();
-            void initRandomNumberGenerator();
-
-            void preUpdate(const Clock& time);
-            void postUpdate(const Clock& time);
-
-            void loadGraphics();
-            void unloadGraphics();
-
             void setThreadAffinity(int limitToCPU);
 
-            PathConfig*               pathConfig_;
-            DynLibManager*            dynLibManager_;
-            SignalHandler*            signalHandler_;
-            ConfigFileManager*        configFileManager_;
-            Language*                 languageInstance_;
-            IOConsole*                ioConsole_;
-            TclBind*                  tclBind_;
-            TclThreadManager*         tclThreadManager_;
-            Scope<ScopeID::Root>*     rootScope_;
+            ApplicationPaths*                applicationPaths_;
+            ConfigurablePaths*               configurablePaths_;
+            DynLibManager*                   dynLibManager_;
+            SignalHandler*                   signalHandler_;
+            ConfigFileManager*               configFileManager_;
+            Language*                        languageInstance_;
+            Loader*                          loaderInstance_;
+            IOConsole*                       ioConsole_;
+            TclBind*                         tclBind_;
+            TclThreadManager*                tclThreadManager_;
+            Scope<ScopeID::ROOT>*            rootScope_;
             // graphical
-            GraphicsManager*          graphicsManager_;            //!< Interface to OGRE
-            InputManager*             inputManager_;               //!< Interface to OIS
-            GUIManager*               guiManager_;                 //!< Interface to GUI
-            Scope<ScopeID::Graphics>* graphicsScope_;
+            GraphicsManager*                 graphicsManager_;            //!< Interface to OGRE
+            InputManager*                    inputManager_;               //!< Interface to OIS
+            GUIManager*                      guiManager_;                 //!< Interface to GUI
+            Scope<ScopeID::GRAPHICS>*        graphicsScope_;
+            bool                             bGraphicsLoaded_;
 
-            bool                      bGraphicsLoaded_;
-            std::string               language_;                   //!< The language
-            bool                      bInitRandomNumberGenerator_; //!< If true, srand(time(0)) is called
-            bool                      bStartIOConsole_;            //!< Set to false if you don't want to use the IOConsole
-            long long                 lastLevelTimestamp_;         ///< Timestamp when the last level was started
-            long long                 ogreConfigTimestamp_;        ///< Timestamp wehen the ogre config level was modified
-            bool                      bDevMode_;                   //!< Developers bit. If set to false, some options are not available as to not confuse the normal user.
+            CoreStaticInitializationHandler* staticInitHandler_;
+            PluginManager*                   pluginManager_;
+            ModuleInstance*                  rootModule_;
+            std::list<ModuleInstance*>       modules_;
+
+            /// Helper object that stores the config values
+            CoreConfig*                      config_;
 
             /// Helper object that executes the surrogate destructor destroy()
-            DestructionHelper<Core>   destructionHelper_;
+            DestructionHelper<Core>          destructionHelper_;
 
-            static Core*              singletonPtr_s;
+            static Core*                     singletonPtr_s;
     };
 }
Index: code/trunk/src/libraries/core/CoreConfig.cc
===================================================================
--- code/trunk/src/libraries/core/CoreConfig.cc	(revision 10624)
+++ code/trunk/src/libraries/core/CoreConfig.cc	(revision 10624)
@@ -0,0 +1,154 @@
+/*
+ *   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 "CoreConfig.h"
+
+#include "util/output/LogWriter.h"
+#include "util/output/OutputManager.h"
+#include "core/CoreIncludes.h"
+#include "core/config/ConfigValueIncludes.h"
+#include "core/Language.h"
+#include "core/ApplicationPaths.h"
+
+namespace orxonox
+{
+    RegisterClassNoArgs(CoreConfig);
+
+    CoreConfig::CoreConfig()
+        : bDevMode_(false)
+        , bStartIOConsole_(true)
+        , lastLevelTimestamp_(0)
+        , ogreConfigTimestamp_(0)
+    {
+        RegisterObject(CoreConfig);
+        this->setConfigValues();
+    }
+
+    //! Function to collect the SetConfigValue-macro calls.
+    void CoreConfig::setConfigValues()
+    {
+        SetConfigValueExternal(OutputManager::getInstance().getLogWriter()->configurableMaxLevel_,
+                               OutputManager::getInstance().getLogWriter()->getConfigurableSectionName(),
+                               OutputManager::getInstance().getLogWriter()->getConfigurableMaxLevelName(),
+                               OutputManager::getInstance().getLogWriter()->configurableMaxLevel_)
+            .description("The maximum level of output shown in the log file")
+            .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableLevel);
+        SetConfigValueExternal(OutputManager::getInstance().getLogWriter()->configurableAdditionalContextsMaxLevel_,
+                               OutputManager::getInstance().getLogWriter()->getConfigurableSectionName(),
+                               OutputManager::getInstance().getLogWriter()->getConfigurableAdditionalContextsMaxLevelName(),
+                               OutputManager::getInstance().getLogWriter()->configurableAdditionalContextsMaxLevel_)
+            .description("The maximum level of output shown in the log file for additional contexts")
+            .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableAdditionalContextsLevel);
+        SetConfigValueExternal(OutputManager::getInstance().getLogWriter()->configurableAdditionalContexts_,
+                               OutputManager::getInstance().getLogWriter()->getConfigurableSectionName(),
+                               OutputManager::getInstance().getLogWriter()->getConfigurableAdditionalContextsName(),
+                               OutputManager::getInstance().getLogWriter()->configurableAdditionalContexts_)
+            .description("Additional output contexts shown in the log file")
+            .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableAdditionalContexts);
+
+        SetConfigValue(bDevMode_, ApplicationPaths::buildDirectoryRun())
+            .description("Developer mode. If not set, hides some things from the user to not confuse him.")
+            .callback(this, &CoreConfig::devModeChanged);
+        SetConfigValue(language_, Language::getInstance().defaultLanguage_)
+            .description("The language of the in game text")
+            .callback(this, &CoreConfig::languageChanged);
+        SetConfigValue(bInitRandomNumberGenerator_, true)
+            .description("If true, all random actions are different each time you start the game")
+            .callback(this, &CoreConfig::initRandomNumberGenerator);
+        SetConfigValue(bStartIOConsole_, true)
+            .description("Set to false if you don't want to use the IOConsole (for Lua debugging for instance)");
+        SetConfigValue(lastLevelTimestamp_, 0)
+            .description("Timestamp when the last level was started.");
+        SetConfigValue(ogreConfigTimestamp_, 0)
+            .description("Timestamp when the ogre config file was changed.");
+    }
+
+    /** Callback function for changes in the dev mode that affect debug levels.
+        The function behaves according to these rules:
+        - 'normal' mode is defined based on where the program was launched: if
+          the launch path was the build directory, development mode \c on is
+          normal, otherwise normal means development mode \c off.
+        - Debug levels should not be hard configured (\c config instead of
+          \c tconfig) in non 'normal' mode to avoid strange behaviour.
+        - Changing the development mode from 'normal' to the other state will
+          immediately change the debug levels to predefined values which can be
+          reconfigured with \c tconfig.
+    @note
+        The debug levels for the IOConsole and the InGameConsole can be found
+        in the Shell class. The same rules apply.
+    */
+    void CoreConfig::devModeChanged()
+    {
+        // Inform listeners
+        ObjectList<DevModeListener>::iterator it = ObjectList<DevModeListener>::begin();
+        for (; it != ObjectList<DevModeListener>::end(); ++it)
+            it->devModeChanged(bDevMode_);
+    }
+
+    //! Callback function if the language has changed.
+    void CoreConfig::languageChanged()
+    {
+        // Read the translation file after the language was configured
+        bool success = Language::getInstance().readTranslatedLanguageFile(this->language_);
+        if (!success)
+        {
+            // Set the language in the config-file back to the default.
+            ResetConfigValue(language_);
+            orxout(internal_info, context::language) << "Reset language to " << this->language_ << '.' << endl;
+        }
+    }
+
+    void CoreConfig::initRandomNumberGenerator()
+    {
+        static bool bInitialized = false;
+        if (!bInitialized && this->bInitRandomNumberGenerator_)
+        {
+            srand(static_cast<unsigned int>(time(0)));
+            rand();
+            bInitialized = true;
+        }
+    }
+
+    void CoreConfig::updateLastLevelTimestamp()
+    {
+        ModifyConfigValue(lastLevelTimestamp_, set, static_cast<long long>(time(NULL)));
+    }
+
+    void CoreConfig::updateOgreConfigTimestamp()
+    {
+        ModifyConfigValue(ogreConfigTimestamp_, set, static_cast<long long>(time(NULL)));
+    }
+
+
+    RegisterAbstractClass(DevModeListener).inheritsFrom<Listable>();
+
+    DevModeListener::DevModeListener()
+    {
+        RegisterObject(DevModeListener);
+    }
+}
Index: code/trunk/src/libraries/core/CoreConfig.h
===================================================================
--- code/trunk/src/libraries/core/CoreConfig.h	(revision 10624)
+++ code/trunk/src/libraries/core/CoreConfig.h	(revision 10624)
@@ -0,0 +1,83 @@
+/*
+ *   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 _CoreConfig_H__
+#define _CoreConfig_H__
+
+#include "core/CorePrereqs.h"
+
+#include "core/config/Configurable.h"
+
+namespace orxonox
+{
+    class _CoreExport CoreConfig : virtual public Configurable
+    {
+        public:
+            CoreConfig();
+
+            void setConfigValues();
+
+            //! Developers bit. If returns false, some options are not available as to not confuse the normal user.
+            inline bool inDevMode(void) const
+                { return this->bDevMode_; }
+
+            inline bool getStartIOConsole() const
+                { return this->bStartIOConsole_; }
+
+            void updateLastLevelTimestamp();
+            inline long long getLastLevelTimestamp() const
+                { return this->lastLevelTimestamp_; }
+
+            void updateOgreConfigTimestamp();
+            inline long long getOgreConfigTimestamp() const
+                { return this->ogreConfigTimestamp_; }
+
+        private:
+            void devModeChanged();
+            void languageChanged();
+            void initRandomNumberGenerator();
+
+            bool                      bDevMode_;                   //!< Developers bit. If set to false, some options are not available as to not confuse the normal user.
+            std::string               language_;                   //!< The language
+            bool                      bInitRandomNumberGenerator_; //!< If true, srand(time(0)) is called
+            bool                      bStartIOConsole_;            //!< Set to false if you don't want to use the IOConsole
+            long long                 lastLevelTimestamp_;         ///< Timestamp when the last level was started
+            long long                 ogreConfigTimestamp_;        ///< Timestamp wehen the ogre config level was modified
+    };
+
+    //! Informs about changes in the Development Mode.
+    class DevModeListener : virtual public Listable
+    {
+    public:
+        DevModeListener();
+        virtual ~DevModeListener() {}
+        virtual void devModeChanged(bool value) = 0;
+    };
+}
+
+#endif /* _CoreConfig_H__ */
Index: code/trunk/src/libraries/core/CoreIncludes.h
===================================================================
--- code/trunk/src/libraries/core/CoreIncludes.h	(revision 10622)
+++ code/trunk/src/libraries/core/CoreIncludes.h	(revision 10624)
@@ -84,4 +84,5 @@
 #include "object/ClassFactory.h"
 #include "object/ObjectList.h"
+#include "module/StaticallyInitializedInstance.h"
 
 // resolve macro conflict on windows
@@ -126,5 +127,5 @@
 */
 #define RegisterClassWithFactory(ClassName, FactoryInstance, bLoadable) \
-    Identifier& _##ClassName##Identifier = orxonox::registerClass<ClassName>(#ClassName, FactoryInstance, bLoadable)
+    orxonox::SI_I& _##ClassName##Identifier = (*new orxonox::SI_I(orxonox::registerClass<ClassName>(#ClassName, FactoryInstance, bLoadable)))
 
 /**
@@ -133,5 +134,5 @@
 */
 #define RegisterObject(ClassName) \
-    if (ClassIdentifier<ClassName>::getIdentifier(#ClassName)->initializeObject(this)) \
+    if (ClassIdentifier<ClassName>::getIdentifier()->initializeObject(this)) \
         return; \
     else \
@@ -152,5 +153,5 @@
      */
     template <class T>
-    inline Identifier& registerClass(const std::string& name, ClassFactory<T>* factory, bool bLoadable = true)
+    inline Identifier* registerClass(const std::string& name, ClassFactory<T>* factory, bool bLoadable = true)
     {
         return registerClass<T>(name, static_cast<Factory*>(factory), bLoadable);
@@ -164,11 +165,7 @@
      */
     template <class T>
-    inline Identifier& registerClass(const std::string& name, Factory* factory, bool bLoadable = true)
-    {
-        orxout(verbose, context::misc::factory) << "Create entry for " << name << " in Factory." << endl;
-        Identifier* identifier = ClassIdentifier<T>::getIdentifier(name);
-        identifier->setFactory(factory);
-        identifier->setLoadable(bLoadable);
-        return *identifier;
+    inline Identifier* registerClass(const std::string& name, Factory* factory, bool bLoadable = true)
+    {
+        return new ClassIdentifier<T>(name, factory, bLoadable);
     }
 
@@ -211,4 +208,52 @@
         return ClassIdentifier<T>::getIdentifier();
     }
+
+
+
+
+    /**
+     * The static initializer stores the parent classes of this identifier. The corresponding identifiers are later loaded. This prevents identifiers from
+     * being used before they are completely initialized.
+     */
+    class _CoreExport StaticallyInitializedIdentifier : public StaticallyInitializedInstance
+    {
+        template <class T>
+        struct InheritsFromClass : public Identifier::InheritsFrom
+        {
+            virtual Identifier* getParent() const { return Class(T); }
+        };
+
+        public:
+            StaticallyInitializedIdentifier(Identifier* identifier)
+                : StaticallyInitializedInstance(StaticInitialization::IDENTIFIER)
+                , identifier_(identifier)
+            {}
+            ~StaticallyInitializedIdentifier() { delete identifier_; }
+
+            virtual void load()
+            {
+                IdentifierManager::getInstance().addIdentifier(this->identifier_);
+            }
+
+            virtual void unload()
+            {
+                IdentifierManager::getInstance().removeIdentifier(this->identifier_);
+            }
+
+            inline Identifier& getIdentifier()
+                { return *this->identifier_; }
+
+            template <class T>
+            inline StaticallyInitializedIdentifier& inheritsFrom()
+                { this->identifier_->inheritsFrom(new InheritsFromClass<T>()); return *this; }
+
+            inline StaticallyInitializedIdentifier& virtualBase()
+                { this->identifier_->setVirtualBase(true); return *this; }
+
+        private:
+            Identifier* identifier_;
+    };
+
+    typedef StaticallyInitializedIdentifier SI_I;
 }
 
Index: code/trunk/src/libraries/core/CorePrereqs.h
===================================================================
--- code/trunk/src/libraries/core/CorePrereqs.h	(revision 10622)
+++ code/trunk/src/libraries/core/CorePrereqs.h	(revision 10624)
@@ -77,4 +77,24 @@
 namespace orxonox
 {
+    namespace ScopeID
+    {
+        typedef int Value;
+
+        //!A list of available scopes for the Scope template.
+        static const Value ROOT = 1;
+        static const Value GRAPHICS = 2;
+    }
+
+    namespace StaticInitialization
+    {
+        typedef int Type;
+
+        static const Type STATIC_INITIALIZATION_HANDLER = 1;
+        static const Type IDENTIFIER = 2;
+        static const Type SCOPED_SINGLETON_WRAPPER = 3;
+        static const Type COMMAND_LINE_ARGUMENT = 4;
+        static const Type CONSOLE_COMMAND = 5;
+    }
+
     namespace XMLPort
     {
@@ -123,4 +143,5 @@
     T orxonox_cast(U*);
 
+    class ApplicationPaths;
     class BaseObject;
     template <class T>
@@ -143,8 +164,12 @@
     class ConfigFileSection;
     class Configurable;
+    class ConfigurablePaths;
     class ConfigValueContainer;
     class Context;
     class Core;
+    class CoreConfig;
+    class CoreStaticInitializationHandler;
     class Destroyable;
+    class DestroyLaterManager;
     class DestructionListener;
     class DynLib;
@@ -154,4 +179,5 @@
     class Factory;
     class Game;
+    class GameConfig;
     class GameState;
     struct GameStateInfo;
@@ -165,8 +191,10 @@
     class Language;
     class Listable;
+    class Loader;
     class LuaFunctor;
     class LuaState;
     class MemoryArchive;
     class MemoryArchiveFactory;
+    class ModuleInstance;
     class Namespace;
     class NamespaceNode;
@@ -182,9 +210,18 @@
     class OrxonoxClass;
     class OrxonoxInterface;
-    class PathConfig;
+    class Plugin;
+    class PluginManager;
+    class PluginReference;
     struct ResourceInfo;
+    template <ScopeID::Value>
+    class Scope;
+    class ScopeManager;
+    class ScopedSingletonWrapper;
     class SettingsConfigFile;
-    template <class T>
-    class SmartPtr;
+    class StaticallyInitializedInstance;
+    class StaticInitializationHandler;
+    class StaticInitializationManager;
+    template <class T>
+    class StrongPtr;
     template <class T>
     class SubclassIdentifier;
@@ -192,4 +229,5 @@
     class Thread;
     class ThreadPool;
+    class UpdateListener;
     class ViewportEventListener;
     template <class T>
@@ -210,4 +248,5 @@
     class CommandEvaluation;
     class ConsoleCommand;
+    class ConsoleCommandManager;
     class Executor;
     template <class T>
Index: code/trunk/src/libraries/core/CoreStaticInitializationHandler.cc
===================================================================
--- code/trunk/src/libraries/core/CoreStaticInitializationHandler.cc	(revision 10624)
+++ code/trunk/src/libraries/core/CoreStaticInitializationHandler.cc	(revision 10624)
@@ -0,0 +1,136 @@
+/*
+ *   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 "CoreStaticInitializationHandler.h"
+
+#include "CoreIncludes.h"
+#include "module/ModuleInstance.h"
+#include "object/Iterator.h"
+#include "class/IdentifierManager.h"
+#include "singleton/ScopeManager.h"
+#include "command/ConsoleCommandManager.h"
+#include "commandline/CommandLineParser.h"
+
+namespace orxonox
+{
+    void CoreStaticInitializationHandler::setupHandler()
+    {
+        // initialize singletons
+        new IdentifierManager();
+        new ScopeManager();
+        new CommandLineParser();
+        new ConsoleCommandManager();
+    }
+
+    void CoreStaticInitializationHandler::shutdownHandler()
+    {
+        delete &ConsoleCommandManager::getInstance();
+        delete &CommandLineParser::getInstance();
+        delete &ScopeManager::getInstance();
+        delete &IdentifierManager::getInstance();
+    }
+
+    void CoreStaticInitializationHandler::loadModule(ModuleInstance* module)
+    {
+        this->loadInstances(module);
+        if (this->bInitInstances_)
+            this->initInstances(module);
+    }
+
+    void CoreStaticInitializationHandler::loadInstances(ModuleInstance* module)
+    {
+        // the order of initialization is important: handlers > identifiers > singletons > everything else
+        module->loadAllStaticallyInitializedInstances(StaticInitialization::STATIC_INITIALIZATION_HANDLER);
+        module->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+        module->loadAllStaticallyInitializedInstances(StaticInitialization::SCOPED_SINGLETON_WRAPPER);
+        module->loadAllStaticallyInitializedInstances(StaticInitialization::COMMAND_LINE_ARGUMENT);
+        module->loadAllStaticallyInitializedInstances(StaticInitialization::CONSOLE_COMMAND);
+    }
+
+    void CoreStaticInitializationHandler::initInstances(ModuleInstance* module)
+    {
+        IdentifierManager::getInstance().createClassHierarchy();
+    }
+
+    void CoreStaticInitializationHandler::unloadModule(ModuleInstance* module)
+    {
+        // inverted order of initialization
+        module->unloadAllStaticallyInitializedInstances(StaticInitialization::CONSOLE_COMMAND);
+        module->unloadAllStaticallyInitializedInstances(StaticInitialization::COMMAND_LINE_ARGUMENT);
+        module->unloadAllStaticallyInitializedInstances(StaticInitialization::SCOPED_SINGLETON_WRAPPER);
+
+        // until now every object (including singletons) of the unloaded identifiers should have been destroyed in a controlled manner.
+        // every remaining object is now destroyed in random order.
+        this->destroyObjects(module);
+
+        // all objects are gone now and we can unload identifiers
+        module->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+        module->unloadAllStaticallyInitializedInstances(StaticInitialization::STATIC_INITIALIZATION_HANDLER);
+    }
+
+    void CoreStaticInitializationHandler::destroyObjects(ModuleInstance* module)
+    {
+        // collect all identifiers that are about to be unloaded
+        std::set<Identifier*> identifiers;
+        const std::set<StaticallyInitializedInstance*>& instances = module->getInstances(StaticInitialization::IDENTIFIER);
+        for (std::set<StaticallyInitializedInstance*>::const_iterator it = instances.begin(); it != instances.end(); ++it)
+            identifiers.insert(&static_cast<StaticallyInitializedIdentifier*>(*it)->getIdentifier());
+
+        // destroy objects. some objects may survive this at first because they still have strong pointers pointing at them. this is
+        // ok as long as those strong pointers are held by objects that are also about to be destroyed in the same loop. this means
+        // that objects within one module may reference each other by strong pointers. but it is not allowed that objects from another
+        // module (which is not unloaded) uses strong pointers to point at objects inside the unloaded module. this will lead to a crash.
+        for (std::set<Identifier*>::iterator it = identifiers.begin(); it != identifiers.end(); ++it)
+            (*it)->destroyObjects();
+
+        // check if all objects were really destroyed. this is not the case if an object is referenced by a strong pointer from another
+        // module (or if two objects inside this module reference each other). this will lead to a crash and must be fixed (e.g. by
+        // changing object dependencies; or by changing the logic that allows modules to be unloaded).
+        for (std::set<Identifier*>::iterator it = identifiers.begin(); it != identifiers.end(); ++it)
+        {
+            ObjectListBase* objectList = Context::getRootContext()->getObjectList(*it);
+            if (objectList->size() > 0)
+            {
+                orxout(internal_error) << "There are still " << objectList->size() << " objects of type " << (*it)->getName()
+                    << " after unloading the Identifier. This may lead to a crash" << endl;
+            }
+        }
+
+        // destroy object-lists in all contexts
+        for (std::set<Identifier*>::iterator it_identifier = identifiers.begin(); it_identifier != identifiers.end(); ++it_identifier)
+        {
+            // only do this if the Identifier is not a Context itself; otherwise we delete the list we're iterating over
+            if (!(*it_identifier)->isExactlyA(Class(Context)))
+            {
+                // iterate over all contexts
+                for (ObjectList<Context>::iterator it_context = ObjectList<Context>::begin(); it_context != ObjectList<Context>::end(); ++it_context)
+                    it_context->destroyObjectList((*it_identifier));
+            }
+        }
+    }
+}
Index: code/trunk/src/libraries/core/CoreStaticInitializationHandler.h
===================================================================
--- code/trunk/src/libraries/core/CoreStaticInitializationHandler.h	(revision 10624)
+++ code/trunk/src/libraries/core/CoreStaticInitializationHandler.h	(revision 10624)
@@ -0,0 +1,64 @@
+/*
+ *   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 _CoreStaticInitializationHandler_H__
+#define _CoreStaticInitializationHandler_H__
+
+#include "core/CorePrereqs.h"
+
+#include "module/StaticInitializationHandler.h"
+
+namespace orxonox
+{
+    class _CoreExport CoreStaticInitializationHandler : public StaticInitializationHandler
+    {
+        friend class Core;
+
+        public:
+            CoreStaticInitializationHandler() : bInitInstances_(false) {}
+
+            virtual void setupHandler();
+            virtual void shutdownHandler();
+
+            virtual void loadModule(ModuleInstance* module);
+            virtual void unloadModule(ModuleInstance* module);
+
+            inline void setInitInstances(bool bInitInstances)
+                { this->bInitInstances_ = bInitInstances; }
+
+        private:
+            void loadInstances(ModuleInstance* module);
+            void initInstances(ModuleInstance* module);
+
+            void destroyObjects(ModuleInstance* module);
+
+            bool bInitInstances_;
+    };
+}
+
+#endif /* _CoreStaticInitializationHandler_H__ */
Index: code/trunk/src/libraries/core/DynLib.cc
===================================================================
--- code/trunk/src/libraries/core/DynLib.cc	(revision 10622)
+++ 	(revision )
@@ -1,148 +1,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2006 Torus Knot Software Ltd
-Also see acknowledgements in Readme.html
-
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU Lesser 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 Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place - Suite 330, Boston, MA 02111-1307, USA, or go to
-http://www.gnu.org/copyleft/lesser.txt.
-
-You may alternatively use this source under the terms of a specific version of
-the OGRE Unrestricted License provided you have obtained such a license from
-Torus Knot Software Ltd.
------------------------------------------------------------------------------
-*/
-
-// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
-
-#include "DynLib.h"
-
-#include "util/Exception.h"
-
-#ifdef ORXONOX_PLATFORM_WINDOWS
-#  define WIN32_LEAN_AND_MEAN
-#  ifndef NOMINMAX
-#    define NOMINMAX // required to stop windows.h messing up std::min
-#  endif
-#  include <windows.h>
-#endif
-
-#ifdef ORXONOX_PLATFORM_UNIX
-#  include <dlfcn.h>
-#endif
-
-#ifdef ORXONOX_PLATFORM_APPLE
-#   include <OSX/macUtils.h> // OGRE include
-#endif
-
-namespace orxonox
-{
-    //-----------------------------------------------------------------------
-    DynLib::DynLib( const std::string& name )
-    {
-        mName = name;
-#if defined(ORXONOX_PLATFORM_WINDOWS)
-        //altered search path doesn't work with paths with forward slashes
-        std::replace(mName.begin(), mName.end(), '/', '\\');
-#endif
-        m_hInst = NULL;
-    }
-
-    //-----------------------------------------------------------------------
-    DynLib::~DynLib()
-    {
-    }
-
-    //-----------------------------------------------------------------------
-    void DynLib::load()
-    {
-        // Log library load
-        orxout(internal_info) << "Loading module " << mName << endl;
-
-        std::string name = mName;
-#ifdef ORXONOX_PLATFORM_LINUX
-        // dlopen() does not add .so to the filename, like windows does for .dll
-        if (name.substr(name.length() - 3, 3) != ".so")
-           name += ".so";
-#elif defined(ORXONOX_PLATFORM_APPLE)
-        // dlopen() does not add .dylib to the filename, like windows does for .dll
-        if (name.substr(name.length() - 6, 6) != ".dylib")
-            name += ".dylib";
-#elif defined(ORXONOX_PLATFORM_WINDOWS)
-        // Although LoadLibraryEx will add .dll itself when you only specify the library name,
-        // if you include a relative path then it does not. So, add it to be sure.
-        if (name.substr(name.length() - 4, 4) != ".dll")
-            name += ".dll";
-#endif
-
-        m_hInst = (DYNLIB_HANDLE)DYNLIB_LOAD( name.c_str() );
-
-        if (!m_hInst)
-            ThrowException(
-                General,
-                "Could not load dynamic library " + mName +
-                ".  System Error: " + dynlibError());
-    }
-
-    //-----------------------------------------------------------------------
-    void DynLib::unload()
-    {
-        // Log library unload
-        orxout(internal_info) << "Unloading module " << mName << endl;
-
-        if (DYNLIB_UNLOAD( m_hInst ))
-        {
-            ThrowException(
-                General,
-                "Could not unload dynamic library " + mName +
-                ".  System Error: " + dynlibError());
-        }
-
-    }
-
-    //-----------------------------------------------------------------------
-    void* DynLib::getSymbol( const std::string& strName ) const throw()
-    {
-        return (void*)DYNLIB_GETSYM( m_hInst, strName.c_str() );
-    }
-    //-----------------------------------------------------------------------
-    std::string DynLib::dynlibError( void )
-    {
-#if defined(ORXONOX_PLATFORM_WINDOWS)
-        LPVOID lpMsgBuf;
-        FormatMessage(
-            FORMAT_MESSAGE_ALLOCATE_BUFFER |
-            FORMAT_MESSAGE_FROM_SYSTEM |
-            FORMAT_MESSAGE_IGNORE_INSERTS,
-            NULL,
-            GetLastError(),
-            MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-            (LPTSTR) &lpMsgBuf,
-            0,
-            NULL
-            );
-        std::string ret = (char*)lpMsgBuf;
-        // Free the buffer.
-        LocalFree( lpMsgBuf );
-        return ret;
-#elif defined(ORXONOX_PLATFORM_UNIX)
-        return std::string(dlerror());
-#else
-        return "";
-#endif
-    }
-}
Index: code/trunk/src/libraries/core/DynLib.h
===================================================================
--- code/trunk/src/libraries/core/DynLib.h	(revision 10622)
+++ 	(revision )
@@ -1,119 +1,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2006 Torus Knot Software Ltd
-Also see acknowledgements in Readme.html
-
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU Lesser 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 Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place - Suite 330, Boston, MA 02111-1307, USA, or go to
-http://www.gnu.org/copyleft/lesser.txt.
-
-You may alternatively use this source under the terms of a specific version of
-the OGRE Unrestricted License provided you have obtained such a license from
-Torus Knot Software Ltd.
------------------------------------------------------------------------------
-*/
-
-// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
-
-/**
-    @file
-    @ingroup Management CoreGame
-    @brief Declaration of DynLib which represents a dynamically loaded module.
-*/
-
-#ifndef _Core_DynLib_H__
-#define _Core_DynLib_H__
-
-#include "CorePrereqs.h"
-
-#include <string>
-
-#if defined(ORXONOX_PLATFORM_WINDOWS)
-#    define DYNLIB_HANDLE hInstance
-#    define DYNLIB_LOAD( a ) LoadLibraryEx( a, NULL, LOAD_WITH_ALTERED_SEARCH_PATH )
-#    define DYNLIB_GETSYM( a, b ) GetProcAddress( a, b )
-#    define DYNLIB_UNLOAD( a ) !FreeLibrary( a )
-
-struct HINSTANCE__;
-typedef struct HINSTANCE__* hInstance;
-
-#elif defined(ORXONOX_PLATFORM_UNIX)
-#    define DYNLIB_HANDLE void*
-#    define DYNLIB_LOAD( a ) dlopen( a, RTLD_LAZY | RTLD_GLOBAL)
-#    define DYNLIB_GETSYM( a, b ) dlsym( a, b )
-#    define DYNLIB_UNLOAD( a ) dlclose( a )
-#endif
-
-namespace orxonox
-{
-    /** %Resource holding data about a dynamic library.
-        @remarks
-            This class holds the data required to get symbols from
-            libraries loaded at run-time (i.e. from DLL's for so's)
-        @author
-            Adrian Cearnãu (cearny@cearny.ro)
-        @since
-            27 January 2002
-    */
-    class _CoreExport DynLib
-    {
-    protected:
-        std::string mName;
-        /// Gets the last loading error
-        std::string dynlibError(void);
-    public:
-        /** Default constructor - used by DynLibManager.
-            @warning
-                Do not call directly
-        */
-        DynLib( const std::string& name );
-
-        /** Default destructor.
-        */
-        ~DynLib();
-
-        /** Load the library
-        */
-        void load();
-        /** Unload the library
-        */
-        void unload();
-        /// Get the name of the library
-        const std::string& getName(void) const { return mName; }
-
-        /**
-            Returns the address of the given symbol from the loaded library.
-            @param
-                strName The name of the symbol to search for
-            @returns
-                If the function succeeds, the returned value is a handle to
-                the symbol.
-            @par
-                If the function fails, the returned value is <b>NULL</b>.
-
-        */
-        void* getSymbol( const std::string& strName ) const throw();
-
-    protected:
-
-        /// Handle to the loaded library.
-        DYNLIB_HANDLE m_hInst;
-    };
-
-}
-
-#endif /* _Core_DynLib_H__ */
Index: code/trunk/src/libraries/core/DynLibManager.cc
===================================================================
--- code/trunk/src/libraries/core/DynLibManager.cc	(revision 10622)
+++ 	(revision )
@@ -1,86 +1,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2006 Torus Knot Software Ltd
-Also see acknowledgements in Readme.html
-
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU Lesser 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 Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place - Suite 330, Boston, MA 02111-1307, USA, or go to
-http://www.gnu.org/copyleft/lesser.txt.
-
-You may alternatively use this source under the terms of a specific version of
-the OGRE Unrestricted License provided you have obtained such a license from
-Torus Knot Software Ltd.
------------------------------------------------------------------------------
-*/
-
-// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
-
-#include "DynLibManager.h"
-
-#include "DynLib.h"
-
-namespace orxonox
-{
-    //-----------------------------------------------------------------------
-    //! Static pointer to the singleton
-    DynLibManager* DynLibManager::singletonPtr_s  = 0;
-
-    //-----------------------------------------------------------------------
-    DynLibManager::DynLibManager()
-    {
-    }
-    //-----------------------------------------------------------------------
-    DynLib* DynLibManager::load( const std::string& filename)
-    {
-        DynLibList::iterator i = mLibList.find(filename);
-        if (i != mLibList.end())
-        {
-            return i->second;
-        }
-        else
-        {
-            DynLib* pLib = new DynLib(filename);
-            pLib->load();
-            mLibList[filename] = pLib;
-            return pLib;
-        }
-    }
-    //-----------------------------------------------------------------------
-    void DynLibManager::unload(DynLib* lib)
-    {
-        DynLibList::iterator i = mLibList.find(lib->getName());
-        if (i != mLibList.end())
-        {
-            mLibList.erase(i);
-        }
-        lib->unload();
-        delete lib;
-    }
-    //-----------------------------------------------------------------------
-    DynLibManager::~DynLibManager()
-    {
-        // Unload & delete resources in turn
-        for (DynLibList::iterator it = mLibList.begin(); it != mLibList.end(); ++it)
-        {
-            it->second->unload();
-            delete it->second;
-        }
-
-        // Empty the list
-        mLibList.clear();
-    }
-}
Index: code/trunk/src/libraries/core/DynLibManager.h
===================================================================
--- code/trunk/src/libraries/core/DynLibManager.h	(revision 10622)
+++ 	(revision )
@@ -1,104 +1,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2006 Torus Knot Software Ltd
-Also see acknowledgements in Readme.html
-
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU Lesser 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 Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place - Suite 330, Boston, MA 02111-1307, USA, or go to
-http://www.gnu.org/copyleft/lesser.txt.
-
-You may alternatively use this source under the terms of a specific version of
-the OGRE Unrestricted License provided you have obtained such a license from
-Torus Knot Software Ltd.
------------------------------------------------------------------------------
-*/
-
-// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
-
-/**
-    @file
-    @ingroup Management CoreGame
-    @brief Declaration of DynLibManager, used to load modules at runtime.
-*/
-
-#ifndef _Core_DynLibManager_H__
-#define _Core_DynLibManager_H__
-
-#include "CorePrereqs.h"
-
-#include <map>
-#include <string>
-#include "util/Singleton.h"
-
-namespace orxonox
-{
-    /** Manager for Dynamic-loading Libraries.
-        @remarks
-            This manager keeps a track of all the open dynamic-loading
-            libraries, opens them and returns references to already-open
-            libraries.
-    */
-    class _CoreExport DynLibManager: public Singleton<DynLibManager>
-    {
-        friend class Singleton<DynLibManager>;
-
-        protected:
-            typedef std::map<std::string, DynLib*> DynLibList;
-            DynLibList mLibList;
-
-        public:
-            /**
-            @brief
-                Default constructor.
-            @note
-                Should never be called as the singleton is automatically
-                created during the creation of the Root object.
-            @see
-                Root::Root
-            */
-            DynLibManager();
-
-            /**
-            @brief
-                Default destructor.
-            @see
-                Root::~Root
-            */
-            virtual ~DynLibManager();
-
-            /**
-            @brief
-                Loads the passed library.
-            @param filename
-                The name of the library. The extension can be omitted
-            */
-            DynLib* load(const std::string& filename);
-
-            /**
-            @brief
-                Unloads the passed library.
-            @param lib
-                A pointer to the library object
-            */
-            void unload(DynLib* lib);
-
-        private:
-            static DynLibManager* singletonPtr_s;
-    };
-}
-
-#endif /* _Core_DynLibManager_H__ */
Index: code/trunk/src/libraries/core/GUIManager.cc
===================================================================
--- code/trunk/src/libraries/core/GUIManager.cc	(revision 10622)
+++ code/trunk/src/libraries/core/GUIManager.cc	(revision 10624)
@@ -106,7 +106,7 @@
 #include "GraphicsManager.h"
 #include "LuaState.h"
-#include "PathConfig.h"
+#include "ConfigurablePaths.h"
 #include "Resource.h"
-#include "command/ConsoleCommand.h"
+#include "command/ConsoleCommandIncludes.h"
 #include "input/InputManager.h"
 #include "input/InputState.h"
@@ -255,4 +255,6 @@
     SetConsoleCommand("toggleGUI", &GUIManager::toggleGUI).defaultValue(1, false).defaultValue(2, false);
 
+    RegisterAbstractClass(GUIManager).inheritsFrom<WindowEventListener>();
+
     /**
     @brief
@@ -329,5 +331,5 @@
         // Create our own logger to specify the filepath
         std::auto_ptr<CEGUILogger> ceguiLogger(new CEGUILogger());
-        ceguiLogger->setLogFilename(PathConfig::getLogPathString() + "cegui.log");
+        ceguiLogger->setLogFilename(ConfigurablePaths::getLogPathString() + "cegui.log");
         ceguiLogger->setLoggingLevel(static_cast<CEGUI::LoggingLevel>(this->outputLevelCeguiLog_));
         this->ceguiLogger_ = ceguiLogger.release();
@@ -833,5 +835,5 @@
     /*static*/ bool GUIManager::inDevMode()
     {
-         return Core::getInstance().inDevMode();
+         return Core::getInstance().getConfig()->inDevMode();
     }
 
Index: code/trunk/src/libraries/core/Game.cc
===================================================================
--- code/trunk/src/libraries/core/Game.cc	(revision 10622)
+++ code/trunk/src/libraries/core/Game.cc	(revision 10624)
@@ -45,12 +45,11 @@
 #include "util/SubString.h"
 #include "Core.h"
-#include "CoreIncludes.h"
-#include "config/CommandLineParser.h"
-#include "config/ConfigValueIncludes.h"
+#include "commandline/CommandLineParser.h"
+#include "GameConfig.h"
 #include "GameMode.h"
 #include "GameState.h"
 #include "GraphicsManager.h"
 #include "GUIManager.h"
-#include "command/ConsoleCommand.h"
+#include "command/ConsoleCommandIncludes.h"
 
 namespace orxonox
@@ -82,4 +81,5 @@
         , bChangingState_(false)
         , bAbort_(false)
+        , config_(NULL)
         , destructionHelper_(this)
     {
@@ -110,8 +110,8 @@
         orxout(internal_info) << "creating Core object:" << endl;
         this->core_ = new Core(cmdLine);
+        this->core_->loadModules();
 
         // Do this after the Core creation!
-        RegisterObject(Game);
-        this->setConfigValues();
+        this->config_ = new GameConfig();
 
         // After the core has been created, we can safely instantiate the GameStates that don't require graphics
@@ -136,7 +136,4 @@
         orxout(internal_status) << "destroying Game object..." << endl;
 
-        // Remove us from the object lists again to avoid problems when destroying them
-        this->unregisterObject();
-
         assert(loadedStates_.size() <= 1); // Just empty root GameState
         // Destroy all GameStates (shared_ptrs take care of actual destruction)
@@ -144,19 +141,11 @@
 
         GameStateFactory::getFactories().clear();
+        safeObjectDelete(&config_);
+        if (this->core_)
+            this->core_->unloadModules();
         safeObjectDelete(&core_);
         safeObjectDelete(&gameClock_);
 
         orxout(internal_status) << "finished destroying Game object..." << endl;
-    }
-
-    void Game::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.");
-
-        SetConfigValueExternal(fpsLimit_, "GraphicsSettings", "fpsLimit", 50)
-            .description("Sets the desired frame rate (0 for no limit).");
     }
 
@@ -229,5 +218,5 @@
             // Limit frame rate
             static bool hasVSync = GameMode::showsGraphics() && GraphicsManager::getInstance().hasVSyncEnabled(); // can be static since changes of VSync currently require a restart
-            if (this->fpsLimit_ > 0 && !hasVSync)
+            if (this->config_->getFpsLimit() > 0 && !hasVSync)
                 this->updateFPSLimiter();
         }
@@ -311,9 +300,9 @@
         this->statisticsTickTimes_.back().tickLength += (uint32_t)(currentRealTime - currentTime);
         this->periodTickTime_ += (uint32_t)(currentRealTime - currentTime);
-        if (this->periodTime_ > this->statisticsRefreshCycle_)
+        if (this->periodTime_ > this->config_->getStatisticsRefreshCycle())
         {
             std::list<StatisticsTickInfo>::iterator it = this->statisticsTickTimes_.begin();
             assert(it != this->statisticsTickTimes_.end());
-            int64_t lastTime = currentTime - this->statisticsAvgLength_;
+            int64_t lastTime = currentTime - this->config_->getStatisticsAvgLength();
             if (static_cast<int64_t>(it->tickTime) < lastTime)
             {
@@ -333,5 +322,5 @@
             this->avgTickTime_ = static_cast<float>(this->periodTickTime_) / framesPerPeriod / 1000.0f;
 
-            this->periodTime_ -= this->statisticsRefreshCycle_;
+            this->periodTime_ -= this->config_->getStatisticsRefreshCycle();
         }
     }
@@ -339,5 +328,5 @@
     void Game::updateFPSLimiter()
     {
-        uint64_t nextTime = gameClock_->getMicroseconds() - excessSleepTime_ + static_cast<uint32_t>(1000000.0f / fpsLimit_);
+        uint64_t nextTime = gameClock_->getMicroseconds() - excessSleepTime_ + static_cast<uint32_t>(1000000.0f / this->config_->getFpsLimit());
         uint64_t currentRealTime = gameClock_->getRealMicroseconds();
         while (currentRealTime < nextTime - minimumSleepTime_)
@@ -529,5 +518,5 @@
 
             core_->loadGraphics();
-            Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics);
+            Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics, true);
 
             // Construct all the GameStates that require graphics
@@ -550,5 +539,5 @@
     }
 
-    void Game::unloadGraphics()
+    void Game::unloadGraphics(bool loadGraphicsManagerWithoutRenderer)
     {
         if (GameMode::showsGraphics())
@@ -566,5 +555,5 @@
             }
 
-            core_->unloadGraphics();
+            core_->unloadGraphics(loadGraphicsManagerWithoutRenderer);
         }
     }
@@ -587,5 +576,5 @@
 
         // If state requires graphics, load it
-        Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics);
+        Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics, true);
         if (gameStateDeclarations_s[name].bGraphicsMode && !GameMode::showsGraphics())
             this->loadGraphics();
@@ -623,12 +612,9 @@
         }
         // Check if graphics is still required
-        if (!bAbort_)
-        {
-            bool graphicsRequired = false;
-            for (unsigned i = 0; i < loadedStates_.size(); ++i)
-                graphicsRequired |= loadedStates_[i]->getInfo().bGraphicsMode;
-            if (!graphicsRequired)
-                this->unloadGraphics();
-        }
+        bool graphicsRequired = false;
+        for (unsigned i = 0; i < loadedStates_.size(); ++i)
+            graphicsRequired |= loadedStates_[i]->getInfo().bGraphicsMode;
+        if (!graphicsRequired)
+            this->unloadGraphics(!this->bAbort_); // if abort is false, that means the game is still running while unloading graphics. in this case we load a graphics manager without renderer (to keep all necessary ogre instances alive)
         this->bChangingState_ = false;
     }
Index: code/trunk/src/libraries/core/Game.h
===================================================================
--- code/trunk/src/libraries/core/Game.h	(revision 10622)
+++ code/trunk/src/libraries/core/Game.h	(revision 10624)
@@ -50,5 +50,4 @@
 #include "util/DestructionHelper.h"
 #include "util/Singleton.h"
-#include "config/Configurable.h"
 
 /**
@@ -82,5 +81,5 @@
     class _CoreExport Game
 // tolua_end
-        : public Singleton<Game>, public Configurable
+        : public Singleton<Game>
     { // tolua_export
         friend class Singleton<Game>;
@@ -96,6 +95,4 @@
         /// Destructor that also executes when object fails to construct
         void destroy();
-
-        void setConfigValues();
 
         void setStateHierarchy(const std::string& str);
@@ -151,5 +148,5 @@
 
         void loadGraphics();
-        void unloadGraphics();
+        void unloadGraphics(bool loadGraphicsManagerWithoutRenderer = true);
 
         void parseStates(std::vector<std::pair<std::string, int> >::const_iterator& it, shared_ptr<GameStateTreeNode> currentNode);
@@ -189,8 +186,6 @@
         unsigned int                       minimumSleepTime_;
 
-        // config values
-        unsigned int                       statisticsRefreshCycle_;
-        unsigned int                       statisticsAvgLength_;
-        unsigned int                       fpsLimit_;
+        /// Helper object that stores the config values
+        GameConfig*                        config_;
 
         /// Helper object that executes the surrogate destructor destroy()
Index: code/trunk/src/libraries/core/GameConfig.cc
===================================================================
--- code/trunk/src/libraries/core/GameConfig.cc	(revision 10624)
+++ code/trunk/src/libraries/core/GameConfig.cc	(revision 10624)
@@ -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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "GameConfig.h"
+#include "core/CoreIncludes.h"
+#include "core/config/ConfigValueIncludes.h"
+
+namespace orxonox
+{
+    RegisterClassNoArgs(GameConfig);
+
+    GameConfig::GameConfig()
+    {
+        RegisterObject(GameConfig);
+        this->setConfigValues();
+    }
+
+    void GameConfig::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.");
+
+        SetConfigValueExternal(fpsLimit_, "GraphicsSettings", "fpsLimit", 50)
+            .description("Sets the desired frame rate (0 for no limit).");
+    }
+}
Index: code/trunk/src/libraries/core/GameConfig.h
===================================================================
--- code/trunk/src/libraries/core/GameConfig.h	(revision 10624)
+++ code/trunk/src/libraries/core/GameConfig.h	(revision 10624)
@@ -0,0 +1,60 @@
+/*
+ *   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 _GameConfig_H__
+#define _GameConfig_H__
+
+#include "core/CorePrereqs.h"
+
+#include "core/config/Configurable.h"
+
+namespace orxonox
+{
+    class _CoreExport GameConfig : virtual public Configurable
+    {
+        public:
+            GameConfig();
+
+            void setConfigValues();
+
+            inline unsigned int getStatisticsRefreshCycle() const
+                { return this->statisticsRefreshCycle_; }
+            inline unsigned int getStatisticsAvgLength() const
+                { return this->statisticsAvgLength_; }
+            inline unsigned int getFpsLimit() const
+                { return this->fpsLimit_; }
+
+        private:
+            // config values
+            unsigned int statisticsRefreshCycle_;
+            unsigned int statisticsAvgLength_;
+            unsigned int fpsLimit_;
+    };
+}
+
+#endif /* _GameConfig_H__ */
Index: code/trunk/src/libraries/core/GraphicsManager.cc
===================================================================
--- code/trunk/src/libraries/core/GraphicsManager.cc	(revision 10622)
+++ code/trunk/src/libraries/core/GraphicsManager.cc	(revision 10624)
@@ -59,9 +59,10 @@
 #include "GUIManager.h"
 #include "Loader.h"
-#include "PathConfig.h"
+#include "ApplicationPaths.h"
+#include "ConfigurablePaths.h"
 #include "ViewportEventListener.h"
 #include "WindowEventListener.h"
 #include "XMLFile.h"
-#include "command/ConsoleCommand.h"
+#include "command/ConsoleCommandIncludes.h"
 #include "input/InputManager.h"
 
@@ -94,4 +95,6 @@
     GraphicsManager* GraphicsManager::singletonPtr_s = 0;
 
+    RegisterAbstractClass(GraphicsManager).inheritsFrom<Configurable>();
+
     GraphicsManager::GraphicsManager(bool bLoadRenderer)
         : ogreWindowEventListener_(new OgreWindowEventListener())
@@ -111,17 +114,17 @@
 
         // At first, add the root paths of the data directories as resource locations
-        Ogre::ResourceGroupManager::getSingleton().addResourceLocation(PathConfig::getDataPathString(), "FileSystem");
+        Ogre::ResourceGroupManager::getSingleton().addResourceLocation(ConfigurablePaths::getDataPathString(), "FileSystem");
         // Load resources
         resources_.reset(new XMLFile("DefaultResources.oxr"));
         resources_->setLuaSupport(false);
-        Loader::open(resources_.get(), ClassTreeMask(), false);
+        Loader::getInstance().load(resources_.get(), ClassTreeMask(), false);
 
         // Only for runs in the build directory (not installed)
-        if (PathConfig::buildDirectoryRun())
-            Ogre::ResourceGroupManager::getSingleton().addResourceLocation(PathConfig::getExternalDataPathString(), "FileSystem");
+        if (ApplicationPaths::buildDirectoryRun())
+            Ogre::ResourceGroupManager::getSingleton().addResourceLocation(ConfigurablePaths::getExternalDataPathString(), "FileSystem");
 
         extResources_.reset(new XMLFile("resources.oxr"));
         extResources_->setLuaSupport(false);
-        Loader::open(extResources_.get(), ClassTreeMask(), false);
+        Loader::getInstance().load(extResources_.get(), ClassTreeMask(), false);
 
         if (bLoadRenderer)
@@ -137,6 +140,4 @@
     {
         orxout(internal_status) << "destroying GraphicsManager..." << endl;
-
-        Loader::unload(debugOverlay_.get());
 
         Ogre::WindowEventUtilities::removeWindowEventListener(renderWindow_, ogreWindowEventListener_);
@@ -147,6 +148,6 @@
 
         // Undeclare the resources
-        Loader::unload(resources_.get());
-        Loader::unload(extResources_.get());
+        Loader::getInstance().unload(resources_.get());
+        Loader::getInstance().unload(extResources_.get());
 
         safeObjectDelete(&ogreRoot_);
@@ -218,6 +219,6 @@
         }
 
-        boost::filesystem::path ogreConfigFilepath(PathConfig::getConfigPath() / this->ogreConfigFile_);
-        boost::filesystem::path ogreLogFilepath(PathConfig::getLogPath() / this->ogreLogFile_);
+        boost::filesystem::path ogreConfigFilepath(ConfigurablePaths::getConfigPath() / this->ogreConfigFile_);
+        boost::filesystem::path ogreLogFilepath(ConfigurablePaths::getLogPath() / this->ogreLogFile_);
 
         // create a new logManager
@@ -258,11 +259,11 @@
         std::string pluginPath = specialConfig::ogrePluginsDirectory;
 #ifdef DEPENDENCY_PACKAGE_ENABLE
-        if (!PathConfig::buildDirectoryRun())
+        if (!ApplicationPaths::buildDirectoryRun())
         {
 #  if defined(ORXONOX_PLATFORM_WINDOWS)
-            pluginPath = PathConfig::getExecutablePathString();
+            pluginPath = ApplicationPaths::getExecutablePathString();
 #  elif defined(ORXONOX_PLATFORM_APPLE)
             // TODO: Where are the plugins being installed to?
-            pluginPath = PathConfig::getExecutablePathString();
+            pluginPath = ApplicationPaths::getExecutablePathString();
 #  endif
         }
@@ -279,5 +280,5 @@
         orxout(internal_info) << "GraphicsManager: Configuring Renderer" << endl;
 
-        bool updatedConfig = Core::getInstance().getOgreConfigTimestamp() > Core::getInstance().getLastLevelTimestamp();
+        bool updatedConfig = Core::getInstance().getConfig()->getOgreConfigTimestamp() > Core::getInstance().getConfig()->getLastLevelTimestamp();
         if (updatedConfig)
             orxout(user_info)<< "Ogre config file has changed, but no level was started since then. Displaying config dialogue again to verify the changes." << endl;
@@ -288,5 +289,5 @@
                 ThrowException(InitialisationFailed, "OGRE graphics configuration dialogue canceled.");
             else
-                Core::getInstance().updateOgreConfigTimestamp();
+                Core::getInstance().getConfig()->updateOgreConfigTimestamp();
         }
 
@@ -328,5 +329,10 @@
         orxout(internal_info) << "Loading Debug Overlay..." << endl;
         debugOverlay_.reset(new XMLFile("debug.oxo"));
-        Loader::open(debugOverlay_.get(), ClassTreeMask(), false);
+        Loader::getInstance().load(debugOverlay_.get(), ClassTreeMask(), false);
+    }
+
+    void GraphicsManager::unloadDebugOverlay()
+    {
+        Loader::getInstance().unload(debugOverlay_.get());
     }
 
@@ -514,5 +520,5 @@
             GraphicsManager::getInstance().getRenderWindow()->setFullscreen(fullscreen, width, height);
             this->ogreRoot_->saveConfig();
-            Core::getInstance().updateOgreConfigTimestamp();
+            Core::getInstance().getConfig()->updateOgreConfigTimestamp();
             // Also reload the input devices
             InputManager::getInstance().reload();
@@ -532,5 +538,5 @@
             //this->ogreRoot_->getRenderSystem()->reinitialise(); // can't use this that easily, because it recreates the render window, invalidating renderWindow_
             this->ogreRoot_->saveConfig();
-            Core::getInstance().updateOgreConfigTimestamp();
+            Core::getInstance().getConfig()->updateOgreConfigTimestamp();
         }
 
@@ -548,5 +554,5 @@
             //this->ogreRoot_->getRenderSystem()->reinitialise(); // can't use this that easily, because it recreates the render window, invalidating renderWindow_
             this->ogreRoot_->saveConfig();
-            Core::getInstance().updateOgreConfigTimestamp();
+            Core::getInstance().getConfig()->updateOgreConfigTimestamp();
         }
 
@@ -557,5 +563,5 @@
     {
         assert(this->renderWindow_);
-        this->renderWindow_->writeContentsToTimestampedFile(PathConfig::getLogPathString() + "screenShot_", ".png");
+        this->renderWindow_->writeContentsToTimestampedFile(ConfigurablePaths::getLogPathString() + "screenShot_", ".png");
     }
 }
Index: code/trunk/src/libraries/core/GraphicsManager.h
===================================================================
--- code/trunk/src/libraries/core/GraphicsManager.h	(revision 10622)
+++ code/trunk/src/libraries/core/GraphicsManager.h	(revision 10624)
@@ -95,4 +95,5 @@
         void upgradeToGraphics();
         void loadDebugOverlay();
+        void unloadDebugOverlay();
         bool rendererLoaded() const { return renderWindow_ != NULL; }
 
Index: code/trunk/src/libraries/core/Language.cc
===================================================================
--- code/trunk/src/libraries/core/Language.cc	(revision 10622)
+++ code/trunk/src/libraries/core/Language.cc	(revision 10624)
@@ -37,6 +37,5 @@
 #include "util/Output.h"
 #include "util/StringUtils.h"
-#include "Core.h"
-#include "PathConfig.h"
+#include "ConfigurablePaths.h"
 
 namespace orxonox
@@ -203,5 +202,5 @@
         orxout(internal_info, context::language) << "Read default language file." << endl;
 
-        const std::string& filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_);
+        const std::string& filepath = ConfigurablePaths::getConfigPathString() + getFilename(this->defaultLanguage_);
 
         // This creates the file if it's not existing
@@ -247,10 +246,11 @@
     /**
         @brief Reads the language file of the configured language and assigns the localisation to the corresponding LanguageEntry object.
-    */
-    void Language::readTranslatedLanguageFile()
-    {
-        orxout(internal_info, context::language) << "Read translated language file (" << Core::getInstance().getLanguage() << ")." << endl;
-
-        const std::string& filepath = PathConfig::getConfigPathString() + getFilename(Core::getInstance().getLanguage());
+        @return Returns false if the language file couldn't be found.
+    */
+    bool Language::readTranslatedLanguageFile(const std::string& language)
+    {
+        orxout(internal_info, context::language) << "Read translated language file (" << language << ")." << endl;
+
+        const std::string& filepath = ConfigurablePaths::getConfigPathString() + getFilename(language);
 
         // Open the file
@@ -261,8 +261,6 @@
         {
             orxout(internal_error, context::language) << "An error occurred in Language.cc:" << endl;
-            orxout(internal_error, context::language) << "Couldn't open file " << getFilename(Core::getInstance().getLanguage()) << " to read the translated language entries!" << endl;
-            Core::getInstance().resetLanguage();
-            orxout(internal_info, context::language) << "Reset language to " << this->defaultLanguage_ << '.' << endl;
-            return;
+            orxout(internal_error, context::language) << "Couldn't open file " << getFilename(language) << " to read the translated language entries!" << endl;
+            return false;
         }
 
@@ -291,5 +289,5 @@
                 else
                 {
-                    orxout(internal_warning, context::language) << "Invalid language entry \"" << lineString << "\" in " << getFilename(Core::getInstance().getLanguage()) << endl;
+                    orxout(internal_warning, context::language) << "Invalid language entry \"" << lineString << "\" in " << getFilename(language) << endl;
                 }
             }
@@ -297,4 +295,5 @@
 
         file.close();
+        return true;
     }
 
@@ -306,5 +305,5 @@
         orxout(verbose, context::language) << "Write default language file." << endl;
 
-        const std::string& filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_);
+        const std::string& filepath = ConfigurablePaths::getConfigPathString() + getFilename(this->defaultLanguage_);
 
         // Open the file
Index: code/trunk/src/libraries/core/Language.h
===================================================================
--- code/trunk/src/libraries/core/Language.h	(revision 10622)
+++ code/trunk/src/libraries/core/Language.h	(revision 10624)
@@ -161,5 +161,5 @@
     {
         friend class Singleton<Language>;
-        friend class Core;
+        friend class CoreConfig;
 
         public:
@@ -174,5 +174,5 @@
 
             void readDefaultLanguageFile();
-            void readTranslatedLanguageFile();
+            bool readTranslatedLanguageFile(const std::string& language);
             void writeDefaultLanguageFile() const;
             static std::string getFilename(const std::string& language);
Index: code/trunk/src/libraries/core/Loader.cc
===================================================================
--- code/trunk/src/libraries/core/Loader.cc	(revision 10622)
+++ code/trunk/src/libraries/core/Loader.cc	(revision 10624)
@@ -48,92 +48,5 @@
 namespace orxonox
 {
-    std::vector<std::pair<const XMLFile*, ClassTreeMask> > Loader::files_s;
-    ClassTreeMask Loader::currentMask_s;
-
-    bool Loader::open(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose)
-    {
-        Loader::add(file, mask);
-        return Loader::load(file, mask, bVerbose);
-    }
-
-    void Loader::close()
-    {
-        Loader::unload();
-        Loader::files_s.clear();
-    }
-
-    void Loader::close(const XMLFile* file)
-    {
-        Loader::unload(file);
-        Loader::remove(file);
-    }
-
-    void Loader::add(const XMLFile* file, const ClassTreeMask& mask)
-    {
-        if (!file)
-            return;
-        Loader::files_s.insert(Loader::files_s.end(), std::pair<const XMLFile*, ClassTreeMask>(file, mask));
-    }
-
-    void Loader::remove(const XMLFile* file)
-    {
-        if (!file)
-            return;
-        for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it)
-        {
-            if (it->first == file)
-            {
-                Loader::files_s.erase(it);
-                break;
-            }
-        }
-    }
-
-    /**
-    @brief
-        Loads all opened files, while conforming to the restrictions given by the input ClassTreeMask.
-    @param mask
-        A ClassTreeMask, which defines which types of classes are loaded and which aren't.
-    @param bVerbose
-        Whether the loader is verbose (prints its progress in a low output level) or not.
-    @return
-        Returns true if successful.
-    */
-    bool Loader::load(const ClassTreeMask& mask, bool bVerbose)
-    {
-        bool success = true;
-        for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it)
-            if (!Loader::load(it->first, it->second * mask, bVerbose))
-                success = false;
-
-        return success;
-    }
-
-    void Loader::unload(const ClassTreeMask& mask)
-    {
-        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); )
-        {
-            if (mask.isIncluded(it->getIdentifier()))
-                (it++)->destroy();
-            else
-                ++it;
-        }
-    }
-
-    /**
-    @brief
-        Reloads all opened files, while conforming to the restrictions given by the input ClassTreeMask.
-    @param mask
-        A ClassTreeMask, which defines which types of classes are reloaded and which aren't.
-    @param bVerbose
-        Whether the loader is verbose (prints its progress in a low output level) or not.
-    @return
-        Returns true if successful.
-    */
-    bool Loader::reload(const ClassTreeMask& mask, bool bVerbose)
-    {
-        Loader::unload(mask);
-        return Loader::load(mask, bVerbose);
-    }
+    Loader* Loader::singletonPtr_s = 0;
 
     /**
@@ -156,5 +69,5 @@
             return false;
 
-        Loader::currentMask_s = file->getMask() * mask;
+        this->currentMask_ = file->getMask() * mask;
 
         std::string xmlInput;
@@ -189,5 +102,5 @@
                 // start of the program.
                 // Assumption: the LevelInfo tag does not use Lua scripting
-                xmlInput = removeLuaTags(xmlInput);
+                xmlInput = Loader::removeLuaTags(xmlInput);
             }
         }
@@ -198,10 +111,10 @@
             {
                 orxout(user_info) << "Start loading " << file->getFilename() << "..." << endl;
-                orxout(internal_info, context::loader) << "Mask: " << Loader::currentMask_s << endl;
+                orxout(internal_info, context::loader) << "Mask: " << this->currentMask_ << endl;
             }
             else
             {
                 orxout(verbose, context::loader) << "Start loading " << file->getFilename() << "..." << endl;
-                orxout(verbose_more, context::loader) << "Mask: " << Loader::currentMask_s << endl;
+                orxout(verbose_more, context::loader) << "Mask: " << this->currentMask_ << endl;
             }
 
@@ -220,5 +133,4 @@
             rootNamespace->setLoaderIndentation("    ");
             rootNamespace->setFile(file);
-            rootNamespace->setNamespace(rootNamespace);
             rootNamespace->setRoot(true);
             rootNamespace->XMLPort(rootElement, XMLPort::LoadObject);
@@ -303,22 +215,4 @@
                 ++it;
         }
-    }
-
-    /**
-    @brief
-        Reloads the input file, while conforming to the restrictions given by the input ClassTreeMask.
-    @param file
-        The file to be reloaded.
-    @param mask
-        A ClassTreeMask, which defines which types of classes are reloaded and which aren't.
-    @param bVerbose
-        Whether the loader is verbose (prints its progress in a low output level) or not.
-    @return
-        Returns true if successful.
-    */
-    bool Loader::reload(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose)
-    {
-        Loader::unload(file, mask);
-        return Loader::load(file, mask, bVerbose);
     }
 
Index: code/trunk/src/libraries/core/Loader.h
===================================================================
--- code/trunk/src/libraries/core/Loader.h	(revision 10622)
+++ code/trunk/src/libraries/core/Loader.h	(revision 10624)
@@ -44,36 +44,30 @@
 #include <map>
 #include <vector>
+
+#include "util/Singleton.h"
 #include "ClassTreeMask.h"
 
 namespace orxonox
 {
-    class _CoreExport Loader
+    class _CoreExport Loader : public Singleton<Loader>
     {
+        friend class Singleton<Loader>;
+
         public:
-            static bool open(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true);
-            static void close();
-            static void close(const XMLFile* file);
-
-            static void add(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
-            static void remove(const XMLFile* file);
-
-            static bool load(const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true);
-            static void unload(const ClassTreeMask& mask = ClassTreeMask());
-            static bool reload(const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true);
-
-            static bool load(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(),
-                             bool bVerbose = true, bool bRemoveLuaTags = false);
-            static void unload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
-            static bool reload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true);
+            bool load(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(),
+                      bool bVerbose = true, bool bRemoveLuaTags = false);
+            void unload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
 
             static std::string replaceLuaTags(const std::string& text);
             static std::string removeLuaTags(const std::string& text);
 
-            static ClassTreeMask currentMask_s;
+            ClassTreeMask currentMask_;
 
         private:
             static bool getLuaTags(const std::string& text, std::map<size_t, bool>& luaTags);
 
-            static std::vector<std::pair<const XMLFile*, ClassTreeMask> > files_s;
+            std::vector<std::pair<const XMLFile*, ClassTreeMask> > files_;
+
+            static Loader* singletonPtr_s;
     };
 }
Index: code/trunk/src/libraries/core/Namespace.cc
===================================================================
--- code/trunk/src/libraries/core/Namespace.cc	(revision 10622)
+++ code/trunk/src/libraries/core/Namespace.cc	(revision 10624)
@@ -47,5 +47,5 @@
         RegisterObject(Namespace);
 
-        this->setNamespace(SmartPtr<Namespace>(this, false));
+        this->setNamespace(WeakPtr<Namespace>(this)); // store a weak-pointer to itself (a strong-pointer would create a recursive dependency)
     }
 
@@ -105,5 +105,4 @@
     void Namespace::loadObjects(BaseObject* object)
     {
-        object->setNamespace(this);
     }
 
Index: code/trunk/src/libraries/core/PathConfig.cc
===================================================================
--- code/trunk/src/libraries/core/PathConfig.cc	(revision 10622)
+++ 	(revision )
@@ -1,324 +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 "PathConfig.h"
-
-#include <cassert>
-#include <cstdlib>
-#include <cstdio>
-#include <vector>
-#include <boost/filesystem.hpp>
-
-#ifdef ORXONOX_PLATFORM_WINDOWS
-#  ifndef WIN32_LEAN_AND_MEAN
-#    define WIN32_LEAN_AND_MEAN
-#  endif
-#  include <windows.h>
-#  undef min
-#  undef max
-#elif defined(ORXONOX_PLATFORM_APPLE)
-#  include <sys/param.h>
-#  include <mach-o/dyld.h>
-#else /* Linux */
-#  include <sys/types.h>
-#  include <unistd.h>
-#endif
-
-#include "SpecialConfig.h"
-#include "util/Output.h"
-#include "util/Exception.h"
-#include "config/CommandLineParser.h"
-
-// Differentiate Boost Filesystem v2 and v3
-#if (BOOST_FILESYSTEM_VERSION < 3)
-#  define BF_LEAF leaf
-#  define BF_GENERIC_STRING string
-#  define BF_NATIVE_STRING file_string
-#else
-#  define BF_LEAF path().filename().string
-#  define BF_GENERIC_STRING generic_string
-#  define BF_NATIVE_STRING string
-#endif
-
-namespace orxonox
-{
-    namespace bf = boost::filesystem;
-
-    //! Static pointer to the singleton
-    PathConfig* PathConfig::singletonPtr_s  = 0;
-
-    SetCommandLineArgument(externalDataPath, "").information("Path to the external data files");
-    SetCommandLineArgument(writingPathSuffix, "").information("Additional subfolder for config and log files");
-
-    PathConfig::PathConfig()
-        : rootPath_(*(new bf::path()))
-        , executablePath_(*(new bf::path()))
-        , modulePath_(*(new bf::path()))
-        , dataPath_(*(new bf::path()))
-        , externalDataPath_(*(new bf::path()))
-        , configPath_(*(new bf::path()))
-        , logPath_(*(new bf::path()))
-        , bBuildDirectoryRun_(false)
-    {
-        //////////////////////////
-        // FIND EXECUTABLE PATH //
-        //////////////////////////
-
-#ifdef ORXONOX_PLATFORM_WINDOWS
-        // get executable module
-        TCHAR buffer[1024];
-        if (GetModuleFileName(NULL, buffer, 1024) == 0)
-            ThrowException(General, "Could not retrieve executable path.");
-
-#elif defined(ORXONOX_PLATFORM_APPLE)
-        char buffer[1024];
-        uint32_t path_len = 1023;
-        if (_NSGetExecutablePath(buffer, &path_len))
-            ThrowException(General, "Could not retrieve executable path.");
-
-#else /* Linux */
-        /* written by Nicolai Haehnle <prefect_@gmx.net> */
-
-        /* Get our PID and build the name of the link in /proc */
-        char linkname[64]; /* /proc/<pid>/exe */
-        if (snprintf(linkname, sizeof(linkname), "/proc/%i/exe", getpid()) < 0)
-        {
-            /* This should only happen on large word systems. I'm not sure
-               what the proper response is here.
-               Since it really is an assert-like condition, aborting the
-               program seems to be in order. */
-            assert(false);
-        }
-
-        /* Now read the symbolic link */
-        char buffer[1024];
-        int ret;
-        ret = readlink(linkname, buffer, 1024);
-        /* In case of an error, leave the handling up to the caller */
-        if (ret == -1)
-            ThrowException(General, "Could not retrieve executable path.");
-
-        /* Ensure proper NUL termination */
-        buffer[ret] = 0;
-#endif
-
-        // Remove executable filename
-        executablePath_ = bf::path(buffer).branch_path();
-
-        /////////////////////
-        // SET MODULE PATH //
-        /////////////////////
-
-        if (bf::exists(executablePath_ / "orxonox_dev_build.keep_me"))
-        {
-            orxout(internal_info) << "Running from the build tree." << endl;
-            PathConfig::bBuildDirectoryRun_ = true;
-            modulePath_ = specialConfig::moduleDevDirectory;
-        }
-        else
-        {
-
-#ifdef INSTALL_COPYABLE // --> relative paths
-
-            // Also set the root path
-            bf::path relativeExecutablePath(specialConfig::defaultRuntimePath);
-            rootPath_ = executablePath_;
-            while (!bf::equivalent(rootPath_ / relativeExecutablePath, executablePath_) && !rootPath_.empty())
-                rootPath_ = rootPath_.branch_path();
-            if (rootPath_.empty())
-                ThrowException(General, "Could not derive a root directory. Might the binary installation directory contain '..' when taken relative to the installation prefix path?");
-
-            // Module path is fixed as well
-            modulePath_ = rootPath_ / specialConfig::defaultModulePath;
-
-#else
-
-            // There is no root path, so don't set it at all
-            // Module path is fixed as well
-            modulePath_ = specialConfig::moduleInstallDirectory;
-
-#endif
-        }
-    }
-
-    PathConfig::~PathConfig()
-    {
-        delete &rootPath_;
-        delete &executablePath_;
-        delete &modulePath_;
-        delete &dataPath_;
-        delete &externalDataPath_;
-        delete &configPath_;
-        delete &logPath_;
-    }
-
-    void PathConfig::setConfigurablePaths()
-    {
-        if (bBuildDirectoryRun_)
-        {
-            dataPath_         = specialConfig::dataDevDirectory;
-            configPath_       = specialConfig::configDevDirectory;
-            logPath_          = specialConfig::logDevDirectory;
-
-            // Check for data path override by the command line
-            if (!CommandLineParser::getArgument("externalDataPath")->hasDefaultValue())
-                externalDataPath_ = CommandLineParser::getValue("externalDataPath").get<std::string>();
-            else
-                externalDataPath_ = specialConfig::externalDataDevDirectory;
-        }
-        else
-        {
-
-#ifdef INSTALL_COPYABLE // --> relative paths
-
-            // Using paths relative to the install prefix, complete them
-            dataPath_   = rootPath_ / specialConfig::defaultDataPath;
-            configPath_ = rootPath_ / specialConfig::defaultConfigPath;
-            logPath_    = rootPath_ / specialConfig::defaultLogPath;
-
-#else
-
-            dataPath_  = specialConfig::dataInstallDirectory;
-
-            // Get user directory
-#ifdef ORXONOX_PLATFORM_UNIX
-            char* userDataPathPtr(getenv("HOME"));
-#else
-            char* userDataPathPtr(getenv("APPDATA"));
-#endif
-            if (userDataPathPtr == NULL)
-                ThrowException(General, "Could not retrieve user data path.");
-            bf::path userDataPath(userDataPathPtr);
-            userDataPath /= ".orxonox";
-
-            configPath_ = userDataPath / specialConfig::defaultConfigPath;
-            logPath_    = userDataPath / specialConfig::defaultLogPath;
-
-#endif
-
-        }
-
-        // Option to put all the config and log files in a separate folder
-        if (!CommandLineParser::getArgument("writingPathSuffix")->hasDefaultValue())
-        {
-            const std::string& directory(CommandLineParser::getValue("writingPathSuffix").get<std::string>());
-            configPath_ = configPath_ / directory;
-            logPath_    = logPath_    / directory;
-        }
-
-        // Create directories to avoid problems when opening files in non existent folders.
-        std::vector<std::pair<bf::path, std::string> > directories;
-        directories.push_back(std::make_pair(bf::path(configPath_), std::string("config")));
-        directories.push_back(std::make_pair(bf::path(logPath_), std::string("log")));
-
-        for (std::vector<std::pair<bf::path, std::string> >::iterator it = directories.begin();
-            it != directories.end(); ++it)
-        {
-            if (bf::exists(it->first) && !bf::is_directory(it->first))
-            {
-                ThrowException(General, std::string("The ") + it->second + " directory has been preoccupied by a file! \
-                                         Please remove " + it->first.BF_GENERIC_STRING());
-            }
-            if (bf::create_directories(it->first)) // function may not return true at all (bug?)
-            {
-                orxout(internal_info) << "Created " << it->second << " directory" << endl;
-            }
-        }
-    }
-
-    std::vector<std::string> PathConfig::getModulePaths()
-    {
-        std::vector<std::string> modulePaths;
-
-        // We search for helper files with the following extension
-        const std::string& moduleextension = specialConfig::moduleExtension;
-        size_t moduleextensionlength = moduleextension.size();
-
-        // Make sure the path exists, otherwise don't load modules
-        if (!boost::filesystem::exists(modulePath_))
-            return modulePaths;
-
-        boost::filesystem::directory_iterator file(modulePath_);
-        boost::filesystem::directory_iterator end;
-
-        // Iterate through all files
-        while (file != end)
-        {
-            std::string filename = file->BF_LEAF();
-
-            // Check if the file ends with the extension in question
-            if (filename.size() > moduleextensionlength)
-            {
-                if (filename.substr(filename.size() - moduleextensionlength) == moduleextension)
-                {
-                    // We've found a helper file
-                    const std::string& library = filename.substr(0, filename.size() - moduleextensionlength);
-                    modulePaths.push_back(getModulePathString() + library);
-                }
-            }
-            ++file;
-        }
-
-        return modulePaths;
-    }
-
-    /*static*/ std::string PathConfig::getRootPathString()
-    {
-        return getInstance().rootPath_.BF_GENERIC_STRING() + '/';
-    }
-
-    /*static*/ std::string PathConfig::getExecutablePathString()
-    {
-        return getInstance().executablePath_.BF_GENERIC_STRING() + '/';
-    }
-
-    /*static*/ std::string PathConfig::getDataPathString()
-    {
-        return getInstance().dataPath_.BF_GENERIC_STRING() + '/';
-    }
-
-    /*static*/ std::string PathConfig::getExternalDataPathString()
-    {
-        return getInstance().externalDataPath_.BF_GENERIC_STRING() + '/';
-    }
-
-    /*static*/ std::string PathConfig::getConfigPathString()
-    {
-        return getInstance().configPath_.BF_GENERIC_STRING() + '/';
-    }
-
-    /*static*/ std::string PathConfig::getLogPathString()
-    {
-        return getInstance().logPath_.BF_GENERIC_STRING() + '/';
-    }
-
-    /*static*/ std::string PathConfig::getModulePathString()
-    {
-        return getInstance().modulePath_.BF_GENERIC_STRING() + '/';
-    }
-}
Index: code/trunk/src/libraries/core/PathConfig.h
===================================================================
--- code/trunk/src/libraries/core/PathConfig.h	(revision 10622)
+++ 	(revision )
@@ -1,145 +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:
- *      ...
- *
- */
-
-/**
-    @file
-    @ingroup Management Resources
-*/
-
-#ifndef _PathConfig_H__
-#define _PathConfig_H__
-
-#include "CorePrereqs.h"
-
-#include <string>
-#include <vector>
-#include "util/Singleton.h"
-
-//tolua_begin
-namespace orxonox
-{
-//tolua_end
-    /**
-    @brief
-        The PathConfig class is a singleton used to configure different paths.
-    @details
-        The class provides information about the data, config, log, executable,
-        root and module path.
-        It determines those by the use of platform specific functions.
-    @remarks
-        Not all paths are always available:
-        - root only when installed copyable
-        - externalData only for development builds in the build tree
-    */
-    class _CoreExport PathConfig //tolua_export
-        : public Singleton<PathConfig>
-    { //tolua_export
-        friend class Singleton<PathConfig>;
-        friend class Core;
-
-        public:
-            /**
-            @brief
-                Retrieves the executable path and sets all hard coded fixed paths (currently only the module path)
-                Also checks for "orxonox_dev_build.keep_me" in the executable diretory.
-                If found it means that this is not an installed run, hence we
-                don't write the logs and config files to ~/.orxonox
-            @throw
-                GeneralException
-            */
-            PathConfig();
-            ~PathConfig();
-
-            //! Returns the path to the root folder as boost::filesystem::path
-            static const boost::filesystem::path& getRootPath()
-                { return getInstance().rootPath_; }
-            //! Returns the path to the executable folder as boost::filesystem::path
-            static const boost::filesystem::path& getExecutablePath()
-                { return getInstance().executablePath_; }
-            //! Returns the path to the data files as boost::filesystem::path
-            static const boost::filesystem::path& getDataPath()
-                { return getInstance().dataPath_; }
-            //! Returns the path to the external data files as boost::filesystem::path
-            static const boost::filesystem::path& getExternalDataPath()
-                { return getInstance().externalDataPath_; }
-            //! Returns the path to the config files as boost::filesystem::path
-            static const boost::filesystem::path& getConfigPath()
-                { return getInstance().configPath_; }
-            //! Returns the path to the log files as boost::filesystem::path
-            static const boost::filesystem::path& getLogPath()
-                { return getInstance().logPath_; }
-            //! Returns the path to the modules as boost::filesystem::path
-            static const boost::filesystem::path& getModulePath()
-                { return getInstance().modulePath_; }
-
-            //! Returns the path to the root folder as std::string
-            static std::string getRootPathString();
-            //! Returns the path to the executable folder as std::string
-            static std::string getExecutablePathString();
-            //! Returns the path to the data files as std::string
-            static std::string getDataPathString();
-            //! Returns the path to the external data files as std::string
-            static std::string getExternalDataPathString();
-            //! Returns the path to the config files as std::string
-            static std::string getConfigPathString(); //tolua_export
-            //! Returns the path to the log files as std::string
-            static std::string getLogPathString();
-            //! Returns the path to the modules as std::string
-            static std::string getModulePathString();
-
-            //! Return true for runs in the build directory (not installed)
-            static bool buildDirectoryRun() { return getInstance().bBuildDirectoryRun_; }
-
-        private:
-            PathConfig(const PathConfig&); //!< Don't use (undefined symbol)
-
-            /**
-            @brief
-                Sets config, log and media path and creates the folders if necessary.
-            @throws
-                GeneralException
-            */
-            void setConfigurablePaths();
-            //! Returns a list with all modules declared by a *.module file in the module folder.
-            std::vector<std::string> getModulePaths();
-
-            //! Path to the parent directory of the ones above if program was installed with relative paths
-            boost::filesystem::path& rootPath_;
-            boost::filesystem::path& executablePath_;        //!< Path to the executable
-            boost::filesystem::path& modulePath_;            //!< Path to the modules
-            boost::filesystem::path& dataPath_;              //!< Path to the data files folder
-            boost::filesystem::path& externalDataPath_;      //!< Path to the external data files folder
-            boost::filesystem::path& configPath_;            //!< Path to the config files folder
-            boost::filesystem::path& logPath_;               //!< Path to the log files folder
-
-            bool                     bBuildDirectoryRun_;    //!< True for runs in the build directory (not installed)
-            static PathConfig* singletonPtr_s;
-    }; //tolua_export
-} //tolua_export
-
-#endif /* _PathConfig_H__ */
Index: code/trunk/src/libraries/core/UpdateListener.cc
===================================================================
--- code/trunk/src/libraries/core/UpdateListener.cc	(revision 10624)
+++ code/trunk/src/libraries/core/UpdateListener.cc	(revision 10624)
@@ -0,0 +1,40 @@
+/*
+ *   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 "UpdateListener.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+    RegisterAbstractClass(UpdateListener).inheritsFrom<Listable>();
+
+    UpdateListener::UpdateListener()
+    {
+        RegisterObject(UpdateListener);
+    }
+}
Index: code/trunk/src/libraries/core/UpdateListener.h
===================================================================
--- code/trunk/src/libraries/core/UpdateListener.h	(revision 10624)
+++ code/trunk/src/libraries/core/UpdateListener.h	(revision 10624)
@@ -0,0 +1,64 @@
+/*
+ *   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 _UpdateListener_H__
+#define _UpdateListener_H__
+
+#include "core/CorePrereqs.h"
+
+#include "core/object/Listable.h"
+
+namespace orxonox
+{
+    /**
+     * Inherit from UpdateListener if you need to receive calls before or after the game is ticked. All classes inheriting from UpdateListener
+     * need to be strictly independent of each other and may not rely on a specific order in which all UpdateListeners are called.
+     *
+     * If you do have such a dependency between two UpdateListeners, e.g. A::preUpdate() always needs to be called before B::preUpdate(), then
+     * you need to create a third class C (which inherits from UpdateListener) with the following implementation:
+     * void C::preUpdate()
+     * {
+     *     A::preUpdate();
+     *     B::preUpdate();
+     * }
+     * This is the only way to ensure that A gets called before B. In this example, only C inherits from UpdateListener, while A and B do not.
+     * Instead they receive the update from C.
+     */
+    class _CoreExport UpdateListener : virtual public Listable
+    {
+        public:
+            UpdateListener();
+
+            /// Gets called by Core before the framework is ticked.
+            virtual void preUpdate(const Clock& time) = 0;
+            /// Gets called by Core after the framework was ticked (but before graphics are drawn).
+            virtual void postUpdate(const Clock& time) = 0;
+    };
+}
+
+#endif /* _UpdateListener_H__ */
Index: code/trunk/src/libraries/core/ViewportEventListener.cc
===================================================================
--- code/trunk/src/libraries/core/ViewportEventListener.cc	(revision 10622)
+++ code/trunk/src/libraries/core/ViewportEventListener.cc	(revision 10624)
@@ -32,5 +32,5 @@
 namespace orxonox
 {
-    RegisterAbstractClass(ViewportEventListener).inheritsFrom(Class(Listable));
+    RegisterAbstractClass(ViewportEventListener).inheritsFrom<Listable>();
 
     ViewportEventListener::ViewportEventListener()
Index: code/trunk/src/libraries/core/WindowEventListener.cc
===================================================================
--- code/trunk/src/libraries/core/WindowEventListener.cc	(revision 10622)
+++ code/trunk/src/libraries/core/WindowEventListener.cc	(revision 10624)
@@ -35,5 +35,5 @@
     unsigned int WindowEventListener::windowHeight_s = 0;
 
-    RegisterAbstractClass(WindowEventListener).inheritsFrom(Class(Listable));
+    RegisterAbstractClass(WindowEventListener).inheritsFrom<Listable>();
 
     WindowEventListener::WindowEventListener()
Index: code/trunk/src/libraries/core/XMLNameListener.cc
===================================================================
--- code/trunk/src/libraries/core/XMLNameListener.cc	(revision 10622)
+++ code/trunk/src/libraries/core/XMLNameListener.cc	(revision 10624)
@@ -32,5 +32,5 @@
 namespace orxonox
 {
-    RegisterAbstractClass(XMLNameListener).inheritsFrom(Class(Listable));
+    RegisterAbstractClass(XMLNameListener).inheritsFrom<Listable>();
 
     XMLNameListener::XMLNameListener()
Index: code/trunk/src/libraries/core/XMLPort.cc
===================================================================
--- code/trunk/src/libraries/core/XMLPort.cc	(revision 10622)
+++ code/trunk/src/libraries/core/XMLPort.cc	(revision 10624)
@@ -40,5 +40,5 @@
     bool XMLPortObjectContainer::identifierIsIncludedInLoaderMask(const Identifier* identifier)
     {
-        return ((!this->bApplyLoaderMask_) || identifier->isA(ClassIdentifier<Namespace>::getIdentifier()) || Loader::currentMask_s.isIncluded(identifier));
+        return ((!this->bApplyLoaderMask_) || identifier->isA(ClassIdentifier<Namespace>::getIdentifier()) || Loader::getInstance().currentMask_.isIncluded(identifier));
     }
 
Index: code/trunk/src/libraries/core/class/Identifiable.cc
===================================================================
--- code/trunk/src/libraries/core/class/Identifiable.cc	(revision 10622)
+++ code/trunk/src/libraries/core/class/Identifiable.cc	(revision 10624)
@@ -41,5 +41,5 @@
 namespace orxonox
 {
-    RegisterClassNoArgs(Identifiable);
+    RegisterClassNoArgs(Identifiable).virtualBase();
 
     /**
Index: code/trunk/src/libraries/core/class/Identifier.cc
===================================================================
--- code/trunk/src/libraries/core/class/Identifier.cc	(revision 10622)
+++ code/trunk/src/libraries/core/class/Identifier.cc	(revision 10624)
@@ -44,4 +44,6 @@
 namespace orxonox
 {
+    bool Identifier::initConfigValues_s = true;
+
     // ###############################
     // ###       Identifier        ###
@@ -50,10 +52,16 @@
         @brief Constructor: No factory, no object created, new ObjectList and a unique networkID.
     */
-    Identifier::Identifier()
-        : classID_(IdentifierManager::getInstance().getUniqueClassId())
-    {
-        this->factory_ = 0;
+    Identifier::Identifier(const std::string& name, Factory* factory, bool bLoadable)
+    {
+        orxout(verbose, context::identifier) << "Create identifier for " << name << endl;
+
+        static unsigned int classIDCounter = 0;
+
+        this->classID_ = classIDCounter++;
+        this->name_ = name;
+        this->factory_ = factory;
+        this->bLoadable_ = bLoadable;
         this->bInitialized_ = false;
-        this->bLoadable_ = false;
+        this->bIsVirtualBase_ = false;
 
         this->bHasConfigValues_ = false;
@@ -71,4 +79,17 @@
             delete this->factory_;
 
+        for (std::list<const InheritsFrom*>::const_iterator it = this->manualDirectParents_.begin(); it != this->manualDirectParents_.end(); ++it)
+            delete (*it);
+
+        // erase this Identifier from all related identifiers
+        for (std::list<const Identifier*>::const_iterator it = this->parents_.begin(); it != this->parents_.end(); ++it)
+            const_cast<Identifier*>(*it)->children_.erase(this);
+        for (std::list<const Identifier*>::const_iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it)
+            const_cast<Identifier*>(*it)->directChildren_.erase(this);
+        for (std::set<const Identifier*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ++it)
+            const_cast<Identifier*>(*it)->parents_.remove(this);
+        for (std::set<const Identifier*>::const_iterator it = this->directChildren_.begin(); it != this->directChildren_.end(); ++it)
+            const_cast<Identifier*>(*it)->directParents_.remove(this);
+
         for (std::map<std::string, ConfigValueContainer*>::iterator it = this->configValues_.begin(); it != this->configValues_.end(); ++it)
             delete (it->second);
@@ -77,24 +98,4 @@
         for (std::map<std::string, XMLPortObjectContainer*>::iterator it = this->xmlportObjectContainers_.begin(); it != this->xmlportObjectContainers_.end(); ++it)
             delete (it->second);
-    }
-
-    /**
-        @brief Sets the name of the class.
-    */
-    void Identifier::setName(const std::string& name)
-    {
-        if (name != this->name_)
-        {
-            this->name_ = name;
-            IdentifierManager::getInstance().addIdentifierToLookupMaps(this);
-        }
-    }
-
-    void Identifier::setFactory(Factory* factory)
-    {
-        if (this->factory_)
-            delete this->factory_;
-
-        this->factory_ = factory;
     }
 
@@ -126,5 +127,5 @@
     {
         this->networkID_ = id;
-        IdentifierManager::getInstance().addIdentifierToLookupMaps(this);
+        IdentifierManager::getInstance().addIdentifier(this);    // add with new id
     }
 
@@ -132,10 +133,10 @@
      * @brief Used to define the direct parents of an Identifier of an abstract class.
      */
-    Identifier& Identifier::inheritsFrom(Identifier* directParent)
-    {
-        if (this->parents_.empty())
-            this->directParents_.insert(directParent);
-        else
-            orxout(internal_error) << "Trying to add " << directParent->getName() << " as a direct parent of " << this->getName() << " after the latter was already initialized" << endl;
+    Identifier& Identifier::inheritsFrom(InheritsFrom* directParent)
+    {
+        if (this->directParents_.empty())
+            this->manualDirectParents_.push_back(directParent);
+        else
+            orxout(internal_error) << "Trying to manually add direct parent of " << this->getName() << " after the latter was already initialized" << endl;
 
         return *this;
@@ -144,7 +145,7 @@
     /**
      * @brief Initializes the parents of this Identifier while creating the class hierarchy.
-     * @param identifiers All identifiers that were used to create an instance of this class (including this identifier itself)
-     */
-    void Identifier::initializeParents(const std::set<const Identifier*>& identifiers)
+     * @param initializationTrace All identifiers that were recorded while creating an instance of this class (including nested classes and this identifier itself)
+     */
+    void Identifier::initializeParents(const std::list<const Identifier*>& initializationTrace)
     {
         if (!IdentifierManager::getInstance().isCreatingHierarchy())
@@ -154,67 +155,78 @@
         }
 
-        for (std::set<const Identifier*>::const_iterator it = identifiers.begin(); it != identifiers.end(); ++it)
-            if (*it != this)
-                this->parents_.insert(*it);
-    }
-
-    /**
-     * @brief Initializes the direct parents of this Identifier while creating the class hierarchy. This is only intended for abstract classes.
-     */
-    void Identifier::initializeDirectParentsOfAbstractClass()
+        if (this->directParents_.empty())
+        {
+            for (std::list<const Identifier*>::const_iterator it = initializationTrace.begin(); it != initializationTrace.end(); ++it)
+                if (*it != this)
+                    this->parents_.push_back(*it);
+        }
+        else
+            orxout(internal_error) << "Trying to add parents to " << this->getName() << " after it was already initialized with manual calls to inheritsFrom<Class>()." << endl;
+    }
+
+    /**
+     * @brief Finishes the initialization of this Identifier after creating the class hierarchy by wiring the (direct) parent/child references correctly.
+     */
+    void Identifier::finishInitialization()
     {
         if (!IdentifierManager::getInstance().isCreatingHierarchy())
         {
-            orxout(internal_warning) << "Identifier::initializeDirectParentsOfAbstractClass() created outside of class hierarchy creation" << endl;
+            orxout(internal_warning) << "Identifier::finishInitialization() created outside of class hierarchy creation" << endl;
             return;
         }
 
-        // only Identifiable is allowed to have no parents (even tough it's currently not abstract)
-        if (this->directParents_.empty() && !this->isExactlyA(Class(Identifiable)))
-        {
-            orxout(internal_error) << "Identifier " << this->getName() << " / " << this->getTypeidName() << " is marked as abstract but has no direct parents defined" << endl;
+        if (this->isInitialized())
+            return;
+
+        if (!this->parents_.empty())
+        {
+            // parents defined -> this class was initialized by creating a sample instance and recording the trace of identifiers
+
+            // initialize all parents
+            for (std::list<const Identifier*>::const_iterator it = this->parents_.begin(); it != this->parents_.end(); ++it)
+                const_cast<Identifier*>(*it)->finishInitialization(); // initialize parent
+
+            // parents of parents are no direct parents of this identifier
+            this->directParents_ = this->parents_;
+            for (std::list<const Identifier*>::const_iterator it_parent = this->parents_.begin(); it_parent != this->parents_.end(); ++it_parent)
+                for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent)
+                    this->directParents_.remove(*it_parent_parent);
+
+            this->verifyIdentifierTrace();
+        }
+        else if (!this->manualDirectParents_.empty())
+        {
+            // no parents defined -> this class was manually initialized by calling inheritsFrom<Class>()
+
+            // initialize all direct parents
+            for (std::list<const InheritsFrom*>::const_iterator it = this->manualDirectParents_.begin(); it != this->manualDirectParents_.end(); ++it)
+            {
+                Identifier* directParent = (*it)->getParent();
+                this->directParents_.push_back(directParent);
+                directParent->finishInitialization(); // initialize parent
+            }
+
+            // direct parents and their parents are also parents of this identifier (but only add them once)
+            for (std::list<const Identifier*>::const_iterator it_parent = this->directParents_.begin(); it_parent != this->directParents_.end(); ++it_parent)
+            {
+                for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent)
+                    this->addIfNotExists(this->parents_, *it_parent_parent);
+                this->addIfNotExists(this->parents_, *it_parent);
+            }
+        }
+        else if (!this->isExactlyA(Class(Identifiable)))
+        {
+            // only Identifiable is allowed to have no parents (even tough it's currently not abstract)
+            orxout(internal_error) << "Identifier " << this->getName() << " / " << this->getTypeInfo().name() << " is marked as abstract but has no direct parents defined" << endl;
             orxout(internal_error) << "  If this class is not abstract, use RegisterClass(ThisClass);" << endl;
             orxout(internal_error) << "  If this class is abstract, use RegisterAbstractClass(ThisClass).inheritsFrom(Class(BaseClass));" << endl;
         }
-    }
-
-    /**
-     * @brief Finishes the initialization of this Identifier after creating the class hierarchy by wiring the (direct) parent/child references correctly.
-     */
-    void Identifier::finishInitialization()
-    {
-        if (!IdentifierManager::getInstance().isCreatingHierarchy())
-        {
-            orxout(internal_warning) << "Identifier::finishInitialization() created outside of class hierarchy creation" << endl;
-            return;
-        }
-
-        if (this->isInitialized())
-            return;
-
-        // if no direct parents were defined, initialize them with the set of all parents
-        if (this->directParents_.empty())
-            this->directParents_ = this->parents_;
-
-        // initialize all parents before continuing to initialize this identifier
-        for (std::set<const Identifier*>::const_iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it)
-        {
-            Identifier* directParent = const_cast<Identifier*>(*it);
-            directParent->finishInitialization(); // initialize parent
-            this->parents_.insert(directParent);  // direct parent is also a parent
-            this->parents_.insert(directParent->parents_.begin(), directParent->parents_.end()); // parents of direct parent are also parents
-        }
-
-        // parents of parents are no direct parents of this identifier
-        for (std::set<const Identifier*>::const_iterator it_parent = this->parents_.begin(); it_parent != this->parents_.end(); ++it_parent)
-            for (std::set<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent)
-                this->directParents_.erase(*it_parent_parent);
 
         // tell all parents that this identifier is a child
-        for (std::set<const Identifier*>::const_iterator it = this->parents_.begin(); it != this->parents_.end(); ++it)
+        for (std::list<const Identifier*>::const_iterator it = this->parents_.begin(); it != this->parents_.end(); ++it)
             const_cast<Identifier*>(*it)->children_.insert(this);
 
         // tell all direct parents that this identifier is a direct child
-        for (std::set<const Identifier*>::const_iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it)
+        for (std::list<const Identifier*>::const_iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it)
         {
             const_cast<Identifier*>(*it)->directChildren_.insert(this);
@@ -228,4 +240,75 @@
 
     /**
+     * Resets all information about the class hierarchy. The identifier is considered uninitialized afterwards.
+     */
+    void Identifier::reset()
+    {
+        this->directParents_.clear();
+        this->parents_.clear();
+        this->directChildren_.clear();
+        this->children_.clear();
+        this->bInitialized_ = false;
+    }
+
+    /**
+     * Verifies if the recorded trace of parent identifiers matches the expected trace according to the class hierarchy. If it doesn't match, the class
+     * hierarchy is likely wrong, e.g. due to wrong inheritsFrom<>() definitions in abstract classes.
+     */
+    void Identifier::verifyIdentifierTrace() const
+    {
+
+        std::list<const Identifier*> expectedIdentifierTrace;
+
+        // if any parent class is virtual, it will be instantiated first, so we need to add them first.
+        for (std::list<const Identifier*>::const_iterator it_parent = this->parents_.begin(); it_parent != this->parents_.end(); ++it_parent)
+        {
+            if ((*it_parent)->isVirtualBase())
+            {
+                for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent)
+                    this->addIfNotExists(expectedIdentifierTrace, *it_parent_parent);
+                this->addIfNotExists(expectedIdentifierTrace, *it_parent);
+            }
+        }
+
+        // now all direct parents get created recursively. already added identifiers (e.g. virtual base classes) are not added again.
+        for (std::list<const Identifier*>::const_iterator it_parent = this->directParents_.begin(); it_parent != this->directParents_.end(); ++it_parent)
+        {
+            for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent)
+                this->addIfNotExists(expectedIdentifierTrace, *it_parent_parent);
+            this->addIfNotExists(expectedIdentifierTrace, *it_parent);
+        }
+
+        // check if the expected trace matches the actual trace (which was defined by creating a sample instance)
+        if (expectedIdentifierTrace != this->parents_)
+        {
+            orxout(internal_warning) << this->getName() << " has an unexpected initialization trace:" << endl;
+
+            orxout(internal_warning) << "  Actual trace (after creating a sample instance):" << endl << "    ";
+            for (std::list<const Identifier*>::const_iterator it_parent = this->parents_.begin(); it_parent != this->parents_.end(); ++it_parent)
+                orxout(internal_warning) << " " << (*it_parent)->getName();
+            orxout(internal_warning) << endl;
+
+            orxout(internal_warning) << "  Expected trace (according to class hierarchy definitions):" << endl << "    ";
+            for (std::list<const Identifier*>::const_iterator it_parent = expectedIdentifierTrace.begin(); it_parent != expectedIdentifierTrace.end(); ++it_parent)
+                orxout(internal_warning) << " " << (*it_parent)->getName();
+            orxout(internal_warning) << endl;
+
+            orxout(internal_warning) << "  Direct parents (according to class hierarchy definitions):" << endl << "    ";
+            for (std::list<const Identifier*>::const_iterator it_parent = this->directParents_.begin(); it_parent != this->directParents_.end(); ++it_parent)
+                orxout(internal_warning) << " " << (*it_parent)->getName();
+            orxout(internal_warning) << endl;
+        }
+    }
+
+    /**
+     * Adds @param identifierToAdd to @param list if this identifier is not already contained in the list.
+     */
+    void Identifier::addIfNotExists(std::list<const Identifier*>& list, const Identifier* identifierToAdd) const
+    {
+        if (std::find(list.begin(), list.end(), identifierToAdd) == list.end())
+            list.push_back(identifierToAdd);
+    }
+
+    /**
         @brief Returns true, if the Identifier is at least of the given type.
         @param identifier The identifier to compare with
@@ -233,5 +316,5 @@
     bool Identifier::isA(const Identifier* identifier) const
     {
-        return (identifier == this || (this->parents_.find(identifier) != this->parents_.end()));
+        return (identifier == this || (this->isChildOf(identifier)));
     }
 
@@ -251,5 +334,5 @@
     bool Identifier::isChildOf(const Identifier* identifier) const
     {
-        return (this->parents_.find(identifier) != this->parents_.end());
+        return (std::find(this->parents_.begin(), this->parents_.end(),  identifier) != this->parents_.end());
     }
 
@@ -260,5 +343,5 @@
     bool Identifier::isDirectChildOf(const Identifier* identifier) const
     {
-        return (this->directParents_.find(identifier) != this->directParents_.end());
+        return (std::find(this->directParents_.begin(), this->directParents_.end(), identifier) != this->directParents_.end());
     }
 
Index: code/trunk/src/libraries/core/class/Identifier.h
===================================================================
--- code/trunk/src/libraries/core/class/Identifier.h	(revision 10622)
+++ code/trunk/src/libraries/core/class/Identifier.h	(revision 10624)
@@ -80,6 +80,9 @@
 #include <typeinfo>
 #include <loki/TypeTraits.h>
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_base_of.hpp>
 
 #include "util/Output.h"
+#include "util/OrxAssert.h"
 #include "core/object/ObjectList.h"
 #include "core/object/Listable.h"
@@ -109,5 +112,12 @@
     {
         public:
-            Identifier();
+            struct InheritsFrom //! helper class to manually define inheritance
+            {
+                virtual ~InheritsFrom() {}
+                virtual Identifier* getParent() const = 0;
+            };
+
+        public:
+            Identifier(const std::string& name, Factory* factory, bool bLoadable);
             Identifier(const Identifier& identifier); // don't copy
             virtual ~Identifier();
@@ -115,8 +125,7 @@
             /// Returns the name of the class the Identifier belongs to.
             inline const std::string& getName() const { return this->name_; }
-            void setName(const std::string& name);
-
-            /// Returns the name of the class as it is returned by typeid(T).name()
-            virtual const std::string& getTypeidName() = 0;
+
+            /// Returns the type_info of the class as it is returned by typeid(T)
+            virtual const std::type_info& getTypeInfo() = 0;
 
             /// Returns the network ID to identify a class through the network.
@@ -127,6 +136,4 @@
             ORX_FORCEINLINE unsigned int getClassID() const { return this->classID_; }
 
-            /// Sets the Factory.
-            void setFactory(Factory* factory);
             /// Returns true if the Identifier has a Factory.
             inline bool hasFactory() const { return (this->factory_ != 0); }
@@ -136,9 +143,18 @@
             /// Returns true if the class can be loaded through XML.
             inline bool isLoadable() const { return this->bLoadable_; }
-            /// Set the class to be loadable through XML or not.
-            inline void setLoadable(bool bLoadable) { this->bLoadable_ = bLoadable; }
+
+            /// Returns true if child classes should inherit virtually from this class.
+            inline bool isVirtualBase() const { return this->bIsVirtualBase_; }
+            /// Defines if child classes should inherit virtually from this class.
+            inline void setVirtualBase(bool bIsVirtualBase) { this->bIsVirtualBase_ = bIsVirtualBase; }
 
             /// Returns true if the Identifier was completely initialized.
             inline bool isInitialized() const { return this->bInitialized_; }
+
+            virtual void destroyObjects() = 0;
+
+            virtual bool canDynamicCastObjectToIdentifierClass(Identifiable* object) const = 0;
+
+            static bool initConfigValues_s; // TODO: this is a hack - remove it as soon as possible
 
 
@@ -146,9 +162,9 @@
             ////// Class Hierarchy //////
             /////////////////////////////
-            Identifier& inheritsFrom(Identifier* directParent);
-
-            void initializeParents(const std::set<const Identifier*>& identifiers);
-            void initializeDirectParentsOfAbstractClass();
+            Identifier& inheritsFrom(InheritsFrom* directParent);
+
+            void initializeParents(const std::list<const Identifier*>& initializationTrace);
             void finishInitialization();
+            void reset();
 
             bool isA(const Identifier* identifier) const;
@@ -159,31 +175,13 @@
             bool isDirectParentOf(const Identifier* identifier) const;
 
+            /// Returns the direct parents of the class the Identifier belongs to.
+            inline const std::list<const Identifier*>& getDirectParents() const { return this->directParents_; }
             /// Returns the parents of the class the Identifier belongs to.
-            inline const std::set<const Identifier*>& getParents() const { return this->parents_; }
-            /// Returns the begin-iterator of the parents-list.
-            inline std::set<const Identifier*>::const_iterator getParentsBegin() const { return this->parents_.begin(); }
-            /// Returns the end-iterator of the parents-list.
-            inline std::set<const Identifier*>::const_iterator getParentsEnd() const { return this->parents_.end(); }
-
+            inline const std::list<const Identifier*>& getParents() const { return this->parents_; }
+
+            /// Returns the direct children the class the Identifier belongs to.
+            inline const std::set<const Identifier*>& getDirectChildren() const { return this->directChildren_; }
             /// Returns the children of the class the Identifier belongs to.
             inline const std::set<const Identifier*>& getChildren() const { return this->children_; }
-            /// Returns the begin-iterator of the children-list.
-            inline std::set<const Identifier*>::const_iterator getChildrenBegin() const { return this->children_.begin(); }
-            /// Returns the end-iterator of the children-list.
-            inline std::set<const Identifier*>::const_iterator getChildrenEnd() const { return this->children_.end(); }
-
-            /// Returns the direct parents of the class the Identifier belongs to.
-            inline const std::set<const Identifier*>& getDirectParents() const { return this->directParents_; }
-            /// Returns the begin-iterator of the direct-parents-list.
-            inline std::set<const Identifier*>::const_iterator getDirectParentsBegin() const { return this->directParents_.begin(); }
-            /// Returns the end-iterator of the direct-parents-list.
-            inline std::set<const Identifier*>::const_iterator getDirectParentsEnd() const { return this->directParents_.end(); }
-
-            /// Returns the direct children the class the Identifier belongs to.
-            inline const std::set<const Identifier*>& getDirectChildren() const { return this->directChildren_; }
-            /// Returns the begin-iterator of the direct-children-list.
-            inline std::set<const Identifier*>::const_iterator getDirectChildrenBegin() const { return this->directChildren_.begin(); }
-            /// Returns the end-iterator of the direct-children-list.
-            inline std::set<const Identifier*>::const_iterator getDirectChildrenEnd() const { return this->directChildren_.end(); }
 
 
@@ -223,21 +221,25 @@
             XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname);
 
-
         protected:
             virtual void createSuperFunctionCaller() const = 0;
 
         private:
-            std::set<const Identifier*> parents_;                          //!< The parents of the class the Identifier belongs to
+            void verifyIdentifierTrace() const;
+            void addIfNotExists(std::list<const Identifier*>& list, const Identifier* identifierToAdd) const;
+
+            std::list<const InheritsFrom*> manualDirectParents_;            //!< Manually defined direct parents
+            std::list<const Identifier*> directParents_;                    //!< The direct parents of the class the Identifier belongs to (sorted by their order of initialization)
+            std::list<const Identifier*> parents_;                          //!< The parents of the class the Identifier belongs to (sorted by their order of initialization)
+
+            std::set<const Identifier*> directChildren_;                   //!< The direct children of the class the Identifier belongs to
             std::set<const Identifier*> children_;                         //!< The children of the class the Identifier belongs to
-
-            std::set<const Identifier*> directParents_;                    //!< The direct parents of the class the Identifier belongs to
-            std::set<const Identifier*> directChildren_;                   //!< The direct children of the class the Identifier belongs to
 
             bool bInitialized_;                                            //!< Is true if the Identifier was completely initialized
             bool bLoadable_;                                               //!< False = it's not permitted to load the object through XML
+            bool bIsVirtualBase_;                                          //!< If true, it is recommended to inherit virtually from this class. This changes the order of initialization of child classes, thus this information is necessary to check the class hierarchy.
             std::string name_;                                             //!< The name of the class the Identifier belongs to
             Factory* factory_;                                             //!< The Factory, able to create new objects of the given class (if available)
             uint32_t networkID_;                                           //!< The network ID to identify a class through the network
-            const unsigned int classID_;                                   //!< Uniquely identifies a class (might not be the same as the networkID_)
+            unsigned int classID_;                                         //!< Uniquely identifies a class (might not be the same as the networkID_)
 
             bool bHasConfigValues_;                                        //!< True if this class has at least one assigned config value
@@ -267,4 +269,6 @@
     class ClassIdentifier : public Identifier
     {
+        BOOST_STATIC_ASSERT((boost::is_base_of<Identifiable, T>::value));
+
         #ifndef DOXYGEN_SHOULD_SKIP_THIS
           #define SUPER_INTRUSIVE_DECLARATION_INCLUDE
@@ -273,27 +277,9 @@
 
         public:
-            static ClassIdentifier<T>* getIdentifier();
-            static ClassIdentifier<T>* getIdentifier(const std::string& name);
-
-            bool initializeObject(T* object);
-
-            void setConfigValues(T* object, Configurable*) const;
-            void setConfigValues(T* object, Identifiable*) const;
-
-            void addObjectToList(T* object, Listable*);
-            void addObjectToList(T* object, Identifiable*);
-
-            virtual void updateConfigValues(bool updateChildren = true) const;
-
-            virtual const std::string& getTypeidName()
-                { return this->typeidName_; }
-
-        private:
-            static void initializeIdentifier();
-
-            ClassIdentifier(const ClassIdentifier<T>& identifier) {}    // don't copy
-            ClassIdentifier()
+            ClassIdentifier(const std::string& name, Factory* factory, bool bLoadable) : Identifier(name, factory, bLoadable)
             {
-                this->typeidName_ = typeid(T).name();
+                OrxVerify(ClassIdentifier<T>::classIdentifier_s == NULL, "Assertion failed in ClassIdentifier of type " << typeid(T).name());
+                ClassIdentifier<T>::classIdentifier_s = this;
+
                 SuperFunctionInitialization<0, T>::initialize(this);
             }
@@ -303,8 +289,36 @@
             }
 
+            bool initializeObject(T* object);
+
+            virtual void updateConfigValues(bool updateChildren = true) const;
+
+            virtual const std::type_info& getTypeInfo()
+                { return typeid(T); }
+
+            virtual bool canDynamicCastObjectToIdentifierClass(Identifiable* object) const
+                { return dynamic_cast<T*>(object) != 0; }
+
+            virtual void destroyObjects();
+
+            static ClassIdentifier<T>* getIdentifier();
+
+        private:
+            ClassIdentifier(const ClassIdentifier<T>& identifier) {}    // don't copy
+
+            void setConfigValues(T* object, Configurable*) const;
+            void setConfigValues(T* object, Identifiable*) const;
+
+            void addObjectToList(T* object, Listable*);
+            void addObjectToList(T* object, Identifiable*);
+
+            void destroyObjects(Listable*);
+            void destroyObjects(void*);
+
+            void destroyObject(Destroyable* object);
+            void destroyObject(void* object);
+
             void updateConfigValues(bool updateChildren, Listable*) const;
             void updateConfigValues(bool updateChildren, Identifiable*) const;
 
-            std::string typeidName_;
             static WeakPtr<ClassIdentifier<T> > classIdentifier_s;
     };
@@ -318,45 +332,11 @@
     */
     template <class T>
-    inline ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier()
-    {
-        // check if the Identifier already exists
-        if (!ClassIdentifier<T>::classIdentifier_s)
-            ClassIdentifier<T>::initializeIdentifier();
-
+    /*static*/ inline ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier()
+    {
+        if (ClassIdentifier<T>::classIdentifier_s == NULL)
+            ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*) IdentifierManager::getInstance().getIdentifierByTypeInfo(typeid(T));
+
+        OrxVerify(ClassIdentifier<T>::classIdentifier_s != NULL, "Did you forget to register the class of type " << typeid(T).name() << "?");
         return ClassIdentifier<T>::classIdentifier_s;
-    }
-
-    /**
-        @brief Does the same as getIdentifier() but sets the name if this wasn't done yet.
-        @param name The name of this Identifier
-        @return The Identifier
-    */
-    template <class T>
-    inline ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier(const std::string& name)
-    {
-        ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier();
-        identifier->setName(name);
-        return identifier;
-    }
-
-    /**
-        @brief Assigns the static field for the identifier singleton.
-    */
-    template <class T>
-    /*static */ void ClassIdentifier<T>::initializeIdentifier()
-    {
-        // create a new identifier anyway. Will be deleted if not used.
-        ClassIdentifier<T>* proposal = new ClassIdentifier<T>();
-
-        // Get the entry from the map
-        ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*)IdentifierManager::getInstance().getGloballyUniqueIdentifier(proposal);
-
-        if (ClassIdentifier<T>::classIdentifier_s == proposal)
-            orxout(verbose, context::identifier) << "Requested Identifier for " << proposal->getTypeidName() << " was not yet existing and got created." << endl;
-        else
-        {
-            orxout(verbose, context::identifier) << "Requested Identifier for " << proposal->getTypeidName() << " was already existing and got assigned." << endl;
-            delete proposal; // delete proposal (it is not used anymore)
-        }
     }
 
@@ -375,5 +355,7 @@
             IdentifierManager::getInstance().createdObject(object);
 
-            this->setConfigValues(object, object);
+            if (Identifier::initConfigValues_s)
+                this->setConfigValues(object, object);
+
             return true;
         }
@@ -420,4 +402,48 @@
 
     /**
+     * @brief Destroy all objects of this class (must be Listable).
+     * Destroyables are destroyed with destroy(), all other classes with delete.
+     */
+    template <class T>
+    void ClassIdentifier<T>::destroyObjects()
+    {
+        this->destroyObjects((T*)0);
+    }
+
+    /**
+     * @brief Only searches and destroys objects if is a @ref Listable
+     */
+    template <class T>
+    void ClassIdentifier<T>::destroyObjects(Listable*)
+    {
+        ObjectListBase* objectList = Context::getRootContext()->getObjectList(this);
+        ObjectListElement<T>* begin = static_cast<ObjectListElement<T>*>(objectList->begin());
+        ObjectListElement<T>* end = static_cast<ObjectListElement<T>*>(objectList->end());
+        for (typename ObjectList<T>::iterator it = begin; it != end; )
+            this->destroyObject(*(it++));
+    }
+
+    template <class T>
+    void ClassIdentifier<T>::destroyObjects(void*)
+    {
+        // no action
+    }
+
+    /**
+     * @brief Call 'object->destroy()' for Destroyables and 'delete object' for all other types.
+     */
+    template <class T>
+    void ClassIdentifier<T>::destroyObject(Destroyable* object)
+    {
+        object->destroy();
+    }
+
+    template <class T>
+    void ClassIdentifier<T>::destroyObject(void* object)
+    {
+        delete static_cast<Identifiable*>(object);
+    }
+
+    /**
         @brief Updates the config-values of all existing objects of this class by calling their setConfigValues() function.
     */
@@ -438,5 +464,5 @@
 
         if (updateChildren)
-            for (std::set<const Identifier*>::const_iterator it = this->getChildrenBegin(); it != this->getChildrenEnd(); ++it)
+            for (std::set<const Identifier*>::const_iterator it = this->getChildren().begin(); it != this->getChildren().end(); ++it)
                 (*it)->updateConfigValues(false);
     }
Index: code/trunk/src/libraries/core/class/IdentifierManager.cc
===================================================================
--- code/trunk/src/libraries/core/class/IdentifierManager.cc	(revision 10622)
+++ code/trunk/src/libraries/core/class/IdentifierManager.cc	(revision 10624)
@@ -37,5 +37,5 @@
 
 #include "util/StringUtils.h"
-#include "core/CoreIncludes.h"
+#include "core/Core.h"
 #include "core/config/ConfigValueContainer.h"
 #include "core/XMLPort.h"
@@ -44,37 +44,10 @@
 namespace orxonox
 {
-    /* static */ IdentifierManager& IdentifierManager::getInstance()
-    {
-        static IdentifierManager instance;
-        return instance;
-    }
+    IdentifierManager* IdentifierManager::singletonPtr_s = 0;
 
     IdentifierManager::IdentifierManager()
     {
         this->hierarchyCreatingCounter_s = 0;
-        this->classIDCounter_s = 0;
-    }
-
-    /**
-        @brief Returns an identifier by name and adds it if not available
-        @param proposal A pointer to a newly created identifier for the case of non existence in the map
-        @return The identifier (unique instance)
-    */
-    Identifier* IdentifierManager::getGloballyUniqueIdentifier(Identifier* proposal)
-    {
-        const std::string& typeidName = proposal->getTypeidName();
-        std::map<std::string, Identifier*>::const_iterator it = this->identifierByTypeidName_.find(typeidName);
-
-        if (it != this->identifierByTypeidName_.end())
-        {
-            // There is already an entry: return it
-            return it->second;
-        }
-        else
-        {
-            // There is no entry: put the proposal into the map and return it
-            this->identifierByTypeidName_[typeidName] = proposal;
-            return proposal;
-        }
+        this->recordTraceForIdentifier_ = NULL;
     }
 
@@ -82,15 +55,23 @@
      * Registers the identifier in all maps of the IdentifierManager.
      */
-    void IdentifierManager::addIdentifierToLookupMaps(Identifier* identifier)
-    {
-        const std::string& typeidName = identifier->getTypeidName();
-        if (this->identifierByTypeidName_.find(typeidName) != this->identifierByTypeidName_.end())
-        {
-            this->identifierByString_[identifier->getName()] = identifier;
-            this->identifierByLowercaseString_[getLowercase(identifier->getName())] = identifier;
-            this->identifierByNetworkId_[identifier->getNetworkID()] = identifier;
-        }
-        else
-            orxout(internal_warning) << "Trying to add an identifier to lookup maps which is not known to IdentifierManager" << endl;
+    void IdentifierManager::addIdentifier(Identifier* identifier)
+    {
+        orxout(verbose, context::identifier) << "Adding identifier for " << identifier->getName() << " / " << identifier->getTypeInfo().name() << endl;
+
+        this->identifiers_.insert(identifier);
+        this->identifierByString_[identifier->getName()] = identifier;
+        this->identifierByLowercaseString_[getLowercase(identifier->getName())] = identifier;
+        this->identifierByNetworkId_[identifier->getNetworkID()] = identifier;
+    }
+
+    /**
+     * Unregisters the identifier from all maps of the IdentifierManager.
+     */
+    void IdentifierManager::removeIdentifier(Identifier* identifier)
+    {
+        this->identifiers_.erase(identifier);
+        this->identifierByString_.erase(identifier->getName());
+        this->identifierByLowercaseString_.erase(getLowercase(identifier->getName()));
+        this->identifierByNetworkId_.erase(identifier->getNetworkID());
     }
 
@@ -112,22 +93,30 @@
         {
             Context temporaryContext(NULL);
-            for (std::map<std::string, Identifier*>::const_iterator it = this->identifierByTypeidName_.begin(); it != this->identifierByTypeidName_.end(); ++it)
+            for (std::set<Identifier*>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)
             {
-                orxout(verbose, context::identifier) << "Initialize ClassIdentifier<" << it->second->getName() << ">-Singleton." << endl;
+                Identifier* identifier = (*it);
+                if (identifier->isInitialized())
+                    continue;
+
+                orxout(verbose, context::identifier) << "Initialize ClassIdentifier<" << identifier->getName() << ">-Singleton." << endl;
                 // To initialize the identifier, we create a new object and delete it afterwards.
-                if (it->second->hasFactory())
+                if (identifier->hasFactory())
                 {
-                    this->identifiersOfNewObject_.clear();
-                    Identifiable* temp = it->second->fabricate(&temporaryContext);
-                    if (temp->getIdentifier() != it->second)
-                        orxout(internal_error) << "Newly created object of type " << it->second->getName() << " has unexpected identifier. Did you forget to use RegisterObject(classname)?" << endl;
+                    this->identifierTraceOfNewObject_.clear();
+                    this->recordTraceForIdentifier_ = identifier;
+
+                    Identifiable* temp = identifier->fabricate(&temporaryContext);
+
+                    this->recordTraceForIdentifier_ = NULL;
+
+                    if (temp->getIdentifier() != identifier)
+                        orxout(internal_error) << "Newly created object of type " << identifier->getName() << " has unexpected identifier. Did you forget to use RegisterObject(classname)?" << endl;
+
+                    identifier->initializeParents(this->identifierTraceOfNewObject_[temp]);
+
                     delete temp;
-
-                    it->second->initializeParents(this->identifiersOfNewObject_);
                 }
-                else
-                    it->second->initializeDirectParentsOfAbstractClass();
-
-                initializedIdentifiers.insert(it->second);
+
+                initializedIdentifiers.insert(identifier);
             }
 
@@ -138,11 +127,10 @@
 
         // finish the initialization of all identifiers
-        for (std::map<std::string, Identifier*>::const_iterator it = this->identifierByTypeidName_.begin(); it != this->identifierByTypeidName_.end(); ++it)
-        {
-            if (initializedIdentifiers.find(it->second) != initializedIdentifiers.end())
-                it->second->finishInitialization();
-            else
-                orxout(internal_error) << "Identifier was registered late and is not initialized: " << it->second->getName() << " / " << it->second->getTypeidName() << endl;
-        }
+        for (std::set<Identifier*>::const_iterator it = initializedIdentifiers.begin(); it != initializedIdentifiers.end(); ++it)
+            (*it)->finishInitialization();
+
+        // only check class hierarchy in dev mode because it's an expensive operation and it requires a developer to fix detected problems anyway.
+        if (!Core::exists() || Core::getInstance().getConfig()->inDevMode())
+            this->verifyClassHierarchy(initializedIdentifiers);
 
         this->stopCreatingHierarchy();
@@ -151,15 +139,51 @@
 
     /**
-        @brief Destroys all Identifiers. Called when exiting the program.
-    */
-    void IdentifierManager::destroyAllIdentifiers()
-    {
-        for (std::map<std::string, Identifier*>::iterator it = this->identifierByTypeidName_.begin(); it != this->identifierByTypeidName_.end(); ++it)
-            delete (it->second);
-
-        this->identifierByTypeidName_.clear();
-        this->identifierByString_.clear();
-        this->identifierByLowercaseString_.clear();
-        this->identifierByNetworkId_.clear();
+     * Verifies if the class hierarchy is consistent with the RTTI.
+     */
+    void IdentifierManager::verifyClassHierarchy(const std::set<Identifier*>& initializedIdentifiers)
+    {
+        // check if there are any uninitialized identifiers remaining
+        for (std::set<Identifier*>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)
+            if (!(*it)->isInitialized())
+                orxout(internal_error) << "Identifier was registered late and is not initialized: " << (*it)->getName() << " / " << (*it)->getTypeInfo().name() << endl;
+
+        // for all initialized identifiers, check if a sample instance behaves as expected according to the class hierarchy
+        Context temporaryContext(NULL);
+        for (std::set<Identifier*>::const_iterator it1 = initializedIdentifiers.begin(); it1 != initializedIdentifiers.end(); ++it1)
+        {
+            if (!(*it1)->hasFactory())
+                continue;
+
+            Identifiable* temp = (*it1)->fabricate(&temporaryContext);
+
+            for (std::set<Identifier*>::const_iterator it2 = this->identifiers_.begin(); it2 != this->identifiers_.end(); ++it2)
+            {
+                bool isA_AccordingToRtti = (*it2)->canDynamicCastObjectToIdentifierClass(temp);
+                bool isA_AccordingToClassHierarchy = temp->isA((*it2));
+
+                if (isA_AccordingToRtti != isA_AccordingToClassHierarchy)
+                {
+                    orxout(internal_error) << "Class hierarchy does not match RTTI: Class hierarchy claims that " << (*it1)->getName() <<
+                        (isA_AccordingToClassHierarchy ? " is a " : " is not a ") << (*it2)->getName() << " but RTTI says the opposite." << endl;
+                }
+            }
+
+            delete temp;
+        }
+        orxout(internal_info) << "Class hierarchy matches RTTI" << endl;
+
+        size_t numberOfObjects = temporaryContext.getObjectList<Listable>()->size();
+        if (numberOfObjects > 0)
+            orxout(internal_warning) << "There are still " << numberOfObjects << " listables left after creating the class hierarchy" << endl;
+    }
+
+    /**
+     * @brief Resets all Identifiers.
+     */
+    void IdentifierManager::destroyClassHierarchy()
+    {
+        orxout(internal_status) << "Destroy class-hierarchy" << endl;
+        for (std::set<Identifier*>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)
+            (*it)->reset();
     }
 
@@ -170,5 +194,16 @@
     {
         if (this->isCreatingHierarchy())
-            this->identifiersOfNewObject_.insert(identifiable->getIdentifier());
+        {
+            if (this->recordTraceForIdentifier_)
+            {
+                std::list<const Identifier*>& traceForObject = this->identifierTraceOfNewObject_[identifiable];
+                if (std::find(traceForObject.begin(), traceForObject.end(), identifiable->getIdentifier()) != traceForObject.end())
+                {
+                    orxout(internal_warning) << this->recordTraceForIdentifier_->getName() << " inherits two times from " <<
+                        identifiable->getIdentifier()->getName() << ". Did you forget to use virtual inheritance?" << endl;
+                }
+                traceForObject.push_back(identifiable->getIdentifier());
+            }
+        }
         else
             orxout(internal_warning) << "createdObject() called outside of class hierarchy creation" << endl;
@@ -218,4 +253,18 @@
 
     /**
+        @brief Returns the Identifier with a given typeid-name.
+        @param name The typeid-name of the wanted Identifier
+        @return The Identifier
+    */
+    Identifier* IdentifierManager::getIdentifierByTypeInfo(const std::type_info& typeInfo)
+    {
+        // TODO: use std::type_index and a map to find identifiers by type_info (only with c++11)
+        for (std::set<Identifier*>::iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)
+            if ((*it)->getTypeInfo() == typeInfo)
+                return (*it);
+        return 0;
+    }
+
+    /**
         @brief Cleans the NetworkID map (needed on clients for correct initialization)
     */
Index: code/trunk/src/libraries/core/class/IdentifierManager.h
===================================================================
--- code/trunk/src/libraries/core/class/IdentifierManager.h	(revision 10622)
+++ code/trunk/src/libraries/core/class/IdentifierManager.h	(revision 10624)
@@ -39,18 +39,21 @@
 #include <map>
 #include <set>
+#include <list>
 #include <string>
+
+#include "util/Singleton.h"
 
 namespace orxonox
 {
-    class _CoreExport IdentifierManager
+    class _CoreExport IdentifierManager : public Singleton<IdentifierManager>
     {
+        friend class Singleton<IdentifierManager>;
+
         public:
-            static IdentifierManager& getInstance();
+            IdentifierManager();
+            ~IdentifierManager() {}
 
-            Identifier* getGloballyUniqueIdentifier(Identifier* proposal);
-            void addIdentifierToLookupMaps(Identifier* identifier);
-
-            unsigned int getUniqueClassId()
-                { return this->classIDCounter_s++; }
+            void addIdentifier(Identifier* identifier);
+            void removeIdentifier(Identifier* identifier);
 
 
@@ -59,5 +62,6 @@
             /////////////////////////////
             void createClassHierarchy();
-            void destroyAllIdentifiers();
+            void verifyClassHierarchy(const std::set<Identifier*>& initializedIdentifiers);
+            void destroyClassHierarchy();
 
             void createdObject(Identifiable* identifiable);
@@ -74,4 +78,5 @@
             Identifier* getIdentifierByLowercaseString(const std::string& name);
             Identifier* getIdentifierByID(uint32_t id);
+            Identifier* getIdentifierByTypeInfo(const std::type_info& typeInfo);
 
             void clearNetworkIDs();
@@ -88,7 +93,5 @@
 
         private:
-            IdentifierManager();
-            IdentifierManager(const IdentifierManager&);
-            ~IdentifierManager() {}
+            IdentifierManager(const IdentifierManager&); // not implemented
 
             /// Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents.
@@ -99,6 +102,5 @@
                 { hierarchyCreatingCounter_s--; }
 
-            std::map<std::string, Identifier*> identifierByTypeidName_;      //!< Map with the names as received by typeid(). This is only used internally.
-
+            std::set<Identifier*> identifiers_;                              //!< All identifiers. This is only used internally.
             std::map<std::string, Identifier*> identifierByString_;          //!< Map that stores all Identifiers with their names.
             std::map<std::string, Identifier*> identifierByLowercaseString_; //!< Map that stores all Identifiers with their names in lowercase.
@@ -106,6 +108,11 @@
 
             int hierarchyCreatingCounter_s;                         //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading)
-            std::set<const Identifier*> identifiersOfNewObject_;    //!< Used while creating the object hierarchy to keep track of the identifiers of a newly created object
-            unsigned int classIDCounter_s;                          //!< counter for the unique classIDs
+
+            /// Used while creating the object hierarchy to keep track of the identifiers of a newly created object (and all other objects that get created as
+            /// a consequence of this, e.g. nested member objects).
+            std::map<Identifiable*, std::list<const Identifier*> > identifierTraceOfNewObject_;
+            Identifier* recordTraceForIdentifier_; //!< The identifier for which we want to record the trace of identifiers during object creation. If null, no trace is recorded.
+
+            static IdentifierManager* singletonPtr_s;
     };
 }
Index: code/trunk/src/libraries/core/class/OrxonoxInterface.cc
===================================================================
--- code/trunk/src/libraries/core/class/OrxonoxInterface.cc	(revision 10622)
+++ code/trunk/src/libraries/core/class/OrxonoxInterface.cc	(revision 10624)
@@ -32,5 +32,5 @@
 namespace orxonox
 {
-    RegisterClassNoArgs(OrxonoxInterface);
+    RegisterClassNoArgs(OrxonoxInterface).virtualBase();
 
     OrxonoxInterface::OrxonoxInterface()
Index: code/trunk/src/libraries/core/class/Super.h
===================================================================
--- code/trunk/src/libraries/core/class/Super.h	(revision 10622)
+++ code/trunk/src/libraries/core/class/Super.h	(revision 10624)
@@ -274,7 +274,4 @@
         SUPER_NOARGS(classname, functionname)
 
-    #define SUPER_changedGametype(classname, functionname, ...) \
-        SUPER_NOARGS(classname, functionname)
-
     #define SUPER_changedUsed(classname, functionname, ...) \
         SUPER_NOARGS(classname, functionname)
@@ -555,17 +552,13 @@
         SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
 
-        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(9, changedGametype, false)
-            ()
-        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
-
-        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(10, changedUsed, false)
-            ()
-        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
-
-        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(11, changedCarrier, false)
-            ()
-        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
-
-        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(12, changedPickedUp, false)
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(9, changedUsed, false)
+            ()
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
+
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(10, changedCarrier, false)
+            ()
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
+
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(11, changedPickedUp, false)
             ()
         SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
@@ -623,5 +616,4 @@
     SUPER_INTRUSIVE_DECLARATION(changedOverlayGroup);
     SUPER_INTRUSIVE_DECLARATION(changedName);
-    SUPER_INTRUSIVE_DECLARATION(changedGametype);
     SUPER_INTRUSIVE_DECLARATION(changedUsed);
     SUPER_INTRUSIVE_DECLARATION(changedCarrier);
Index: code/trunk/src/libraries/core/command/ArgumentCompletionFunctions.cc
===================================================================
--- code/trunk/src/libraries/core/command/ArgumentCompletionFunctions.cc	(revision 10622)
+++ code/trunk/src/libraries/core/command/ArgumentCompletionFunctions.cc	(revision 10624)
@@ -44,4 +44,5 @@
 #include "CommandExecutor.h"
 #include "ConsoleCommand.h"
+#include "ConsoleCommandManager.h"
 #include "TclThreadManager.h"
 
@@ -98,5 +99,5 @@
 
                 // get all the groups that are visible (except the shortcut group "")
-                const std::map<std::string, std::map<std::string, ConsoleCommand*> >& commands = ConsoleCommand::getCommands();
+                const std::map<std::string, std::map<std::string, ConsoleCommand*> >& commands = ConsoleCommandManager::getInstance().getCommands();
                 for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = commands.begin(); it_group != commands.end(); ++it_group)
                     if (groupIsVisible(it_group->second, bOnlyShowHidden) && it_group->first != "" && (fragmentLC == "" || getLowercase(it_group->first).find(fragmentLC) == 0))
@@ -137,11 +138,11 @@
 
                 // find the iterator of the given group
-                std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommands().begin();
-                for ( ; it_group != ConsoleCommand::getCommands().end(); ++it_group)
+                std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommandManager::getInstance().getCommands().begin();
+                for ( ; it_group != ConsoleCommandManager::getInstance().getCommands().end(); ++it_group)
                     if (getLowercase(it_group->first) == groupLC)
                         break;
 
                 // add all commands in the group to the list
-                if (it_group != ConsoleCommand::getCommands().end())
+                if (it_group != ConsoleCommandManager::getInstance().getCommands().end())
                 {
                     for (std::map<std::string, ConsoleCommand*>::const_iterator it_command = it_group->second.begin(); it_command != it_group->second.end(); ++it_command)
@@ -206,11 +207,11 @@
                 return detail::_groupsandcommands(fragment, true);
 
-            if (ConsoleCommand::getCommandLC(getLowercase(tokens[0])))
+            if (ConsoleCommandManager::getInstance().getCommandLC(getLowercase(tokens[0])))
                 return ARGUMENT_COMPLETION_FUNCTION_CALL(command)(fragment);
 
             if (tokens.size() == 1)
             {
-                std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommands().find(tokens[0]);
-                if (it_group != ConsoleCommand::getCommands().end())
+                std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommandManager::getInstance().getCommands().find(tokens[0]);
+                if (it_group != ConsoleCommandManager::getInstance().getCommands().end())
                     return detail::_subcommands(fragment, tokens[0], true);
                 else
@@ -218,5 +219,5 @@
             }
 
-            if (ConsoleCommand::getCommandLC(getLowercase(tokens[0]), getLowercase(tokens[1])))
+            if (ConsoleCommandManager::getInstance().getCommandLC(getLowercase(tokens[0]), getLowercase(tokens[1])))
                 return ARGUMENT_COMPLETION_FUNCTION_CALL(command)(fragment);
 
Index: code/trunk/src/libraries/core/command/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/core/command/CMakeLists.txt	(revision 10622)
+++ code/trunk/src/libraries/core/command/CMakeLists.txt	(revision 10624)
@@ -4,4 +4,6 @@
   ConsoleCommand.cc
   ConsoleCommandCompilation.cc
+  ConsoleCommandIncludes.cc
+  ConsoleCommandManager.cc
   Executor.cc
   IOConsole.cc
Index: code/trunk/src/libraries/core/command/CommandEvaluation.cc
===================================================================
--- code/trunk/src/libraries/core/command/CommandEvaluation.cc	(revision 10622)
+++ code/trunk/src/libraries/core/command/CommandEvaluation.cc	(revision 10624)
@@ -37,4 +37,5 @@
 #include "CommandExecutor.h"
 #include "ConsoleCommand.h"
+#include "ConsoleCommandManager.h"
 
 namespace orxonox
@@ -305,5 +306,5 @@
                 // the user typed 1-2 arguments, check what he tried to type and print a suitable error
                 std::string groupLC = getLowercase(this->getToken(0));
-                for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommandsLC().begin(); it_group != ConsoleCommand::getCommandsLC().end(); ++it_group)
+                for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommandManager::getInstance().getCommandsLC().begin(); it_group != ConsoleCommandManager::getInstance().getCommandsLC().end(); ++it_group)
                     if (it_group->first == groupLC)
                         return std::string("Error: There is no command in group \"") + this->getToken(0) + "\" starting with \"" + this->getToken(1) + "\".";
@@ -327,5 +328,5 @@
 
         // iterate through all groups and their commands and calculate the distance to the current command. keep the best.
-        for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommandsLC().begin(); it_group != ConsoleCommand::getCommandsLC().end(); ++it_group)
+        for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommandManager::getInstance().getCommandsLC().begin(); it_group != ConsoleCommandManager::getInstance().getCommandsLC().end(); ++it_group)
         {
             if (it_group->first != "")
@@ -345,6 +346,6 @@
 
         // now also iterate through all shortcuts and keep the best if it's better than the one found above.
-        std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommandsLC().find("");
-        if (it_group !=  ConsoleCommand::getCommandsLC().end())
+        std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommandManager::getInstance().getCommandsLC().find("");
+        if (it_group !=  ConsoleCommandManager::getInstance().getCommandsLC().end())
         {
             for (std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); ++it_name)
Index: code/trunk/src/libraries/core/command/CommandExecutor.cc
===================================================================
--- code/trunk/src/libraries/core/command/CommandExecutor.cc	(revision 10622)
+++ code/trunk/src/libraries/core/command/CommandExecutor.cc	(revision 10624)
@@ -34,5 +34,5 @@
 #include "CommandExecutor.h"
 
-#include "ConsoleCommand.h"
+#include "ConsoleCommandIncludes.h"
 #include "TclBind.h"
 #include "Shell.h"
@@ -155,5 +155,5 @@
 
         // assign the fallback-command to get hints about the possible commands and groups
-        evaluation.hintCommand_ = ConsoleCommand::getCommand(__CC_CommandExecutor_name, __CC_autocomplete_name);
+        evaluation.hintCommand_ = ConsoleCommandManager::getInstance().getCommand(__CC_CommandExecutor_name, __CC_autocomplete_name);
 
         // check if there's at least one argument
@@ -161,5 +161,5 @@
         {
             // try to get a command from the first token
-            evaluation.execCommand_ = ConsoleCommand::getCommandLC(evaluation.getToken(0));
+            evaluation.execCommand_ = ConsoleCommandManager::getInstance().getCommandLC(evaluation.getToken(0));
             if (evaluation.execCommand_)
                 evaluation.execArgumentsOffset_ = 1;
@@ -167,5 +167,5 @@
             {
                 // try to get a command from the first two tokens
-                evaluation.execCommand_ = ConsoleCommand::getCommandLC(evaluation.getToken(0), evaluation.getToken(1));
+                evaluation.execCommand_ = ConsoleCommandManager::getInstance().getCommandLC(evaluation.getToken(0), evaluation.getToken(1));
                 if (evaluation.execCommand_)
                     evaluation.execArgumentsOffset_ = 2;
@@ -288,5 +288,5 @@
 
             // check if the alias already exists - print an error and return if it does
-            if ((tokens.size() == 1 && ConsoleCommand::getCommand(tokens[0])) || (tokens.size() == 2 && ConsoleCommand::getCommand(tokens[0], tokens[1])))
+            if ((tokens.size() == 1 && ConsoleCommandManager::getInstance().getCommand(tokens[0])) || (tokens.size() == 2 && ConsoleCommandManager::getInstance().getCommand(tokens[0], tokens[1])))
             {
                 orxout(user_error) << "A command with name \"" << alias << "\" already exists." << endl;
@@ -296,7 +296,7 @@
             // create a new console command with the given alias as its name
             if (tokens.size() == 1)
-                createConsoleCommand(tokens[0], executor);
+                ConsoleCommandManager::getInstance().registerCommand(new ConsoleCommand(tokens[0], executor));
             else if (tokens.size() == 2)
-                createConsoleCommand(tokens[0], tokens[1], executor);
+                ConsoleCommandManager::getInstance().registerCommand(new ConsoleCommand(tokens[0], tokens[1], executor));
             else
                 orxout(user_error) << "\"" << alias << "\" is not a valid alias name (must have one or two words)." << endl;
Index: code/trunk/src/libraries/core/command/ConsoleCommand.cc
===================================================================
--- code/trunk/src/libraries/core/command/ConsoleCommand.cc	(revision 10622)
+++ code/trunk/src/libraries/core/command/ConsoleCommand.cc	(revision 10624)
@@ -35,14 +35,25 @@
 
 #include "util/Convert.h"
-#include "util/StringUtils.h"
 #include "core/Language.h"
 #include "core/GameMode.h"
 #include "core/input/KeyBinder.h"
 #include "core/input/KeyBinderManager.h"
+#include "ConsoleCommandManager.h"
 
 namespace orxonox
 {
     /**
-        @brief Constructor: Initializes all values and registers the command.
+        @brief Constructor: Initializes all values and registers the command (without a group).
+        @param name The name of the command
+        @param executor The executor of the command
+        @param bInitialized If true, the executor is used for both, the definition of the function-header AND to executute the command. If false, the command is inactive and needs to be assigned a function before it can be used.
+    */
+    ConsoleCommand::ConsoleCommand(const std::string& name, const ExecutorPtr& executor, bool bInitialized)
+    {
+        this->init("", name, executor, bInitialized);
+    }
+
+    /**
+        @brief Constructor: Initializes all values and registers the command (with a group).
         @param group The group of the command
         @param name The name of the command
@@ -52,4 +63,9 @@
     ConsoleCommand::ConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized)
     {
+        this->init(group, name, executor, bInitialized);
+    }
+
+    void ConsoleCommand::init(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized)
+    {
         this->bActive_ = true;
         this->bHidden_ = false;
@@ -68,5 +84,5 @@
             this->executor_ = executor;
 
-        ConsoleCommand::registerCommand(group, name, this);
+        this->names_.push_back(CommandName(group, name));
     }
 
@@ -76,5 +92,4 @@
     ConsoleCommand::~ConsoleCommand()
     {
-        ConsoleCommand::unregisterCommand(this);
     }
 
@@ -84,5 +99,5 @@
     ConsoleCommand& ConsoleCommand::addShortcut()
     {
-        ConsoleCommand::registerCommand("", this->baseName_, this);
+        this->names_.push_back(CommandName("", this->baseName_));
         return *this;
     }
@@ -93,5 +108,5 @@
     ConsoleCommand& ConsoleCommand::addShortcut(const std::string&  name)
     {
-        ConsoleCommand::registerCommand("", name, this);
+        this->names_.push_back(CommandName("", name));
         return *this;
     }
@@ -102,5 +117,5 @@
     ConsoleCommand& ConsoleCommand::addGroup(const std::string& group)
     {
-        ConsoleCommand::registerCommand(group, this->baseName_, this);
+        this->names_.push_back(CommandName(group, this->baseName_));
         return *this;
     }
@@ -111,5 +126,5 @@
     ConsoleCommand& ConsoleCommand::addGroup(const std::string& group, const std::string&  name)
     {
-        ConsoleCommand::registerCommand(group, name, this);
+        this->names_.push_back(CommandName(group, name));
         return *this;
     }
@@ -587,166 +602,3 @@
         return *this;
     }
-
-    /**
-        @brief Returns the command with given group an name.
-        @param group The group of the requested command
-        @param name The group of the requested command
-        @param bPrintError If true, an error is printed if the command doesn't exist
-    */
-    /* static */ ConsoleCommand* ConsoleCommand::getCommand(const std::string& group, const std::string& name, bool bPrintError)
-    {
-        // find the group
-        std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommandMap().find(group);
-        if (it_group != ConsoleCommand::getCommandMap().end())
-        {
-            // find the name
-            std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.find(name);
-            if (it_name != it_group->second.end())
-            {
-                // return the pointer
-                return it_name->second;
-            }
-        }
-        if (bPrintError)
-        {
-            if (group == "")
-                orxout(internal_error, context::commands) << "Couldn't find console command with shortcut \"" << name << "\"" << endl;
-            else
-                orxout(internal_error, context::commands) << "Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << endl;
-        }
-        return 0;
-    }
-
-    /**
-        @brief Returns the command with given group an name in lowercase.
-        @param group The group of the requested command in lowercase
-        @param name The group of the requested command in lowercase
-        @param bPrintError If true, an error is printed if the command doesn't exist
-    */
-    /* static */ ConsoleCommand* ConsoleCommand::getCommandLC(const std::string& group, const std::string& name, bool bPrintError)
-    {
-        std::string groupLC = getLowercase(group);
-        std::string nameLC = getLowercase(name);
-
-        // find the group
-        std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommandMapLC().find(groupLC);
-        if (it_group != ConsoleCommand::getCommandMapLC().end())
-        {
-            // find the name
-            std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.find(nameLC);
-            if (it_name != it_group->second.end())
-            {
-                // return the pointer
-                return it_name->second;
-            }
-        }
-        if (bPrintError)
-        {
-            if (group == "")
-                orxout(internal_error, context::commands) << "Couldn't find console command with shortcut \"" << name << "\"" << endl;
-            else
-                orxout(internal_error, context::commands) << "Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << endl;
-        }
-        return 0;
-    }
-
-    /**
-        @brief Returns the static map that stores all console commands.
-    */
-    /* static */ std::map<std::string, std::map<std::string, ConsoleCommand*> >& ConsoleCommand::getCommandMap()
-    {
-        static std::map<std::string, std::map<std::string, ConsoleCommand*> > commandMap;
-        return commandMap;
-    }
-
-    /**
-        @brief Returns the static map that stores all console commands in lowercase.
-    */
-    /* static */ std::map<std::string, std::map<std::string, ConsoleCommand*> >& ConsoleCommand::getCommandMapLC()
-    {
-        static std::map<std::string, std::map<std::string, ConsoleCommand*> > commandMapLC;
-        return commandMapLC;
-    }
-
-    /**
-        @brief Registers a new command with given group an name by adding it to the command map.
-    */
-    /* static */ void ConsoleCommand::registerCommand(const std::string& group, const std::string& name, ConsoleCommand* command)
-    {
-        if (name == "")
-            return;
-
-        // check if a command with this name already exists
-        if (ConsoleCommand::getCommand(group, name) != 0)
-        {
-            if (group == "")
-                orxout(internal_warning, context::commands) << "A console command with shortcut \"" << name << "\" already exists." << endl;
-            else
-                orxout(internal_warning, context::commands) << "A console command with name \"" << name << "\" already exists in group \"" << group << "\"." << endl;
-        }
-        else
-        {
-            // add the command to the map
-            ConsoleCommand::getCommandMap()[group][name] = command;
-            ConsoleCommand::getCommandMapLC()[getLowercase(group)][getLowercase(name)] = command;
-        }
-    }
-
-    /**
-        @brief Removes the command from the command map.
-    */
-    /* static */ void ConsoleCommand::unregisterCommand(ConsoleCommand* command)
-    {
-        // iterate through all groups
-        for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::iterator it_group = ConsoleCommand::getCommandMap().begin(); it_group != ConsoleCommand::getCommandMap().end(); )
-        {
-            // iterate through all commands of each group
-            for (std::map<std::string, ConsoleCommand*>::iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); )
-            {
-                // erase the command
-                if (it_name->second == command)
-                    it_group->second.erase(it_name++);
-                else
-                    ++it_name;
-            }
-
-            // erase the group if it is empty now
-            if (it_group->second.empty())
-                ConsoleCommand::getCommandMap().erase(it_group++);
-            else
-                ++it_group;
-        }
-
-        // now the same for the lowercase-map:
-
-        // iterate through all groups
-        for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::iterator it_group = ConsoleCommand::getCommandMapLC().begin(); it_group != ConsoleCommand::getCommandMapLC().end(); )
-        {
-            // iterate through all commands of each group
-            for (std::map<std::string, ConsoleCommand*>::iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); )
-            {
-                // erase the command
-                if (it_name->second == command)
-                    it_group->second.erase(it_name++);
-                else
-                    ++it_name;
-            }
-
-            // erase the group if it is empty now
-            if (it_group->second.empty())
-                ConsoleCommand::getCommandMapLC().erase(it_group++);
-            else
-                ++it_group;
-        }
-    }
-
-    /**
-        @brief Deletes all commands
-    */
-    /* static */ void ConsoleCommand::destroyAll()
-    {
-        // delete entries until the map is empty
-        while (!ConsoleCommand::getCommandMap().empty() && !ConsoleCommand::getCommandMap().begin()->second.empty())
-            delete ConsoleCommand::getCommandMap().begin()->second.begin()->second;
-    }
 }
Index: code/trunk/src/libraries/core/command/ConsoleCommand.h
===================================================================
--- code/trunk/src/libraries/core/command/ConsoleCommand.h	(revision 10622)
+++ code/trunk/src/libraries/core/command/ConsoleCommand.h	(revision 10624)
@@ -28,189 +28,7 @@
 
 /**
-    @defgroup ConsoleCommand Console commands
-    @ingroup Command
-*/
-
-/**
     @file
     @ingroup Command ConsoleCommand
-    @brief Declaration of the orxonox::ConsoleCommand class and the SetConsoleCommand() macro.
-
-    @anchor ConsoleCommandExample
-
-    Console commands can be used to write scripts, use key-bindings or simply to be
-    entered into the shell by the user. Instances of orxonox::ConsoleCommand define
-    the function of a command, and also more information like, for example, if it is
-    active, default values, and possible arguments.
-
-    Commands need to be registered to the system statically on startup by using the
-    SetConsoleCommand() or DeclareConsoleCommand() macros outside of a function.
-    This ensures that commands are known to the system at any time, so they can be
-    evaluated (see orxonox::CommandExecutor::evaluate()), for example for key-bindings.
-
-    Example:
-    @code
-    void myCoutFunction(const std::string& text)        // Define a static function
-    {
-        orxout() << "Text: " << text << endl;           // Print the text to the console
-    }
-
-    SetConsoleCommand("cout", &myCoutFunction);         // Register the function as command with name "cout"
-    @endcode
-
-    Now you can open the shell and execute the command:
-    @code
-    $ cout Hello World
-    @endcode
-
-    Internally this command is now passed to orxonox::CommandExecutor::execute():
-    @code
-    CommandExecutor::execute("cout HelloWorld");
-    @endcode
-
-    CommandExecutor searches for a command with name "cout" and passes the arguments
-    "Hello World" to it. Because we registered myCoutFunction() with this command,
-    as a result the following text will be printed to the console:
-    @code
-    Text: Hello World
-    @endcode
-
-    You can add more attributes to the ConsoleCommand, by using the command-chain feature
-    of SetConsoleCommand(). For example like this:
-    @code
-    SetConsoleCommand("cout", &myCoutFunction)
-        .addGroup("output", "text")
-        .accessLevel(AccessLevel::Offline)
-        .defaultValues("no text");
-    @endcode
-
-    Open the shell again and try it:
-    @code
-    $ cout Hello World
-    Text: Hello World
-    $ output text Hello World
-    Text: Hello World
-    $ cout
-    Text: no text
-    @endcode
-
-    If you execute it online (note: the access level is "Offline"), you will see the
-    following (or something similar):
-    @code
-    $ cout Hello World
-    Error: Can't execute command "cout", access denied.
-    @endcode
-
-    If a command is executed, the arguments are passed to an underlying function,
-    whitch is wrapped by an orxonox::Functor which again is wrapped by an orxonox::Executor.
-    The Functor contains the function-pointer, as well as the object-pointer in
-    case of a non-static member-function. The executor stores possible default-values
-    for each argument of the function.
-
-    The function of a command can be changed at any time. It's possible to just exchange
-    the function-pointer of the underlying Functor if the headers of the functions are
-    exactly the same. But you can also exchange the Functor itself or even completely
-    replace the Executor. Also the other attributes of a ConsoleCommand can be modified
-    during the game, for example it can be activated or deactivated.
-
-    To do so, the function ModifyConsoleCommand() has to be used. It returns an instance
-    of orxonox::ConsoleCommand::ConsoleCommandManipulator which has an interface similar to
-    orxonox::ConsoleCommand, but with slight differences. You can use it the same way like
-    SetConsoleCommand(), meaning you can use command-chains to change different attributes at
-    the same time. ModifyConsoleCommand() must not be executed statically, but rather in a
-    function at some point of the execution of the program.
-
-    Example:
-    @code
-    void myOtherCoutFunction(const std::string& text)                       // Define a new static function
-    {
-        orxout() << "Uppercase: " << getUppercase(text) << endl;            // Print the text in uppercase to the console
-    }
-
-    {
-        // ...                                                              // somewhere in the code
-
-        ModifyConsoleCommand("cout").setFunction(&myOtherCoutFunction);     // Modify the underlying function of the command
-
-        // ...
-    }
-    @endcode
-
-    If you now enter the command into the shell, you'll see a different behavior:
-    @code
-    $ cout Hello World
-    Uppercase: HELLO WORLD
-    $ cout
-    Uppercase: NO TEXT
-    @endcode
-
-    A few important notes about changing functions:
-
-    Instead of changing the function with setFunction(), you can also create a command-stack
-    by using pushFunction() and popFunction(). It's important to note a few things about that,
-    because the underlying structure of Executor and Functor has a few pitfalls:
-     - If you push a new function-pointer, the same executor as before will be used (and, if
-       the headers match, even the same functor can be used, which is very fast)
-     - If you push a new Functor, the same executor as before will be used
-     - If you push a new Executor, everything is changed
-
-    Note that the executor contains the @b default @b values, so if you just exchange the
-    Functor, the default values remain the same. However if you decide to change the default
-    values at any point of the stack, <b>this will also change the default values on all
-    other stack-levels</b> that share the same executor. If you don't like this behavior,
-    you have to explicitly push a new executor before changing the default values, either by
-    calling pushFunction(executor) or by calling pushFunction(void) which pushes a copy of
-    the current executor to the stack.
-
-    Another important point are object pointers in case of non-static member-functions.
-    Whenever you set or push a new function, <b>you must add the object pointer again</b>
-    because objects are stored in the Functor which is usually exchanged if you change
-    the function.
-
-    You can also use a stack for objects, but note that this <b>object-stack is different for each
-    function</b> - so if you set a new function, the object-stack will be cleared. If you push
-    a new function, the old object-stack is stored in the stack, so it can be restored if
-    you pop the function.
-
-    %DeclareConsoleCommand():
-
-    Appart from SetConsoleCommand() you can also call DeclareConsoleCommand(). In contrast
-    to SetConsoleCommand(), this doesn't assign a function to the command. Indeed you have
-    to pass a function-pointer to DeclareConsoleCommand(), but it is only used to determine
-    the header of the future command-function. This allows to declare a command statically,
-    thus it's possible to evaluate key-bindings of this command, but the actual function
-    can be assigned at a later point.
-
-    Example:
-    @code
-    DeclareConsoleCommand("cout", &prototype::void__string);
-    @endcode
-
-    If you try to execute the command now, you see the following (or something similar):
-    @code
-    $ cout Hello World
-    Error: Can't execute command "cout", command is not active.
-    @endcode
-
-    You first have to assign a function to use the command:
-    @code
-    {
-        // ...
-
-        ModifyConsoleCommand("cout").setFunction(&myCoutFunction);
-
-        // ...
-    }
-    @endcode
-
-    Now you can use it:
-    @code
-    $ cout Hello World
-    Text: Hello World
-    @endcode
-
-    Note that the initial function prototype::void__string is defined in the namespace
-    orxonox::prototype. If there's no function with the desired header, you can extend
-    the collection of functions or simply use another function that has the same header.
+    @brief Declaration of the orxonox::ConsoleCommand class.
 */
 
@@ -223,85 +41,6 @@
 #include <vector>
 
-#include "util/VA_NARGS.h"
 #include "ArgumentCompletionFunctions.h"
 #include "Executor.h"
-
-
-/**
-    @brief Defines a console command. The macro is overloaded for 2-4 parameters.
-
-    This is an overloaded macro. Depending on the number of arguments a different
-    overloaded implementation of the macro will be chosen.
-
-    Console commands created with SetConsoleCommand() become active immediately and
-    the given function-pointer (and optionally the object) will be used to execute
-    the command.
-*/
-#define SetConsoleCommand(...) \
-    BOOST_PP_EXPAND(BOOST_PP_CAT(SetConsoleCommand, ORXONOX_VA_NARGS(__VA_ARGS__))(__VA_ARGS__))
-/**
-    @brief This macro is executed if you call SetConsoleCommand() with 2 arguments.
-    @param name The name (string) of the console command
-    @param functionpointer The function-pointer of the corresponding command-function
-*/
-#define SetConsoleCommand2(name, functionpointer) \
-    SetConsoleCommandGeneric("", name, orxonox::createFunctor(functionpointer))
-/**
-    @brief This macro is executed if you call SetConsoleCommand() with 3 arguments.
-    @param group The group (string) of the console command
-    @param name The name (string) of the console command
-    @param functionpointer The function-pointer of the corresponding command-function
-*/
-#define SetConsoleCommand3(group, name, functionpointer) \
-    SetConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer))
-/**
-    @brief This macro is executed if you call SetConsoleCommand() with 4 arguments.
-    @param group The group (string) of the console command
-    @param name The name (string) of the console command
-    @param functionpointer The function-pointer of the corresponding command-function
-    @param object The object that will be assigned to the command. Used for member-functions.
-*/
-#define SetConsoleCommand4(group, name, functionpointer, object) \
-    SetConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer, object))
-
-/// Internal macro
-#define SetConsoleCommandGeneric(group, name, functor) \
-    static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) = (*orxonox::createConsoleCommand(group, name, orxonox::createExecutor(functor)))
-
-
-/**
-    @brief Declares a console command. The macro is overloaded for 2-3 parameters.
-
-    This is an overloaded macro. Depending on the number of arguments a different
-    overloaded implementation of the macro will be chosen.
-
-    Console commands created with DeclareConsoleCommand() don't use the the given
-    function-pointer to execute the command, it is only used to define the header
-    of the future command-function. The command is inactive until you manually
-    set a function with orxonox::ModifyConsoleCommand(). You can use a different
-    function-pointer than in the final command, as long as it has the same header.
-*/
-#define DeclareConsoleCommand(...) \
-    BOOST_PP_EXPAND(BOOST_PP_CAT(DeclareConsoleCommand, ORXONOX_VA_NARGS(__VA_ARGS__))(__VA_ARGS__))
-/**
-    @brief This macro is executed if you call DeclareConsoleCommand() with 2 arguments.
-    @param name The name (string) of the console command
-    @param functionpointer The function-pointer of an arbitrary function that has the same header as the final function
-*/
-#define DeclareConsoleCommand2(name, functionpointer) \
-    DeclareConsoleCommandGeneric("", name, orxonox::createFunctor(functionpointer))
-/**
-    @brief This macro is executed if you call DeclareConsoleCommand() with 3 arguments.
-    @param group The group (string) of the console command
-    @param name The name (string) of the console command
-    @param functionpointer The function-pointer of an arbitrary function that has the same header as the final function
-*/
-#define DeclareConsoleCommand3(group, name, functionpointer) \
-    DeclareConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer))
-
-/// Internal macro
-#define DeclareConsoleCommandGeneric(group, name, functor) \
-    static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) = (*orxonox::createConsoleCommand(group, name, orxonox::createExecutor(functor), false))
-
 
 namespace orxonox
@@ -365,4 +104,14 @@
 
         public:
+            /**
+             * @brief Defines the name of a command, consisting of an optional group ("" means no group) and the name itself.
+             */
+            struct CommandName
+            {
+                CommandName(const std::string& group, const std::string& name) : group_(group), name_(name) {}
+                std::string group_;
+                std::string name_;
+            };
+
             /**
                 @brief Helper class that is used to manipulate console commands.
@@ -522,4 +271,5 @@
 
         public:
+            ConsoleCommand(const std::string& name, const ExecutorPtr& executor, bool bInitialized = true);
             ConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized = true);
             ~ConsoleCommand();
@@ -620,5 +370,10 @@
                 { return this; }
 
+            inline const std::vector<CommandName>& getNames()
+                { return this->names_; }
+
         private:
+            void init(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized);
+
             bool headersMatch(const FunctorPtr& functor);
             bool headersMatch(const ExecutorPtr& executor);
@@ -641,4 +396,5 @@
             AccessLevel::Enum accessLevel_;                                 ///< The access level (the state of the game in which you can access the command)
             std::string baseName_;                                          ///< The name that was first assigned to the command
+            std::vector<CommandName> names_;                                ///< All names and aliases of this command
             FunctorPtr baseFunctor_;                                        ///< The functor that defines the header of the command-function
 
@@ -655,70 +411,5 @@
             LanguageEntryLabel descriptionReturnvalue_;                     ///< A description of the return-value
             LanguageEntryLabel descriptionParam_[MAX_FUNCTOR_ARGUMENTS];    ///< A description for each argument
-
-        public:
-            /// Returns the map with all groups and commands.
-            static inline const std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommands()
-                { return ConsoleCommand::getCommandMap(); }
-            /// Returns the map with all groups and commands in lowercase.
-            static inline const std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommandsLC()
-                { return ConsoleCommand::getCommandMapLC(); }
-
-            /// Returns a command (shortcut) with given name. @param name The name of the command shortcut @param bPrintError If true, an error is printed if the command doesn't exist
-            static inline ConsoleCommand* getCommand(const std::string& name, bool bPrintError = false)
-                { return ConsoleCommand::getCommand("", name, bPrintError); }
-            /// Returns a command (shortcut) with given name in lowercase. @param name The lowercase name of the command shortcut @param bPrintError If true, an error is printed if the command doesn't exist
-            static inline ConsoleCommand* getCommandLC(const std::string& name, bool bPrintError = false)
-                { return ConsoleCommand::getCommandLC("", name, bPrintError); }
-
-            static ConsoleCommand* getCommand(const std::string& group, const std::string& name, bool bPrintError = false);
-            static ConsoleCommand* getCommandLC(const std::string& group, const std::string& name, bool bPrintError = false);
-
-            static void destroyAll();
-
-        private:
-            static std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommandMap();
-            static std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommandMapLC();
-
-            static void registerCommand(const std::string& group, const std::string& name, ConsoleCommand* command);
-            static void unregisterCommand(ConsoleCommand* command);
     };
-
-    /**
-        @brief Creates a new ConsoleCommand.
-        @param name The name of the command
-        @param executor The executor of the command
-        @param bInitialized If true, the command is ready to be executed, otherwise it has to be activated first.
-    */
-    inline ConsoleCommand* createConsoleCommand(const std::string& name, const ExecutorPtr& executor, bool bInitialized = true)
-        { return new ConsoleCommand("", name, executor, bInitialized); }
-    /**
-        @brief Creates a new ConsoleCommand.
-        @param group The group of the command
-        @param name The name of the command
-        @param executor The executor of the command
-        @param bInitialized If true, the command is ready to be executed, otherwise it has to be activated first.
-    */
-    inline ConsoleCommand* createConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized = true)
-        { return new ConsoleCommand(group, name, executor, bInitialized); }
-
-
-    /**
-        @brief Returns a manipulator for a command with the given name.
-
-        @note If the command doesn't exist, the manipulator contains a NULL pointer to the command,
-        but it can still be used without checks, because all functions of ConsoleCommandManipulator
-        check internally if the command exists.
-    */
-    inline ConsoleCommand::ConsoleCommandManipulator ModifyConsoleCommand(const std::string& name)
-        { return ConsoleCommand::getCommand(name, true); }
-    /**
-        @brief Returns a manipulator for a command with the given group and name.
-
-        @note If the command doesn't exist, the manipulator contains a NULL pointer to the command,
-        but it can still be used without checks, because all functions of ConsoleCommandManipulator
-        check internally if the command exists.
-    */
-    inline ConsoleCommand::ConsoleCommandManipulator ModifyConsoleCommand(const std::string& group, const std::string& name)
-        { return ConsoleCommand::getCommand(group, name, true); }
 }
 
Index: code/trunk/src/libraries/core/command/ConsoleCommandCompilation.cc
===================================================================
--- code/trunk/src/libraries/core/command/ConsoleCommandCompilation.cc	(revision 10622)
+++ code/trunk/src/libraries/core/command/ConsoleCommandCompilation.cc	(revision 10624)
@@ -41,5 +41,5 @@
 #include "util/ExprParser.h"
 #include "util/StringUtils.h"
-#include "ConsoleCommand.h"
+#include "ConsoleCommandIncludes.h"
 #include "CommandExecutor.h"
 
Index: code/trunk/src/libraries/core/command/ConsoleCommandIncludes.cc
===================================================================
--- code/trunk/src/libraries/core/command/ConsoleCommandIncludes.cc	(revision 10624)
+++ code/trunk/src/libraries/core/command/ConsoleCommandIncludes.cc	(revision 10624)
@@ -0,0 +1,44 @@
+/*
+ *   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 "ConsoleCommandIncludes.h"
+
+#include "ConsoleCommandManager.h"
+
+namespace orxonox
+{
+    void StaticallyInitializedConsoleCommand::load()
+    {
+        ConsoleCommandManager::getInstance().registerCommand(this->command_);
+    }
+
+    void StaticallyInitializedConsoleCommand::unload()
+    {
+        ConsoleCommandManager::getInstance().unregisterCommand(this->command_);
+    }
+}
Index: code/trunk/src/libraries/core/command/ConsoleCommandIncludes.h
===================================================================
--- code/trunk/src/libraries/core/command/ConsoleCommandIncludes.h	(revision 10624)
+++ code/trunk/src/libraries/core/command/ConsoleCommandIncludes.h	(revision 10624)
@@ -0,0 +1,350 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+/**
+    @defgroup ConsoleCommand Console commands
+    @ingroup Command
+*/
+
+/**
+    @file
+    @ingroup Command ConsoleCommand
+    @brief Declaration the SetConsoleCommand() macro.
+
+    @anchor ConsoleCommandExample
+
+    Console commands can be used to write scripts, use key-bindings or simply to be
+    entered into the shell by the user. Instances of orxonox::ConsoleCommand define
+    the function of a command, and also more information like, for example, if it is
+    active, default values, and possible arguments.
+
+    Commands need to be registered to the system statically on startup by using the
+    SetConsoleCommand() or DeclareConsoleCommand() macros outside of a function.
+    This ensures that commands are known to the system at any time, so they can be
+    evaluated (see orxonox::CommandExecutor::evaluate()), for example for key-bindings.
+
+    Example:
+    @code
+    void myCoutFunction(const std::string& text)        // Define a static function
+    {
+        orxout() << "Text: " << text << endl;           // Print the text to the console
+    }
+
+    SetConsoleCommand("cout", &myCoutFunction);         // Register the function as command with name "cout"
+    @endcode
+
+    Now you can open the shell and execute the command:
+    @code
+    $ cout Hello World
+    @endcode
+
+    Internally this command is now passed to orxonox::CommandExecutor::execute():
+    @code
+    CommandExecutor::execute("cout HelloWorld");
+    @endcode
+
+    CommandExecutor searches for a command with name "cout" and passes the arguments
+    "Hello World" to it. Because we registered myCoutFunction() with this command,
+    as a result the following text will be printed to the console:
+    @code
+    Text: Hello World
+    @endcode
+
+    You can add more attributes to the ConsoleCommand, by using the command-chain feature
+    of SetConsoleCommand(). For example like this:
+    @code
+    SetConsoleCommand("cout", &myCoutFunction)
+        .addGroup("output", "text")
+        .accessLevel(AccessLevel::Offline)
+        .defaultValues("no text");
+    @endcode
+
+    Open the shell again and try it:
+    @code
+    $ cout Hello World
+    Text: Hello World
+    $ output text Hello World
+    Text: Hello World
+    $ cout
+    Text: no text
+    @endcode
+
+    If you execute it online (note: the access level is "Offline"), you will see the
+    following (or something similar):
+    @code
+    $ cout Hello World
+    Error: Can't execute command "cout", access denied.
+    @endcode
+
+    If a command is executed, the arguments are passed to an underlying function,
+    whitch is wrapped by an orxonox::Functor which again is wrapped by an orxonox::Executor.
+    The Functor contains the function-pointer, as well as the object-pointer in
+    case of a non-static member-function. The executor stores possible default-values
+    for each argument of the function.
+
+    The function of a command can be changed at any time. It's possible to just exchange
+    the function-pointer of the underlying Functor if the headers of the functions are
+    exactly the same. But you can also exchange the Functor itself or even completely
+    replace the Executor. Also the other attributes of a ConsoleCommand can be modified
+    during the game, for example it can be activated or deactivated.
+
+    To do so, the function ModifyConsoleCommand() has to be used. It returns an instance
+    of orxonox::ConsoleCommand::ConsoleCommandManipulator which has an interface similar to
+    orxonox::ConsoleCommand, but with slight differences. You can use it the same way like
+    SetConsoleCommand(), meaning you can use command-chains to change different attributes at
+    the same time. ModifyConsoleCommand() must not be executed statically, but rather in a
+    function at some point of the execution of the program.
+
+    Example:
+    @code
+    void myOtherCoutFunction(const std::string& text)                       // Define a new static function
+    {
+        orxout() << "Uppercase: " << getUppercase(text) << endl;            // Print the text in uppercase to the console
+    }
+
+    {
+        // ...                                                              // somewhere in the code
+
+        ModifyConsoleCommand("cout").setFunction(&myOtherCoutFunction);     // Modify the underlying function of the command
+
+        // ...
+    }
+    @endcode
+
+    If you now enter the command into the shell, you'll see a different behavior:
+    @code
+    $ cout Hello World
+    Uppercase: HELLO WORLD
+    $ cout
+    Uppercase: NO TEXT
+    @endcode
+
+    A few important notes about changing functions:
+
+    Instead of changing the function with setFunction(), you can also create a command-stack
+    by using pushFunction() and popFunction(). It's important to note a few things about that,
+    because the underlying structure of Executor and Functor has a few pitfalls:
+     - If you push a new function-pointer, the same executor as before will be used (and, if
+       the headers match, even the same functor can be used, which is very fast)
+     - If you push a new Functor, the same executor as before will be used
+     - If you push a new Executor, everything is changed
+
+    Note that the executor contains the @b default @b values, so if you just exchange the
+    Functor, the default values remain the same. However if you decide to change the default
+    values at any point of the stack, <b>this will also change the default values on all
+    other stack-levels</b> that share the same executor. If you don't like this behavior,
+    you have to explicitly push a new executor before changing the default values, either by
+    calling pushFunction(executor) or by calling pushFunction(void) which pushes a copy of
+    the current executor to the stack.
+
+    Another important point are object pointers in case of non-static member-functions.
+    Whenever you set or push a new function, <b>you must add the object pointer again</b>
+    because objects are stored in the Functor which is usually exchanged if you change
+    the function.
+
+    You can also use a stack for objects, but note that this <b>object-stack is different for each
+    function</b> - so if you set a new function, the object-stack will be cleared. If you push
+    a new function, the old object-stack is stored in the stack, so it can be restored if
+    you pop the function.
+
+    %DeclareConsoleCommand():
+
+    Appart from SetConsoleCommand() you can also call DeclareConsoleCommand(). In contrast
+    to SetConsoleCommand(), this doesn't assign a function to the command. Indeed you have
+    to pass a function-pointer to DeclareConsoleCommand(), but it is only used to determine
+    the header of the future command-function. This allows to declare a command statically,
+    thus it's possible to evaluate key-bindings of this command, but the actual function
+    can be assigned at a later point.
+
+    Example:
+    @code
+    DeclareConsoleCommand("cout", &prototype::void__string);
+    @endcode
+
+    If you try to execute the command now, you see the following (or something similar):
+    @code
+    $ cout Hello World
+    Error: Can't execute command "cout", command is not active.
+    @endcode
+
+    You first have to assign a function to use the command:
+    @code
+    {
+        // ...
+
+        ModifyConsoleCommand("cout").setFunction(&myCoutFunction);
+
+        // ...
+    }
+    @endcode
+
+    Now you can use it:
+    @code
+    $ cout Hello World
+    Text: Hello World
+    @endcode
+
+    Note that the initial function prototype::void__string is defined in the namespace
+    orxonox::prototype. If there's no function with the desired header, you can extend
+    the collection of functions or simply use another function that has the same header.
+*/
+
+#ifndef _ConsoleCommandIncludes_H__
+#define _ConsoleCommandIncludes_H__
+
+#include "core/CorePrereqs.h"
+
+#include "ConsoleCommand.h"
+#include "ConsoleCommandManager.h"
+#include "util/VA_NARGS.h"
+#include "core/module/StaticallyInitializedInstance.h"
+
+
+/**
+    @brief Defines a console command. The macro is overloaded for 2-4 parameters.
+
+    This is an overloaded macro. Depending on the number of arguments a different
+    overloaded implementation of the macro will be chosen.
+
+    Console commands created with SetConsoleCommand() become active immediately and
+    the given function-pointer (and optionally the object) will be used to execute
+    the command.
+*/
+#define SetConsoleCommand(...) \
+    BOOST_PP_EXPAND(BOOST_PP_CAT(SetConsoleCommand, ORXONOX_VA_NARGS(__VA_ARGS__))(__VA_ARGS__))
+/**
+    @brief This macro is executed if you call SetConsoleCommand() with 2 arguments.
+    @param name The name (string) of the console command
+    @param functionpointer The function-pointer of the corresponding command-function
+*/
+#define SetConsoleCommand2(name, functionpointer) \
+    SetConsoleCommandGeneric("", name, orxonox::createFunctor(functionpointer))
+/**
+    @brief This macro is executed if you call SetConsoleCommand() with 3 arguments.
+    @param group The group (string) of the console command
+    @param name The name (string) of the console command
+    @param functionpointer The function-pointer of the corresponding command-function
+*/
+#define SetConsoleCommand3(group, name, functionpointer) \
+    SetConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer))
+/**
+    @brief This macro is executed if you call SetConsoleCommand() with 4 arguments.
+    @param group The group (string) of the console command
+    @param name The name (string) of the console command
+    @param functionpointer The function-pointer of the corresponding command-function
+    @param object The object that will be assigned to the command. Used for member-functions.
+*/
+#define SetConsoleCommand4(group, name, functionpointer, object) \
+    SetConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer, object))
+
+/// Internal macro
+#define SetConsoleCommandGeneric(group, name, functor) \
+    static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) \
+        = (new orxonox::SI_CC(new orxonox::ConsoleCommand(group, name, orxonox::createExecutor(functor))))->getCommand()
+
+
+/**
+    @brief Declares a console command. The macro is overloaded for 2-3 parameters.
+
+    This is an overloaded macro. Depending on the number of arguments a different
+    overloaded implementation of the macro will be chosen.
+
+    Console commands created with DeclareConsoleCommand() don't use the the given
+    function-pointer to execute the command, it is only used to define the header
+    of the future command-function. The command is inactive until you manually
+    set a function with orxonox::ModifyConsoleCommand(). You can use a different
+    function-pointer than in the final command, as long as it has the same header.
+*/
+#define DeclareConsoleCommand(...) \
+    BOOST_PP_EXPAND(BOOST_PP_CAT(DeclareConsoleCommand, ORXONOX_VA_NARGS(__VA_ARGS__))(__VA_ARGS__))
+/**
+    @brief This macro is executed if you call DeclareConsoleCommand() with 2 arguments.
+    @param name The name (string) of the console command
+    @param functionpointer The function-pointer of an arbitrary function that has the same header as the final function
+*/
+#define DeclareConsoleCommand2(name, functionpointer) \
+    DeclareConsoleCommandGeneric("", name, orxonox::createFunctor(functionpointer))
+/**
+    @brief This macro is executed if you call DeclareConsoleCommand() with 3 arguments.
+    @param group The group (string) of the console command
+    @param name The name (string) of the console command
+    @param functionpointer The function-pointer of an arbitrary function that has the same header as the final function
+*/
+#define DeclareConsoleCommand3(group, name, functionpointer) \
+    DeclareConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer))
+
+/// Internal macro
+#define DeclareConsoleCommandGeneric(group, name, functor) \
+    static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) \
+        = (new orxonox::SI_CC(new orxonox::ConsoleCommand(group, name, orxonox::createExecutor(functor), false)))->getCommand()
+
+
+namespace orxonox
+{
+    class _CoreExport StaticallyInitializedConsoleCommand : public StaticallyInitializedInstance
+    {
+        public:
+            StaticallyInitializedConsoleCommand(ConsoleCommand* command)
+                : StaticallyInitializedInstance(StaticInitialization::CONSOLE_COMMAND)
+                , command_(command)
+            {}
+            ~StaticallyInitializedConsoleCommand() { delete command_; }
+
+            virtual void load();
+            virtual void unload();
+
+            inline ConsoleCommand& getCommand()
+                { return *this->command_; }
+
+        private:
+            ConsoleCommand* command_;
+    };
+
+    typedef StaticallyInitializedConsoleCommand SI_CC;
+
+    /**
+        @brief Returns a manipulator for a command with the given name.
+
+        @note If the command doesn't exist, the manipulator contains a NULL pointer to the command,
+        but it can still be used without checks, because all functions of ConsoleCommandManipulator
+        check internally if the command exists.
+    */
+    inline ConsoleCommand::ConsoleCommandManipulator ModifyConsoleCommand(const std::string& name)
+        { return ConsoleCommandManager::getInstance().getCommand(name, true); }
+    /**
+        @brief Returns a manipulator for a command with the given group and name.
+
+        @note If the command doesn't exist, the manipulator contains a NULL pointer to the command,
+        but it can still be used without checks, because all functions of ConsoleCommandManipulator
+        check internally if the command exists.
+    */
+    inline ConsoleCommand::ConsoleCommandManipulator ModifyConsoleCommand(const std::string& group, const std::string& name)
+        { return ConsoleCommandManager::getInstance().getCommand(group, name, true); }
+}
+
+#endif /* _ConsoleCommandIncludes_H__ */
Index: code/trunk/src/libraries/core/command/ConsoleCommandManager.cc
===================================================================
--- code/trunk/src/libraries/core/command/ConsoleCommandManager.cc	(revision 10624)
+++ code/trunk/src/libraries/core/command/ConsoleCommandManager.cc	(revision 10624)
@@ -0,0 +1,189 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Implementation of the ConsoleCommand class.
+*/
+
+#include "ConsoleCommandManager.h"
+
+#include "ConsoleCommand.h"
+#include "util/StringUtils.h"
+
+namespace orxonox
+{
+    ConsoleCommandManager* ConsoleCommandManager::singletonPtr_s = 0;
+
+    /**
+        @brief Returns the command with given group an name.
+        @param group The group of the requested command
+        @param name The group of the requested command
+        @param bPrintError If true, an error is printed if the command doesn't exist
+    */
+    ConsoleCommand* ConsoleCommandManager::getCommand(const std::string& group, const std::string& name, bool bPrintError)
+    {
+        // find the group
+        std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = this->commandMap_.find(group);
+        if (it_group != this->commandMap_.end())
+        {
+            // find the name
+            std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.find(name);
+            if (it_name != it_group->second.end())
+            {
+                // return the pointer
+                return it_name->second;
+            }
+        }
+        if (bPrintError)
+        {
+            if (group == "")
+                orxout(internal_error, context::commands) << "Couldn't find console command with shortcut \"" << name << "\"" << endl;
+            else
+                orxout(internal_error, context::commands) << "Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << endl;
+        }
+        return 0;
+    }
+
+    /**
+        @brief Returns the command with given group an name in lowercase.
+        @param group The group of the requested command in lowercase
+        @param name The group of the requested command in lowercase
+        @param bPrintError If true, an error is printed if the command doesn't exist
+    */
+    ConsoleCommand* ConsoleCommandManager::getCommandLC(const std::string& group, const std::string& name, bool bPrintError)
+    {
+        std::string groupLC = getLowercase(group);
+        std::string nameLC = getLowercase(name);
+
+        // find the group
+        std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = this->commandMapLC_.find(groupLC);
+        if (it_group != this->commandMapLC_.end())
+        {
+            // find the name
+            std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.find(nameLC);
+            if (it_name != it_group->second.end())
+            {
+                // return the pointer
+                return it_name->second;
+            }
+        }
+        if (bPrintError)
+        {
+            if (group == "")
+                orxout(internal_error, context::commands) << "Couldn't find console command with shortcut \"" << name << "\"" << endl;
+            else
+                orxout(internal_error, context::commands) << "Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << endl;
+        }
+        return 0;
+    }
+
+    /**
+        @brief Registers a new command with the groups and names that are defined by ConsoleCommand::getNames().
+    */
+    void ConsoleCommandManager::registerCommand(ConsoleCommand* command)
+    {
+        for (size_t i = 0; i < command->getNames().size(); ++i)
+        {
+            const ConsoleCommand::CommandName& name = command->getNames()[i];
+            this->registerCommand(name.group_, name.name_, command);
+        }
+    }
+
+    /**
+        @brief Registers a new command with given group an name by adding it to the command map.
+    */
+    void ConsoleCommandManager::registerCommand(const std::string& group, const std::string& name, ConsoleCommand* command)
+    {
+        if (name == "")
+            return;
+
+        // check if a command with this name already exists
+        if (this->getCommand(group, name) != 0)
+        {
+            if (group == "")
+                orxout(internal_warning, context::commands) << "A console command with shortcut \"" << name << "\" already exists." << endl;
+            else
+                orxout(internal_warning, context::commands) << "A console command with name \"" << name << "\" already exists in group \"" << group << "\"." << endl;
+        }
+        else
+        {
+            // add the command to the map
+            this->commandMap_[group][name] = command;
+            this->commandMapLC_[getLowercase(group)][getLowercase(name)] = command;
+        }
+    }
+
+    /**
+        @brief Removes the command from the command map.
+    */
+    void ConsoleCommandManager::unregisterCommand(ConsoleCommand* command)
+    {
+        // iterate through all groups
+        for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::iterator it_group = this->commandMap_.begin(); it_group != this->commandMap_.end(); )
+        {
+            // iterate through all commands of each group
+            for (std::map<std::string, ConsoleCommand*>::iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); )
+            {
+                // erase the command
+                if (it_name->second == command)
+                    it_group->second.erase(it_name++);
+                else
+                    ++it_name;
+            }
+
+            // erase the group if it is empty now
+            if (it_group->second.empty())
+                this->commandMap_.erase(it_group++);
+            else
+                ++it_group;
+        }
+
+        // now the same for the lowercase-map:
+
+        // iterate through all groups
+        for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::iterator it_group = this->commandMapLC_.begin(); it_group != this->commandMapLC_.end(); )
+        {
+            // iterate through all commands of each group
+            for (std::map<std::string, ConsoleCommand*>::iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); )
+            {
+                // erase the command
+                if (it_name->second == command)
+                    it_group->second.erase(it_name++);
+                else
+                    ++it_name;
+            }
+
+            // erase the group if it is empty now
+            if (it_group->second.empty())
+                this->commandMapLC_.erase(it_group++);
+            else
+                ++it_group;
+        }
+    }
+}
Index: code/trunk/src/libraries/core/command/ConsoleCommandManager.h
===================================================================
--- code/trunk/src/libraries/core/command/ConsoleCommandManager.h	(revision 10624)
+++ code/trunk/src/libraries/core/command/ConsoleCommandManager.h	(revision 10624)
@@ -0,0 +1,80 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+/**
+    @defgroup ConsoleCommand Console commands
+    @ingroup Command
+*/
+
+#ifndef _ConsoleCommandManager_H__
+#define _ConsoleCommandManager_H__
+
+#include "core/CorePrereqs.h"
+
+#include "util/Singleton.h"
+
+namespace orxonox
+{
+    /**
+     * A singleton that stores all existing ConsoleCommands.
+     */
+    class _CoreExport ConsoleCommandManager : public Singleton<ConsoleCommandManager>
+    {
+        friend class Singleton<ConsoleCommandManager>;
+
+        public:
+            void registerCommand(ConsoleCommand* command);
+            void registerCommand(const std::string& group, const std::string& name, ConsoleCommand* command);
+            void unregisterCommand(ConsoleCommand* command);
+
+            /// Returns the map with all groups and commands.
+            inline const std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommands()
+                { return this->commandMap_; }
+            /// Returns the map with all groups and commands in lowercase.
+            inline const std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommandsLC()
+                { return this->commandMapLC_; }
+
+            /// Returns a command (shortcut) with given name. @param name The name of the command shortcut @param bPrintError If true, an error is printed if the command doesn't exist
+            inline ConsoleCommand* getCommand(const std::string& name, bool bPrintError = false)
+                { return this->getCommand("", name, bPrintError); }
+            /// Returns a command (shortcut) with given name in lowercase. @param name The lowercase name of the command shortcut @param bPrintError If true, an error is printed if the command doesn't exist
+            inline ConsoleCommand* getCommandLC(const std::string& name, bool bPrintError = false)
+                { return this->getCommandLC("", name, bPrintError); }
+
+            ConsoleCommand* getCommand(const std::string& group, const std::string& name, bool bPrintError = false);
+            ConsoleCommand* getCommandLC(const std::string& group, const std::string& name, bool bPrintError = false);
+
+        private:
+            std::map<std::string, std::map<std::string, ConsoleCommand*> > commandMap_;
+            std::map<std::string, std::map<std::string, ConsoleCommand*> > commandMapLC_;
+
+            static ConsoleCommandManager* singletonPtr_s;
+    };
+}
+
+#endif /* _ConsoleCommandManager_H__ */
Index: code/trunk/src/libraries/core/command/IRC.cc
===================================================================
--- code/trunk/src/libraries/core/command/IRC.cc	(revision 10622)
+++ code/trunk/src/libraries/core/command/IRC.cc	(revision 10624)
@@ -39,5 +39,5 @@
 #include "util/Exception.h"
 #include "util/StringUtils.h"
-#include "ConsoleCommand.h"
+#include "ConsoleCommandIncludes.h"
 #include "TclThreadManager.h"
 
Index: code/trunk/src/libraries/core/command/Shell.cc
===================================================================
--- code/trunk/src/libraries/core/command/Shell.cc	(revision 10622)
+++ code/trunk/src/libraries/core/command/Shell.cc	(revision 10624)
@@ -42,5 +42,5 @@
 #include "core/config/ConfigFileManager.h"
 #include "core/config/ConfigValueIncludes.h"
-#include "core/PathConfig.h"
+#include "core/ApplicationPaths.h"
 #include "core/input/InputBuffer.h"
 #include "CommandExecutor.h"
@@ -84,5 +84,5 @@
 
         // Choose the default level according to the path Orxonox was started (build directory or not)
-        OutputLevel defaultDebugLevel = (PathConfig::buildDirectoryRun() ? DefaultLogLevel::Dev : DefaultLogLevel::User);
+        OutputLevel defaultDebugLevel = (ApplicationPaths::buildDirectoryRun() ? DefaultLogLevel::Dev : DefaultLogLevel::User);
         this->setLevelMax(defaultDebugLevel);
 
@@ -164,5 +164,5 @@
     void Shell::devModeChanged(bool value)
     {
-        bool isNormal = (value == PathConfig::buildDirectoryRun());
+        bool isNormal = (value == ApplicationPaths::buildDirectoryRun());
         if (isNormal)
         {
Index: code/trunk/src/libraries/core/command/Shell.h
===================================================================
--- code/trunk/src/libraries/core/command/Shell.h	(revision 10622)
+++ code/trunk/src/libraries/core/command/Shell.h	(revision 10624)
@@ -49,5 +49,5 @@
 
 #include "util/output/BaseWriter.h"
-#include "core/Core.h"
+#include "core/CoreConfig.h"
 
 namespace orxonox
Index: code/trunk/src/libraries/core/command/TclBind.cc
===================================================================
--- code/trunk/src/libraries/core/command/TclBind.cc	(revision 10622)
+++ code/trunk/src/libraries/core/command/TclBind.cc	(revision 10624)
@@ -37,7 +37,7 @@
 #include "util/Exception.h"
 #include "util/StringUtils.h"
-#include "core/PathConfig.h"
+#include "core/ApplicationPaths.h"
 #include "CommandExecutor.h"
-#include "ConsoleCommand.h"
+#include "ConsoleCommandIncludes.h"
 #include "TclThreadManager.h"
 
@@ -143,8 +143,8 @@
     {
 #ifdef DEPENDENCY_PACKAGE_ENABLE
-        if (PathConfig::buildDirectoryRun())
+        if (ApplicationPaths::buildDirectoryRun())
             return (std::string(specialConfig::dependencyLibraryDirectory) + "/tcl");
         else
-            return (PathConfig::getRootPathString() + specialConfig::defaultLibraryPath + "/tcl");
+            return (ApplicationPaths::getRootPathString() + specialConfig::defaultLibraryPath + "/tcl");
 #else
         return "";
Index: code/trunk/src/libraries/core/command/TclThreadManager.cc
===================================================================
--- code/trunk/src/libraries/core/command/TclThreadManager.cc	(revision 10622)
+++ code/trunk/src/libraries/core/command/TclThreadManager.cc	(revision 10624)
@@ -47,5 +47,5 @@
 #include "core/CoreIncludes.h"
 #include "CommandExecutor.h"
-#include "ConsoleCommand.h"
+#include "ConsoleCommandIncludes.h"
 #include "TclBind.h"
 #include "TclThreadList.h"
Index: code/trunk/src/libraries/core/commandline/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/core/commandline/CMakeLists.txt	(revision 10624)
+++ code/trunk/src/libraries/core/commandline/CMakeLists.txt	(revision 10624)
@@ -0,0 +1,3 @@
+ADD_SOURCE_FILES(CORE_SRC_FILES
+  CommandLineParser.cc
+)
Index: code/trunk/src/libraries/core/commandline/CommandLineIncludes.h
===================================================================
--- code/trunk/src/libraries/core/commandline/CommandLineIncludes.h	(revision 10624)
+++ code/trunk/src/libraries/core/commandline/CommandLineIncludes.h	(revision 10624)
@@ -0,0 +1,82 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+/**
+    @defgroup CmdArgs Commandline arguments
+    @ingroup Config
+    @brief For a reference of all commandline arguments see @ref cmdargspage
+*/
+
+/**
+    @file
+    @ingroup Config CmdArgs
+    @brief Declaration of CommandLineParser and CommandLineArgument, definition of the SetCommandLineArgument() macros.
+*/
+
+#ifndef _CommandLineIncludes_H__
+#define _CommandLineIncludes_H__
+
+#include "core/CorePrereqs.h"
+
+#include "CommandLineParser.h"
+#include "core/module/StaticallyInitializedInstance.h"
+
+#define SetCommandLineArgument(name, defaultValue) \
+    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
+        = (new orxonox::SI_CLA(new orxonox::CommandLineArgument(#name, defaultValue)))->getArgument()
+#define SetCommandLineSwitch(name) \
+    SetCommandLineArgument(name, false)
+
+namespace orxonox
+{
+    class _CoreExport StaticallyInitializedCommandLineArgument : public StaticallyInitializedInstance
+    {
+        public:
+            StaticallyInitializedCommandLineArgument(CommandLineArgument* argument)
+                : StaticallyInitializedInstance(StaticInitialization::COMMAND_LINE_ARGUMENT)
+                , argument_(argument)
+            {}
+            ~StaticallyInitializedCommandLineArgument() { delete argument_; }
+
+            virtual void load()
+                { CommandLineParser::addArgument(this->argument_); }
+
+            virtual void unload()
+                { CommandLineParser::removeArgument(this->argument_); }
+
+            inline CommandLineArgument& getArgument()
+                { return *this->argument_; }
+
+        private:
+            CommandLineArgument* argument_;
+    };
+
+    typedef StaticallyInitializedCommandLineArgument SI_CLA;
+}
+
+#endif /* _CommandLineIncludes_H__ */
Index: code/trunk/src/libraries/core/commandline/CommandLineParser.cc
===================================================================
--- code/trunk/src/libraries/core/commandline/CommandLineParser.cc	(revision 10624)
+++ code/trunk/src/libraries/core/commandline/CommandLineParser.cc	(revision 10624)
@@ -0,0 +1,341 @@
+/*
+ *   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 "CommandLineParser.h"
+
+#include <algorithm>
+#include <sstream>
+
+#include "util/Convert.h"
+#include "util/Output.h"
+#include "util/Exception.h"
+#include "util/StringUtils.h"
+#include "util/SubString.h"
+
+namespace orxonox
+{
+    CommandLineParser* CommandLineParser::singletonPtr_s = 0;
+
+    /**
+    @brief
+        Parses a value string for a command line argument.
+        It simply uses convertValue(Output, Input) to do that.
+        Bools are treated specially. That is necessary
+        so that you can have simple command line switches.
+    */
+    void CommandLineArgument::parse(const std::string& value)
+    {
+        if (value_.isType<bool>())
+        {
+            // simulate command line switch
+            bool temp;
+            if (convertValue(&temp, value))
+            {
+                this->bHasDefaultValue_ = false;
+                this->value_ = temp;
+            }
+            else if (value.empty())
+            {
+                this->bHasDefaultValue_ = false;
+                this->value_ = true;
+            }
+            else
+                ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
+        }
+        else
+        {
+            if (!value_.set(value))
+            {
+                value_.set(defaultValue_);
+                ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
+            }
+            else
+                this->bHasDefaultValue_ = false;
+        }
+    }
+
+
+    /**
+    @brief
+        Destructor destroys all CommandLineArguments with it.
+    */
+    CommandLineParser::~CommandLineParser()
+    {
+    }
+
+    /** Parses the command line string for arguments and stores these.
+    @note
+        The reason that you have to provide the string to be parsed as
+        space separated list is because of argc and argv. If you only have
+        a whole string, simply use getAllStrings() of SubString.
+    @param cmdLine
+        Command line string WITHOUT the execution path.
+    */
+    void CommandLineParser::_parse(const std::string& cmdLine)
+    {
+        std::vector<std::string> arguments;
+        SubString tokens(cmdLine, " ", " ", false, '\\', true, '"', true, '\0', '\0', false);
+        for (unsigned i = 0; i < tokens.size(); ++i)
+            arguments.push_back(tokens[i]);
+
+        try
+        {
+            // why this? See bFirstTimeParse_ declaration.
+            if (bFirstTimeParse_)
+            {
+                // first shove all the shortcuts in a map
+                for (std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.begin();
+                    it != cmdLineArgs_.end(); ++it)
+                {
+                    OrxAssert(cmdLineArgsShortcut_.find(it->second->getShortcut()) == cmdLineArgsShortcut_.end(),
+                        "Cannot have two command line shortcut with the same name.");
+                    if (!it->second->getShortcut().empty())
+                        cmdLineArgsShortcut_[it->second->getShortcut()] = it->second;
+                }
+                bFirstTimeParse_ = false;
+            }
+
+            std::string name;
+            std::string shortcut;
+            std::string value;
+            for (unsigned int i = 0; i < arguments.size(); ++i)
+            {
+                if (arguments[i].size() != 0)
+                {
+                    // sure not ""
+                    if (arguments[i][0] == '-')
+                    {
+                        // start with "-"
+                        if (arguments[i].size() == 1)
+                        {
+                            // argument[i] is "-", probably a minus sign
+                            value += "- ";
+                        }
+                        else if (arguments[i][1] <= 57 && arguments[i][1] >= 48)
+                        {
+                            // negative number as a value
+                            value += arguments[i] + ' ';
+                        }
+                        else
+                        {
+                            // can be shortcut or full name argument
+
+                            // save old data first
+                            value = removeTrailingWhitespaces(value);
+                            if (!name.empty())
+                            {
+                                checkFullArgument(name, value);
+                                name.clear();
+                                assert(shortcut.empty());
+                            }
+                            else if (!shortcut.empty())
+                            {
+                                checkShortcut(shortcut, value);
+                                shortcut.clear();
+                                assert(name.empty());
+                            }
+
+                            if (arguments[i][1] == '-')
+                            {
+                                // full name argument with "--name"
+                                name = arguments[i].substr(2);
+                            }
+                            else
+                            {
+                                // shortcut with "-s"
+                                shortcut = arguments[i].substr(1);
+                            }
+
+                            // reset value string
+                            value.clear();
+                        }
+                    }
+                    else
+                    {
+                        // value string
+
+                        if (name.empty() && shortcut.empty())
+                        {
+                            ThrowException(Argument, "Expected \"-\" or \"-\" in command line arguments.\n");
+                        }
+
+                        // Concatenate strings as long as there's no new argument by "-" or "--"
+                        value += arguments[i] + ' ';
+                    }
+                }
+            }
+
+            // parse last argument
+            value = removeTrailingWhitespaces(value);
+            if (!name.empty())
+            {
+                checkFullArgument(name, value);
+                assert(shortcut.empty());
+            }
+            else if (!shortcut.empty())
+            {
+                checkShortcut(shortcut, value);
+                assert(name.empty());
+            }
+        }
+        catch (const ArgumentException& ex)
+        {
+            orxout(user_error) << "Could not parse command line: " << ex.what() << endl;
+            orxout(user_error) << CommandLineParser::getUsageInformation() << endl;
+            throw GeneralException("");
+        }
+    }
+
+    /**
+    @brief
+        Parses an argument based on its full name.
+    @param name
+        Full name of the argument
+    @param value
+        String containing the value
+    @param bParsingFile
+        Parsing a file or the command line itself
+    */
+    void CommandLineParser::checkFullArgument(const std::string& name, const std::string& value)
+    {
+        std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.find(name);
+        if (it == cmdLineArgs_.end())
+            ThrowException(Argument, "Command line argument '" + name + "' does not exist.");
+
+        it->second->parse(value);
+    }
+
+    /**
+    @brief
+        Parses an argument based on its shortcut.
+    @param shortcut
+        Shortcut to the argument
+    @param value
+        String containing the value
+    @param bParsingFile
+        Parsing a file or the command line itself
+    */
+    void CommandLineParser::checkShortcut(const std::string& shortcut, const std::string& value)
+    {
+        std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgsShortcut_.find(shortcut);
+        if (it == cmdLineArgsShortcut_.end())
+            ThrowException(Argument, "Command line shortcut '" + shortcut + "' does not exist.");
+
+        it->second->parse(value);
+    }
+
+    std::string CommandLineParser::getUsageInformation()
+    {
+        CommandLineParser& inst = getInstance();
+        std::ostringstream infoStr;
+
+        // determine maximum name size
+        size_t maxNameSize = 0;
+        for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst.cmdLineArgs_.begin();
+            it != inst.cmdLineArgs_.end(); ++it)
+        {
+            maxNameSize = std::max(it->second->getName().size(), maxNameSize);
+        }
+
+        infoStr << endl;
+        infoStr << "Usage: orxonox [options]" << endl;
+        infoStr << "Available options:" << endl;
+
+        for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst.cmdLineArgs_.begin();
+            it != inst.cmdLineArgs_.end(); ++it)
+        {
+            if (!it->second->getShortcut().empty())
+                infoStr << " [-" << it->second->getShortcut() << "] ";
+            else
+                infoStr << "      ";
+            infoStr << "--" << it->second->getName() << ' ';
+            if (it->second->getValue().isType<bool>())
+                infoStr << "    ";
+            else
+                infoStr << "ARG ";
+            // fill with the necessary amount of blanks
+            infoStr << std::string(maxNameSize - it->second->getName().size(), ' ');
+            infoStr << ": " << it->second->getInformation();
+            infoStr << endl;
+        }
+        return infoStr.str();
+    }
+
+    void CommandLineParser::generateDoc(std::ofstream& file)
+    {
+        file << "/** @page cmdargspage Command Line Arguments Reference" << endl;
+        file << "    @verbatim"; /*no endl*/
+        file << getUsageInformation(); /*no endl*/
+        file << "    @endverbatim" << endl;
+        file << "*/" << endl;
+    }
+
+    /**
+    @brief
+        Retrieves a CommandLineArgument.
+        The method throws an exception if 'name' was not found or the value could not be converted.
+    @note
+        You should of course not call this method before the command line has been parsed.
+    */
+    const CommandLineArgument* CommandLineParser::getArgument(const std::string& name)
+    {
+        std::map<std::string, CommandLineArgument*>::const_iterator it = getInstance().cmdLineArgs_.find(name);
+        if (it == getInstance().cmdLineArgs_.end())
+        {
+            ThrowException(Argument, "Could find command line argument '" + name + "'.");
+        }
+        else
+        {
+            return it->second;
+        }
+    }
+
+    /**
+    @brief
+        Adds a new CommandLineArgument to the internal map.
+        Note that only such arguments are actually valid.
+    */
+    void CommandLineParser::addArgument(CommandLineArgument* argument)
+    {
+        OrxAssert(!getInstance().existsArgument(argument->getName()),
+            "Cannot add a command line argument with name '" + argument->getName() + "' twice.");
+        OrxAssert(!argument->getDefaultValue().isType<bool>() || argument->getDefaultValue().get<bool>() != true,
+               "Boolean command line arguments with positive default values are not supported." << endl
+            << "Please use SetCommandLineSwitch and adjust your argument: " << argument->getName());
+
+        getInstance().cmdLineArgs_[argument->getName()] = argument;
+    }
+
+    /**
+     * @brief Removes a CommandLineArgument from the internal map.
+     */
+    void CommandLineParser::removeArgument(CommandLineArgument* argument)
+    {
+        getInstance().cmdLineArgs_.erase(argument->getName());
+    }
+}
Index: code/trunk/src/libraries/core/commandline/CommandLineParser.h
===================================================================
--- code/trunk/src/libraries/core/commandline/CommandLineParser.h	(revision 10624)
+++ code/trunk/src/libraries/core/commandline/CommandLineParser.h	(revision 10624)
@@ -0,0 +1,201 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+/**
+    @defgroup CmdArgs Commandline arguments
+    @ingroup Config
+    @brief For a reference of all commandline arguments see @ref cmdargspage
+*/
+
+/**
+    @file
+    @ingroup Config CmdArgs
+    @brief Declaration of CommandLineParser and CommandLineArgument, definition of the SetCommandLineArgument() macros.
+*/
+
+#ifndef _CommandLine_H__
+#define _CommandLine_H__
+
+#include "core/CorePrereqs.h"
+
+#include <fstream>
+#include <map>
+#include "util/OrxAssert.h"
+#include "util/MultiType.h"
+#include "util/Singleton.h"
+
+namespace orxonox
+{
+    /**
+    @brief
+        Container class for a command line argument of any type supported by MultiType.
+
+        Whenever you want to have an option specified by a command line switch,
+        you need to first define it with SetCommandLineArgument(name, defaultValue).
+        It is then added to a map and possibly changed when the command line is being parsed.
+        If the option was not given, you can detect this by asking hasDefaultValue().
+
+        There is a possibility to define a short cut so you can write "-p 20" instead of "--port 20".
+        Note the difference between "-" and "--"!
+        Also, there is no restriction to the number of strings you add after --name.
+        So "--startVector {2, 4, 5}" is perfectly legal.
+
+        Retrieving an argument is possible with the getCommandLineArgument function of the
+        CommandLineParser class. It is a Singleton, but the public interface is static.
+    */
+    class _CoreExport CommandLineArgument
+    {
+        friend class CommandLineParser;
+
+    public:
+        //! Constructor initialises both value_ and defaultValue_ with defaultValue.
+        CommandLineArgument(const std::string& name, const MultiType& defaultValue)
+            : bHasDefaultValue_(true)
+            , name_(name)
+            , value_(defaultValue)
+            , defaultValue_(defaultValue)
+        { }
+        ~CommandLineArgument() { }
+
+        //! Tells whether the value has been changed by the command line.
+        bool hasDefaultValue() const { return bHasDefaultValue_; }
+        //! Returns the name of the argument.
+        const std::string& getName() const { return name_; }
+
+        //! Returns the shortcut (example: "-p 22" for "--port 22") of the argument.
+        //! Evaluates to "" if there is none.
+        const std::string& getShortcut() const { return shortcut_; }
+        //! Sets the shortcut for the argument
+        CommandLineArgument& shortcut(const std::string& shortcut)
+        { this->shortcut_ = shortcut; return *this; }
+
+        //! Returns the usage information
+        const std::string& getInformation() const { return this->usageInformation_; }
+        //! Sets the option information when displaying orxonox usage.
+        CommandLineArgument& information(const std::string& usage)
+        { this->usageInformation_ = usage; return *this; }
+
+        //! Returns the actual value of the argument. Can be equal to default value.
+        const MultiType& getValue() const { return value_; }
+        //! Returns the given default value as type T.
+        const MultiType& getDefaultValue() const { return defaultValue_; }
+
+    private:
+        //! Undefined copy constructor
+        CommandLineArgument(const CommandLineArgument& instance);
+
+        //! Parses the value string of a command line argument.
+        void parse(const std::string& value);
+
+        //! Tells whether the value has been changed by the command line.
+        bool bHasDefaultValue_;
+
+    private:
+        std::string name_;             //!< Name of the argument
+        std::string shortcut_;         //!< Shortcut of the argument. @see getShortcut().
+        std::string usageInformation_; //!< Tells about the usage of this parameter
+
+        MultiType   value_;            //!< The actual value
+        MultiType   defaultValue_;     //!< Default value. Should not be changed.
+    };
+
+
+    /**
+    @brief
+        Global interface to command line options.
+        Allows to add and retrieve command line arguments. Also does the parsing.
+    @note
+        Internally it is a Singleton, but the public interface is static.
+    @see
+        CommandLineArgument
+    */
+    class _CoreExport CommandLineParser : public Singleton<CommandLineParser>
+    {
+        friend class Singleton<CommandLineParser>;
+
+    public:
+        //! Constructor initialises bFirstTimeParse_ with true.
+        CommandLineParser() : bFirstTimeParse_(true) { }
+        ~CommandLineParser();
+
+        //! Parse redirection to internal member method.
+        static void parse(const std::string& cmdLine)
+        { getInstance()._parse(cmdLine); }
+
+        static std::string getUsageInformation();
+
+        static const CommandLineArgument* getArgument(const std::string& name);
+        //! Writes the argument value in the given parameter.
+        template <class T>
+        static void getValue(const std::string& name, T* value)
+        { *value = (T)(getArgument(name)->getValue()); }
+        static const MultiType& getValue(const std::string& name)
+        { return getArgument(name)->getValue(); }
+
+        static void addArgument(CommandLineArgument* argument);
+        static void removeArgument(CommandLineArgument* argument);
+
+        static bool existsArgument(const std::string& name)
+        {
+            std::map<std::string, CommandLineArgument*>::const_iterator it = getInstance().cmdLineArgs_.find(name);
+            return !(it == getInstance().cmdLineArgs_.end());
+        }
+
+        static void generateDoc(std::ofstream& file);
+
+    private:
+        //! Undefined copy constructor
+        CommandLineParser(const CommandLineParser& instance);
+
+        void _parse(const std::string& cmdLine);
+        void checkFullArgument(const std::string& name, const std::string& value);
+        void checkShortcut(const std::string& shortcut, const std::string& value);
+
+        /**
+            Tells whether we parsed for the first time. The CommmandLineArguments are added before main().
+            So when we call parse() the first time, we need to create a map with all shortcuts since these
+            get added after addCommandLineArgument().
+        */
+        bool bFirstTimeParse_;
+
+        //! Holds all pointers to the arguments and serves as a search map by name.
+        std::map<std::string, CommandLineArgument*> cmdLineArgs_;
+        //! Search map by shortcut for the arguments.
+        std::map<std::string, CommandLineArgument*> cmdLineArgsShortcut_;
+
+        static CommandLineParser* singletonPtr_s;
+    };
+
+    template <>
+    inline void CommandLineParser::getValue<std::string>(const std::string& name, std::string* value)
+    {
+        *value = getArgument(name)->getValue().get<std::string>();
+    }
+}
+
+#endif /* _CommandLine_H__ */
Index: code/trunk/src/libraries/core/config/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/core/config/CMakeLists.txt	(revision 10622)
+++ code/trunk/src/libraries/core/config/CMakeLists.txt	(revision 10624)
@@ -1,4 +1,3 @@
 ADD_SOURCE_FILES(CORE_SRC_FILES
-  CommandLineParser.cc
 #  ConfigFile.cc is already included in FilesystemBuildUnit.cc
   ConfigFileEntryValue.cc
Index: code/trunk/src/libraries/core/config/CommandLineParser.cc
===================================================================
--- code/trunk/src/libraries/core/config/CommandLineParser.cc	(revision 10622)
+++ 	(revision )
@@ -1,340 +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 "CommandLineParser.h"
-
-#include <algorithm>
-#include <sstream>
-
-#include "util/Convert.h"
-#include "util/Output.h"
-#include "util/Exception.h"
-#include "util/StringUtils.h"
-#include "util/SubString.h"
-#include "core/PathConfig.h"
-
-namespace orxonox
-{
-    /**
-    @brief
-        Parses a value string for a command line argument.
-        It simply uses convertValue(Output, Input) to do that.
-        Bools are treated specially. That is necessary
-        so that you can have simple command line switches.
-    */
-    void CommandLineArgument::parse(const std::string& value)
-    {
-        if (value_.isType<bool>())
-        {
-            // simulate command line switch
-            bool temp;
-            if (convertValue(&temp, value))
-            {
-                this->bHasDefaultValue_ = false;
-                this->value_ = temp;
-            }
-            else if (value.empty())
-            {
-                this->bHasDefaultValue_ = false;
-                this->value_ = true;
-            }
-            else
-                ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
-        }
-        else
-        {
-            if (!value_.set(value))
-            {
-                value_.set(defaultValue_);
-                ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
-            }
-            else
-                this->bHasDefaultValue_ = false;
-        }
-    }
-
-
-    /**
-    @brief
-        Destructor destroys all CommandLineArguments with it.
-    */
-    CommandLineParser::~CommandLineParser()
-    {
-        CommandLineParser::destroyAllArguments();
-    }
-
-    /**
-    @brief
-        Returns a unique instance (Meyers Singleton).
-    */
-    CommandLineParser& CommandLineParser::_getInstance()
-    {
-        static CommandLineParser instance;
-        return instance;
-    }
-
-    /**
-    @brief
-        Destroys all command line arguments. This should be called at the end
-        of main. Do not use before that.
-    */
-    void CommandLineParser::destroyAllArguments()
-    {
-        for (std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.begin();
-            it != _getInstance().cmdLineArgs_.end(); ++it)
-            delete it->second;
-        _getInstance().cmdLineArgs_.clear();
-    }
-
-    /** Parses the command line string for arguments and stores these.
-    @note
-        The reason that you have to provide the string to be parsed as
-        space separated list is because of argc and argv. If you only have
-        a whole string, simply use getAllStrings() of SubString.
-    @param cmdLine
-        Command line string WITHOUT the execution path.
-    */
-    void CommandLineParser::_parse(const std::string& cmdLine)
-    {
-        std::vector<std::string> arguments;
-        SubString tokens(cmdLine, " ", " ", false, '\\', true, '"', true, '\0', '\0', false);
-        for (unsigned i = 0; i < tokens.size(); ++i)
-            arguments.push_back(tokens[i]);
-
-        try
-        {
-            // why this? See bFirstTimeParse_ declaration.
-            if (bFirstTimeParse_)
-            {
-                // first shove all the shortcuts in a map
-                for (std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.begin();
-                    it != cmdLineArgs_.end(); ++it)
-                {
-                    OrxAssert(cmdLineArgsShortcut_.find(it->second->getShortcut()) == cmdLineArgsShortcut_.end(),
-                        "Cannot have two command line shortcut with the same name.");
-                    if (!it->second->getShortcut().empty())
-                        cmdLineArgsShortcut_[it->second->getShortcut()] = it->second;
-                }
-                bFirstTimeParse_ = false;
-            }
-
-            std::string name;
-            std::string shortcut;
-            std::string value;
-            for (unsigned int i = 0; i < arguments.size(); ++i)
-            {
-                if (arguments[i].size() != 0)
-                {
-                    // sure not ""
-                    if (arguments[i][0] == '-')
-                    {
-                        // start with "-"
-                        if (arguments[i].size() == 1)
-                        {
-                            // argument[i] is "-", probably a minus sign
-                            value += "- ";
-                        }
-                        else if (arguments[i][1] <= 57 && arguments[i][1] >= 48)
-                        {
-                            // negative number as a value
-                            value += arguments[i] + ' ';
-                        }
-                        else
-                        {
-                            // can be shortcut or full name argument
-
-                            // save old data first
-                            value = removeTrailingWhitespaces(value);
-                            if (!name.empty())
-                            {
-                                checkFullArgument(name, value);
-                                name.clear();
-                                assert(shortcut.empty());
-                            }
-                            else if (!shortcut.empty())
-                            {
-                                checkShortcut(shortcut, value);
-                                shortcut.clear();
-                                assert(name.empty());
-                            }
-
-                            if (arguments[i][1] == '-')
-                            {
-                                // full name argument with "--name"
-                                name = arguments[i].substr(2);
-                            }
-                            else
-                            {
-                                // shortcut with "-s"
-                                shortcut = arguments[i].substr(1);
-                            }
-
-                            // reset value string
-                            value.clear();
-                        }
-                    }
-                    else
-                    {
-                        // value string
-
-                        if (name.empty() && shortcut.empty())
-                        {
-                            ThrowException(Argument, "Expected \"-\" or \"-\" in command line arguments.\n");
-                        }
-
-                        // Concatenate strings as long as there's no new argument by "-" or "--"
-                        value += arguments[i] + ' ';
-                    }
-                }
-            }
-
-            // parse last argument
-            value = removeTrailingWhitespaces(value);
-            if (!name.empty())
-            {
-                checkFullArgument(name, value);
-                assert(shortcut.empty());
-            }
-            else if (!shortcut.empty())
-            {
-                checkShortcut(shortcut, value);
-                assert(name.empty());
-            }
-        }
-        catch (const ArgumentException& ex)
-        {
-            orxout(user_error) << "Could not parse command line: " << ex.what() << endl;
-            orxout(user_error) << CommandLineParser::getUsageInformation() << endl;
-            throw GeneralException("");
-        }
-    }
-
-    /**
-    @brief
-        Parses an argument based on its full name.
-    @param name
-        Full name of the argument
-    @param value
-        String containing the value
-    @param bParsingFile
-        Parsing a file or the command line itself
-    */
-    void CommandLineParser::checkFullArgument(const std::string& name, const std::string& value)
-    {
-        std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.find(name);
-        if (it == cmdLineArgs_.end())
-            ThrowException(Argument, "Command line argument '" + name + "' does not exist.");
-
-        it->second->parse(value);
-    }
-
-    /**
-    @brief
-        Parses an argument based on its shortcut.
-    @param shortcut
-        Shortcut to the argument
-    @param value
-        String containing the value
-    @param bParsingFile
-        Parsing a file or the command line itself
-    */
-    void CommandLineParser::checkShortcut(const std::string& shortcut, const std::string& value)
-    {
-        std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgsShortcut_.find(shortcut);
-        if (it == cmdLineArgsShortcut_.end())
-            ThrowException(Argument, "Command line shortcut '" + shortcut + "' does not exist.");
-
-        it->second->parse(value);
-    }
-
-    std::string CommandLineParser::getUsageInformation()
-    {
-        CommandLineParser& inst = _getInstance();
-        std::ostringstream infoStr;
-
-        // determine maximum name size
-        size_t maxNameSize = 0;
-        for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst.cmdLineArgs_.begin();
-            it != inst.cmdLineArgs_.end(); ++it)
-        {
-            maxNameSize = std::max(it->second->getName().size(), maxNameSize);
-        }
-
-        infoStr << endl;
-        infoStr << "Usage: orxonox [options]" << endl;
-        infoStr << "Available options:" << endl;
-
-        for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst.cmdLineArgs_.begin();
-            it != inst.cmdLineArgs_.end(); ++it)
-        {
-            if (!it->second->getShortcut().empty())
-                infoStr << " [-" << it->second->getShortcut() << "] ";
-            else
-                infoStr << "      ";
-            infoStr << "--" << it->second->getName() << ' ';
-            if (it->second->getValue().isType<bool>())
-                infoStr << "    ";
-            else
-                infoStr << "ARG ";
-            // fill with the necessary amount of blanks
-            infoStr << std::string(maxNameSize - it->second->getName().size(), ' ');
-            infoStr << ": " << it->second->getInformation();
-            infoStr << endl;
-        }
-        return infoStr.str();
-    }
-
-    void CommandLineParser::generateDoc(std::ofstream& file)
-    {
-        file << "/** @page cmdargspage Command Line Arguments Reference" << endl;
-        file << "    @verbatim"; /*no endl*/
-        file << getUsageInformation(); /*no endl*/
-        file << "    @endverbatim" << endl;
-        file << "*/" << endl;
-    }
-
-    /**
-    @brief
-        Retrieves a CommandLineArgument.
-        The method throws an exception if 'name' was not found or the value could not be converted.
-    @note
-        You should of course not call this method before the command line has been parsed.
-    */
-    const CommandLineArgument* CommandLineParser::getArgument(const std::string& name)
-    {
-        std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.find(name);
-        if (it == _getInstance().cmdLineArgs_.end())
-        {
-            ThrowException(Argument, "Could find command line argument '" + name + "'.");
-        }
-        else
-        {
-            return it->second;
-        }
-    }
-}
Index: code/trunk/src/libraries/core/config/CommandLineParser.h
===================================================================
--- code/trunk/src/libraries/core/config/CommandLineParser.h	(revision 10622)
+++ 	(revision )
@@ -1,227 +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:
- *      ...
- *
- */
-
-/**
-    @defgroup CmdArgs Commandline arguments
-    @ingroup Config
-    @brief For a reference of all commandline arguments see @ref cmdargspage
-*/
-
-/**
-    @file
-    @ingroup Config CmdArgs
-    @brief Declaration of CommandLineParser and CommandLineArgument, definition of the SetCommandLineArgument() macros.
-*/
-
-#ifndef _CommandLine_H__
-#define _CommandLine_H__
-
-#include "core/CorePrereqs.h"
-
-#include <fstream>
-#include <map>
-#include "util/OrxAssert.h"
-#include "util/MultiType.h"
-
-#define SetCommandLineArgument(name, defaultValue) \
-    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
-    = orxonox::CommandLineParser::addArgument(#name, defaultValue)
-#define SetCommandLineSwitch(name) \
-    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
-    = orxonox::CommandLineParser::addArgument(#name, false)
-
-namespace orxonox
-{
-    /**
-    @brief
-        Container class for a command line argument of any type supported by MultiType.
-
-        Whenever you want to have an option specified by a command line switch,
-        you need to first define it with SetCommandLineArgument(name, defaultValue).
-        It is then added to a map and possibly changed when the command line is being parsed.
-        If the option was not given, you can detect this by asking hasDefaultValue().
-
-        There is a possibility to define a short cut so you can write "-p 20" instead of "--port 20".
-        Note the difference between "-" and "--"!
-        Also, there is no restriction to the number of strings you add after --name.
-        So "--startVector {2, 4, 5}" is perfectly legal.
-
-        Retrieving an argument is possible with the getCommandLineArgument function of the
-        CommandLineParser class. It is a Singleton, but the public interface is static.
-    */
-    class _CoreExport CommandLineArgument
-    {
-        friend class CommandLineParser;
-
-    public:
-        //! Tells whether the value has been changed by the command line.
-        bool hasDefaultValue() const { return bHasDefaultValue_; }
-        //! Returns the name of the argument.
-        const std::string& getName() const { return name_; }
-
-        //! Returns the shortcut (example: "-p 22" for "--port 22") of the argument.
-        //! Evaluates to "" if there is none.
-        const std::string& getShortcut() const { return shortcut_; }
-        //! Sets the shortcut for the argument
-        CommandLineArgument& shortcut(const std::string& shortcut)
-        { this->shortcut_ = shortcut; return *this; }
-
-        //! Returns the usage information
-        const std::string& getInformation() const { return this->usageInformation_; }
-        //! Sets the option information when displaying orxonox usage.
-        CommandLineArgument& information(const std::string& usage)
-        { this->usageInformation_ = usage; return *this; }
-
-        //! Returns the actual value of the argument. Can be equal to default value.
-        const MultiType& getValue() const { return value_; }
-        //! Returns the given default value as type T.
-        const MultiType& getDefaultValue() const { return defaultValue_; }
-
-    private:
-        //! Constructor initialises both value_ and defaultValue_ with defaultValue.
-        CommandLineArgument(const std::string& name, const MultiType& defaultValue)
-            : bHasDefaultValue_(true)
-            , name_(name)
-            , value_(defaultValue)
-            , defaultValue_(defaultValue)
-        { }
-
-        //! Undefined copy constructor
-        CommandLineArgument(const CommandLineArgument& instance);
-        ~CommandLineArgument() { }
-
-        //! Parses the value string of a command line argument.
-        void parse(const std::string& value);
-
-        //! Tells whether the value has been changed by the command line.
-        bool bHasDefaultValue_;
-
-    private:
-        std::string name_;             //!< Name of the argument
-        std::string shortcut_;         //!< Shortcut of the argument. @see getShortcut().
-        std::string usageInformation_; //!< Tells about the usage of this parameter
-
-        MultiType   value_;            //!< The actual value
-        MultiType   defaultValue_;     //!< Default value. Should not be changed.
-    };
-
-
-    /**
-    @brief
-        Global interface to command line options.
-        Allows to add and retrieve command line arguments. Also does the parsing.
-    @note
-        Internally it is a Singleton, but the public interface is static.
-    @see
-        CommandLineArgument
-    */
-    class _CoreExport CommandLineParser
-    {
-    public:
-
-        //! Parse redirection to internal member method.
-        static void parse(const std::string& cmdLine)
-        { _getInstance()._parse(cmdLine); }
-
-        static std::string getUsageInformation();
-
-        static const CommandLineArgument* getArgument(const std::string& name);
-        //! Writes the argument value in the given parameter.
-        template <class T>
-        static void getValue(const std::string& name, T* value)
-        { *value = (T)(getArgument(name)->getValue()); }
-        static const MultiType& getValue(const std::string& name)
-        { return getArgument(name)->getValue(); }
-        template <class T>
-        static CommandLineArgument& addArgument(const std::string& name, T defaultValue);
-
-        static bool existsArgument(const std::string& name)
-        {
-            std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.find(name);
-            return !(it == _getInstance().cmdLineArgs_.end());
-        }
-
-        static void destroyAllArguments();
-
-        static void generateDoc(std::ofstream& file);
-
-    private:
-        //! Constructor initialises bFirstTimeParse_ with true.
-        CommandLineParser() : bFirstTimeParse_(true) { }
-        //! Undefined copy constructor
-        CommandLineParser(const CommandLineParser& instance);
-        ~CommandLineParser();
-
-        static CommandLineParser& _getInstance();
-
-        void _parse(const std::string& cmdLine);
-        void checkFullArgument(const std::string& name, const std::string& value);
-        void checkShortcut(const std::string& shortcut, const std::string& value);
-
-        /**
-            Tells whether we parsed for the first time. The CommmandLineArguments are added before main().
-            So when we call parse() the first time, we need to create a map with all shortcuts since these
-            get added after addCommandLineArgument().
-        */
-        bool bFirstTimeParse_;
-
-        //! Holds all pointers to the arguments and serves as a search map by name.
-        std::map<std::string, CommandLineArgument*> cmdLineArgs_;
-        //! Search map by shortcut for the arguments.
-        std::map<std::string, CommandLineArgument*> cmdLineArgsShortcut_;
-    };
-
-    template <>
-    inline void CommandLineParser::getValue<std::string>(const std::string& name, std::string* value)
-    {
-        *value = getArgument(name)->getValue().get<std::string>();
-    }
-
-    /**
-    @brief
-        Adds a new CommandLineArgument to the internal map.
-        Note that only such arguments are actually valid.
-    @param name
-        Name of the argument. Shortcut can be added later.
-    @param defaultValue
-        Default value that is used when argument was not given.
-    */
-    template <class T>
-    CommandLineArgument& CommandLineParser::addArgument(const std::string& name, T defaultValue)
-    {
-        OrxAssert(!_getInstance().existsArgument(name),
-            "Cannot add a command line argument with name '" + name + "' twice.");
-        OrxAssert(!MultiType(defaultValue).isType<bool>() || MultiType(defaultValue).get<bool>() != true,
-               "Boolean command line arguments with positive default values are not supported." << endl
-            << "Please use SetCommandLineSwitch and adjust your argument: " << name);
-
-        return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue));
-    }
-}
-
-#endif /* _CommandLine_H__ */
Index: code/trunk/src/libraries/core/config/ConfigFile.cc
===================================================================
--- code/trunk/src/libraries/core/config/ConfigFile.cc	(revision 10622)
+++ code/trunk/src/libraries/core/config/ConfigFile.cc	(revision 10624)
@@ -38,5 +38,5 @@
 #include "util/Convert.h"
 #include "util/StringUtils.h"
-#include "core/PathConfig.h"
+#include "core/ConfigurablePaths.h"
 #include "ConfigFileEntryComment.h"
 #include "ConfigFileEntryValue.h"
@@ -81,5 +81,5 @@
         if (!filepath.is_complete())
         {
-            filepath = PathConfig::getConfigPath() / filepath;
+            filepath = ConfigurablePaths::getConfigPath() / filepath;
             if (this->bCopyFallbackFile_)
             {
@@ -87,5 +87,5 @@
                 if (!boost::filesystem::exists(filepath))
                 {
-                    boost::filesystem::path defaultFilepath(PathConfig::getDataPath() / DEFAULT_CONFIG_FOLDER / this->filename_);
+                    boost::filesystem::path defaultFilepath(ConfigurablePaths::getDataPath() / DEFAULT_CONFIG_FOLDER / this->filename_);
                     if (boost::filesystem::exists(defaultFilepath))
                     {
@@ -216,5 +216,5 @@
         boost::filesystem::path filepath(filename);
         if (!filepath.is_complete())
-            filepath = PathConfig::getConfigPath() / filename;
+            filepath = ConfigurablePaths::getConfigPath() / filename;
         std::ofstream file;
         file.open(filepath.string().c_str(), std::fstream::out);
Index: code/trunk/src/libraries/core/config/Configurable.cc
===================================================================
--- code/trunk/src/libraries/core/config/Configurable.cc	(revision 10622)
+++ code/trunk/src/libraries/core/config/Configurable.cc	(revision 10624)
@@ -32,5 +32,5 @@
 namespace orxonox
 {
-    RegisterClassNoArgs(Configurable);
+    RegisterClassNoArgs(Configurable).virtualBase();
 
     Configurable::Configurable()
Index: code/trunk/src/libraries/core/config/SettingsConfigFile.cc
===================================================================
--- code/trunk/src/libraries/core/config/SettingsConfigFile.cc	(revision 10622)
+++ code/trunk/src/libraries/core/config/SettingsConfigFile.cc	(revision 10624)
@@ -35,5 +35,5 @@
 
 #include "util/StringUtils.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "ConfigFileManager.h"
 #include "ConfigValueContainer.h"
Index: code/trunk/src/libraries/core/input/InputManager.cc
===================================================================
--- code/trunk/src/libraries/core/input/InputManager.cc	(revision 10622)
+++ code/trunk/src/libraries/core/input/InputManager.cc	(revision 10624)
@@ -48,6 +48,6 @@
 #include "core/GraphicsManager.h"
 #include "core/config/ConfigValueIncludes.h"
-#include "core/config/CommandLineParser.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/commandline/CommandLineIncludes.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "core/command/Functor.h"
 
@@ -85,4 +85,6 @@
         return (lval = (InputManager::State)(lval & rval));
     }
+
+    RegisterAbstractClass(InputManager).inheritsFrom<WindowEventListener>();
 
     // ############################################################
Index: code/trunk/src/libraries/core/input/JoyStick.cc
===================================================================
--- code/trunk/src/libraries/core/input/JoyStick.cc	(revision 10622)
+++ code/trunk/src/libraries/core/input/JoyStick.cc	(revision 10624)
@@ -47,4 +47,6 @@
 
     std::vector<std::string> JoyStick::deviceNames_s;
+
+    RegisterAbstractClass(JoyStick).inheritsFrom<Configurable>();
 
     JoyStick::JoyStick(unsigned int id, OIS::InputManager* oisInputManager)
Index: code/trunk/src/libraries/core/input/JoyStickQuantityListener.cc
===================================================================
--- code/trunk/src/libraries/core/input/JoyStickQuantityListener.cc	(revision 10622)
+++ code/trunk/src/libraries/core/input/JoyStickQuantityListener.cc	(revision 10624)
@@ -36,4 +36,6 @@
     std::vector<JoyStick*> JoyStickQuantityListener::joyStickList_s;
 
+    RegisterAbstractClass(JoyStickQuantityListener).inheritsFrom<Listable>();
+
     JoyStickQuantityListener::JoyStickQuantityListener()
     {
Index: code/trunk/src/libraries/core/input/KeyBinder.cc
===================================================================
--- code/trunk/src/libraries/core/input/KeyBinder.cc	(revision 10622)
+++ code/trunk/src/libraries/core/input/KeyBinder.cc	(revision 10624)
@@ -37,5 +37,6 @@
 #include "core/config/ConfigValueIncludes.h"
 #include "core/config/ConfigFile.h"
-#include "core/PathConfig.h"
+#include "core/ApplicationPaths.h"
+#include "core/ConfigurablePaths.h"
 #include "InputCommands.h"
 #include "JoyStick.h"
@@ -43,4 +44,6 @@
 namespace orxonox
 {
+    RegisterAbstractClass(KeyBinder).inheritsFrom<JoyStickQuantityListener>();
+
     /**
     @brief
@@ -253,11 +256,11 @@
         orxout(internal_info, context::input) << "KeyBinder: Loading key bindings..." << endl;
 
-        this->configFile_ = new ConfigFile(this->filename_, !PathConfig::buildDirectoryRun());
+        this->configFile_ = new ConfigFile(this->filename_, !ApplicationPaths::buildDirectoryRun());
         this->configFile_->load();
 
-        if (PathConfig::buildDirectoryRun())
+        if (ApplicationPaths::buildDirectoryRun())
         {
             // Dev users should have combined key bindings files
-            std::string defaultFilepath(PathConfig::getDataPathString() + ConfigFile::DEFAULT_CONFIG_FOLDER + '/' + this->filename_);
+            std::string defaultFilepath(ConfigurablePaths::getDataPathString() + ConfigFile::DEFAULT_CONFIG_FOLDER + '/' + this->filename_);
             std::ifstream file(defaultFilepath.c_str());
             if (file.is_open())
@@ -287,5 +290,5 @@
             addButtonToCommand(binding, it->second);
             std::string str = binding;
-            if (PathConfig::buildDirectoryRun() && binding.empty())
+            if (ApplicationPaths::buildDirectoryRun() && binding.empty())
                 str = "NoBinding";
             it->second->setBinding(this->configFile_, this->fallbackConfigFile_, binding, bTemporary);
Index: code/trunk/src/libraries/core/input/KeyBinderManager.cc
===================================================================
--- code/trunk/src/libraries/core/input/KeyBinderManager.cc	(revision 10622)
+++ code/trunk/src/libraries/core/input/KeyBinderManager.cc	(revision 10624)
@@ -31,9 +31,9 @@
 #include "util/Output.h"
 #include "util/Exception.h"
-#include "util/ScopedSingletonManager.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 #include "core/config/ConfigValueIncludes.h"
 #include "core/CoreIncludes.h"
 #include "core/LuaState.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "InputManager.h"
 #include "KeyDetector.h"
@@ -41,5 +41,5 @@
 namespace orxonox
 {
-    ManageScopedSingleton(KeyBinderManager, ScopeID::Graphics, false);
+    ManageScopedSingleton(KeyBinderManager, ScopeID::GRAPHICS, false);
 
     static const std::string __CC_keybind_name = "keybind";
@@ -52,4 +52,6 @@
     SetConsoleCommand(__CC_unbind_name,   &KeyBinderManager::unbind).defaultValues("");
     SetConsoleCommand(__CC_tunbind_name,  &KeyBinderManager::tunbind).defaultValues("");
+
+    RegisterAbstractClass(KeyBinderManager).inheritsFrom<Configurable>();
 
     KeyBinderManager::KeyBinderManager()
Index: code/trunk/src/libraries/core/input/KeyDetector.cc
===================================================================
--- code/trunk/src/libraries/core/input/KeyDetector.cc	(revision 10622)
+++ code/trunk/src/libraries/core/input/KeyDetector.cc	(revision 10624)
@@ -29,7 +29,7 @@
 #include "KeyDetector.h"
 
-#include "util/ScopedSingletonManager.h"
 #include "core/CoreIncludes.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "Button.h"
 #include "InputManager.h"
@@ -38,8 +38,10 @@
 namespace orxonox
 {
-    ManageScopedSingleton(KeyDetector, ScopeID::Graphics, false);
+    ManageScopedSingleton(KeyDetector, ScopeID::GRAPHICS, false);
 
     static const std::string __CC_KeyDetector_callback_name = "KeyDetectorKeyPressed";
     DeclareConsoleCommand(__CC_KeyDetector_callback_name, &prototype::void__string).hide();
+
+    RegisterAbstractClass(KeyDetector).inheritsFrom<KeyBinder>();
 
     KeyDetector::KeyDetector()
Index: code/trunk/src/libraries/core/input/Mouse.cc
===================================================================
--- code/trunk/src/libraries/core/input/Mouse.cc	(revision 10622)
+++ code/trunk/src/libraries/core/input/Mouse.cc	(revision 10624)
@@ -31,5 +31,5 @@
 #include <ois/OISMouse.h>
 #include "core/CoreIncludes.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "InputState.h"
 
@@ -50,4 +50,6 @@
     SetConsoleCommand(__CC_Mouse_name, __CC_ungrab_name, &Mouse::ungrab);
 #endif
+
+    RegisterAbstractClass(Mouse).inheritsFrom<WindowEventListener>();
 
     Mouse::Mouse(unsigned int id, OIS::InputManager* oisInputManager)
Index: code/trunk/src/libraries/core/module/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/core/module/CMakeLists.txt	(revision 10624)
+++ code/trunk/src/libraries/core/module/CMakeLists.txt	(revision 10624)
@@ -0,0 +1,11 @@
+ADD_SOURCE_FILES(CORE_SRC_FILES
+  DynLib.cc
+  DynLibManager.cc
+  ModuleInstance.cc
+  Plugin.cc
+  PluginManager.cc
+  PluginReference.cc
+  StaticallyInitializedInstance.cc
+  StaticInitializationHandlerIncludes.cc
+  StaticInitializationManager.cc
+)
Index: code/trunk/src/libraries/core/module/DynLib.cc
===================================================================
--- code/trunk/src/libraries/core/module/DynLib.cc	(revision 10624)
+++ code/trunk/src/libraries/core/module/DynLib.cc	(revision 10624)
@@ -0,0 +1,146 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+    (Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2006 Torus Knot Software Ltd
+Also see acknowledgements in Readme.html
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser 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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+
+You may alternatively use this source under the terms of a specific version of
+the OGRE Unrestricted License provided you have obtained such a license from
+Torus Knot Software Ltd.
+-----------------------------------------------------------------------------
+*/
+
+// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
+
+#include "DynLib.h"
+
+#include "util/Exception.h"
+
+#ifdef ORXONOX_PLATFORM_WINDOWS
+#  define WIN32_LEAN_AND_MEAN
+#  ifndef NOMINMAX
+#    define NOMINMAX // required to stop windows.h messing up std::min
+#  endif
+#  include <windows.h>
+#endif
+
+#ifdef ORXONOX_PLATFORM_UNIX
+#  include <dlfcn.h>
+#endif
+
+#ifdef ORXONOX_PLATFORM_APPLE
+#   include <OSX/macUtils.h> // OGRE include
+#endif
+
+namespace orxonox
+{
+    //-----------------------------------------------------------------------
+    DynLib::DynLib( const std::string& name )
+    {
+        mName = name;
+        m_hInst = NULL;
+    }
+
+    //-----------------------------------------------------------------------
+    DynLib::~DynLib()
+    {
+    }
+
+    //-----------------------------------------------------------------------
+    void DynLib::load()
+    {
+        // Log library load
+        orxout(internal_info) << "load DynLib " << mName << endl;
+
+        std::string name = mName;
+#ifdef ORXONOX_PLATFORM_LINUX
+        // dlopen() does not add .so to the filename, like windows does for .dll
+        if (name.substr(name.length() - 3, 3) != ".so")
+           name += ".so";
+#elif defined(ORXONOX_PLATFORM_APPLE)
+        // dlopen() does not add .dylib to the filename, like windows does for .dll
+        if (name.substr(name.length() - 6, 6) != ".dylib")
+            name += ".dylib";
+#elif defined(ORXONOX_PLATFORM_WINDOWS)
+        //altered search path doesn't work with paths with forward slashes
+        std::replace(name.begin(), name.end(), '/', '\\');
+        // Although LoadLibraryEx will add .dll itself when you only specify the library name,
+        // if you include a relative path then it does not. So, add it to be sure.
+        if (name.substr(name.length() - 4, 4) != ".dll")
+            name += ".dll";
+#endif
+
+        m_hInst = (DYNLIB_HANDLE)DYNLIB_LOAD( name.c_str() );
+
+        if (!m_hInst)
+            ThrowException(
+                General,
+                "Could not load dynamic library " + mName +
+                ".  System Error: " + dynlibError());
+    }
+
+    //-----------------------------------------------------------------------
+    void DynLib::unload()
+    {
+        // Log library unload
+        orxout(internal_info) << "unload DynLib " << mName << endl;
+
+        if (DYNLIB_UNLOAD( m_hInst ))
+        {
+            ThrowException(
+                General,
+                "Could not unload dynamic library " + mName +
+                ".  System Error: " + dynlibError());
+        }
+
+    }
+
+    //-----------------------------------------------------------------------
+    void* DynLib::getSymbol( const std::string& strName ) const throw()
+    {
+        return (void*)DYNLIB_GETSYM( m_hInst, strName.c_str() );
+    }
+    //-----------------------------------------------------------------------
+    std::string DynLib::dynlibError( void )
+    {
+#if defined(ORXONOX_PLATFORM_WINDOWS)
+        LPVOID lpMsgBuf;
+        FormatMessage(
+            FORMAT_MESSAGE_ALLOCATE_BUFFER |
+            FORMAT_MESSAGE_FROM_SYSTEM |
+            FORMAT_MESSAGE_IGNORE_INSERTS,
+            NULL,
+            GetLastError(),
+            MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+            (LPTSTR) &lpMsgBuf,
+            0,
+            NULL
+            );
+        std::string ret = (char*)lpMsgBuf;
+        // Free the buffer.
+        LocalFree( lpMsgBuf );
+        return ret;
+#elif defined(ORXONOX_PLATFORM_UNIX)
+        return std::string(dlerror());
+#else
+        return "";
+#endif
+    }
+}
Index: code/trunk/src/libraries/core/module/DynLib.h
===================================================================
--- code/trunk/src/libraries/core/module/DynLib.h	(revision 10624)
+++ code/trunk/src/libraries/core/module/DynLib.h	(revision 10624)
@@ -0,0 +1,119 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+    (Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2006 Torus Knot Software Ltd
+Also see acknowledgements in Readme.html
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser 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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+
+You may alternatively use this source under the terms of a specific version of
+the OGRE Unrestricted License provided you have obtained such a license from
+Torus Knot Software Ltd.
+-----------------------------------------------------------------------------
+*/
+
+// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
+
+/**
+    @file
+    @ingroup Management CoreGame
+    @brief Declaration of DynLib which represents a dynamically loaded module.
+*/
+
+#ifndef _Core_DynLib_H__
+#define _Core_DynLib_H__
+
+#include "core/CorePrereqs.h"
+
+#include <string>
+
+#if defined(ORXONOX_PLATFORM_WINDOWS)
+#    define DYNLIB_HANDLE hInstance
+#    define DYNLIB_LOAD( a ) LoadLibraryEx( a, NULL, LOAD_WITH_ALTERED_SEARCH_PATH )
+#    define DYNLIB_GETSYM( a, b ) GetProcAddress( a, b )
+#    define DYNLIB_UNLOAD( a ) !FreeLibrary( a )
+
+struct HINSTANCE__;
+typedef struct HINSTANCE__* hInstance;
+
+#elif defined(ORXONOX_PLATFORM_UNIX)
+#    define DYNLIB_HANDLE void*
+#    define DYNLIB_LOAD( a ) dlopen( a, RTLD_LAZY | RTLD_GLOBAL)
+#    define DYNLIB_GETSYM( a, b ) dlsym( a, b )
+#    define DYNLIB_UNLOAD( a ) dlclose( a )
+#endif
+
+namespace orxonox
+{
+    /** %Resource holding data about a dynamic library.
+        @remarks
+            This class holds the data required to get symbols from
+            libraries loaded at run-time (i.e. from DLL's for so's)
+        @author
+            Adrian Cearnãu (cearny@cearny.ro)
+        @since
+            27 January 2002
+    */
+    class _CoreExport DynLib
+    {
+    protected:
+        std::string mName;
+        /// Gets the last loading error
+        std::string dynlibError(void);
+    public:
+        /** Default constructor - used by DynLibManager.
+            @warning
+                Do not call directly
+        */
+        DynLib( const std::string& name );
+
+        /** Default destructor.
+        */
+        ~DynLib();
+
+        /** Load the library
+        */
+        void load();
+        /** Unload the library
+        */
+        void unload();
+        /// Get the name of the library
+        const std::string& getName(void) const { return mName; }
+
+        /**
+            Returns the address of the given symbol from the loaded library.
+            @param
+                strName The name of the symbol to search for
+            @returns
+                If the function succeeds, the returned value is a handle to
+                the symbol.
+            @par
+                If the function fails, the returned value is <b>NULL</b>.
+
+        */
+        void* getSymbol( const std::string& strName ) const throw();
+
+    protected:
+
+        /// Handle to the loaded library.
+        DYNLIB_HANDLE m_hInst;
+    };
+
+}
+
+#endif /* _Core_DynLib_H__ */
Index: code/trunk/src/libraries/core/module/DynLibManager.cc
===================================================================
--- code/trunk/src/libraries/core/module/DynLibManager.cc	(revision 10624)
+++ code/trunk/src/libraries/core/module/DynLibManager.cc	(revision 10624)
@@ -0,0 +1,86 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+    (Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2006 Torus Knot Software Ltd
+Also see acknowledgements in Readme.html
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser 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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+
+You may alternatively use this source under the terms of a specific version of
+the OGRE Unrestricted License provided you have obtained such a license from
+Torus Knot Software Ltd.
+-----------------------------------------------------------------------------
+*/
+
+// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
+
+#include "DynLibManager.h"
+
+#include "DynLib.h"
+
+namespace orxonox
+{
+    //-----------------------------------------------------------------------
+    //! Static pointer to the singleton
+    DynLibManager* DynLibManager::singletonPtr_s  = 0;
+
+    //-----------------------------------------------------------------------
+    DynLibManager::DynLibManager()
+    {
+    }
+    //-----------------------------------------------------------------------
+    DynLib* DynLibManager::load( const std::string& filename)
+    {
+        DynLibList::iterator i = mLibList.find(filename);
+        if (i != mLibList.end())
+        {
+            return i->second;
+        }
+        else
+        {
+            DynLib* pLib = new DynLib(filename);
+            pLib->load();
+            mLibList[filename] = pLib;
+            return pLib;
+        }
+    }
+    //-----------------------------------------------------------------------
+    void DynLibManager::unload(DynLib* lib)
+    {
+        DynLibList::iterator i = mLibList.find(lib->getName());
+        if (i != mLibList.end())
+        {
+            mLibList.erase(i);
+        }
+        lib->unload();
+        delete lib;
+    }
+    //-----------------------------------------------------------------------
+    DynLibManager::~DynLibManager()
+    {
+        // Unload & delete resources in turn
+        for (DynLibList::iterator it = mLibList.begin(); it != mLibList.end(); ++it)
+        {
+            it->second->unload();
+            delete it->second;
+        }
+
+        // Empty the list
+        mLibList.clear();
+    }
+}
Index: code/trunk/src/libraries/core/module/DynLibManager.h
===================================================================
--- code/trunk/src/libraries/core/module/DynLibManager.h	(revision 10624)
+++ code/trunk/src/libraries/core/module/DynLibManager.h	(revision 10624)
@@ -0,0 +1,104 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+    (Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2006 Torus Knot Software Ltd
+Also see acknowledgements in Readme.html
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser 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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+
+You may alternatively use this source under the terms of a specific version of
+the OGRE Unrestricted License provided you have obtained such a license from
+Torus Knot Software Ltd.
+-----------------------------------------------------------------------------
+*/
+
+// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
+
+/**
+    @file
+    @ingroup Management CoreGame
+    @brief Declaration of DynLibManager, used to load modules at runtime.
+*/
+
+#ifndef _Core_DynLibManager_H__
+#define _Core_DynLibManager_H__
+
+#include "core/CorePrereqs.h"
+
+#include <map>
+#include <string>
+#include "util/Singleton.h"
+
+namespace orxonox
+{
+    /** Manager for Dynamic-loading Libraries.
+        @remarks
+            This manager keeps a track of all the open dynamic-loading
+            libraries, opens them and returns references to already-open
+            libraries.
+    */
+    class _CoreExport DynLibManager: public Singleton<DynLibManager>
+    {
+        friend class Singleton<DynLibManager>;
+
+        protected:
+            typedef std::map<std::string, DynLib*> DynLibList;
+            DynLibList mLibList;
+
+        public:
+            /**
+            @brief
+                Default constructor.
+            @note
+                Should never be called as the singleton is automatically
+                created during the creation of the Root object.
+            @see
+                Root::Root
+            */
+            DynLibManager();
+
+            /**
+            @brief
+                Default destructor.
+            @see
+                Root::~Root
+            */
+            virtual ~DynLibManager();
+
+            /**
+            @brief
+                Loads the passed library.
+            @param filename
+                The name of the library. The extension can be omitted
+            */
+            DynLib* load(const std::string& filename);
+
+            /**
+            @brief
+                Unloads the passed library.
+            @param lib
+                A pointer to the library object
+            */
+            void unload(DynLib* lib);
+
+        private:
+            static DynLibManager* singletonPtr_s;
+    };
+}
+
+#endif /* _Core_DynLibManager_H__ */
Index: code/trunk/src/libraries/core/module/ModuleInstance.cc
===================================================================
--- code/trunk/src/libraries/core/module/ModuleInstance.cc	(revision 10624)
+++ code/trunk/src/libraries/core/module/ModuleInstance.cc	(revision 10624)
@@ -0,0 +1,94 @@
+/*
+ *   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 "ModuleInstance.h"
+
+#include "StaticallyInitializedInstance.h"
+
+namespace orxonox
+{
+    ModuleInstance* ModuleInstance::currentModuleInstance_s = NULL;
+
+    ModuleInstance::ModuleInstance(const std::string& libraryName)
+        : libraryName_(libraryName)
+        , dynLib_(NULL)
+    {
+    }
+
+    ModuleInstance::~ModuleInstance()
+    {
+        this->deleteAllStaticallyInitializedInstances();
+    }
+
+    void ModuleInstance::addStaticallyInitializedInstance(StaticallyInitializedInstance* instance)
+    {
+        this->staticallyInitializedInstancesByType_[instance->getType()].insert(instance);
+    }
+
+    void ModuleInstance::removeStaticallyInitializedInstance(StaticallyInitializedInstance* instance)
+    {
+        this->staticallyInitializedInstancesByType_[instance->getType()].erase(instance);
+    }
+
+    void ModuleInstance::loadAllStaticallyInitializedInstances(StaticInitialization::Type type)
+    {
+        const std::set<StaticallyInitializedInstance*>& instances = this->staticallyInitializedInstancesByType_[type];
+        for (std::set<StaticallyInitializedInstance*>::iterator it = instances.begin(); it != instances.end(); ++it)
+            (*it)->load();
+    }
+
+    void ModuleInstance::unloadAllStaticallyInitializedInstances(StaticInitialization::Type type)
+    {
+        // unload in reversed order
+        const std::set<StaticallyInitializedInstance*>& instances = this->staticallyInitializedInstancesByType_[type];
+        for (std::set<StaticallyInitializedInstance*>::reverse_iterator it = instances.rbegin(); it != instances.rend(); ++it)
+            (*it)->unload();
+    }
+
+    void ModuleInstance::deleteAllStaticallyInitializedInstances()
+    {
+        std::map<StaticInitialization::Type, std::set<StaticallyInitializedInstance*> > copy(this->staticallyInitializedInstancesByType_);
+        this->staticallyInitializedInstancesByType_.clear();
+        for (std::map<StaticInitialization::Type, std::set<StaticallyInitializedInstance*> >::iterator it1 = copy.begin(); it1 != copy.end(); ++it1)
+            for (std::set<StaticallyInitializedInstance*>::iterator it2 = it1->second.begin(); it2 != it1->second.end(); ++it2)
+                delete (*it2);
+    }
+
+
+    /*static*/ void ModuleInstance::setCurrentModuleInstance(ModuleInstance* instance)
+    {
+        ModuleInstance::currentModuleInstance_s = instance;
+    }
+
+    /*static*/ ModuleInstance* ModuleInstance::getCurrentModuleInstance()
+    {
+        if (!ModuleInstance::currentModuleInstance_s)
+            ModuleInstance::currentModuleInstance_s = new ModuleInstance("");
+        return ModuleInstance::currentModuleInstance_s;
+    }
+}
Index: code/trunk/src/libraries/core/module/ModuleInstance.h
===================================================================
--- code/trunk/src/libraries/core/module/ModuleInstance.h	(revision 10624)
+++ code/trunk/src/libraries/core/module/ModuleInstance.h	(revision 10624)
@@ -0,0 +1,79 @@
+/*
+ *   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 _ModuleInstance_H__
+#define _ModuleInstance_H__
+
+#include "core/CorePrereqs.h"
+
+#include <set>
+#include <map>
+#include <string>
+
+#include "StaticallyInitializedInstance.h"
+
+namespace orxonox
+{
+    class _CoreExport ModuleInstance
+    {
+        public:
+            ModuleInstance(const std::string& libraryName);
+            ~ModuleInstance();
+
+            void addStaticallyInitializedInstance(StaticallyInitializedInstance* instance);
+            void removeStaticallyInitializedInstance(StaticallyInitializedInstance* instance);
+
+            void loadAllStaticallyInitializedInstances(StaticInitialization::Type type);
+            void unloadAllStaticallyInitializedInstances(StaticInitialization::Type type);
+
+            inline const std::set<StaticallyInitializedInstance*>& getInstances(StaticInitialization::Type type)
+                { return this->staticallyInitializedInstancesByType_[type]; }
+
+            void deleteAllStaticallyInitializedInstances();
+
+            inline const std::string& getLibraryName() const
+                { return this->libraryName_; }
+
+            inline void setDynLib(DynLib* dynLib)
+                { this->dynLib_ = dynLib; }
+            inline DynLib* getDynLib() const
+                { return this->dynLib_; }
+
+            static void setCurrentModuleInstance(ModuleInstance* instance);
+            static ModuleInstance* getCurrentModuleInstance();
+
+        private:
+            std::map<StaticInitialization::Type, std::set<StaticallyInitializedInstance*> > staticallyInitializedInstancesByType_;
+            std::string libraryName_;
+            DynLib* dynLib_;
+
+            static ModuleInstance* currentModuleInstance_s;
+    };
+}
+
+#endif /* _ModuleInstance_H__ */
Index: code/trunk/src/libraries/core/module/Plugin.cc
===================================================================
--- code/trunk/src/libraries/core/module/Plugin.cc	(revision 10624)
+++ code/trunk/src/libraries/core/module/Plugin.cc	(revision 10624)
@@ -0,0 +1,84 @@
+/*
+ *   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 "Plugin.h"
+
+#include "ModuleInstance.h"
+#include "util/Output.h"
+#include "core/Core.h"
+
+namespace orxonox
+{
+    Plugin::Plugin(const std::string& name, const std::string& libraryName) : name_(name), libraryName_(libraryName)
+    {
+        this->referenceCounter_ = 0;
+        this->moduleInstance_ = NULL;
+    }
+
+    Plugin::~Plugin()
+    {
+        if (this->moduleInstance_ != NULL)
+        {
+            this->referenceCounter_ = 1; // force unloading
+            this->unload();
+        }
+    }
+
+    void Plugin::load()
+    {
+        this->referenceCounter_++;
+        if (this->referenceCounter_ == 1) // increased from 0 to 1 -> load plugin
+        {
+            orxout(internal_info) << "Loading plugin " << this->name_ << "..." << endl;
+            this->moduleInstance_ = new ModuleInstance(this->libraryName_);
+            Core::getInstance().loadModule(this->moduleInstance_);
+        }
+        else
+            orxout(internal_info) << "Increased reference count for plugin " << this->name_ << " to " << this->referenceCounter_ << endl;
+    }
+
+    void Plugin::unload()
+    {
+        if (this->referenceCounter_ == 0)
+        {
+            orxout(internal_warning) << "Tried to dereference plugin " << this->name_ << " more often than it was referenced" << endl;
+            return;
+        }
+
+        this->referenceCounter_--;
+        if (this->referenceCounter_ == 0) // reduced from 1 to 0 -> load plugin
+        {
+            orxout(internal_info) << "Unloading plugin " << this->name_ << "..." << endl;
+            Core::getInstance().unloadModule(this->moduleInstance_);
+            delete this->moduleInstance_;
+            this->moduleInstance_ = NULL;
+        }
+        else
+            orxout(internal_info) << "Reduced reference count for plugin " << this->name_ << " to " << this->referenceCounter_ << endl;
+    }
+}
Index: code/trunk/src/libraries/core/module/Plugin.h
===================================================================
--- code/trunk/src/libraries/core/module/Plugin.h	(revision 10624)
+++ code/trunk/src/libraries/core/module/Plugin.h	(revision 10624)
@@ -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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Plugin_H__
+#define _Plugin_H__
+
+#include "core/CorePrereqs.h"
+
+namespace orxonox
+{
+    class _CoreExport Plugin
+    {
+        public:
+            Plugin(const std::string& name, const std::string& libraryName);
+            ~Plugin();
+
+            void load();
+            void unload();
+
+        private:
+            std::string name_;
+            std::string libraryName_;
+            unsigned int referenceCounter_;
+            ModuleInstance* moduleInstance_;
+    };
+}
+
+#endif /* _Plugin_H__ */
Index: code/trunk/src/libraries/core/module/PluginManager.cc
===================================================================
--- code/trunk/src/libraries/core/module/PluginManager.cc	(revision 10624)
+++ code/trunk/src/libraries/core/module/PluginManager.cc	(revision 10624)
@@ -0,0 +1,134 @@
+/*
+ *   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 "PluginManager.h"
+
+#include <fstream>
+
+#include "SpecialConfig.h"
+#include "Plugin.h"
+#include "PluginReference.h"
+#include "core/ApplicationPaths.h"
+#include "core/command/ConsoleCommandIncludes.h"
+#include "core/object/Context.h"
+
+namespace orxonox
+{
+    static const std::string __CC_PluginManager_load_name  = "load";
+    static const std::string __CC_PluginManager_unload_name  = "unload";
+
+    SetConsoleCommand("PluginManager", __CC_PluginManager_load_name, &PluginManager::loadPlugin);
+    SetConsoleCommand("PluginManager", __CC_PluginManager_unload_name, &PluginManager::unloadPlugin);
+
+    PluginManager* PluginManager::singletonPtr_s  = 0;
+
+    PluginManager::PluginManager()
+    {
+        ModifyConsoleCommand("PluginManager", __CC_PluginManager_load_name).setObject(this);
+        ModifyConsoleCommand("PluginManager", __CC_PluginManager_unload_name).setObject(this);
+    }
+
+    PluginManager::~PluginManager()
+    {
+        ModifyConsoleCommand("PluginManager", __CC_PluginManager_load_name).setObject(NULL);
+        ModifyConsoleCommand("PluginManager", __CC_PluginManager_unload_name).setObject(NULL);
+
+        for (std::map<std::string, PluginReference*>::iterator it = this->references_.begin(); it != this->references_.end(); ++it)
+            delete it->second;
+        for (std::map<std::string, Plugin*>::iterator it = this->plugins_.begin(); it != this->plugins_.end(); ++it)
+            delete it->second;
+    }
+
+    void PluginManager::findPlugins()
+    {
+        const std::vector<std::string>& pluginPaths = ApplicationPaths::getInstance().getPluginPaths();
+        for (std::vector<std::string>::const_iterator it = pluginPaths.begin(); it != pluginPaths.end(); ++it)
+        {
+            std::string name;
+            std::string libraryName = (*it);
+            std::string filename = libraryName +  + specialConfig::pluginExtension;
+            std::ifstream infile(filename.c_str());
+            if (infile >> name)
+            {
+                orxout(internal_info) << "Found plugin with name '" << name << "' in module " << libraryName << endl;
+                this->plugins_[name] = new Plugin(name, libraryName);
+            }
+            else
+            {
+                orxout(internal_warning) << "Could not read plugin file " << filename << endl;
+            }
+        }
+    }
+
+    void PluginManager::referencePlugin(const std::string& name)
+    {
+        Plugin* plugin = this->plugins_[name];
+        if (plugin != NULL)
+            plugin->load();
+        else
+            orxout(internal_warning) << "Cannot find plugin with name " << name << endl;
+    }
+
+    void PluginManager::dereferencePlugin(const std::string& name)
+    {
+        Plugin* plugin = this->plugins_[name];
+        if (plugin != NULL)
+            plugin->unload();
+        else
+            orxout(internal_warning) << "Cannot find plugin with name " << name << endl;
+    }
+
+    /**
+     * @brief Console command to manually load a plugin. The plugin stays loaded until @ref unloadPlugin is called.
+     */
+    void PluginManager::loadPlugin(const std::string& name)
+    {
+        if (this->references_[name] == NULL)
+        {
+            this->references_[name] = new PluginReference(name);
+        }
+        else
+            orxout(internal_warning) << "Plugin " << name << " is already loaded" << endl;
+    }
+
+    /**
+     * @brief Console command to unload a plugin if it was previously loaded manually by calling @ref loadPlugin.
+     * Does not unload the plugin immediately if it is still used by another @ref PluginReference (e.g. by a @ref Level).
+     */
+    void PluginManager::unloadPlugin(const std::string& name)
+    {
+        PluginReference* reference = this->references_[name];
+        if (reference != NULL)
+        {
+            this->references_[name] = NULL;
+            delete reference;
+        }
+        else
+            orxout(internal_warning) << "Plugin " << name << " is already unloaded" << endl;
+    }
+}
Index: code/trunk/src/libraries/core/module/PluginManager.h
===================================================================
--- code/trunk/src/libraries/core/module/PluginManager.h	(revision 10624)
+++ code/trunk/src/libraries/core/module/PluginManager.h	(revision 10624)
@@ -0,0 +1,65 @@
+/*
+ *   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 _PluginManager_H__
+#define _PluginManager_H__
+
+#include "core/CorePrereqs.h"
+
+#include <map>
+#include <string>
+#include "util/Singleton.h"
+
+namespace orxonox
+{
+    class _CoreExport PluginManager : public Singleton<PluginManager>
+    {
+        friend class Singleton<PluginManager>;
+
+        public:
+            PluginManager();
+            ~PluginManager();
+
+            void findPlugins();
+
+            void referencePlugin(const std::string& name);
+            void dereferencePlugin(const std::string& name);
+
+            // console commands
+            void loadPlugin(const std::string& name);
+            void unloadPlugin(const std::string& name);
+
+        private:
+            std::map<std::string, Plugin*> plugins_;
+            std::map<std::string, PluginReference*> references_; // references that were created by console command
+
+            static PluginManager* singletonPtr_s;
+    };
+}
+
+#endif /* _PluginManager_H__ */
Index: code/trunk/src/libraries/core/module/PluginReference.cc
===================================================================
--- code/trunk/src/libraries/core/module/PluginReference.cc	(revision 10624)
+++ code/trunk/src/libraries/core/module/PluginReference.cc	(revision 10624)
@@ -0,0 +1,46 @@
+/*
+ *   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 "PluginReference.h"
+
+#include "PluginManager.h"
+
+namespace orxonox
+{
+    PluginReference::PluginReference(const std::string& name) : name_(name)
+    {
+        // load plugin
+        PluginManager::getInstance().referencePlugin(this->name_);
+    }
+
+    PluginReference::~PluginReference()
+    {
+        // unload plugin
+        PluginManager::getInstance().dereferencePlugin(this->name_);
+    }
+}
Index: code/trunk/src/libraries/core/module/PluginReference.h
===================================================================
--- code/trunk/src/libraries/core/module/PluginReference.h	(revision 10624)
+++ code/trunk/src/libraries/core/module/PluginReference.h	(revision 10624)
@@ -0,0 +1,49 @@
+/*
+ *   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 _PluginReference_H__
+#define _PluginReference_H__
+
+#include "core/CorePrereqs.h"
+
+#include "core/object/Destroyable.h"
+
+namespace orxonox
+{
+    class _CoreExport PluginReference : public Destroyable
+    {
+        public:
+            PluginReference(const std::string& name);
+            ~PluginReference();
+
+        private:
+            std::string name_;
+    };
+}
+
+#endif /* _PluginReference_H__ */
Index: code/trunk/src/libraries/core/module/StaticInitializationHandler.h
===================================================================
--- code/trunk/src/libraries/core/module/StaticInitializationHandler.h	(revision 10624)
+++ code/trunk/src/libraries/core/module/StaticInitializationHandler.h	(revision 10624)
@@ -0,0 +1,50 @@
+/*
+ *   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 _StaticInitializationHandler_H__
+#define _StaticInitializationHandler_H__
+
+#include "core/CorePrereqs.h"
+
+namespace orxonox
+{
+    class _CoreExport StaticInitializationHandler
+    {
+        public:
+            StaticInitializationHandler() {}
+            virtual ~StaticInitializationHandler() {}
+
+            virtual void setupHandler() = 0;
+            virtual void shutdownHandler() = 0;
+
+            virtual void loadModule(ModuleInstance* module) = 0;
+            virtual void unloadModule(ModuleInstance* module) = 0;
+    };
+}
+
+#endif /* _StaticInitializationHandler_H__ */
Index: code/trunk/src/libraries/core/module/StaticInitializationHandlerIncludes.cc
===================================================================
--- code/trunk/src/libraries/core/module/StaticInitializationHandlerIncludes.cc	(revision 10624)
+++ code/trunk/src/libraries/core/module/StaticInitializationHandlerIncludes.cc	(revision 10624)
@@ -0,0 +1,44 @@
+/*
+ *   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 "StaticInitializationHandlerIncludes.h"
+
+#include "StaticInitializationManager.h"
+
+namespace orxonox
+{
+    void StaticallyInitializedStaticInitializationHandler::load()
+    {
+        StaticInitializationManager::getInstance().addHandler(this->handler_);
+    }
+
+    void StaticallyInitializedStaticInitializationHandler::unload()
+    {
+        StaticInitializationManager::getInstance().removeHandler(this->handler_);
+    }
+}
Index: code/trunk/src/libraries/core/module/StaticInitializationHandlerIncludes.h
===================================================================
--- code/trunk/src/libraries/core/module/StaticInitializationHandlerIncludes.h	(revision 10624)
+++ code/trunk/src/libraries/core/module/StaticInitializationHandlerIncludes.h	(revision 10624)
@@ -0,0 +1,68 @@
+/*
+ *   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 _StaticInitializationHandlerIncludes_H__
+#define _StaticInitializationHandlerIncludes_H__
+
+#include "core/CorePrereqs.h"
+
+#include "StaticInitializationHandler.h"
+#include "StaticallyInitializedInstance.h"
+
+/**
+ * Registers a StaticInitializationHandler
+ */
+#define RegisterStaticInitializationHandler(className) \
+    static StaticInitializationHandler& className##StaticInitializationHandler \
+        = (new orxonox::SI_SIH(new className()))->getHandler()
+
+namespace orxonox
+{
+    class _CoreExport StaticallyInitializedStaticInitializationHandler : public StaticallyInitializedInstance
+    {
+        public:
+            StaticallyInitializedStaticInitializationHandler(StaticInitializationHandler* handler)
+                : StaticallyInitializedInstance(StaticInitialization::STATIC_INITIALIZATION_HANDLER)
+                , handler_(handler)
+            {}
+            ~StaticallyInitializedStaticInitializationHandler() { delete handler_; }
+
+            virtual void load();
+            virtual void unload();
+
+            inline StaticInitializationHandler& getHandler()
+                { return *this->handler_; }
+
+        private:
+            StaticInitializationHandler* handler_;
+    };
+
+    typedef StaticallyInitializedStaticInitializationHandler SI_SIH;
+}
+
+#endif /* _StaticInitializationHandlerIncludes_H__ */
Index: code/trunk/src/libraries/core/module/StaticInitializationManager.cc
===================================================================
--- code/trunk/src/libraries/core/module/StaticInitializationManager.cc	(revision 10624)
+++ code/trunk/src/libraries/core/module/StaticInitializationManager.cc	(revision 10624)
@@ -0,0 +1,63 @@
+/*
+ *   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 "StaticInitializationManager.h"
+
+#include "StaticInitializationHandler.h"
+
+namespace orxonox
+{
+    StaticInitializationManager* StaticInitializationManager::singletonPtr_s = 0;
+
+    void StaticInitializationManager::addHandler(StaticInitializationHandler* handler)
+    {
+        handler->setupHandler();
+        this->handlers_.push_back(handler);
+    }
+
+    void StaticInitializationManager::removeHandler(StaticInitializationHandler* handler)
+    {
+        this->handlers_.remove(handler);
+        handler->shutdownHandler();
+    }
+
+    void StaticInitializationManager::loadModule(ModuleInstance* module)
+    {
+        // attention: loading a module may add new handlers to the list
+        for (std::list<StaticInitializationHandler*>::iterator it = this->handlers_.begin(); it != this->handlers_.end(); ++it)
+            (*it)->loadModule(module);
+    }
+
+    void StaticInitializationManager::unloadModule(ModuleInstance* module)
+    {
+        // unload in reversed order
+        // attention: unloading a module may remove handlers from the list
+        for (std::list<StaticInitializationHandler*>::reverse_iterator it = this->handlers_.rbegin(); it != this->handlers_.rend(); )
+            (*(it++))->unloadModule(module);
+    }
+}
Index: code/trunk/src/libraries/core/module/StaticInitializationManager.h
===================================================================
--- code/trunk/src/libraries/core/module/StaticInitializationManager.h	(revision 10624)
+++ code/trunk/src/libraries/core/module/StaticInitializationManager.h	(revision 10624)
@@ -0,0 +1,61 @@
+/*
+ *   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 _StaticInitializationManager_H__
+#define _StaticInitializationManager_H__
+
+#include "core/CorePrereqs.h"
+
+#include <list>
+
+#include "util/Singleton.h"
+
+namespace orxonox
+{
+    class _CoreExport StaticInitializationManager : public Singleton<StaticInitializationManager>
+    {
+        friend class Singleton<StaticInitializationManager>;
+
+        public:
+            StaticInitializationManager() {}
+            virtual ~StaticInitializationManager() {}
+
+            void addHandler(StaticInitializationHandler* handler);
+            void removeHandler(StaticInitializationHandler* handler);
+
+            void loadModule(ModuleInstance* module);
+            void unloadModule(ModuleInstance* module);
+
+        private:
+            std::list<StaticInitializationHandler*> handlers_;
+
+            static StaticInitializationManager* singletonPtr_s;
+    };
+}
+
+#endif /* _StaticInitializationManager_H__ */
Index: code/trunk/src/libraries/core/module/StaticallyInitializedInstance.cc
===================================================================
--- code/trunk/src/libraries/core/module/StaticallyInitializedInstance.cc	(revision 10624)
+++ code/trunk/src/libraries/core/module/StaticallyInitializedInstance.cc	(revision 10624)
@@ -0,0 +1,46 @@
+/*
+ *   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 "StaticallyInitializedInstance.h"
+
+#include "ModuleInstance.h"
+
+namespace orxonox
+{
+    StaticallyInitializedInstance::StaticallyInitializedInstance(StaticInitialization::Type type)
+    {
+        this->type_ = type;
+        this->module_ = ModuleInstance::getCurrentModuleInstance();
+        this->module_->addStaticallyInitializedInstance(this);
+    }
+
+    StaticallyInitializedInstance::~StaticallyInitializedInstance()
+    {
+        this->module_->removeStaticallyInitializedInstance(this);
+    }
+}
Index: code/trunk/src/libraries/core/module/StaticallyInitializedInstance.h
===================================================================
--- code/trunk/src/libraries/core/module/StaticallyInitializedInstance.h	(revision 10624)
+++ code/trunk/src/libraries/core/module/StaticallyInitializedInstance.h	(revision 10624)
@@ -0,0 +1,55 @@
+/*
+ *   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 _StaticallyInitializedInstance_H__
+#define _StaticallyInitializedInstance_H__
+
+#include "core/CorePrereqs.h"
+
+namespace orxonox
+{
+    class _CoreExport StaticallyInitializedInstance
+    {
+        public:
+
+            StaticallyInitializedInstance(StaticInitialization::Type type);
+            virtual ~StaticallyInitializedInstance();
+
+            virtual void load() = 0;
+            virtual void unload() = 0;
+
+            inline StaticInitialization::Type getType() const
+                { return this->type_; }
+
+        private:
+            ModuleInstance* module_;
+            StaticInitialization::Type type_;
+    };
+}
+
+#endif /* _StaticallyInitializedInstance_H__ */
Index: code/trunk/src/libraries/core/object/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/core/object/CMakeLists.txt	(revision 10622)
+++ code/trunk/src/libraries/core/object/CMakeLists.txt	(revision 10624)
@@ -2,4 +2,5 @@
   Context.cc
   Destroyable.cc
+  DestroyLaterManager.cc
   Listable.cc
   ObjectListBase.cc
Index: code/trunk/src/libraries/core/object/Context.cc
===================================================================
--- code/trunk/src/libraries/core/object/Context.cc	(revision 10622)
+++ code/trunk/src/libraries/core/object/Context.cc	(revision 10624)
@@ -76,13 +76,16 @@
     /*static*/ void Context::setRootContext(Context* context)
     {
-        if (Context::rootContext_s)
-            delete Context::rootContext_s;
         Context::rootContext_s = context;
+    }
+
+    /*static*/ void Context::destroyRootContext()
+    {
+        delete Context::rootContext_s;
+        Context::rootContext_s = NULL;
     }
 
     /*static*/ Context* Context::getRootContext()
     {
-        if (!Context::rootContext_s)
-            Context::rootContext_s = new Context(NULL);
+        OrxVerify(Context::rootContext_s != NULL, "Root Context is undefined");
         return Context::rootContext_s;
     }
@@ -97,3 +100,10 @@
         return this->objectLists_[classID];
     }
+
+    void Context::destroyObjectList(const Identifier* identifier)
+    {
+        ObjectListBase* objectList = this->getObjectList(identifier);
+        delete objectList;
+        this->objectLists_[identifier->getClassID()] = NULL;
+    }
 }
Index: code/trunk/src/libraries/core/object/Context.h
===================================================================
--- code/trunk/src/libraries/core/object/Context.h	(revision 10622)
+++ code/trunk/src/libraries/core/object/Context.h	(revision 10624)
@@ -47,4 +47,5 @@
         public:
             static void setRootContext(Context* context);
+            static void destroyRootContext();
             static Context* getRootContext();
 
@@ -71,4 +72,6 @@
             }
 
+            void destroyObjectList(const Identifier* identifier);
+
         private:
             Context* parentContext_;
Index: code/trunk/src/libraries/core/object/DestroyLaterManager.cc
===================================================================
--- code/trunk/src/libraries/core/object/DestroyLaterManager.cc	(revision 10624)
+++ code/trunk/src/libraries/core/object/DestroyLaterManager.cc	(revision 10624)
@@ -0,0 +1,56 @@
+/*
+ *   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 "DestroyLaterManager.h"
+
+#include "core/CoreIncludes.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
+
+namespace orxonox
+{
+    ManageScopedSingleton(DestroyLaterManager, ScopeID::ROOT, false);
+
+    RegisterAbstractClass(DestroyLaterManager).inheritsFrom<UpdateListener>();
+
+    DestroyLaterManager::DestroyLaterManager()
+    {
+        RegisterObject(DestroyLaterManager);
+    }
+
+    DestroyLaterManager::~DestroyLaterManager()
+    {
+        // Be sure to release all instances
+        this->retainedInstances_.clear();
+    }
+
+    void DestroyLaterManager::postUpdate(const Clock& time)
+    {
+        // clearing the list will destroy all strong pointers and thus all retained instances (as long as there are no other strong pointers pointing to them).
+        this->retainedInstances_.clear();
+    }
+}
Index: code/trunk/src/libraries/core/object/DestroyLaterManager.h
===================================================================
--- code/trunk/src/libraries/core/object/DestroyLaterManager.h	(revision 10624)
+++ code/trunk/src/libraries/core/object/DestroyLaterManager.h	(revision 10624)
@@ -0,0 +1,60 @@
+/*
+ *   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 _DestroyLaterManager_H__
+#define _DestroyLaterManager_H__
+
+#include "core/CorePrereqs.h"
+
+#include "util/Singleton.h"
+#include "core/UpdateListener.h"
+#include "StrongPtr.h"
+
+namespace orxonox
+{
+    class _CoreExport DestroyLaterManager : public Singleton<DestroyLaterManager>, public UpdateListener
+    {
+            friend class Singleton<DestroyLaterManager>;
+        public:
+            DestroyLaterManager();
+            virtual ~DestroyLaterManager();
+
+            virtual void preUpdate(const Clock& time) { /*no action*/ }
+            virtual void postUpdate(const Clock& time);
+
+            void retain(Destroyable* instance)
+                { this->retainedInstances_.push_back(instance); }
+
+        private:
+            std::vector<StrongPtr<Destroyable> > retainedInstances_;
+
+            static DestroyLaterManager* singletonPtr_s;
+    };
+}
+
+#endif /* _DestroyLaterManager_H__ */
Index: code/trunk/src/libraries/core/object/Destroyable.cc
===================================================================
--- code/trunk/src/libraries/core/object/Destroyable.cc	(revision 10622)
+++ code/trunk/src/libraries/core/object/Destroyable.cc	(revision 10624)
@@ -33,4 +33,5 @@
 
 #include "Destroyable.h"
+#include "DestroyLaterManager.h"
 
 #include <cassert>
@@ -60,6 +61,6 @@
 
     /**
-        @brief Deletes the object if no @ref orxonox::SmartPtr "smart pointers" point to this object. Otherwise schedules the object to be deleted as soon as possible.
-        Always call destroy() instead of using 'delete' directly, otherwise smart pointers won't work.
+        @brief Deletes the object if no @ref orxonox::StrongPtr "strong pointers" point to this object. Otherwise schedules the object to be deleted as soon as possible.
+        Always call destroy() instead of using 'delete' directly, otherwise strong pointers won't work.
     */
     void Destroyable::destroy()
@@ -74,3 +75,15 @@
         }
     }
+
+    /**
+     * Works like @ref destroy() but doesn't destroy the object until the current tick has ended.
+     */
+    void Destroyable::destroyLater()
+    {
+        // register in DestroyLaterManager - this ensures that a strongPtr points to this object and keeps it alive for a while
+        DestroyLaterManager::getInstance().retain(this);
+
+        // request destruction -> object will be deleted after all strongPtrs (including the one in DestroyLaterManager) were destroyed.
+        this->destroy();
+    }
 }
Index: code/trunk/src/libraries/core/object/Destroyable.h
===================================================================
--- code/trunk/src/libraries/core/object/Destroyable.h	(revision 10622)
+++ code/trunk/src/libraries/core/object/Destroyable.h	(revision 10624)
@@ -30,5 +30,5 @@
     @file
     @ingroup Object
-    @brief Declaration of Destroyable, the base class of all objects which can be used with SmartPtr and WeakPtr.
+    @brief Declaration of Destroyable, the base class of all objects which can be used with StrongPtr and WeakPtr.
 */
 
@@ -43,10 +43,10 @@
 {
     /**
-        @brief Classes must inherit from this class if they should be used with SmartPtr or WeakPtr.
+        @brief Classes must inherit from this class if they should be used with StrongPtr or WeakPtr.
     */
     class _CoreExport Destroyable
     {
         template <class T>
-        friend class SmartPtr;
+        friend class StrongPtr;
 
         friend class DestructionListener;
@@ -57,19 +57,20 @@
 
             void destroy();
+            void destroyLater();
 
-            /// Returns the number of @ref orxonox::SmartPtr "smart pointers" that point to this object.
+            /// Returns the number of @ref orxonox::StrongPtr "strong pointers" that point to this object.
             inline unsigned int getReferenceCount() const
                 { return this->referenceCount_; }
 
         protected:
-            /// This virtual function is called if destroy() is called and no SmartPtr points to this object. Used in some cases to create a new SmartPtr to
+            /// This virtual function is called if destroy() is called and no StrongPtr points to this object. Used in some cases to create a new StrongPtr to
             /// prevent destruction. Don't call this function directly - use destroy() instead.
             virtual void preDestroy() {}
 
         private:
-            /// Increments the reference counter (for smart pointers).
+            /// Increments the reference counter (for strong pointers).
             inline void incrementReferenceCount()
                 { ++this->referenceCount_; }
-            /// Decrements the reference counter (for smart pointers).
+            /// Decrements the reference counter (for strong pointers).
             inline void decrementReferenceCount()
             {
@@ -86,5 +87,5 @@
                 { this->destructionListeners_.erase(pointer); }
 
-            int referenceCount_;                                    //!< Counts the references from smart pointers to this object
+            int referenceCount_;                                    //!< Counts the references from strong pointers to this object
             bool requestedDestruction_;                             //!< Becomes true after someone called delete on this object
             std::set<DestructionListener*> destructionListeners_;   //!< All destruction listeners (for example weak pointers which point to this object and like to get notified if it dies)
Index: code/trunk/src/libraries/core/object/Iterator.h
===================================================================
--- code/trunk/src/libraries/core/object/Iterator.h	(revision 10622)
+++ code/trunk/src/libraries/core/object/Iterator.h	(revision 10624)
@@ -76,5 +76,5 @@
                 @brief Constructor: Sets the element, whereon the iterator points, to zero.
             */
-            inline Iterator() : IteratorBase<T, Iterator<T> >(NULL) {}
+            inline Iterator() : IteratorBase<T, Iterator<T> >() {}
 
             /**
@@ -88,5 +88,5 @@
                 @param other The other Iterator
             */
-            inline Iterator(const Iterator<T>& other) : IteratorBase<T, Iterator<T> >(other) {}
+            inline Iterator(const IteratorBase<T, Iterator<T> >& other) : IteratorBase<T, Iterator<T> >(other) {}
 
             /**
Index: code/trunk/src/libraries/core/object/IteratorBase.h
===================================================================
--- code/trunk/src/libraries/core/object/IteratorBase.h	(revision 10622)
+++ code/trunk/src/libraries/core/object/IteratorBase.h	(revision 10624)
@@ -37,4 +37,7 @@
 
 #include "core/CorePrereqs.h"
+
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_base_of.hpp>
 
 #include "ObjectListBase.h"
@@ -49,10 +52,36 @@
     class IteratorBase : public ObjectListElementRemovalListener
     {
+        BOOST_STATIC_ASSERT((boost::is_base_of<Listable, T>::value));
+
+        protected:
+            /**
+                @brief Constructor: Sets the element, whereon the iterator points, to the given element.
+                This constructor is protected and only for internal usage (don't mess with the BaseElements directly).
+            */
+            inline IteratorBase(ObjectListBaseElement* element = NULL)
+            {
+                this->element_ = element;
+                this->registerIterator();
+            }
+
+
         public:
             /**
-                @brief Constructor: Sets the element, whereon the iterator points, to zero.
-            */
-            inline IteratorBase(ObjectListBaseElement* element)
-            {
+                @brief Constructor: Sets the element, whereon the iterator points, to the given element.
+            */
+            inline IteratorBase(ObjectListElement<T>* element)
+            {
+                this->element_ = element;
+                this->registerIterator();
+            }
+
+            /**
+                @brief Constructor: Sets the element, whereon the iterator points, to the given element of another type.
+                The element's type O must be a derivative of the Iterator's type T.
+            */
+            template <class O>
+            inline IteratorBase(ObjectListElement<O>* element)
+            {
+                (void)static_cast<T*>((O*)NULL); // Check type: The element's type O must be a derivative of the Iterator's type T.
                 this->element_ = element;
                 this->registerIterator();
Index: code/trunk/src/libraries/core/object/Listable.cc
===================================================================
--- code/trunk/src/libraries/core/object/Listable.cc	(revision 10622)
+++ code/trunk/src/libraries/core/object/Listable.cc	(revision 10624)
@@ -39,5 +39,5 @@
 namespace orxonox
 {
-    RegisterClass(Listable);
+    RegisterClass(Listable).virtualBase();
 
     /**
Index: code/trunk/src/libraries/core/object/ObjectList.h
===================================================================
--- code/trunk/src/libraries/core/object/ObjectList.h	(revision 10622)
+++ code/trunk/src/libraries/core/object/ObjectList.h	(revision 10624)
@@ -47,4 +47,7 @@
 #include "core/CorePrereqs.h"
 
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+
 #include "ObjectListBase.h"
 #include "ObjectListIterator.h"
@@ -66,38 +69,55 @@
     class ObjectList
     {
+        BOOST_STATIC_ASSERT((boost::is_base_of<Listable, T>::value));
+
         public:
             typedef ObjectListIterator<T> iterator;
 
+            /// Returns the size of the list (for the root context)
+            inline static size_t size()
+            {   return size(Context::getRootContext());   }
             /// Returns the size of the list
-            inline static size_t size()
+            inline static size_t size(Context* context)
             {
-                return Context::getRootContext()->getObjectList<T>()->size();
+                return context->getObjectList<T>()->size();
             }
 
+            /// Returns an Iterator to the first element in the list (for the root context).
+            inline static ObjectListElement<T>* begin()
+            {   return begin(Context::getRootContext());   }
             /// Returns an Iterator to the first element in the list.
-            inline static ObjectListElement<T>* begin()
+            inline static ObjectListElement<T>* begin(Context* context)
             {
-                ObjectListBase* list = Context::getRootContext()->getObjectList<T>();
+                ObjectListBase* list = context->getObjectList<T>();
                 return static_cast<ObjectListElement<T>*>(list->begin());
             }
 
+            /// Returns an Iterator to the element after the last element in the list (for the root context).
+            inline static ObjectListElement<T>* end()
+            {   return end(Context::getRootContext());   }
             /// Returns an Iterator to the element after the last element in the list.
-            inline static ObjectListElement<T>* end()
+            inline static ObjectListElement<T>* end(Context* context)
             {
-                ObjectListBase* list = Context::getRootContext()->getObjectList<T>();
+                ObjectListBase* list = context->getObjectList<T>();
                 return static_cast<ObjectListElement<T>*>(list->end());
             }
 
+            /// Returns an Iterator to the last element in the list (for the root context).
+            inline static ObjectListElement<T>* rbegin()
+            {   return rbegin(Context::getRootContext());   }
             /// Returns an Iterator to the last element in the list.
-            inline static ObjectListElement<T>* rbegin()
+            inline static ObjectListElement<T>* rbegin(Context* context)
             {
-                ObjectListBase* list = Context::getRootContext()->getObjectList<T>();
+                ObjectListBase* list = context->getObjectList<T>();
                 return static_cast<ObjectListElement<T>*>(list->rbegin());
             }
 
+            /// Returns an Iterator to the element before the first element in the list (for the root context).
+            inline static ObjectListElement<T>* rend()
+            {   return rend(Context::getRootContext());   }
             /// Returns an Iterator to the element before the first element in the list.
-            inline static ObjectListElement<T>* rend()
+            inline static ObjectListElement<T>* rend(Context* context)
             {
-                ObjectListBase* list = Context::getRootContext()->getObjectList<T>();
+                ObjectListBase* list = context->getObjectList<T>();
                 return static_cast<ObjectListElement<T>*>(list->rend());
             }
Index: code/trunk/src/libraries/core/object/ObjectListIterator.h
===================================================================
--- code/trunk/src/libraries/core/object/ObjectListIterator.h	(revision 10622)
+++ code/trunk/src/libraries/core/object/ObjectListIterator.h	(revision 10624)
@@ -74,5 +74,5 @@
                 @brief Constructor: Sets the element, whereon the ObjectListIterator points, to zero.
             */
-            inline ObjectListIterator() : IteratorBase<T, ObjectListIterator<T> >(NULL) {}
+            inline ObjectListIterator() : IteratorBase<T, ObjectListIterator<T> >() {}
 
             /**
Index: code/trunk/src/libraries/core/object/SmartPtr.h
===================================================================
--- code/trunk/src/libraries/core/object/SmartPtr.h	(revision 10622)
+++ 	(revision )
@@ -1,316 +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:
- *      ...
- *
- */
-
-// Inspired by boost::intrusive_ptr by Peter Dimov
-
-/**
-    @defgroup SmartPtr SmartPtr<T> and WeakPtr<T>
-    @ingroup Object
-*/
-
-/**
-    @file
-    @ingroup Object SmartPtr
-    @brief Definition of SmartPtr<T>, wraps a pointer to an object and keeps it alive.
-
-    @anchor SmartPtrExample
-
-    orxonox::SmartPtr is an implementation of a smart pointer - it wraps a pointer to an
-    object  and keeps this object alive until no SmartPtr points to this object anymore.
-    In contrast to orxonox::SharedPtr, SmartPtr works only with classes that are derived
-    from orxonox::Destroyable, because it's an intrusive implementation, meaning the
-    reference counter is stored in the object itself.
-
-    It's possible to use normal pointers and smart pointers to an object simultaneously.
-    You don't have to use SmartPtr all the time, you can create a SmartPtr for an object
-    at any time and also convert it back to a normal pointer if you like. This is possible
-    because the reference counter is stored in the object itself and not in SmartPtr (in
-    contrast to SharedPtr).
-
-    @b Important: If you want to delete an object, you must not use @c delete @c object but
-    rather @c object->destroy(). This function will check if there are smart pointers
-    pointing to the object. If yes, the object will be kept alive until all smart pointes
-    are destroyed. If no, the object is deleted instantly.
-
-    If all smart pointers that point to an object are destroyed, but you never called
-    @c object->destroy() before, the object will not be deleted! All a SmartPtr will do
-    is to really just keep an object alive, but it will not delete it automatically
-    unless you tried to destroy it before.
-
-    Example:
-    @code
-    class MyClass                                           // class declaration
-    {
-        public:
-            void setObject(OtherClass* object)              // passes a normal pointer which will be stored in a SmartPtr
-                { this->object_ = object; }
-
-            OtherClass* getObject() const                   // converts the SmartPtr to a normal pointer and returns it
-                { return this->object_; }
-
-        private:
-            SmartPtr<OtherClass> object_;                   // a pointer to an instance of OtherClass is stored in a SmartPtr
-    };
-    @endcode
-    In this example we assume that OtherClass is a child of Destroyable. We don't care
-    about the inheritance of MyClass though.
-
-    Now we create an instance of MyClass and assign a pointer to an instance of OtherClass:
-    @code
-    MyClass* myclass = new MyClass();                       // create an instance of MyClass
-    OtherClass* object = new OtherClass();                  // create an instance of OtherClass
-    myclass->setObject(object);                             // the object is now stored in a SmartPtr inside myclass
-
-    object->destroy();                                      // we try to destroy object, but there's still a SmartPtr pointing at it.
-
-    # object still exists at this point (because a SmartPtr points at it)
-
-    delete myclass;                                         // now we delete myclass, which also destroys the SmartPtr
-
-    # object doesn't exist anymore (because the SmartPtr is now destroyed)
-    @endcode
-
-    Now we look at the same example, but we first delete myclass, then destroy object:
-    @code
-    MyClass* myclass = new MyClass();                       // create an instance of MyClass
-    OtherClass* object = new OtherClass();                  // create an instance of OtherClass
-    myclass->setObject(object);                             // the object is now stored in a SmartPtr inside myclass
-
-    delete myclass;                                         // we delete myclass, which also destroys the SmartPtr
-
-    # object still exists at this point (because destroy() was not called yet)
-
-    object->destroy();                                      // now we try to destroy object, which works instantly
-
-    # object doesn't exist anymore (because we just destroyed it)
-    @endcode
-
-    Note that in any case @c object->destroy() has to be called to delete the object.
-    However if a SmartPtr points at it, the destruction is delayed until all SmartPtr
-    are destroyed.
-*/
-
-#ifndef _SmartPtr_H__
-#define _SmartPtr_H__
-
-#include "core/CorePrereqs.h"
-
-#include <cassert>
-
-#include "core/object/Destroyable.h"
-#include "WeakPtr.h"
-
-namespace orxonox
-{
-    /**
-        @brief A smart pointer which wraps a pointer to an object and keeps this object alive as long as the smart pointer exists.
-
-        @see See @ref SmartPtrExample "this description" for more information and an example.
-    */
-    template <class T>
-    class SmartPtr
-    {
-        public:
-            /// Constructor: Initializes the smart pointer with a null pointer.
-            inline SmartPtr() : pointer_(0), base_(0)
-            {
-            }
-
-            /// Constructor: Used to explicitly initialize the smart pointer with a null pointer
-            inline SmartPtr(int) : pointer_(0), base_(0)
-            {
-            }
-
-            /// Constructor: Initializes the smart pointer with a pointer to an object. @param pointer The pointer @param bAddRef If true, the reference counter is increased. Don't set this to false unless you know exactly what you're doing! (for example to avoid circular references if the @c this pointer of the possessing object is stored)
-            inline SmartPtr(T* pointer, bool bAddRef = true) : pointer_(pointer), base_(pointer)
-            {
-                if (this->base_ && bAddRef)
-                    this->base_->incrementReferenceCount();
-            }
-
-            /// Copy-constructor
-            inline SmartPtr(const SmartPtr& other) : pointer_(other.pointer_), base_(other.base_)
-            {
-                if (this->base_)
-                    this->base_->incrementReferenceCount();
-            }
-
-            /// Copy-constructor for smart pointers to objects of another class.
-            template <class O>
-            inline SmartPtr(const SmartPtr<O>& other) : pointer_(other.get()), base_(other.base_)
-            {
-                if (this->base_)
-                    this->base_->incrementReferenceCount();
-            }
-
-            /// Constructor: Initializes the smart pointer with the pointer that is stored in a WeakPtr.
-            template <class O>
-            inline SmartPtr(const WeakPtr<O>& other) : pointer_(other.get()), base_(other.getBase())
-            {
-                if (this->base_)
-                    this->base_->incrementReferenceCount();
-            }
-
-            /// Destructor: Decrements the reference counter.
-            inline ~SmartPtr()
-            {
-                if (this->base_)
-                    this->base_->decrementReferenceCount();
-            }
-
-            /// Used to assign a null pointer.
-            inline SmartPtr& operator=(int)
-            {
-                SmartPtr(0).swap(*this);
-                return *this;
-            }
-
-            /// Assigns a new pointer.
-            inline SmartPtr& operator=(T* pointer)
-            {
-                SmartPtr(pointer).swap(*this);
-                return *this;
-            }
-
-            /// Assigns the wrapped pointer of another SmartPtr.
-            inline SmartPtr& operator=(const SmartPtr& other)
-            {
-                SmartPtr(other).swap(*this);
-                return *this;
-            }
-
-            /// Assigns the wrapped pointer of a SmartPtr of another class
-            template <class O>
-            inline SmartPtr& operator=(const SmartPtr<O>& other)
-            {
-                SmartPtr(other).swap(*this);
-                return *this;
-            }
-
-            /// Assigns the wrapped pointer of a WeakPtr.
-            template <class O>
-            inline SmartPtr& operator=(const WeakPtr<O>& other)
-            {
-                SmartPtr(other).swap(*this);
-                return *this;
-            }
-
-            /// Returns the wrapped pointer as @c T*
-            inline T* get() const
-            {
-                return this->pointer_;
-            }
-
-            /// Returns the wrapped pointer as @c Destroyable*
-            inline Destroyable* getBase() const
-            {
-                return this->base_;
-            }
-
-            /// Implicitly converts the SmartPtr to a pointer of type @c T*
-            inline operator T*() const
-            {
-                return this->pointer_;
-            }
-
-            /// Overloaded operator, returns a pointer to the stored object.
-            inline T* operator->() const
-            {
-                assert(this->pointer_ != 0);
-                return this->pointer_;
-            }
-
-            /// Overloaded operator, returns a reference to the stored object.
-            inline T& operator*() const
-            {
-                assert(this->pointer_ != 0);
-                return *this->pointer_;
-            }
-
-            /// Returns true if the wrapped pointer is NULL.
-            inline bool operator!() const
-            {
-                return (this->pointer_ == 0);
-            }
-
-            /// Swaps the contents of two smart pointers.
-            inline void swap(SmartPtr& other)
-            {
-                {
-                    T* temp = this->pointer_;
-                    this->pointer_ = other.pointer_;
-                    other.pointer_ = temp;
-                }
-                {
-                    Destroyable* temp = this->base_;
-                    this->base_ = other.base_;
-                    other.base_ = temp;
-                }
-            }
-
-            /// Resets the smart pointer (equivalent to assigning a NULL pointer).
-            inline void reset()
-            {
-                SmartPtr().swap(*this);
-            }
-
-        private:
-            T* pointer_;            ///< The wrapped pointer to an object of type @a T
-            Destroyable* base_;    ///< The wrapped pointer, casted up to Destroyable (this is needed because with just a T* pointer, SmartPtr couln't be used with forward declarations)
-    };
-
-    /// Swaps the contents of two smart pointers.
-    template <class T>
-    void swap(SmartPtr<T>& a, SmartPtr<T>& b)
-    {
-        a.swap(b);
-    }
-
-    /// Uses a static_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new SmartPtr<T>.
-    template <class T, class U>
-    SmartPtr<T> static_pointer_cast(const SmartPtr<U>& p)
-    {
-        return static_cast<T*>(p.get());
-    }
-
-    /// Uses a const_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new SmartPtr<T>.
-    template <class T, class U>
-    SmartPtr<T> const_pointer_cast(const SmartPtr<U>& p)
-    {
-        return const_cast<T*>(p.get());
-    }
-
-    /// Uses a dynamic_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new SmartPtr<T>.
-    template <class T, class U>
-    SmartPtr<T> dynamic_pointer_cast(const SmartPtr<U>& p)
-    {
-        return orxonox_cast<T*>(p.get());
-    }
-}
-
-#endif /* _SmartPtr_H__ */
Index: code/trunk/src/libraries/core/object/StrongPtr.h
===================================================================
--- code/trunk/src/libraries/core/object/StrongPtr.h	(revision 10624)
+++ code/trunk/src/libraries/core/object/StrongPtr.h	(revision 10624)
@@ -0,0 +1,304 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+// Inspired by boost::intrusive_ptr by Peter Dimov
+
+/**
+    @defgroup SmartPtr StrongPtr<T> and WeakPtr<T>
+    @ingroup Object
+*/
+
+/**
+    @file
+    @ingroup Object SmartPtr
+    @brief Definition of StrongPtr<T>, wraps a pointer to an object and keeps it alive.
+
+    @anchor StrongPtrExample
+
+    orxonox::StrongPtr is an implementation of a smart pointer - it wraps a pointer to an
+    object  and keeps this object alive until no StrongPtr points to this object anymore.
+    In contrast to orxonox::SharedPtr, StrongPtr works only with classes that are derived
+    from orxonox::Destroyable, because it's an intrusive implementation, meaning the
+    reference counter is stored in the object itself.
+
+    It's possible to use normal pointers and strong pointers to an object simultaneously.
+    You don't have to use StrongPtr all the time, you can create a StrongPtr for an object
+    at any time and also convert it back to a normal pointer if you like. This is possible
+    because the reference counter is stored in the object itself and not in StrongPtr (in
+    contrast to SharedPtr).
+
+    @b Important: If you want to delete an object, you must not use @c delete @c object but
+    rather @c object->destroy(). This function will check if there are strong pointers
+    pointing to the object. If yes, the object will be kept alive until all strong pointers
+    are destroyed. If no, the object is deleted instantly.
+
+    If all strong pointers that point to an object are destroyed, but you never called
+    @c object->destroy() before, the object will not be deleted! All a StrongPtr will do
+    is to really just keep an object alive, but it will not delete it automatically
+    unless you tried to destroy it before.
+
+    Example:
+    @code
+    class MyClass                                           // class declaration
+    {
+        public:
+            void setObject(OtherClass* object)              // passes a normal pointer which will be stored in a StrongPtr
+                { this->object_ = object; }
+
+            OtherClass* getObject() const                   // converts the StrongPtr to a normal pointer and returns it
+                { return this->object_; }
+
+        private:
+            StrongPtr<OtherClass> object_;                  // a pointer to an instance of OtherClass is stored in a StrongPtr
+    };
+    @endcode
+    In this example we assume that OtherClass is a child of Destroyable. We don't care
+    about the inheritance of MyClass though.
+
+    Now we create an instance of MyClass and assign a pointer to an instance of OtherClass:
+    @code
+    MyClass* myclass = new MyClass();                       // create an instance of MyClass
+    OtherClass* object = new OtherClass();                  // create an instance of OtherClass
+    myclass->setObject(object);                             // the object is now stored in a StrongPtr inside myclass
+
+    object->destroy();                                      // we try to destroy object, but there's still a StrongPtr pointing at it.
+
+    # object still exists at this point (because a StrongPtr points at it)
+
+    delete myclass;                                         // now we delete myclass, which also destroys the StrongPtr
+
+    # object doesn't exist anymore (because the StrongPtr is now destroyed)
+    @endcode
+
+    Now we look at the same example, but we first delete myclass, then destroy object:
+    @code
+    MyClass* myclass = new MyClass();                       // create an instance of MyClass
+    OtherClass* object = new OtherClass();                  // create an instance of OtherClass
+    myclass->setObject(object);                             // the object is now stored in a StrongPtr inside myclass
+
+    delete myclass;                                         // we delete myclass, which also destroys the StrongPtr
+
+    # object still exists at this point (because destroy() was not called yet)
+
+    object->destroy();                                      // now we try to destroy object, which works instantly
+
+    # object doesn't exist anymore (because we just destroyed it)
+    @endcode
+
+    Note that in any case @c object->destroy() has to be called to delete the object.
+    However if a StrongPtr points at it, the destruction is delayed until all StrongPtr
+    are destroyed.
+*/
+
+#ifndef _StrongPtr_H__
+#define _StrongPtr_H__
+
+#include "core/CorePrereqs.h"
+
+#include <cassert>
+
+#include "core/object/Destroyable.h"
+#include "WeakPtr.h"
+
+namespace orxonox
+{
+    /**
+        @brief A strong pointer which wraps a pointer to an object and keeps this object alive as long as the strong pointer exists.
+
+        @see See @ref StrongPtrExample "this description" for more information and an example.
+    */
+    template <class T>
+    class StrongPtr
+    {
+        public:
+            /// Constructor: Initializes the strong pointer with a null pointer.
+            inline StrongPtr() : pointer_(0), base_(0)
+            {
+            }
+
+            /// Constructor: Initializes the strong pointer with a pointer to an object. @param pointer The pointer
+            inline StrongPtr(T* pointer) : pointer_(pointer), base_(pointer)
+            {
+                if (this->base_)
+                    this->base_->incrementReferenceCount();
+            }
+
+            /// Copy-constructor
+            inline StrongPtr(const StrongPtr& other) : pointer_(other.pointer_), base_(other.base_)
+            {
+                if (this->base_)
+                    this->base_->incrementReferenceCount();
+            }
+
+            /// Copy-constructor for strong pointers to objects of another class.
+            template <class O>
+            inline StrongPtr(const StrongPtr<O>& other) : pointer_(other.get()), base_(other.base_)
+            {
+                if (this->base_)
+                    this->base_->incrementReferenceCount();
+            }
+
+            /// Constructor: Initializes the strong pointer with the pointer that is stored in a WeakPtr.
+            template <class O>
+            inline StrongPtr(const WeakPtr<O>& other) : pointer_(other.get()), base_(other.getBase())
+            {
+                if (this->base_)
+                    this->base_->incrementReferenceCount();
+            }
+
+            /// Destructor: Decrements the reference counter.
+            inline ~StrongPtr()
+            {
+                if (this->base_)
+                    this->base_->decrementReferenceCount();
+            }
+
+            /// Assigns a new pointer.
+            inline StrongPtr& operator=(T* pointer)
+            {
+                StrongPtr(pointer).swap(*this);
+                return *this;
+            }
+
+            /// Assigns the wrapped pointer of another StrongPtr.
+            inline StrongPtr& operator=(const StrongPtr& other)
+            {
+                StrongPtr(other).swap(*this);
+                return *this;
+            }
+
+            /// Assigns the wrapped pointer of a StrongPtr of another class
+            template <class O>
+            inline StrongPtr& operator=(const StrongPtr<O>& other)
+            {
+                StrongPtr(other).swap(*this);
+                return *this;
+            }
+
+            /// Assigns the wrapped pointer of a WeakPtr.
+            template <class O>
+            inline StrongPtr& operator=(const WeakPtr<O>& other)
+            {
+                StrongPtr(other).swap(*this);
+                return *this;
+            }
+
+            /// Returns the wrapped pointer as @c T*
+            inline T* get() const
+            {
+                return this->pointer_;
+            }
+
+            /// Returns the wrapped pointer as @c Destroyable*
+            inline Destroyable* getBase() const
+            {
+                return this->base_;
+            }
+
+            /// Implicitly converts the StrongPtr to a pointer of type @c T*
+            inline operator T*() const
+            {
+                return this->pointer_;
+            }
+
+            /// Overloaded operator, returns a pointer to the stored object.
+            inline T* operator->() const
+            {
+                assert(this->pointer_ != 0);
+                return this->pointer_;
+            }
+
+            /// Overloaded operator, returns a reference to the stored object.
+            inline T& operator*() const
+            {
+                assert(this->pointer_ != 0);
+                return *this->pointer_;
+            }
+
+            /// Returns true if the wrapped pointer is NULL.
+            inline bool operator!() const
+            {
+                return (this->pointer_ == 0);
+            }
+
+            /// Swaps the contents of two strong pointers.
+            inline void swap(StrongPtr& other)
+            {
+                {
+                    T* temp = this->pointer_;
+                    this->pointer_ = other.pointer_;
+                    other.pointer_ = temp;
+                }
+                {
+                    Destroyable* temp = this->base_;
+                    this->base_ = other.base_;
+                    other.base_ = temp;
+                }
+            }
+
+            /// Resets the strong pointer (equivalent to assigning a NULL pointer).
+            inline void reset()
+            {
+                StrongPtr().swap(*this);
+            }
+
+        private:
+            T* pointer_;            ///< The wrapped pointer to an object of type @a T
+            Destroyable* base_;    ///< The wrapped pointer, casted up to Destroyable (this is needed because with just a T* pointer, StrongPtr couln't be used with forward declarations)
+    };
+
+    /// Swaps the contents of two strong pointers.
+    template <class T>
+    void swap(StrongPtr<T>& a, StrongPtr<T>& b)
+    {
+        a.swap(b);
+    }
+
+    /// Uses a static_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new StrongPtr<T>.
+    template <class T, class U>
+    StrongPtr<T> static_pointer_cast(const StrongPtr<U>& p)
+    {
+        return static_cast<T*>(p.get());
+    }
+
+    /// Uses a const_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new StrongPtr<T>.
+    template <class T, class U>
+    StrongPtr<T> const_pointer_cast(const StrongPtr<U>& p)
+    {
+        return const_cast<T*>(p.get());
+    }
+
+    /// Uses a dynamic_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new StrongPtr<T>.
+    template <class T, class U>
+    StrongPtr<T> dynamic_pointer_cast(const StrongPtr<U>& p)
+    {
+        return orxonox_cast<T*>(p.get());
+    }
+}
+
+#endif /* _StrongPtr_H__ */
Index: code/trunk/src/libraries/core/object/WeakPtr.h
===================================================================
--- code/trunk/src/libraries/core/object/WeakPtr.h	(revision 10622)
+++ code/trunk/src/libraries/core/object/WeakPtr.h	(revision 10624)
@@ -104,9 +104,4 @@
             }
 
-            /// Constructor: Used to explicitly initialize the weak pointer with a null pointer
-            inline WeakPtr(int) : pointer_(0), base_(0), callback_(0)
-            {
-            }
-
             /// Constructor: Initializes the weak pointer with a pointer to an object.
             inline WeakPtr(T* pointer) : pointer_(pointer), base_(pointer), callback_(0)
@@ -132,11 +127,4 @@
             {
                 this->unregisterAsDestructionListener(this->base_);
-            }
-
-            /// Used to assign a null pointer.
-            inline WeakPtr& operator=(int)
-            {
-                WeakPtr(0).swap(*this);
-                return *this;
             }
 
Index: code/trunk/src/libraries/core/singleton/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/core/singleton/CMakeLists.txt	(revision 10624)
+++ code/trunk/src/libraries/core/singleton/CMakeLists.txt	(revision 10624)
@@ -0,0 +1,4 @@
+ADD_SOURCE_FILES(CORE_SRC_FILES
+  ScopeManager.cc
+  ScopedSingletonIncludes.cc
+)
Index: code/trunk/src/libraries/core/singleton/Scope.h
===================================================================
--- code/trunk/src/libraries/core/singleton/Scope.h	(revision 10624)
+++ code/trunk/src/libraries/core/singleton/Scope.h	(revision 10624)
@@ -0,0 +1,133 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+/**
+@file
+@ingroup SingletonScope
+@brief Declaration of the classes that are needed to use Scopes: orxonox::Scope and orxonox::ScopeListener.
+
+@anchor Scope
+
+A virtual scope can be represented by an instance of class orxonox::Scope. orxonox::Scope<@a scope> is a template
+an its template argument defines the name of the virtual scope. See orxonox::ScopeID for an enumeration of the
+available values for @a scope. The orxonox::Scope object for a given @a scope can be activated or deactivated.
+Instances of orxonox::ScopeListener can register in orxonox::ScopeMAnager for a given @a scope and will get a
+notification if the corresponding orxonox::Scope object changes its state.
+
+Scopes are usually used to control the creation and destruction of Singletons.
+
+@see orxonox::Singleton
+*/
+
+#ifndef __Core_Scope_H__
+#define __Core_Scope_H__
+
+#include "core/CorePrereqs.h"
+
+#include <cassert>
+#include <map>
+#include <set>
+#include <loki/ScopeGuard.h>
+
+#include "util/Output.h"
+#include "ScopeManager.h"
+
+namespace orxonox
+{
+    /**
+        @brief ScopeListeners register themselves in the corresponding Scope and wait for notifications.
+        Notifications are sent if a Scope is activated or deactivated.
+
+        @see See @ref Scope "this description" for details about the interrelationship of Scope, ScopeListener, and ScopeManager.
+    */
+    class _CoreExport ScopeListener
+    {
+        friend class ScopeManager;
+
+        protected:
+            ScopeListener() : bActivated_(false) { }
+            virtual ~ScopeListener() { }
+
+            //! Gets called if the scope is activated
+            virtual void activated() = 0;
+            //! Gets called if the scope is deactivated
+            virtual void deactivated() = 0;
+
+        private:
+            bool bActivated_;
+    };
+
+    /**
+        @brief A scope for a given template argument is either active or not.
+
+        Objects inheriting from a ScopeListener are registered in a list (different for each scope).
+        If the scope gets activated or deactivated, all objects in this list are notified.
+
+        @see See @ref Scope "this description" for details about the interrelationship of Scope, ScopeListener, and ScopeManager.
+    */
+    template <ScopeID::Value scope>
+    class Scope
+    {
+        public:
+            //! Constructor: activate the listeners.
+            Scope()
+            {
+                orxout(internal_status) << "creating scope... (" << scope << ")" << endl;
+
+                Loki::ScopeGuard deactivator = Loki::MakeObjGuard(*this, &Scope::deactivateScope);
+                ScopeManager::getInstance().addScope(scope);
+                deactivator.Dismiss();
+
+                orxout(internal_status) << "created scope (" << scope << ")" << endl;
+            }
+
+            //! Destructor: deactivate the listeners.
+            ~Scope()
+            {
+                orxout(internal_status) << "destroying scope... (" << scope << ")" << endl;
+
+                this->deactivateScope();
+
+                orxout(internal_status) << "destroyed scope (" << scope << ")" << endl;
+            }
+
+            //! Deactivates the listeners of this scope in case the scope is destroyed or the construction fails.
+            void deactivateScope()
+            {
+                ScopeManager::getInstance().removeScope(scope);
+            }
+
+            //! Returns true if the scope is active.
+            static bool isActive()
+            {
+                return ScopeManager::getInstance().isActive(scope);
+            }
+    };
+}
+
+#endif /* __Core_Scope_H__ */
Index: code/trunk/src/libraries/core/singleton/ScopeManager.cc
===================================================================
--- code/trunk/src/libraries/core/singleton/ScopeManager.cc	(revision 10624)
+++ code/trunk/src/libraries/core/singleton/ScopeManager.cc	(revision 10624)
@@ -0,0 +1,102 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Implementation of orxonox::ScopeManager.
+*/
+
+#include "ScopeManager.h"
+
+#include "Scope.h"
+
+namespace orxonox
+{
+    ScopeManager* ScopeManager::singletonPtr_s = 0;
+
+    void ScopeManager::addScope(ScopeID::Value scope)
+    {
+        this->activeScopes_.insert(scope);
+        this->activateListenersForScope(scope);
+    }
+
+    void ScopeManager::removeScope(ScopeID::Value scope)
+    {
+        this->activeScopes_.erase(scope);
+        this->deactivateListenersForScope(scope);
+    }
+
+    bool ScopeManager::isActive(ScopeID::Value scope)
+    {
+        return this->activeScopes_.find(scope) != this->activeScopes_.end();
+    }
+
+    void ScopeManager::addListener(ScopeListener* listener, ScopeID::Value scope)
+    {
+        this->listeners_[scope].insert(listener);
+        if (this->isActive(scope))
+            this->activateListener(listener);
+    }
+
+    void ScopeManager::removeListener(ScopeListener* listener, ScopeID::Value scope)
+    {
+        if (this->isActive(scope))
+            this->deactivateListener(listener);
+        this->listeners_[scope].erase(listener);
+    }
+
+    void ScopeManager::activateListenersForScope(ScopeID::Value scope)
+    {
+        for (std::set<ScopeListener*>::iterator it = this->listeners_[scope].begin(); it != this->listeners_[scope].end(); ++it)
+            this->activateListener(*it);
+    }
+
+    void ScopeManager::deactivateListenersForScope(ScopeID::Value scope)
+    {
+        for (std::set<ScopeListener*>::iterator it = this->listeners_[scope].begin(); it != this->listeners_[scope].end(); ++it)
+            this->deactivateListener(*it);
+    }
+
+    void ScopeManager::activateListener(ScopeListener* listener)
+    {
+        listener->activated();
+        listener->bActivated_ = true;
+    }
+
+    void ScopeManager::deactivateListener(ScopeListener* listener)
+    {
+        if (listener->bActivated_)
+        {
+            try
+                { listener->deactivated(); }
+            catch (...)
+                { orxout(internal_warning) << "ScopeListener::deactivated() failed! This MUST NOT happen, fix it!" << endl; }
+            listener->bActivated_ = false;
+        }
+    }
+}
Index: code/trunk/src/libraries/core/singleton/ScopeManager.h
===================================================================
--- code/trunk/src/libraries/core/singleton/ScopeManager.h	(revision 10624)
+++ code/trunk/src/libraries/core/singleton/ScopeManager.h	(revision 10624)
@@ -0,0 +1,87 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+/**
+@file
+@ingroup SingletonScope
+@brief Declaration of orxonox::ScopeManager.
+*/
+
+#ifndef __ScopeManager_H__
+#define __ScopeManager_H__
+
+#include "core/CorePrereqs.h"
+
+#include <map>
+#include <set>
+
+#include "util/Singleton.h"
+
+namespace orxonox
+{
+    /**
+        @brief The ScopeManager stores the variables of the Scope templates in a statically linked context.
+
+        If all Scope objects are managed by this class, they are statically linked in the core library.
+        Without this, a new instance of Scope<T> for each T would be created in every library of Orxonox,
+        which is of course not the desired behavior.
+
+        @see See @ref Scope "this description" for details about the interrelationship of Scope, ScopeListener, and ScopeManager.
+    */
+    class _CoreExport ScopeManager : public Singleton<ScopeManager>
+    {
+        friend class Singleton<ScopeManager>;
+
+        public:
+            /** Adds a scope and activates all listeners which are registered for this scope */
+            void addScope(ScopeID::Value scope);
+            /** Removes a scope and deactivates all listeners which are registered for this scope */
+            void removeScope(ScopeID::Value scope);
+            /** Returns true if this scope is active */
+            bool isActive(ScopeID::Value scope);
+
+            /** Registers a listener for the given scope. If the scope is already active, the listener is activate immediately. */
+            void addListener(ScopeListener* listener, ScopeID::Value scope);
+            /** Unregisters a listener for the given scope. If the scope is still active, the listener is deactivated before removal. */
+            void removeListener(ScopeListener* listener, ScopeID::Value scope);
+
+        private:
+            void activateListenersForScope(ScopeID::Value scope);
+            void deactivateListenersForScope(ScopeID::Value scope);
+
+            void activateListener(ScopeListener* listener);
+            void deactivateListener(ScopeListener* listener);
+
+            std::set<ScopeID::Value> activeScopes_;
+            std::map<ScopeID::Value, std::set<ScopeListener*> > listeners_; //!< Stores all listeners for a scope
+
+            static ScopeManager* singletonPtr_s;
+    };
+}
+
+#endif /* __ScopeManager_H__ */
Index: code/trunk/src/libraries/core/singleton/ScopedSingletonIncludes.cc
===================================================================
--- code/trunk/src/libraries/core/singleton/ScopedSingletonIncludes.cc	(revision 10624)
+++ code/trunk/src/libraries/core/singleton/ScopedSingletonIncludes.cc	(revision 10624)
@@ -0,0 +1,42 @@
+/*
+ *   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 "ScopedSingletonIncludes.h"
+
+namespace orxonox
+{
+    void StaticallyInitializedScopedSingletonWrapper::load()
+    {
+        ScopeManager::getInstance().addListener(this->wrapper_, this->scope_);
+    }
+
+    void StaticallyInitializedScopedSingletonWrapper::unload()
+    {
+        ScopeManager::getInstance().removeListener(this->wrapper_, this->scope_);
+    }
+}
Index: code/trunk/src/libraries/core/singleton/ScopedSingletonIncludes.h
===================================================================
--- code/trunk/src/libraries/core/singleton/ScopedSingletonIncludes.h	(revision 10624)
+++ code/trunk/src/libraries/core/singleton/ScopedSingletonIncludes.h	(revision 10624)
@@ -0,0 +1,103 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @ingroup SingletonScope
+    @brief Definition of the ManageScopedSingleton macro.
+*/
+
+#ifndef __ScopedSingletonIncludes_H__
+#define __ScopedSingletonIncludes_H__
+
+#include "core/CorePrereqs.h"
+
+#include "ScopedSingletonWrapper.h"
+#include "core/module/StaticallyInitializedInstance.h"
+
+/**
+    @brief Creates an orxonox::ScopedSingletonWrapper for an orxonox::Singleton and registers it with orxonox::ScopeManager.
+    @param className The name of the singleton class
+    @param scope The scope in which the singleton should exist
+    @param allowedToFail If true, the singleton is allowed to fail and thus a try-catch block is used when creating the singleton.
+
+    If this macro is called for a singleton, it is wrapped in a ScopedSingletonWrapper and registered with ScopeManager
+    and will thus be created if its scope becomes active and destroyed if is deactivated.
+
+
+    Usually a singleton gets created automatically when it is first used, but it will never
+    be destroyed (unless the singleton explicitly deletes itself). To allow controlled
+    construction and destruction, the singleton can be put within a virtual scope. This is
+    done by registering the singleton class with orxonox::ScopeManager. To
+    do so, the ManageScopedSingleton() macro has to be called:
+
+    @code
+    ManageScopedSingleton(TestSingleton, ScopeID::Graphics, false); // muste be called in a source (*.cc) file
+    @endcode
+
+    @b Important: If you call ManageScopedSingleton(), you don't have to initialize singletonPtr_s anymore,
+    because that's already done by the macro.
+
+    Now the singleton TestSingleton gets automatically created if the scope Graphics becomes
+    active and also gets destroyed if the scope is deactivated.
+
+    Note that not all singletons must register with a scope, but it's recommended.
+
+*/
+#define ManageScopedSingleton(className, scope, allowedToFail) \
+    className* className::singletonPtr_s = NULL; \
+    static ScopedSingletonWrapper& className##ScopedSingletonWrapper \
+        = (new orxonox::SI_SSW(new ClassScopedSingletonWrapper<className, allowedToFail>(#className), scope))->getWrapper()
+
+namespace orxonox
+{
+    class _CoreExport StaticallyInitializedScopedSingletonWrapper : public StaticallyInitializedInstance
+    {
+        public:
+            StaticallyInitializedScopedSingletonWrapper(ScopedSingletonWrapper* wrapper, ScopeID::Value scope)
+                : StaticallyInitializedInstance(StaticInitialization::SCOPED_SINGLETON_WRAPPER)
+                , wrapper_(wrapper)
+                , scope_(scope)
+            {}
+            ~StaticallyInitializedScopedSingletonWrapper() { delete wrapper_; }
+
+            virtual void load();
+            virtual void unload();
+
+            inline ScopedSingletonWrapper& getWrapper()
+                { return *this->wrapper_; }
+
+        private:
+            ScopedSingletonWrapper* wrapper_;
+            ScopeID::Value scope_;
+    };
+
+    typedef StaticallyInitializedScopedSingletonWrapper SI_SSW;
+}
+
+#endif /* __ScopedSingletonIncludes_H__ */
Index: code/trunk/src/libraries/core/singleton/ScopedSingletonWrapper.h
===================================================================
--- code/trunk/src/libraries/core/singleton/ScopedSingletonWrapper.h	(revision 10624)
+++ code/trunk/src/libraries/core/singleton/ScopedSingletonWrapper.h	(revision 10624)
@@ -0,0 +1,196 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @ingroup SingletonScope
+    @brief Definition of orxonox::ScopedSingletonWrapper and orxonox::ClassScopedSingletonWrapper.
+
+    ScopedSingletonWrapper is used to create and destroy Singletons that belong to
+    a given Scope. For each one of these singletons, the macro ManageScopedSingleton()
+    has to be called to register the wrapper with orxonox::ScopeManager.
+
+    See @ref SingletonExample "this code" for an example.
+
+    @see orxonox::Singleton
+    @see orxonox::Scope
+*/
+
+#ifndef __ScopedSingletonWrapper_H__
+#define __ScopedSingletonWrapper_H__
+
+#include "core/CorePrereqs.h"
+
+#include <cassert>
+#include "util/Exception.h"
+#include "util/Singleton.h"
+#include "Scope.h"
+
+namespace orxonox
+{
+    /**
+        @brief Base class of ClassScopedSingletonWrapper.
+    */
+    class _CoreExport ScopedSingletonWrapper : public ScopeListener
+    {
+        public:
+            /// Constructor: Initializes all the values
+            ScopedSingletonWrapper(const std::string& className)
+                : className_(className)
+            { }
+            virtual ~ScopedSingletonWrapper() { }
+
+        protected:
+            const std::string className_;   ///< The name of the scoped singleton class that is managed by this object
+    };
+
+    /**
+        @anchor ClassScopedSingletonWrapper
+
+        @brief Manages a scoped singleton
+        @param T The managed singleton class
+        @param allowedToFail If true, a specialization of this template is used, that uses try-catch blocks to handle possible failures.
+
+        This class inherits from ScopeListener and is registered for a scope in ScopeManager and thus its functions
+        activated() and deactivated() are called whenever the Scope changes its state.
+
+        If the Scope is activated, a new instance of @a T (which must be a singleton) is created.
+        If the Scope is deactivated, the singleton is destroyed.
+
+        @see Singleton
+    */
+    template <class T, bool allowedToFail>
+    class ClassScopedSingletonWrapper : public ScopedSingletonWrapper
+    {
+    public:
+        ClassScopedSingletonWrapper(const std::string& className)
+            : ScopedSingletonWrapper(className)
+            , singletonPtr_(NULL)
+        {
+        }
+
+        ~ClassScopedSingletonWrapper()
+        {
+            if (singletonPtr_)
+                this->destroy(singletonPtr_);
+        }
+
+        //! Called if the Scope of the Singleton gets active (creates the instance)
+        void activated()
+        {
+            assert(singletonPtr_ == NULL);
+            singletonPtr_ = new T();
+        }
+
+        //! Called if the Scope of this Singleton gets deactivated (destroys the instance)
+        void deactivated()
+        {
+            assert(singletonPtr_ != NULL);
+            this->destroy(singletonPtr_);
+            singletonPtr_ = NULL;
+        }
+
+        //! Destroys the singleton instance - overloaded for Destroyable, calls Destroyable::destroy()
+        void destroy(Destroyable*)
+        {
+            singletonPtr_->destroy();
+        }
+        //! Destroys the singleton instance - overloaded for all other pointers, calls delete
+        void destroy(void*)
+        {
+            delete singletonPtr_;
+        }
+
+    private:
+        T* singletonPtr_;   ///< Unique instance of the singleton class @a T
+    };
+
+    /**
+        @brief This class partially spezializes ClassScopedSingletonWrapper for classes @a T that are allowed to fail.
+        @param T The managed singleton class
+
+        Because @a T could fail when being created, this partial spezialization of ClassScopedSingletonWrapper
+        uses a try-catch block to handle exceptions.
+
+        See @ref ClassScopedSingletonWrapper for a full documentation of the basis template.
+    */
+    template <class T>
+    class ClassScopedSingletonWrapper<T, true> : public ScopedSingletonWrapper
+    {
+    public:
+        ClassScopedSingletonWrapper(const std::string& className)
+            : ScopedSingletonWrapper(className)
+            , singletonPtr_(NULL)
+        {
+        }
+
+        ~ClassScopedSingletonWrapper()
+        {
+            if (singletonPtr_)
+                this->destroy(singletonPtr_);
+        }
+
+        //! Called if the Scope of the Singleton gets active (creates the instance)
+        void activated()
+        {
+            assert(singletonPtr_ == NULL);
+            try
+                { singletonPtr_ = new T(); }
+            catch (const InitialisationAbortedException& ex)
+                { orxout(internal_error) << ex.getDescription() << endl; }
+            catch (...)
+                { orxout(internal_error) << "Singleton creation failed: " << Exception::handleMessage() << endl; }
+        }
+
+        //! Called if the Scope of this Singleton gets deactivated (destroys the instance)
+        void deactivated()
+        {
+            if (singletonPtr_ != NULL)
+            {
+                this->destroy(singletonPtr_);
+                singletonPtr_ = NULL;
+            }
+        }
+
+        //! Destroys the singleton instance - overloaded for Destroyable, calls Destroyable::destroy()
+        void destroy(Destroyable*)
+        {
+            singletonPtr_->destroy();
+        }
+        //! Destroys the singleton instance - overloaded for void*, calls delete
+        void destroy(void*)
+        {
+            delete singletonPtr_;
+        }
+
+    private:
+        T* singletonPtr_;   ///< Unique instance of the singleton class @a T
+    };
+}
+
+#endif /* __ScopedSingletonWrapper_H__ */
Index: code/trunk/src/libraries/network/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/network/CMakeLists.txt	(revision 10622)
+++ code/trunk/src/libraries/network/CMakeLists.txt	(revision 10624)
@@ -34,4 +34,7 @@
   MasterServerComm.cc
   NetworkFunction.cc
+  NetworkFunctionIncludes.cc
+  NetworkFunctionManager.cc
+  NetworkStaticInitializationHandler.cc
   Host.cc
   Server.cc
@@ -43,36 +46,9 @@
 )
 
-SET_SOURCE_FILES(NETWORK_HDR_FILES
-  Client.h
-  ClientConnection.h
-  ClientConnectionListener.h
-  Connection.h
-  FunctionCall.h
-  FunctionCallManager.h
-  #GamestateClient.h
-  GamestateHandler.h
-  GamestateManager.h
-  Host.h
-  LANDiscoverable.h
-  LANDiscovery.h
-  WANDiscoverable.h
-  WANDiscovery.h
-  MasterServerComm.h
-  NetworkChatListener.h
-  NetworkFunction.h
-  NetworkPrecompiledHeaders.h
-  NetworkPrereqs.h
-  Server.h
-  MasterServer.h
-  PeerList.h
-  ServerList.h
-  ServerConnection.h
-  TrafficControl.h
-)
-
 ADD_SUBDIRECTORY(packet)
 ADD_SUBDIRECTORY(synchronisable)
 
 ORXONOX_ADD_LIBRARY(network
+  FIND_HEADER_FILES
   TOLUA_FILES
     Client.h
@@ -90,4 +66,4 @@
     core
   SOURCE_FILES
-    ${NETWORK_SRC_FILES} ${NETWORK_HDR_FILES}
+    ${NETWORK_SRC_FILES}
 )
Index: code/trunk/src/libraries/network/Client.cc
===================================================================
--- code/trunk/src/libraries/network/Client.cc	(revision 10622)
+++ code/trunk/src/libraries/network/Client.cc	(revision 10624)
@@ -45,5 +45,4 @@
 #include "util/Clock.h"
 #include "util/Output.h"
-#include "util/ScopedSingletonManager.h"
 #include "synchronisable/Synchronisable.h"
 #include "packet/Chat.h"
@@ -52,10 +51,11 @@
 #include "core/CoreIncludes.h"
 #include "core/Game.h"
-#include "core/config/CommandLineParser.h"
+#include "core/commandline/CommandLineParser.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 
 namespace orxonox
 {
 
-  ManageScopedSingleton( Client, ScopeID::Root, true );
+  ManageScopedSingleton( Client, ScopeID::ROOT, false );
 
   /**
@@ -194,14 +194,4 @@
   void Client::connectionClosed()
   {
-    ObjectList<Synchronisable>::iterator it;
-    for(it = ObjectList<Synchronisable>::begin(); it; )
-    {
-      if( it->getSyncMode() != 0x0 )
-        (it++)->destroy();
-      else
-      {
-        ++it;
-      }
-    }
     Game::getInstance().popState();
     Game::getInstance().popState();
Index: code/trunk/src/libraries/network/ClientConnectionListener.cc
===================================================================
--- code/trunk/src/libraries/network/ClientConnectionListener.cc	(revision 10622)
+++ code/trunk/src/libraries/network/ClientConnectionListener.cc	(revision 10624)
@@ -35,5 +35,5 @@
 namespace orxonox
 {
-    RegisterAbstractClass(ClientConnectionListener).inheritsFrom(Class(Listable));
+    RegisterAbstractClass(ClientConnectionListener).inheritsFrom<Listable>();
 
     ClientConnectionListener::ClientConnectionListener()
Index: code/trunk/src/libraries/network/FunctionCall.cc
===================================================================
--- code/trunk/src/libraries/network/FunctionCall.cc	(revision 10622)
+++ code/trunk/src/libraries/network/FunctionCall.cc	(revision 10624)
@@ -32,4 +32,5 @@
 #include "util/MultiType.h"
 #include "NetworkFunction.h"
+#include "NetworkFunctionManager.h"
 
 namespace orxonox {
@@ -46,98 +47,57 @@
 
 bool FunctionCall::execute(){
-  if( this->bIsStatic_ )
+  NetworkFunctionBase* fct = NetworkFunctionManager::getInstance().getFunctionByNetworkId( this->functionID_ );
+  assert( fct != NULL );
+  assert( this->nrOfArguments_==this->arguments_.size() );
+  switch(this->nrOfArguments_)
   {
-    NetworkFunctionStatic *fct = NetworkFunctionStatic::getFunction( this->functionID_ );
-    assert( this->nrOfArguments_==this->arguments_.size() );
-    switch(this->nrOfArguments_)
-    {
-      case 0:
-        fct->call();
-        break;
-      case 1:
-        fct->call(this->arguments_[0]);
-        break;
-      case 2:
-        fct->call(this->arguments_[0], this->arguments_[1]);
-        break;
-      case 3:
-        fct->call(this->arguments_[0], this->arguments_[1], this->arguments_[2]);
-        break;
-      case 4:
-        fct->call(this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]);
-        break;
-      case 5:
-        fct->call(this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]);
-        break;
-      default:
-        assert(0);
-    }
+    case 0:
+      return fct->call(this->objectID_);
+    case 1:
+      return fct->call(this->objectID_, this->arguments_[0]);
+    case 2:
+      return fct->call(this->objectID_, this->arguments_[0], this->arguments_[1]);
+    case 3:
+      return fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2]);
+    case 4:
+      return fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]);
+    case 5:
+      return fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]);
+    default:
+      assert(0);
+      return true; // return true to avoid that this functions gets called over and over again
   }
-  else // not a static function, so also handle with the objectID
-  {
-    NetworkMemberFunctionBase *fct = NetworkMemberFunctionBase::getFunction( this->functionID_ );
-    switch(this->nrOfArguments_)
-    {
-      case 0:
-        if( !fct->call(this->objectID_) )
-          return false;
-        break;
-      case 1:
-        if( !fct->call(this->objectID_, this->arguments_[0]) )
-          return false;
-        break;
-      case 2:
-        if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1]) )
-          return false;
-        break;
-      case 3:
-        if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2]) )
-          return false;
-        break;
-      case 4:
-        if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]) )
-          return false;
-        break;
-      case 5:
-        if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]) )
-          return false;
-        break;
-      default:
-        assert(0);
-    }
-  }
-  return true;
 }
 
-void FunctionCall::setCallStatic( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
+void FunctionCall::setCall( uint32_t networkID, uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5){
 
   // first determine the size that has to be reserved for this call
-  uint32_t callsize = 2*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and for bool isStatic
+  uint32_t callsize = 3*sizeof(uint32_t); //size for network-function-id and nrOfArguments and the objectID
   uint32_t nrOfArguments = 0;
-  if(mt1)
+  if(!mt1.null())
   {
     nrOfArguments++;
-    callsize += mt1->getNetworkSize();
-    this->arguments_.push_back(*mt1);
-    if(mt2)
+    callsize += mt1.getNetworkSize();
+    this->arguments_.push_back(mt1);
+    if(!mt2.null())
     {
       nrOfArguments++;
-      callsize += mt2->getNetworkSize();
-      this->arguments_.push_back(*mt2);
-      if(mt3)
+      callsize += mt2.getNetworkSize();
+      this->arguments_.push_back(mt2);
+      if(!mt3.null())
       {
         nrOfArguments++;
-        callsize += mt3->getNetworkSize();
-        this->arguments_.push_back(*mt3);
-        if(mt4)
+        callsize += mt3.getNetworkSize();
+        this->arguments_.push_back(mt3);
+        if(!mt4.null())
         {
           nrOfArguments++;
-          callsize += mt4->getNetworkSize();
-          this->arguments_.push_back(*mt4);
-          if(mt5)
+          callsize += mt4.getNetworkSize();
+          this->arguments_.push_back(mt4);
+          if(!mt5.null())
           {
             nrOfArguments++;
-            callsize += mt5->getNetworkSize();
-            this->arguments_.push_back(*mt5);
+            callsize += mt5.getNetworkSize();
+            this->arguments_.push_back(mt5);
           }
         }
@@ -146,49 +106,7 @@
   }
   this->nrOfArguments_ = nrOfArguments;
+  this->functionID_ = networkID;
+  this->objectID_ = objectID;
   this->size_ = callsize;
-  this->bIsStatic_ = true;
-  this->functionID_ = networkID;
-}
-
-void FunctionCall::setCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
-
-  // first determine the size that has to be reserved for this call
-  uint32_t callsize = 3*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and the objectID and bIsStatic
-  uint32_t nrOfArguments = 0;
-  if(mt1)
-  {
-    nrOfArguments++;
-    callsize += mt1->getNetworkSize();
-    this->arguments_.push_back(*mt1);
-    if(mt2)
-    {
-      nrOfArguments++;
-      callsize += mt2->getNetworkSize();
-      this->arguments_.push_back(*mt2);
-      if(mt3)
-      {
-        nrOfArguments++;
-        callsize += mt3->getNetworkSize();
-        this->arguments_.push_back(*mt3);
-        if(mt4)
-        {
-          nrOfArguments++;
-          callsize += mt4->getNetworkSize();
-          this->arguments_.push_back(*mt4);
-          if(mt5)
-          {
-            nrOfArguments++;
-            callsize += mt5->getNetworkSize();
-            this->arguments_.push_back(*mt5);
-          }
-        }
-      }
-    }
-  }
-  this->nrOfArguments_ = nrOfArguments;
-  this->bIsStatic_ = false;
-  this->functionID_ = networkID;
-  this->size_ = callsize;
-  this->objectID_ = objectID;
 }
 
@@ -196,15 +114,7 @@
 {
   this->functionID_ = *(uint32_t*)mem;
-  this->bIsStatic_ = *(uint8_t*)(mem+sizeof(uint32_t));
-  this->nrOfArguments_ = *(uint32_t*)(mem+sizeof(uint32_t)+sizeof(uint8_t));
-  if( this->bIsStatic_ )
-  {
-    mem += 2*sizeof(uint32_t)+sizeof(uint8_t);
-  }
-  else
-  {
-    this->objectID_ = *(uint32_t*)(mem+2*sizeof(uint32_t)+sizeof(uint8_t));
-    mem += 3*sizeof(uint32_t)+sizeof(uint8_t);
-  }
+  this->nrOfArguments_ = *(uint32_t*)(mem+sizeof(uint32_t));
+  this->objectID_ = *(uint32_t*)(mem+2*sizeof(uint32_t));
+  mem += 3*sizeof(uint32_t);
   for( unsigned int i=0; i<this->nrOfArguments_; ++i )
   {
@@ -218,15 +128,7 @@
   // now serialise the mt values and copy the function id and isStatic
   *(uint32_t*)mem = this->functionID_;
-  *(uint8_t*)(mem+sizeof(uint32_t)) = this->bIsStatic_;
-  *(uint32_t*)(mem+sizeof(uint32_t)+sizeof(uint8_t)) = this->nrOfArguments_;
-  if( this->bIsStatic_ )
-  {
-    mem += 2*sizeof(uint32_t)+sizeof(uint8_t);
-  }
-  else
-  {
-    *(uint32_t*)(mem+2*sizeof(uint32_t)+sizeof(uint8_t)) = this->objectID_;
-    mem += 3*sizeof(uint32_t)+sizeof(uint8_t);
-  }
+  *(uint32_t*)(mem+sizeof(uint32_t)) = this->nrOfArguments_;
+  *(uint32_t*)(mem+2*sizeof(uint32_t)) = this->objectID_;
+  mem += 3*sizeof(uint32_t);
   for( std::vector<MultiType>::iterator it = this->arguments_.begin(); it!=this->arguments_.end(); ++it )
   {
Index: code/trunk/src/libraries/network/FunctionCall.h
===================================================================
--- code/trunk/src/libraries/network/FunctionCall.h	(revision 10622)
+++ code/trunk/src/libraries/network/FunctionCall.h	(revision 10624)
@@ -52,6 +52,5 @@
   bool execute();
 
-  void setCallStatic( uint32_t networkID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
-  void setCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
+  void setCall( uint32_t networkID, uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
   
   void saveData( uint8_t*& mem );
@@ -59,7 +58,6 @@
 private:
   uint32_t                  nrOfArguments_;
-  bool                      bIsStatic_;
   uint32_t                  functionID_;
-  uint32_t                  objectID_;
+  uint32_t                  objectID_; // equals OBJECTID_UNKNOWN for static functions
   uint32_t                  size_;
   std::vector<MultiType>    arguments_;
Index: code/trunk/src/libraries/network/FunctionCallManager.cc
===================================================================
--- code/trunk/src/libraries/network/FunctionCallManager.cc	(revision 10622)
+++ code/trunk/src/libraries/network/FunctionCallManager.cc	(revision 10624)
@@ -39,7 +39,6 @@
 std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t> > > FunctionCallManager::sIncomingFunctionCallBuffer_;
 
-// Static calls
 
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID)
+void FunctionCallManager::addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
 {
   if(sPeerMap_.find(peerID)==sPeerMap_.end())
@@ -48,108 +47,5 @@
     FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
   }
-  FunctionCallManager::sPeerMap_[peerID]->addCallStatic(functionID);
-}
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1)
-{
-  if(sPeerMap_.find(peerID)==sPeerMap_.end())
-  {
-    FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
-    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
-  }
-  FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1);
-}
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2)
-{
-  if(sPeerMap_.find(peerID)==sPeerMap_.end())
-  {
-    FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
-    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
-  }
-  FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2);
-}
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
-{
-  if(sPeerMap_.find(peerID)==sPeerMap_.end())
-  {
-    FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
-    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
-  }
-  FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2, &mt3);
-}
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
-{
-  if(sPeerMap_.find(peerID)==sPeerMap_.end())
-  {
-    FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
-    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
-  }
-  FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4);
-}
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
-{
-  if(sPeerMap_.find(peerID)==sPeerMap_.end())
-  {
-    FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
-    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
-  }
-  FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4, &mt5);
-}
-
-
-// MemberCalls
-
-void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID)
-{
-  if(sPeerMap_.find(peerID)==sPeerMap_.end())
-  {
-    FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
-    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
-  }
-  FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID);
-}
-void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1)
-{
-  if(sPeerMap_.find(peerID)==sPeerMap_.end())
-  {
-    FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
-    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
-  }
-  FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1);
-}
-void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2)
-{
-  if(sPeerMap_.find(peerID)==sPeerMap_.end())
-  {
-    FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
-    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
-  }
-  FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2);
-}
-void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
-{
-  if(sPeerMap_.find(peerID)==sPeerMap_.end())
-  {
-    FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
-    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
-  }
-  FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3);
-}
-void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
-{
-  if(sPeerMap_.find(peerID)==sPeerMap_.end())
-  {
-    FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
-    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
-  }
-  FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4);
-}
-void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
-{
-  if(sPeerMap_.find(peerID)==sPeerMap_.end())
-  {
-    FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
-    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
-  }
-  FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4, &mt5);
+  FunctionCallManager::sPeerMap_[peerID]->addCall(functionID, objectID, mt1, mt2, mt3, mt4, mt5);
 }
 
Index: code/trunk/src/libraries/network/FunctionCallManager.h
===================================================================
--- code/trunk/src/libraries/network/FunctionCallManager.h	(revision 10622)
+++ code/trunk/src/libraries/network/FunctionCallManager.h	(revision 10624)
@@ -46,17 +46,5 @@
 {
 public:
-  static void addCallStatic(uint32_t functionID, uint32_t peerID);
-  static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1);
-  static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2);
-  static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3);
-  static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4);
-  static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
-
-  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID);
-  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1);
-  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2);
-  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3);
-  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4);
-  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
+  static void addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
 
   static void sendCalls(orxonox::Host* host);
Index: code/trunk/src/libraries/network/Host.cc
===================================================================
--- code/trunk/src/libraries/network/Host.cc	(revision 10622)
+++ code/trunk/src/libraries/network/Host.cc	(revision 10624)
@@ -34,5 +34,5 @@
 #include "core/CoreIncludes.h"
 #include "core/object/ObjectList.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "NetworkChatListener.h"
 
@@ -143,4 +143,6 @@
   //////////////////////////////////////////////////////////////////////////
 
+  RegisterAbstractClass(NetworkChatListener).inheritsFrom<Listable>();
+
   NetworkChatListener::NetworkChatListener()
   {
Index: code/trunk/src/libraries/network/LANDiscovery.cc
===================================================================
--- code/trunk/src/libraries/network/LANDiscovery.cc	(revision 10622)
+++ code/trunk/src/libraries/network/LANDiscovery.cc	(revision 10624)
@@ -32,11 +32,11 @@
 #include <cstring>
 
-#include "util/ScopedSingletonManager.h"
 #include "core/CoreIncludes.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 
 
 namespace orxonox
 {
-  ManageScopedSingleton(LANDiscovery, ScopeID::Graphics, true);
+  ManageScopedSingleton(LANDiscovery, ScopeID::GRAPHICS, false);
 
   LANDiscovery::LANDiscovery()
Index: code/trunk/src/libraries/network/MasterServer.cc
===================================================================
--- code/trunk/src/libraries/network/MasterServer.cc	(revision 10622)
+++ code/trunk/src/libraries/network/MasterServer.cc	(revision 10624)
@@ -28,8 +28,8 @@
 
 #include "MasterServer.h"
-#include "util/ScopedSingletonManager.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "core/CoreIncludes.h"
 #include "core/CorePrereqs.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 #include "util/Output.h"
 
Index: code/trunk/src/libraries/network/NetworkFunction.cc
===================================================================
--- code/trunk/src/libraries/network/NetworkFunction.cc	(revision 10622)
+++ code/trunk/src/libraries/network/NetworkFunction.cc	(revision 10624)
@@ -28,85 +28,20 @@
 
 #include "NetworkFunction.h"
-#include "core/CoreIncludes.h"
+#include "NetworkFunctionManager.h"
 
 namespace orxonox
 {
-  std::map<uint32_t, bool> NetworkFunctionBase::isStaticMap_;
+    NetworkFunctionBase::NetworkFunctionBase(const std::string& name, const NetworkFunctionPointer& pointer)
+    {
+        static uint32_t networkID = 0;
+        this->networkID_ = networkID++;
+        this->name_ = name;
+        this->pointer_ = pointer;
+    }
 
-  std::map<NetworkFunctionPointer, NetworkMemberFunctionBase*> NetworkMemberFunctionBase::functorMap_;
-  std::map<uint32_t, NetworkMemberFunctionBase*> NetworkMemberFunctionBase::idMap_;
-
-  // no suitable factory for NetworkFunctionBase (and children), so we declare it abstract
-  RegisterAbstractClass(NetworkFunctionBase).inheritsFrom(Class(Listable));
-  RegisterAbstractClass(NetworkFunctionStatic).inheritsFrom(Class(NetworkFunctionBase));
-  RegisterAbstractClass(NetworkMemberFunctionBase).inheritsFrom(Class(NetworkFunctionBase));
-
-  NetworkFunctionBase::NetworkFunctionBase(const std::string& name)
-  {
-      RegisterObject(NetworkFunctionBase);
-
-    static uint32_t networkID = 0;
-    this->networkID_ = networkID++;
-
-    this->name_ = name;
-    NetworkFunctionBase::getNameMap()[name] = this;
-  }
-  NetworkFunctionBase::~NetworkFunctionBase()
-  {
-  }
-
-
-  void NetworkFunctionBase::destroyAllNetworkFunctions()
-  {
-    std::map<std::string, NetworkFunctionBase*>& map = NetworkFunctionBase::getNameMap();
-    std::map<std::string, NetworkFunctionBase*>::iterator it;
-    for( it=map.begin(); it!=map.end(); ++it )
-      delete it->second;
-  }
-
-
-  /*static*/ std::map<std::string, NetworkFunctionBase*>& NetworkFunctionBase::getNameMap()
-  {
-    static std::map<std::string, NetworkFunctionBase*> nameMap_;
-    return nameMap_;
-  }
-
-
-  NetworkFunctionStatic::NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p):
-    NetworkFunctionBase(name)
-  {
-    RegisterObject(NetworkFunctionStatic);
-
-    this->functor_ = functor;
-    NetworkFunctionStatic::getFunctorMap()[p] = this;
-    NetworkFunctionStatic::getIdMap()[ this->getNetworkID() ] = this;
-  }
-
-  /*static*/ std::map<NetworkFunctionPointer, NetworkFunctionStatic*>& NetworkFunctionStatic::getFunctorMap()
-  {
-    static std::map<NetworkFunctionPointer, NetworkFunctionStatic*> functorMap_;
-    return functorMap_;
-  }
-
-  /*static*/ std::map<uint32_t, NetworkFunctionStatic*>& NetworkFunctionStatic::getIdMap()
-  {
-    static std::map<uint32_t, NetworkFunctionStatic*> idMap_;
-    return idMap_;
-  }
-
-
-  NetworkMemberFunctionBase::NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p):
-    NetworkFunctionBase(name)
-  {
-    RegisterObject(NetworkMemberFunctionBase);
-
-    this->functorMap_[p] = this;
-    this->idMap_[ this->getNetworkID() ] = this;
-  }
-
-  NetworkMemberFunctionBase::~NetworkMemberFunctionBase()
-  {
-  }
-
-
+    void NetworkFunctionBase::setNetworkID(uint32_t id)
+    {
+        this->networkID_ = id;
+        NetworkFunctionManager::getInstance().registerFunction(this);   // register with new id
+    }
 }
Index: code/trunk/src/libraries/network/NetworkFunction.h
===================================================================
--- code/trunk/src/libraries/network/NetworkFunction.h	(revision 10622)
+++ code/trunk/src/libraries/network/NetworkFunction.h	(revision 10624)
@@ -36,9 +36,5 @@
 #include <map>
 #include <string>
-#include <boost/preprocessor/cat.hpp>
-#include <boost/static_assert.hpp>
-
-#include "core/object/Listable.h"
-#include "core/class/Identifier.h"
+
 #include "core/command/Functor.h"
 #include "FunctionCallManager.h"
@@ -60,8 +56,22 @@
   {
 #if defined(ORXONOX_COMPILER_GCC) && defined(ORXONOX_ARCH_32)
-    return pointer[0]<b.pointer[0] ? true : pointer[1]<b.pointer[1];
-#else //ORXONOX_COMPILER_GCC
-    return pointer[0]<b.pointer[0] ? true : ( pointer[1]<b.pointer[1] ? true : ( pointer[2]<b.pointer[2] ? true : pointer[3]<b.pointer[3] ) );
-#endif //ORXONOX_COMPILER_GCC
+    if (pointer[0] != b.pointer[0])
+        return pointer[0] < b.pointer[0];
+    else if (pointer[1] != b.pointer[1])
+        return pointer[1] < b.pointer[1];
+    else
+        return false;
+#else
+    if (pointer[0] != b.pointer[0])
+        return pointer[0] < b.pointer[0];
+    else if (pointer[1] != b.pointer[1])
+        return pointer[1] < b.pointer[1];
+    else if (pointer[2] != b.pointer[2])
+        return pointer[2] < b.pointer[2];
+    else if (pointer[3] != b.pointer[3])
+        return pointer[3] < b.pointer[3];
+    else
+        return false;
+#endif
   }
 };
@@ -71,73 +81,14 @@
 
 
-class _NetworkExport NetworkFunctionBase: virtual public Listable {
-  public:
-    NetworkFunctionBase(const std::string& name);
-    ~NetworkFunctionBase();
-
-    virtual void        setNetworkID(uint32_t id)       { this->networkID_ = id; }
-    inline uint32_t     getNetworkID() const            { return this->networkID_; }
-    inline const std::string& getName() const           { return name_; }
-    static inline bool  isStatic( uint32_t networkID )  { return isStaticMap_[networkID]; }
-
-    static inline void setNetworkID(const std::string& name, uint32_t id)
-    {
-        std::map<std::string, NetworkFunctionBase*>& map = NetworkFunctionBase::getNameMap();
-        assert( map.find(name)!=map.end() );
-        map[name]->setNetworkID(id);
-    }
-
-    static void destroyAllNetworkFunctions();
-
-  protected:
-    static std::map<uint32_t, bool> isStaticMap_;
-
-  private:
-    static std::map<std::string, NetworkFunctionBase*>& getNameMap();
-    uint32_t networkID_;
-    std::string name_;
-
-};
-
-
-class _NetworkExport NetworkFunctionStatic: public NetworkFunctionBase {
-  public:
-    NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p);
-
-    inline void call(){ (*this->functor_)(); }
-    inline void call(const MultiType& mt1){ (*this->functor_)(mt1); }
-    inline void call(const MultiType& mt1, const MultiType& mt2){ (*this->functor_)(mt1, mt2); }
-    inline void call(const MultiType& mt1, const MultiType& mt2, const MultiType& mt3){ (*this->functor_)(mt1, mt2, mt3); }
-    inline void call(const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4){ (*this->functor_)(mt1, mt2, mt3, mt4); }
-    inline void call(const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5){ (*this->functor_)(mt1, mt2, mt3, mt4, mt5); }
-
-    virtual void setNetworkID( uint32_t id )
-        { NetworkFunctionBase::setNetworkID( id ); NetworkFunctionStatic::getIdMap()[id] = this; }
-    static inline NetworkFunctionStatic* getNetworkFunction( uint32_t id)
-        { assert( NetworkFunctionStatic::getIdMap().find(id)!=NetworkFunctionStatic::getIdMap().end() ); return NetworkFunctionStatic::getIdMap()[id]; }
-    static NetworkFunctionStatic* getFunction( uint32_t id )
-        { assert( NetworkFunctionStatic::getIdMap().find(id) != NetworkFunctionStatic::getIdMap().end() ); return NetworkFunctionStatic::getIdMap()[id]; }
-    static NetworkFunctionStatic* getFunction( const NetworkFunctionPointer& p )
-        { assert( NetworkFunctionStatic::getFunctorMap().find(p) != NetworkFunctionStatic::getFunctorMap().end() ); return NetworkFunctionStatic::getFunctorMap()[p]; }
-
-  private:
-    static std::map<NetworkFunctionPointer, NetworkFunctionStatic*>& getFunctorMap();
-    static std::map<uint32_t, NetworkFunctionStatic*>& getIdMap();
-    FunctorStaticPtr functor_;
-
-};
-
-
-class _NetworkExport NetworkMemberFunctionBase: public NetworkFunctionBase {
-  public:
-    NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p);
-    ~NetworkMemberFunctionBase();
-
-    virtual void setNetworkID( uint32_t id ){ NetworkFunctionBase::setNetworkID( id ); idMap_[id] = this; }
-    static inline NetworkMemberFunctionBase* getNetworkFunction( uint32_t id){ assert( idMap_.find(id)!=idMap_.end() ); return idMap_[id]; }
-    static NetworkMemberFunctionBase* getFunction( uint32_t id ){ assert( idMap_.find(id) != idMap_.end() ); return idMap_[id]; }
-    static NetworkMemberFunctionBase* getFunction( const NetworkFunctionPointer& p ){ assert( functorMap_.find(p) != functorMap_.end() ); return functorMap_[p]; }
-
-    //
+class _NetworkExport NetworkFunctionBase {
+  public:
+    NetworkFunctionBase(const std::string& name, const NetworkFunctionPointer& pointer);
+    virtual ~NetworkFunctionBase() {}
+
+    void setNetworkID(uint32_t id);
+    inline uint32_t     getNetworkID() const                { return this->networkID_; }
+    inline const std::string& getName() const               { return this->name_; }
+    inline const NetworkFunctionPointer& getPointer() const { return this->pointer_; }
+
     virtual bool call(uint32_t objectID)=0;
     virtual bool call(uint32_t objectID, const MultiType& mt1)=0;
@@ -148,6 +99,37 @@
 
   private:
-    static std::map<NetworkFunctionPointer, NetworkMemberFunctionBase*> functorMap_;
-    static std::map<uint32_t, NetworkMemberFunctionBase*> idMap_;
+    uint32_t networkID_;
+    std::string name_;
+    NetworkFunctionPointer pointer_;
+
+};
+
+
+class _NetworkExport NetworkFunctionStatic: public NetworkFunctionBase {
+  public:
+    NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p)
+        : NetworkFunctionBase(name, p)
+        , functor_(functor)
+    { }
+
+    // ignore the objectID because its a static function
+    virtual bool call(uint32_t objectID){ (*this->functor_)(); return true; }
+    virtual bool call(uint32_t objectID, const MultiType& mt1){ (*this->functor_)(mt1); return true; }
+    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2){ (*this->functor_)(mt1, mt2); return true; }
+    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3){ (*this->functor_)(mt1, mt2, mt3); return true; }
+    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4){ (*this->functor_)(mt1, mt2, mt3, mt4); return true; }
+    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5){ (*this->functor_)(mt1, mt2, mt3, mt4, mt5); return true; }
+
+  private:
+    FunctorStaticPtr functor_;
+
+};
+
+
+class _NetworkExport NetworkMemberFunctionBase: public NetworkFunctionBase {
+  public:
+    NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p)
+        : NetworkFunctionBase(name, p)
+    { }
 };
 
@@ -155,5 +137,8 @@
 template <class T> class NetworkMemberFunction: public NetworkMemberFunctionBase {
   public:
-    NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p);
+    NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p)
+        : NetworkMemberFunctionBase(name, p)
+        , functor_(functor)
+    { }
 
     inline bool call(uint32_t objectID)
@@ -222,58 +207,5 @@
 };
 
-template <class T> NetworkMemberFunction<T>::NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p):
-    NetworkMemberFunctionBase(name, p), functor_(functor)
-{
 }
 
-template<class T> inline void copyPtr( T ptr, NetworkFunctionPointer& destptr)
-{
-  if( sizeof(NetworkFunctionPointer)-sizeof(T) > 0)
-    memset((uint8_t*)&destptr + sizeof(T), 0, sizeof(NetworkFunctionPointer)-sizeof(T));
-  T p2 = ptr;
-  memcpy( &destptr, &p2, sizeof(T) );
-//   for(unsigned int i=0; i<(sizeof(T)-1/4)+1; i++)
-//     *((uint32_t*)destptr+i) = p2>>32*i;
-}
-
-template<class T> inline void* registerStaticNetworkFunctionFct( T ptr, const std::string& name )
-{
-  BOOST_STATIC_ASSERT( sizeof(T)<=sizeof(NetworkFunctionPointer) ); // if this fails your compiler uses bigger pointers for static functions than defined above
-  NetworkFunctionPointer destptr;
-  copyPtr( ptr, destptr );
-  new NetworkFunctionStatic( createFunctor(ptr), name, destptr );
-  return 0;
-}
-
-template<class T, class PT> inline void* registerMemberNetworkFunctionFct( PT ptr, const std::string& name )
-{
-  BOOST_STATIC_ASSERT( sizeof(PT)<=sizeof(NetworkFunctionPointer) ); // if this fails your compiler uses bigger pointers for a specific kind of member functions than defined above
-  NetworkFunctionPointer destptr;
-  copyPtr( ptr, destptr );
-  new NetworkMemberFunction<T>( createFunctor(ptr), name, destptr );
-  return 0;
-}
-
-#define registerStaticNetworkFunction( functionPointer ) \
-  static void* BOOST_PP_CAT( NETWORK_FUNCTION_, __UNIQUE_NUMBER__ ) = registerStaticNetworkFunctionFct( functionPointer, #functionPointer );
-#define registerMemberNetworkFunction( class, function ) \
-  static void* BOOST_PP_CAT( NETWORK_FUNCTION_##class, __UNIQUE_NUMBER__ ) = registerMemberNetworkFunctionFct<class>( &class::function, #class "_" #function);
-  // call it with functionPointer, clientID, args
-#define callStaticNetworkFunction( functionPointer, ...) \
-  { \
-    NetworkFunctionPointer p1; \
-    copyPtr( functionPointer, p1 ); \
-    FunctionCallManager::addCallStatic(NetworkFunctionStatic::getFunction(p1)->getNetworkID(), __VA_ARGS__); \
-  }
-  // call it with class, function, objectID, clientID, args
-#define callMemberNetworkFunction( class, function, objectID, ...) \
-  { \
-    NetworkFunctionPointer p1; \
-    copyPtr( &class::function, p1 ); \
-    FunctionCallManager::addCallMember(NetworkMemberFunctionBase::getFunction(p1)->getNetworkID(), objectID, __VA_ARGS__); \
-  }
-
-
-}
-
 #endif /* _NetworkFunction_H__ */
Index: code/trunk/src/libraries/network/NetworkFunctionIncludes.cc
===================================================================
--- code/trunk/src/libraries/network/NetworkFunctionIncludes.cc	(revision 10624)
+++ code/trunk/src/libraries/network/NetworkFunctionIncludes.cc	(revision 10624)
@@ -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:
+ *      Oliver Scheuss
+ *   Co-authors:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+#include "NetworkFunctionIncludes.h"
+#include "NetworkFunctionManager.h"
+
+#include "core/module/StaticInitializationHandlerIncludes.h"
+#include "NetworkStaticInitializationHandler.h"
+
+namespace orxonox
+{
+    RegisterStaticInitializationHandler(NetworkStaticInitializationHandler);
+
+    void StaticallyInitializedNetworkFunction::load()
+    {
+        NetworkFunctionManager::getInstance().registerFunction(this->function_);
+    }
+
+    void StaticallyInitializedNetworkFunction::unload()
+    {
+        NetworkFunctionManager::getInstance().unregisterFunction(this->function_);
+    }
+
+    uint32_t getNetworkIdForPointer(const NetworkFunctionPointer& pointer)
+    {
+        return NetworkFunctionManager::getInstance().getFunctionByFunctionPointer(pointer)->getNetworkID();
+    }
+}
Index: code/trunk/src/libraries/network/NetworkFunctionIncludes.h
===================================================================
--- code/trunk/src/libraries/network/NetworkFunctionIncludes.h	(revision 10624)
+++ code/trunk/src/libraries/network/NetworkFunctionIncludes.h	(revision 10624)
@@ -0,0 +1,119 @@
+/*
+ *   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:
+ *      Oliver Scheuss
+ *   Co-authors:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+#ifndef _NetworkFunctionIncludes_H__
+#define _NetworkFunctionIncludes_H__
+
+#include "NetworkPrereqs.h"
+
+#include <boost/preprocessor/cat.hpp>
+#include <boost/static_assert.hpp>
+
+#include "NetworkFunction.h"
+#include "core/module/StaticallyInitializedInstance.h"
+
+#define registerStaticNetworkFunction( functionPointer ) \
+    static orxonox::NetworkFunctionBase& BOOST_PP_CAT( NETWORK_FUNCTION_, __UNIQUE_NUMBER__ ) \
+        = (new orxonox::SI_NF(orxonox::registerStaticNetworkFunctionFct( functionPointer, #functionPointer )))->getFunction()
+
+#define registerMemberNetworkFunction( class, function ) \
+    static orxonox::NetworkFunctionBase& BOOST_PP_CAT( NETWORK_FUNCTION_##class, __UNIQUE_NUMBER__ ) \
+        = (new orxonox::SI_NF(orxonox::registerMemberNetworkFunctionFct<class>( &class::function, #class "_" #function)))->getFunction()
+
+namespace orxonox
+{
+    class _NetworkExport StaticallyInitializedNetworkFunction : public StaticallyInitializedInstance
+    {
+        public:
+            StaticallyInitializedNetworkFunction(NetworkFunctionBase* function)
+                : StaticallyInitializedInstance(StaticInitialization::NETWORK_FUNCTION)
+                , function_(function)
+            {}
+            ~StaticallyInitializedNetworkFunction() { delete function_; }
+
+            virtual void load();
+            virtual void unload();
+
+            inline NetworkFunctionBase& getFunction()
+                { return *this->function_; }
+
+        private:
+            NetworkFunctionBase* function_;
+    };
+
+    typedef StaticallyInitializedNetworkFunction SI_NF;
+
+    template<class PT>
+    inline NetworkFunctionBase* registerStaticNetworkFunctionFct(PT ptr, const std::string& name)
+    {
+        BOOST_STATIC_ASSERT(sizeof(PT) <= sizeof(NetworkFunctionPointer)); // if this fails your compiler uses bigger pointers for static functions than defined above
+        NetworkFunctionPointer destptr;
+        copyPtr(ptr, destptr);
+        return new NetworkFunctionStatic(createFunctor(ptr), name, destptr);
+    }
+
+    template<class T, class PT>
+    inline NetworkFunctionBase* registerMemberNetworkFunctionFct(PT ptr, const std::string& name)
+    {
+        BOOST_STATIC_ASSERT(sizeof(PT) <= sizeof(NetworkFunctionPointer)); // if this fails your compiler uses bigger pointers for a specific kind of member functions than defined above
+        NetworkFunctionPointer destptr;
+        copyPtr(ptr, destptr);
+        return new NetworkMemberFunction<T>(createFunctor(ptr), name, destptr);
+    }
+
+    _NetworkExport uint32_t getNetworkIdForPointer(const NetworkFunctionPointer& pointer);
+
+    // call it with functionPointer, clientID, args
+    template<class PT>
+    void callStaticNetworkFunction(PT ptr, uint32_t clientID, const MultiType& mt1 = MultiType::Null, const MultiType& mt2 = MultiType::Null, const MultiType& mt3 = MultiType::Null, const MultiType& mt4 = MultiType::Null, const MultiType& mt5 = MultiType::Null)
+    {
+        NetworkFunctionPointer destptr;
+        copyPtr(ptr, destptr);
+        FunctionCallManager::addCall(getNetworkIdForPointer(destptr), OBJECTID_UNKNOWN, clientID, mt1, mt2, mt3, mt4, mt5);
+    }
+
+    // call it with class::function, objectID, clientID, args
+    template<class PT>
+    void callMemberNetworkFunction(PT ptr, uint32_t objectID, uint32_t clientID, const MultiType& mt1 = MultiType::Null, const MultiType& mt2 = MultiType::Null, const MultiType& mt3 = MultiType::Null, const MultiType& mt4 = MultiType::Null, const MultiType& mt5 = MultiType::Null)
+    {
+        NetworkFunctionPointer destptr;
+        copyPtr(ptr, destptr);
+        FunctionCallManager::addCall(getNetworkIdForPointer(destptr), objectID, clientID, mt1, mt2, mt3, mt4, mt5);
+    }
+
+    template<class PT>
+    inline void copyPtr(PT ptr, NetworkFunctionPointer& destptr)
+    {
+        if (sizeof(NetworkFunctionPointer) - sizeof(PT) > 0)
+            memset((uint8_t*)&destptr + sizeof(PT), 0, sizeof(NetworkFunctionPointer) - sizeof(PT));
+        PT p2 = ptr;
+        memcpy(&destptr, &p2, sizeof(PT));
+    }
+}
+
+#endif /* _NetworkFunctionIncludes_H__ */
Index: code/trunk/src/libraries/network/NetworkFunctionManager.cc
===================================================================
--- code/trunk/src/libraries/network/NetworkFunctionManager.cc	(revision 10624)
+++ code/trunk/src/libraries/network/NetworkFunctionManager.cc	(revision 10624)
@@ -0,0 +1,83 @@
+/*
+ *   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 "NetworkFunctionManager.h"
+#include "NetworkFunction.h"
+
+namespace orxonox
+{
+    NetworkFunctionManager* NetworkFunctionManager::singletonPtr_s = 0;
+
+    void NetworkFunctionManager::registerFunction(NetworkFunctionBase* function)
+    {
+        this->functions_.insert(function);
+        this->nameMap_[function->getName()] = function;
+        this->idMap_[function->getNetworkID()] = function;
+        this->functorMap_[function->getPointer()] = function;
+    }
+
+    void NetworkFunctionManager::unregisterFunction(NetworkFunctionBase* function)
+    {
+        this->functions_.erase(function);
+        this->nameMap_.erase(function->getName());
+        this->idMap_.erase(function->getNetworkID());
+        this->functorMap_.erase(function->getPointer());
+    }
+
+    NetworkFunctionBase* NetworkFunctionManager::getFunctionByName(const std::string& name)
+    {
+        std::map<std::string, NetworkFunctionBase*>::iterator it = nameMap_.find(name);
+        assert(it != nameMap_.end());
+        return it->second;
+    }
+
+    NetworkFunctionBase* NetworkFunctionManager::getFunctionByFunctionPointer(const NetworkFunctionPointer& p)
+    {
+        std::map<NetworkFunctionPointer, NetworkFunctionBase*>::iterator it = functorMap_.find(p);
+        assert(it != functorMap_.end());
+        return it->second;
+    }
+
+    NetworkFunctionBase* NetworkFunctionManager::getFunctionByNetworkId(uint32_t id)
+    {
+        std::map<uint32_t, NetworkFunctionBase*>::iterator it = idMap_.find(id);
+        assert(it != idMap_.end());
+        if(it != idMap_.end())
+            return it->second;
+        else
+            return NULL;
+    }
+
+    /**
+        @brief Cleans the NetworkID map (needed on clients for correct initialization)
+    */
+    void NetworkFunctionManager::clearNetworkIDs()
+    {
+        this->idMap_.clear();
+    }
+}
Index: code/trunk/src/libraries/network/NetworkFunctionManager.h
===================================================================
--- code/trunk/src/libraries/network/NetworkFunctionManager.h	(revision 10624)
+++ code/trunk/src/libraries/network/NetworkFunctionManager.h	(revision 10624)
@@ -0,0 +1,70 @@
+/*
+ *   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 __NetworkFunctionManager_H__
+#define __NetworkFunctionManager_H__
+
+#include "NetworkPrereqs.h"
+
+#include <cassert>
+#include <map>
+#include <set>
+
+#include "util/Singleton.h"
+#include "NetworkFunction.h"
+
+namespace orxonox
+{
+    class _NetworkExport NetworkFunctionManager : public Singleton<NetworkFunctionManager>
+    {
+        friend class Singleton<NetworkFunctionManager>;
+
+        public:
+            void registerFunction(NetworkFunctionBase* function);
+            void unregisterFunction(NetworkFunctionBase* function);
+
+            inline const std::set<NetworkFunctionBase*>& getAllFunctions()
+                { return functions_; }
+
+            NetworkFunctionBase* getFunctionByName(const std::string& name);
+            NetworkFunctionBase* getFunctionByFunctionPointer(const NetworkFunctionPointer& p);
+            NetworkFunctionBase* getFunctionByNetworkId(uint32_t id);
+
+            void clearNetworkIDs();
+
+        private:
+            std::set<NetworkFunctionBase*> functions_;
+            std::map<std::string, NetworkFunctionBase*> nameMap_;
+            std::map<NetworkFunctionPointer, NetworkFunctionBase*> functorMap_;
+            std::map<uint32_t, NetworkFunctionBase*> idMap_;
+
+            static NetworkFunctionManager* singletonPtr_s;
+    };
+}
+
+#endif /* __NetworkFunctionManager_H__ */
Index: code/trunk/src/libraries/network/NetworkPrereqs.h
===================================================================
--- code/trunk/src/libraries/network/NetworkPrereqs.h	(revision 10622)
+++ code/trunk/src/libraries/network/NetworkPrereqs.h	(revision 10624)
@@ -97,4 +97,10 @@
     }
   }
+
+  namespace StaticInitialization
+  {
+    typedef int Type;
+    static const Type NETWORK_FUNCTION = 6;
+  }
 }
 
Index: code/trunk/src/libraries/network/NetworkStaticInitializationHandler.cc
===================================================================
--- code/trunk/src/libraries/network/NetworkStaticInitializationHandler.cc	(revision 10624)
+++ code/trunk/src/libraries/network/NetworkStaticInitializationHandler.cc	(revision 10624)
@@ -0,0 +1,56 @@
+/*
+ *   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 "NetworkStaticInitializationHandler.h"
+
+#include "core/module/ModuleInstance.h"
+#include "NetworkFunctionManager.h"
+
+namespace orxonox
+{
+    void NetworkStaticInitializationHandler::setupHandler()
+    {
+        // initialize singleton
+        new NetworkFunctionManager();
+    }
+
+    void NetworkStaticInitializationHandler::shutdownHandler()
+    {
+        delete &NetworkFunctionManager::getInstance();
+    }
+
+    void NetworkStaticInitializationHandler::loadModule(ModuleInstance* module)
+    {
+        module->loadAllStaticallyInitializedInstances(StaticInitialization::NETWORK_FUNCTION);
+    }
+
+    void NetworkStaticInitializationHandler::unloadModule(ModuleInstance* module)
+    {
+        module->unloadAllStaticallyInitializedInstances(StaticInitialization::NETWORK_FUNCTION);
+    }
+}
Index: code/trunk/src/libraries/network/NetworkStaticInitializationHandler.h
===================================================================
--- code/trunk/src/libraries/network/NetworkStaticInitializationHandler.h	(revision 10624)
+++ code/trunk/src/libraries/network/NetworkStaticInitializationHandler.h	(revision 10624)
@@ -0,0 +1,49 @@
+/*
+ *   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 _NetworkStaticInitializationHandler_H__
+#define _NetworkStaticInitializationHandler_H__
+
+#include "network/NetworkPrereqs.h"
+
+#include "core/module/StaticInitializationHandler.h"
+
+namespace orxonox
+{
+    class _NetworkExport NetworkStaticInitializationHandler : public StaticInitializationHandler
+    {
+        public:
+            virtual void setupHandler();
+            virtual void shutdownHandler();
+
+            virtual void loadModule(ModuleInstance* module);
+            virtual void unloadModule(ModuleInstance* module);
+    };
+}
+
+#endif /* _NetworkStaticInitializationHandler_H__ */
Index: code/trunk/src/libraries/network/WANDiscoverable.cc
===================================================================
--- code/trunk/src/libraries/network/WANDiscoverable.cc	(revision 10622)
+++ code/trunk/src/libraries/network/WANDiscoverable.cc	(revision 10624)
@@ -39,4 +39,5 @@
 namespace orxonox
 {
+  RegisterAbstractClass(WANDiscoverable).inheritsFrom<Configurable>();
 
   WANDiscoverable::WANDiscoverable(): bActive_(false)
Index: code/trunk/src/libraries/network/WANDiscovery.cc
===================================================================
--- code/trunk/src/libraries/network/WANDiscovery.cc	(revision 10622)
+++ code/trunk/src/libraries/network/WANDiscovery.cc	(revision 10624)
@@ -37,4 +37,6 @@
 namespace orxonox
 {
+  RegisterAbstractClass(WANDiscovery).inheritsFrom<Configurable>();
+
   WANDiscovery::WANDiscovery()
   {
Index: code/trunk/src/libraries/network/packet/FunctionCalls.cc
===================================================================
--- code/trunk/src/libraries/network/packet/FunctionCalls.cc	(revision 10622)
+++ code/trunk/src/libraries/network/packet/FunctionCalls.cc	(revision 10624)
@@ -82,19 +82,10 @@
 }
 
-void FunctionCalls::addCallStatic( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5)
+void FunctionCalls::addCall( uint32_t networkID, uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
 {
   assert(!isDataENetAllocated());
   
   this->functionCalls_.push(orxonox::FunctionCall());
-  this->functionCalls_.back().setCallStatic( networkID, mt1, mt2, mt3, mt4, mt5 );
-  this->currentSize_ += this->functionCalls_.back().getSize();
-}
-
-void FunctionCalls::addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5)
-{
-  assert(!isDataENetAllocated());
-  
-  this->functionCalls_.push(orxonox::FunctionCall());
-  this->functionCalls_.back().setCallMember( networkID, objectID, mt1, mt2, mt3, mt4, mt5 );
+  this->functionCalls_.back().setCall( networkID, objectID, mt1, mt2, mt3, mt4, mt5 );
   this->currentSize_ += this->functionCalls_.back().getSize();
 }
Index: code/trunk/src/libraries/network/packet/FunctionCalls.h
===================================================================
--- code/trunk/src/libraries/network/packet/FunctionCalls.h	(revision 10622)
+++ code/trunk/src/libraries/network/packet/FunctionCalls.h	(revision 10624)
@@ -56,6 +56,5 @@
   virtual bool process(orxonox::Host* host);
 
-  void addCallStatic( uint32_t networkID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
-  void addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
+  void addCall( uint32_t networkID, uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
   virtual bool send(orxonox::Host* host);
 private:
Index: code/trunk/src/libraries/network/packet/FunctionIDs.cc
===================================================================
--- code/trunk/src/libraries/network/packet/FunctionIDs.cc	(revision 10622)
+++ code/trunk/src/libraries/network/packet/FunctionIDs.cc	(revision 10624)
@@ -37,4 +37,5 @@
 #include "core/object/ObjectList.h"
 #include "network/NetworkFunction.h"
+#include "network/NetworkFunctionManager.h"
 
 namespace orxonox {
@@ -55,9 +56,10 @@
 
   //calculate total needed size (for all strings and integers)
-  ObjectList<NetworkFunctionBase>::iterator it;
-  for(it = ObjectList<NetworkFunctionBase>::begin(); it; ++it)
+  const std::set<NetworkFunctionBase*>& set = NetworkFunctionManager::getInstance().getAllFunctions();
+  std::set<NetworkFunctionBase*>::const_iterator it;
+  for (it = set.begin(); it != set.end(); ++it)
   {
-    const std::string& functionname = it->getName();
-    networkID = it->getNetworkID();
+    const std::string& functionname = (*it)->getName();
+    networkID = (*it)->getNetworkID();
     // now push the network id and the classname to the stack
     tempQueue.push( std::pair<unsigned int, std::string>(networkID, functionname) );
@@ -126,4 +128,7 @@
   unsigned char *functionname;
 
+  //clear the map of network ids
+  NetworkFunctionManager::getInstance().clearNetworkIDs();
+
   orxout(verbose, context::packets) << "=== processing functionids: " << endl;
   std::pair<uint32_t, std::string> tempPair;
@@ -138,5 +143,5 @@
     functionname = temp+2*sizeof(uint32_t);
     orxout(internal_info, context::packets) << "processing functionid: " << networkID << " name: " << functionname << endl;
-    NetworkFunctionBase::setNetworkID((const char*)functionname, networkID);
+    NetworkFunctionManager::getInstance().getFunctionByName((const char*)functionname)->setNetworkID(networkID);
     temp += 2*sizeof(uint32_t) + stringsize;
   }
Index: code/trunk/src/libraries/network/synchronisable/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/network/synchronisable/CMakeLists.txt	(revision 10622)
+++ code/trunk/src/libraries/network/synchronisable/CMakeLists.txt	(revision 10624)
@@ -2,5 +2,4 @@
   NetworkCallbackManager.cc
   Synchronisable.cc
-  SynchronisableVariable.cc
 )
 
Index: code/trunk/src/libraries/network/synchronisable/Serialise.h
===================================================================
--- code/trunk/src/libraries/network/synchronisable/Serialise.h	(revision 10622)
+++ code/trunk/src/libraries/network/synchronisable/Serialise.h	(revision 10624)
@@ -78,8 +78,8 @@
     }
 
-    // These functions implement loading / saving / etc. for SmartPtr<T>
+    // These functions implement loading / saving / etc. for StrongPtr<T>
 
     /** @brief returns the size of the objectID needed to synchronise the pointer */
-    template <class T> inline uint32_t returnSize( const SmartPtr<T>& )
+    template <class T> inline uint32_t returnSize( const StrongPtr<T>& )
     {
         return sizeof(uint32_t);
@@ -87,13 +87,13 @@
 
     /** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */
-    template <class T> inline void loadAndIncrease( const SmartPtr<T>& variable, uint8_t*& mem )
+    template <class T> inline void loadAndIncrease( const StrongPtr<T>& variable, uint8_t*& mem )
     {
 //         *const_cast<typename Loki::TypeTraits<T*>::UnqualifiedType*>(&variable) = dynamic_cast<T*>(variable->getSynchronisable( *(uint32_t*)(mem) ));
-        *const_cast<typename Loki::TypeTraits<SmartPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));
+        *const_cast<typename Loki::TypeTraits<StrongPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));
         mem += returnSize( variable );
     }
 
     /** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */
-    template <class T> inline void saveAndIncrease( const SmartPtr<T>& variable, uint8_t*& mem )
+    template <class T> inline void saveAndIncrease( const StrongPtr<T>& variable, uint8_t*& mem )
     {
         if ( variable.get() )
@@ -105,5 +105,5 @@
 
     /** @brief checks whether the objectID of the variable is the same as in the bytestream */
-    template <class T> inline  bool checkEquality( const SmartPtr<T>& variable, uint8_t* mem )
+    template <class T> inline  bool checkEquality( const StrongPtr<T>& variable, uint8_t* mem )
     {
         if ( variable.get() )
@@ -125,5 +125,5 @@
     {
         //         *const_cast<typename Loki::TypeTraits<T*>::UnqualifiedType*>(&variable) = dynamic_cast<T*>(variable->getSynchronisable( *(uint32_t*)(mem) ));
-        *const_cast<typename Loki::TypeTraits<SmartPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));
+        *const_cast<typename Loki::TypeTraits<WeakPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));
         mem += returnSize( variable );
     }
Index: code/trunk/src/libraries/network/synchronisable/Synchronisable.cc
===================================================================
--- code/trunk/src/libraries/network/synchronisable/Synchronisable.cc	(revision 10622)
+++ code/trunk/src/libraries/network/synchronisable/Synchronisable.cc	(revision 10624)
@@ -45,5 +45,5 @@
   uint8_t Synchronisable::state_=0x1; // detemines wheter we are server (default) or client
 
-  RegisterAbstractClass(Synchronisable).inheritsFrom(Class(OrxonoxInterface));
+  RegisterAbstractClass(Synchronisable).inheritsFrom<OrxonoxInterface>();
 
   /**
@@ -151,5 +151,5 @@
         for(int i = 0; i<160; i++)
             orxout(user_error, context::network) << "classid: " << i << " identifier: " << ClassByID(i) << endl;
-        orxout(user_error, context::network) << "Assertion failed: id" << endl;
+        orxout(user_error, context::network) << "Assertion failed: Could not find Identifier for ClassID " << header.getClassID() << endl;
         orxout(user_error, context::network) << "Possible reason for this error: Client received a synchronizable object whose class has no factory." << endl;
         abort();
@@ -182,10 +182,4 @@
     no->setClassID(header.getClassID());
     assert(no->contextID_ == header.getContextID());
-    if( context )
-    {
-      BaseObject* boContext = orxonox_cast<BaseObject*>(context);
-      if (boContext)
-          bo->setLevel(boContext->getLevel()); // Note: this ensures that the level is known on the client for child objects of the scene (and the scene itself)
-    }
     //assert(no->classID_ == header.getClassID());
     orxout(verbose, context::network) << "fabricate objectID_: " << no->objectID_ << " classID_: " << no->classID_ << endl;
Index: code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.cc
===================================================================
--- code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.cc	(revision 10622)
+++ 	(revision )
@@ -1,36 +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:
- *      Oliver Scheuss
- *   Co-authors:
- *      ...
- *
- */
-
-#include "SynchronisableVariable.h"
-
-namespace orxonox{
-
-uint8_t SynchronisableVariableBase::state_ = 0;
-
-
-} //namespace
Index: code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h
===================================================================
--- code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h	(revision 10622)
+++ code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h	(revision 10624)
@@ -65,6 +65,4 @@
       virtual uint8_t getMode()=0;
       virtual ~SynchronisableVariableBase() {}
-    protected:
-      static uint8_t state_;
   };
 
@@ -108,8 +106,4 @@
       variable_( variable ), mode_( syncDirection ), callback_( cb )
   {
-    if ( state_ == 0x0 )
-    {
-      state_ = GameMode::isMaster() ? 0x1 : 0x2;  // set the appropriate mode here
-    }
   }
 
Index: code/trunk/src/libraries/tools/ParticleInterface.cc
===================================================================
--- code/trunk/src/libraries/tools/ParticleInterface.cc	(revision 10622)
+++ code/trunk/src/libraries/tools/ParticleInterface.cc	(revision 10624)
@@ -49,5 +49,6 @@
 {
     unsigned int ParticleInterface::counter_s = 0;
-    ParticleInterface* ParticleInterface::currentParticleInterface_s = 0;
+
+    RegisterAbstractClass(ParticleInterface).inheritsFrom<TimeFactorListener>();
 
     ParticleInterface::ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::Value detaillevel)
Index: code/trunk/src/libraries/tools/ParticleInterface.h
===================================================================
--- code/trunk/src/libraries/tools/ParticleInterface.h	(revision 10622)
+++ code/trunk/src/libraries/tools/ParticleInterface.h	(revision 10624)
@@ -34,9 +34,4 @@
 #include "util/OgreForwardRefs.h"
 #include "tools/interfaces/TimeFactorListener.h"
-
-#define getAllEmitters() \
-  storeThisAsCurrentParticleInterface(); \
-  for (unsigned int i = 0; i < ParticleInterface::getCurrentParticleInterface()->getNumEmitters(); ++i) \
-    ParticleInterface::getCurrentParticleInterface()->getEmitter(i)
 
 namespace orxonox
@@ -80,9 +75,4 @@
             void setDetailLevel(unsigned int level);
 
-            inline void storeThisAsCurrentParticleInterface()
-                { ParticleInterface::currentParticleInterface_s = this; }
-            inline static ParticleInterface* getCurrentParticleInterface()
-                { return ParticleInterface::currentParticleInterface_s; }
-
         protected:
             virtual void changedTimeFactor(float factor_new, float factor_old);
@@ -103,5 +93,4 @@
             unsigned int              globalDetailLevel_; //!< Global maximum detail level of particle effects (0: off, 1: low, 2: normal, 3: high)
 
-            static ParticleInterface* currentParticleInterface_s;
             static unsigned int       counter_s;
     };
Index: code/trunk/src/libraries/tools/ResourceLocation.cc
===================================================================
--- code/trunk/src/libraries/tools/ResourceLocation.cc	(revision 10622)
+++ code/trunk/src/libraries/tools/ResourceLocation.cc	(revision 10624)
@@ -35,5 +35,6 @@
 #include "util/Exception.h"
 #include "core/CoreIncludes.h"
-#include "core/PathConfig.h"
+#include "core/ApplicationPaths.h"
+#include "core/ConfigurablePaths.h"
 #include "core/XMLFile.h"
 #include "core/XMLPort.h"
@@ -74,8 +75,8 @@
         namespace bf = boost::filesystem;
         bf::path path;
-        if (bf::exists(PathConfig::getDataPath() / this->getPath()))
-            path = PathConfig::getDataPath() / this->getPath();
-        else if (PathConfig::buildDirectoryRun() && bf::exists(PathConfig::getExternalDataPath() / this->getPath()))
-            path = PathConfig::getExternalDataPath() / this->getPath();
+        if (bf::exists(ConfigurablePaths::getDataPath() / this->getPath()))
+            path = ConfigurablePaths::getDataPath() / this->getPath();
+        else if (ApplicationPaths::buildDirectoryRun() && bf::exists(ConfigurablePaths::getExternalDataPath() / this->getPath()))
+            path = ConfigurablePaths::getExternalDataPath() / this->getPath();
         else
         {
Index: code/trunk/src/libraries/tools/Timer.cc
===================================================================
--- code/trunk/src/libraries/tools/Timer.cc	(revision 10622)
+++ code/trunk/src/libraries/tools/Timer.cc	(revision 10624)
@@ -40,5 +40,5 @@
 #include "util/Clock.h"
 #include "core/CoreIncludes.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "core/command/CommandExecutor.h"
 #include "core/command/Executor.h"
@@ -247,4 +247,7 @@
     // RealTimer //
     ///////////////
+
+    RegisterClassNoArgs(RealTimer);
+
     /// @copydoc Timer::Timer
     RealTimer::RealTimer()
Index: code/trunk/src/libraries/tools/interfaces/ToolsInterfaceCompilation.cc
===================================================================
--- code/trunk/src/libraries/tools/interfaces/ToolsInterfaceCompilation.cc	(revision 10622)
+++ code/trunk/src/libraries/tools/interfaces/ToolsInterfaceCompilation.cc	(revision 10624)
@@ -46,5 +46,5 @@
     float TimeFactorListener::timefactor_s = 1.0f;
 
-    RegisterAbstractClass(TimeFactorListener).inheritsFrom(Class(Listable));
+    RegisterAbstractClass(TimeFactorListener).inheritsFrom<Listable>();
 
     TimeFactorListener::TimeFactorListener()
@@ -67,5 +67,5 @@
     // Tickable
     //----------------------------
-    RegisterAbstractClass(Tickable).inheritsFrom(Class(OrxonoxInterface));
+    RegisterAbstractClass(Tickable).inheritsFrom<OrxonoxInterface>();
 
     /**
Index: code/trunk/src/libraries/util/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/util/CMakeLists.txt	(revision 10622)
+++ code/trunk/src/libraries/util/CMakeLists.txt	(revision 10624)
@@ -26,6 +26,4 @@
   CRC32.cc
   ExprParser.cc
-  Scope.cc
-  ScopedSingletonManager.cc
   SharedPtr.cc
   Sleep.cc
Index: code/trunk/src/libraries/util/Scope.cc
===================================================================
--- code/trunk/src/libraries/util/Scope.cc	(revision 10622)
+++ 	(revision )
@@ -1,40 +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:
- *      ...
- *
- */
-
-/**
-    @file
-    @brief Static linkage of the two maps in orxonox::ScopeManager.
-*/
-
-#include "Scope.h"
-
-namespace orxonox
-{
-    std::map<ScopeID::Value, int> ScopeManager::instanceCounts_s;
-    std::map<ScopeID::Value, std::set<ScopeListener*> > ScopeManager::listeners_s;
-}
Index: code/trunk/src/libraries/util/Scope.h
===================================================================
--- code/trunk/src/libraries/util/Scope.h	(revision 10622)
+++ 	(revision )
@@ -1,200 +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:
- *      ...
- *
- */
-
-/**
-@file
-@ingroup SingletonScope
-@brief Declaration of the classes that are needed to use Scopes:
-orxonox::Scope, orxonox::ScopeListener, and orxonox::ScopeManager.
-
-@anchor Scope
-
-A virtual scope can be represented by an instance of class orxonox::Scope. orxonox::Scope<@a scope> is a template
-an its template argument defines the name of the virtual scope. See orxonox::ScopeID for an enumeration of the
-available values for @a scope. The orxonox::Scope object for a given @a scope can be activated or deactivated.
-Instances of orxonox::ScopeListener can register for a given @a scope and will get a notification if the
-corresponding orxonox::Scope object changes its state.
-
-To avoid multiple instances of orxonox::Scope<@a scope> in different libraries, each instance of orxonox::Scope
-registers in orxonox::ScopeManager, where they are linked statically in the util library.
-
-Scopes are usually used to control the creation and destruction of Singletons.
-
-@see orxonox::ScopedSingletonManager
-@see orxonox::Singleton
-*/
-
-#ifndef __Util_Scope_H__
-#define __Util_Scope_H__
-
-#include "UtilPrereqs.h"
-
-#include <cassert>
-#include <map>
-#include <set>
-#include <loki/ScopeGuard.h>
-
-#include "Output.h"
-
-namespace orxonox
-{
-    /**
-        @brief The ScopeManager stores the variables of the Scope templates in a statically linked context.
-
-        If all Scope objects are managed by this class, they are statically linked in the util library.
-        Without this, a new instance of Scope<T> for each T would be created in every library of Orxonox,
-        which is of course not the desired behavior.
-
-        @see See @ref Scope "this description" for details about the interrelationship of Scope, ScopeListener, and ScopeManager.
-    */
-    class _UtilExport ScopeManager
-    {
-        template <ScopeID::Value scope>
-        friend class Scope;
-        friend class ScopeListener;
-
-        private:
-            static std::map<ScopeID::Value, int> instanceCounts_s;                  //!< Counts the number of active instances (>0 means active) for a scope
-            static std::map<ScopeID::Value, std::set<ScopeListener*> > listeners_s; //!< Stores all listeners for a scope
-    };
-
-    /**
-        @brief ScopeListeners register themselves in the corresponding Scope and wait for notifications.
-        Notifications are sent if a Scope is activated or deactivated.
-
-        @see See @ref Scope "this description" for details about the interrelationship of Scope, ScopeListener, and ScopeManager.
-    */
-    class _UtilExport ScopeListener
-    {
-        template <ScopeID::Value scope>
-        friend class Scope;
-
-        protected:
-            //! Constructor: Registers the instance.
-            ScopeListener(ScopeID::Value scope) : scope_(scope), bActivated_(false)
-                { ScopeManager::listeners_s[this->scope_].insert(this); }
-            //! Destructor: Unregisters the instance.
-            virtual ~ScopeListener()
-                { ScopeManager::listeners_s[this->scope_].erase(this); }
-
-            //! Gets called if the scope is activated
-            virtual void activated() = 0;
-            //! Gets called if the scope is deactivated
-            virtual void deactivated() = 0;
-
-        private:
-            ScopeID::Value scope_; //!< Store the scope to unregister on destruction
-            bool bActivated_;
-    };
-
-    /**
-        @brief A scope for a given template argument is either active or not.
-
-        Objects inheriting from a ScopeListener are registered in a list (different for each scope).
-        If the scope gets activated or deactivated, all objects in this list are notified.
-
-        @see See @ref Scope "this description" for details about the interrelationship of Scope, ScopeListener, and ScopeManager.
-    */
-    template <ScopeID::Value scope>
-    class Scope
-    {
-        public:
-            //! Constructor: Increases the instance counter and activates the scope if the count went from 0 to 1. Counts >1 don't change anything.
-            Scope()
-            {
-                orxout(internal_status) << "creating scope... (" << scope << ")" << endl;
-
-                try
-                {
-                    ScopeManager::instanceCounts_s[scope]++;
-                    assert(ScopeManager::instanceCounts_s[scope] > 0);
-                    if (ScopeManager::instanceCounts_s[scope] == 1)
-                    {
-                        Loki::ScopeGuard deactivator = Loki::MakeObjGuard(*this, &Scope::deactivateListeners);
-                        for (typename std::set<ScopeListener*>::iterator it = ScopeManager::listeners_s[scope].begin(); it != ScopeManager::listeners_s[scope].end(); )
-                        {
-                            (*it)->activated();
-                            (*(it++))->bActivated_ = true;
-                        }
-                        deactivator.Dismiss();
-                    }
-                }
-                catch (...)
-                {
-                    ScopeManager::instanceCounts_s[scope]--;
-                    throw;
-                }
-
-                orxout(internal_status) << "created scope (" << scope << ")" << endl;
-            }
-
-            //! Destructor: Decreases the instance counter and deactivates the scope if the count went from 1 to 0. Counts >0 don't change anything.
-            ~Scope()
-            {
-                orxout(internal_status) << "destroying scope... (" << scope << ")" << endl;
-
-                ScopeManager::instanceCounts_s[scope]--;
-
-                // This shouldn't happen but just to be sure: check if the count is positive
-                assert(ScopeManager::instanceCounts_s[scope] >= 0);
-                if (ScopeManager::instanceCounts_s[scope] < 0)
-                    ScopeManager::instanceCounts_s[scope] = 0;
-
-                if (ScopeManager::instanceCounts_s[scope] == 0)
-                    this->deactivateListeners();
-
-                orxout(internal_status) << "destroyed scope (" << scope << ")" << endl;
-            }
-
-            //! Deactivates the listeners of this scope in case the scope is destroyed or the construction fails.
-            void deactivateListeners()
-            {
-                for (typename std::set<ScopeListener*>::iterator it = ScopeManager::listeners_s[scope].begin(); it != ScopeManager::listeners_s[scope].end(); )
-                {
-                    if ((*it)->bActivated_)
-                    {
-                        try
-                            { (*it)->deactivated(); }
-                        catch (...)
-                            { orxout(internal_warning) << "ScopeListener::deactivated() failed! This MUST NOT happen, fix it!" << endl; }
-                        (*(it++))->bActivated_ = false;
-                    }
-                    else
-                        ++it;
-                }
-            }
-
-            //! Returns true if the scope is active.
-            static bool isActive()
-            {
-                return (ScopeManager::instanceCounts_s[scope] > 0);
-            }
-    };
-}
-
-#endif /* __Util_Scope_H__ */
Index: code/trunk/src/libraries/util/ScopedSingletonManager.cc
===================================================================
--- code/trunk/src/libraries/util/ScopedSingletonManager.cc	(revision 10622)
+++ 	(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:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-    @file
-    @brief Static linkage of the ScopedSingletonManager maps.
-*/
-
-#include "ScopedSingletonManager.h"
-
-namespace orxonox
-{
-    /*static*/ std::map<std::string, ScopedSingletonManager*>& ScopedSingletonManager::getManagers()
-    {
-        static std::map<std::string, ScopedSingletonManager*> managers;
-        return managers;
-    }
-    /*static*/ ScopedSingletonManager::ManagerMultiMap& ScopedSingletonManager::getManagersByScope()
-    {
-        static ManagerMultiMap managers;
-        return managers;
-    }
-
-    /*static*/ void ScopedSingletonManager::addManager(ScopedSingletonManager* manager)
-    {
-        getManagers()[manager->className_] = manager;
-        getManagersByScope().insert(std::make_pair(manager->scope_, manager));
-    }
-}
Index: code/trunk/src/libraries/util/ScopedSingletonManager.h
===================================================================
--- code/trunk/src/libraries/util/ScopedSingletonManager.h	(revision 10622)
+++ 	(revision )
@@ -1,282 +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:
- *      ...
- *
- */
-
-/**
-    @file
-    @ingroup SingletonScope
-    @brief Definition of orxonox::ScopedSingletonManager, orxonox::ClassScopedSingletonManager, and the ManageScopedSingleton macro.
-
-    ScopedSingletonManager is used to create and destroy Singletons that belong to
-    a given Scope. For each one of these singletons, the macro ManageScopedSingleton()
-    has to be called to register the singleton with orxonox::ScopedSingletonManager.
-
-    See @ref SingletonExample "this code" for an example.
-
-    @see orxonox::Singleton
-    @see orxonox::Scope
-*/
-
-#ifndef __ScopedSingletonManager_H__
-#define __ScopedSingletonManager_H__
-
-#include "UtilPrereqs.h"
-
-#include <cassert>
-#include <map>
-#include "util/Exception.h"
-#include "util/Scope.h"
-#include "util/Singleton.h"
-
-/**
-    @brief Registers an orxonox::Singleton with orxonox::ScopedSingletonManager.
-    @param className The name of the singleton class
-    @param scope The scope in which the singleton should exist
-    @param allowedToFail If true, the singleton is allowed to fail and thus a try-catch block is used when creating the singleton.
-
-    If this macro is called for a singleton, it is registered with ScopedSingletonManager
-    and will thus be created if its scope becomes active and destroyed if is deactivated.
-*/
-#define ManageScopedSingleton(className, scope, allowedToFail) \
-    className* className::singletonPtr_s = NULL; \
-    static ClassScopedSingletonManager<className, scope, allowedToFail> className##ScopedSingletonManager(#className)
-
-namespace orxonox
-{
-    class Destroyable;
-
-    /**
-        @brief Base class of ClassScopedSingletonManager, implements some static functions
-        used to dispatch calls to preUpdate and postUpdate to all instances of this class.
-        It also keeps track of all existing ScopedSingletonManagers and stores them in a
-        map, sorted by the scope they belong to.
-    */
-    class _UtilExport ScopedSingletonManager
-    {
-        public:
-            /// Constructor: Initializes all the values
-            ScopedSingletonManager(const std::string& className, ScopeID::Value scope)
-                : className_(className)
-                , scope_(scope)
-            { }
-            virtual ~ScopedSingletonManager() { }
-
-            /// Adds a new instance of ScopedSingletonManager to the map.
-            static void addManager(ScopedSingletonManager* manager);
-
-            /// Calls preUpdate in all instances of ScopedSingletonManager that are registered in the map.
-            template<ScopeID::Value scope>
-            static void preUpdate(const Clock& time)
-            {
-                assert(Scope<scope>::isActive());
-                for (ManagerMultiMap::iterator it = getManagersByScope().lower_bound(scope); it != getManagersByScope().upper_bound(scope); ++it)
-                    it->second->preUpdate(time);
-            }
-            virtual void preUpdate(const Clock& time) = 0;
-
-            /// Calls postUpdate in all instances of ScopedSingletonManager that are registered in the map.
-            template<ScopeID::Value scope>
-            static void postUpdate(const Clock& time)
-            {
-                assert(Scope<scope>::isActive());
-                for (ManagerMultiMap::iterator it = getManagersByScope().lower_bound(scope); it != getManagersByScope().upper_bound(scope); ++it)
-                    it->second->postUpdate(time);
-            }
-            virtual void postUpdate(const Clock& time) = 0;
-
-            static std::map<std::string, ScopedSingletonManager*>& getManagers();
-            typedef std::multimap<ScopeID::Value, ScopedSingletonManager*> ManagerMultiMap;
-            static ManagerMultiMap& getManagersByScope();
-
-        protected:
-            const std::string className_;   ///< The name of the scoped singleton class that is managed by this object
-            const ScopeID::Value scope_;    ///< The scope of the singleton that is managed by this object
-    };
-
-    /**
-        @anchor ClassScopedSingletonManager
-
-        @brief Manages a scoped singleton for a given scope.
-        @param T The managed singleton class
-        @param scope The scope in which the singleton @a T should be active
-        @param allowedToFail If true, a specialization of this template is used, that uses try-catch blocks to handle possible failures.
-
-        This class inherits from ScopeListener for the given scope and thus its functions
-        activated() and deactivated() are called whenever the Scope changes its state.
-
-        If the Scope is activated, a new instance of @a T (which must be a singleton) is created.
-        If the Scope is deactivated, the singleton is destroyed.
-
-        @see Singleton
-    */
-    template <class T, ScopeID::Value scope, bool allowedToFail>
-    class ClassScopedSingletonManager : public ScopedSingletonManager, public ScopeListener
-    {
-    public:
-        //! Constructor: Initializes the singleton pointer and passes the scope to ScopedSingletonManager and ScopeListener
-        ClassScopedSingletonManager(const std::string& className)
-            : ScopedSingletonManager(className, scope)
-            , ScopeListener(scope)
-            , singletonPtr_(NULL)
-        {
-            ScopedSingletonManager::addManager(this);
-        }
-
-        ~ClassScopedSingletonManager()
-        {
-        }
-
-        //! Called if the Scope of the Singleton gets active (creates the instance)
-        void activated()
-        {
-            assert(singletonPtr_ == NULL);
-            singletonPtr_ = new T();
-        }
-
-        //! Called if the Scope of this Singleton gets deactivated (destroys the instance)
-        void deactivated()
-        {
-            assert(singletonPtr_ != NULL);
-            this->destroy(singletonPtr_);
-            singletonPtr_ = NULL;
-        }
-
-        //! Destroys the singleton instance - overloaded for Destroyable, calls Destroyable::destroy()
-        void destroy(Destroyable*)
-        {
-            singletonPtr_->destroy();
-        }
-        //! Destroys the singleton instance - overloaded for all other pointers, calls delete
-        void destroy(void*)
-        {
-            delete singletonPtr_;
-        }
-
-        //! Called every frame by the ScopedSingletonManager
-        void preUpdate(const Clock& time)
-        {
-            assert(Scope<scope>::isActive());
-            // assuming T inherits Singleton<T>
-            singletonPtr_->preUpdateSingleton(time);
-        }
-
-        //! Called every frame by the ScopedSingletonManager
-        void postUpdate(const Clock& time)
-        {
-            assert(Scope<scope>::isActive());
-            // assuming T inherits Singleton<T>
-            singletonPtr_->postUpdateSingleton(time);
-        }
-
-    private:
-        T* singletonPtr_;   ///< Unique instance of the singleton class @a T
-    };
-
-    /**
-        @brief This class partially spezializes ClassScopedSingletonManager for classes @a T that are allowed to fail.
-        @param T The managed singleton class
-        @param scope The scope in which the singleton @a T should be active
-
-        Because @a T could fail when being created, this partial spezialization of ClassScopedSingletonManager
-        uses a try-catch block to handle exceptions.
-
-        See @ref ClassScopedSingletonManager for a full documentation of the basis template.
-    */
-    template <class T, ScopeID::Value scope>
-    class ClassScopedSingletonManager<T, scope, true> : public ScopedSingletonManager, public ScopeListener
-    {
-    public:
-        //! Constructor: Initializes the singleton pointer and passes the scope to ScopedSingletonManager and ScopeListener
-        ClassScopedSingletonManager(const std::string& className)
-            : ScopedSingletonManager(className, scope)
-            , ScopeListener(scope)
-            , singletonPtr_(NULL)
-        {
-            ScopedSingletonManager::addManager(this);
-        }
-
-        ~ClassScopedSingletonManager()
-        {
-        }
-
-        //! Called if the Scope of the Singleton gets active (creates the instance)
-        void activated()
-        {
-            assert(singletonPtr_ == NULL);
-            try
-                { singletonPtr_ = new T(); }
-            catch (const InitialisationAbortedException& ex)
-                { orxout(internal_error) << ex.getDescription() << endl; }
-            catch (...)
-                { orxout(internal_error) << "Singleton creation failed: " << Exception::handleMessage() << endl; }
-        }
-
-        //! Called if the Scope of this Singleton gets deactivated (destroys the instance)
-        void deactivated()
-        {
-            if (singletonPtr_ != NULL)
-            {
-                this->destroy(singletonPtr_);
-                singletonPtr_ = NULL;
-            }
-        }
-
-        //! Destroys the singleton instance - overloaded for Destroyable, calls Destroyable::destroy()
-        void destroy(Destroyable*)
-        {
-            singletonPtr_->destroy();
-        }
-        //! Destroys the singleton instance - overloaded for void*, calls delete
-        void destroy(void*)
-        {
-            delete singletonPtr_;
-        }
-
-        //! Called every frame by the ScopedSingletonManager
-        void preUpdate(const Clock& time)
-        {
-            assert(Scope<scope>::isActive());
-            // assuming T inherits Singleton<T>
-            if (singletonPtr_ != NULL)
-                singletonPtr_->preUpdateSingleton(time);
-        }
-
-        //! Called every frame by the ScopedSingletonManager
-        void postUpdate(const Clock& time)
-        {
-            assert(Scope<scope>::isActive());
-            // assuming T inherits Singleton<T>
-            if (singletonPtr_ != NULL)
-                singletonPtr_->postUpdateSingleton(time);
-        }
-
-    private:
-        T* singletonPtr_;   ///< Unique instance of the singleton class @a T
-    };
-}
-
-#endif /* __ScopedSingletonManager_H__ */
Index: code/trunk/src/libraries/util/SharedPtr.h
===================================================================
--- code/trunk/src/libraries/util/SharedPtr.h	(revision 10622)
+++ code/trunk/src/libraries/util/SharedPtr.h	(revision 10624)
@@ -138,5 +138,5 @@
         OtherClass* other3 = new OtherClass(object);        // "
 
-    }                                                       // The SmartPtr "object" is destroyed at the end of the scope,
+    }                                                       // The SharedPtr "object" is destroyed at the end of the scope,
                                                             // but the three instances of OtherClass keep the object alive
                                                             // until they are all destroyed.
Index: code/trunk/src/libraries/util/Singleton.h
===================================================================
--- code/trunk/src/libraries/util/Singleton.h	(revision 10622)
+++ code/trunk/src/libraries/util/Singleton.h	(revision 10624)
@@ -52,5 +52,5 @@
         public:
             TestSingleton();                                // public constructor because we may want to manage this singleton
-                                                            //     with an orxonox::ScopedSingletonManager (see below)
+                                                            //     with an orxonox::ScopedSingletonWrapper
             virtual ~TestSingleton();                       // public destructor
 
@@ -68,22 +68,4 @@
     TestSingleton* TestSingleton::singletonPtr_s = NULL;
     @endcode
-
-    Usually a singleton gets created automatically when it is first used, but it will never
-    be destroyed (unless the singleton explicitly deletes itself). To allow controlled
-    construction and destruction, the singleton can be put within a virtual scope. This is
-    done by registering the singleton class with orxonox::ScopedSingletonManager. To
-    do so, the ManageScopedSingleton() macro has to be called:
-
-    @code
-    ManageScopedSingleton(TestSingleton, ScopeID::Graphics, false); // muste be called in a source (*.cc) file
-    @endcode
-
-    @b Important: If you call ManageScopedSingleton(), you don't have to initialize singletonPtr_s anymore,
-    because that's already done by the macro.
-
-    Now the singleton TestSingleton gets automatically created if the scope Graphics becomes
-    active and also gets destroyed if the scope is deactivated.
-
-    Note that not all singletons must register with a scope, but it's recommended.
 
     If a class inherits from orxonox::Singleton, it also inherits its functions. The most important
@@ -112,6 +94,8 @@
 #include "UtilPrereqs.h"
 
-#include <cassert>
 #include <cstring>
+#include <typeinfo>
+
+#include "OrxAssert.h"
 
 namespace orxonox
@@ -134,5 +118,5 @@
         static T& getInstance()
         {
-            assert(T::singletonPtr_s != NULL);
+            OrxVerify(T::singletonPtr_s != NULL, "T=" << typeid(T).name());
             return *T::singletonPtr_s;
         }
@@ -144,18 +128,9 @@
         }
 
-        //! Update method called by ClassSingletonManager (if used)
-        void preUpdateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->preUpdate(time); }
-        //! Empty update method for the static polymorphism
-        void preUpdate(const Clock& time) { }
-        //! Update method called by ClassSingletonManager (if used)
-        void postUpdateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->postUpdate(time); }
-        //! Empty update method for the static polymorphism
-        void postUpdate(const Clock& time) { }
-
     protected:
         //! Constructor sets the singleton instance pointer
         Singleton()
         {
-            assert(T::singletonPtr_s == NULL);
+            OrxVerify(T::singletonPtr_s == NULL, "T=" << typeid(T).name());
             T::singletonPtr_s = static_cast<T*>(this);
         }
@@ -164,5 +139,5 @@
         virtual ~Singleton()
         {
-            assert(T::singletonPtr_s != NULL);
+            OrxVerify(T::singletonPtr_s != NULL, "T=" << typeid(T).name());
             T::singletonPtr_s = NULL;
         }
Index: code/trunk/src/libraries/util/UtilPrereqs.h
===================================================================
--- code/trunk/src/libraries/util/UtilPrereqs.h	(revision 10622)
+++ code/trunk/src/libraries/util/UtilPrereqs.h	(revision 10624)
@@ -62,21 +62,4 @@
 
 //-----------------------------------------------------------------------
-// Enums
-//-----------------------------------------------------------------------
-
-namespace orxonox
-{
-    namespace ScopeID
-    {
-        //!A list of available scopes for the Scope template.
-        enum Value
-        {
-            Root,
-            Graphics
-        };
-    }
-}
-
-//-----------------------------------------------------------------------
 // Forward declarations
 //-----------------------------------------------------------------------
@@ -96,8 +79,4 @@
     class OutputManager;
     class OutputStream;
-    template <ScopeID::Value>
-    class Scope;
-    template <class, ScopeID::Value>
-    class ScopedSingleton;
     class ScopeListener;
     template <class T>
Index: code/trunk/src/libraries/util/output/OutputDefinitions.h
===================================================================
--- code/trunk/src/libraries/util/output/OutputDefinitions.h	(revision 10622)
+++ code/trunk/src/libraries/util/output/OutputDefinitions.h	(revision 10624)
@@ -170,5 +170,4 @@
             {
                 REGISTER_OUTPUT_SUBCONTEXT(misc, executor);
-                REGISTER_OUTPUT_SUBCONTEXT(misc, factory);
                 REGISTER_OUTPUT_SUBCONTEXT(misc, gui);
                 REGISTER_OUTPUT_SUBCONTEXT(misc, overlays);
Index: code/trunk/src/modules/designtools/ScreenshotManager.cc
===================================================================
--- code/trunk/src/modules/designtools/ScreenshotManager.cc	(revision 10622)
+++ code/trunk/src/modules/designtools/ScreenshotManager.cc	(revision 10624)
@@ -45,8 +45,8 @@
 #include "core/config/ConfigValueIncludes.h"
 #include "core/GraphicsManager.h"
-#include "core/PathConfig.h"
+#include "core/ConfigurablePaths.h"
 #include "core/Resource.h"
-#include "core/command/ConsoleCommand.h"
-#include "util/ScopedSingletonManager.h"
+#include "core/command/ConsoleCommandIncludes.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 #include "util/StringUtils.h"
 
@@ -61,5 +61,7 @@
     SetConsoleCommand("printScreenHD", &ScreenshotManager::makeScreenshot_s);
     
-    ManageScopedSingleton(ScreenshotManager, ScopeID::Graphics, false);
+    ManageScopedSingleton(ScreenshotManager, ScopeID::GRAPHICS, false);
+
+    RegisterAbstractClass(ScreenshotManager).inheritsFrom<Configurable>();
 
     /**
@@ -152,5 +154,5 @@
         {
             // Save it.
-            finalImage->save(PathConfig::getInstance().getLogPathString() + "screenshot_" + getTimestamp() + this->fileExtension_);
+            finalImage->save(ConfigurablePaths::getLogPathString() + "screenshot_" + getTimestamp() + this->fileExtension_);
             delete finalImage;
             orxout(user_info) << "Finished taking " << this->gridSize_*this->windowWidth_ << "x" << this->gridSize_*this->windowHeight_ << " pixel HD screenshot. Storing in log/." << endl;
Index: code/trunk/src/modules/designtools/SkyboxGenerator.cc
===================================================================
--- code/trunk/src/modules/designtools/SkyboxGenerator.cc	(revision 10622)
+++ code/trunk/src/modules/designtools/SkyboxGenerator.cc	(revision 10624)
@@ -38,12 +38,12 @@
 #include <OgreCamera.h>
 
-#include "util/ScopedSingletonManager.h"
 #include "core/CoreIncludes.h"
 #include "core/config/ConfigValueIncludes.h"
 #include "core/GraphicsManager.h"
-#include "core/PathConfig.h"
+#include "core/ConfigurablePaths.h"
 #include "core/Resource.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "core/command/CommandExecutor.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 
 #include "controllers/HumanController.h"
@@ -60,5 +60,7 @@
     SetConsoleCommand("SkyboxGenerator", "createSkybox", &SkyboxGenerator::createSkybox).addShortcut();
 
-    ManageScopedSingleton(SkyboxGenerator, ScopeID::Graphics, false);
+    ManageScopedSingleton(SkyboxGenerator, ScopeID::GRAPHICS, false);
+
+    RegisterAbstractClass(SkyboxGenerator).inheritsFrom<Configurable>().inheritsFrom<Tickable>();
 
     /**
@@ -173,5 +175,5 @@
                 this->setupRenderWindow(renderWindow);
                 // Add the log path to the standard resource group.
-                Ogre::ResourceGroupManager::getSingleton().addResourceLocation(PathConfig::getInstance().getLogPathString(), "FileSystem", Resource::getDefaultResourceGroup());
+                Ogre::ResourceGroupManager::getSingleton().addResourceLocation(ConfigurablePaths::getLogPathString(), "FileSystem", Resource::getDefaultResourceGroup());
                 
                 orxout(internal_status) << "Setting up SkyboxGenerator..." << endl;
@@ -208,5 +210,5 @@
                 this->restoreRenderWindow(renderWindow);
                 // Remove the log path from the standard resource group.
-                Ogre::ResourceGroupManager::getSingleton().removeResourceLocation(PathConfig::getInstance().getLogPathString(), Resource::getDefaultResourceGroup());
+                Ogre::ResourceGroupManager::getSingleton().removeResourceLocation(ConfigurablePaths::getLogPathString(), Resource::getDefaultResourceGroup());
                 
                 // Reset the flow parameters for the next skybox generation.
@@ -306,5 +308,5 @@
     void SkyboxGenerator::saveImage(Ogre::Image* image, const std::string& name) const
     {
-        image->save(PathConfig::getInstance().getLogPathString()+name);
+        image->save(ConfigurablePaths::getLogPathString()+name);
         delete image;
         // Loading the resizing, then saving again. This seems stupid, but resizing doesn't seem to work otherwise.
@@ -313,5 +315,5 @@
         image->load(name, Resource::getDefaultResourceGroup());
         image->resize(this->size_, this->size_);
-        image->save(PathConfig::getInstance().getLogPathString()+name);
+        image->save(ConfigurablePaths::getLogPathString()+name);
         delete image;
         ScreenshotManager::getInstance().cleanup(); // Free memory in ScreenshotManager.
Index: code/trunk/src/modules/docking/Dock.cc
===================================================================
--- code/trunk/src/modules/docking/Dock.cc	(revision 10622)
+++ code/trunk/src/modules/docking/Dock.cc	(revision 10624)
@@ -37,6 +37,6 @@
 #include "core/LuaState.h"
 #include "core/GUIManager.h"
-#include "core/command/ConsoleCommand.h"
-#include "network/NetworkFunction.h"
+#include "core/command/ConsoleCommandIncludes.h"
+#include "network/NetworkFunctionIncludes.h"
 
 #include "infos/HumanPlayer.h"
@@ -184,5 +184,5 @@
             }
             else
-                callStaticNetworkFunction(Dock::showDockingDialog, player->getClientID());
+                callStaticNetworkFunction(&Dock::showDockingDialog, player->getClientID());
 
         }
@@ -201,5 +201,5 @@
         }
         else
-            callStaticNetworkFunction(Dock::showDockingDialog, player->getClientID());
+            callStaticNetworkFunction(&Dock::showDockingDialog, player->getClientID());
 
     }
Index: code/trunk/src/modules/docking/DockingAnimation.cc
===================================================================
--- code/trunk/src/modules/docking/DockingAnimation.cc	(revision 10622)
+++ code/trunk/src/modules/docking/DockingAnimation.cc	(revision 10624)
@@ -39,5 +39,5 @@
 namespace orxonox
 {
-    RegisterAbstractClass(DockingAnimation).inheritsFrom(Class(BaseObject));
+    RegisterAbstractClass(DockingAnimation).inheritsFrom<BaseObject>();
 
     DockingAnimation::DockingAnimation(Context* context) : BaseObject(context)
Index: code/trunk/src/modules/docking/DockingEffect.cc
===================================================================
--- code/trunk/src/modules/docking/DockingEffect.cc	(revision 10622)
+++ code/trunk/src/modules/docking/DockingEffect.cc	(revision 10624)
@@ -37,5 +37,5 @@
 namespace orxonox
 {
-    RegisterAbstractClass(DockingEffect).inheritsFrom(Class(BaseObject));
+    RegisterAbstractClass(DockingEffect).inheritsFrom<BaseObject>();
 
     DockingEffect::DockingEffect(Context* context) : BaseObject(context)
Index: code/trunk/src/modules/dodgerace/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/dodgerace/CMakeLists.txt	(revision 10622)
+++ code/trunk/src/modules/dodgerace/CMakeLists.txt	(revision 10624)
@@ -8,5 +8,5 @@
 
 ORXONOX_ADD_LIBRARY(dodgerace
-  MODULE
+  PLUGIN
   FIND_HEADER_FILES
   LINK_LIBRARIES
Index: code/trunk/src/modules/dodgerace/DodgeRace.cc
===================================================================
--- code/trunk/src/modules/dodgerace/DodgeRace.cc	(revision 10622)
+++ code/trunk/src/modules/dodgerace/DodgeRace.cc	(revision 10624)
@@ -35,4 +35,5 @@
 #include "DodgeRaceShip.h" // Necessary for getPlayer function. Do NOT include this in Header!
 #include "DodgeRaceCube.h"
+#include "core/CoreIncludes.h"
 
 namespace orxonox
@@ -43,13 +44,5 @@
     {
         RegisterObject(DodgeRace);
-        init();
-        this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
-        this->center_ = 0;
-
-        this->setHUDTemplate("DodgeRaceHUD");
-    }
-
-    void DodgeRace::init()
-    {
+
         bEndGame = false;
         lives = 1;
@@ -65,4 +58,8 @@
         //enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&DodgeRace::spawnEnemy, this)));
         comboTimer.setTimer(3.0f, true, createExecutor(createFunctor(&DodgeRace::comboControll, this)));
+        this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
+        this->center_ = 0;
+
+        this->setHUDTemplate("DodgeRaceHUD");
     }
 
@@ -74,5 +71,5 @@
             for (int i = 0; i < 7; i++)
             {
-                WeakPtr<BigExplosion> chunk = new BigExplosion(this->center_->getContext());
+                BigExplosion* chunk = new BigExplosion(this->center_->getContext());
                 chunk->setPosition(Vector3(600, 0, 100.f * i - 300));
                 chunk->setVelocity(Vector3(1000, 0, 0));  //player->getVelocity()
@@ -90,6 +87,4 @@
         if (getPlayer() != NULL)
         {
-            //WeakPtr<DodgeRaceShip> ship = getPlayer();
-
             currentPosition = getPlayer()->getWorldPosition().x;
             counter = counter + (currentPosition - lastPosition);
@@ -112,5 +107,5 @@
                 for(int i = 0; i<6; i++)
                 {
-                    WeakPtr<DodgeRaceCube> cube = new DodgeRaceCube(this->center_->getContext());
+                    DodgeRaceCube* cube = new DodgeRaceCube(this->center_->getContext());
                     cubeList.push_back(cube);
                     switch(pattern)
@@ -137,5 +132,5 @@
     }
 
-    WeakPtr<DodgeRaceShip> DodgeRace::getPlayer()
+    DodgeRaceShip* DodgeRace::getPlayer()
     {
         if (player == NULL)
@@ -168,5 +163,4 @@
     {
         orxout() << "start" << endl;
-        init();
         for(unsigned int i=0; i< cubeList.size();i++)
         {
@@ -199,5 +193,4 @@
         /*
         orxout() << "prespawn" << endl;
-        init();
         for(int i=0; i< cubeList.size();i++)
         {
Index: code/trunk/src/modules/dodgerace/DodgeRace.h
===================================================================
--- code/trunk/src/modules/dodgerace/DodgeRace.h	(revision 10622)
+++ code/trunk/src/modules/dodgerace/DodgeRace.h	(revision 10624)
@@ -44,5 +44,4 @@
 
 
-#include "core/CoreIncludes.h"
 #include "core/EventIncludes.h"
 #include "core/command/Executor.h"
@@ -69,6 +68,4 @@
        public:
             DodgeRace(Context* context);
-
-            void init();
 
             virtual void start();
@@ -106,5 +103,5 @@
             Timer endGameTimer;
 
-            WeakPtr<DodgeRaceShip> getPlayer();
+            DodgeRaceShip* getPlayer();
             WeakPtr<DodgeRaceShip> player;
             std::vector<DodgeRaceCube*> cubeList;
Index: code/trunk/src/modules/dodgerace/DodgeRaceCenterPoint.cc
===================================================================
--- code/trunk/src/modules/dodgerace/DodgeRaceCenterPoint.cc	(revision 10622)
+++ code/trunk/src/modules/dodgerace/DodgeRaceCenterPoint.cc	(revision 10624)
@@ -54,17 +54,9 @@
     }
 
-    void DodgeRaceCenterPoint::changedGametype()
-    {
-        SUPER(DodgeRaceCenterPoint, changedGametype);
-
-        // Check, whether it's still DodgeRace.
-        this->checkGametype();
-    }
-
     void DodgeRaceCenterPoint::checkGametype()
     {
         if (this->getGametype() != NULL && this->getGametype()->isA(Class(DodgeRace)))
         {
-            DodgeRace* DodgeRaceGametype = orxonox_cast<DodgeRace*>(this->getGametype().get());
+            DodgeRace* DodgeRaceGametype = orxonox_cast<DodgeRace*>(this->getGametype());
             DodgeRaceGametype->setCenterpoint(this);
         }
Index: code/trunk/src/modules/dodgerace/DodgeRaceCenterPoint.h
===================================================================
--- code/trunk/src/modules/dodgerace/DodgeRaceCenterPoint.h	(revision 10622)
+++ code/trunk/src/modules/dodgerace/DodgeRaceCenterPoint.h	(revision 10624)
@@ -52,5 +52,4 @@
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 
-            virtual void changedGametype(); //!< Is called when the gametype has changed.
         private:
             void checkGametype();
Index: code/trunk/src/modules/dodgerace/DodgeRaceCube.cc
===================================================================
--- code/trunk/src/modules/dodgerace/DodgeRaceCube.cc	(revision 10622)
+++ code/trunk/src/modules/dodgerace/DodgeRaceCube.cc	(revision 10624)
@@ -33,4 +33,5 @@
 #include "DodgeRaceCube.h"
 #include "DodgeRace.h"
+#include "core/CoreIncludes.h"
 
 namespace orxonox
Index: code/trunk/src/modules/dodgerace/DodgeRaceHUDinfo.cc
===================================================================
--- code/trunk/src/modules/dodgerace/DodgeRaceHUDinfo.cc	(revision 10622)
+++ code/trunk/src/modules/dodgerace/DodgeRaceHUDinfo.cc	(revision 10624)
@@ -82,5 +82,5 @@
         if (this->getOwner() && this->getOwner()->getGametype())
         {
-            this->DodgeRaceGame = orxonox_cast<DodgeRace*>(this->getOwner()->getGametype().get());
+            this->DodgeRaceGame = orxonox_cast<DodgeRace*>(this->getOwner()->getGametype());
         }
         else
Index: code/trunk/src/modules/dodgerace/DodgeRaceShip.cc
===================================================================
--- code/trunk/src/modules/dodgerace/DodgeRaceShip.cc	(revision 10622)
+++ code/trunk/src/modules/dodgerace/DodgeRaceShip.cc	(revision 10624)
@@ -33,4 +33,5 @@
 
 #include "DodgeRaceShip.h"
+#include "core/CoreIncludes.h"
 
 namespace orxonox
@@ -89,5 +90,5 @@
 
         // Camera
-        WeakPtr<Camera> camera = this->getCamera();
+        Camera* camera = this->getCamera();
         if (camera != NULL)
         {
@@ -149,5 +150,5 @@
     }
 
-    WeakPtr<DodgeRace> DodgeRaceShip::getGame()
+    DodgeRace* DodgeRaceShip::getGame()
     {
         if (game == NULL)
Index: code/trunk/src/modules/dodgerace/DodgeRaceShip.h
===================================================================
--- code/trunk/src/modules/dodgerace/DodgeRaceShip.h	(revision 10622)
+++ code/trunk/src/modules/dodgerace/DodgeRaceShip.h	(revision 10624)
@@ -38,5 +38,4 @@
 #include "dodgerace/DodgeRacePrereqs.h"
 
-#include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
 #include "worldentities/pawns/SpaceShip.h"
@@ -79,5 +78,5 @@
         private:
             virtual inline bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
-            WeakPtr<DodgeRace> getGame();
+            DodgeRace* getGame();
             WeakPtr<DodgeRace> game;
             WeakPtr<WorldEntity> lastEntity;
Index: code/trunk/src/modules/gametypes/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/gametypes/CMakeLists.txt	(revision 10622)
+++ code/trunk/src/modules/gametypes/CMakeLists.txt	(revision 10624)
@@ -10,5 +10,5 @@
 
 ORXONOX_ADD_LIBRARY(gametypes
-  MODULE
+  PLUGIN
   FIND_HEADER_FILES
   TOLUA_FILES
Index: code/trunk/src/modules/gametypes/OldRaceCheckPoint.cc
===================================================================
--- code/trunk/src/modules/gametypes/OldRaceCheckPoint.cc	(revision 10622)
+++ code/trunk/src/modules/gametypes/OldRaceCheckPoint.cc	(revision 10624)
@@ -61,5 +61,5 @@
         SUPER(OldRaceCheckPoint, tick, dt);
 
-        OldSpaceRace* gametype = orxonox_cast<OldSpaceRace*>(this->getGametype().get());
+        OldSpaceRace* gametype = orxonox_cast<OldSpaceRace*>(this->getGametype());
         assert(gametype);
         if (this->getCheckpointIndex() == gametype->getCheckpointsReached())
@@ -82,5 +82,5 @@
         DistanceTrigger::triggered(bIsTriggered);
 
-        OldSpaceRace* gametype = orxonox_cast<OldSpaceRace*>(this->getGametype().get());
+        OldSpaceRace* gametype = orxonox_cast<OldSpaceRace*>(this->getGametype());
         if (gametype && this->getCheckpointIndex() == gametype->getCheckpointsReached() && bIsTriggered)
         {
@@ -107,5 +107,5 @@
         if (this->bTimeLimit_ != 0)
         {
-            OldSpaceRace* gametype = orxonox_cast<OldSpaceRace*>(this->getGametype().get());
+            OldSpaceRace* gametype = orxonox_cast<OldSpaceRace*>(this->getGametype());
             if (gametype)
             {
Index: code/trunk/src/modules/gametypes/SpaceRaceManager.cc
===================================================================
--- code/trunk/src/modules/gametypes/SpaceRaceManager.cc	(revision 10622)
+++ code/trunk/src/modules/gametypes/SpaceRaceManager.cc	(revision 10624)
@@ -46,5 +46,5 @@
     {
         RegisterObject(SpaceRaceManager);
-        this->race_ = orxonox_cast<SpaceRace*>(this->getGametype().get());
+        this->race_ = orxonox_cast<SpaceRace*>(this->getGametype());
         assert(race_);
         //amountOfPlayers=(race_->getPlayers()).size();
@@ -139,5 +139,5 @@
     void SpaceRaceManager::checkpointReached(RaceCheckPoint* newCheckpoint, PlayerInfo* player)
     {
-        SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
+        SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype());
         assert(gametype);
         if (!gametype)
Index: code/trunk/src/modules/invader/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/invader/CMakeLists.txt	(revision 10622)
+++ code/trunk/src/modules/invader/CMakeLists.txt	(revision 10624)
@@ -13,5 +13,5 @@
 
 ORXONOX_ADD_LIBRARY(invader
-  MODULE
+  PLUGIN
   FIND_HEADER_FILES
   LINK_LIBRARIES
Index: code/trunk/src/modules/invader/Invader.cc
===================================================================
--- code/trunk/src/modules/invader/Invader.cc	(revision 10622)
+++ code/trunk/src/modules/invader/Invader.cc	(revision 10624)
@@ -62,10 +62,4 @@
         this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
         this->center_ = 0;
-        init();
-        this->setHUDTemplate("InvaderHUD");
-    }
-
-    void Invader::init()
-    {
         bEndGame = false;
         lives = 3;
@@ -78,4 +72,5 @@
         enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&Invader::spawnEnemy, this)));
         comboTimer.setTimer(3.0f, true, createExecutor(createFunctor(&Invader::comboControll, this)));
+        this->setHUDTemplate("InvaderHUD");
     }
 
@@ -87,5 +82,5 @@
             for (int i = 0; i < 7; i++)
             {
-                WeakPtr<BigExplosion> chunk = new BigExplosion(this->center_->getContext());
+                BigExplosion* chunk = new BigExplosion(this->center_->getContext());
                 chunk->setPosition(Vector3(600, 0, 100.f * i - 300));
                 chunk->setVelocity(Vector3(1000, 0, 0));  //player->getVelocity()
@@ -99,5 +94,5 @@
     }
 
-    WeakPtr<InvaderShip> Invader::getPlayer()
+    InvaderShip* Invader::getPlayer()
     {
         if (player == NULL)
@@ -116,5 +111,5 @@
         for (int i = 0; i < (3*log10(static_cast<double>(level)) + 1); i++)
         {
-            WeakPtr<InvaderEnemy> newPawn;
+            InvaderEnemy* newPawn;
             if (rand() % 42/(1 + level*level) == 0)
             {
@@ -155,5 +150,4 @@
     void Invader::start()
     {
-        init();
         // Set variable to temporarily force the player to spawn.
         this->bForceSpawn_ = true;
Index: code/trunk/src/modules/invader/Invader.h
===================================================================
--- code/trunk/src/modules/invader/Invader.h	(revision 10622)
+++ code/trunk/src/modules/invader/Invader.h	(revision 10624)
@@ -71,5 +71,4 @@
             // checks if multiplier should be reset.
             void comboControll();
-            void init();
             int lives;
             int multiplier;
@@ -78,5 +77,5 @@
         private:
             void toggleShowLevel(){bShowLevel = !bShowLevel;}
-            WeakPtr<InvaderShip> getPlayer();
+            InvaderShip* getPlayer();
             WeakPtr<InvaderCenterPoint> center_;
             WeakPtr<InvaderShip> player;
Index: code/trunk/src/modules/invader/InvaderCenterPoint.cc
===================================================================
--- code/trunk/src/modules/invader/InvaderCenterPoint.cc	(revision 10622)
+++ code/trunk/src/modules/invader/InvaderCenterPoint.cc	(revision 10624)
@@ -54,17 +54,9 @@
     }
 
-    void InvaderCenterPoint::changedGametype()
-    {
-        SUPER(InvaderCenterPoint, changedGametype);
-
-        // Check, whether it's still Invader.
-        this->checkGametype();
-    }
-
     void InvaderCenterPoint::checkGametype()
     {
         if (this->getGametype() != NULL && this->getGametype()->isA(Class(Invader)))
         {
-            Invader* InvaderGametype = orxonox_cast<Invader*>(this->getGametype().get());
+            Invader* InvaderGametype = orxonox_cast<Invader*>(this->getGametype());
             InvaderGametype->setCenterpoint(this);
         }
Index: code/trunk/src/modules/invader/InvaderCenterPoint.h
===================================================================
--- code/trunk/src/modules/invader/InvaderCenterPoint.h	(revision 10622)
+++ code/trunk/src/modules/invader/InvaderCenterPoint.h	(revision 10624)
@@ -49,5 +49,4 @@
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 
-            virtual void changedGametype(); //!< Is called when the gametype has changed.
         private:
             void checkGametype();
Index: code/trunk/src/modules/invader/InvaderEnemy.cc
===================================================================
--- code/trunk/src/modules/invader/InvaderEnemy.cc	(revision 10622)
+++ code/trunk/src/modules/invader/InvaderEnemy.cc	(revision 10624)
@@ -69,5 +69,5 @@
     }
 
-    WeakPtr<Invader> InvaderEnemy::getGame()
+    Invader* InvaderEnemy::getGame()
     {
         if (game == NULL)
Index: code/trunk/src/modules/invader/InvaderEnemy.h
===================================================================
--- code/trunk/src/modules/invader/InvaderEnemy.h	(revision 10622)
+++ code/trunk/src/modules/invader/InvaderEnemy.h	(revision 10624)
@@ -49,9 +49,9 @@
             virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
             virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator);
-            virtual void setPlayer(WeakPtr<InvaderShip> player){this->player = player;}
+            virtual void setPlayer(InvaderShip* player){this->player = player;}
 
             int level;
         protected:
-            WeakPtr<Invader> getGame();
+            Invader* getGame();
             WeakPtr<Invader> game;
             WeakPtr<InvaderShip> player;
Index: code/trunk/src/modules/invader/InvaderHUDinfo.cc
===================================================================
--- code/trunk/src/modules/invader/InvaderHUDinfo.cc	(revision 10622)
+++ code/trunk/src/modules/invader/InvaderHUDinfo.cc	(revision 10624)
@@ -128,5 +128,5 @@
         if (this->getOwner() && this->getOwner()->getGametype())
         {
-            this->InvaderGame = orxonox_cast<Invader*>(this->getOwner()->getGametype().get());
+            this->InvaderGame = orxonox_cast<Invader*>(this->getOwner()->getGametype());
         }
         else
Index: code/trunk/src/modules/invader/InvaderShip.cc
===================================================================
--- code/trunk/src/modules/invader/InvaderShip.cc	(revision 10622)
+++ code/trunk/src/modules/invader/InvaderShip.cc	(revision 10624)
@@ -91,5 +91,5 @@
 
         // Camera
-        WeakPtr<Camera> camera = this->getCamera();
+        Camera* camera = this->getCamera();
         if (camera != NULL)
         {
@@ -142,6 +142,6 @@
     {
         // orxout() << "touch!!! " << endl; //<< otherObject << " at " << contactPoint;
-        WeakPtr<InvaderEnemy> enemy = orxonox_cast<InvaderEnemy*>(otherObject);
-        WeakPtr<Projectile> shot = orxonox_cast<Projectile*>(otherObject);
+        InvaderEnemy* enemy = orxonox_cast<InvaderEnemy*>(otherObject);
+        Projectile* shot = orxonox_cast<Projectile*>(otherObject);
         // ensure that this gets only called once per enemy.
         if (enemy != NULL && lastEnemy != enemy)
@@ -171,5 +171,5 @@
     }
 
-    WeakPtr<Invader> InvaderShip::getGame()
+    Invader* InvaderShip::getGame()
     {
         if (game == NULL)
Index: code/trunk/src/modules/invader/InvaderShip.h
===================================================================
--- code/trunk/src/modules/invader/InvaderShip.h	(revision 10622)
+++ code/trunk/src/modules/invader/InvaderShip.h	(revision 10624)
@@ -70,5 +70,5 @@
             virtual void death();
         private:
-            WeakPtr<Invader> getGame();
+            Invader* getGame();
             WeakPtr<Invader> game;
             Camera* camera;
Index: code/trunk/src/modules/invader/InvaderWeapon.cc
===================================================================
--- code/trunk/src/modules/invader/InvaderWeapon.cc	(revision 10622)
+++ code/trunk/src/modules/invader/InvaderWeapon.cc	(revision 10624)
@@ -68,5 +68,5 @@
         // Create the projectile.projectile
         projectile = new Projectile(this->getContext());
-        WeakPtr<Model> model = new Model(projectile->getContext());
+        Model* model = new Model(projectile->getContext());
         model->setMeshSource(mesh_);
         model->setCastShadows(false);
Index: code/trunk/src/modules/jump/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/jump/CMakeLists.txt	(revision 10622)
+++ code/trunk/src/modules/jump/CMakeLists.txt	(revision 10624)
@@ -24,5 +24,5 @@
 
 ORXONOX_ADD_LIBRARY(jump
-  MODULE
+  PLUGIN
   FIND_HEADER_FILES
   LINK_LIBRARIES
Index: code/trunk/src/modules/jump/JumpCenterpoint.cc
===================================================================
--- code/trunk/src/modules/jump/JumpCenterpoint.cc	(revision 10622)
+++ code/trunk/src/modules/jump/JumpCenterpoint.cc	(revision 10624)
@@ -80,16 +80,9 @@
     }
 
-    void JumpCenterpoint::changedGametype()
-    {
-        SUPER(JumpCenterpoint, changedGametype);
-
-        checkGametype();
-    }
-
     void JumpCenterpoint::checkGametype()
     {
         if (getGametype() != NULL && this->getGametype()->isA(Class(Jump)))
         {
-            Jump* jumpGametype = orxonox_cast<Jump*>(this->getGametype().get());
+            Jump* jumpGametype = orxonox_cast<Jump*>(this->getGametype());
             jumpGametype->setCenterpoint(this);
         }
Index: code/trunk/src/modules/jump/JumpCenterpoint.h
===================================================================
--- code/trunk/src/modules/jump/JumpCenterpoint.h	(revision 10622)
+++ code/trunk/src/modules/jump/JumpCenterpoint.h	(revision 10624)
@@ -114,5 +114,4 @@
             virtual ~JumpCenterpoint() {}
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method to create a JumpCenterpoint through XML.
-            virtual void changedGametype();
             void setPlatformStaticTemplate(const std::string& balltemplate)
                 { this->platformStaticTemplate_ = balltemplate; }
Index: code/trunk/src/modules/jump/JumpEnemy.cc
===================================================================
--- code/trunk/src/modules/jump/JumpEnemy.cc	(revision 10622)
+++ code/trunk/src/modules/jump/JumpEnemy.cc	(revision 10624)
@@ -151,5 +151,5 @@
         An array (of size 2) of weak pointers, to be set as the new bats.
     */
-    void JumpEnemy::setFigure(WeakPtr<JumpFigure> newFigure)
+    void JumpEnemy::setFigure(JumpFigure* newFigure)
     {
         figure_ = newFigure;
Index: code/trunk/src/modules/jump/JumpEnemy.h
===================================================================
--- code/trunk/src/modules/jump/JumpEnemy.h	(revision 10622)
+++ code/trunk/src/modules/jump/JumpEnemy.h	(revision 10624)
@@ -68,5 +68,5 @@
 
             virtual void setProperties(float newLeftBoundary, float newRightBoundary, float newLowerBoundary, float newUpperBoundary, float newHSpeed, float newVSpeed);
-            void setFigure(WeakPtr<JumpFigure> bats);
+            void setFigure(JumpFigure* newFigure);
             virtual void touchFigure();
             bool dead_;
Index: code/trunk/src/modules/jump/JumpItem.cc
===================================================================
--- code/trunk/src/modules/jump/JumpItem.cc	(revision 10622)
+++ code/trunk/src/modules/jump/JumpItem.cc	(revision 10624)
@@ -109,5 +109,5 @@
     }
 
-    void JumpItem::setFigure(WeakPtr<JumpFigure> newFigure)
+    void JumpItem::setFigure(JumpFigure* newFigure)
     {
         figure_ = newFigure;
Index: code/trunk/src/modules/jump/JumpItem.h
===================================================================
--- code/trunk/src/modules/jump/JumpItem.h	(revision 10622)
+++ code/trunk/src/modules/jump/JumpItem.h	(revision 10624)
@@ -53,5 +53,5 @@
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
             virtual void setProperties(float newLeftBoundary, float newRightBoundary, float newLowerBoundary, float newUpperBoundary, float newHSpeed, float newVSpeed);
-            virtual void setFigure(WeakPtr<JumpFigure> bats);
+            virtual void setFigure(JumpFigure* newFigure);
             virtual void touchFigure();
 
Index: code/trunk/src/modules/jump/JumpPlatform.cc
===================================================================
--- code/trunk/src/modules/jump/JumpPlatform.cc	(revision 10622)
+++ code/trunk/src/modules/jump/JumpPlatform.cc	(revision 10624)
@@ -125,5 +125,5 @@
     }
 
-    void JumpPlatform::setFigure(WeakPtr<JumpFigure> newFigure)
+    void JumpPlatform::setFigure(JumpFigure* newFigure)
     {
         figure_ = newFigure;
Index: code/trunk/src/modules/jump/JumpPlatform.h
===================================================================
--- code/trunk/src/modules/jump/JumpPlatform.h	(revision 10622)
+++ code/trunk/src/modules/jump/JumpPlatform.h	(revision 10624)
@@ -49,5 +49,5 @@
             virtual void tick(float dt);
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-            void setFigure(WeakPtr<JumpFigure> bats); //!< Set the bats for the ball.
+            void setFigure(JumpFigure* newFigure);
             virtual void touchFigure();
 
Index: code/trunk/src/modules/jump/JumpProjectile.cc
===================================================================
--- code/trunk/src/modules/jump/JumpProjectile.cc	(revision 10622)
+++ code/trunk/src/modules/jump/JumpProjectile.cc	(revision 10624)
@@ -84,5 +84,5 @@
     }
 
-    void JumpProjectile::setFigure(WeakPtr<JumpFigure> figure)
+    void JumpProjectile::setFigure(JumpFigure* figure)
     {
         figure_ = figure;
Index: code/trunk/src/modules/jump/JumpProjectile.h
===================================================================
--- code/trunk/src/modules/jump/JumpProjectile.h	(revision 10622)
+++ code/trunk/src/modules/jump/JumpProjectile.h	(revision 10624)
@@ -56,5 +56,5 @@
                 { return Vector2(this->fieldWidth_, this->fieldHeight_); }
 
-            void setFigure(WeakPtr<JumpFigure> figure);
+            void setFigure(JumpFigure* figure);
 
         protected:
Index: code/trunk/src/modules/jump/JumpScore.cc
===================================================================
--- code/trunk/src/modules/jump/JumpScore.cc	(revision 10622)
+++ code/trunk/src/modules/jump/JumpScore.cc	(revision 10624)
@@ -118,5 +118,5 @@
         if (this->getOwner() != NULL && this->getOwner()->getGametype())
         {
-            this->owner_ = orxonox_cast<Jump*>(this->getOwner()->getGametype().get());
+            this->owner_ = orxonox_cast<Jump*>(this->getOwner()->getGametype());
         }
         else
Index: code/trunk/src/modules/mini4dgame/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/mini4dgame/CMakeLists.txt	(revision 10622)
+++ code/trunk/src/modules/mini4dgame/CMakeLists.txt	(revision 10624)
@@ -6,5 +6,5 @@
 
 ORXONOX_ADD_LIBRARY(mini4dgame
-  MODULE
+  PLUGIN
   FIND_HEADER_FILES
   LINK_LIBRARIES
Index: code/trunk/src/modules/mini4dgame/Mini4Dgame.cc
===================================================================
--- code/trunk/src/modules/mini4dgame/Mini4Dgame.cc	(revision 10622)
+++ code/trunk/src/modules/mini4dgame/Mini4Dgame.cc	(revision 10624)
@@ -45,5 +45,5 @@
 #include "core/config/ConfigValueIncludes.h"
 #include "infos/PlayerInfo.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 
 #include "gamestates/GSLevel.h"
Index: code/trunk/src/modules/mini4dgame/Mini4DgameBoard.cc
===================================================================
--- code/trunk/src/modules/mini4dgame/Mini4DgameBoard.cc	(revision 10622)
+++ code/trunk/src/modules/mini4dgame/Mini4DgameBoard.cc	(revision 10624)
@@ -901,16 +901,4 @@
     /**
     @brief
-        Is called when the gametype has changed.
-    */
-    void Mini4DgameBoard::changedGametype()
-    {
-        SUPER(Mini4DgameBoard, changedGametype);
-
-        // Check, whether it's still Mini4Dgame.
-        this->checkGametype();
-    }
-
-    /**
-    @brief
         Checks whether the gametype is Mini4Dgame and if it is, sets its centerpoint.
     */
@@ -919,5 +907,5 @@
         if (this->getGametype() != NULL && this->getGametype()->isA(Class(Mini4Dgame)))
         {
-            Mini4Dgame* Mini4DgameGametype = orxonox_cast<Mini4Dgame*>(this->getGametype().get());
+            Mini4Dgame* Mini4DgameGametype = orxonox_cast<Mini4Dgame*>(this->getGametype());
             Mini4DgameGametype->setGameboard(this);
         }
Index: code/trunk/src/modules/mini4dgame/Mini4DgameBoard.h
===================================================================
--- code/trunk/src/modules/mini4dgame/Mini4DgameBoard.h	(revision 10622)
+++ code/trunk/src/modules/mini4dgame/Mini4DgameBoard.h	(revision 10624)
@@ -81,5 +81,4 @@
             Mini4DgameWinner getWinner();
 
-            void changedGametype();
             void checkGametype();
 
Index: code/trunk/src/modules/notifications/NotificationDispatcher.cc
===================================================================
--- code/trunk/src/modules/notifications/NotificationDispatcher.cc	(revision 10622)
+++ code/trunk/src/modules/notifications/NotificationDispatcher.cc	(revision 10624)
@@ -37,5 +37,5 @@
 #include "core/EventIncludes.h"
 #include "core/XMLPort.h"
-#include "network/NetworkFunction.h"
+#include "network/NetworkFunctionIncludes.h"
 #include "network/Host.h"
 
@@ -118,5 +118,5 @@
         if(!GameMode::isStandalone())
         {
-            callMemberNetworkFunction(NotificationDispatcher, broadcastHelper, this->getObjectID(), NETWORK_PEER_ID_BROADCAST);
+            callMemberNetworkFunction(&NotificationDispatcher::broadcastHelper, this->getObjectID(), NETWORK_PEER_ID_BROADCAST);
         }
     }
@@ -148,5 +148,5 @@
         else if(GameMode::isServer())
         {
-            callMemberNetworkFunction(NotificationDispatcher, dispatch, this->getObjectID(), clientId, clientId);
+            callMemberNetworkFunction(&NotificationDispatcher::dispatch, this->getObjectID(), clientId, clientId);
         }
     }
Index: code/trunk/src/modules/notifications/NotificationManager.cc
===================================================================
--- code/trunk/src/modules/notifications/NotificationManager.cc	(revision 10622)
+++ code/trunk/src/modules/notifications/NotificationManager.cc	(revision 10624)
@@ -37,5 +37,5 @@
 #include "core/CoreIncludes.h"
 #include "core/LuaState.h"
-#include "util/ScopedSingletonManager.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 
 #include "interfaces/NotificationListener.h"
@@ -47,5 +47,7 @@
 {
 
-    ManageScopedSingleton(NotificationManager, ScopeID::Root, false);
+    ManageScopedSingleton(NotificationManager, ScopeID::ROOT, false);
+
+    RegisterAbstractClass(NotificationManager).inheritsFrom<NotificationListener>();
 
     /**
Index: code/trunk/src/modules/objects/Planet.cc
===================================================================
--- code/trunk/src/modules/objects/Planet.cc	(revision 10622)
+++ code/trunk/src/modules/objects/Planet.cc	(revision 10624)
@@ -85,8 +85,4 @@
 
         SUPER(Planet, tick, dt);
-    }
-
-    void Planet::init()
-    {
     }
 
Index: code/trunk/src/modules/objects/Planet.h
===================================================================
--- code/trunk/src/modules/objects/Planet.h	(revision 10622)
+++ code/trunk/src/modules/objects/Planet.h	(revision 10624)
@@ -52,5 +52,4 @@
             virtual ~Planet();
 
-            void init();
             virtual void tick(float dt);
 
Index: code/trunk/src/modules/objects/Script.cc
===================================================================
--- code/trunk/src/modules/objects/Script.cc	(revision 10622)
+++ code/trunk/src/modules/objects/Script.cc	(revision 10624)
@@ -37,5 +37,5 @@
 #include "core/XMLPort.h"
 #include "network/Host.h"
-#include "network/NetworkFunction.h"
+#include "network/NetworkFunctionIncludes.h"
 
 #include "PlayerManager.h"
@@ -198,5 +198,5 @@
                 for(std::map<unsigned int, PlayerInfo*>::const_iterator it = clients.begin(); it != clients.end(); it++)
                 {
-                    callStaticNetworkFunction(Script::executeHelper, it->first, this->getCode(), this->getMode(), this->getNeedsGraphics());
+                    callStaticNetworkFunction(&Script::executeHelper, it->first, this->getCode(), this->getMode(), this->getNeedsGraphics());
                     if(this->times_ != Script::INF) // Decrement the number of remaining executions.
                     {
@@ -210,5 +210,5 @@
             else
             {
-                callStaticNetworkFunction(Script::executeHelper, clientId, this->getCode(), this->getMode(), this->getNeedsGraphics());
+                callStaticNetworkFunction(&Script::executeHelper, clientId, this->getCode(), this->getMode(), this->getNeedsGraphics());
                 if(this->times_ != Script::INF) // Decrement the number of remaining executions.
                     this->remainingExecutions_--;
@@ -248,5 +248,5 @@
         if(GameMode::isServer() && this->isOnLoad())
         {
-            callStaticNetworkFunction(Script::executeHelper, clientId, this->getCode(), this->getMode(), this->getNeedsGraphics());
+            callStaticNetworkFunction(&Script::executeHelper, clientId, this->getCode(), this->getMode(), this->getNeedsGraphics());
         }
     }
Index: code/trunk/src/modules/objects/SpaceBoundaries.cc
===================================================================
--- code/trunk/src/modules/objects/SpaceBoundaries.cc	(revision 10622)
+++ code/trunk/src/modules/objects/SpaceBoundaries.cc	(revision 10624)
@@ -210,5 +210,5 @@
         for( std::list<WeakPtr<Pawn> >::iterator current = pawnsIn_.begin(); current != pawnsIn_.end(); current++ )
         {
-            Pawn* currentPawn = current->get();
+            Pawn* currentPawn = *current;
             if( currentPawn && currentPawn->getNode() ) 
             {
Index: code/trunk/src/modules/objects/collisionshapes/AbstractRadiusHeightCollisionShape.cc
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/AbstractRadiusHeightCollisionShape.cc	(revision 10622)
+++ code/trunk/src/modules/objects/collisionshapes/AbstractRadiusHeightCollisionShape.cc	(revision 10624)
@@ -40,5 +40,5 @@
 namespace orxonox
 {
-    RegisterAbstractClass(AbstractRadiusHeightCollisionShape).inheritsFrom(Class(CollisionShape));
+    RegisterAbstractClass(AbstractRadiusHeightCollisionShape).inheritsFrom<CollisionShape>();
 
     /**
Index: code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.cc
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.cc	(revision 10622)
+++ code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.cc	(revision 10624)
@@ -58,11 +58,4 @@
     }
 
-    BoxCollisionShape::~BoxCollisionShape()
-    {
-        // TODO: Move to CollisionShape?
-        if (this->isInitialized())
-            delete this->collisionShape_;
-    }
-
     void BoxCollisionShape::registerVariables()
     {
Index: code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.h
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.h	(revision 10622)
+++ code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.h	(revision 10624)
@@ -58,5 +58,4 @@
         public:
             BoxCollisionShape(Context* context);
-            virtual ~BoxCollisionShape();
 
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
Index: code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.cc
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.cc	(revision 10622)
+++ code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.cc	(revision 10624)
@@ -54,10 +54,4 @@
     }
 
-    ConeCollisionShape::~ConeCollisionShape()
-    {
-        if (this->isInitialized())
-            delete this->collisionShape_;
-    }
-
     /**
     @brief
Index: code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.h
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.h	(revision 10622)
+++ code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.h	(revision 10624)
@@ -56,5 +56,4 @@
         public:
             ConeCollisionShape(Context* context);
-            virtual ~ConeCollisionShape();
 
         private:
Index: code/trunk/src/modules/objects/collisionshapes/CylinderCollisionShape.cc
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/CylinderCollisionShape.cc	(revision 10622)
+++ code/trunk/src/modules/objects/collisionshapes/CylinderCollisionShape.cc	(revision 10624)
@@ -54,10 +54,4 @@
     }
 
-    CylinderCollisionShape::~CylinderCollisionShape()
-    {
-        if (this->isInitialized())
-            delete this->collisionShape_;
-    }
-
     /**
     @brief
Index: code/trunk/src/modules/objects/collisionshapes/CylinderCollisionShape.h
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/CylinderCollisionShape.h	(revision 10622)
+++ code/trunk/src/modules/objects/collisionshapes/CylinderCollisionShape.h	(revision 10624)
@@ -53,5 +53,4 @@
         public:
             CylinderCollisionShape(Context* context);
-            virtual ~CylinderCollisionShape();
 
         private:
Index: code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.cc
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.cc	(revision 10622)
+++ code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.cc	(revision 10624)
@@ -59,10 +59,4 @@
     }
 
-    PlaneCollisionShape::~PlaneCollisionShape()
-    {
-        if (this->isInitialized())
-            delete this->collisionShape_;
-    }
-
     void PlaneCollisionShape::registerVariables()
     {
Index: code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.h
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.h	(revision 10622)
+++ code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.h	(revision 10624)
@@ -58,5 +58,4 @@
         public:
             PlaneCollisionShape(Context* context);
-            virtual ~PlaneCollisionShape();
 
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
Index: code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.cc
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.cc	(revision 10622)
+++ code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.cc	(revision 10624)
@@ -58,10 +58,4 @@
     }
 
-    SphereCollisionShape::~SphereCollisionShape()
-    {
-        if (this->isInitialized())
-            delete this->collisionShape_;
-    }
-
     void SphereCollisionShape::registerVariables()
     {
Index: code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.h
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.h	(revision 10622)
+++ code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.h	(revision 10624)
@@ -56,5 +56,4 @@
         public:
             SphereCollisionShape(Context* context);
-            virtual ~SphereCollisionShape();
 
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
Index: code/trunk/src/modules/objects/triggers/CheckPoint.cc
===================================================================
--- code/trunk/src/modules/objects/triggers/CheckPoint.cc	(revision 10622)
+++ code/trunk/src/modules/objects/triggers/CheckPoint.cc	(revision 10624)
@@ -93,5 +93,5 @@
         DistanceTrigger::triggered(bIsTriggered);
 
-        Asteroids* gametype = orxonox_cast<Asteroids*>(this->getGametype().get());
+        Asteroids* gametype = orxonox_cast<Asteroids*>(this->getGametype());
         if (gametype)
         {
Index: code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc
===================================================================
--- code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc	(revision 10622)
+++ code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc	(revision 10624)
@@ -100,13 +100,12 @@
 
         // Check for objects that were in range but no longer are. Iterate through all objects, that are in range.
-        for(std::map<WorldEntity*, WeakPtr<WorldEntity>* >::iterator it = this->range_.begin(); it != this->range_.end(); )
+        for(std::set<WeakPtr<WorldEntity> >::iterator it = this->range_.begin(); it != this->range_.end(); )
         {
-            WorldEntity* entity = it->second->get();
-            WorldEntity* key = it->first;
-            it++; // Incrementing the iterator in advance, since we don't need the current anymore and we potentially are going to delete the current element thus invalidating the iterator.
+            WorldEntity* entity = *it;
+
             // If the entity no longer exists.
             if(entity == NULL)
             {
-                this->removeFromRange(key);
+                this->range_.erase(it++);
                 continue;
             }
@@ -116,7 +115,5 @@
             if (distanceVec.length() > this->distance_)
             {
-                // If for some reason the entity could not be removed.
-                if(!this->removeFromRange(key))
-                    continue;
+                this->range_.erase(it++);
 
                 // If no queue has been created, yet.
@@ -129,4 +126,8 @@
                 state->originator = entity;
                 queue->push(state);
+            }
+            else
+            {
+                ++it;
             }
         }
@@ -260,32 +261,6 @@
     bool DistanceMultiTrigger::addToRange(WorldEntity* entity)
     {
-        WeakPtr<WorldEntity>* weakptr = new WeakPtr<WorldEntity>(entity);
-        std::pair<std::map<WorldEntity*, WeakPtr<WorldEntity>* >::iterator, bool> pair = this->range_.insert(std::pair<WorldEntity*, WeakPtr<WorldEntity>* >(entity, weakptr));
-
-        if(!pair.second)
-        {
-            delete weakptr;
-            return false;
-        }
-
-        return true;
-    }
-
-    /**
-    @brief
-        Remove a given entity from the set of entities, that currently are in range of the DistanceMultiTrigger.
-    @param entity
-        A pointer ot the entity.
-    @return
-        Returns true if successful.
-    */
-    bool DistanceMultiTrigger::removeFromRange(WorldEntity* entity)
-    {
-        WeakPtr<WorldEntity>* weakptr = this->range_.find(entity)->second;
-        bool erased = this->range_.erase(entity) > 0;
-        if(erased)
-            delete weakptr;
-        return erased;
-    }
-
+        std::pair<std::set<WeakPtr<WorldEntity> >::iterator, bool> pair = this->range_.insert(entity);
+        return pair.second;
+    }
 }
Index: code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h
===================================================================
--- code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h	(revision 10622)
+++ code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h	(revision 10624)
@@ -140,5 +140,4 @@
 
             bool addToRange(WorldEntity* entity); // Add a given entity to the entities, that currently are in range of the DistanceMultiTrigger.
-            bool removeFromRange(WorldEntity* entity); // Remove a given entity from the set of entities, that currently are in range of the DistanceMultiTrigger.
 
         private:
@@ -154,5 +153,5 @@
             ClassTreeMask beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons.
 
-            std::map<WorldEntity*, WeakPtr<WorldEntity>* > range_; //!< The set of entities that currently are in range of the DistanceMultiTrigger.
+            std::set<WeakPtr<WorldEntity> > range_; //!< The set of entities that currently are in range of the DistanceMultiTrigger.
 
     };
Index: code/trunk/src/modules/objects/triggers/DistanceTrigger.cc
===================================================================
--- code/trunk/src/modules/objects/triggers/DistanceTrigger.cc	(revision 10622)
+++ code/trunk/src/modules/objects/triggers/DistanceTrigger.cc	(revision 10624)
@@ -147,7 +147,7 @@
     {
         // Check whether there is a cached object, it still exists and whether it is still in range, if so nothing further needs to be done.
-        if(this->cache_.get() != NULL)
-        {
-            if((this->cache_.get()->getWorldPosition() - this->getWorldPosition()).length() < this->distance_)
+        if(this->cache_ != NULL)
+        {
+            if((this->cache_->getWorldPosition() - this->getWorldPosition()).length() < this->distance_)
                 return true;
             else
@@ -213,5 +213,5 @@
                 
                 // Add the entity to the cache.
-                this->cache_ = WeakPtr<WorldEntity>(entity);
+                this->cache_ = entity;
 
                 return true;
Index: code/trunk/src/modules/objects/triggers/Trigger.cc
===================================================================
--- code/trunk/src/modules/objects/triggers/Trigger.cc	(revision 10622)
+++ code/trunk/src/modules/objects/triggers/Trigger.cc	(revision 10624)
@@ -38,5 +38,5 @@
 #include "core/GameMode.h"
 #include "core/XMLPort.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 
 #include "Scene.h"
Index: code/trunk/src/modules/overlays/hud/HUDHealthBar.h
===================================================================
--- code/trunk/src/modules/overlays/hud/HUDHealthBar.h	(revision 10622)
+++ code/trunk/src/modules/overlays/hud/HUDHealthBar.h	(revision 10624)
@@ -115,5 +115,5 @@
         private:
             WeakPtr<Pawn> owner_;
-            SmartPtr<OverlayText> textoverlay_;
+            StrongPtr<OverlayText> textoverlay_;
             bool bUseBarColour_;
             ColourValue textColour_;
Index: code/trunk/src/modules/overlays/hud/HUDNavigation.cc
===================================================================
--- code/trunk/src/modules/overlays/hud/HUDNavigation.cc	(revision 10622)
+++ code/trunk/src/modules/overlays/hud/HUDNavigation.cc	(revision 10624)
@@ -41,5 +41,5 @@
 #include "util/Math.h"
 #include "util/Convert.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
Index: code/trunk/src/modules/overlays/hud/LastManStandingInfos.cc
===================================================================
--- code/trunk/src/modules/overlays/hud/LastManStandingInfos.cc	(revision 10622)
+++ code/trunk/src/modules/overlays/hud/LastManStandingInfos.cc	(revision 10624)
@@ -87,5 +87,5 @@
         {
             this->player_ = orxonox_cast<PlayerInfo*>(this->getOwner());
-            this->lms_ = orxonox_cast<LastManStanding*>(this->getOwner()->getGametype().get());
+            this->lms_ = orxonox_cast<LastManStanding*>(this->getOwner()->getGametype());
         }
         else
Index: code/trunk/src/modules/overlays/hud/LastTeamStandingInfos.cc
===================================================================
--- code/trunk/src/modules/overlays/hud/LastTeamStandingInfos.cc	(revision 10622)
+++ code/trunk/src/modules/overlays/hud/LastTeamStandingInfos.cc	(revision 10624)
@@ -87,5 +87,5 @@
         {
             this->player_ = orxonox_cast<PlayerInfo*>(this->getOwner());
-            this->lts_ = orxonox_cast<LastTeamStanding*>(this->getOwner()->getGametype().get());
+            this->lts_ = orxonox_cast<LastTeamStanding*>(this->getOwner()->getGametype());
         }
         else
Index: code/trunk/src/modules/overlays/hud/TeamBaseMatchScore.cc
===================================================================
--- code/trunk/src/modules/overlays/hud/TeamBaseMatchScore.cc	(revision 10622)
+++ code/trunk/src/modules/overlays/hud/TeamBaseMatchScore.cc	(revision 10624)
@@ -118,5 +118,5 @@
 
         if (this->getOwner() && this->getOwner()->getGametype())
-            this->owner_ = orxonox_cast<TeamBaseMatch*>(this->getOwner()->getGametype().get());
+            this->owner_ = orxonox_cast<TeamBaseMatch*>(this->getOwner()->getGametype());
         else
             this->owner_ = 0;
Index: code/trunk/src/modules/pickup/CollectiblePickup.cc
===================================================================
--- code/trunk/src/modules/pickup/CollectiblePickup.cc	(revision 10622)
+++ code/trunk/src/modules/pickup/CollectiblePickup.cc	(revision 10624)
@@ -40,5 +40,5 @@
 namespace orxonox
 {
-    RegisterAbstractClass(CollectiblePickup).inheritsFrom(Class(Pickupable));
+    RegisterAbstractClass(CollectiblePickup).inheritsFrom<Pickupable>();
 
     /**
Index: code/trunk/src/modules/pickup/PickupManager.cc
===================================================================
--- code/trunk/src/modules/pickup/PickupManager.cc	(revision 10622)
+++ code/trunk/src/modules/pickup/PickupManager.cc	(revision 10624)
@@ -38,7 +38,7 @@
 #include "core/GUIManager.h"
 #include "core/class/Identifier.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 #include "network/Host.h"
-#include "network/NetworkFunction.h"
-#include "util/ScopedSingletonManager.h"
+#include "network/NetworkFunctionIncludes.h"
 
 #include "infos/PlayerInfo.h"
@@ -51,5 +51,5 @@
 namespace orxonox
 {
-    ManageScopedSingleton(PickupManager, ScopeID::Root, false);
+    ManageScopedSingleton(PickupManager, ScopeID::ROOT, false);
 
     // Initialization of the name of the PickupInventory GUI.
@@ -62,4 +62,6 @@
     registerStaticNetworkFunction(PickupManager::usePickupNetworked);
 
+    RegisterAbstractClass(PickupManager).inheritsFrom<PickupListener>();
+
     /**
     @brief
@@ -94,6 +96,4 @@
 
         // Destroying all the WeakPointers that are still there.
-        for(std::map<uint32_t, WeakPtr<Pickupable>*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
-            delete it->second;
         this->pickups_.clear();
 
@@ -212,5 +212,5 @@
         else
         {
-            callStaticNetworkFunction(PickupManager::pickupChangedUsedNetwork, clientId, index, used, pickup->isUsable(), pickup->isUnusable());
+            callStaticNetworkFunction(&PickupManager::pickupChangedUsedNetwork, clientId, index, used, pickup->isUsable(), pickup->isUnusable());
         }
     }
@@ -286,5 +286,5 @@
             // Add the Pickupable to the indexes_ and pickups_ lists.
             this->indexes_[pickup] = index;
-            this->pickups_[index] = new WeakPtr<Pickupable>(pickup);
+            this->pickups_[index] = pickup;
         }
         else // If it was dropped, it is removed from the required lists.
@@ -294,9 +294,7 @@
             index = it->second;
 
-            // Remove the Pickupable form the indexes_ and pickups_ list.
-            WeakPtr<Pickupable>* ptr = this->pickups_[index];
+            // Remove the Pickupable from the indexes_ and pickups_ list.
             this->indexes_.erase(it);
             this->pickups_.erase(index);
-            delete ptr;
         }
 
@@ -316,9 +314,9 @@
             if(this->representations_.find(pickup->getRepresentationName()) == this->representations_.end())
             {
-                callStaticNetworkFunction(PickupManager::pickupChangedPickedUpNetwork, clientId, index, pickup->isUsable(), this->defaultRepresentation_->getObjectID(), pickedUp);
+                callStaticNetworkFunction(&PickupManager::pickupChangedPickedUpNetwork, clientId, index, pickup->isUsable(), this->defaultRepresentation_->getObjectID(), pickedUp);
             }
             else
             {
-                callStaticNetworkFunction(PickupManager::pickupChangedPickedUpNetwork, clientId, index, pickup->isUsable(), this->representations_[pickup->getRepresentationName()]->getObjectID(), pickedUp);
+                callStaticNetworkFunction(&PickupManager::pickupChangedPickedUpNetwork, clientId, index, pickup->isUsable(), this->representations_[pickup->getRepresentationName()]->getObjectID(), pickedUp);
             }
         }
@@ -400,5 +398,5 @@
             if(this->pickups_.empty())
                 return;
-            Pickupable* pickupable = this->pickups_.find(pickup)->second->get();
+            Pickupable* pickupable = this->pickups_.find(pickup)->second;
             if(pickupable != NULL)
                 pickupable->drop();
@@ -407,5 +405,5 @@
         else
         {
-            callStaticNetworkFunction(PickupManager::dropPickupNetworked, 0, pickup);
+            callStaticNetworkFunction(&PickupManager::dropPickupNetworked, 0, pickup);
         }
     }
@@ -443,5 +441,5 @@
             if(this->pickups_.empty())
                 return;
-            Pickupable* pickupable = this->pickups_.find(pickup)->second->get();
+            Pickupable* pickupable = this->pickups_.find(pickup)->second;
             if(pickupable != NULL)
                 pickupable->setUsed(use);
@@ -450,5 +448,5 @@
         else
         {
-            callStaticNetworkFunction(PickupManager::usePickupNetworked, 0, pickup, use);
+            callStaticNetworkFunction(&PickupManager::usePickupNetworked, 0, pickup, use);
         }
     }
Index: code/trunk/src/modules/pickup/PickupManager.h
===================================================================
--- code/trunk/src/modules/pickup/PickupManager.h	(revision 10622)
+++ code/trunk/src/modules/pickup/PickupManager.h	(revision 10624)
@@ -161,5 +161,5 @@
             std::map<uint32_t, PickupInventoryContainer*>::iterator pickupsIterator_; //!< An iterator pointing to the current Pickupable in pickupsList_.
 
-            std::map<uint32_t, WeakPtr<Pickupable>*> pickups_; //!< Map linking a number identifying a Pickupable to a weak pointer of a Pickupable.
+            std::map<uint32_t, WeakPtr<Pickupable> > pickups_; //!< Map linking a number identifying a Pickupable to a weak pointer of a Pickupable.
             std::map<Pickupable*, uint32_t> indexes_;//!< Map linking Pickupable to the number identifying it.
 
Index: code/trunk/src/modules/pickup/PickupSpawner.cc
===================================================================
--- code/trunk/src/modules/pickup/PickupSpawner.cc	(revision 10622)
+++ code/trunk/src/modules/pickup/PickupSpawner.cc	(revision 10624)
@@ -145,5 +145,6 @@
         if(GameMode::isMaster() && this->isActive())
         {
-            WeakPtr<PickupSpawner> spawner = this; // Create a smart pointer to keep the PickupSpawner alive until we iterated through all Pawns (in case a Pawn takes the last pickup)
+            // TODO: why is this a WeakPtr when the comment says StrongPtr?
+            WeakPtr<PickupSpawner> spawner = this; // Create a strong pointer to keep the PickupSpawner alive until we iterated through all Pawns (in case a Pawn takes the last pickup)
 
             // Remove PickupCarriers from the blocked list if they have exceeded their time.
Index: code/trunk/src/modules/pickup/items/ShrinkPickup.cc
===================================================================
--- code/trunk/src/modules/pickup/items/ShrinkPickup.cc	(revision 10622)
+++ code/trunk/src/modules/pickup/items/ShrinkPickup.cc	(revision 10624)
@@ -182,5 +182,5 @@
 
                 // Iterate over all camera positions and inversely move the camera to create a shrinking sensation.
-                const std::list< SmartPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();
+                const std::list< StrongPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();
                 int size = cameraPositions.size();
                 for(int index = 0; index < size; index++)
@@ -208,5 +208,5 @@
 
                 // Iterate over all camera positions and inversely move the camera to create a shrinking sensation.
-                const std::list< SmartPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();
+                const std::list< StrongPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();
                 int size = cameraPositions.size();
                 for(int index = 0; index < size; index++)
@@ -263,5 +263,5 @@
 
                 // Iterate over all camera positions and inversely move the camera to create a shrinking sensation.
-                const std::list< SmartPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();
+                const std::list< StrongPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();
                 int size = cameraPositions.size();
                 for(int index = 0; index < size; index++)
@@ -304,5 +304,5 @@
 
                 // Iterate over all camera positions and inversely move the camera to create a shrinking sensation.
-                const std::list< SmartPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();
+                const std::list< StrongPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();
                 int size = cameraPositions.size();
                 for(int index = 0; index < size; index++)
Index: code/trunk/src/modules/pong/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/pong/CMakeLists.txt	(revision 10622)
+++ code/trunk/src/modules/pong/CMakeLists.txt	(revision 10624)
@@ -12,5 +12,5 @@
 
 ORXONOX_ADD_LIBRARY(pong
-  MODULE
+  PLUGIN
   FIND_HEADER_FILES
   LINK_LIBRARIES
Index: code/trunk/src/modules/pong/PongCenterpoint.cc
===================================================================
--- code/trunk/src/modules/pong/PongCenterpoint.cc	(revision 10622)
+++ code/trunk/src/modules/pong/PongCenterpoint.cc	(revision 10624)
@@ -80,16 +80,4 @@
     /**
     @brief
-        Is called when the gametype has changed.
-    */
-    void PongCenterpoint::changedGametype()
-    {
-        SUPER(PongCenterpoint, changedGametype);
-
-        // Check, whether it's still Pong.
-        this->checkGametype();
-    }
-
-    /**
-    @brief
         Checks whether the gametype is Pong and if it is, sets its centerpoint.
     */
@@ -98,5 +86,5 @@
         if (this->getGametype() != NULL && this->getGametype()->isA(Class(Pong)))
         {
-            Pong* pongGametype = orxonox_cast<Pong*>(this->getGametype().get());
+            Pong* pongGametype = orxonox_cast<Pong*>(this->getGametype());
             pongGametype->setCenterpoint(this);
         }
Index: code/trunk/src/modules/pong/PongCenterpoint.h
===================================================================
--- code/trunk/src/modules/pong/PongCenterpoint.h	(revision 10622)
+++ code/trunk/src/modules/pong/PongCenterpoint.h	(revision 10624)
@@ -126,6 +126,4 @@
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method to create a PongCenterpoint through XML.
 
-            virtual void changedGametype(); //!< Is called when the gametype has changed.
-
             /**
             @brief Set the template for the ball. (e.g. to attach the model of the ball, but also to attach an EventListener to it to detect, when it hits the boundaries, and e.g. display some ParticleEffets, when it does.)
Index: code/trunk/src/modules/pong/PongScore.cc
===================================================================
--- code/trunk/src/modules/pong/PongScore.cc	(revision 10622)
+++ code/trunk/src/modules/pong/PongScore.cc	(revision 10624)
@@ -170,5 +170,5 @@
 
         if (this->getOwner() != NULL && this->getOwner()->getGametype())
-            this->owner_ = orxonox_cast<Pong*>(this->getOwner()->getGametype().get());
+            this->owner_ = orxonox_cast<Pong*>(this->getOwner()->getGametype());
         else
             this->owner_ = 0;
Index: code/trunk/src/modules/questsystem/Quest.cc
===================================================================
--- code/trunk/src/modules/questsystem/Quest.cc	(revision 10622)
+++ code/trunk/src/modules/questsystem/Quest.cc	(revision 10624)
@@ -45,5 +45,5 @@
 namespace orxonox
 {
-    RegisterAbstractClass(Quest).inheritsFrom(Class(QuestItem));
+    RegisterAbstractClass(Quest).inheritsFrom<QuestItem>();
 
     /**
Index: code/trunk/src/modules/questsystem/QuestEffect.cc
===================================================================
--- code/trunk/src/modules/questsystem/QuestEffect.cc	(revision 10622)
+++ code/trunk/src/modules/questsystem/QuestEffect.cc	(revision 10624)
@@ -37,5 +37,5 @@
 namespace orxonox
 {
-    RegisterAbstractClass(QuestEffect).inheritsFrom(Class(BaseObject));
+    RegisterAbstractClass(QuestEffect).inheritsFrom<BaseObject>();
 
     /**
Index: code/trunk/src/modules/questsystem/QuestManager.cc
===================================================================
--- code/trunk/src/modules/questsystem/QuestManager.cc	(revision 10622)
+++ code/trunk/src/modules/questsystem/QuestManager.cc	(revision 10624)
@@ -36,5 +36,5 @@
 #include "util/Exception.h"
 #include "util/OrxAssert.h"
-#include "util/ScopedSingletonManager.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 #include "core/command/ConsoleCommand.h"
 #include "core/GUIManager.h"
@@ -49,5 +49,5 @@
 namespace orxonox
 {
-    ManageScopedSingleton(QuestManager, ScopeID::Root, false);
+    ManageScopedSingleton(QuestManager, ScopeID::ROOT, false);
 
     /**
Index: code/trunk/src/modules/questsystem/effects/ChangeQuestStatus.cc
===================================================================
--- code/trunk/src/modules/questsystem/effects/ChangeQuestStatus.cc	(revision 10622)
+++ code/trunk/src/modules/questsystem/effects/ChangeQuestStatus.cc	(revision 10624)
@@ -42,5 +42,5 @@
 namespace orxonox
 {
-    RegisterAbstractClass(ChangeQuestStatus).inheritsFrom(Class(QuestEffect));
+    RegisterAbstractClass(ChangeQuestStatus).inheritsFrom<QuestEffect>();
 
     /**
Index: code/trunk/src/modules/tetris/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/tetris/CMakeLists.txt	(revision 10622)
+++ code/trunk/src/modules/tetris/CMakeLists.txt	(revision 10624)
@@ -8,5 +8,5 @@
 
 ORXONOX_ADD_LIBRARY(tetris
-  MODULE
+  PLUGIN
   FIND_HEADER_FILES
   LINK_LIBRARIES
Index: code/trunk/src/modules/tetris/Tetris.cc
===================================================================
--- code/trunk/src/modules/tetris/Tetris.cc	(revision 10622)
+++ code/trunk/src/modules/tetris/Tetris.cc	(revision 10624)
@@ -104,5 +104,5 @@
         }
 
-        for (std::list<SmartPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
+        for (std::list<StrongPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
             (*it)->destroy();
         this->stones_.clear();
@@ -136,5 +136,5 @@
             return false;
 
-        for(std::list<SmartPtr<TetrisStone> >::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
+        for(std::list<StrongPtr<TetrisStone> >::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
         {
             const Vector3& currentStonePosition = (*it)->getPosition(); //!< Saves the position of the currentStone
@@ -192,5 +192,5 @@
 
         // check for collisions with all stones
-        for(std::list<SmartPtr<TetrisStone> >::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
+        for(std::list<StrongPtr<TetrisStone> >::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
         {
             //Vector3 currentStonePosition = rotateVector((*it)->getPosition(), this->activeBrick_->getRotationCount());
@@ -469,7 +469,7 @@
         {
             stonesPerRow = 0;
-            for(std::list<SmartPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); )
-            {
-                std::list<SmartPtr<TetrisStone> >::iterator it_temp = it++;
+            for(std::list<StrongPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); )
+            {
+                std::list<StrongPtr<TetrisStone> >::iterator it_temp = it++;
                 correctPosition = static_cast<unsigned int>(((*it_temp)->getPosition().y - 5)/this->center_->getStoneSize());
                 if(correctPosition == row)
@@ -491,5 +491,5 @@
     void Tetris::clearRow(unsigned int row)
     {// clear the full row
-        for(std::list<SmartPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); )
+        for(std::list<StrongPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); )
         {
             if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) == row)
@@ -502,5 +502,5 @@
         }
       // adjust height of stones above the deleted row //TODO: check if this could be a source of a bug.
-        for(std::list<SmartPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
+        for(std::list<StrongPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
         {
             if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) > row)
Index: code/trunk/src/modules/tetris/Tetris.h
===================================================================
--- code/trunk/src/modules/tetris/Tetris.h	(revision 10622)
+++ code/trunk/src/modules/tetris/Tetris.h	(revision 10624)
@@ -69,5 +69,5 @@
 
             PlayerInfo* getPlayer(void) const; //!< Get the player.
-            WeakPtr<TetrisCenterpoint> getCenterpoint(void)
+            TetrisCenterpoint* getCenterpoint(void)
                 { return this->center_; }
 
@@ -93,5 +93,5 @@
 
             WeakPtr<TetrisCenterpoint> center_; //!< The playing field.
-            std::list<SmartPtr<TetrisStone> > stones_; //!< A list of all stones in play.
+            std::list<StrongPtr<TetrisStone> > stones_; //!< A list of all stones in play.
             WeakPtr<TetrisBrick> activeBrick_;
             WeakPtr<TetrisBrick> futureBrick_;
Index: code/trunk/src/modules/tetris/TetrisBrick.cc
===================================================================
--- code/trunk/src/modules/tetris/TetrisBrick.cc	(revision 10622)
+++ code/trunk/src/modules/tetris/TetrisBrick.cc	(revision 10624)
@@ -169,5 +169,5 @@
         if (this->getGametype() != NULL && this->getGametype()->isA(Class(Tetris)))
         {
-            Tetris* tetrisGametype = orxonox_cast<Tetris*>(this->getGametype().get());
+            Tetris* tetrisGametype = orxonox_cast<Tetris*>(this->getGametype());
             return tetrisGametype;
         }
Index: code/trunk/src/modules/tetris/TetrisCenterpoint.cc
===================================================================
--- code/trunk/src/modules/tetris/TetrisCenterpoint.cc	(revision 10622)
+++ code/trunk/src/modules/tetris/TetrisCenterpoint.cc	(revision 10624)
@@ -80,16 +80,4 @@
     /**
     @brief
-        Is called when the gametype has changed.
-    */
-    void TetrisCenterpoint::changedGametype()
-    {
-        SUPER(TetrisCenterpoint, changedGametype);
-
-        // Check, whether it's still Tetris.
-        this->checkGametype();
-    }
-
-    /**
-    @brief
         Checks whether the gametype is Tetris and if it is, sets its centerpoint.
     */
@@ -98,5 +86,5 @@
         if (this->getGametype() != NULL && this->getGametype()->isA(Class(Tetris)))
         {
-            Tetris* tetrisGametype = orxonox_cast<Tetris*>(this->getGametype().get());
+            Tetris* tetrisGametype = orxonox_cast<Tetris*>(this->getGametype());
             tetrisGametype->setCenterpoint(this);
         }
Index: code/trunk/src/modules/tetris/TetrisCenterpoint.h
===================================================================
--- code/trunk/src/modules/tetris/TetrisCenterpoint.h	(revision 10622)
+++ code/trunk/src/modules/tetris/TetrisCenterpoint.h	(revision 10624)
@@ -64,6 +64,4 @@
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method to create a TetrisCenterpoint through XML.
 
-            virtual void changedGametype(); //!< Is called when the gametype has changed.
-            
             /**
             @brief Set the width of the playing field.
Index: code/trunk/src/modules/tetris/TetrisScore.cc
===================================================================
--- code/trunk/src/modules/tetris/TetrisScore.cc	(revision 10622)
+++ code/trunk/src/modules/tetris/TetrisScore.cc	(revision 10624)
@@ -118,5 +118,5 @@
 
         if (this->getOwner() != NULL && this->getOwner()->getGametype())
-            this->owner_ = orxonox_cast<Tetris*>(this->getOwner()->getGametype().get());
+            this->owner_ = orxonox_cast<Tetris*>(this->getOwner()->getGametype());
         else
             this->owner_ = 0;
Index: code/trunk/src/modules/towerdefense/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/towerdefense/CMakeLists.txt	(revision 10622)
+++ code/trunk/src/modules/towerdefense/CMakeLists.txt	(revision 10624)
@@ -11,5 +11,5 @@
 
 ORXONOX_ADD_LIBRARY(towerdefense
-  MODULE
+  PLUGIN
   FIND_HEADER_FILES
   LINK_LIBRARIES
Index: code/trunk/src/modules/towerdefense/TDCoordinate.h
===================================================================
--- code/trunk/src/modules/towerdefense/TDCoordinate.h	(revision 10622)
+++ code/trunk/src/modules/towerdefense/TDCoordinate.h	(revision 10624)
@@ -2,5 +2,4 @@
 #define _TDCoordinate_H__
 
-#include "core/CoreIncludes.h"
 #include "TDCoordinate.h"
 //#include "towerdefense/TowerDefense.h"
@@ -13,5 +12,5 @@
 //Class to save the Coordinates in a class instead of struct
 //Convert 2d coordinates to 3d in order to set waypoints
-    class _TowerDefenseExport TDCoordinate : public OrxonoxClass
+    class _TowerDefenseExport TDCoordinate
     {
         public:
Index: code/trunk/src/modules/towerdefense/TowerDefense.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefense.cc	(revision 10622)
+++ code/trunk/src/modules/towerdefense/TowerDefense.cc	(revision 10624)
@@ -85,5 +85,5 @@
 #include "core/CoreIncludes.h"
 /* Part of a temporary hack to allow the player to add towers */
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include <cmath>
 
Index: code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.cc	(revision 10622)
+++ code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.cc	(revision 10624)
@@ -83,16 +83,4 @@
     /**
     @brief
-        Is called when the gametype has changed.
-    */
-    void TowerDefenseCenterpoint::changedGametype()
-    {
-        SUPER(TowerDefenseCenterpoint, changedGametype);
-
-        // Check, whether it's still TowerDefense.
-        this->checkGametype();
-    }
-
-    /**
-    @brief
         Checks whether the gametype is TowerDefense and if it is, sets its centerpoint.
     */
@@ -102,5 +90,5 @@
         {
             // Sets the centerpoint of the gametype. The gametype uses this to later spawn in towers, he needs the tower template stored in the center point
-            TowerDefense* towerDefenseGametype = orxonox_cast<TowerDefense*>(this->getGametype().get());
+            TowerDefense* towerDefenseGametype = orxonox_cast<TowerDefense*>(this->getGametype());
             towerDefenseGametype->setCenterpoint(this);
         }
Index: code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.h
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.h	(revision 10622)
+++ code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.h	(revision 10624)
@@ -53,5 +53,4 @@
 
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-            virtual void changedGametype();
 
             /**
Index: code/trunk/src/modules/towerdefense/TowerDefenseEnemy.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseEnemy.cc	(revision 10622)
+++ code/trunk/src/modules/towerdefense/TowerDefenseEnemy.cc	(revision 10624)
@@ -29,5 +29,5 @@
         this->setCollisionType(WorldEntity::Dynamic);
         //needed to keep track of the PlayerStats coded in TowerDefense.h
-        this->td = orxonox_cast<TowerDefense*>(this->getGametype().get());
+        this->td = orxonox_cast<TowerDefense*>(this->getGametype());
         once_=false;
 
@@ -53,5 +53,5 @@
     }
 
-    WeakPtr<TowerDefense> TowerDefenseEnemy::getGame()
+    TowerDefense* TowerDefenseEnemy::getGame()
     {
         if (game == NULL)
Index: code/trunk/src/modules/towerdefense/TowerDefenseEnemy.h
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseEnemy.h	(revision 10622)
+++ code/trunk/src/modules/towerdefense/TowerDefenseEnemy.h	(revision 10624)
@@ -47,5 +47,5 @@
 
     private:
-        WeakPtr<TowerDefense> getGame();
+        TowerDefense* getGame();
         WeakPtr<TowerDefense> game;
         TowerDefense* td;
Index: code/trunk/src/modules/towerdefense/TowerDefenseHUDController.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseHUDController.cc	(revision 10622)
+++ code/trunk/src/modules/towerdefense/TowerDefenseHUDController.cc	(revision 10624)
@@ -80,5 +80,5 @@
             if (this->getOwner() && this->getOwner()->getGametype())
                     {
-                        this->td = orxonox_cast<TowerDefense*>(this->getOwner()->getGametype().get());
+                        this->td = orxonox_cast<TowerDefense*>(this->getOwner()->getGametype());
                     }
                     else
Index: code/trunk/src/modules/weapons/projectiles/ParticleProjectile.cc
===================================================================
--- code/trunk/src/modules/weapons/projectiles/ParticleProjectile.cc	(revision 10622)
+++ code/trunk/src/modules/weapons/projectiles/ParticleProjectile.cc	(revision 10624)
@@ -54,5 +54,6 @@
             this->particles_->setKeepParticlesInLocalSpace(0);
 
-            this->particles_->getAllEmitters()->setDirection(-WorldEntity::FRONT);
+            for (unsigned int i = 0; i < this->particles_->getNumEmitters(); ++i)
+                this->particles_->getEmitter(i)->setDirection(-WorldEntity::FRONT);
         }
         else
Index: code/trunk/src/orxonox/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/CMakeLists.txt	(revision 10622)
+++ code/trunk/src/orxonox/CMakeLists.txt	(revision 10624)
@@ -29,7 +29,5 @@
   Main.cc
   MoodManager.cc
-  PawnManager.cc
   PlayerManager.cc
-  ShipPartManager.cc
   Radar.cc
 #  Test.cc
Index: code/trunk/src/orxonox/CameraManager.cc
===================================================================
--- code/trunk/src/orxonox/CameraManager.cc	(revision 10622)
+++ code/trunk/src/orxonox/CameraManager.cc	(revision 10624)
@@ -35,8 +35,8 @@
 #include <OgreCompositorManager.h>
 
-#include "util/ScopedSingletonManager.h"
 #include "core/GameMode.h"
 #include "core/GraphicsManager.h"
 #include "core/object/ObjectList.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 #include "tools/Shader.h"
 #include "graphics/Camera.h"
@@ -44,5 +44,5 @@
 namespace orxonox
 {
-    ManageScopedSingleton(CameraManager, ScopeID::Graphics, false);
+    ManageScopedSingleton(CameraManager, ScopeID::GRAPHICS, false);
 
     CameraManager::CameraManager()
Index: code/trunk/src/orxonox/Level.cc
===================================================================
--- code/trunk/src/orxonox/Level.cc	(revision 10622)
+++ code/trunk/src/orxonox/Level.cc	(revision 10624)
@@ -35,4 +35,5 @@
 #include "core/XMLFile.h"
 #include "core/XMLPort.h"
+#include "core/module/PluginReference.h"
 
 #include "infos/PlayerInfo.h"
@@ -49,4 +50,5 @@
         RegisterObject(Level);
 
+        this->setLevel(WeakPtr<Level>(this)); // store a weak-pointer to itself (a strong-pointer would create a recursive dependency)
 
         this->registerVariables();
@@ -63,5 +65,7 @@
 
             if (this->xmlfile_)
-                Loader::unload(this->xmlfile_);
+                Loader::getInstance().unload(this->xmlfile_);
+
+            this->unloadPlugins();
         }
     }
@@ -71,4 +75,5 @@
         SUPER(Level, XMLPort, xmlelement, mode);
 
+        XMLPortParam(Level, "plugins",  setPluginsString,  getPluginsString,  xmlelement, mode);
         XMLPortParam(Level, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype");
 
@@ -95,5 +100,5 @@
         this->xmlfile_ = new XMLFile(mask, this->xmlfilename_);
 
-        Loader::open(this->xmlfile_);
+        Loader::getInstance().load(this->xmlfile_);
     }
 
@@ -105,4 +110,31 @@
             Template::getTemplate(*it)->applyOn(this);
         }
+    }
+
+    void Level::setPluginsString(const std::string& pluginsString)
+    {
+        // unload old plugins
+        this->unloadPlugins();
+
+        // load new plugins
+        this->pluginsString_ = pluginsString;
+        SubString tokens(pluginsString, ",");
+        for (size_t i = 0; i < tokens.size(); ++i)
+            this->plugins_.push_back(new PluginReference(tokens[i]));
+    }
+
+    void Level::unloadPlugins()
+    {
+        // use destroyLater() - this ensures that plugins are not unloaded too early.
+        // Note: When a level gets unloaded, the Level object is usually the last object that gets destroyed. This is because all other
+        //       objects inside a level have a StrongPtr (in BaseObject) that references the Level object. This means that the Level
+        //       object is only destroyed, when all StrongPtrs that pointed to it were destroyed. But at the time when the last StrongPtr
+        //       is destroyed, the other object is not yet fully destroyed because the StrongPtr is destroyed in ~BaseObject (and this
+        //       means that e.g. ~Identifiable was not yet called for this object). This means that technically there are still other
+        //       objects alive when ~Level is called. This is the reason why we cannot directly destroy() the Plugins - instead we need
+        //       to call destroyLater() to ensure that no instances from this plugin exist anymore.
+        for (std::list<PluginReference*>::iterator it = this->plugins_.begin(); it != this->plugins_.end(); ++it)
+            (*it)->destroyLater();
+        this->plugins_.clear();
     }
 
@@ -121,8 +153,9 @@
 
         Gametype* rootgametype = orxonox_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);
+
+        // store a weak-pointer to the gametype to avoid a circular dependency between this level and the gametype (which has a strong-reference on this level)
+        this->setGametype(WeakPtr<Gametype>(rootgametype));
+
+        rootgametype->init(); // call init() AFTER the gametype was set
 
         if (LevelManager::exists())
@@ -134,6 +167,4 @@
     {
         this->objects_.push_back(object);
-        object->setGametype(this->getGametype());
-        object->setLevel(this);
     }
 
@@ -170,5 +201,5 @@
     {
         orxout(internal_info) << "player entered level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << endl;
-        player->setGametype(this->getGametype());
+        player->switchGametype(this->getGametype());
     }
 
@@ -176,5 +207,5 @@
     {
         orxout(internal_info) << "player left level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << endl;
-        player->setGametype(0);
+        player->switchGametype(0);
     }
 }
Index: code/trunk/src/orxonox/Level.h
===================================================================
--- code/trunk/src/orxonox/Level.h	(revision 10622)
+++ code/trunk/src/orxonox/Level.h	(revision 10624)
@@ -65,4 +65,10 @@
 //            MeshLodInformation* getLodInfo(unsigned int index) const;
 
+            void setPluginsString(const std::string& pluginsString);
+            inline const std::string& getPluginsString() const
+                { return this->pluginsString_; }
+
+            void unloadPlugins();
+
             void setGametypeString(const std::string& gametype);
             inline const std::string& getGametypeString() const
@@ -70,4 +76,7 @@
 
             void networkcallback_applyXMLFile();
+
+            std::string                    pluginsString_;
+            std::list<PluginReference*>    plugins_;
 
             std::string                    gametype_;
Index: code/trunk/src/orxonox/LevelManager.cc
===================================================================
--- code/trunk/src/orxonox/LevelManager.cc	(revision 10622)
+++ code/trunk/src/orxonox/LevelManager.cc	(revision 10624)
@@ -36,6 +36,6 @@
 #include <map>
 
-#include "util/ScopedSingletonManager.h"
-#include "core/config/CommandLineParser.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
+#include "core/commandline/CommandLineIncludes.h"
 #include "core/config/ConfigValueIncludes.h"
 #include "core/CoreIncludes.h"
@@ -51,5 +51,7 @@
     SetCommandLineArgument(level, "").shortcut("l").information("Default level file (overrides LevelManager::defaultLevelName_ configValue)");
 
-    ManageScopedSingleton(LevelManager, ScopeID::Root, false);
+    ManageScopedSingleton(LevelManager, ScopeID::ROOT, false);
+
+    RegisterAbstractClass(LevelManager).inheritsFrom<Configurable>();
 
     /**
@@ -274,5 +276,5 @@
                 // Load the LevelInfo object from the level file.
                 XMLFile file = XMLFile(*it);
-                Loader::load(&file, mask, false, true);
+                Loader::getInstance().load(&file, mask, false, true);
 
                 // Find the LevelInfo object we've just loaded (if there was one)
@@ -282,5 +284,5 @@
 
                 // We don't need the loaded stuff anymore
-                Loader::unload(&file);
+                Loader::getInstance().unload(&file);
 
                 if(info == NULL)
Index: code/trunk/src/orxonox/Main.cc
===================================================================
--- code/trunk/src/orxonox/Main.cc	(revision 10622)
+++ code/trunk/src/orxonox/Main.cc	(revision 10624)
@@ -36,5 +36,5 @@
 #include "Main.h"
 
-#include "core/config/CommandLineParser.h"
+#include "core/commandline/CommandLineIncludes.h"
 #include "core/Game.h"
 #include "core/LuaState.h"
Index: code/trunk/src/orxonox/MoodManager.cc
===================================================================
--- code/trunk/src/orxonox/MoodManager.cc	(revision 10622)
+++ code/trunk/src/orxonox/MoodManager.cc	(revision 10624)
@@ -29,5 +29,5 @@
 #include "MoodManager.h"
 
-#include "util/ScopedSingletonManager.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 #include "core/config/ConfigValueIncludes.h"
 #include "core/CoreIncludes.h"
@@ -36,8 +36,11 @@
 namespace orxonox
 {
-    ManageScopedSingleton(MoodManager, ScopeID::Root, false);
+    ManageScopedSingleton(MoodManager, ScopeID::ROOT, false);
 
     // Note: I'm (Kevin Young) not entirely sure whether that's good code style:
     const std::string MoodManager::defaultMood_ = "default";
+
+    RegisterAbstractClass(MoodListener).inheritsFrom<OrxonoxInterface>();
+    RegisterAbstractClass(MoodManager).inheritsFrom<Configurable>();
 
     MoodManager::MoodManager()
Index: code/trunk/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/trunk/src/orxonox/OrxonoxPrereqs.h	(revision 10622)
+++ code/trunk/src/orxonox/OrxonoxPrereqs.h	(revision 10624)
@@ -73,5 +73,4 @@
     class LevelInfoItem;
     class LevelManager;
-    class PawnManager;
     class PlayerManager;
     class Radar;
Index: code/trunk/src/orxonox/PawnManager.cc
===================================================================
--- code/trunk/src/orxonox/PawnManager.cc	(revision 10622)
+++ 	(revision )
@@ -1,61 +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 "PawnManager.h"
-
-#include "util/ScopedSingletonManager.h"
-#include "core/CoreIncludes.h"
-#include "worldentities/pawns/Pawn.h"
-
-namespace orxonox
-{
-    ManageScopedSingleton(PawnManager, ScopeID::Root, false);
-
-    PawnManager::PawnManager()
-    {
-        RegisterObject(PawnManager);
-    }
-
-    PawnManager::~PawnManager()
-    {
-        // Be sure to delete all the pawns
-        for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); )
-            (it++)->destroy();
-    }
-
-    void PawnManager::preUpdate(const Clock& time)
-    {
-        for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); )
-        {
-            if (!it->isAlive())
-                (it++)->destroy();
-            else
-                ++it;
-        }
-    }
-}
Index: code/trunk/src/orxonox/PawnManager.h
===================================================================
--- code/trunk/src/orxonox/PawnManager.h	(revision 10622)
+++ 	(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:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _PawnManager_H__
-#define _PawnManager_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "util/Singleton.h"
-#include "tools/interfaces/Tickable.h"
-
-namespace orxonox
-{
-    class _OrxonoxExport PawnManager : public Singleton<PawnManager>, public Tickable
-    {
-            friend class Singleton<PawnManager>;
-        public:
-            PawnManager();
-            virtual ~PawnManager();
-
-            virtual void preUpdate(const Clock& time);
-
-        private:
-
-            static PawnManager* singletonPtr_s;
-    };
-}
-
-#endif /* _PawnManager_H__ */
Index: code/trunk/src/orxonox/PlayerManager.cc
===================================================================
--- code/trunk/src/orxonox/PlayerManager.cc	(revision 10622)
+++ code/trunk/src/orxonox/PlayerManager.cc	(revision 10624)
@@ -31,5 +31,5 @@
 #include "core/CoreIncludes.h"
 #include "core/GameMode.h"
-#include "util/ScopedSingletonManager.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 
 #include "Level.h"
@@ -39,5 +39,7 @@
 namespace orxonox
 {
-    ManageScopedSingleton(PlayerManager, ScopeID::Root, false);
+    ManageScopedSingleton(PlayerManager, ScopeID::ROOT, false);
+
+    RegisterAbstractClass(PlayerManager).inheritsFrom<ClientConnectionListener>();
 
     PlayerManager::PlayerManager()
Index: code/trunk/src/orxonox/Radar.cc
===================================================================
--- code/trunk/src/orxonox/Radar.cc	(revision 10622)
+++ code/trunk/src/orxonox/Radar.cc	(revision 10624)
@@ -37,4 +37,5 @@
 
 //#include "util/Math.h"
+#include "core/CoreIncludes.h"
 #include "core/object/ObjectList.h"
 #include "core/command/ConsoleCommand.h"
@@ -45,4 +46,5 @@
 namespace orxonox
 {
+    RegisterAbstractClass(Radar).inheritsFrom<Tickable>();
 
     Radar::Radar()
Index: code/trunk/src/orxonox/Scene.cc
===================================================================
--- code/trunk/src/orxonox/Scene.cc	(revision 10622)
+++ code/trunk/src/orxonox/Scene.cc	(revision 10624)
@@ -44,5 +44,5 @@
 #include "core/GUIManager.h"
 #include "core/XMLPort.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "tools/BulletConversions.h"
 #include "tools/BulletDebugDrawer.h"
@@ -62,9 +62,11 @@
         RegisterObject(Scene);
 
-        this->setScene(SmartPtr<Scene>(this, false), OBJECTID_UNKNOWN);
+        this->setScene(WeakPtr<Scene>(this), this->getObjectID()); // store a weak-pointer to itself (a strong-pointer would create a recursive dependency)
+
         this->bShadows_ = true;
         this->bDebugDrawPhysics_ = false;
         this->debugDrawer_ = NULL;
         this->soundReferenceDistance_ = 20.0;
+        this->bIsUpdatingPhysics_ = false;
 
         if (GameMode::showsGraphics())
@@ -141,5 +143,4 @@
         registerVariable(this->bHasPhysics_,        VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_hasPhysics));
         registerVariable(this->bShadows_,           VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyShadows));
-        registerVariable(this->getLevel(),          VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::changedLevel));
     }
 
@@ -266,8 +267,10 @@
             // Note: 60 means that Bullet will do physics correctly down to 1 frames per seconds.
             //       Under that mark, the simulation will "loose time" and get unusable.
-            physicalWorld_->stepSimulation(dt, 60);
+            this->bIsUpdatingPhysics_ = true;
+            this->physicalWorld_->stepSimulation(dt, 60);
+            this->bIsUpdatingPhysics_ = false;
 
             if (this->bDebugDrawPhysics_)
-                physicalWorld_->debugDrawWorld();
+                this->physicalWorld_->debugDrawWorld();
         }
     }
@@ -313,5 +316,4 @@
     {
         this->objects_.push_back(object);
-        object->setScene(this, this->getObjectID());
     }
 
@@ -363,6 +365,6 @@
     {
         // get the WorldEntity pointers
-        SmartPtr<WorldEntity> object0 = static_cast<WorldEntity*>(colObj0->getUserPointer());
-        SmartPtr<WorldEntity> object1 = static_cast<WorldEntity*>(colObj1->getUserPointer());
+        StrongPtr<WorldEntity> object0 = static_cast<WorldEntity*>(colObj0->getUserPointer());
+        StrongPtr<WorldEntity> object1 = static_cast<WorldEntity*>(colObj1->getUserPointer());
 
         // get the CollisionShape pointers
Index: code/trunk/src/orxonox/Scene.h
===================================================================
--- code/trunk/src/orxonox/Scene.h	(revision 10622)
+++ code/trunk/src/orxonox/Scene.h	(revision 10624)
@@ -110,5 +110,5 @@
 
         public:
-            inline bool hasPhysics()
+            inline bool hasPhysics() const
                 { return this->physicalWorld_ != 0; }
             void setPhysicalWorld(bool wantsPhysics);
@@ -128,4 +128,7 @@
             void addPhysicalObject(WorldEntity* object);
             void removePhysicalObject(WorldEntity* object);
+
+            inline bool isUpdatingPhysics() const
+                { return this->bIsUpdatingPhysics_; }
 
             void setDebugDrawPhysics(bool bDraw, bool bFill, float fillAlpha);
@@ -163,4 +166,5 @@
             BulletDebugDrawer*                   debugDrawer_;
             bool                                 bDebugDrawPhysics_;
+            bool                                 bIsUpdatingPhysics_;
     };
 }
Index: code/trunk/src/orxonox/ShipPartManager.cc
===================================================================
--- code/trunk/src/orxonox/ShipPartManager.cc	(revision 10622)
+++ 	(revision )
@@ -1,61 +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 "ShipPartManager.h"
-
-#include "util/ScopedSingletonManager.h"
-#include "core/CoreIncludes.h"
-#include "items/ShipPart.h"
-
-namespace orxonox
-{
-    ManageScopedSingleton(ShipPartManager, ScopeID::Root, false);
-
-    ShipPartManager::ShipPartManager()
-    {
-        RegisterObject(ShipPartManager);
-    }
-
-    ShipPartManager::~ShipPartManager()
-    {
-        // Be sure to delete all the pawns
-        for (ObjectList<ShipPart>::iterator it = ObjectList<ShipPart>::begin(); it != ObjectList<ShipPart>::end(); )
-            (it++)->death();
-    }
-
-    void ShipPartManager::preUpdate(const Clock& time)
-    {
-        for (ObjectList<ShipPart>::iterator it = ObjectList<ShipPart>::begin(); it != ObjectList<ShipPart>::end(); )
-        {
-            if (!it->isAlive())
-                (it++)->death();
-            else
-                ++it;
-        }
-    }
-}
Index: code/trunk/src/orxonox/ShipPartManager.h
===================================================================
--- code/trunk/src/orxonox/ShipPartManager.h	(revision 10622)
+++ 	(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:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _ShipPartManager_H__
-#define _ShipPartManager_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "util/Singleton.h"
-#include "tools/interfaces/Tickable.h"
-
-namespace orxonox
-{
-    class _OrxonoxExport ShipPartManager : public Singleton<ShipPartManager>, public Tickable
-    {
-            friend class Singleton<ShipPartManager>;
-        public:
-            ShipPartManager();
-            virtual ~ShipPartManager();
-
-            virtual void preUpdate(const Clock& time);
-
-        private:
-
-            static ShipPartManager* singletonPtr_s;
-    };
-}
-
-#endif /* _ShipPartManager_H__ */
Index: code/trunk/src/orxonox/Test.cc
===================================================================
--- code/trunk/src/orxonox/Test.cc	(revision 10622)
+++ code/trunk/src/orxonox/Test.cc	(revision 10624)
@@ -29,6 +29,6 @@
 #include "core/CoreIncludes.h"
 #include "core/config/ConfigValueIncludes.h"
-#include "core/command/ConsoleCommand.h"
-#include "network/NetworkFunction.h"
+#include "core/command/ConsoleCommandIncludes.h"
+#include "network/NetworkFunctionIncludes.h"
 #include "Test.h"
 #include "util/MultiType.h"
@@ -105,11 +105,11 @@
   void Test::call(unsigned int clientID)
     {
-        callStaticNetworkFunction( &Test::printV1, clientID );
-        callStaticNetworkFunction( &Test::printV1, clientID );
+        callStaticNetworkFunction(&Test::printV1, clientID );
+        callStaticNetworkFunction(&Test::printV1, clientID );
     }
 
     void Test::call2(unsigned int clientID, std::string s1, std::string s2, std::string s3, std::string s4)
     {
-        callMemberNetworkFunction( Test, printBlaBla, this->getObjectID(), clientID, s1, s2, s3, s4, s4 );
+        callMemberNetworkFunction( &Test::printBlaBla, this->getObjectID(), clientID, s1, s2, s3, s4, s4 );
     }
 
@@ -130,5 +130,5 @@
     //     if(!Core::isMaster())
     //       call2(0, "bal", "a", "n", "ce");
-    //       callMemberNetworkFunction( Test, checkU1, this->getObjectID(), 0 );
+    //       callMemberNetworkFunction( &Test::checkU1, this->getObjectID(), 0 );
     }
 
Index: code/trunk/src/orxonox/chat/ChatHistory.cc
===================================================================
--- code/trunk/src/orxonox/chat/ChatHistory.cc	(revision 10622)
+++ code/trunk/src/orxonox/chat/ChatHistory.cc	(revision 10624)
@@ -28,5 +28,6 @@
 
 #include "ChatHistory.h"
-#include "util/ScopedSingletonManager.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
+#include "core/ConfigurablePaths.h"
 
 #ifndef CHATTEST
@@ -34,5 +35,8 @@
 {
   /* singleton */
-  ManageScopedSingleton( ChatHistory, ScopeID::Root, false );
+  ManageScopedSingleton( ChatHistory, ScopeID::ROOT, false );
+
+  RegisterAbstractClass(ChatHistory).inheritsFrom<ChatListener>();
+
 #endif
 
@@ -118,5 +122,5 @@
      */
 #ifndef CHATTEST
-    this->hist_logfile.open( (PathConfig::getInstance().getLogPathString() +
+    this->hist_logfile.open( (ConfigurablePaths::getLogPathString() +
       "chatlog.log").c_str(),
       std::fstream::out | std::fstream::app );
Index: code/trunk/src/orxonox/chat/ChatHistory.h
===================================================================
--- code/trunk/src/orxonox/chat/ChatHistory.h	(revision 10622)
+++ code/trunk/src/orxonox/chat/ChatHistory.h	(revision 10624)
@@ -41,5 +41,4 @@
 #include "util/Singleton.h"
 #include "core/BaseObject.h"
-#include "core/PathConfig.h"
 #include "chat/ChatListener.h"
 #include "infos/PlayerInfo.h"
Index: code/trunk/src/orxonox/chat/ChatInputHandler.cc
===================================================================
--- code/trunk/src/orxonox/chat/ChatInputHandler.cc	(revision 10622)
+++ code/trunk/src/orxonox/chat/ChatInputHandler.cc	(revision 10624)
@@ -47,8 +47,8 @@
 #endif
 
-#include "util/ScopedSingletonManager.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 #include "core/CoreIncludes.h"
 #include "core/GUIManager.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "core/input/InputBuffer.h"
 #include "core/input/InputManager.h"
@@ -62,9 +62,11 @@
 {
   /* singleton */
-  ManageScopedSingleton( ChatInputHandler, ScopeID::Graphics, false );
+  ManageScopedSingleton( ChatInputHandler, ScopeID::GRAPHICS, false );
 
   /* add commands to console */
   SetConsoleCommand( "startchat", &ChatInputHandler::activate_static );
   SetConsoleCommand( "startchat_small", &ChatInputHandler::activate_small_static );
+
+  RegisterAbstractClass(ChatInputHandler).inheritsFrom<ChatListener>();
 
   /* constructor */
Index: code/trunk/src/orxonox/chat/ChatManager.cc
===================================================================
--- code/trunk/src/orxonox/chat/ChatManager.cc	(revision 10622)
+++ code/trunk/src/orxonox/chat/ChatManager.cc	(revision 10624)
@@ -30,7 +30,7 @@
 #include "ChatListener.h"
 
-#include "util/ScopedSingletonManager.h"
 #include "core/CoreIncludes.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "network/Host.h"
 
@@ -40,7 +40,9 @@
 namespace orxonox
 {
-    ManageScopedSingleton(ChatManager, ScopeID::Root, false);
+    ManageScopedSingleton(ChatManager, ScopeID::ROOT, false);
 
     SetConsoleCommand("chat", &ChatManager::chat).defaultValue(1, NETWORK_PEER_ID_BROADCAST);
+
+    RegisterAbstractClass(ChatManager).inheritsFrom<NetworkChatListener>();
 
     ChatManager::ChatManager()
@@ -113,5 +115,5 @@
     // ChatListener                                                         //
     //////////////////////////////////////////////////////////////////////////
-    RegisterAbstractClass(ChatListener).inheritsFrom(Class(Listable));
+    RegisterAbstractClass(ChatListener).inheritsFrom<Listable>();
 
     ChatListener::ChatListener()
Index: code/trunk/src/orxonox/collisionshapes/CollisionShape.cc
===================================================================
--- code/trunk/src/orxonox/collisionshapes/CollisionShape.cc	(revision 10622)
+++ code/trunk/src/orxonox/collisionshapes/CollisionShape.cc	(revision 10624)
@@ -41,8 +41,9 @@
 #include "CompoundCollisionShape.h"
 #include "WorldEntityCollisionShape.h"
+#include "Scene.h"
 
 namespace orxonox
 {
-    RegisterAbstractClass(CollisionShape).inheritsFrom(Class(BaseObject)).inheritsFrom(Class(Synchronisable));
+    RegisterAbstractClass(CollisionShape).inheritsFrom<BaseObject>().inheritsFrom<Synchronisable>();
 
     /**
@@ -74,6 +75,15 @@
     {
         // Detach from parent CompoundCollisionShape.
-        if (this->isInitialized() && this->parent_)
-            this->parent_->detach(this);
+        if (this->isInitialized())
+        {
+            if (this->getScene() && this->getScene()->isUpdatingPhysics())
+                orxout(internal_error) << "Don't destroy collision shapes while the physics is updated! This will lead to crashes. Try to use destroyLater() instead" << endl;
+
+            if (this->parent_)
+                this->parent_->detach(this);
+
+            if (this->collisionShape_)
+                delete this->collisionShape_;
+        }
     }
 
Index: code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.cc
===================================================================
--- code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.cc	(revision 10622)
+++ code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.cc	(revision 10624)
@@ -71,7 +71,11 @@
                 it->first->notifyDetached();
                 it->first->destroy();
+                if (this->collisionShape_ == it->second)
+                    this->collisionShape_ = NULL; // don't destroy it twice
             }
 
             delete this->compoundShape_;
+            if (this->collisionShape_ == this->compoundShape_)
+                this->collisionShape_ = NULL; // don't destroy it twice
         }
     }
Index: code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.cc
===================================================================
--- code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.cc	(revision 10622)
+++ code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.cc	(revision 10624)
@@ -37,4 +37,6 @@
 namespace orxonox
 {
+    RegisterClass(WorldEntityCollisionShape);
+
     WorldEntityCollisionShape::WorldEntityCollisionShape(Context* context) : CompoundCollisionShape(context)
     {
@@ -44,9 +46,4 @@
         // suppress synchronisation
         this->setSyncMode(ObjectDirection::None);
-    }
-
-    WorldEntityCollisionShape::~WorldEntityCollisionShape()
-    {
-        // Called always by WE destructor
     }
 
Index: code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.h
===================================================================
--- code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.h	(revision 10622)
+++ code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.h	(revision 10624)
@@ -39,5 +39,4 @@
         public:
             WorldEntityCollisionShape(Context* context);
-            virtual ~WorldEntityCollisionShape();
 
             inline void setWorldEntityOwner(WorldEntity* worldEntityOwner)
Index: code/trunk/src/orxonox/controllers/ArtificialController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/ArtificialController.cc	(revision 10622)
+++ code/trunk/src/orxonox/controllers/ArtificialController.cc	(revision 10624)
@@ -30,5 +30,5 @@
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "worldentities/pawns/Pawn.h"
 #include "worldentities/pawns/SpaceShip.h"
Index: code/trunk/src/orxonox/controllers/FormationController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/FormationController.cc	(revision 10622)
+++ code/trunk/src/orxonox/controllers/FormationController.cc	(revision 10624)
@@ -33,5 +33,5 @@
 
 #include "core/XMLPort.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 
 #include "worldentities/ControllableEntity.h"
Index: code/trunk/src/orxonox/controllers/HumanController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/HumanController.cc	(revision 10622)
+++ code/trunk/src/orxonox/controllers/HumanController.cc	(revision 10624)
@@ -30,5 +30,5 @@
 
 #include "core/CoreIncludes.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "worldentities/ControllableEntity.h"
 #include "worldentities/pawns/Pawn.h"
@@ -59,6 +59,4 @@
     SetConsoleCommand("HumanController", __CC_suicide_name,        &HumanController::suicide       ).addShortcut();
     SetConsoleCommand("HumanController", "toggleGodMode",          &HumanController::toggleGodMode ).addShortcut();
-    SetConsoleCommand("HumanController", "addBots",                &HumanController::addBots       ).addShortcut().defaultValues(1);
-    SetConsoleCommand("HumanController", "killBots",               &HumanController::killBots      ).addShortcut().defaultValues(0);
     SetConsoleCommand("HumanController", "cycleNavigationFocus",   &HumanController::cycleNavigationFocus).addShortcut();
     SetConsoleCommand("HumanController", "releaseNavigationFocus", &HumanController::releaseNavigationFocus).addShortcut();
@@ -318,16 +316,4 @@
     }
 
-    void HumanController::addBots(unsigned int amount)
-    {
-        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype())
-            HumanController::localController_s->controllableEntity_->getGametype()->addBots(amount);
-    }
-
-    void HumanController::killBots(unsigned int amount)
-    {
-        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype())
-            HumanController::localController_s->controllableEntity_->getGametype()->killBots(amount);
-    }
-
     Pawn* HumanController::getLocalControllerEntityAsPawn()
     {
Index: code/trunk/src/orxonox/controllers/HumanController.h
===================================================================
--- code/trunk/src/orxonox/controllers/HumanController.h	(revision 10622)
+++ code/trunk/src/orxonox/controllers/HumanController.h	(revision 10624)
@@ -83,7 +83,4 @@
             static void FFChangeMode();
 
-            static void addBots(unsigned int amount);
-            static void killBots(unsigned int amount = 0);
-
             static void pauseControl(); // tolua_export
             static void resumeControl(); // tolua_export
Index: code/trunk/src/orxonox/controllers/NewHumanController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/NewHumanController.cc	(revision 10622)
+++ code/trunk/src/orxonox/controllers/NewHumanController.cc	(revision 10624)
@@ -37,5 +37,5 @@
 
 #include "core/CoreIncludes.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "core/input/KeyBinder.h"
 #include "core/input/KeyBinderManager.h"
Index: code/trunk/src/orxonox/gamestates/GSClient.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSClient.cc	(revision 10622)
+++ code/trunk/src/orxonox/gamestates/GSClient.cc	(revision 10624)
@@ -30,5 +30,5 @@
 
 #include "util/Exception.h"
-#include "core/config/CommandLineParser.h"
+#include "core/commandline/CommandLineIncludes.h"
 #include "core/Game.h"
 #include "core/GameMode.h"
Index: code/trunk/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSLevel.cc	(revision 10622)
+++ code/trunk/src/orxonox/gamestates/GSLevel.cc	(revision 10624)
@@ -44,7 +44,8 @@
 #include "core/Loader.h"
 #include "core/XMLFile.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 
 #include "LevelManager.h"
+#include "Level.h"
 #include "PlayerManager.h"
 #include "GSRoot.h"
@@ -95,4 +96,6 @@
         }
 
+        this->prepareObjectTracking();
+
         if (GameMode::isMaster())
         {
@@ -128,4 +131,8 @@
         if (GameMode::isMaster())
             this->unloadLevel();
+        else
+            this->unloadLevelAsClient();
+
+        this->performObjectTracking();
 
         if (GameMode::showsGraphics())
@@ -161,23 +168,12 @@
     }
 
-    void GSLevel::loadLevel()
+    void GSLevel::prepareObjectTracking()
     {
         for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
             this->staticObjects_.insert(*it);
-
-        // call the loader
-        startFile_ = new XMLFile(LevelManager::getInstance().getDefaultLevel());
-        bool loaded = Loader::open(startFile_);
-
-        Core::getInstance().updateLastLevelTimestamp();
-        if(!loaded)
-            GSRoot::delayedStartMainMenu();
-    }
-
-    void GSLevel::unloadLevel()
-    {
-        Loader::unload(startFile_);
-        delete startFile_;
-
+    }
+
+    void GSLevel::performObjectTracking()
+    {
         orxout(internal_info) << "Remaining objects:" << endl;
         unsigned int i = 0;
@@ -187,5 +183,5 @@
             if (find == this->staticObjects_.end())
             {
-                orxout(internal_info) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << "), references: " << it->getReferenceCount() << endl;
+                orxout(internal_warning) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << "), references: " << it->getReferenceCount() << endl;
             }
         }
@@ -194,4 +190,43 @@
         else
             orxout(internal_warning) << i << " objects remaining. Try harder!" << endl;
+    }
+
+    void GSLevel::loadLevel()
+    {
+        // call the loader
+        startFile_ = new XMLFile(LevelManager::getInstance().getDefaultLevel());
+        bool loaded = Loader::getInstance().load(startFile_);
+
+        Core::getInstance().getConfig()->updateLastLevelTimestamp();
+        if(!loaded)
+            GSRoot::delayedStartMainMenu();
+    }
+
+    void GSLevel::unloadLevel()
+    {
+        Loader::getInstance().unload(startFile_);
+        delete startFile_;
+    }
+
+    /**
+     * Unloads a level when the game instance is (or was) a client in a multiplayer session.
+     * In this case, cleanup after unloading a level is done differently because certain things (e.g. the xml file) are unknown.
+     */
+    void GSLevel::unloadLevelAsClient()
+    {
+        for (ObjectList<Level>::iterator it = ObjectList<Level>::begin(); it != ObjectList<Level>::end(); )
+        {
+            StrongPtr<Level> level = *(it++); // StrongPtr prevents that the Level gets destroyed while we loop over it
+            for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(level); it != ObjectList<BaseObject>::end(level); )
+                (it++)->destroy();
+        }
+
+        for (ObjectList<Synchronisable>::iterator it = ObjectList<Synchronisable>::begin(); it != ObjectList<Synchronisable>::end(); )
+        {
+            if (it->getSyncMode() != 0x0)
+                (it++)->destroy();
+            else
+                ++it;
+        }
     }
 
@@ -252,5 +287,5 @@
     ///////////////////////////////////////////////////////////////////////////
 
-    RegisterAbstractClass(GSLevelMemento).inheritsFrom(Class(OrxonoxInterface));
+    RegisterAbstractClass(GSLevelMemento).inheritsFrom<OrxonoxInterface>();
 
     GSLevelMemento::GSLevelMemento()
Index: code/trunk/src/orxonox/gamestates/GSLevel.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSLevel.h	(revision 10622)
+++ code/trunk/src/orxonox/gamestates/GSLevel.h	(revision 10624)
@@ -53,7 +53,11 @@
         void reloadLevel();
 
-    protected:
+    private:
         void loadLevel();
         void unloadLevel();
+        void unloadLevelAsClient();
+
+        void prepareObjectTracking();
+        void performObjectTracking();
 
         InputState*              gameInputState_;          //!< input state for normal ingame playing
Index: code/trunk/src/orxonox/gamestates/GSMainMenu.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSMainMenu.cc	(revision 10622)
+++ code/trunk/src/orxonox/gamestates/GSMainMenu.cc	(revision 10624)
@@ -36,5 +36,5 @@
 #include "core/GraphicsManager.h"
 #include "core/GUIManager.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "core/input/KeyBinderManager.h"
 #include "network/Client.h"
@@ -63,4 +63,6 @@
     SetConsoleCommand(__CC_setMainMenuSoundPath_name, &GSMainMenu::setMainMenuSoundPath).hide();
 
+    RegisterAbstractClass(GSMainMenu).inheritsFrom<Configurable>();
+
     GSMainMenu::GSMainMenu(const GameStateInfo& info)
         : GameState(info)
Index: code/trunk/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSRoot.cc	(revision 10622)
+++ code/trunk/src/orxonox/gamestates/GSRoot.cc	(revision 10624)
@@ -33,6 +33,6 @@
 #include "core/Game.h"
 #include "core/GameMode.h"
-#include "core/command/ConsoleCommand.h"
-#include "network/NetworkFunction.h"
+#include "core/command/ConsoleCommandIncludes.h"
+#include "network/NetworkFunctionIncludes.h"
 #include "tools/Timer.h"
 #include "tools/interfaces/Tickable.h"
@@ -68,5 +68,4 @@
     GSRoot::~GSRoot()
     {
-        NetworkFunctionBase::destroyAllNetworkFunctions();
     }
 
Index: code/trunk/src/orxonox/gamestates/GSServer.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSServer.cc	(revision 10622)
+++ code/trunk/src/orxonox/gamestates/GSServer.cc	(revision 10624)
@@ -30,5 +30,5 @@
 
 #include "util/Output.h"
-#include "core/config/CommandLineParser.h"
+#include "core/commandline/CommandLineIncludes.h"
 #include "core/Game.h"
 #include "core/GameMode.h"
Index: code/trunk/src/orxonox/gametypes/Dynamicmatch.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/Dynamicmatch.cc	(revision 10622)
+++ code/trunk/src/orxonox/gametypes/Dynamicmatch.cc	(revision 10624)
@@ -310,10 +310,7 @@
         if (spaceship)
         {
-            WeakPtr<SpaceShip>* ptr = new WeakPtr<SpaceShip>(spaceship);
-            if(ptr == NULL)
-                return;
             spaceship->addSpeedFactor(5);
             ExecutorPtr executor = createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this));
-            executor->setDefaultValue(0, ptr);
+            executor->setDefaultValue(0, spaceship);
             new Timer(10, false, executor, true);
         }
@@ -593,11 +590,10 @@
     }
 
-    void Dynamicmatch::resetSpeedFactor(WeakPtr<SpaceShip>* ptr)// helper function
-    {
-        if (*ptr)
-        {
-            (*ptr)->addSpeedFactor(1.0f/5.0f);
-        }
-        delete ptr;
+    void Dynamicmatch::resetSpeedFactor(SpaceShip* spaceship)// helper function
+    {
+        if (spaceship)
+        {
+            spaceship->addSpeedFactor(1.0f/5.0f);
+        }
     }
 
Index: code/trunk/src/orxonox/gametypes/Dynamicmatch.h
===================================================================
--- code/trunk/src/orxonox/gametypes/Dynamicmatch.h	(revision 10622)
+++ code/trunk/src/orxonox/gametypes/Dynamicmatch.h	(revision 10624)
@@ -77,5 +77,5 @@
             virtual void rewardPig();
             void grantPigBoost(SpaceShip* spaceship); // Grant the piggy a boost.
-            void resetSpeedFactor(WeakPtr<SpaceShip>* ptr);
+            void resetSpeedFactor(SpaceShip* spaceship);
             void tick (float dt);// used to end the game
             SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
Index: code/trunk/src/orxonox/gametypes/Gametype.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/Gametype.cc	(revision 10622)
+++ code/trunk/src/orxonox/gametypes/Gametype.cc	(revision 10624)
@@ -34,5 +34,5 @@
 #include "core/config/ConfigValueIncludes.h"
 #include "core/GameMode.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "gamestates/GSLevel.h"
 
@@ -49,4 +49,10 @@
 namespace orxonox
 {
+    static const std::string __CC_addBots_name  = "addBots";
+    static const std::string __CC_killBots_name = "killBots";
+
+    SetConsoleCommand("Gametype", __CC_addBots_name,  &Gametype::addBots ).addShortcut().defaultValues(1);
+    SetConsoleCommand("Gametype", __CC_killBots_name, &Gametype::killBots).addShortcut().defaultValues(0);
+
     RegisterUnloadableClass(Gametype);
 
@@ -55,9 +61,10 @@
         RegisterObject(Gametype);
 
+        this->setGametype(WeakPtr<Gametype>(this)); // store a weak-pointer to itself (a strong-pointer would create a recursive dependency)
+
         this->gtinfo_ = new GametypeInfo(context);
 
-        this->setGametype(SmartPtr<Gametype>(this, false));
-
         this->defaultControllableEntity_ = Class(Spectator);
+        this->scoreboard_ = 0;
 
         this->bAutoStart_ = false;
@@ -74,29 +81,31 @@
         this->setConfigValues();
 
+        ModifyConsoleCommand(__CC_addBots_name).setObject(this);
+        ModifyConsoleCommand(__CC_killBots_name).setObject(this);
+    }
+
+    Gametype::~Gametype()
+    {
+        if (this->isInitialized())
+        {
+            if (this->gtinfo_)
+                this->gtinfo_->destroy();
+
+            ModifyConsoleCommand(__CC_addBots_name).setObject(NULL);
+            ModifyConsoleCommand(__CC_killBots_name).setObject(NULL);
+        }
+    }
+
+    /**
+     * @brief Initializes sub-objects of the Gametype. This must be called after the constructor.
+     * At this point, the context is expected to have the current gametype. This allows to pass the current gametype to the sub-objects via constructor.
+     */
+    void Gametype::init()
+    {
         // load the corresponding score board
         if (GameMode::showsGraphics() && !this->scoreboardTemplate_.empty())
         {
-            this->scoreboard_ = new OverlayGroup(context);
+            this->scoreboard_ = new OverlayGroup(this->getContext());
             this->scoreboard_->addTemplate(this->scoreboardTemplate_);
-            this->scoreboard_->setGametype(this);
-        }
-        else
-            this->scoreboard_ = 0;
-
-        /* HACK HACK HACK */
-        this->dedicatedAddBots_ = createConsoleCommand( "dedicatedAddBots", createExecutor( createFunctor(&Gametype::addBots, this) ) );
-        this->dedicatedKillBots_ = createConsoleCommand( "dedicatedKillBots", createExecutor( createFunctor(&Gametype::killBots, this) ) );
-        /* HACK HACK HACK */
-    }
-
-    Gametype::~Gametype()
-    {
-        if (this->isInitialized())
-        {
-            this->gtinfo_->destroy();
-            if( this->dedicatedAddBots_ )
-                delete this->dedicatedAddBots_;
-            if( this->dedicatedKillBots_ )
-                delete this->dedicatedKillBots_;
         }
     }
@@ -406,5 +415,5 @@
                     {
                         // If in developer's mode, there is no start countdown.
-                        if(Core::getInstance().inDevMode())
+                        if(Core::getInstance().getConfig()->inDevMode())
                             this->start();
                         else
Index: code/trunk/src/orxonox/gametypes/Gametype.h
===================================================================
--- code/trunk/src/orxonox/gametypes/Gametype.h	(revision 10622)
+++ code/trunk/src/orxonox/gametypes/Gametype.h	(revision 10624)
@@ -72,4 +72,6 @@
             virtual ~Gametype();
 
+            virtual void init();
+
             void setConfigValues();
 
@@ -176,5 +178,5 @@
             virtual void importMementoState(const std::vector<GSLevelMementoState*>& states);
 
-            SmartPtr<GametypeInfo> gtinfo_;
+            WeakPtr<GametypeInfo> gtinfo_;
 
             bool bAutoStart_;
@@ -199,8 +201,4 @@
             std::string scoreboardTemplate_;
 
-            /* HACK HACK HACK */
-            ConsoleCommand* dedicatedAddBots_;
-            ConsoleCommand* dedicatedKillBots_;
-            /* HACK HACK HACK */
             Timer showMenuTimer_;
     };
Index: code/trunk/src/orxonox/gametypes/Mission.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/Mission.cc	(revision 10622)
+++ code/trunk/src/orxonox/gametypes/Mission.cc	(revision 10624)
@@ -33,5 +33,5 @@
 
 #include "core/CoreIncludes.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "infos/PlayerInfo.h"
 #include "network/Host.h"
Index: code/trunk/src/orxonox/infos/GametypeInfo.cc
===================================================================
--- code/trunk/src/orxonox/infos/GametypeInfo.cc	(revision 10622)
+++ code/trunk/src/orxonox/infos/GametypeInfo.cc	(revision 10624)
@@ -37,5 +37,5 @@
 #include "core/GameMode.h"
 #include "network/Host.h"
-#include "network/NetworkFunction.h"
+#include "network/NetworkFunctionIncludes.h"
 #include "util/Convert.h"
 
@@ -369,5 +369,5 @@
                 this->changedReadyToSpawn(ready);
             else
-                callMemberNetworkFunction(GametypeInfo, changedReadyToSpawn, this->getObjectID(), player->getClientID(), ready);
+                callMemberNetworkFunction(&GametypeInfo::changedReadyToSpawn, this->getObjectID(), player->getClientID(), ready);
         }
     }
@@ -388,5 +388,5 @@
                     this->changedSpawned(spawned);
             else
-                callMemberNetworkFunction(GametypeInfo, changedSpawned, this->getObjectID(), player->getClientID(), spawned);
+                callMemberNetworkFunction(&GametypeInfo::changedSpawned, this->getObjectID(), player->getClientID(), spawned);
         }
     }
@@ -399,5 +399,5 @@
         if (GameMode::isMaster())
         {
-            callMemberNetworkFunction(GametypeInfo, dispatchAnnounceMessage, this->getObjectID(), NETWORK_PEER_ID_BROADCAST, message);
+            callMemberNetworkFunction(&GametypeInfo::dispatchAnnounceMessage, this->getObjectID(), NETWORK_PEER_ID_BROADCAST, message);
             this->dispatchAnnounceMessage(message);
         }
@@ -411,5 +411,5 @@
                 this->dispatchAnnounceMessage(message);
             else
-                callMemberNetworkFunction(GametypeInfo, dispatchAnnounceMessage, this->getObjectID(), clientID, message);
+                callMemberNetworkFunction(&GametypeInfo::dispatchAnnounceMessage, this->getObjectID(), clientID, message);
         }
     }
@@ -422,5 +422,5 @@
                 this->dispatchKillMessage(message);
             else
-                callMemberNetworkFunction(GametypeInfo, dispatchKillMessage, this->getObjectID(), clientID, message);
+                callMemberNetworkFunction(&GametypeInfo::dispatchKillMessage, this->getObjectID(), clientID, message);
         }
     }
@@ -433,5 +433,5 @@
                 this->dispatchDeathMessage(message);
             else
-                callMemberNetworkFunction(GametypeInfo, dispatchDeathMessage, this->getObjectID(), clientID, message);
+                callMemberNetworkFunction(&GametypeInfo::dispatchDeathMessage, this->getObjectID(), clientID, message);
         }
     }
@@ -444,5 +444,5 @@
                 this->dispatchStaticMessage(message, colour);
             else
-                callMemberNetworkFunction(GametypeInfo, dispatchStaticMessage, this->getObjectID(), clientID, message, colour);
+                callMemberNetworkFunction(&GametypeInfo::dispatchStaticMessage, this->getObjectID(), clientID, message, colour);
         }
     }
@@ -455,5 +455,5 @@
                 this->dispatchFadingMessage(message);
             else
-                callMemberNetworkFunction(GametypeInfo, dispatchFadingMessage, this->getObjectID(), clientID, message);
+                callMemberNetworkFunction(&GametypeInfo::dispatchFadingMessage, this->getObjectID(), clientID, message);
         }
     }
Index: code/trunk/src/orxonox/infos/HumanPlayer.cc
===================================================================
--- code/trunk/src/orxonox/infos/HumanPlayer.cc	(revision 10622)
+++ code/trunk/src/orxonox/infos/HumanPlayer.cc	(revision 10624)
@@ -160,7 +160,7 @@
     }
 
-    void HumanPlayer::changedGametype()
-    {
-        PlayerInfo::changedGametype();
+    void HumanPlayer::switchGametype(Gametype* gametype)
+    {
+        PlayerInfo::switchGametype(gametype);
 
         if (this->isInitialized() && this->isLocalPlayer())
Index: code/trunk/src/orxonox/infos/HumanPlayer.h
===================================================================
--- code/trunk/src/orxonox/infos/HumanPlayer.h	(revision 10622)
+++ code/trunk/src/orxonox/infos/HumanPlayer.h	(revision 10624)
@@ -51,5 +51,5 @@
             void setClientID(unsigned int clientID);
 
-            virtual void changedGametype();
+            virtual void switchGametype(Gametype* gametype);
 
             inline void setHumanHUDTemplate(const std::string& name)
Index: code/trunk/src/orxonox/infos/PlayerInfo.cc
===================================================================
--- code/trunk/src/orxonox/infos/PlayerInfo.cc	(revision 10622)
+++ code/trunk/src/orxonox/infos/PlayerInfo.cc	(revision 10624)
@@ -40,5 +40,5 @@
 namespace orxonox
 {
-    RegisterAbstractClass(PlayerInfo).inheritsFrom(Class(Info));
+    RegisterAbstractClass(PlayerInfo).inheritsFrom<Info>();
 
     PlayerInfo::PlayerInfo(Context* context) : Info(context)
@@ -57,5 +57,5 @@
         this->gtinfo_ = 0;
         this->gtinfoID_ = OBJECTID_UNKNOWN;
-        this->updateGametypeInfo();
+        this->updateGametypeInfo(this->getGametype());
 
         this->registerVariables();
@@ -95,36 +95,41 @@
     }
 
-    void PlayerInfo::changedGametype()
-    {
-        this->updateGametypeInfo();
+    void PlayerInfo::switchGametype(Gametype* gametype)
+    {
+        Gametype* oldGametype = this->getGametype();
+        this->setGametype(StrongPtr<Gametype>(gametype));
+        Gametype* newGametype = this->getGametype();
+
+
+        this->updateGametypeInfo(newGametype);
 
         if (this->isInitialized())
         {
-            if (this->getOldGametype())
+            if (oldGametype)
             {
-                if (this->getGametype())
-                    this->getOldGametype()->playerSwitched(this, this->getGametype());
+                if (newGametype)
+                    oldGametype->playerSwitched(this, newGametype);
                 else
-                    this->getOldGametype()->playerLeft(this);
+                    oldGametype->playerLeft(this);
             }
 
-            if (this->getGametype())
+            if (newGametype)
             {
-                if (this->getOldGametype())
-                    this->getGametype()->playerSwitchedBack(this, this->getOldGametype());
+                if (oldGametype)
+                    newGametype->playerSwitchedBack(this, oldGametype);
                 else
-                    this->getGametype()->playerEntered(this);
+                    newGametype->playerEntered(this);
             }
         }
     }
 
-    void PlayerInfo::updateGametypeInfo()
+    void PlayerInfo::updateGametypeInfo(Gametype* gametype)
     {
         this->gtinfo_ = 0;
         this->gtinfoID_ = OBJECTID_UNKNOWN;
 
-        if (this->getGametype() && this->getGametype()->getGametypeInfo())
-        {
-            this->gtinfo_ = this->getGametype()->getGametypeInfo();
+        if (gametype && gametype->getGametypeInfo())
+        {
+            this->gtinfo_ = gametype->getGametypeInfo();
             this->gtinfoID_ = this->gtinfo_->getObjectID();
         }
@@ -186,5 +191,5 @@
 
         this->controllableEntity_->destroyHud(); // HACK-ish
-        this->previousControllableEntity_.push_back(WeakPtr<ControllableEntity>(this->controllableEntity_));
+        this->previousControllableEntity_.push_back(this->controllableEntity_);
         this->controllableEntity_ = entity;
         this->controllableEntityID_ = entity->getObjectID();
Index: code/trunk/src/orxonox/infos/PlayerInfo.h
===================================================================
--- code/trunk/src/orxonox/infos/PlayerInfo.h	(revision 10622)
+++ code/trunk/src/orxonox/infos/PlayerInfo.h	(revision 10624)
@@ -45,5 +45,5 @@
 
             virtual void changedName();
-            virtual void changedGametype();
+            virtual void switchGametype(Gametype* gametype);
 
             virtual void changedController() {}
@@ -94,5 +94,5 @@
             void networkcallback_changedcontrollableentityID();
             void networkcallback_changedgtinfoID();
-            void updateGametypeInfo();
+            void updateGametypeInfo(Gametype* gametype);
 
             bool bReadyToSpawn_;
Index: code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc
===================================================================
--- code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc	(revision 10622)
+++ code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc	(revision 10624)
@@ -50,5 +50,5 @@
     // GametypeMessageListener
     //----------------------------
-    RegisterAbstractClass(GametypeMessageListener).inheritsFrom(Class(OrxonoxInterface));
+    RegisterAbstractClass(GametypeMessageListener).inheritsFrom<OrxonoxInterface>();
 
     GametypeMessageListener::GametypeMessageListener()
@@ -60,5 +60,5 @@
     // PlayerTrigger
     //----------------------------
-    RegisterAbstractClass(PlayerTrigger).inheritsFrom(Class(OrxonoxInterface));
+    RegisterAbstractClass(PlayerTrigger).inheritsFrom<OrxonoxInterface>();
 
     PlayerTrigger::PlayerTrigger()
@@ -72,7 +72,7 @@
     {
         assert(pawn);
-        this->pawn_ = WeakPtr<Pawn>(pawn);
+        this->pawn_ = pawn;
         if (pawn)
-            this->player_ = WeakPtr<PlayerInfo>(pawn->getPlayer());
+            this->player_ = pawn->getPlayer();
     }
 
@@ -80,5 +80,5 @@
     // RadarListener
     //----------------------------
-    RegisterAbstractClass(RadarListener).inheritsFrom(Class(OrxonoxInterface));
+    RegisterAbstractClass(RadarListener).inheritsFrom<OrxonoxInterface>();
 
     RadarListener::RadarListener()
@@ -90,5 +90,5 @@
     // TeamColourable
     //----------------------------
-    RegisterAbstractClass(TeamColourable).inheritsFrom(Class(OrxonoxInterface));
+    RegisterAbstractClass(TeamColourable).inheritsFrom<OrxonoxInterface>();
 
     TeamColourable::TeamColourable()
@@ -100,5 +100,5 @@
     // Rewardable
     //----------------------------
-    RegisterAbstractClass(Rewardable).inheritsFrom(Class(OrxonoxInterface));
+    RegisterAbstractClass(Rewardable).inheritsFrom<OrxonoxInterface>();
 
     Rewardable::Rewardable()
Index: code/trunk/src/orxonox/interfaces/NotificationListener.cc
===================================================================
--- code/trunk/src/orxonox/interfaces/NotificationListener.cc	(revision 10622)
+++ code/trunk/src/orxonox/interfaces/NotificationListener.cc	(revision 10624)
@@ -34,5 +34,5 @@
 #include "core/CoreIncludes.h"
 #include "network/Host.h"
-#include "network/NetworkFunction.h"
+#include "network/NetworkFunctionIncludes.h"
 #include "util/SubString.h"
 
@@ -51,4 +51,6 @@
     registerStaticNetworkFunction(NotificationListener::sendHelper);
     
+    RegisterAbstractClass(NotificationListener).inheritsFrom<OrxonoxInterface>();
+
     NotificationListener::NotificationListener()
     {
@@ -82,10 +84,10 @@
         else if(GameMode::isServer() && sendMode == notificationSendMode::network && Host::getPlayerID() != clientId)
         {
-            callStaticNetworkFunction(NotificationListener::sendHelper, clientId, message, sender, isCommand, (unsigned int)messageType);
+            callStaticNetworkFunction(&NotificationListener::sendHelper, clientId, message, sender, isCommand, (unsigned int)messageType);
         }
         else if(GameMode::isServer() && sendMode == notificationSendMode::broadcast)
         {
             // TODO: Works as intended?
-            callStaticNetworkFunction(NotificationListener::sendHelper, NETWORK_PEER_ID_BROADCAST, message, sender, isCommand, (unsigned int)messageType);
+            callStaticNetworkFunction(&NotificationListener::sendHelper, NETWORK_PEER_ID_BROADCAST, message, sender, isCommand, (unsigned int)messageType);
         }
     }
Index: code/trunk/src/orxonox/interfaces/PickupCarrier.cc
===================================================================
--- code/trunk/src/orxonox/interfaces/PickupCarrier.cc	(revision 10622)
+++ code/trunk/src/orxonox/interfaces/PickupCarrier.cc	(revision 10624)
@@ -41,5 +41,5 @@
 namespace orxonox
 {
-    RegisterAbstractClass(PickupCarrier).inheritsFrom(Class(OrxonoxInterface));
+    RegisterAbstractClass(PickupCarrier).inheritsFrom<OrxonoxInterface>();
 
     /**
Index: code/trunk/src/orxonox/interfaces/PickupListener.cc
===================================================================
--- code/trunk/src/orxonox/interfaces/PickupListener.cc	(revision 10622)
+++ code/trunk/src/orxonox/interfaces/PickupListener.cc	(revision 10624)
@@ -40,4 +40,5 @@
 namespace orxonox
 {
+    RegisterAbstractClass(PickupListener).inheritsFrom<OrxonoxInterface>();
 
     /**
Index: code/trunk/src/orxonox/interfaces/Pickupable.cc
===================================================================
--- code/trunk/src/orxonox/interfaces/Pickupable.cc	(revision 10622)
+++ code/trunk/src/orxonox/interfaces/Pickupable.cc	(revision 10624)
@@ -46,5 +46,5 @@
 namespace orxonox
 {
-    RegisterAbstractClass(Pickupable).inheritsFrom(Class(OrxonoxInterface)).inheritsFrom(Class(Rewardable));
+    RegisterAbstractClass(Pickupable).inheritsFrom<OrxonoxInterface>().inheritsFrom<Rewardable>();
 
     /**
Index: code/trunk/src/orxonox/interfaces/Pickupable.h
===================================================================
--- code/trunk/src/orxonox/interfaces/Pickupable.h	(revision 10622)
+++ code/trunk/src/orxonox/interfaces/Pickupable.h	(revision 10624)
@@ -187,7 +187,7 @@
 
     //! SUPER functions.
-    SUPER_FUNCTION(10, Pickupable, changedUsed, false);
-    SUPER_FUNCTION(11, Pickupable, changedCarrier, false);
-    SUPER_FUNCTION(12, Pickupable, changedPickedUp, false);
+    SUPER_FUNCTION(9, Pickupable, changedUsed, false);
+    SUPER_FUNCTION(10, Pickupable, changedCarrier, false);
+    SUPER_FUNCTION(11, Pickupable, changedPickedUp, false);
 }
 
Index: code/trunk/src/orxonox/interfaces/PlayerTrigger.h
===================================================================
--- code/trunk/src/orxonox/interfaces/PlayerTrigger.h	(revision 10622)
+++ code/trunk/src/orxonox/interfaces/PlayerTrigger.h	(revision 10624)
@@ -63,5 +63,5 @@
         */
         inline Pawn* getTriggeringPawn(void) const
-            { return this->pawn_.get(); }
+            { return this->pawn_; }
 
         /**
Index: code/trunk/src/orxonox/interfaces/RadarViewable.cc
===================================================================
--- code/trunk/src/orxonox/interfaces/RadarViewable.cc	(revision 10622)
+++ code/trunk/src/orxonox/interfaces/RadarViewable.cc	(revision 10624)
@@ -38,5 +38,5 @@
 namespace orxonox
 {
-    RegisterAbstractClass(RadarViewable).inheritsFrom(Class(OrxonoxInterface));
+    RegisterAbstractClass(RadarViewable).inheritsFrom<OrxonoxInterface>();
 
     /**
Index: code/trunk/src/orxonox/interfaces/RadarViewable.h
===================================================================
--- code/trunk/src/orxonox/interfaces/RadarViewable.h	(revision 10622)
+++ code/trunk/src/orxonox/interfaces/RadarViewable.h	(revision 10624)
@@ -37,5 +37,5 @@
 #include "util/Math.h"
 #include "core/class/OrxonoxInterface.h"
-#include "core/object/SmartPtr.h"
+#include "core/object/StrongPtr.h"
 
 namespace orxonox
@@ -163,5 +163,5 @@
         //Radar
         const WorldEntity* wePtr_;
-        SmartPtr<Radar> radar_;
+        StrongPtr<Radar> radar_;
         float radarObjectCamouflage_;
         Shape radarObjectShape_;
Index: code/trunk/src/orxonox/items/ShipPart.cc
===================================================================
--- code/trunk/src/orxonox/items/ShipPart.cc	(revision 10622)
+++ code/trunk/src/orxonox/items/ShipPart.cc	(revision 10624)
@@ -50,9 +50,8 @@
 
     ShipPart::ShipPart(Context* context)
-        : Item(context)
+        : Item(context), parent_(NULL)
     {
         RegisterObject(ShipPart);
-        this->setAlive(true);
-        this->setEventExecution(true);
+        this->eventExecution_ = true;
         this->healthMem_ = 100;
     }
@@ -60,5 +59,9 @@
     ShipPart::~ShipPart()
     {
-
+        if (this->parent_)
+        {
+            // Remove this ShipPart from the parent.
+            this->parent_->removeShipPart(this);
+        }
     }
 
@@ -86,9 +89,5 @@
     void ShipPart::death()
     {
-        //if (!(this->isAlive()))
-            //return;
-
         this->explode();
-        this->setAlive(false);
 
         if(eventExecution_)
@@ -101,7 +100,5 @@
         }
 
-        // Remove this ShipPart from the parent.
-        this->parent_->removeShipPart(this);
-        delete this;
+        this->destroyLater();
     }
 
@@ -203,10 +200,4 @@
     {
         this->health_ = health;
-    }
-
-    void ShipPart::setAlive(bool var)
-    {
-        this->alive_ = var;
-        orxout() << "ShipPart " << this->getName() << " alive_: " << this->alive_ << endl;
     }
 
@@ -240,6 +231,5 @@
         }
         if (this->health_ < 0)
-            this->alive_ = false;
-            //this->death();
+            this->death();
 
         // (Ugly) Chatoutput of health, until a GUI for modularspaceships-shipparts is implemented.
Index: code/trunk/src/orxonox/items/ShipPart.h
===================================================================
--- code/trunk/src/orxonox/items/ShipPart.h	(revision 10622)
+++ code/trunk/src/orxonox/items/ShipPart.h	(revision 10624)
@@ -72,8 +72,4 @@
                 { return this->parent_; }
 
-            void setAlive(bool var);
-            inline bool isAlive()
-                { return this->alive_; }
-
             inline void setEventExecution(bool var)
                 { this->eventExecution_ = var; }
@@ -121,5 +117,4 @@
             std::vector<PartDestructionEvent*> eventList_;  // The list of all PartDestructionEvent assigned to this ShipPart.
 
-            bool alive_;
             bool eventExecution_;
 
Index: code/trunk/src/orxonox/overlays/InGameConsole.cc
===================================================================
--- code/trunk/src/orxonox/overlays/InGameConsole.cc	(revision 10622)
+++ code/trunk/src/orxonox/overlays/InGameConsole.cc	(revision 10624)
@@ -45,10 +45,10 @@
 #include "util/Math.h"
 #include "util/DisplayStringConversions.h"
-#include "util/ScopedSingletonManager.h"
 #include "util/output/MemoryWriter.h"
 #include "util/output/OutputManager.h"
 #include "core/CoreIncludes.h"
 #include "core/config/ConfigValueIncludes.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 #include "core/GUIManager.h"
 #include "core/input/InputManager.h"
@@ -65,5 +65,7 @@
     SetConsoleCommand("InGameConsole", "closeConsole", &InGameConsole::closeConsole);
 
-    ManageScopedSingleton(InGameConsole, ScopeID::Graphics, false);
+    ManageScopedSingleton(InGameConsole, ScopeID::GRAPHICS, false);
+
+    RegisterAbstractClass(InGameConsole).inheritsFrom<WindowEventListener>().inheritsFrom<UpdateListener>();
 
     /**
Index: code/trunk/src/orxonox/overlays/InGameConsole.h
===================================================================
--- code/trunk/src/orxonox/overlays/InGameConsole.h	(revision 10622)
+++ code/trunk/src/orxonox/overlays/InGameConsole.h	(revision 10624)
@@ -39,8 +39,9 @@
 #include "core/WindowEventListener.h"
 #include "core/command/Shell.h"
+#include "core/UpdateListener.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport InGameConsole : public Singleton<InGameConsole>, public ShellListener, public WindowEventListener
+    class _OrxonoxExport InGameConsole : public Singleton<InGameConsole>, public ShellListener, public WindowEventListener, public UpdateListener
     {
         friend class Singleton<InGameConsole>;
@@ -53,4 +54,5 @@
 
         void preUpdate(const Clock& time);
+        void postUpdate(const Clock& time) { /*no action*/ }
 
         static void openConsole();
Index: code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc
===================================================================
--- code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc	(revision 10622)
+++ code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc	(revision 10624)
@@ -48,5 +48,5 @@
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 
 #include "OverlayGroup.h"
Index: code/trunk/src/orxonox/overlays/OverlayGroup.cc
===================================================================
--- code/trunk/src/orxonox/overlays/OverlayGroup.cc	(revision 10622)
+++ code/trunk/src/orxonox/overlays/OverlayGroup.cc	(revision 10624)
@@ -36,6 +36,7 @@
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "OrxonoxOverlay.h"
+#include "gametypes/Gametype.h"
 
 namespace orxonox
@@ -61,5 +62,5 @@
     OverlayGroup::~OverlayGroup()
     {
-        for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+        for (std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
             (*it)->destroy();
         this->hudElements_.clear();
@@ -85,5 +86,5 @@
     void OverlayGroup::setScale(const Vector2& scale)
     {
-        for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+        for (std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
             (*it)->scale(scale / this->scale_);
         this->scale_ = scale;
@@ -93,5 +94,5 @@
     void OverlayGroup::setScroll(const Vector2& scroll)
     {
-        for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+        for (std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
             (*it)->scroll(scroll - this->scroll_);
         this->scroll_ = scroll;
@@ -106,5 +107,5 @@
     void OverlayGroup::addElement(OrxonoxOverlay* element)
     {
-        hudElements_.insert(SmartPtr<OrxonoxOverlay>(element));
+        hudElements_.insert(element);
         element->setOverlayGroup( this );
         if (this->owner_)
@@ -122,5 +123,5 @@
     bool OverlayGroup::removeElement(OrxonoxOverlay* element)
     {
-        if(this->hudElements_.erase(SmartPtr<OrxonoxOverlay>(element)) == 0)
+        if(this->hudElements_.erase(element) == 0)
             return false;
         return true;
@@ -132,8 +133,8 @@
         if (index < this->hudElements_.size())
         {
-            std::set< SmartPtr<OrxonoxOverlay> >::const_iterator it = hudElements_.begin();
+            std::set< StrongPtr<OrxonoxOverlay> >::const_iterator it = hudElements_.begin();
             for (unsigned int i = 0; i != index; ++it, ++i)
                 ;
-            return it->get();
+            return *it;
         }
         else
@@ -146,22 +147,13 @@
         SUPER( OverlayGroup, changedVisibility );
 
-        for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+        for (std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
             (*it)->changedVisibility(); //inform all Child Overlays that our visibility has changed
     }
 
-    //! Changes the gametype of all elements
-    void OverlayGroup::changedGametype()
-    {
-        SUPER( OverlayGroup, changedGametype );
-
-        for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
-            (*it)->setGametype(this->getGametype());
-    }
-
     void OverlayGroup::setOwner(BaseObject* owner)
     {
         this->owner_ = owner;
 
-        for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+        for (std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
             (*it)->setOwner(owner);
     }
Index: code/trunk/src/orxonox/overlays/OverlayGroup.h
===================================================================
--- code/trunk/src/orxonox/overlays/OverlayGroup.h	(revision 10622)
+++ code/trunk/src/orxonox/overlays/OverlayGroup.h	(revision 10624)
@@ -65,9 +65,8 @@
         static void scrollGroup(const std::string& name, const Vector2& scroll);
 
-        inline const std::set< SmartPtr<OrxonoxOverlay> >& getOverlays() const
+        inline const std::set< StrongPtr<OrxonoxOverlay> >& getOverlays() const
             { return this->hudElements_; }
 
         virtual void changedVisibility();
-        virtual void changedGametype();
 
         void setOwner(BaseObject* owner);
@@ -92,5 +91,5 @@
 
     private:
-        std::set< SmartPtr<OrxonoxOverlay> > hudElements_;    //!< Contains all the OrxonoxOverlays of the this group.
+        std::set< StrongPtr<OrxonoxOverlay> > hudElements_;    //!< Contains all the OrxonoxOverlays of the this group.
         Vector2 scale_;                            //!< Current scale (independent of the elements).
         Vector2 scroll_;                           //!< Current scrolling offset.
Index: code/trunk/src/orxonox/sound/AmbientSound.cc
===================================================================
--- code/trunk/src/orxonox/sound/AmbientSound.cc	(revision 10622)
+++ code/trunk/src/orxonox/sound/AmbientSound.cc	(revision 10624)
@@ -36,4 +36,6 @@
 namespace orxonox
 {
+    RegisterAbstractClass(AmbientSound).inheritsFrom<BaseSound>().inheritsFrom<MoodListener>();
+
     AmbientSound::AmbientSound()
         : bPlayOnLoad_(false)
@@ -49,5 +51,5 @@
         if (GameMode::playsSound())
         {
-            // Smoothly fade out by keeping a SmartPtr
+            // Smoothly fade out by keeping a StrongPtr
             SoundManager::getInstance().unregisterAmbientSound(this);
         }
Index: code/trunk/src/orxonox/sound/BaseSound.cc
===================================================================
--- code/trunk/src/orxonox/sound/BaseSound.cc	(revision 10622)
+++ code/trunk/src/orxonox/sound/BaseSound.cc	(revision 10624)
@@ -43,5 +43,5 @@
 namespace orxonox
 {
-    RegisterAbstractClass(BaseSound).inheritsFrom(Class(Listable));
+    RegisterAbstractClass(BaseSound).inheritsFrom<Listable>();
 
     BaseSound::BaseSound()
Index: code/trunk/src/orxonox/sound/SoundBuffer.h
===================================================================
--- code/trunk/src/orxonox/sound/SoundBuffer.h	(revision 10622)
+++ code/trunk/src/orxonox/sound/SoundBuffer.h	(revision 10624)
@@ -46,5 +46,5 @@
         friend class SoundManager;
 #if !defined(_MSC_VER) || _MSC_VER >= 1500
-        // Make sure nobody deletes an instance (using smart pointers)
+        // Make sure nobody deletes an instance (using strong pointers)
         template <class T>
         friend void boost::checked_delete(T*);
Index: code/trunk/src/orxonox/sound/SoundManager.cc
===================================================================
--- code/trunk/src/orxonox/sound/SoundManager.cc	(revision 10622)
+++ code/trunk/src/orxonox/sound/SoundManager.cc	(revision 10624)
@@ -38,5 +38,5 @@
 #include "util/Math.h"
 #include "util/Clock.h"
-#include "util/ScopedSingletonManager.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 #include "core/config/ConfigValueIncludes.h"
 #include "core/CoreIncludes.h"
@@ -50,5 +50,5 @@
 namespace orxonox
 {
-    ManageScopedSingleton(SoundManager, ScopeID::Graphics, true);
+    ManageScopedSingleton(SoundManager, ScopeID::GRAPHICS, true);
 
     std::string SoundManager::getALErrorString(ALenum code)
@@ -65,4 +65,6 @@
         }
     }
+
+    RegisterAbstractClass(SoundManager).inheritsFrom<Configurable>().inheritsFrom<UpdateListener>();
 
     SoundManager::SoundManager()
@@ -163,5 +165,5 @@
     SoundManager::~SoundManager()
     {
-        // Erase fade lists because of the smart pointers
+        // Erase fade lists because of the strong pointers
         this->bDestructorCalled_ = true;
         this->fadeInList_.clear();
@@ -417,8 +419,8 @@
     }
 
-    void SoundManager::fadeIn(const SmartPtr<AmbientSound>& sound)
+    void SoundManager::fadeIn(AmbientSound* sound)
     {
         // If we're already fading out --> remove that
-        for (std::list<SmartPtr<AmbientSound> >::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); it++)
+        for (std::list<StrongPtr<AmbientSound> >::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); it++)
         {
             if (*it == sound)
@@ -433,8 +435,8 @@
     }
 
-    void SoundManager::fadeOut(const SmartPtr<AmbientSound>& sound)
+    void SoundManager::fadeOut(AmbientSound* sound)
     {
         // If we're already fading in --> remove that
-        for (std::list<SmartPtr<AmbientSound> >::iterator it = this->fadeInList_.begin(); it != this->fadeInList_.end(); it++)
+        for (std::list<StrongPtr<AmbientSound> >::iterator it = this->fadeInList_.begin(); it != this->fadeInList_.end(); it++)
         {
             if (*it == sound)
@@ -459,5 +461,5 @@
 
         // FADE IN
-        for (std::list<SmartPtr<AmbientSound> >::iterator it= this->fadeInList_.begin(); it != this->fadeInList_.end(); )
+        for (std::list<StrongPtr<AmbientSound> >::iterator it= this->fadeInList_.begin(); it != this->fadeInList_.end(); )
         {
             if ((*it)->getVolume() + this->crossFadeStep_*dt > 1.0f)
@@ -474,5 +476,5 @@
 
         // FADE OUT
-        for (std::list<SmartPtr<AmbientSound> >::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); )
+        for (std::list<StrongPtr<AmbientSound> >::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); )
         {
             if ((*it)->getVolume() - this->crossFadeStep_*dt < 0.0f)
Index: code/trunk/src/orxonox/sound/SoundManager.h
===================================================================
--- code/trunk/src/orxonox/sound/SoundManager.h	(revision 10622)
+++ code/trunk/src/orxonox/sound/SoundManager.h	(revision 10624)
@@ -40,5 +40,6 @@
 #include "util/Singleton.h"
 #include "core/config/Configurable.h"
-#include "core/object/SmartPtr.h"
+#include "core/object/StrongPtr.h"
+#include "core/UpdateListener.h"
 
 // tolua_begin
@@ -59,5 +60,5 @@
     class _OrxonoxExport SoundManager
     // tolua_end
-        : public Singleton<SoundManager>, public Configurable
+        : public Singleton<SoundManager>, public Configurable, public UpdateListener
     { // tolua_export
         friend class Singleton<SoundManager>;
@@ -68,4 +69,5 @@
 
         void preUpdate(const Clock& time);
+        void postUpdate(const Clock& time) { /*no action*/ }
         void setConfigValues();
 
@@ -104,6 +106,6 @@
     private:
         void processCrossFading(float dt);
-        void fadeIn(const SmartPtr<AmbientSound>& sound);
-        void fadeOut(const SmartPtr<AmbientSound>& sound);
+        void fadeIn(AmbientSound* sound);
+        void fadeOut(AmbientSound* sound);
 
         void checkFadeStepValidity();
@@ -127,6 +129,6 @@
         //! Absolute change per second (0.1 means 10% of the nominal volume) for cross fading
         float                              crossFadeStep_;
-        std::list<SmartPtr<AmbientSound> > fadeInList_;
-        std::list<SmartPtr<AmbientSound> > fadeOutList_;
+        std::list<StrongPtr<AmbientSound> > fadeInList_;
+        std::list<StrongPtr<AmbientSound> > fadeOutList_;
 
         // Volume related
Index: code/trunk/src/orxonox/sound/WorldAmbientSound.cc
===================================================================
--- code/trunk/src/orxonox/sound/WorldAmbientSound.cc	(revision 10622)
+++ code/trunk/src/orxonox/sound/WorldAmbientSound.cc	(revision 10624)
@@ -33,5 +33,5 @@
 #include "core/XMLPort.h"
 #include "AmbientSound.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include <exception>
 
Index: code/trunk/src/orxonox/weaponsystem/WeaponMode.cc
===================================================================
--- code/trunk/src/orxonox/weaponsystem/WeaponMode.cc	(revision 10622)
+++ code/trunk/src/orxonox/weaponsystem/WeaponMode.cc	(revision 10624)
@@ -45,5 +45,5 @@
 namespace orxonox
 {
-    RegisterAbstractClass(WeaponMode).inheritsFrom(Class(BaseObject));
+    RegisterAbstractClass(WeaponMode).inheritsFrom<BaseObject>();
 
     WeaponMode::WeaponMode(Context* context) : BaseObject(context)
Index: code/trunk/src/orxonox/worldentities/ControllableEntity.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/ControllableEntity.cc	(revision 10622)
+++ code/trunk/src/orxonox/worldentities/ControllableEntity.cc	(revision 10624)
@@ -36,5 +36,5 @@
 #include "core/GameMode.h"
 #include "core/XMLPort.h"
-#include "network/NetworkFunction.h"
+#include "network/NetworkFunctionIncludes.h"
 
 #include "Scene.h"
@@ -108,5 +108,5 @@
                 this->camera_->destroy();
 
-            for (std::list<SmartPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
+            for (std::list<StrongPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
                 (*it)->destroy();
 
@@ -165,5 +165,5 @@
     {
         unsigned int i = 0;
-        for (std::list<SmartPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
+        for (std::list<StrongPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
         {
             if (i == index)
@@ -180,5 +180,5 @@
 
         unsigned int counter = 0;
-        for (std::list<SmartPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
+        for (std::list<StrongPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
         {
             if ((*it) == this->currentCameraPosition_)
@@ -215,9 +215,9 @@
             {
                 this->cameraPositions_.front()->attachCamera(this->camera_);
-                this->currentCameraPosition_ = this->cameraPositions_.front().get();
+                this->currentCameraPosition_ = this->cameraPositions_.front();
             }
             else if (this->cameraPositions_.size() > 0)
             {
-                for (std::list<SmartPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
+                for (std::list<StrongPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
                 {
                     if ((*it) == this->camera_->getParent())
@@ -307,5 +307,5 @@
         else
         {
-            callMemberNetworkFunction(ControllableEntity, fire, this->getObjectID(), 0, firemode);
+            callMemberNetworkFunction(&ControllableEntity::fire, this->getObjectID(), 0, firemode);
         }
     }
@@ -323,9 +323,9 @@
             if ( target != 0 )
             {
-                callMemberNetworkFunction(ControllableEntity, setTargetInternal, this->getObjectID(), 0, target->getObjectID() );
+                callMemberNetworkFunction(&ControllableEntity::setTargetInternal, this->getObjectID(), 0, target->getObjectID() );
             }
            else
            {
-                callMemberNetworkFunction(ControllableEntity, setTargetInternal, this->getObjectID(), 0, OBJECTID_UNKNOWN );
+                callMemberNetworkFunction(&ControllableEntity::setTargetInternal, this->getObjectID(), 0, OBJECTID_UNKNOWN );
            }
         }
@@ -477,5 +477,5 @@
         if (parent)
         {
-            for (std::list<SmartPtr<CameraPosition> >::iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
+            for (std::list<StrongPtr<CameraPosition> >::iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
                 if ((*it)->getIsAbsolute())
                     parent->attach((*it));
Index: code/trunk/src/orxonox/worldentities/ControllableEntity.h
===================================================================
--- code/trunk/src/orxonox/worldentities/ControllableEntity.h	(revision 10622)
+++ code/trunk/src/orxonox/worldentities/ControllableEntity.h	(revision 10624)
@@ -121,5 +121,5 @@
             void addCameraPosition(CameraPosition* position);
             CameraPosition* getCameraPosition(unsigned int index) const;
-            inline const std::list<SmartPtr<CameraPosition> >& getCameraPositions() const
+            inline const std::list<StrongPtr<CameraPosition> >& getCameraPositions() const
                 { return this->cameraPositions_; }
             unsigned int getCurrentCameraIndex() const;
@@ -162,5 +162,5 @@
 
             inline Controller* getController() const
-                { return this->controller_.get(); }
+                { return this->controller_; }
             void setController(Controller* val);
 
@@ -168,5 +168,5 @@
             virtual void setTarget( WorldEntity* target );
             virtual WorldEntity* getTarget()
-                { return this->target_.get(); }
+                { return this->target_; }
             void setTargetInternal( uint32_t targetID );
 
@@ -242,5 +242,5 @@
             bool bMouseLook_;
             float mouseLookSpeed_;
-            std::list<SmartPtr<CameraPosition> > cameraPositions_;
+            std::list<StrongPtr<CameraPosition> > cameraPositions_;
             CameraPosition* currentCameraPosition_;
             std::string cameraPositionTemplate_;
Index: code/trunk/src/orxonox/worldentities/WorldEntity.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/WorldEntity.cc	(revision 10622)
+++ code/trunk/src/orxonox/worldentities/WorldEntity.cc	(revision 10624)
@@ -61,5 +61,5 @@
     BOOST_STATIC_ASSERT((int)Ogre::Node::TS_WORLD  == (int)WorldEntity::World);
 
-    RegisterAbstractClass(WorldEntity).inheritsFrom(Class(BaseObject)).inheritsFrom(Class(Synchronisable));
+    RegisterAbstractClass(WorldEntity).inheritsFrom<BaseObject>().inheritsFrom<Synchronisable>();
 
     /**
@@ -130,5 +130,5 @@
                 WorldEntity* entity = *it;
 
-                // do this for all children, because even if getDeleteWithParent() returns true a child might still stay active due to smart pointers pointing to it
+                // do this for all children, because even if getDeleteWithParent() returns true a child might still stay active due to strong pointers pointing to it
                 entity->setPosition(entity->getWorldPosition());
                 this->detach(entity); // detach also erases the element from the children set
Index: code/trunk/src/orxonox/worldentities/pawns/Destroyer.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/Destroyer.cc	(revision 10622)
+++ code/trunk/src/orxonox/worldentities/pawns/Destroyer.cc	(revision 10624)
@@ -40,5 +40,5 @@
         RegisterObject(Destroyer);
 
-        UnderAttack* gametype = orxonox_cast<UnderAttack*>(this->getGametype().get());
+        UnderAttack* gametype = orxonox_cast<UnderAttack*>(this->getGametype());
         if (gametype)
         {
Index: code/trunk/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/ModularSpaceShip.cc	(revision 10622)
+++ code/trunk/src/orxonox/worldentities/pawns/ModularSpaceShip.cc	(revision 10624)
@@ -37,5 +37,5 @@
 #include "util/Math.h"
 #include "gametypes/Gametype.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 
 #include "items/ShipPart.h"
@@ -69,5 +69,6 @@
         if (this->isInitialized())
         {
-
+            while (!this->partList_.empty())
+                this->partList_[0]->destroy();
         }
     }
@@ -177,5 +178,5 @@
             if (it->second->getName() == name)
             {
-                it->second->setAlive(false);
+                it->second->death();
                 return;
             }
@@ -196,5 +197,5 @@
             if (it->second->getName() == name)
             {
-                it->second->setAlive(false);
+                it->second->death();
                 return;
             }
Index: code/trunk/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/Pawn.cc	(revision 10622)
+++ code/trunk/src/orxonox/worldentities/pawns/Pawn.cc	(revision 10624)
@@ -326,6 +326,7 @@
         if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_))
         {
-            // Set bAlive_ to false and wait for PawnManager to do the destruction
+            // Set bAlive_ to false and wait for destroyLater() to do the destruction
             this->bAlive_ = false;
+            this->destroyLater();
 
             this->setDestroyWhenPlayerLeft(false);
Index: code/trunk/src/orxonox/worldentities/pawns/Spectator.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/Spectator.cc	(revision 10622)
+++ code/trunk/src/orxonox/worldentities/pawns/Spectator.cc	(revision 10624)
@@ -34,5 +34,5 @@
 #include "core/GameMode.h"
 #include "core/command/CommandExecutor.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 
 #include "tools/BillboardSet.h"
Index: code/trunk/src/orxonox/worldentities/pawns/TeamBaseMatchBase.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/TeamBaseMatchBase.cc	(revision 10622)
+++ code/trunk/src/orxonox/worldentities/pawns/TeamBaseMatchBase.cc	(revision 10624)
@@ -45,5 +45,5 @@
         this->state_ = BaseState::Uncontrolled;
 
-        TeamBaseMatch* gametype = orxonox_cast<TeamBaseMatch*>(this->getGametype().get());
+        TeamBaseMatch* gametype = orxonox_cast<TeamBaseMatch*>(this->getGametype());
         if (gametype)
         {
@@ -58,5 +58,5 @@
         this->fireEvent();
 
-        TeamDeathmatch* gametype = orxonox_cast<TeamDeathmatch*>(this->getGametype().get());
+        TeamDeathmatch* gametype = orxonox_cast<TeamDeathmatch*>(this->getGametype());
         if (!gametype)
             return;
