PEP8 and deprecation fixes