remove unused imports

also sort imports alphabetically for convenience
minor whitespace cleanup
fix wrong indentation
use augmented assignment
move docstrings to right place