Updated exponential fitting to make it robust.