What year was the confederacy defeated?