Fixed deprecation warning and some PEP8 fixes