def op_canonicalize_quirks(op_name, new_record, current_record):
    """
    This method preserves backwards-compatibility quirks on canonicalized op data,
    for snapshotting purposes.  It gets called after the nameop is committed and 
    its history is saved, but before it gets snapshotted to form the new consensus hash.
    
    Backwards-compatibility quirks:
    * if the operation was created by a NAME_IMPORT, then 'op_fee' must be a float (i.e. must end in .0)
    * always preserve the 'last_creation_op' field if it is not set in new_record

    Other quirks:
    * make sure token_fee is a string, to prevent overflows when reading from history

    Returns the new canonicalized op data
    """
    ret = {}
    ret.update(new_record)

    if op_name in OPCODE_NAME_NAMEOPS and op_name in OPCODE_NAME_STATE_TRANSITIONS:
        # nameop state transition.  Need to ensure the op_fee is in the right format.
        # depends on what created it
        if op_name != 'NAME_IMPORT':
            # this is some other state transition besides an import.  A prior record must exist.
            assert current_record
        
        if current_record:
            for f in ['op_fee', 'last_creation_op']:
                assert f in current_record, 'BUG: missing {} for existing {}'.format(f, op_name)

        # extract quirky values
        quirk_values = {}
        for f in ['op_fee', 'last_creation_op']:
            # get the quirky field, favoring the new record's value over the current record
            val = new_record.get(f)
            if val is None and current_record is not None:
                val = current_record.get(f)
            
            assert val is not None, 'Neither new record nor current record has a value for "{}"'.format(f)
            quirk_values[f] = val

        # QUIRK: NAME_IMPORT-created ops need a float(op_fee).  Everyone else just takes it as it is.
        assert quirk_values['op_fee'] is not None, 'BUG: no op_fee carried over'
        if quirk_values['last_creation_op'] == NAME_IMPORT:
            quirk_values['op_fee'] = float(quirk_values['op_fee'])
        else:
            quirk_values['op_fee'] = int(quirk_values['op_fee'])

        ret['op_fee'] = quirk_values['op_fee']

        # QUIRK: preserve last_creation_op across records
        ret['last_creation_op'] = quirk_values['last_creation_op']

    if 'token_fee' in ret and isinstance(ret['token_fee'], (int,long)):
        ret['token_fee'] = '{}'.format(ret['token_fee'])

    return ret
This method preserves backwards-compatibility quirks on canonicalized op data,
    for snapshotting purposes.  It gets called after the nameop is committed and 
    its history is saved, but before it gets snapshotted to form the new consensus hash.
    
    Backwards-compatibility quirks:
    * if the operation was created by a NAME_IMPORT, then 'op_fee' must be a float (i.e. must end in .0)
    * always preserve the 'last_creation_op' field if it is not set in new_record

    Other quirks:
    * make sure token_fee is a string, to prevent overflows when reading from history

    Returns the new canonicalized op data