1. A method executed by a processor for upgrading software represented as a call flow graph having a plurality of states and a plurality of state transitions where a plurality of tokens traverse the graph executing functions, comprising: identifying a target region of the graph; obtaining a new region for the graph; determining a correspondence between states of the target region of the graph and states of the new region for the graph, said step of determining the correspondence between states of the target region of the graph and states of the new region for the graph comprising: identifying states of the target region of the graph; identifying states of the new region for the graph; and for each of the identified states of the target region of the graph, determining whether any of the states of the new region for the graph are associated with that state of the target region of the graph; and replacing the target region of the graph with the new region for the graph using the correspondence between states of the target region of the graph and states of the new region for the graph.