Improve handling of constraints