Implementing lua_var, lua_ref and lua_value