Bugfix: Iterator invalidation lead to core dumps or assertion failures.

See #42 and #47.