Fix error on switching buffers.