Cleaning up code and making it PEP8 compliant