misc changes to 2d treshold function