Fix ABA problem, but introduces a memory leak (a better problem than random segfaults)