Index: code/trunk/src/libraries/core/BaseObject.cc
===================================================================
--- code/trunk/src/libraries/core/BaseObject.cc	(revision 6859)
+++ code/trunk/src/libraries/core/BaseObject.cc	(revision 7163)
@@ -75,4 +75,5 @@
             this->setScene(this->creator_->getScene(), this->creator_->getSceneID());
             this->setGametype(this->creator_->getGametype());
+            this->setLevel(this->creator_->getLevel());
         }
         else
@@ -83,4 +84,5 @@
             this->sceneID_ = OBJECTID_UNKNOWN;
             this->gametype_ = 0;
+            this->level_ = 0;
         }
     }
@@ -103,5 +105,5 @@
         }
     }
-    
+
     /** @brief Adds an object which listens to the events of this object. */
     void BaseObject::registerEventListener(BaseObject* object)
@@ -123,5 +125,5 @@
         XMLPortParam(BaseObject, "mainstate", setMainStateName, getMainStateName, xmlelement, mode);
         XMLPortParamTemplate(BaseObject, "template", addTemplate, getSingleTemplate, xmlelement, mode, const std::string&);
-        
+
         XMLPortObjectTemplate(BaseObject, Template, "templates", addTemplate, getTemplate, xmlelement, mode, Template*);
         XMLPortObject(BaseObject, BaseObject, "eventlisteners", addEventListener, getEventListener, xmlelement, mode);
@@ -194,4 +196,11 @@
     {
         this->templates_.insert(temp);
+        if( temp->isLink() )
+        {
+          this->networkTemplateNames_.insert(temp->getLink());
+          assert( !Template::getTemplate(temp->getLink())->isLink() );
+        }
+        else
+          this->networkTemplateNames_.insert(temp->getName());
         temp->applyOn(this);
     }
@@ -363,5 +372,5 @@
     {
         this->registerEventStates();
-        
+
         COUT(4) << this->getIdentifier()->getName() << " (&" << this << ") processing event. originator: " << event.originator_->getIdentifier()->getName() << " (&" << event.originator_ << "), activate: " << event.activate_ << ", name: " << event.name_ << ", statename: " << event.statename_ << "." << std::endl;
 
Index: code/trunk/src/libraries/core/BaseObject.h
===================================================================
--- code/trunk/src/libraries/core/BaseObject.h	(revision 6859)
+++ code/trunk/src/libraries/core/BaseObject.h	(revision 7163)
@@ -51,4 +51,5 @@
     class Scene;
     class Gametype;
+    class Level;
 
     //! The BaseObject is the parent of all classes representing an instance in the game.
@@ -154,4 +155,15 @@
             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() {}
+
             void addEventSource(BaseObject* source, const std::string& state);
             void removeEventSource(BaseObject* source);
@@ -179,10 +191,11 @@
             EventState* getEventState(const std::string& name) const;
 
-            std::string name_;                                 //!< The name of the object
-            std::string oldName_;                              //!< The old name of the object
-            mbool       bActive_;                              //!< True = the object is active
-            mbool       bVisible_;                             //!< True = the object is visible
-            std::string mainStateName_;
-            Functor*    mainStateFunctor_;
+            std::string             name_;                     //!< The name of the object
+            std::string             oldName_;                  //!< The old name of the object
+            mbool                   bActive_;                  //!< True = the object is active
+            mbool                   bVisible_;                 //!< True = the object is visible
+            std::string             mainStateName_;
+            Functor*                mainStateFunctor_;
+            std::set<std::string>   networkTemplateNames_;
 
         private:
@@ -209,4 +222,5 @@
             SmartPtr<Gametype>     gametype_;
             Gametype*              oldGametype_;
+            SmartPtr<Level>        level_;
             std::set<Template*>    templates_;
 
Index: code/trunk/src/libraries/core/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/core/CMakeLists.txt	(revision 6859)
+++ code/trunk/src/libraries/core/CMakeLists.txt	(revision 7163)
@@ -96,6 +96,4 @@
     input/KeyBinder.h
     input/KeyBinderManager.h
-  DEFINE_SYMBOL
-    "CORE_SHARED_BUILD"
   PCH_FILE
     CorePrecompiledHeaders.h
@@ -112,6 +110,6 @@
     ogreceguirenderer_orxonox
     ois_orxonox
-    tinyxml++_orxonox
-    tolua++_orxonox
+    tinyxml_orxonox
+    tolua_orxonox
     util
   SOURCE_FILES
Index: code/trunk/src/libraries/core/ConfigFileManager.cc
===================================================================
--- code/trunk/src/libraries/core/ConfigFileManager.cc	(revision 6859)
+++ code/trunk/src/libraries/core/ConfigFileManager.cc	(revision 7163)
@@ -33,4 +33,5 @@
 #include "util/Convert.h"
 #include "util/Math.h"
+#include "util/StringUtils.h"
 #include "ConsoleCommand.h"
 #include "ConfigValueContainer.h"
Index: code/trunk/src/libraries/core/ConfigFileManager.h
===================================================================
--- code/trunk/src/libraries/core/ConfigFileManager.h	(revision 6859)
+++ code/trunk/src/libraries/core/ConfigFileManager.h	(revision 7163)
@@ -39,5 +39,4 @@
 
 #include "util/Singleton.h"
-#include "util/StringUtils.h"
 
 namespace orxonox // tolua_export
Index: code/trunk/src/libraries/core/Core.cc
===================================================================
--- code/trunk/src/libraries/core/Core.cc	(revision 6859)
+++ code/trunk/src/libraries/core/Core.cc	(revision 7163)
@@ -79,4 +79,5 @@
     SetCommandLineArgument(settingsFile, "orxonox.ini").information("THE configuration file");
     SetCommandLineSwitch(noIOConsole).information("Use this if you don't want to use the IOConsole (for instance for Lua debugging)");
+
 #ifdef ORXONOX_PLATFORM_WINDOWS
     SetCommandLineArgument(limitToCPU, 1).information("Limits the program to one CPU/core (1, 2, 3, etc.). Default is the first core (faster than off)");
Index: code/trunk/src/libraries/core/Event.cc
===================================================================
--- code/trunk/src/libraries/core/Event.cc	(revision 6859)
+++ code/trunk/src/libraries/core/Event.cc	(revision 7163)
@@ -60,5 +60,5 @@
 
         COUT(4) << "Processing event (EventState) : originator: " << event.originator_->getIdentifier()->getName() << " (&" << event.originator_ << "), activate: " << event.activate_ << ", name: " << event.name_ << ", statename: " << event.statename_ << ", object: " << object->getIdentifier()->getName() << " (&" << object << ")" << "." << std::endl;
-        
+
         // check if the originator is an instance of the requested class
         if (event.originator_->isA(this->subclass_))
Index: code/trunk/src/libraries/core/EventIncludes.h
===================================================================
--- code/trunk/src/libraries/core/EventIncludes.h	(revision 6859)
+++ code/trunk/src/libraries/core/EventIncludes.h	(revision 7163)
@@ -52,5 +52,5 @@
     } \
     XMLPortEventStateIntern(xmlportevent##function, classname, statename, xmlelement, mode)
-    
+
 #define XMLPortEventSink(classname, subclassname, statename, function, xmlelement, mode) \
     orxonox::EventState* containername##function = this->getEventState(statename); \
Index: code/trunk/src/libraries/core/Executor.cc
===================================================================
--- code/trunk/src/libraries/core/Executor.cc	(revision 6859)
+++ code/trunk/src/libraries/core/Executor.cc	(revision 7163)
@@ -30,5 +30,10 @@
 #include "Executor.h"
 
+#include <algorithm>
+
 #include "util/Convert.h"
+#include "util/Debug.h"
+#include "util/StringUtils.h"
+#include "util/SubString.h"
 #include "Language.h"
 
@@ -63,5 +68,87 @@
     bool Executor::parse(const std::string& params, const std::string& delimiter) const
     {
-        EXECUTOR_PARSE(normal);
+        unsigned int paramCount = this->functor_->getParamCount();
+       
+        if (paramCount == 0)
+        {
+            COUT(5) << "Calling Executor " << this->name_ << " through parser without parameters." << std::endl;
+            (*this->functor_)();
+        }
+        else if (paramCount == 1)
+        {
+            const std::string& temp = getStripped(params);
+            if (!temp.empty())
+            {
+                COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using whole string: " << params << std::endl;
+                (*this->functor_)(MultiType(params));
+            }
+            else if (this->bAddedDefaultValue_[0])
+            {
+                COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using default value: " << this->defaultValue_[0] << std::endl;
+                (*this->functor_)(this->defaultValue_[0]);
+            }
+            else
+            {
+                COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input: " << temp << ")." << std::endl;
+                return false;
+            }
+        }
+        else
+        {
+            SubString tokens(params, delimiter, SubString::WhiteSpaces, false, '\\', true, '"', true, '(', ')', true, '\0');
+           
+            for (unsigned int i = tokens.size(); i < this->functor_->getParamCount(); i++)
+            {
+                if (!this->bAddedDefaultValue_[i])
+                {
+                    COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input:" << params << ")." << std::endl;
+                    return false;
+                }
+            }
+           
+            MultiType param[MAX_FUNCTOR_ARGUMENTS];
+            COUT(5) << "Calling Executor " << this->name_ << " through parser with " << paramCount << " parameters, using " << tokens.size() << " tokens (";
+            for (unsigned int i = 0; i < tokens.size() && i < MAX_FUNCTOR_ARGUMENTS; i++)
+            {
+                param[i] = tokens[i];
+                if (i != 0)
+                {
+                    COUT(5) << ", ";
+                }
+                COUT(5) << tokens[i];
+            }
+            COUT(5) << ") and " << std::max((int)paramCount - (int)tokens.size(), 0) << " default values (";
+            for (unsigned int i = tokens.size(); i < paramCount; i++)
+            {
+                param[i] = this->defaultValue_[i];
+                if (i != 0)
+                {
+                    COUT(5) << ", ";
+                }
+                COUT(5) << this->defaultValue_[i];
+            }
+            COUT(5) << ")." << std::endl;
+           
+            if ((tokens.size() > paramCount) && (this->functor_->getTypenameParam(paramCount - 1) == "string"))
+                param[paramCount - 1] = tokens.subSet(paramCount - 1).join();
+           
+            switch(paramCount)
+            {
+                case 2:
+                    (*this->functor_)(param[0], param[1]);
+                    break;
+                case 3:
+                    (*this->functor_)(param[0], param[1], param[2]);
+                    break;
+                case 4:
+                    (*this->functor_)(param[0], param[1], param[2], param[3]);
+                    break;
+                case 5:
+                    (*this->functor_)(param[0], param[1], param[2], param[3], param[4]);
+                    break;
+            }
+        }
+
+        return true;
     }
 
Index: code/trunk/src/libraries/core/Executor.h
===================================================================
--- code/trunk/src/libraries/core/Executor.h	(revision 6859)
+++ code/trunk/src/libraries/core/Executor.h	(revision 7163)
@@ -33,108 +33,7 @@
 #include "CorePrereqs.h"
 
-#include <algorithm>
 #include <string>
-
-#include "util/Debug.h"
-#include "util/Math.h"
-#include "util/StringUtils.h"
-#include "util/SubString.h"
+#include "util/MultiType.h"
 #include "Functor.h"
-
-
-#define EXECUTOR_PARSE_FUNCTORCALL(mode) EXECUTOR_PARSE_FUNCTORCALL##mode
-#define EXECUTOR_PARSE_FUNCTORCALLnormal (*this->functor_)
-#define EXECUTOR_PARSE_FUNCTORCALLobject (*((FunctorMember<T>*)this->functor_))
-
-#define EXECUTOR_PARSE_OBJECT(mode, comma) EXECUTOR_PARSE_OBJECT##mode##comma
-#define EXECUTOR_PARSE_OBJECTnormal0
-#define EXECUTOR_PARSE_OBJECTnormal1
-#define EXECUTOR_PARSE_OBJECTobject0 object
-#define EXECUTOR_PARSE_OBJECTobject1 object,
-
-#define EXECUTOR_PARSE(mode) \
-    unsigned int paramCount = this->functor_->getParamCount(); \
-    \
-    if (paramCount == 0) \
-    { \
-        COUT(5) << "Calling Executor " << this->name_ << " through parser without parameters." << std::endl; \
-        EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 0)); \
-    } \
-    else if (paramCount == 1) \
-    { \
-        const std::string& temp = getStripped(params); \
-        if (!temp.empty()) \
-        { \
-            COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using whole string: " << params << std::endl; \
-            EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) MultiType(params)); \
-        } \
-        else if (this->bAddedDefaultValue_[0]) \
-        { \
-            COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using default value: " << this->defaultValue_[0] << std::endl; \
-            EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) this->defaultValue_[0]); \
-        } \
-        else \
-        { \
-            COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input: " << temp << ")." << std::endl; \
-            return false; \
-        } \
-    } \
-    else \
-    { \
-        SubString tokens(params, delimiter, SubString::WhiteSpaces, false, '\\', true, '"', true, '(', ')', true, '\0'); \
-        \
-        for (unsigned int i = tokens.size(); i < this->functor_->getParamCount(); i++) \
-        { \
-            if (!this->bAddedDefaultValue_[i]) \
-            { \
-                COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input:" << params << ")." << std::endl; \
-                return false; \
-            } \
-        } \
-        \
-        MultiType param[MAX_FUNCTOR_ARGUMENTS]; \
-        COUT(5) << "Calling Executor " << this->name_ << " through parser with " << paramCount << " parameters, using " << tokens.size() << " tokens ("; \
-        for (unsigned int i = 0; i < tokens.size() && i < MAX_FUNCTOR_ARGUMENTS; i++) \
-        { \
-            param[i] = tokens[i]; \
-            if (i != 0) \
-            { \
-                COUT(5) << ", "; \
-            } \
-            COUT(5) << tokens[i]; \
-        } \
-        COUT(5) << ") and " << std::max(static_cast<int>(paramCount) - static_cast<int>(tokens.size()), 0) << " default values ("; \
-        for (unsigned int i = tokens.size(); i < paramCount; i++) \
-        { \
-            param[i] = this->defaultValue_[i]; \
-            if (i != 0) \
-            { \
-                COUT(5) << ", "; \
-            } \
-            COUT(5) << this->defaultValue_[i]; \
-        } \
-        COUT(5) << ")." << std::endl; \
-        \
-        if ((tokens.size() > paramCount) && (this->functor_->getTypenameParam(paramCount - 1) == "string")) \
-            param[paramCount - 1] = tokens.subSet(paramCount - 1).join(); \
-        \
-        switch(paramCount) \
-        { \
-            case 2: \
-                EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) param[0], param[1]); \
-                break; \
-            case 3: \
-                EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) param[0], param[1], param[2]); \
-                break; \
-            case 4: \
-                EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) param[0], param[1], param[2], param[3]); \
-                break; \
-            case 5: \
-                EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) param[0], param[1], param[2], param[3], param[4]); \
-                break; \
-        } \
-    } \
-    \
-    return true
 
 namespace orxonox
@@ -284,10 +183,24 @@
             bool parse(T* object, const std::string& params, const std::string& delimiter = " ") const
             {
-                EXECUTOR_PARSE(object);
+                static_cast<FunctorMember<T>*>(this->functor_)->setObject(object);
+                if (Executor::parse(params, delimiter))
+                    return true;
+                else
+                {
+                    static_cast<FunctorMember<T>*>(this->functor_)->setObject((T*)NULL);
+                    return false;
+                }
             }
 
             bool parse(const T* object, const std::string& params, const std::string& delimiter = " ") const
             {
-                EXECUTOR_PARSE(object);
+                static_cast<FunctorMember<T>*>(this->functor_)->setObject(object);
+                if (Executor::parse(params, delimiter))
+                    return true;
+                else
+                {
+                    static_cast<FunctorMember<T>*>(this->functor_)->setObject((T*)NULL);
+                    return false;
+                }
             }
     };
Index: code/trunk/src/libraries/core/GUIManager.cc
===================================================================
--- code/trunk/src/libraries/core/GUIManager.cc	(revision 6859)
+++ code/trunk/src/libraries/core/GUIManager.cc	(revision 7163)
@@ -321,5 +321,5 @@
     }
 
-    void GUIManager::keyPressed(const KeyEvent& evt)
+    void GUIManager::buttonPressed(const KeyEvent& evt)
     {
         this->protectedCall(boost::bind(&CEGUI::System::injectKeyDown, _1, evt.getKeyCode()));
@@ -327,5 +327,5 @@
     }
 
-    void GUIManager::keyReleased(const KeyEvent& evt)
+    void GUIManager::buttonReleased(const KeyEvent& evt)
     {
         this->protectedCall(boost::bind(&CEGUI::System::injectKeyUp, _1, evt.getKeyCode()));
Index: code/trunk/src/libraries/core/GUIManager.h
===================================================================
--- code/trunk/src/libraries/core/GUIManager.h	(revision 6859)
+++ code/trunk/src/libraries/core/GUIManager.h	(revision 7163)
@@ -84,4 +84,6 @@
         //! Creates a new InputState to be used with a GUI Sheet
         const std::string& createInputState(const std::string& name, TriBool::Value showCursor = TriBool::True, TriBool::Value useKeyboard = TriBool::True, bool bBlockJoyStick = false); // tolua_export
+        LuaState* getLuaState(void)
+            { return this->luaState_.get(); }
 
         //! Returns the root window for all menu sheets
@@ -95,6 +97,5 @@
         inline void setPlayer(const std::string& guiname, PlayerInfo* player)
             { this->players_[guiname] = player; }
-        inline PlayerInfo* getPlayer(const std::string& guiname) const
-            { std::map<std::string, PlayerInfo*>::const_iterator it = this->players_.find(guiname); return (it != this->players_.end()) ? it->second : 0; }
+        inline orxonox::PlayerInfo* getPlayer(const std::string& guiname) const { std::map<std::string, PlayerInfo*>::const_iterator it = this->players_.find(guiname); return (it != this->players_.end()) ? it->second : 0; } // tolua_export
 
         // TODO: Temporary hack because the tolua exported CEGUI method does not seem to work
@@ -105,12 +106,12 @@
     private:
         GUIManager(const GUIManager& instance); //!< private and undefined copy c'tor (this is a singleton class)
+        void executeCode(const std::string& str);
 
-        void executeCode(const std::string& str);
         template <typename FunctionType>
         bool protectedCall(FunctionType function);
 
         // keyHandler functions
-        void keyPressed (const KeyEvent& evt);
-        void keyReleased(const KeyEvent& evt);
+        void buttonPressed (const KeyEvent& evt);
+        void buttonReleased(const KeyEvent& evt);
 
         // mouseHandler functions
Index: code/trunk/src/libraries/core/OrxonoxClass.h
===================================================================
--- code/trunk/src/libraries/core/OrxonoxClass.h	(revision 6859)
+++ code/trunk/src/libraries/core/OrxonoxClass.h	(revision 7163)
@@ -108,5 +108,5 @@
             bool isParentOf(const OrxonoxClass* object);
             bool isDirectParentOf(const OrxonoxClass* object);
-            
+
             virtual void clone(OrxonoxClass*& item) {}
 
@@ -172,7 +172,7 @@
             std::vector<std::pair<unsigned int, void*> > objectPointers_;
     };
-    
-    SUPER_FUNCTION(11, OrxonoxClass, clone, true);
-    
+
+    SUPER_FUNCTION(11, OrxonoxClass, clone, false);
+
 }
 
Index: code/trunk/src/libraries/core/Super.h
===================================================================
--- code/trunk/src/libraries/core/Super.h	(revision 6859)
+++ code/trunk/src/libraries/core/Super.h	(revision 7163)
@@ -267,17 +267,17 @@
     #define SUPER_changedGametype(classname, functionname, ...) \
         SUPER_NOARGS(classname, functionname)
-        
+
     #define SUPER_changedUsed(classname, functionname, ...) \
         SUPER_NOARGS(classname, functionname)
-        
+
     #define SUPER_clone(classname, functionname, ...) \
         SUPER_ARGS(classname, functionname, __VA_ARGS__)
-        
+
     #define SUPER_changedCarrier(classname, functionname, ...) \
         SUPER_NOARGS(classname, functionname)
-        
+
     #define SUPER_changedPickedUp(classname, functionname, ...) \
         SUPER_NOARGS(classname, functionname)
-        
+
     // (1/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
 
@@ -530,5 +530,5 @@
             ()
         SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
-        
+
         SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(10, changedUsed, false)
             ()
@@ -538,9 +538,9 @@
             (item)
         SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
-        
+
         SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(12, changedCarrier, false)
             ()
         SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
-        
+
         SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(13, changedPickedUp, false)
             ()
Index: code/trunk/src/libraries/core/Template.cc
===================================================================
--- code/trunk/src/libraries/core/Template.cc	(revision 6859)
+++ code/trunk/src/libraries/core/Template.cc	(revision 7163)
@@ -99,5 +99,5 @@
     }
 
-    const TiXmlElement& Template::getXMLElement() const
+    const TiXmlElement& Template::getXMLElement()
     {
         if (this->bIsLink_)
@@ -106,4 +106,6 @@
             if (temp)
             {
+                this->bLoadDefaults_ = temp->bLoadDefaults_;
+
                 if (!temp->bIsReturningXMLElement_)
                 {
Index: code/trunk/src/libraries/core/Template.h
===================================================================
--- code/trunk/src/libraries/core/Template.h	(revision 6859)
+++ code/trunk/src/libraries/core/Template.h	(revision 7163)
@@ -51,4 +51,6 @@
             inline const std::string& getLink() const
                 { return this->link_; }
+            inline bool isLink() const
+                { return this->bIsLink_; }
 
             inline void setLoadDefaults(bool bLoadDefaults)
@@ -58,5 +60,5 @@
 
             void setXMLElement(const TiXmlElement& xmlelement);
-            const TiXmlElement& getXMLElement() const;
+            const TiXmlElement& getXMLElement();
 
             void setBaseclass(const std::string& baseclass);
Index: code/trunk/src/libraries/core/XMLPort.cc
===================================================================
--- code/trunk/src/libraries/core/XMLPort.cc	(revision 6859)
+++ code/trunk/src/libraries/core/XMLPort.cc	(revision 7163)
@@ -41,3 +41,98 @@
         return ((!this->bApplyLoaderMask_) || identifier->isA(ClassIdentifier<Namespace>::getIdentifier()) || Loader::currentMask_s.isIncluded(identifier));
     }
+
+    XMLPortObjectContainer& XMLPortObjectContainer::port(BaseObject* object, Element& xmlelement, XMLPort::Mode mode)
+    {
+        if ((mode == XMLPort::LoadObject) || (mode == XMLPort::ExpandObject))
+        {
+            try
+            {
+                Element* xmlsubelement;
+                if (!this->sectionname_.empty())
+                    xmlsubelement = xmlelement.FirstChildElement(this->sectionname_, false);
+                else
+                    xmlsubelement = &xmlelement;
+
+                if (!xmlsubelement)
+                    return (*this);
+
+                for (ticpp::Iterator<ticpp::Element> child = xmlsubelement->FirstChildElement(false); child != child.end(); child++)
+                {
+                    Identifier* identifier = Identifier::getIdentifierByString(child->Value());
+                    if (!identifier)
+                    {
+                        if (!this->sectionname_.empty())
+                        {
+                            COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not a valid classname." << std::endl;
+                        }
+                        else
+                        {
+                            // It's probably just another subsection
+                        }
+                        continue;
+                    }
+                    if (!identifier->isA(objectIdentifier_))
+                    {
+                        COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not a '" << objectIdentifier_->getName() << "'." << std::endl;
+                        continue;
+                    }
+                    if (!identifier->isLoadable())
+                    {
+                        COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not loadable." << std::endl;
+                        continue;
+                    }
+                    if (!this->identifierIsIncludedInLoaderMask(identifier))
+                        continue;
+
+                    try
+                    {
+                        COUT(4) << object->getLoaderIndentation() << "fabricating " << child->Value() << "..." << std::endl;
+
+                        BaseObject* newObject = identifier->fabricate(object);
+                        newObject->setLoaderIndentation(object->getLoaderIndentation() + "  ");
+
+                        if (this->bLoadBefore_)
+                        {
+                            newObject->XMLPort(*child, XMLPort::LoadObject);
+                            COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << static_cast<BaseObject*>(object)->getName() << ')' << std::endl;
+                        }
+                        else
+                        {
+                            COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << static_cast<BaseObject*>(object)->getName() << ')' << std::endl;
+                        }
+
+                        COUT(5) << object->getLoaderIndentation();
+
+                        this->callLoadExecutor(object, newObject);
+
+                        if (!this->bLoadBefore_)
+                            newObject->XMLPort(*child, XMLPort::LoadObject);
+
+                        COUT(5) << object->getLoaderIndentation() << "...fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << std::endl;
+                    }
+                    catch (AbortLoadingException& ex)
+                    {
+                        COUT(1) << "An error occurred while loading object, abort loading..." << std::endl;
+                        throw ex;
+                    }
+                    catch (...)
+                    {
+                        COUT(1) << "An error occurred while loading object:" << std::endl;
+                        COUT(1) << Exception::handleMessage() << std::endl;
+                    }
+                }
+            }
+            catch (ticpp::Exception& ex)
+            {
+                COUT(1) << std::endl;
+                COUT(1) << "An error occurred in XMLPort.h while loading a '" << objectIdentifier_->getName() << "' in '" << this->sectionname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << object->getName() << ") in " << object->getFilename() << ':' << std::endl;
+                COUT(1) << ex.what() << std::endl;
+            }
+        }
+        else if (mode == XMLPort::SaveObject)
+        {
+        }
+
+        return (*this);
+    }
 }
Index: code/trunk/src/libraries/core/XMLPort.h
===================================================================
--- code/trunk/src/libraries/core/XMLPort.h	(revision 6859)
+++ code/trunk/src/libraries/core/XMLPort.h	(revision 7163)
@@ -197,5 +197,5 @@
     @param loadfunction The function to add a new object to the class
     @param loadfunction The function to get all added objects from the class
-    @param xmlelement The XMLElement (recieved through the XMLPort function)
+    @param xmlelement The XMLElement (received through the XMLPort function)
     @param mode The mode (load/save) (received through the XMLPort function)
     @param bApplyLoaderMask If this is true, an added sub-object gets loaded only if it's class is included in the Loaders ClassTreeMask (this is usually false)
@@ -495,4 +495,8 @@
             virtual ~XMLPortObjectContainer() {}
 
+            XMLPortObjectContainer& port(BaseObject* object, Element& xmlelement, XMLPort::Mode mode);
+
+            virtual void callLoadExecutor(BaseObject* object, BaseObject* newObject) = 0;
+
             inline const std::string& getName() const
                 { return this->sectionname_; }
@@ -508,4 +512,5 @@
             bool bLoadBefore_;
             Identifier* identifier_;
+            Identifier* objectIdentifier_;
     };
 
@@ -518,4 +523,6 @@
                 this->sectionname_ = sectionname;
                 this->identifier_ = identifier;
+                assert(identifier->isA(ClassIdentifier<T>::getIdentifier()));
+                this->objectIdentifier_ = ClassIdentifier<O>::getIdentifier();
                 this->loadexecutor_ = loadexecutor;
                 this->saveexecutor_ = saveexecutor;
@@ -532,106 +539,12 @@
             }
 
-            XMLPortObjectContainer& port(T* object, Element& xmlelement, XMLPort::Mode mode)
-            {
-                if ((mode == XMLPort::LoadObject) || (mode == XMLPort::ExpandObject))
-                {
-                    try
-                    {
-                        Element* xmlsubelement;
-                        if (!this->sectionname_.empty())
-                            xmlsubelement = xmlelement.FirstChildElement(this->sectionname_, false);
-                        else
-                            xmlsubelement = &xmlelement;
-
-                        if (xmlsubelement)
-                        {
-                            for (ticpp::Iterator<ticpp::Element> child = xmlsubelement->FirstChildElement(false); child != child.end(); child++)
-                            {
-                                Identifier* identifier = Identifier::getIdentifierByString(child->Value());
-                                if (identifier)
-                                {
-                                    if (identifier->isA(ClassIdentifier<O>::getIdentifier()))
-                                    {
-                                        if (identifier->isLoadable())
-                                        {
-                                            if (this->identifierIsIncludedInLoaderMask(identifier))
-                                            {
-                                                try
-                                                {
-                                                    COUT(4) << object->getLoaderIndentation() << "fabricating " << child->Value() << "..." << std::endl;
-
-                                                    BaseObject* newObject = identifier->fabricate(static_cast<BaseObject*>(object));
-                                                    assert(newObject);
-                                                    newObject->setLoaderIndentation(object->getLoaderIndentation() + "  ");
-
-                                                    O* castedObject = orxonox_cast<O*>(newObject);
-                                                    assert(castedObject);
-
-                                                    if (this->bLoadBefore_)
-                                                    {
-                                                        newObject->XMLPort(*child, XMLPort::LoadObject);
-                                                        COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << static_cast<BaseObject*>(object)->getName() << ')' << std::endl;
-                                                    }
-                                                    else
-                                                    {
-                                                        COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << static_cast<BaseObject*>(object)->getName() << ')' << std::endl;
-                                                    }
-
-                                                    COUT(5) << object->getLoaderIndentation();
-                                                    (*this->loadexecutor_)(object, castedObject);
-
-                                                    if (!this->bLoadBefore_)
-                                                        newObject->XMLPort(*child, XMLPort::LoadObject);
-
-                                                    COUT(5) << object->getLoaderIndentation() << "...fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << std::endl;
-                                                }
-                                                catch (AbortLoadingException& ex)
-                                                {
-                                                    COUT(1) << "An error occurred while loading object, abort loading..." << std::endl;
-                                                    throw ex;
-                                                }
-                                                catch (...)
-                                                {
-                                                    COUT(1) << "An error occurred while loading object:" << std::endl;
-                                                    COUT(1) << Exception::handleMessage() << std::endl;
-                                                }
-                                            }
-                                        }
-                                        else
-                                        {
-                                            COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not loadable." << std::endl;
-                                        }
-                                    }
-                                    else
-                                    {
-                                        COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not a '" << ClassIdentifier<O>::getIdentifier()->getName() << "'." << std::endl;
-                                    }
-                                }
-                                else
-                                {
-                                    if (!this->sectionname_.empty())
-                                    {
-                                        COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not a valid classname." << std::endl;
-                                    }
-                                    else
-                                    {
-                                        // It's probably just another subsection
-                                    }
-                                }
-                            }
-                        }
-                    }
-                    catch (ticpp::Exception& ex)
-                    {
-                        COUT(1) << std::endl;
-                        COUT(1) << "An error occurred in XMLPort.h while loading a '" << ClassIdentifier<O>::getIdentifier()->getName() << "' in '" << this->sectionname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << object->getName() << ") in " << object->getFilename() << ':' << std::endl;
-                        COUT(1) << ex.what() << std::endl;
-                    }
-                }
-                else if (mode == XMLPort::SaveObject)
-                {
-                }
-
-                return (*this);
+            void callLoadExecutor(BaseObject* object, BaseObject* newObject)
+            {
+                T* castedObject = orxonox_cast<T*>(object);
+                assert(castedObject);
+                O* castedNewObject = orxonox_cast<O*>(newObject);
+                assert(castedNewObject);
+
+                (*this->loadexecutor_)(castedObject, castedNewObject);
             }
 
