Fixed TG_ calculation algorithm.