changed order of N allocation, to roots then leaves