Index: /code/branches/netp6/src/core/CorePrecompiledHeaders.h
===================================================================
--- /code/branches/netp6/src/core/CorePrecompiledHeaders.h	(revision 3263)
+++ /code/branches/netp6/src/core/CorePrecompiledHeaders.h	(revision 3264)
@@ -60,6 +60,4 @@
 #include <boost/shared_ptr.hpp> // 12
 #include <boost/preprocessor/cat.hpp> // 12
-// Included by both filesystem and thread but still relatively small
-#include <boost/iterator/iterator_facade.hpp> // 10
 
 // Just in case some header included windows.h
Index: /code/branches/netp6/src/core/CorePrereqs.h
===================================================================
--- /code/branches/netp6/src/core/CorePrereqs.h	(revision 3263)
+++ /code/branches/netp6/src/core/CorePrereqs.h	(revision 3264)
@@ -150,5 +150,4 @@
     class SubclassIdentifier;
     class TclBind;
-    struct TclInterpreterBundle;
     class TclThreadManager;
     class Template;
@@ -207,5 +206,5 @@
         template <class String, class Traits> class basic_path;
         typedef basic_path<std::string, path_traits> path;
-    } 
+    }
     class thread;
     class mutex;
Index: /code/branches/netp6/src/core/IRC.cc
===================================================================
--- /code/branches/netp6/src/core/IRC.cc	(revision 3263)
+++ /code/branches/netp6/src/core/IRC.cc	(revision 3264)
@@ -47,5 +47,5 @@
     {
         RegisterRootObject(IRC);
-        this->bundle_ = 0;
+        this->interpreter_ = 0;
     }
 
@@ -54,12 +54,12 @@
         unsigned int threadID = (unsigned int)IRC_TCL_THREADID;
         TclThreadManager::createID(threadID);
-        this->bundle_ = TclThreadManager::getInstance().getInterpreterBundle(threadID);
+        this->interpreter_ = TclThreadManager::getInstance().getTclInterpreter(threadID);
 
         try
         {
-            this->bundle_->interpreter_->def("orxonox::irc::say", IRC::tcl_say, Tcl::variadic());
-            this->bundle_->interpreter_->def("orxonox::irc::privmsg", IRC::tcl_privmsg, Tcl::variadic());
-            this->bundle_->interpreter_->def("orxonox::irc::action", IRC::tcl_action, Tcl::variadic());
-            this->bundle_->interpreter_->def("orxonox::irc::info", IRC::tcl_info, Tcl::variadic());
+            this->interpreter_->def("orxonox::irc::say", IRC::tcl_say, Tcl::variadic());
+            this->interpreter_->def("orxonox::irc::privmsg", IRC::tcl_privmsg, Tcl::variadic());
+            this->interpreter_->def("orxonox::irc::action", IRC::tcl_action, Tcl::variadic());
+            this->interpreter_->def("orxonox::irc::info", IRC::tcl_info, Tcl::variadic());
         }
         catch (Tcl::tcl_error const &e)
@@ -68,5 +68,5 @@
         {   COUT(1) << "Error while initializing Tcl (IRC): " << e.what();   }
 
-        this->nickname_ = "orx" + getConvertedValue<int, std::string>((unsigned int)rand());
+        this->nickname_ = "orx" + getConvertedValue<int, std::string>(static_cast<unsigned int>(rand()));
         TclThreadManager::execute(threadID, "set nickname " + this->nickname_);
         TclThreadManager::execute(threadID, "source irc.tcl");
@@ -81,5 +81,5 @@
     bool IRC::eval(const std::string& command)
     {
-        if (!IRC::getInstance().bundle_)
+        if (!IRC::getInstance().interpreter_)
         {
             IRC::getInstance().initialize();
@@ -90,5 +90,5 @@
         try
         {
-            IRC::getInstance().bundle_->interpreter_->eval(command);
+            IRC::getInstance().interpreter_->eval(command);
             return true;
         }
Index: /code/branches/netp6/src/core/IRC.h
===================================================================
--- /code/branches/netp6/src/core/IRC.h	(revision 3263)
+++ /code/branches/netp6/src/core/IRC.h	(revision 3264)
@@ -59,5 +59,5 @@
             ~IRC() {}
 
-            TclInterpreterBundle* bundle_;
+            Tcl::interpreter* interpreter_;
             std::string nickname_;
     };
Index: /code/branches/netp6/src/core/TclThreadManager.cc
===================================================================
--- /code/branches/netp6/src/core/TclThreadManager.cc	(revision 3263)
+++ /code/branches/netp6/src/core/TclThreadManager.cc	(revision 3264)
@@ -30,4 +30,7 @@
 
 #include <boost/bind.hpp>
+#include <boost/thread/condition.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
 #include <OgreTimer.h>
 #include <cpptcl/cpptcl.h>
@@ -56,4 +59,32 @@
     SetConsoleCommand(TclThreadManager, flush,   false).argumentCompleter(0, autocompletion::tclthreads());
 
+    struct TclInterpreterBundle
+    {
+        unsigned int id_;
+
+        std::list<std::string> queue_;
+        boost::mutex queueMutex_;
+
+        Tcl::interpreter* interpreter_;
+        std::string interpreterName_;
+        boost::try_mutex interpreterMutex_;
+
+        std::list<unsigned int> queriers_;
+        boost::mutex queriersMutex_;
+
+        bool running_;
+        boost::mutex runningMutex_;
+
+        bool finished_;
+        boost::mutex finishedMutex_;
+        boost::condition finishedCondition_;
+    };
+
+
+    static boost::thread::id threadID_g;
+    static boost::mutex bundlesMutex_g;
+    static boost::condition fullQueueCondition_g;
+    static boost::condition orxonoxEvalCondition_g;
+
     TclThreadManager* TclThreadManager::singletonRef_s = 0;
 
@@ -66,11 +97,7 @@
 
         this->threadCounter_ = 0;
-        this->orxonoxInterpreterBundle_.id_ = 0;
-        this->orxonoxInterpreterBundle_.interpreter_ = interpreter;
-#if (BOOST_VERSION >= 103500)
-        this->threadID_ = boost::this_thread::get_id();
-#else
-        //
-#endif
+        this->orxonoxInterpreterBundle_->id_ = 0;
+        this->orxonoxInterpreterBundle_->interpreter_ = interpreter;
+        threadID_g = boost::this_thread::get_id();
     }
 
@@ -79,5 +106,5 @@
         unsigned int threadID;
         {
-            boost::mutex::scoped_lock bundles_lock(this->bundlesMutex_);
+            boost::mutex::scoped_lock bundles_lock(bundlesMutex_g);
             if (this->interpreterBundles_.begin() == this->interpreterBundles_.end())
                 return;
@@ -92,5 +119,5 @@
     unsigned int TclThreadManager::create()
     {
-        boost::mutex::scoped_lock bundles_lock(TclThreadManager::getInstance().bundlesMutex_);
+        boost::mutex::scoped_lock bundles_lock(bundlesMutex_g);
         TclThreadManager::getInstance().threadCounter_++;
         std::string name = getConvertedValue<unsigned int, std::string>(TclThreadManager::getInstance().threadCounter_);
@@ -132,20 +159,12 @@
                     if (bundle->finished_)
                     {
-                        boost::mutex::scoped_lock bundles_lock(TclThreadManager::getInstance().bundlesMutex_);
-#if (BOOST_VERSION >= 103500)
+                        boost::mutex::scoped_lock bundles_lock(bundlesMutex_g);
                         boost::mutex::scoped_try_lock interpreter_lock(bundle->interpreterMutex_);
-#else
-                        boost::try_mutex::scoped_try_lock interpreter_lock(bundle->interpreterMutex_);
-#endif
                         try
                         {
                             while (!interpreter_lock.try_lock())
                             {
-                                TclThreadManager::getInstance().orxonoxEvalCondition_.notify_one();
-#if (BOOST_VERSION >= 103500)
+                                orxonoxEvalCondition_g.notify_one();
                                 boost::this_thread::yield();
-#else
-                                boost::thread::yield();
-#endif
                             }
                         } catch (...) {}
@@ -157,10 +176,6 @@
                 }
 
-                TclThreadManager::getInstance().orxonoxEvalCondition_.notify_one();
-#if (BOOST_VERSION >= 103500)
+                orxonoxEvalCondition_g.notify_one();
                 boost::this_thread::yield();
-#else
-                boost::thread::yield();
-#endif
             }
 
@@ -181,5 +196,5 @@
     std::string TclThreadManager::query(unsigned int threadID, const std::string& command)
     {
-        return TclThreadManager::getInstance().evalQuery(TclThreadManager::getInstance().orxonoxInterpreterBundle_.id_, threadID, command);
+        return TclThreadManager::getInstance().evalQuery(TclThreadManager::getInstance().orxonoxInterpreterBundle_->id_, threadID, command);
     }
 
@@ -191,6 +206,6 @@
         output += "\t\t";
         {
-            boost::mutex::scoped_lock queue_lock(TclThreadManager::getInstance().orxonoxInterpreterBundle_.queueMutex_);
-            output += getConvertedValue<unsigned int, std::string>(TclThreadManager::getInstance().orxonoxInterpreterBundle_.queue_.size());
+            boost::mutex::scoped_lock queue_lock(TclThreadManager::getInstance().orxonoxInterpreterBundle_->queueMutex_);
+            output += getConvertedValue<unsigned int, std::string>(TclThreadManager::getInstance().orxonoxInterpreterBundle_->queue_.size());
         }
         output += "\t\t";
@@ -198,5 +213,5 @@
         COUT(0) << output << std::endl;
 
-        boost::mutex::scoped_lock bundles_lock(TclThreadManager::getInstance().bundlesMutex_);
+        boost::mutex::scoped_lock bundles_lock(bundlesMutex_g);
         for (std::map<unsigned int, TclInterpreterBundle*>::const_iterator it = TclThreadManager::getInstance().interpreterBundles_.begin(); it != TclThreadManager::getInstance().interpreterBundles_.end(); ++it)
         {
@@ -209,9 +224,5 @@
             output += "\t\t";
             {
-#if (BOOST_VERSION >= 103500)
                 boost::mutex::scoped_try_lock interpreter_lock((*it).second->interpreterMutex_);
-#else
-                boost::try_mutex::scoped_try_lock interpreter_lock((*it).second->interpreterMutex_);
-#endif
                 if (interpreter_lock.try_lock())
                     output += "ready";
@@ -228,5 +239,5 @@
         if (threadID == 0)
         {
-            bundle = &TclThreadManager::getInstance().orxonoxInterpreterBundle_;
+            bundle = TclThreadManager::getInstance().orxonoxInterpreterBundle_;
             COUT(0) << "Queue dump of Orxonox:" << std::endl;
         }
@@ -254,5 +265,5 @@
         TclInterpreterBundle* bundle = 0;
         if (threadID == 0)
-            bundle = &TclThreadManager::getInstance().orxonoxInterpreterBundle_;
+            bundle = TclThreadManager::getInstance().orxonoxInterpreterBundle_;
         else
             if (!(bundle = TclThreadManager::getInstance().getInterpreterBundle(threadID)))
@@ -334,5 +345,5 @@
     TclInterpreterBundle* TclThreadManager::getInterpreterBundle(unsigned int threadID)
     {
-        boost::mutex::scoped_lock bundles_lock(this->bundlesMutex_);
+        boost::mutex::scoped_lock bundles_lock(bundlesMutex_g);
         std::map<unsigned int, TclInterpreterBundle*>::iterator it = this->interpreterBundles_.find(threadID);
         if (it != this->interpreterBundles_.end())
@@ -347,4 +358,9 @@
     }
 
+    Tcl::interpreter* TclThreadManager::getTclInterpreter(unsigned int threadID)
+    {
+        return this->getInterpreterBundle(threadID)->interpreter_;
+    }
+
     std::string TclThreadManager::dumpList(const std::list<unsigned int>& list)
     {
@@ -362,18 +378,10 @@
     void TclThreadManager::error(const std::string& error)
     {
-#if (BOOST_VERSION >= 103500)
-        if (boost::this_thread::get_id() != this->threadID_)
-#else
-        if (boost::thread() != this->threadID_)
-#endif
-        {
-            boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_.queueMutex_);
-            if (this->orxonoxInterpreterBundle_.queue_.size() >= TCLTHREADMANAGER_MAX_QUEUE_LENGTH)
-            {
-#if (BOOST_VERSION >= 103500)
+        if (boost::this_thread::get_id() != threadID_g)
+        {
+            boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_->queueMutex_);
+            if (this->orxonoxInterpreterBundle_->queue_.size() >= TCLTHREADMANAGER_MAX_QUEUE_LENGTH)
+            {
                 boost::this_thread::yield();
-#else
-                boost::thread::yield();
-#endif
                 return;
             }
@@ -385,18 +393,10 @@
     void TclThreadManager::debug(const std::string& error)
     {
-#if (BOOST_VERSION >= 103500)
-        if (boost::this_thread::get_id() != this->threadID_)
-#else
-        if (boost::thread() != this->threadID_)
-#endif
-        {
-            boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_.queueMutex_);
-            if (this->orxonoxInterpreterBundle_.queue_.size() >= TCLTHREADMANAGER_MAX_QUEUE_LENGTH)
-            {
-#if (BOOST_VERSION >= 103500)
+        if (boost::this_thread::get_id() != threadID_g)
+        {
+            boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_->queueMutex_);
+            if (this->orxonoxInterpreterBundle_->queue_.size() >= TCLTHREADMANAGER_MAX_QUEUE_LENGTH)
+            {
                 boost::this_thread::yield();
-#else
-                boost::thread::yield();
-#endif
                 return;
             }
@@ -408,23 +408,23 @@
     void TclThreadManager::pushCommandToQueue(const std::string& command)
     {
-        boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_.queueMutex_);
-        while (this->orxonoxInterpreterBundle_.queue_.size() >= TCLTHREADMANAGER_MAX_QUEUE_LENGTH)
-            this->fullQueueCondition_.wait(queue_lock);
-
-        this->orxonoxInterpreterBundle_.queue_.push_back(command);
+        boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_->queueMutex_);
+        while (this->orxonoxInterpreterBundle_->queue_.size() >= TCLTHREADMANAGER_MAX_QUEUE_LENGTH)
+            fullQueueCondition_g.wait(queue_lock);
+
+        this->orxonoxInterpreterBundle_->queue_.push_back(command);
     }
 
     void TclThreadManager::forceCommandToFrontOfQueue(const std::string& command)
     {
-        boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_.queueMutex_);
-        this->orxonoxInterpreterBundle_.queue_.push_front(command);
+        boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_->queueMutex_);
+        this->orxonoxInterpreterBundle_->queue_.push_front(command);
     }
 
     std::string TclThreadManager::popCommandFromQueue()
     {
-        boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_.queueMutex_);
-        std::string temp = this->orxonoxInterpreterBundle_.queue_.front();
-        this->orxonoxInterpreterBundle_.queue_.pop_front();
-        this->fullQueueCondition_.notify_one();
+        boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_->queueMutex_);
+        std::string temp = this->orxonoxInterpreterBundle_->queue_.front();
+        this->orxonoxInterpreterBundle_->queue_.pop_front();
+        fullQueueCondition_g.notify_one();
         return temp;
     }
@@ -432,6 +432,6 @@
     bool TclThreadManager::queueIsEmpty()
     {
-        boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_.queueMutex_);
-        return this->orxonoxInterpreterBundle_.queue_.empty();
+        boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_->queueMutex_);
+        return this->orxonoxInterpreterBundle_->queue_.empty();
     }
 
@@ -505,12 +505,8 @@
         if (querier)
         {
-            if (this->updateQueriersList(querier, &this->orxonoxInterpreterBundle_))
-            {
-#if (BOOST_VERSION >= 103500)
-                boost::mutex::scoped_lock interpreter_lock(this->orxonoxInterpreterBundle_.interpreterMutex_);
-#else
-                boost::try_mutex::scoped_lock interpreter_lock(this->orxonoxInterpreterBundle_.interpreterMutex_);
-#endif
-                this->orxonoxEvalCondition_.wait(interpreter_lock);
+            if (this->updateQueriersList(querier, this->orxonoxInterpreterBundle_))
+            {
+                boost::mutex::scoped_lock interpreter_lock(this->orxonoxInterpreterBundle_->interpreterMutex_);
+                orxonoxEvalCondition_g.wait(interpreter_lock);
 
                 if (!CommandExecutor::execute(command, false))
@@ -521,6 +517,6 @@
             }
 
-            boost::mutex::scoped_lock queriers_lock(this->orxonoxInterpreterBundle_.queriersMutex_);
-            this->orxonoxInterpreterBundle_.queriers_.clear();
+            boost::mutex::scoped_lock queriers_lock(this->orxonoxInterpreterBundle_->queriersMutex_);
+            this->orxonoxInterpreterBundle_->queriers_.clear();
         }
         return output;
@@ -533,5 +529,5 @@
             target = this->getInterpreterBundle(threadID);
         else
-            target = &this->orxonoxInterpreterBundle_;
+            target = this->orxonoxInterpreterBundle_;
 
         std::string output = "";
@@ -542,5 +538,5 @@
                 querier = this->getInterpreterBundle(querierID);
             else
-                querier = &this->orxonoxInterpreterBundle_;
+                querier = this->orxonoxInterpreterBundle_;
 
             if (querier)
@@ -548,9 +544,5 @@
                 if (this->updateQueriersList(querier, target))
                 {
-#if (BOOST_VERSION >= 103500)
                     boost::mutex::scoped_try_lock interpreter_lock(target->interpreterMutex_);
-#else
-                    boost::try_mutex::scoped_try_lock interpreter_lock(target->interpreterMutex_);
-#endif
                     bool successfullyLocked = false;
                     try
@@ -562,9 +554,5 @@
                             while (!interpreter_lock.try_lock())
                             {
-#if (BOOST_VERSION >= 103500)
                                 boost::this_thread::yield();
-#else
-                                boost::thread::yield();
-#endif
                             }
 
@@ -599,14 +587,10 @@
     {
         {
-            this->orxonoxEvalCondition_.notify_one();
-#if (BOOST_VERSION >= 103500)
+            orxonoxEvalCondition_g.notify_one();
             boost::this_thread::yield();
-#else
-            boost::thread::yield();
-#endif
-        }
-
-        {
-            boost::mutex::scoped_lock bundles_lock(this->bundlesMutex_);
+        }
+
+        {
+            boost::mutex::scoped_lock bundles_lock(bundlesMutex_g);
             for (std::map<unsigned int, TclInterpreterBundle*>::iterator it = this->interpreterBundles_.begin(); it != this->interpreterBundles_.end(); ++it)
             {
@@ -626,9 +610,5 @@
 
         {
-#if (BOOST_VERSION >= 103500)
-            boost::mutex::scoped_lock interpreter_lock(this->orxonoxInterpreterBundle_.interpreterMutex_);
-#else
-            boost::try_mutex::scoped_lock interpreter_lock(this->orxonoxInterpreterBundle_.interpreterMutex_);
-#endif
+            boost::mutex::scoped_lock interpreter_lock(this->orxonoxInterpreterBundle_->interpreterMutex_);
             unsigned long maxtime = (unsigned long)(time.getDeltaTime() * 1000000 * TCLTHREADMANAGER_MAX_CPU_USAGE);
             Ogre::Timer timer;
@@ -644,5 +624,5 @@
     std::list<unsigned int> TclThreadManager::getThreadList() const
     {
-        boost::mutex::scoped_lock bundles_lock(TclThreadManager::getInstance().bundlesMutex_);
+        boost::mutex::scoped_lock bundles_lock(bundlesMutex_g);
         std::list<unsigned int> threads;
         for (std::map<unsigned int, TclInterpreterBundle*>::const_iterator it = this->interpreterBundles_.begin(); it != this->interpreterBundles_.end(); ++it)
@@ -654,9 +634,5 @@
     {
         TclThreadManager::getInstance().debug("TclThread_execute: " + command);
-#if (BOOST_VERSION >= 103500)
         boost::mutex::scoped_lock interpreter_lock(interpreterBundle->interpreterMutex_);
-#else
-        boost::try_mutex::scoped_lock interpreter_lock(interpreterBundle->interpreterMutex_);
-#endif
         try
         {
Index: /code/branches/netp6/src/core/TclThreadManager.h
===================================================================
--- /code/branches/netp6/src/core/TclThreadManager.h	(revision 3263)
+++ /code/branches/netp6/src/core/TclThreadManager.h	(revision 3264)
@@ -35,33 +35,10 @@
 #include <map>
 #include <string>
-#include <boost/thread/condition.hpp>
-#include <boost/thread/mutex.hpp>
-#include <boost/thread/thread.hpp>
-
 #include "core/OrxonoxClass.h"
 
 namespace orxonox
 {
-    struct _CoreExport TclInterpreterBundle
-    {
-        unsigned int id_;
-
-        std::list<std::string> queue_;
-        boost::mutex queueMutex_;
-
-        Tcl::interpreter* interpreter_;
-        std::string interpreterName_;
-        boost::try_mutex interpreterMutex_;
-
-        std::list<unsigned int> queriers_;
-        boost::mutex queriersMutex_;
-
-        bool running_;
-        boost::mutex runningMutex_;
-
-        bool finished_;
-        boost::mutex finishedMutex_;
-        boost::condition finishedCondition_;
-    };
+    // Internal struct
+    struct TclInterpreterBundle;
 
     class _CoreExport TclThreadManager : public OrxonoxClass
@@ -101,4 +78,5 @@
 
             Tcl::interpreter* createNewTclInterpreter(const std::string& threadID);
+            Tcl::interpreter* getTclInterpreter(unsigned int threadID);
             TclInterpreterBundle* getInterpreterBundle(unsigned int threadID);
             std::string dumpList(const std::list<unsigned int>& list);
@@ -119,14 +97,6 @@
 
             unsigned int threadCounter_;
-            TclInterpreterBundle orxonoxInterpreterBundle_;
+            TclInterpreterBundle* orxonoxInterpreterBundle_;
             std::map<unsigned int, TclInterpreterBundle*> interpreterBundles_;
-            boost::mutex bundlesMutex_;
-            boost::condition fullQueueCondition_;
-            boost::condition orxonoxEvalCondition_;
-#if (BOOST_VERSION >= 103500)
-            boost::thread::id threadID_;
-#else
-            boost::thread threadID_;
-#endif
 
             static TclThreadManager* singletonRef_s;
