Code review and pep8 improvements