Equals and hashCode functions implemented for Term