fix and improvement on deallocation of memory in various stage of chaos framework

Signed-off-by: Claudio Bisegni <Claudio.Bisegni@lnf.infn.it>