Technology, Market Structure and the Gains from Trade