Fixed all errors and warnings indicated by flake8