Py3 related bugs fixed