Removed unused diagnostic function
Cleaner StopIteration handling