added prefs, fixed bugs