Various compat changes for Python 3