DialogSelectThresholds() doesn't crash anymore but for some reason, doesn't really give any sensible threshold outputs.  You definitely need to step through the code with a find toothed comb.

The Optimization button also still generates a strange error (and doesn't work at all...). More work for tomorrow(?)