gcd(): allow user to override (some of) heuristics.