Refactor for JSHint

Mostly passes linting now