public function assignTokensToRelations()
    {
        // Find out if we have relation fields and return when none exists in this track
        $relationFields = $this->getTrackEngine()->getFieldsOfType('relation');
        if (empty($relationFields)) {
            return 0;
        }

        // Check if we have a respondent relation id (grr_id) in the track fields
        // and assign the token to the correct relation or leave open when no
        // relation is defined.
        $this->_ensureRounds();
        $relationFields = $this->getFieldData();
        $fieldPrefix = \Gems\Tracker\Model\FieldMaintenanceModel::FIELDS_NAME . \Gems\Tracker\Engine\FieldsDefinition::FIELD_KEY_SEPARATOR;
        $changes = 0;
        foreach ($this->getTokens() as $token) {
            /* @var $token Gems_Tracker_Token */
            if (!$token->isCompleted() && $token->getReceptionCode()->isSuccess()) {
                $roundId = $token->getRoundId();
                if (!array_key_exists($roundId, $this->_rounds)) {
                    // If not a current round for this track, do check the round when it still exists
                    $round = $this->getTrackEngine()->getRoundModel(true, 'index')->loadFirst(array('gro_id_round' => $roundId));
                } else {
                    $round = $this->_rounds[$roundId];
                }

                $relationFieldId = null;
                $relationId      = null;

                // Read from the round
                if (!empty($round) && $round['gro_id_track'] == $this->getTrackId() && $round['gro_active'] == 1) {
                    if ($round['gro_id_relationfield'] > 0) {
                        $relationFieldId = $round['gro_id_relationfield'];
                    }
                } else {
                    // Try to read from token, as this is a token without a round
                    $relationFieldId = $token->getRelationFieldId();
                }

                if ($relationFieldId>0) {
                    $fieldKey = $fieldPrefix . $relationFieldId;
                    if (isset($relationFields[$fieldKey])) {
                        $relationId = (int) $relationFields[$fieldKey];
                    } else {
                        $relationId = -1 * $relationFieldId;
                    }
                }

                $changes = $changes + $token->assignTo($relationId, $relationFieldId);
            }
        }

        if (MUtil_Model::$verbose && $changes > 0) {
            MUtil_Echo::r(sprintf('%s tokens changed due to changes in respondent relation assignments.', $changes));
        }

        return $changes;
    }