The code was removing material slots while iterating through them which
is generally a bad idea, and it stopped working as the addon expected in
Blender 3.0+.
The slots are now removed by counting how many slots there are and then
removing that number of slots.