Added undo/redo functionality.