fixed half memory leaks