flake8 fixes to core files