fixed some nag warnings, added triangle case to t_e,max calculation, minor restructuring