Refactor iterator and its utils into its own module