Each category now tracks with nodes belong to it.

This is needed to correctly implement dag_to_file.
Adds @vars to dag_to_file