When numResults == 1, path.ids are wrongly inserted into the beginning of generator_.ids. This is fine if the batchSize == 1, but will have an reverse batch if batchSize > 1. The .begin() should be changed to .end(). The original code '.begin()' must be a typo.