minor cleanup, and preallocate residual vector on CPU