Refactored code dealing with buffering, changed how cacheing works for the buffers