Fix memory leak: do not add trait duplications to @defined_traits