New modpow function. Substantially faster now