Used MAX instead of fmax so that we are not converting between doubles and floats on 64-bit builds.