Py2->Py3 bug fix.
Mainly bug fixes.