I rebased this patch because of confliction in src/kwsearch.c.