Remove some code duplication in InventoryState.