-Corrections made to compute the average threshold value (duh). Still
untested;