Fixed problems with saving preferences