mostly fixed undo