1) remove the dependent equations before removing Polynomials. Notice that this newer version has not being tested if this is better than original one, and also the c version has not been implemented yet.

Signed-off-by: ezheng <ezheng@cs.unc.edu>