Fixes for prime factor calculation