Pull event listener out of loop and remove closure

Closure was not needed, and removing function from loop makes quiets
jslint. Some other jslint complaints fixed too.