Improve transformRows and inputsToExps.