Cure an assert failure by gathering the right set of free variables