Cherry picking outlier rejection changes from PR #146