Simplify some type inference code, implement type inference for reduceat