Improved IPubAfterTraversal hook code