Index: trunk/src/lua/lua_glm.cc
===================================================================
--- trunk/src/lua/lua_glm.cc	(revision 173)
+++ trunk/src/lua/lua_glm.cc	(revision 174)
@@ -108,12 +108,20 @@
 int nlua_vec_new( lua_State* L )
 {
-	nlua_push_vec( L, nlua_vec_constructor<T,sizeof( T ) / sizeof( typename T::value_type )>::construct( L, 1 ) );
-	return 1;
-}
+	nlua_push_vec<T>( L, nlua_vec_constructor<T,sizeof( T ) / sizeof( typename T::value_type )>::construct( L, 1 ) );
+	return 1;
+}
+
+template< typename T >
+int nlua_vec_clone( lua_State* L )
+{
+	nlua_push_vec<T>( L, nlua_to_vec<T>( L, 1 ) );
+	return 1;
+}
+
 
 template< typename T >
 int nlua_vec_call( lua_State* L )
 {
-	nlua_push_vec( L, nlua_vec_constructor<T,sizeof( T ) / sizeof( typename T::value_type )>::construct( L, 2 ) );
+	nlua_push_vec<T>( L, nlua_vec_constructor<T,sizeof( T ) / sizeof( typename T::value_type )>::construct( L, 2 ) );
 	return 1;
 }
@@ -224,5 +232,5 @@
 	}
 
-	luaL_getmetafield( L, 1, "__base" );
+	luaL_getmetafield( L, 1, "__functions" );
 	lua_pushvalue( L, 2 );
 	lua_rawget( L, -2 );
@@ -281,11 +289,16 @@
 int luaopen_vec( lua_State * L )
 {
+	static const struct luaL_Reg nlua_vec_sf [] = {
+		{ "new",            nlua_vec_new<T> },
+		{NULL, NULL}
+	};
+
 	static const struct luaL_Reg nlua_vec_f [] = {
-		{ "new",            nlua_vec_new<T> },
+		{ "clone",          nlua_vec_clone<T> },
 		{ "get",            nlua_vec_get<T> },
 		{NULL, NULL}
 	};
 
-	static const struct luaL_Reg nlua_vec_fm [] = {
+	static const struct luaL_Reg nlua_vec_sm [] = {
 		{ "__call",         nlua_vec_call<T> },
 		{NULL, NULL}
@@ -309,9 +322,11 @@
 	lua_createtable( L, 0, 0 );
 	nlua_register( L, nlua_vec_f, -1 );
-	lua_pushvalue(L, -1);
-	lua_setfield(L, -3, "__base" );
-	lua_replace(L, -2);
+	lua_setfield(L, -2, "__functions" );
+	lua_pop( L, 1 );
+
 	lua_createtable( L, 0, 0 );
-	nlua_register( L, nlua_vec_fm, -1 );
+	nlua_register( L, nlua_vec_sf, -1 );
+	lua_createtable( L, 0, 0 );
+	nlua_register( L, nlua_vec_sm, -1 );
 	lua_setmetatable( L, -2 );
 	return 1;
