Finished refactoring of SetNonzeros