More port to Python 3.
More Python 3 compatibility fixes