apply bug fix from gsl branch from @NebJ