Added calculation of primal and dual residuals