Minor changes to script, including variable names, comments, and some code organization