fix undo/redo behavior and disable the buttons when appropriate