--- a/src/index/recollindex.cpp
+++ b/src/index/recollindex.cpp
@@ -1,5 +1,5 @@
 #ifndef lint
-static char rcsid[] = "@(#$Id: recollindex.cpp,v 1.4 2004-12-17 13:01:01 dockes Exp $ (C) 2004 J.F.Dockes";
+static char rcsid[] = "@(#$Id: recollindex.cpp,v 1.5 2005-01-25 14:37:21 dockes Exp $ (C) 2004 J.F.Dockes";
 #endif
 
 #include <sys/stat.h>
@@ -18,100 +18,10 @@
 #include "indexer.h"
 #include "csguess.h"
 #include "transcode.h"
+#include "mimehandler.h"
 
 using namespace std;
 
-
-bool textPlainToDoc(RclConfig *conf, const string &fn, 
-			 const string &mtype, Rcl::Doc &docout)
-{
-    string otext;
-    if (!file_to_string(fn, otext))
-	return false;
-	
-    // Try to guess charset, then convert to utf-8, and fill document
-    // fields The charset guesser really doesnt work well in general
-    // and should be avoided (especially for short documents)
-    string charset;
-    if (conf->guesscharset) {
-	charset = csguess(otext, conf->defcharset);
-    } else
-	charset = conf->defcharset;
-    string utf8;
-    cerr << "textPlainToDoc: transcod from " << charset << " to  UTF-8" 
-	 << endl;
-
-    if (!transcode(otext, utf8, charset, "UTF-8")) {
-	cerr << "textPlainToDoc: transcode failed: charset '" << charset
-	     << "' to UTF-8: "<< utf8 << endl;
-	otext.erase();
-	return 0;
-    }
-
-    Rcl::Doc out;
-    out.origcharset = charset;
-    out.text = utf8;
-    //out.text = otext;
-    docout = out;
-    cerr << utf8 << endl;
-    return true;
-}
-
-// Map of mime types to internal interner functions. This could just as well 
-// be an if else if suite inside getMimeHandler(), but this is prettier ?
-static map<string, MimeHandlerFunc> ihandlers;
-// Static object to get the map to be initialized at program start.
-class IHandler_Init {
- public:
-    IHandler_Init() {
-	ihandlers["text/plain"] = textPlainToDoc;
-	// Add new associations here when needed
-    }
-};
-static IHandler_Init ihandleriniter;
-
-
-/**
- * Return handler function for given mime type
- */
-MimeHandlerFunc getMimeHandler(const std::string &mtype, ConfTree *mhandlers)
-{
-    // Return handler definition for mime type
-    string hs;
-    if (!mhandlers->get(mtype, hs, "")) 
-	return 0;
-
-    // Break definition into type and name 
-    vector<string> toks;
-    ConfTree::stringToStrings(hs, toks);
-    if (toks.size() < 1) {
-	cerr << "Bad mimeconf line for " << mtype << endl;
-	return 0;
-    }
-
-    // Retrieve handler function according to type
-    if (!strcasecmp(toks[0].c_str(), "internal")) {
-	cerr << "Internal Handler" << endl;
-	map<string, MimeHandlerFunc>::const_iterator it = 
-	    ihandlers.find(mtype);
-	if (it == ihandlers.end()) {
-	    cerr << "Internal handler not found for " << mtype << endl;
-	    return 0;
-	}
-	cerr << "Got handler" << endl;
-	return it->second;
-    } else if (!strcasecmp(toks[0].c_str(), "dll")) {
-	if (toks.size() != 2)
-	    return 0;
-	return 0;
-    } else if (!strcasecmp(toks[0].c_str(), "exec")) {
-	if (toks.size() != 2)
-	    return 0;
-	return 0;
-    } else {
-	return 0;
-    }
-}
 
 /**
  * Bunch holder for data used while indexing a directory tree
@@ -151,7 +61,11 @@
 
 /** 
  * This function gets called for every file and directory found by the
- * tree walker. Adjust parameters and index files if/when needed.
+ * tree walker. It checks with the db is the file has changed and needs to
+ * be reindexed. If so, it calls an appropriate handler depending on the mime
+ * type, which is responsible for populating an Rcl::Doc.
+ * Accent and majuscule handling are performed by the db module when doing
+ * the actual indexing work.
  */
 FsTreeWalker::Status 
 indexfile(void *cdata, const std::string &fn, const struct stat *stp, 
@@ -209,7 +123,6 @@
 }
 
 
-
 int main(int argc, const char **argv)
 {
     RclConfig *config = new RclConfig;