Prevent oscillation and stack overflow due to numerical imprecision, see #110