PEP8 and minor bugfixes