Improved overlap gain error estimate

The error was calculated using only two or three values per gain point,
which seriously underestimates the error. The code was changed to use
all scan points to calculate the error rather than just the sum.