Correctly flushing on large batches

Fixes #247