Python 3 compatibility and PEP8 cleanup (since I'm OCD)