Added compatibility with Python 3