Improve DLP (gcd before invmod)