Fix SQLite database implementation even more