Various stylistic changes
Fixes variable redeclarations
Uses Array.prototype.foreach for stricter scoping
Strict comparison operators with 0