Improved nth_prime error handling
Refactoring
Fix overflow bug in isqrt(x)