Fix deletion of nodes and undo