Making the code Py3 compatible