Refactor constraint hashing