Added protection to inventory updating.