Improve undo/redo and cut/copy/paste behavior.