Scripting changes

Squashed all the compile-time bugs. I'll leave the runtime errors to you.