Improve templating of buffers