Replaced some calls to std::isnan() by calls to !std::isfinite().