Improve dealing with 0 in terms
Add functions for finding the GCD