Added joinable() check to thread code so we only wait on active threads (exception otherwise)
Added assert.h include globally