Might as well do this cleanly in one place.
This further cleans up the pgraph lib to be more generic.