Refactor of the buffer resizing logic, and first implementation of the
shape buffer switching logic. Much better!