Cleanups, thanks to code reviews from dalke on https://news.ycombinator.com/item?id=5771790 and bob2 on irc.freenode.net #python