Add Python 3 support.
REfactoring