Improve the behaviour of root-finding when g2 is zero or close to zero.