Add Python 3 support.
- Also contains some minor style fixes.