Fixed Python 2.x compatibility issues.