Fixed potential iteration exceptions, and duplication of rows.