Python 2.x compatibility fixes