Index: code/branches/core2/src/orxonox/core/Loader.cc
===================================================================
--- code/branches/core2/src/orxonox/core/Loader.cc	(revision 899)
+++ code/branches/core2/src/orxonox/core/Loader.cc	(revision 901)
@@ -115,6 +115,8 @@
             ticpp::Document xmlfile(level->getFile());
             xmlfile.LoadFile();
+
             ticpp::Element rootElement;
             rootElement.SetAttribute("name", "root");
+            rootElement.SetAttribute("bAutogenerated", true);
 
             for (ticpp::Iterator<ticpp::Element> child = xmlfile.FirstChildElement(false); child != child.end(); child++)
@@ -126,8 +128,10 @@
             rootNamespace->setLevel(level);
             rootNamespace->setNamespace(rootNamespace);
-            rootNamespace->deleteNamespaceNodesAfterDestruction(true);
+            rootNamespace->setRoot(true);
             rootNamespace->XMLPort(rootElement, true);
 
             COUT(0) << "Finished loading " << level->getFile() << "." << std::endl;
+
+            COUT(4) << "Namespace-tree:" << std::endl << rootNamespace->toString("  ") << std::endl;
 
             return true;
Index: code/branches/core2/src/orxonox/core/Namespace.cc
===================================================================
--- code/branches/core2/src/orxonox/core/Namespace.cc	(revision 899)
+++ code/branches/core2/src/orxonox/core/Namespace.cc	(revision 901)
@@ -41,5 +41,5 @@
 
         this->bAutogeneratedFileRootNamespace_ = false;
-        this->bDeleteNamespaceNodesAfterDestruction_ = false;
+        this->bRoot_ = false;
         this->operator_ = "or";
     }
@@ -47,5 +47,5 @@
     Namespace::~Namespace()
     {
-        if (this->bDeleteNamespaceNodesAfterDestruction_)
+        if (this->bRoot_)
             for (std::set<NamespaceNode*>::iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); ++it)
                 delete (*it);
@@ -73,10 +73,17 @@
             name.replace(pos, 1, " ");
         SubString tokens(name, " ", "", false, '\\', '"', '\0', '\0', '\0');
-        for (unsigned int i = 0; i < tokens.size(); i++)
+        if (this->bRoot_)
         {
-            for (std::set<NamespaceNode*>::iterator it = this->getNamespace()->representingNamespaces_.begin(); it != this->getNamespace()->representingNamespaces_.end(); ++it)
+            this->representingNamespaces_.insert(new NamespaceNode(this->getName()));
+        }
+        else
+        {
+            for (unsigned int i = 0; i < tokens.size(); i++)
             {
-                std::set<NamespaceNode*> temp = (*it)->getNodeRelative(tokens[i]);
-                this->representingNamespaces_.insert(temp.begin(), temp.end());
+                for (std::set<NamespaceNode*>::iterator it = this->getNamespace()->representingNamespaces_.begin(); it != this->getNamespace()->representingNamespaces_.end(); ++it)
+                {
+                    std::set<NamespaceNode*> temp = (*it)->getNodeRelative(tokens[i]);
+                    this->representingNamespaces_.insert(temp.begin(), temp.end());
+                }
             }
         }
@@ -138,3 +145,35 @@
         return false;
     }
+
+    std::string Namespace::toString() const
+    {
+        std::string output;
+
+        int i = 0;
+        for (std::set<NamespaceNode*>::const_iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); i++, ++it)
+        {
+            if (i > 0)
+                output += " / ";
+
+            output += (*it)->toString();
+        }
+
+        return output;
+    }
+
+    std::string Namespace::toString(const std::string& indentation) const
+    {
+        std::string output;
+
+        int i = 0;
+        for (std::set<NamespaceNode*>::const_iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); i++, ++it)
+        {
+            if (i > 0)
+                output += "\n";
+
+            output += (*it)->toString(indentation);
+        }
+
+        return output;
+    }
 }
Index: code/branches/core2/src/orxonox/core/Namespace.h
===================================================================
--- code/branches/core2/src/orxonox/core/Namespace.h	(revision 899)
+++ code/branches/core2/src/orxonox/core/Namespace.h	(revision 901)
@@ -59,14 +59,17 @@
                 { return this->operator_; }
 
+            void setRoot(bool bRoot)
+                { this->bRoot_ = bRoot; }
+
             bool includes(const Namespace* ns) const;
             bool isIncludedIn(const Namespace* ns) const { return ns->includes(this); }
 
-            void deleteNamespaceNodesAfterDestruction(bool bDelete)
-                { this->bDeleteNamespaceNodesAfterDestruction_ = bDelete; }
+            std::string toString() const;
+            std::string toString(const std::string& indentation) const;
 
         private:
             std::set<NamespaceNode*> representingNamespaces_;
             bool bAutogeneratedFileRootNamespace_;
-            bool bDeleteNamespaceNodesAfterDestruction_;
+            bool bRoot_;
             std::string operator_;
     };
Index: code/branches/core2/src/orxonox/core/NamespaceNode.cc
===================================================================
--- code/branches/core2/src/orxonox/core/NamespaceNode.cc	(revision 899)
+++ code/branches/core2/src/orxonox/core/NamespaceNode.cc	(revision 901)
@@ -49,5 +49,5 @@
         std::set<NamespaceNode*> nodes;
 
-        if (name == "")
+        if ((name.size() == 0) || (name == ""))
         {
             nodes.insert(this);
@@ -56,6 +56,12 @@
         {
             unsigned int pos = name.find("::");
-            std::string firstPart = name.substr(0, pos);
-            std::string secondPart = name.substr(pos + 2, std::string::npos);
+            std::string firstPart = name;
+            std::string secondPart;
+
+            if (pos != std::string::npos)
+            {
+                firstPart = name.substr(0, pos);
+                secondPart = name.substr(pos + 2, std::string::npos);
+            }
 
             if (firstPart == "..")
@@ -64,4 +70,9 @@
                 {
                     COUT(2) << "Warning: Can't go to enclosing namespace with '..' operator in namespace " << this->name_ << ", namespace is root." << std::endl;
+                    nodes = this->getNodeRelative(secondPart);
+                }
+                else if (!this->parent_)
+                {
+                    COUT(2) << "Warning: Can't go to enclosing namespace with '..' operator in namespace " << this->name_ << ", no parent namespace set." << std::endl;
                     nodes = this->getNodeRelative(secondPart);
                 }
@@ -78,10 +89,17 @@
 
                 if ((*it).second->isHidden())
+                {
                     COUT(2) << "Warning: Subnamespace '" << firstPart << "' in namespace '" << this->name_ << "' is hidden and can't be accessed." << std::endl;
+                    nodes.insert(this);
+                }
                 else
+                {
                     nodes = (*it).second->getNodeRelative(secondPart);
+                }
             }
             else
             {
+                bool bFoundMatchingNamespace = false;
+
                 for (std::map<std::string, NamespaceNode*>::iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ++it)
                 {
@@ -90,5 +108,12 @@
                         std::set<NamespaceNode*> temp2 = (*it).second->getNodeRelative(secondPart);
                         nodes.insert(temp2.begin(), temp2.end());
+                        bFoundMatchingNamespace = true;
                     }
+                }
+
+                if (!bFoundMatchingNamespace)
+                {
+                    COUT(2) << "Warning: No file included with name '" << firstPart.substr(1, std::string::npos) << "' at this part of the level file, using parent namespace instead." << std::endl;
+                    nodes = this->getNodeRelative(secondPart);
                 }
             }
@@ -113,3 +138,36 @@
         return false;
     }
+
+    std::string NamespaceNode::toString() const
+    {
+        std::string output = this->name_;
+
+        if (this->subnodes_.size() > 0)
+        {
+            output += " (";
+
+            int i = 0;
+            for (std::map<std::string, NamespaceNode*>::const_iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); i++, ++it)
+            {
+                if (i > 0)
+                    output += ", ";
+
+                output += (*it).second->toString();
+            }
+
+            output += ")";
+        }
+
+        return output;
+    }
+
+    std::string NamespaceNode::toString(const std::string& indentation) const
+    {
+        std::string output = (indentation + this->name_ + "\n");
+
+        for (std::map<std::string, NamespaceNode*>::const_iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ++it)
+            output += (*it).second->toString(indentation + "  ");
+
+        return output;
+    }
 }
Index: code/branches/core2/src/orxonox/core/NamespaceNode.h
===================================================================
--- code/branches/core2/src/orxonox/core/NamespaceNode.h	(revision 899)
+++ code/branches/core2/src/orxonox/core/NamespaceNode.h	(revision 901)
@@ -53,4 +53,7 @@
             bool includes(const NamespaceNode*) const;
 
+            std::string toString() const;
+            std::string toString(const std::string& indentation) const;
+
         private:
             std::string name_;
Index: code/branches/core2/src/orxonox/core/XMLPort.h
===================================================================
--- code/branches/core2/src/orxonox/core/XMLPort.h	(revision 899)
+++ code/branches/core2/src/orxonox/core/XMLPort.h	(revision 901)
@@ -256,6 +256,12 @@
                                             newObject->setNamespace(object->getNamespace());
                                             if (this->bLoadBefore_)
+                                            {
                                                 newObject->XMLPort(*child, true);
-                                            COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->classname_ << " (objectname " << object->getName() << ")" << std::endl;
+                                                COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->classname_ << " (objectname " << object->getName() << ")" << std::endl;
+                                            }
+                                            else
+                                            {
+                                                COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->classname_ << " (objectname " << object->getName() << ")" << std::endl;
+                                            }
                                             (*object.*this->loadfunction_)(newObject);
                                             if (!this->bLoadBefore_)
