Started implementing thread joining before freeing