Index: trunk/src/formats/assimp_loader.cc
===================================================================
--- trunk/src/formats/assimp_loader.cc	(revision 382)
+++ trunk/src/formats/assimp_loader.cc	(revision 383)
@@ -188,5 +188,5 @@
 }
 
-bool nv::assimp_loader::load_bones( size_t index, std::vector< mesh_node_data >& bones )
+bool nv::assimp_loader::load_bones( size_t index, array_ref< mesh_node_data > bones )
 {
 	if ( m_scene == nullptr ) return false;
@@ -285,10 +285,10 @@
 {
 	const aiScene* scene = (const aiScene*)m_scene;
-	std::vector< mesh_node_data > final_bones;
+	vector< mesh_node_data > final_bones;
 	std::unordered_map< std::string, uint16 > names;
 	for ( unsigned int m = 0; m < m_mesh_count; ++m )
 	{
 		uint16 translate[MAX_BONES];
-		std::vector< mesh_node_data > bones;
+		vector< mesh_node_data > bones;
 		const aiMesh*  mesh  = scene->mMeshes[ m ];
 		if ( mesh->mNumBones != 0 )
@@ -334,5 +334,5 @@
 	}
 	mesh_node_data* bones = new mesh_node_data[ final_bones.size() ];
-	std::copy( final_bones.begin(), final_bones.end(), bones );
+	nv::raw_copy( final_bones.begin(), final_bones.end(), bones );
 	return new mesh_nodes_data( "bones", final_bones.size(), bones );
 }
Index: trunk/src/formats/md2_loader.cc
===================================================================
--- trunk/src/formats/md2_loader.cc	(revision 382)
+++ trunk/src/formats/md2_loader.cc	(revision 383)
@@ -251,5 +251,5 @@
 	uint32 stats_collision  = 0;
 
-	std::vector< sint32 > index_translation( static_cast< uint32 >( md2->header.num_vertices ), -1 );
+	vector< sint32 > index_translation( static_cast< uint32 >( md2->header.num_vertices ), -1 );
 
 	m_new_indexes.clear();
@@ -364,5 +364,5 @@
 	{
 		uint16* icp = (uint16*)ic->data;
-		std::copy_n( m_new_indexes.data(), m_new_indexes.size(), icp );
+		raw_copy_n( m_new_indexes.data(), m_new_indexes.size(), icp );
 	}
 
Index: trunk/src/formats/md3_loader.cc
===================================================================
--- trunk/src/formats/md3_loader.cc	(revision 382)
+++ trunk/src/formats/md3_loader.cc	(revision 383)
@@ -198,5 +198,5 @@
 	md3->tags     = new md3_tag_t    [ md3->header.num_tags * md3->header.num_frames ];
 	md3->surfaces = new md3_surface_t[ md3->header.num_surfaces ];
-	std::memset( md3->surfaces, 0, static_cast< nv::size_t >( md3->header.num_surfaces ) * sizeof( md3_surface_t ) );
+	nv::raw_zero_n( md3->surfaces, static_cast< nv::size_t >( md3->header.num_surfaces ) );
 
 	source.seek( md3->header.ofs_frames, origin::SET );
@@ -285,5 +285,5 @@
 }
 
-nv::key_raw_channel* nv::md3_loader::load_tags( const std::string& tag )
+nv::key_raw_channel* nv::md3_loader::load_tags( const string_ref& tag )
 {
 	md3_t* md3 = (md3_t*)m_md3;
@@ -295,5 +295,5 @@
 		{
 			const md3_tag_t& rtag = md3->tags[i + md3->header.num_tags * f];
-			std::string rname((char*)(rtag.name));
+			string_ref rname((char*)(rtag.name));
 			if (rname == tag)
 			{
@@ -421,13 +421,13 @@
 	md3_t* md3 = (md3_t*)m_md3;
 	uint32 node_count = (uint32)md3->header.num_tags;
-	if ( node_count == 0 ) return nullptr;;
+	if ( node_count == 0 ) return nullptr;
 	mesh_node_data* nodes = new mesh_node_data[ node_count ];
 	for ( uint32 i = 0; i < node_count; ++i )
 	{
 		const md3_tag_t& rtag = md3->tags[i];
-		std::string name( (char*)(rtag.name) );
+		string_ref name( (char*)(rtag.name) );
 
 		nodes[i].transform = mat4();
-		nodes[i].name      = name;
+		nodes[i].name      = name.to_string();
 		nodes[i].parent_id = -1;
 		nodes[i].target_id = -1;
Index: trunk/src/formats/md5_loader.cc
===================================================================
--- trunk/src/formats/md5_loader.cc	(revision 382)
+++ trunk/src/formats/md5_loader.cc	(revision 383)
@@ -48,6 +48,6 @@
 
 	// MESH data
-	std::vector<md5_joint_info> joint_infos;
-	std::vector<transform>      base_frames;
+	dynamic_array< md5_joint_info > joint_infos;
+	vector< transform >             base_frames;
 	size_t num_animated_components = 0;
 	size_t frame_rate = 0;
@@ -301,5 +301,5 @@
 		else if ( command == "frame" )
 		{
-			std::vector<float> frame;
+			vector<float> frame;
 			uint32 frame_id;
 			sstream >> frame_id;
@@ -454,5 +454,5 @@
 }
 
-void md5_loader::build_frame_skeleton( mesh_node_data* nodes, uint32 index, const std::vector<md5_joint_info>& joint_infos, const std::vector<transform>& base_frames, const std::vector<float>& frame_data )
+void md5_loader::build_frame_skeleton( mesh_node_data* nodes, uint32 index, const const_array_ref<md5_joint_info>& joint_infos, const const_array_ref<transform>& base_frames, const const_array_ref<float>& frame_data )
 {
 	assert( m_type == ANIMATION );
Index: trunk/src/formats/nmd_loader.cc
===================================================================
--- trunk/src/formats/nmd_loader.cc	(revision 382)
+++ trunk/src/formats/nmd_loader.cc	(revision 383)
@@ -162,5 +162,5 @@
 static void nmd_dump_mesh( const mesh_data* mesh, stream& stream_out )
 {
-	const std::vector< mesh_raw_channel* >& data  = mesh->get_raw_channels();
+	const_array_ref< mesh_raw_channel* > data  = mesh->get_raw_channels();
 
 	uint32 size = sizeof( nmd_element_header );
Index: trunk/src/formats/obj_loader.cc
===================================================================
--- trunk/src/formats/obj_loader.cc	(revision 382)
+++ trunk/src/formats/obj_loader.cc	(revision 383)
@@ -44,7 +44,7 @@
 struct obj_reader
 {
-	std::vector< vec3 > v;
-	std::vector< vec3 > n;
-	std::vector< vec2 > t;
+	vector< vec3 > v;
+	vector< vec3 > n;
+	vector< vec2 > t;
 
 	std::string line;
@@ -204,5 +204,5 @@
 	}
 	bool m_normals;
-	std::vector< VTX > m_data;
+	vector< VTX > m_data;
 	virtual void reset() { m_data.clear(); }
 	virtual nv::size_t raw_size() const { return m_data.size() * sizeof( VTX ); }
@@ -228,14 +228,9 @@
 	void calculate_tangents()
 	{
-		//		const std::vector< vec3 >& vp = m_mesh->get_positions();
-		//		const std::vector< vec2 >& vt = m_mesh->get_texcoords();
-		//		const std::vector< vec3 >& vn = m_mesh->get_normals();
-		//		std::vector< vec3 >& tg = m_mesh->get_tangents();
-
 		nv::size_t count = m_data.size();
 		nv::size_t tcount = count / 3;
 
-		std::vector< vec3 > tan1( count );
-		std::vector< vec3 > tan2( count );
+		vector< vec3 > tan1( count );
+		vector< vec3 > tan2( count );
 
 		for ( nv::size_t a = 0; a < tcount; ++a )
@@ -335,5 +330,5 @@
 		{
 			data = new uint8[ reader->raw_size() ];
-			std::copy_n( reader->raw_pointer(), reader->raw_size(), data );
+			raw_copy_n( reader->raw_pointer(), reader->raw_size(), data );
 		}
 		channel->data  = data;
Index: trunk/src/gfx/image.cc
===================================================================
--- trunk/src/gfx/image.cc	(revision 382)
+++ trunk/src/gfx/image.cc	(revision 383)
@@ -4,4 +4,5 @@
 
 #include "nv/gfx/image.hh"
+#include "nv/stl/algorithm.hh"
 
 using namespace nv;
@@ -31,5 +32,5 @@
 		for( int i = 0; i < m_size.y; ++i )
 		{
-			std::copy( data + i * bline, data + (i + 1) * bline, m_data + bsize - ( i + 1 ) * bline );
+			raw_copy( data + i * bline, data + (i + 1) * bline, m_data + bsize - ( i + 1 ) * bline );
 		}
 
@@ -37,5 +38,5 @@
 	else 
 	{
-		std::copy( data, data + bsize, m_data );
+		raw_copy( data, data + bsize, m_data );
 	}
 }
@@ -43,5 +44,5 @@
 void image::fill( uint8 value )
 {
-	std::fill( m_data, m_data + m_size.x * m_size.y * (int)m_depth, value );
+	raw_fill( m_data, m_data + m_size.x * m_size.y * (int)m_depth, value );
 }
 
@@ -56,5 +57,5 @@
 	{
 		// TODO: test 
-		std::fill( m_data + bpos + bline * i, m_data + bpos + bline * i + stride, value );
+		raw_fill( m_data + bpos + bline * i, m_data + bpos + bline * i + stride, value );
 	}
 }
@@ -73,5 +74,5 @@
 //		memcpy( m_data+((r.pos.y+i)*m_size.x + r.pos.x ) * m_depth, 
 //			data + (i*stride), r.size.x * m_depth );
-		std::copy( data + i*stride, data + (i+1)*stride, m_data + bpos + bline * i );
+		raw_copy( data + i*stride, data + (i+1)*stride, m_data + bpos + bline * i );
 	}
 }
Index: trunk/src/gfx/mesh_creator.cc
===================================================================
--- trunk/src/gfx/mesh_creator.cc	(revision 382)
+++ trunk/src/gfx/mesh_creator.cc	(revision 383)
@@ -350,6 +350,6 @@
 	for ( uint32 i = 0; i < count; ++i )
 	{
-		std::copy_n( a->data + i * adesc.size, adesc.size, data + i*desc.size );
-		std::copy_n( b->data + i * bdesc.size, bdesc.size, data + i*desc.size + adesc.size );
+		raw_copy_n( a->data + i * adesc.size, adesc.size, data + i*desc.size );
+		raw_copy_n( b->data + i * bdesc.size, bdesc.size, data + i*desc.size + adesc.size );
 	}
 	mesh_raw_channel* result = new mesh_raw_channel;
@@ -373,6 +373,6 @@
 	{
 		size_t a_size = vtx_size * a->count;
-		std::copy_n( a->data, a_size, data );
-		std::copy_n( b->data, vtx_size * b->count, data + a_size );		
+		raw_copy_n( a->data, a_size, data );
+		raw_copy_n( b->data, vtx_size * b->count, data + a_size );
 	}
 	else
@@ -385,6 +385,6 @@
 		for ( size_t i = 0; i < frame_count; ++i )
 		{
-			std::copy_n( a->data + pos_a, frame_size_a, data + pos );
-			std::copy_n( b->data + pos_b, frame_size_b, data + pos + frame_size_a );				pos_a += frame_size_a; 
+			raw_copy_n( a->data + pos_a, frame_size_a, data + pos );
+			raw_copy_n( b->data + pos_b, frame_size_b, data + pos + frame_size_a );				pos_a += frame_size_a;
 			pos_b += frame_size_b; 
 			pos   += frame_size_a + frame_size_b;
Index: trunk/src/gfx/skeletal_mesh.cc
===================================================================
--- trunk/src/gfx/skeletal_mesh.cc	(revision 382)
+++ trunk/src/gfx/skeletal_mesh.cc	(revision 383)
@@ -43,5 +43,5 @@
 			}
 
-			std::fill( m_pntdata.raw_data(), m_pntdata.raw_data() + m_pntdata.raw_size(), 0 );
+			fill( m_pntdata.raw_data(), m_pntdata.raw_data() + m_pntdata.raw_size(), 0 );
 			for ( unsigned int i = 0; i < vertex_count; ++i )
 			{
Index: trunk/src/gl/gl_device.cc
===================================================================
--- trunk/src/gl/gl_device.cc	(revision 382)
+++ trunk/src/gl/gl_device.cc	(revision 383)
@@ -221,5 +221,5 @@
 	const gl_program_info* info = m_programs.get( p );
 	{
-		uniform_map::const_iterator i = info->m_uniform_map.find( name );
+		nv::uniform_map::const_iterator i = info->m_uniform_map.find( name );
 		if ( i != info->m_uniform_map.end() )
 		{
Index: trunk/src/io/string_table.cc
===================================================================
--- trunk/src/io/string_table.cc	(revision 382)
+++ trunk/src/io/string_table.cc	(revision 383)
@@ -6,4 +6,5 @@
 
 #include "nv/io/string_table.hh"
+#include <array>
 
 nv::string_table_creator::string_table_creator()
Index: trunk/src/lua/lua_map_tile.cc
===================================================================
--- trunk/src/lua/lua_map_tile.cc	(revision 382)
+++ trunk/src/lua/lua_map_tile.cc	(revision 383)
@@ -118,6 +118,6 @@
 		new_tile->ascii = new nv::uchar8[ size ];
 	}
-	std::copy( old_tile->data, old_tile->data + size, new_tile->data );
-	if ( old_tile->ascii ) std::copy( old_tile->ascii, old_tile->ascii + size, new_tile->ascii );
+	nv::raw_copy_n( old_tile->data, size, new_tile->data );
+	if ( old_tile->ascii ) nv::raw_copy_n( old_tile->ascii, size, new_tile->ascii );
 
 	luaL_getmetatable( L, NLUA_MAP_TILE_METATABLE );
@@ -237,6 +237,10 @@
 	map_tile* tile = nlua_to_pmap_tile( L, 1 );
 	// assert( tile^.ascii == nullptr );
-	std::vector< nv::uint8 > sizes_x = nlua_tobytearray( L, 2 );
-	std::vector< nv::uint8 > sizes_y = ( lua_istable( L, 3 ) ? nlua_tobytearray( L, 3 ) : sizes_x );
+	nv::vector< nv::uint8 > sizes_x = nlua_tobytearray( L, 2 );
+	nv::vector< nv::uint8 > sizes_y;
+	if ( lua_istable( L, 3 ) )
+		sizes_y = nlua_tobytearray( L, 2 );
+	else
+		sizes_y.assign( sizes_x );
 
 	nv::uint16 org_x = tile->size_x;
Index: trunk/src/lua/lua_raw.cc
===================================================================
--- trunk/src/lua/lua_raw.cc	(revision 382)
+++ trunk/src/lua/lua_raw.cc	(revision 383)
@@ -262,8 +262,8 @@
 }
 
-std::vector<nv::uint8> nlua_tobytearray( lua_State *L, int index )
-{
-	index = lua_absindex( L, index );
-	std::vector<nv::uint8> result;
+nv::vector<nv::uint8> nlua_tobytearray( lua_State *L, int index )
+{
+	index = lua_absindex( L, index );
+	nv::vector<nv::uint8> result;
 	if ( lua_istable( L, index ) )
 	{
