Many small port fixes in the Python.