Index: code/trunk/src/core/CoreIncludes.h
===================================================================
--- code/trunk/src/core/CoreIncludes.h	(revision 3323)
+++ code/trunk/src/core/CoreIncludes.h	(revision 3325)
@@ -56,25 +56,8 @@
 */
 #define InternRegisterObject(ClassName, bRootClass) \
-    this->setIdentifier(orxonox::ClassIdentifier<ClassName>::getIdentifier(#ClassName)); \
-    if (orxonox::Identifier::isCreatingHierarchy()) \
-    { \
-        if (this->getParents()) \
-        { \
-            orxonox::ClassIdentifier<ClassName>::getIdentifier(#ClassName)->initializeClassHierarchy(this->getParents(), bRootClass); \
-            this->getParents()->insert(this->getParents()->end(), this->getIdentifier()); \
-        } \
-        this->setConfigValues(); \
+    if (ClassIdentifier<ClassName>::getIdentifier(#ClassName)->initialiseObject(this, #ClassName, bRootClass)) \
         return; \
-    } \
-    orxonox::ClassIdentifier<ClassName>::getIdentifier()->addObject(this)
-
-/**
-    @brief Intern macro, containing the specific part of RegisterRootObject.
-    @param ClassName The name of the class
-*/
-#define InternRegisterRootObject(ClassName) \
-    if (orxonox::Identifier::isCreatingHierarchy() && !this->getParents()) \
-        this->createParents(); \
-    InternRegisterObject(ClassName, true)
+    else \
+        ((void)0)
 
 /**
@@ -83,5 +66,4 @@
 */
 #define RegisterObject(ClassName) \
-    COUT(5) << "*** Register Object: " << #ClassName << std::endl; \
     InternRegisterObject(ClassName, false)
 
@@ -91,6 +73,5 @@
 */
 #define RegisterRootObject(ClassName) \
-    COUT(5) << "*** Register Root-Object: " << #ClassName << std::endl; \
-    InternRegisterRootObject(ClassName)
+    InternRegisterObject(ClassName, true)
 
 /**
@@ -115,17 +96,25 @@
     orxonox::ClassIdentifier<ClassName>::getIdentifier()
 
-/**
-    @brief Returns the Identifier with a given name through the factory.
-    @param String The name of the class
-*/
-#define ClassByString(String) \
-    orxonox::Factory::getIdentifier(String)
 
-/**
-    @brief Returns the Identifier with a given network ID through the factory.
-    @param networkID The network ID of the class
-*/
-#define ClassByID(networkID) \
-    orxonox::Factory::getIdentifier(networkID)
+namespace orxonox
+{
+    /**
+        @brief Returns the Identifier with a given name through the factory.
+        @param String The name of the class
+    */
+    inline Identifier* ClassByString(const std::string& name)
+    {
+        return Factory::getIdentifier(name);
+    }
+
+    /**
+        @brief Returns the Identifier with a given network ID through the factory.
+        @param networkID The network ID of the class
+    */
+    inline Identifier* ClassByID(uint32_t id)
+    {
+        return Factory::getIdentifier(id);
+    }
+}
 
 #endif /* _CoreIncludes_H__ */
Index: code/trunk/src/core/EventIncludes.h
===================================================================
--- code/trunk/src/core/EventIncludes.h	(revision 3323)
+++ code/trunk/src/core/EventIncludes.h	(revision 3325)
@@ -54,5 +54,5 @@
         this->addEventContainer(eventname, containername); \
     } \
-    event.castedOriginator_ = dynamic_cast<subclassname*>(event.originator_); \
+    event.castedOriginator_ = orxonox::orxonox_cast<subclassname*>(event.originator_); \
     containername->process(this, event)
 
@@ -66,5 +66,5 @@
         this->addEventContainer(eventname, containername); \
     } \
-    event.castedOriginator_ = dynamic_cast<subclassname*>(event.originator_); \
+    event.castedOriginator_ = orxonox::orxonox_cast<subclassname*>(event.originator_); \
     containername->process(this, event)
 
Index: code/trunk/src/core/Identifier.cc
===================================================================
--- code/trunk/src/core/Identifier.cc	(revision 3323)
+++ code/trunk/src/core/Identifier.cc	(revision 3325)
@@ -47,5 +47,6 @@
     // ###       Identifier        ###
     // ###############################
-    int Identifier::hierarchyCreatingCounter_s = 0; // Set the static member variable hierarchyCreatingCounter_s to zero (this static member variable is ok: it's used in main(), not before)
+    int Identifier::hierarchyCreatingCounter_s = 0;
+    unsigned int Identifier::classIDCounter_s = 0;
 
     /**
@@ -53,4 +54,5 @@
     */
     Identifier::Identifier()
+        : classID_(classIDCounter_s++)
     {
         this->objects_ = new ObjectListBase(this);
@@ -67,7 +69,6 @@
         this->directChildren_ = new std::set<const Identifier*>();
 
-        // Use a static variable because the classID gets created before main() and that's why we should avoid static member variables
-        static unsigned int classIDcounter_s = 0;
-        this->classID_ = classIDcounter_s++;
+        // Default network ID is the class ID
+        this->networkID_ = this->classID_;
     }
 
@@ -244,6 +245,6 @@
     void Identifier::setNetworkID(uint32_t id)
     {
-        Factory::changeNetworkID(this, this->classID_, id);
-        this->classID_ = id;
+        Factory::changeNetworkID(this, this->networkID_, id);
+        this->networkID_ = id;
     }
 
Index: code/trunk/src/core/Identifier.h
===================================================================
--- code/trunk/src/core/Identifier.h	(revision 3323)
+++ code/trunk/src/core/Identifier.h	(revision 3325)
@@ -224,8 +224,11 @@
 
             /** @brief Returns the network ID to identify a class through the network. @return the network ID */
-            inline const uint32_t getNetworkID() const { return this->classID_; }
+            inline const uint32_t getNetworkID() const { return this->networkID_; }
 
             /** @brief Sets the network ID to a new value. @param id The new value */
             void setNetworkID(uint32_t id);
+
+            /** @brief Returns the unique ID of the class */
+            FORCEINLINE unsigned int getClassID() const { return this->classID_; }
 
             void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container);
@@ -305,5 +308,7 @@
             BaseFactory* factory_;                                         //!< The Factory, able to create new objects of the given class (if available)
             static int hierarchyCreatingCounter_s;                         //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading)
-            uint32_t classID_;                                             //!< The network ID to identify a class through the network
+            uint32_t networkID_;                                           //!< The network ID to identify a class through the network
+            const unsigned int classID_;                                   //!< Uniquely identifies a class (might not be the same as the networkID_)
+            static unsigned int classIDCounter_s;                          //!< Static counter for the unique classIDs
 
             bool bHasConfigValues_;                                        //!< True if this class has at least one assigned config value
@@ -344,5 +349,6 @@
             static ClassIdentifier<T> *getIdentifier();
             static ClassIdentifier<T> *getIdentifier(const std::string& name);
-            void addObject(T* object);
+
+            bool initialiseObject(T* object, const std::string& className, bool bRootClass);
 
             void updateConfigValues(bool updateChildren = true) const;
@@ -423,8 +429,35 @@
     */
     template <class T>
-    inline void ClassIdentifier<T>::addObject(T* object)
-    {
-        COUT(5) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl;
-        object->getMetaList().add(this->objects_, this->objects_->add(new ObjectListElement<T>(object)));
+    bool ClassIdentifier<T>::initialiseObject(T* object, const std::string& className, bool bRootClass)
+    {
+        if (bRootClass)
+            COUT(5) << "*** Register Root-Object: " << className << std::endl;
+        else
+            COUT(5) << "*** Register Object: " << className << std::endl;
+
+        object->identifier_ = this;
+        if (Identifier::isCreatingHierarchy())
+        {
+            if (bRootClass && !object->parents_)
+                object->parents_ = new std::set<const Identifier*>();
+
+            if (object->parents_)
+            {
+                this->initializeClassHierarchy(object->parents_, bRootClass);
+                object->parents_->insert(object->parents_->end(), this);
+            }
+
+            object->setConfigValues();
+            return true;
+        }
+        else
+        {
+            COUT(5) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl;
+            object->metaList_->add(this->objects_, this->objects_->add(new ObjectListElement<T>(object)));
+
+            // Add pointer of type T to the map in the OrxonoxClass instance that enables "dynamic_casts"
+            object->objectPointers_.push_back(std::make_pair(this->getClassID(), reinterpret_cast<void*>(object)));
+            return false;
+        }
     }
 
@@ -444,4 +477,51 @@
             for (std::set<const Identifier*>::const_iterator it = this->getChildrenBegin(); it != this->getChildrenEnd(); ++it)
                 (*it)->updateConfigValues(false);
+    }
+
+
+    // ###############################
+    // ###      orxonox_cast       ###
+    // ###############################
+    //! Helper struct to have orxonox_cast<T*> instead of orxonox_cast<T>
+    template <class T, class U>
+    struct OrxonoxCaster
+    {
+        static T* cast(U* source)
+        {
+            // If you see this function in a compiler error description, it means
+            // you were misusing orxonox_cast. You must always cast to a pointer type!
+            *****T();
+        }
+    };
+
+    //! Helper struct to have orxonox_cast<T*> instead of orxonox_cast<T*>
+    template <class T, class U>
+    struct OrxonoxCaster<T*, U>
+    {
+        FORCEINLINE static T* cast(U* source)
+        {
+#ifdef ORXONOX_COMPILER_MSVC
+            return source->template getDerivedPointer<T>(ClassIdentifier<T>::getIdentifier()->getClassID());
+#else
+            return dynamic_cast<T*>(source);
+#endif
+        }
+    };
+
+    /**
+    @brief
+        Casts on object of type OrxonoxClass to any derived type that is
+        registered in the class hierarchy.
+    @return
+        Returns NULL if the cast is not possible
+    @note
+        In case of NULL return (and using MSVC), a dynamic_cast might still be possible if
+        a class forgot to register its objects.
+        Also note that the function is implemented differently for GCC/MSVC.
+    */
+    template <class T, class U>
+    FORCEINLINE T orxonox_cast(U* source)
+    {
+        return OrxonoxCaster<T, U>::cast(source);
     }
 
@@ -539,5 +619,5 @@
                 if (newObject)
                 {
-                    return dynamic_cast<T*>(newObject);
+                    return orxonox_cast<T*>(newObject);
                 }
                 else
Index: code/trunk/src/core/Iterator.h
===================================================================
--- code/trunk/src/core/Iterator.h	(revision 3323)
+++ code/trunk/src/core/Iterator.h	(revision 3325)
@@ -240,5 +240,5 @@
             {
                 if (this->element_)
-                    return dynamic_cast<T*>(this->element_->objectBase_);
+                    return orxonox_cast<T*>(this->element_->objectBase_);
                 else
                     return 0;
@@ -252,5 +252,5 @@
             {
                 if (this->element_)
-                    return dynamic_cast<T*>(this->element_->objectBase_);
+                    return orxonox_cast<T*>(this->element_->objectBase_);
                 else
                     return 0;
Index: code/trunk/src/core/OrxonoxClass.h
===================================================================
--- code/trunk/src/core/OrxonoxClass.h	(revision 3323)
+++ code/trunk/src/core/OrxonoxClass.h	(revision 3325)
@@ -50,4 +50,7 @@
     class _CoreExport OrxonoxClass
     {
+        template <class T>
+        friend class ClassIdentifier;
+
         public:
             OrxonoxClass();
@@ -59,17 +62,4 @@
             /** @brief Returns the Identifier of the object. @return The Identifier */
             inline Identifier* getIdentifier() const { return this->identifier_; }
-
-            /** @brief Sets the Identifier of the object. Used by the RegisterObject-macro. */
-            inline void setIdentifier(Identifier* identifier) { this->identifier_ = identifier; }
-
-            /** @brief Returns the list of all parents of the object. @return The list */
-            inline std::set<const Identifier*>* getParents() const { return this->parents_; }
-
-            /** @brief Creates the parents-list. */
-            inline void createParents() { this->parents_ = new std::set<const Identifier*>(); }
-
-            /** @brief Returns the MetaObjectList of the object, containing a link to all ObjectLists and ObjectListElements the object is registered in. @return The list */
-            inline MetaObjectList& getMetaList() { return (*this->metaList_); }
-
 
             bool isA(const Identifier* identifier);
@@ -101,8 +91,28 @@
             bool isDirectParentOf(const OrxonoxClass* object);
 
+            /**
+            @brief
+                Returns a valid pointer of any derived type that is
+                registered in the class hierarchy.
+            @return
+                Returns NULL if the no pointer was found.
+            */
+            template <class T>
+            FORCEINLINE T* getDerivedPointer(unsigned int classID) const
+            {
+                for (int i = this->objectPointers_.size() - 1; i >= 0; --i)
+                {
+                    if (this->objectPointers_[i].first == classID)
+                        return reinterpret_cast<T*>(this->objectPointers_[i].second);
+                }
+                return NULL;
+            }
+
         private:
             Identifier* identifier_;                   //!< The Identifier of the object
             std::set<const Identifier*>* parents_;     //!< List of all parents of the object
             MetaObjectList* metaList_;                 //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in
+            //! 'Fast map' that holds this-pointers of all derived types
+            std::vector<std::pair<unsigned int, void*> > objectPointers_;
     };
 }
Index: code/trunk/src/core/Super.h
===================================================================
--- code/trunk/src/core/Super.h	(revision 3323)
+++ code/trunk/src/core/Super.h	(revision 3325)
@@ -206,6 +206,11 @@
 
     // SUPER-macro: Calls Parent::functionname() where Parent is the direct parent of classname
-    #define SUPER(classname, functionname, ...) \
-        SUPER_##functionname(classname, functionname, __VA_ARGS__)
+    #ifdef ORXONOX_COMPILER_MSVC
+        #define SUPER(classname, functionname, ...) \
+            __super::functionname(__VA_ARGS__)
+    #else
+        #define SUPER(classname, functionname, ...) \
+            SUPER_##functionname(classname, functionname, __VA_ARGS__)
+    #endif
 
     // helper macro: for functions without arguments
Index: code/trunk/src/core/XMLPort.h
===================================================================
--- code/trunk/src/core/XMLPort.h	(revision 3323)
+++ code/trunk/src/core/XMLPort.h	(revision 3325)
@@ -565,5 +565,5 @@
                                                     newObject->setLoaderIndentation(object->getLoaderIndentation() + "  ");
 
-                                                    O* castedObject = dynamic_cast<O*>(newObject);
+                                                    O* castedObject = orxonox_cast<O*>(newObject);
                                                     assert(castedObject);
 
