Hierarchy depth bug fix.
Code clean up.