Fixed bugs with localStorage