more aggressive flake8-based cleanup

Mostly style, but a few dropped unused vars
and imports.