Fix crashing problem in preferences.