Fixed some bugs, switched db to sqlite