Python 3 support & reformatted based on PEP8 recommendations.