Misc cleanups

As the title says, lots of miscellaneous cleanups. Mostly removing unused code and fixing various pylint warnings and/or minor things that have annoyed me for a while. E.g., style errors show up where the failed test report is now.

Each commit is one self-contained change, so I'm not going to list them all here.

@7andrew7 want to give it a skim please?
TODO fixme?