Fixed bug in checking of subterms.