Contract and franchise design