fixed memory leak at node removal, TODO: conditional variables