Fix nested iteration.

Fixes for #11.