Remove dead code and restore the database to working order