Index: trunk/nv/common.hh
===================================================================
--- trunk/nv/common.hh	(revision 265)
+++ trunk/nv/common.hh	(revision 266)
@@ -143,6 +143,4 @@
 namespace nv
 {
-	class uid_store;
-
 	namespace lua
 	{
Index: trunk/nv/gui/gui_element.hh
===================================================================
--- trunk/nv/gui/gui_element.hh	(revision 265)
+++ trunk/nv/gui/gui_element.hh	(revision 266)
@@ -186,4 +186,18 @@
 			 */
 			virtual void recalculate_absolute_children();
+
+			/**
+			 * Moves element to back of child list (top of stack)
+			 *
+			 * @returns true if object found, false otherwise
+			 */
+			bool move_to_top( element* child );
+
+			/**
+			 * Moves element to front of child list (bottom of stack)
+			 *
+			 * @returns true if object found, false otherwise
+			 */
+			bool move_to_bottom( element* child );
 
 		protected:
Index: trunk/nv/lua/lua_object.hh
===================================================================
--- trunk/nv/lua/lua_object.hh	(revision 265)
+++ 	(revision )
@@ -1,48 +1,0 @@
-// Copyright (C) 2014 ChaosForge Ltd 
-// http://chaosforge.org/
-//
-// This file is part of NV Libraries.
-// For conditions of distribution and use, see copyright notice in nv.hh
-
-#ifndef NV_LUA_OBJECT_HH
-#define NV_LUA_OBJECT_HH
-
-#include <nv/common.hh>
-#include <nv/lua/lua_values.hh>
-#include <nv/object.hh>
-
-namespace nv
-{
-
-	namespace lua
-	{
-
-		namespace detail
-		{
-
-			template <typename T>
-			struct type_degrade< T*, typename std::enable_if< std::is_base_of<object, T >::value >::type >
-			{
-				typedef object* type;
-			};
-
-		}
-
-		template <>
-		struct pass_traits<object*>
-		{
-			static void push( lua_State *L, object* o ) 
-			{
-				if ( o )
-					detail::push_ref_object( L, lua::ref(o->get_lua_index()) );
-				else
-					detail::push_nil( L );
-			}
-			static object* to( lua_State *L, int index ) { return static_cast< object* >( detail::to_ref_object( L, index ) ); }
-			static object* to( lua_State *L, int index, object* def ) { return static_cast< object* >( detail::to_ref_object( L, index, def ) ); }
-		};
-
-	}
-}
-
-#endif // NV_LUA_OBJECT_HH
Index: trunk/nv/object.hh
===================================================================
--- trunk/nv/object.hh	(revision 265)
+++ trunk/nv/object.hh	(revision 266)
@@ -20,9 +20,4 @@
 	public:
 		friend class root;
-
-		/**
-		 * Register the object type in the type database.
-		 */
-		//static void register_type( type_database* db );
 
 		/// List type
@@ -134,23 +129,4 @@
 		const std::string& get_id() const { return m_id; }
 
-		/**
-		 * Returns object UID
-		 */
-		int get_lua_index() const { return m_lua_index; }
-
-		/**
-		 * Moves object to back of child list (top of stack)
-		 *
-		 * @returns true if object found, false otherwise
-		 */
-		bool move_to_top( object* child );
-
-		/**
-		 * Moves object to front of child list (bottom of stack)
-		 *
-		 * @returns true if object found, false otherwise
-		 */
-		bool move_to_bottom( object* child );
-
 		list::iterator begin() { return m_children.begin(); }
 		list::iterator end()   { return m_children.end(); }
@@ -168,6 +144,4 @@
 		string   m_name;            ///< name of the object
 		uid      m_uid;             ///< uid of the object
-		int      m_lua_index;       ///< lua reference
-		int      m_lua_proto_index; ///< lua reference
 		object*  m_parent;          ///< pointer to parent
 		list     m_children;        ///< children objects
Index: trunk/nv/root.hh
===================================================================
--- trunk/nv/root.hh	(revision 265)
+++ trunk/nv/root.hh	(revision 266)
@@ -20,7 +20,5 @@
 	{
 	public:
-		root() : m_lua_state( nullptr ), m_uid_store( nullptr ) {}
-		lua::state*    get_lua_state()     const { return m_lua_state; }
-		uid_store*     get_uid_store()     const { return m_uid_store; }
+		root() {}
 		template < typename T >
 		object* create_object( const std::string& id )
@@ -30,13 +28,9 @@
 			return o;
 		}
-		void register_with_lua( object* o, const char* lua_name, const char* storage );
 		void destroy_children( object* o );
 		virtual void destroy_object( object* o );
 		virtual ~root() {}
 	protected:
-		virtual void object_created( object* o );
-
-		lua::state*    m_lua_state;
-		uid_store*     m_uid_store; 
+		virtual void object_created( object* ) {}
 	};
 	
Index: trunk/nv/uid.hh
===================================================================
--- trunk/nv/uid.hh	(revision 265)
+++ trunk/nv/uid.hh	(revision 266)
@@ -19,14 +19,13 @@
 namespace nv
 {
-	class object;
 
-	class uid_store
+	class uid_store_raw
 	{
 	public:
 		
 		/**
-		 * Creates a new instance of the unique indentifier store.
+		 * Creates a new instance of the unique identifier store.
 		 */
-		uid_store();
+		uid_store_raw();
 
 		/**
@@ -36,5 +35,5 @@
 		 * @returns The stored object for that ID.
 		 */
-		object* get( uid auid ) const;
+		void* get( uid auid ) const;
 
 		/**
@@ -52,5 +51,5 @@
 		 * @param auid The ID to assign to the object.
 		 */
-		void insert( object* o, uid auid );
+		void insert( void* o, uid auid );
 
 		/**
@@ -60,5 +59,5 @@
 		 * @returns The ID the object was store under.
 		 */
-		uid insert( object* o );
+		uid insert( void* o );
 
 		/**
@@ -72,5 +71,21 @@
 		 * Destroys the unique identifier store.
 		 */
-		~uid_store();
+		~uid_store_raw();
+
+	protected:
+		typedef std::unordered_map< uid, void* > map;
+		map m_map; ///< The hash map everything is stored in.
+		uid m_current; ///< The last UID assigned.
+	};
+
+	template < typename T >
+	class uid_store
+	{
+	public:
+		T* get( uid auid ) const      { return static_cast<T*>( m_store.get( auid ) ); }
+		bool remove( uid auid )       { m_store.remove( auid ); }
+		void insert( T* o, uid auid ) { m_store.insert( o, auid ); }
+		uid insert( T* o )            { return m_store.insert( o ); }
+		uid request_uid()             { return m_store.request_uid(); }
 
 		/**
@@ -81,14 +96,13 @@
 		 * @returns An object of the indicated type that was stored at the indicated ID.
 		 */
-		template< typename T >
-		T* get_as( uid auid ) const 
+		template< typename U >
+		U* get_as( uid auid ) const 
 		{
-			return dynamic_cast< T* >( get(auid) );
+			return dynamic_cast< U* >( get(auid) );
 		}
-	private:
-		typedef std::unordered_map< uid, object* > map;
-		map m_map; ///< The hash map everything is stored in.
-		uid m_current; ///< The last UID assigned.
+	protected:
+		uid_store_raw m_store;
 	};
+	
 }
 
Index: trunk/src/gui/gui_element.cc
===================================================================
--- trunk/src/gui/gui_element.cc	(revision 265)
+++ trunk/src/gui/gui_element.cc	(revision 266)
@@ -81,4 +81,29 @@
 }
 
+
+bool element::move_to_top( element* child )
+{
+	list::iterator it = std::find( m_children.begin(), m_children.end(), (object*)child );
+	if ( it != m_children.end() )
+	{
+		m_children.erase( it );
+		m_children.push_back( child );
+		return true;
+	}	
+	return false;
+}
+
+bool element::move_to_bottom( element* child )
+{
+	list::iterator it = std::find( m_children.begin(), m_children.end(), (object*)child );
+	if ( it != m_children.end() )
+	{
+		m_children.erase( it );
+		m_children.push_front( child );
+		return true;
+	}	
+	return false;
+}
+
 element::~element()
 {
Index: trunk/src/object.cc
===================================================================
--- trunk/src/object.cc	(revision 265)
+++ trunk/src/object.cc	(revision 266)
@@ -8,7 +8,4 @@
 
 #include <algorithm>
-#include "nv/types.hh"
-#include "nv/lua/lua_state.hh"
-#include "nv/uid.hh"
 
 using namespace nv;
@@ -18,6 +15,4 @@
 	, m_name()
 	, m_uid(0)
-	, m_lua_index(lua::ref::none)
-	, m_lua_proto_index(lua::ref::none)
 	, m_parent( nullptr )
 	, m_children()
@@ -124,27 +119,4 @@
 }
 
-bool object::move_to_top( object* child )
-{
-	list::iterator it = std::find( m_children.begin(), m_children.end(), child );
-	if ( it != m_children.end() )
-	{
-		m_children.erase( it );
-		m_children.push_back( child );
-		return true;
-	}	
-	return false;
-}
-
-bool object::move_to_bottom( object* child )
-{
-	list::iterator it = std::find( m_children.begin(), m_children.end(), child );
-	if ( it != m_children.end() )
-	{
-		m_children.erase( it );
-		m_children.push_front( child );
-		return true;
-	}	
-	return false;
-}
 
 // void object::register_type( type_database* db )
Index: trunk/src/root.cc
===================================================================
--- trunk/src/root.cc	(revision 265)
+++ trunk/src/root.cc	(revision 266)
@@ -10,24 +10,8 @@
 #include "nv/lua/lua_state.hh"
 
-void nv::root::object_created( object* o )
-{
-	if ( m_uid_store )
-	{
-		o->m_uid = m_uid_store->insert( o );
-	}
-}
-
 void nv::root::destroy_object( object* o )
 {
 	destroy_children( o );
 	o->detach();
-	if ( m_lua_state && o->m_lua_index != lua::ref::none )
-	{
-		m_lua_state->unregister_object( lua::ref( o->m_lua_index ) );
-	}
-	if ( m_uid_store && o->m_uid != 0 )
-	{
-		m_uid_store->remove( o->m_uid );
-	}
 	delete o;
 }
@@ -40,19 +24,2 @@
 	}
 }
-
-void nv::root::register_with_lua( object* o, const char* lua_name, const char* storage )
-{
-	if ( m_lua_state )
-	{
-		if ( lua_name != nullptr )
-		{
-			o->m_lua_index       = m_lua_state->register_object( o, lua_name ).get();
-		}
-		if ( storage != nullptr )
-		{
-			o->m_lua_proto_index = m_lua_state->register_proto( o->get_id().c_str(), storage ).get();
-		}
-	}
-
-}
-
Index: trunk/src/uid.cc
===================================================================
--- trunk/src/uid.cc	(revision 265)
+++ trunk/src/uid.cc	(revision 266)
@@ -9,5 +9,5 @@
 using namespace nv;
 
-uid_store::uid_store()
+uid_store_raw::uid_store_raw()
 	: m_map(), m_current(0)
 {
@@ -15,5 +15,5 @@
 }
 
-object* uid_store::get( uid auid ) const
+void* uid_store_raw::get( uid auid ) const
 {
 	map::const_iterator i = m_map.find( auid );
@@ -25,15 +25,15 @@
 }
 
-bool uid_store::remove( uid auid )
+bool uid_store_raw::remove( uid auid )
 {
 	return m_map.erase( auid ) != 0;
 }
 
-void uid_store::insert( object* o, uid auid )
+void uid_store_raw::insert( void* o, uid auid )
 {
 	m_map[ auid ] = o;
 }
 
-uid uid_store::insert( object* o )
+uid uid_store_raw::insert( void* o )
 {
 	uid u = request_uid();
@@ -42,10 +42,10 @@
 }
 
-uid uid_store::request_uid()
+uid uid_store_raw::request_uid()
 {
 	return ++m_current;
 }
 
-uid_store::~uid_store()
+uid_store_raw::~uid_store_raw()
 {
 	// no-op
