Some thread optimization