Improve accuracy of `mean_before_p`