More efficient prime number detection

I would be surprised if we got any significant speed improvement, but I find it cleaner this way :)