Fixing some bugs in the scripts and making bad script states a little
more obvious when parsing.