fix sqlite related bugs