NaN and Inf fix