Refactor incoming buffer flushing.