Index: /trunk/nv/core/types.hh
===================================================================
--- /trunk/nv/core/types.hh	(revision 444)
+++ /trunk/nv/core/types.hh	(revision 445)
@@ -19,5 +19,22 @@
 namespace nv
 {
-	typedef nv::uint64 type_hash;
+
+	struct type_hash_tag {};
+
+	class thash64 : public hash_value< uint64, type_hash_tag >
+	{
+	public:
+		typedef uint64 hash_type;
+		typedef uint64 value_type;
+		typedef thash64 this_type;
+		typedef hash_value< uint64, type_hash_tag > inherited_type;
+
+		// TODO: enforce exact type?
+		constexpr thash64() : inherited_type() {}
+		template < typename T >
+		constexpr thash64() : inherited_type( rtti_type_hash< T >::hash() ) {}
+		constexpr explicit thash64( hash_type value ) : inherited_type( value ) {}
+		constexpr thash64( const thash64& value ) = default;
+	};
 
 	template< typename T >
@@ -57,5 +74,4 @@
 	{
 		shash64     name;     //!< name of the field
-		type_hash   hash; //!< typeinfo for later retrieval of type
 		type_entry* type;     //!< pointer to field type
 		uint32      flags;    //!< flags 
@@ -71,16 +87,14 @@
 	struct type_entry
 	{
-		// Function types for the constructor and destructor of registered types
-		typedef void( *constructor_func )( void* );
-		typedef void( *destructor_func )( void* );
-
-		type_database*          type_db;     //!< Parent type database
-		uint64                  name;        //!< Scoped C++ name of the type
-		constructor_func        constructor; //!< Pointers to the constructor 
-		destructor_func         destructor;  //!< Pointers to the destructor 
-		size_t                  size;        //!< Result of sizeof(type) operation
-		type_entry*             base_type;   //!< Base type
+		type_database*     type_db;     //!< Parent type database
+		shash64            name;        //!< Scoped C++ name of the type
+		constructor_t      constructor; //!< Pointers to the constructor 
+		destructor_t       destructor;  //!< Pointers to the destructor 
+		size_t             size;        //!< Result of sizeof(type) operation
+		type_entry*        base_type;   //!< Base type
 		vector<type_field> field_list;  //!< Field list
 		vector<type_enum>  enum_list;   //!< Enum list
+		hash_store< shash64, type_field* > field_names;
+		hash_store< shash64, type_enum* >  enum_names;
 	};
 
@@ -95,10 +109,10 @@
 
 		template< typename TOBJECT, typename TFIELD >
-		type_creator field( const char* aname, TFIELD TOBJECT::*field, typename enable_if< is_container<TFIELD>::value, void* >::type = nullptr );
+		type_creator field( const string_view& aname, TFIELD TOBJECT::*field, typename enable_if< is_container<TFIELD>::value, void* >::type = nullptr );
 
 		template< typename TOBJECT, typename TFIELD >
-		type_creator field( const char* aname, TFIELD TOBJECT::*field, typename enable_if< !is_container<TFIELD>::value, void* >::type = nullptr );
-
-		type_creator value( const char* name, sint32 value );
+		type_creator field( const string_view& aname, TFIELD TOBJECT::*field, typename enable_if< !is_container<TFIELD>::value, void* >::type = nullptr );
+
+		type_creator value( const string_view& aname, sint32 value );
 	private:
 		type_database* m_database;
@@ -112,36 +126,37 @@
 
 		template< typename TYPE >
-		type_creator create_type( const char* name )
+		type_creator create_type( const string_view& name )
 		{
 			NV_ASSERT( !m_names.exists( name ), "Type redefinition!" );
-			uint64 name_hash = m_names.insert( name );
 			type_entry* i_type = new type_entry;
 			i_type->type_db = this;
-			i_type->name = name_hash;
+			i_type->name = m_names.insert( name );
 			i_type->size = sizeof( TYPE );
 
 			i_type->constructor = raw_construct_object < TYPE >;
 			i_type->destructor  = raw_destroy_object < TYPE >;
-			m_index_by_type[typeid( TYPE )] = i_type;
-			m_index_by_name[name_hash] = i_type;
+			m_index_by_type[ thash64< TYPE >() ] = i_type;
+			m_index_by_name[ i_type->name ] = i_type;
 			m_type_list.push_back( i_type );
 			return type_creator( this, i_type );
 		}
 
-		type_entry* get_type( const char* name )
-		{
-			uint64 name_hash = hash_string<type_hash>( name );
-			auto it = m_index_by_name.find( name_hash );
+		type_entry* get_type( shash64 name )
+		{
+			auto it = m_index_by_name.find( name );
 			return it != m_index_by_name.end() ? it->second : nullptr;
 		}
 
-		type_entry* get_type( type_hash hash )
-		{
-			type_hash_map::iterator it = m_index_by_type.find( hash );
-			if ( it != m_index_by_type.end() )
-			{
-				return it->second;
-			}
-			return nullptr;
+		type_entry* get_type( thash64 hash )
+		{
+			auto it = m_index_by_type.find( hash );
+			return it != m_index_by_type.end() ? it->second : nullptr;
+		}
+
+		template< typename T >
+		type_entry* get_type()
+		{
+			auto it = m_index_by_type.find( thash64< T >() );
+			return it != m_index_by_type.end() ? it->second : nullptr;
 		}
 
@@ -156,10 +171,8 @@
 		}
 	private:
-		typedef vector<type_entry*>                   type_list;
-		typedef unordered_map<type_hash, type_entry*> type_hash_map;
-		string_table  m_names;
-		type_list     m_type_list;
-		type_hash_map m_index_by_type;
-		type_hash_map m_index_by_name;
+		string_table                       m_names;
+		vector<type_entry*>                m_type_list;
+		hash_store< shash64, type_entry* > m_index_by_name;
+		hash_store< thash64, type_entry* > m_index_by_type;
 	};
 	
@@ -167,10 +180,10 @@
 	type_creator type_creator::base()
 	{
-		m_entry->base_type = m_database->get_type( typeid( TYPE ) );
+		m_entry->base_type = m_database->get_type< TYPE >();
 		return *this;
 	}
 
 	template< typename TOBJECT, typename TFIELD >
-	type_creator type_creator::field( const char* aname, TFIELD TOBJECT::*field, typename enable_if< is_container<TFIELD>::value, void* >::type )
+	type_creator type_creator::field( const string_view& aname, TFIELD TOBJECT::*field, typename enable_if< is_container<TFIELD>::value, void* >::type )
 	{
 		typedef typename TFIELD::value_type field_type;
@@ -178,6 +191,5 @@
 		type_field f;
 		f.name = m_database->m_names.insert( name );
-		f.hash = rtti_type_hash< remove_pointer_t<field_type> >::hash();
-		f.type = type_db->get_type( f.hash );
+		f.type = type_db->get_type< remove_pointer_t<TFIELD> >();
 		f.flags = TF_CONTAINER |
 			( is_pointer<field_type>::value ? TF_POINTER : 0 ) |
@@ -189,11 +201,10 @@
 
 	template< typename TOBJECT, typename TFIELD >
-	type_creator type_creator::field( const char* aname, TFIELD TOBJECT::*field, typename enable_if< !is_container<TFIELD>::value, void* >::type )
+	type_creator type_creator::field( const string_view& aname, TFIELD TOBJECT::*field, typename enable_if< !is_container<TFIELD>::value, void* >::type )
 	{
 		NV_ASSERT( m_entry->enum_list.empty(), "Type cannot have both enums and fields!" );
 		type_field f;
 		f.name = m_database->m_names.insert( name );
-		f.hash = rtti_type_hash< remove_pointer_t<TFIELD> >::hash();
-		f.type = type_db->get_type( f.hash );
+		f.type = type_db->get_type< remove_pointer_t<TFIELD> >();
 		f.flags =
 			( is_pointer<TFIELD>::value ? TF_POINTER : 0 ) |
@@ -204,9 +215,9 @@
 	}
 
-	inline type_creator type_creator::value( const char* name, sint32 value )
+	inline type_creator type_creator::value( const string_view& aname, sint32 value )
 	{
 		NV_ASSERT( m_entry->field_list.empty(), "Type cannot have both enums and fields!" );
 		type_enum e;
-		e.name = m_database->m_names.insert( name );
+		e.name = m_database->m_names.insert( aname );
 		e.value = value;
 		m_entry->enum_list.push_back( e );
Index: /trunk/nv/lua/lua_state.hh
===================================================================
--- /trunk/nv/lua/lua_state.hh	(revision 444)
+++ /trunk/nv/lua/lua_state.hh	(revision 445)
@@ -111,8 +111,8 @@
 
 			template< typename R, typename T >
-			R get( const T& key, const R& def )
+			R get( T&& key, const R& def )
 			{
 				if ( m_global ) push_global_table();
-				detail::push_value( m_state, key );
+				detail::push_value( m_state, ::nv::forward<T>( key ) );
 				call_get();
 				if ( m_global ) pop_global_table();
@@ -121,8 +121,8 @@
 
 			template< typename R, typename T >
-			R raw_get( const T& key, const R& def )
+			R raw_get( T&& key, const R& def )
 			{
 				if ( m_global ) push_global_table();
-				detail::push_value( m_state, key );
+				detail::push_value( m_state, ::nv::forward<T>( key ) );
 				call_get_raw();
 				if ( m_global ) pop_global_table();
@@ -247,6 +247,8 @@
 			}
 
+			using state_wrapper::call;
+
 			template < typename R >
-			R call( ref table, const path& p )
+			R call_table( ref table, const path& p )
 			{
 				stack_guard guard( this ); // TODO: remove
@@ -262,5 +264,5 @@
 			}
 			template < typename R, typename... Args >
-			R call( ref table, const path& p, Args&&... args )
+			R call_table( ref table, const path& p, Args&&... args )
 			{
 				stack_guard guard( this ); // TODO: remove
Index: /trunk/nv/lua/lua_values.hh
===================================================================
--- /trunk/nv/lua/lua_values.hh	(revision 444)
+++ /trunk/nv/lua/lua_values.hh	(revision 445)
@@ -36,23 +36,23 @@
 		typedef double        lnumber;
 
- 		struct passer
-		{
-			virtual void push( lua_State *L ) const = 0;
-			virtual ~passer(){}
-		};
-
-		template < typename T >
-		struct returner
-		{
-			returner( lua_State *, int ) : value() {}
-			returner( lua_State *, int, const T& ) : value() {}
-			operator T() { return value; }
-			operator const T() const { return value; }
-			virtual returner<T> to( lua_State *L, int index ) = 0;
-			virtual returner<T> to( lua_State *L, int index, const T& def ) = 0;
-			virtual ~returner(){}
-		protected:
-			T value;
-		};
+//  		struct passer
+// 		{
+// 			virtual void push( lua_State *L ) const = 0;
+// 			virtual ~passer(){}
+// 		};
+// 
+// 		template < typename T >
+// 		struct returner
+// 		{
+// 			returner( lua_State *, int ) : value() {}
+// 			returner( lua_State *, int, const T& ) : value() {}
+// 			operator T() { return value; }
+// 			operator const T() const { return value; }
+// 			virtual returner<T> to( lua_State *L, int index ) = 0;
+// 			virtual returner<T> to( lua_State *L, int index, const T& def ) = 0;
+// 			virtual ~returner(){}
+// 		protected:
+// 			T value;
+// 		};
 
 		template < typename T >
@@ -82,5 +82,5 @@
 			lnumber     to_number     ( lua_State *L, int index );
 			bool        to_bool       ( lua_State *L, int index );
-			const char* to_cstring    ( lua_State *L, int index );
+//			const char* to_cstring    ( lua_State *L, int index );
 			string_view to_string_view( lua_State *L, int index );
 			void*       to_pointer    ( lua_State *L, int index );
@@ -91,5 +91,5 @@
 			lnumber     to_number     ( lua_State *L, int index, lnumber def );
 			bool        to_bool       ( lua_State *L, int index, bool def );
-			const char* to_cstring    ( lua_State *L, int index, const char* def );
+//			const char* to_cstring    ( lua_State *L, int index, const char* def );
 			string_view to_string_view( lua_State *L, int index, string_view def );
 			void*       to_pointer    ( lua_State *L, int index, void* def );
@@ -139,11 +139,11 @@
 		};
 
-		template <>
-		struct pass_traits<const char*>
-		{
-			static void push( lua_State *L, const char* s ) { detail::push_cstring( L, s ); }
-			static const char* to( lua_State *L, int index ) { return detail::to_cstring( L, index ); }
-			static const char* to( lua_State *L, int index, const char* def ) { return detail::to_cstring( L, index, def ); }
-		};
+// 		template <>
+// 		struct pass_traits<const char*>
+// 		{
+// 			static void push( lua_State *L, const char* s ) { detail::push_cstring( L, s ); }
+// 			static const char* to( lua_State *L, int index ) { return detail::to_cstring( L, index ); }
+// 			static const char* to( lua_State *L, int index, const char* def ) { return detail::to_cstring( L, index, def ); }
+// 		};
 
 		template <>
@@ -177,15 +177,16 @@
 		};
 
+
 		namespace detail
 		{
 
 			template <typename T, class ENABLE = void >
-			struct type_degrade
-			{
-				typedef remove_cvr_t<T> type;
-			};
-
-			template <typename T>
-			struct type_degrade< T, enable_if_t< is_floating_point< T >::value > >
+			struct lua_type_impl
+			{
+				typedef T type;
+			};
+
+			template <typename T>
+			struct lua_type_impl< T, enable_if_t< is_floating_point< T >::value > >
 			{
 				typedef lnumber type;
@@ -193,5 +194,5 @@
 
 			template <typename T>
-			struct type_degrade< T, enable_if_t< is_integral< T >::value && is_signed< T >::value > >
+			struct lua_type_impl< T, enable_if_t< is_integral< T >::value && is_signed< T >::value > >
 			{
 				typedef linteger type;
@@ -199,5 +200,5 @@
 
 			template <typename T>
-			struct type_degrade< T, enable_if_t< is_integral< T >::value && is_unsigned< T >::value > >
+			struct lua_type_impl< T, enable_if_t< is_integral< T >::value && is_unsigned< T >::value > >
 			{
 				typedef lunsigned type;
@@ -205,22 +206,33 @@
 
 			template <typename T>
-			struct type_degrade< T, enable_if_t< is_cstring< T >::value > >
-			{
-				typedef const char* type;
+			struct lua_type_impl< T, enable_if_t< is_cstring< T >::value > >
+			{
+				typedef string_view type;
 			};
 
 			template <>
-			struct type_degrade< bool >
+			struct lua_type_impl< bool >
 			{
 				typedef bool type;
 			};
 
-			template < typename T >
-			using type_degrade_t = typename type_degrade< T >::type;
+		}
+
+		template < typename T >
+		struct converted_type
+		{
+			typedef typename detail::lua_type_impl< remove_cvr_t<T> >::type type;
+		};
+
+		template < typename T >
+		using converted_type_t = typename converted_type< T >::type;
+
+		namespace detail
+		{
 
  			template < typename T >
- 			void push_value( lua_State *L, const T& p )
+ 			void push_value( lua_State *L, T&& p )
  			{
-				pass_traits< type_degrade_t<T> >::push( L, p );
+				pass_traits< converted_type_t<T> >::push( L, ::nv::forward<T>( p ) );
  			}
 
@@ -241,5 +253,5 @@
 			inline void pop_value( lua_State *L, T& p )
 			{
-				p = static_cast<T>( pass_traits< type_degrade_t<T> >::to( L, -1 ) );
+				p = static_cast<T>( pass_traits< converted_type_t<T> >::to( L, -1 ) );
 				detail::pop_and_discard(L, 1);
 			}
@@ -247,5 +259,5 @@
 			inline T pop_return_value( lua_State *L )
 			{
-				T ret = static_cast<T>( pass_traits< type_degrade_t<T> >::to( L, -1 ) );
+				T ret = static_cast<T>( pass_traits< converted_type_t<T> >::to( L, -1 ) );
 				detail::pop_and_discard(L, 1);
 				return ret;
@@ -260,11 +272,11 @@
 			inline void pop_value( lua_State *L, T& p, const T& def )
 			{
-				p = static_cast<T>( pass_traits< type_degrade_t<T> >::to( L, -1, def ) );
+				p = static_cast<T>( pass_traits< converted_type_t<T> >::to( L, -1, def ) );
 				detail::pop_and_discard(L, 1);
 			}
 			template < typename T >
-			inline T pop_return_value( lua_State *L, const T& def )
-			{
-				T ret = static_cast<T>( pass_traits< type_degrade_t<T> >::to( L, -1, def ) );
+			inline converted_type_t<T> pop_return_value( lua_State *L, const T& def )
+			{
+				T ret = static_cast<T>( pass_traits< converted_type_t<T> >::to( L, -1, def ) );
 				detail::pop_and_discard(L, 1);
 				return ret;
@@ -272,13 +284,13 @@
 
 			template < typename T >
-			inline type_degrade_t<T> get_value( lua_State *L, int index )
-			{
-				return pass_traits< type_degrade_t<T> >::to( L, index );
-			}
-
-			template < typename T >
-			inline T get_value( lua_State *L, int index, const T& def )
-			{
-				return pass_traits< type_degrade_t<T> >::to( L, index, def );
+			inline converted_type_t<T> get_value( lua_State *L, int index )
+			{
+				return pass_traits< converted_type_t<T> >::to( L, index );
+			}
+
+			template < typename T >
+			inline converted_type_t<T> get_value( lua_State *L, int index, const T& def )
+			{
+				return pass_traits< converted_type_t<T> >::to( L, index, def );
 			}
 
Index: /trunk/nv/stl/algorithm.hh
===================================================================
--- /trunk/nv/stl/algorithm.hh	(revision 444)
+++ /trunk/nv/stl/algorithm.hh	(revision 445)
@@ -156,5 +156,5 @@
 	inline void reverse( BidirectionalIterator first, BidirectionalIterator last )
 	{
-		for ( ; distance( first, --last ) > 0; ++first )
+		for ( ; ::nv::distance( first, --last ) > 0; ++first )
 			iter_swap( first, last );
 	}
Index: /trunk/nv/stl/memory.hh
===================================================================
--- /trunk/nv/stl/memory.hh	(revision 444)
+++ /trunk/nv/stl/memory.hh	(revision 445)
@@ -27,4 +27,8 @@
 namespace nv
 {
+
+	using constructor_t = void(*)( void* );
+	using destructor_t  = void(*)( void* );
+
 	
 	namespace mem_flags
Index: /trunk/nv/stl/string/string_base.hh
===================================================================
--- /trunk/nv/stl/string/string_base.hh	(revision 444)
+++ /trunk/nv/stl/string/string_base.hh	(revision 445)
@@ -123,5 +123,5 @@
 		// Non-literal constructors
 		template< typename U >
-		inline string_view( U str, typename enable_if<is_same<U, const char*>::value>::type* = nullptr ) : this_type( str, nvstrlen( str ) ) {}
+		inline string_view( U str, typename enable_if<is_same<U, const char*>::value>::type* = nullptr ) : this_type( str, str ? nvstrlen( str ) : 0 ) {}
 
 		// Non-literal constructors
Index: /trunk/src/lua/lua_path.cc
===================================================================
--- /trunk/src/lua/lua_path.cc	(revision 444)
+++ /trunk/src/lua/lua_path.cc	(revision 445)
@@ -78,15 +78,15 @@
 	string128 buffer;
 	bool dot = false;
-	for ( const element& e : m_elements )
+	for ( size_t c = 0; c < m_count; ++c )
 	{
 		if ( dot ) buffer.append( "." );
-		if ( e.length == 0 )
+		if ( m_elements[c].length == 0 )
 		{
-			buffer.append( "["_ls + e.value + "]"_ls );
+			buffer.append( "["_ls + m_elements[c].value + "]"_ls );
 			dot = false;
 		}
 		else
 		{
-			buffer.append( e.str, e.length );
+			buffer.append( m_elements[c].str, m_elements[c].length );
 			dot = true;
 		}
Index: /trunk/src/lua/lua_values.cc
===================================================================
--- /trunk/src/lua/lua_values.cc	(revision 444)
+++ /trunk/src/lua/lua_values.cc	(revision 445)
@@ -106,8 +106,8 @@
 }
 
-const char* nv::lua::detail::to_cstring ( lua_State *L, int index )
-{
-	return lua_tolstring( L, index, nullptr );
-}
+// const char* nv::lua::detail::to_cstring ( lua_State *L, int index )
+// {
+// 	return lua_tolstring( L, index, nullptr );
+// }
 
 nv::string_view nv::lua::detail::to_string_view( lua_State *L, int index )
@@ -164,8 +164,8 @@
 }
 
-const char* nv::lua::detail::to_cstring ( lua_State *L, int index, const char* def )
-{
-	return ( lua_type( L, index ) == LUA_TSTRING ? lua_tostring( L, index ) : def );
-}
+// const char* nv::lua::detail::to_cstring ( lua_State *L, int index, const char* def )
+// {
+// 	return ( lua_type( L, index ) == LUA_TSTRING ? lua_tostring( L, index ) : def );
+// }
 
 void*       nv::lua::detail::to_pointer ( lua_State *L, int index, void* def )
