Fix massive memory leak