Refactor the buffer repo