ENH: clean up the very ugly iteration buffering