fixed few Memory leaks

And added the a flag in cmake to build for memory leak checking
forgot return character