fix redeploying failing the secondary objective

code cleanup
add a switch for the behavior regression introduced by #7067