Apply 1.3.x percentiles fix to 1.4.x

This fix was applied to the 1.3.x branch, but didn't make it into the 1.4 release. It's also not in master.