More work on scripting and stuff

Script reloading no longer crashes randomly (apparently).