GM: Fix flake8 issues and missing imports