added time offsets between tf and tg. Fixed bugs