Bug fixes in PreferenceState and elsewhere; moved DebugUtility