Fix multi-tr-to-record loophool and refactor.
Fix multi-tr-to-record loophool and refactor.

johnbachman/indra,sorgerlab/indra,pvtodorov/indra,sorgerlab/indra,bgyori/indra,sorgerlab/belpy,pvtodorov/indra,bgyori/indra,sorgerlab/indra,johnbachman/indra,johnbachman/belpy,pvtodorov/indra,johnbachman/indra,bgyori/indra,johnbachman/belpy,johnbachman/belpy,pvtodorov/indra,sorgerlab/belpy,sorgerlab/belpy