(fixes #10) Index variable is not reset when multiple foreach loops are used in a single statement. Thanks to jgorinsky for the test case.