improve directory selection in settings panel
remove observer before destroying the object
Save and restore settings from pref file
better casting to avoid compiler warning