Various syntactical errors

Running this script through jshint, I found various syntactic errors, so I fixed them. Here's a PR.

My editor (Atom) also cleaned up some trailing whitespace. I was too lazy to edit that out.