Fixed #248. There was a bug in the buffer resizing code.