Various PEP8 fixes, plus insufficient import in loop fix