A couple minor fixes and cleanups

There were more, but I was too slow to make a patch, and other people already fixed them :)

I've annotated the fixes inline to describe each one.