Fixed a few GMP math bugs causing the build fails