Bugfixes for Python 3