Luascript cleanup/refactor