Optimizing leaf position fetching

The array for the leafpositions is now using the leafcount property to
size the array efficiently.