Improved traversal code a bit.