Remove unused iterators and add an explicit cast to suppress compiler

warning.