Refactored HierarchyGridState and GridState.