Index: code/branches/core5/src/libraries/core/BaseObject.cc
===================================================================
--- code/branches/core5/src/libraries/core/BaseObject.cc	(revision 5865)
+++ code/branches/core5/src/libraries/core/BaseObject.cc	(revision 5866)
@@ -94,9 +94,9 @@
         if (this->isInitialized())
         {
-            for (std::list<BaseObject*>::const_iterator it = this->events_.begin(); it != this->events_.end(); ++it)
-                (*it)->unregisterEventListener(this);
-
-            for (std::map<BaseObject*, std::string>::const_iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
-                it->first->removeEvent(this);
+            for (std::map<BaseObject*, std::string>::const_iterator it = this->eventSources_.begin(); it != this->eventSources_.end(); )
+                this->removeEventSource((it++)->first);
+
+            for (std::set<BaseObject*>::const_iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); )
+                (*(it++))->removeEventSource(this);
 
             for (std::map<std::string, EventContainer*>::const_iterator it = this->eventContainers_.begin(); it != this->eventContainers_.end(); ++it)
@@ -145,7 +145,8 @@
             {
                 std::string sectionname = (*it);
-                ExecutorMember<BaseObject>* loadexecutor = createExecutor(createFunctor(&BaseObject::addEvent), std::string( "BaseObject" ) + "::" + "addEvent");
-                ExecutorMember<BaseObject>* saveexecutor = createExecutor(createFunctor(&BaseObject::getEvent), std::string( "BaseObject" ) + "::" + "getEvent");
+                ExecutorMember<BaseObject>* loadexecutor = createExecutor(createFunctor(&BaseObject::addEventSource), std::string( "BaseObject" ) + "::" + "addEventSource");
+                ExecutorMember<BaseObject>* saveexecutor = createExecutor(createFunctor(&BaseObject::getEventSource), std::string( "BaseObject" ) + "::" + "getEventSource");
                 loadexecutor->setDefaultValue(1, sectionname);
+                saveexecutor->setDefaultValue(1, sectionname);
 
                 XMLPortClassObjectContainer<BaseObject, BaseObject>* container = 0;
@@ -224,22 +225,37 @@
     }
 
-    void BaseObject::addEvent(BaseObject* event, const std::string& sectionname)
-    {
-        event->registerEventListener(this, sectionname);
-        this->events_.push_back(event);
-    }
-
-    void BaseObject::removeEvent(BaseObject* event)
-    {
-        this->events_.remove(event);
-    }
-
-    BaseObject* BaseObject::getEvent(unsigned int index) const
+    /**
+        @brief Adds a new event source for a specific state.
+        @param source The object which sends events to this object
+        @param state The state of this object which will be affected by the events
+    */
+    void BaseObject::addEventSource(BaseObject* source, const std::string& state)
+    {
+        this->eventSources_[source] = state;
+        source->registerEventListener(this);
+    }
+
+    /**
+        @brief Removes an eventsource (but doesn't unregister itself at the source).
+    */
+    void BaseObject::removeEventSource(BaseObject* source)
+    {
+        this->eventSources_.erase(source);
+        source->unregisterEventListener(this);
+    }
+
+    /**
+        @brief Returns an eventsource with a given index.
+    */
+    BaseObject* BaseObject::getEventSource(unsigned int index, const std::string& state) const
     {
         unsigned int i = 0;
-        for (std::list<BaseObject*>::const_iterator it = this->events_.begin(); it != this->events_.end(); ++it)
-        {
+        for (std::map<BaseObject*, std::string>::const_iterator it = this->eventSources_.begin(); it != this->eventSources_.end(); ++it)
+        {
+            if (it->second != state)
+                continue;
+            
             if (i == index)
-                return (*it);
+                return it->first;
             ++i;
         }
@@ -268,4 +284,7 @@
     }
 
+    /**
+        @brief Fires an event (without a state).
+    */
     void BaseObject::fireEvent()
     {
@@ -274,4 +293,7 @@
     }
 
+    /**
+        @brief Fires an event which activates or deactivates a state.
+    */
     void BaseObject::fireEvent(bool activate)
     {
@@ -279,19 +301,25 @@
     }
 
+    /**
+        @brief Fires an event which activates or deactivates a state with agiven originator (the object which sends the event).
+    */
     void BaseObject::fireEvent(bool activate, BaseObject* originator)
     {
         Event event(activate, originator);
 
-        for (std::map<BaseObject*, std::string>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
-        {
-            event.sectionname_ = it->second;
-            it->first->processEvent(event);
-        }
-    }
-
+        for (std::set<BaseObject*>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
+        {
+            event.sectionname_ = (*it)->eventSources_[this];
+            (*it)->processEvent(event);
+        }
+    }
+
+    /**
+        @brief Fires an event, using the Event struct.
+    */
     void BaseObject::fireEvent(Event& event)
     {
-        for (std::map<BaseObject*, std::string>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
-            it->first->processEvent(event);
+        for (std::set<BaseObject*>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
+            (*it)->processEvent(event);
     }
 
Index: code/branches/core5/src/libraries/core/BaseObject.h
===================================================================
--- code/branches/core5/src/libraries/core/BaseObject.h	(revision 5865)
+++ code/branches/core5/src/libraries/core/BaseObject.h	(revision 5866)
@@ -152,4 +152,8 @@
             virtual void changedGametype() {}
 
+            void addEventSource(BaseObject* source, const std::string& state);
+            void removeEventSource(BaseObject* source);
+            BaseObject* getEventSource(unsigned int index, const std::string& state) const;
+
             void fireEvent();
             void fireEvent(bool activate);
@@ -159,16 +163,4 @@
             virtual void processEvent(Event& event);
 
-            inline void registerEventListener(BaseObject* object, const std::string& sectionname)
-                { this->eventListeners_[object] = sectionname; }
-            inline void unregisterEventListener(BaseObject* object)
-                { this->eventListeners_.erase(object); }
-
-            void addEvent(BaseObject* event, const std::string& sectionname);
-            void removeEvent(BaseObject* event);
-            BaseObject* getEvent(unsigned int index) const;
-
-            void addEventContainer(const std::string& sectionname, EventContainer* container);
-            EventContainer* getEventContainer(const std::string& sectionname) 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; }
@@ -177,4 +169,14 @@
 
         protected:
+            /** @brief Adds an object which listens to the events of this object. */
+            inline void registerEventListener(BaseObject* object)
+                { this->eventListeners_.insert(object); }
+            /** @brief Removes an event listener from this object. */
+            inline void unregisterEventListener(BaseObject* object)
+                { this->eventListeners_.erase(object); }
+
+            void addEventContainer(const std::string& sectionname, EventContainer* container);
+            EventContainer* getEventContainer(const std::string& sectionname) const;
+
             std::string name_;                                 //!< The name of the object
             std::string oldName_;                              //!< The old name of the object
@@ -197,11 +199,12 @@
             BaseObject*            creator_;
             SmartPtr<Scene>        scene_;
+            uint32_t               sceneID_;
             SmartPtr<Gametype>     gametype_;
             Gametype*              oldGametype_;
             std::set<Template*>    templates_;
-            std::map<BaseObject*,  std::string> eventListeners_;
-            std::list<BaseObject*> events_;
-            std::map<std::string, EventContainer*> eventContainers_;
-            uint32_t               sceneID_;
+            
+            std::map<BaseObject*, std::string>      eventSources_;      //!< List of objects which send events to this object, mapped to the state which they affect
+            std::set<BaseObject*>                   eventListeners_;    //!< List of objects which listen to the events of this object
+            std::map<std::string, EventContainer*>  eventContainers_;
     };
 
Index: code/branches/core5/src/libraries/core/Event.cc
===================================================================
--- code/branches/core5/src/libraries/core/Event.cc	(revision 5865)
+++ code/branches/core5/src/libraries/core/Event.cc	(revision 5866)
@@ -30,5 +30,4 @@
 
 #include "BaseObject.h"
-#include "Executor.h"
 
 namespace orxonox
Index: code/branches/core5/src/libraries/core/Event.h
===================================================================
--- code/branches/core5/src/libraries/core/Event.h	(revision 5865)
+++ code/branches/core5/src/libraries/core/Event.h	(revision 5866)
@@ -48,5 +48,5 @@
     {
         public:
-            EventContainer(const std::string& eventname, Executor* eventfunction, Identifier* subclass) : bActive_(false), eventname_(eventname), eventfunction_(eventfunction), subclass_(subclass), activeEvents_(0) {}
+            EventContainer(const std::string& eventname, Functor* eventfunction, Identifier* subclass) : bActive_(false), eventname_(eventname), eventfunction_(eventfunction), subclass_(subclass), activeEvents_(0) {}
             virtual ~EventContainer();
 
@@ -56,5 +56,5 @@
             bool bActive_;
             std::string eventname_;
-            Executor* eventfunction_;
+            Functor* eventfunction_;
             Identifier* subclass_;
 
Index: code/branches/core5/src/libraries/core/EventIncludes.h
===================================================================
--- code/branches/core5/src/libraries/core/EventIncludes.h	(revision 5865)
+++ code/branches/core5/src/libraries/core/EventIncludes.h	(revision 5866)
@@ -40,7 +40,9 @@
 
 #define ORXONOX_SET_SUBCLASS_EVENT(classname, eventname, functionname, event, subclassname) \
+    event.castedOriginator_ = orxonox::orxonox_cast<subclassname*>(event.originator_); \
     ORXONOX_SET_EVENT_GENERIC(eventcontainer##classname##functionname, classname, eventname, functionname, event, subclassname)
 
 #define ORXONOX_SET_SUBCLASS_EVENT_TEMPLATE(classname, eventname, functionname, event, subclassname, ...) \
+    event.castedOriginator_ = orxonox::orxonox_cast<subclassname*>(event.originator_); \
     ORXONOX_SET_EVENT_GENERIC_TEMPLATE(eventcontainer##classname##functionname, classname, eventname, functionname, event, subclassname, __VA_ARGS__)
 
@@ -49,9 +51,8 @@
     if (!containername) \
     { \
-        ExecutorMember<classname>* executor = orxonox::createExecutor(orxonox::createFunctor(&classname::functionname, this), std::string( #classname ) + "::" + #functionname); \
-        containername = new orxonox::EventContainer(std::string(eventname), executor, orxonox::ClassIdentifier<subclassname>::getIdentifier()); \
+        Functor* functor = orxonox::createFunctor(&classname::functionname, this); \
+        containername = new orxonox::EventContainer(std::string(eventname), functor, orxonox::ClassIdentifier<subclassname>::getIdentifier()); \
         this->addEventContainer(eventname, containername); \
     } \
-    event.castedOriginator_ = orxonox::orxonox_cast<subclassname*>(event.originator_); \
     containername->process(this, event)
 
@@ -60,9 +61,8 @@
     if (!containername) \
     { \
-        ExecutorMember<classname>* executor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::functionname, this), std::string( #classname ) + "::" + #functionname); \
-        containername = new orxonox::EventContainer(std::string(eventname), executor, orxonox::ClassIdentifier<subclassname>::getIdentifier()); \
+        Functor* functor = orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::functionname, this); \
+        containername = new orxonox::EventContainer(std::string(eventname), functor, orxonox::ClassIdentifier<subclassname>::getIdentifier()); \
         this->addEventContainer(eventname, containername); \
     } \
-    event.castedOriginator_ = orxonox::orxonox_cast<subclassname*>(event.originator_); \
     containername->process(this, event)
 
Index: code/branches/core5/src/libraries/core/Identifier.h
===================================================================
--- code/branches/core5/src/libraries/core/Identifier.h	(revision 5865)
+++ code/branches/core5/src/libraries/core/Identifier.h	(revision 5866)
@@ -261,4 +261,14 @@
             inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortObjectMapEnd() const { return this->xmlportObjectContainers_.end(); }
 
+            void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container);
+            XMLPortParamContainer* getXMLPortParamContainer(const std::string& paramname);
+
+            void addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container);
+            XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname);
+
+
+            //////////////////
+            ///// Events /////
+            //////////////////
             /** @brief Returns the map that stores all XMLPort events. @return The const_iterator */
             inline const std::map<std::string, XMLPortObjectContainer*>& getXMLPortEventMap() const { return this->xmlportEventContainers_; }
@@ -267,10 +277,4 @@
             /** @brief Returns a const_iterator to the end of the map that stores all XMLPort events. @return The const_iterator */
             inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortEventMapEnd() const { return this->xmlportEventContainers_.end(); }
-
-            void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container);
-            XMLPortParamContainer* getXMLPortParamContainer(const std::string& paramname);
-
-            void addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container);
-            XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname);
 
             void addXMLPortEventContainer(const std::string& eventname, XMLPortObjectContainer* container);
Index: code/branches/core5/src/modules/objects/eventsystem/EventListener.cc
===================================================================
--- code/branches/core5/src/modules/objects/eventsystem/EventListener.cc	(revision 5865)
+++ code/branches/core5/src/modules/objects/eventsystem/EventListener.cc	(revision 5866)
@@ -78,5 +78,5 @@
         for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
             if (it->getName() == this->eventName_)
-                this->registerAsListener(*it);
+                this->addEventSource(*it, "");
     }
 
@@ -87,10 +87,5 @@
 
         if (object->getName() == this->eventName_)
-            this->registerAsListener(object);
-    }
-
-    void EventListener::registerAsListener(BaseObject* object)
-    {
-        object->registerEventListener(this, "");
+            this->addEventSource(object, "");
     }
 }
Index: code/branches/core5/src/modules/objects/eventsystem/EventListener.h
===================================================================
--- code/branches/core5/src/modules/objects/eventsystem/EventListener.h	(revision 5865)
+++ code/branches/core5/src/modules/objects/eventsystem/EventListener.h	(revision 5866)
@@ -54,5 +54,4 @@
         private:
             virtual void loadedNewXMLName(BaseObject* object);
-            void registerAsListener(BaseObject* object);
 
             std::string eventName_;
Index: code/branches/core5/src/modules/objects/eventsystem/EventTarget.cc
===================================================================
--- code/branches/core5/src/modules/objects/eventsystem/EventTarget.cc	(revision 5865)
+++ code/branches/core5/src/modules/objects/eventsystem/EventTarget.cc	(revision 5866)
@@ -49,5 +49,5 @@
         for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
             if (it->getName() == this->getName())
-                this->addAsEvent(*it);
+                this->addEventTarget(*it);
     }
 
@@ -58,11 +58,11 @@
 
         if (object->getName() == this->getName())
-            this->addAsEvent(object);
+            this->addEventTarget(object);
     }
 
-    void EventTarget::addAsEvent(BaseObject* object)
+    void EventTarget::addEventTarget(BaseObject* object)
     {
         if (object != static_cast<BaseObject*>(this))
-            object->addEvent(this, "");
+            object->addEventSource(this, "");
     }
 }
Index: code/branches/core5/src/modules/objects/eventsystem/EventTarget.h
===================================================================
--- code/branches/core5/src/modules/objects/eventsystem/EventTarget.h	(revision 5865)
+++ code/branches/core5/src/modules/objects/eventsystem/EventTarget.h	(revision 5866)
@@ -47,5 +47,5 @@
         private:
             virtual void loadedNewXMLName(BaseObject* object);
-            void addAsEvent(BaseObject* object);
+            void addEventTarget(BaseObject* object);
     };
 }
