refactor, cleanup, add prime_divisors func in tools