various Py3 fixes