General purpose buffer handling module