Revert "Fixed some potential memory leaks."

This reverts commit 73c8c8229c5435eab981e2f86bafb806748ee9c6.