added a function to free buffers.