cleanups

This pull request is actually just to call attention to some specific minor issues in the code which I found by running flake8. Most of it is just formatting stuff, but there are also a couple of likely typos which might affect the functioning of the code. I will be happy if you review the changes and close the pull request without merging, but you could also merge if you are bored of doing it manually.