Tidy-up code with PEP8/Flake8 edits