Fix Python 3 compatibility
More Python 3 fixes