Refactor gradient building to not assume DoubleEndedIterator
b6a2f4a
Future changes to how auxiliary data is stored will break this.