Refactor code to be valid with JSHint