Index: code/branches/objecthierarchy/src/core/Event.cc
===================================================================
--- code/branches/objecthierarchy/src/core/Event.cc	(revision 2081)
+++ code/branches/objecthierarchy/src/core/Event.cc	(revision 2082)
@@ -38,6 +38,14 @@
     }
 
-    void EventContainer::process(void* object, const Event& event)
+    void EventContainer::process(BaseObject* object, const Event& event)
     {
+        if (this->bActive_)
+        {
+            COUT(2) << "Warning: Detected Event loop in section \"" << this->eventname_ << "\" of object \"" << object->getName() << "\" and fired by \"" << event.originator_->getName() << "\"" << std::endl;
+            return;
+        }
+
+        this->bActive_ = true;
+
         if (this->eventname_ == event.sectionname_)
         {
@@ -65,4 +73,6 @@
             }
         }
+
+        this->bActive_ = false;
     }
 }
Index: code/branches/objecthierarchy/src/core/Event.h
===================================================================
--- code/branches/objecthierarchy/src/core/Event.h	(revision 2081)
+++ code/branches/objecthierarchy/src/core/Event.h	(revision 2082)
@@ -47,10 +47,11 @@
     {
         public:
-            EventContainer(const std::string& eventname, Executor* eventfunction, Identifier* subclass) : eventname_(eventname), eventfunction_(eventfunction), subclass_(subclass), activeEvents_(0) {}
+            EventContainer(const std::string& eventname, Executor* eventfunction, Identifier* subclass) : bActive_(false), eventname_(eventname), eventfunction_(eventfunction), subclass_(subclass), activeEvents_(0) {}
             virtual ~EventContainer();
 
-            virtual void process(void* object, const Event& event);
+            void process(BaseObject* object, const Event& event);
 
         private:
+            bool bActive_;
             std::string eventname_;
             Executor* eventfunction_;
@@ -59,20 +60,4 @@
             int activeEvents_;
     };
-
-    template <class T>
-    class ClassEventContainer : public EventContainer
-    {
-        public:
-            ClassEventContainer(const std::string& eventname, ExecutorMember<T>* eventfunction, Identifier* subclass) : EventContainer(eventname, (Executor*)eventfunction, subclass), eventfunction_(eventfunction) {}
-
-            void process(void* object, const Event& event)
-            {
-                this->eventfunction_->setObject((T*)object);
-                EventContainer::process(object, event);
-            }
-
-        private:
-            ExecutorMember<T>* eventfunction_;
-    };
 }
 
Index: code/branches/objecthierarchy/src/core/EventIncludes.h
===================================================================
--- code/branches/objecthierarchy/src/core/EventIncludes.h	(revision 2081)
+++ code/branches/objecthierarchy/src/core/EventIncludes.h	(revision 2082)
@@ -34,20 +34,34 @@
 
 #define SetEvent(classname, eventname, functionname, event) \
-    SetEventGeneric(eventcontainer##classname##functionname, classname, eventname, orxonox::createExecutor(orxonox::createFunctor(&classname::functionname), std::string( #classname ) + "::" + #functionname), event, BaseObject)
+    SetEventGeneric(eventcontainer##classname##functionname, classname, eventname, functionname, event, BaseObject)
 
 #define SetEventTemplate(classname, eventname, functionname, event, ...) \
-    SetEventGeneric(eventcontainer##classname##functionname, classname, eventname, orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::functionname), std::string( #classname ) + "::" + #functionname), event, BaseObject)
+    SetEventGenericTemplate(eventcontainer##classname##functionname, classname, eventname, functionname, event, BaseObject, __VA_ARGS__)
 
 #define SetSubclassEvent(classname, eventname, functionname, event, subclassname) \
-    SetEventGeneric(eventcontainer##classname##functionname, classname, eventname, orxonox::createExecutor(orxonox::createFunctor(&classname::functionname), std::string( #classname ) + "::" + #functionname), event, subclassname)
+    SetEventGeneric(eventcontainer##classname##functionname, classname, eventname, functionname, event, subclassname)
 
 #define SetSubclassEventTemplate(classname, eventname, functionname, event, subclassname, ...) \
-    SetEventGeneric(eventcontainer##classname##functionname, classname, eventname, orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::functionname), std::string( #classname ) + "::" + #functionname), event, subclassname)
+    SetEventGenericTemplate(eventcontainer##classname##functionname, classname, eventname, functionname, event, subclassname, __VA_ARGS__)
 
-#define SetEventGeneric(containername, classname, eventname, executor, event, subclassname) \
+#define SetEventGeneric(containername, classname, eventname, functionname, event, subclassname) \
     orxonox::EventContainer* containername = this->getEventContainer(eventname); \
     if (!containername) \
     { \
-        containername = new orxonox::ClassEventContainer<classname>(std::string(eventname), executor, orxonox::ClassIdentifier<subclassname>::getIdentifier()); \
+        ExecutorMember<classname>* executor = orxonox::createExecutor(orxonox::createFunctor(&classname::functionname), std::string( #classname ) + "::" + #functionname); \
+        executor->setObject(this); \
+        containername = new orxonox::EventContainer(std::string(eventname), executor, orxonox::ClassIdentifier<subclassname>::getIdentifier()); \
+        this->addEventContainer(eventname, containername); \
+    } \
+    event.castedOriginator_ = dynamic_cast<subclassname*>(event.originator_); \
+    containername->process(this, event)
+
+#define SetEventGenericTemplate(containername, classname, eventname, functionname, event, subclassname, ...) \
+    orxonox::EventContainer* containername = this->getEventContainer(eventname); \
+    if (!containername) \
+    { \
+        ExecutorMember<classname>* executor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::functionname), std::string( #classname ) + "::" + #functionname); \
+        executor->setObject(this); \
+        containername = new orxonox::EventContainer(std::string(eventname), executor, orxonox::ClassIdentifier<subclassname>::getIdentifier()); \
         this->addEventContainer(eventname, containername); \
     } \
Index: code/branches/objecthierarchy/src/core/XMLPort.h
===================================================================
--- code/branches/objecthierarchy/src/core/XMLPort.h	(revision 2081)
+++ code/branches/objecthierarchy/src/core/XMLPort.h	(revision 2082)
@@ -70,5 +70,7 @@
 */
 #define XMLPortParam(classname, paramname, loadfunction, savefunction, xmlelement, mode) \
-    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode)
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
+    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode)
 /**
     @brief This is the same as XMLPortParam, but you can set the template arguments needed to store the loadfunction.
@@ -83,5 +85,7 @@
 */
 #define XMLPortParamTemplate(classname, paramname, loadfunction, savefunction, xmlelement, mode, ...) \
-    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode)
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
+    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode)
 
 // --------------------
@@ -100,10 +104,12 @@
 */
 #define XMLPortParamLoadOnly(classname, paramname, loadfunction, xmlelement, mode) \
-    XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), 0, xmlelement, mode)
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##0##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+    XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, xmlcontainer##loadfunction##0##loadexecutor, 0, xmlelement, mode)
 /**
     @brief This is the same as XMLPortParamTemplate, but for load-only attributes (see XMLPortParamLoadOnly).
 */
 #define XMLPortParamLoadOnlyTemplate(classname, paramname, loadfunction, xmlelement, mode, ...) \
-    XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), 0, xmlelement, mode)
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##0##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+    XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, xmlcontainer##loadfunction##0##loadexecutor, 0, xmlelement, mode)
 
 // ------------------
@@ -130,10 +136,14 @@
 */
 #define XMLPortParamExtern(classname, externclass, object, paramname, loadfunction, savefunction, xmlelement, mode) \
-    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, orxonox::createExecutor(orxonox::createFunctor(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction), xmlelement, mode);
+    static ExecutorMember<externclass>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction); \
+    static ExecutorMember<externclass>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction); \
+    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode);
 /**
     @brief This is the same as XMLPortParamTemplate, but for extern attributes (see XMLPortParamExtern).
 */
 #define XMLPortParamExternTemplate(classname, externclass, object, paramname, loadfunction, savefunction, xmlelement, mode, ...) \
-    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, orxonox::createExecutor(orxonox::createFunctor<externclass, __VA_ARGS__ >(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction), xmlelement, mode);
+    static ExecutorMember<externclass>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<externclass, __VA_ARGS__ >(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction); \
+    static ExecutorMember<externclass>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction); \
+    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode);
 
 // -------------------
@@ -214,10 +224,14 @@
 */
 #define XMLPortObjectExtended(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \
-    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode, bApplyLoaderMask, bLoadBefore)
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
+    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, bApplyLoaderMask, bLoadBefore)
 /**
     @brief This is the same as XMLPortObjectExtended, but you can specify the loadfunction by adding the param types. See XMLPortParamTemplate for more details about the types.
 */
 #define XMLPortObjectExtendedTemplate(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore, ...) \
-    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode, bApplyLoaderMask, bLoadBefore)
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
+    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, bApplyLoaderMask, bLoadBefore)
 
 // -------------
@@ -228,10 +242,14 @@
 */
 #define XMLPortObject(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode) \
-    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode, false, true)
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
+    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, false, true)
 /**
     @brief This is the same as XMLPortObject, but you can specify the loadfunction by adding the param types. See XMLPortParamTemplate for more details about the types.
 */
 #define XMLPortObjectTemplate(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, ...) \
-    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode, false, true)
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
+    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, false, true)
 
 // --------------------
Index: code/branches/objecthierarchy/src/orxonox/objects/EventListener.cc
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/EventListener.cc	(revision 2081)
+++ code/branches/objecthierarchy/src/orxonox/objects/EventListener.cc	(revision 2082)
@@ -41,4 +41,6 @@
     {
         RegisterObject(EventListener);
+
+        this->bActive_ = false;
     }
 
@@ -56,5 +58,15 @@
     void EventListener::processEvent(Event& event)
     {
+        if (this->bActive_)
+        {
+            COUT(2) << "Warning: Detected Event loop in EventListener \"" << this->getName() << "\"" << std::endl;
+            return;
+        }
+
+        this->bActive_ = true;
+
         this->fireEvent(event.activate_, event.originator_);
+
+        this->bActive_ = false;
     }
 
Index: code/branches/objecthierarchy/src/orxonox/objects/EventListener.h
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/EventListener.h	(revision 2081)
+++ code/branches/objecthierarchy/src/orxonox/objects/EventListener.h	(revision 2082)
@@ -55,4 +55,5 @@
 
             std::string eventName_;
+            bool bActive_;
     };
 }
Index: code/branches/objecthierarchy/src/orxonox/objects/EventTarget.cc
===================================================================
--- code/branches/objecthierarchy/src/orxonox/objects/EventTarget.cc	(revision 2081)
+++ code/branches/objecthierarchy/src/orxonox/objects/EventTarget.cc	(revision 2082)
@@ -64,5 +64,6 @@
     void EventTarget::addAsEvent(BaseObject* object)
     {
-        object->addEvent(this, "");
+        if (object != (BaseObject*)this)
+            object->addEvent(this, "");
     }
 }
