Credits for Python3 port.