Previous code example did not flush all entities when entity count was not a multiple of batch count.