Return upstream only if MAX_BATCH_SIZE is reached or we have drained all records
Minor cleanup.