Correctly deal with True/False/inf when substituting constants in standalone code