Make sure the lastG/lastT values are consistent in case of g() raising exception

2 jobs for issue-797 in 27 minutes and 41 seconds (queued for 22 minutes and 53 seconds)