Generalise constraint handling a little