Generalize the XFA kill_variables code