jon,
since you have hostname defined, next_gw() function sets r-uri and
destination uri and t_relay() should relay only based destination uri
unless you call t_relay() more than once.
No append_branch is executed at all. I have two
INVITES IMHO because
next_gw() function does create the second one.
next_gw() function does not create any invites. check how your r-uri
and dst uri look like after next_gw() call.
-- juha