Reset loop counters when entering periodic loops.