Aligned with current preferences API
Resolve JSLint errors
Improved selector detection