Fix upgrade.

Don't use the ORM, handle duped slugs, and generally clean up.