Refactor InventoryMode. #166