Fixed stack memory leak