Add safe iterators interface.
Add flattening for safe iterators.