Added saving of preferences

Uses the SetPref to store settings between sessions.
Merge remote-tracking branch 'origin/micke-work'