Fix handling of loops with 0 counter