Formatting, pep8 and minor fixes