Refactoring the creation of scratch buffers.