Fixed some bugs in sub string search code ...