Prepare restore of iterator state
Let foreach operate on IteratorState (in a quite crazy way)
Consider referenced arrays correctly