Fix undo bug in freehand mode.