Regrouped reference.ts by directory