free buffers and matrix