diff --git a/pyglance/glance/delta.py b/pyglance/glance/delta.py
index cbfdd0b421af52ad4f96243681c72929c73eb653..ae4d85ed40fadafa6905c718ef3e77f08b77bb79 100644
--- a/pyglance/glance/delta.py
+++ b/pyglance/glance/delta.py
@@ -9,34 +9,112 @@ Copyright (c) 2009 University of Wisconsin SSEC. All rights reserved.
 
 import logging
 import numpy as np
-from numpy import *
-from scipy.stats import pearsonr
+from numpy import * # todo, remove this line
 
-compute_r = pearsonr
+from scipy.stats import pearsonr
 
 LOG = logging.getLogger(__name__)
 
-# TODO, where is this being used?
-def _missing(x, missing_value=None):
-    if missing_value is not None:
-        return isnan(x) | (x==missing_value)
-    return isnan(x)
+# -------------- generic data manipulation and analysis --------------
+
+def min_with_mask(data, goodMask=None) :
+    """
+    get the minimum of the values in data,
+    inspecting only the values selected in the goodMask
+    
+    if no mask is passed and a masked array is given the
+    mask associated with the array will be used
+    if no mask is passed and any other kind of data is
+    given, all values are assumed to be good
+    """
+    
+    # if the data array is a masked array and we weren't
+    # given a mask, assume that we should use the one
+    # associated with the masked array
+    if (goodMask is None) and (type(data) is numpy.ma) :
+        goodMask = data.mask
+    
+    # select only the good data values
+    goodData = data[goodMask]
+    
+    # if we have any good data, get the minimum
+    toReturn = None
+    if goodData.size > 0 :
+        toReturn = np.min(goodData)
+    
+    return toReturn
+
+def max_with_mask(data, goodMask=None) :
+    """
+    get the maximum of the values in data,
+    inspecting only the values selected in the goodMask
+    
+    if no mask is passed and a masked array is given the
+    mask associated with the array will be used
+    if no mask is passed and any other kind of data is
+    given, all values are assumed to be good
+    """
+    
+    # if the data array is a masked array and we weren't
+    # given a mask, assume that we should use the one
+    # associated with the masked array
+    if (goodMask is None) and (type(data) is numpy.ma) :
+        goodMask = data.mask
+    
+    # select only the good data values
+    goodData = data[goodMask]
+    
+    # if we have any good data, get the maximum
+    toReturn = None
+    if goodData.size > 0 :
+        toReturn = np.max(goodData)
+    
+    return toReturn
+
+def compute_correlation(xData, yData, goodMask, compute_r_function=pearsonr):
+    """
+    compute the correlation coefficient of two data sets
+    given a mask describing good data values in the sets
+    """
+    
+    # make sure our data sets and mask are the same shape
+    assert(xData.shape == yData.shape)
+    assert(xData.shape == goodMask.shape)
+    
+    # pull out just the good data
+    good_x_data = xData[goodMask]
+    good_y_data = yData[goodMask]
+    
+    # make sure that there is no remaining bad data
+    assert(np.all(np.isfinite(good_x_data)))
+    assert(np.all(np.isfinite(good_y_data)))
+    
+    # if we have enough data, try to build the correlation
+    toReturn = np.nan
+    if (good_x_data.size >= 2) and (good_y_data.size >= 2) :
+        toReturn = compute_r_function(good_x_data, good_y_data)[0]
+    
+    return toReturn
 
-def corr(x,y,mask):
-    "compute correlation coefficient"
-    gf = mask.flatten()
-    xf = x.flatten()[gf]
-    yf = y.flatten()[gf]
-    assert(sum(~isfinite(yf))==0)
-    assert(sum(~isfinite(xf))==0)
-    # don't try to build a correlation if
-    # masking left us with insufficient data
-    # to do so
-    if (xf.size < 2) or (yf.size < 2) :
-        return nan
-    return compute_r(xf,yf)[0]
+def calculate_root_mean_square (data, goodMask=None) :
+    """
+    calculate the root mean square of the data,
+    possibly selecting only the points in the given
+    goodMask, if no mask is given, all points will
+    be used
+    """
+    
+    # get a count of how many good data points we have
+    numGoodPoints = data.size
+    if goodMask is not None:
+        numGoodPoints = np.sum(goodMask)
+    
+    rootMeanSquare = np.sqrt( np.sum( data[goodMask] ** 2 ) / numGoodPoints )
+    
+    return rootMeanSquare
 
-def convert_mag_dir_to_U_V_vector(magnitude_data, direction_data, invalidMask=None):
+# TODO, should the name of this function be changed?
+def convert_mag_dir_to_U_V_vector(magnitude_data, direction_data, invalidMask=None, offset_degrees=180):
     """
     This method is intended to convert magnitude and direction data into (U, V) vector data.
     An invalid mask may be given if some of the points in the set should be masked out.
@@ -45,22 +123,24 @@ def convert_mag_dir_to_U_V_vector(magnitude_data, direction_data, invalidMask=No
     """
     
     if invalidMask is None :
-        invalidMask = zeros(magnitude_data.shape, dtype=bool)
+        invalidMask = np.zeros(magnitude_data.shape, dtype=bool)
     
-    new_direction_data = direction_data[:] + 180
+    new_direction_data = direction_data[:] + offset_degrees
     
-    print ("direction data: " + str(new_direction_data[~invalidMask]))
+    LOG.debug ("direction data: " + str(new_direction_data[~invalidMask]))
     
-    uData = zeros(magnitude_data.shape, dtype=float)
-    uData[invalidMask]  = nan
+    uData = np.zeros(magnitude_data.shape, dtype=float)
+    uData[invalidMask]  = np.nan
     uData[~invalidMask] = magnitude_data[~invalidMask] * np.sin (deg2rad(new_direction_data[~invalidMask]))
     
-    vData = zeros(magnitude_data.shape, dtype=float)
-    vData[invalidMask]  = nan
+    vData = np.zeros(magnitude_data.shape, dtype=float)
+    vData[invalidMask]  = np.nan
     vData[~invalidMask] = magnitude_data[~invalidMask] * np.cos (deg2rad(new_direction_data[~invalidMask]))
     
     return uData, vData
 
+# ------------- bin/tuple related functions --------------------
+
 # a method to make a list of index numbers for reordering a multi-dimensional array
 def _make_new_index_list(numberOfIndexes, firstIndexNumber=0, lastIndexNumber=None) :
     """
@@ -136,48 +216,6 @@ def determine_case_indecies (flatIndex, originalCaseShape) :
     
     return positionOfIndex
 
-def calculate_root_mean_square (data, goodMask=None) :
-    """
-    calculate the root mean square of the data,
-    possibly selecting only the points in the given
-    goodMask, if no mask is given, all points will
-    be used
-    """
-    if goodMask is None:
-        goodMask = np.ones(data.shape, dtype=bool)
-    
-    rootMeanSquare = sqrt( sum( data[goodMask] ** 2 ) / sum( goodMask ) )
-    
-    return rootMeanSquare
-
-# get the min, ignoring the stuff in mask
-def min_with_mask(data, mask=None) :
-    
-    if (mask is None) and (type(data) is numpy.ma) :
-        mask = ~data.mask
-    if mask is None :
-        mask = np.zeros(data.shape, dtype=bool)
-    
-    temp = data[~mask]
-    toReturn = None
-    if len(temp) > 0 :
-        toReturn = temp[temp.argmin()]
-    return toReturn
-
-# get the max, ignoring the stuff in mask
-def max_with_mask(data, mask=None) :
-    
-    if (mask is None) and (type(data) is numpy.ma) :
-        mask = ~data.mask
-    if mask is None :
-        mask = np.zeros(data.shape, dtype=bool)
-    
-    temp = data[~mask]
-    toReturn = None
-    if len(temp) > 0 :
-        toReturn = temp[temp.argmax()]
-    return toReturn
-
 if __name__=='__main__':
     import doctest
     doctest.testmod()
diff --git a/pyglance/glance/figures.py b/pyglance/glance/figures.py
index ea3b8c3a88d89eb5579b49fa9c26822ee1f3d014..563c5c4b149cf47676e7328d0c0d9fa134910f83 100644
--- a/pyglance/glance/figures.py
+++ b/pyglance/glance/figures.py
@@ -55,13 +55,13 @@ def _make_range(data_a, invalid_a_mask, num_intervals, offset_to_range=0.0, data
     if the b data is passed, a total range that encompasses both sets of
     data will be used
     """
-    minVal = delta.min_with_mask(data_a, invalid_a_mask)
-    maxVal = delta.max_with_mask(data_a, invalid_a_mask)
+    minVal = delta.min_with_mask(data_a, ~invalid_a_mask)
+    maxVal = delta.max_with_mask(data_a, ~invalid_a_mask)
     
     # if we have a second set of data, include it in the min/max calculations
     if (data_b is not None) :
-        minVal = min(delta.min_with_mask(data_b, invalid_b_mask), minVal)
-        maxVal = max(delta.max_with_mask(data_b, invalid_b_mask), maxVal)
+        minVal = min(delta.min_with_mask(data_b, ~invalid_b_mask), minVal)
+        maxVal = max(delta.max_with_mask(data_b, ~invalid_b_mask), maxVal)
     
     minVal = minVal - offset_to_range
     maxVal = maxVal + offset_to_range
diff --git a/pyglance/glance/plot.py b/pyglance/glance/plot.py
index 910fac41e42621cc7fd54c6d324be7e57b906eb5..71f232edba6faabe312aa7bee103331d6c10a99b 100644
--- a/pyglance/glance/plot.py
+++ b/pyglance/glance/plot.py
@@ -113,7 +113,7 @@ def plot_and_save_spacial_trouble(longitude, latitude,
     """
     
     # get the bounding axis and make a basemap
-    boundingAxes = plotfns.get_visible_axes(longitude, latitude, spaciallyInvalidMask)
+    boundingAxes = plotfns.get_visible_axes(longitude, latitude, ~spaciallyInvalidMask)
     LOG.debug("Visible axes for lon/lat trouble figure  are: " + str(boundingAxes))
     baseMapInstance, boundingAxes = maps.create_basemap(longitude, latitude, boundingAxes, plotfns.select_projection(boundingAxes))
     
diff --git a/pyglance/glance/plotcreatefns.py b/pyglance/glance/plotcreatefns.py
index a03ee875ae2d4c4a619eacc45b2131c369aec027..465b1580f8829823023690ee2879a26b81fab9fc 100644
--- a/pyglance/glance/plotcreatefns.py
+++ b/pyglance/glance/plotcreatefns.py
@@ -52,16 +52,15 @@ def _abstract( ) :
     raise NotImplementedError('Method must be implemented in subclass.')
 
 # figure out the bounding axes for the display given a set of
-# longitude and latitude and possible a mask of invalid values
-# that we should ignore in them
-def get_visible_axes(longitudeData, latitudeData, toIgnoreMask) :
+# longitude and latitude and possible a mask of good values
+def get_visible_axes(longitudeData, latitudeData, goodMask) :
     
     # calculate the bounding range for the display
     # this is in the form [longitude min, longitude max, latitude min, latitude max]
-    visibleAxes = [delta.min_with_mask(longitudeData, toIgnoreMask),
-                   delta.max_with_mask(longitudeData, toIgnoreMask),
-                   delta.min_with_mask(latitudeData,  toIgnoreMask),
-                   delta.max_with_mask(latitudeData,  toIgnoreMask)]
+    visibleAxes = [delta.min_with_mask(longitudeData, goodMask),
+                   delta.max_with_mask(longitudeData, goodMask),
+                   delta.min_with_mask(latitudeData,  goodMask),
+                   delta.max_with_mask(latitudeData,  goodMask)]
     
     return visibleAxes
 
@@ -110,8 +109,8 @@ def _make_axis_and_basemap(lonLatDataDict, goodInAMask, goodInBMask, shouldUseSh
         nameMessage = " (" + variableDisplayName + ")"
     
     # figure out the bounding axis
-    aAxis = get_visible_axes(lonLatDataDict['a']['lon'], lonLatDataDict['a']['lat'], ~goodInAMask)
-    bAxis = get_visible_axes(lonLatDataDict['b']['lon'], lonLatDataDict['b']['lat'], ~goodInBMask)
+    aAxis = get_visible_axes(lonLatDataDict['a']['lon'], lonLatDataDict['a']['lat'], goodInAMask)
+    bAxis = get_visible_axes(lonLatDataDict['b']['lon'], lonLatDataDict['b']['lat'], goodInBMask)
     fullAxis = [min(aAxis[0], bAxis[0]), max(aAxis[1], bAxis[1]),
                 min(aAxis[2], bAxis[2]), max(aAxis[3], bAxis[3])]
     
diff --git a/pyglance/glance/stats.py b/pyglance/glance/stats.py
index 7461c2c432c55abfb5dea34638114462fab42c77..48ef9ca8c9b31f872a7a00563c67d1b1ae768a5a 100644
--- a/pyglance/glance/stats.py
+++ b/pyglance/glance/stats.py
@@ -97,7 +97,7 @@ def _get_numerical_data_stats(a, b, diff_data,  data_is_finite_mask,
     # calculate our various statistics
     num_finite_values_too_different = np.sum(outside_epsilon_mask)
     num_perfect = _get_num_perfect(a, b, ~data_is_finite_mask)
-    r_corr = delta.corr(a, b, data_is_finite_mask)
+    r_corr = delta.compute_correlation(a, b, data_is_finite_mask)
     num_trouble = np.sum(trouble_mask)
     
     # we actually want the total number of _finite_ values rather than all the data
@@ -143,10 +143,10 @@ def _get_general_data_stats(a, b,
     general_stats = {'a_missing_value': a_missing_value,
                      'b_missing_value': b_missing_value,
                      'epsilon': epsilon,
-                     'max_a': delta.max_with_mask(a, bad_in_a),
-                     'max_b': delta.max_with_mask(b, bad_in_b),
-                     'min_a': delta.min_with_mask(a, bad_in_a),
-                     'min_b': delta.min_with_mask(b, bad_in_b),
+                     'max_a': delta.max_with_mask(a, ~bad_in_a),
+                     'max_b': delta.max_with_mask(b, ~bad_in_b),
+                     'min_a': delta.min_with_mask(a, ~bad_in_a),
+                     'min_b': delta.min_with_mask(b, ~bad_in_b),
                      'num_data_points': total_num_values,
                      'shape': a.shape,
                      'spatially_invalid_pts_ignored_in_a': num_ignored_in_a,