Fix bugs with inventory handling