Refactor the Lua sandbox API