fix weights and residuals