Index: code/branches/core7/src/libraries/core/Core.cc
===================================================================
--- code/branches/core7/src/libraries/core/Core.cc	(revision 10529)
+++ code/branches/core7/src/libraries/core/Core.cc	(revision 10530)
@@ -130,5 +130,5 @@
         // TODO: initialize NetworkFunctionManager here
         this->rootModule_ = ModuleInstance::getCurrentModuleInstance();
-        this->rootModule_->loadAllStaticallyInitializedInstances();
+        this->rootModule_->loadAllStaticallyInitializedInstances(0);
 
         // Parse command line arguments AFTER the modules have been loaded (static code!)
@@ -246,5 +246,5 @@
         if (this->rootModule_)
         {
-            this->rootModule_->unloadAllStaticallyInitializedInstances();
+            this->rootModule_->unloadAllStaticallyInitializedInstances(0);
             this->rootModule_->deleteAllStaticallyInitializedInstances();
         }
@@ -287,5 +287,5 @@
         DynLib* dynLib = this->dynLibManager_->load(module->getName());
         module->setDynLib(dynLib);
-        module->loadAllStaticallyInitializedInstances();
+        module->loadAllStaticallyInitializedInstances(0);
         IdentifierManager::getInstance().createClassHierarchy();
         ScopeManager::getInstance().updateListeners();
@@ -307,5 +307,5 @@
         orxout(internal_info) << "Unloading module " << module->getName() << "..." << endl;
 
-        module->unloadAllStaticallyInitializedInstances();
+        module->unloadAllStaticallyInitializedInstances(0);
         module->deleteAllStaticallyInitializedInstances();
         this->dynLibManager_->unload(module->getDynLib());
Index: code/branches/core7/src/libraries/core/CoreIncludes.h
===================================================================
--- code/branches/core7/src/libraries/core/CoreIncludes.h	(revision 10529)
+++ code/branches/core7/src/libraries/core/CoreIncludes.h	(revision 10530)
@@ -225,5 +225,8 @@
 
         public:
-            StaticallyInitializedIdentifier(Identifier* identifier) : identifier_(identifier) {}
+            StaticallyInitializedIdentifier(Identifier* identifier)
+                : StaticallyInitializedInstance(0)
+                , identifier_(identifier)
+            {}
             ~StaticallyInitializedIdentifier() { delete identifier_; }
 
Index: code/branches/core7/src/libraries/core/command/ConsoleCommandIncludes.h
===================================================================
--- code/branches/core7/src/libraries/core/command/ConsoleCommandIncludes.h	(revision 10529)
+++ code/branches/core7/src/libraries/core/command/ConsoleCommandIncludes.h	(revision 10530)
@@ -310,5 +310,8 @@
     {
         public:
-            StaticallyInitializedConsoleCommand(ConsoleCommand* command) : command_(command) {}
+            StaticallyInitializedConsoleCommand(ConsoleCommand* command)
+                : StaticallyInitializedInstance(0)
+                , command_(command)
+            {}
             ~StaticallyInitializedConsoleCommand() { delete command_; }
 
Index: code/branches/core7/src/libraries/core/commandline/CommandLineIncludes.h
===================================================================
--- code/branches/core7/src/libraries/core/commandline/CommandLineIncludes.h	(revision 10529)
+++ code/branches/core7/src/libraries/core/commandline/CommandLineIncludes.h	(revision 10530)
@@ -58,5 +58,8 @@
     {
         public:
-            StaticallyInitializedCommandLineArgument(CommandLineArgument* argument) : argument_(argument) {}
+            StaticallyInitializedCommandLineArgument(CommandLineArgument* argument)
+                : StaticallyInitializedInstance(0)
+                , argument_(argument)
+            {}
             ~StaticallyInitializedCommandLineArgument() { delete argument_; }
 
Index: code/branches/core7/src/libraries/core/module/ModuleInstance.cc
===================================================================
--- code/branches/core7/src/libraries/core/module/ModuleInstance.cc	(revision 10529)
+++ code/branches/core7/src/libraries/core/module/ModuleInstance.cc	(revision 10530)
@@ -48,30 +48,33 @@
     void ModuleInstance::addStaticallyInitializedInstance(StaticallyInitializedInstance* instance)
     {
-        this->staticallyInitializedInstances_.insert(instance);
-    }
-
-    void ModuleInstance::loadAllStaticallyInitializedInstances()
-    {
-        for (std::set<StaticallyInitializedInstance*>::iterator it = this->staticallyInitializedInstances_.begin(); it != this->staticallyInitializedInstances_.end(); ++it)
-            (*it)->load();
-    }
-
-    void ModuleInstance::unloadAllStaticallyInitializedInstances()
-    {
-        for (std::set<StaticallyInitializedInstance*>::iterator it = this->staticallyInitializedInstances_.begin(); it != this->staticallyInitializedInstances_.end(); ++it)
-            (*it)->unload();
+        this->staticallyInitializedInstancesByType_[instance->getType()].insert(instance);
     }
 
     void ModuleInstance::removeStaticallyInitializedInstance(StaticallyInitializedInstance* instance)
     {
-        this->staticallyInitializedInstances_.erase(instance);
+        this->staticallyInitializedInstancesByType_[instance->getType()].erase(instance);
+    }
+
+    void ModuleInstance::loadAllStaticallyInitializedInstances(StaticallyInitializedInstance::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(StaticallyInitializedInstance::Type type)
+    {
+        const std::set<StaticallyInitializedInstance*>& instances = this->staticallyInitializedInstancesByType_[type];
+        for (std::set<StaticallyInitializedInstance*>::iterator it = instances.begin(); it != instances.end(); ++it)
+            (*it)->unload();
     }
 
     void ModuleInstance::deleteAllStaticallyInitializedInstances()
     {
-        std::set<StaticallyInitializedInstance*> copy(this->staticallyInitializedInstances_);
-        this->staticallyInitializedInstances_.clear();
-        for (std::set<StaticallyInitializedInstance*>::iterator it = copy.begin(); it != copy.end(); ++it)
-            delete (*it);
+        std::map<StaticallyInitializedInstance::Type, std::set<StaticallyInitializedInstance*> > copy(this->staticallyInitializedInstancesByType_);
+        this->staticallyInitializedInstancesByType_.clear();
+        for (std::map<StaticallyInitializedInstance::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);
     }
 
Index: code/branches/core7/src/libraries/core/module/ModuleInstance.h
===================================================================
--- code/branches/core7/src/libraries/core/module/ModuleInstance.h	(revision 10529)
+++ code/branches/core7/src/libraries/core/module/ModuleInstance.h	(revision 10530)
@@ -33,5 +33,8 @@
 
 #include <set>
+#include <map>
 #include <string>
+
+#include "StaticallyInitializedInstance.h"
 
 namespace orxonox
@@ -44,7 +47,9 @@
 
             void addStaticallyInitializedInstance(StaticallyInitializedInstance* instance);
-            void loadAllStaticallyInitializedInstances();
-            void unloadAllStaticallyInitializedInstances();
             void removeStaticallyInitializedInstance(StaticallyInitializedInstance* instance);
+
+            void loadAllStaticallyInitializedInstances(StaticallyInitializedInstance::Type type);
+            void unloadAllStaticallyInitializedInstances(StaticallyInitializedInstance::Type type);
+
             void deleteAllStaticallyInitializedInstances();
 
@@ -61,5 +66,5 @@
 
         private:
-            std::set<StaticallyInitializedInstance*> staticallyInitializedInstances_;
+            std::map<StaticallyInitializedInstance::Type, std::set<StaticallyInitializedInstance*> > staticallyInitializedInstancesByType_;
             std::string name_;
             DynLib* dynLib_;
Index: code/branches/core7/src/libraries/core/module/StaticallyInitializedInstance.cc
===================================================================
--- code/branches/core7/src/libraries/core/module/StaticallyInitializedInstance.cc	(revision 10529)
+++ code/branches/core7/src/libraries/core/module/StaticallyInitializedInstance.cc	(revision 10530)
@@ -33,6 +33,7 @@
 namespace orxonox
 {
-    StaticallyInitializedInstance::StaticallyInitializedInstance()
+    StaticallyInitializedInstance::StaticallyInitializedInstance(Type type)
     {
+        this->type_ = type;
         this->module_ = ModuleInstance::getCurrentModuleInstance();
         this->module_->addStaticallyInitializedInstance(this);
Index: code/branches/core7/src/libraries/core/module/StaticallyInitializedInstance.h
===================================================================
--- code/branches/core7/src/libraries/core/module/StaticallyInitializedInstance.h	(revision 10529)
+++ code/branches/core7/src/libraries/core/module/StaticallyInitializedInstance.h	(revision 10530)
@@ -37,5 +37,7 @@
     {
         public:
-            StaticallyInitializedInstance();
+            typedef int Type;
+
+            StaticallyInitializedInstance(Type type);
             virtual ~StaticallyInitializedInstance();
 
@@ -43,6 +45,10 @@
             virtual void unload() = 0;
 
+            inline Type getType() const
+                { return this->type_; }
+
         private:
             ModuleInstance* module_;
+            Type type_;
     };
 }
Index: code/branches/core7/src/libraries/core/singleton/ScopedSingletonIncludes.h
===================================================================
--- code/branches/core7/src/libraries/core/singleton/ScopedSingletonIncludes.h	(revision 10529)
+++ code/branches/core7/src/libraries/core/singleton/ScopedSingletonIncludes.h	(revision 10530)
@@ -81,5 +81,6 @@
         public:
             StaticallyInitializedScopedSingletonWrapper(ScopedSingletonWrapper* wrapper, ScopeID::Value scope)
-                : wrapper_(wrapper)
+                : StaticallyInitializedInstance(0)
+                , wrapper_(wrapper)
                 , scope_(scope)
             {}
Index: code/branches/core7/src/libraries/network/NetworkFunctionIncludes.h
===================================================================
--- code/branches/core7/src/libraries/network/NetworkFunctionIncludes.h	(revision 10529)
+++ code/branches/core7/src/libraries/network/NetworkFunctionIncludes.h	(revision 10530)
@@ -51,5 +51,8 @@
     {
         public:
-            StaticallyInitializedNetworkFunction(NetworkFunctionBase* function) : function_(function) {}
+            StaticallyInitializedNetworkFunction(NetworkFunctionBase* function)
+                : StaticallyInitializedInstance(0)
+                , function_(function)
+            {}
             ~StaticallyInitializedNetworkFunction() { delete function_; }
 
Index: code/branches/core7/test/core/class/IdentifierClassHierarchyTest.cc
===================================================================
--- code/branches/core7/test/core/class/IdentifierClassHierarchyTest.cc	(revision 10529)
+++ code/branches/core7/test/core/class/IdentifierClassHierarchyTest.cc	(revision 10530)
@@ -142,5 +142,5 @@
                 virtual void SetUp()
                 {
-                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
                     Identifier::initConfigValues_s = false; // TODO: hack!
                     IdentifierManager::getInstance().createClassHierarchy();
@@ -150,5 +150,5 @@
                 {
                     IdentifierManager::getInstance().destroyClassHierarchy();
-                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
                 }
         };
Index: code/branches/core7/test/core/class/IdentifierExternalClassHierarchyTest.cc
===================================================================
--- code/branches/core7/test/core/class/IdentifierExternalClassHierarchyTest.cc	(revision 10529)
+++ code/branches/core7/test/core/class/IdentifierExternalClassHierarchyTest.cc	(revision 10530)
@@ -49,5 +49,5 @@
                 virtual void SetUp()
                 {
-                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
                     Identifier::initConfigValues_s = false; // TODO: hack!
                     IdentifierManager::getInstance().createClassHierarchy();
@@ -57,5 +57,5 @@
                 {
                     IdentifierManager::getInstance().destroyClassHierarchy();
-                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
                 }
         };
Index: code/branches/core7/test/core/class/IdentifierNestedClassHierarchyTest.cc
===================================================================
--- code/branches/core7/test/core/class/IdentifierNestedClassHierarchyTest.cc	(revision 10529)
+++ code/branches/core7/test/core/class/IdentifierNestedClassHierarchyTest.cc	(revision 10530)
@@ -109,5 +109,5 @@
                 virtual void SetUp()
                 {
-                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
                     Identifier::initConfigValues_s = false; // TODO: hack!
                     IdentifierManager::getInstance().createClassHierarchy();
@@ -117,5 +117,5 @@
                 {
                     IdentifierManager::getInstance().destroyClassHierarchy();
-                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
                 }
         };
Index: code/branches/core7/test/core/class/IdentifierSimpleClassHierarchyTest.cc
===================================================================
--- code/branches/core7/test/core/class/IdentifierSimpleClassHierarchyTest.cc	(revision 10529)
+++ code/branches/core7/test/core/class/IdentifierSimpleClassHierarchyTest.cc	(revision 10530)
@@ -51,5 +51,5 @@
                 virtual void SetUp()
                 {
-                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
                     Identifier::initConfigValues_s = false; // TODO: hack!
                     IdentifierManager::getInstance().createClassHierarchy();
@@ -59,5 +59,5 @@
                 {
                     IdentifierManager::getInstance().destroyClassHierarchy();
-                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
                 }
         };
Index: code/branches/core7/test/core/class/SubclassIdentifierTest.cc
===================================================================
--- code/branches/core7/test/core/class/SubclassIdentifierTest.cc	(revision 10529)
+++ code/branches/core7/test/core/class/SubclassIdentifierTest.cc	(revision 10530)
@@ -31,5 +31,5 @@
                 virtual void SetUp()
                 {
-                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
                     Identifier::initConfigValues_s = false; // TODO: hack!
                     IdentifierManager::getInstance().createClassHierarchy();
@@ -43,5 +43,5 @@
 
                     IdentifierManager::getInstance().destroyClassHierarchy();
-                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
                 }
         };
Index: code/branches/core7/test/core/class/SuperTest.cc
===================================================================
--- code/branches/core7/test/core/class/SuperTest.cc	(revision 10529)
+++ code/branches/core7/test/core/class/SuperTest.cc	(revision 10530)
@@ -72,5 +72,5 @@
                 virtual void SetUp()
                 {
-                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
                     Identifier::initConfigValues_s = false; // TODO: hack!
                     IdentifierManager::getInstance().createClassHierarchy();
@@ -84,5 +84,5 @@
 
                     IdentifierManager::getInstance().destroyClassHierarchy();
-                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
                 }
         };
Index: code/branches/core7/test/core/command/CommandTest.cc
===================================================================
--- code/branches/core7/test/core/command/CommandTest.cc	(revision 10529)
+++ code/branches/core7/test/core/command/CommandTest.cc	(revision 10530)
@@ -140,5 +140,5 @@
                 virtual void SetUp()
                 {
-                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
                     Identifier::initConfigValues_s = false; // TODO: hack!
                     IdentifierManager::getInstance().createClassHierarchy();
@@ -148,5 +148,5 @@
                 {
                     IdentifierManager::getInstance().destroyClassHierarchy();
-                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
                 }
         };
Index: code/branches/core7/test/core/object/ClassFactoryTest.cc
===================================================================
--- code/branches/core7/test/core/object/ClassFactoryTest.cc	(revision 10529)
+++ code/branches/core7/test/core/object/ClassFactoryTest.cc	(revision 10530)
@@ -16,10 +16,10 @@
                 {
                     Context::setRootContext(new Context(NULL));
-                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
                 }
 
                 virtual void TearDown()
                 {
-                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
                     Context::setRootContext(NULL);
                 }
Index: code/branches/core7/test/core/object/ContextTest.cc
===================================================================
--- code/branches/core7/test/core/object/ContextTest.cc	(revision 10529)
+++ code/branches/core7/test/core/object/ContextTest.cc	(revision 10530)
@@ -24,10 +24,10 @@
                 {
                     Context::setRootContext(new Context(NULL));
-                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
                 }
 
                 virtual void TearDown()
                 {
-                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
                     Context::setRootContext(NULL);
                 }
Index: code/branches/core7/test/core/object/IteratorTest.cc
===================================================================
--- code/branches/core7/test/core/object/IteratorTest.cc	(revision 10529)
+++ code/branches/core7/test/core/object/IteratorTest.cc	(revision 10530)
@@ -35,10 +35,10 @@
                 {
                     Context::setRootContext(new Context(NULL));
-                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
                 }
 
                 virtual void TearDown()
                 {
-                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
                     Context::setRootContext(NULL);
                 }
Index: code/branches/core7/test/core/object/ListableTest.cc
===================================================================
--- code/branches/core7/test/core/object/ListableTest.cc	(revision 10529)
+++ code/branches/core7/test/core/object/ListableTest.cc	(revision 10530)
@@ -40,10 +40,10 @@
                 {
                     Context::setRootContext(new Context(NULL));
-                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
                 }
 
                 virtual void TearDown()
                 {
-                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
                     Context::setRootContext(NULL);
                 }
Index: code/branches/core7/test/core/object/ObjectListIteratorTest.cc
===================================================================
--- code/branches/core7/test/core/object/ObjectListIteratorTest.cc	(revision 10529)
+++ code/branches/core7/test/core/object/ObjectListIteratorTest.cc	(revision 10530)
@@ -27,10 +27,10 @@
                 {
                     Context::setRootContext(new Context(NULL));
-                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
                 }
 
                 virtual void TearDown()
                 {
-                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
                     Context::setRootContext(NULL);
                 }
Index: code/branches/core7/test/core/singleton/ScopeTest.cc
===================================================================
--- code/branches/core7/test/core/singleton/ScopeTest.cc	(revision 10529)
+++ code/branches/core7/test/core/singleton/ScopeTest.cc	(revision 10530)
@@ -27,10 +27,10 @@
                 virtual void SetUp()
                 {
-                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(0);
                 }
 
                 virtual void TearDown()
                 {
-                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(0);
                 }
         };
