Fixed JSHint warnings and beautified