Fixed js errors when prefs not set