Add constraintExists function, mild cleanup of other nearby funcs.