Moved type classes to avoid type casts when using Index.
Changed commonFactor semantics: will never return 0.