some fixes for undo