1. Zero out the residuals vector before it is used. 2. explicit comparison with NULL for jacobian and residuals pointers.