Fix dupe bug caused by externally modified inventory