Rearrange code for Flake8 compliance

Rearranges some of the code to comply with Flake8 warnings and errors.

This is part 1 of 2 for #44