Refine prime_factors