Fix scoping around loop counters.