How to Reduce Value Leakage in Complex Contracts