Tidied up prime library and made a little more efficient (and usable for various number ranges)