Python 2.2 compatibility fixes