[RFC] Consolidates macro code

Refactors macro code, and adds triangular indexing for constraints. Also allows to add conditionals to both when that's a viable option. I didn't update the ``@defConstrRef`` code yet, and honestly I'm not sure how useful it is anymore...
Also some comments on the input parameters and output format of this function would help us down the line.