more effichent multithreading in leafcount