Factor out BufferStream