Moved some common logic into TransportHelper.