cleanup unused imports
PEP8: fix spacing

- around keyword args
- between top-level functions
remove unused variable
update exception raising syntax to new style

Old format is deprecated in PEP8
PEP8: Reduce all lines to max 80 characters