Fixed a major memory leak