adding proper destructors and some small changes in analysis macro