Fixed scripting bugs