Added better constraint handling