Changes to inversion logic from Victor.