Py2/3 compatibility fixes.