Finished new key, fixed a bug in modInverse, refactored heavily