Fixed some compatibility issues with Python 2.6, 3.0, and 3.1