Updated CalcTA function and IntegrateMatrix Function