Simple methods such as using density during compositional simulations often fail to identify the phases correctly and this can cause discontinuities in the computed relative permeability values. The results are then physically incorrect. Furthermore, numerical simulators often slow down or even stop due to discontinuities. There are many important applications where the phase behavior can be single phase, gas-liquid, liquid-liquid, gas-liquid-liquid or gas-liquid-solid at different times in different grid blocks. Assigning physically correct phase identities during a compositional simulation turns out to be a very difficult problem that has resisted a general solution for decades. We know the intensive thermodynamic properties such as molar Gibbs free energy must be continuous assuming local equilibrium, but this condition is difficult to impose in numerical simulators because of the discrete nature of the calculations. An alternative approach is to develop a relative permeability model that is continuous and independent of the phase numbers assigned by the flash calculation. Relative permeability is a function of saturation, but also composition since composition affects the phase distribution in the pores i.e. the wettability. The equilibrium distribution of fluids in pores corresponds to the minimum in the Gibbs free energy for the entire fluid-rock system including interfaces. However, in general this relationship is very difficult to model from first principles. What we can easily do is calculate the molar Gibbs free energy (G) of each phase at reference compositions where the relative permeabilities are known or assumed to be known and then interpolate between these values using the G calculated during each time step of the simulation. Relative permeability values calculated this way are unconditionally continuous for all possible phase behavior changes including even critical points. We tested the new relative permeability model on a variety of extremely difficult simulation problems with up to four phases and it has not failed yet. We illustrate several of these applications.