Remove trail spaces

and fix some other code style warnings from Flake8.