Improved compatibility with Python 3.