Refine handling of debug state