Moved to leverage six instead of doing manual checks for PY2/PY3
and fixed some basic pep8 issues.