Fix severe memory leak