Fix a bug where constraints could be inserted before the elements that are constrained (cont)