Revert "Some memory leaks fixed."

This reverts commit ec773c532c09f3a4dc253a1bc1ff292cb5807440.