MAINT: cleanup and use count_nonzero for large q check