Fixing iterator problem, where the wrong instance was instantiated.

Fixed issue #45.