Modified collected and nodes to store indices instead of nodes
Hopefully reduce memory usage