Some memory leaks fixes;