Refactor constraints hashing
Refactor file copying and caching