Separate some functions to work with buffer into another file