Index: trunk/src/lua/lua_glm.cc
===================================================================
--- trunk/src/lua/lua_glm.cc	(revision 56)
+++ trunk/src/lua/lua_glm.cc	(revision 74)
@@ -335,4 +335,5 @@
 	nlua_swizzel_lookup['v'] = 0;
 	nlua_swizzel_lookup['3'] = 3;
+	int stack = lua_gettop( L );
 	luaL_requiref(L, "ivec2", luaopen_vec<glm::ivec2>, 1);
 	luaL_requiref(L, "ivec3", luaopen_vec<glm::ivec3>, 1);
@@ -341,4 +342,5 @@
 	luaL_requiref(L, "vec3", luaopen_vec<glm::vec3>, 1);
 	luaL_requiref(L, "vec4", luaopen_vec<glm::vec4>, 1);
-}
-
+	lua_settop( L, stack );
+}
+
Index: trunk/src/lua/lua_state.cc
===================================================================
--- trunk/src/lua/lua_state.cc	(revision 56)
+++ trunk/src/lua/lua_state.cc	(revision 74)
@@ -24,6 +24,7 @@
 }
 
-lua::state::state( bool is_main /*= false*/ )
-{
+lua::state::state( bool load_libs /*= false*/ )
+{
+	load_lua_library();
 	m_owner = true;
 	L = luaL_newstate( );
@@ -33,15 +34,22 @@
 	lua_call(L, 1, 0);
 
-	if (is_main)
-	{
-		NV_ASSERT( this == get(), "lua_state : another main state created!" );
+	if ( load_libs )
+	{
 		stack_guard guard( this );
-		luaopen_base( L );
-		luaopen_string( L );
-		luaopen_table( L );
-		luaopen_math( L );
-	}
-
-	NV_LOG( nv::LOG_TRACE, is_main ? "Main Lua state created" : "Secondary Lua state created");
+		static const luaL_Reg lualibs[] =
+		{
+			{ "string", luaopen_string },
+			{ "table",  luaopen_table },
+			{ "math",   luaopen_math },
+			{ NULL, NULL}
+		};
+		const luaL_Reg *lib = lualibs;
+		for(; lib->func != NULL; lib++)
+		{
+			lib->func( L );
+		}
+	}
+
+	NV_LOG( nv::LOG_TRACE, "Lua state created" );
 }
 
@@ -121,10 +129,4 @@
 }
 
-lua::state* lua::state::get()
-{
-	static lua::state main_state(true);
-	return &main_state;
-}
-
 bool lua::state::push( const std::string& path, bool global )
 {
@@ -275,5 +277,5 @@
 	for ( int i = 0; i < top; ++i )
 	{
-		NV_LOG( LOG_DEBUG, "#" << i+1 << " - " << lua_typename(L, i+1) << " = " << nlua_typecontent(L, i+1) );
+		NV_LOG( LOG_DEBUG, "#" << i+1 << " - " << lua_typename(L, lua_type(L, i+1) ) << " = " << nlua_typecontent(L, i+1) );
 	}
 }
