Get rid of dependency on libgmp by writing our own routine for