Fix Python 3 inconsistencies