Py3 bugs fixed