Added localstorage saving and loading of preferences