Fixes to restore Python 2 support