a lot of PEP8 corrections and some bugs