General fixes, improvements and refactoring.

Lots of new goodies, including lambda vars and DBC guards on var objects.