code styling & pep8 refactoring

I've tested this but please run tests on this code before approve.

Change-Id: I69c9a89d3e377a25bf1319909f93ddf18fc8eaf3
Merge "code styling & pep8 refactoring"