Make respect_nan work for all modes