Minor optimizations.
Fix bug: Adt not set when variable in equation.
Minor improvements.