Modified to pass most of flake8 checks.