Remove use of for-in loop and make sure variables are declared with
"var".

See
https://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml?showone=for-in_loop#for-in_loop
for details on why for-in is bad.