In optimizeProductChain, I pass Matrix2 chain... and then construct a tree of Products from this chain, and I need to pass in Ring into each Product (atm, taken from the left). In particular, it's called in optimize's case for Sum's children (L145-146) - the implicit Ring for optimize was removed and I couldn't get Ring elsewhere, unless it's implicitly in Matrix2. But perhaps there's a more elegant solution.