fix errors when clearing local storage.