Thread Safety Analysis: update TIL traversal mechanism to allow arbitrary
local contexts.  Also includes some minor refactoring.