Bug fixes for hierarchy and more unit tests.