Commented console.log and fixed globals leaks

@sidorares this silence `console.log`s and add some missing `var`s to avoid global variable leaks