Add subterms and pattern matching functions.