fixed issues, made (mostly) pep8 compliant