Better thread management