Complex sentence: New York in 1799, through gradual emancipation that freed the last slave in 1827; and New Jersey in 1804, in a program of gradual emancipation that resulted in some persons listed in the census before the American Civil War as still "indentured for life".
Split into simpler sentences: New York in 1827; and New Jersey in 1804, in a program of gradual emancipation. At the time of the American Civil War, some former slaves in New Jersey were still listed in the census as "indentured for life".