Fixed a TypeError on Py3.
Fixed some syntax errors on Py26.