Fixed bug regarding undefined localstorage.