I'm not really too familiar with LUA scripting, but is there a way to bank cast times of spells into a variable, and then apply some conditional logic that says if you cast icicle generator within a certain timeframe (this would need to be worked out I guess) of Ice Lance, it's icicle count is ignored? Did these situations only occur under meta/hero? Might be able to put all of that inside a conditional that first checks for those buffs (if you can even do that), so that none of those variables needed to do that are declared until needed and shouldn't impact performance too much.