Fixed template specialization in num_nodes.

Now respect const correctness