diff --git a/CEP/PyBDSM/doc/source/conf.py b/CEP/PyBDSM/doc/source/conf.py
index d6fb4ea7bc3790e0167766fb320bf6d8121cd0f9..46d6a3618f3c1ca0423a7cc76f15dd9e8557d8a9 100644
--- a/CEP/PyBDSM/doc/source/conf.py
+++ b/CEP/PyBDSM/doc/source/conf.py
@@ -48,9 +48,9 @@ copyright = u'2012, David Rafferty and Niruj Mohan'
 # built documents.
 #
 # The short X.Y version.
-version = '1.1'
+version = '1.2'
 # The full version, including alpha/beta/rc tags.
-release = '1.1'
+release = '1.2'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff --git a/CEP/PyBDSM/doc/source/installation.rst b/CEP/PyBDSM/doc/source/installation.rst
index 929a3c545d7f370d3f74c24d0d6e5f848bdce53f..7bf77c45d27198f0829b31db67655206bfeb1f5a 100644
--- a/CEP/PyBDSM/doc/source/installation.rst
+++ b/CEP/PyBDSM/doc/source/installation.rst
@@ -20,11 +20,22 @@ Preparing to compile the code
 -----------------------------
 Before compiling the PyBDSM source code, you need to make sure you have the required dependencies:
 
+* Python 2.6 or newer (including NumPy, SciPy, Matplotlib, and IPython). The easiest way to install Python and all of the required modules is to use the 64-bit EPD Python distribution, available at http://enthought.com/products/epd.php. For academic users, a free version is available at http://www.enthought.com/products/edudownload.php.
 * gfortran. Binaries are available from http://gcc.gnu.org/wiki/GFortranBinaries.
-* Python (including numpy and scipy). The easiest way to install Python on a Mac is to use the 64-bit EPD Python distribution, available at http://enthought.com/products/epd.php.
 * PyWCS. You can get PyWCS from https://trac6.assembla.com/astrolib.
 * Boost. Get the latest version from http://www.boost.org. Only the Python libraries need to be compiled.
 
+.. note::
+
+    If you use the 64-bit EPD distribution on Mac OS X, there are problems with the default matplotlib backend that cause some of the plotting functionality of PyBDSM to be lost. To fix this problem, edit (or create) the ``~/.matplotlib/matplotlibrc`` file and add the line::
+    
+        backend : Qt4Agg
+        
+    Then add the following line to your ``.bash_profile``::
+    
+        export QT_API='pyside'
+
+
 Compiling and installing
 ------------------------
 Lastly, compile the software. To do so, make a ``build/gnu_opt`` directory, go there, and execute ``make``::
diff --git a/CEP/PyBDSM/doc/source/process_image.rst b/CEP/PyBDSM/doc/source/process_image.rst
index 82b683721442018885ab64076bf15f03ff05748e..0eda3e055f2e91caff110af5fbbcf73a19c23ed2 100644
--- a/CEP/PyBDSM/doc/source/process_image.rst
+++ b/CEP/PyBDSM/doc/source/process_image.rst
@@ -303,7 +303,10 @@ The advanced options are:
 
 .. parsed-literal::
 
-    advanced_opts ......... True : Show advanced options                       
+    advanced_opts ......... True : Show advanced options
+      :term:`aperture` ............ 10.0 : Radius of aperture in pixels inside which aperture
+                                   fluxes are measured for each source. None => no aperture 
+                                   fluxes measured
       :term:`blank_zeros` ........ False : Blank zeros in the image                    
       :term:`bmpersrc_th` ......... None : Theoretical estimate of number of beams per 
                                    source. None => calculate inside program    
@@ -350,16 +353,25 @@ The advanced options are:
 
 .. glossary::
 
+    aperture
+        This parameter is a float (default is ``None``) that sets the radius (in
+        pixels) inside which the aperture flux is measured for each source. 
+        The aperture is centered on the centroid of the source. Errors are 
+        calculated from the mean of the rms map inside the aperture.
+    
     blank_zeros
-        This parameter is a Boolean (default is ``False``). If ``True``, all pixels in the input image with values of 0.0 are blanked. If ``False``, any such pixels are left unblanked (and hence will affect the rms and mean maps, etc.). Pixels with a value of NaN are always blanked.
+        This parameter is a Boolean (default is ``False``). If ``True``, all
+        pixels in the input image with values of 0.0 are blanked. If ``False``,
+        any such pixels are left unblanked (and hence will affect the rms and
+        mean maps, etc.). Pixels with a value of NaN are always blanked.
         
     bmpersrc_th
-        This parameter is a float (default is ``None``) that sets the theoretical estimate of number of beams per source.
-        If ``None``, the value is calculated
-        as N/[n*(alpha-1)], where N is the total number of pixels in the image,
-        n is the number of pixels in the image whose value is greater than 5
-        times the clipped rms, and alpha is the slope of the differential source
-        counts distribution, assumed to be 2.5. 
+        This parameter is a float (default is ``None``) that sets the
+        theoretical estimate of number of beams per source. If ``None``, the
+        value is calculated as N/[n*(alpha-1)], where N is the total number of
+        pixels in the image, n is the number of pixels in the image whose value
+        is greater than 5 times the clipped rms, and alpha is the slope of the
+        differential source counts distribution, assumed to be 2.5.
         
         The value of ``bmpersrc_th`` is used
         to estimate the average separation in pixels between two sources, which
@@ -370,13 +382,14 @@ The advanced options are:
         zero.
         
     check_outsideuniv
-        This parameter is a Boolean (default is ``False``). If ``True``, then the coordinate of each pixel is examined to check if it is
-        outside the universe, which may happen when, e.g., an all sky image is
-        made with SIN projection (commonly done at LOFAR earlier). When found,
-        these pixels are blanked (since imaging software do not do this on their
-        own). Note that this process takes a lot of time, as every pixel is
-        checked in case weird geometries and projections are used.
-        
+        This parameter is a Boolean (default is ``False``). If ``True``, then
+        the coordinate of each pixel is examined to check if it is outside the
+        universe, which may happen when, e.g., an all sky image is made with SIN
+        projection (commonly done at LOFAR earlier). When found, these pixels
+        are blanked (since imaging software do not do this on their own). Note
+        that this process takes a lot of time, as every pixel is checked in case
+        weird geometries and projections are used.
+       
     detection_image
         This parameter is a string (default is ``''``) that sets the detection image file name used only for detecting islands of emission. Source measurement is still done on the main image. The detection image can be a FITS or CASA 2-, 3-, or 4-D cube and must have the same size and WCS parameters as the main image.
         
diff --git a/CEP/PyBDSM/doc/source/whats_new.rst b/CEP/PyBDSM/doc/source/whats_new.rst
index 74d987b7b8cffa5d43e6d1175e369e8726f83ef4..a6094d39aa87175b9b7e256110366829ec39b2f7 100644
--- a/CEP/PyBDSM/doc/source/whats_new.rst
+++ b/CEP/PyBDSM/doc/source/whats_new.rst
@@ -4,6 +4,18 @@
 What's New
 **********
 
+Version 1.2 (2012/06/06):
+        
+    * Added option to output flux densities for every channel found by the spectral index module. 
+    
+    * Added option to spectral index module to allow use of flux densities that do not meet the desired SNR.
+
+    * Implemented an adaptive scaling scheme for the ``rms_box`` parameter that shrinks the box size near bright sources and expands it far from them (enabled with the ``adaptive_rms_box`` option when ``rms_box`` is None). This scheme generally results in improved rms and mean maps when both strong artifacts and extended sources are present.
+
+    *  Improved speed of Gaussian fitting to wavelet images.
+
+    * Added option to calculate fluxes within a specified aperture radius in pixels (set with the ``aperture`` option). Aperture fluxes, if measured, are output in the ``srl`` format catalogs.
+
 Version 1.1 (2012/03/28):
 
     * Tweaked settings that affect fitting of Gaussians to improve fitting in general.
diff --git a/CEP/PyBDSM/src/python/_version.py b/CEP/PyBDSM/src/python/_version.py
index 5bfc2843a22e6c07b61b3f6eaa7b74731cc12f6c..03eded4636a95876dbb555d4ee912e76afa6918f 100644
--- a/CEP/PyBDSM/src/python/_version.py
+++ b/CEP/PyBDSM/src/python/_version.py
@@ -9,7 +9,7 @@ adding to the changelog will naturally do this.
 """
 
 # Version number
-__version__ = '1.1'
+__version__ = '1.2'
 
 # Store svn Revision number. For this to work, one also
 # needs to do: 
@@ -27,6 +27,13 @@ def changelog():
     PyBDSM Changelog.
     -----------------------------------------------------------------------
     
+    2012/06/06 - Version 1.2
+    
+    2012/06/06 - Added option to calculate fluxes within a specified 
+        aperture radius in pixels (set with the "aperture" option). 
+        Aperture fluxes, if measured, are output in the "srl" catalogs.
+        Changed code that determines terminal width to be more robust.
+    
     2012/05/07 - Removed dependencies on matplotlib -- if matplotlib is
     	not available, plotting is disabled. Corrected inconsistencies,
     	spelling mistakes, etc. in help text and documentation. Cleaned
diff --git a/CEP/PyBDSM/src/python/functions.py b/CEP/PyBDSM/src/python/functions.py
index c1ec58cb1fee6715b6e532763e5449db5e10325f..90d99a38d8668e0a629a168ffa64bc2ade5a8904 100755
--- a/CEP/PyBDSM/src/python/functions.py
+++ b/CEP/PyBDSM/src/python/functions.py
@@ -1497,7 +1497,40 @@ class NullDevice():
     def write(self, s):
         pass
 
+def get_aperture_flux(img, posn_pix, aperture_pix):
+    """Measure ch0 flux inside radius aperture_pix pixels centered on posn_pix.
     
+    Returns [flux, fluxE]
+    """
+    import numpy as N
+    
+    # Make a subimage and mask
+    xlo = posn_pix[0]-int(aperture_pix)-1
+    if xlo < 0:
+        xlo = 0
+    xhi = posn_pix[0]+int(aperture_pix)+1
+    if xhi > img.ch0.shape[0]:
+        xhi = img.ch0.shape[0]
+    ylo = posn_pix[1]-int(aperture_pix)-1
+    if ylo < 0:
+        ylo = 0
+    yhi = posn_pix[1]+int(aperture_pix)+1
+    if yhi > img.ch0.shape[1]:
+        yhi = img.ch0.shape[1]
+        
+    aper_im = img.ch0[xlo:xhi, ylo:yhi]
+    aper_rms = img.rms[xlo:xhi, ylo:yhi]
+    dist_mask = N.zeros(aper_im.shape)
+
+    for i in range(aper_im.shape[0]):
+        for j in range(aper_im.shape[1]):
+            dist_mask[i, j] = N.sqrt( (i + xlo - posn_pix[0])**2 + (j + ylo - posn_pix[1])**2 )
+    aper_mask = N.where(dist_mask < aperture_pix)
+    aper_flux = N.nansum(aper_im[aper_mask])/img.pixel_beamarea # Jy
+    pixels_in_source = N.sum(~N.isnan(aper_im[aper_mask])) # number of unmasked pixels assigned to current source
+    aper_fluxE = nanmean(aper_rms[aper_mask]) * N.sqrt(pixels_in_source/img.pixel_beamarea) # Jy
+    
+    return [aper_flux, aper_fluxE]
 
 
 
diff --git a/CEP/PyBDSM/src/python/gaul2srl.py b/CEP/PyBDSM/src/python/gaul2srl.py
index ecbcdadb6f7620b5f7cd51277e4cdfcf6bbf97ec..d24cdea41fd3d9f6b5f355bebbe1c43dd48b639b 100644
--- a/CEP/PyBDSM/src/python/gaul2srl.py
+++ b/CEP/PyBDSM/src/python/gaul2srl.py
@@ -81,8 +81,12 @@ class Op_gaul2srl(Op):
         ngaus = 1
         island_id = g.island_id
         gaussians = list([g])
-        
-        source_prop = list([code, total_flux, peak_flux_centroid, peak_flux_max, posn_sky_centroid, \
+        if img.opts.aperture != None:
+            aper_flux = func.get_aperture_flux(img, g.centre_pix, img.opts.aperture)
+        else:
+            aper_flux = [0.0, 0.0]
+
+        source_prop = list([code, total_flux, peak_flux_centroid, peak_flux_max, aper_flux, posn_sky_centroid, \
              posn_sky_max, size_sky, deconv_size_sky, bbox, ngaus, island_id, gaussians])
         source = Source(img, source_prop)
 
@@ -377,8 +381,17 @@ class Op_gaul2srl(Op):
         size_skyE = [mompara3E*sqrt(cdeltsq), mompara4E*sqrt(cdeltsq), mompara5E]
         sraE, sdecE = (mompara1E*sqrt(cdeltsq), mompara2E*sqrt(cdeltsq))
         
+        # Find aperture flux
+        if img.opts.aperture != None:
+            aper_flux, aper_fluxE = func.get_aperture_flux(img, [mompara[1]+delc[0], 
+                                    mompara[2]+delc[1]], img.opts.aperture)
+        else:
+            aper_flux = 0.0
+            aper_fluxE = 0.0
+        
         isl_id = isl.island_id
-        source_prop = list(['M', [tot, totE], [s_peak, isl.rms], [maxpeak, isl.rms], [[sra, sdec], 
+        source_prop = list(['M', [tot, totE], [s_peak, isl.rms], [maxpeak, isl.rms], 
+                      [aper_flux, aper_fluxE], [[sra, sdec], 
                       [sraE, sdecE]], [[mra, mdec], [sraE, sdecE]], [size_sky, size_skyE], 
                       deconv_size_sky, isl.bbox, len(g_sublist), isl_id, g_sublist])
         source = Source(img, source_prop)
@@ -462,6 +475,10 @@ class Source(object):
                                 colname='Peak_flux', units='Jy/beam')
     peak_flux_maxE      = Float(doc="Error in peak flux density per beam at posn of max emission (Jy/beam)",
                                 colname='E_Peak_flux', units='Jy/beam')
+    aperture_flux       = Float(doc="Total aperture flux density (Jy)", colname='Aperture_flux', 
+                                units='Jy')
+    aperture_fluxE      = Float(doc="Error in total aperture flux density (Jy)", colname='E_Aperture_flux', 
+                                units='Jy')
     posn_sky_centroid   = List(Float(), doc="Posn (RA, Dec in deg) of centroid of source", 
                                colname=['RA', 'DEC'], units=['deg', 'deg'])
     posn_sky_centroidE  = List(Float(), doc="Error in posn (RA, Dec in deg) of centroid of source", 
@@ -507,7 +524,7 @@ class Source(object):
 
     def __init__(self, img, sourceprop):
     
-        code, total_flux, peak_flux_centroid, peak_flux_max, posn_sky_centroid, \
+        code, total_flux, peak_flux_centroid, peak_flux_max, aper_flux, posn_sky_centroid, \
                      posn_sky_max, size_sky, deconv_size_sky, bbox, ngaus, island_id, gaussians = sourceprop
         self.code = code
         self.total_flux, self.total_fluxE = total_flux 
@@ -524,6 +541,8 @@ class Source(object):
         self.rms_isl = img.islands[island_id].rms
         self.mean_isl = img.islands[island_id].mean
         self.jlevel = img.j
+        self.aperture_flux, self.aperture_fluxE =  aper_flux
+         
 
 Image.sources = List(tInstance(Source), doc="List of Sources")
 Island.sources = List(tInstance(Source), doc="List of Sources")
diff --git a/CEP/PyBDSM/src/python/opts.py b/CEP/PyBDSM/src/python/opts.py
index 05e494bd8498b3f1651ba1ac2d434762f3c0aece..782b7a81abdc7915eec3f258ded956136d0a7079 100644
--- a/CEP/PyBDSM/src/python/opts.py
+++ b/CEP/PyBDSM/src/python/opts.py
@@ -407,6 +407,15 @@ class Opts(object):
                                  "Jy/beam to use if rms_map = False. "\
                                  "None => calculate inside program",
                              group="advanced_opts")
+    aperture        = Option(None, Float(),
+                             doc="Radius of aperture in pixels inside which aperture fluxes are measured "\
+                                 "for each source. None => no aperture fluxes measured\n" \
+                                 "This is a float and sets the radius (in pixels) inside "
+                                 "which the aperture flux is measured for each source. "
+                                 "The aperture is centered "
+                                 "on the centroid of the source. Errors are calculated "
+                                 "from the mean of the rms map inside the aperture.",
+                             group="advanced_opts")
     ini_gausfit     =   Enum('default', 'simple', 'nobeam',
                              doc = "Initial guess for Gaussian "\
                                  "parameters: 'default', 'simple', or 'nobeam'\n"\
@@ -746,8 +755,9 @@ class Opts(object):
                                  "patches (FITS or CASA format)",
                              group="output_opts")
     solnname        = Option(None, String(),
-                             doc="Name of the run, to be appended "\
-                                 "to the name of the output directory",
+                             doc="Name of the run, to be prepended "\
+                                 "to the name of the output directory. E.g., "\
+                                 "solname='Run_1'",
                              group="output_opts")
     indir           = Option(None, String(),
                              doc="Directory of input FITS files. None => get "\
diff --git a/CEP/PyBDSM/src/python/output.py b/CEP/PyBDSM/src/python/output.py
index c31aadd9066bacdc28a62e726c8b453b0bebde15..6295c8c14759ef5be4bbf8ea491a1e866e7d434d 100644
--- a/CEP/PyBDSM/src/python/output.py
+++ b/CEP/PyBDSM/src/python/output.py
@@ -336,11 +336,16 @@ def write_fits_list(img, filename=None, sort_by='indx', objtype='gaul',
                 nmax = isl.shapelet_nmax
         nmax += 1
     
+    if img.opts.aperture != None:
+        incl_aper = True
+    else:
+        incl_aper = False
     cvals, cnames, cformats, cunits = make_output_columns(outl[0][0], fits=True,
                                                           objtype=objtype, 
                                                           incl_spin=img.opts.spectralindex_do,
                                                           incl_chan=img.opts.incl_chan,
                                                           incl_pol=img.opts.polarisation_do,
+                                                          incl_aper=incl_aper,
                                                           nmax=nmax, nchan=img.nchan)
     out_list = make_fits_list(img, outl, objtype=objtype, nmax=nmax)
     col_list = []
@@ -578,12 +583,18 @@ def make_ascii_str(img, glist, objtype='gaul'):
     outstr_list.append('# Reference frequency of the detection ("ch0") image: %s Hz\n' % freq)
     outstr_list.append('# Equinox : %s \n\n' % img.equinox)
     val_list = []
+    if img.opts.aperture != None:
+        incl_aper = True
+    else:
+        incl_aper = False
+
     for i, g in enumerate(glist[0]):
         cvals, cnames, cformats, cunits = make_output_columns(g, fits=False, 
                                                               objtype=objtype, 
                                                               incl_spin=img.opts.spectralindex_do,
                                                               incl_chan=img.opts.incl_chan,
                                                               incl_pol=img.opts.polarisation_do,
+                                                              incl_aper=incl_aper,
                                                               nchan=img.nchan)
         cformats[-1] += "\n"
         if i == 0:
@@ -596,11 +607,16 @@ def make_fits_list(img, glist, objtype='gaul', nmax=30):
     import functions as func
 
     out_list = []
+    if img.opts.aperture != None:
+        incl_aper = True
+    else:
+        incl_aper = False
     for g in glist[0]:
         cvals, ext1, ext2, ext3 = make_output_columns(g, fits=True, objtype=objtype, 
                                                       incl_spin=img.opts.spectralindex_do,
                                                       incl_chan=img.opts.incl_chan,
                                                       incl_pol=img.opts.polarisation_do,
+                                                      incl_aper=incl_aper,
                                                       nmax=nmax, nchan=img.nchan)
         out_list.append(cvals)
     out_list = func.trans_gaul(out_list)
@@ -805,7 +821,8 @@ def list_and_sort_gaussians(img, patch=None, root=None,
     return (outlist_sorted, outnames_sorted, patchnames_sorted)
 
 def make_output_columns(obj, fits=False, objtype='gaul', incl_spin=False,
-                        incl_chan=False, incl_pol=False, nmax=30, nchan=1):
+                        incl_chan=False, incl_pol=False, incl_aper=False, 
+                        nmax=30, nchan=1):
     """Returns a list of column names, formats, and units for Gaussian, Source, or Shapelet"""
     import numpy as N
     
@@ -820,10 +837,15 @@ def make_output_columns(obj, fits=False, objtype='gaul', incl_spin=False,
                  'deconv_size_skyE', 'rms', 'mean', 'gresid_rms', 'gresid_mean',
                  'code']
     elif objtype == 'srl':
+        if incl_aper:
+            infix = ['aperture_flux', 'aperture_fluxE']
+        else:
+            infix = []
         names = ['source_id', 'island_id', 'posn_sky_centroid', 
                  'posn_sky_centroidE', 'total_flux', 
                  'total_fluxE', 
-                 'peak_flux_max', 'peak_flux_maxE', 'posn_sky_max', 'posn_sky_maxE', 
+                 'peak_flux_max', 'peak_flux_maxE'] + infix + \
+                 ['posn_sky_max', 'posn_sky_maxE', 
                  'posn_pix_centroid', 'posn_pix_centroidE', 'posn_pix_max', 
                  'posn_pix_maxE',
                  'size_sky', 'size_skyE', 'deconv_size_sky',
diff --git a/CEP/PyBDSM/src/python/plotresults.py b/CEP/PyBDSM/src/python/plotresults.py
index f86b730f08434d8eb9297f2b34baa0f523aea4de..f16c37643dfc96a313ef984c49c906f328d5a63f 100644
--- a/CEP/PyBDSM/src/python/plotresults.py
+++ b/CEP/PyBDSM/src/python/plotresults.py
@@ -425,7 +425,6 @@ def on_press(event):
     global pixels_per_beam, vmin, vmax, vmin_cur, vmax_cur, img_pi
     global ch0min, ch0max, low, fig, images, src_list, srcid_cur
     global markers
-#     print 'Testing...'
     if event.key == '0':
         print 'Resetting limits to defaults (%.4f -- %.4f Jy/beam)' \
             % (pow(10, vmin)-low,
diff --git a/CEP/PyBDSM/src/python/psf_vary.py b/CEP/PyBDSM/src/python/psf_vary.py
index 30c5f865ac0036ec80993d68d7de95364a779e0a..701a444bb113aad571911339488093e5c0179b6b 100644
--- a/CEP/PyBDSM/src/python/psf_vary.py
+++ b/CEP/PyBDSM/src/python/psf_vary.py
@@ -248,10 +248,10 @@ class Op_psf_vary(Op):
                 img.psf_vary_ratio = psf_ratio_int
     
                 if opts.output_all:
-                    func.write_image_to_file(img.use_io, img.imagename + '.psf_vary_maj.fits', N.transpose(psf_maj_in)*fwsig, img, dir)
-                    func.write_image_to_file(img.use_io, img.imagename + '.psf_vary_min.fits', N.transpose(psf_min_in)*fwsig, img, dir)
-                    func.write_image_to_file(img.use_io, img.imagename + '.psf_vary_pa.fits', N.transpose(psf_pa_in), img, dir)
-                    func.write_image_to_file(img.use_io, img.imagename + '.psf_vary_ratio.fits', N.transpose(psf_ratio_in), img, dir)
+                    func.write_image_to_file(img.use_io, img.imagename + '.psf_vary_maj.fits', N.transpose(psf_maj_int)*fwsig, img, dir)
+                    func.write_image_to_file(img.use_io, img.imagename + '.psf_vary_min.fits', N.transpose(psf_min_int)*fwsig, img, dir)
+                    func.write_image_to_file(img.use_io, img.imagename + '.psf_vary_pa.fits', N.transpose(psf_pa_int), img, dir)
+                    func.write_image_to_file(img.use_io, img.imagename + '.psf_vary_ratio.fits', N.transpose(psf_ratio_int), img, dir)
                 
                 # Loop through source and Gaussian lists and deconvolve the sizes using appropriate beam
                 bar2 = statusbar.StatusBar('Correcting deconvolved source sizes ..... : ', 0, img.nsrc)
diff --git a/CEP/PyBDSM/src/python/readimage.py b/CEP/PyBDSM/src/python/readimage.py
index 4b2d07c5b78f97140be149da99900061ec741efa..5793991023944924c1856a95853af51ef4ba6b85 100644
--- a/CEP/PyBDSM/src/python/readimage.py
+++ b/CEP/PyBDSM/src/python/readimage.py
@@ -115,7 +115,7 @@ class Op_readimage(Op):
                 img.opts.opdir_overwrite = 'append'
                 mylog.info('Appending output files in directory '+basedir)
             img.basedir = basedir + '/'
-            if img.opts.solnname != None: img.basedir += img.opts.solnname + '__'
+            if img.opts.solnname != None: img.basedir += img.opts.solnname + '_'
             img.basedir += time.strftime("%d%b%Y_%H.%M.%S")
 
             if os.path.isfile(basedir): os.system("rm -fr "+basedir)
diff --git a/CEP/PyBDSM/src/python/statusbar.py b/CEP/PyBDSM/src/python/statusbar.py
index 6c1e67e94db369231c371e1c4fbd554761585f85..eb0e16b9aad3449b6bd864570de85e38bef865fc 100644
--- a/CEP/PyBDSM/src/python/statusbar.py
+++ b/CEP/PyBDSM/src/python/statusbar.py
@@ -26,11 +26,48 @@ class StatusBar():
             self.comp = int(float(self.pos) / self.max * self.columns)
         else:
             self.comp = 0
+
+    def getTerminalSize(self):
+        """
+        returns (lines:int, cols:int)
+        """
+        import os, struct
+        def ioctl_GWINSZ(fd):
+            import fcntl, termios
+            return struct.unpack("hh", fcntl.ioctl(fd, termios.TIOCGWINSZ, "1234"))
+        # try stdin, stdout, stderr
+        for fd in (0, 1, 2):
+            try:
+                return ioctl_GWINSZ(fd)
+            except:
+                pass
+        # try os.ctermid()
+        try:
+            fd = os.open(os.ctermid(), os.O_RDONLY)
+            try:
+                return ioctl_GWINSZ(fd)
+            finally:
+                os.close(fd)
+        except:
+            pass
+        # try `stty size`
+        try:
+            return tuple(int(x) for x in os.popen("stty size", "r").read().split())
+        except:
+            pass
+        # try environment variables
+        try:
+            return tuple(int(os.getenv(var)) for var in ("LINES", "COLUMNS"))
+        except:
+            pass
+        # Give up. return 0.
+        return (0, 0)            
             
     # find number of columns in terminal
     def __getsize(self):
         try:
-            rows, columns = os.popen('stty size', 'r').read().split()
+#             rows, columns = os.popen('stty size', 'r').read().split()
+            rows, columns = self.getTerminalSize()
         except ValueError:
             rows = columns = 0
         if int(columns) > self.max + 2 + 44 + (len(str(self.max))*2 + 2):