Factor ref-counting out into macros.
Fix tracing in indexnodes.
TODO.