Fix JavaScript "for i in" issues