Corrections from André's review (27.01.2013).
Check loop vars more carefully.