Added persistent undo functionality.