Moved term logic to term.c