pep8 and various re-formatting

originally came about from #367