Refactoring and shutting up jslint