Fixed bug when deleting nodes.