Calculation of TE implemented
Still in need of debugging