Index: /trunk/nv/core/handle.hh
===================================================================
--- /trunk/nv/core/handle.hh	(revision 349)
+++ /trunk/nv/core/handle.hh	(revision 350)
@@ -84,4 +84,5 @@
 			value_type i = get_free_entry();
 			m_entries[i].counter++;
+			NV_ASSERT( m_entries[i].counter != 0, "Out of handles!" );
 			m_entries[i].next_free = USED;
 			return hop::create( i, m_entries[i].counter );
@@ -90,12 +91,16 @@
 		void free_handle( handle h )
 		{
-			m_entries[h.index()].next_free = NONE;
-			if ( m_last_free == -1 )
+			value_type index = h.index();
+			typedef handle_operator<HANDLE> hop;
+			NV_ASSERT( m_entries[index].next_free == USED, "Unused handle freed!" );
+			NV_ASSERT( m_entries[index].counter == hop::get_counter( h ), "Handle corruption!" );
+			m_entries[index].next_free = NONE;
+			if ( m_last_free == NONE )
 			{
-				m_first_free = m_last_free = h.index();
+				m_first_free = m_last_free = index;
 				return;
 			}
-			m_entries[(unsigned)m_last_free].next_free = h.index();
-			m_last_free = h.index();
+			m_entries[(unsigned)m_last_free].next_free = index;
+			m_last_free = index;
 		}
 
@@ -120,10 +125,10 @@
 		value_type get_free_entry()
 		{
-			if ( m_first_free != -1 )
+			if ( m_first_free != NONE )
 			{
 				value_type result = (value_type)m_first_free;
 				m_first_free = m_entries[result].next_free;
 				m_entries[result].next_free = USED;
-				if ( m_first_free == -1 ) m_last_free = -1;
+				if ( m_first_free == NONE ) m_last_free = NONE;
 				return result;
 			}
Index: /trunk/nv/core/math.hh
===================================================================
--- /trunk/nv/core/math.hh	(revision 349)
+++ /trunk/nv/core/math.hh	(revision 350)
@@ -31,4 +31,8 @@
 	typedef glm::detail::tvec3<sint16> i16vec3;
 	typedef glm::detail::tvec4<sint16> i16vec4;
+
+	typedef glm::detail::tvec2<uint8> u8vec2;
+	typedef glm::detail::tvec3<uint8> u8vec3;
+	typedef glm::detail::tvec4<uint8> u8vec4;
 
 	typedef glm::vec2 vec2;
@@ -104,4 +108,7 @@
 		BYTE_VECTOR_3,
 		BYTE_VECTOR_4,
+		UBYTE_VECTOR_2,
+		UBYTE_VECTOR_3,
+		UBYTE_VECTOR_4,
 		QUAT,
 		TRANSFORM,
@@ -140,5 +147,8 @@
 			{ 1 * 3,  BYTE, 3 },  // BYTE_VECTOR_3,
 			{ 1 * 4,  BYTE, 4 },  // BYTE_VECTOR_4,
-			{ 4 * 4,  FLOAT, 4 },      // QUAT,
+			{ 1 * 2, UBYTE, 2 },  // UBYTE_VECTOR_2,
+			{ 1 * 3, UBYTE, 3 },  // UBYTE_VECTOR_3,
+			{ 1 * 4, UBYTE, 4 },  // UBYTE_VECTOR_4,
+			{ 4 * 4, FLOAT, 4 },      // QUAT,
 			{ 7 * 4,  FLOAT, 7 },      // TRANSFORM,
 		};
@@ -168,4 +178,8 @@
 	template <> struct enum_to_type< BYTE_VECTOR_3 > { typedef i8vec3 type; };
 	template <> struct enum_to_type< BYTE_VECTOR_4 > { typedef i8vec4 type; };
+
+	template <> struct enum_to_type < UBYTE_VECTOR_2 > { typedef u8vec2 type; };
+	template <> struct enum_to_type < UBYTE_VECTOR_3 > { typedef u8vec3 type; };
+	template <> struct enum_to_type < UBYTE_VECTOR_4 > { typedef u8vec4 type; };
 
 	template <> struct enum_to_type< FLOAT_MATRIX_2 > { typedef mat2 type; };
@@ -200,4 +214,9 @@
 	template <> struct type_to_enum< i8vec4 > { static const datatype type = BYTE_VECTOR_4; };
 
+	template <> struct type_to_enum < u8vec2 > { static const datatype type = UBYTE_VECTOR_2; };
+	template <> struct type_to_enum < u8vec3 > { static const datatype type = UBYTE_VECTOR_3; };
+	template <> struct type_to_enum < u8vec4 > { static const datatype type = UBYTE_VECTOR_4; };
+
+
 	template <> struct type_to_enum< mat2 > { static const datatype type = FLOAT_MATRIX_2; };
 	template <> struct type_to_enum< mat3 > { static const datatype type = FLOAT_MATRIX_3; };
Index: /trunk/nv/gl/gl_device.hh
===================================================================
--- /trunk/nv/gl/gl_device.hh	(revision 349)
+++ /trunk/nv/gl/gl_device.hh	(revision 350)
@@ -41,4 +41,5 @@
 		gl_device();
 		virtual image_data* create_image_data( const std::string& filename ); // temporary
+		virtual image_data* create_image_data( const uint8* data, uint32 size ); // temporary
 
 		virtual program create_program( const string& vs_source, const string& fs_source );
Index: /trunk/nv/gui/gui_style.hh
===================================================================
--- /trunk/nv/gui/gui_style.hh	(revision 349)
+++ /trunk/nv/gui/gui_style.hh	(revision 350)
@@ -28,11 +28,11 @@
 			style();
 			void load_style( const std::string& filename );
-			bool get( element* e, const std::string& entry, std::string& s );
-			bool get( element* e, const std::string& entry, vec4& vec );
-			bool get( element* e, const std::string& entry, int& i );
-			bool get( element* e, const std::string& entry, double& d );
+			bool get( element* e, const char* centry, std::string& s );
+			bool get( element* e, const char* centry, vec4& vec );
+			bool get( element* e, const char* centry, int& i );
+			bool get( element* e, const char* centry, double& d );
 			~style();
 		protected:
-			bool resolve( element* e, const std::string& entry, int type );
+			bool resolve( const char* cid, const char* cclass, const char* centry, int type );
 		protected:
 			lua::state m_lua; //!< separate lua state for style calculation
Index: /trunk/nv/interface/context.hh
===================================================================
--- /trunk/nv/interface/context.hh	(revision 349)
+++ /trunk/nv/interface/context.hh	(revision 350)
@@ -184,5 +184,5 @@
 		{
 			vertex_array va = create_vertex_array( v, vcount, hint );
-			buffer       ib = create_buffer( INDEX_BUFFER, hint, icount * sizeof( IDX ), i );
+			buffer       ib = m_device->create_buffer( INDEX_BUFFER, hint, icount * sizeof( IDX ), i );
 			set_index_buffer( va, ib, type_to_enum< IDX >::type, true );
 			return va;
Index: /trunk/nv/interface/device.hh
===================================================================
--- /trunk/nv/interface/device.hh	(revision 349)
+++ /trunk/nv/interface/device.hh	(revision 350)
@@ -162,4 +162,5 @@
 		virtual texture create_texture( ivec2 size, image_format aformat, sampler asampler, void* data = nullptr ) { return create_texture( TEXTURE_2D, size, aformat, asampler, data ); }
 		virtual image_data* create_image_data( const std::string& filename ) = 0; // temporary
+		virtual image_data* create_image_data( const uint8* data, uint32 size ) = 0; // temporary
 		virtual void release( texture ) = 0;
 		virtual void release( buffer ) = 0;
Index: /trunk/src/gl/gl_device.cc
===================================================================
--- /trunk/src/gl/gl_device.cc	(revision 349)
+++ /trunk/src/gl/gl_device.cc	(revision 350)
@@ -49,4 +49,22 @@
 	image_data* data = new image_data( format, glm::ivec2( image->w, image->h ), (nv::uint8*)image->pixels );
 	return data;
+}
+
+// this is a temporary function that will be removed once we find a way to 
+// pass binary file data around
+image_data* gl_device::create_image_data( const uint8* data, uint32 size )
+{
+	load_sdl_image_library();
+	SDL_Surface* image = IMG_LoadTyped_RW( SDL_RWFromMem( (void*)data, size ), 1, "tga" );
+	if ( !image )
+	{
+		NV_LOG( LOG_ERROR, "Image binary data cannot be loaded found!" );
+		return nullptr;
+	}
+	// TODO: BGR vs RGB, single channel
+	assert( image->format->BytesPerPixel > 2 );
+	image_format format( image->format->BytesPerPixel == 3 ? RGB : RGBA, UBYTE );
+	image_data* idata = new image_data( format, glm::ivec2( image->w, image->h ), ( nv::uint8* )image->pixels );
+	return idata;
 }
 
Index: /trunk/src/gl/gl_enum.cc
===================================================================
--- /trunk/src/gl/gl_enum.cc	(revision 349)
+++ /trunk/src/gl/gl_enum.cc	(revision 350)
@@ -296,5 +296,9 @@
 	case BYTE_VECTOR_3  : return GL_INT_VEC3;
 	case BYTE_VECTOR_4  : return GL_INT_VEC4;
-	default : return 0; // TODO: throw!
+		// remove, error or ?
+	case UBYTE_VECTOR_2: return GL_INT_VEC2;
+	case UBYTE_VECTOR_3: return GL_INT_VEC3;
+	case UBYTE_VECTOR_4: return GL_INT_VEC4;
+	default: return 0; // TODO: throw!
 	}
 }
Index: /trunk/src/gui/gui_style.cc
===================================================================
--- /trunk/src/gui/gui_style.cc	(revision 349)
+++ /trunk/src/gui/gui_style.cc	(revision 350)
@@ -21,16 +21,16 @@
 }
 
-bool style::get( element* e, const std::string& entry, std::string& s )
+bool style::get( element* e, const char* centry, std::string& s )
 {
 	lua::stack_guard guard( m_lua );
-	if ( !resolve( e, entry, LUA_TSTRING ) ) return false;
+	if ( !resolve( e->m_id.c_str(), e->m_class.c_str(), centry, LUA_TSTRING ) ) return false;
 	s = lua_tostring( m_lua, -1 );
 	return true;
 }
 
-bool style::get( element* e, const std::string& entry, vec4& vec )
+bool style::get( element* e, const char* centry, vec4& vec )
 {
 	lua::stack_guard guard( m_lua );
-	if ( !resolve( e, entry, LUA_TTABLE ) ) return false;
+	if ( !resolve( e->m_id.c_str(), e->m_class.c_str(), centry, LUA_TTABLE ) ) return false;
 	vec = vec4();
 	for (size_t i = 0; i < 4; ++i )
@@ -44,16 +44,16 @@
 }
 
-bool style::get( element* e, const std::string& entry, int& i )
+bool style::get( element* e, const char* centry, int& i )
 {
 	lua::stack_guard guard( m_lua );
-	if ( !resolve( e, entry, LUA_TNUMBER ) ) return false;
+	if ( !resolve( e->m_id.c_str(), e->m_class.c_str(), centry, LUA_TNUMBER ) ) return false;
 	i = static_cast< int >( lua_tointeger( m_lua, -1 ) );
 	return true;
 }
 
-bool style::get( element* e, const std::string& entry, double& d )
+bool style::get( element* e, const char* centry, double& d )
 {
 	lua::stack_guard guard( m_lua );
-	if ( !resolve( e, entry, LUA_TNUMBER ) ) return false;
+	if ( !resolve( e->m_id.c_str(), e->m_class.c_str(), centry, LUA_TNUMBER ) ) return false;
 	d = lua_tonumber( m_lua, -1 );
 	return true;
@@ -64,9 +64,6 @@
 }
 
-bool style::resolve( element* e, const std::string& entry, int type )
+bool style::resolve( const char* cid, const char* cclass, const char* centry, int type )
 {
-	const char* centry = entry.c_str();
-	const char* cid    = e->m_id.c_str();
-	const char* cclass = e->m_class.c_str();
 	lua_getglobal( m_lua, "default" );
 	int global = lua_gettop( m_lua );
