Some hacking to make it compatible with python3.