Query expansion and egrep processing rewritten