Style fixes (and a bugfix)

Small bunch of cleanups and a couple of missing variables were spotted.