add PEP8 coding style and fix bugs