Fixed sqlite consistency problems