Index: code/branches/core/src/orxonox/core/BaseObject.cc
===================================================================
--- code/branches/core/src/orxonox/core/BaseObject.cc	(revision 855)
+++ code/branches/core/src/orxonox/core/BaseObject.cc	(revision 856)
@@ -36,4 +36,5 @@
 #include "BaseObject.h"
 #include "XMLPort.h"
+#include "Level.h"
 
 namespace orxonox
@@ -79,8 +80,16 @@
     Element& BaseObject::XMLPort(Element& xmlelement, bool loading)
     {
-        std::cout << "1_1: " << this->getName() << std::endl;
         XMLPortParam(BaseObject, "name", setName, getName, xmlelement, loading);
-std::cout << "1_2: " << this->getName() << std::endl;
+
         return xmlelement;
     }
+
+    /**
+        @brief Returns the levelfile that loaded this object.
+        @return The levelfile
+    */
+    const std::string& BaseObject::getLevelfile() const
+    {
+        return this->level_->getFile();
+    }
 }
Index: code/branches/core/src/orxonox/core/BaseObject.h
===================================================================
--- code/branches/core/src/orxonox/core/BaseObject.h	(revision 855)
+++ code/branches/core/src/orxonox/core/BaseObject.h	(revision 856)
@@ -77,4 +77,10 @@
             /** @brief Returns a pointer to the level that loaded this object. @return The level */
             inline const Level* getLevel() const { return this->level_; }
+            const std::string& getLevelfile() const;
+
+            /** @brief Sets the indentation of the debug output in the Loader. @param indentation The indentation */
+            inline void setLoaderIndentation(const std::string& indentation) { this->loaderIndentation_ = indentation; }
+            /** @brief Returns the indentation of the debug output in the Loader. @return The indentation */
+            inline const std::string& getLoaderIndentation() const { return this->loaderIndentation_; }
 
         private:
@@ -83,4 +89,5 @@
             bool bVisible_;                             //!< True = the object is visible
             const Level* level_;                        //!< The level that loaded this object
+            std::string loaderIndentation_;             //!< Indentation of the debug output in the Loader
     };
 }
Index: code/branches/core/src/orxonox/core/CorePrereqs.h
===================================================================
--- code/branches/core/src/orxonox/core/CorePrereqs.h	(revision 855)
+++ code/branches/core/src/orxonox/core/CorePrereqs.h	(revision 856)
@@ -103,7 +103,10 @@
   template <class T>
   class SubclassIdentifier;
-  class XMLPortParamContainer;
+  template <class T, class O>
+  class XMLPortClassObjectContainer;
   template <class T>
   class XMLPortClassParamContainer;
+  class XMLPortObjectContainer;
+  class XMLPortParamContainer;
 }
 
Index: code/branches/core/src/orxonox/core/Debug.h
===================================================================
--- code/branches/core/src/orxonox/core/Debug.h	(revision 855)
+++ code/branches/core/src/orxonox/core/Debug.h	(revision 856)
@@ -55,5 +55,5 @@
 #define ORX_PRINT_DEBUG_OUTPUT 1 // <-- fix that! should be a configurable setting
 
-#define ORX_HARD_DEBUG_LEVEL ORX_DEBUG
+#define ORX_HARD_DEBUG_LEVEL ORX_vDEBUG
 //#define ORX_SOFT_DEBUG_LEVEL ORX_WARNING // <-- fix that! should be a configurable setting
 
Index: code/branches/core/src/orxonox/core/Identifier.h
===================================================================
--- code/branches/core/src/orxonox/core/Identifier.h	(revision 855)
+++ code/branches/core/src/orxonox/core/Identifier.h	(revision 856)
@@ -62,5 +62,4 @@
 #include "Debug.h"
 #include "Iterator.h"
-//#include "XMLPort.h"
 
 namespace orxonox
@@ -158,4 +157,7 @@
             virtual void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container) = 0;
 
+            virtual XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname) = 0;
+            virtual void addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container) = 0;
+
             static bool identifierIsInList(const Identifier* identifier, const std::list<const Identifier*>& list);
 
@@ -238,4 +240,7 @@
             void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container);
 
+            XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname);
+            void addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container);
+
         private:
             ClassIdentifier();
@@ -246,4 +251,5 @@
             bool bSetName_;             //!< True if the name is set
             std::map<std::string, XMLPortClassParamContainer<T>*> xmlportParamContainers_;
+            std::map<std::string, XMLPortClassObjectContainer<T, class O>*> xmlportObjectContainers_;
     };
 
@@ -336,4 +342,20 @@
     {
         this->xmlportParamContainers_[paramname] = (XMLPortClassParamContainer<T>*)container;
+    }
+
+    template <class T>
+    XMLPortObjectContainer* ClassIdentifier<T>::getXMLPortObjectContainer(const std::string& sectionname)
+    {
+        typename std::map<std::string, XMLPortClassObjectContainer<T, class O>*>::const_iterator it = xmlportObjectContainers_.find(sectionname);
+        if (it != xmlportObjectContainers_.end())
+            return (XMLPortObjectContainer*)((*it).second);
+        else
+            return 0;
+    }
+
+    template <class T>
+    void ClassIdentifier<T>::addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container)
+    {
+        this->xmlportObjectContainers_[sectionname] = (XMLPortClassObjectContainer<T, class O>*)container;
     }
 
Index: code/branches/core/src/orxonox/core/Level.h
===================================================================
--- code/branches/core/src/orxonox/core/Level.h	(revision 855)
+++ code/branches/core/src/orxonox/core/Level.h	(revision 856)
@@ -32,4 +32,5 @@
 
 #include "CorePrereqs.h"
+#include "ClassTreeMask.h"
 
 namespace orxonox
Index: code/branches/core/src/orxonox/core/Loader.cc
===================================================================
--- code/branches/core/src/orxonox/core/Loader.cc	(revision 855)
+++ code/branches/core/src/orxonox/core/Loader.cc	(revision 856)
@@ -39,4 +39,5 @@
 {
     std::vector<std::pair<const Level*, ClassTreeMask> > Loader::levels_s;
+    ClassTreeMask Loader::currentMask_s;
 
     bool Loader::open(const Level* level, const ClassTreeMask& mask)
@@ -104,26 +105,32 @@
     bool Loader::load(const Level* level, const ClassTreeMask& mask)
     {
-        ClassTreeMask loadmask = level->getMask() * mask;
+        Loader::currentMask_s = level->getMask() * mask;
 
         try
         {
             COUT(0) << "Start loading " << level->getFile() << "..." << std::endl;
-            COUT(3) << "Mask: " << loadmask << std::endl;
+            COUT(3) << "Mask: " << Loader::currentMask_s << std::endl;
 
             ticpp::Document xmlfile(level->getFile());
             xmlfile.LoadFile();
 
-            for ( ticpp::Iterator< ticpp::Element > child = xmlfile.FirstChildElement(); child != child.end(); child++ )
+            for ( ticpp::Iterator<ticpp::Element> child = xmlfile.FirstChildElement(false); child != child.end(); child++ )
             {
                 Identifier* identifier = ID(child->Value());
                 if (identifier)
                 {
-                    COUT(4) << "  fabricating " << child->Value() << "..." << std::endl;
-                    BaseObject* newObject = identifier->fabricate();
-                    newObject->XMLPort(*child, true);
+                    if (Loader::currentMask_s.isIncluded(identifier))
+                    {
+                        COUT(4) << "  fabricating " << child->Value() << "..." << std::endl;
+                        BaseObject* newObject = identifier->fabricate();
+                        newObject->setLoaderIndentation("    ");
+                        newObject->setLevel(level);
+                        newObject->XMLPort(*child, true);
+                        COUT(5) << "  ...fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << std::endl;
+                    }
                 }
                 else
                 {
-                    COUT(2) << "  Warning: '"<< child->Value() <<"' is not a valid classname." << std::endl;
+                    COUT(2) << "  Warning: '" << child->Value() << "' is not a valid classname." << std::endl;
                 }
             }
@@ -135,4 +142,5 @@
         catch(ticpp::Exception& ex)
         {
+            COUT(1) << std::endl;
             COUT(1) << "An error occurred in Loader.cc while loading " << level->getFile() << ":" << std::endl;
             COUT(1) << ex.what() << std::endl;
Index: code/branches/core/src/orxonox/core/Loader.h
===================================================================
--- code/branches/core/src/orxonox/core/Loader.h	(revision 855)
+++ code/branches/core/src/orxonox/core/Loader.h	(revision 856)
@@ -56,4 +56,6 @@
             static bool reload(const Level* level, const ClassTreeMask& mask = ClassTreeMask());
 
+            static ClassTreeMask currentMask_s;
+
         private:
             static std::vector<std::pair<const Level*, ClassTreeMask> > levels_s;
Index: code/branches/core/src/orxonox/core/XMLPort.cc
===================================================================
--- code/branches/core/src/orxonox/core/XMLPort.cc	(revision 855)
+++ code/branches/core/src/orxonox/core/XMLPort.cc	(revision 856)
@@ -31,4 +31,7 @@
 namespace orxonox
 {
+    // ###############################
+    // ###  XMLPortParamContainer  ###
+    // ###############################
     XMLPortParamContainer::XMLPortParamContainer()
     {
@@ -53,3 +56,29 @@
         return GetLocalisation(this->description_);
     }
+
+
+    // ################################
+    // ###  XMLPortObjectContainer  ###
+    // ################################
+    XMLPortObjectContainer::XMLPortObjectContainer()
+    {
+        this->bAddedDescription_ = false;
+    }
+
+    XMLPortObjectContainer& XMLPortObjectContainer::description(const std::string description)
+    {
+        if (!this->bAddedDescription_)
+        {
+            this->description_ = std::string("XMLPortObjectContainer::" + this->classname_ + "::" + this->sectionname_);
+            AddLanguageEntry(this->description_, description);
+            this->bAddedDescription_ = true;
+        }
+
+        return (*this);
+    }
+
+    const std::string& XMLPortObjectContainer::getDescription()
+    {
+        return GetLocalisation(this->description_);
+    }
 }
Index: code/branches/core/src/orxonox/core/XMLPort.h
===================================================================
--- code/branches/core/src/orxonox/core/XMLPort.h	(revision 855)
+++ code/branches/core/src/orxonox/core/XMLPort.h	(revision 856)
@@ -35,4 +35,7 @@
 #include "Functor.h"
 #include "Debug.h"
+#include "CoreIncludes.h"
+#include "BaseObject.h"
+#include "Loader.h"
 
 #include "CorePrereqs.h"
@@ -57,6 +60,19 @@
     xmlcontainer##loadfunction##savefunction->port(this, xmlelement, loading)
 
+#define XMLPortObject(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, loading) \
+    orxonox::XMLPortClassObjectContainer<classname, objectclass>* xmlcontainer##loadfunction##savefunction = (orxonox::XMLPortClassObjectContainer<classname, objectclass>*)(this->getIdentifier()->getXMLPortObjectContainer(sectionname)); \
+    if (!xmlcontainer##loadfunction##savefunction) \
+    { \
+        xmlcontainer##loadfunction##savefunction = new orxonox::XMLPortClassObjectContainer<classname, objectclass>(this->getIdentifier()->getName(), std::string(sectionname), &classname::loadfunction, &classname::savefunction); \
+        this->getIdentifier()->addXMLPortObjectContainer(sectionname, xmlcontainer##loadfunction##savefunction); \
+    } \
+    xmlcontainer##loadfunction##savefunction->port(this, xmlelement, loading)
+
+
 namespace orxonox
 {
+    // ###############################
+    // ###  XMLPortParamContainer  ###
+    // ###############################
     class _CoreExport XMLPortParamContainer
     {
@@ -108,30 +124,45 @@
                 if (loading)
                 {
-                    std::string attribute = xmlelement.GetAttribute(this->paramname_);
-                    if (attribute.size() > 0)
-                    {
-                        SubString tokens(attribute, ",", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0');
-                        if ((unsigned int)tokens.size() >= (unsigned int)this->loadfunction_->getParamCount())
+                    try
+                    {
+                        std::string attribute = xmlelement.GetAttribute(this->paramname_);
+                        if (attribute.size() > 0)
                         {
-                            if (this->loadfunction_->getParamCount() == 1)
+                            SubString tokens(attribute, ",", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0');
+                            if ((unsigned int)tokens.size() >= (unsigned int)this->loadfunction_->getParamCount())
                             {
-                                (*this->loadfunction_)(object, MultiTypeMath(attribute));
+                                COUT(5) << object->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << this->classname_ << " (objectname " << object->getName() << ") with ";
+                                if (this->loadfunction_->getParamCount() == 1)
+                                {
+                                    COUT(5) << "1 parameter (using whole string):" << std::endl;
+                                    COUT(5) << object->getLoaderIndentation() << "  " << attribute << std::endl;
+                                    (*this->loadfunction_)(object, MultiTypeMath(attribute));
+                                }
+                                else
+                                {
+                                    COUT(5) << tokens.size() << " parameter (using MultiTypeMath)." << std::endl;
+                                    MultiTypeMath param1, param2, param3, param4, param5;
+                                    if (tokens.size() >= 1) param1 = tokens[0];
+                                    if (tokens.size() >= 2) param1 = tokens[1];
+                                    if (tokens.size() >= 3) param1 = tokens[2];
+                                    if (tokens.size() >= 4) param1 = tokens[3];
+                                    if (tokens.size() >= 5) param1 = tokens[4];
+                                    COUT(5) << object->getLoaderIndentation() << "  " << attribute << std::endl;
+                                    COUT(5) << object->getLoaderIndentation() << "  " << tokens[0] << " -> " << param1 << ", " << tokens[1] << " -> " << param2 << ", " << tokens[2] << " -> " << param3 << ", " << tokens[3] << " -> " << param4 << ", " << tokens[4] << " -> " << param5 << std::endl;
+
+                                    (*this->loadfunction_)(object, param1, param2, param3, param4, param5);
+                                }
                             }
                             else
                             {
-                                MultiTypeMath param1, param2, param3, param4, param5;
-                                if (tokens.size() >= 1) param1 = tokens[0];
-                                if (tokens.size() >= 2) param1 = tokens[1];
-                                if (tokens.size() >= 3) param1 = tokens[2];
-                                if (tokens.size() >= 4) param1 = tokens[3];
-                                if (tokens.size() >= 5) param1 = tokens[4];
-
-                                (*this->loadfunction_)(object, param1, param2, param3, param4, param5);
+                                COUT(2) << object->getLoaderIndentation() << "Warning: Parameter \"" << this->paramname_ << "\" in \"" << this->classname_ << "\" (objectname: " << object->getName() << ") is incomplete and couln't be loaded." << std::endl;
                             }
                         }
-                        else
-                        {
-                            COUT(2) << "  Warning: Parameter \"" << this->paramname_ << "\" in \"" << this->classname_ << "\" (objectname: " << object->getName() << ") is incomplete and couln't be loaded." << std::endl;
-                        }
+                    }
+                    catch(ticpp::Exception& ex)
+                    {
+                        COUT(1) << std::endl;
+                        COUT(1) << "An error occurred in XMLPort.h while loading attribute '" << this->paramname_ << "' of '" << this->classname_ << "' (objectname: " << object->getName() << ") in " << object->getLevelfile() << ":" << std::endl;
+                        COUT(1) << ex.what() << std::endl;
                     }
                 }
@@ -151,4 +182,100 @@
             FunctorMember<T>* savefunction_;
     };
+
+
+    // ################################
+    // ###  XMLPortObjectContainer  ###
+    // ################################
+    class _CoreExport XMLPortObjectContainer
+    {
+        public:
+            XMLPortObjectContainer();
+
+            inline const std::string& getName() const
+                { return this->sectionname_; }
+
+            XMLPortObjectContainer& description(const std::string description);
+            const std::string& getDescription();
+
+        protected:
+            std::string classname_;
+            std::string sectionname_;
+
+        private:
+            LanguageEntryLabel description_;
+            bool bAddedDescription_;
+    };
+
+    template <class T, class O>
+    class XMLPortClassObjectContainer : public XMLPortObjectContainer
+    {
+        public:
+            XMLPortClassObjectContainer(const std::string classname, const std::string sectionname, void (T::*loadfunction)(O*), const O* (T::*savefunction)(unsigned int))
+            {
+                this->classname_ = classname;
+                this->sectionname_ = sectionname;
+                this->loadfunction_ = loadfunction;
+                this->savefunction_ = savefunction;
+            }
+
+            XMLPortObjectContainer& port(T* object, Element& xmlelement, bool loading)
+            {
+                if (loading)
+                {
+                    try
+                    {
+                        Element* xmlsubelement = xmlelement.FirstChildElement(this->sectionname_, false);
+
+                        if (xmlsubelement)
+                        {
+                            for ( ticpp::Iterator<ticpp::Element> child = xmlsubelement->FirstChildElement(false); child != child.end(); child++ )
+                            {
+                                Identifier* identifier = ID(child->Value());
+                                if (identifier)
+                                {
+                                    if (identifier->isA(Class(O)))
+                                    {
+                                        if (Loader::currentMask_s.isIncluded(identifier))
+                                        {
+                                            COUT(4) << object->getLoaderIndentation() << "fabricating " << child->Value() << "..." << std::endl;
+                                            O* newObject = (O*)identifier->fabricate();
+                                            newObject->setLoaderIndentation(object->getLoaderIndentation() + "  ");
+                                            newObject->setLevel(object->getLevel());
+                                            newObject->XMLPort(*child, true);
+                                            COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->classname_ << " (objectname " << object->getName() << ")" << std::endl;
+                                            (*object.*this->loadfunction_)(newObject);
+                                            COUT(5) << "  ...fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << std::endl;
+                                        }
+                                    }
+                                    else
+                                    {
+                                        COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not a '" << Class(O)->getName() << "'." << std::endl;
+                                    }
+                                }
+                                else
+                                {
+                                    COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not a valid classname." << std::endl;
+                                }
+                            }
+                        }
+                    }
+                    catch(ticpp::Exception& ex)
+                    {
+                        COUT(1) << std::endl;
+                        COUT(1) << "An error occurred in XMLPort.h while loading a '" << Class(O)->getName() << "' in '" << this->sectionname_ << "' of '" << this->classname_ << "' (objectname: " << object->getName() << ") in " << object->getLevelfile() << ":" << std::endl;
+                        COUT(1) << ex.what() << std::endl;
+                    }
+                }
+                else
+                {
+                }
+
+                return (*this);
+            }
+
+        private:
+            void     (T::*loadfunction_)(O*);
+            const O* (T::*savefunction_)(unsigned int);
+    };
 }
 
Index: code/branches/core/src/orxonox/objects/WorldEntity.cc
===================================================================
--- code/branches/core/src/orxonox/objects/WorldEntity.cc	(revision 855)
+++ code/branches/core/src/orxonox/objects/WorldEntity.cc	(revision 856)
@@ -167,5 +167,4 @@
     Element& WorldEntity::XMLPort(Element& xmlelement, bool loading)
     {
-std::cout << "2_1: " << this->getPosition() << std::endl;
         BaseObject::XMLPort(xmlelement, loading);
 
@@ -178,5 +177,6 @@
         XMLPortParam(WorldEntity, "rotationAxis", setRotationAxis, getRotationAxis, xmlelement, loading);
         XMLPortParam(WorldEntity, "rotationRate", setRotationRate, getRotationRate, xmlelement, loading);
-std::cout << "2_2: " << this->getPosition() << std::endl;
+
+        XMLPortObject(WorldEntity, WorldEntity, "attached", attachWorldEntity, getAttachedWorldEntity, xmlelement, loading);
 
         return xmlelement;
@@ -210,3 +210,16 @@
       registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA);*/
     }
+
+    void WorldEntity::attachWorldEntity(WorldEntity* entity)
+    {
+        this->attachedWorldEntities_.push_back(entity);
+    }
+
+    const WorldEntity* WorldEntity::getAttachedWorldEntity(unsigned int index)
+    {
+        if (index < this->attachedWorldEntities_.size())
+            return this->attachedWorldEntities_[index];
+        else
+            return 0;
+    }
 }
Index: code/branches/core/src/orxonox/objects/WorldEntity.h
===================================================================
--- code/branches/core/src/orxonox/objects/WorldEntity.h	(revision 855)
+++ code/branches/core/src/orxonox/objects/WorldEntity.h	(revision 856)
@@ -27,4 +27,7 @@
             virtual Element& XMLPort(Element& xmlelement, bool loading);
             bool create();
+
+            void attachWorldEntity(WorldEntity* entity);
+            const WorldEntity* getAttachedWorldEntity(unsigned int index);
 
             inline Ogre::SceneNode* getNode()
@@ -156,4 +159,5 @@
             Ogre::SceneNode* node_;
             bool bStatic_;
+            std::vector<WorldEntity*> attachedWorldEntities_;
     };
 }
