Rewrite handling of constraints