Refactoring iterator classes