Replaced isnan(x) which caused build problems on OSX with x != x.