Fixed issues with memory leaks
Merge branch 'diego'