Add state transitioning between Imperative and CPP phases.