This includes a fix reported with simplifications in the presence of NaN. This reverts the revert commit 06408451.