First cleanup branch

This fixes some import and whitespace issues to align closer to pep8.
I added a few comments to make further contributions easier.

Tested on Ubuntu 14.04 and cyanogenmod 10