Use a.ndim instead of numpy.rank(a).
Try to rewrite min/max handlers to fix bug 383.
Merge branch 'martinal/fix-issue-383'