Adapt to Python3