Forgot to include Rtd coeff in gradient!
Also added if() to skip TD section when NTD==0