I think we should split the bodies of these loops out into functions, just so this method is shorter and we're sure we're not accidentally re-using local variables we don't want to? Maybe ``row_for_outbound_messsage(...)`` and ``row_for_inbound_message(...)``?