Draft implementation of SMSDetector and gradient