slightly rework lib tree popu algo to be more robust