Some refactoring to build a Buffer