Code cleanup

Apply flake8 fixes and whitespace cleanup.