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

2 jobs for issue-797 in 27 minutes and 44 seconds (queued for 7 seconds)