Make contract profiler's path shortening more robust.