Tweaked tree-walks for performance. Stores results of tree-walks and only rewalks tree when required.
Removed other changes than tree-walk tweaks
Merge pull request #1 from sjwqmul/master

merge steve's performance tweaks