Index: /code/branches/core7/src/libraries/core/Core.cc
===================================================================
--- /code/branches/core7/src/libraries/core/Core.cc	(revision 10517)
+++ /code/branches/core7/src/libraries/core/Core.cc	(revision 10518)
@@ -111,4 +111,5 @@
         , graphicsScope_(NULL)
         , bGraphicsLoaded_(false)
+        , rootModule_(NULL)
         , config_(NULL)
         , destructionHelper_(this)
@@ -121,19 +122,4 @@
         // Create a new dynamic library manager
         this->dynLibManager_ = new DynLibManager();
-
-        // Load modules
-        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)
-        {
-            try
-            {
-                this->dynLibManager_->load(*it);
-            }
-            catch (...)
-            {
-                orxout(user_error) << "Couldn't load module \"" << *it << "\": " << Exception::handleMessage() << endl;
-            }
-        }
 
         // TODO: initialize Root-Context
@@ -142,5 +128,6 @@
         // TODO: initialize CommandLineParser here
         // TODO: initialize ConsoleCommandManager here
-        ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
+        this->rootModule_ = ModuleInstance::getCurrentModuleInstance();
+        this->rootModule_->loadAllStaticallyInitializedInstances();
 
         // Parse command line arguments AFTER the modules have been loaded (static code!)
@@ -258,4 +245,7 @@
         IdentifierManager::getInstance().destroyAllIdentifiers();
         safeObjectDelete(&signalHandler_);
+//        if (this->rootModule_)
+//            this->rootModule_->unloadAllStaticallyInitializedInstances();
+//        safeObjectDelete(&rootModule_);
         safeObjectDelete(&dynLibManager_);
         safeObjectDelete(&configurablePaths_);
@@ -263,4 +253,55 @@
 
         orxout(internal_status) << "finished destroying Core object" << endl;
+    }
+
+    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)
+        {
+            try
+            {
+                ModuleInstance* module = new ModuleInstance(*it);
+                this->loadModule(module);
+                this->modules_.push_back(module);
+            }
+            catch (...)
+            {
+                orxout(user_error) << "Couldn't load module \"" << *it << "\": " << Exception::handleMessage() << endl;
+            }
+        }
+
+        orxout(internal_info) << "finished loading modules" << endl;
+    }
+
+    void Core::loadModule(ModuleInstance* module)
+    {
+        ModuleInstance::setCurrentModuleInstance(module);
+        DynLib* dynLib = this->dynLibManager_->load(module->getName());
+        module->setDynLib(dynLib);
+        module->loadAllStaticallyInitializedInstances();
+        IdentifierManager::getInstance().createClassHierarchy();
+        ScopeManager::getInstance().updateListeners();
+    }
+
+    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)
+    {
+        module->unloadAllStaticallyInitializedInstances();
+        module->deleteAllStaticallyInitializedInstances();
+        this->dynLibManager_->unload(module->getDynLib());
+        module->setDynLib(NULL);
     }
 
Index: /code/branches/core7/src/libraries/core/Core.h
===================================================================
--- /code/branches/core7/src/libraries/core/Core.h	(revision 10517)
+++ /code/branches/core7/src/libraries/core/Core.h	(revision 10518)
@@ -60,5 +60,4 @@
     {
         friend class Singleton<Core>;
-        friend class Game;
 
         public:
@@ -77,4 +76,15 @@
             void destroy();
 
+            void preUpdate(const Clock& time);
+            void postUpdate(const Clock& time);
+
+            void loadGraphics();
+            void unloadGraphics();
+
+            void loadModules();
+            void unloadModules();
+            void loadModule(ModuleInstance* module);
+            void unloadModule(ModuleInstance* module);
+
             inline CoreConfig* getConfig() const
                 { return this->config_; }
@@ -82,10 +92,4 @@
         private:
             Core(const Core&); //!< Don't use (undefined symbol)
-
-            void preUpdate(const Clock& time);
-            void postUpdate(const Clock& time);
-
-            void loadGraphics();
-            void unloadGraphics();
 
             void setThreadAffinity(int limitToCPU);
@@ -108,4 +112,6 @@
             Scope<ScopeID::GRAPHICS>* graphicsScope_;
             bool                      bGraphicsLoaded_;
+            ModuleInstance*           rootModule_;
+            std::list<ModuleInstance*>modules_;
 
             /// Helper object that stores the config values
Index: /code/branches/core7/src/libraries/core/Game.cc
===================================================================
--- /code/branches/core7/src/libraries/core/Game.cc	(revision 10517)
+++ /code/branches/core7/src/libraries/core/Game.cc	(revision 10518)
@@ -110,4 +110,5 @@
         orxout(internal_info) << "creating Core object:" << endl;
         this->core_ = new Core(cmdLine);
+        this->core_->loadModules();
 
         // Do this after the Core creation!
@@ -141,4 +142,6 @@
         GameStateFactory::getFactories().clear();
         safeObjectDelete(&config_);
+//        if (this->core_)
+//            this->core_->unloadModules();
         safeObjectDelete(&core_);
         safeObjectDelete(&gameClock_);
Index: /code/branches/core7/src/libraries/core/class/IdentifierManager.cc
===================================================================
--- /code/branches/core7/src/libraries/core/class/IdentifierManager.cc	(revision 10517)
+++ /code/branches/core7/src/libraries/core/class/IdentifierManager.cc	(revision 10518)
@@ -100,4 +100,6 @@
             {
                 Identifier* identifier = (*it);
+                if (identifier->isInitialized())
+                    continue;
 
                 orxout(verbose, context::identifier) << "Initialize ClassIdentifier<" << identifier->getName() << ">-Singleton." << endl;
@@ -135,5 +137,5 @@
             if (initializedIdentifiers.find(identifier) != initializedIdentifiers.end())
                 identifier->finishInitialization();
-            else
+            else if (!identifier->isInitialized())
                 orxout(internal_error) << "Identifier was registered late and is not initialized: " << identifier->getName() << " / " << identifier->getTypeInfo().name() << endl;
         }
Index: /code/branches/core7/src/libraries/core/module/ModuleInstance.cc
===================================================================
--- /code/branches/core7/src/libraries/core/module/ModuleInstance.cc	(revision 10517)
+++ /code/branches/core7/src/libraries/core/module/ModuleInstance.cc	(revision 10518)
@@ -35,19 +35,23 @@
     ModuleInstance* ModuleInstance::currentModuleInstance_s = NULL;
 
+    ModuleInstance::ModuleInstance(const std::string& name)
+        : name_(name)
+        , dynLib_(NULL)
+    {
+    }
+
     ModuleInstance::~ModuleInstance()
     {
-        std::list<StaticallyInitializedInstance*> copy(this->staticallyInitializedInstances_);
-        for (std::list<StaticallyInitializedInstance*>::iterator it = this->staticallyInitializedInstances_.begin(); it != this->staticallyInitializedInstances_.end(); ++it)
-            delete (*it);
+        this->deleteAllStaticallyInitializedInstances();
     }
 
     void ModuleInstance::addStaticallyInitializedInstance(StaticallyInitializedInstance* instance)
     {
-        this->staticallyInitializedInstances_.push_back(instance);
+        this->staticallyInitializedInstances_.insert(instance);
     }
 
     void ModuleInstance::loadAllStaticallyInitializedInstances()
     {
-        for (std::list<StaticallyInitializedInstance*>::iterator it = this->staticallyInitializedInstances_.begin(); it != this->staticallyInitializedInstances_.end(); ++it)
+        for (std::set<StaticallyInitializedInstance*>::iterator it = this->staticallyInitializedInstances_.begin(); it != this->staticallyInitializedInstances_.end(); ++it)
             (*it)->load();
     }
@@ -55,5 +59,5 @@
     void ModuleInstance::unloadAllStaticallyInitializedInstances()
     {
-        for (std::list<StaticallyInitializedInstance*>::iterator it = this->staticallyInitializedInstances_.begin(); it != this->staticallyInitializedInstances_.end(); ++it)
+        for (std::set<StaticallyInitializedInstance*>::iterator it = this->staticallyInitializedInstances_.begin(); it != this->staticallyInitializedInstances_.end(); ++it)
             (*it)->unload();
     }
@@ -61,6 +65,15 @@
     void ModuleInstance::removeStaticallyInitializedInstance(StaticallyInitializedInstance* instance)
     {
-        this->staticallyInitializedInstances_.remove(instance);
+        this->staticallyInitializedInstances_.erase(instance);
     }
+
+    void ModuleInstance::deleteAllStaticallyInitializedInstances()
+    {
+        std::set<StaticallyInitializedInstance*> copy(this->staticallyInitializedInstances_);
+        this->staticallyInitializedInstances_.clear();
+        for (std::set<StaticallyInitializedInstance*>::iterator it = this->staticallyInitializedInstances_.begin(); it != this->staticallyInitializedInstances_.end(); ++it)
+            delete (*it);
+    }
+
 
     /*static*/ void ModuleInstance::setCurrentModuleInstance(ModuleInstance* instance)
@@ -72,5 +85,5 @@
     {
         if (!ModuleInstance::currentModuleInstance_s)
-            ModuleInstance::currentModuleInstance_s = new ModuleInstance();
+            ModuleInstance::currentModuleInstance_s = new ModuleInstance("");
         return ModuleInstance::currentModuleInstance_s;
     }
Index: /code/branches/core7/src/libraries/core/module/ModuleInstance.h
===================================================================
--- /code/branches/core7/src/libraries/core/module/ModuleInstance.h	(revision 10517)
+++ /code/branches/core7/src/libraries/core/module/ModuleInstance.h	(revision 10518)
@@ -32,5 +32,6 @@
 #include "core/CorePrereqs.h"
 
-#include <list>
+#include <set>
+#include <string>
 
 namespace orxonox
@@ -39,4 +40,5 @@
     {
         public:
+            ModuleInstance(const std::string& name);
             ~ModuleInstance();
 
@@ -45,4 +47,13 @@
             void unloadAllStaticallyInitializedInstances();
             void removeStaticallyInitializedInstance(StaticallyInitializedInstance* instance);
+            void deleteAllStaticallyInitializedInstances();
+
+            inline const std::string& getName() const
+                { return this->name_; }
+
+            inline void setDynLib(DynLib* dynLib)
+                { this->dynLib_ = dynLib; }
+            inline DynLib* getDynLib() const
+                { return this->dynLib_; }
 
             static void setCurrentModuleInstance(ModuleInstance* instance);
@@ -50,5 +61,7 @@
 
         private:
-            std::list<StaticallyInitializedInstance*> staticallyInitializedInstances_;
+            std::set<StaticallyInitializedInstance*> staticallyInitializedInstances_;
+            std::string name_;
+            DynLib* dynLib_;
 
             static ModuleInstance* currentModuleInstance_s;
