Index: trunk/nv/core/array2d.hh
===================================================================
--- trunk/nv/core/array2d.hh	(revision 366)
+++ trunk/nv/core/array2d.hh	(revision 367)
@@ -320,5 +320,5 @@
 			if ( dest_start_x + min(size_x, source.m_size.x - source_start_x) > m_size.x || dest_start_y + min(size_y, source.m_size.y - source_start_y) > m_size.y )
 			{
-				NV_LOG_WARNING( "set_sub_array: Source area does not fit in the destination area.  Data will be truncated." );
+				//NV_LOG_WARNING( "set_sub_array: Source area does not fit in the destination area.  Data will be truncated." );
 			}
 		
Index: trunk/nv/core/math.hh
===================================================================
--- trunk/nv/core/math.hh	(revision 366)
+++ trunk/nv/core/math.hh	(revision 367)
@@ -18,6 +18,9 @@
 #include <glm/glm.hpp>
 #include <glm/gtc/matrix_transform.hpp>
+#include <glm/gtc/matrix_access.hpp>
 #include <glm/gtc/type_ptr.hpp>
 #include <glm/gtc/quaternion.hpp>
+#include <glm/gtx/rotate_vector.hpp>
+#include <glm/gtx/vector_angle.hpp>
 
 namespace nv
Index: trunk/nv/core/string.hh
===================================================================
--- trunk/nv/core/string.hh	(revision 366)
+++ trunk/nv/core/string.hh	(revision 367)
@@ -281,7 +281,15 @@
 	}
 
+#if NV_COMPILER == NV_GNUC
+	template< typename T >
+	struct string_length : public detail::string_length_impl <
+		typename std::remove_cv < typename std::remove_reference< T >::type >::type >
+	{
+	};
+#else
 	template< typename T >
 	using string_length = detail::string_length_impl <
 		typename std::remove_cv < typename std::remove_reference< T >::type >::type >;
+#endif
 
 	class string_ref;
@@ -473,10 +481,10 @@
 
 		// Non-literal constructors
-		template< typename U, typename std::enable_if<std::is_same<U, const char*>::value>::type* = nullptr >
-		inline string_ref( U str ) : string_base( str, std::strlen( str ) ) {}
+		template< typename U >
+		inline string_ref( U str, typename std::enable_if<std::is_same<U, const char*>::value>::type* = nullptr ) : string_base( str, std::strlen( str ) ) {}
 
 		// Non-literal constructors
-		template< typename U, typename std::enable_if<std::is_same<U, char*>::value>::type* = nullptr >
-		inline string_ref( U str ) : string_base( str, std::strlen( str ) ) {}
+		template< typename U >
+		inline string_ref( U str, typename std::enable_if<std::is_same<U, char*>::value>::type* = nullptr ) : string_base( str, std::strlen( str ) ) {}
 
 		inline string_ref& operator=( const string_ref &rhs )
Index: trunk/nv/gfx/animation.hh
===================================================================
--- trunk/nv/gfx/animation.hh	(revision 366)
+++ trunk/nv/gfx/animation.hh	(revision 367)
@@ -16,5 +16,4 @@
 #include <nv/interface/interpolation_template.hh>
 #include <nv/core/transform.hh>
-#include <glm/gtc/matrix_transform.hpp>
 
 namespace nv
Index: trunk/nv/lua/lua_raw.hh
===================================================================
--- trunk/nv/lua/lua_raw.hh	(revision 366)
+++ trunk/nv/lua/lua_raw.hh	(revision 367)
@@ -8,9 +8,6 @@
 
 #include <nv/core/common.hh>
+#include <nv/core/array.hh>
 #include <nv/lib/lua.hh>
-#include <istream>
-#include <string>
-#include <vector>
-#include <map>
 
 void nlua_toflags_set( lua_State *L, int index, nv::uint8* data, nv::uint32 count );
Index: trunk/nv/lua/lua_state.hh
===================================================================
--- trunk/nv/lua/lua_state.hh	(revision 366)
+++ trunk/nv/lua/lua_state.hh	(revision 367)
@@ -15,6 +15,4 @@
 #include <nv/core/flags.hh>
 #include <nv/core/handle.hh>
-#include <istream>
-#include <map>
 
 #include <nv/lua/lua_handle.hh>
@@ -193,5 +191,4 @@
 			explicit state( lua_State* state );
 			bool do_string( string_ref code, string_ref name, int rvalues = 0 );
-			bool do_stream( std::istream& stream, string_ref name );
 			bool do_file( string_ref filename );
 			int get_stack_size();
@@ -282,5 +279,4 @@
 
 			int load_string( string_ref code, string_ref name );
-			int load_stream( std::istream& stream, string_ref name );
 			int load_file( string_ref filename );
 			int do_current( string_ref name, int rvalues = 0 );
Index: trunk/src/core/string.cc
===================================================================
--- trunk/src/core/string.cc	(revision 366)
+++ trunk/src/core/string.cc	(revision 367)
@@ -66,5 +66,4 @@
 		n /= 10;
 	} while ( n > 0 );
-	if ( n < 0 ) *s++ = '-';
 	*s = '\0';
 	string_reverse( str, s - 1 );
@@ -80,5 +79,4 @@
 		n /= 10;
 	} while ( n > 0 );
-	if ( n < 0 ) *s++ = '-';
 	*s = '\0';
 	string_reverse( str, s - 1 );
@@ -91,5 +89,5 @@
 	sprintf_s( str, 64, "%.*g", 6, n );
 #else
-	snprintf( buffer, 64, "%.*g", 6, n );
+	snprintf( str, 64, "%.*g", 6, n );
 #endif
 	sprintf( str, "%g", n );
@@ -102,5 +100,5 @@
 	sprintf_s( str, 64, "%.*g", 6, n );
 #else
-	snprintf( buffer, 64, "%.*g", 6, n );
+	snprintf( str, 64, "%.*g", 6, n );
 #endif
 	return strlen( str );
Index: trunk/src/formats/assimp_loader.cc
===================================================================
--- trunk/src/formats/assimp_loader.cc	(revision 366)
+++ trunk/src/formats/assimp_loader.cc	(revision 367)
@@ -7,5 +7,4 @@
 #include "nv/formats/assimp_loader.hh"
 #include <unordered_map>
-#include <glm/gtx/transform.hpp>
 #include "nv/io/std_stream.hh"
 #include "nv/gfx/mesh_creator.hh"
Index: trunk/src/formats/md2_loader.cc
===================================================================
--- trunk/src/formats/md2_loader.cc	(revision 366)
+++ trunk/src/formats/md2_loader.cc	(revision 367)
@@ -7,5 +7,4 @@
 #include "nv/formats/md2_loader.hh"
 
-#include <glm/gtc/constants.hpp>
 #include "nv/core/logging.hh"
 #include <cstring>
Index: trunk/src/formats/md3_loader.cc
===================================================================
--- trunk/src/formats/md3_loader.cc	(revision 366)
+++ trunk/src/formats/md3_loader.cc	(revision 367)
@@ -7,5 +7,4 @@
 #include "nv/formats/md3_loader.hh"
 
-#include <glm/gtc/constants.hpp>
 #include "nv/core/logging.hh"
 #include <cstring>
Index: trunk/src/formats/md5_loader.cc
===================================================================
--- trunk/src/formats/md5_loader.cc	(revision 366)
+++ trunk/src/formats/md5_loader.cc	(revision 367)
@@ -5,8 +5,6 @@
 #include "nv/formats/md5_loader.hh"
 
-#include <glm/gtc/constants.hpp>
 #include "nv/core/logging.hh"
 #include "nv/io/std_stream.hh"
-#include <cstring>
 
 using namespace nv;
@@ -14,10 +12,9 @@
 static void next_line( std::istream& stream )
 {
-	stream.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
+	stream.ignore( 1024*1024, '\n' );
 }
 
 static inline void discard( std::istream& stream, const std::string& token )
 {
-//	stream.ignore( std::numeric_limits<std::streamsize>::max(), ' ' );
 	std::string discarded;
 	stream >> discarded;
Index: trunk/src/gfx/keyframed_mesh.cc
===================================================================
--- trunk/src/gfx/keyframed_mesh.cc	(revision 366)
+++ trunk/src/gfx/keyframed_mesh.cc	(revision 367)
@@ -5,10 +5,6 @@
 #include "nv/gfx/keyframed_mesh.hh"
 
-#include <glm/gtc/matrix_access.hpp>
-#include <glm/gtx/matrix_interpolation.hpp>
 #include "nv/interface/context.hh"
 #include "nv/interface/device.hh"
-
-
 #include "nv/core/logging.hh"
 
Index: trunk/src/gfx/skeletal_mesh.cc
===================================================================
--- trunk/src/gfx/skeletal_mesh.cc	(revision 366)
+++ trunk/src/gfx/skeletal_mesh.cc	(revision 367)
@@ -5,9 +5,6 @@
 #include "nv/gfx/skeletal_mesh.hh"
 
-#include <glm/gtc/matrix_access.hpp>
-#include <glm/gtx/matrix_interpolation.hpp>
 #include "nv/interface/context.hh"
 #include "nv/interface/device.hh"
-
 
 nv::skeletal_mesh_cpu::skeletal_mesh_cpu( context* a_context, const mesh_data* a_mesh_data, const mesh_nodes_data* bones )
Index: trunk/src/gfx/texture_atlas.cc
===================================================================
--- trunk/src/gfx/texture_atlas.cc	(revision 366)
+++ trunk/src/gfx/texture_atlas.cc	(revision 367)
@@ -8,5 +8,4 @@
 
 #include "nv/core/logging.hh"
-#include <iostream>
 
 using namespace nv;
Index: trunk/src/gfx/texture_font.cc
===================================================================
--- trunk/src/gfx/texture_font.cc	(revision 366)
+++ trunk/src/gfx/texture_font.cc	(revision 367)
@@ -6,6 +6,4 @@
 #include "nv/gfx/texture_font.hh"
 
-#include <sstream>
-#include <stdexcept>
 #include "nv/lib/freetype2.hh"
 #include "nv/core/logging.hh"
@@ -126,8 +124,6 @@
 		if ( error )
 		{
-			std::stringstream error_msg;
-			error_msg << "FT_Error while loading glyphs, error: "
-				<< error << " code: " << c; 
-			NV_THROW( std::runtime_error, error_msg.str().c_str() );
+			NV_LOG_ERROR( "FT_Error while loading glyphs, error: ", error, " code: ", c );
+			NV_THROW( std::runtime_error, "FT_Error while loading glyphs" );
 		}
 
@@ -144,9 +140,6 @@
 		if ( r.pos.x < 0 ) 
 		{
-			std::stringstream error_msg;
-			error_msg << "Atlas full while loading glyphs, "
-				<< "r.pos.x: " << r.pos.x << " code: "
-				<< c; 
-			NV_THROW( std::runtime_error, error_msg.str().c_str() );
+			NV_LOG_ERROR( "Atlas full while loading glyphs, r.pos.x: ", r.pos.x, " code: ", c );
+			NV_THROW( std::runtime_error, "Atlas full while loading glyphs" );
 		}
 		if (depth == 4)
Index: trunk/src/gui/gui_gfx_renderer.cc
===================================================================
--- trunk/src/gui/gui_gfx_renderer.cc	(revision 366)
+++ trunk/src/gui/gui_gfx_renderer.cc	(revision 367)
@@ -6,6 +6,4 @@
 
 #include "nv/gui/gui_gfx_renderer.hh"
-
-#include <glm/gtc/matrix_transform.hpp>
 
 #include "nv/interface/device.hh"
Index: trunk/src/lua/lua_aux.cc
===================================================================
--- trunk/src/lua/lua_aux.cc	(revision 366)
+++ trunk/src/lua/lua_aux.cc	(revision 367)
@@ -7,5 +7,4 @@
 #include "nv/lua/lua_aux.hh"
 
-#include <utility>
 #include "nv/lua/lua_raw.hh"
 #include "nv/core/random.hh"
@@ -117,6 +116,6 @@
 			int arg1 = static_cast< int >( luaL_checkinteger( L, 1 ) );
 			int arg2 = static_cast< int >( luaL_checkinteger( L, 2 ) );
-			if (arg2 < arg1) std::swap( arg2, arg1 );
-			lua_pushinteger( L, nv::random::get().srange( arg1, arg2 ) );
+			int result = ( arg2 >= arg1 ? nv::random::get().srange( arg1, arg2 ) : nv::random::get().srange( arg2, arg1 ) );
+			lua_pushinteger( L, result );
 		}
 	}
Index: trunk/src/lua/lua_state.cc
===================================================================
--- trunk/src/lua/lua_state.cc	(revision 366)
+++ trunk/src/lua/lua_state.cc	(revision 367)
@@ -356,12 +356,4 @@
 }
 
-int lua::state::load_stream( std::istream& stream, string_ref name )
-{
-	NV_LOG_NOTICE( "Loading Lua stream '", name, "'");
-	return load_string( std::string(
-		(std::istreambuf_iterator<char>(stream)),
-		std::istreambuf_iterator<char>()), name );
-}
-
 int lua::state::load_file( string_ref filename )
 {
@@ -380,16 +372,4 @@
 	}
 	return do_current( name, rvalues ) == 0;
-}
-
-bool lua::state::do_stream( std::istream& stream, string_ref name )
-{
-	lua::stack_guard( this );
-	int result = load_stream(stream,name);
-	if (result)
-	{
-		NV_LOG_WARNING( "Failed to open stream ", name, ": ", lua_tostring( m_state, -1 ) );
-		return false;
-	}
-	return do_current( name ) == 0;
 }
 
Index: trunk/src/sdl/sdl_audio.cc
===================================================================
--- trunk/src/sdl/sdl_audio.cc	(revision 366)
+++ trunk/src/sdl/sdl_audio.cc	(revision 367)
@@ -7,6 +7,5 @@
 #include "nv/sdl/sdl_audio.hh"
 
-#include <glm/gtx/vector_angle.hpp>
-#include "nv/lib/sdl.hh"
+#include "nv/core/math.hh"
 #include "nv/lib/sdl_mixer.hh"
 #include "nv/core/logging.hh"
Index: trunk/src/sdl/sdl_window.cc
===================================================================
--- trunk/src/sdl/sdl_window.cc	(revision 366)
+++ trunk/src/sdl/sdl_window.cc	(revision 367)
@@ -9,4 +9,5 @@
 #include "nv/lib/sdl.hh"
 #include "nv/sdl/sdl_input.hh"
+#include "nv/gl/gl_context.hh"
 
 using namespace nv;
