Writting buffer refactoring