More loop-invariant stuff to factor out.