small modifications to the graph merge stuff. TMB