Apply some of @tominsam's Python clean-up suggestions
Fix syntax errors. (Note to self- check the right script is running.)