use weakref for row.buf
fix orphaned rows
improve ESC[M, implement ESC[L