py3/py26 compatibility improvements