Fix restoring and improve deleting