allow renaming script api variable in script, fix resetApi and invokeFunction