Refactor for buffering.