Fix a bunch of flake8 things

Fixes
- A bunch of unused imports
- A bunch of cases where variables were being assigned but not used