Index: code/trunk/src/libraries/core/BaseObject.cc
===================================================================
--- code/trunk/src/libraries/core/BaseObject.cc	(revision 10624)
+++ code/trunk/src/libraries/core/BaseObject.cc	(revision 11071)
@@ -65,7 +65,7 @@
         this->bRegisteredEventStates_ = false;
 
-        this->lastLoadedXMLElement_ = 0;
-
-        this->mainStateFunctor_ = 0;
+        this->lastLoadedXMLElement_ = nullptr;
+
+        this->mainStateFunctor_ = nullptr;
 
         if (context)
@@ -86,5 +86,5 @@
         else
         {
-            this->file_ = 0;
+            this->file_ = nullptr;
             this->sceneID_ = OBJECTID_UNKNOWN;
         }
@@ -132,5 +132,5 @@
         XMLPortObject(BaseObject, BaseObject, "eventlisteners", addEventListener, getEventListener, xmlelement, mode);
 
-        Element* events = 0;
+        Element* events = nullptr;
         if (mode == XMLPort::LoadObject || mode == XMLPort::ExpandObject)
             events = xmlelement.FirstChildElement("events", false);
@@ -163,6 +163,6 @@
         this->setName(name);
 
-        for (ObjectList<XMLNameListener>::iterator it = ObjectList<XMLNameListener>::begin(); it != ObjectList<XMLNameListener>::end(); ++it)
-            it->loadedNewXMLName(this);
+        for (XMLNameListener* listener : ObjectList<XMLNameListener>())
+            listener->loadedNewXMLName(this);
     }
 
@@ -205,5 +205,5 @@
             Template* link;
             assert(!(link = Template::getTemplate(temp->getLink())) || !link->isLink());
-            link = NULL;
+            link = nullptr;
         }
         else
@@ -234,11 +234,11 @@
     {
         unsigned int i = 0;
-        for (std::set<Template*>::const_iterator it = this->templates_.begin(); it != this->templates_.end(); ++it)
+        for (Template* temp : this->templates_)
         {
             if (i == index)
-                return (*it);
+                return temp;
             i++;
         }
-        return 0;
+        return nullptr;
     }
 
@@ -269,14 +269,14 @@
     {
         unsigned int i = 0;
-        for (std::map<BaseObject*, std::string>::const_iterator it = this->eventSources_.begin(); it != this->eventSources_.end(); ++it)
-        {
-            if (it->second != state)
+        for (const auto& mapEntry : this->eventSources_)
+        {
+            if (mapEntry.second != state)
                 continue;
 
             if (i == index)
-                return it->first;
+                return mapEntry.first;
             ++i;
         }
-        return 0;
+        return nullptr;
     }
 
@@ -296,11 +296,11 @@
     {
         unsigned int i = 0;
-        for (std::set<BaseObject*>::const_iterator it = this->eventListenersXML_.begin(); it != this->eventListenersXML_.end(); ++it)
+        for (BaseObject* listener : this->eventListenersXML_)
         {
             if (i == index)
-                return *it;
+                return listener;
             ++i;
         }
-        return 0;
+        return nullptr;
     }
 
@@ -331,5 +331,5 @@
             return (it->second);
         else
-            return 0;
+            return nullptr;
     }
 
@@ -358,8 +358,8 @@
         Event event(activate, originator, name);
 
-        for (std::set<BaseObject*>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
-        {
-            event.statename_ = (*it)->eventSources_[this];
-            (*it)->processEvent(event);
+        for (BaseObject* listener : this->eventListeners_)
+        {
+            event.statename_ = listener->eventSources_[this];
+            listener->processEvent(event);
         }
     }
@@ -370,6 +370,6 @@
     void BaseObject::fireEvent(Event& event)
     {
-        for (std::set<BaseObject*>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
-            (*it)->processEvent(event);
+        for (BaseObject* listener : this->eventListeners_)
+            listener->processEvent(event);
     }
 
@@ -423,5 +423,5 @@
     void BaseObject::changedMainStateName()
     {
-        this->mainStateFunctor_ = 0;
+        this->mainStateFunctor_ = nullptr;
 
         if (!this->mainStateName_.empty())
@@ -474,8 +474,6 @@
 
             // iterate through all states and get the event sources
-            for (std::list<std::string>::iterator it = eventnames.begin(); it != eventnames.end(); ++it)
-            {
-                const std::string& statename = (*it);
-
+            for (const std::string& statename : eventnames)
+            {
                 // if the event state is already known, continue with the next state
                 orxonox::EventState* eventstate = object->getEventState(statename);
