Fixed undo functionality.