Small optimizations and fixes.
Reuse topology to save computation.
Added Alex's models as a test case.
Fix for duplicate variables.