Switched to using BigInteger where possible to handle exceeding the double limitations.