fixed bugs and improved prefs