Fixed memory and timing issues, removed Node[][] arrays for keeping track of topological sort orders