refactor: cleaned up the code for Lua VM instance management.