fixes #592

And perhaps it'd be simpler to apply the sorting here eg `dict(id=self.id, variables=sorted(variables))`.