Replaces math.isnan with simple None comparisons.