Fixing some misuses of the Lua C API.