Loop invariants working.