diff --git a/tsg_io/readBucketData.m b/tsg_io/readBucketData.m
index d5091070e58fba33f8e4b7de5561fcd83e7a89e2..e26dd4310f8d034ef77419a23d4632c1aa39a511 100644
--- a/tsg_io/readBucketData.m
+++ b/tsg_io/readBucketData.m
@@ -44,7 +44,7 @@ if fid ~= -1
     tsg.LATX_WS    = bucketData(:,7);
     tsg.LONX_WS    = bucketData(:,8);
     tsg.SSPS_WS    = bucketData(:,9);
-    tsg.SSPS_WS_QC = zeros(size(tsg.SSPS_WS));
+    tsg.SSPS_WS_QC = tsg.qc.Code.NO_CONTROL * ones(size(tsg.SSPS_WS));
     
     %@ completer ces 2 champs !!!!!!!!
     %tsg.PSAL_WS_ANALDATE =  ; 
diff --git a/tsg_io/readTsgDataLabview.m b/tsg_io/readTsgDataLabview.m
index 1e3bbf64e558d90bf1c6346ca9782cdef7f5251a..346487eca1622c09e67181347c50d55ae9546d81 100644
--- a/tsg_io/readTsgDataLabview.m
+++ b/tsg_io/readTsgDataLabview.m
@@ -88,7 +88,7 @@ if fid ~= -1
     tsg.SPDC       = sog;
     
     % Remplacer la valeur par tsg.qc.code.NOCONTROL
-    tsg.SSPS_QC    = ones(nblig,1);
+    tsg.SSPS_QC    = tsg.qc.Code.NO_CONTROL * ones(nblig,1);
 
     % populate tsg.file structure
     % ---------------------------
diff --git a/tsg_util/plot_SalTempVel.m b/tsg_util/plot_SalTempVel.m
index d69aa03ea9cf229596f88cefaefa662902644622..96f6256c3d4e64fe68c1b897aa7ff410c49d3350 100644
--- a/tsg_util/plot_SalTempVel.m
+++ b/tsg_util/plot_SalTempVel.m
@@ -14,33 +14,32 @@ function plot_SalTempVel( hTsgGUI, hAxes )
 % Retrieve named application data
 % -------------------------------
 tsg = getappdata( hTsgGUI, 'tsg_data');
-qc  = getappdata( hTsgGUI, 'qcColor');
 
 % Plot the Salinity with the right color code
 % -------------------------------------------
 axes( hAxes(1));
 
-ind = find(tsg.SSPS_QC <= qc.Code.NO_CONTROL );
+ind = find(tsg.SSPS_QC <= tsg.qc.Code.NO_CONTROL );
 plot(hAxes(1), tsg.DAYD(ind), tsg.SSPS(ind), ...
-               strcat('.',qc.Color.NO_CONTROL));
+               strcat('.',tsg.qc.Color.NO_CONTROL));
 
 hold on;
 
-ind = find(tsg.SSPS_QC == qc.Code.GOOD );
+ind = find(tsg.SSPS_QC == tsg.qc.Code.GOOD );
 plot(hAxes(1), tsg.DAYD(ind), tsg.SSPS(ind), ...
-               strcat('.',qc.Color.GOOD));
+               strcat('.',tsg.qc.Color.GOOD));
            
-ind = find(tsg.SSPS_QC == qc.Code.PROBABLY_GOOD );
+ind = find(tsg.SSPS_QC == tsg.qc.Code.PROBABLY_GOOD );
 plot(hAxes(1), tsg.DAYD(ind), tsg.SSPS(ind), ...
-               strcat('.',qc.Color.PROBABLY_GOOD));
+               strcat('.',tsg.qc.Color.PROBABLY_GOOD));
            
-ind = find(tsg.SSPS_QC == qc.Code.PROBABLY_BAD );
+ind = find(tsg.SSPS_QC == tsg.qc.Code.PROBABLY_BAD );
 plot(hAxes(1), tsg.DAYD(ind), tsg.SSPS(ind), ...
-               strcat('.',qc.Color.PROBABLY_BAD));
+               strcat('.',tsg.qc.Color.PROBABLY_BAD));
            
-ind = find(tsg.SSPS_QC == qc.Code.BAD );
+ind = find(tsg.SSPS_QC == tsg.qc.Code.BAD );
 plot(hAxes(1), tsg.DAYD(ind), tsg.SSPS(ind), ...
-               strcat('.',qc.Color.BAD));
+               strcat('.',tsg.qc.Color.BAD));
 hold off;             
 
 % Plot Temperature and ship velocity with no qc color code
diff --git a/tsg_util/plot_SalTsgSample.m b/tsg_util/plot_SalTsgSample.m
index 242610f59dd1b2baea9f51a8cc68bd19f91a9a72..da1c51efeb99c2509ad64837f5f95b18d7d2028b 100644
--- a/tsg_util/plot_SalTsgSample.m
+++ b/tsg_util/plot_SalTsgSample.m
@@ -14,35 +14,32 @@ function plot_SalTsgSample( hGUI, hAxes )
 % Retrieve named application data
 % -------------------------------
 tsg    = getappdata( hGUI, 'tsg_data');
-%sample = getappdata( hGUI, 'sample' );
-qc     = getappdata( hGUI, 'qcColor');
-
 
 % Plot the Salinity with the right color code
 % -------------------------------------------
 axes( hAxes(1));
 
-ind = find(tsg.SSPS_QC <= qc.Code.NO_CONTROL );
+ind = find(tsg.SSPS_QC <= tsg.qc.Code.NO_CONTROL );
 plot(hAxes(1), tsg.DAYD(ind), tsg.SSPS(ind), ...
-               strcat('.',qc.Color.NO_CONTROL));
+               strcat('.',tsg.qc.Color.NO_CONTROL));
 
 hold on;
 
-ind = find(tsg.SSPS_QC == qc.Code.GOOD );
+ind = find(tsg.SSPS_QC == tsg.qc.Code.GOOD );
 plot(hAxes(1), tsg.DAYD(ind), tsg.SSPS(ind), ...
-               strcat('.',qc.Color.GOOD));
+               strcat('.',tsg.qc.Color.GOOD));
            
-ind = find(tsg.SSPS_QC == qc.Code.PROBABLY_GOOD );
+ind = find(tsg.SSPS_QC == tsg.qc.Code.PROBABLY_GOOD );
 plot(hAxes(1), tsg.DAYD(ind), tsg.SSPS(ind), ...
-               strcat('.',qc.Color.PROBABLY_GOOD));
+               strcat('.',tsg.qc.Color.PROBABLY_GOOD));
            
-ind = find(tsg.SSPS_QC == qc.Code.PROBABLY_BAD );
+ind = find(tsg.SSPS_QC == tsg.qc.Code.PROBABLY_BAD );
 plot(hAxes(1), tsg.DAYD(ind), tsg.SSPS(ind), ...
-               strcat('.',qc.Color.PROBABLY_BAD));
+               strcat('.',tsg.qc.Color.PROBABLY_BAD));
            
-ind = find(tsg.SSPS_QC == qc.Code.BAD );
+ind = find(tsg.SSPS_QC == tsg.qc.Code.BAD );
 plot(hAxes(1), tsg.DAYD(ind), tsg.SSPS(ind), ...
-               strcat('.',qc.Color.BAD));
+               strcat('.',tsg.qc.Color.BAD));
            
 % Plot salinity sample on TSG plot
 % --------------------------------
diff --git a/tsg_util/tsg_initialisation.m b/tsg_util/tsg_initialisation.m
index 612519220b05b6ca33ec01aa56dd50d11da3dc31..a9ee58f12740284278eeb682d390e87bcec628dd 100644
--- a/tsg_util/tsg_initialisation.m
+++ b/tsg_util/tsg_initialisation.m
@@ -36,27 +36,20 @@ tsg.file.type = [];
 % -------------------------------------------------------------------------
 % Quality Code and color
 
-qc.Color.NO_CONTROL    = 'k';
-qc.Color.GOOD          = 'b';
-qc.Color.PROBABLY_GOOD = 'g';
-qc.Color.PROBABLY_BAD  = 'm';
-qc.Color.BAD           = 'r';
-
-qc.Code.NO_CONTROL     = 1;
-qc.Code.GOOD           = 2;
-qc.Code.PROBABLY_GOOD  = 3;
-qc.Code.PROBABLY_BAD   = 4;
-qc.Code.BAD            = 5;
-
-% Store default value 'quality' a application data - It's not useful
-% ------------------------------------------------------------------
-quality.Code  = qc.Code.GOOD;
-quality.Color = qc.Color.GOOD;
-set( hQcCmenu, 'UserData', quality );
-
-% Store the 'qc' structure as application data
-% --------------------------------------------
-setappdata( hTsgGUI, 'qcColor', qc);
+tsg.qc.Color.NO_CONTROL    = 'k';
+tsg.qc.Color.GOOD          = 'b';
+tsg.qc.Color.PROBABLY_GOOD = 'g';
+tsg.qc.Color.PROBABLY_BAD  = 'm';
+tsg.qc.Color.BAD           = 'r';
+
+tsg.qc.Code.NO_CONTROL     = 1;
+tsg.qc.Code.GOOD           = 2;
+tsg.qc.Code.PROBABLY_GOOD  = 3;
+tsg.qc.Code.PROBABLY_BAD   = 4;
+tsg.qc.Code.BAD            = 5;
+
+tsg.qc.Code.ACTIVE         = tsg.qc.Code.NO_CONTROL;
+tsg.qc.Color.ACTIVE        = tsg.qc.Color.NO_CONTROL;
 
 % -------------------------------------------------------------------------
 %              Constants for the Correction procedure
@@ -187,7 +180,6 @@ tsg.LONX_WS               = [];
 
 % Water Sample variables
 tsg.SSPS_WS               = []; 
-tsg.SSPS_WS               = []; 
 tsg.SSPS_WS_QC            = []; 
 %tsg.SSPS_WS_DIF           = [];
 %tsg.SSPS_WS_SMOOTH        = [];  % a verifier
diff --git a/tsg_util/tsg_mergesample.m b/tsg_util/tsg_mergesample.m
index 6587544dc3368d0822144cabdf55c9586cc28628..9186ee0197ee9570e9c43c31ed805cf15b5f1006 100644
--- a/tsg_util/tsg_mergesample.m
+++ b/tsg_util/tsg_mergesample.m
@@ -1,4 +1,4 @@
-function [sample] = tsg_mergesample( hMainFig )
+function [] = tsg_mergesample( hTsgGUI )
 %
 % function [sample] = dev_mergesample( bucketNETCDF, bucketASCII)
 %
@@ -15,65 +15,58 @@ function [sample] = tsg_mergesample( hMainFig )
 % Get bucket data in ASCII or NETCDF format. If the data does not exist
 % getappdata return an empty matrix
 % ---------------------------------------------------------------------
-bucketASCII  = getappdata( hMainFig, 'bucketASCII');
-bucketNETCDF = getappdata( hMainFig, 'bucketNETCDF');
+tsg  = getappdata( hTsgGUI, 'tsg_data');
 
 % Create an empty structure with no fields
 % ----------------------------------------
-sample = struct('TIME',{} ,'LATITUDE',{} ,'LONGITUDE',{} ,'PSAL',{} , ...
-                'PSAL_QC',{} ,'PSAL_DIF',{} ,'PSAL_SMOOTH',{} ,'TYPE', {});    
+sample = struct('DAYD',{} ,'LATX',{} ,'LONX',{} ,'SSPS',{} , ...
+         'SSPS_QC',{} ,'SSPS_DIF',{} ,'SSPS_SMOOTH',{} ,'SSPS_TYPE', {});    
 
-% Fill the structure sample with the bucketNETCDF data.
+% Fill the structure sample with the bucket data.
 % This measurements are of TYPE 1
-% ----------------------------------------------------
-if ~isempty(bucketNETCDF)
-    
-    % Complete the bucket structure
-    % -----------------------------
-    bucketNETCDF.PSAL_DIF    = zeros(size(bucketNETCDF.PSAL));
-    bucketNETCDF.PSAL_SMOOTH = zeros(size(bucketNETCDF.PSAL));
-    bucketNETCDF.TYPE        = ones(size(bucketNETCDF.PSAL));
-    
-    sample = bucketNETCDF;
+% ------------------------------------------------
+if ~isempty(tsg.SSPS_WS)
+
+  sample.DAYD        = tsg.DAYD_WS;
+  sample.LATX        = tsg.LATX_WS;
+  sample.LONX        = tsg.LONX_WS;
+  sample.SSPS        = tsg.SSPS_WS;
+  sample.SSPS_QC     = tsg.SSPS_WS_QC;
+  sample.SSPS_DIF    = zeros(size(sample.DAYD));
+  sample.SSPS_SMOOTH = zeros(size(sample.DAYD));
+  sample.SSPS_TYPE   = ones(size(sample.DAYD));
 
 end
 
-% Fill the structure sample with the bucketNETCDF data.
-% This measurements are of TYPE 2
-% ----------------------------------------------------
-if ~isempty(bucketASCII)
-    
-    % Complete the bucketNETCDF structure
-    % -----------------------------------
-    bucketASCII.PSAL_DIF    = zeros(size(bucketASCII.PSAL));
-    bucketASCII.PSAL_SMOOTH = zeros(size(bucketASCII.PSAL));
-    bucketASCII.TYPE        = 2 * ones(size(bucketASCII.PSAL));
-       
-    % Fill in the sample structure
-    % ----------------------------
-    if isempty( sample )
-        sample = bucketASCII;
-    else
-        sample.TIME        = [sample.TIME;        bucketASCII.TIME];
-        sample.LATITUDE    = [sample.LATITUDE;    bucketASCII.LATITUDE];
-        sample.LONGITUDE   = [sample.LONGITUDE;   bucketASCII.LONGITUDE];
-        sample.PSAL        = [sample.PSAL;        bucketASCII.PSAL];
-        sample.PSAL_QC     = [sample.PSAL_QC;     bucketASCII.PSAL_QC];
-        sample.PSAL_DIF    = [sample.PSAL_DIF;    bucketASCII.PSAL_DIF];
-        sample.PSAL_SMOOTH = [sample.PSAL_SMOOTH; bucketASCII.PSAL_SMOOTH];
-        sample.TYPE        = [sample.TYPE;        bucketASCII.TYPE];
-    end
+% Fill the structure sample with the external sample
+% This measurements are of TYPE EXT
+% --------------------------------------------------
+if ~isempty(tsg.SSPS_EXT)
+
+  sample.DAYD        = [sample.DAYD;        tsg.DAYD_WS];
+  sample.LATX        = [sample.LATX;        tsg.LATX_WS];
+  sample.LONX        = [sample.LONX;        tsg.LONX_WS];
+  sample.SSPS        = [sample.SSPS;        tsg.SSPS_WS];
+  sample.SSPS_QC     = [sample.SSPS_QC;     tsg.SSPS_WS_QC];
+  sample.SSPS_DIF    = [sample.SSPS_DIF;    zeros(size(tsg.DAYD_WS))];
+  sample.SSPS_SMOOTH = [sample.SSPS_SMOOTH; zeros(size(tsg.DAYD_WS))];
+  sample.SSPS_TYPE   = [sample.SSPS_TYPE;   tsg.SSPS_EXT_TYPE];
+
 end
 
 % Sort the struct sample - increasing time.
 % -----------------------------------------
 if ~isempty(sample)
-    [sample.TIME, iOrder]  = sort(sample.TIME);
-    sample.LATITUDE    = sample.LATITUDE(iOrder);
-    sample.LONGITUDE   = sample.LONGITUDE(iOrder);
-    sample.PSAL        = sample.PSAL(iOrder);
-    sample.PSAL_QC     = sample.PSAL_QC(iOrder);
-    sample.PSAL_DIF    = sample.PSAL_DIF(iOrder);
-    sample.PSAL_SMOOTH = sample.PSAL_SMOOTH(iOrder);
-    sample.TYPE        = sample.TYPE(iOrder);
+  [sample.DAYD, iOrder] = sort(sample.DAYD);
+  sample.LATX           = sample.LATITUDE(iOrder);
+  sample.LONX           = sample.LONGITUDE(iOrder);
+  sample.SSPS           = sample.PSAL(iOrder);
+  sample.SSPS_QC        = sample.PSAL_QC(iOrder);
+  sample.SSPS_DIF       = sample.PSAL_DIF(iOrder);
+  sample.SSPS_SMOOTH    = sample.PSAL_SMOOTH(iOrder);
+  sample.SSPS_TYPE      = sample.TYPE(iOrder);
 end
+
+% Update application data sample
+% ------------------------------
+setappdata( hTsgGUI, 'sample', sample );
diff --git a/tsgcor_GUI.m b/tsgcor_GUI.m
index 98bf8acfe232cee27748bd7f59b1b0ae5c482f99..bad45a8e91e4c1d06254176557ad7a1e889e9ff1 100644
--- a/tsgcor_GUI.m
+++ b/tsgcor_GUI.m
@@ -1,14 +1,10 @@
-function tsgcor_GUI( hMainFig )
+function tsgcor_GUI( hTsgGUI )
 % tsgcor_GUI 
 %
 % GUI for correction of TSG data by comparison to samples
 % this GUI is a children of tsgqc_GUI
 %
 %
-% TO DO
-%   Se baser sur le code developper ici pour modifier tsgqc_GUI pour
-%   le menu contextuel : 1 seule fonction pour attribuer le code qualite
-%   et de couleur
 
 %% COPYRIGHT & LICENSE
 %  Copyright 2007 - IRD US191, all rights reserved.
@@ -32,104 +28,75 @@ function tsgcor_GUI( hMainFig )
 
 %%  Initialization tasks
 %   ********************
-    clc
-    
-    % Find program directory.
-    % functions (icons) should be store at a lower level
-    % add directories to Matlab search path, works on UNIX
-    % and Windows host
-    % ---------------------------------------------------
-    tsgqcname = mfilename;
-    fulltsgqcname = mfilename('fullpath');
-    DEFAULT_PATH_FILE = strrep(fulltsgqcname, tsgqcname, '') ;
-    p = [pathsep,...
-         DEFAULT_PATH_FILE,[filesep 'tsg_util' pathsep],...
-         DEFAULT_PATH_FILE,[filesep 'tsg_data' pathsep]
-        ];
-    addpath( p, '-END' );
-    rehash;
-    
-    % Screen limits for the GUI
-    % -------------------------
-    set(0,'Units','normalized');
-    guiLimits = get(0,'ScreenSize');
-    guiLimits(1) = guiLimits(1) + 0.05;
-    guiLimits(2) = guiLimits(2) + 0.05;
-    guiLimits(3) = guiLimits(3) - 0.1;
-    guiLimits(4) = guiLimits(4) - 0.2;
-
-    % Create and then hide the GUI as it is being constructed.
-    % --------------------------------------------------------
-    hChild1Fig = figure(...
-                'Name', 'TSG Correction', ...
-                'NumberTitle', 'off', ...
-                'Resize', 'on', ...
-                'Menubar','none', ...
-                'Toolbar', 'none', ...
-                'Tag', 'ButtonMotionOff', ...
-                'WindowButtonMotionFcn', @MouseMotion, ...
-                'CloseRequestFcn', @QuitProgram,...
-                'HandleVisibility','callback',...
-                'Visible','on',...
-                'Units', 'normalized',...
-                'Position',guiLimits);
+clc
+
+% Screen limits for the GUI
+% -------------------------
+set(0,'Units','normalized');
+guiLimits = get(0,'ScreenSize');
+guiLimits(1) = guiLimits(1) + 0.05;
+guiLimits(2) = guiLimits(2) + 0.05;
+guiLimits(3) = guiLimits(3) - 0.1;
+guiLimits(4) = guiLimits(4) - 0.2;
+
+% Create and then hide the GUI as it is being constructed.
+% --------------------------------------------------------
+hTsgCorGUI = figure(...
+  'Name', 'TSG Correction', ...
+  'NumberTitle', 'off', ...
+  'Resize', 'on', ...
+  'Menubar','none', ...
+  'Toolbar', 'none', ...
+  'Tag', 'ButtonMotionOff', ...
+  'WindowButtonMotionFcn', @MouseMotion, ...
+  'CloseRequestFcn', @QuitProgram,...
+  'HandleVisibility','callback',...
+  'Visible','on',...
+  'Units', 'normalized',...
+  'Position',guiLimits);
  
-% Get the data useful to the correction GUI
-% -----------------------------------------
-tsg    = getappdata( hMainFig, 'tsg_data' );
-sample = getappdata( hMainFig, 'sample' );
-cst    = getappdata( hMainFig, 'constante');
-qc     = getappdata( hMainFig, 'qcColor');
-
-    %  Construct the Menu
-    %   -----------------
-    hFileMenu = uimenu(...
-                    'Parent', hChild1Fig,...
-                    'HandleVisibility','callback',...
-                    'Label', 'File');
-    hSaveMenu = uimenu(...
-                    'Parent', hFileMenu,...
-                    'Label','Save',...
-                    'Accelerator','S',...
-                    'Tag', 'off', ...
-                    'HandleVisibility','callback',...
-                    'Callback',@SaveMenuCallback);
-    hQuitMenu = uimenu(...
-                    'Parent',hFileMenu,...
-                    'Label','Quit',...
-                    'Separator','on',...
-                    'Accelerator','Q',...
-                    'HandleVisibility','callback',...
-                    'Callback',@QuitMenuCallback);
-
-    %  Construct the Toolbar
-    %   -----------------
-    hToolbar       =   uitoolbar(...   % Toolbar for Open and Print buttons
-                        'Parent',hChild1Fig, ...
-                        'HandleVisibility','callback');
-    hSavePushtool  =   uipushtool(...   % Open Save toolbar button
-                        'Parent',hToolbar,...
-                        'TooltipString','Save file',...
-                        'CData',iconRead( ...
-                           [DEFAULT_PATH_FILE 'tsg_icon' filesep 'savedoc.mat']),...
-                        'HandleVisibility','callback', ...
-                        'ClickedCallback', @SaveMenuCallback);
-    hZoomPushtool  =   uipushtool(...   % Open Zoom toolbar button
-                        'Parent',hToolbar,...
-                        'Separator', 'on', ...
-                        'TooltipString','Zoom',...
-                        'CData', iconRead(fullfile(matlabroot, ...
-                                     '/toolbox/matlab/icons/zoom.mat')),...
-                        'HandleVisibility','callback', ...
-                        'ClickedCallback', @ZoomMenuCallback);
-    hPanPushtool  =   uipushtool(...   % Open Pan toolbar button
-                        'Parent',hToolbar,...
-                        'TooltipString','Pan',...
-                        'CData',iconRead(fullfile(matlabroot, ...
-                                      '/toolbox/matlab/icons/pan.mat')),...
-                        'HandleVisibility','callback', ...
-                        'ClickedCallback', @PanMenuCallback);
-    hBottlePushtool  = uipushtool(...   % Open toolbar button
+% Get the CONSTANTS
+% -----------------
+cst    = getappdata( hTsgGUI, 'constante');
+
+%  Construct the Menu
+%   -----------------
+hFileMenu = uimenu(...
+  'Parent', hTsgCorGUI,...
+  'HandleVisibility','callback',...
+  'Label', 'File');
+
+hQuitMenu = uimenu(...
+  'Parent',hFileMenu,...
+  'Label','Quit',...
+  'Separator','on',...
+  'Accelerator','Q',...
+  'HandleVisibility','callback',...
+  'Callback',@QuitMenuCallback);
+
+%  Construct the Toolbar
+%   --------------------
+hToolbar       =   uitoolbar(...   % Toolbar for Open and Print buttons
+  'Parent',hTsgCorGUI, ...
+  'HandleVisibility','callback');
+hZoomPushtool  =   uipushtool(...   % Open Zoom toolbar button
+  'Parent',hToolbar,...
+  'Separator', 'on', ...
+  'TooltipString','Zoom',...
+  'CData', iconRead(fullfile(matlabroot, ...
+          '/toolbox/matlab/icons/zoom.mat')),...
+  'HandleVisibility','callback', ...
+  'ClickedCallback', @ZoomMenuCallback);
+
+hPanPushtool  =   uipushtool(...   % Open Pan toolbar button
+  'Parent',hToolbar,...
+  'TooltipString','Pan',...
+  'CData',iconRead(fullfile(matlabroot, ...
+          '/toolbox/matlab/icons/pan.mat')),...
+  'HandleVisibility','callback', ...
+  'ClickedCallback', @PanMenuCallback);
+
+hBottlePushtool  = uipushtool(...   % Open toolbar button
                         'Parent',hToolbar,...
                         'TooltipString','Plot the Samples',...
                         'Separator', 'on', ...
@@ -159,7 +126,7 @@ qc     = getappdata( hMainFig, 'qcColor');
     % Static text that displays the position, salinity and temperature
     % ----------------------------------------------------------------
     hInfoText = uicontrol(...
-                'Parent', hChild1Fig, ...
+                'Parent', hTsgCorGUI, ...
                 'Style', 'text', ...
                 'Fontsize', 12, ...
                 'Fontweight', 'bold', ...
@@ -171,19 +138,19 @@ qc     = getappdata( hMainFig, 'qcColor');
     % Construct the plot axes
     % -----------------------
     hPlotAxes(1) = axes(...     % the axes for plotting Salinity
-                'Parent', hChild1Fig, ...
+                'Parent', hTsgCorGUI, ...
                 'Units', 'normalized', ...
                 'Visible', 'off', ...
                 'HandleVisibility','callback', ...
                 'Position',[.25, .6, .7, .32]); 
     hPlotAxes(2) = axes(...     % the axes for plotting sample
-                'Parent', hChild1Fig, ...
+                'Parent', hTsgCorGUI, ...
                 'Units', 'normalized', ...
                 'Visible', 'off', ...
                 'HandleVisibility','callback', ...
                 'Position',[.25, .3, .7, .25]); 
     hPlotAxes(3) = axes(...     % the axes for plotting ship velocity
-                'Parent', hChild1Fig, ...
+                'Parent', hTsgCorGUI, ...
                 'Units', 'normalized', ...
                 'Visible', 'off', ...
                 'HandleVisibility','callback', ...
@@ -193,7 +160,7 @@ qc     = getappdata( hMainFig, 'qcColor');
     % --------------------------------------------------
     % Create the uipanel
     hpDateLimit = uipanel( ...
-                'Parent', hChild1Fig, ...
+                'Parent', hTsgCorGUI, ...
                 'Title', 'Date Limits', ...
                 'Units', 'normalized', ...
                 'FontSize', 11, ...
@@ -240,7 +207,7 @@ qc     = getappdata( hMainFig, 'qcColor');
     % --------------------------------------------------
     % Create the button group
     hbgMethod = uibuttongroup( ...
-                'Parent',hChild1Fig, ...
+                'Parent',hTsgCorGUI, ...
                 'Title','Correction Method', ...
                 'Units', 'normalized', ...
                 'FontSize',11, ...
@@ -276,7 +243,7 @@ qc     = getappdata( hMainFig, 'qcColor');
     % Construct the context menu to delete samples
     % --------------------------------------------
     hSampleCmenu       = uicontextmenu(...
-                            'Parent', hChild1Fig, ...
+                            'Parent', hTsgCorGUI, ...
                             'HandleVisibility','callback' );
     hQcSampleNocontrol = uimenu(...
                             'Parent', hSampleCmenu,... 
@@ -297,9 +264,22 @@ qc     = getappdata( hMainFig, 'qcColor');
                             'ForegroundColor', 'r',...
                             'Callback', @Qc);
 
+                          
+                          
+                          
 % Pointer set to watch during reading and plotting
 % ------------------------------------------------
-set( hChild1Fig, 'Pointer', 'watch' );
+set( hTsgCorGUI, 'Pointer', 'watch' );
+
+% Get the data useful to the correction GUI
+% -----------------------------------------
+tsg    = getappdata( hTsgGUI, 'tsg_data' );
+
+% Merge bucket and external samples
+% ---------------------------------
+tsg_mergesample( hTsgGUI );
+
+
 
 dateMin = datestr(tsg.TIME(1), 31);
 dateMax = datestr(tsg.TIME(end), 31);
@@ -316,20 +296,17 @@ TSG_SAMPLING_TIME = tsg.TIME(2) - tsg.TIME(1);
 % Compute the sample-TSG differences
 sample = dev_diffTsgSample(tsg, psal_smooth, sample, TSG_SAMPLING_TIME);
 
-% Update application data sample
-setappdata( hMainFig, 'sample', sample );
-
 % Tracé
 % -----
-tsg_plot_SalTsgSample( hMainFig, hPlotAxes );
+tsg_plot_SalTsgSample( hTsgGUI, hPlotAxes );
 
 % Pointer reset to arrow
 % ----------------------
-set( hChild1Fig, 'Pointer', 'arrow' );
+set( hTsgCorGUI, 'Pointer', 'arrow' );
 
 % The callback to detect the mouse motion can be set to on
 % --------------------------------------------------------
-set( hChild1Fig, 'Tag', 'ButtonMotionOn');
+set( hTsgCorGUI, 'Tag', 'ButtonMotionOn');
     
 %  Callbacks for tsgcqc_GUI
 %  ************************
@@ -340,7 +317,7 @@ set( hChild1Fig, 'Tag', 'ButtonMotionOn');
         
         % Returns a zoom mode object for the figure handle
         % ------------------------------------------------
-        hZoom = zoom(hChild1Fig);
+        hZoom = zoom(hTsgCorGUI);
         
         % Specifies whether this mode is currently enabled on the figure
         % --------------------------------------------------------------
@@ -351,7 +328,7 @@ set( hChild1Fig, 'Tag', 'ButtonMotionOn');
                 zoomAdaptiveDateTicks('off');
             case 'off'
                 pan off
-                set(hChild1Fig,'Pointer','arrow');
+                set(hTsgCorGUI,'Pointer','arrow');
                 set(hEndlimitPushtool, 'Tag', 'off' );
                 set(hStartlimitPushtool, 'Tag', 'off' );
 
@@ -366,7 +343,7 @@ set( hChild1Fig, 'Tag', 'ButtonMotionOn');
         
         % Returns a pan mode object for the figure handle
         % -----------------------------------------------
-        hPan = pan(hChild1Fig);
+        hPan = pan(hTsgCorGUI);
         
         % Specifies whether this mode is currently enabled on the figure
         % --------------------------------------------------------------
@@ -377,7 +354,7 @@ set( hChild1Fig, 'Tag', 'ButtonMotionOn');
                 panAdaptiveDateTicks('off');
             case 'off'
                 zoom off
-                set(hChild1Fig,'Pointer','arrow');
+                set(hTsgCorGUI,'Pointer','arrow');
                 set(hEndlimitPushtool, 'Tag', 'off' );
                 set(hStartlimitPushtool, 'Tag', 'off' );
 
@@ -397,17 +374,17 @@ set( hChild1Fig, 'Tag', 'ButtonMotionOn');
 
         % Retrieve named application data
         % -------------------------------
-        tsg = getappdata( hMainFig, 'tsg_data');
+        tsg = getappdata( hTsgGUI, 'tsg_data');
         
         % Toggle the tag of the Qc pushbutton to 'on' or 'off'
         % ----------------------------------------------------
         switch get(hObject, 'Tag'); 
             case 'off'
                 set(hObject, 'Tag', 'on' );
-                set( hChild1Fig, 'Pointer', 'crosshair');
+                set( hTsgCorGUI, 'Pointer', 'crosshair');
             case 'on'
                 set(hObject, 'Tag', 'off' );
-                set(hChild1Fig,'Pointer','arrow');
+                set(hTsgCorGUI,'Pointer','arrow');
         end
 
         % Wait for key press
@@ -422,161 +399,149 @@ set( hChild1Fig, 'Tag', 'ButtonMotionOn');
             set( hetDateMin, 'String', datestr(x, 31));
         end
         
-        set(hChild1Fig,'Pointer','arrow');
+        set(hTsgCorGUI,'Pointer','arrow');
 
     end
 
 %----------------------------------------------------------------------
-    function BottleMenuCallback(gcbo, eventdata,handles)
+  function BottleMenuCallback(gcbo, eventdata,handles)
     % Callback function run when the QC pushbutton is selected
+    
+    % Desactivate the Zoom and Pan functions.
+    % ---------------------------------------
+    zoom off; pan off
+    panAdaptiveDateTicks('off');zoomAdaptiveDateTicks('off');
+    
+    % Toggle the tag of the Qc pushbutton to 'on' or 'off'
+    % ----------------------------------------------------
+    switch get(hBottlePushtool, 'Tag');
+      case 'off'
+        set(hBottlePushtool, 'Tag', 'on' );
+        set(hPlotAxes(2),'UIContextMenu', hSampleCmenu);
+        set(hTsgCorGUI, 'Pointer', 'crosshair');
+      case 'on'
+        set(hBottlePushtool, 'Tag', 'off' );
+        set(hPlotAxes(2),'UIContextMenu', []);
+        set(hTsgCorGUI,'Pointer','arrow');
+    end
+
+    qualityCode = -1;
+    ind = [];
+    while strcmp( get(hBottlePushtool, 'Tag'),'on')
+      
+      k = waitforbuttonpress;
+      
+      % If the QC pushbutton is pressed we quit the callback
+      % ----------------------------------------------------
+      if strcmp( get(hBottlePushtool, 'Tag'),'off')
         
-        % Desactivate the Zoom and Pan functions.
-        % ---------------------------------------
-        zoom off; pan off
-        panAdaptiveDateTicks('off');zoomAdaptiveDateTicks('off');
+        % Desactivate the context menu use to choose the Quality Codes
+        % ----------------------------------------------
+        set(hSampleCmenu, 'Visible', 'off');
+        break
+      end
 
-        % Retrieve named application data
-        % -------------------------------
-        sample = getappdata( hMainFig, 'sample' );
+      % Test if the right mouse button is clicked
+      % -----------------------------------------
+      if strcmp(get(hTsgCorGUI, 'SelectionType'), 'alt') && ~isempty(ind)
         
-        % Toggle the tag of the Qc pushbutton to 'on' or 'off'
-        % ----------------------------------------------------
-        switch get(hBottlePushtool, 'Tag'); 
-            case 'off'
-                set(hBottlePushtool, 'Tag', 'on' );
-                set(hPlotAxes(2),'UIContextMenu', hSampleCmenu);
-                set(hChild1Fig, 'Pointer', 'crosshair');
-            case 'on'
-                set(hBottlePushtool, 'Tag', 'off' );
-                set(hPlotAxes(2),'UIContextMenu', []);
-                set(hChild1Fig,'Pointer','arrow');
-        end
+        % Wait for a QC Context Menu choice : The user choose the
+        % quality code
+        % -------------------------------------------------------
+        uiwait
+        qualityCode = 1;
+      
+      else
+
+        % Mouse motion callback desactivated when a selection is made.
+        % Otherwise there is a conflict with the map if it is activated
+        % -------------------------------------------------------
+        set( hTsgCorGUI, 'Tag', 'ButtonMotionOff');
         
-        qualityCode = -1;
-        ind = [];
-        while strcmp( get(hBottlePushtool, 'Tag'),'on')
+        % Selection of the data within the figure
+        % ---------------------------------------
+        point1    = get(gca,'CurrentPoint');    % button down detected
+        finalRect = rbbox;                      % return figure units
+        point2    = get(gca,'CurrentPoint');    % button up detected
         
-            k = waitforbuttonpress;
+        point1    = point1(1,1:2);              % extract x and y
+        point2    = point2(1,1:2);
         
-            % If the QC pushbutton is pressed we quit the callback
-            % ----------------------------------------------------
-            if strcmp( get(hBottlePushtool, 'Tag'),'off')
-                        
-                % Desactivate the context menu use to choose the
-                % Quality Codes
-                % ----------------------------------------------
-                set(hSampleCmenu, 'Visible', 'off');
-                break
-            end
-
-            % Test if the right mouse button is clicked
-            % -----------------------------------------
-            if strcmp(get(hChild1Fig, 'SelectionType'), 'alt') && ~isempty(ind)
-                % Wait for a QC Context Menu choice : The user choose the
-                % quality code
-                % -------------------------------------------------------
-                uiwait
-                qualityCode = 1;
-
-            else
-
-                % Mouse motion callback desactivated when a selection is
-                % made. Otherwise there is a conflict with the map if it
-                % is activated
-                % -------------------------------------------------------
-                set( hChild1Fig, 'Tag', 'ButtonMotionOff');
-                
-                % Selection of the data within the figure
-                % ---------------------------------------
-                point1 = get(gca,'CurrentPoint');    % button down detected
-                finalRect = rbbox;                   % return figure units
-                point2 = get(gca,'CurrentPoint');    % button up detected
-
-                point1 = point1(1,1:2);              % extract x and y
-                point2 = point2(1,1:2);
+        p1 = min(point1,point2);
+        p2 = max(point1,point2);             % calculate locations
         
-                p1 = min(point1,point2); 
-                p2 = max(point1,point2);             % calculate locations
-
-                ind = find(sample.TIME > p1(1,1) & ...
-                           sample.TIME < p2(1,1) & ...
-                           sample.PSAL_DIF > p1(1,2) & ...
-                           sample.PSAL_DIF < p2(1,2));
-                
-                % As soon as a modification took place the data should be
-                % saved
-                % -------------------------------------------------------
-%                set( hSaveMenu, 'Tag', 'on' );
+        % Retrieve named application data
+        % -------------------------------
+        sample = getappdata( hTsgGUI, 'sample');
+        
+        ind = find(sample.DAYD > p1(1,1) & sample.DAYD < p2(1,1) & ...
+                   sample.SSPS_DIF > p1(1,2) & sample.SSPS_DIF < p2(1,2));
                         
-                % Selection made : Mouse motion callback re-activated
-                % --------------------------------------------------
-                set( hChild1Fig, 'Tag', 'ButtonMotionOn');
-
-            end
+        % Selection made : Mouse motion callback re-activated
+        % ---------------------------------------------------
+        set( hTsgCorGUI, 'Tag', 'ButtonMotionOn');
+      
+      end
 
-            % Plot the data with the color of the chosen quality Code.
-            % Is it the right place for this source code ????
-            % --------------------------------------------------------
-            if qualityCode ~= -1
-                
-                quality = get( hSampleCmenu, 'UserData');
-
-                sample.PSAL_QC(ind) = quality.Code;   
-                
-                % Save the modifications
-                % ----------------------
-                setappdata( hMainFig, 'sample', sample);
-               
-                axes(hPlotAxes(2));
-                hold on
-                
-                color = ['o' quality.Color];
-                
-                plot(sample.TIME(ind), sample.PSAL_DIF(ind), color );
-                
-                hold off
-                
-            end
-        end
+      % Plot the data with the color of the chosen quality Code.
+      % Is it the right place for this source code ????
+      % --------------------------------------------------------
+      if qualityCode ~= -1
+        
+        tsg = getappdata( hTsgGUI, 'tsg_data');
+        
+        sample.SSPS_QC(ind) =  tsg.qc.Code.ACTIVE;
+        
+        % Save the modifications
+        % ----------------------
+        setappdata( hTsgGUI, 'sample', sample);
+        
+        axes(hPlotAxes(2));
+        hold on
+        color = ['o' tsg.qc.Color.ACTIVE];
+        plot(sample.DAYD(ind), sample.SSPS_DIF(ind), color );
+        hold off
+      end
     end
+  end
 
-    %---------------------------------------------------------------------
-    function Qc(hObject, eventdata)
-    % Callback function run when the QC context menu is selected
-    
-         % Retrieve Default Quality Code and Color
-         % ---------------------------------------
-         qc = getappdata( hMainFig, 'qcColor');
-         
-         switch hObject
-             case hQcSampleNocontrol
-                quality.Code  = qc.Code.NO_CONTROL;
-                quality.Color = qc.Color.NO_CONTROL;
-             case hQcSampleGood
-                quality.Code  = qc.Code.GOOD;
-                quality.Color = qc.Color.GOOD;
-             case hQcSampleBad
-                quality.Code  = qc.Code.BAD;
-                quality.Color = qc.Color.BAD;
-         end
-         
-         set( hSampleCmenu, 'UserData', quality );
-         
-         % uiwait in the QCMenuCallback function
-         % -------------------------------------
-         uiresume
-    end
+%---------------------------------------------------------------------
+function Qc(hObject, eventdata)
+  % Callback function run when the QC context menu is selected
+  
+  % Retrieve Default Quality Code and Color
+  % ---------------------------------------
+  tsg = getappdata( hTsgGUI, 'qcColor');
+  
+  switch hObject
+    case hQcSampleNocontrol
+      tsg.qc.Code.ACTIVE   = tsg.qc.Code.NO_CONTROL;
+      tsg.qc.Color.ACTIVE  = tsg.qc.Color.NO_CONTROL;
+    case hQcSampleGood
+      tsg.qc.Code.ACTIVE   = tsg.qc.Code.GOOD;
+      tsg.qc.Color.ACTIVE  = tsg.qc.Color.GOOD;
+    case hQcSampleBad
+      tsg.qc.Code.ACTIVE   = tsg.qc.Code.PROBABLY_BAD;
+      tsg.qc.Color.ACTIVE  = tsg.qc.Color.PROBABLY_BAD;
+  end
+
+  setappdata( hMainFig, 'tsg_data', tsg );
+  
+  % uiwait in the QCMenuCallback function
+  % -------------------------------------
+  uiresume
+end
 
     %---------------------------------------------------------------------
     function MouseMotion(hObject, eventdata)
      
       % Test if the callback can be activated
       % -------------------------------------
-      if strcmp( get( hChild1Fig, 'Tag'), 'ButtonMotionOn')
+      if strcmp( get( hTsgCorGUI, 'Tag'), 'ButtonMotionOn')
           
         % Retrieve named application data
         % -------------------------------
-        tsg = getappdata( hMainFig, 'tsg_data');
+        tsg = getappdata( hTsgGUI, 'tsg_data');
         
         % Get the mouse position
         % ----------------------
@@ -617,7 +582,7 @@ set( hChild1Fig, 'Tag', 'ButtonMotionOn');
 %                                            'Save file name');
         
 %        fileName = [pathName fileName];
-%        error = tsg_writeTsgData( hMainFig, fileName );
+%        error = tsg_writeTsgData( hTsgGUI, fileName );
 %        if ~error
             % 
 %        end
@@ -648,7 +613,7 @@ set( hChild1Fig, 'Tag', 'ButtonMotionOn');
         
         % Update application data 'tsg'
         % ----------------------------
-        %tsg    = getappdata( hMainFig, 'tsg_data' );
+        %tsg    = getappdata( hTsgGUI, 'tsg_data' );
    
     end
 
@@ -672,8 +637,8 @@ set( hChild1Fig, 'Tag', 'ButtonMotionOn');
             end
         else
             selection = ...
-                    questdlg(['Quit ' get(hChild1Fig, 'Name') '?'],...
-                             ['Quit ' get(hChild1Fig, 'Name') '?'],...
+                    questdlg(['Quit ' get(hTsgCorGUI, 'Name') '?'],...
+                             ['Quit ' get(hTsgCorGUI, 'Name') '?'],...
                               'Yes', 'No', 'Yes');
             if strcmp(selection, 'No')
                 return;
@@ -687,7 +652,7 @@ set( hChild1Fig, 'Tag', 'ButtonMotionOn');
   % ----------------------------------------------------------------
   function QuitProgram(hObject, eventdata)
 
-    delete(hChild1Fig);
+    delete(hTsgCorGUI);
 
   end
       
diff --git a/tsgqc_GUI.m b/tsgqc_GUI.m
index 9e0b9fb2eee5a5ae3c7cc18986f327a031970bfe..5d432f6ca1e15e679e1660cf6ce3a7970e9cc7ea 100644
--- a/tsgqc_GUI.m
+++ b/tsgqc_GUI.m
@@ -150,7 +150,7 @@ hQCPushtool  =   uipushtool(...   % Open QC toolbar button
   'CData',iconRead(...
   [DEFAULT_PATH_FILE 'tsg_icon' filesep 'qcicon.mat']),...
   'HandleVisibility','callback', ...
-  'Tag','QC',...
+  'Tag','PUSHTOOL_QC',...
   'UserData', 'off',...
   'Enable', 'off',...
   'ClickedCallback', @QCMenuCallback);
@@ -183,7 +183,7 @@ hBottlePushtool  = uipushtool(...   % Open toolbar button
   'CData',iconRead(...
   [DEFAULT_PATH_FILE 'tsg_icon' filesep 'bottleicon.mat']),...
   'HandleVisibility','callback', ...
-  'Tag','BOTTLE',...
+  'Tag','PUSHTOOL_BOTTLE',...
   'Enable', 'off',...
   'ClickedCallback', @BottleMenuCallback);
 hHeaderPushtool  = uipushtool(...   % Open headerForm button
@@ -400,31 +400,31 @@ hQcCmenuNocontrol = uimenu(...
   'HandleVisibility','off', ...
   'Label', 'No control',...
   'ForegroundColor', 'k',...
-  'Callback', @QcNoControl);
+  'Callback', @Qc);
 hQcCmenuGood      = uimenu(...
   'Parent', hQcCmenu,...
   'HandleVisibility','off', ...
   'Label', 'Good',...
   'ForegroundColor', 'b',...
-  'Callback', @QcGood);
+  'Callback', @Qc);
 hQcCmenuProbGood  = uimenu(...
   'Parent', hQcCmenu,...
   'HandleVisibility','off', ...
   'Label', 'Probably Good',...
-  'Callback', @QcProbGood,...
+  'Callback', @Qc,...
   'ForegroundColor', 'g');
 hQcCmenuProbBad   = uimenu(...
   'Parent', hQcCmenu,...
   'HandleVisibility','off', ...
   'Label', 'Probably bad',...
   'ForegroundColor', 'm',...
-  'Callback', @QcProbBad);
+  'Callback', @Qc);
 hQcCmenuBad       = uimenu(...
   'Parent', hQcCmenu,...
   'HandleVisibility','off', ...
   'Label', 'Bad',...
   'ForegroundColor', 'r',...
-  'Callback', @QcBad);
+  'Callback', @Qc);
 
 
 % Initialisation
@@ -524,11 +524,13 @@ tsg_initialisation(hMainFig, hQcCmenu)
     %    setappdata( hMainFig, 'sample', sample );
     %end
 
-    % Plot Salinity bucket
-    % ------------------------------------------------
-    if error2 ~= -1
-      plot_SalTsgSample( hMainFig, hPlotAxes );
-    end
+    % Plot Salinity bucket 
+    % NOT at that step. It will interfere with the QC process
+    % Maybe use a new pushbutton to draw or delete the bucket
+    % -------------------------------------------------------
+    %if error2 ~= -1
+    %  plot_SalTsgSample( hMainFig, hPlotAxes );
+    %end
     
     % Pointer reset to arrow
     % ----------------------
@@ -590,10 +592,6 @@ tsg_initialisation(hMainFig, hQcCmenu)
     zoom off; pan off
     panAdaptiveDateTicks('off');zoomAdaptiveDateTicks('off');
 
-    % Retrieve named application data
-    % -------------------------------
-    tsg = getappdata( hMainFig, 'tsg_data');
-
     % Toggle the tag of the Qc pushbutton to 'on' or 'off'
     % ----------------------------------------------------
     switch get(hQCPushtool, 'UserData');
@@ -617,9 +615,8 @@ tsg_initialisation(hMainFig, hQcCmenu)
       % ----------------------------------------------------
       if strcmp( get(hQCPushtool, 'UserData'),'off')
 
-        % Desactivate the context menu use to choose the
-        % Quality Codes
-        % ----------------------------------------------
+        % Desactivate the context menu use to choose the Quality Codes
+        % ------------------------------------------------------------
         set(hQcCmenu, 'Visible', 'off');
         break
       end
@@ -635,10 +632,9 @@ tsg_initialisation(hMainFig, hQcCmenu)
 
       else
 
-        % Mouse motion callback desactivated when a selection is
-        % made. Otherwise there is a conflict with the map if it
-        % is activated
-        % -------------------------------------------------------
+        % Mouse motion callback desactivated when a selection is made.
+        % Otherwise there is a conflict with the map if it is activated
+        % -------------------------------------------------------------
         set( hMainFig, 'UserData', 'ButtonMotionOff');
 
         % Selection of the data within the figure
@@ -653,12 +649,15 @@ tsg_initialisation(hMainFig, hQcCmenu)
         p1 = min(point1,point2);
         p2 = max(point1,point2);             % calculate locations
 
+        % Retrieve named application data
+        % -------------------------------
+        tsg = getappdata( hMainFig, 'tsg_data');
+
         ind = find(tsg.DAYD > p1(1,1) & tsg.DAYD < p2(1,1) & ...
           tsg.SSPS > p1(1,2) & tsg.SSPS < p2(1,2));
 
-        % As soon as a modification took place the data should be
-        % saved
-        % -------------------------------------------------------
+        % As soon as a modification took place the data should be saved
+        % -------------------------------------------------------------
         set( hSaveMenu, 'UserData', 'on' );
 
         % Selection made : Mouse motion callback re-activated
@@ -672,9 +671,11 @@ tsg_initialisation(hMainFig, hQcCmenu)
       % --------------------------------------------------------
       if qualityCode ~= -1
 
-        quality = get( hQcCmenu, 'UserData');
+        % Retrieve named application data - Code could have been changed
+        % --------------------------------------------------------------
+        tsg = getappdata( hMainFig, 'tsg_data');
 
-        tsg.SSPS_QC(ind) = quality.Code;
+        tsg.SSPS_QC(ind) = tsg.qc.Code.ACTIVE;
 
         % Save the modifications
         % ----------------------
@@ -682,7 +683,7 @@ tsg_initialisation(hMainFig, hQcCmenu)
 
         axes(hPlotAxes(1));
         hold on
-        color = ['.' quality.Color];
+        color = ['.' tsg.qc.Color.ACTIVE];
         plot(tsg.DAYD(ind), tsg.SSPS(ind), color );
         hold off
 
@@ -691,89 +692,37 @@ tsg_initialisation(hMainFig, hQcCmenu)
   end
 
 %---------------------------------------------------------------------
-  function QcNoControl(hObject, eventdata)
-    % Callback function run when the QC context menu is selected
-
-    % Retrieve Default Quality Code and Color
-    % ---------------------------------------
-    qc = getappdata( hMainFig, 'qcColor');
-
-    quality.Code  = qc.Code.NO_CONTROL;
-    quality.Color = qc.Color.NO_CONTROL;
-    set( hQcCmenu, 'UserData', quality );
-
-    % uiwait in the QCMenuCallback function
-    % -------------------------------------
-    uiresume
-  end
-
-%---------------------------------------------------------------------
-  function QcGood(hObject, eventdata)
-    % Callback function run when the QC context menu is selected
-
-    % Retrieve named application data
-    % -------------------------------
-    qc = getappdata( hMainFig, 'qcColor');
-
-    quality.Code  = qc.Code.GOOD;
-    quality.Color = qc.Color.GOOD;
-    set( hQcCmenu, 'UserData', quality );
-
-    % uiwait in the QCMenuCallback function
-    % -------------------------------------
-    uiresume
-  end
-
-%---------------------------------------------------------------------
-  function QcProbGood(hObject, eventdata)
-    % Callback function run when the QC context menu is selected
-
-    % Retrieve named application data
-    % -------------------------------
-    qc = getappdata( hMainFig, 'qcColor');
-
-    quality.Code  = qc.Code.PROBABLY_GOOD;
-    quality.Color = qc.Color.PROBABLY_GOOD;
-    set( hQcCmenu, 'UserData', quality );
-
-    % uiwait in the QCMenuCallback function
-    % -------------------------------------
-    uiresume
-  end
-
-%---------------------------------------------------------------------
-  function QcProbBad(hObject, eventdata)
-    % Callback function run when the QC context menu is selected
-
-    % Retrieve named application data
-    % -------------------------------
-    qc = getappdata( hMainFig, 'qcColor');
-
-    quality.Code  = qc.Code.PROBABLY_BAD;
-    quality.Color = qc.Color.PROBABLY_BAD;
-    set( hQcCmenu, 'UserData', quality );
-
-    % uiwait in the QCMenuCallback function
-    % -------------------------------------
-    uiresume
-  end
-
-%---------------------------------------------------------------------
-  function QcBad(hObject, eventdata)
+  function Qc(hObject, eventdata)
     % Callback function run when the QC context menu is selected
+    
+      % Retrieve Default Quality Code and Color
+      % ---------------------------------------
+      tsg = getappdata( hMainFig, 'tsg_data');
+      
+      switch hObject
+        case hQcCmenuNocontrol
+          tsg.qc.Code.ACTIVE   = tsg.qc.Code.NO_CONTROL;
+          tsg.qc.Color.ACTIVE  = tsg.qc.Color.NO_CONTROL;
+        case hQcCmenuGood
+          tsg.qc.Code.ACTIVE   = tsg.qc.Code.GOOD;
+          tsg.qc.Color.ACTIVE  = tsg.qc.Color.GOOD;
+        case hQcCmenuProbGood
+          tsg.qc.Code.ACTIVE   = tsg.qc.Code.PROBABLY_GOOD;
+          tsg.qc.Color.ACTIVE  = tsg.qc.Color.PROBABLY_GOOD;
+        case hQcCmenuProbBad
+          tsg.qc.Code.ACTIVE   = tsg.qc.Code.PROBABLY_BAD;
+          tsg.qc.Color.ACTIVE  = tsg.qc.Color.PROBABLY_BAD;
+        case hQcCmenuBad
+          tsg.qc.Code.ACTIVE   = tsg.qc.Code.BAD;
+          tsg.qc.Color.ACTIVE  = tsg.qc.Color.BAD;
+      end
 
-    % Retrieve named application data
-    % -------------------------------
-    qc = getappdata( hMainFig, 'qcColor');
-
-    quality.Code  = qc.Code.BAD;
-    quality.Color = qc.Color.BAD;
-    set( hQcCmenu, 'UserData', quality );
-
-    % uiwait in the QCMenuCallback function
-    % -------------------------------------
-    uiresume
-  end
+      setappdata( hMainFig, 'tsg_data', tsg );
+      
+      % uiwait in the QCMenuCallback function
+      % -------------------------------------
+      uiresume
+    end
 
 %---------------------------------------------------------------------
   function MouseMotion(hObject, eventdata)
@@ -854,7 +803,24 @@ tsg_initialisation(hMainFig, hQcCmenu)
 %---------------------------------------------------------------------
   function BottleMenuCallback(hObject, eventdata)
     % Callback function run when the Bottle tool bar item is selected
-    %
+
+    % Get the tsg data structure
+    % --------------------------
+    tsg = getappdata( hMainFig, 'tsg_data');
+    
+    % Test if tsg and sample data have been loaded
+    % --------------------------------------------
+    if ~isempty( tsg.SSPS_WS ) || ~isempty( tsg.SSPS_EXT )
+      
+      % Call the GUI for tsg correction
+      % -------------------------------
+      msgbox('Correction module not yet implemented', 'modal');
+      % tsgcor_GUI( hMainFig );    
+    else
+      msgbox('TSG or Sample data not loaded in the program', 'modal');
+    end
+
+    % Vieux bout de code pour le trace et la suppression des bouteilles
     % Plot or Delete the buckets measurements on the Salinity graph
     %
     % Need to read them right now - but they will be soon in the NetCdf
@@ -862,30 +828,11 @@ tsg_initialisation(hMainFig, hQcCmenu)
 
     % Test if the sample Push button has been pressed
     % -----------------------------------------------
-    if strcmp( get(hBottlePushtool, 'UserData'), 'off')
-
+    % if strcmp( get(hBottlePushtool, 'UserData'), 'off')
+     
       % Sample Push button - UserData set to 'on'
       % ------------------------------------
-      set( hBottlePushtool, 'UserData', 'on' );
-
-      % Test if tsg and sample data have been loaded
-      % --------------------------------------------
-      if ~isempty( getappdata( hMainFig, 'tsg_data') ) && ...
-          ~isempty( getappdata( hMainFig, 'sample') )
-
-        % Call the GUI for tsg correction
-        % -------------------------------
-        %msgbox('The correction module has not been implemented', 'modal');
-        tsgcor_GUI( hMainFig );
-
-      else
-
-        msgbox('TSG or Sample data not loaded in the program', 'modal');
-
-      end
-
-      %           hLine  = get( hPlotAxes(1), 'UserData');
-
+      % set( hBottlePushtool, 'UserData', 'on' );
 
       % Plot the samples if the TSG file has been read
       % ----------------------------------------------
@@ -903,7 +850,7 @@ tsg_initialisation(hMainFig, hQcCmenu)
 
       %        else
 
-      set( hBottlePushtool, 'UserData', 'off' );
+      % set( hBottlePushtool, 'UserData', 'off' );
 
       % The bucket pushbutton has been pressed again :
       % Delete the bucket on figure
@@ -912,7 +859,6 @@ tsg_initialisation(hMainFig, hQcCmenu)
       %            if ~isempty( hLine ) && ishandle( hLine.Sample )
       %                delete(hLine.Sample);
       %           end
-    end
   end
 
 %---------------------------------------------------------------------