One more thing: the "direction" contained in the dialog NOTIFYs is backwards, I think:
 
if (!strcasecmp(direction, "outbound")) {
    direction = "recipient";
    dft_state = "early";
} else {
    direction = "initiator";
    dft_state = "confirmed";
}
 
should be either comparing on "inbound" or switched around.  I am seeing inbound dialogs being marked "initiator".  The observed user (the internal FS extension) was the recipient of the call.
"This attribute is either initiator or recipient, and
         indicates whether the observed user was the initiator of the
         dialog, or the recipient of the INVITE that created it."