What was the effect of the invention of the cotton gin on the United States in the first half of the nineteenth century?