Latent heat give the most applicable solution.
In AOS or Arena maps, it's possible to use disable abilities as only one hero present. But sometimes it's not applicable, which means the second trick is the best way around.
The variable should be different for each caster, if there are multiple levels and multiple heroes uses the spell, as it might return wrong level when restored.