Fixed a large memory leak.