matrix hierarchy refactoring