Index: trunk/src/curses/curses_terminal.cc
===================================================================
--- trunk/src/curses/curses_terminal.cc	(revision 372)
+++ trunk/src/curses/curses_terminal.cc	(revision 374)
@@ -65,5 +65,5 @@
 	}
 	mvaddch( p.y-1, p.x-1, ch );
-	move( m_cursor.y-1, m_cursor.x-1 );
+	::move( m_cursor.y-1, m_cursor.x-1 );
 }
 
@@ -80,5 +80,5 @@
 	m_update_needed = true;
 	::clear();
-	move( m_cursor.y-1, m_cursor.x-1 );
+	::move( m_cursor.y-1, m_cursor.x-1 );
 }
 
@@ -160,5 +160,5 @@
 {
 	terminal::set_cursor( p );
-	move( m_cursor.y-1, m_cursor.x-1 );
+	::move( m_cursor.y-1, m_cursor.x-1 );
 }
 
Index: trunk/src/engine/particle_engine.cc
===================================================================
--- trunk/src/engine/particle_engine.cc	(revision 372)
+++ trunk/src/engine/particle_engine.cc	(revision 374)
@@ -7,7 +7,7 @@
 #include <nv/interface/device.hh>
 #include <nv/core/random.hh>
+#include <nv/stl/utility.hh>
 #include <nv/lua/lua_glm.hh>
 #include <nv/core/logging.hh>
-#include <cmath>
 
 static const char *nv_particle_engine_vertex_shader_world =
@@ -203,5 +203,5 @@
 	if ( datap->average )
 	{
-		float norm_factor = glm::min( factor, 1.0f );
+		float norm_factor = nv::min( factor, 1.0f );
 		for ( uint32 i = 0; i < count; ++i ) 
 			p[i].velocity = datap->force_vector * norm_factor + p[i].velocity * ( 1.0f - norm_factor );
@@ -696,5 +696,5 @@
 			{
 				info->count--;
-				std::swap( info->particles[i], info->particles[info->count] );
+				swap( info->particles[i], info->particles[info->count] );
 			}
 		}
Index: trunk/src/formats/md2_loader.cc
===================================================================
--- trunk/src/formats/md2_loader.cc	(revision 372)
+++ trunk/src/formats/md2_loader.cc	(revision 374)
@@ -238,5 +238,5 @@
 }
 
-size_t md2_loader::get_max_frames() const
+nv::size_t md2_loader::get_max_frames() const
 {
 	return static_cast< size_t >( ((md2_t*)m_md2)->header.num_frames );
Index: trunk/src/formats/md3_loader.cc
===================================================================
--- trunk/src/formats/md3_loader.cc	(revision 372)
+++ trunk/src/formats/md3_loader.cc	(revision 374)
@@ -172,5 +172,5 @@
 	source.read( surface->vertices, sizeof( md3_vertex_t ), static_cast<size_t>( surface->header.num_verts * surface->header.num_frames ) );
 
-	if ( source.tell() != static_cast<std::size_t>( pos + surface->header.ofs_end ) ) return false;
+	if ( source.tell() != static_cast<size_t>( pos + surface->header.ofs_end ) ) return false;
 
 	return true;
Index: trunk/src/formats/md5_loader.cc
===================================================================
--- trunk/src/formats/md5_loader.cc	(revision 372)
+++ trunk/src/formats/md5_loader.cc	(revision 374)
@@ -344,5 +344,6 @@
 		vtc.tangent  = glm::vec3(0);
 
-		std::sort( weights + start_weight, weights + start_weight + weight_count, [](const md5_weight& a, const md5_weight& b) -> bool { return a.bias > b.bias; } );
+		stable_sort( weights + start_weight, weights + start_weight + weight_count, [] ( const md5_weight& a, const md5_weight& b ) -> bool { return a.bias > b.bias; } );
+		//std::sort( weights + start_weight, weights + start_weight + weight_count, [](const md5_weight& a, const md5_weight& b) -> bool { return a.bias > b.bias; } );
 
 		if ( weight_count > 4 )
Index: trunk/src/formats/obj_loader.cc
===================================================================
--- trunk/src/formats/obj_loader.cc	(revision 372)
+++ trunk/src/formats/obj_loader.cc	(revision 374)
@@ -53,6 +53,6 @@
 	std::string next_name;
 
-	std::size_t size;
-	bool        eof;
+	size_t size;
+	bool   eof;
 
 	obj_reader();
@@ -172,5 +172,5 @@
 {
 	mesh_data_reader( bool normals ) : m_normals( normals ) {}
-	virtual std::size_t add_face( uint32* vi, uint32* ti, uint32* ni, size_t count )
+	virtual size_t add_face( uint32* vi, uint32* ti, uint32* ni, size_t count )
 	{
 		if ( count < 3 ) return 0; // TODO : report error?
@@ -178,5 +178,5 @@
 		// TODO : support if normals not present;
 		vec3 nullvec;
-		std::size_t result = 0;
+		size_t result = 0;
 		// Simple triangulation - obj's shouldn't have more than quads anyway
 
@@ -278,5 +278,5 @@
 		}
 
-		for (std::size_t a = 0; a < count; ++a )
+		for (size_t a = 0; a < count; ++a )
 		{
 			const vec3& n = m_data[a].normal;
Index: trunk/src/gfx/image.cc
===================================================================
--- trunk/src/gfx/image.cc	(revision 372)
+++ trunk/src/gfx/image.cc	(revision 374)
@@ -4,6 +4,4 @@
 
 #include "nv/gfx/image.hh"
-
-#include <algorithm>
 
 using namespace nv;
Index: trunk/src/io/c_stream.cc
===================================================================
--- trunk/src/io/c_stream.cc	(revision 372)
+++ trunk/src/io/c_stream.cc	(revision 374)
@@ -6,5 +6,4 @@
 #include <sys/stat.h> 
 #include "nv/io/c_stream.hh"
-#include <limits>
 
 using namespace nv;
Index: trunk/src/io/std_stream.cc
===================================================================
--- trunk/src/io/std_stream.cc	(revision 372)
+++ trunk/src/io/std_stream.cc	(revision 374)
@@ -8,5 +8,6 @@
 
 #include "nv/io/std_stream.hh"
-#include <algorithm>
+#include "nv/stl/math.hh"
+#include "nv/stl/utility.hh"
 
 using namespace nv;
@@ -15,6 +16,6 @@
 	: m_stream( source )
 	, m_owner( owner )
-	, m_buffer( std::max(bsize, put_back) + put_back )
-	, m_put_back( std::max( put_back, std::size_t( 1 ) ) )
+	, m_buffer( nv::max(bsize, put_back) + put_back )
+	, m_put_back( nv::max( put_back, std::size_t( 1 ) ) )
 {
 	char *end = &m_buffer.front() + m_buffer.size();
Index: trunk/src/lib/curses.cc
===================================================================
--- trunk/src/lib/curses.cc	(revision 372)
+++ trunk/src/lib/curses.cc	(revision 374)
@@ -11,4 +11,5 @@
 #include "nv/core/library.hh"
 
+#define FILE void
 #define NV_CURSES_FUN( rtype, fname, fparams ) rtype (*fname) fparams = nullptr;
 #include <nv/lib/detail/curses_functions.inc>
@@ -21,5 +22,5 @@
 	curses_library.open( path );
 
-#	define NV_CURSES_FUN( rtype, fname, fparams ) *(void **) (&fname) = curses_library.get(#fname);
+#	define NV_CURSES_FUN( rtype, fname, fparams ) *(void **) (&::fname) = curses_library.get(#fname);
 #	include <nv/lib/detail/curses_functions.inc>
 #	undef NV_CURSES_FUN
Index: trunk/src/lua/lua_area.cc
===================================================================
--- trunk/src/lua/lua_area.cc	(revision 372)
+++ trunk/src/lua/lua_area.cc	(revision 374)
@@ -79,5 +79,5 @@
 {
 	nv::rectangle* a = to_parea( L, 1 );
-	std::size_t l;
+	nv::size_t l;
 	const char* index = lua_tolstring( L, 2, &l );
 	if ( l == 1 && index[0] == 'a' )
@@ -101,5 +101,5 @@
 {
 	nv::rectangle* a = to_parea( L, 1 );
-	std::size_t l;
+	nv::size_t l;
 	const char* index = lua_tolstring( L, 2, &l );
 	nv::ivec2 value( to_coord( L, 3 ) );
Index: trunk/src/lua/lua_map_tile.cc
===================================================================
--- trunk/src/lua/lua_map_tile.cc	(revision 372)
+++ trunk/src/lua/lua_map_tile.cc	(revision 374)
@@ -7,7 +7,8 @@
 #include "nv/lua/lua_map_tile.hh"
 
-#include <numeric>
 #include "nv/lua/lua_map_area.hh"
 #include "nv/stl/flags.hh"
+#include "nv/stl/numeric.hh"
+#include "nv/stl/algorithm.hh"
 #include "nv/core/random.hh"
 #include "nv/lua/lua_area.hh"
@@ -59,5 +60,5 @@
 	map_tile tile;
 
-	tile.size_y = (nv::uint16)( std::count( code.begin(), code.end(), '\n' ) + 1 );
+	tile.size_y = (nv::uint16)( nv::count( code.begin(), code.end(), '\n' ) + 1 );
 	tile.size_x = (nv::uint16)( code.find( '\n' ) );
 	if ( tile.size_x == 0 )
@@ -236,6 +237,6 @@
 	nv::uint16 org_x = tile->size_x;
 	nv::uint16 org_y = tile->size_y;
-	nv::uint16 new_x = (nv::uint16)std::accumulate( sizes_x.begin(), sizes_x.end(), 0 );
-	nv::uint16 new_y = (nv::uint16)std::accumulate( sizes_y.begin(), sizes_y.end(), 0 );
+	nv::uint16 new_x = ( nv::uint16 )nv::accumulate( sizes_x.begin(), sizes_x.end(), 0 );
+	nv::uint16 new_y = ( nv::uint16 )nv::accumulate( sizes_y.begin(), sizes_y.end(), 0 );
 
 	nv::uint8* data = new nv::uint8[ new_x * new_y ];
Index: trunk/src/stl/string.cc
===================================================================
--- trunk/src/stl/string.cc	(revision 372)
+++ trunk/src/stl/string.cc	(revision 374)
@@ -28,5 +28,5 @@
 }
 
-size_t nv::sint32_to_buffer( sint32 n, char* str )
+nv::size_t nv::sint32_to_buffer( sint32 n, char* str )
 {
 	char* s = str;
@@ -43,5 +43,5 @@
 }
 
-size_t nv::sint64_to_buffer( sint64 n, char* str )
+nv::size_t nv::sint64_to_buffer( sint64 n, char* str )
 {
 	char* s = str;
@@ -58,5 +58,5 @@
 }
 
-size_t nv::uint32_to_buffer( uint32 n, char* str )
+nv::size_t nv::uint32_to_buffer( uint32 n, char* str )
 {
 	char* s = str;
@@ -71,5 +71,5 @@
 }
 
-size_t nv::uint64_to_buffer( uint64 n, char* str )
+nv::size_t nv::uint64_to_buffer( uint64 n, char* str )
 {
 	char* s = str;
@@ -84,5 +84,5 @@
 }
 
-size_t nv::f32_to_buffer( f32 n, char* str )
+nv::size_t nv::f32_to_buffer( f32 n, char* str )
 {
 #if NV_COMPILER == NV_MSVC
@@ -95,5 +95,5 @@
 }
 
-size_t nv::f64_to_buffer( f64 n, char* str )
+nv::size_t nv::f64_to_buffer( f64 n, char* str )
 {
 #if NV_COMPILER == NV_MSVC
