fix leaks in ADD_TRAIT, ADD_INTERFACE and FETCH_CLASS