Index: trunk/nv/flags.hh
===================================================================
--- trunk/nv/flags.hh	(revision 196)
+++ trunk/nv/flags.hh	(revision 197)
@@ -15,6 +15,6 @@
 
 #include <nv/common.hh>
+#include <nv/type_traits.hh>
 #include <bitset>
-#include <type_traits>
 
 namespace nv
@@ -29,5 +29,5 @@
 	struct base_underlying_type_helper< T, std::true_type >
 	{
-		typedef typename std::underlying_type<T>::type type;
+		typedef typename nv::underlying_type<T>::type type;
 	};
 
@@ -67,5 +67,5 @@
 
 		private:
-			reference() : m_flags( nullptr ), m_position( 0 ) {}
+			reference() : m_flags( nullptr ), m_index( 0 ) {}
 
 			reference( flags<SIZE,T>* a_flags, index_type a_index )
@@ -112,5 +112,5 @@
 		{
 			raw_index_type idx = static_cast< raw_index_type >( i ) / data_type_size;
-			raw_index_type pos = < raw_index_type >( i ) % data_type_size;
+			raw_index_type pos = static_cast< raw_index_type >( i ) % data_type_size;
 			m_data[ idx ] |= 1 << static_cast< data_type >( pos );
 		}
Index: trunk/nv/lib/fmod.hh
===================================================================
--- trunk/nv/lib/fmod.hh	(revision 196)
+++ trunk/nv/lib/fmod.hh	(revision 197)
Index: trunk/nv/lua/lua_state.hh
===================================================================
--- trunk/nv/lua/lua_state.hh	(revision 196)
+++ trunk/nv/lua/lua_state.hh	(revision 197)
@@ -43,125 +43,5 @@
 		};
 
-		class table_guard
-		{
-		public:
-			table_guard( state* lstate, const path& p, bool global = true );
-			table_guard( const table_guard& parent, const path& p );
-			size_t get_size();
-			bool has_field( const std::string& element );
-			std::string get_string( const std::string& element, const std::string& defval = "" );
-			char get_char( const std::string& element, char defval = ' ' );
-			int get_integer( const std::string& element, int defval = 0 );
-			unsigned get_unsigned( const std::string& element, unsigned defval = 0 );
-			double get_double( const std::string& element, double defval = 0.0 );
-			bool get_boolean( const std::string& element, bool defval = false );
-			bool is_defined( const path& p );
-
-			template< typename R, typename T >
-			R get( const T& key )
-			{
-				detail::push_value( L->L, key );
-				call_get();
-				return detail::pop_return_value( L->L )
-			}
-
-			template< typename R, typename T >
-			R raw_get( const T& key )
-			{
-				detail::push_value( L->L, key );
-				call_get_raw();
-				return detail::pop_return_value( L->L )
-			}
-
-			template< uint32 SIZE, typename T >
-			flags< SIZE, T > get_flags( const std::string& element )
-			{
-				flags< SIZE, T > result;
-				get_raw_flags( element, result.data(), result.size() );
-				return result;
-			}
-
-			template< uint32 SIZE, typename T >
-			void load_flags( const std::string& element, flags< SIZE, T >& flags )
-			{
-				get_raw_flags( element, flags.data(), flags.size() );
-			}
-
-			template < typename R >
-			R call( const path& p )
-			{
-				if ( L->push_function( p, false ) )
-				{
-					if ( call_function( 0, detail::return_count< R >::value ) == 0 )
-					{
-						return detail::pop_return_value<R>( L );
-					}
-				}
-				return R();
-			}
-			template < typename R, typename T1 >
-			R call( const path& p, const T1& p1 )
-			{
-				if ( L->push_function( p, false ) )
-				{
-					detail::push_value( L, p1 );
-					if ( L->call_function( 1, detail::return_count< R >::value ) == 0 )
-					{
-						return detail::pop_return_value<R>( L );
-					}
-				}
-				return R();
-			}
-			template < typename R, typename T1, typename T2 >
-			R call( const path& p, const T1& p1, const T2& p2 )
-			{
-				if ( L->push_function( p, false ) )
-				{
-					detail::push_values( L, p1, p2 );
-					if ( L->call_function( 2, detail::return_count< R >::value ) == 0 )
-					{
-						return detail::pop_return_value<R>( L );
-					}
-				}
-				return R();
-			}
-			template < typename R, typename T1, typename T2, typename T3 >
-			R call( const path& p, const T1& p1, const T2& p2, const T3& p3 )
-			{
-				if ( L->push_function( p, false ) )
-				{
-					detail::push_values( L, p1, p2, p3 );
-					if ( L->call_function( 3, detail::return_count< R >::value ) == 0 )
-					{
-						return detail::pop_return_value<R>( L );
-					}
-				}
-				return R();
-			}
-			template < typename R, typename T1, typename T2, typename T3, typename T4 >
-			R call( const path& p, const T1& p1, const T2& p2, const T3& p3, const T4& p4 )
-			{
-				if ( L->push_function( p, false ) )
-				{
-					detail::push_value( L, p1, p2, p3, p4 );
-					if ( L->call_function( 4, detail::return_count< R >::value ) == 0 )
-					{
-						return detail::pop_return_value<R>( L );
-					}
-				}
-				return R();
-			}
-
-		private:
-			bool push_function( const path& p );
-			int call_function( int nargs, int nresults );
-			void call_get();
-			void call_get_raw();
-			void get_raw_flags( const std::string& element, uint8* data, uint32 count );
-
-			state* L;
-			stack_guard m_guard;
-		};
-
+		class table_guard;
 		class state
 		{
@@ -264,4 +144,127 @@
 		};
 
+		class table_guard
+		{
+		public:
+			table_guard( state* lstate, const path& p, bool global = true );
+			table_guard( const table_guard& parent, const path& p );
+			size_t get_size();
+			bool has_field( const std::string& element );
+			std::string get_string( const std::string& element, const std::string& defval = "" );
+			char get_char( const std::string& element, char defval = ' ' );
+			int get_integer( const std::string& element, int defval = 0 );
+			unsigned get_unsigned( const std::string& element, unsigned defval = 0 );
+			double get_double( const std::string& element, double defval = 0.0 );
+			bool get_boolean( const std::string& element, bool defval = false );
+			bool is_defined( const path& p );
+
+			template< typename R, typename T >
+			R get( const T& key )
+			{
+				detail::push_value( L->L, key );
+				call_get();
+				return detail::pop_return_value<R>( L->L );
+			}
+
+			template< typename R, typename T >
+			R raw_get( const T& key )
+			{
+				detail::push_value( L->L, key );
+				call_get_raw();
+				return detail::pop_return_value<R>( L->L );
+			}
+
+			template< uint32 SIZE, typename T >
+			flags< SIZE, T > get_flags( const std::string& element )
+			{
+				flags< SIZE, T > result;
+				get_raw_flags( element, result.data(), result.size() );
+				return result;
+			}
+
+			template< uint32 SIZE, typename T >
+			void load_flags( const std::string& element, flags< SIZE, T >& flags )
+			{
+				get_raw_flags( element, flags.data(), flags.size() );
+			}
+
+			template < typename R >
+			R call( const path& p )
+			{
+				if ( L->push_function( p, false ) )
+				{
+					if ( call_function( 0, detail::return_count< R >::value ) == 0 )
+					{
+						return detail::pop_return_value<R>( L );
+					}
+				}
+				return R();
+			}
+			template < typename R, typename T1 >
+			R call( const path& p, const T1& p1 )
+			{
+				if ( L->push_function( p, false ) )
+				{
+					detail::push_value( L, p1 );
+					if ( L->call_function( 1, detail::return_count< R >::value ) == 0 )
+					{
+						return detail::pop_return_value<R>( L );
+					}
+				}
+				return R();
+			}
+			template < typename R, typename T1, typename T2 >
+			R call( const path& p, const T1& p1, const T2& p2 )
+			{
+				if ( L->push_function( p, false ) )
+				{
+					detail::push_values( L, p1, p2 );
+					if ( L->call_function( 2, detail::return_count< R >::value ) == 0 )
+					{
+						return detail::pop_return_value<R>( L );
+					}
+				}
+				return R();
+			}
+			template < typename R, typename T1, typename T2, typename T3 >
+			R call( const path& p, const T1& p1, const T2& p2, const T3& p3 )
+			{
+				if ( L->push_function( p, false ) )
+				{
+					detail::push_values( L, p1, p2, p3 );
+					if ( L->call_function( 3, detail::return_count< R >::value ) == 0 )
+					{
+						return detail::pop_return_value<R>( L );
+					}
+				}
+				return R();
+			}
+			template < typename R, typename T1, typename T2, typename T3, typename T4 >
+			R call( const path& p, const T1& p1, const T2& p2, const T3& p3, const T4& p4 )
+			{
+				if ( L->push_function( p, false ) )
+				{
+					detail::push_value( L, p1, p2, p3, p4 );
+					if ( L->call_function( 4, detail::return_count< R >::value ) == 0 )
+					{
+						return detail::pop_return_value<R>( L );
+					}
+				}
+				return R();
+			}
+
+		private:
+			bool push_function( const path& p );
+			int call_function( int nargs, int nresults );
+			void call_get();
+			void call_get_raw();
+			void get_raw_flags( const std::string& element, uint8* data, uint32 count );
+
+			state* L;
+			stack_guard m_guard;
+		};
+
+
+
 	} // namespace lua
 
Index: trunk/nv/lua/lua_values.hh
===================================================================
--- trunk/nv/lua/lua_values.hh	(revision 196)
+++ trunk/nv/lua/lua_values.hh	(revision 197)
@@ -21,4 +21,5 @@
 		{
 			virtual void push( lua_State *L ) const = 0;
+			virtual ~passer(){}
 		};
 
@@ -26,4 +27,5 @@
 		{
 			virtual void pop( lua_State *L ) = 0;
+			virtual ~returner_base(){}
 		};
 
Index: trunk/nv/string.hh
===================================================================
--- trunk/nv/string.hh	(revision 196)
+++ trunk/nv/string.hh	(revision 197)
@@ -132,20 +132,20 @@
 	struct string_length
 	{
-		static const size_t get( T ) { return 0; }
+		static size_t get( T ) { return 0; }
 	};
 	template< size_t S >
 	struct string_length< const char[S] >
 	{
-		static const size_t get( const char* ) { return S-1; }
+		static size_t get( const char* ) { return S-1; }
 	};
 	template<>
 	struct string_length< const char* >
 	{
-		static const size_t get( const char* s ) { return std::strlen( s ); }
+		static size_t get( const char* s ) { return std::strlen( s ); }
 	};
 	template<>
 	struct string_length< std::string >
 	{
-		static const size_t get( const std::string& s ) { return s.length(); }
+		static size_t get( const std::string& s ) { return s.length(); }
 	};
 
Index: trunk/nv/type_traits.hh
===================================================================
--- trunk/nv/type_traits.hh	(revision 196)
+++ trunk/nv/type_traits.hh	(revision 197)
@@ -18,4 +18,7 @@
 namespace nv
 {
+
+	// Just for once, MSVC is the good guy, and everybody else sucks.
+	// Remove, once requiring standard-compliant CLANG/GCC versions.
 #if NV_COMPILER == NV_MSVC
 	using std::underlying_type;
Index: trunk/src/formats/md5_loader.cc
===================================================================
--- trunk/src/formats/md5_loader.cc	(revision 196)
+++ trunk/src/formats/md5_loader.cc	(revision 197)
@@ -276,5 +276,5 @@
 	auto normal   = m->add_attribute< vec3 >( "nv_normal" );
 	auto texcoord = m->add_attribute< vec2 >( "nv_texcoord" );
-	auto tangent  = m->add_attribute< vec2 >( "nv_tangent" );
+	auto tangent  = m->add_attribute< vec3 >( "nv_tangent" );
 	auto indices  = m->add_indices< uint32 >();
 
