grid() args processing bit more elegant

Previously all args were traversed twice. Now there's a partition
on all args, then only class-args are traversed again for map_join.