code: def cleanup(self):
          
          for dict in (self.rule2func, self.rules, self.rule2name):
              for i in list(dict.keys()):
                  dict[i] = None
          for i in dir(self):
              setattr(self, i, None)
docs: Remove recursive references to allow garbage
          collector to collect this object.