Replaced all occurences of buf with buffer.