fixed some bugs, partially implemented localStorage