added missing lua_type call for lua_typename
make compat-5.2.c compile for Lua 5.0 (still untested and unsupported)
added some missing stack checks