Reformatted code and optimized imports

Reformatted according to pep 8 style guide.