Fixed JSHint errors
Refactored global