Add more compatibility with Python 2 and 3