Added an iterator and refactored a few small things