Codereview : refactoring and initial sqlite3 support