Index: /trunk/nv/base/common.hh
===================================================================
--- /trunk/nv/base/common.hh	(revision 405)
+++ /trunk/nv/base/common.hh	(revision 406)
@@ -162,5 +162,5 @@
 #endif
 
-#define NV_COUNT_OF(x) ((sizeof(x)/sizeof(0[x])) / ((nv::size_t)(!(sizeof(x) % sizeof(0[x])))))
+#define NV_COUNT_OF(x) ((sizeof(x)/sizeof(0[x])) / (static_cast<nv::size_t>(!(sizeof(x) % sizeof(0[x])))))
 #define NV_SAFE_ARRAY( arr, idx, def ) ( index < NV_COUNT_OF(arr) ? (arr)[idx] : (def) )
 
@@ -186,4 +186,5 @@
 namespace nv
 {
+
 	template < typename T >
 	struct static_assert_fail
@@ -263,4 +264,28 @@
 	}
 
+	template< typename T >
+	void void_assign( T*& out, void* in )
+	{
+		out = reinterpret_cast<T*>( in );
+	}
+
+	enum log_level
+	{
+		LOG_NONE = 0,
+		LOG_FATAL = 10,
+		LOG_CRITICAL = 20,
+		LOG_ERROR = 30,
+		LOG_WARNING = 40,
+		LOG_NOTICE = 50,
+		LOG_INFO = 60,
+		LOG_DEBUG = 80,
+		LOG_TRACE = 100
+	};
+
+	using log_handler_t = void( *)( int, const char*, size_t );
+
+	log_handler_t get_log_handler();
+	void set_log_handler( log_handler_t );
+
 } // namespace nv
 
Index: /trunk/nv/core/logging.hh
===================================================================
--- /trunk/nv/core/logging.hh	(revision 405)
+++ /trunk/nv/core/logging.hh	(revision 406)
@@ -21,17 +21,4 @@
 namespace nv
 {
-
-	enum log_level
-	{
-		LOG_NONE     = 0,
-		LOG_FATAL    = 10,
-		LOG_CRITICAL = 20,
-		LOG_ERROR    = 30,
-		LOG_WARNING  = 40,
-		LOG_NOTICE   = 50,
-		LOG_INFO     = 60,
-		LOG_DEBUG    = 80,
-		LOG_TRACE    = 100
-	};
 
 	class logger_base : public singleton< logger_base >
@@ -90,10 +77,10 @@
 		inline void log_sequence( log_level level, T&& t, Args&&... args )
 		{
-			log_append( t );
-			log_sequence( level, nv::forward<Args>( args )... );
+			this->log_append( t );
+			this->log_sequence( level, nv::forward<Args>( args )... );
 		}
 		virtual ~logger_base() {}
 	protected:
-		char m_message[256];
+		char m_message[1024];
 		char* m_pos;
 		unsigned int m_level;
Index: /trunk/nv/gfx/animation.hh
===================================================================
--- /trunk/nv/gfx/animation.hh	(revision 405)
+++ /trunk/nv/gfx/animation.hh	(revision 406)
@@ -57,5 +57,5 @@
 			if ( count == 0 ) return 0;
 			uint32 keyfsize   = desc.size / 4;
-			const float* fdata = ((const float*)data) + keyfsize * index;
+			const float* fdata = reinterpret_cast<const float*>( data ) + keyfsize * index;
 			uint32 mod        = 0;
 			if ( desc.slots[0].vslot == animation_slot::TIME ) mod = 1;
@@ -69,5 +69,5 @@
 			uint32 keyfsize   = desc.size / 4;
 			uint32 keyfresult = keyfsize;
-			const float* fdata = (const float*)data;
+			const float* fdata = reinterpret_cast<const float*>( data );
 
 			uint32 slot = 0;
@@ -87,10 +87,14 @@
 				for ( unsigned i = 1 ; i < count ; i++ )
 				{
-					if ( time < fdata[ i * keyfsize ] ) { index0 = (int)i - 1; break; }
+					if ( time < fdata[ i * keyfsize ] ) 
+					{
+						index0 = static_cast<int>(i) - 1; 
+						break;
+					}
 				}
 				NV_ASSERT( index0 >= 0, "animation time fail!");
 				index1 = index0 + 1;
-				float time0  = fdata[ index0 * (int)keyfsize ];
-				float time1  = fdata[ index1 * (int)keyfsize ];
+				float time0  = fdata[ index0 * static_cast<int>( keyfsize ) ];
+				float time1  = fdata[ index1 * static_cast<int>( keyfsize ) ];
 				float delta  = time1 - time0;
 				factor = glm::clamp( (time - time0) / delta, 0.0f, 1.0f );
@@ -103,5 +107,5 @@
 					return keyfresult;
 				}
-				index0 = glm::clamp<int>( (int) time, 0, (int)count - 2 );
+				index0 = glm::clamp<int>( int( time ), 0, int( count ) - 2 );
 				index1 = index0 + 1;
 				factor = glm::clamp<float> ( time - index0, 0.0f, 1.0f );
@@ -112,6 +116,6 @@
 				ret += nv::interpolate_raw( 
 					desc.slots[slot], factor, 
-					fdata + index0 * (int)keyfsize + desc.slots[slot].offset / 4,
-					fdata + index1 * (int)keyfsize + desc.slots[slot].offset / 4,
+					fdata + index0 * static_cast<int>( keyfsize ) + desc.slots[slot].offset / 4,
+					fdata + index1 * static_cast<int>( keyfsize ) + desc.slots[slot].offset / 4,
 					result + ret );
 			}
@@ -225,10 +229,10 @@
 			if ( m_data->count == 1 ) 
 			{
-				result = ((KEY*)m_data->data)[0];
+				result = reinterpret_cast<KEY*>(m_data->data)[0];
 				return;
 			}
 			size_t index = glm::clamp<size_t>( size_t( frame ), 0, m_data->count - 2 );
 			float factor = glm::clamp<float> ( frame - index, 0.0f, 1.0f );
-			KEY* keys = ((KEY*)m_data->data);
+			KEY* keys = reinterpret_cast<KEY*>( m_data->data );
 			interpolate_key( result, keys[index], keys[index+1], factor );
 		}
@@ -254,5 +258,5 @@
 		{
 			// TODO: this probably could be optimized
-			const KEY* keys = (const KEY*)(m_data->data);
+			const KEY* keys = reinterpret_cast<const KEY*>(m_data->data);
 			NV_ASSERT( m_data, "Data is null!" );
 			if ( m_data->count == 0 ) return;
@@ -263,5 +267,5 @@
 			}
 			int index = -1;
-			for ( int i = 0 ; i < (int)m_data->count - 1 ; i++ )
+			for ( int i = 0 ; i < int( m_data->count ) - 1 ; i++ )
 			{
 				if ( time < keys[i + 1].time ) { index = i; break; }
@@ -375,6 +379,6 @@
 		bool empty() const { return m_channel->count == 0; }
 		size_t size() const { return m_channel->count; }
-		const transform& get( size_t index ) const { return ((key*)(m_channel->data))[ index ].tform; }
-		const transform* data() const { return (const transform*)m_channel->data; }
+		const transform& get( size_t index ) const { return reinterpret_cast<key*>(m_channel->data)[ index ].tform; }
+		const transform* data() const { return reinterpret_cast<const transform*>( m_channel->data ); }
 
 		virtual uint32 raw_size() const 
Index: /trunk/nv/gfx/sliced_buffer.hh
===================================================================
--- /trunk/nv/gfx/sliced_buffer.hh	(revision 405)
+++ /trunk/nv/gfx/sliced_buffer.hh	(revision 406)
@@ -112,5 +112,5 @@
 			if ( !m_full_update && resized )
 			{
-				m_data.erase( m_data.begin() + (int)offset, m_data.end() );
+				m_data.erase( m_data.begin() + int( offset ), m_data.end() );
 				m_min = nv::min<size_t>( m_min, offset );
 				m_full_update = true;
@@ -124,5 +124,5 @@
 			{
 //				raw_copy( bv.cbegin(), bv.cend(), m_data.begin() + (int)offset );
-				raw_copy( bv.data(), bv.data() + bv.size(), m_data.data() + (int)offset );
+				raw_copy( bv.data(), bv.data() + bv.size(), m_data.data() + int( offset ) );
 				m_min = nv::min<size_t>( m_min, offset );
 				m_max = nv::max<size_t>( m_max, offset + bv.size() );
@@ -157,5 +157,5 @@
 		{
 			bool result = false;
-			size_t bsize = (size_t)get_max_size();
+			size_t bsize = get_max_size();
 			if ( m_data.size() > bsize )
 			{
Index: /trunk/nv/gl/gl_context.hh
===================================================================
--- /trunk/nv/gl/gl_context.hh	(revision 405)
+++ /trunk/nv/gl/gl_context.hh	(revision 406)
@@ -49,5 +49,5 @@
 		virtual void bind( texture t, texture_slot slot );
 
-		virtual void update( texture t, void* data );
+		virtual void update( texture t, const void* data );
 		virtual void update( buffer b, const void* data, size_t offset, size_t size );
 
Index: /trunk/nv/gl/gl_device.hh
===================================================================
--- /trunk/nv/gl/gl_device.hh	(revision 405)
+++ /trunk/nv/gl/gl_device.hh	(revision 406)
@@ -46,5 +46,5 @@
 		virtual program create_program( string_view vs_source, string_view fs_source );
 		virtual buffer create_buffer( buffer_type type, buffer_hint hint, size_t size, const void* source = nullptr );
-		virtual texture create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, void* data = nullptr );
+		virtual texture create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, const void* data = nullptr );
 
 		virtual void release( buffer b );
Index: /trunk/nv/gui/gui_ascii_renderer.hh
===================================================================
--- /trunk/nv/gui/gui_ascii_renderer.hh	(revision 405)
+++ /trunk/nv/gui/gui_ascii_renderer.hh	(revision 406)
@@ -45,3 +45,3 @@
 } // namespace nv
 
-#endif // NV_GUI_RENDERER_HH
+#endif // NV_ASCII_RENDERER_HH
Index: /trunk/nv/gui/gui_renderer.hh
===================================================================
--- /trunk/nv/gui/gui_renderer.hh	(revision 405)
+++ /trunk/nv/gui/gui_renderer.hh	(revision 406)
Index: /trunk/nv/interface/animation_key.hh
===================================================================
--- /trunk/nv/interface/animation_key.hh	(revision 405)
+++ /trunk/nv/interface/animation_key.hh	(revision 406)
@@ -193,5 +193,5 @@
 	struct key_descriptor
 	{
-		key_descriptor_slot slots[ (uint16)animation_slot::SLOT_MAX_STORE ];
+		key_descriptor_slot slots[ uint16( animation_slot::SLOT_MAX_STORE ) ];
 		uint32              count;
 		uint32              size;
Index: /trunk/nv/interface/context.hh
===================================================================
--- /trunk/nv/interface/context.hh	(revision 405)
+++ /trunk/nv/interface/context.hh	(revision 406)
@@ -102,5 +102,5 @@
 		virtual void bind( framebuffer f, framebuffer_slot slot = FRAMEBUFFER ) = 0;
 		virtual void bind( texture, texture_slot ) = 0;
-		virtual void update( texture, void* ) = 0;
+		virtual void update( texture, const void* ) = 0;
 		virtual void update( buffer, const void*, size_t /*offset*/, size_t /*size*/ ) = 0;
 
@@ -267,5 +267,5 @@
 			if ( info )
 			{
-				NV_ASSERT( info->count < (uint16)vertex_array_info::MAX_ATTRIBUTES, "MAX_ATTRIBUTES reached!" );
+				NV_ASSERT( info->count < uint16( vertex_array_info::MAX_ATTRIBUTES ), "MAX_ATTRIBUTES reached!" );
 				vertex_buffer_attribute& p = info->attr[ info->count ];
 				p.vbuffer    = buf;
Index: /trunk/nv/interface/device.hh
===================================================================
--- /trunk/nv/interface/device.hh	(revision 405)
+++ /trunk/nv/interface/device.hh	(revision 406)
@@ -159,7 +159,7 @@
 		virtual program create_program( string_view vs_source, string_view fs_source ) = 0;
 		virtual buffer create_buffer( buffer_type type, buffer_hint hint, size_t size, const void* source = nullptr ) = 0;
-		virtual texture create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, void* data = nullptr ) = 0;
+		virtual texture create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, const void* data = nullptr ) = 0;
 		// TODO: remove?
-		virtual texture create_texture( ivec2 size, image_format aformat, sampler asampler, void* data = nullptr ) { return create_texture( TEXTURE_2D, size, aformat, asampler, data ); }
+		virtual texture create_texture( ivec2 size, image_format aformat, sampler asampler, const void* data = nullptr ) { return create_texture( TEXTURE_2D, size, aformat, asampler, data ); }
 		virtual image_data* create_image_data( string_view filename ) = 0; // temporary
 		virtual image_data* create_image_data( const uint8* data, uint32 size ) = 0; // temporary
@@ -173,5 +173,5 @@
 		virtual texture create_texture( image_data* data, sampler asampler ) 
 		{
-			return create_texture( data->get_size(), data->get_format(), asampler, (void*)data->get_data() );
+			return create_texture( data->get_size(), data->get_format(), asampler, data->get_data() );
 		}
 
@@ -192,6 +192,6 @@
 				{
 					// TODO: nicer check
-					NV_ASSERT( (int)count <= base->get_length(), "LENGTH CHECK FAIL" );
-					((uniform<T>*)( base ))->set_value( value, count );
+					NV_ASSERT( static_cast<int>( count ) <= base->get_length(), "LENGTH CHECK FAIL" );
+					static_cast< uniform<T>* >( base )->set_value( value, count );
 				}
 			}
@@ -207,5 +207,5 @@
 		void set_opt_uniform_array( program p, const std::string& name, const array_view<T>& value )
 		{
-			set_uniform_array( p, name, (const T*)value.data(), value.size(), false );
+			set_uniform_array( p, name, value.data(), value.size(), false );
 		}
 
@@ -219,5 +219,5 @@
 				if ( base->type_check( type_to_enum<T>::type ) )
 				{
-					((uniform<T>*)( base ))->set_value( value );
+					static_cast< uniform<T>* >( base )->set_value( value );
 				}
 			}
Index: /trunk/nv/interface/input.hh
===================================================================
--- /trunk/nv/interface/input.hh	(revision 405)
+++ /trunk/nv/interface/input.hh	(revision 406)
Index: /trunk/nv/interface/interpolation_raw.hh
===================================================================
--- /trunk/nv/interface/interpolation_raw.hh	(revision 405)
+++ /trunk/nv/interface/interpolation_raw.hh	(revision 406)
@@ -29,5 +29,5 @@
 	inline uint32 interpolate_raw_quat( float factor, const float* k1, const float* k2, float* result )
 	{
-		*((quat*)(result)) = interpolate( *((quat*)(k1)), *((quat*)(k2)), factor );
+		*( reinterpret_cast<quat*>(result) ) = interpolate( *( reinterpret_cast<const quat*>(k1) ), *( reinterpret_cast<const quat*>(k2) ), factor );
 		return 4;
 	}
@@ -53,5 +53,5 @@
 	{
 		quat result;
-		memcpy((float*)(&result), data, sizeof(quat));
+		memcpy(reinterpret_cast<float*>(&result), data, sizeof(quat));
 		return result;
 	}
@@ -139,20 +139,20 @@
 	inline void transform_key_position( uint8* data, float scale, const mat3& r33 )
 	{
-		vec3& p = *((vec3*)(data));
+		vec3& p = *( reinterpret_cast<vec3*>( data ) );
 		p = r33 * p * scale;
 	}
 	inline void transform_key_rotation( uint8* data, const mat3& r33, const mat3& ri33 )
 	{
-		quat& r = *((quat*)(data));
+		quat& r = *( reinterpret_cast<quat*>( data ) );
 		r = quat_cast( r33 * mat3_cast( r ) * ri33 );
 	}
 	inline void transform_key_scale( void* data, float scale )
 	{
-		vec3& s = *((vec3*)(data));
+		vec3& s = *( reinterpret_cast<vec3*>( data ) );
 		s = s * scale;
 	}
 	inline void transform_key_transform( uint8* data, float scale, const mat3& r33, const mat3& ri33 )
 	{
-		transform& t = *((transform*)(data));
+		transform& t = *( reinterpret_cast<transform*>( data ) );
 		t = transform( 
 			r33 * t.get_position() * scale,
Index: /trunk/nv/interface/map_area.hh
===================================================================
--- /trunk/nv/interface/map_area.hh	(revision 405)
+++ /trunk/nv/interface/map_area.hh	(revision 406)
Index: /trunk/nv/interface/mesh_data.hh
===================================================================
--- /trunk/nv/interface/mesh_data.hh	(revision 405)
+++ /trunk/nv/interface/mesh_data.hh	(revision 406)
@@ -136,5 +136,5 @@
 					if ( ch->desc.slots[i].vslot == s )
 					{
-						return (int)c;
+						return int( c );
 					}
 			}
@@ -180,5 +180,5 @@
 				if ( ch->desc == compare )
 				{
-					return (VTX*)ch->data;
+					return reinterpret_cast<VTX*>( ch->data );
 				}
 			}
@@ -266,5 +266,5 @@
 			{
 				if ( m_nodes[ i ].name == name )
-					return (int)i;
+					return int( i );
 			}
 			return -1;
Index: /trunk/nv/interface/uniform.hh
===================================================================
--- /trunk/nv/interface/uniform.hh	(revision 405)
+++ /trunk/nv/interface/uniform.hh	(revision 406)
@@ -106,5 +106,5 @@
 		typedef uniform<T> uniform_type;
 
-		engine_uniform( uniform_base* u ) : m_uniform( (uniform<T>*)u ) {}
+		engine_uniform( uniform_base* u ) : m_uniform( static_cast<uniform<T>*>( u ) ) {}
 	protected:
 		uniform<T>* m_uniform;
@@ -145,5 +145,5 @@
 
 		engine_link_uniform() {}
-		virtual void set( uniform_base* u ) { set_impl( (uniform<T>*)u ); }
+		virtual void set( uniform_base* u ) { set_impl( static_cast<uniform<T>*>(u) ); }
 		virtual void set_impl( uniform<T>* u ) = 0;
 	};
Index: /trunk/nv/interface/vertex.hh
===================================================================
--- /trunk/nv/interface/vertex.hh	(revision 405)
+++ /trunk/nv/interface/vertex.hh	(revision 406)
@@ -238,5 +238,5 @@
 	struct vertex_descriptor
 	{
-		vertex_descriptor_slot slots[ (uint16)slot::SLOT_MAX_STORE ];
+		vertex_descriptor_slot slots[ uint16( slot::SLOT_MAX_STORE ) ];
 		uint32                 count;
 		uint32                 size;
Index: /trunk/nv/lib/assimp.hh
===================================================================
--- /trunk/nv/lib/assimp.hh	(revision 405)
+++ /trunk/nv/lib/assimp.hh	(revision 406)
@@ -67,5 +67,5 @@
 	inline mat4 assimp_mat4_cast( const aiMatrix4x4& m )
 	{
-		const float* p = (float*)&m;
+		const float* p = reinterpret_cast<const float*>( &m );
 		return glm::transpose( make_mat4( p ) );
 	}
Index: /trunk/nv/lib/detail/assimp_types.inc
===================================================================
--- /trunk/nv/lib/detail/assimp_types.inc	(revision 405)
+++ /trunk/nv/lib/detail/assimp_types.inc	(revision 406)
@@ -381,14 +381,14 @@
 #define AI_MATKEY_GLOBAL_BACKGROUND_IMAGE "?bg.global",0,0
 
-#define _AI_MATKEY_TEXTURE_BASE			"$tex.file"
-#define _AI_MATKEY_UVWSRC_BASE			"$tex.uvwsrc"
-#define _AI_MATKEY_TEXOP_BASE			"$tex.op"
-#define _AI_MATKEY_MAPPING_BASE			"$tex.mapping"
-#define _AI_MATKEY_TEXBLEND_BASE		"$tex.blend"
-#define _AI_MATKEY_MAPPINGMODE_U_BASE	"$tex.mapmodeu"
-#define _AI_MATKEY_MAPPINGMODE_V_BASE	"$tex.mapmodev"
-#define _AI_MATKEY_TEXMAP_AXIS_BASE		"$tex.mapaxis"
-#define _AI_MATKEY_UVTRANSFORM_BASE		"$tex.uvtrafo"
-#define _AI_MATKEY_TEXFLAGS_BASE		"$tex.flags"
+#define AI_MATKEY_TEXTURE_BASE			"$tex.file"
+#define AI_MATKEY_UVWSRC_BASE			"$tex.uvwsrc"
+#define AI_MATKEY_TEXOP_BASE			"$tex.op"
+#define AI_MATKEY_MAPPING_BASE			"$tex.mapping"
+#define AI_MATKEY_TEXBLEND_BASE		"$tex.blend"
+#define AI_MATKEY_MAPPINGMODE_U_BASE	"$tex.mapmodeu"
+#define AI_MATKEY_MAPPINGMODE_V_BASE	"$tex.mapmodev"
+#define AI_MATKEY_TEXMAP_AXIS_BASE		"$tex.mapaxis"
+#define AI_MATKEY_UVTRANSFORM_BASE		"$tex.uvtrafo"
+#define AI_MATKEY_TEXFLAGS_BASE		"$tex.flags"
 
 struct aiVectorKey
Index: /trunk/nv/lib/detail/curses_functions.inc
===================================================================
--- /trunk/nv/lib/detail/curses_functions.inc	(revision 405)
+++ /trunk/nv/lib/detail/curses_functions.inc	(revision 406)
Index: /trunk/nv/lib/detail/curses_types.inc
===================================================================
--- /trunk/nv/lib/detail/curses_types.inc	(revision 405)
+++ /trunk/nv/lib/detail/curses_types.inc	(revision 406)
Index: /trunk/nv/lib/detail/gl_ext/gl_ext_all_functions.inc
===================================================================
--- /trunk/nv/lib/detail/gl_ext/gl_ext_all_functions.inc	(revision 405)
+++ /trunk/nv/lib/detail/gl_ext/gl_ext_all_functions.inc	(revision 406)
Index: /trunk/nv/lib/detail/gl_ext/gl_ext_all_types.inc
===================================================================
--- /trunk/nv/lib/detail/gl_ext/gl_ext_all_types.inc	(revision 405)
+++ /trunk/nv/lib/detail/gl_ext/gl_ext_all_types.inc	(revision 406)
Index: /trunk/nv/lib/detail/gl_ext/gl_ext_framebuffer_blit_functions.inc
===================================================================
--- /trunk/nv/lib/detail/gl_ext/gl_ext_framebuffer_blit_functions.inc	(revision 405)
+++ /trunk/nv/lib/detail/gl_ext/gl_ext_framebuffer_blit_functions.inc	(revision 406)
@@ -1,3 +1,2 @@
 /* GL_EXT_FRAMEBUFFER_BLIT */
 NV_GL_FUN_EXT( void , glBlitFramebuffer , ( GLint , GLint , GLint , GLint , GLint , GLint , GLint , GLint , GLbitfield , GLenum ) );
-
Index: /trunk/nv/lib/detail/gl_ext/gl_ext_framebuffer_object_functions.inc
===================================================================
--- /trunk/nv/lib/detail/gl_ext/gl_ext_framebuffer_object_functions.inc	(revision 405)
+++ /trunk/nv/lib/detail/gl_ext/gl_ext_framebuffer_object_functions.inc	(revision 406)
Index: /trunk/nv/lib/detail/gl_ext/gl_ext_framebuffer_object_types.inc
===================================================================
--- /trunk/nv/lib/detail/gl_ext/gl_ext_framebuffer_object_types.inc	(revision 405)
+++ /trunk/nv/lib/detail/gl_ext/gl_ext_framebuffer_object_types.inc	(revision 406)
Index: /trunk/nv/lib/detail/gl_ext/gl_ext_info.inc
===================================================================
--- /trunk/nv/lib/detail/gl_ext/gl_ext_info.inc	(revision 405)
+++ /trunk/nv/lib/detail/gl_ext/gl_ext_info.inc	(revision 406)
Index: /trunk/nv/lib/detail/sdl_functions.inc
===================================================================
--- /trunk/nv/lib/detail/sdl_functions.inc	(revision 405)
+++ /trunk/nv/lib/detail/sdl_functions.inc	(revision 406)
Index: /trunk/nv/lib/detail/sdl_keys.inc
===================================================================
--- /trunk/nv/lib/detail/sdl_keys.inc	(revision 405)
+++ /trunk/nv/lib/detail/sdl_keys.inc	(revision 406)
@@ -532,3 +532,2 @@
     SDLK_SLEEP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SLEEP)
 };
- 
Index: /trunk/nv/lib/freetype2.hh
===================================================================
--- /trunk/nv/lib/freetype2.hh	(revision 405)
+++ /trunk/nv/lib/freetype2.hh	(revision 406)
@@ -104,9 +104,9 @@
 
 #define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
-          (FT_Tag)                        \
-          ( ( (FT_ULong)_x1 << 24 ) |     \
-            ( (FT_ULong)_x2 << 16 ) |     \
-            ( (FT_ULong)_x3 <<  8 ) |     \
-              (FT_ULong)_x4         )
+          static_cast<FT_Tag>( \
+            ( static_cast<FT_ULong>(_x1) << 24 ) |     \
+            ( static_cast<FT_ULong>(_x2) << 16 ) |     \
+            ( static_cast<FT_ULong>(_x3) <<  8 ) |     \
+              static_cast<FT_ULong>(_x4)         )
 
   /* ftimage.h */
@@ -214,8 +214,8 @@
 #ifndef FT_IMAGE_TAG
 #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 )  \
-          value = ( ( (unsigned long)_x1 << 24 ) | \
-                    ( (unsigned long)_x2 << 16 ) | \
-                    ( (unsigned long)_x3 << 8  ) | \
-                      (unsigned long)_x4         )
+          value = ( ( static_cast<unsigned long>(_x1) << 24 ) | \
+                    ( static_cast<unsigned long>(_x2) << 16 ) | \
+                    ( static_cast<unsigned long>(_x3) << 8  ) | \
+                      static_cast<unsigned long>(_x4)         )
 #endif /* FT_IMAGE_TAG */
 
@@ -383,8 +383,8 @@
 #ifndef FT_ENC_TAG
 #define FT_ENC_TAG( value, a, b, c, d )         \
-          value = ( ( (FT_UInt32)(a) << 24 ) |  \
-                    ( (FT_UInt32)(b) << 16 ) |  \
-                    ( (FT_UInt32)(c) <<  8 ) |  \
-                      (FT_UInt32)(d)         )
+          value = ( ( static_cast<FT_UInt32>(a) << 24 ) |  \
+                    ( static_cast<FT_UInt32>(b) << 16 ) |  \
+                    ( static_cast<FT_UInt32>(c) <<  8 ) |  \
+                      static_cast<FT_UInt32>(d)         )
 
 #endif /* FT_ENC_TAG */
@@ -671,5 +671,5 @@
 #define FT_LOAD_ADVANCE_ONLY                 0x100
 #define FT_LOAD_SBITS_ONLY                   0x4000
-#define FT_LOAD_TARGET_( x )   ( (FT_Int32)( (x) & 15 ) << 16 )
+#define FT_LOAD_TARGET_( x )   ( static_cast<FT_UInt32>( (x) & 15 ) << 16 )
 #define FT_LOAD_TARGET_NORMAL  FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL )
 #define FT_LOAD_TARGET_LIGHT   FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT  )
@@ -677,5 +677,5 @@
 #define FT_LOAD_TARGET_LCD     FT_LOAD_TARGET_( FT_RENDER_MODE_LCD    )
 #define FT_LOAD_TARGET_LCD_V   FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V  )
-#define FT_LOAD_TARGET_MODE( x )  ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) )
+#define FT_LOAD_TARGET_MODE( x )  ( static_cast<FT_Render_Mode>( ( (x) >> 16 ) & 15 ) )
 
   typedef enum  FT_Render_Mode_
Index: /trunk/nv/lib/lua.hh
===================================================================
--- /trunk/nv/lib/lua.hh	(revision 405)
+++ /trunk/nv/lib/lua.hh	(revision 406)
@@ -367,6 +367,6 @@
 extern int LUA_VERSION_NUM;
 #define lua_upvalueindex(i)    (LUA_UPVALUEINDEX-(i))
-#define lua_tounsigned(L,idx) (lua_Unsigned)lua_tointeger(L,idx)
-#define lua_pushunsigned(L,u) lua_pushinteger(L,(lua_Integer)u)
+#define lua_tounsigned(L,idx) static_cast<lua_Unsigned>( lua_tointeger(L,idx) )
+#define lua_pushunsigned(L,u) lua_pushinteger(L,static_cast<lua_Integer>( u ) )
 #define lua_objlen lua_rawlen
 #endif
Index: /trunk/nv/lua/lua_area.hh
===================================================================
--- /trunk/nv/lua/lua_area.hh	(revision 405)
+++ /trunk/nv/lua/lua_area.hh	(revision 406)
@@ -24,6 +24,6 @@
 			extern const char* AREA_METATABLE;
 			inline bool is_area( lua_State* L, int index ) { return is_userdata( L, index, AREA_METATABLE ); }
-			inline rectangle to_area( lua_State* L, int index ) { return *(rectangle*)check_userdata( L, index, AREA_METATABLE ); }
-			inline rectangle* to_parea( lua_State* L, int index ) { return (rectangle*)check_userdata( L, index, AREA_METATABLE ); }
+			inline rectangle to_area( lua_State* L, int index ) { return *reinterpret_cast<rectangle*>( check_userdata( L, index, AREA_METATABLE ) ); }
+			inline rectangle* to_parea( lua_State* L, int index ) { return reinterpret_cast<rectangle*>( check_userdata( L, index, AREA_METATABLE ) ); }
 			inline void push_area( lua_State* L, const rectangle& v ) { push_userdata( L, v, AREA_METATABLE ); }
 
Index: /trunk/nv/lua/lua_dispatch.hh
===================================================================
--- /trunk/nv/lua/lua_dispatch.hh	(revision 405)
+++ /trunk/nv/lua/lua_dispatch.hh	(revision 406)
@@ -134,5 +134,5 @@
 			int object_method_wrapper( lua_State* L ) 
 			{
-				C* c = (C*)to_ref_object( L, 1 );
+				C* c = reinterpret_cast<C*>( to_ref_object( L, 1 ) );
 				return dispatch( L, 2, c, f );
 			}
@@ -141,5 +141,5 @@
 			int fixed_method_wrapper( lua_State* L ) 
 			{
-				C* c = (C*)to_pointer( L, nv::lua::detail::upvalue_index(1) );
+				C* c = reinterpret_cast<C*>( to_pointer( L, nv::lua::detail::upvalue_index(1) ) );
 				return dispatch( L, 1, c, f );
 			}
Index: /trunk/nv/lua/lua_function.hh
===================================================================
--- /trunk/nv/lua/lua_function.hh	(revision 405)
+++ /trunk/nv/lua/lua_function.hh	(revision 406)
@@ -81,3 +81,3 @@
 } // namespace nv
 
-#endif // NV_LUA_HH
+#endif // NV_LUA_FUNCTION_HH
Index: /trunk/nv/lua/lua_glm.hh
===================================================================
--- /trunk/nv/lua/lua_glm.hh	(revision 405)
+++ /trunk/nv/lua/lua_glm.hh	(revision 406)
@@ -37,5 +37,5 @@
 			T to_vec( lua_State* L, int index )
 			{
-				return *(T*)check_userdata( L, index, detail::glm_metatable_name<T>() );
+				return *reinterpret_cast<T*>( check_userdata( L, index, detail::glm_metatable_name<T>() ) );
 			}
 
@@ -43,5 +43,5 @@
 			T to_vec( lua_State* L, int index, const T& def )
 			{
-				return ( is_vec<T>( L, index ) ? *(T*)to_pointer( L, index ) : def );
+				return ( is_vec<T>( L, index ) ? *reinterpret_cast<T*>( to_pointer( L, index ) ) : def );
 			}
 
@@ -49,5 +49,5 @@
 			T* to_pvec( lua_State* L, int index )
 			{
-				return (T*)check_userdata( L, index, detail::glm_metatable_name<T>() );
+				return reinterpret_cast<T*>( check_userdata( L, index, detail::glm_metatable_name<T>() ) );
 			}
 
Index: /trunk/nv/lua/lua_values.hh
===================================================================
--- /trunk/nv/lua/lua_values.hh	(revision 405)
+++ /trunk/nv/lua/lua_values.hh	(revision 406)
@@ -242,5 +242,5 @@
 			inline void pop_value( lua_State *L, T& p )
 			{
-				p = (T)pass_traits< type_degrade_t<T> >::to( L, -1 );
+				p = static_cast<T>( pass_traits< type_degrade_t<T> >::to( L, -1 ) );
 				detail::pop_and_discard(L, 1);
 			}
@@ -248,6 +248,5 @@
 			inline T pop_return_value( lua_State *L )
 			{
-				T ret;
-				ret = (T)pass_traits< type_degrade_t<T> >::to( L, -1 );
+				T ret = static_cast<T>( pass_traits< type_degrade_t<T> >::to( L, -1 ) );
 				detail::pop_and_discard(L, 1);
 				return ret;
@@ -262,5 +261,5 @@
 			inline void pop_value( lua_State *L, T& p, const T& def )
 			{
-				p = (T)pass_traits< type_degrade_t<T> >::to( L, -1, def );
+				p = static_cast<T>( pass_traits< type_degrade_t<T> >::to( L, -1, def ) );
 				detail::pop_and_discard(L, 1);
 			}
@@ -268,6 +267,5 @@
 			inline T pop_return_value( lua_State *L, const T& def )
 			{
-				T ret;
-				ret = (T)pass_traits< type_degrade_t<T> >::to( L, -1, def );
+				T ret = static_cast<T>( pass_traits< type_degrade_t<T> >::to( L, -1, def ) );
 				detail::pop_and_discard(L, 1);
 				return ret;
Index: /trunk/nv/sdl/sdl_window_manager.hh
===================================================================
--- /trunk/nv/sdl/sdl_window_manager.hh	(revision 405)
+++ /trunk/nv/sdl/sdl_window_manager.hh	(revision 406)
Index: /trunk/nv/stl/array.hh
===================================================================
--- /trunk/nv/stl/array.hh	(revision 405)
+++ /trunk/nv/stl/array.hh	(revision 406)
Index: /trunk/nv/stl/container/contiguous_storage.hh
===================================================================
--- /trunk/nv/stl/container/contiguous_storage.hh	(revision 405)
+++ /trunk/nv/stl/container/contiguous_storage.hh	(revision 406)
@@ -91,9 +91,9 @@
 		{
 			if ( copy_needed )
-				m_data = (uint8*)nvrealloc( m_data, new_size * sizeof( value_type ) );
+				m_data = static_cast<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 );
+				m_data = ( new_size > 0 ? static_cast<uint8*>( nvmalloc( new_size * sizeof( value_type ) ) ) : nullptr );
 			}
 			return true; // TODO : alloc check?
Index: /trunk/nv/stl/container/contiguous_storage_policy.hh
===================================================================
--- /trunk/nv/stl/container/contiguous_storage_policy.hh	(revision 405)
+++ /trunk/nv/stl/container/contiguous_storage_policy.hh	(revision 406)
@@ -66,5 +66,5 @@
 		}
 		static constexpr size_type max_size() { return size_type( 0x80000000 ); }
-		constexpr size_t capacity() { return m_size; }
+		constexpr size_t capacity() const { return m_size; }
 		constexpr size_t size() const { return m_size; }
 		constexpr bool empty() const { return m_size == 0; }
@@ -135,5 +135,5 @@
 		}
 		static constexpr size_type max_size() { return size_type( 0x80000000 ); }
-		constexpr size_t capacity() { return m_capacity; }
+		constexpr size_t capacity() const { return m_capacity; }
 		constexpr size_t size() const { return m_size; }
 		constexpr bool empty() const { return m_size == 0; }
Index: /trunk/nv/stl/flags.hh
===================================================================
--- /trunk/nv/stl/flags.hh	(revision 405)
+++ /trunk/nv/stl/flags.hh	(revision 406)
@@ -48,5 +48,5 @@
 		private:
 			reference() : m_flags( nullptr ), m_index( index_type(0) ) {}
-
+			reference( const reference& ) = default;
 			reference( flags<SIZE,T>* a_flags, index_type a_index )
 				: m_flags( a_flags ), m_index( a_index )
@@ -109,5 +109,5 @@
 				{
 					if ( raw_index_type(m_index) >= SIZE ) { m_flags = nullptr; m_index = index_type(0); return; }
-					m_index = index_type((raw_index_type)m_index + 1);
+					m_index = index_type( raw_index_type( m_index + 1 ) );
 				} while ( !m_flags->test( m_index ) );
 			}
Index: /trunk/nv/stl/handle.hh
===================================================================
--- /trunk/nv/stl/handle.hh	(revision 405)
+++ /trunk/nv/stl/handle.hh	(revision 406)
@@ -99,9 +99,9 @@
 			if ( m_last_free == NONE )
 			{
-				m_first_free = m_last_free = (index_type)index;
+				m_first_free = m_last_free = static_cast<index_type>( index );
 				return;
 			}
-			m_entries[(value_type)m_last_free].next_free = (index_type)index;
-			m_last_free = (index_type)index;
+			m_entries[static_cast<value_type>( m_last_free ) ].next_free = static_cast<index_type>( index );
+			m_last_free = static_cast<index_type>( index );
 		}
 
@@ -128,5 +128,5 @@
 			if ( m_first_free != NONE )
 			{
-				value_type result = (value_type)m_first_free;
+				value_type result = static_cast<value_type>( m_first_free );
 				m_first_free = m_entries[result].next_free;
 				m_entries[result].next_free = USED;
@@ -165,6 +165,6 @@
 		T* insert( handle h )
 		{
-			resize_indexes_to( (index_type) h.index() );
-			m_indexes[ h.index() ] = (index_type) m_data.size();
+			resize_indexes_to( index_type( h.index() ) );
+			m_indexes[ h.index() ] = index_type( m_data.size() );
 			m_handles.push_back( h );
 			m_data.emplace_back();
@@ -182,5 +182,5 @@
 			if ( h.is_nil() || h.index() >= m_indexes.size() ) return nullptr;
 			index_type i = m_indexes[ h.index() ];
-			return i >= 0 ? &(m_data[ (unsigned)i ]) : nullptr;
+			return i >= 0 ? &(m_data[ unsigned( i ) ]) : nullptr;
 		}
 
@@ -189,5 +189,5 @@
 			if ( h.is_nil() || h.index() >= m_indexes.size() ) return nullptr;
 			index_type i = m_indexes[h.index()];
-			return i >= 0 ? &( m_data[(unsigned)i] ) : nullptr;
+			return i >= 0 ? &( m_data[ unsigned( i )] ) : nullptr;
 		}
 
@@ -196,11 +196,11 @@
 			if ( h.is_nil() || h.index() >= m_indexes.size() || m_indexes[h.index()] == -1 ) 
 				return;
-			handle swap_handle    = m_handles.back();
-			sint32 dead_eindex    = m_indexes[ h.index() ];
-			if ( dead_eindex != (sint32)m_data.size()-1 )
+			handle     swap_handle    = m_handles.back();
+			index_type dead_eindex    = m_indexes[ h.index() ];
+			if ( dead_eindex != static_cast<index_type>( m_data.size()-1 ) )
 			{
-				m_data[ (unsigned)dead_eindex ]    = m_data.back();
-				m_handles[ (unsigned)dead_eindex ] = swap_handle;
-				m_indexes[ swap_handle.index() ]   = dead_eindex;
+				m_data[ unsigned( dead_eindex ) ]    = m_data.back();
+				m_handles[unsigned( dead_eindex ) ] = swap_handle;
+				m_indexes[ swap_handle.index() ]       = dead_eindex;
 			}
 			m_data.pop_back();
@@ -216,5 +216,5 @@
 		}
 
-		handle get_handle( index_type i ) const { return m_handles[(unsigned)i]; }
+		handle get_handle( index_type i ) const { return m_handles[unsigned(i)]; }
 
 		const value_type& operator[] ( index_type i ) const { return m_data[i]; }
@@ -233,10 +233,10 @@
 		void resize_indexes_to( index_type i )
 		{
-			index_type size = (index_type)m_indexes.size();
+			index_type size = index_type( m_indexes.size() );
 			if ( i >= size )
 			{
 				if ( size == 0 ) size = 1;
 				while ( i >= size ) size = size * 2;
-				m_indexes.resize( (size_t)size, -1 );
+				m_indexes.resize( static_cast<size_t>( size ), -1 );
 			}
 		}
@@ -297,6 +297,6 @@
 
 		handle get_handle( index_type i ) const { return m_data.get_handle(i); }
-		const value_type& operator[] ( index_type i ) const { return m_data[(unsigned)i]; }
-		value_type& operator[] ( index_type i ) { return m_data[(unsigned)i]; }
+		const value_type& operator[] ( index_type i ) const { return m_data[unsigned(i)]; }
+		value_type& operator[] ( index_type i ) { return m_data[unsigned(i)]; }
 		size_t size() const { return m_data.size(); }
 
Index: /trunk/nv/stl/range.hh
===================================================================
--- /trunk/nv/stl/range.hh	(revision 405)
+++ /trunk/nv/stl/range.hh	(revision 406)
@@ -105,5 +105,5 @@
 			bits_iterator_base( T value, T current ) : forward_iterator_base<T>( current ), m_full( value )
 			{
-				if( !( (base_type)value & (base_type)current ) )
+				if( !( static_cast<base_type>( value ) & static_cast<base_type>( current ) ) )
 					next();
 			}
@@ -125,6 +125,6 @@
 				{
 					if ( base_class::m_value == invalid || m_full <= base_class::m_value ) { base_class::m_value = invalid; m_full = invalid; break; }
-					base_class::m_value = T((base_type)base_class::m_value << 1);
-				} while ( !( (base_type)m_full & (base_type)base_class::m_value ) );
+					base_class::m_value = T( static_cast<base_type>( base_class::m_value ) << 1);
+				} while ( !( static_cast<base_type>( m_full ) & static_cast<base_type>( base_class::m_value ) ) );
 			}
 
Index: /trunk/src/curses/curses_terminal.cc
===================================================================
--- /trunk/src/curses/curses_terminal.cc	(revision 405)
+++ /trunk/src/curses/curses_terminal.cc	(revision 406)
@@ -20,7 +20,7 @@
 	noecho();
 
-	nodelay  ( (WINDOW*)m_screen, true );
-	intrflush( (WINDOW*)m_screen, false );
-	keypad   ( (WINDOW*)m_screen, true );
+	nodelay  ( static_cast<WINDOW*>( m_screen ), true );
+	intrflush( static_cast<WINDOW*>( m_screen ), false );
+	keypad   ( static_cast<WINDOW*>( m_screen ), true );
 
 	start_color();
@@ -89,5 +89,5 @@
 
 	// Get value from curses
-	int result = wgetch((WINDOW*)m_screen);
+	int result = wgetch( static_cast<WINDOW*>( m_screen ) );
 
 	// If value is err, return none event
Index: /trunk/src/engine/particle_engine.cc
===================================================================
--- /trunk/src/engine/particle_engine.cc	(revision 405)
+++ /trunk/src/engine/particle_engine.cc	(revision 406)
@@ -194,5 +194,5 @@
 static bool nv_particle_affector_linear_force_init( lua::table_guard* table, particle_affector_data* data )
 {
-	nvpe_linear_force_data* datap = ((nvpe_linear_force_data*)data->paramters);
+	nvpe_linear_force_data* datap = reinterpret_cast<nvpe_linear_force_data*>( data->paramters );
 	datap->force_vector = table->get<vec3>("force_vector", vec3() );
 	datap->average      = table->get<bool>("average", false );
@@ -202,5 +202,5 @@
 static void nv_particle_affector_linear_force( const particle_affector_data* data, particle* p, float factor, uint32 count )
 {
-	nvpe_linear_force_data* datap = ((nvpe_linear_force_data*)data->paramters);
+	const nvpe_linear_force_data* datap = reinterpret_cast<const nvpe_linear_force_data*>( data->paramters );
 	if ( datap->average )
 	{
@@ -226,5 +226,5 @@
 static bool nv_particle_affector_deflector_plane_init( lua::table_guard* table, particle_affector_data* data )
 {
-	nvpe_deflector_plane_data* datap = ((nvpe_deflector_plane_data*)data->paramters);
+	nvpe_deflector_plane_data* datap = reinterpret_cast<nvpe_deflector_plane_data*>( data->paramters );
 	datap->plane_point  = table->get<vec3>("plane_point",  vec3() );
 	datap->plane_normal = table->get<vec3>("plane_normal", vec3(0.0f,1.0f,0.0f) );
@@ -237,5 +237,5 @@
 static void nv_particle_affector_deflector_plane( const particle_affector_data* data, particle* p, float factor, uint32 count )
 {
-	nvpe_deflector_plane_data* datap = ((nvpe_deflector_plane_data*)data->paramters);
+	const nvpe_deflector_plane_data* datap = reinterpret_cast<const nvpe_deflector_plane_data*>( data->paramters );
 	for ( uint32 i = 0; i < count; ++i )
 	{
@@ -262,5 +262,5 @@
 static bool nv_particle_affector_color_fader_init( lua::table_guard* table, particle_affector_data* data )
 {
-	nvpe_color_fader_data* datap = ((nvpe_color_fader_data*)data->paramters);
+	nvpe_color_fader_data* datap = reinterpret_cast<nvpe_color_fader_data*>( data->paramters );
 	datap->adjustment = table->get<vec4>("adjustment",  vec4() );
 	return true;
@@ -269,5 +269,5 @@
 static void nv_particle_affector_color_fader( const particle_affector_data* data, particle* p, float factor, uint32 count )
 {
-	nvpe_color_fader_data* datap = ((nvpe_color_fader_data*)data->paramters);
+	const nvpe_color_fader_data* datap = reinterpret_cast<const nvpe_color_fader_data*>( data->paramters );
 	vec4 adjustment = datap->adjustment * factor;
 	for ( uint32 i = 0; i < count; ++i )
@@ -284,5 +284,5 @@
 static bool nv_particle_affector_scaler_init( lua::table_guard* table, particle_affector_data* data )
 {
-	nvpe_scaler_data* datap = ((nvpe_scaler_data*)data->paramters);
+	nvpe_scaler_data* datap = reinterpret_cast<nvpe_scaler_data*>( data->paramters );
 	float rate        = table->get<float>("rate", 0.0f );
 	datap->adjustment = table->get<vec2>("adjustment",  vec2(rate,rate) );
@@ -292,5 +292,5 @@
 static void nv_particle_affector_scaler( const particle_affector_data* data, particle* p, float factor, uint32 count )
 {
-	nvpe_scaler_data* datap = ((nvpe_scaler_data*)data->paramters);
+	const nvpe_scaler_data* datap = reinterpret_cast<const nvpe_scaler_data*>( data->paramters );
 	vec2 adjustment = datap->adjustment * factor;
 	for ( uint32 i = 0; i < count; ++i )
@@ -496,6 +496,5 @@
 	info->particles = new particle[ data->quota ];
 	info->quads     = new particle_quad[ data->quota ];
-	info->vtx_array = m_context->create_vertex_array<particle_vtx>( 
-		(particle_vtx*)info->quads, data->quota*6, STREAM_DRAW );
+	info->vtx_array = m_context->create_vertex_array<particle_vtx>( info->quads[0].data, data->quota*6, STREAM_DRAW );
 	info->vtx_buffer = m_context->find_buffer( info->vtx_array, slot::POSITION );
 	info->last_update = m_last_update;
@@ -691,5 +690,5 @@
 {
 	if ( info->count > 0 )
-		for ( sint32 i = (sint32)info->count-1; i >= 0; --i )
+		for ( sint32 i = sint32( info->count ) - 1; i >= 0; --i )
 		{
 			particle& pinfo = info->particles[i];
Index: /trunk/src/fmod/fmod_audio.cc
===================================================================
--- /trunk/src/fmod/fmod_audio.cc	(revision 405)
+++ /trunk/src/fmod/fmod_audio.cc	(revision 406)
@@ -41,6 +41,6 @@
 	if ( info )
 	{
-		FMOD_SYSTEM* system   = (FMOD_SYSTEM*)m_system;
-		FMOD_SOUND* sample    = (FMOD_SOUND*)( info->fmod_sound );
+		FMOD_SYSTEM* system   = static_cast<FMOD_SYSTEM*>( m_system );
+		FMOD_SOUND* sample    = static_cast<FMOD_SOUND*>( info->fmod_sound );
 		FMOD_CHANNEL* channel = nullptr;
 		FMOD_RESULT result    = FMOD_System_PlaySound( system, FMOD_CHANNEL_FREE, sample, true, &channel );
@@ -64,6 +64,6 @@
 	if ( info )
 	{
-		FMOD_SYSTEM* system   = (FMOD_SYSTEM*)m_system;
-		FMOD_SOUND* sample    = (FMOD_SOUND*)( info->fmod_sound );
+		FMOD_SYSTEM* system   = static_cast<FMOD_SYSTEM*>( m_system );
+		FMOD_SOUND* sample    = static_cast<FMOD_SOUND*>( info->fmod_sound );
 		FMOD_CHANNEL* channel = nullptr;
 		FMOD_RESULT result    = FMOD_System_PlaySound( system, FMOD_CHANNEL_FREE, sample, true, &channel );
@@ -90,5 +90,5 @@
 nv::sound fmod::audio::load_sound( const string_view& a_path )
 {
-	FMOD_SYSTEM* system = (FMOD_SYSTEM*)m_system;
+	FMOD_SYSTEM* system = static_cast<FMOD_SYSTEM*>( m_system );
 	FMOD_SOUND* sample;
 	FMOD_RESULT fm_result = FMOD_System_CreateSound( system, a_path.data(), FMOD_3D, 0, &sample );
@@ -109,5 +109,5 @@
 	if ( info )
 	{
-		FMOD_Sound_Release( (FMOD_SOUND*)info->fmod_sound );
+		FMOD_Sound_Release( static_cast<FMOD_SOUND*>( info->fmod_sound ) );
 		m_sounds.destroy( a_sound );
 	}
@@ -125,5 +125,5 @@
 	fmod_up.z = up.z;
 	// TODO: we also need to setup orientation!
-	FMOD_System_Set3DListenerAttributes( (FMOD_SYSTEM*)m_system, 0, 0, 0, &fmod_forward, &fmod_up );
+	FMOD_System_Set3DListenerAttributes( static_cast<FMOD_SYSTEM*>( m_system ), 0, 0, 0, &fmod_forward, &fmod_up );
 }
 
@@ -140,6 +140,6 @@
 // 	fmod_up.z = 0.0f;
 	// TODO: we also need to setup orientation!
-	FMOD_System_Set3DListenerAttributes( (FMOD_SYSTEM*)m_system, 0, &fmod_position, 0, 0, 0 );
-	FMOD_System_Update( (FMOD_SYSTEM*)m_system );
+	FMOD_System_Set3DListenerAttributes( static_cast<FMOD_SYSTEM*>( m_system ), 0, &fmod_position, 0, 0, 0 );
+	FMOD_System_Update( static_cast<FMOD_SYSTEM*>( m_system ) );
 }
 
@@ -148,5 +148,5 @@
 	while ( m_sounds.size() > 0 )
 		release( m_sounds.get_handle(0) );
-	FMOD_System_Release( (FMOD_SYSTEM*)m_system );
+	FMOD_System_Release( static_cast<FMOD_SYSTEM*>( m_system ) );
 }
 
Index: /trunk/src/formats/assimp_loader.cc
===================================================================
--- /trunk/src/formats/assimp_loader.cc	(revision 405)
+++ /trunk/src/formats/assimp_loader.cc	(revision 406)
@@ -84,5 +84,5 @@
 {
 	load_assimp_library();
-	if ( m_scene != nullptr ) aiReleaseImport( (const aiScene*)m_scene );
+	if ( m_scene != nullptr ) aiReleaseImport( reinterpret_cast<const aiScene*>( m_scene ) );
 	m_scene = nullptr;
 	m_mesh_count = 0;
@@ -113,5 +113,5 @@
 void nv::assimp_loader::load_mesh_data( mesh_data* data, size_t index )
 {
-	const aiScene* scene = (const aiScene*)m_scene;
+	const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
 	const aiMesh*  mesh  = scene->mMeshes[ index ];
 	data->set_name( mesh->mName.data );
@@ -139,12 +139,12 @@
 		nv::vec4 vt ( t_i[0], t_i[1], t_i[2], det );
 		if ( skinned )
-			((assimp_skinned_vtx*)channel->data)[i] = assimp_skinned_vtx( v, s, n, vt );
+			reinterpret_cast< assimp_skinned_vtx* >(channel->data)[i] = assimp_skinned_vtx( v, s, n, vt );
 		else
-			((assimp_plain_vtx*)channel->data)[i] = assimp_plain_vtx( v, s, n, vt );
+			reinterpret_cast< assimp_plain_vtx* >(channel->data)[i] = assimp_plain_vtx( v, s, n, vt );
 	}
 
 	if ( skinned )
 	{
-		assimp_skinned_vtx* vtx = (assimp_skinned_vtx*)channel->data;
+		assimp_skinned_vtx* vtx = reinterpret_cast< assimp_skinned_vtx* >( channel->data );
 		for (unsigned int m=0; m<mesh->mNumBones; m++)
 		{
@@ -154,9 +154,9 @@
 				assimp_skinned_vtx& v = vtx[ bone->mWeights[w].mVertexId ];
 				bool found = false;
-				for (nv::uint32 i = 0 ; i < 4; ++i)
+				for ( int i = 0 ; i < 4; ++i )
 				{
 					if ( v.boneweight[i] <= 0.0f ) 
 					{
-						v.boneindex[i]  = (int)m;
+						v.boneindex[i]  = int( m );
 						v.boneweight[i] = bone->mWeights[w].mWeight;
 						found = true;
@@ -171,5 +171,5 @@
 	mesh_raw_channel* ichannel = mesh_raw_channel::create_index( USHORT, mesh->mNumFaces * 3 );
 	data->add_channel( ichannel );
-	uint16* indices = (uint16*)ichannel->data;
+	uint16* indices = reinterpret_cast<uint16*>( ichannel->data );
 	for (unsigned int i=0; i<mesh->mNumFaces; i++)
 	{
@@ -177,5 +177,5 @@
 		for (unsigned int j=0; j<face->mNumIndices; j++)
 		{
-			indices[ i*3 + j ] = (uint16)face->mIndices[j];
+			indices[ i*3 + j ] = uint16( face->mIndices[j] );
 		}
 	}
@@ -184,5 +184,5 @@
 nv::assimp_loader::~assimp_loader()
 {
-	if ( m_scene != nullptr ) aiReleaseImport( (const aiScene*)m_scene );
+	if ( m_scene != nullptr ) aiReleaseImport( reinterpret_cast<const aiScene*>( m_scene ) );
 }
 
@@ -190,5 +190,5 @@
 {
 	if ( m_scene == nullptr ) return false;
-	const aiScene* scene = (const aiScene*)m_scene;
+	const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
 	const aiMesh*  mesh  = scene->mMeshes[ index ];
 
@@ -208,5 +208,5 @@
 void nv::assimp_loader::scene_report() const
 {
-	const aiScene* scene = (const aiScene*)m_scene;
+	const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
 	if ( scene == nullptr ) return;
 
@@ -237,5 +237,5 @@
 			aiMesh* mesh = scene->mMeshes[mc];
 
-			NV_LOG_NOTICE( "Mesh #", mc, "   - ", string_view( (char*)mesh->mName.data ) );
+			NV_LOG_NOTICE( "Mesh #", mc, "   - ", string_view( static_cast<char*>( mesh->mName.data ) ) );
 			NV_LOG_NOTICE( "  bones   - ", mesh->mNumBones );
 			NV_LOG_NOTICE( "  uvs     - ", mesh->mNumUVComponents[0] );
@@ -283,5 +283,5 @@
 mesh_nodes_data* nv::assimp_loader::release_merged_bones( mesh_data* meshes )
 {
-	const aiScene* scene = (const aiScene*)m_scene;
+	const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
 	vector< mesh_node_data > final_bones;
 	unordered_map< std::string, uint16 > names;
@@ -303,5 +303,5 @@
 				{
 					NV_ASSERT( final_bones.size() < MAX_BONES, "Too many bones to merge!" );
-					uint16 index = (uint16)final_bones.size();
+					uint16 index = uint16( final_bones.size() );
 					final_bones.push_back( bone );
 					names[ bone.name ] = index;
@@ -316,14 +316,14 @@
 			{
 				mesh_raw_channel* channel = meshes[m].get_raw_channels()[0];
-				assimp_skinned_vtx* va = (assimp_skinned_vtx*)channel->data;
+				assimp_skinned_vtx* va = reinterpret_cast< assimp_skinned_vtx* >( channel->data );
 				for ( unsigned v = 0; v < channel->count; ++v )
 				{
 					assimp_skinned_vtx& vertex = va[v];
 
-					for (uint32 i = 0 ; i < 4; ++i)
+					for ( int i = 0 ; i < 4; ++i)
 					{
 						if ( vertex.boneweight[i] > 0.0f ) 
 						{
-							vertex.boneindex[i] = (int)translate[vertex.boneindex[i]];
+							vertex.boneindex[i] = int( translate[vertex.boneindex[i]] );
 						}
 					}
@@ -340,5 +340,5 @@
 {
 	if ( m_scene == nullptr ) return nullptr;
-	const aiScene* scene = (const aiScene*)m_scene;
+	const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
 	if ( scene->mRootNode == nullptr || scene->mAnimations == nullptr || scene->mAnimations[index] == nullptr) return nullptr;
 
@@ -349,6 +349,6 @@
 	mesh_node_data* data    = new mesh_node_data[count];
 
-	uint16 frame_rate     = (uint16)anim->mTicksPerSecond;
-	float  duration       = (float)anim->mDuration;
+	uint16 frame_rate     = static_cast<uint16>( anim->mTicksPerSecond );
+	float  duration       = static_cast<float>( anim->mDuration );
 	bool   flat           = false;
 
@@ -360,5 +360,5 @@
 nv::uint32 nv::assimp_loader::count_nodes( const void* node ) const
 {
-	const aiNode* ainode = (const aiNode*)node;
+	const aiNode* ainode = reinterpret_cast< const aiNode* >( node );
 	nv::uint32 count = 1;
 	for ( unsigned i = 0; i < ainode->mNumChildren; ++i )
@@ -371,6 +371,6 @@
 nv::sint16 nv::assimp_loader::load_node( uint32 anim_id, mesh_node_data* nodes, const void* vnode, sint16 this_id, sint16 parent_id )
 {
-	const aiScene* scene = (const aiScene*)m_scene;
-	const aiNode*  node  = (const aiNode*)vnode;
+	const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
+	const aiNode*  node  = reinterpret_cast<const aiNode*>( vnode );
 	std::string name( node->mName.data );
 	const aiAnimation* anim  = scene->mAnimations[anim_id];
@@ -411,5 +411,5 @@
 void nv::assimp_loader::create_keys( mesh_node_data* data, const void* vnode )
 {
-	const aiNodeAnim* node = (const aiNodeAnim*)vnode;
+	const aiNodeAnim* node = reinterpret_cast< const aiNodeAnim* >( vnode );
 	if ( node->mNumPositionKeys == 0 && node->mNumRotationKeys == 0 && node->mNumScalingKeys == 0 )
 	{
@@ -424,16 +424,16 @@
 	data->data->add_channel( raw_rchannel );
 	//data->data->add_channel( raw_schannel );
-	assimp_key_p* pchannel = ((assimp_key_p*)(raw_pchannel->data));
-	assimp_key_r* rchannel = ((assimp_key_r*)(raw_rchannel->data));
+	assimp_key_p* pchannel = reinterpret_cast< assimp_key_p* >( raw_pchannel->data );
+	assimp_key_r* rchannel = reinterpret_cast< assimp_key_r* >( raw_rchannel->data );
 	//assimp_key_s* schannel = ((assimp_key_s*)(raw_schannel->data));
 
 	for ( unsigned np = 0; np < node->mNumPositionKeys; ++np )
 	{
-		pchannel[np].time     = (float)node->mPositionKeys[np].mTime;
+		pchannel[np].time     = static_cast<float>( node->mPositionKeys[np].mTime );
 		pchannel[np].position = assimp_vec3_cast(node->mPositionKeys[np].mValue);
 	}
 	for ( unsigned np = 0; np < node->mNumRotationKeys; ++np )
 	{
-		rchannel[np].time     = (float)node->mRotationKeys[np].mTime;
+		rchannel[np].time     = static_cast<float>( node->mRotationKeys[np].mTime );
 		rchannel[np].rotation = assimp_quat_cast(node->mRotationKeys[np].mValue );
 	}
@@ -463,5 +463,5 @@
 {
 	if ( m_scene == nullptr || m_mesh_count == 0 ) return nullptr;
-	const aiScene* scene = (const aiScene*)m_scene;
+	const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
 	bool has_bones = false;
 	mesh_data* meshes = new mesh_data[ m_mesh_count ];
@@ -481,5 +481,5 @@
 {
 	if ( m_scene == nullptr ) return 0;
-	const aiScene* scene = (const aiScene*)m_scene;
+	const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
 	return scene->mNumAnimations;	
 }
Index: /trunk/src/formats/md2_loader.cc
===================================================================
--- /trunk/src/formats/md2_loader.cc	(revision 405)
+++ /trunk/src/formats/md2_loader.cc	(revision 406)
@@ -192,9 +192,4 @@
 	//	return vec3( v[0], v[1], v[2] );
 	return vec3( v[0], v[2], v[1] );
-}
-
-static inline vec3 md2_normal( uint8 normal )
-{
-	return md2_vec3( md2_normal_table[normal] );
 }
 
@@ -220,8 +215,9 @@
 md2_loader::~md2_loader()
 {
-	if (m_md2 != nullptr)
-	{
-		free_md2( (md2_t*)(m_md2) );
-		delete (md2_t*)m_md2;
+	md2_t* md2 = reinterpret_cast< md2_t* >( m_md2 );
+	if ( md2 != nullptr)
+	{
+		free_md2( md2 );
+		delete md2;
 	}
 }
@@ -229,6 +225,7 @@
 bool md2_loader::load( stream& source )
 {
-	m_md2 = (void*)(new md2_t);
-	if ( !read_md2( (md2_t*)m_md2, source ) )
+	md2_t* md2 = new md2_t; 
+	m_md2 = md2;
+	if ( !read_md2( md2, source ) )
 	{
 		return false;
@@ -240,10 +237,10 @@
 nv::size_t md2_loader::get_max_frames() const
 {
-	return static_cast< size_t >( ((md2_t*)m_md2)->header.num_frames );
+	return static_cast<size_t>( reinterpret_cast<md2_t*>( m_md2 )->header.num_frames );
 }
 
 void nv::md2_loader::reindex()
 {
-	md2_t* md2 = (md2_t*)m_md2;
+	md2_t* md2 = reinterpret_cast< md2_t* >( m_md2 );
 	uint32 num_indexes = static_cast< uint32 >( md2->header.num_tris * 3 );
 
@@ -321,5 +318,5 @@
 void nv::md2_loader::release_mesh_frame( mesh_data* data, sint32 frame )
 {
-	md2_t* md2 = (md2_t*)m_md2;
+	md2_t* md2 = reinterpret_cast< md2_t* >( m_md2 );
 	size_t num_frames = static_cast< size_t >( md2->header.num_frames );
 	size_t num_verts  =	m_new_vindexes.size();
@@ -328,5 +325,5 @@
 
 	mesh_raw_channel* mc_pn = mesh_raw_channel::create< vtx_md2_pn >( num_verts * frame_count );
-	vtx_md2_pn* vtx_pn = (vtx_md2_pn*)mc_pn->data;
+	vtx_md2_pn* vtx_pn = reinterpret_cast< vtx_md2_pn* >( mc_pn->data );
 
 	uint32 index = 0;
@@ -351,7 +348,7 @@
 
 	mesh_raw_channel* mc_t = mesh_raw_channel::create< vtx_md2_t >( num_verts );
-	vtx_md2_t* vtx_t = (vtx_md2_t*)mc_t->data;
-
-	vec2 scale( 1.0f / (float) md2->header.skinwidth, 1.0f / (float) md2->header.skinheight );
+	vtx_md2_t* vtx_t = reinterpret_cast< vtx_md2_t* >( mc_t->data );
+
+	vec2 scale( 1.0f / static_cast<float>( md2->header.skinwidth ), 1.0f / static_cast<float>( md2->header.skinheight ) );
 	for (size_t i = 0; i < num_verts; ++i )
 	{
@@ -363,5 +360,5 @@
 	if ( m_new_indexes.size() > 0 )
 	{
-		uint16* icp = (uint16*)ic->data;
+		uint16* icp = reinterpret_cast< uint16* >( ic->data );
 		raw_copy_n( m_new_indexes.data(), m_new_indexes.size(), icp );
 	}
Index: /trunk/src/formats/md2_normals.inc
===================================================================
--- /trunk/src/formats/md2_normals.inc	(revision 405)
+++ /trunk/src/formats/md2_normals.inc	(revision 406)
Index: /trunk/src/formats/md3_loader.cc
===================================================================
--- /trunk/src/formats/md3_loader.cc	(revision 405)
+++ /trunk/src/formats/md3_loader.cc	(revision 406)
@@ -267,8 +267,9 @@
 nv::md3_loader::~md3_loader()
 {
-	if (m_md3 != nullptr)
-	{
-		free_md3( (md3_t*)(m_md3) );
-		delete (md3_t*)m_md3;
+	md3_t* md3 = reinterpret_cast< md3_t* >( m_md3 );
+	if ( md3 != nullptr )
+	{
+		free_md3( md3 );
+		delete md3;
 	}
 }
@@ -276,6 +277,7 @@
 bool nv::md3_loader::load( stream& source )
 {
-	m_md3 = (void*)(new md3_t);
-	if ( !read_md3( (md3_t*)m_md3, source ) )
+	md3_t* md3 = new md3_t;
+	m_md3 = md3;
+	if ( !read_md3( md3, source ) )
 	{
 		return false;
@@ -286,6 +288,6 @@
 nv::key_raw_channel* nv::md3_loader::load_tags( const string_view& tag )
 {
-	md3_t* md3 = (md3_t*)m_md3;
-	key_raw_channel* result = key_raw_channel::create<md3_key>( (uint32)md3->header.num_frames );
+	md3_t* md3 = reinterpret_cast< md3_t* >( m_md3 );
+	key_raw_channel* result = key_raw_channel::create<md3_key>( uint32( md3->header.num_frames ) );
 	// TODO: is this brain damaged in efficiency (loop nest order) or what?
 	for ( sint32 f = 0; f < md3->header.num_frames; ++f )
@@ -294,5 +296,5 @@
 		{
 			const md3_tag_t& rtag = md3->tags[i + md3->header.num_tags * f];
-			string_view rname((char*)(rtag.name));
+			string_view rname( reinterpret_cast< const char* >(rtag.name) );
 			if (rname == tag)
 			{
@@ -301,5 +303,5 @@
 				vec3 axisy  ( md3_vec3( rtag.axis[2] ) );
 				vec3 origin ( md3_vec3( rtag.origin )  );
-				((md3_key*)(result->data))[f].tform = transform( origin, quat( mat3( axisx, axisy, axisz ) ) );
+				reinterpret_cast< md3_key*>(result->data)[f].tform = transform( origin, quat( mat3( axisx, axisy, axisz ) ) );
 			}
 		}
@@ -323,5 +325,5 @@
 {
 	mesh_data* data = new mesh_data;
-	release_mesh_frame( data, -1, (sint32)index );
+	release_mesh_frame( data, -1, static_cast< sint32 >( index ) );
 	return data;
 }
@@ -329,31 +331,31 @@
 void nv::md3_loader::release_mesh_frame( mesh_data* data, sint32 frame, sint32 surface )
 {
-	md3_t* md3 = (md3_t*)m_md3;
-	uint32 num_surfaces  = (uint32)md3->header.num_surfaces;
-	uint32 num_verts     = 0;
-	uint32 current_frame = ( frame == -1 ? 0 : (uint32)frame );
-	uint32 frame_count   = ( frame == -1 ? (uint32)md3->header.num_frames : 1 );
-	uint32 current_surf  = ( surface == -1 ? 0 : (uint32)surface );
-	uint32 surf_count    = ( surface == -1 ? (uint32)md3->header.num_surfaces : 1 );
-	uint32 index_count   = 0;
+	md3_t* md3 = reinterpret_cast< md3_t* >( m_md3 );
+	sint32 num_surfaces  = md3->header.num_surfaces;
+	sint32 num_verts     = 0;
+	sint32 current_frame = ( frame == -1 ? 0 : frame );
+	sint32 frame_count   = ( frame == -1 ? md3->header.num_frames : 1 );
+	sint32 current_surf  = ( surface == -1 ? 0 : surface );
+	sint32 surf_count    = ( surface == -1 ? md3->header.num_surfaces : 1 );
+	sint32 index_count   = 0;
 
 	if ( surface >= 0 )
 	{
-		index_count = (uint32)md3->surfaces[(uint32)surface].header.num_triangles * 3;
-		num_verts   = (uint32)md3->surfaces[(uint32)surface].header.num_verts;
+		index_count = md3->surfaces[surface].header.num_triangles * 3;
+		num_verts   = md3->surfaces[surface].header.num_verts;
 	}
 	else
-		for ( uint32 i = 0; i < num_surfaces; ++i )
-		{
-			index_count += (uint32)md3->surfaces[i].header.num_triangles * 3;
-			num_verts   += (uint32)md3->surfaces[i].header.num_verts;
-		}
-
-	mesh_raw_channel* mc_pn = mesh_raw_channel::create< vtx_md3_pn >( num_verts * frame_count );
-	mesh_raw_channel* mc_t  = mesh_raw_channel::create< vtx_md3_t >( num_verts );
-	mesh_raw_channel* ic = mesh_raw_channel::create_index< uint16 >( index_count );
-	vtx_md3_pn* vtx_pn = (vtx_md3_pn*)mc_pn->data;
-	vtx_md3_t*  vtx_t  = (vtx_md3_t*) mc_t->data;
-	uint16*     icp    = (uint16*)ic->data;
+		for ( sint32 i = 0; i < num_surfaces; ++i )
+		{
+			index_count += md3->surfaces[i].header.num_triangles * 3;
+			num_verts   += md3->surfaces[i].header.num_verts;
+		}
+
+	mesh_raw_channel* mc_pn = mesh_raw_channel::create< vtx_md3_pn >( uint32( num_verts * frame_count ) );
+	mesh_raw_channel* mc_t  = mesh_raw_channel::create< vtx_md3_t >( uint32( num_verts ) );
+	mesh_raw_channel* ic = mesh_raw_channel::create_index< uint16 >( uint32( index_count ) );
+	vtx_md3_pn* vtx_pn = reinterpret_cast< vtx_md3_pn* >( mc_pn->data );
+	vtx_md3_t*  vtx_t  = reinterpret_cast< vtx_md3_t* >( mc_t->data );
+	uint16*     icp    = reinterpret_cast< uint16* >( ic->data );
 
 	uint32 index  = 0;
@@ -387,14 +389,14 @@
 	while ( frame_count > 0 )
 	{
-		current_surf  = ( surface == -1 ? 0 : (uint32)surface );
-		surf_count    = ( surface == -1 ? (uint32)md3->header.num_surfaces : 1 );
+		current_surf  = ( surface == -1 ? 0 : surface );
+		surf_count    = ( surface == -1 ? md3->header.num_surfaces : 1 );
 
 		while ( surf_count > 0 )
 		{
 			md3_surface_t& sface  = md3->surfaces[current_surf];
-			uint32         vcount = (uint32)sface.header.num_verts;
-			uint32         offset = vcount * current_frame;
-			uint32         limit  = vcount + offset;
-			for (uint32 j = offset; j < limit; ++j )
+			sint32 vcount = sface.header.num_verts;
+			sint32 offset = vcount * current_frame;
+			sint32 limit  = vcount + offset;
+			for ( sint32 j = offset; j < limit; ++j )
 			{
 				md3_vertex_t& v = sface.vertices[j];
@@ -410,5 +412,5 @@
 	}
 
-	data->set_name( (char*)md3->header.name );
+	data->set_name( reinterpret_cast< char* >( md3->header.name ) );
 	data->add_channel( mc_pn );
 	data->add_channel( mc_t );
@@ -418,6 +420,6 @@
 mesh_nodes_data* nv::md3_loader::release_mesh_nodes_data( nv::size_t )
 {
-	md3_t* md3 = (md3_t*)m_md3;
-	uint32 node_count = (uint32)md3->header.num_tags;
+	md3_t* md3 = reinterpret_cast< md3_t* >( m_md3 );
+	uint32 node_count = uint32( md3->header.num_tags );
 	if ( node_count == 0 ) return nullptr;
 	mesh_node_data* nodes = new mesh_node_data[ node_count ];
@@ -425,5 +427,5 @@
 	{
 		const md3_tag_t& rtag = md3->tags[i];
-		string_view name( (char*)(rtag.name) );
+		string_view name( reinterpret_cast< const char* >(rtag.name) );
 
 		nodes[i].transform = mat4();
@@ -441,6 +443,6 @@
 mesh_data_pack* nv::md3_loader::release_mesh_data_pack()
 {
-	md3_t* md3 = (md3_t*)m_md3;
-	uint32 count = 1;
+	md3_t* md3 = reinterpret_cast<md3_t*>( m_md3 );
+	int count = 1;
 	mesh_data* data = nullptr;
 	if ( m_merge_all )
@@ -448,21 +450,21 @@
 		data = new mesh_data[1];
 		release_mesh_frame( &data[0], -1, -1 );
-		data[0].set_name( (char*)md3->header.name );
+		data[0].set_name( reinterpret_cast< char* >( md3->header.name ) );
 	}
 	else
 	{
-		count = (uint32)md3->header.num_surfaces;
+		count = md3->header.num_surfaces;
 		data = new mesh_data[ count ];
-		for ( uint32 i = 0; i < count; ++i )
-		{
-			release_mesh_frame( &data[i], -1, (sint32)i );
-			data[i].set_name( (char*)md3->surfaces[i].header.name );
-		}
-	}
-	return new mesh_data_pack( count, data, release_mesh_nodes_data() );
+		for ( int i = 0; i < count; ++i )
+		{
+			release_mesh_frame( &data[i], -1, i );
+			data[i].set_name( reinterpret_cast< char* >( md3->surfaces[i].header.name ) );
+		}
+	}
+	return new mesh_data_pack( uint32( count ), data, release_mesh_nodes_data() );
 }
 
 nv::size_t md3_loader::get_max_frames() const
 {
-	return static_cast< size_t >( ((md3_t*)m_md3)->header.num_frames );
-}
+	return static_cast<size_t>( reinterpret_cast<md3_t*>( m_md3 )->header.num_frames );
+}
Index: /trunk/src/formats/md5_loader.cc
===================================================================
--- /trunk/src/formats/md5_loader.cc	(revision 405)
+++ /trunk/src/formats/md5_loader.cc	(revision 406)
@@ -162,5 +162,5 @@
 						mesh_raw_channel* ch_t   = mesh_raw_channel::create<md5_vtx_t>( num_verts );
 						mesh_raw_channel* ch_pntiw = mesh_raw_channel::create<md5_vtx_pntiw>( num_verts );
-						tdata = (md5_vtx_t*)ch_t->data;
+						tdata = reinterpret_cast< md5_vtx_t* >( ch_t->data );
 						mesh->add_channel( ch_pnt );
 						mesh->add_channel( ch_t );
@@ -191,5 +191,5 @@
 
 					mesh_raw_channel* ch_i = mesh_raw_channel::create_index<uint32>( num_tris * 3 );
-					uint32* vtx_i                = (uint32*)ch_i->data;
+					uint32* vtx_i                = reinterpret_cast< uint32* >( ch_i->data );
 					uint32 idx = 0;
 					mesh->add_channel( ch_i );
@@ -199,14 +199,14 @@
 					for ( uint32 i = 0; i < num_tris; ++i )
 					{
-						size_t ti0;
-						size_t ti1;
-						size_t ti2;
+						unsigned ti0;
+						unsigned ti1;
+						unsigned ti2;
 
 						std::getline( sstream, line );
 						sscanf( line.c_str(), "%*s %*u %u %u %u )", &(ti0), &(ti1), &(ti2));
 
-						vtx_i[idx++] = (uint32)ti0;
-						vtx_i[idx++] = (uint32)ti1;
-						vtx_i[idx++] = (uint32)ti2;
+						vtx_i[idx++] = ti0;
+						vtx_i[idx++] = ti1;
+						vtx_i[idx++] = ti2;
 					}              
 				}
@@ -244,5 +244,5 @@
 			assert( nodes == nullptr );
 			nodes = new mesh_node_data[ num_joints ];
-			m_nodes = new mesh_nodes_data( "md5_animation", num_joints, nodes, (nv::uint16)frame_rate, (float)num_frames, true );
+			m_nodes = new mesh_nodes_data( "md5_animation", num_joints, nodes, static_cast< nv::uint16 >( frame_rate ), static_cast< float >( num_frames ), true );
 			joint_infos.resize( num_joints );
 
@@ -318,5 +318,5 @@
 			{
 				sstream >> buf;
-				frame.push_back((float)atof(buf));
+				frame.push_back( static_cast< float >( atof(buf) ) );
 			}
 
@@ -336,6 +336,6 @@
 {
 	assert( m_type == MESH );
-	md5_vtx_pnt* vtcs = (md5_vtx_pnt*)mdata->get_channel< md5_vtx_pnt >()->data; 
-	md5_vtx_pntiw* vtx_data = (md5_vtx_pntiw*)mdata->get_channel< md5_vtx_pntiw >()->data; 
+	md5_vtx_pnt* vtcs       = reinterpret_cast< md5_vtx_pnt* >( mdata->get_channel< md5_vtx_pnt >()->data ); 
+	md5_vtx_pntiw* vtx_data = reinterpret_cast< md5_vtx_pntiw* >( mdata->get_channel< md5_vtx_pntiw >()->data );
 
 	for ( uint32 i = 0; i < vtx_count; ++i )
@@ -368,10 +368,10 @@
 		}
 
-		for ( size_t j = 0; j < 4; ++j )
-		{
-			if ( j < weight_count )
-			{
-				vdata.boneindex[j]  = (int)weights[start_weight + j].joint_id;
-				vdata.boneweight[j] = weights[start_weight + j].bias;
+		for ( int j = 0; j < 4; ++j )
+		{
+			if ( j < int(weight_count) )
+			{
+				vdata.boneindex[j]  = int( weights[int(start_weight) + j].joint_id );
+				vdata.boneweight[j] = weights[int(start_weight) + j].bias;
 			}
 			else
@@ -396,5 +396,5 @@
 	}
 
-	const uint32*    idata = (uint32*)mdata->get_index_channel()->data;
+	const uint32*    idata = reinterpret_cast< uint32* >( mdata->get_index_channel()->data );
 	const md5_vtx_t* tdata = mdata->get_channel_data<md5_vtx_t>();
 
@@ -448,5 +448,5 @@
  		vdata.tangent  = vec3(0);
  
- 		for ( size_t j = 0; j < 4; ++j )
+ 		for ( int j = 0; j < 4; ++j )
  		{
 			const mesh_node_data&  joint = nodes[vdata.boneindex[j]];
@@ -484,5 +484,5 @@
 		{
 			const mesh_node_data& pjoint = nodes[parent_id];
-			const transform* ptv = (const transform*)pjoint.data->get_channel(0)->data;
+			const transform* ptv = reinterpret_cast< const transform* >( pjoint.data->get_channel(0)->data );
 			transform ptr;
 			if ( pjoint.data->get_channel(0)->count > index ) ptr = ptv[ index ];
@@ -495,5 +495,5 @@
 		}
 
-		((transform*)joint.data->get_channel(0)->data)[index] = transform( pos, orient );
+		reinterpret_cast< transform* >( joint.data->get_channel(0)->data )[index] = transform( pos, orient );
 	}
 }
Index: /trunk/src/formats/nmd_loader.cc
===================================================================
--- /trunk/src/formats/nmd_loader.cc	(revision 405)
+++ /trunk/src/formats/nmd_loader.cc	(revision 406)
@@ -174,5 +174,5 @@
 	eheader.type     = nmd_type::MESH;
 	eheader.name     = 0;
-	eheader.children = (uint16)data.size();
+	eheader.children = static_cast< uint16 >( data.size() );
 	eheader.size     = size;
 	stream_out.write( &eheader, sizeof( eheader ), 1 );
@@ -213,5 +213,5 @@
 	header.name     = 0;
 	header.type     = nmd_type::ANIMATION;
-	header.children = (uint16)nodes->get_count();
+	header.children = static_cast< uint16 >( nodes->get_count() );
 	header.size     = total;
 	stream_out.write( &header, sizeof( header ), 1 );
@@ -237,5 +237,5 @@
 		eheader.type     = nmd_type::NODE;
 		eheader.name     = strings->insert( node->name );
-		eheader.children = (uint16)chan_count;
+		eheader.children = static_cast< uint16 >( chan_count );
 		eheader.size     = sizeof( nmd_node_header ) + chan_size;
 		stream_out.write( &eheader, sizeof( eheader ), 1 );
Index: /trunk/src/formats/obj_loader.cc
===================================================================
--- /trunk/src/formats/obj_loader.cc	(revision 405)
+++ /trunk/src/formats/obj_loader.cc	(revision 406)
@@ -207,5 +207,5 @@
 	virtual void reset() { m_data.clear(); }
 	virtual nv::size_t raw_size() const { return m_data.size() * sizeof( VTX ); }
-	virtual const uint8* raw_pointer() const { return (const uint8*)m_data.data(); }
+	virtual const uint8* raw_pointer() const { return reinterpret_cast< const uint8* >( m_data.data() ); }
 };
 
Index: /trunk/src/gfx/image.cc
===================================================================
--- /trunk/src/gfx/image.cc	(revision 405)
+++ /trunk/src/gfx/image.cc	(revision 406)
@@ -46,5 +46,5 @@
 void image::fill( uint8 value )
 {
-	raw_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 * static_cast<int>( m_depth ), value );
 }
 
Index: /trunk/src/gfx/keyframed_mesh.cc
===================================================================
--- /trunk/src/gfx/keyframed_mesh.cc	(revision 405)
+++ /trunk/src/gfx/keyframed_mesh.cc	(revision 406)
@@ -71,5 +71,5 @@
 	if ( m_active )
 	{
-		float tick_time = ( (float)a_anim_time * 0.001f ) * anim->get_frame_rate();
+		float tick_time = ( static_cast<float>( a_anim_time ) * 0.001f ) * anim->get_frame_rate();
 		float duration  = anim->is_looping() ? anim->get_duration() + 1.0f : anim->get_duration();
 		if ( tick_time >= duration )
@@ -82,5 +82,5 @@
 			{
 				m_active     = false;
-				m_last_frame = (uint32)anim->get_end();
+				m_last_frame = static_cast<uint32>( anim->get_end() );
 				m_next_frame = m_last_frame;
 				m_interpolation = 0.0f;
@@ -88,7 +88,7 @@
 			}
 		}
-		m_last_frame    = (uint32)( glm::floor( tick_time ) + anim->get_start() );
+		m_last_frame    = static_cast<uint32>( glm::floor( tick_time ) + anim->get_start() );
 		m_next_frame    = m_last_frame + 1;
-		if ( m_next_frame > (uint32)anim->get_end() ) m_next_frame = (uint32)anim->get_start();
+		if ( m_next_frame > static_cast<uint32>( anim->get_end() ) ) m_next_frame = static_cast<uint32>( anim->get_start() );
 		m_interpolation = tick_time - glm::floor( tick_time );
 	}
@@ -152,9 +152,9 @@
 	{
 		uint32 base_offset = m_next_frame * m_vertex_count * m_vsize; 
-		m_context->update_attribute_offset( m_va, (slot)m_loc_next_position, base_offset );
-		m_context->update_attribute_offset( m_va, (slot)m_loc_next_normal, base_offset + sizeof( vec3 ) );
+		m_context->update_attribute_offset( m_va, static_cast<slot>( m_loc_next_position ), base_offset );
+		m_context->update_attribute_offset( m_va, static_cast<slot>( m_loc_next_normal ), base_offset + sizeof( vec3 ) );
 		if ( m_has_tangent && m_loc_next_tangent != -1 )
 		{
-			m_context->update_attribute_offset( m_va, (slot)m_loc_next_tangent, base_offset + 2*sizeof( vec3 ) );
+			m_context->update_attribute_offset( m_va, static_cast<slot>( m_loc_next_tangent ), base_offset + 2*sizeof( vec3 ) );
 		}
 		m_gpu_next_frame = m_next_frame;
@@ -172,8 +172,8 @@
 			m_loc_next_tangent  = dev->get_attribute_location( a_program, "nv_next_tangent" );
 
-		m_context->add_vertex_buffer( m_va, (slot)m_loc_next_position, m_pbuffer, FLOAT, 3, 0, m_vsize, false );
-		m_context->add_vertex_buffer( m_va, (slot)m_loc_next_normal,   m_pbuffer, FLOAT, 3, sizeof( vec3 ), m_vsize, false );
+		m_context->add_vertex_buffer( m_va, static_cast<slot>( m_loc_next_position ), m_pbuffer, FLOAT, 3, 0, m_vsize, false );
+		m_context->add_vertex_buffer( m_va, static_cast<slot>( m_loc_next_normal ),   m_pbuffer, FLOAT, 3, sizeof( vec3 ), m_vsize, false );
 		if ( m_has_tangent )
-			m_context->add_vertex_buffer( m_va, (slot)m_loc_next_tangent, m_pbuffer, FLOAT, 4, 2*sizeof( vec3 ), m_vsize, false );
+			m_context->add_vertex_buffer( m_va, static_cast<slot>( m_loc_next_tangent ), m_pbuffer, FLOAT, 4, 2*sizeof( vec3 ), m_vsize, false );
 	}
 	keyframed_mesh::update( a_program );
@@ -184,11 +184,11 @@
 {
 	m_va      = m_context->create_vertex_array();
-	m_pbuffer = m_context->get_device()->create_buffer( VERTEX_BUFFER, STATIC_DRAW, m_vertex_count * m_vsize, (void*)m_vchannel->data );
+	m_pbuffer = m_context->get_device()->create_buffer( VERTEX_BUFFER, STATIC_DRAW, m_vertex_count * m_vsize, m_vchannel->data );
 	m_context->add_vertex_buffers( m_va, m_pbuffer, m_vchannel );
 
-	buffer  vb = m_context->get_device()->create_buffer( VERTEX_BUFFER, STATIC_DRAW, m_vertex_count * sizeof( vec2 ), (void*)m_mesh_data->get_channel<vertex_t>()->data );
+	buffer  vb = m_context->get_device()->create_buffer( VERTEX_BUFFER, STATIC_DRAW, m_vertex_count * sizeof( vec2 ), m_mesh_data->get_channel<vertex_t>()->data );
 	m_context->add_vertex_buffers( m_va, vb, m_mesh_data->get_channel<vertex_t>() );
 
-	buffer  ib = m_context->get_device()->create_buffer( INDEX_BUFFER, STATIC_DRAW, m_mesh_data->get_index_channel()->size(), (void*)m_mesh_data->get_index_channel()->data );
+	buffer  ib = m_context->get_device()->create_buffer( INDEX_BUFFER, STATIC_DRAW, m_mesh_data->get_index_channel()->size(), m_mesh_data->get_index_channel()->data );
 
 	m_context->set_index_buffer( m_va, ib, m_mesh_data->get_index_channel()->desc.slots[0].etype, true );
@@ -206,5 +206,5 @@
 		const vertex_pnt* prev = data + m_vertex_count * m_last_frame;
 		const vertex_pnt* next = data + m_vertex_count * m_next_frame;
-		      vertex_pnt* vtx  = (vertex_pnt*)m_data;
+		      vertex_pnt* vtx  = reinterpret_cast<vertex_pnt*>( m_data );
 		for ( size_t i = 0; i < m_vertex_count; ++i )
 		{
@@ -219,5 +219,5 @@
 		const vertex_pn* prev = data + m_vertex_count * m_last_frame;
 		const vertex_pn* next = data + m_vertex_count * m_next_frame;
-		      vertex_pn* vtx  = (vertex_pn*)m_data;
+		      vertex_pn* vtx  = reinterpret_cast<vertex_pn*>( m_data );
 
 		for ( size_t i = 0; i < m_vertex_count; ++i )
Index: /trunk/src/gfx/mesh_creator.cc
===================================================================
--- /trunk/src/gfx/mesh_creator.cc	(revision 405)
+++ /trunk/src/gfx/mesh_creator.cc	(revision 406)
@@ -24,6 +24,6 @@
 		if ( pkeys && pkeys->get_channel_count() > 0 && keys && keys->get_channel_count() > 0 )
 		{
-			nv_key_transform*  channel = ((nv_key_transform*)(keys->get_channel(0)->data));
-			nv_key_transform* pchannel = ((nv_key_transform*)(pkeys->get_channel(0)->data));
+			nv_key_transform*  channel = reinterpret_cast<nv_key_transform*>(keys->get_channel(0)->data);
+			nv_key_transform* pchannel = reinterpret_cast<nv_key_transform*>(pkeys->get_channel(0)->data);
 			for ( unsigned n = 0; n < count; ++n )
 			{
@@ -37,5 +37,5 @@
 	{
 		m_data->m_frame_rate = 32;
-		m_data->m_duration   = (float)max_frames;
+		m_data->m_duration   = static_cast<float>( max_frames );
 	}
 
@@ -69,5 +69,5 @@
 			key_data* new_keys = new key_data;
 			new_keys->add_channel( raw_channel );
-			nv_key_transform* channel = ((nv_key_transform*)(raw_channel->data));
+			nv_key_transform* channel = reinterpret_cast<nv_key_transform*>(raw_channel->data);
 			key_descriptor final_key = old_keys->get_final_key();
 
@@ -110,5 +110,5 @@
 				for ( size_t n = 0; n < channel->count; ++n )
 				{
-					transform_key_raw( channel->desc, (uint8*)(channel->data + n * key_size), scale, r33, ri33 );
+					transform_key_raw( channel->desc, channel->data + n * key_size, scale, r33, ri33 );
 				}
 			}
@@ -135,7 +135,7 @@
 			switch ( desc.slots[i].vslot )
 			{
-				case slot::POSITION : if ( desc.slots[i].etype == FLOAT_VECTOR_3 ) p_offset = (int)desc.slots[i].offset; break;
-				case slot::NORMAL   : if ( desc.slots[i].etype == FLOAT_VECTOR_3 ) n_offset = (int)desc.slots[i].offset; break;
-				case slot::TANGENT  : if ( desc.slots[i].etype == FLOAT_VECTOR_4 ) t_offset = (int)desc.slots[i].offset; break;
+				case slot::POSITION : if ( desc.slots[i].etype == FLOAT_VECTOR_3 ) p_offset = int(desc.slots[i].offset); break;
+				case slot::NORMAL   : if ( desc.slots[i].etype == FLOAT_VECTOR_3 ) n_offset = int(desc.slots[i].offset); break;
+				case slot::TANGENT  : if ( desc.slots[i].etype == FLOAT_VECTOR_4 ) t_offset = int(desc.slots[i].offset); break;
 				default             : break;
 			}
@@ -144,5 +144,5 @@
 			for ( uint32 i = 0; i < channel->count; i++)
 			{
-				vec3& p = *((vec3*)(raw_data + vtx_size*i + p_offset ));
+				vec3& p = *reinterpret_cast<vec3*>( raw_data + vtx_size*i + p_offset );
 				p = vertex_transform * p + vertex_offset;
 			}
@@ -151,5 +151,5 @@
 			for ( uint32 i = 0; i < channel->count; i++)
 			{
-				vec3& n = *((vec3*)(raw_data + vtx_size*i + n_offset ));
+				vec3& n = *reinterpret_cast<vec3*>( raw_data + vtx_size*i + n_offset );
 				n = glm::normalize( normal_transform * n );
 			}
@@ -157,5 +157,5 @@
 			for ( uint32 i = 0; i < channel->count; i++)
 			{
-				vec4& t = *((vec4*)(raw_data + vtx_size*i + t_offset ));
+				vec4& t = *reinterpret_cast<vec4*>(raw_data + vtx_size*i + t_offset );
 				t = vec4( glm::normalize( normal_transform * vec3(t) ), t[3] );
 			}
@@ -173,5 +173,5 @@
 	size_t n_offset = 0;
 	if ( ch_n == -1 ) return;
-	mesh_raw_channel* channel = m_data->m_channels[ (unsigned) ch_n ];
+	mesh_raw_channel* channel = m_data->m_channels[ unsigned( ch_n ) ];
 	for ( uint32 i = 0; i < channel->desc.count; ++i )
 		if ( channel->desc.slots[i].vslot == slot::NORMAL )
@@ -182,5 +182,5 @@
 	for ( uint32 i = 0; i < channel->count; ++i )
 	{
-		vec3& normal = *(vec3*)(channel->data + channel->desc.size * i + n_offset);
+		vec3& normal = *reinterpret_cast<vec3*>( channel->data + channel->desc.size * i + n_offset );
 		normal = -normal;
 	}
@@ -211,5 +211,5 @@
 				if ( desc.slots[i].etype == FLOAT_VECTOR_3 ) 
 				{
-					p_offset  = (int)desc.slots[i].offset; 
+					p_offset  = int( desc.slots[i].offset );
 					p_channel = channel;
 				}
@@ -217,5 +217,5 @@
 			case slot::NORMAL   : if ( desc.slots[i].etype == FLOAT_VECTOR_3 ) 
 				{
-					n_offset  = (int)desc.slots[i].offset; 
+					n_offset  = int( desc.slots[i].offset );
 					n_channel = m_data->m_channels[ c ];
 					n_channel_index = c;
@@ -224,5 +224,5 @@
 			case slot::TEXCOORD : if ( desc.slots[i].etype == FLOAT_VECTOR_2 ) 
 				{
-					t_offset  = (int)desc.slots[i].offset; 
+					t_offset  = int( desc.slots[i].offset );
 					t_channel = channel;
 				}
@@ -246,5 +246,5 @@
 
 	mesh_raw_channel* g_channel = mesh_raw_channel::create<vertex_g>( p_channel->count );
-	vec4* tangents              = (vec4*)g_channel->data;
+	vec4* tangents              = reinterpret_cast<vec4*>( g_channel->data );
 	vec3* tangents2             = new vec3[ p_channel->count ];
 	uint32 tri_count = i_channel ? i_channel->count / 3 : t_channel->count / 3;
@@ -259,5 +259,5 @@
 		if ( i_type == UINT )
 		{
-			const uint32* idata = (const uint32*)i_channel->data;
+			const uint32* idata = reinterpret_cast<const uint32*>( i_channel->data );
 			ti0 = idata[ i * 3 ];
 			ti1 = idata[ i * 3 + 1 ];
@@ -266,5 +266,5 @@
 		else if ( i_type == USHORT )
 		{
-			const uint16* idata = (const uint16*)i_channel->data;
+			const uint16* idata = reinterpret_cast<const uint16*>( i_channel->data );
 			ti0 = idata[ i * 3 ];
 			ti1 = idata[ i * 3 + 1 ];
@@ -278,7 +278,7 @@
 		}
 
-		const vec2& w1 = *((vec2*)(t_channel->data + t_channel->desc.size*ti0 + t_offset ));
-		const vec2& w2 = *((vec2*)(t_channel->data + t_channel->desc.size*ti1 + t_offset ));
-		const vec2& w3 = *((vec2*)(t_channel->data + t_channel->desc.size*ti2 + t_offset ));
+		const vec2& w1 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc.size*ti0 + t_offset );
+		const vec2& w2 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc.size*ti1 + t_offset );
+		const vec2& w3 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc.size*ti2 + t_offset );
 		vec2 st1 = w3 - w1;
 		vec2 st2 = w2 - w1;
@@ -291,7 +291,7 @@
 			uint32 nti1 = t_channel->count * set + ti1;
 			uint32 nti2 = t_channel->count * set + ti2;
-			vec3 v1 = *((vec3*)(p_channel->data + p_channel->desc.size*nti0 + p_offset ));
-			vec3 v2 = *((vec3*)(p_channel->data + p_channel->desc.size*nti1 + p_offset ));
-			vec3 v3 = *((vec3*)(p_channel->data + p_channel->desc.size*nti2 + p_offset ));
+			vec3 v1 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc.size*nti0 + p_offset );
+			vec3 v2 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc.size*nti1 + p_offset );
+			vec3 v3 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc.size*nti2 + p_offset );
 			vec3 xyz1 = v3 - v1;
 			vec3 xyz2 = v2 - v1;
@@ -317,5 +317,5 @@
 	for ( unsigned int i = 0; i < vtx_count; ++i )
 	{
-		const vec3 n = *((vec3*)(n_channel->data + n_channel->desc.size*i + n_offset ));
+		const vec3 n = *reinterpret_cast<vec3*>( n_channel->data + n_channel->desc.size*i + n_offset );
 		const vec3 t = vec3(tangents[i]);
 		if ( ! ( t.x == 0.0f && t.y == 0.0f && t.z == 0.0f ) )
@@ -420,8 +420,8 @@
 	int och_ti = other->get_channel_index( slot::TEXCOORD );
 	if ( ch_pi == -1 || ch_ti == -1 ) return;
-	size_t size   = m_data->m_channels[ (unsigned)ch_ti ]->count;
-	size_t osize  =  other->m_channels[ (unsigned)och_ti ]->count;
-	size_t count  = m_data->m_channels[ (unsigned)ch_pi ]->count;
-	size_t ocount =  other->m_channels[ (unsigned)och_pi ]->count;
+	size_t size   = m_data->m_channels[ unsigned(ch_ti) ]->count;
+	size_t osize  =  other->m_channels[ unsigned(och_ti) ]->count;
+	size_t count  = m_data->m_channels[ unsigned(ch_pi) ]->count;
+	size_t ocount =  other->m_channels[ unsigned(och_pi) ]->count;
 	if ( count % size != 0 || ocount % osize != 0 ) return;
 	if ( count / size != ocount / osize ) return;
@@ -440,7 +440,7 @@
 				{
 					NV_ASSERT( size + osize < uint16(-1), "Index out of range!" );
-					uint16* indexes = (uint16*)m_data->m_channels[c]->data;
-					for ( uint16 i = (uint16)old->count; i < m_data->m_channels[c]->count; ++i )
-						indexes[i] += (uint16)size;
+					uint16* indexes = reinterpret_cast<uint16*>( m_data->m_channels[c]->data );
+					for ( uint16 i = uint16( old->count ); i < m_data->m_channels[c]->count; ++i )
+						indexes[i] += uint16( size );
 
 				}
@@ -448,5 +448,5 @@
 			case UINT   : 
 				{
-					uint32* indexes = (uint32*)m_data->m_channels[c]->data;
+					uint32* indexes = reinterpret_cast<uint32*>( m_data->m_channels[c]->data );
 					for ( uint32 i = old->count; i < m_data->m_channels[c]->count; ++i )
 						indexes[i] += size;
Index: /trunk/src/gfx/skeletal_mesh.cc
===================================================================
--- /trunk/src/gfx/skeletal_mesh.cc	(revision 405)
+++ /trunk/src/gfx/skeletal_mesh.cc	(revision 406)
@@ -16,5 +16,5 @@
 {
 	const mesh_raw_channel* pnt_chan = a_mesh_data->get_channel<md5_vtx_pnt>();
-	m_pntdata.assign( (const md5_vtx_pnt*)pnt_chan->data, pnt_chan->count );
+	m_pntdata.assign( reinterpret_cast<const md5_vtx_pnt*>( pnt_chan->data ), pnt_chan->count );
 	m_bone_offset.resize( bones->get_count() );
 	m_transform.resize( bones->get_count() );
@@ -35,6 +35,6 @@
 	if ( a_anim )
 	{
-		skeletal_animation_entry_cpu * anim = (skeletal_animation_entry_cpu*)a_anim;
-		anim->update_skeleton( m_transform.data(), (float)a_anim_time );
+		skeletal_animation_entry_cpu * anim = static_cast<skeletal_animation_entry_cpu*>( a_anim );
+		anim->update_skeleton( m_transform.data(), static_cast<float>( a_anim_time ) );
 		{
 			size_t skeleton_size = m_bone_offset.size();
@@ -51,7 +51,7 @@
 				const md5_vtx_pntiw& vert = m_vtx_data[i];
 
-				for ( size_t j = 0; j < 4; ++j )
+				for ( int j = 0; j < 4; ++j )
 				{
-					unsigned index = (unsigned)vert.boneindex[j];
+					unsigned index = unsigned( vert.boneindex[j] );
 					float weight   = vert.boneweight[j];
 					const quat& orient      = m_transform[index].get_orientation();
@@ -71,5 +71,5 @@
 void nv::skeletal_animation_entry_cpu::update_skeleton( transform* skeleton, float time ) const
 {
-	float frame_duration = 1000.f / (float)m_node_data->get_frame_rate();
+	float frame_duration = 1000.f / static_cast<float>( m_node_data->get_frame_rate() );
 	float anim_duration = frame_duration * m_node_data->get_duration();
 	float new_time = fmodf( time, anim_duration ) * 0.001f;
@@ -152,5 +152,5 @@
 		if ( bi != bone_names.end() )
 		{
-			bone_id = (sint16)bi->second;
+			bone_id = sint16( bi->second );
 		}
 		m_bone_ids[n] = bone_id;
@@ -207,5 +207,5 @@
 	if ( m_bone_data && a_anim )
 	{
-		skeletal_animation_entry_gpu * anim = (skeletal_animation_entry_gpu*)a_anim;
+		skeletal_animation_entry_gpu * anim = static_cast<skeletal_animation_entry_gpu*>( a_anim );
 		anim->prepare( m_bone_data );
 		anim->update_skeleton( m_transform, a_anim_time );
Index: /trunk/src/gl/gl_context.cc
===================================================================
--- /trunk/src/gl/gl_context.cc	(revision 405)
+++ /trunk/src/gl/gl_context.cc	(revision 406)
@@ -91,5 +91,5 @@
 	// TODO: support GL_READ_FRAMEBUFFER?
 	const gl_framebuffer_info* info  = m_framebuffers.get( f );
-	const gl_texture_info*     tinfo = (gl_texture_info*)m_device->get_texture_info( t );
+	const gl_texture_info*     tinfo = static_cast< const gl_texture_info* >( m_device->get_texture_info( t ) );
 	if ( info )
 	{
@@ -101,9 +101,9 @@
 			//		if ( tinfo->size.y == 0 )
 				//			glFramebufferTexture1D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0+(unsigned)slot, GL_TEXTURE_1D, tinfo->glid, 0 );
-			glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0+(unsigned)slot, gl_type, tinfo->glid, 0 );
+			glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0+unsigned( slot ), gl_type, tinfo->glid, 0 );
 		}
 		else
 		{
-			glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0+(unsigned)slot, gl_type, 0, 0 );
+			glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0+unsigned( slot ), gl_type, 0, 0 );
 		}
 
@@ -116,5 +116,5 @@
 	// TODO: support GL_READ_FRAMEBUFFER?
 	const gl_framebuffer_info* info  = m_framebuffers.get( f );
-	const gl_texture_info*     tinfo = (gl_texture_info*)m_device->get_texture_info( depth );
+	const gl_texture_info*     tinfo = static_cast< const gl_texture_info* >( m_device->get_texture_info( depth ) );
 	if ( info )
 	{
@@ -213,9 +213,10 @@
 void nv::gl_context::bind( program p )
 {
-	gl_program_info* info = ((gl_device*)m_device)->m_programs.get( p );
+	gl_device* gdevice    = static_cast<gl_device*>( m_device );
+	gl_program_info* info = gdevice->m_programs.get( p );
 	if ( info )
 	{
 		glUseProgram( info->glid );
-		((gl_device*)m_device)->update_uniforms( info );
+		gdevice->update_uniforms( info );
 	}
 }
@@ -248,11 +249,11 @@
 			}
 
-			glVertexAttribPointer( 
-				location, 
-				static_cast<GLint>( vba.components ), 
+			glVertexAttribPointer(
+				location,
+				static_cast<GLint>( vba.components ),
 				nv::datatype_to_gl_enum( vba.dtype ),
 				GL_FALSE,
 				static_cast<GLsizei>( vba.stride ),
-				(void*)vba.offset
+				reinterpret_cast<void*>( vba.offset )
 				);
 		}
@@ -317,5 +318,5 @@
 }
 
-void nv::gl_context::update( texture t, void* data )
+void nv::gl_context::update( texture t, const void* data )
 {
 	const gl_texture_info* info = static_cast< const gl_texture_info* >( m_device->get_texture_info( t ) );
@@ -327,5 +328,5 @@
 
 		glBindTexture( gl_type, info->glid );
-		glTexImage2D( gl_type, 0, (GLint)nv::image_format_to_internal_enum(format.format), size.x, size.y, 0, nv::image_format_to_enum(format.format), nv::datatype_to_gl_enum(format.type), data );
+		glTexImage2D( gl_type, 0, static_cast<GLint>( nv::image_format_to_internal_enum(format.format) ), size.x, size.y, 0, nv::image_format_to_enum(format.format), nv::datatype_to_gl_enum(format.type), data );
 	}
 }
@@ -338,5 +339,5 @@
 		GLenum glenum = buffer_type_to_enum( info->type );
 		glBindBuffer( glenum, info->glid );
-		glBufferSubData( glenum, (GLintptr)offset, (GLsizeiptr)size, data );
+		glBufferSubData( glenum, GLintptr( offset ), GLsizeiptr( size ), data );
 	}
 }
@@ -700,5 +701,5 @@
 void nv::gl_context::apply_engine_uniforms( program p, const scene_state& s )
 {
-	gl_program_info* info = ((gl_device*)m_device)->m_programs.get( p );
+	gl_program_info* info = static_cast<gl_device*>( m_device )->m_programs.get( p );
 	if ( info )
 	{
@@ -725,5 +726,5 @@
 		if ( slots[i] > OUTPUT_7 ) buffers[i] = 0;
 	}
-	glDrawBuffers( (GLsizei)count, buffers );
+	glDrawBuffers( GLsizei( count ), buffers );
 }
 
Index: /trunk/src/gl/gl_device.cc
===================================================================
--- /trunk/src/gl/gl_device.cc	(revision 405)
+++ /trunk/src/gl/gl_device.cc	(revision 406)
@@ -53,5 +53,5 @@
 	assert( image->format->BytesPerPixel > 2 );
 	image_format format(image->format->BytesPerPixel == 3 ? RGB : RGBA, UBYTE );
-	image_data* data = new image_data( format, ivec2( image->w, image->h ), (nv::uint8*)image->pixels );
+	image_data* data = new image_data( format, ivec2( image->w, image->h ), static_cast<nv::uint8*>( image->pixels ) );
 	return data;
 }
@@ -62,5 +62,5 @@
 {
 	load_sdl_image_library();
-	SDL_Surface* image = IMG_LoadTyped_RW( SDL_RWFromMem( (void*)data, (int)size ), 1, "png" );
+	SDL_Surface* image = IMG_LoadTyped_RW( SDL_RWFromMem( const_cast<uint8*>( data ), int( size ) ), 1, "png" );
 	if ( !image )
 	{
@@ -71,5 +71,5 @@
 	assert( image->format->BytesPerPixel > 2 );
 	image_format format( image->format->BytesPerPixel == 3 ? RGB : RGBA, UBYTE );
-	image_data* idata = new image_data( format, ivec2( image->w, image->h ), ( nv::uint8* )image->pixels );
+	image_data* idata = new image_data( format, ivec2( image->w, image->h ), static_cast<nv::uint8*>( image->pixels ) );
 	return idata;
 }
@@ -86,5 +86,5 @@
 }
 
-nv::texture nv::gl_device::create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, void* data /*= nullptr */ )
+nv::texture nv::gl_device::create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, const void* data /*= nullptr */ )
 {
 	unsigned glid = 0;
@@ -106,10 +106,10 @@
 	}
 
-	glTexParameteri( gl_type, GL_TEXTURE_MIN_FILTER, (int)nv::sampler_filter_to_enum( asampler.filter_min ) );
-	glTexParameteri( gl_type, GL_TEXTURE_MAG_FILTER, (int)nv::sampler_filter_to_enum( asampler.filter_max ) );
-	glTexParameteri( gl_type, GL_TEXTURE_WRAP_S, (int)nv::sampler_wrap_to_enum( asampler.wrap_s) );
-	glTexParameteri( gl_type, GL_TEXTURE_WRAP_T, (int)nv::sampler_wrap_to_enum( asampler.wrap_t) );
-
-	glTexImage2D( gl_type, 0, (GLint)nv::image_format_to_internal_enum(aformat.format), size.x, size.y, 0, nv::image_format_to_enum(aformat.format), nv::datatype_to_gl_enum(aformat.type), data );
+	glTexParameteri( gl_type, GL_TEXTURE_MIN_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_min ) ) );
+	glTexParameteri( gl_type, GL_TEXTURE_MAG_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_max ) ) );
+	glTexParameteri( gl_type, GL_TEXTURE_WRAP_S, GLint( nv::sampler_wrap_to_enum( asampler.wrap_s) ) );
+	glTexParameteri( gl_type, GL_TEXTURE_WRAP_T, GLint( nv::sampler_wrap_to_enum( asampler.wrap_t) ) );
+
+	glTexImage2D( gl_type, 0, GLint( nv::image_format_to_internal_enum(aformat.format) ), size.x, size.y, 0, nv::image_format_to_enum(aformat.format), nv::datatype_to_gl_enum(aformat.type), data );
 
 	glBindTexture( gl_type, 0 );
@@ -163,5 +163,5 @@
 
 	glBindBuffer( glenum, glid );
-	glBufferData( glenum, (GLsizeiptr)size, source, buffer_hint_to_enum( hint ) );
+	glBufferData( glenum, GLsizeiptr( size ), source, buffer_hint_to_enum( hint ) );
 	glBindBuffer( glenum, 0 );
 
@@ -325,15 +325,15 @@
 			switch( ubase->get_type() )
 			{
-			case FLOAT          : glUniform1fv( uloc, ubase->get_length(), ((uniform< enum_to_type< FLOAT >::type >*)( ubase ))->get_value() ); break;
-			case INT            : glUniform1iv( uloc, ubase->get_length(), ((uniform< enum_to_type< INT >::type >*)( ubase ))->get_value() ); break;
-			case FLOAT_VECTOR_2 : glUniform2fv( uloc, ubase->get_length(), (GLfloat*)((uniform< enum_to_type< FLOAT_VECTOR_2 >::type >*)( ubase ))->get_value()); break;
-			case FLOAT_VECTOR_3 : glUniform3fv( uloc, ubase->get_length(), (GLfloat*)((uniform< enum_to_type< FLOAT_VECTOR_3 >::type >*)( ubase ))->get_value()); break;
-			case FLOAT_VECTOR_4 : glUniform4fv( uloc, ubase->get_length(), (GLfloat*)((uniform< enum_to_type< FLOAT_VECTOR_4 >::type >*)( ubase ))->get_value()); break;
-			case INT_VECTOR_2   : glUniform2iv( uloc, ubase->get_length(), (GLint*)((uniform< enum_to_type< INT_VECTOR_2 >::type >*)( ubase ))->get_value()); break;
-			case INT_VECTOR_3   : glUniform3iv( uloc, ubase->get_length(), (GLint*)((uniform< enum_to_type< INT_VECTOR_3 >::type >*)( ubase ))->get_value()); break;
-			case INT_VECTOR_4   : glUniform4iv( uloc, ubase->get_length(), (GLint*)((uniform< enum_to_type< INT_VECTOR_4 >::type >*)( ubase ))->get_value()); break;
-			case FLOAT_MATRIX_2 : glUniformMatrix2fv( uloc, ubase->get_length(), GL_FALSE, (GLfloat*)((uniform< enum_to_type< FLOAT_MATRIX_2 >::type >*)( ubase ))->get_value()); break;
-			case FLOAT_MATRIX_3 : glUniformMatrix3fv( uloc, ubase->get_length(), GL_FALSE, (GLfloat*)((uniform< enum_to_type< FLOAT_MATRIX_3 >::type >*)( ubase ))->get_value()); break;
-			case FLOAT_MATRIX_4 : glUniformMatrix4fv( uloc, ubase->get_length(), GL_FALSE, (GLfloat*)((uniform< enum_to_type< FLOAT_MATRIX_4 >::type >*)( ubase ))->get_value()); break;
+			case FLOAT          : glUniform1fv( uloc, ubase->get_length(), static_cast< uniform< enum_to_type< FLOAT >::type >*>( ubase )->get_value() ); break;
+			case INT            : glUniform1iv( uloc, ubase->get_length(), static_cast< uniform< enum_to_type< INT >::type >*>( ubase )->get_value() ); break;
+			case FLOAT_VECTOR_2 : glUniform2fv( uloc, ubase->get_length(), reinterpret_cast<const GLfloat*>( static_cast< uniform< enum_to_type< FLOAT_VECTOR_2 >::type >*>( ubase )->get_value())); break;
+			case FLOAT_VECTOR_3 : glUniform3fv( uloc, ubase->get_length(), reinterpret_cast<const GLfloat*>( static_cast< uniform< enum_to_type< FLOAT_VECTOR_3 >::type >*>( ubase )->get_value())); break;
+			case FLOAT_VECTOR_4 : glUniform4fv( uloc, ubase->get_length(), reinterpret_cast<const GLfloat*>( static_cast< uniform< enum_to_type< FLOAT_VECTOR_4 >::type >*>( ubase )->get_value())); break;
+			case INT_VECTOR_2   : glUniform2iv( uloc, ubase->get_length(), reinterpret_cast<const GLint*>( static_cast< uniform< enum_to_type< INT_VECTOR_2 >::type >*>( ubase )->get_value())); break;
+			case INT_VECTOR_3   : glUniform3iv( uloc, ubase->get_length(), reinterpret_cast<const GLint*>( static_cast< uniform< enum_to_type< INT_VECTOR_3 >::type >*>( ubase )->get_value())); break;
+			case INT_VECTOR_4   : glUniform4iv( uloc, ubase->get_length(), reinterpret_cast<const GLint*>( static_cast< uniform< enum_to_type< INT_VECTOR_4 >::type >*>( ubase )->get_value())); break;
+			case FLOAT_MATRIX_2 : glUniformMatrix2fv( uloc, ubase->get_length(), GL_FALSE, reinterpret_cast<const GLfloat*>( static_cast< uniform< enum_to_type< FLOAT_MATRIX_2 >::type >*>( ubase )->get_value())); break;
+			case FLOAT_MATRIX_3 : glUniformMatrix3fv( uloc, ubase->get_length(), GL_FALSE, reinterpret_cast<const GLfloat*>( static_cast< uniform< enum_to_type< FLOAT_MATRIX_3 >::type >*>( ubase )->get_value())); break;
+			case FLOAT_MATRIX_4 : glUniformMatrix4fv( uloc, ubase->get_length(), GL_FALSE, reinterpret_cast<const GLfloat*>( static_cast< uniform< enum_to_type< FLOAT_MATRIX_4 >::type >*>( ubase )->get_value())); break;
 			default : break; // error?
 			}
@@ -348,5 +348,5 @@
 	glGetProgramiv( p->glid, GL_ACTIVE_ATTRIBUTES, &params );
 
-	for ( unsigned i = 0; i < (unsigned)params; ++i )
+	for ( unsigned i = 0; i < unsigned( params ); ++i )
 	{
 		int attr_nlen;
@@ -377,5 +377,5 @@
 	glGetProgramiv( p->glid, GL_ACTIVE_UNIFORMS, &params );
 
-	for ( unsigned i = 0; i < size_t(params); ++i )
+	for ( unsigned i = 0; i < unsigned( params ); ++i )
 	{
 		int uni_nlen;
@@ -412,5 +412,5 @@
 
 	const char* pc = shader_code.data();
-	int l = (int)shader_code.length();
+	int l = int( shader_code.length() );
 
 	glShaderSource( glid, 1, &pc, &l );
@@ -428,9 +428,9 @@
 		if ( compile_ok == 0 )
 		{
-			NV_LOG_ERROR( "Shader #", glid, " error: ", buffer );
+			NV_LOG_ERROR( "Shader #", glid, " error: ", string_view( buffer, size_t( length ) ) );
 		}
 		else
 		{
-			NV_LOG_INFO( "Shader #", glid, " compiled successfully: ", buffer );
+			NV_LOG_INFO( "Shader #", glid, " compiled successfully: ", string_view( buffer, size_t( length ) ) );
 		}
 	}
Index: /trunk/src/gl/gl_window.cc
===================================================================
--- /trunk/src/gl/gl_window.cc	(revision 405)
+++ /trunk/src/gl/gl_window.cc	(revision 406)
@@ -15,5 +15,5 @@
 {
 #if NV_PLATFORM == NV_WINDOWS
-		::SwapBuffers( (HDC)m_hwnd );
+		::SwapBuffers( reinterpret_cast<HDC>( m_hwnd ) );
 #else
 	NV_ASSERT( false, "Native GL context currently only working on Windows!" );
@@ -26,5 +26,5 @@
 	{
 #if NV_PLATFORM == NV_WINDOWS
-			dynwglDeleteContext( (HGLRC)m_context->get_native_handle() );
+			dynwglDeleteContext( reinterpret_cast<HGLRC>( m_context->get_native_handle() ) );
 #endif
 	}
@@ -40,8 +40,8 @@
 	m_input = a_input;
 
-	m_handle = (void*)handle;
+	m_handle = handle;
 
 	// TODO: error checking
-	HDC hdc = (HDC)dc;
+	HDC hdc = reinterpret_cast<HDC>( dc );
 
 	const int wgl_attrib_list[] =
@@ -103,5 +103,5 @@
 //  	m_height  = (uint16)rect.bottom;
 	m_handle  = wm->adopt_window( handle );
-	m_hwnd    = ::GetDC( (HWND)handle );
+	m_hwnd    = ::GetDC( reinterpret_cast<HWND>( handle ) );
 	m_context->set_viewport( nv::ivec4( 0, 0, m_width, m_height ) );
 #else
Index: /trunk/src/gui/gui_ascii_renderer.cc
===================================================================
--- /trunk/src/gui/gui_ascii_renderer.cc	(revision 405)
+++ /trunk/src/gui/gui_ascii_renderer.cc	(revision 406)
@@ -18,5 +18,5 @@
 	bool   clear;
 	bool   border;
-	char   border_chars[8];
+	uchar8 border_chars[8];
 	uint32 border_color;
 	uint32 text_color;
@@ -42,5 +42,5 @@
 	}
 	else 
-		er = (ascii_render_data*)( e->m_render_data );
+		er = static_cast< ascii_render_data* >( e->m_render_data );
 
 	rectangle abs = e->m_absolute;
@@ -68,5 +68,5 @@
 				er->border_color = uint32( border_color );
 			for ( uint32 i = 0; i < 8 && i < path.length(); )
-				er->border_chars[i] = path[i];
+				er->border_chars[i] = static_cast< uchar8 >( path[i] );
 		}
 	}
@@ -75,5 +75,5 @@
 void ascii_renderer::draw( element* e )
 {
-	ascii_render_data* er = (ascii_render_data*)( e->m_render_data );
+	ascii_render_data* er = static_cast< ascii_render_data* >( e->m_render_data );
 	rectangle abs = e->m_absolute;
 	if ( er->clear ) m_terminal->clear( abs );
@@ -82,18 +82,18 @@
 		for ( int x = 0; x < abs.get_width(); ++x )
 		{
-			m_terminal->print( position( abs.ul.y, abs.ul.x + x ), er->border_color, (unsigned char)er->border_chars[0] );
-			m_terminal->print( position( abs.lr.y, abs.ul.x + x ), er->border_color, (unsigned char)er->border_chars[1] );
+			m_terminal->print( position( abs.ul.y, abs.ul.x + x ), er->border_color, er->border_chars[0] );
+			m_terminal->print( position( abs.lr.y, abs.ul.x + x ), er->border_color, er->border_chars[1] );
 		}
 
 		for ( int y = 0; y < abs.get_height(); ++y )
 		{
-			m_terminal->print( position( abs.ul.y + y, abs.ul.x ), er->border_color, (unsigned char)er->border_chars[2] );
-			m_terminal->print( position( abs.ul.y + y, abs.lr.x ), er->border_color, (unsigned char)er->border_chars[3] );
+			m_terminal->print( position( abs.ul.y + y, abs.ul.x ), er->border_color, er->border_chars[2] );
+			m_terminal->print( position( abs.ul.y + y, abs.lr.x ), er->border_color, er->border_chars[3] );
 		}
 
-		m_terminal->print( abs.ul,   er->border_color, (unsigned char)er->border_chars[4] );
-		m_terminal->print( abs.ur(), er->border_color, (unsigned char)er->border_chars[5] );
-		m_terminal->print( abs.ll(), er->border_color, (unsigned char)er->border_chars[6] );
-		m_terminal->print( abs.lr,   er->border_color, (unsigned char)er->border_chars[7] );
+		m_terminal->print( abs.ul,   er->border_color, er->border_chars[4] );
+		m_terminal->print( abs.ur(), er->border_color, er->border_chars[5] );
+		m_terminal->print( abs.ll(), er->border_color, er->border_chars[6] );
+		m_terminal->print( abs.lr,   er->border_color, er->border_chars[7] );
 	}
 	if ( !e->m_text.empty() )
@@ -102,5 +102,5 @@
 		for ( char c : e->m_text )
 		{
-			m_terminal->print( p, er->text_color, (unsigned char)c );
+			m_terminal->print( p, er->text_color, static_cast< unsigned char >( c ) );
 			++p.x;
 		}
Index: /trunk/src/gui/gui_gfx_renderer.cc
===================================================================
--- /trunk/src/gui/gui_gfx_renderer.cc	(revision 405)
+++ /trunk/src/gui/gui_gfx_renderer.cc	(revision 406)
@@ -190,5 +190,5 @@
 {
 	std::string id_name( filename );
-	char buffer[8]; size_t len = nv::sint32_to_buffer( (sint32)size, buffer );
+	char buffer[8]; size_t len = nv::sint32_to_buffer( sint32( size ), buffer );
 	id_name.append( std::string( buffer, len ) );
 	auto i = m_font_names.find( id_name );
@@ -197,6 +197,6 @@
 		return i->second;
 	}
-	size_t result = (size_t)m_fonts.size();
-	texture_font* f = new texture_font( &m_atlas, filename.c_str(), (float)size );
+	size_t result = m_fonts.size();
+	texture_font* f = new texture_font( &m_atlas, filename.c_str(), static_cast<float>( size ) );
 	f->load_glyphs( "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ " );
 	m_fonts.push_back( f );
@@ -228,10 +228,10 @@
 void gfx_renderer::redraw( element* e, uint32 )
 {
-	screen_render_data* sr = (screen_render_data*)m_render_data;
+	screen_render_data* sr = reinterpret_cast< screen_render_data* >( m_render_data );
 	if ( e->m_render_data == nullptr )
 	{
 		e->m_render_data = new element_render_data( &sr->buffer );
 	}
-	element_render_data* er = (element_render_data*)( e->m_render_data );
+	element_render_data* er = reinterpret_cast< element_render_data* >( e->m_render_data );
 	size_t size_before = er->buffer.data().size();
 
@@ -318,5 +318,5 @@
 			if ( m_style.get( e, "text_color", selector, color ) && m_style.get( e, "text_font", selector, path ) && m_style.get( e, "text_size", selector, border ) )
 			{
-				size_t font_id = load_font( path, (uint16)border );
+				size_t font_id = load_font( path, size_t( border ) );
 				texture_font* font = get_font( font_id );
 				position p = abs.ul + position( 0, border );
@@ -361,5 +361,5 @@
 void gfx_renderer::draw( element* e )
 {
-	element_render_data* er = (element_render_data*)( e->m_render_data );
+	element_render_data* er = reinterpret_cast< element_render_data* >( e->m_render_data );
 	er->buffer.commit();
 }
@@ -367,9 +367,9 @@
 void gfx_renderer::draw()
 {
-	screen_render_data* sr = (screen_render_data*)m_render_data;
+	screen_render_data* sr = reinterpret_cast< screen_render_data* >( m_render_data );
 
 	if ( m_reupload )
 	{
-		m_context->update( sr->tex, (void*)m_atlas.get_data() );
+		m_context->update( sr->tex, m_atlas.get_data() );
 		m_reupload = false;
 	}
@@ -392,5 +392,5 @@
 	if ( m_render_data )
 	{
-		m_context->get_device()->release( ( (screen_render_data*)m_render_data )->tex );
+		m_context->get_device()->release( reinterpret_cast< screen_render_data* >( m_render_data )->tex );
 		delete m_render_data;
 	}
Index: /trunk/src/gui/gui_style.cc
===================================================================
--- /trunk/src/gui/gui_style.cc	(revision 405)
+++ /trunk/src/gui/gui_style.cc	(revision 406)
@@ -34,9 +34,9 @@
 	if ( !resolve( e->m_id.c_str(), e->m_class.c_str(), cselector, centry, LUA_TTABLE ) ) return false;
 	vec = vec4();
-	for (size_t i = 0; i < 4; ++i )
+	for ( int i = 0; i < 4; ++i )
 	{
-		lua_rawgeti( m_lua, -1, static_cast<int>( i+1 ) );
+		lua_rawgeti( m_lua, -1, i+1 );
 		if ( lua_isnil( m_lua, -1 ) ) return true;
-		vec[i] = (float)lua_tonumber( m_lua, -1 );
+		vec[i] = static_cast< float >( lua_tonumber( m_lua, -1 ) );
 		lua_pop( m_lua, 1 );
 	}
Index: /trunk/src/io/c_stream.cc
===================================================================
--- /trunk/src/io/c_stream.cc	(revision 405)
+++ /trunk/src/io/c_stream.cc	(revision 406)
@@ -31,5 +31,5 @@
 	if ( m_file )
 	{
-		::fclose( (FILE*)m_file );
+		::fclose( reinterpret_cast<FILE*>( m_file ) );
 	}
 }
@@ -38,5 +38,5 @@
 {
 	NV_ASSERT( buffer != nullptr && size != 0 && count != 0, "Bad parameter passed to read!" );
-	return m_file ? ::fread( buffer, size, count, (FILE*)m_file ) : 0;
+	return m_file ? ::fread( buffer, size, count, reinterpret_cast<FILE*>( m_file ) ) : 0;
 }
 
@@ -44,15 +44,15 @@
 {
 	NV_ASSERT( buffer != nullptr && size != 0 && count != 0, "Bad parameter passed to write!" );
-	return m_file ? ::fwrite( buffer, size, count, (FILE*)m_file ) : 0;
+	return m_file ? ::fwrite( buffer, size, count, reinterpret_cast<FILE*>( m_file ) ) : 0;
 }
 
 bool c_stream::seek( long offset, origin orig )
 {
-	return m_file != nullptr && ( ::fseek( (FILE*)m_file, (long)offset, static_cast<int>(orig) ) == 0 );
+	return m_file != nullptr && ( ::fseek( reinterpret_cast<FILE*>( m_file ), offset, static_cast<int>(orig) ) == 0 );
 }
 
 nv::size_t c_stream::tell()
 {
-	return m_file != nullptr ? static_cast< nv::size_t >( ::ftell( (FILE*)m_file ) ) : 0;
+	return m_file != nullptr ? static_cast< nv::size_t >( ::ftell( reinterpret_cast<FILE*>( m_file ) ) ) : 0;
 }
 
@@ -72,5 +72,5 @@
 			return 0; 
 		}
-		m_file_size = (size_t) (fstat.st_size); 		
+		m_file_size = static_cast<size_t>(fstat.st_size); 		
 	}
 
@@ -82,5 +82,5 @@
 	if ( m_file != nullptr )
 	{
-		::fflush( (FILE*)m_file );
+		::fflush( reinterpret_cast<FILE*>( m_file ) );
 	}
 }
Index: /trunk/src/io/string_table.cc
===================================================================
--- /trunk/src/io/string_table.cc	(revision 405)
+++ /trunk/src/io/string_table.cc	(revision 406)
@@ -22,5 +22,5 @@
 	uint32 cs_size = s.size() + 1;
 	NV_ASSERT( m_offsets.size() < index(-1), "Too many strings!" );
-	index  result  = (index)m_offsets.size();
+	index  result = index( m_offsets.size() );
 	size_t dsize = m_data.size();
 	m_offsets.push_back( dsize );
@@ -37,10 +37,10 @@
 	raw_copy( m_offsets.begin(), m_offsets.end(), offsets );
 	raw_copy( m_data.begin(),    m_data.end(),    data );
-	return new string_table( data, m_data.size(), offsets, (index)m_offsets.size() );
+	return new string_table( data, m_data.size(), offsets, index( m_offsets.size() ) );
 }
 
 void nv::string_table_creator::dump( nv::stream* out ) const
 {
-	index  count = (index)m_offsets.size();
+	index  count = index( m_offsets.size() );
 	uint32 size  = m_data.size();
 	out->write( &count,  sizeof( count ), 1 );
Index: /trunk/src/lib/assimp.cc
===================================================================
--- /trunk/src/lib/assimp.cc	(revision 405)
+++ /trunk/src/lib/assimp.cc	(revision 406)
@@ -35,5 +35,5 @@
 	assimp_library.open( path );
 
-#	define NV_ASSIMP_FUN( rtype, fname, fparams ) *(void **) (&fname) = assimp_library.get(#fname);
+#	define NV_ASSIMP_FUN( rtype, fname, fparams ) void_assign( fname, assimp_library.get(#fname) );
 #	include <nv/lib/detail/assimp_functions.inc>
 #	undef NV_ASSIMP_FUN
Index: /trunk/src/lib/curses.cc
===================================================================
--- /trunk/src/lib/curses.cc	(revision 405)
+++ /trunk/src/lib/curses.cc	(revision 406)
@@ -22,5 +22,5 @@
 	curses_library.open( path );
 
-#	define NV_CURSES_FUN( rtype, fname, fparams ) *(void **) (&::fname) = curses_library.get(#fname);
+#	define NV_CURSES_FUN( rtype, fname, fparams ) void_assign( ::fname, curses_library.get(#fname) );
 #	include <nv/lib/detail/curses_functions.inc>
 #	undef NV_CURSES_FUN
Index: /trunk/src/lib/fmod.cc
===================================================================
--- /trunk/src/lib/fmod.cc	(revision 405)
+++ /trunk/src/lib/fmod.cc	(revision 406)
@@ -125,5 +125,5 @@
 	fmod_library.open( path );
 
-#	define NV_FMOD_FUN( rtype, fname, fparams ) *(void **) (&fname) = fmod_library.get(#fname);
+#	define NV_FMOD_FUN( rtype, fname, fparams ) void_assign( fname, fmod_library.get(#fname) );
 #	include <nv/lib/detail/fmod_functions.inc>
 #	undef NV_FMOD_FUN
Index: /trunk/src/lib/freetype2.cc
===================================================================
--- /trunk/src/lib/freetype2.cc	(revision 405)
+++ /trunk/src/lib/freetype2.cc	(revision 406)
@@ -21,5 +21,5 @@
 	freetype_library.open( path );
 
-#	define NV_FREETYPE_FUN( rtype, fname, fparams ) *(void **) (&fname) = freetype_library.get(#fname);
+#	define NV_FREETYPE_FUN( rtype, fname, fparams ) void_assign( fname, freetype_library.get(#fname) );
 #	include <nv/lib/detail/freetype2_functions.inc>
 #	undef NV_FREETYPE_FUN
Index: /trunk/src/lib/gl.cc
===================================================================
--- /trunk/src/lib/gl.cc	(revision 405)
+++ /trunk/src/lib/gl.cc	(revision 406)
@@ -82,21 +82,21 @@
 	if ( gl_library_loaded && !force_reload ) return true;
 #if defined( NV_SDL_GL )
-#		define NV_GL_LOAD( symbol ) *(void **) (&symbol) = SDL_GL_GetProcAddress(#symbol);
-#		define NV_GL_LOAD_EXT( symbol ) *(void **) (&symbol) = SDL_GL_GetProcAddress(#symbol);
-	*(void **) (&gl_ext_loader) = SDL_GL_GetProcAddress;
+#		define NV_GL_LOAD( symbol ) void_assign( symbol, SDL_GL_GetProcAddress(#symbol) );
+#		define NV_GL_LOAD_EXT( symbol ) void_assign( symbol, SDL_GL_GetProcAddress(#symbol) );
+	void_assign( gl_ext_loader, SDL_GL_GetProcAddress );
 #else
 	if ( !gl_library.is_open() ) gl_library.open( path );
 
 #	if NV_PLATFORM == NV_WINDOWS 
-#		define NV_GL_LOAD( symbol ) *(void **) (&symbol) = gl_library.get(#symbol);
-		*(void **) (&gl_ext_loader) = gl_library.get("wglGetProcAddress");
-#		define NV_GL_LOAD_EXT( symbol ) *(void **) (&symbol) = gl_ext_loader(#symbol);
+#		define NV_GL_LOAD( symbol ) void_assign( symbol, gl_library.get(#symbol) );
+		void_assign( gl_ext_loader, gl_library.get( "wglGetProcAddress" ) );
+#		define NV_GL_LOAD_EXT( symbol ) void_assign( symbol, gl_ext_loader(#symbol) );
 #	elif (NV_PLATFORM == NV_LINUX || NV_PLATFORM == NV_APPLE)
-#		define NV_GL_LOAD( symbol ) *(void **) (&symbol) = gl_library.get(#symbol);
-		*(void **) (&gl_ext_loader) = gl_library.get("glXGetProcAddress");
-#		define NV_GL_LOAD_EXT( symbol ) *(void **) (&symbol) = gl_ext_loader(#symbol);
+#		define NV_GL_LOAD( symbol ) void_assign( symbol, gl_library.get(#symbol) );
+		void_assign( gl_ext_loader, gl_library.get("glXGetProcAddress") );
+#		define NV_GL_LOAD_EXT( symbol ) void_assign( symbol, gl_ext_loader(#symbol) );
 #	else
-#		define NV_GL_LOAD( symbol ) *(void **) (&symbol) = gl_library.get(#symbol);
-#		define NV_GL_LOAD_EXT( symbol ) *(void **) (&symbol) = gl_library.get(#symbol);
+#		define NV_GL_LOAD( symbol ) void_assign( symbol, gl_library.get(#symbol) );
+#		define NV_GL_LOAD_EXT( symbol ) void_assign( symbol, gl_library.get(#symbol) );
 #	endif
 #endif
@@ -114,4 +114,6 @@
 }
 
+
+
 bool nv::load_wgl_library( const char* path /*= NV_GL_PATH */, bool force_reload )
 {
@@ -119,15 +121,15 @@
 #if NV_PLATFORM == NV_WINDOWS 
 #if defined( NV_SDL_GL )
-#		define NV_GL_LOAD( symbol ) *(void **) (&symbol) = SDL_GL_GetProcAddress(#symbol);
-#		define NV_GL_LOAD_EXT( symbol ) *(void **) (&symbol) = SDL_GL_GetProcAddress(#symbol);
-#	    define NV_GL_LOAD_REN( fname, rname )  *(void **) (&rname) = SDL_GL_GetProcAddress(#fname);
-	(void **) (&gl_ext_loader) = SDL_GL_GetProcAddress;
+#		define NV_GL_LOAD( symbol ) void_assign( symbol, SDL_GL_GetProcAddress(#symbol) );
+#		define NV_GL_LOAD_EXT( symbol ) void_assign( symbol, SDL_GL_GetProcAddress(#symbol) );
+#	    define NV_GL_LOAD_REN( fname, rname )  void_assign( rname, SDL_GL_GetProcAddress(#fname) );
+	void_assign( gl_ext_loader, SDL_GL_GetProcAddress );
 #else // 
 	if ( !gl_library.is_open() ) gl_library.open( path );
 
-	*(void **) (&gl_ext_loader) = gl_library.get("wglGetProcAddress");
-#define NV_GL_LOAD( symbol ) *(void **) (&symbol) = gl_library.get(#symbol);
-#define NV_GL_LOAD_EXT( symbol ) *(void **) (&symbol) = gl_ext_loader(#symbol);
-#define NV_GL_LOAD_REN( fname, rname ) *(void **) (&rname) = gl_library.get(#fname);
+	void_assign( gl_ext_loader, gl_library.get("wglGetProcAddress") );
+#define NV_GL_LOAD( symbol ) void_assign( symbol, gl_library.get(#symbol) );
+#define NV_GL_LOAD_EXT( symbol ) void_assign( symbol, gl_ext_loader(#symbol) );
+#define NV_GL_LOAD_REN( fname, rname ) void_assign( rname, gl_library.get(#fname) );
 #endif 
 #	define NV_GL_FUN( rtype, fname, fparams ) NV_GL_LOAD( fname )
@@ -161,7 +163,7 @@
 	BOOL  (NV_GL_APIENTRY *wgl_deletecontext) (HGLRC)      = nullptr;
 
-	*(void **) &wgl_createcontext = gl_library.get("wglCreateContext");
-	*(void **) &wgl_makecurrent   = gl_library.get("wglMakeCurrent");
-	*(void **) &wgl_deletecontext = gl_library.get("wglDeleteContext");
+	void_assign( wgl_createcontext, gl_library.get("wglCreateContext") );
+	void_assign( wgl_makecurrent,   gl_library.get("wglMakeCurrent") );
+	void_assign( wgl_deletecontext, gl_library.get("wglDeleteContext") );
 
 	WNDCLASS wndClass;
@@ -175,5 +177,5 @@
 	wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
 	wndClass.hInstance = hInstance;
-	wndClass.lpfnWndProc = (WNDPROC) DefWindowProc;
+	wndClass.lpfnWndProc = reinterpret_cast<WNDPROC>( DefWindowProc );
 	wndClass.lpszClassName = TEXT("Dummy67789");
 	wndClass.lpszMenuName = 0;
@@ -253,5 +255,5 @@
 
 #	define NV_GL_FUN_EXT( rtype, symbol, fparams ) \
-	*(void **) (&symbol) = load_gl_ext_symbol(#symbol, true, nullptr); \
+	void_assign( symbol, load_gl_ext_symbol(#symbol, true, nullptr) ); \
 	count++; if ( !symbol ) fail_count++;
 
@@ -266,5 +268,5 @@
 	default : {
 		NV_LOG_ERROR( "load_gl_extension - unknown extension \"", name, "\"!" );
-		return nullptr;
+		return false;
 	}
 	}
@@ -274,5 +276,5 @@
 	{
 		NV_LOG_NOTICE( "load_gl_extension - extension \"", name, "\" loaded (", count, " symbols)" );
-		gl_loaded_extensions = (gl_extensions)( gl_loaded_extensions | (unsigned)extension );
+		gl_loaded_extensions = gl_extensions( gl_loaded_extensions | static_cast<unsigned>( extension ) );
 		return false;
 	}
Index: /trunk/src/lib/lua.cc
===================================================================
--- /trunk/src/lib/lua.cc	(revision 405)
+++ /trunk/src/lib/lua.cc	(revision 406)
@@ -128,5 +128,5 @@
 static const lua_Number *lua_version_51 (lua_State*) 
 {
-	static const lua_Number version = (lua_Number)LUA_VERSION_NUM;
+	static const lua_Number version = lua_Number( LUA_VERSION_NUM );
 	return &version;
 }
@@ -227,5 +227,5 @@
 #endif
 
-#	define NV_LUA_FUN( rtype, fname, fparams ) *(void **) (&fname) = lua_library.get(#fname);
+#	define NV_LUA_FUN( rtype, fname, fparams ) void_assign( fname, lua_library.get(#fname) );
 #	if NV_LUA_VERSION == NV_LUA_52
 #		define NV_LUA_FUN_51( rtype, fname, fparams )
@@ -246,11 +246,11 @@
 
 #if NV_LUA_VERSION == NV_LUA_5C
-#	define NV_LUA_LOAD( fname ) *(void **) (&fname) = lua_library.get(#fname);
-#	define NV_LUA_LOAD_AS( fname,fname2 ) *(void **) (&fname) = lua_library.get(#fname2);
+#	define NV_LUA_LOAD( fname ) void_assign( fname, lua_library.get(#fname) );
+#	define NV_LUA_LOAD_AS( fname,fname2 ) void_assign( fname, lua_library.get(#fname2) );
 	bool version_52 = lua_library.try_get("luaL_checkversion_") != nullptr;
 	if (version_52)
 	{
 #	define NV_LUA_COMPAT_FUN( u1, fn, u2, u3, fn2, u5, u6, u7 ) \
-	*(void **) (&(fn2##_compat)) = lua_library.get(#fn2); \
+	void_assign( fn2##_compat, lua_library.get(#fn2) ); \
 	fn = call_##fn2##_compat; 
 #	include <nv/lib/detail/lua_functions_compat.inc>
@@ -280,5 +280,5 @@
 	{
 #	define NV_LUA_COMPAT_FUN( u1, fn, u2, u3, u4, u5, u6, u7 ) \
-		*(void **) (&fn) = lua_library.get(#fn);
+		void_assign(fn, lua_library.get(#fn) );
 #	include <nv/lib/detail/lua_functions_compat.inc>
 #	undef NV_LUA_COMPAT_FUN
Index: /trunk/src/lib/sdl.cc
===================================================================
--- /trunk/src/lib/sdl.cc	(revision 405)
+++ /trunk/src/lib/sdl.cc	(revision 406)
@@ -20,5 +20,5 @@
 	if ( sdl_library.is_open() ) return true;
 	sdl_library.open( path );
-#	define NV_SDL_FUN( rtype, fname, fparams ) *(void **) (&fname) = sdl_library.get(#fname);
+#	define NV_SDL_FUN( rtype, fname, fparams )void_assign( fname, sdl_library.get(#fname) );
 #	include <nv/lib/detail/sdl_functions.inc>
 #	undef NV_SDL_FUN
Index: /trunk/src/lib/sdl_image.cc
===================================================================
--- /trunk/src/lib/sdl_image.cc	(revision 405)
+++ /trunk/src/lib/sdl_image.cc	(revision 406)
@@ -21,5 +21,5 @@
 	sdl_image_library.open( path );
 
-#	define NV_SDL_FUN( rtype, fname, fparams ) *(void **) (&fname) = sdl_image_library.get(#fname);
+#	define NV_SDL_FUN( rtype, fname, fparams ) void_assign( fname, sdl_image_library.get(#fname) );
 #	include <nv/lib/detail/sdl_image_functions.inc>
 #	undef NV_SDL_FUN
Index: /trunk/src/lib/sdl_mixer.cc
===================================================================
--- /trunk/src/lib/sdl_mixer.cc	(revision 405)
+++ /trunk/src/lib/sdl_mixer.cc	(revision 406)
@@ -21,5 +21,5 @@
 	sdl_mixer_library.open( path );
 
-#	define NV_SDL_FUN( rtype, fname, fparams ) *(void **) (&fname) = sdl_mixer_library.get(#fname);
+#	define NV_SDL_FUN( rtype, fname, fparams ) void_assign( fname, sdl_mixer_library.get(#fname) );
 #	include <nv/lib/detail/sdl_mixer_functions.inc>
 #	undef NV_SDL_FUN
Index: /trunk/src/lua/lua_function.cc
===================================================================
--- /trunk/src/lua/lua_function.cc	(revision 405)
+++ /trunk/src/lua/lua_function.cc	(revision 406)
@@ -5,9 +5,14 @@
 // For conditions of distribution and use, see copying.txt file in root folder.
 
-#include <nv/lua/lua_function.hh>
+#include "nv/lua/lua_function.hh"
 
-#include <nv/lua/lua_raw.hh>
+#include "nv/core/logging.hh"
+#include "nv/lua/lua_raw.hh"
 
 using namespace nv;
+
+#define NV_LUA_ABORT( func, ... ) \
+	NV_LOG_CRITICAL( "lua::" func " : ", __VA_ARGS__ ) \
+	NV_ABORT( "lua::" func " : critical error!" )
 
 lua::function_base::function_base( lua_State* a_L, const path& a_path, bool a_global /*= true*/ ) : L(a_L)
@@ -16,5 +21,5 @@
 	{
 		lua_pop( L, 1 );
-		throw std::runtime_error("not a valid path - " + a_path.to_string() );
+		NV_LUA_ABORT( "function_base::function_base", "not a valid path - ", a_path.to_string() );
 	}
 
@@ -22,5 +27,5 @@
 	{
 		lua_pop( L, 1 );
-		throw std::runtime_error("not a valid function - " + a_path.to_string() );
+		NV_LUA_ABORT( "function_base::function_base", "not a valid function - ", a_path.to_string() );
 	}
 	m_ref = luaL_ref( L, LUA_REGISTRYINDEX );
@@ -61,5 +66,5 @@
 		std::string error = lua_tostring( L, -1 );
 		lua_pop( L, 1 );
-		throw std::runtime_error(error.c_str());
+		NV_LUA_ABORT( "function_base::call", "call failed - ", error.c_str() );
 	}
 }
Index: /trunk/src/lua/lua_glm.cc
===================================================================
--- /trunk/src/lua/lua_glm.cc	(revision 405)
+++ /trunk/src/lua/lua_glm.cc	(revision 406)
@@ -11,5 +11,5 @@
 #include "nv/stl/type_traits/common.hh"
 
-static size_t nlua_swizzel_lookup[256];
+static int nlua_swizzel_lookup[256];
 
 using nv::lua::detail::is_vec;
@@ -18,5 +18,5 @@
 using nv::lua::detail::push_vec;
 
-inline bool nlua_is_swizzel( const unsigned char* str, size_t max )
+inline bool nlua_is_swizzel( const unsigned char* str, int max )
 {
 	while (*str)
@@ -155,8 +155,8 @@
 {
 	if ( lua_type( L, 1 ) == LUA_TNUMBER )
-		push_vec<T>( L, (typename T::value_type)(lua_tonumber( L, 1 )) + to_vec<T>( L, 2 ) );
+		push_vec<T>( L, static_cast<typename T::value_type>(lua_tonumber( L, 1 )) + to_vec<T>( L, 2 ) );
 	else
 		if ( lua_type( L, 2 ) == LUA_TNUMBER )
-			push_vec<T>( L, to_vec<T>( L, 1 ) + (typename T::value_type)(lua_tonumber( L, 2 )) );
+			push_vec<T>( L, to_vec<T>( L, 1 ) + static_cast<typename T::value_type>(lua_tonumber( L, 2 )) );
 		else
 			push_vec<T>( L, to_vec<T>( L, 1 ) + to_vec<T>( L, 2 ) );
@@ -168,8 +168,8 @@
 {
 	if ( lua_type( L, 1 ) == LUA_TNUMBER )
-		push_vec<T>( L, (typename T::value_type)(lua_tonumber( L, 1 )) - to_vec<T>( L, 2 ) );
+		push_vec<T>( L, static_cast<typename T::value_type>(lua_tonumber( L, 1 )) - to_vec<T>( L, 2 ) );
 	else
 		if ( lua_type( L, 2 ) == LUA_TNUMBER )
-			push_vec<T>( L, to_vec<T>( L, 1 ) - (typename T::value_type)(lua_tonumber( L, 2 )) );
+			push_vec<T>( L, to_vec<T>( L, 1 ) - static_cast<typename T::value_type>(lua_tonumber( L, 2 )) );
 		else
 			push_vec<T>( L, to_vec<T>( L, 1 ) - to_vec<T>( L, 2 ) );
@@ -181,8 +181,8 @@
 {
 	if ( lua_type( L, 1 ) == LUA_TNUMBER )
-		push_vec<T>( L, (typename T::value_type)(lua_tonumber( L, 1 )) * to_vec<T>( L, 2 ) );
+		push_vec<T>( L, static_cast<typename T::value_type>(lua_tonumber( L, 1 )) * to_vec<T>( L, 2 ) );
 	else
 		if ( lua_type( L, 2 ) == LUA_TNUMBER )
-			push_vec<T>( L, to_vec<T>( L, 1 ) * (typename T::value_type)(lua_tonumber( L, 2 )) );
+			push_vec<T>( L, to_vec<T>( L, 1 ) * static_cast<typename T::value_type>(lua_tonumber( L, 2 )) );
 		else
 			push_vec<T>( L, to_vec<T>( L, 1 ) * to_vec<T>( L, 2 ) );
@@ -194,8 +194,8 @@
 {
 	if ( lua_type( L, 1 ) == LUA_TNUMBER )
-		push_vec<T>( L, (typename T::value_type)(lua_tonumber( L, 1 )) / to_vec<T>( L, 2 ) );
+		push_vec<T>( L, static_cast<typename T::value_type>(lua_tonumber( L, 1 )) / to_vec<T>( L, 2 ) );
 	else
 		if ( lua_type( L, 2 ) == LUA_TNUMBER )
-			push_vec<T>( L, to_vec<T>( L, 1 ) / (typename T::value_type)(lua_tonumber( L, 2 )) );
+			push_vec<T>( L, to_vec<T>( L, 1 ) / static_cast<typename T::value_type>(lua_tonumber( L, 2 )) );
 		else
 			push_vec<T>( L, to_vec<T>( L, 1 ) / to_vec<T>( L, 2 ) );
@@ -226,7 +226,7 @@
 	T* v = to_pvec<T>( L, 1 );
 	size_t len  = 0;
-	size_t vlen = v->length();
-	const unsigned char * key = (const unsigned char *)( lua_tolstring( L, 2, &len ) );
-	size_t idx = 255;
+	int vlen = v->length();
+	const unsigned char * key = reinterpret_cast<const unsigned char *>( lua_tolstring( L, 2, &len ) );
+	int idx = 255;
 
 	if ( len == 1 )
@@ -264,7 +264,7 @@
 	T* v = to_pvec<T>( L, 1 );
 	size_t len  = 0;
-	size_t vlen = v->length();
-	const unsigned char * key = (const unsigned char *)( lua_tolstring( L, 2, &len ) );
-	size_t idx = 255;
+	int vlen = v->length();
+	const unsigned char * key = reinterpret_cast<const unsigned char *>( lua_tolstring( L, 2, &len ) );
+	int idx = 255;
 	if( len == 1 )
 	{
@@ -272,5 +272,5 @@
 		if ( idx < vlen )
 		{
-			(*v)[idx] = (typename T::value_type)luaL_checknumber( L, 3 );
+			(*v)[idx] = static_cast<typename T::value_type>( luaL_checknumber( L, 3 ) );
 			return 0;
 		}
@@ -279,7 +279,7 @@
 	{
  		switch (len) {
-		case 2 : { vec2 v2 = to_vec<vec2>(L,3); for (size_t i = 0; i<len; ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v2[i]; } return 0;
-		case 3 : { vec3 v3 = to_vec<vec3>(L,3); for (size_t i = 0; i<len; ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v3[i]; } return 0;
-		case 4 : { vec4 v4 = to_vec<vec4>(L,3); for (size_t i = 0; i<len; ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v4[i]; } return 0;
+		case 2 : { vec2 v2 = to_vec<vec2>(L,3); for ( int i = 0; i<int( len ); ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v2[i]; } return 0;
+		case 3 : { vec3 v3 = to_vec<vec3>(L,3); for ( int i = 0; i<int( len ); ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v3[i]; } return 0;
+		case 4 : { vec4 v4 = to_vec<vec4>(L,3); for ( int i = 0; i<int( len ); ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v4[i]; } return 0;
  		default: break;
 		}
Index: /trunk/src/lua/lua_handle.cc
===================================================================
--- /trunk/src/lua/lua_handle.cc	(revision 405)
+++ /trunk/src/lua/lua_handle.cc	(revision 406)
@@ -16,5 +16,5 @@
 	NV_LUA_STACK_ASSERT( L, +1 );
 	lua_rawgeti( L, LUA_REGISTRYINDEX, pseudoindex ); // table
-	lua_rawgeti( L, -1, (int)index );                 // table, entry
+	lua_rawgeti( L, -1, int( index ) );                 // table, entry
 	if ( !lua_istable( L, -1 ) )
 	{
@@ -58,5 +58,5 @@
 	lua_rawgeti( L, LUA_REGISTRYINDEX, pseudoindex );
 	lua_insert( L, -2 );
-	lua_rawseti( L, -2, (int)index );
+	lua_rawseti( L, -2, int( index ) );
 	lua_pop( L, 1 );
 }
@@ -67,5 +67,5 @@
 	lua_rawgeti( L, LUA_REGISTRYINDEX, pseudoindex ); // table
 	lua_pushinteger( L, 0 );
-	lua_rawseti( L, -2, (int)index );
+	lua_rawseti( L, -2, int( index ) );
 	lua_pop( L, 1 );
 }
Index: /trunk/src/lua/lua_map_area.cc
===================================================================
--- /trunk/src/lua/lua_map_area.cc	(revision 405)
+++ /trunk/src/lua/lua_map_area.cc	(revision 406)
@@ -67,5 +67,5 @@
 	else
 	{
-		return *(nv::map_area**)luaL_checkudata( L, index, NLUA_MAP_AREA_METATABLE );
+		return *reinterpret_cast<nv::map_area**>( luaL_checkudata( L, index, NLUA_MAP_AREA_METATABLE ) );
 	}
 	return o;
@@ -88,5 +88,5 @@
 void nv::lua::detail::push_map_area( lua_State* L, nv::map_area* c )
 {
-	nv::map_area** pm = (nv::map_area**) (lua_newuserdata(L, sizeof(nv::map_area*)));
+	nv::map_area** pm = reinterpret_cast<nv::map_area**>( lua_newuserdata(L, sizeof(nv::map_area*) ) );
 	*pm = c;
 	luaL_getmetatable( L, NLUA_MAP_AREA_METATABLE );
@@ -237,5 +237,5 @@
 	lua_rawgeti( L, LUA_REGISTRYINDEX, object_index.get() );
 	lua_pushliteral( L, "__map_area_ptr" );
-	lua_pushlightuserdata( L, (map_area*)area );
+	lua_pushlightuserdata( L, area );
 	lua_rawset( L, -3 );
 	lua_pop( L, 1 );
Index: /trunk/src/lua/lua_map_tile.cc
===================================================================
--- /trunk/src/lua/lua_map_tile.cc	(revision 405)
+++ /trunk/src/lua/lua_map_tile.cc	(revision 406)
@@ -40,10 +40,10 @@
 static map_tile* nlua_to_pmap_tile( lua_State* L, int index )
 {
-	return (map_tile*)luaL_checkudata( L, index, NLUA_MAP_TILE_METATABLE );
+	return reinterpret_cast<map_tile*>( luaL_checkudata( L, index, NLUA_MAP_TILE_METATABLE ) );
 }
 
 static void nlua_push_map_tile( lua_State* L, const map_tile& tile )
 {
-	map_tile* result = (map_tile*)lua_newuserdata( L, sizeof(map_tile) );
+	map_tile* result = reinterpret_cast<map_tile*>( lua_newuserdata( L, sizeof(map_tile) ) );
 	*result = tile;
 	luaL_setmetatable( L, NLUA_MAP_TILE_METATABLE );
@@ -65,9 +65,9 @@
 	map_tile tile;
 
-	tile.size_y = (nv::uint16)( nv::count( code.begin(), code.end(), '\n' ) + 1 );
-	tile.size_x = (nv::uint16)( code.find( '\n' ) );
+	tile.size_y = nv::uint16( nv::count( code.begin(), code.end(), '\n' ) + 1 );
+	tile.size_x = nv::uint16( code.find( '\n' ) );
 	if ( tile.size_x == 0 )
 	{
-		tile.size_x = (nv::uint16)code.length();
+		tile.size_x = nv::uint16( code.length() );
 	}
 	tile.data  = new nv::uint8[ tile.size_x * tile.size_y ];
@@ -85,5 +85,5 @@
 			if ( lua_isstring( L, -2 ) && lua_objlen( L, -2 ) == 1 )
 			{
-				translation[ (nv::uint8)( lua_tostring( L, -2 )[0] ) ] = nv::uint8( map_area->string_to_id( lua_tostring( L, -1 ) ) );
+				translation[ nv::uint8( lua_tostring( L, -2 )[0] ) ] = nv::uint8( map_area->string_to_id( lua_tostring( L, -1 ) ) );
 			}
 			// removes 'value'; keeps 'key' for next iteration */
@@ -95,5 +95,5 @@
 		for ( nv::uint16 row = 0; row < tile.size_y; row++ )
 		{
-			nv::uchar8 gylph = (nv::uchar8)code[ row * ( tile.size_x + 1 ) + line ];
+			nv::uchar8 gylph = nv::uchar8( code[ row * ( tile.size_x + 1 ) + line ] );
 			// TODO: check for errors
 			tile.data[ row * tile.size_x + line ] = translation[ gylph ];
@@ -108,5 +108,5 @@
 {
 	map_tile* old_tile = nlua_to_pmap_tile( L, 1 );
-	map_tile* new_tile = (map_tile*) lua_newuserdata( L, sizeof( map_tile ) );
+	map_tile* new_tile = reinterpret_cast<map_tile*>( lua_newuserdata( L, sizeof( map_tile ) ) );
 	new_tile->size_x = old_tile->size_x;
 	new_tile->size_y = old_tile->size_y;
@@ -246,6 +246,6 @@
 	nv::uint16 org_x = tile->size_x;
 	nv::uint16 org_y = tile->size_y;
-	nv::uint16 new_x = ( nv::uint16 )nv::accumulate( sizes_x.begin(), sizes_x.end(), 0 );
-	nv::uint16 new_y = ( nv::uint16 )nv::accumulate( sizes_y.begin(), sizes_y.end(), 0 );
+	nv::uint16 new_x = nv::uint16( nv::accumulate( sizes_x.begin(), sizes_x.end(), 0 ) );
+	nv::uint16 new_y = nv::uint16( nv::accumulate( sizes_y.begin(), sizes_y.end(), 0 ) );
 
 	nv::uint8* data = new nv::uint8[ new_x * new_y ];
@@ -274,5 +274,5 @@
 static int nlua_map_tile_raw_get( lua_State* L )
 {
-	map_tile* tile = (map_tile*)lua_touserdata( L, 1 );
+	map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) );
 	if ( lua_type( L, 2 ) == LUA_TNUMBER )
 	{
@@ -289,13 +289,13 @@
 static int nlua_map_tile_raw_set( lua_State* L )
 {
-	map_tile* tile = (map_tile*)lua_touserdata( L, 1 );
+	map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) );
 	if ( lua_type( L, 2 ) == LUA_TNUMBER )
 	{
-		tile->data[ ( lua_tointeger( L, 2 ) - 1 ) + ( lua_tointeger( L, 3 ) - 1 ) * tile->size_x ] = (nv::uint8)lua_tointeger( L, 3 );
+		tile->data[ ( lua_tointeger( L, 2 ) - 1 ) + ( lua_tointeger( L, 3 ) - 1 ) * tile->size_x ] = nv::uint8( lua_tointeger( L, 3 ) );
 	}
 	else
 	{
 		nv::ivec2 coord = nv::lua::detail::to_coord( L, 2 );
-		tile->data[ ( coord.x - 1 ) + ( coord.y - 1 ) * tile->size_x ] = (nv::uint8)lua_tointeger( L, 3 );
+		tile->data[ ( coord.x - 1 ) + ( coord.y - 1 ) * tile->size_x ] = nv::uint8( lua_tointeger( L, 3 ) );
 	}
 	return 0;
@@ -304,5 +304,5 @@
 static int nlua_map_tile_ascii_get( lua_State* L )
 {
-	map_tile* tile = (map_tile*)lua_touserdata( L, 1 );
+	map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) );
 	if ( lua_type( L, 2 ) == LUA_TNUMBER )
 	{
@@ -319,13 +319,13 @@
 static int nlua_map_tile_ascii_set( lua_State* L )
 {
-	map_tile* tile = (map_tile*)lua_touserdata( L, 1 );
+	map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) );
 	if ( lua_type( L, 2 ) == LUA_TNUMBER )
 	{
-		tile->ascii[ ( lua_tointeger( L, 2 ) - 1 ) + ( lua_tointeger( L, 3 ) - 1 ) * tile->size_x ] = (nv::uint8)lua_tointeger( L, 3 );
+		tile->ascii[ ( lua_tointeger( L, 2 ) - 1 ) + ( lua_tointeger( L, 3 ) - 1 ) * tile->size_x ] = nv::uint8( lua_tointeger( L, 3 ) );
 	}
 	else
 	{
 		nv::ivec2 coord = nv::lua::detail::to_coord( L, 2 );
-		tile->ascii[ ( coord.x - 1 ) + ( coord.y - 1 ) * tile->size_x ] = (nv::uint8)lua_tointeger( L, 3 );
+		tile->ascii[ ( coord.x - 1 ) + ( coord.y - 1 ) * tile->size_x ] = nv::uint8( lua_tointeger( L, 3 ) );
 	}
 	return 0;
@@ -334,5 +334,5 @@
 static int nlua_map_tile_gc( lua_State* L )
 {
-	map_tile* tile = (map_tile*)lua_touserdata( L, 1 );
+	map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) );
 	if ( tile != nullptr )
 	{
Index: /trunk/src/lua/lua_raw.cc
===================================================================
--- /trunk/src/lua/lua_raw.cc	(revision 405)
+++ /trunk/src/lua/lua_raw.cc	(revision 406)
@@ -271,5 +271,5 @@
 		while ( lua_next( L, index ) != 0 )
 		{
-			result.push_back( (nv::uint8) lua_tointeger( L, -1 ) );
+			result.push_back( static_cast<nv::uint8>( lua_tointeger( L, -1 ) ) );
 			lua_pop( L, 1 );
 		}
Index: /trunk/src/lua/lua_state.cc
===================================================================
--- /trunk/src/lua/lua_state.cc	(revision 405)
+++ /trunk/src/lua/lua_state.cc	(revision 406)
@@ -258,5 +258,5 @@
 {
 	lua_getfield( m_state, -1, element.data() );
-	float result = lua_type( m_state, -1 ) == LUA_TNUMBER ? (float)lua_tonumber( m_state, -1 ) : defval;
+	float result = lua_type( m_state, -1 ) == LUA_TNUMBER ? static_cast<float>( lua_tonumber( m_state, -1 ) ) : defval;
 	lua_pop( m_state, 1 );
 	return result;
Index: /trunk/src/rogue/fov_recursive_shadowcasting.cc
===================================================================
--- /trunk/src/rogue/fov_recursive_shadowcasting.cc	(revision 405)
+++ /trunk/src/rogue/fov_recursive_shadowcasting.cc	(revision 406)
@@ -25,5 +25,5 @@
 		position max_radius = m_size-m_position;
 		max_radius = glm::max(max_radius,m_position);
-		m_radius = (int)glm::length((vec2)max_radius)+1;
+		m_radius = static_cast<int>( glm::length( vec2( max_radius ) ) )+1;
 	}
 	m_radius2 = m_radius * m_radius;
Index: /trunk/src/sdl/sdl_audio.cc
===================================================================
--- /trunk/src/sdl/sdl_audio.cc	(revision 405)
+++ /trunk/src/sdl/sdl_audio.cc	(revision 406)
@@ -36,5 +36,5 @@
 	if ( info )
 	{
-		int channel = Mix_PlayChannel(-1, (Mix_Chunk*)( info->sdl_sound), 0);
+		int channel = Mix_PlayChannel(-1, static_cast<Mix_Chunk*>( info->sdl_sound ), 0);
 		if ( channel == -1 )
 		{
@@ -43,8 +43,8 @@
 		else
 		{
-			Mix_Volume( channel, int( volume * 128.0f ) );
+			Mix_Volume( channel, static_cast<int>( volume * 128.0f ) );
 			if ( pan != 0.0f) 
 			{
-				uint8 right = (uint8)( (pan + 1.0f) * 127.0f ); 
+				uint8 right = static_cast<uint8>( (pan + 1.0f) * 127.0f ); 
 				Mix_SetPanning( channel, 254-right, right );
 			}
@@ -63,5 +63,5 @@
 	if ( info )
 	{
-		int channel = Mix_PlayChannel(-1, (Mix_Chunk*)( info->sdl_sound), 0);
+		int channel = Mix_PlayChannel(-1, static_cast<Mix_Chunk*>( info->sdl_sound ), 0);
 		if ( channel == -1 )
 		{
@@ -123,5 +123,5 @@
 	if ( info )
 	{
-		Mix_FreeChunk( (Mix_Chunk*)info->sdl_sound );
+		Mix_FreeChunk( static_cast<Mix_Chunk*>( info->sdl_sound ) );
 		m_sounds.destroy( a_sound );
 	}
Index: /trunk/src/sdl/sdl_input.cc
===================================================================
--- /trunk/src/sdl/sdl_input.cc	(revision 405)
+++ /trunk/src/sdl/sdl_input.cc	(revision 406)
@@ -25,5 +25,5 @@
 	kevent.key.code    = KEY_NONE;
 
-	uint32 ucode = (uint32)ke.keysym.sym;
+	uint32 ucode = static_cast<uint32>( ke.keysym.sym );
 
 	// if result is a typable char place it into the structure
@@ -36,5 +36,5 @@
 			int capslock = !!(ke.keysym.mod & KMOD_CAPS);
 			if ((shifted ^ capslock) != 0) {
-				kevent.key.ascii = (uchar8)SDL_toupper((int)ucode);
+				kevent.key.ascii = static_cast<uchar8>( SDL_toupper( static_cast<int>( ucode ) ) );
 			}
 		}
Index: /trunk/src/sdl/sdl_window.cc
===================================================================
--- /trunk/src/sdl/sdl_window.cc	(revision 405)
+++ /trunk/src/sdl/sdl_window.cc	(revision 406)
@@ -64,8 +64,8 @@
 
 	nv::load_gl_library();
-	NV_LOG_INFO( "OpenGL Vendor       : ", (const char*)glGetString(GL_VENDOR) );
-	NV_LOG_INFO( "OpenGL Renderer     : ", (const char*)glGetString( GL_RENDERER ) );
-	NV_LOG_INFO( "OpenGL Version      : ", (const char*)glGetString( GL_VERSION ) );
-	NV_LOG_INFO( "OpenGL GLSL Version : ", (const char*)glGetString( GL_SHADING_LANGUAGE_VERSION ) );
+	NV_LOG_INFO( "OpenGL Vendor       : ", reinterpret_cast<const char*>( glGetString(GL_VENDOR) ) );
+	NV_LOG_INFO( "OpenGL Renderer     : ", reinterpret_cast<const char*>( glGetString( GL_RENDERER ) ) );
+	NV_LOG_INFO( "OpenGL Version      : ", reinterpret_cast<const char*>( glGetString( GL_VERSION ) ) );
+	NV_LOG_INFO( "OpenGL GLSL Version : ", reinterpret_cast<const char*>( glGetString( GL_SHADING_LANGUAGE_VERSION ) ) );
 	SDL_GL_SetSwapInterval(1);
 
Index: /trunk/src/stl/assert.cc
===================================================================
--- /trunk/src/stl/assert.cc	(revision 405)
+++ /trunk/src/stl/assert.cc	(revision 406)
@@ -64,2 +64,8 @@
 	exit( 1 );
 }
+
+
+NV_NORETURN void nv::exit( int ret_val )
+{
+	::exit( ret_val );
+}
