more tidying up of the regression code