Fix memory leak in EmergeManager