Fix potential bugs with opening/closing inventories in inventory events