switch residue to BasicMatrix and optimized reorthogonalize