fixing up some bugs in define-constraint-interaction
adding an environment to templates to make sure two occurrences of a fresh var in the pattern get the same fresh var in the copy