Substitute constants with modular equivalents more safely