I changed my code to use larger prime numbers than I was using previously, and the problem has stopped. I'm not sure what changed other than the values but it's working again :) Thank you for the responses :) -Sam