Added more comments to the Python implementation.