Index: code/branches/resource2/cmake/ParseMacroArguments.cmake
===================================================================
--- code/branches/resource2/cmake/ParseMacroArguments.cmake	(revision 5597)
+++ code/branches/resource2/cmake/ParseMacroArguments.cmake	(revision 5610)
@@ -36,33 +36,42 @@
 
 MACRO(PARSE_MACRO_ARGUMENTS _switches _list_names)
+
+  # Using LIST(FIND ...) speeds up the process
+  SET(_keywords ${_switches} ${_list_names})
+
   # Parse all the arguments and set the corresponding variable
   # If the option is just a switch, set the variable to its name for later use
   FOREACH(_arg ${ARGN})
-    SET(_arg_found FALSE)
 
-    # Switches
-    FOREACH(_switch ${_switches})
-      IF(${_switch} STREQUAL ${_arg})
-        SET(_arg_${_switch} ${_switch})
-	SET(_arg_found TRUE)
-        # Avoid interpreting arguments after this one as options args for the previous one
-	SET(_storage_var)
-        BREAK()
-      ENDIF()
-    ENDFOREACH(_switch)
+    # Is the argument a keyword?
+    LIST(FIND _keywords ${_arg} _keyword_index)
+    IF(NOT _keyword_index EQUAL -1)
 
-    # Input options
-    IF(NOT _arg_found)
-      FOREACH(_list_name ${_list_names})
-        IF(${_list_name} STREQUAL ${_arg})
-          SET(_storage_var _arg_${_list_name})
-	  SET(_arg_found TRUE)
+      # Another optimisation
+      SET(_arg_found FALSE)
+      # Switches
+      FOREACH(_switch ${_switches})
+        IF(${_switch} STREQUAL ${_arg})
+          SET(_arg_${_switch} ${_switch})
+          SET(_arg_found TRUE)
+          # Avoid interpreting arguments after this one as options args for the previous one
+          SET(_storage_var)
           BREAK()
         ENDIF()
-      ENDFOREACH(_list_name)
-    ENDIF(NOT _arg_found)
+      ENDFOREACH(_switch)
 
-    # Arguments of an input option (like source files for SOURCE_FILES)
-    IF(NOT _arg_found)
+      # Input options
+      IF(NOT _arg_found)
+        FOREACH(_list_name ${_list_names})
+          IF(${_list_name} STREQUAL ${_arg})
+            SET(_storage_var _arg_${_list_name})
+            BREAK()
+          ENDIF()
+        ENDFOREACH(_list_name)
+      ENDIF(NOT _arg_found)
+
+    ELSE()
+
+      # Arguments of an input option (like source files for SOURCE_FILES)
       IF(_storage_var)
         # Store in variable define above in the foreach loop
@@ -71,5 +80,6 @@
         MESSAGE(FATAL_ERROR "ORXONOX_ADD_${_target_type} was given a non compliant argument: ${_arg}")
       ENDIF(_storage_var)
-    ENDIF(NOT _arg_found)
+
+    ENDIF()
 
   ENDFOREACH(_arg)
Index: code/branches/resource2/src/core/ClassFactory.h
===================================================================
--- code/branches/resource2/src/core/ClassFactory.h	(revision 5597)
+++ code/branches/resource2/src/core/ClassFactory.h	(revision 5610)
@@ -54,4 +54,6 @@
     class ClassFactory : public BaseFactory
     {
+        friend class Factory;
+
         public:
             static bool create(const std::string& name, bool bLoadable = true);
@@ -59,9 +61,11 @@
 
         private:
-            ClassFactory() {}                               // Don't create
-            ClassFactory(const ClassFactory& factory) {}    // Don't copy
+            ClassFactory(bool bLoadable) : bLoadable_(bLoadable) {}
+            ClassFactory(const ClassFactory& factory);      // Don't copy
             virtual ~ClassFactory() {}                      // Don't delete
 
-            static T* createNewObject(BaseObject* creator);
+            Identifier* createIdentifier(const std::string& name);
+
+            bool bLoadable_;
     };
 
@@ -76,7 +80,5 @@
     {
         COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl;
-        ClassIdentifier<T>::getIdentifier(name)->addFactory(new ClassFactory<T>);
-        ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable);
-        Factory::add(name, ClassIdentifier<T>::getIdentifier());
+        Factory::add(name, new ClassFactory<T>(bLoadable));
 
         return true;
@@ -90,15 +92,16 @@
     inline BaseObject* ClassFactory<T>::fabricate(BaseObject* creator)
     {
-        return ClassFactory<T>::createNewObject(creator);
+        return new T(creator);
     }
 
     /**
-        @brief Creates and returns a new object of class T; this is a wrapper for the new operator.
-        @return The new object
     */
     template <class T>
-    inline T* ClassFactory<T>::createNewObject(BaseObject* creator)
+    inline Identifier* ClassFactory<T>::createIdentifier(const std::string& name)
     {
-        return new T(creator);
+        Identifier* identifier = ClassIdentifier<T>::getIdentifier(name);
+        identifier->addFactory(this);
+        identifier->setLoadable(this->bLoadable_);
+        return identifier;
     }
 }
Index: code/branches/resource2/src/core/Factory.cc
===================================================================
--- code/branches/resource2/src/core/Factory.cc	(revision 5597)
+++ code/branches/resource2/src/core/Factory.cc	(revision 5610)
@@ -73,8 +73,7 @@
         @param identifier The identifier to add
     */
-    void Factory::add(const std::string& name, Identifier* identifier)
+    void Factory::add(const std::string& name, BaseFactory* factory)
     {
-        getFactoryPointer()->identifierStringMap_[name] = identifier;
-        getFactoryPointer()->identifierNetworkIDMap_[identifier->getNetworkID()] = identifier;
+        getFactoryPointer()->factoryMap_[name] = factory;
     }
 
@@ -105,14 +104,18 @@
     {
         COUT(3) << "*** Factory: Create class-hierarchy" << std::endl;
-        std::map<std::string, Identifier*>::iterator it;
-        it = getFactoryPointer()->identifierStringMap_.begin();
-        (*getFactoryPointer()->identifierStringMap_.begin()).second->startCreatingHierarchy();
-        for (it = getFactoryPointer()->identifierStringMap_.begin(); it != getFactoryPointer()->identifierStringMap_.end(); ++it)
+        std::map<std::string, BaseFactory*>::iterator it;
+        it = getFactoryPointer()->factoryMap_.begin();
+        Identifier::startCreatingHierarchy();
+        for (it = getFactoryPointer()->factoryMap_.begin(); it != getFactoryPointer()->factoryMap_.end(); ++it)
         {
+            // Create the corresponding identifier first
+            Identifier* identifier = it->second->createIdentifier(it->first);
+            getFactoryPointer()->identifierStringMap_[it->first] = identifier;
+            getFactoryPointer()->identifierNetworkIDMap_[identifier->getNetworkID()] = identifier;
             // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards.
-            BaseObject* temp = (*it).second->fabricate(0);
+            BaseObject* temp = identifier->fabricate(0);
             delete temp;
         }
-        (*getFactoryPointer()->identifierStringMap_.begin()).second->stopCreatingHierarchy();
+        Identifier::stopCreatingHierarchy();
         COUT(3) << "*** Factory: Finished class-hierarchy creation" << std::endl;
     }
Index: code/branches/resource2/src/core/Factory.h
===================================================================
--- code/branches/resource2/src/core/Factory.h	(revision 5597)
+++ code/branches/resource2/src/core/Factory.h	(revision 5610)
@@ -61,5 +61,5 @@
             static Identifier* getIdentifier(const std::string& name);
             static Identifier* getIdentifier(const uint32_t id);
-            static void add(const std::string& name, Identifier* identifier);
+            static void add(const std::string& name, BaseFactory* factory);
             static void changeNetworkID(Identifier* identifier, const uint32_t oldID, const uint32_t newID);
             static void cleanNetworkIDs();
@@ -69,5 +69,5 @@
 
             /** @brief Returns the factory-map. */
-            static const std::map<std::string, Identifier*>& getFacbtoryMap()
+            static const std::map<std::string, Identifier*>& getFactoryMap()
                 { return Factory::getFactoryPointer()->identifierStringMap_; }
             /** @brief Returns the begin-iterator of the factory-map. */
@@ -85,4 +85,5 @@
             std::map<std::string, Identifier*> identifierStringMap_;            //!< The map, mapping the name with the Identifier
             std::map<uint32_t, Identifier*> identifierNetworkIDMap_;        //!< The map, mapping the network ID with the Identifier
+            std::map<std::string, BaseFactory*> factoryMap_;
     };
 
@@ -95,4 +96,5 @@
         public:
             virtual BaseObject* fabricate(BaseObject* creator) = 0;
+            virtual Identifier* createIdentifier(const std::string& name) = 0;
             virtual ~BaseFactory() {};
     };
Index: code/branches/resource2/src/network/CMakeLists.txt
===================================================================
--- code/branches/resource2/src/network/CMakeLists.txt	(revision 5597)
+++ code/branches/resource2/src/network/CMakeLists.txt	(revision 5610)
@@ -35,9 +35,29 @@
   TrafficControl.cc
 )
+
+SET_SOURCE_FILES(NETWORK_HDR_FILES
+  ChatListener.h
+  Client.h
+  ClientConnection.h
+  ClientConnectionListener.h
+  ClientInformation.h
+  Connection.h
+  FunctionCallManager.h
+  GamestateClient.h
+  GamestateHandler.h
+  GamestateManager.h
+  Host.h
+  NetworkFunction.h
+  NetworkPrecompiledHeaders.h
+  NetworkPrereqs.h
+  Server.h
+  ServerConnection.h
+  TrafficControl.h
+)
+
 ADD_SUBDIRECTORY(packet)
 ADD_SUBDIRECTORY(synchronisable)
 
 ORXONOX_ADD_LIBRARY(network
-  FIND_HEADER_FILES
   DEFINE_SYMBOL
     "NETWORK_SHARED_BUILD"
@@ -51,4 +71,4 @@
     core
   SOURCE_FILES
-    ${NETWORK_SRC_FILES}
+    ${NETWORK_SRC_FILES} ${NETWORK_HDR_FILES}
 )
Index: code/branches/resource2/src/network/packet/CMakeLists.txt
===================================================================
--- code/branches/resource2/src/network/packet/CMakeLists.txt	(revision 5597)
+++ code/branches/resource2/src/network/packet/CMakeLists.txt	(revision 5610)
@@ -1,4 +1,3 @@
 ADD_SOURCE_FILES(NETWORK_SRC_FILES
-  Packet.cc
   Acknowledgement.cc
   Chat.cc
@@ -8,4 +7,18 @@
   FunctionCalls.cc
   Gamestate.cc
+  Packet.cc
   Welcome.cc
 )
+
+ADD_SOURCE_FILES(NETWORK_HDR_FILES
+  Acknowledgement.h
+  Chat.cc
+  Chat.h
+  ClassID.h
+  DeleteObjects.h
+  FunctionCalls.h
+  FunctionIDs.h
+  Gamestate.h
+  Packet.h
+  Welcome.h
+)
Index: code/branches/resource2/src/network/synchronisable/CMakeLists.txt
===================================================================
--- code/branches/resource2/src/network/synchronisable/CMakeLists.txt	(revision 5597)
+++ code/branches/resource2/src/network/synchronisable/CMakeLists.txt	(revision 5610)
@@ -5,2 +5,9 @@
   SynchronisableVariable.cc
 )
+
+ADD_SOURCE_FILES(NETWORK_HDR_FILES
+  NetworkCallback.h
+  NetworkCallbackManager.h
+  Synchronisable.h
+  SynchronisableVariable.h
+)
Index: code/branches/resource2/src/util/CMakeLists.txt
===================================================================
--- code/branches/resource2/src/util/CMakeLists.txt	(revision 5597)
+++ code/branches/resource2/src/util/CMakeLists.txt	(revision 5610)
@@ -33,4 +33,35 @@
 )
 
+SET_SOURCE_FILES(UTIL_HDR_FILES
+  CRC32.h
+  Clipboard.h
+  Convert.h
+  Debug.h
+  Exception.h
+  ExprParser.h
+  Math.h
+  MathConvert.h
+  mbool.h
+  MultiType.h
+  MultiTypeValue.h
+  OgreForwardRefs.h
+  OrxAssert.h
+  OrxEnum.h
+  OutputBuffer.h
+  OutputHandler.h
+  RefToValue.h
+  ScopeGuard.h
+  Serialise.h
+  SignalHandler.h
+  Singleton.h
+  Sleep.h
+  StringUtils.h
+  SubString.h
+  TemplateUtils.h
+  TypeTraits.h
+  UTFStringConversions.h
+  UtilPrereqs.h
+)
+
 IF(GCC_NO_SYSTEM_HEADER_SUPPORT)
   # Get around displaying a few hundred lines of warning code
@@ -39,5 +70,4 @@
 
 ORXONOX_ADD_LIBRARY(util
-  FIND_HEADER_FILES
   DEFINE_SYMBOL
     "UTIL_SHARED_BUILD"
@@ -45,4 +75,4 @@
     ${OGRE_LIBRARY}
   SOURCE_FILES
-    ${UTIL_SRC_FILES}
+    ${UTIL_SRC_FILES} ${UTIL_HDR_FILES}
 )
