More threading fixes