Fixed a memory leak in join