Added some flake8 compliance and fixed a bug