fixed a bug in distinct degree factorization
fixed a memory leak