refactor(buffering): cleanup buffering code