Piecewise linear interpolation bug fix