added defensive code for deleting an embedded imp.