Added peak removal for the rest of the thresholds.
Moved threshold calculation above the threshold application.