Fix for gcd thanks to @elementalvoid!