Refined the inventory gathering code.