fixed flake8 issues and template imports