Fix minor problems in term matching.