--- a/src/rcldb/rcldb.h
+++ b/src/rcldb/rcldb.h
@@ -111,13 +111,19 @@
     void clear() 
     {
 	entries.clear(); 
-	dbdoccount = 0; 
-	dbavgdoclen = 0;
     }
     // Term expansion
     vector<TermMatchEntry> entries;
     // If a field was specified, this is the corresponding index prefix
     string prefix;
+};
+
+class DbStats {
+public:
+    DbStats()
+	:dbdoccount(0), dbavgdoclen(0), mindoclen(0), maxdoclen(0)
+    {
+    }
     // Index-wide stats
     unsigned int dbdoccount;
     double       dbavgdoclen;
@@ -310,7 +316,9 @@
      * Expansion is performed either with either wildcard or regexp processing
      * Stem expansion is performed if lang is not empty 
      * 
-     * @param typ defines the kind of expansion: wildcard, regexp or stemming
+     * @param typ_sens defines the kind of expansion: none, wildcard, 
+     *    regexp or stemming. "none" will still expand case and
+     *    diacritics depending on the casesens and diacsens flags.
      * @param lang sets the stemming language(s). Can be a space-separated list
      * @param term is the term to expand
      * @param result is the main output
@@ -321,10 +329,16 @@
      *        will be appropriately prefix and the prefix value will be set 
      *        in the TermMatchResult header
      */
-    enum MatchType {ET_WILD, ET_REGEXP, ET_STEM};
-    bool termMatch(MatchType typ, const string &lang, const string &term, 
+    enum MatchType {ET_NONE=0, ET_WILD=1, ET_REGEXP=2, ET_STEM=3, 
+		    ET_DIACSENS=8, ET_CASESENS=16};
+    int matchTypeTp(int tp) 
+    {
+	return tp & 7;
+    }
+    bool termMatch(int typ_sens, const string &lang, const string &term, 
 		   TermMatchResult& result, int max = -1, 
 		   const string& field = cstr_null);
+    bool dbStats(DbStats& stats);
     /** Return min and max years for doc mod times in db */
     bool maxYearSpan(int *minyear, int *maxyear);
 
@@ -426,8 +440,13 @@
     bool i_close(bool final);
     // Reinitialize when adding/removing additional dbs
     bool adjustdbs(); 
+#ifdef RCL_INDEX_STRIPCHARS
     bool stemExpand(const string &lang, const string &s, 
 		    TermMatchResult& result);
+#endif
+    bool idxTermMatch(int typ_sens, const string &lang, const string &term, 
+		      TermMatchResult& result, int max = -1, 
+		      const string& field = cstr_null);
 
     // Flush when idxflushmb is reached
     bool maybeflush(off_t moretext);