fix saving of preferences