Work in progress NMH traversal and rebuild code.

And various helper classes/functions.