Slightly improve trace detection to avoid library crash