Some fixes for Lua interpreter crashes