Fix most memory leaks by clearing the thread queue on pool.join() and setting m_function=nullptr after runnning it.