Run through JSHint to fix some inconsistencies and make it more robust