I haven't looked at this script in years, so I don't know the smelt/unload routines. What I do know is that at GM mining and fighting ore elementals means you would also collect the ML large gems and crystalline blackrock. These items are not able to be smelted either and must be unloaded.
The only thing that can be smelted is the ore, and the smallest of ore pieces need 2 or more to be valid for smelting.
So there must be some logic about what is smelted or not already there which you should be able to find and take advantage of when making your modification.