Some changes to the Python implementation.