Fix doctest + misc. PEP8 and formatting fixes.