'Rename auto-generated unique variables'

def normalize(self, newvars=None):

    def get_indiv_vars(e):
        if isinstance(e, IndividualVariableExpression):
            return set([e])
        elif isinstance(e, AbstractVariableExpression):
            return set()
        else:
            return e.visit(get_indiv_vars, (lambda parts: reduce(operator.or_, parts, set())))
    result = self
    for (i, e) in enumerate(sorted(get_indiv_vars(self), key=(lambda e: e.variable))):
        if isinstance(e, EventVariableExpression):
            newVar = e.__class__(Variable((u'e0%s' % (i + 1))))
        elif isinstance(e, IndividualVariableExpression):
            newVar = e.__class__(Variable((u'z%s' % (i + 1))))
        else:
            newVar = e
        result = result.replace(e.variable, newVar, True)
    return result
