Added possibility to perform subqueries in exists and in clauses using closures.

Also made some minor changes to minimize chances of naming collisions.

Everything is tested :)