Add iterator and toArray() functionality