Handle nil-block in iterators

Fixes #333.