BUG: Fixed crash when deleting a node

When node references were attempted to be deleted the node was not valid anymore.
UpdateNodeReferences for all nodes didn't work (default NULL parameter was not accepted).