Cleaned up the script generation quite a bit