Better handling of variables invalidation, but not complete yet