fixed thread lifetime problems #14