Fixes of some memory leaks

Fixes of some memory leaks