Index: trunk/src/gl/gl_context.cc
===================================================================
--- trunk/src/gl/gl_context.cc	(revision 334)
+++ trunk/src/gl/gl_context.cc	(revision 335)
@@ -63,4 +63,5 @@
 			glDeleteRenderbuffers( 1, &info->depth_rb_glid );
 		glDeleteFramebuffers( 1, &info->glid );
+		m_framebuffers.destroy( f );
 	}
 }
Index: trunk/src/lua/lua_area.cc
===================================================================
--- trunk/src/lua/lua_area.cc	(revision 334)
+++ trunk/src/lua/lua_area.cc	(revision 335)
@@ -403,5 +403,5 @@
 static int luaopen_area( lua_State * L )
 {
-	NV_LUA_STACKASSERT( L, 0 );
+	NV_LUA_STACK_ASSERT( L, 1 );
 	static const struct luaL_Reg nlua_area_sf [] = {
 		{ "new",            nlua_area_new },
Index: trunk/src/lua/lua_handle.cc
===================================================================
--- trunk/src/lua/lua_handle.cc	(revision 334)
+++ trunk/src/lua/lua_handle.cc	(revision 335)
@@ -7,4 +7,5 @@
 #include "nv/lua/lua_handle.hh"
 
+#include "nv/lua/lua_state.hh"
 #include "nv/lua/lua_raw.hh"
 
@@ -12,17 +13,20 @@
 void nv::lua::detail::push_handle_impl( lua_State* L, int pseudoindex, uint32 index )
 {
-	int stack = lua_gettop(L);
+	NV_LUA_STACK_ASSERT( L, +1 );
 	lua_rawgeti( L, LUA_REGISTRYINDEX, pseudoindex ); // table
 	lua_rawgeti( L, -1, index );                      // table, entry
-	if ( lua_isnil( L, -1 ) )
+	if ( !lua_istable( L, -1 ) )
 	{
 		NV_LOG( nv::LOG_ERROR, "NIL" );
+		lua_pop( L, 2 );
+		lua_pushnil( L );
+		return;
 	}
-	lua_replace( L, stack + 1 );
-	lua_settop( L, stack + 1 );
+	lua_replace( L, -2 );
 }
 
 nv::lua::detail::handle_struct nv::lua::detail::to_handle_impl( lua_State* L, int i, uint32 dindex, uint32 dcounter )
 {
+	NV_LUA_STACK_ASSERT( L, 0 );
 	handle_conversion hc;
 	hc.h.index   = dindex;
@@ -59,8 +63,8 @@
 void nv::lua::detail::unregister_handle_impl( lua_State* L, int pseudoindex, uint32 index )
 {
-	int stack = lua_gettop(L);
+	NV_LUA_STACK_ASSERT( L, 0 );
 	lua_rawgeti( L, LUA_REGISTRYINDEX, pseudoindex ); // table
 	lua_pushinteger( L, 0 );
 	lua_rawseti( L, -2, index );
-	lua_settop( L, stack );
+	lua_pop( L, 1 );
 }
