Made code comply to PEP8 and work with python3.