Fix modular inverse computation