Add code to auto clear up buffers