Index: /code/branches/consolecommands3/src/libraries/core/BaseObject.h
===================================================================
--- /code/branches/consolecommands3/src/libraries/core/BaseObject.h	(revision 7197)
+++ /code/branches/consolecommands3/src/libraries/core/BaseObject.h	(revision 7198)
@@ -196,5 +196,5 @@
             mbool                   bVisible_;                 //!< True = the object is visible
             std::string             mainStateName_;
-            Functor*                mainStateFunctor_;
+            FunctorPtr              mainStateFunctor_;
             std::set<std::string>   networkTemplateNames_;
 
Index: /code/branches/consolecommands3/src/libraries/core/ConsoleCommand.cc
===================================================================
--- /code/branches/consolecommands3/src/libraries/core/ConsoleCommand.cc	(revision 7197)
+++ /code/branches/consolecommands3/src/libraries/core/ConsoleCommand.cc	(revision 7198)
@@ -34,5 +34,5 @@
 namespace orxonox
 {
-    ConsoleCommand::ConsoleCommand(Functor* functor, const std::string& name) : Executor(functor, name)
+    ConsoleCommand::ConsoleCommand(const FunctorPtr& functor, const std::string& name) : Executor(functor, name)
     {
         this->accessLevel_ = AccessLevel::None;
@@ -124,5 +124,5 @@
     _ConsoleCommand::_ConsoleCommandManipulator test(_ModifyConsoleCommand("BaseObject", "setName").setFunction(&BaseObject::setActive));
 
-    _ConsoleCommand::_ConsoleCommand(const std::string& group, const std::string& name, Functor* functor, bool bInitialized) : Executor(functor, name), functionHeader_(functor->getHeaderIdentifier())
+    _ConsoleCommand::_ConsoleCommand(const std::string& group, const std::string& name, const FunctorPtr& functor, bool bInitialized) : Executor(functor, name), functionHeader_(functor->getHeaderIdentifier())
     {
         this->bActive_ = true;
@@ -155,5 +155,5 @@
     }
 
-    bool _ConsoleCommand::setFunctor(Functor* functor, bool bForce)
+    bool _ConsoleCommand::setFunctor(const FunctorPtr& functor, bool bForce)
     {
         if (!functor)
@@ -174,7 +174,7 @@
     }
 
-    void _ConsoleCommand::pushFunctor(Functor* functor, bool bForce)
-    {
-        Functor* oldfunctor = this->getFunctor();
+    void _ConsoleCommand::pushFunctor(const FunctorPtr& functor, bool bForce)
+    {
+        const FunctorPtr& oldfunctor = this->getFunctor();
 
         if (this->setFunctor(functor, bForce));
@@ -184,5 +184,5 @@
     void _ConsoleCommand::popFunctor()
     {
-        Functor* newfunctor = 0;
+        FunctorPtr newfunctor;
         if (!this->functorStack_.empty())
         {
@@ -193,13 +193,13 @@
     }
 
-    Functor* _ConsoleCommand::getFunctor() const
-    {
-        if (this->bInitialized_)
+    const FunctorPtr& _ConsoleCommand::getFunctor() const
+    {
+//        if (this->bInitialized_) // FIXME
             return this->functor_;
-        else
-            return 0;
-    }
-
-    bool _ConsoleCommand::functionHeaderMatches(Functor* functor) const
+//        else
+//            return 0;
+    }
+
+    bool _ConsoleCommand::functionHeaderMatches(const FunctorPtr& functor) const
     {
         if (!this->functor_)
@@ -216,5 +216,5 @@
             this->functor_->setRawObjectPointer(object);
         else if (object)
-            COUT(0) << "Error: Can't set object in console command \"" << this->getName() << "\", no functor set." << std::endl;
+            COUT(1) << "Error: Can't set object in console command \"" << this->getName() << "\", no functor set." << std::endl;
     }
 
@@ -227,5 +227,5 @@
         }
         else
-            COUT(0) << "Error: Can't set object in console command \"" << this->getName() << "\", no functor set." << std::endl;
+            COUT(1) << "Error: Can't set object in console command \"" << this->getName() << "\", no functor set." << std::endl;
     }
 
@@ -263,7 +263,7 @@
         {
             if (group == "")
-                COUT(0) << "Error: Couldn't find console command with shortcut \"" << name << "\"" << std::endl;
+                COUT(1) << "Error: Couldn't find console command with shortcut \"" << name << "\"" << std::endl;
             else
-                COUT(0) << "Error: Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << std::endl;
+                COUT(1) << "Error: Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << std::endl;
         }
         return 0;
Index: /code/branches/consolecommands3/src/libraries/core/ConsoleCommand.h
===================================================================
--- /code/branches/consolecommands3/src/libraries/core/ConsoleCommand.h	(revision 7197)
+++ /code/branches/consolecommands3/src/libraries/core/ConsoleCommand.h	(revision 7198)
@@ -88,5 +88,5 @@
     {
         public:
-            ConsoleCommand(Functor* functor, const std::string& name = "");
+            ConsoleCommand(const FunctorPtr& functor, const std::string& name = "");
 
             ConsoleCommand& description(const std::string& description);
@@ -159,5 +159,5 @@
     };
 
-    inline ConsoleCommand* createConsoleCommand(Functor* functor, const std::string& name = "")
+    inline ConsoleCommand* createConsoleCommand(const FunctorPtr& functor, const std::string& name = "")
     {
         return new ConsoleCommand(functor, name);
@@ -212,5 +212,5 @@
                     inline _ConsoleCommandManipulator& setFunction(F function, O* object, bool bForce = false)
                         { if (this->command_) { this->command_->setFunctor(createFunctor(function, object), bForce); } return *this; }
-                    inline _ConsoleCommandManipulator& setFunction(Functor* functor, bool bForce = false)
+                    inline _ConsoleCommandManipulator& setFunction(const FunctorPtr& functor, bool bForce = false)
                         { if (this->command_) { this->command_->setFunctor(functor, bForce); } return *this; }
 
@@ -221,5 +221,5 @@
                     inline _ConsoleCommandManipulator& pushFunction(F function, O* object, bool bForce = false)
                         { if (this->command_) { this->command_->pushFunctor(createFunctor(function, object), bForce); } return *this; }
-                    inline _ConsoleCommandManipulator& pushFunction(Functor* functor, bool bForce = false)
+                    inline _ConsoleCommandManipulator& pushFunction(const FunctorPtr& functor, bool bForce = false)
                         { if (this->command_) { this->command_->pushFunctor(functor, bForce); } return *this; }
 
@@ -245,5 +245,5 @@
 
         public:
-            _ConsoleCommand(const std::string& group, const std::string& name, Functor* functor, bool bInitialized = true);
+            _ConsoleCommand(const std::string& group, const std::string& name, const FunctorPtr& functor, bool bInitialized = true);
 
             _ConsoleCommand& addShortcut();
@@ -271,10 +271,10 @@
             static void registerCommand(const std::string& group, const std::string& name, _ConsoleCommand* command);
 
-            bool setFunctor(Functor* functor, bool bForce = false);
-            void pushFunctor(Functor* functor, bool bForce = false);
+            bool setFunctor(const FunctorPtr& functor, bool bForce = false);
+            void pushFunctor(const FunctorPtr& functor, bool bForce = false);
             void popFunctor();
-            Functor* getFunctor() const;
-
-            bool functionHeaderMatches(Functor* functor) const;
+            const FunctorPtr& getFunctor() const;
+
+            bool functionHeaderMatches(const FunctorPtr& functor) const;
 
             void setObject(void* object);
@@ -286,14 +286,14 @@
             bool bInitialized_;
             const std::type_info& functionHeader_;
-            std::stack<Functor*> functorStack_;
+            std::stack<FunctorPtr> functorStack_;
             std::stack<void*> objectStack_;
     };
 
-    inline _ConsoleCommand* _createConsoleCommand(const std::string& name, Functor* functor, bool bInitialized = true)
+    inline _ConsoleCommand* _createConsoleCommand(const std::string& name, const FunctorPtr& functor, bool bInitialized = true)
     {
         return new _ConsoleCommand("", name, functor, bInitialized);
     }
 
-    inline _ConsoleCommand* _createConsoleCommand(const std::string& group, const std::string& name, Functor* functor, bool bInitialized = true)
+    inline _ConsoleCommand* _createConsoleCommand(const std::string& group, const std::string& name, const FunctorPtr& functor, bool bInitialized = true)
     {
         return new _ConsoleCommand(group, name, functor, bInitialized);
Index: /code/branches/consolecommands3/src/libraries/core/Event.cc
===================================================================
--- /code/branches/consolecommands3/src/libraries/core/Event.cc	(revision 7197)
+++ /code/branches/consolecommands3/src/libraries/core/Event.cc	(revision 7198)
@@ -34,13 +34,4 @@
 namespace orxonox
 {
-    /**
-        @brief Destructor: Deletes the functor of the event state.
-    */
-    EventState::~EventState()
-    {
-        if (this->statefunction_)
-            delete this->statefunction_;
-    }
-
     /**
         @brief Processes an event (calls the set-function if the necessary conditions are met).
Index: /code/branches/consolecommands3/src/libraries/core/Event.h
===================================================================
--- /code/branches/consolecommands3/src/libraries/core/Event.h	(revision 7197)
+++ /code/branches/consolecommands3/src/libraries/core/Event.h	(revision 7198)
@@ -67,10 +67,9 @@
     {
         public:
-            EventState(Functor* statefunction, Identifier* subclass, bool bSink = false) : bProcessingEvent_(false), activeEvents_(0), statefunction_(statefunction), subclass_(subclass), bSink_(bSink) {}
-            virtual ~EventState();
+            EventState(const FunctorPtr& statefunction, Identifier* subclass, bool bSink = false) : bProcessingEvent_(false), activeEvents_(0), statefunction_(statefunction), subclass_(subclass), bSink_(bSink) {}
 
             void process(const Event& event, BaseObject* object);
 
-            Functor* getFunctor() const
+            const FunctorPtr& getFunctor() const
                 { return this->statefunction_; }
 
@@ -78,5 +77,5 @@
             bool        bProcessingEvent_;  //!< This becomes true while the container processes an event (used to prevent loops)
             int         activeEvents_;      //!< The number of events which affect this state and are currently active
-            Functor*    statefunction_;     //!< A functor to set the state
+            FunctorPtr  statefunction_;     //!< A functor to set the state
             Identifier* subclass_;          //!< Originators must be an instance of this class (usually BaseObject, but some statefunctions allow a second argument with an originator of a specific class)
             bool        bSink_;             //!< Determines whether the EventState acts as an EventSink forwarding any Event (even if the state didn't change) or in the normal manner, only processing Events that change the state.
Index: /code/branches/consolecommands3/src/libraries/core/Executor.cc
===================================================================
--- /code/branches/consolecommands3/src/libraries/core/Executor.cc	(revision 7197)
+++ /code/branches/consolecommands3/src/libraries/core/Executor.cc	(revision 7198)
@@ -42,5 +42,5 @@
     int Executor::instances_s = 0;
 
-    Executor::Executor(Functor* functor, const std::string& name)
+    Executor::Executor(const FunctorPtr& functor, const std::string& name)
     {
         this->functor_ = functor;
@@ -51,5 +51,4 @@
     Executor::~Executor()
     {
-        delete this->functor_;
         --instances_s; COUT(0) << "executor --: " << instances_s << std::endl;
     }
Index: /code/branches/consolecommands3/src/libraries/core/Executor.h
===================================================================
--- /code/branches/consolecommands3/src/libraries/core/Executor.h	(revision 7197)
+++ /code/branches/consolecommands3/src/libraries/core/Executor.h	(revision 7198)
@@ -42,8 +42,6 @@
     class _CoreExport Executor
     {
-        friend class SharedPtr<Executor>;
-
         public:
-            Executor(Functor* functor, const std::string& name = "");
+            Executor(const FunctorPtr& functor, const std::string& name = "");
             virtual ~Executor();
 
@@ -65,5 +63,5 @@
             bool evaluate(const std::string& params, MultiType param[5], const std::string& delimiter = " ") const;
 
-            inline Functor* getFunctor() const
+            inline const FunctorPtr& getFunctor() const
                 { return this->functor_; }
             inline unsigned int getParamCount() const
@@ -108,5 +106,5 @@
 
         protected:
-            Functor* functor_;
+            FunctorPtr functor_;
             std::string name_;
             MultiType defaultValue_[MAX_FUNCTOR_ARGUMENTS];
@@ -119,5 +117,5 @@
     {
         public:
-            ExecutorStatic(FunctorStatic* functor, const std::string& name = "") : Executor(functor, name) {}
+            ExecutorStatic(const FunctorStaticPtr& functor, const std::string& name = "") : Executor(functor, name) {}
             virtual ~ExecutorStatic() {}
     };
@@ -127,5 +125,5 @@
     {
         public:
-            ExecutorMember(FunctorMember<T>* functor, const std::string& name = "") : Executor(functor, name) {}
+            ExecutorMember(const FunctorMemberPtr<T>& functor, const std::string& name = "") : Executor(functor, name), functorMember_(functor) {}
             virtual ~ExecutorMember() {}
 
@@ -133,34 +131,34 @@
 
             inline MultiType operator()(T* object) const
-                { return (*((FunctorMember<T>*)this->functor_))(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+                { return (*this->functorMember_)(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
             inline MultiType operator()(T* object, const MultiType& param1) const
-                { return (*((FunctorMember<T>*)this->functor_))(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+                { return (*this->functorMember_)(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
             inline MultiType operator()(T* object, const MultiType& param1, const MultiType& param2) const
-                { return (*((FunctorMember<T>*)this->functor_))(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+                { return (*this->functorMember_)(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
             inline MultiType operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const
-                { return (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
+                { return (*this->functorMember_)(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
             inline MultiType operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
-                { return (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, this->defaultValue_[4]); }
+                { return (*this->functorMember_)(object, param1, param2, param3, param4, this->defaultValue_[4]); }
             inline MultiType operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
-                { return (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, param5); }
+                { return (*this->functorMember_)(object, param1, param2, param3, param4, param5); }
 
 
             inline MultiType operator()(const T* object) const
-                { return (*((FunctorMember<T>*)this->functor_))(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+                { return (*this->functorMember_)(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
             inline MultiType operator()(const T* object, const MultiType& param1) const
-                { return (*((FunctorMember<T>*)this->functor_))(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+                { return (*this->functorMember_)(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
             inline MultiType operator()(const T* object, const MultiType& param1, const MultiType& param2) const
-                { return (*((FunctorMember<T>*)this->functor_))(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+                { return (*this->functorMember_)(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
             inline MultiType operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const
-                { return (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
+                { return (*this->functorMember_)(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
             inline MultiType operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
-                { return (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, this->defaultValue_[4]); }
+                { return (*this->functorMember_)(object, param1, param2, param3, param4, this->defaultValue_[4]); }
             inline MultiType operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
-                { return (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, param5); }
+                { return (*this->functorMember_)(object, param1, param2, param3, param4, param5); }
 
             inline void setObject(T* object) const
-                { ((FunctorMember<T>*)this->functor_)->setObject(object); }
+                { this->functorMember_->setObject(object); }
             inline void setObject(const T* object) const
-                { ((FunctorMember<T>*)this->functor_)->setObject(object); }
+                { this->functorMember_->setObject(object); }
 
             using Executor::parse;
@@ -168,11 +166,9 @@
             MultiType parse(T* object, const std::string& params, bool* success = 0, const std::string& delimiter = " ") const
             {
-                FunctorMember<T>* functorMember = static_cast<FunctorMember<T>*>(this->functor_);
-
-                const typename FunctorMember<T>::Objects& objects = functorMember->getObjects();
-
-                functorMember->setObject(object);
+                const typename FunctorMember<T>::Objects& objects = this->functorMember_->getObjects();
+
+                this->functorMember_->setObject(object);
                 const MultiType& result = Executor::parse(params, success, delimiter);
-                functorMember->setObjects(objects);
+                this->functorMember_->setObjects(objects);
 
                 return result;
@@ -181,17 +177,18 @@
             MultiType parse(const T* object, const std::string& params, bool* success = 0, const std::string& delimiter = " ") const
             {
-                FunctorMember<T>* functorMember = static_cast<FunctorMember<T>*>(this->functor_);
-
-                const typename FunctorMember<T>::Objects& objects = functorMember->getObjects();
-
-                functorMember->setObject(object);
+                const typename FunctorMember<T>::Objects& objects = this->functorMember_->getObjects();
+
+                this->functorMember_->setObject(object);
                 const MultiType& result = Executor::parse(params, success, delimiter);
-                functorMember->setObjects(objects);
+                this->functorMember_->setObjects(objects);
 
                 return result;
             }
+
+        protected:
+            FunctorMemberPtr<T> functorMember_;
     };
 
-    inline Executor* createExecutor(Functor* functor, const std::string& name = "")
+    inline Executor* createExecutor(const FunctorPtr& functor, const std::string& name = "")
     {
         return new Executor(functor, name);
@@ -199,10 +196,10 @@
 
     template <class T>
-    inline ExecutorMember<T>* createExecutor(FunctorMember<T>* functor, const std::string& name = "")
+    inline ExecutorMember<T>* createExecutor(const FunctorMemberPtr<T>& functor, const std::string& name = "")
     {
         return new ExecutorMember<T>(functor, name);
     }
 
-    inline ExecutorStatic* createExecutor(FunctorStatic* functor, const std::string& name = "")
+    inline ExecutorStatic* createExecutor(const FunctorStaticPtr& functor, const std::string& name = "")
     {
         return new ExecutorStatic(functor, name);
Index: /code/branches/consolecommands3/src/libraries/core/Functor.h
===================================================================
--- /code/branches/consolecommands3/src/libraries/core/Functor.h	(revision 7197)
+++ /code/branches/consolecommands3/src/libraries/core/Functor.h	(revision 7198)
@@ -89,6 +89,4 @@
     class _CoreExport Functor
     {
-        friend class SharedPtr<Functor>;
-
         public:
             struct Type
@@ -215,5 +213,5 @@
 
 
-    inline Functor* createFunctor(Functor* functor)
+    inline const FunctorPtr& createFunctor(const FunctorPtr& functor)
     {
         return functor;
@@ -424,5 +422,5 @@
     \
     FUNCTOR_TEMPLATE(0, returnvalue, numparams, 0) \
-    inline FunctorStatic##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(0, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \
+    inline SharedChildPtr<FunctorStatic##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(0, returnvalue, numparams), FunctorStaticPtr> createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \
     { \
         return new FunctorStatic##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(0, returnvalue, numparams) (functionPointer); \
@@ -517,5 +515,5 @@
     \
     FUNCTOR_TEMPLATE(1, returnvalue, numparams, 0) \
-    inline FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \
+    inline SharedChildPtr<FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams), FunctorMemberPtr<T> > createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \
     { \
         return new FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams) (functionPointer); \
@@ -524,5 +522,5 @@
     \
     FUNCTOR_TEMPLATE(1, returnvalue, numparams, 0) \
-    inline FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)) const) \
+    inline SharedChildPtr<FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams), FunctorMemberPtr<T> > createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)) const) \
     { \
         return new FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams) (functionPointer); \
@@ -530,5 +528,5 @@
     \
     FUNCTOR_TEMPLATE(1, returnvalue, numparams, 1) \
-    inline FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)), O* object) \
+    inline SharedChildPtr<FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams), FunctorMemberPtr<T> > createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)), O* object) \
     { \
         FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* functor = new FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams) (functionPointer); \
@@ -539,5 +537,5 @@
     \
     FUNCTOR_TEMPLATE(1, returnvalue, numparams, 1) \
-    inline FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)) const, O* object) \
+    inline SharedChildPtr<FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams), FunctorMemberPtr<T> > createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)) const, O* object) \
     { \
         FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* functor = new FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams) (functionPointer); \
Index: /code/branches/consolecommands3/src/libraries/core/WeakPtr.h
===================================================================
--- /code/branches/consolecommands3/src/libraries/core/WeakPtr.h	(revision 7197)
+++ /code/branches/consolecommands3/src/libraries/core/WeakPtr.h	(revision 7198)
@@ -77,6 +77,4 @@
                 if (this->base_)
                     this->base_->unregisterWeakPtr(this);
-                if (this->callback_)
-                    delete this->callback_;
 
             }
@@ -168,10 +166,10 @@
             }
 
-            inline void setCallback(Functor* callback)
+            inline void setCallback(const FunctorPtr& callback)
             {
                 this->callback_ = callback;
             }
 
-            inline Functor* getFunctor() const
+            inline const FunctorPtr& getCallback() const
             {
                 return this->callback_;
@@ -189,5 +187,5 @@
             T* pointer_;
             OrxonoxClass* base_;
-            Functor* callback_;
+            FunctorPtr callback_;
     };
 
Index: /code/branches/consolecommands3/src/libraries/core/input/InputState.h
===================================================================
--- /code/branches/consolecommands3/src/libraries/core/input/InputState.h	(revision 7197)
+++ /code/branches/consolecommands3/src/libraries/core/input/InputState.h	(revision 7198)
@@ -150,7 +150,7 @@
         void left();
         //! Sets a functor to be called upon activation of the state
-        void setEnterFunctor(Functor* functor) { this->enterFunctor_ = functor; }
+        void setEnterFunctor(const FunctorPtr& functor) { this->enterFunctor_ = functor; }
         //! Sets a functor to be called upon deactivation of the state
-        void setLeaveFunctor(Functor* functor) { this->leaveFunctor_ = functor; }
+        void setLeaveFunctor(const FunctorPtr& functor) { this->leaveFunctor_ = functor; }
 
     private:
@@ -172,6 +172,6 @@
         //! Handler to be used for all joy sticks (needs to be saved in case another joy stick gets attached)
         InputHandler*               joyStickHandlerAll_;
-        Functor*                    enterFunctor_;          //!< Functor to be executed on enter
-        Functor*                    leaveFunctor_;          //!< Functor to be executed on leave
+        FunctorPtr                  enterFunctor_;          //!< Functor to be executed on enter
+        FunctorPtr                  leaveFunctor_;          //!< Functor to be executed on leave
     };
 
Index: /code/branches/consolecommands3/src/libraries/core/input/KeyBinderManager.cc
===================================================================
--- /code/branches/consolecommands3/src/libraries/core/input/KeyBinderManager.cc	(revision 7197)
+++ /code/branches/consolecommands3/src/libraries/core/input/KeyBinderManager.cc	(revision 7198)
@@ -156,5 +156,5 @@
         {
             COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
-            KeyDetector::getInstance().setCallback(shared_ptr<Functor>(createFunctor(&KeyBinderManager::keybindKeyPressed, this)));
+            KeyDetector::getInstance().setCallback(createFunctor(&KeyBinderManager::keybindKeyPressed, this));
             InputManager::getInstance().enterState("detector");
             this->command_ = command;
Index: /code/branches/consolecommands3/src/libraries/core/input/KeyBinderManager.h
===================================================================
--- /code/branches/consolecommands3/src/libraries/core/input/KeyBinderManager.h	(revision 7197)
+++ /code/branches/consolecommands3/src/libraries/core/input/KeyBinderManager.h	(revision 7198)
@@ -99,5 +99,5 @@
         void unbind(const std::string& binding); //tolua_export
         void tunbind(const std::string& binding);
-        inline void registerKeybindCallback(Functor* function) { this->callbackFunction_.reset(function); } // tolua_export
+        inline void registerKeybindCallback(const FunctorPtr& function) { this->callbackFunction_ = function; } // tolua//_//export // <-- FIXME
 
     private:
@@ -114,5 +114,5 @@
 
         // keybind command related
-        shared_ptr<Functor> callbackFunction_;       //! Function to be called when key was pressed after "keybind" command
+        FunctorPtr callbackFunction_;                //! Function to be called when key was pressed after "keybind" command
         bool bBinding_;                              //! Tells whether a key binding process is active
         bool bTemporary_;                            //! Stores tkeybind/keybind value
Index: /code/branches/consolecommands3/src/libraries/core/input/KeyDetector.h
===================================================================
--- /code/branches/consolecommands3/src/libraries/core/input/KeyDetector.h	(revision 7197)
+++ /code/branches/consolecommands3/src/libraries/core/input/KeyDetector.h	(revision 7198)
@@ -46,5 +46,5 @@
         ~KeyDetector();
 
-        void setCallback(const shared_ptr<Functor>& function) { this->callbackFunction_ = function; }
+        void setCallback(const FunctorPtr& function) { this->callbackFunction_ = function; }
 
     private:
@@ -55,5 +55,5 @@
         void assignCommands();
 
-        shared_ptr<Functor> callbackFunction_;
+        FunctorPtr callbackFunction_;
         InputState* inputState_;
         static std::string callbackCommand_s;
Index: /code/branches/consolecommands3/src/libraries/network/NetworkFunction.cc
===================================================================
--- /code/branches/consolecommands3/src/libraries/network/NetworkFunction.cc	(revision 7197)
+++ /code/branches/consolecommands3/src/libraries/network/NetworkFunction.cc	(revision 7198)
@@ -68,5 +68,5 @@
 
 
-  NetworkFunctionStatic::NetworkFunctionStatic(FunctorStatic* functor, const std::string& name, const NetworkFunctionPointer& p):
+  NetworkFunctionStatic::NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p):
     NetworkFunctionBase(name)
   {
@@ -76,9 +76,4 @@
     NetworkFunctionStatic::getFunctorMap()[p] = this;
     NetworkFunctionStatic::getIdMap()[ this->getNetworkID() ] = this;
-  }
-
-  NetworkFunctionStatic::~NetworkFunctionStatic()
-  {
-    delete this->functor_;
   }
 
Index: /code/branches/consolecommands3/src/libraries/network/NetworkFunction.h
===================================================================
--- /code/branches/consolecommands3/src/libraries/network/NetworkFunction.h	(revision 7197)
+++ /code/branches/consolecommands3/src/libraries/network/NetworkFunction.h	(revision 7198)
@@ -102,6 +102,5 @@
 class _NetworkExport NetworkFunctionStatic: public NetworkFunctionBase {
   public:
-    NetworkFunctionStatic(FunctorStatic* functor, const std::string& name, const NetworkFunctionPointer& p);
-    ~NetworkFunctionStatic();
+    NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p);
 
     inline void call(){ (*this->functor_)(); }
@@ -124,5 +123,5 @@
     static std::map<NetworkFunctionPointer, NetworkFunctionStatic*>& getFunctorMap();
     static std::map<uint32_t, NetworkFunctionStatic*>& getIdMap();
-    FunctorStatic* functor_;
+    FunctorStaticPtr functor_;
 
 };
@@ -155,6 +154,5 @@
 template <class T> class NetworkMemberFunction: public NetworkMemberFunctionBase {
   public:
-    NetworkMemberFunction(FunctorMember<T>* functor, const std::string& name, const NetworkFunctionPointer& p);
-    ~NetworkMemberFunction();
+    NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p);
 
     inline void call(uint32_t objectID)
@@ -190,14 +188,10 @@
 
   private:
-    FunctorMember<T>* functor_;
-};
-
-template <class T> NetworkMemberFunction<T>::NetworkMemberFunction(FunctorMember<T>* functor, const std::string& name, const NetworkFunctionPointer& p):
+    FunctorMemberPtr<T> functor_;
+};
+
+template <class T> NetworkMemberFunction<T>::NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p):
     NetworkMemberFunctionBase(name, p), functor_(functor)
 {
-}
-template <class T> NetworkMemberFunction<T>::~NetworkMemberFunction()
-{
-  delete this->functor_;
 }
 
