Bug fixes and altered sequential_resid_sfunc