r161: disable multi-threading when too few left
r162: special casing single insertion in multi mod
r163: fixed mem leak and a deadlock