Improve on the complexity of dictionary elab.

Use sets to memorize already visited classes