Correct bad scoping for for loops.  This fixes #640
3 files changed