Fixup contract restricts.

Add useful printing.
Add removal of trival constraints.
Fix bug in close loop when constraints were not getting closed correctly.
Fix class static contracts and add tests.