More fixes to tree walk (mostly functions)