Improve zero checks in sparse and reduce