Fixed incompatibilities with Python 3.x