Index: /code/branches/resource2/src/core/Core.cc
===================================================================
--- /code/branches/resource2/src/core/Core.cc	(revision 5654)
+++ /code/branches/resource2/src/core/Core.cc	(revision 5655)
@@ -78,5 +78,4 @@
 #include "TclBind.h"
 #include "TclThreadManager.h"
-#include "ToluaBindCore.h"
 #include "input/InputManager.h"
 
@@ -267,6 +266,4 @@
             setThreadAffinity(static_cast<unsigned int>(limitToCPU));
 #endif
-        // Add tolua interface
-        LuaState::addToluaInterface(&tolua_Core_open, "Core");
 
         // Manage ini files and set the default settings file (usually orxonox.ini)
Index: /code/branches/resource2/src/core/LuaState.cc
===================================================================
--- /code/branches/resource2/src/core/LuaState.cc	(revision 5654)
+++ /code/branches/resource2/src/core/LuaState.cc	(revision 5655)
@@ -39,4 +39,5 @@
 #include "Core.h"
 #include "Resource.h"
+#include "ToluaBindCore.h"
 
 namespace orxonox
@@ -44,4 +45,7 @@
     LuaState::ToluaInterfaceMap LuaState::toluaInterfaces_s;
     std::vector<LuaState*> LuaState::instances_s;
+
+    // Do this after declaring toluaInterfaces_s and instances_s to avoid larger problems
+    DeclareToluaInterface(Core);
 
     LuaState::LuaState()
Index: /code/branches/resource2/src/core/LuaState.h
===================================================================
--- /code/branches/resource2/src/core/LuaState.h	(revision 5654)
+++ /code/branches/resource2/src/core/LuaState.h	(revision 5655)
@@ -40,4 +40,5 @@
 
 #include "util/ScopeGuard.h"
+#include "ToluaInterface.h"
 
 // tolua_begin
Index: /code/branches/resource2/src/core/ToluaInterface.h
===================================================================
--- /code/branches/resource2/src/core/ToluaInterface.h	(revision 5655)
+++ /code/branches/resource2/src/core/ToluaInterface.h	(revision 5655)
@@ -0,0 +1,45 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+    This is required because tolua would parse this macro in LuaState.h and fail
+*/
+
+#ifndef _ToluaInterface_H__
+#define _ToluaInterface_H__
+
+#include "CorePrereqs.h"
+#include <boost/preprocessor/cat.hpp>
+
+// Macro for declaring a tolua interface of a library/module
+#define DeclareToluaInterface(libraryName) \
+    static bool BOOST_PP_CAT(bDummy##libraryName, __LINE__) = orxonox::LuaState::addToluaInterface(&tolua_##libraryName##_open, #libraryName); \
+    static Loki::ScopeGuardImpl1<bool (*)(const std::string&), std::string> BOOST_PP_CAT(dummy##libraryName, __LINE__)(&orxonox::LuaState::removeToluaInterface, #libraryName)
+
+#endif /* _ToluaInterface_H__ */
Index: /code/branches/resource2/src/orxonox/Main.cc
===================================================================
--- /code/branches/resource2/src/orxonox/Main.cc	(revision 5654)
+++ /code/branches/resource2/src/orxonox/Main.cc	(revision 5655)
@@ -48,4 +48,6 @@
 #include "core/CommandLine.h"
 #include "core/Game.h"
+#include "core/LuaState.h"
+#include "ToluaBindOrxonox.h"
 
 SetCommandLineSwitch(console).information("Start in console mode (text IO only)");
@@ -55,4 +57,6 @@
 SetCommandLineSwitch(dedicated).information("Start in dedicated server mode");
 SetCommandLineSwitch(standalone).information("Start in standalone mode");
+
+DeclareToluaInterface(Orxonox);
 
 /*
Index: /code/branches/resource2/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- /code/branches/resource2/src/orxonox/gamestates/GSRoot.cc	(revision 5654)
+++ /code/branches/resource2/src/orxonox/gamestates/GSRoot.cc	(revision 5655)
@@ -33,7 +33,5 @@
 #include "core/Game.h"
 #include "core/GameMode.h"
-#include "core/LuaState.h"
 #include "network/NetworkFunction.h"
-#include "ToluaBindOrxonox.h"
 #include "tools/Timer.h"
 #include "interfaces/TimeFactorListener.h"
@@ -53,7 +51,4 @@
         this->ccSetTimeFactor_ = 0;
         this->ccPause_ = 0;
-
-        // Tell LuaBind about all tolua interfaces
-        LuaState::addToluaInterface(&tolua_Orxonox_open, "Orxonox");
     }
 
