fix code according to pep8 (almost) and add the new features