Improve the iterator by only creating the object templates once

- also remove use of 'auto'