Extract buffering code to module
Merge branch 'master' into utp