Add trace minimization code