Checking for free variables faster.

Added a specialised procedure that checks for free variables, instead
of computing getFreeVars() for every sub term.