private final long fetchRecord(long records, int id) {
        if (records != Record.NOT_STORED) {
            byte[] session = getRecordManager().fetch(records);

            if (Debug.ENABLED)
                Debug.assertion(session.length == Session.TOTAL_LENGTH * 8);

            return Utils.readLong(session, id * 8);
        }

        return Record.NOT_STORED;
    }
    final void updateRecord(Version shared, Session session, byte[] uid, long currentRecord, long newRecord, int id) {
        if (Debug.ENABLED)
            Debug.assertion(newRecord != currentRecord);

        int index = _updatedVersions.add(shared);

        if (index == _updatedVersionsRecords.length)
            _updatedVersionsRecords = Utils.extend(_updatedVersionsRecords);

        _updatedVersionsRecords[index] = newRecord;

        // Sessions

        int sessionIndex = _updatedSessions.indexOf(session);
        long records = sessionIndex >= 0 ? _updatedSessionsRecords[sessionIndex] : session.getRecords();
        final long initialRecords = records;

        if (records == Record.NOT_STORED)
            records = _sessions.fetch(uid);

        if (records != Record.NOT_STORED) {
            byte[] data = getRecordManager().fetch(records);

            if (Debug.ENABLED) {
                Debug.assertion(data.length == Session.TOTAL_LENGTH * 8);
                Debug.assertion(Utils.readLong(data, id * 8) == currentRecord);
            }

            Utils.writeLong(data, id * 8, newRecord);
            getRecordManager().update(records, data, 0, data.length);
        } else {
            byte[] data = new byte[Session.TOTAL_LENGTH * 8];
            Utils.writeLong(data, id * 8, newRecord);
            records = getRecordManager().insert(data, 0, data.length);
            _sessions.put(uid, records);
        }

        if (records != initialRecords) {
            index = _updatedSessions.add(session);

            if (index == _updatedSessionsRecords.length)
                _updatedSessionsRecords = Utils.extend(_updatedSessionsRecords);

            _updatedSessionsRecords[index] = records;
        }
    }