[WIP] insert variable disposal instructions in the IR

This should help fix #578
Indeed. I will remove the WIP marker when I have finished polishing (and perhaps adding some tests to validate the sanity of the disposal logic).