Intermediate debugging code that may have fixed memory leak (maybe?)