Basic inventory overflow fix. Warning: It doesn't fix inventory overflow completely.