Fixed bug in, and improved, is_prime() implementation.