Fix NPE in preferences.