changed modexp to use pow(x,y,z).  It is much (~2.5 times) faster.