Fix bugs in code for Python 3.