Make the code PEP8 compatible, and several minor revisions.