Index: /trunk/nv.lua
===================================================================
--- /trunk/nv.lua	(revision 382)
+++ /trunk/nv.lua	(revision 383)
@@ -147,5 +147,5 @@
 
 	configuration "vs*"
-		defines { "_SECURE_SCL=0", "_CRT_SECURE_NO_WARNINGS=1" }
+		defines { "_SECURE_SCL=0", "_CRT_SECURE_NO_WARNINGS=1", "_ITERATOR_DEBUG_LEVEL=0", "_HAS_ITERATOR_DEBUGGING=0" }
 
 if _ACTION == "gmake-clang" then
Index: /trunk/nv/core/common.hh
===================================================================
--- /trunk/nv/core/common.hh	(revision 382)
+++ /trunk/nv/core/common.hh	(revision 383)
@@ -6,4 +6,6 @@
 #ifndef NV_CORE_COMMON_HH
 #define NV_CORE_COMMON_HH
+
+#define _ITERATOR_DEBUG_LEVEL 0
 
 // NV Library version
Index: /trunk/nv/core/profiler.hh
===================================================================
--- /trunk/nv/core/profiler.hh	(revision 382)
+++ /trunk/nv/core/profiler.hh	(revision 383)
@@ -21,7 +21,10 @@
 #if NV_PROFILER 
 #define NV_PROFILE( tag ) nv::profiler_guard __profile( tag )
+#define NV_PROFILE_IF( tag, condition ) nv::profiler_condition_guard __profile( tag, condition )
 #else
 #define NV_PROFILE( tag )
+#define NV_PROFILE_IF( tag, condition ) 
 #endif
+
 
 namespace nv
@@ -68,4 +71,5 @@
 		friend class auto_singleton< profiler >;
 		friend class profiler_guard;
+		friend class profiler_condition_guard;
 		void log_report();
 	private:
@@ -89,4 +93,21 @@
 	};
 
+	class profiler_condition_guard
+	{
+	public:
+		profiler_condition_guard( string_ref tag, bool condition )
+			: m_active( condition )
+		{
+			if ( m_active ) profiler::pointer()->start_profile( tag );
+		}
+
+		~profiler_condition_guard()
+		{
+			if ( m_active ) profiler::pointer()->stop_profile();
+		}
+	private:
+		bool m_active;
+	};
+
 } // namespace nv
 
Index: /trunk/nv/formats/assimp_loader.hh
===================================================================
--- /trunk/nv/formats/assimp_loader.hh	(revision 382)
+++ /trunk/nv/formats/assimp_loader.hh	(revision 383)
@@ -31,5 +31,5 @@
 	private:
 		mesh_nodes_data* release_merged_bones( mesh_data* meshes );
-		bool load_bones( size_t index, std::vector< mesh_node_data >& bones );
+		bool load_bones( size_t index, array_ref< mesh_node_data > bones );
 		void load_mesh_data( mesh_data* data, size_t index );
 		sint16 load_node( uint32 anim_id, mesh_node_data* nodes, const void* vnode, sint16 this_id, sint16 parent_id );
Index: /trunk/nv/formats/md2_loader.hh
===================================================================
--- /trunk/nv/formats/md2_loader.hh	(revision 382)
+++ /trunk/nv/formats/md2_loader.hh	(revision 383)
@@ -15,5 +15,4 @@
 
 #include <nv/core/common.hh>
-#include <unordered_map>
 #include <nv/stl/array.hh>
 #include <nv/interface/mesh_loader.hh>
@@ -37,7 +36,7 @@
 	private:
 		void* m_md2;
-		std::vector< uint16 > m_new_indexes;
-		std::vector< uint16 > m_new_vindexes;
-		std::vector< uint16 > m_new_tindexes;
+		vector< uint16 > m_new_indexes;
+		vector< uint16 > m_new_vindexes;
+		vector< uint16 > m_new_tindexes;
 	};
 
Index: /trunk/nv/formats/md3_loader.hh
===================================================================
--- /trunk/nv/formats/md3_loader.hh	(revision 382)
+++ /trunk/nv/formats/md3_loader.hh	(revision 383)
@@ -43,5 +43,5 @@
 	private:
 		void release_mesh_frame( mesh_data* data, sint32 frame, sint32 surface );
-		key_raw_channel* load_tags( const std::string& tag );
+		key_raw_channel* load_tags( const string_ref& tag );
 		bool m_merge_all;
 		void* m_md3;
Index: /trunk/nv/formats/md5_loader.hh
===================================================================
--- /trunk/nv/formats/md5_loader.hh	(revision 382)
+++ /trunk/nv/formats/md5_loader.hh	(revision 383)
@@ -83,5 +83,5 @@
 	protected:
 		void reset();
-		void build_frame_skeleton( mesh_node_data* nodes, uint32 index, const std::vector<md5_joint_info>& joint_info, const std::vector<transform>& base_frames, const std::vector<float>& frame_data );
+		void build_frame_skeleton( mesh_node_data* nodes, uint32 index, const const_array_ref<md5_joint_info>& joint_info, const const_array_ref<transform>& base_frames, const const_array_ref<float>& frame_data );
 		bool prepare_mesh( mesh_node_data* nodes, uint32 vtx_count, mesh_data* mdata, md5_weight* weights, md5_weight_info* weight_info );
 	protected:
Index: /trunk/nv/formats/obj_loader.hh
===================================================================
--- /trunk/nv/formats/obj_loader.hh	(revision 382)
+++ /trunk/nv/formats/obj_loader.hh	(revision 383)
@@ -31,8 +31,8 @@
 		~obj_loader();
 	private:
-		vertex_descriptor         m_descriptor;
-		bool                      m_normals;
-		bool                      m_tangents;
-		std::vector< mesh_data* > m_meshes;
+		vertex_descriptor    m_descriptor;
+		bool                 m_normals;
+		bool                 m_tangents;
+		vector< mesh_data* > m_meshes;
 	};
 
Index: /trunk/nv/interface/context.hh
===================================================================
--- /trunk/nv/interface/context.hh	(revision 382)
+++ /trunk/nv/interface/context.hh	(revision 383)
@@ -297,5 +297,5 @@
 		{
 			vertex_array  va = create_vertex_array();
-			const std::vector< mesh_raw_channel* >& channels = data->get_raw_channels();
+			const_array_ref< mesh_raw_channel* > channels = data->get_raw_channels();
 			for ( uint32 ch = 0; ch < channels.size(); ++ch )
 			{
Index: /trunk/nv/interface/mesh_data.hh
===================================================================
--- /trunk/nv/interface/mesh_data.hh	(revision 382)
+++ /trunk/nv/interface/mesh_data.hh	(revision 383)
@@ -107,6 +107,6 @@
 		}
 
-		const std::vector< mesh_raw_channel* >& get_raw_channels() const { return m_channels; }
-		const mesh_raw_channel*           get_index_channel() const { return m_index_channel; }
+		const_array_ref< mesh_raw_channel* > get_raw_channels()  const { return m_channels; }
+		const mesh_raw_channel*              get_index_channel() const { return m_index_channel; }
 		size_t get_channel_count() const { return m_channels.size(); }
 		const mesh_raw_channel* get_channel( size_t index ) const 
@@ -214,7 +214,7 @@
 		}
 	private:
-		std::string                      m_name;
-		std::vector< mesh_raw_channel* > m_channels;
-		mesh_raw_channel*                m_index_channel;
+		std::string                 m_name;
+		vector< mesh_raw_channel* > m_channels;
+		mesh_raw_channel*           m_index_channel;
 	};
 
Index: /trunk/nv/lua/lua_dispatch.hh
===================================================================
--- /trunk/nv/lua/lua_dispatch.hh	(revision 382)
+++ /trunk/nv/lua/lua_dispatch.hh	(revision 383)
@@ -4,10 +4,4 @@
 // This file is part of NV Libraries.
 // For conditions of distribution and use, see copyright notice in nv.hh
-//
-// TODO: the calls are supported only up to 4 parameters because:
-//    -- if you have more than 4 params, you're doing something wrong
-//    -- once the Variadic Templates cometh, for great justice we will win!
-//
-// TODO: this is a job for std::forward, but I'll take care of it later
 
 #ifndef NV_LUA_DISPATCH_HH
@@ -38,15 +32,15 @@
 				static void do_call(lua_State* L, R(*func)(Args...), Vs&&... vs)
 				{
-					push_value(L, func(std::forward<Vs>(vs)...)); 
+					push_value(L, func( nv::forward<Vs>(vs)...));
 				}
 				template <class C, typename... Args, typename... Vs>
 				static void do_call(lua_State* L, C* c, R(C::*func)(Args...), Vs&&... vs)
 				{
-					push_value(L, (*c.*func)(std::forward<Vs>(vs)...)); 
+					push_value(L, (*c.*func)( nv::forward<Vs>(vs)...));
 				}
 				template <class C, typename... Args, typename... Vs>
 				static void do_call( lua_State* L, C const * c, R( C::*func )( Args... ) const, Vs&&... vs )
 				{
-					push_value( L, ( *c.*func )( std::forward<Vs>( vs )... ) );
+					push_value( L, ( *c.*func )( nv::forward<Vs>( vs )... ) );
 				}
 			};
@@ -58,15 +52,15 @@
 				static void do_call(lua_State*, void(*func)(Args...), Vs&&... vs)
 				{
-					func(std::forward<Vs>(vs)...);
+					func( nv::forward<Vs>(vs)...);
 				}
 				template <class C, typename... Args, typename... Vs>
 				static void do_call(lua_State*, C* c, void(C::*func)(Args...), Vs&&... vs)
 				{
-					(*c.*func)(std::forward<Vs>(vs)...);
+					(*c.*func)( nv::forward<Vs>(vs)...);
 				}
 				template <class C, typename... Args, typename... Vs>
 				static void do_call( lua_State*, C const * c, void( C::*func )( Args... ) const, Vs&&... vs )
 				{
-					( *c.*func )( std::forward<Vs>( vs )... );
+					( *c.*func )( nv::forward<Vs>( vs )... );
 				}
 			};
@@ -75,5 +69,5 @@
 			int do_call(lua_State* L, int index, R(*func)(Args...), types<Head, Tail...>, Vs&&... vs)
 			{
-				do_call(L, index + 1, func, types < Tail... > {}, std::forward<Vs>(vs)..., get_value<Head>(L, index)); return 1;
+				do_call(L, index + 1, func, types < Tail... > {}, nv::forward<Vs>(vs)..., get_value<Head>(L, index)); return 1;
 			}
 
@@ -81,5 +75,5 @@
 			int do_call(lua_State* L, int index, C* c, R(C::*func)(Args...), types<Head, Tail...>, Vs&&... vs)
 			{
-				do_call(L, index + 1, c, func, types < Tail... > {}, std::forward<Vs>(vs)..., get_value<Head>(L, index)); return 1;
+				do_call(L, index + 1, c, func, types < Tail... > {}, nv::forward<Vs>(vs)..., get_value<Head>(L, index)); return 1;
 			}
 
@@ -87,5 +81,5 @@
 			int do_call( lua_State* L, int index, C const * c, R( C::*func )( Args... ) const, types<Head, Tail...>, Vs&&... vs )
 			{
-				do_call( L, index + 1, c, func, types < Tail... > {}, std::forward<Vs>( vs )..., get_value<Head>( L, index ) ); return 1;
+				do_call( L, index + 1, c, func, types < Tail... > {}, nv::forward<Vs>( vs )..., get_value<Head>( L, index ) ); return 1;
 			}
 
@@ -93,5 +87,5 @@
 			int do_call(lua_State* L, int, R(*func)(Args...), types<>, Vs&&... vs)
 			{
-				call_and_push<R>::do_call(L, func, std::forward<Vs>(vs)...);
+				call_and_push<R>::do_call(L, func, nv::forward<Vs>(vs)...);
 				return 1;
 			}
@@ -100,5 +94,5 @@
 			int do_call(lua_State* L, int, C* c, R(C::*func)(Args...), types<>, Vs&&... vs)
 			{
-				call_and_push<R>::do_call(L, c, func, std::forward<Vs>(vs)...);
+				call_and_push<R>::do_call(L, c, func, nv::forward<Vs>(vs)...);
 				return 1;
 			}
@@ -107,5 +101,5 @@
 			int do_call( lua_State* L, int, C const * c, R( C::*func )( Args... ) const, types<>, Vs&&... vs )
 			{
-				call_and_push<R>::do_call( L, c, func, std::forward<Vs>( vs )... );
+				call_and_push<R>::do_call( L, c, func, nv::forward<Vs>( vs )... );
 				return 1;
 			}
Index: /trunk/nv/lua/lua_raw.hh
===================================================================
--- /trunk/nv/lua/lua_raw.hh	(revision 382)
+++ /trunk/nv/lua/lua_raw.hh	(revision 383)
@@ -24,5 +24,5 @@
 void nlua_tokeyset( lua_State *L, int index );
 
-std::vector<nv::uint8> nlua_tobytearray( lua_State *L, int index );
+nv::vector<nv::uint8> nlua_tobytearray( lua_State *L, int index );
 
 void nlua_register( lua_State *L, const char* fname, lua_CFunction func, int index );
Index: /trunk/nv/stl/algorithm.hh
===================================================================
--- /trunk/nv/stl/algorithm.hh	(revision 382)
+++ /trunk/nv/stl/algorithm.hh	(revision 383)
@@ -18,4 +18,5 @@
 #include <nv/stl/utility.hh>
 #include <nv/stl/iterator.hh>
+#include <nv/stl/capi.hh>
 
 namespace nv
@@ -185,30 +186,108 @@
 	}
 
+	template< typename T >
+	T* raw_copy( const T* first, const T* last, T* out )
+	{
+		return (T*)nvmemcpy( out, first, (size_t)( (uintptr_t)last - (uintptr_t)first ) ) + ( last - first );
+	}
+
+	template< typename T >
+	T* raw_copy_n( const T* ptr, size_t n, T* out )
+	{
+		return (T*)nvmemcpy( out, ptr, n * sizeof(T) ) + n;
+	}
+
+	template< typename T >
+	T* raw_alias_copy( const T* first, const T* last, T* out )
+	{
+		return (T*)nvmemmove( out, first, (size_t)( (uintptr_t)last - (uintptr_t)first ) ) + ( last - first );
+	}
+
+	template< typename T >
+	T* raw_alias_copy_n( const T* ptr, size_t n, T* out )
+	{
+		return (T*)nvmemmove( out, ptr, n * sizeof( T ) ) + n;
+	}
+
+	template< typename T >
+	T* raw_zero( T* first, T* last )
+	{
+		return (T*)nvmemset( first, 0, (size_t)( (uintptr_t)last - (uintptr_t)first ) ) + ( last - first );
+	}
+
+	template< typename T >
+	T* raw_zero_n( T* ptr, size_t n )
+	{
+		return (T*)nvmemset( ptr, 0, n * sizeof( T ) ) + n;
+	}
+
+	template< typename T >
+	T* raw_fill( T* first, T* last, unsigned char value )
+	{
+		return (T*)nvmemset( first, value, (size_t)( (uintptr_t)last - (uintptr_t)first ) ) + ( last - first );
+	}
+
+	template< typename T >
+	T* raw_fill_n( T* ptr, size_t n, unsigned char value )
+	{
+		return (T*)nvmemset( ptr, value, n * sizeof( T ) ) + n;
+	}
+
 	namespace detail
 	{
-		template < typename ForwardIterator, typename T >
-		void fill_impl( ForwardIterator first, ForwardIterator last, const T& value, false_type )
-		{
+		template < typename ForwardIterator, typename T, typename AnyType >
+		void fill_impl( ForwardIterator first, ForwardIterator last, const T& value, AnyType, forward_iterator_tag )
+		{
+			// TODO: version with T temp = value for scalars
 			for (; first != last; ++first )
 				*first = value;
 		}
 
-		template < typename ForwardIterator, typename T >
-		void fill_impl( ForwardIterator first, ForwardIterator last, const T& value, true_type )
-		{
-			memset( first, value, last - first );
-		}
-
-		template < typename ForwardIterator, typename T >
-		ForwardIterator fill_n_impl( ForwardIterator first, size_t count, const T& value, false_type )
-		{
+		template < typename BlockAccessIterator, typename T >
+		void fill_impl( BlockAccessIterator first, BlockAccessIterator last, T value, true_type, block_access_iterator_tag )
+		{
+			raw_fill( first, last, (unsigned char)value );  
+		}
+
+		template < typename ForwardIterator, typename T, typename AnyType >
+		ForwardIterator fill_n_impl( ForwardIterator first, size_t count, const T& value, AnyType, forward_iterator_tag )
+		{
+			// TODO: version with T temp = T() for scalars
 			for ( ; count-- > 0; ++first ) *first = value;
 			return first;
 		}
 
-		template < typename ForwardIterator, typename T >
-		ForwardIterator fill_n_impl( ForwardIterator first, size_t count, const T& value, true_type )
-		{
-			return ForwardIterator( memset( first, value, count ) + count );
+		template < typename BlockAccessIterator, typename T >
+		BlockAccessIterator fill_n_impl( BlockAccessIterator first, size_t count, T value, true_type, block_access_iterator_tag )
+		{
+			return BlockAccessIterator( raw_fill_n( first, count, (unsigned char)value ) );
+		}
+
+		template < typename ForwardIterator, typename T, typename AnyType >
+		void fill_default_impl( ForwardIterator first, ForwardIterator last, AnyType, forward_iterator_tag )
+		{
+			// TODO: version with T temp = T() for scalars
+			for ( ; first != last; ++first )
+				*first = T();
+		}
+
+		template < typename BlockAccessIterator, typename T >
+		void fill_default_impl( BlockAccessIterator first, BlockAccessIterator last, true_type, block_access_iterator_tag )
+		{
+			raw_zero( first, last );
+		}
+
+		template < typename ForwardIterator, typename T, typename AnyType >
+		ForwardIterator fill_default_n_impl( ForwardIterator first, size_t n, AnyType, forward_iterator_tag )
+		{
+			// TODO: version with T temp = T() for scalars
+			for ( ; n-- > 0; ++first ) *first = value;
+			return first;
+		}
+
+		template < typename BlockAccessIterator, typename T >
+		BlockAccessIterator fill_default_n_impl( BlockAccessIterator first, size_t count, true_type, block_access_iterator_tag )
+		{
+			return BlockAccessIterator( raw_zero_n( first, count, (unsigned char)value ) );
 		}
 	}
@@ -218,6 +297,9 @@
 	inline void fill( ForwardIterator first, ForwardIterator last, const T& value )
 	{
-		detail::fill_impl( first, last, value,
-			bool_constant< sizeof( T ) == 1 && has_trivial_assign<T>::value >() );
+		typedef typename iterator_traits< ForwardIterator >::value_type        value_type;
+		typedef typename iterator_traits< ForwardIterator >::iterator_category iterator_category;
+		detail::fill_impl( first, last, static_cast<value_type>( value ),
+			bool_constant< sizeof( value_type ) == 1 && 
+			has_trivial_assign<value_type>::value >(), iterator_category() );
 	}
 
@@ -225,6 +307,8 @@
 	inline ForwardIterator fill_n( ForwardIterator first, size_t count, const T& value )
 	{
-		return detail::fill_n_impl( first, count, value,
-			bool_constant< sizeof( T ) == 1 && has_trivial_assign<T>::value >() );
+		typedef typename iterator_traits< ForwardIterator >::value_type value_type;
+		typedef typename iterator_traits< ForwardIterator >::iterator_category iterator_category;
+		return detail::fill_n_impl( first, count, static_cast<value_type>( value ),
+			bool_constant< sizeof( value_type ) == 1 && has_trivial_assign<value_type>::value >(), iterator_category() );
 	}
 
@@ -232,8 +316,8 @@
 	inline void fill_default( ForwardIterator first, ForwardIterator last )
 	{
-		// TODO: implement
 		typedef typename iterator_traits< ForwardIterator >::value_type value_type;
-		detail::fill_impl( first, last, value_type(),
-			bool_constant< sizeof( value_type ) == 1 && has_trivial_assign<value_type>::value >() );
+		typedef typename iterator_traits< ForwardIterator >::iterator_category iterator_category;
+		detail::fill_default_impl( first, last, 
+			bool_constant< sizeof( value_type ) == 1 && has_trivial_assign<value_type>::value >(), iterator_category() );
 	}
 
@@ -241,8 +325,58 @@
 	inline ForwardIterator fill_default_n( ForwardIterator first, size_t count )
 	{
-		// TODO: implement
 		typedef typename iterator_traits< ForwardIterator >::value_type value_type;
-		return detail::fill_n_impl( first, count, value_type(),
-			bool_constant< sizeof( value_type ) == 1 && has_trivial_assign<value_type>::value >() );
+		typedef typename iterator_traits< ForwardIterator >::iterator_category iterator_category;
+		return detail::fill_default_n_impl( first, count, 
+			bool_constant< sizeof( value_type ) == 1 && has_trivial_assign<value_type>::value >(), iterator_category() );
+	}
+
+	namespace detail
+	{
+		template< typename InputIterator, typename OutputIterator, typename AnyType >
+		inline OutputIterator copy_impl( InputIterator first, InputIterator last, OutputIterator out, AnyType, input_iterator_tag, forward_iterator_tag )
+		{
+			for ( ; first != last; ++first, ++out )
+				*first = *out;
+			return out;
+		}
+
+		template< typename BlockAccessIterator, typename OutputIterator >
+		inline BlockAccessIterator copy_impl( BlockAccessIterator first, BlockAccessIterator last, OutputIterator out, true_type, block_access_iterator_tag, block_access_iterator_tag )
+		{
+			return raw_alias_copy( first, last, out )
+		}
+
+		template< typename InputIterator, typename OutputIterator, typename AnyType >
+		inline OutputIterator copy_n_impl( InputIterator first, size_t n, OutputIterator out, AnyType, input_iterator_tag, forward_iterator_tag )
+		{
+			for ( ; n-- > 0; ++first, ++out ) *first = *out;
+			return out;
+		}
+
+		template< typename BlockAccessIterator, typename OutputIterator >
+		inline BlockAccessIterator copy_n_impl( BlockAccessIterator first, BlockAccessIterator n, OutputIterator out, true_type, block_access_iterator_tag, block_access_iterator_tag )
+		{
+			return raw_alias_copy_n( first, n, out )
+		}
+	}
+
+	template< class InputIterator, class OutputIterator >
+	inline OutputIterator copy( InputIterator first, InputIterator last, OutputIterator out )
+	{
+		typedef typename iterator_traits< InputIterator >::value_type value_type;
+		typedef typename iterator_traits< InputIterator >::iterator_category input_iterator_category;
+		typedef typename iterator_traits< OutputIterator >::iterator_category output_iterator_category;
+		return detail::copy_impl( first, last, out,
+			has_trivial_copy<value_type>::value, iterator_category(), output_iterator_category() );
+	}
+
+	template< class InputIterator, class OutputIterator >
+	inline OutputIterator copy_n( InputIterator first, size_t n, OutputIterator out )
+	{
+		typedef typename iterator_traits< InputIterator >::value_type value_type;
+		typedef typename iterator_traits< InputIterator >::iterator_category input_iterator_category;
+		typedef typename iterator_traits< OutputIterator >::iterator_category output_iterator_category;
+		return detail::copy_n_impl( first, n, out,
+			has_trivial_copy<value_type>::value, iterator_category(), output_iterator_category() );
 	}
 
Index: /trunk/nv/stl/array.hh
===================================================================
--- /trunk/nv/stl/array.hh	(revision 382)
+++ /trunk/nv/stl/array.hh	(revision 383)
@@ -24,15 +24,579 @@
 namespace nv
 {
-	using ::std::vector;
+
+	struct default_init
+	{
+
+	};
+
+	template< typename SizeType >
+	struct default_next_capacity
+	{
+		static SizeType get( SizeType requested, SizeType capacity, SizeType max_size )
+		{
+			SizeType remaining = max_size - capacity;
+			if ( remaining < requested ) return 0;
+			SizeType additional = nv::max( requested, capacity );
+			return ( remaining < additional ? max_size : capacity + additional );
+		}
+	};
+
+	struct policy_initialize_always
+	{
+		template < typename ForwardIterator >
+		inline static void initialize( ForwardIterator first, ForwardIterator last )
+		{
+			uninitialized_construct( first, last );
+		}
+		template < typename InputIterator, typename ForwardIterator >
+		inline static ForwardIterator copy( InputIterator first, InputIterator last, ForwardIterator out )
+		{
+			return uninitialized_copy( first, last, out );
+		}
+		template < typename ForwardIterator >
+		inline static void destroy( ForwardIterator first, ForwardIterator last )
+		{
+			uninitialized_destroy( first, last );
+		}
+		template < typename ForwardIterator >
+		inline static void destroy( ForwardIterator first )
+		{
+			destroy_object( first );
+		}
+	};
+
+	struct policy_initialize_never
+	{
+		template < typename ForwardIterator >
+		inline static void initialize( ForwardIterator, ForwardIterator )
+		{
+		}
+		template < typename InputIterator, typename ForwardIterator >
+		inline static ForwardIterator copy( InputIterator first, InputIterator last, ForwardIterator out )
+		{
+			return detail::uninitialized_copy( first, last, out, true_type );
+		}
+		template < typename ForwardIterator >
+		inline static void destroy( ForwardIterator, ForwardIterator )
+		{
+		}
+		template < typename ForwardIterator >
+		inline static void destroy( ForwardIterator )
+		{
+		}
+	};
+
+	struct policy_initialize_standard
+	{
+		template < typename ForwardIterator >
+		inline static void initialize( ForwardIterator first, ForwardIterator last )
+		{
+			typedef typename iterator_traits< ForwardIterator >::value_type value_type;
+			if ( !has_trivial_constructor<value_type>() )
+				detail::uninitialized_construct_impl( first, last, false_type() );
+		}
+		template < typename InputIterator, typename ForwardIterator >
+		inline static ForwardIterator copy( InputIterator first, InputIterator last, ForwardIterator out )
+		{
+			return uninitialized_copy( first, last, out );
+		}
+		template < typename ForwardIterator >
+		inline static void destroy( ForwardIterator first, ForwardIterator last )
+		{
+			typedef typename iterator_traits< ForwardIterator >::value_type value_type;
+			if ( !has_trivial_destructor<value_type>() )
+				detail::uninitialized_destroy_impl( first, last, false_type() );
+		}
+		template < typename ForwardIterator >
+		inline static void destroy( ForwardIterator first )
+		{
+			typedef typename iterator_traits< ForwardIterator >::value_type value_type;
+			if ( !has_trivial_destructor<value_type>() )
+				destroy_object( first );
+		}
+	};
+
+	template< typename T >
+	class dynamic_storage
+	{
+	public:
+		typedef T      value_type;
+
+		static constexpr bool is_static = false;
+		static constexpr bool is_const = false;
+
+		constexpr const value_type* data() const { return reinterpret_cast<const value_type*>( m_data ); }
+		inline    value_type* data() { return reinterpret_cast<T*>( m_data ); }
+		constexpr const char* raw_data() const { return reinterpret_cast<const char*>( m_data ); }
+		inline    char* raw_data() { return reinterpret_cast<char*>( m_data ); }
+
+	protected:
+		constexpr dynamic_storage() : m_data( nullptr ) {}
+		// prevent copying 
+		dynamic_storage( const dynamic_storage& ) = delete;
+		dynamic_storage& operator=( const dynamic_storage& ) = delete;
+		// allow move
+		inline dynamic_storage( dynamic_storage&& other )
+			: m_data( other.m_data )
+		{
+			other.m_data = nullptr;
+		}
+		inline dynamic_storage& operator=( dynamic_storage&& other  )
+		{
+			if ( this != &other )
+			{
+				reallocate( 0, false );
+				m_data = other.m_data;
+			}
+			return *this;
+		}
+		~dynamic_storage() = default;
+
+		bool reallocate( size_t new_size, bool copy_needed )
+		{
+			if ( copy_needed )
+				m_data = (uint8*)nvrealloc( m_data, new_size * sizeof( value_type ) );
+			else
+			{
+				nvfree( m_data );
+				m_data = ( new_size > 0 ? (uint8*)nvmalloc( new_size * sizeof( value_type ) ) : nullptr );
+			}
+			return true; // TODO : alloc check?
+		}
+	protected:
+		uint8* m_data;
+	};
+
+	template< typename T, size_t N >
+	class static_storage
+	{
+	public:
+		typedef T      value_type;
+
+		static constexpr bool is_static = true;
+		static constexpr bool is_const = false;
+
+		constexpr const value_type* data() const { return reinterpret_cast<const value_type*>( m_data ); }
+		inline    value_type* data() { return reinterpret_cast<T*>( m_data ); }
+		constexpr const char* raw_data() const { return reinterpret_cast<const char*>( m_data ); }
+		inline    char* raw_data() { return reinterpret_cast<char*>( m_data ); }
+
+	protected:
+		static constexpr bool reallocate( size_t new_size, bool /*copy_needed*/ ) { return new_size <= N; }
+
+		static_storage() = default;
+
+		// prevent copying 
+		static_storage( const static_storage& ) = delete;
+		static_storage& operator=( const static_storage& ) = delete;
+		// allow move
+		static_storage( static_storage&& other ) = default;
+		static_storage& operator=( static_storage&& other ) = default;
+
+		~static_storage() = default;
+	protected:
+		typedef aligned_array_t<T, N, alignof( T ) > storage_type;
+		storage_type m_data;
+	};
+
+	template< typename Storage, size_t N >
+	class fixed_storage : public Storage
+	{
+	public:
+		typedef size_t                       size_type;
+		typedef typename Storage::value_type value_type;
+
+		static constexpr bool is_fixed = true;
+
+		fixed_storage()
+		{
+			Storage::reallocate( N, false );
+		}
+		~fixed_storage()
+		{
+			Storage::reallocate( 0, false );
+		}
+		static constexpr size_type max_size() { return N; }
+		static constexpr size_type capacity() { return N; }
+		static constexpr size_type size() { return N; }
+		static constexpr bool empty() { return N == 0; }
+		static constexpr size_type raw_size() { return sizeof( value_type ) * N; }
+
+		operator array_ref< value_type >()             { return array_ref< value_type >( Storage::data(), size() ); }
+		operator const_array_ref< value_type >() const { return const_array_ref< value_type >( Storage::data(), size() ); }
+
+		// allow move
+		fixed_storage( fixed_storage&& ) = default;
+		fixed_storage& operator=( fixed_storage&& ) = default;
+	};
+
+	template< typename Storage >
+	class resizable_storage : public Storage
+	{
+	public:
+		typedef size_t                       size_type;
+		typedef typename Storage::value_type value_type;
+
+		static constexpr bool is_fixed = false;
+
+		~resizable_storage()
+		{
+			if ( m_size > 0 ) reallocate( 0, false );
+		}
+		static constexpr size_type max_size() { return size_type( 0x80000000 ); }
+		constexpr size_t capacity() { return m_size; }
+		constexpr size_t size() const { return m_size; }
+		constexpr bool empty() const { return m_size == 0; }
+		constexpr size_t raw_size() const { return sizeof( value_type ) * m_size; }
+
+		operator array_ref< value_type >()             { return array_ref< value_type >( Storage::data(), size() ); }
+		operator const_array_ref< value_type >() const { return const_array_ref< value_type >( Storage::data(), size() ); }
+	protected:
+		constexpr resizable_storage() : m_size( 0 ) {}
+
+		// allow move
+		inline resizable_storage( resizable_storage&& other )
+			: Storage( nv::move( other ) ), m_size( other.m_size )
+		{
+			other.m_size = 0;
+		}
+		inline resizable_storage& operator=( resizable_storage&& other )
+		{
+			m_size = other.m_size;
+			Storage::operator=( nv::move( o ) );
+			other.m_size = 0;
+			return *this;
+		}
+
+		// TODO: return type error checking
+		bool try_resize( size_t new_size, bool copy_needed )
+		{
+			if ( new_size != m_size )
+			{
+				if ( reallocate( new_size, copy_needed ) )
+				{
+					m_size = new_size;
+					return true;
+				}
+				return false;
+			}
+			return true;
+		}
+	protected:
+		size_type m_size;
+	};
+
+	template< typename Storage, typename NextCapacity = default_next_capacity< size_t > >
+	class growable_storage : public Storage
+	{
+	public:
+		typedef size_t                       size_type;
+		typedef typename Storage::value_type value_type;
+
+		static constexpr bool is_fixed = false;
+
+		~growable_storage()
+		{
+			if ( m_capacity > 0 ) reallocate( 0, false );
+		}
+		static constexpr size_type max_size() { return size_type( 0x80000000 ); }
+		constexpr size_t capacity() { return m_capacity; }
+		constexpr size_t size() const { return m_size; }
+		constexpr bool empty() const { return m_size == 0; }
+		constexpr size_t raw_size() const { return sizeof( value_type ) * m_size; }
+
+		operator array_ref< value_type >()             { return array_ref< value_type >( Storage::data(), size() ); }
+		operator const_array_ref< value_type >() const { return const_array_ref< value_type >( Storage::data(), size() ); }
+	protected:
+		constexpr growable_storage() : m_size( 0 ), m_capacity( 0 ) {}
+
+		// allow move
+		inline growable_storage( growable_storage&& other )
+			: Storage( nv::move( other ) ), m_size( other.m_size ), m_capacity( other.m_capacity )
+		{
+			other.m_size     = 0;
+			other.m_capacity = 0;
+		}
+		inline growable_storage& operator=( growable_storage&& other )
+		{
+			m_size     = other.m_size;
+			m_capacity = other.m_capacity;
+			Storage::operator=( nv::move( other ) );
+			other.m_size     = 0;
+			other.m_capacity = 0;
+			return *this;
+		}
+
+		// TODO: return type error checking
+		bool try_grow( size_t amount )
+		{
+			size_type new_size = amount + m_size;
+			if ( new_size > m_capacity )
+			{
+				size_type new_capacity = NextCapacity::get( new_size - m_capacity, m_capacity, max_size() );
+				if ( new_capacity > 0 && reallocate( new_capacity, true ) )
+				{
+					m_capacity = new_capacity;
+					m_size = new_size;
+				}
+				else return false;
+			}
+			m_size = new_size;
+			return true;
+		}
+		// TODO: return type error checking
+		bool try_reserve( size_t new_capacity, bool copy_needed )
+		{
+			if ( new_capacity > m_capacity )
+			{
+				if ( reallocate( new_capacity, copy_needed ) )
+				{
+					m_capacity = new_capacity;
+				}
+				else return false;
+			}
+			return true;
+		}
+		// TODO: return type error checking
+		bool try_resize( size_t new_size, bool copy_needed )
+		{
+			if ( new_size > m_size )
+			{
+				if ( try_reserve( new_size, copy_needed ) )
+				{
+					m_size = new_size;
+					return true;
+				}
+				return false;
+			}
+			m_size = new_size;
+			return true;
+		}
+	protected:
+		size_type m_size;
+		size_type m_capacity;
+	};
+
+
+	template< typename T, size_t N >
+	using fixed_static_storage = fixed_storage< static_storage< T, N >, N >;
+
+	template< typename T, size_t N >
+	using fixed_dynamic_storage = fixed_storage< dynamic_storage< T >, N >;
+
+	template< typename T >
+	using resizable_dynamic_storage = resizable_storage< dynamic_storage< T > >;
+
+	template< typename T, size_t N >
+	using resizable_static_storage = resizable_storage< static_storage< T, N > >;
+
+	template< typename T >
+	using growable_dynamic_storage = growable_storage< dynamic_storage< T > >;
+
+	template< typename T, size_t N >
+	using growable_static_storage = growable_storage< static_storage< T, N > >;
+
+	template <
+		typename Storage,
+		typename InitializePolicy = policy_initialize_standard
+	>
+	class fixed_container_allocator : public Storage
+	{
+	public:
+		typedef typename Storage::value_type value_type;
+		typedef typename Storage::size_type  size_type;
+
+		fixed_container_allocator()
+		{
+			InitializePolicy::initialize( data(), data() + Storage::capacity() );
+		}
+
+		explicit fixed_container_allocator( default_init )
+		{
+			uninitialized_construct( data(), data() + Storage::capacity() );
+		}
+
+		explicit fixed_container_allocator( const value_type& v )
+		{
+			uninitialized_fill( data(), data() + Storage::capacity(), v );
+		}
+
+		~fixed_container_allocator()
+		{
+			InitializePolicy::destroy( data(), data() + Storage::capacity() );
+		}
+
+		// prevent copying 
+		fixed_container_allocator( const fixed_container_allocator& ) = delete;
+		fixed_container_allocator& operator=( const fixed_container_allocator& ) = delete;
+		// allow move
+		fixed_container_allocator( fixed_container_allocator&& ) = default;
+		fixed_container_allocator& operator=( fixed_container_allocator&& ) = default;
+	};
+
+	template <
+		typename Storage,
+		typename InitializePolicy = policy_initialize_standard
+	>
+	class sized_container_allocator : public Storage
+	{
+	public:
+		typedef typename Storage::value_type value_type;
+		typedef typename Storage::size_type  size_type;
+
+		inline sized_container_allocator() {}
+		inline explicit sized_container_allocator( size_type new_size ) { resize( new_size ); }
+		inline explicit sized_container_allocator( default_init ) { resize( default_init() ); }
+		inline sized_container_allocator( size_type new_size, const value_type& v ) { resize( new_size, v ); }
+
+		// prevent copying 
+		sized_container_allocator( const sized_container_allocator& ) = delete;
+		sized_container_allocator& operator=( const sized_container_allocator& ) = delete;
+		// allow move
+		sized_container_allocator( sized_container_allocator&& ) = default;
+		sized_container_allocator& operator=( sized_container_allocator&& ) = default;
+
+
+		inline void resize( size_type new_size )
+		{
+			size_type old_size = Storage::size();
+			resize_impl( new_size );
+			initialize_range( old_size, Storage::size() );
+		}
+
+		inline void resize( size_type new_size, default_init )
+		{
+			size_type old_size = Storage::size();
+			resize_impl( new_size );
+			initialize_range( old_size, Storage::size(), default_init() );
+		}
+
+		inline void resize( size_type new_size, const value_type& value )
+		{
+			size_type old_size = Storage::size();
+			resize_impl( new_size );
+			initialize_range( old_size, Storage::size(), value );
+		}
+
+		inline void assign( const value_type* ptr, size_type sz )
+		{
+			if ( Storage::size() > 0 ) InitializePolicy::destroy( Storage::data(), Storage::data() + Storage::size() );
+			if ( ptr != nullptr && sz > 0 )
+			{
+				if ( sz != Storage::size() && Storage::try_resize( sz, false ) )
+					InitializePolicy::copy( ptr, ptr + sz, Storage::data() );
+			}
+			else Storage::try_resize( 0, false );
+		}
+
+		template< typename InputIterator >
+		inline void assign( InputIterator first, InputIterator last )
+		{
+			size_type d = distance( first, last );
+			if ( d != Storage::size() && Storage::try_resize( sz, false ) )
+				InitializePolicy::copy( first, last, Storage::data() );
+		}
+
+		// explicit copy
+		inline void assign( const sized_container_allocator& other )
+		{
+			assign( other.data(), other.size() );
+		}
+
+		inline void clear()
+		{
+			if ( Storage::size() > 0 )
+			{
+				InitializePolicy::destroy( Storage::data(), Storage::data() + Storage::size() );
+				Storage::try_resize( 0, false );
+			}
+		}
+
+		~sized_container_allocator()
+		{
+			if ( Storage::size() > 0 ) clear();
+		}
+
+	protected:
+
+		inline void initialize_range( size_type old_size, size_type new_size )
+		{
+			if ( new_size > old_size ) InitializePolicy::initialize( Storage::data() + old_size, Storage::data() + new_size );
+		}
+		inline void initialize_range( size_type old_size, size_type new_size, default_init )
+		{
+			if ( new_size > old_size ) uninitialized_construct( Storage::data() + old_size, Storage::data() + new_size );
+		}
+		inline void initialize_range( size_type old_size, size_type new_size, const value_type& value )
+		{
+			if ( new_size > old_size ) uninitialized_fill( Storage::data() + old_size, Storage::data() + new_size, value );
+		}
+		inline void resize_impl( size_type new_size )
+		{
+			size_type old_size = Storage::size();
+			if ( new_size != old_size )
+			{
+				if ( new_size < old_size )
+				{
+					InitializePolicy::destroy( Storage::data() + new_size, Storage::data() + old_size );
+				}
+				if ( Storage::try_resize( new_size, true ) )
+				{
+					// TODO: error checking
+				}
+			}
+		}
+
+	};
+
+	template <
+		typename Storage,
+		typename InitializePolicy = policy_initialize_standard
+	>
+	class growing_container_allocator : public sized_container_allocator< Storage, InitializePolicy >
+	{
+		typedef sized_container_allocator< Storage, InitializePolicy > inherited;
+	public:
+		typedef typename Storage::value_type value_type;
+		typedef typename Storage::size_type  size_type;
+
+		using sized_container_allocator< Storage, InitializePolicy >::sized_container_allocator;
+
+		void reserve( size_type new_capacity )
+		{
+			Storage::try_reserve( new_capacity, true );
+		}
+		void push_back( const value_type& e )
+		{
+			if ( Storage::try_grow( 1 ) ) copy_construct_object( data() + size() - 1, e );
+		}
+		void push_back( value_type&& e )
+		{
+			if ( Storage::try_grow( 1 ) ) move_construct_object( data() + size() - 1, forward<value_type>( e ) );
+		}
+		template < typename... Args >
+		void emplace_back( Args&&... args )
+		{
+			if ( Storage::try_grow( 1 ) ) construct_object( data() + size() - 1, forward<Args>( args )... );
+		}
+		void pop_back()
+		{
+			try_resize( size() - 1, true );
+		}
+
+	};
+
 
 	template < typename ContainerAllocator >
-	using array_base = detail::add_random_access< detail::add_iterators < ContainerAllocator > >;
-
+	using array_base_t = detail::add_random_access< detail::add_iterators < ContainerAllocator > >;
 
 	template< typename T, size_t N >
-	using array = array_base < fixed_container_allocator < fixed_static_storage< T, N > > >;
+	using array = array_base_t < fixed_container_allocator < fixed_static_storage< T, N > > >;
 	
 	template< typename T >
-	using dynamic_array = array_base < sized_container_allocator< resizable_dynamic_storage< T > > >;
+	using dynamic_array = array_base_t < sized_container_allocator< resizable_dynamic_storage< T > > >;
+
+	template< typename T >
+	using vector = array_base_t < growing_container_allocator< growable_dynamic_storage< T > > >;
 
 // 	template < typename T, typename ContainerAllocator >
Index: /trunk/nv/stl/array2d.hh
===================================================================
--- /trunk/nv/stl/array2d.hh	(revision 382)
+++ /trunk/nv/stl/array2d.hh	(revision 383)
@@ -95,5 +95,5 @@
 					for ( sint32 i = 0; i < min(new_size.y, m_size.y); i++ )
 					{
-						std::copy( m_data + m_size.x * i, m_data + m_size.x * i + min( new_size.x, m_size.x ), new_data + m_size.x * i );
+						raw_copy_n( m_data + m_size.x * i, nv::min( new_size.x, m_size.x ), new_data + m_size.x * i );
 					}
 				}
@@ -193,5 +193,5 @@
 			for ( sint32 i = 0; i < m_size.y; i++ )
 			{
-				std::copy( m_data + m_size.x * i, m_data + m_size.x * i + m_size.x, m_size.x * i );
+				raw_copy_n( m_data + m_size.x * i, m_size.x, m_size.x * i );
 			}
 			return temp;
@@ -229,5 +229,5 @@
 				// Destination is the start of the destination row.
 				//         Start                              End                                         Destination
-				std::copy( m_data + m_size().x * i + start_x, m_data + m_size().x * i + start_x + size_x, temp.m_data + temp.m_size().x * ( i - start_y ) );
+				raw_copy_n( m_data + m_size().x * i + start_x, size_x, temp.m_data + temp.m_size().x * ( i - start_y ) );
 			}
 			return temp;
@@ -331,6 +331,7 @@
 				// The end position is either the size limit or the end of either array, whichever is smaller.
 				// Destination start is the beginning of the current destination row (which is dest_start_y + i), offset by dest_start_x.
-				std::copy( source.m_data + ( source_start_y + i ) * source.m_size.x + source_start_x,  // Source Start
-						  source.m_data + ( source_start_y + i ) * source.m_size.x + min( source.m_size.x, min( source_start_x + size_x, source_start_x + m_size.x - dest_start_x ) ), // Source End
+				pointer base = source.m_data + ( source_start_y + i ) * source.m_size.x;
+				raw_copy( base + source_start_x,  // Source Start
+						  base + min( source.m_size.x, min( source_start_x + size_x, source_start_x + m_size.x - dest_start_x ) ), // Source End
 						  m_data + (dest_start_y + i) * m_size.x + dest_start_x ); // Destination Start
 			}
Index: /trunk/nv/stl/capi.hh
===================================================================
--- /trunk/nv/stl/capi.hh	(revision 382)
+++ /trunk/nv/stl/capi.hh	(revision 383)
@@ -73,5 +73,5 @@
 	inline void nvfree( void* p )
 	{
-		NV_CAPI_CALL( free )( p );
+		if ( p ) NV_CAPI_CALL( free )( p );
 	}
 
Index: /trunk/nv/stl/flags.hh
===================================================================
--- /trunk/nv/stl/flags.hh	(revision 382)
+++ /trunk/nv/stl/flags.hh	(revision 383)
@@ -16,5 +16,5 @@
 #include <nv/core/common.hh>
 #include <nv/stl/traits/transforms.hh>
-#include <nv/stl/array.hh>
+#include <nv/stl/algorithm.hh>
 
 namespace nv
@@ -144,10 +144,10 @@
 		void assign( const data_type* a_data )
 		{
-			std::copy( a_data, a_data + data_size, m_data );
+			raw_copy_n( a_data, data_size, m_data );
 		}
 
 		void reset()
 		{
-			std::fill( m_data, m_data + data_size, 0 );
+			raw_zero_n( m_data, data_size );
 		}
 
Index: /trunk/nv/stl/handle.hh
===================================================================
--- /trunk/nv/stl/handle.hh	(revision 382)
+++ /trunk/nv/stl/handle.hh	(revision 383)
@@ -43,5 +43,6 @@
 		bool is_valid() const { return !is_nil(); }
 		T index() const { return m_index; }
-		size_t hash() const { return std::hash<T>()( T( m_counter << IBITS | m_index ) ); }
+		//size_t hash() const { return std::hash<T>()( T( m_counter << IBITS | m_index ) ); }
+		size_t hash() const { NV_ASSERT( false, "UNIMPLEMENTED!" ); return 0; }
 	protected:
 		T m_index   : IBITS;
@@ -139,5 +140,5 @@
 		index_type m_first_free;
 		index_type m_last_free;
-		std::vector< index_entry > m_entries;
+		vector< index_entry > m_entries;
 	};
 
@@ -146,8 +147,8 @@
 	{
 	public:
-		typedef HANDLE                   handle;
-		typedef TINDEX                   index_type;
-		typedef std::vector< T >         storage;
-		typedef T                        value_type;
+		typedef HANDLE              handle;
+		typedef TINDEX              index_type;
+		typedef vector< T >         storage;
+		typedef T                   value_type;
 		typedef typename storage::iterator        iterator;
 		typedef typename storage::const_iterator  const_iterator;
@@ -241,7 +242,7 @@
 		}
 
-		std::vector< T >          m_data;
-		std::vector< handle >     m_handles;
-		std::vector< index_type > m_indexes;
+		vector< T >          m_data;
+		vector< handle >     m_handles;
+		vector< index_type > m_indexes;
 	};
 
@@ -251,8 +252,8 @@
 	{
 	public:
-		typedef HANDLE                   handle;
-		typedef TINDEX                   index_type;
-		typedef std::vector< T >         storage;
-		typedef T                        value_type;
+		typedef HANDLE      handle;
+		typedef TINDEX      index_type;
+		typedef vector< T > storage;
+		typedef T           value_type;
 		typedef typename storage::iterator        iterator;
 		typedef typename storage::const_iterator  const_iterator;
@@ -315,20 +316,3 @@
 }
 
-namespace std
-{
-	template < 
-		typename T, 
-		unsigned IBITS,
-		unsigned CBITS,
-		typename TAG
-	>
-	struct hash<nv::handle<T,IBITS,CBITS,TAG>>
-	{
-		size_t operator()(const nv::handle<T,IBITS,CBITS,TAG>& h) const
-		{
-			return h.hash();
-		}
-	};
-}
-
 #endif // NV_CORE_HANDLE_HH
Index: /trunk/nv/stl/memory.hh
===================================================================
--- /trunk/nv/stl/memory.hh	(revision 382)
+++ /trunk/nv/stl/memory.hh	(revision 383)
@@ -72,5 +72,4 @@
 		static constexpr bool is_fixed    = false;
 		static constexpr bool is_const    = false;
-		static constexpr size_t type_size = sizeof( value_type );
 
 		constexpr storage_view() 
@@ -106,5 +105,4 @@
 		static constexpr bool is_fixed    = false;
 		static constexpr bool is_const    = true;
-		static constexpr size_t type_size = sizeof( value_type );
 
 		constexpr const_storage_view()
@@ -112,4 +110,6 @@
 		constexpr const_storage_view( const value_type* a_data, size_type a_size )
 			: m_data( a_data ), m_size( a_size ) {}
+		constexpr const_storage_view( const storage_view<T>& view )
+			: m_data( view.data() ), m_size( view.size() ) {}
 
 		void assign( const value_type* a_data, size_type a_size )
@@ -142,8 +142,32 @@
 	}
 
+	template < typename T >
+	inline void raw_move_construct_object( void* object, T&& original )
+	{
+		new ( object )T( move( original ) );
+	}
+
+	template < typename T >
+	inline void raw_copy_construct_object( void* object, const T& original )
+	{
+		new ( object )T( original );
+	}
+
 	template < typename T, typename ...Args >
 	inline void construct_object( T* object, Args&&... params )
 	{
 		new ( object )T( forward<Args>( params )... );
+	}
+
+	template < typename T >
+	inline void move_construct_object( T* object, T&& original )
+	{
+		new ( object )T( move( original ) );
+	}
+
+	template < typename T >
+	inline void copy_construct_object( T* object, const T& original )
+	{
+		new ( object )T( original );
 	}
 
@@ -257,8 +281,8 @@
 		inline ForwardIterator uninitialized_copy_impl( InputIterator first, InputIterator last, ForwardIterator out, false_type )
 		{
-			typedef typename std::iterator_traits<ForwardIterator>::value_type value_type;
+			typedef typename iterator_traits<ForwardIterator>::value_type value_type;
 			InputIterator src( first );
 			ForwardIterator dest( out );
-			for ( ; first != last; ++src, ++dest )
+			for ( ; src != last; ++src, ++dest )
 			{
 				::new ( static_cast<void*>( addressof( *dest ) ) ) value_type( *src );
@@ -276,5 +300,5 @@
 		inline ForwardIterator uninitialized_copy_n_impl( InputIterator first, size_t count, ForwardIterator out, false_type )
 		{
-			typedef typename std::iterator_traits<ForwardIterator>::value_type value_type;
+			typedef typename iterator_traits<ForwardIterator>::value_type value_type;
 			InputIterator src( first );
 			ForwardIterator dest( out );
@@ -289,5 +313,5 @@
 		inline ForwardIterator uninitialized_copy_n_impl( InputIterator first, size_t count, ForwardIterator out, true_type )
 		{
-			typedef typename std::iterator_traits<ForwardIterator>::value_type value_type;
+			typedef typename iterator_traits<ForwardIterator>::value_type value_type;
 			return ForwardIterator( nvmemmove( out, first, count * sizeof( value_type ) ) );
 		}
@@ -299,5 +323,5 @@
 	{
 		typedef typename iterator_traits< ForwardIterator >::value_type value_type;
-		detail::uninitialized_fill_impl( first, last, value, has_trivial_assign<value_type>() );
+		detail::uninitialized_fill_impl( first, last, value, has_trivial_destructor<value_type>() );
 	}
 
@@ -306,5 +330,5 @@
 	{
 		typedef typename iterator_traits< ForwardIterator >::value_type value_type;
-		return detail::uninitialized_fill_n_impl( first, count, value, has_trivial_assign<value_type>() );
+		return detail::uninitialized_fill_n_impl( first, count, value, has_trivial_destructor<value_type>() );
 	}
 
@@ -322,5 +346,5 @@
 	{
 		typedef typename iterator_traits< ForwardIterator >::value_type value_type;
-		detail::uninitialized_construct_impl( first, last, has_trivial_constructor<value_type>() );
+		detail::uninitialized_construct_impl( first, last, has_trivial_destructor<value_type>() );
 	}
 
@@ -329,5 +353,5 @@
 	{
 		typedef typename iterator_traits< ForwardIterator >::value_type value_type;
-		return detail::uninitialized_construct_n_impl( first, count, has_trivial_constructor<value_type>() );
+		return detail::uninitialized_construct_n_impl( first, count, has_trivial_destructor<value_type>() );
 	}
 
@@ -428,4 +452,6 @@
 			typedef const value_type&                    const_reference;
 
+			using Super::Super;
+
 			inline const_reference front() const { NV_ASSERT( !Super::empty(), "front() called on empty data!" ); return Super::data()[0]; }
 			inline const_reference back() const { NV_ASSERT( !Super::empty(), "front() called on empty data!" ); return Super::data()[Super::size() - 1]; }
@@ -449,4 +475,6 @@
 			typedef const value_type&                    const_reference;
 
+			using Super::Super;
+
 			inline reference       front() { NV_ASSERT( !Super::empty(), "front() called on empty data!" );  return Super::data()[0]; }
 			inline const_reference front() const { NV_ASSERT( !Super::empty(), "front() called on empty data!" ); return Super::data()[0]; }
@@ -475,312 +503,10 @@
 	}
 
-	class const_mem_ref : public detail::add_iterators< const_storage_view< char > >
-	{
-		typedef detail::add_iterators< const_storage_view< char > > inherited;
-	public:
-		typedef char                 value_type;
-		typedef value_type*          pointer;
-		typedef const value_type*    const_pointer;
-		typedef value_type&		     reference;
-		typedef const value_type&    const_reference;
-		typedef size_t	             size_type;
-		typedef ptrdiff_t            difference_type;
-		typedef const_pointer        const_iterator;
-	public:
-		inline const_mem_ref() : inherited() {}
-		inline const_mem_ref( const void* p, size_type n ) : inherited( (const char*)p, n ) {}
-		inline const_mem_ref( const const_mem_ref& l ) : inherited( l.data(), l.size() ) {}
-	};
-
-	class mem_ref : public detail::add_iterators< storage_view< char > >
-	{
-		typedef detail::add_iterators< storage_view< char > > inherited;
-	public:
-		typedef char                 value_type;
-		typedef value_type*          pointer;
-		typedef const value_type*    const_pointer;
-		typedef value_type&		     reference;
-		typedef const value_type&    const_reference;
-		typedef size_t	             size_type;
-		typedef ptrdiff_t            difference_type;
-		typedef pointer              iterator;
-		typedef const_pointer        const_iterator;
-	public:
-		inline mem_ref() : inherited() {}
-		inline mem_ref( void* p, size_type n ) : inherited( (char*)p, n ) {}
-		inline mem_ref( const mem_ref& l ) : inherited( const_cast< char* >( l.data() ), l.size() ) {}
-	};
-
-	template< typename SizeType >
-	struct default_next_capacity
-	{
-		static SizeType get( SizeType requested, SizeType capacity )
-		{
-			SizeType additional = nv::max( requested, capacity );
-			return capacity + additional;
-		}
-	};
-
-	struct policy_initialize_always
-	{
-		template < typename ForwardIterator >
-		static void initialize( ForwardIterator first, ForwardIterator last )
-		{
-			typedef typename iterator_traits< ForwardIterator >::value_type value_type;
-			uninitialized_construct( first, last, value_type() );
-		}
-		template < typename InputIterator, typename ForwardIterator >
-		static ForwardIterator copy( InputIterator first, InputIterator last, ForwardIterator out )
-		{
-			return uninitialized_copy( first, last, out );
-		}
-		template < typename ForwardIterator >
-		static void destroy( ForwardIterator first, ForwardIterator last )
-		{
-			uninitialized_destroy( first, last );
-		}
-	};
-
-	struct policy_initialize_never
-	{
-		template < typename ForwardIterator >
-		static void initialize( ForwardIterator, ForwardIterator )
-		{
-		}
-		template < typename InputIterator, typename ForwardIterator >
-		static ForwardIterator copy( InputIterator first, InputIterator last, ForwardIterator out )
-		{
-			return detail::uninitialized_copy( first, last, out, true_type );
-		}
-		template < typename ForwardIterator >
-		static void destroy( ForwardIterator, ForwardIterator )
-		{
-		}
-	};
-
-	struct policy_initialize_standard
-	{
-		template < typename ForwardIterator >
-		static void initialize( ForwardIterator first, ForwardIterator last )
-		{
-			typedef typename iterator_traits< ForwardIterator >::value_type value_type;
-			if ( !has_trivial_constructor<value_type>() )
-				detail::uninitialized_construct_impl( first, last, false_type() );
-		}
-		template < typename InputIterator, typename ForwardIterator >
-		static ForwardIterator copy( InputIterator first, InputIterator last, ForwardIterator out )
-		{
-			return uninitialized_copy( first, last, out );
-		}
-		template < typename ForwardIterator >
-		static void destroy( ForwardIterator first, ForwardIterator last )
-		{
-			typedef typename iterator_traits< ForwardIterator >::value_type value_type;
-			if ( !has_trivial_destructor<value_type>() )
-				detail::uninitialized_destroy_impl( first, last, false_type() );
-		}
-	};
-
-	template< typename T >
-	class dynamic_storage
-	{
-	public:
-		typedef T      value_type;
-
-		static constexpr bool is_static   = false;
-		static constexpr bool is_const    = false;
-		static constexpr size_t type_size = sizeof( value_type );
-
-		constexpr dynamic_storage() : m_data( nullptr ) {}
-
-		constexpr const value_type* data() const { return reinterpret_cast<const value_type*>( m_data ); }
-		inline    value_type* data() { return reinterpret_cast<T*>( m_data ); }
-		constexpr const char* raw_data() const { return reinterpret_cast<const char*>( m_data ); }
-		inline    char* raw_data() { return reinterpret_cast<char*>( m_data ); }
-	protected:
-		bool reallocate( size_t new_size )
-		{
-			if ( m_data != 0 || new_size != 0 )
-				m_data = (uint8*)nvrealloc( m_data, new_size * sizeof( value_type ) );
-			return true; // TODO : alloc check?
-		}
-	protected:
-		uint8* m_data;
-	};
-
-	template< typename T, size_t N >
-	class static_storage
-	{
-	public:
-		typedef T      value_type;
-
-		static constexpr bool is_static   = true;
-		static constexpr bool is_const    = false;
-		static constexpr size_t type_size = sizeof( value_type );
-
-		constexpr const value_type* data() const { return reinterpret_cast<const value_type*>( m_data ); }
-		inline    value_type* data() { return reinterpret_cast<T*>( m_data ); }
-		constexpr const char* raw_data() const { return reinterpret_cast<const char*>( m_data ); }
-		inline    char* raw_data() { return reinterpret_cast<char*>( m_data ); }
-	protected:
-		static constexpr bool reallocate( size_t new_size ) { return new_size <= N; }
-	protected:
-		typedef aligned_array_t<T, N, alignof( T ) > storage_type;
-		storage_type m_data;
-	};
-
-	template< typename Storage, size_t N >
-	class fixed_storage : public Storage
-	{
-	public:
-		typedef size_t size_type;
-
-		static constexpr bool is_fixed = true;
-
-		fixed_storage()
-		{
-			Storage::reallocate( N );
-		}
-		~fixed_storage()
-		{
-			Storage::reallocate( 0 );
-		}
-		static constexpr size_t capacity() { return N; }
-		static constexpr size_t size() { return N; }
-		static constexpr bool empty() { return N != 0; }
-		static constexpr size_t raw_size() { return sizeof( T ) * N; }
-	};
-
-	template< typename Storage >
-	class resizable_storage : public Storage
-	{
-	public:
-		typedef size_t size_type;
-
-		static constexpr bool is_fixed = false;
-
-		~resizable_storage()
-		{
-			if ( m_size > 0 ) reallocate( 0 );
-		}
-		constexpr size_t capacity() { return m_size; }
-		constexpr size_t size() const { return m_size; }
-		constexpr bool empty() const { return m_size != 0; }
-		constexpr size_t raw_size() const { return sizeof( value_type ) * m_size; }
-	protected:
-		constexpr resizable_storage() : m_size( 0 ) {}
-		// TODO: return type error checking
-		bool resize( size_t new_size )
-		{
-			if ( new_size != m_size )
-			{
-				m_size = new_size;
-				return reallocate( m_size );
-			}
-			return true;
-		}
-	protected:
-		size_type m_size;
-	};
-
-
-	template< typename T, size_t N >
-	using fixed_static_storage  = fixed_storage< static_storage< T, N >, N >;
-
-	template< typename T, size_t N >
-	using fixed_dynamic_storage = fixed_storage< dynamic_storage< T >, N >;
-
-	template< typename T >
-	using resizable_dynamic_storage = resizable_storage< dynamic_storage< T > >;
-
-// TODO:
-//	template< typename T, size_t N >
-//	using resizable_static_storage  = resizable_storage< static_storage< T, N > >;
-
-// TODO:
-//	template< typename Storage, typename NextCapacity = default_next_capacity >
-//	class growable_storage : Storage;
-
-	template <
-		typename Storage,
-		typename InitializePolicy = policy_initialize_standard
-	>
-	class fixed_container_allocator : public Storage
-	{
-	public:
-		typedef typename Storage::value_type value_type;
-		typedef typename Storage::size_type  size_type;
-
-		fixed_container_allocator()
-		{
-			InitializePolicy::initialize( data(), data() + Storage::capacity() );
-		}
-
-		~fixed_container_allocator()
-		{
-			InitializePolicy::destroy( data(), data() + Storage::capacity() );
-		}
-	};
-
-	template <
-		typename Storage,
-		typename InitializePolicy = policy_initialize_standard
-	>
-	class sized_container_allocator : public Storage
-	{
-	public:
-		typedef typename Storage::value_type value_type;
-		typedef typename Storage::size_type  size_type;
-
-		sized_container_allocator() {}
-		explicit sized_container_allocator( size_type new_size ) { resize( new_size ); }
-
-		void resize( size_type new_size )
-		{
-			size_type old_size = Storage::size();
-			if ( new_size != old_size )
-			{
-				if ( new_size < old_size )
-				{
-					InitializePolicy::destroy( Storage::data() + new_size, Storage::data() + old_size );
-				}
-				Storage::resize( new_size );
-				if ( new_size > old_size )
-				{
-					InitializePolicy::initialize( Storage::data() + old_size, Storage::data() + new_size );
-				}
-			}
-		}
-
-		void assign( const value_type* ptr, size_type sz )
-		{
-			if ( Storage::size() > 0 ) InitializePolicy::destroy( Storage::data(), Storage::data() + Storage::size() );
-			if ( ptr != nullptr && sz > 0 )
-			{
-				if ( sz != Storage::size() )
-				{
-					Storage::resize( 0 );
-					Storage::resize( sz );
-				}
-				InitializePolicy::copy( ptr, ptr + sz, Storage::data() );
-			}
-			else Storage::resize( 0 );
-		}
-
-		void clear()
-		{
-			if ( Storage::size() > 0 )
-			{
-				InitializePolicy::destroy( Storage::data(), Storage::data() + Storage::size() );
-				Storage::resize( 0 );
-			}
-		}
-
-		~sized_container_allocator()
-		{
-			if ( Storage::size() > 0 ) clear();
-		}
-
-	};
+	template < typename T > 
+	using const_array_ref = detail::add_random_access< detail::add_iterators < const_storage_view< T > > >;
+	template < typename T >
+	using array_ref       = detail::add_random_access< detail::add_iterators < storage_view< T > > >;
+	using const_mem_ref = const_array_ref< char >;
+	using mem_ref       = array_ref< char >;
 
 }
Index: /trunk/nv/stl/range.hh
===================================================================
--- /trunk/nv/stl/range.hh	(revision 382)
+++ /trunk/nv/stl/range.hh	(revision 383)
@@ -15,6 +15,6 @@
 #include <nv/core/common.hh>
 #include <nv/stl/math.hh>
+#include <nv/stl/iterator.hh>
 #include <nv/stl/traits/transforms.hh>
-#include <iterator>
 
 namespace nv
@@ -25,5 +25,5 @@
 
 		template < typename T >
-		class forward_iterator_base : public std::iterator< std::input_iterator_tag, T >
+		class forward_iterator_base : public iterator< input_iterator_tag, T >
 		{
 		public:
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 ) )
 	{
