Fixed compatibility issues with Python3