fix lua scripting bugs