Index: /trunk/nv/core/random.hh
===================================================================
--- /trunk/nv/core/random.hh	(revision 437)
+++ /trunk/nv/core/random.hh	(revision 438)
@@ -18,5 +18,5 @@
 	{
 	public:
-		typedef unsigned int result_type; // std::mt19937::result_type
+		typedef unsigned int result_type; // mt19937::result_type
 		typedef unsigned int seed_type;
 
@@ -174,5 +174,5 @@
 		}
 	private:
-		// temporary solution until we get rid of std::random
+		// temporary solution until we get rid of ::random
 		char m_data[16 * 1024];
 	};
Index: /trunk/nv/core/time.hh
===================================================================
--- /trunk/nv/core/time.hh	(revision 437)
+++ /trunk/nv/core/time.hh	(revision 438)
@@ -34,10 +34,10 @@
 
 	/**
-	 * Get millisecond count based on std::clock
+	 * Get millisecond count based on ::clock
 	 */
 	uint32 get_cpu_ms();
 
 	/**
-	 * Get microsecond count based on std::clock
+	 * Get microsecond count based on ::clock
 	 */
 	uint64 get_cpu_us();
Index: /trunk/nv/core/types.hh
===================================================================
--- /trunk/nv/core/types.hh	(revision 437)
+++ /trunk/nv/core/types.hh	(revision 438)
@@ -33,9 +33,9 @@
 	};
 
-	template<>
-	struct is_container < std::string >
-	{
-		static const bool value = false;
-	};
+// 	template<>
+// 	struct is_container < string_view >
+// 	{
+// 		static const bool value = false;
+// 	};
 
 	struct type_entry;
Index: /trunk/nv/engine/program_manager.hh
===================================================================
--- /trunk/nv/engine/program_manager.hh	(revision 437)
+++ /trunk/nv/engine/program_manager.hh	(revision 438)
@@ -28,10 +28,9 @@
 	protected:
 		virtual resource_id load_resource( lua::table_guard& table );
-		void load_source( lua::table_guard& table, std::string& out, const std::string& append );
+		string_buffer load_source( lua::table_guard& table, const string_view& append );
 		virtual void release( program p );
 	private:
 		context* m_context;
-		std::string   m_vertex_head;
-		std::string   m_fragment_head;
+		const_string m_shader_head;
 	};
 
Index: /trunk/nv/gfx/texture_font.hh
===================================================================
--- /trunk/nv/gfx/texture_font.hh	(revision 437)
+++ /trunk/nv/gfx/texture_font.hh	(revision 438)
@@ -43,5 +43,5 @@
 	{
 		public:
-			texture_font( texture_atlas* atlas, const char * filename, float size );
+			texture_font( texture_atlas* atlas, const string_view& filename, float size );
 			const texture_glyph* get_glyph( uint16 charcode ) const;
 			bool load_glyphs( string_view codes );
@@ -54,5 +54,5 @@
 
 			texture_atlas* m_atlas; //!< Atlas Image object for this font.
-			std::string m_filename; //!< Name of the file.
+			string128 m_filename;//!< Filename
 			float m_size;           //!< Font size.
 			float m_height;         //!< Height of the font. (x-height?)
Index: /trunk/nv/gl/gl_device.hh
===================================================================
--- /trunk/nv/gl/gl_device.hh	(revision 437)
+++ /trunk/nv/gl/gl_device.hh	(revision 438)
@@ -56,10 +56,9 @@
 		virtual int get_attribute_location( program p, const std::string& name, bool fatal = true ) const;
 		virtual void prepare_program( program p );
-		virtual const std::string& get_shader_header() const { return m_shader_header; }
+		virtual string_view get_shader_header() const { return m_shader_header; }
 		virtual ~gl_device();
 	protected:
 		uniform_base* get_uniform( program p, const std::string& name, bool fatal = true ) const;
 
-	
 	private:
 		bool compile( gl_program_info* p, string_view vertex_program, string_view fragment_program );
@@ -68,5 +67,5 @@
 		void load_attributes( gl_program_info* p );
 		void load_uniforms( gl_program_info* p );
-		std::string m_shader_header;
+		string_buffer m_shader_header;
 		handle_store< gl_texture_info, texture >         m_textures;
 		handle_store< gl_buffer_info,  buffer >          m_buffers;
Index: /trunk/nv/gl/gl_enum.hh
===================================================================
--- /trunk/nv/gl/gl_enum.hh	(revision 437)
+++ /trunk/nv/gl/gl_enum.hh	(revision 438)
@@ -45,5 +45,5 @@
 	unsigned int datatype_to_gl_enum( datatype type );
 	datatype gl_enum_to_datatype( unsigned int gl_enum );
-	std::string datatype_to_glsl_type( datatype type );
+	string_view datatype_to_glsl_type( datatype type );
 
 } // namespace nv
Index: /trunk/nv/interface/device.hh
===================================================================
--- /trunk/nv/interface/device.hh	(revision 437)
+++ /trunk/nv/interface/device.hh	(revision 438)
@@ -182,5 +182,5 @@
 		virtual const texture_info* get_texture_info( texture ) const = 0;
 		virtual const buffer_info* get_buffer_info( buffer ) const = 0;
-		virtual const std::string& get_shader_header() const = 0;
+		virtual string_view get_shader_header() const = 0;
 
 		virtual texture create_texture( image_data* data, sampler asampler ) 
Index: /trunk/nv/io/c_file_system.hh
===================================================================
--- /trunk/nv/io/c_file_system.hh	(revision 437)
+++ /trunk/nv/io/c_file_system.hh	(revision 438)
@@ -25,6 +25,7 @@
 		c_file_system();
 		virtual ~c_file_system();
-		virtual bool exists( const char* fpath );
-		virtual stream* open( const char* fpath, const char* fmode = "rb" );
+		virtual const_string slurp( const string_view& path );
+		virtual bool exists( const string_view& );
+		virtual stream* open( const string_view&, const string_view& = "rb" );
 	};
 
Index: /trunk/nv/io/c_stream.hh
===================================================================
--- /trunk/nv/io/c_stream.hh	(revision 437)
+++ /trunk/nv/io/c_stream.hh	(revision 438)
@@ -26,4 +26,5 @@
 	protected:
 		c_stream();
+		// TODO: const char* is prone to deletion - don't store it, or store differently!
 		c_stream( void* pfile, const char* filename );
 	public:
Index: /trunk/nv/lua/lua_values.hh
===================================================================
--- /trunk/nv/lua/lua_values.hh	(revision 437)
+++ /trunk/nv/lua/lua_values.hh	(revision 438)
@@ -167,4 +167,12 @@
 
 		template <>
+		struct pass_traits < const_string >
+		{
+			static void push( lua_State *L, const const_string& s ) { detail::push_string_view( L, s ); }
+			static const_string to( lua_State *L, int index ) { return const_string( detail::to_string_view( L, index ) ); }
+			static const_string to( lua_State *L, int index, const_string def ) { return const_string( detail::to_string_view( L, index, def ) ); }
+		};
+
+		template <>
 		struct pass_traits<ref>
 		{
Index: /trunk/nv/stl/container/contiguous_storage.hh
===================================================================
--- /trunk/nv/stl/container/contiguous_storage.hh	(revision 437)
+++ /trunk/nv/stl/container/contiguous_storage.hh	(revision 438)
@@ -83,4 +83,5 @@
 				reallocate( 0, false );
 				m_data = other.m_data;
+				other.m_data = nullptr;
 			}
 			return *this;
Index: /trunk/nv/stl/container/growing_storage.hh
===================================================================
--- /trunk/nv/stl/container/growing_storage.hh	(revision 437)
+++ /trunk/nv/stl/container/growing_storage.hh	(revision 438)
@@ -112,8 +112,10 @@
 		inline growing_storage& operator=( growing_storage&& other )
 		{
-			Storage::reallocate( 0, false );
-			m_size = other.m_size;
-			Storage::operator=( nv::move( other ) );
-			other.m_size = size_impl_type();
+			if ( this != &other )
+			{
+				m_size = other.m_size;
+				Storage::operator=( nv::move( other ) );
+				other.m_size = size_impl_type();
+			}
 			return *this;
 		}
@@ -179,9 +181,11 @@
 		void insert( iterator position, const value_type& value )
 		{
-			iterator iend = Storage::data() + m_size;
+			ptrdiff_t offset = position - Storage::data();
 			if ( try_grow( 1 ) )
 			{
-				raw_alias_copy( position, iend, position + 1 );
-				copy_construct_object( position, value );
+				iterator iposition = Storage::data() + offset;
+				iterator iend = Storage::data() + m_size - 1;
+				raw_alias_copy( iposition, iend, iposition + 1 );
+				copy_construct_object( iposition, value );
 			}
 		}
@@ -192,10 +196,12 @@
 			// TODO: distance can't be called on destructive iterators - check 
 			//   and use pushback if needed?
-			iterator iend = Storage::data() + m_size;
+			ptrdiff_t offset = position - Storage::data();
 			size_type d = distance( first, last );
 			if ( try_grow( d ) )
 			{
-				raw_alias_copy( position, iend, position + d );
-				InitializePolicy::copy( first, last, position );
+				iterator iposition = Storage::data() + offset;
+				iterator iend = Storage::data() + m_size - d;
+				raw_alias_copy( iposition, iend, iposition + d );
+				InitializePolicy::copy( first, last, iposition );
 			}
 		}
Index: /trunk/nv/stl/file_system.hh
===================================================================
--- /trunk/nv/stl/file_system.hh	(revision 437)
+++ /trunk/nv/stl/file_system.hh	(revision 438)
@@ -14,4 +14,5 @@
 
 #include <nv/common.hh>
+#include <nv/stl/string.hh>
 #include <nv/stl/stream.hh>
 
@@ -25,6 +26,8 @@
 	public:
 		virtual ~file_system() {}
-		virtual bool exists( const char* fpath ) = 0;
-		virtual stream* open( const char* fpath, const char* fmode = "rb" ) = 0;
+		virtual const_string slurp( const string_view& path ) = 0;
+		virtual bool exists( const string_view& path ) = 0;
+		virtual stream* open( const string_view& path, const string_view& mode = "rb" ) = 0;
+
 	};
 
Index: /trunk/nv/stl/string.hh
===================================================================
--- /trunk/nv/stl/string.hh	(revision 437)
+++ /trunk/nv/stl/string.hh	(revision 438)
@@ -29,5 +29,4 @@
 #include <nv/stl/string/short_string.hh>
 #include <string>
-#include <sstream>
 #include <nv/stl/type_traits/primary.hh>
 #include <nv/stl/memory.hh>
@@ -47,10 +46,4 @@
 		inline H operator()( const std::string& value ) const { return get( value ); }
 	};
-
-
-	/**
-	* Simple function for slurping a file into a string.
-	*/
-	std::string slurp( const std::string& filename );
 
 	namespace detail
Index: /trunk/nv/stl/string/const_string.hh
===================================================================
--- /trunk/nv/stl/string/const_string.hh	(revision 437)
+++ /trunk/nv/stl/string/const_string.hh	(revision 438)
@@ -41,4 +41,7 @@
 			initialize( s, N - 1 );
 		}
+		// TODO : implement
+		//		inline string_buffer_base( const string_twine& twine );
+
 		~const_string()
 		{
@@ -74,5 +77,5 @@
 		{
 			char* new_data = new char[s + 1];
-			nvmemcpy( new_data, p, s );
+			if (p) nvmemcpy( new_data, p, s );
 			new_data[s] = 0;
 			assign( new_data, s );
Index: /trunk/nv/stl/string/short_string.hh
===================================================================
--- /trunk/nv/stl/string/short_string.hh	(revision 437)
+++ /trunk/nv/stl/string/short_string.hh	(revision 438)
@@ -10,4 +10,5 @@
 #include <nv/stl/string/common.hh>
 #include <nv/stl/string/string_base.hh>
+#include <nv/stl/string/string_twine.hh>
 #include <nv/stl/container/random_access.hh>
 #include <nv/stl/container/contiguous_storage.hh>
@@ -32,14 +33,15 @@
 		}
 
+
+		template < typename Base >
+		inline explicit string_buffer_base( const string_base< Base >& s ) : this_type( s.data(), s.size() ) {}
 		inline explicit string_buffer_base( const string_view& s ) : this_type( s.data(), s.size() ) {}
-		template < typename S >
-		inline string_buffer_base( const string_base<S>& rhs ) : this_type( rhs.data(), rhs.size() ) {}
+
+		inline string_buffer_base( const string_twine& twine )
+		{
+			append( twine );
+		}
 		inline string_buffer_base( string_buffer_base&& copy ) = default;
 		inline string_buffer_base& operator=( string_buffer_base&& other ) = default;
-		inline string_buffer_base& operator=( const string_view& other )
-		{
-			clear();
-			append( other );
-		}
 
 		size_t append( const char* data, size_t sz )
@@ -49,4 +51,13 @@
 			raw_copy_n( data, amount, this->begin() + pos );
 			return amount;
+		}
+
+		size_t append( const string_twine& twine )
+		{
+			size_t pos = size();
+			size_t dump_size = twine.dump_size();
+			expand_by( dump_size );
+			twine.dump( array_ref< char >( data() + pos, size() - pos ) );
+			return size() - pos;
 		}
 
@@ -111,5 +122,5 @@
 		void reserve( size_type new_capacity )
 		{
-			Storage::reserve( new_capacity + 1, true );
+			Storage::reserve( new_capacity + 1 );
 			this->data()[this->size()] = 0;
 		}
@@ -117,5 +128,5 @@
 		void resize( size_type new_size )
 		{
-			Storage::reserve( new_size + 1, true );
+			Storage::reserve( new_size + 1 );
 			Storage::resize( min( new_size, capacity() - 1 ) );
 			this->data()[this->size()] = 0;
Index: /trunk/src/core/library.cc
===================================================================
--- /trunk/src/core/library.cc	(revision 437)
+++ /trunk/src/core/library.cc	(revision 438)
@@ -6,5 +6,4 @@
 
 #include "nv/core/library.hh"
-#include <string>
 
 #if NV_PLATFORM == NV_WINDOWS
@@ -74,17 +73,17 @@
     NV_LOG_NOTICE( "library \"", m_name, "\" : loading..." );
 
-	std::string name( m_name.data(), m_name.length() );
-	std::string ext( NV_LIB_EXT );
+	string128 name( m_name );
+	string_view ext( NV_LIB_EXT );
 
-	if ( name.length() < ext.length() || name.substr( name.length() - ext.length(), ext.length() ) != ext )
+	if ( name.length() < ext.length() || !name.ends_with( ext ) )
     {
-        name.append( ext.data(), ext.length() );
+        name.append( ext );
     }
 
-    m_handle = NV_LIB_OPEN( name.c_str() );
+    m_handle = NV_LIB_OPEN( name.data() );
 
     if ( m_handle == NULL )
     {
-		NV_LOG_NOTICE( "library \"", m_name, "\" : failed to open!" );
+		NV_LOG_NOTICE( "library \"", name, "\" : failed to open!" );
 		return false;
     }
Index: /trunk/src/engine/program_manager.cc
===================================================================
--- /trunk/src/engine/program_manager.cc	(revision 437)
+++ /trunk/src/engine/program_manager.cc	(revision 438)
@@ -9,10 +9,9 @@
 #include "nv/core/logging.hh"
 #include "nv/lua/lua_nova.hh"
-
+#include "nv/io/c_file_system.hh"
 
 nv::program_manager::program_manager( context* a_context ) : m_context( a_context )
 {
-	m_vertex_head   = a_context->get_device()->get_shader_header();
-	m_fragment_head = a_context->get_device()->get_shader_header();
+	m_shader_head = a_context->get_device()->get_shader_header();
 }
 
@@ -20,22 +19,22 @@
 {
 	NV_LOG_DEBUG( table.get_string("id") );
-	std::string vsource;
-	std::string fsource;
-	std::string csource;
+	string_buffer vsource;
+	string_buffer fsource;
+	string_buffer header( m_shader_head );
 	if ( table.is_table("common") )
 	{
 		lua::table_guard common( table, "common" );
-		load_source( common, csource, "" );
+		header.append( "\n" + load_source( common, "" ) + "\n" );
 	}
 	{
 		lua::table_guard vtable( table, "vertex" );
-		load_source( vtable, vsource, m_vertex_head+"\n"+csource+"\n");
+		vsource = load_source( vtable, header );
 	}
 	{
 		lua::table_guard ftable( table, "fragment" );
-		load_source( ftable, fsource, m_fragment_head+"\n"+csource+"\n" );
+		fsource = load_source( ftable, header );
 	}
 
-	nv::program program = m_context->get_device()->create_program( string_view( vsource.c_str(), vsource.size() ), string_view( fsource.c_str(), fsource.size() ) );
+	nv::program program = m_context->get_device()->create_program( vsource, fsource );
 	return add( program );
 }
@@ -46,10 +45,11 @@
 }
 
-void nv::program_manager::load_source( lua::table_guard& table, std::string& out, const std::string& append )
+nv::string_buffer nv::program_manager::load_source( lua::table_guard& table, const string_view& append )
 {
-	out = append;
+	c_file_system fs;
+	string_buffer out( append );
 	if ( table.is_string( "files" ) )
 	{
-		out += nv::slurp( table.get_std_string( "files" ) );
+		out.append( fs.slurp( table.get_string( "files" ) ) );
 	}
 	else if ( table.is_table( "files" ) )
@@ -59,7 +59,7 @@
 		for ( uint32 i = 1; i <= count; ++i )
 		{
-			std::string include( inctable.get<std::string,uint32>(i) );
-			if ( i == count ) out += "#line 1\n";
-			out += nv::slurp( include );
+			const_string include( inctable.get<const_string,uint32>(i) );
+			if ( i == count ) out.append( "#line 1\n" );
+			out.append( fs.slurp( include ) );
 		}
 	}
@@ -67,10 +67,12 @@
 	if ( table.is_string( "file" ) )
 	{
-		out += "#line 1\n" + nv::slurp( table.get_std_string( "file" ) );
+		const_string data = fs.slurp( table.get_string( "file" ) );
+		out.append( "#line 1\n" + data );
 	}
 
 	if ( table.is_string( "source" ) )
 	{
-		out += table.get_std_string( "source" );
+		out.append( table.get_string( "source" ) );
 	}
+	return out;
 }
Index: /trunk/src/gfx/texture_font.cc
===================================================================
--- /trunk/src/gfx/texture_font.cc	(revision 437)
+++ /trunk/src/gfx/texture_font.cc	(revision 438)
@@ -29,6 +29,6 @@
 }
 
-texture_font::texture_font( texture_atlas* atlas, const char * filename, float size )
-	: m_atlas( atlas ), m_filename(filename), m_size( size ), 
+texture_font::texture_font( texture_atlas* atlas, const string_view& filename, float size )
+	: m_atlas( atlas ), m_filename( filename ), m_size( size ),
 	m_height(0), m_linegap(0), m_ascender(0), m_descender(0),
 	m_hinting( true ), m_filtering( true ), m_rlibrary( nullptr ), m_rface( nullptr )
@@ -53,5 +53,5 @@
 	NV_CHECK_FREETYPE_ERROR( error, "error on FT_Init_FreeType, code - ", error );
 
-	error = FT_New_Face( reinterpret_cast<FT_Library>(m_rlibrary), filename, 0, reinterpret_cast<FT_Face*>(&m_rface) );
+	error = FT_New_Face( reinterpret_cast<FT_Library>(m_rlibrary), filename.data(), 0, reinterpret_cast<FT_Face*>(&m_rface) );
 	NV_CHECK_FREETYPE_ERROR( error, "error on FT_New_Face, code - ", error );
 
Index: /trunk/src/gl/gl_device.cc
===================================================================
--- /trunk/src/gl/gl_device.cc	(revision 437)
+++ /trunk/src/gl/gl_device.cc	(revision 438)
@@ -17,9 +17,9 @@
 gl_device::gl_device()
 {
-	m_shader_header  = "#version 120\n";
+	m_shader_header.append( "#version 120\n" );
 	for ( auto& i : get_uniform_factory() ) 
-		m_shader_header += "uniform "+datatype_to_glsl_type( i.second->get_datatype() )+" "+ std::string( i.first.data(), i.first.size() ) +";\n";
+		m_shader_header.append( "uniform "+datatype_to_glsl_type( i.second->get_datatype() )+" "+ i.first +";\n" );
 	for ( auto& i : get_link_uniform_factory() ) 
-		m_shader_header += "uniform sampler2D "+std::string( i.first.data(), i.first.size() ) +";\n";
+		m_shader_header.append( "uniform sampler2D "+i.first +";\n" );
 }
 
Index: /trunk/src/gl/gl_enum.cc
===================================================================
--- /trunk/src/gl/gl_enum.cc	(revision 437)
+++ /trunk/src/gl/gl_enum.cc	(revision 438)
@@ -354,5 +354,5 @@
 }
 
-std::string nv::datatype_to_glsl_type( datatype type )
+string_view nv::datatype_to_glsl_type( datatype type )
 {
 	switch( type )
Index: /trunk/src/io/c_file_system.cc
===================================================================
--- /trunk/src/io/c_file_system.cc	(revision 437)
+++ /trunk/src/io/c_file_system.cc	(revision 438)
@@ -11,4 +11,5 @@
 using namespace nv;
 
+
 c_file_system::c_file_system()
 {
@@ -21,7 +22,7 @@
 }
 
-bool c_file_system::exists( const char* fpath )
+bool c_file_system::exists( const string_view& fpath )
 {
-	FILE* file = ::fopen( fpath, "rb" );
+	FILE* file = ::fopen( fpath.data(), "rb" );
 	if ( !file )
 	{
@@ -32,12 +33,23 @@
 }
 
-stream* c_file_system::open( const char* fpath, const char* fmode /*= "rb" */ )
+stream* c_file_system::open( const string_view& fpath, const string_view& fmode /*= "rb" */ )
 {
-	NV_ASSERT( fpath != nullptr && fmode != nullptr, "Bad parameters passed to open" );
-	FILE* file = ::fopen( fpath, fmode );
+	NV_ASSERT( !fpath.empty() && !fmode.empty(), "Bad parameters passed to open" );
+	FILE* file = ::fopen( fpath.data(), fmode.data() );
 	if ( !file )
 	{
 		return nullptr;
 	}
-	return new c_stream( file, fpath );
+	return new c_stream( file, fpath.data() );
 }
+
+nv::const_string c_file_system::slurp( const string_view& path )
+{
+	stream* fstream = open( path, "rb" );
+	if ( !fstream ) return const_string();
+	uint32 size = fstream->size();
+	const_string result( nullptr, size );
+	fstream->read( const_cast<char*>( result.data() ), size, 1 );
+	delete fstream;
+	return result;
+}
Index: /trunk/src/lua/lua_raw.cc
===================================================================
--- /trunk/src/lua/lua_raw.cc	(revision 437)
+++ /trunk/src/lua/lua_raw.cc	(revision 438)
@@ -30,10 +30,10 @@
 	{
 		size_t l = nv::uint64_to_buffer( buffer, nv::uint64( lua_touserdata( L, idx ) ) );
-		return nv::string_view( buffer.data(), buffer.size() );
+		return nv::string_view( buffer.data(), l );
 	}
 	else if ( type == LUA_TNUMBER )
 	{
 		size_t l = nv::f64_to_buffer( buffer, lua_tonumber( L, idx ) );
-		return nv::string_view( buffer.data(), buffer.size() );
+		return nv::string_view( buffer.data(), l );
 	}
 	return "UNKNOWN!";
Index: /trunk/src/stl/string.cc
===================================================================
--- /trunk/src/stl/string.cc	(revision 437)
+++ /trunk/src/stl/string.cc	(revision 438)
@@ -12,17 +12,9 @@
 #include <cstdlib>
 #include <fstream> // for slurp only
+#include <sstream> // for slurp only
 
 using namespace nv;
 
 //static const double s_power_10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 };
-
-std::string nv::slurp( const std::string& filename )
-{
-	std::ifstream input( filename );
-	//		if ( !input.is_open() ) NV_THROW( std::runtime_error, "File "+filename+" not found!");
-	std::stringstream sstr;
-	while ( input >> sstr.rdbuf() );
-	return sstr.str();
-}
 
 static inline void string_reverse( char* begin, char* end )
