Some refactoring for jslint warnings