How did the cotton gin and the railroad impact slavery?