Fix error with slope thresholding
Merge threshold fix from master