Fixing potential memory leaks
Fixing potential memory leaks