Fixed all for (var i=0; ...) loops