memory leaks in backtrack