A Model of Complex Contracts