Fix some bugs, sqlite3