flake8 all the things!

Lots of modifications to make it pass flake8. All tests still pass. Might want to review thoroughly.