Enhance ThresholdService

Pull some code out of Threshold plugin and put in ThresholdService