thread: various cleanup.