Centralize buffer writes

* Makes it easier to inject debug statements.