Additional changes to support Python 3, now down to 40 test failures.