Fixing delete/undelete logic.