[med-svn] [hyphy] 02/04: Imported Upstream version 2.2.5+dfsg

Andreas Tille tille at debian.org
Sat Jul 11 04:43:24 UTC 2015


This is an automated email from the git hooks/post-receive script.

tille pushed a commit to branch master
in repository hyphy.

commit f517b2a233eb5ac70dd7973c6153255be80d2f32
Author: Andreas Tille <tille at debian.org>
Date:   Sat Jul 11 06:42:14 2015 +0200

    Imported Upstream version 2.2.5+dfsg
---
 LICENSE                                            |  34 ++
 res/TemplateBatchFiles/GARDProcessor.bf            |  26 +-
 res/TemplateBatchFiles/lib2014/IOFunctions.bf      |  47 ++
 res/TemplateBatchFiles/lib2014/UtilityFunctions.bf |  28 +-
 res/TemplateBatchFiles/lib2014/models/DNA/GTR.bf   |   3 +-
 .../lib2014/models/frequencies.bf                  |  43 +-
 .../lib2014/models/model_functions.bf              |  12 +-
 .../lib2014/models/parameters.bf                   |   9 +-
 .../lib2014/models/rate_variation.bf               |  98 ++++
 res/TemplateBatchFiles/lib2014/models/terms.bf     |   5 +
 res/TemplateBatchFiles/lib2014/tasks/estimators.bf |  78 ++-
 src/core/_hyExecutionContext.cpp                   |  64 ++-
 src/core/alignment.cpp                             |  38 ++
 src/core/avllist.cpp                               |  67 ++-
 src/core/avllistx.cpp                              |  67 ++-
 src/core/avllistxl.cpp                             |  67 ++-
 src/core/baseobj.cpp                               |  69 +--
 src/core/batchlan.cpp                              |  28 +-
 src/core/batchlan2.cpp                             |  34 --
 src/core/calcnode.cpp                              |  85 +--
 src/core/calcnode2.cpp                             |  40 +-
 src/core/category.cpp                              |  64 ++-
 src/core/error.cpp                                 |  64 ++-
 src/core/formula.cpp                               |  40 +-
 src/core/include/alignment.h                       |  38 ++
 src/core/include/batchlan.h                        |   2 -
 src/core/include/mypthread.h                       |   2 +-
 src/core/likefunc.cpp                              | 110 +++-
 src/core/list.cpp                                  |  67 ++-
 src/core/mathobj.cpp                               |  39 ++
 src/core/matrix.cpp                                |  64 ++-
 src/core/nexus.cpp                                 |  63 ++-
 src/core/parser.cpp                                |  64 ++-
 src/core/parser2.cpp                               |  64 ++-
 src/core/polynoml.cpp                              |  64 ++-
 src/core/sequence.cpp                              |  64 ++-
 src/core/simplelist.cpp                            |  65 ++-
 src/core/site.cpp                                  |  64 ++-
 src/core/strings.cpp                               |  65 ++-
 src/gui/Components/HYButton.cpp                    |   2 +-
 src/gui/Components/HYButtonBar.cpp                 |  43 +-
 src/gui/Components/HYCheckBox.cpp                  |   2 +-
 src/gui/Components/HYLabel.cpp                     |   2 +-
 src/gui/Components/HYPullDown.cpp                  |  43 +-
 src/gui/Components/HYSequencePanel.cpp             |  43 +-
 src/gui/Components/HYTable.cpp                     |   2 +-
 src/gui/Components/HYTextBox.cpp                   |   2 +-
 src/gui/gtk/Components/HYPlatformButton.cpp        |  41 +-
 src/gui/gtk/Components/HYPlatformButtonBar.cpp     |  43 +-
 src/gui/gtk/Components/HYPlatformCheckBox.cpp      |  43 +-
 src/gui/gtk/Components/HYPlatformLabel.cpp         |  43 +-
 src/gui/gtk/Components/HYPlatformPullDown.cpp      |  43 +-
 src/gui/gtk/Components/HYPlatformSequencePane.cpp  |  43 +-
 src/gui/gtk/Components/HYPlatformTable.cpp         |  43 +-
 src/gui/gtk/Components/HYPlatformTextBox.cpp       |  43 +-
 src/gui/gtk/HYPlatformComponent.cpp                |  40 ++
 src/gui/gtk/HYPlatformGraphicPane.cpp              |  42 +-
 src/gui/gtk/HYPlatformUtils.cpp                    |  40 ++
 src/gui/gtk/HYPlatformWindow.cpp                   |  42 +-
 .../gtk/WindowClasses/HYPlatformBootsrapWindow.cpp |  41 +-
 .../gtk/WindowClasses/HYPlatformChartWindow.cpp    |  41 +-
 .../gtk/WindowClasses/HYPlatformConsoleWindow.cpp  |  39 ++
 src/gui/gtk/WindowClasses/HYPlatformDBWindow.cpp   |   2 +-
 src/gui/gtk/WindowClasses/HYPlatformDataPanel.cpp  |  42 +-
 src/gui/gtk/WindowClasses/HYPlatformGWindow.cpp    |  42 +-
 .../gtk/WindowClasses/HYPlatformModelWindow.cpp    |  42 +-
 src/gui/gtk/WindowClasses/HYPlatformPWindow.cpp    |  42 +-
 .../gtk/WindowClasses/HYPlatformParameterTable.cpp |  42 +-
 src/gui/gtk/WindowClasses/HYPlatformTWindow.cpp    |  42 +-
 src/gui/gtk/WindowClasses/HYPlatformTreePanel.cpp  |  42 +-
 src/gui/gtk/include/Components/HYPlatformButton.h  |  43 +-
 .../gtk/include/Components/HYPlatformButtonBar.h   |  43 +-
 .../gtk/include/Components/HYPlatformCheckbox.h    |  43 +-
 src/gui/gtk/include/Components/HYPlatformLabel.h   |  43 +-
 .../gtk/include/Components/HYPlatformPullDown.h    |  43 +-
 src/gui/gtk/include/Components/HYPlatformTable.h   |  43 +-
 src/gui/gtk/include/Components/HYPlatformTextbox.h |  43 +-
 src/gui/gtk/include/HYPlatformComponent.h          |  43 +-
 src/gui/gtk/include/HYPlatformGraphicPane.h        |  43 +-
 src/gui/gtk/include/HYPlatformWindow.h             |  42 +-
 src/gui/preferences.cpp                            |  71 +--
 src/mains/mac.cpp                                  |  64 ++-
 src/new/HYNetInterface.cpp                         | 375 -------------
 src/new/Net.cpp                                    | 606 ---------------------
 src/new/bgm.cpp                                    |  68 +--
 src/new/bgm2.cpp                                   |  42 +-
 src/new/include/HYNetInterface.h                   |  40 --
 src/new/include/SerangNet.h                        |  95 ----
 src/new/include/bgm.h                              |  43 +-
 src/new/include/scfg.h                             |  44 +-
 src/new/scfg.cpp                                   |  42 +-
 src/ocl/opencl_kernels.cl                          |  40 ++
 src/utils/hyphyunixutils.cpp                       |  39 ++
 tests/gtests/ut_avllists.cpp                       |  42 +-
 tests/gtests/ut_list.cpp                           |  41 +-
 tests/gtests/ut_simplelists.cpp                    |  42 +-
 tests/gtests/ut_strings.cpp                        |  42 +-
 tests/hbltests/SimpleOptimizations/SmallCodon.bf   |   2 +
 .../hbltests/UnitTests/HBLCommands/AllCommands.bf  |   1 -
 99 files changed, 3172 insertions(+), 2003 deletions(-)

diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..4504e0c
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,34 @@
+HyPhy - Hypothesis Testing Using Phylogenies.
+
+Copyright (C) 1997-now
+Core Developers:
+Sergei L Kosakovsky Pond (spond at ucsd.edu)
+Art FY Poon    (apoon at cfenet.ubc.ca)
+Steven Weaver (sweaver at ucsd.edu)
+
+Module Developers:
+Lance Hepler (nlhepler at gmail.com)
+Martin Smith (martin.audacis at gmail.com)
+
+Significant contributions from:
+Spencer V Muse (muse at stat.ncsu.edu)
+Simon DW Frost (sdf22 at cam.ac.uk)
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/res/TemplateBatchFiles/GARDProcessor.bf b/res/TemplateBatchFiles/GARDProcessor.bf
index df611fe..31eb971 100644
--- a/res/TemplateBatchFiles/GARDProcessor.bf
+++ b/res/TemplateBatchFiles/GARDProcessor.bf
@@ -1,10 +1,11 @@
+LoadFunctionLibrary ("lib2014/IOFunctions.bf");
 VERBOSITY_LEVEL = -1;
 
 SetDialogPrompt ("Please load a nucleotide data file:");
 DataSet 	ds = ReadDataFile (PROMPT_FOR_FILE);
 baselineDSPath = LAST_FILE_PATH;
 
-SetDialogPrompt ("Please load a GA partition analysis result file:");
+SetDialogPrompt ("Please load a GA partition analysis result file (.gard_splits extension):");
 fscanf  (PROMPT_FOR_FILE,REWIND,"Lines",partLines);
 
 readPCount = Columns (partLines)/2-1;
@@ -75,6 +76,8 @@ for (h=0; h<filteredData.sites; h=h+1)
 	}
 }
 
+io.printAndUnderline ("Data summary", "-");
+
 fprintf (stdout, "\nSequences :", filteredData.species,
 				 "\nSites     :", filteredData.sites,
 				 "\nVariable  :", Abs(bppMap), "\n"); 
@@ -119,7 +122,8 @@ m1 = computeMeanDivergence ("givenTree");
 
 fprintf  (stdout, "\nMean divergence : ", m1*100, "%\n");
 
-fprintf  (stdout, "\n\nFitting a single-tree, multiple partition model\n");
+
+io.printAndUnderline ("Fitting a single-tree, multiple partition model", "-");
 
 USE_DISTANCES = 0;
 
@@ -152,7 +156,7 @@ lfDef = "";
 lfDef * 128;
 lfDef  * "LikelihoodFunction multiPart  = (";
 
-fprintf  (stdout, "\n\nFitting a mutilple tree, multiple partition model\n");
+io.printAndUnderline ("Fitting a mutilple tree, multiple partition model", "-");
 
 for (pccounter = 0; pccounter < readPCount; pccounter = pccounter + 1)
 {
@@ -180,8 +184,18 @@ myDF = baseParams + res[1][1];
 
 fullCAIC = -2(res[1][0]-myDF*filteredData.sites/(filteredData.sites-myDF-1));
 
-fprintf  (stdout, "\n\nVersus the single partition model: c-AIC = ", fullCAIC, "\nDelta AIC = ", nullCAIC-fullCAIC,"\n\n");
-fprintf  (stdout, "\n\nVersus the single tree/multiple partition model: Delta AIC = ", intCAIC-fullCAIC,"\n\n");
+
+io.printAndUnderline ("Topological Incongruence Summary", "-");
+
+fprintf  (stdout, "\nGARD vs the single partition model: c-AIC = ", fullCAIC, 
+                    "\nDelta AIC = ", nullCAIC-fullCAIC,
+                    "\nEvidence ratio in favor of the GARD model = ", Exp ((nullCAIC-fullCAIC)*0.5),
+                    "\n");
+                    
+fprintf  (stdout, "\nGARD vs the single tree/multiple partition model",
+                  "\nDelta AIC = ", intCAIC-fullCAIC,
+                  "\nEvidence ratio in favor of the GARD model = ", Exp ((intCAIC-fullCAIC)*0.5),                  
+                  "\n\n");
 
 bpLocations = {readPCount, 1}; 
 for (pccounter = 0; pccounter <  readPCount; pccounter = pccounter + 1)
@@ -223,6 +237,8 @@ else
 	cutThreshold		= 2 * OPTIMIZATION_PRECISION;
 }
 
+io.printAndUnderline ("KH Testing", "-");
+
 
 for (pccounter = 0; pccounter <  readPCount; pccounter = pccounter + 1)
 {
diff --git a/res/TemplateBatchFiles/lib2014/IOFunctions.bf b/res/TemplateBatchFiles/lib2014/IOFunctions.bf
index ead0c03..70cd428 100644
--- a/res/TemplateBatchFiles/lib2014/IOFunctions.bf
+++ b/res/TemplateBatchFiles/lib2014/IOFunctions.bf
@@ -11,6 +11,17 @@ function io.readCodonDataSet (dataset_name) {
     return {"code": _Genetic_Code, "stop" : GeneticCodeExclusions, "file" : LAST_FILE_PATH, "sequences" : Eval ("`dataset_name`.species")};
 }
 
+function io.readNucleotideDataSet (dataset_name, file_name) {
+    
+    if (Type (file_name) == "String") {
+        ExecuteCommands ("DataSet `dataset_name` = ReadDataFile (`file_name`);");
+    } else {
+        ExecuteCommands ("DataSet `dataset_name` = ReadDataFile (PROMPT_FOR_FILE);");    
+    }
+    
+    return {"sequences" : Eval ("`dataset_name`.species")};
+}
+
 function io.getTreeString (look_for_newick_tree) {
 
     UseModel (USE_NO_MODEL);
@@ -44,6 +55,42 @@ function io.reportProgressMessage (analysis, text) {
     return None;
 }
 
+function io.validate_a_list_of_files (list) {
+    io.validate_a_list_of_files.result = {};
+    for (io.validate_a_list_of_files.i = 0; io.validate_a_list_of_files.i < Rows(list) * Columns (list); io.validate_a_list_of_files.i += 1) {
+        if (Abs (list[io.validate_a_list_of_files.i])) {
+            io.validate_a_list_of_files.fn = list[io.validate_a_list_of_files.i];
+            io.checkAssertion ("!io.validate_a_list_of_files.fn", "HyPhy cannot open '" + io.validate_a_list_of_files.fn + "' for reading");
+            io.validate_a_list_of_files.result + io.validate_a_list_of_files.fn;
+        }
+    }
+    return io.validate_a_list_of_files.result;
+}
+
+
+function io.get_a_list_of_files (filename) {
+    if (Type (filename) == "String") {
+        if (!filename) { // filename exists
+            fscanf (filename, REWIND, "Lines", io.get_a_list_of_files.list);
+            return io.validate_a_list_of_files (io.get_a_list_of_files.list);
+        }
+    }
+    
+    io.get_a_list_of_files.result = {};
+    io.printAndUnderline ("Enter paths to files (blank line to end entry)", "-");
+    while (1) {
+        fprintf (stdout, "File ", Abs (io.get_a_list_of_files.result) + 1, " [relative path `PATH_TO_CURRENT_BF`]:");
+        io.get_a_list_of_files.current_path = "";
+        fscanf  (stdin,  "String", io.get_a_list_of_files.current_path);
+        if (Abs (io.get_a_list_of_files.current_path)) {
+            io.checkAssertion ("! io.get_a_list_of_files.current_path", "HyPhy cannot open '" + io.get_a_list_of_files.current_path + "' for reading");
+        } else {
+            break;
+        }
+        io.get_a_list_of_files.result + io.get_a_list_of_files.current_path;
+    } 
+}
+
 function io.displayAnalysisBanner (analysis_info) {
     if (io.hasStringKey ("info", analysis_info)) {
         io.printAndUnderline ("Analysis Description", "=");
diff --git a/res/TemplateBatchFiles/lib2014/UtilityFunctions.bf b/res/TemplateBatchFiles/lib2014/UtilityFunctions.bf
index 2dc6ebb..e726247 100644
--- a/res/TemplateBatchFiles/lib2014/UtilityFunctions.bf
+++ b/res/TemplateBatchFiles/lib2014/UtilityFunctions.bf
@@ -12,6 +12,16 @@ function utility.promptForGeneticCodeAndAlignment (dataset_name, datafilter_name
     return data_info;
 }
 
+function utility.readNucleotideAlignment (file_name, dataset_name, datafilter_name) {
+    data_info = io.readNucleotideDataSet (dataset_name, file_name);
+    ExecuteCommands ("DataSetFilter `datafilter_name` = CreateFilter (`dataset_name`,1)");
+    data_info ["sites"] = Eval ("`datafilter_name`.sites");
+    data_info ["dataset"] = dataset_name;
+    data_info ["datafilter"] = datafilter_name;
+    
+    return data_info;
+}
+
 
 function utility.associativeListToJSON(associative_list) {
 
@@ -64,6 +74,22 @@ function utility.callFunction (id, arguments) {
     return None;
 }
 
+function utility.array1D (m) {
+    return Rows (m) * Columns (m);
+}
+
+
+function utility.json_spool (json, file) {
+    USE_JSON_FOR_MATRIX = 1;
+    if (Type (file) == "String") {
+        fprintf (file, CLEAR_FILE, json);
+    } else {
+        fprintf (stdout, "\n", json, "\n");
+    }
+    USE_JSON_FOR_MATRIX = 0;
+}
+
+
 function utility.isFunction (id) {
 	if (Type (id) == "String" && Abs (id) > 0) {
 		ExecuteCommands ("GetString (__funcInfo, `id`, -1)");
@@ -75,7 +101,7 @@ function utility.isFunction (id) {
 }
 
 function utility.toggleEnvVariable (var, value) {
-	if (value != None) {
+	if (None != value) {
 		utilityFunction.toggleEnvVariable.__stash = Eval (var);
 		*var = value;
 	} else {
diff --git a/res/TemplateBatchFiles/lib2014/models/DNA/GTR.bf b/res/TemplateBatchFiles/lib2014/models/DNA/GTR.bf
index dce2d6c..bbc50b9 100644
--- a/res/TemplateBatchFiles/lib2014/models/DNA/GTR.bf
+++ b/res/TemplateBatchFiles/lib2014/models/DNA/GTR.bf
@@ -12,7 +12,8 @@ function models.DNA.GTR.modelDescription (type) {
     		terms.efv_estimate_name: terms.freqs.4x1,
     		"parameters" : 	{
     				"global" : {}, 
-    				"local" : {}
+    				"local"  : {},
+    				"empirical" : 3
     			},
     		"type" : type,
      		"get-branch-length" : "",
diff --git a/res/TemplateBatchFiles/lib2014/models/frequencies.bf b/res/TemplateBatchFiles/lib2014/models/frequencies.bf
index fb6f5aa..e80af6e 100644
--- a/res/TemplateBatchFiles/lib2014/models/frequencies.bf
+++ b/res/TemplateBatchFiles/lib2014/models/frequencies.bf
@@ -7,12 +7,14 @@ function frequencies.equal (model, namespace, datafilter) {
 	__N = Abs (model["alphabet"]);
 	model[terms.efv_estimate]      = {__N,1}["1/__N"];
 	model[terms.efv_estimate_name] = terms.freqs.equal;
+	(model["parameters"])["empirical"] = 0;
 	return model;
 }
 
 function frequencies.empirical.nucleotide (model, namespace, datafilter) {
 	model = frequencies._aux.empirical.singlechar (model, namespace, datafilter);
 	model[terms.efv_estimate_name] = terms.freqs.4x1;
+	(model["parameters"])["empirical"] = 3;
 	return model;
 }
 
@@ -28,7 +30,7 @@ function frequencies.empirical.corrected.CF3x4 (model, namespace, datafilter) {
     GetDataInfo (_givenAlphabet, *datafilter, "CHARACTERS");
     
  	utility.toggleEnvVariable ("COUNT_GAPS_IN_FREQUENCIES", 0);
-	HarvestFrequencies (__f, *datafilter, 3,1,1);
+ 	__f = frequencies._aux.empirical.collect_data (datafilter, 3,1,1);
 	utility.toggleEnvVariable ("COUNT_GAPS_IN_FREQUENCIES", None);
     
     __estimates = frequencies._aux.CF3x4 (__f, model["bases"], __alphabet, model["stop"]);
@@ -47,6 +49,7 @@ function frequencies.empirical.corrected.CF3x4 (model, namespace, datafilter) {
 	}
 	
 	model[terms.efv_estimate_name] = terms.freqs.CF3x4;	
+	(model["parameters"])["empirical"] = 9;
 	return model;
 }
 
@@ -56,9 +59,45 @@ function frequencies.mle (model, namespace, datafilter) {
 
 //--- AUX FUNCTIONS FROM THIS POINT ON ---//
 
+function frequencies._aux.empirical.character_count (datafilter) {
+    return Eval ("`datafilter`.sites * `datafilter`.species");
+}
+
+function frequencies._aux.empirical.collect_data (datafilter, unit, stride, position_specific) {
+    assert (Type (datafilter) == "Matrix" || Type (datafilter) == "String", 
+        "`datafilter` must be a matrix or a string in call to frequencies._aux.empirical.collect_data"
+    );
+    if (Type (datafilter) == "String") {
+        HarvestFrequencies (__f, *datafilter, unit,stride,position_specific);
+    } else {
+        frequencies._aux.empirical.collect_data.site_count = 0;
+    
+        for (frequencies._aux.empirical.collect_data.i = 0; 
+             frequencies._aux.empirical.collect_data.i < Rows (datafilter) * Columns (datafilter); 
+             frequencies._aux.empirical.collect_data.i += 1) {
+            
+            
+             ExecuteCommands ("HarvestFrequencies (__f, " + datafilter[frequencies._aux.empirical.collect_data.i] + ",unit,stride,position_specific_)");
+             frequencies._aux.empirical.collect_data.local_sites = frequencies._aux.empirical.character_count (datafilter[frequencies._aux.empirical.collect_data.i]);
+             
+             if (frequencies._aux.empirical.collect_data.i) {
+                __f_composite += __f *  frequencies._aux.empirical.collect_data.local_sites;
+             } else {
+                __f_composite = __f *  frequencies._aux.empirical.collect_data.local_sites;
+            
+             }
+             frequencies._aux.empirical.collect_data.site_count += frequencies._aux.empirical.collect_data.local_sites;
+        }            
+        return __f_composite * (1/frequencies._aux.empirical.collect_data.site_count);
+    }
+    
+    return __f;
+}
+
+
 function frequencies._aux.empirical.singlechar (model, namespace, datafilter) {
 	utility.toggleEnvVariable ("COUNT_GAPS_IN_FREQUENCIES", 0);
-	HarvestFrequencies (__f, *datafilter, 1,1,1);
+	__f = frequencies._aux.empirical.collect_data (datafilter, 1,1,1);
 	utility.toggleEnvVariable ("COUNT_GAPS_IN_FREQUENCIES", None);
 	model[terms.efv_estimate] = __f;
 	return model;
diff --git a/res/TemplateBatchFiles/lib2014/models/model_functions.bf b/res/TemplateBatchFiles/lib2014/models/model_functions.bf
index 1480c2f..4f22871 100644
--- a/res/TemplateBatchFiles/lib2014/models/model_functions.bf
+++ b/res/TemplateBatchFiles/lib2014/models/model_functions.bf
@@ -80,7 +80,7 @@ function model.generic.define_model (model_spec, id, arguments, data_filter, est
 		
 	utility.callFunction (model.generic.define_model.model ["frequency-estimator"], {"0": "model.generic.define_model.model", 
 													    "1":  parameters.quote(id),
-													    "2":   parameters.quote(data_filter)}); // this sets the EFV field
+													    "2":  parameters.quote(data_filter)}); // this sets the EFV field
 													    
 													  
 													  
@@ -131,10 +131,18 @@ function models.generic.post.definition  (model) {
 //------------------------------------------------------------------------------ 
 
 function models.generic.attachFilter (model, filter) {
+
+    if (Type (filter) == "Matrix") {
+        for (models.generic.attachFilter.i = utility.array1D (filter) - 1; models.generic.attachFilter.i >= 0; models.generic.attachFilter.i = models.generic.attachFilter.i - 1) {
+            models.generic.attachFilter (model, filter[models.generic.attachFilter.i]);
+        }
+        model["data"] = filter;
+        return model;
+    }
+
 	GetDataInfo (_givenAlphabet, *filter, "CHARACTERS");
 	__alphabet = model ["alphabet"];
 
-
 	assert (Columns (__alphabet) == Columns (_givenAlphabet) && model.matchAlphabets (_givenAlphabet, __alphabet), "The declared model alphabet '" + __alphabet + "' does not match the `filter` filter: '" + _givenAlphabet + "'");
 	
 	model ["alphabet"] = _givenAlphabet;
diff --git a/res/TemplateBatchFiles/lib2014/models/parameters.bf b/res/TemplateBatchFiles/lib2014/models/parameters.bf
index 871b0c3..9e111ff 100644
--- a/res/TemplateBatchFiles/lib2014/models/parameters.bf
+++ b/res/TemplateBatchFiles/lib2014/models/parameters.bf
@@ -72,14 +72,18 @@ function parameters.set_value (id, value) {
 
 lfunction parameters.mean (values, weights, d) {
     m = 0;
-    for (i = 0; i < 3; i+=1) {
+    d = Rows  (values)*Columns (values);
+    for (i = 0; i < d; i+=1) {
         m += Eval (values[i]) * Eval(weights[i]);
     }
     return m;
 }
 
 function parameters.quote (arg) {
-	return "\"" + arg + "\"";
+    if (Type (arg) == "String") {
+	    return "\"" + arg + "\"";
+    } 
+    return arg;
 }
 
 lfunction parameters.addMultiplicativeTerm (matrix, term, do_empties) {
@@ -105,6 +109,7 @@ lfunction parameters.addMultiplicativeTerm (matrix, term, do_empties) {
 	return matrix;
 }
 
+
 function parameters.stringMatrixToFormulas (id, matrix) {
 	__N = Rows (matrix);
 	
diff --git a/res/TemplateBatchFiles/lib2014/models/rate_variation.bf b/res/TemplateBatchFiles/lib2014/models/rate_variation.bf
new file mode 100644
index 0000000..8162bc3
--- /dev/null
+++ b/res/TemplateBatchFiles/lib2014/models/rate_variation.bf
@@ -0,0 +1,98 @@
+LoadFunctionLibrary ("parameters.bf");
+
+rate_variation.types = {
+    "Gamma+I": "rate_variation.types.gamma_i"
+};
+
+function rate_variation.add (model, specs) {
+
+    rate_variation.add.spec = rate_variation.types [specs["type"]];
+    assert (Type (rate_variation.add.spec) == "String", 
+            "Unsupported rate variation type '`type`' in call to rate_variation. Use one of " + Rows (rate_variation.types));
+            
+    model  [terms.rate_variation.bins] = specs["bins"];  
+    model ["original q call-back"]    = model["defineQ"];     
+    model ["defineQ"] =  rate_variation.add.spec;
+    return model;
+}
+
+function rate_variation.multiply_in (matrix, variable) {
+    
+}
+
+
+
+function  rate_variation.types.gamma_i (model, namespace) {
+    
+    __global_cache = {};
+	
+	
+	
+	rate_variation.types.gamma_i.alpha = parameters.applyNameSpace ("alpha", namespace);
+	parameters.declareGlobal (rate_variation.types.gamma_i.alpha, __global_cache);
+    
+    rate_variation.types.gamma_i.range = {};
+    rate_variation.types.gamma_i.range [terms.lower_bound] = 0.001;
+    rate_variation.types.gamma_i.range [terms.upper_bound] = 100;
+    
+	parameters.setRange (rate_variation.types.gamma_i.alpha, 
+                         rate_variation.types.gamma_i.range);
+
+
+	rate_variation.types.gamma_i.inv_p = parameters.applyNameSpace ("inv_p", namespace);
+	parameters.declareGlobal (rate_variation.types.gamma_i.inv_p, __global_cache);
+	
+	parameters.set_value (rate_variation.types.gamma_i.inv_p, 0.1);
+	
+	parameters.setRange (rate_variation.types.gamma_i.inv_p, terms.range01);
+
+	rate_variation.types.gamma_i.beta = parameters.applyNameSpace ("beta", namespace);
+    parameters.setConstraint (rate_variation.types.gamma_i.beta, 
+                                "(1-`rate_variation.types.gamma_i.inv_p`)*`rate_variation.types.gamma_i.alpha`", 
+                                "global");
+
+    rate_variation.types.gamma_i.range [terms.upper_bound] = 200;
+	parameters.setRange (rate_variation.types.gamma_i.beta, 
+                         rate_variation.types.gamma_i.range);
+	
+	((model["parameters"])["global"])[terms.rate_variation.gamma_alpha] = rate_variation.types.gamma_i.alpha;
+	((model["parameters"])["global"])[terms.rate_variation.gamma_beta] = rate_variation.types.gamma_i.beta;
+	((model["parameters"])["global"])[terms.rate_variation.gamma_p_inv] = rate_variation.types.gamma_i.inv_p;
+	
+	rate_variation.types.gamma_i.bins = 0 + model [terms.rate_variation.bins];
+	
+	
+	rate_variation.types.gamma_i.main = parameters.applyNameSpace ("gamma_i", namespace);
+	rate_variation.types.gamma_i.cats = parameters.applyNameSpace ("gamma_i.freqs", namespace);
+	
+	ExecuteCommands (rate_variation.types.gamma_i.cats + " = {1 + rate_variation.types.gamma_i.bins, 1}");
+    ExecuteCommands (rate_variation.types.gamma_i.cats + "[0] := `rate_variation.types.gamma_i.inv_p`");
+    	
+	for (rate_variation.types.gamma_i.i=1; rate_variation.types.gamma_i.i<=rate_variation.types.gamma_i.bins;rate_variation.types.gamma_i.i += 1){
+        ExecuteCommands (rate_variation.types.gamma_i.cats + 
+            "[rate_variation.types.gamma_i.i] := (1-`rate_variation.types.gamma_i.inv_p`)/" + 
+            rate_variation.types.gamma_i.bins);
+            
+    }
+    	
+	
+	ExecuteCommands ("category `rate_variation.types.gamma_i.main` = (" +
+	                (1+rate_variation.types.gamma_i.bins) + "," + 
+	                (rate_variation.types.gamma_i.cats) + 
+	                ",MEAN, 
+					(1-`rate_variation.types.gamma_i.inv_p`)*GammaDist(_x_,`rate_variation.types.gamma_i.alpha`,`rate_variation.types.gamma_i.beta`)*(_x_>0), 
+					(1-`rate_variation.types.gamma_i.inv_p`)*CGammaDist(_x_,`rate_variation.types.gamma_i.alpha`,`rate_variation.types.gamma_i.beta`)*(_x_>0)+`rate_variation.types.gamma_i.inv_p`, 
+					0, 
+			  	    1e25,
+			  	    (1-`rate_variation.types.gamma_i.inv_p`)*CGammaDist(_x_,`rate_variation.types.gamma_i.alpha`+1,`rate_variation.types.gamma_i.beta`)*(`rate_variation.types.gamma_i.alpha`/`rate_variation.types.gamma_i.beta`)*(_x_>0)
+			  	 )");
+			  	 
+     ExecuteCommands ("GetInformation (info, `rate_variation.types.gamma_i.main`)");
+			  	 
+     rate_variation.types.gamma_i.q = utility.callFunction (model["original q call-back"],   
+                                                           {"0" : model,
+                                                            "1" : parameters.quote (namespace)});
+       
+     rate_variation.types.gamma_i.q [terms.rate_matrix] = parameters.addMultiplicativeTerm (rate_variation.types.gamma_i.q[terms.rate_matrix], rate_variation.types.gamma_i.main, 0);
+     return rate_variation.types.gamma_i.q;                                               
+}
\ No newline at end of file
diff --git a/res/TemplateBatchFiles/lib2014/models/terms.bf b/res/TemplateBatchFiles/lib2014/models/terms.bf
index da5c7ba..efa93b6 100644
--- a/res/TemplateBatchFiles/lib2014/models/terms.bf
+++ b/res/TemplateBatchFiles/lib2014/models/terms.bf
@@ -27,6 +27,11 @@ terms.lf.global.constrained = "Global Constrained";
 terms.synonymous_rate    = "synonymous rate";
 terms.nonsynonymous_rate = "non-synonymous rate";
 terms.omega_ratio        = "non-synonymous/synonymous rate ratio";
+
+terms.rate_variation.bins = "Rate variation bins";
+terms.rate_variation.gamma_alpha = "Shape parameter for the gamma distribution (alpha)";
+terms.rate_variation.gamma_beta  = "Shape parameter for the gamma distribution (beta)";
+terms.rate_variation.gamma_p_inv  = "Estimated proportion of invariant sites";
  
 function  terms.nucleotideRate (fromC, toC) {
 	return "Substitution rate from nucleotide " + fromC + " to nucleotide " + toC;
diff --git a/res/TemplateBatchFiles/lib2014/tasks/estimators.bf b/res/TemplateBatchFiles/lib2014/tasks/estimators.bf
index 81d8e72..454cd07 100644
--- a/res/TemplateBatchFiles/lib2014/tasks/estimators.bf
+++ b/res/TemplateBatchFiles/lib2014/tasks/estimators.bf
@@ -2,6 +2,7 @@ LoadFunctionLibrary ("../models/model_functions.bf");
 LoadFunctionLibrary ("../models/terms.bf");
 LoadFunctionLibrary ("../models/DNA/GTR.bf");
 
+
 function estimators.copyGlobals2 (key, value) {
     (estimators.extractMLEs.results ["global"])[key] = {"ID" : value, "MLE" : Eval (value)};
 }
@@ -60,16 +61,31 @@ function estimators.fixSubsetOfEstimates (estimates, variables) {
     (estimates["global"])["estimators.fixSubsetOfEstimates.helper"]["estimators.fixSubsetOfEstimates.helper_condition"];
 }
 
+function estimators.branch_lengths_in_string.map (id, value) {
+    estimators.branch_lengths_in_string.lookup [id] = value["MLE"];
+}
+
+function estimators.branch_lengths_in_string (tree_id, lookup) {
+    estimators.branch_lengths_in_string.lookup = {};
+    lookup["estimators.branch_lengths_in_string.map"][""];
+    utility.toggleEnvVariable ("BRANCH_LENGTH_STENCIL", estimators.branch_lengths_in_string.lookup);
+    estimators.branch_lengths_in_string.string = Eval ("Format (`tree_id`,1,1)");
+    utility.toggleEnvVariable ("BRANCH_LENGTH_STENCIL", None);
+    return estimators.branch_lengths_in_string.string;
+}
+
+
 function estimators.extractMLEs (likelihood_function_id, model_descriptions) {
     ExecuteCommands ("GetString (estimators.extractMLEs.lfInfo, `likelihood_function_id`,-1)");  
     estimators.extractMLEs.results = {};
-    estimators.extractMLEs.partitions = Rows (estimators.extractMLEs.lfInfo["Trees"]);
+    estimators.extractMLEs.partitions = utility.array1D (estimators.extractMLEs.lfInfo["Trees"]);
    
     // copy global variables first 
     
     estimators.extractMLEs.results ["global"] = {};
     model_descriptions ["estimators.copyGlobals"][""];
     estimators.extractMLEs.results ["branch lengths"] = {};
+    estimators.extractMLEs.results ["Trees"] = estimators.extractMLEs.lfInfo["Trees"];
     
     for (estimators.extractMLEs.i = 0; estimators.extractMLEs.i < estimators.extractMLEs.partitions; estimators.extractMLEs.i  += 1) {
         _tree_name = (estimators.extractMLEs.lfInfo["Trees"])[estimators.extractMLEs.i];
@@ -83,6 +99,10 @@ function estimators.extractMLEs (likelihood_function_id, model_descriptions) {
             ((estimators.extractMLEs.results ["branch lengths"])[estimators.extractMLEs.i])[_branch_name] = 
                 estimators.extractBranchInformation (_tree_name, _branch_name, model_descriptions[estimators.extractMLEs.map[_branch_name]]);
         }   
+        
+        (estimators.extractMLEs.results ["Trees"])[estimators.extractMLEs.i] = 
+            estimators.branch_lengths_in_string ( (estimators.extractMLEs.results ["Trees"])[estimators.extractMLEs.i], 
+                                                (estimators.extractMLEs.results ["branch lengths"])[estimators.extractMLEs.i]);
     }   
     
     return estimators.extractMLEs.results;
@@ -120,6 +140,62 @@ function estimators.applyExistingEstimates (likelihood_function_id, model_descri
     }   
 }
 
+function estimators._aux.countEmpiricalParameters (id, model) {
+    estimators._aux.parameter_counter += (model["parameters"])["empirical"];
+} 
+
+function estimators.fitLF (data_filters_list, tree_list, model_map, initial_values) {
+    estimators.fitLF.component_count = utility.array1D (data_filters_list);
+    
+    assert (estimators.fitLF.component_count == utility.array1D (tree_list), 
+                "Data filters and tree lists must have the same dimensions in call to estimators.fitLF");
+                
+    
+    estimators.fitLF.components = {estimators.fitLF.component_count,2};
+    
+    for (estimators.fitLF.i = 0; estimators.fitLF.i < estimators.fitLF.component_count; estimators.fitLF.i += 1) {
+        estimators.fitLF.components [estimators.fitLF.i][0] = data_filters_list[estimators.fitLF.i];
+        estimators.fitLF.components [estimators.fitLF.i][1] = tree_list[estimators.fitLF.i];
+    }
+    
+    LikelihoodFunction estimators.fitLF.likelihoodFunction = (estimators.fitLF.components);
+
+    if (Type (initial_values) == "AssociativeList") {
+        utility.toggleEnvVariable ("USE_LAST_RESULTS", 1);
+        estimators.applyExistingEstimates ("estimators.fitLF.likelihoodFunction", model_map, initial_values);
+    }
+    
+    /*Export (boom, estimators.fitLF.likelihoodFunction);
+    fprintf (stdout, boom, "\n");
+    assert (0);*/
+    Optimize (estimators.fitLF.mles, estimators.fitLF.likelihoodFunction);
+    if (Type (initial_values) == "AssociativeList") {
+        utility.toggleEnvVariable ("USE_LAST_RESULTS", None);
+    }
+    
+
+
+    estimators.fitLF.results = estimators.extractMLEs ("estimators.fitLF.likelihoodFunction", model_map);
+    
+    estimators._aux.parameter_counter = 0;
+    model_map ["estimators._aux.countEmpiricalParameters"][""];
+    
+    estimators.fitLF.results["LogL"]         = estimators.fitLF.mles[1][0];
+    estimators.fitLF.results["parameters"]   = estimators.fitLF.mles[1][1] + estimators._aux.parameter_counter;
+    estimators.fitLF.results["Filters"]      = {1,estimators.fitLF.component_count};
+    
+    for (estimators.fitLF.i = 0; estimators.fitLF.i < estimators.fitLF.component_count; estimators.fitLF.i += 1) {
+       (estimators.fitLF.results["Filters"])[estimators.fitLF.i] = data_filters_list[estimators.fitLF.i];
+       //(estimators.fitLF.results["Trees"])[estimators.fitLF.i]   = Eval ("Format("+tree_list[estimators.fitLF.i]+",1,1)");
+    }
+
+
+    DeleteObject (estimators.fitLF.likelihoodFunction);
+    
+    return estimators.fitLF.results;
+
+    return ;
+}
 
 function estimators.fitGTR  (data_filter, tree, initial_values) {
 	// create a nucleotide filter first
diff --git a/src/core/_hyExecutionContext.cpp b/src/core/_hyExecutionContext.cpp
index 86a72c2..dab2c37 100644
--- a/src/core/_hyExecutionContext.cpp
+++ b/src/core/_hyExecutionContext.cpp
@@ -1,31 +1,41 @@
 /*
-
-HyPhy - Hypothesis Testing Using Phylogenies.
-
-Copyright (C) 1997-2009
-  Sergei L Kosakovsky Pond (spond at ucsd.edu)
-  Art FY Poon              (apoon at cfenet.ubc.ca)
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include "_hyExecutionContext.h"
 #include "variablecontainer.h"
diff --git a/src/core/alignment.cpp b/src/core/alignment.cpp
index 0bd60fa..0c0e161 100644
--- a/src/core/alignment.cpp
+++ b/src/core/alignment.cpp
@@ -1,3 +1,41 @@
+/*
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include <cctype>
 #include <cstring>
diff --git a/src/core/avllist.cpp b/src/core/avllist.cpp
index f8bebd1..42c752b 100644
--- a/src/core/avllist.cpp
+++ b/src/core/avllist.cpp
@@ -1,34 +1,41 @@
 /*
-
-HyPhy - Hypothesis Testing Using Phylogenies.
-
-Copyright (C) 1997-2009
-  Sergei L Kosakovsky Pond (spond at ucsd.edu)
-  Art FY Poon              (apoon at cfenet.ubc.ca)
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-_AVLList    structure inspired by the excellent documentation of
-GNU libavl 2.0.1 by Ben Pfaff (http://www.msu.edu/~pfaffben/avl/index.html)
-
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include "avllist.h"
 #include "hy_strings.h"
diff --git a/src/core/avllistx.cpp b/src/core/avllistx.cpp
index a686a75..93d09ee 100644
--- a/src/core/avllistx.cpp
+++ b/src/core/avllistx.cpp
@@ -1,34 +1,41 @@
 /*
-
-HyPhy - Hypothesis Testing Using Phylogenies.
-
-Copyright (C) 1997-2009
-  Sergei L Kosakovsky Pond (spond at ucsd.edu)
-  Art FY Poon              (apoon at cfenet.ubc.ca)
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-_AVLList    structure inspired by the excellent documentation of
-GNU libavl 2.0.1 by Ben Pfaff (http://www.msu.edu/~pfaffben/avl/index.html)
-
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include "avllistx.h"
 #include "hy_strings.h"
diff --git a/src/core/avllistxl.cpp b/src/core/avllistxl.cpp
index d9224bc..89082a8 100644
--- a/src/core/avllistxl.cpp
+++ b/src/core/avllistxl.cpp
@@ -1,34 +1,41 @@
 /*
-
-HyPhy - Hypothesis Testing Using Phylogenies.
-
-Copyright (C) 1997-2009
-  Sergei L Kosakovsky Pond (spond at ucsd.edu)
-  Art FY Poon              (apoon at cfenet.ubc.ca)
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-_AVLList    structure inspired by the excellent documentation of
-GNU libavl 2.0.1 by Ben Pfaff (http://www.msu.edu/~pfaffben/avl/index.html)
-
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include "hy_strings.h"
 #include "errorfns.h"
diff --git a/src/core/baseobj.cpp b/src/core/baseobj.cpp
index 298274a..ded448f 100644
--- a/src/core/baseobj.cpp
+++ b/src/core/baseobj.cpp
@@ -1,36 +1,41 @@
 /*
-
-HyPhy - Hypothesis Testing Using Phylogenies.
-
-Copyright (C) 1997-2007
-
-Primary Development:
-  Sergei L Kosakovsky Pond (sergeilkp at mac.com)
-Significant contributions from:
-  Spencer V Muse (muse at stat.ncsu.edu)
-  Simon DW Frost (sdfrost at ucsd.edu)
-  Art FY Poon    (apoon at biomail.ucsd.edu)
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include "baseobj.h"
 #include "errorfns.h"
diff --git a/src/core/batchlan.cpp b/src/core/batchlan.cpp
index 6036b82..8df86ba 100644
--- a/src/core/batchlan.cpp
+++ b/src/core/batchlan.cpp
@@ -44,8 +44,6 @@
 #include "polynoml.h"
 #include "time.h"
 #include "scfg.h"
-#include "HYNetInterface.h"
-
 #include "bayesgraph.h"
 
 
@@ -1499,7 +1497,6 @@ _String  blFor                  ("for("),               // moved
          blDeleteObject         ("DeleteObject("),
          blRequireVersion           ("RequireVersion("),
          blSCFG                     ("SCFG "),
-         blNN                       ("NeuralNet "),
          blBGM                      ("BayesianGraphicalModel "),
          blSimulateDataSet          ("SimulateDataSet"),
          blAssert                   ("assert(");
@@ -1728,8 +1725,6 @@ bool        _ExecutionList::BuildList   (_String& s, _SimpleList* bc, bool proce
                 _ElementaryCommand::ConstructProfileStatement (currentLine, *this);
             } else if (currentLine.startswith (blSCFG)) { // SCFG definition
                 _ElementaryCommand::ConstructSCFG (currentLine, *this);
-            } else if (currentLine.startswith (blNN)) { // Neural Net definition
-                _ElementaryCommand::ConstructNN (currentLine, *this);
             } else if (currentLine.startswith (blBGM)) {    // Bayesian Graphical Model definition
                 _ElementaryCommand::ConstructBGM (currentLine, *this);
             } 
@@ -2447,10 +2442,9 @@ BaseRef   _ElementaryCommand::toStr      (void)
         result = blRequireVersion & '(' & *converted & ')';
         break;
     }
-    case 61:
-    case 63: {
+    case 61: {
         converted = (_String*)parameters(0)->toStr();
-        result = (code==61?blSCFG:blNN) & *converted & "=(";
+        result = blSCFG & *converted & "=(";
         for (long i=1; i<parameters.lLength; i++) {
             DeleteObject(converted);
             converted = (_String*)parameters(i)->toStr();
@@ -3995,18 +3989,12 @@ void      _ElementaryCommand::ExecuteCase31 (_ExecutionList& chain)
 
     if (parameters.lLength>3) {
         parameterName = (_String*)parameters.lData[3];
-        if (parameterName->Equal(&ModelTrainNNFlag)) {
-            _String arg1 = chain.AddNameSpaceToID(*(_String*)parameters(1));
-            TrainModelNN (&arg0,&arg1);
-            return;
-        } else
-
-            if (parameterName->Equal(&explicitFormMExp)) {
-                doExpressionBased = true;
-                multFreqs         = 0;
-            } else {
-                multFreqs = ProcessNumericArgument (parameterName,chain.nameSpacePrefix);
-            }
+        if (parameterName->Equal(&explicitFormMExp)) {
+            doExpressionBased = true;
+            multFreqs         = 0;
+        } else {
+            multFreqs = ProcessNumericArgument (parameterName,chain.nameSpacePrefix);
+        }
     }
 
     _Matrix*  checkMatrix = nil;
diff --git a/src/core/batchlan2.cpp b/src/core/batchlan2.cpp
index ec370d6..d641e26 100644
--- a/src/core/batchlan2.cpp
+++ b/src/core/batchlan2.cpp
@@ -2079,40 +2079,6 @@ bool    _ElementaryCommand::ConstructSCFG (_String&source, _ExecutionList&target
 }
 
 //____________________________________________________________________________________
-bool    _ElementaryCommand::ConstructNN (_String&source, _ExecutionList&target)
-// syntax: NeuralNet ident = (InMatrix,OutMatrix,HiddenNodes)
-{
-
-    long    mark1 = source.FirstSpaceIndex(0,-1,1),
-            mark2 = source.Find ('=', mark1, -1);
-
-    _String nnID (source, mark1+1,mark2-1);
-
-    if (mark1==-1 || mark2==-1 || mark1+1>mark2-1 || !nnID.IsValidIdentifier(true)) {
-        WarnError ("NeutalNet declaration missing a valid identifier");
-        return false;
-    }
-
-
-    _List pieces;
-
-    mark1 = source.Find ('(',mark2,-1);
-    if (mark1 >= 0) {
-        ExtractConditions (source,mark1+1,pieces,',');
-    }
-
-    if (pieces.lLength != 3) {
-        WarnError ("NeuralNet ident = (InMatrix,OutMatrix,HiddenNodes)");
-        return false;
-    }
-
-    _ElementaryCommand * nn = new _ElementaryCommand (63);
-    nn->parameters  && (&nnID);
-    nn->addAndClean(target,&pieces,0);
-    return true;
-}
-
-//____________________________________________________________________________________
 bool    _ElementaryCommand::ConstructBGM (_String&source, _ExecutionList&target)
 // syntax: BGM ident = (<nodes>)
 {
diff --git a/src/core/calcnode.cpp b/src/core/calcnode.cpp
index 5789953..1359dbf 100644
--- a/src/core/calcnode.cpp
+++ b/src/core/calcnode.cpp
@@ -1,31 +1,41 @@
 /*
-
-HyPhy - Hypothesis Testing Using Phylogenies.
-
-Copyright (C) 1997-2009
-  Sergei L Kosakovsky Pond (spond at ucsd.edu)
-  Art FY Poon              (apoon at cfenet.ubc.ca)
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include "math.h"
 #include "ctype.h"
@@ -487,13 +497,26 @@ _Parameter  _CalcNode::BranchLength (void)
     if (theModel < 0) {
         return Value();
     }
+  
+    {
+      _FString   *stencil = (_FString*)FetchObjectFromVariableByType (&BRANCH_LENGTH_STENCIL,STRING);
 
-    _FString   *stencil = (_FString*)FetchObjectFromVariableByType (&BRANCH_LENGTH_STENCIL,STRING);
-
-    if (stencil && stencil->theString->Equal (&stringSuppliedLengths)) {
-        return Value();
+      if (stencil && stencil->theString->Equal (&stringSuppliedLengths)) {
+          return Value();
+      }
+    }
+    {
+      _AssociativeList *lookup = (_AssociativeList*)FetchObjectFromVariableByType (&BRANCH_LENGTH_STENCIL,ASSOCIATIVE_LIST);
+      if (lookup) {
+        _String lookup_name = ContextFreeName();
+        _Constant * value = (_Constant*)lookup->GetByKey (lookup_name, NUMBER);
+        if (value) {
+          return value->Value();
+        }
+      }
     }
 
+  
 
     _Matrix     *freqMx,
                 *theMx;
diff --git a/src/core/calcnode2.cpp b/src/core/calcnode2.cpp
index f06d8a6..70d1546 100644
--- a/src/core/calcnode2.cpp
+++ b/src/core/calcnode2.cpp
@@ -994,18 +994,20 @@ _Parameter      _TheTree::ComputeTreeBlockByBranch  (                   _SimpleL
     // assemble the entire likelihood
 
     _Parameter _hprestrict_ * rootConditionals = iNodeCache + alphabetDimension * (siteFrom + (flatTree.lLength-1)  * siteCount);
-    _Parameter                result = 0.0;
+    _Parameter                result = 0.0,
+                              correction = 0.0;
 
 
-    for (long siteID = siteFrom; siteID < siteTo; siteID++) {
+    for (long siteID = siteFrom, rootIndex = 0L; siteID < siteTo; siteID++) {
         _Parameter accumulator = 0.;
+      
         if (setBranch == flatTree.lLength-1) {
             long                rootState = setBranchTo[siteOrdering.lData[siteID]];
-            accumulator      += rootConditionals[rootState] * theProbs[rootState];
-            rootConditionals += alphabetDimension;
+            accumulator         = rootConditionals[rootIndex + rootState] * theProbs[rootState];
+            rootIndex           += alphabetDimension;
         } else
-            for (long p = 0; p < alphabetDimension; p++,rootConditionals++) {
-                accumulator += *rootConditionals * theProbs[p];
+            for (long p = 0; p < alphabetDimension; p++,rootIndex++) {
+                accumulator += rootConditionals[rootIndex] * theProbs[p];
             }
 
         /*#pragma omp critical
@@ -1031,11 +1033,21 @@ _Parameter      _TheTree::ComputeTreeBlockByBranch  (                   _SimpleL
                 }
                 break;
             }
+          
+            _Parameter term,
+                       temp_sum;
+          
             if (theFilter->theFrequencies [siteOrdering.lData[siteID]] > 1) {
-                result += log(accumulator) * theFilter->theFrequencies [siteOrdering.lData[siteID]];
+                term = log(accumulator) * theFilter->theFrequencies [siteOrdering.lData[siteID]];
             } else {
-                result += log(accumulator);
+                term = log(accumulator);
             }
+          // Kahan sum
+            term     -= correction;
+            temp_sum = result + term;
+            correction = (temp_sum - result) - term;
+            result = temp_sum;
+          
         }
     }
 
@@ -1481,7 +1493,8 @@ _Parameter          _TheTree::ComputeLLWithBranchCache (
 
     _Parameter _hprestrict_ *branchConditionals = cache              + siteFrom * alphabetDimension;
     _Parameter _hprestrict_ *rootConditionals   = branchConditionals + siteCount * alphabetDimension;
-    _Parameter  result = 0.0;
+    _Parameter  result = 0.0,
+                correction = 0.0;
 
 
     //printf ("ComputeLLWithBranchCache @ %d catID = %d branchID = %d\n", likeFuncEvalCallCount, catID, brID);
@@ -1531,11 +1544,16 @@ _Parameter          _TheTree::ComputeLLWithBranchCache (
                 }
                 break;
             }
+            _Parameter term;
             if (theFilter->theFrequencies [siteOrdering.lData[siteID]] > 1) {
-                result += log(accumulator) * theFilter->theFrequencies [siteOrdering.lData[siteID]];
+                term = log(accumulator) * theFilter->theFrequencies [siteOrdering.lData[siteID]] - correction;
             } else {
-                result += log(accumulator);
+                term = log(accumulator) - correction;
             }
+            _Parameter temp_sum = result + term;
+            correction = (temp_sum - result) - term;
+            result = temp_sum;
+          
             //result += log(accumulator) * theFilter->theFrequencies [siteOrdering.lData[siteID]];
         }
     }
diff --git a/src/core/category.cpp b/src/core/category.cpp
index b8260d0..369b7c6 100644
--- a/src/core/category.cpp
+++ b/src/core/category.cpp
@@ -1,31 +1,41 @@
 /*
-
-HyPhy - Hypothesis Testing Using Phylogenies.
-
-Copyright (C) 1997-2009
-  Sergei L Kosakovsky Pond (spond at ucsd.edu)
-  Art FY Poon              (apoon at cfenet.ubc.ca)
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include  "category.h"
 #include  "math.h"
diff --git a/src/core/error.cpp b/src/core/error.cpp
index 3eba078..f719d80 100644
--- a/src/core/error.cpp
+++ b/src/core/error.cpp
@@ -1,31 +1,41 @@
 /*
-
-HyPhy - Hypothesis Testing Using Phylogenies.
-
-Copyright (C) 1997-2009
-  Sergei L Kosakovsky Pond (spond at ucsd.edu)
-  Art FY Poon              (apoon at cfenet.ubc.ca)
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/src/core/formula.cpp b/src/core/formula.cpp
index 9f1f22c..3d86036 100644
--- a/src/core/formula.cpp
+++ b/src/core/formula.cpp
@@ -1,9 +1,47 @@
+/*
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
+
 #include <math.h>
 #include <float.h>
 #include "defines.h"
 #include "formula.h"
 
-//SW: This should be helper functions
 #include "parser.h"
 
 //Constants
diff --git a/src/core/include/alignment.h b/src/core/include/alignment.h
index 55095e6..5542c21 100644
--- a/src/core/include/alignment.h
+++ b/src/core/include/alignment.h
@@ -1,3 +1,41 @@
+/*
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include "baseobj.h"
 #include "likefunc.h"
diff --git a/src/core/include/batchlan.h b/src/core/include/batchlan.h
index b157491..2e187d8 100644
--- a/src/core/include/batchlan.h
+++ b/src/core/include/batchlan.h
@@ -365,8 +365,6 @@ public:
 
     static  bool      ConstructSCFG         (_String&, _ExecutionList&);
 
-    static  bool      ConstructNN           (_String&, _ExecutionList&);
-
     static  bool      ConstructBGM          (_String&, _ExecutionList&);
 
     static  bool      ConstructAssert       (_String&, _ExecutionList&);
diff --git a/src/core/include/mypthread.h b/src/core/include/mypthread.h
index 9f0b143..9b47954 100644
--- a/src/core/include/mypthread.h
+++ b/src/core/include/mypthread.h
@@ -1 +1 @@
-/*
 
 HyPhy - Hypothesis Testing Using Phylogenies.
 
 Copyright (C) 1997-now
 Core Developers:
 Sergei L Kosakovsky Pond (spond at ucsd.edu)
 Art FY Poon    (apoon at cfenet.ubc.ca)
 Steven Weaver (sweaver at ucsd.edu)
 
 Module Developers:
 Lance Hepler (nlhepler at gmail.com)
 Martin Smith (martin.audacis at gmail.com)
 
 Significant contributions from:
 Spencer V Muse (muse at stat.ncsu.edu)
 Simon DW Frost (sdf22 at cam.ac.uk)
 
 Permission is hereby granted, free of charge, to any person obtaining a
 copy of this software and associated documentation files (the
 "Software"), to deal in the Software without restriction, including
 without limitation the rights to use, copy, modify, merge, publish,
 distribute, sublicense, and/or sell copies of the Software, and to
 permit persons to whom the Software is furnished to do so, subject to
 the following conditions:
 
 The above copyright notice and this permission notice shall be included
 in all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 */
//#define           _BSD_CLOCK_T_DEFINED_
//#define       _BSD_SIZE_T_DEFINED_
//#define           _BSD_SSIZE_T_DEFINED_
//#define           _BSD_TIME_T_DEFINED_
//#undef            __dest_os
//#define       __dest_os __mac_os_x
#include        "time.h"
#include        <pthread.h>
//#undef            __dest_os
//#define       __dest_os __mac_os

#include        "CFBundle.h"
#include        "CFString.h"
#include        "Folders.h"


/*#define            _MAC

#ifndef __POSIX_LIB__

struct _pthread_handler_rec
{
    void           (*routine)(void *);
    void           *arg;                 /
    struct _pthread_handler_rec *next;
};


extern "C"{

#define __PTHREAD_SIZE__           596
#define __PTHREAD_ATTR_SIZE__      36
#define __PTHREAD_MUTEXATTR_SIZE__ 8
#define __PTHREAD_MUTEX_SIZE__     40
#define __PTHREAD_CONDATTR_SIZE__  4
#define __PTHREAD_COND_SIZE__      24
#define __PTHREAD_ONCE_SIZE__      4


typedef struct _opaque_pthread_t { long sig; struct _pthread_handler_rec  *cleanup_stack; char opaque[__PTHREAD_SIZE__];} *pthread_t;

typedef struct _opaque_pthread_attr_t { long sig; char opaque[__PTHREAD_ATTR_SIZE__]; } pthread_attr_t;

typedef struct _opaque_pthread_mutexattr_t { long sig; char opaque[__PTHREAD_MUTEXATTR_SIZE__]; } pthread_mutexattr_t;

typedef struct _opaque_pthread_mutex_t { long sig; char opaque[__PTHREAD_MUTEX_SIZE__]; } pthread_mutex_t;

typedef struct _opaque_pthread_condattr_t { long sig; char opaque[__PTHREAD_CONDATTR_SIZE__]; } pthread_condattr_t;

typedef struct _opaque_pthread_cond_t { long sig;  char opaque[__PTHREAD_COND_SIZE__]; } pthread_cond_t;

typedef struct { long sig; char opaque[__PTHREAD_ONCE_SIZE__]; } pthread_once_t;

#endif

typedef unsigned long pthread_key_t;
}*/




/*extern "C"{
typedef int       (*pthread_join_ptr) (pthread_t thread, void **value_ptr);
typedef int       (*pthread_create_ptr)(pthread_t *thread,
                                         const pthread_attr_t *attr,
                                         void *(*start_routine)(void *),
                                         void *arg);

typedef int       (*pthread_mutex_lock_ptr)   (pthread_mutex_t *mutex);
typedef int       (*pthread_mutex_unlock_ptr) (pthread_mutex_t *mutex);

extern  pthread_join_ptr            pthread_join_p;
extern  pthread_create_ptr          pthread_create_p;
extern  pthread_mutex_lock_ptr      pthread_mutex_lock_p;
extern  pthread_mutex_unlock_ptr    pthread_mutex_unlock_p;
}
*/

typedef void*  (*PThreadHook)      ( void* data );

void    *MachOFunctionPointerForCFMFunctionPointer( void *cfmfp );

void*   ThreadReleafFunctionAA      (void* arg);
void*   ThreadReleafFunctionCodon   (void* arg);
void*   ThreadReleafFunctionNuc     (void* arg);
void*   ThreadReleafFunctionMNuc    (void* arg);
void*   ThreadReleafFunctionMAA     (void* arg);
void*   ThreadReleafFunctionMCodon  (void* arg);
void*   MatrixUpdateFunction        (void* arg);

extern  PThreadHook
ThreadReleafFunctionAAHook,
ThreadReleafFunctionCodonHook,
ThreadReleafFunctionNucHook,
ThreadReleafFunctionMNucHook,
ThreadReleafFunctionMAAHook,
ThreadReleafFunctionMCodonHook,
MatrixUpdateFunctionHook,
StateCounterMPHook;

OSStatus LoadFrameworkBundle(CFStringRef framework, CFBundleRef *bundlePtr);
void    ImportBundle (void);
\ No newline at end of file
+/*
 
 HyPhy - Hypothesis Testing Using Phylogenies.
 
 Copyright (C) 1997-now
 Core Developers:
 Sergei L Kosakovsky Pond (spond at ucsd.edu)
 Art FY Poon    (apoon at cfenet.ubc.ca)
 Steven Weaver (sweaver at ucsd.edu)
 
 Module Developers:
 Lance Hepler (nlhepler at gmail.com)
 Martin Smith (martin.audacis at gmail.com)
 
 Significant contributions from:
 Spencer V Muse (muse at stat.ncsu.edu)
 Simon DW Frost (sdf22 at cam.ac.uk)
 
 Permission is hereby granted, free of charge, to any person obtaining a
 copy of this software and associated documentation files (the
 "Software"), to deal in the Software without restriction, including
 without limitation the rights to use, copy, modify, merge, publish,
 distribute, sublicense, and/or sell copies of the Software, and to
 permit persons to whom the Software is furnished to do so, subject to
 the following conditions:
 
 The above copyright notice and this permission notice shall be included
 in all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 */

//#define           _BSD_CLOCK_T_DEFINED_
//#define       _BSD_SIZE_T_DEFINED_
//#define           _BSD_SSIZE_T_DEFINED_
//#define           _BSD_TIME_T_DEFINED_
//#undef            __dest_os
//#define       __dest_os __mac_os_x
#include        "time.h"
#include        <pthread.h>
//#undef            __dest_os
//#define       __dest_os __mac_os

#include        "CFBundle.h"
#include        "CFString.h"
#include        "Folders.h"


/*#define            _MAC

#ifndef __POSIX_LIB__

struct _pthread_handler_rec
{
    void           (*routine)(void *);
    void           *arg;                 /
    struct _pthread_handler_rec *next;
};


extern "C"{

#define __PTHREAD_SIZE__           596
#define __PTHREAD_ATTR_SIZE__      36
#define __PTHREAD_MUTEXATTR_SIZE__ 8
#define __PTHREAD_MUTEX_SIZE__     40
#define __PTHREAD_CONDATTR_SIZE__  4
#define __PTHREAD_COND_SIZE__      24
#define __PTHREAD_ONCE_SIZE__      4


typedef struct _opaque_pthread_t { long sig; struct _pthread_handler_rec  *cleanup_stack; char opaque[__PTHREAD_SIZE__];} *pthread_t;

typedef struct _opaque_pthread_attr_t { long sig; char opaque[__PTHREAD_ATTR_SIZE__]; } pthread_attr_t;

typedef struct _opaque_pthread_mutexattr_t { long sig; char opaque[__PTHREAD_MUTEXATTR_SIZE__]; } pthread_mutexattr_t;

typedef struct _opaque_pthread_mutex_t { long sig; char opaque[__PTHREAD_MUTEX_SIZE__]; } pthread_mutex_t;

typedef struct _opaque_pthread_condattr_t { long sig; char opaque[__PTHREAD_CONDATTR_SIZE__]; } pthread_condattr_t;

typedef struct _opaque_pthread_cond_t { long sig;  char opaque[__PTHREAD_COND_SIZE__]; } pthread_cond_t;

typedef struct { long sig; char opaque[__PTHREAD_ONCE_SIZE__]; } pthread_once_t;

#endif

typedef unsigned long pthread_key_t;
}*/




/*extern "C"{
typedef int       (*pthread_join_ptr) (pthread_t thread, void **value_ptr);
typedef int       (*pthread_create_ptr)(pthread_t *thread,
                                         const pthread_attr_t *attr,
                                         void *(*start_routine)(void *),
                                         void *arg);

typedef int       (*pthread_mutex_lock_ptr)   (pthread_mutex_t *mutex);
typedef int       (*pthread_mutex_unlock_ptr) (pthread_mutex_t *mutex);

extern  pthread_join_ptr            pthread_join_p;
extern  pthread_create_ptr          pthread_create_p;
extern  pthread_mutex_lock_ptr      pthread_mutex_lock_p;
extern  pthread_mutex_unlock_ptr    pthread_mutex_unlock_p;
}
*/

typedef void*  (*PThreadHook)      ( void* data );

void    *MachOFunctionPointerForCFMFunctionPointer( void *cfmfp );

void*   ThreadReleafFunctionAA      (void* arg);
void*   ThreadReleafFunctionCodon   (void* arg);
void*   ThreadReleafFunctionNuc     (void* arg);
void*   ThreadReleafFunctionMNuc    (void* arg);
void*   ThreadReleafFunctionMAA     (void* arg);
void*   ThreadReleafFunctionMCodon  (void* arg);
void*   MatrixUpdateFunction        (void* arg);

extern  PThreadHook
ThreadReleafFunctionAAHook,
ThreadReleafFunctionCodonHook,
ThreadReleafFunctionNucHook,
ThreadReleafFunctionMNucHook,
ThreadReleafFunctionMAAHook,
ThreadReleafFunctionMCodonHook,
MatrixUpdateFunctionHook,
StateCounterMPHook;

OSStatus LoadFrameworkBundle(CFStringRef framework, CFBundleRef *bundlePtr);
void    ImportBundle (void);
\ No newline at end of file
diff --git a/src/core/likefunc.cpp b/src/core/likefunc.cpp
index 0f1389c..4b6effa 100644
--- a/src/core/likefunc.cpp
+++ b/src/core/likefunc.cpp
@@ -1,31 +1,41 @@
 /*
-
-HyPhy - Hypothesis Testing Using Phylogenies.
-
-Copyright (C) 1997-2009
-  Sergei L Kosakovsky Pond (spond at ucsd.edu)
-  Art FY Poon              (apoon at cfenet.ubc.ca)
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 //#define _UBER_VERBOSE_LF_DEBUG
 
@@ -7805,6 +7815,7 @@ _Parameter  _LikelihoodFunction::ComputeBlock (long index, _Parameter* siteRes,
 
 
             _Parameter sum  = 0.;
+          
             if (doCachedComp >= 3) {
 #ifdef _UBER_VERBOSE_LF_DEBUG
                 fprintf (stderr, "CACHE compute branch %d\n",doCachedComp-3);
@@ -7825,12 +7836,51 @@ _Parameter  _LikelihoodFunction::ComputeBlock (long index, _Parameter* siteRes,
 #ifdef _OPENMP
             np           = MIN(GetThreadCount(),omp_get_max_threads());
 #endif
-            long sitesPerP    = df->NumberDistinctSites() / np + 1;
+            long sitesPerP    = df->NumberDistinctSites() / np + 1L;
 
 #ifdef _UBER_VERBOSE_LF_DEBUG
                 fprintf (stderr, "NORMAL compute lf \n");
 #endif
-
+          
+            _Parameter* thread_results = new _Parameter[np];
+            #pragma omp  parallel for default(shared) schedule(static,1) private(blockID) num_threads (np) if (np>1)
+              for (blockID = 0; blockID < np; blockID ++) {
+                thread_results[blockID] = t->ComputeTreeBlockByBranch (*sl,
+                                                    *branches,
+                                                    tcc,
+                                                    df,
+                                                    inc,
+                                                    conditionalTerminalNodeStateFlag[index],
+                                                    ssf,
+                                                    (_GrowingVector*)conditionalTerminalNodeLikelihoodCaches(index),
+                                                    overallScalingFactors.lData[index],
+                                                    blockID * sitesPerP,
+                                                    (1+blockID) * sitesPerP,
+                                                    catID,
+                                                    siteRes,
+                                                    scc,
+                                                    branchIndex,
+                                                    branchIndex >= 0 ? branchValues->lData: nil);
+              }
+         
+          
+            if (np > 1) {
+              _Parameter correction = 0.;
+              for (blockID = 0; blockID < np; blockID ++)  {
+                thread_results[blockID] -= correction;
+                _Parameter temp_sum = sum +  thread_results[blockID];
+                correction = (temp_sum - sum) - thread_results[blockID];
+                sum = temp_sum;
+              }
+              
+              
+            } else {
+              sum = thread_results[0];
+              
+            }
+          
+            delete [] thread_results;
+            /*
             #pragma omp  parallel for default(shared) schedule(static,1) private(blockID) num_threads (np) reduction(+:sum) if (np>1)
             for (blockID = 0; blockID < np; blockID ++) {
                 sum += t->ComputeTreeBlockByBranch (*sl,
@@ -7849,7 +7899,7 @@ _Parameter  _LikelihoodFunction::ComputeBlock (long index, _Parameter* siteRes,
                                                     scc,
                                                     branchIndex,
                                                     branchIndex >= 0 ? branchValues->lData: nil);
-            }
+            }*/
 
             sum -= _logLFScaler * overallScalingFactors.lData[index];
 
diff --git a/src/core/list.cpp b/src/core/list.cpp
index 901287c..a12407b 100644
--- a/src/core/list.cpp
+++ b/src/core/list.cpp
@@ -1,34 +1,41 @@
 /*
-
-HyPhy - Hypothesis Testing Using Phylogenies.
-
-Copyright (C) 1997-2009
-  Sergei L Kosakovsky Pond (spond at ucsd.edu)
-  Art FY Poon              (apoon at cfenet.ubc.ca)
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-_AVLList    structure inspired by the excellent documentation of
-GNU libavl 2.0.1 by Ben Pfaff (http://www.msu.edu/~pfaffben/avl/index.html)
-
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include "list.h"
 #include "hy_strings.h"
diff --git a/src/core/mathobj.cpp b/src/core/mathobj.cpp
index 5bd2967..62d37d5 100644
--- a/src/core/mathobj.cpp
+++ b/src/core/mathobj.cpp
@@ -1,3 +1,42 @@
+/*
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
+
 #include "parser.h"
 #include "mathobj.h"
 
diff --git a/src/core/matrix.cpp b/src/core/matrix.cpp
index 4f22876..58f4871 100644
--- a/src/core/matrix.cpp
+++ b/src/core/matrix.cpp
@@ -1,31 +1,41 @@
 /*
-
-HyPhy - Hypothesis Testing Using Phylogenies.
-
-Copyright (C) 1997-2009
-  Sergei L Kosakovsky Pond (spond at ucsd.edu)
-  Art FY Poon              (apoon at cfenet.ubc.ca)
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/core/nexus.cpp b/src/core/nexus.cpp
index e342482..e534b22 100644
--- a/src/core/nexus.cpp
+++ b/src/core/nexus.cpp
@@ -1,31 +1,42 @@
 /*
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
-HyPhy - Hypothesis Testing Using Phylogenies.
-
-Copyright (C) 1997-2009
-  Sergei L Kosakovsky Pond (spond at ucsd.edu)
-  Art FY Poon              (apoon at cfenet.ubc.ca)
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
 #include "site.h"
 #include "string.h"
 #include "ctype.h"
diff --git a/src/core/parser.cpp b/src/core/parser.cpp
index a0be2e2..4220155 100644
--- a/src/core/parser.cpp
+++ b/src/core/parser.cpp
@@ -1,31 +1,41 @@
 /*
-
-HyPhy - Hypothesis Testing Using Phylogenies.
-
-Copyright (C) 1997-2009
-  Sergei L Kosakovsky Pond (spond at ucsd.edu)
-  Art FY Poon              (apoon at cfenet.ubc.ca)
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include <math.h>
 #include <float.h>
diff --git a/src/core/parser2.cpp b/src/core/parser2.cpp
index 80b7e6a..bddf230 100644
--- a/src/core/parser2.cpp
+++ b/src/core/parser2.cpp
@@ -1,31 +1,41 @@
 /*
-
-HyPhy - Hypothesis Testing Using Phylogenies.
-
-Copyright (C) 1997-2009
-  Sergei L Kosakovsky Pond (spond at ucsd.edu)
-  Art FY Poon              (apoon at cfenet.ubc.ca)
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include "parser.h"
 #include "matrix.h"
diff --git a/src/core/polynoml.cpp b/src/core/polynoml.cpp
index 236001c..6b70fe1 100644
--- a/src/core/polynoml.cpp
+++ b/src/core/polynoml.cpp
@@ -1,31 +1,41 @@
 /*
-
-HyPhy - Hypothesis Testing Using Phylogenies.
-
-Copyright (C) 1997-2009
-  Sergei L Kosakovsky Pond (spond at ucsd.edu)
-  Art FY Poon              (apoon at cfenet.ubc.ca)
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include "string.h"
 #include "math.h"
diff --git a/src/core/sequence.cpp b/src/core/sequence.cpp
index b4b7b7a..d7cd2a5 100644
--- a/src/core/sequence.cpp
+++ b/src/core/sequence.cpp
@@ -1,31 +1,41 @@
 /*
-
-HyPhy - Hypothesis Testing Using Phylogenies.
-
-Copyright (C) 1997-2009
-  Sergei L Kosakovsky Pond (spond at ucsd.edu)
-  Art FY Poon              (apoon at cfenet.ubc.ca)
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include "sequence.h"
 #include "errorfns.h"
diff --git a/src/core/simplelist.cpp b/src/core/simplelist.cpp
index 39f0da0..d6cccd6 100644
--- a/src/core/simplelist.cpp
+++ b/src/core/simplelist.cpp
@@ -1,33 +1,40 @@
 /*
-
-HyPhy - Hypothesis Testing Using Phylogenies.
-
-Copyright (C) 1997-2009
-  Sergei L Kosakovsky Pond (spond at ucsd.edu)
-  Art FY Poon              (apoon at cfenet.ubc.ca)
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-_AVLList    structure inspired by the excellent documentation of
-GNU libavl 2.0.1 by Ben Pfaff (http://www.msu.edu/~pfaffben/avl/index.html)
-
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
 */
 
 #include "hy_strings.h"
diff --git a/src/core/site.cpp b/src/core/site.cpp
index 37e9bff..31fed3b 100644
--- a/src/core/site.cpp
+++ b/src/core/site.cpp
@@ -1,31 +1,41 @@
 /*
-
-HyPhy - Hypothesis Testing Using Phylogenies.
-
-Copyright (C) 1997-2009
-  Sergei L Kosakovsky Pond (spond at ucsd.edu)
-  Art FY Poon              (apoon at cfenet.ubc.ca)
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include <string.h>
 #include <ctype.h>
diff --git a/src/core/strings.cpp b/src/core/strings.cpp
index 8e5d953..6a24931 100644
--- a/src/core/strings.cpp
+++ b/src/core/strings.cpp
@@ -1,32 +1,41 @@
 /*
-
-HyPhy - Hypothesis Testing Using Phylogenies.
-
-Copyright (C) 1997-2009
-  Sergei L Kosakovsky Pond (spond at ucsd.edu)
-  Art FY Poon              (apoon at cfenet.ubc.ca)
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
-
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include "hy_strings.h"
 
diff --git a/src/gui/Components/HYButton.cpp b/src/gui/Components/HYButton.cpp
index e62f9fc..63dd6c5 100644
--- a/src/gui/Components/HYButton.cpp
+++ b/src/gui/Components/HYButton.cpp
@@ -1 +1 @@
-/*
    Push button component

    Sergei L. Kosakovsky Pond, May 2000 - December 2002.
*/

#include "HYEventTypes.h"
#include "HYButton.h"
#include "HYGraphicPane.h"

#ifdef    __HYPHYDMALLOC__
#include "dmalloc.h"
#endif
//__________________________________________________________________

_HYButton::_HYButton (_HYRect r,Ptr p):_HYComponent (r,p)
{
    backColor.R = backColor.G = backColor.B = 255;
    buttonFont.style = HY_FONT_PLAIN;
#ifndef __HYPHY_GTK__
    buttonFont.size = 12;
    buttonFont.face = "System Font";
#else
    buttonFont.size = 10;
    buttonFont.face = _HY_SANS_FONT;
#endif
    alignFlags = 0;
    buttonKind = 0;
    isEnabled = true;
}

//__________________________________________________________________

_HYButton::~_HYButton()
{
}

//__________________________________________________________________

void        _HYButton::SetBackColor (_HYColor c)
{
    if ((c.R!=backColor.R)||(c.G!=backColor.G)||(c.B!=backColor.B)) {
        backColor = c;
        _SetBackColor (c);
        _MarkForUpdate();
    }
}

//__________________________________________________________________

_HYColor&       _HYButton::GetBackColor (void)
{
    return backColor;
}

//__________________________________________________________________
void            _HYButton::SetText (_String newText)
{
    buttonText = newText;
    _SetText ();
    _MarkForUpdate();
}

//__________________________________________________________________

_String&        _HYButton::GetText (void)
{
    return buttonText;
}

//__________________________________________________________________

_HYFont&        _HYButton::GetFont (void)
{
    return buttonFont;
}

//__________________________________________________________________

void            _HYButton::SetFont (_HYFont&f)
{
    if ((f.face!=buttonFont.face)||(f.size!=buttonFont.size)||(f.style!=buttonFont.style)) {
        _SetFont (f);
        buttonFont.face = f.face;
        buttonFont.size = f.size;
        buttonFont.style = f.style;
        _MarkForUpdate();
    }
}

//__________________________________________________________________
void            _HYButton::SetVisibleSize (_HYRect rel)
{
    _HYComponent::SetVisibleSize (rel);
    _HYPlatformButton::_SetVisibleSize (rel);
}



//__________________________________________________________________

void            _HYButton::EnableButton (bool e)
{
    if (isEnabled!=e) {
        isEnabled = e;
        _EnableButton (e);
    }
}

//__________________________________________________________________

void            _HYButton::SetButtonKind (unsigned char k)
{
    if (buttonKind != k) {
        buttonKind = k;
        _SetButtonKind (k);
    }
}
\ No newline at end of file
+/*
 
 HyPhy - Hypothesis Testing Using Phylogenies.
 
 Copyright (C) 1997-now
 Core Developers:
 Sergei L Kosakovsky Pond (spond at ucsd.edu)
 Art FY Poon    (apoon at cfenet.ubc.ca)
 Steven Weaver (sweaver at ucsd.edu)
 
 Module Developers:
 Lance Hepler (nlhepler at gmail.com)
 Martin Smith (martin.audacis at gmail.com)
 
 Significant contributions from:
 Spencer V Muse (muse at stat.ncsu.edu)
 Simon DW Frost (sdf22 at cam.ac.uk)
 
 Permission is hereby granted, free of charge, to any person obtaining a
 copy of this software and associated documentation files (the
 "Software"), to deal in the Software without restriction, including
 without limitation the rights to use, copy, modify, merge, publish,
 distribute, sublicense, and/or sell copies of the Software, and to
 permit persons to whom the Software is furnished to do so, subject to
 the following conditions:
 
 The above copyright notice and this permission notice shall be included
 in all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 */

#include "HYEventTypes.h"
#include "HYButton.h"
#include "HYGraphicPane.h"

#ifdef    __HYPHYDMALLOC__
#include "dmalloc.h"
#endif
//__________________________________________________________________

_HYButton::_HYButton (_HYRect r,Ptr p):_HYComponent (r,p)
{
    backColor.R = backColor.G = backColor.B = 255;
    buttonFont.style = HY_FONT_PLAIN;
#ifndef __HYPHY_GTK__
    buttonFont.size = 12;
    buttonFont.face = "System Font";
#else
    buttonFont.size = 10;
    buttonFont.face = _HY_SANS_FONT;
#endif
    alignFlags = 0;
    buttonKind = 0;
    isEnabled = true;
}

//__________________________________________________________________

_HYButton::~_HYButton()
{
}

//__________________________________________________________________

void        _HYButton::SetBackColor (_HYColor c)
{
    if ((c.R!=backColor.R)||(c.G!=backColor.G)||(c.B!=backColor.B)) {
        backColor = c;
        _SetBackColor (c);
        _MarkForUpdate();
    }
}

//__________________________________________________________________

_HYColor&       _HYButton::GetBackColor (void)
{
    return backColor;
}

//__________________________________________________________________
void            _HYButton::SetText (_String newText)
{
    buttonText = newText;
    _SetText ();
    _MarkForUpdate();
}

//__________________________________________________________________

_String&        _HYButton::GetText (void)
{
    return buttonText;
}

//__________________________________________________________________

_HYFont&        _HYButton::GetFont (void)
{
    return buttonFont;
}

//__________________________________________________________________

void            _HYButton::SetFont (_HYFont&f)
{
    if ((f.face!=buttonFont.face)||(f.size!=buttonFont.size)||(f.style!=buttonFont.style)) {
        _SetFont (f);
        buttonFont.face = f.face;
        buttonFont.size = f.size;
        buttonFont.style = f.style;
        _MarkForUpdate();
    }
}

//__________________________________________________________________
void            _HYButton::SetVisibleSize (_HYRect rel)
{
    _HYComponent::SetVisibleSize (rel);
    _HYPlatformButton::_SetVisibleSize (rel);
}



//__________________________________________________________________

void            _HYButton::EnableButton (bool e)
{
    if (isEnabled!=e) {
        isEnabled = e;
        _EnableButton (e);
    }
}

//__________________________________________________________________

void            _HYButton::SetButtonKind (unsigned char k)
{
    if (buttonKind != k) {
        buttonKind = k;
        _SetButtonKind (k);
    }
}
\ No newline at end of file
diff --git a/src/gui/Components/HYButtonBar.cpp b/src/gui/Components/HYButtonBar.cpp
index 942f573..41d5db8 100644
--- a/src/gui/Components/HYButtonBar.cpp
+++ b/src/gui/Components/HYButtonBar.cpp
@@ -1,8 +1,41 @@
 /*
-    Iconic button bar (toolbar) component
-
-    Sergei L. Kosakovsky Pond, May 2000 - December 2002.
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include "HYEventTypes.h"
 #include "HYButtonBar.h"
@@ -196,4 +229,4 @@ _HYRect _HYButtonBar::_SuggestDimensions (void)
     res.right =  w*(buttonDim+2*HY_BUTTONBAR_BORDER);
     res.bottom = h*(buttonDim+2*HY_BUTTONBAR_BORDER);
     return res;
-}
\ No newline at end of file
+}
diff --git a/src/gui/Components/HYCheckBox.cpp b/src/gui/Components/HYCheckBox.cpp
index 652532a..f104087 100644
--- a/src/gui/Components/HYCheckBox.cpp
+++ b/src/gui/Components/HYCheckBox.cpp
@@ -1 +1 @@
-/*
    Check box (with an optional label) component

    Sergei L. Kosakovsky Pond, May 2000 - December 2002.
*/

#include "HYEventTypes.h"
#include "HYLabel.h"
#include "HYGraphicPane.h"

#ifdef    __HYPHYDMALLOC__
#include "dmalloc.h"
#endif
//__________________________________________________________________

_HYCheckbox::_HYCheckbox (_HYRect r,Ptr p, bool isR):_HYLabel (r,p), _HYPlatformCheckbox (isR)
{
    checkState   = false;
    isEnabled    = true;
    checkSpacing = 5;
}

//__________________________________________________________________

_HYCheckbox::~_HYCheckbox()
{
}

//__________________________________________________________________

void    _HYCheckbox::SetState(bool ns, bool sendMessage)
{
    if (checkState!=ns) {
        checkState = ns;
        _SetState (ns);
        if (sendMessage&&messageRecipient) {
            messageRecipient->ProcessEvent (generateButtonPushEvent (GetID(), ns));
        }
    }
}

//__________________________________________________________________

void    _HYCheckbox::SetSpacing (long ns)
{
    if (checkSpacing!=ns) {
        checkSpacing = ns;
        SetVisibleSize (rel);
    }
}

//__________________________________________________________________

void    _HYCheckbox::Enable (bool e)
{
    if (isEnabled!=e) {
        isEnabled = e;
        _Enable (e);
    }
}


//__________________________________________________________________
void        _HYCheckbox::SetVisibleSize  (_HYRect rel)
{
    _HYComponent::SetVisibleSize (rel);
    _HYPlatformCheckbox::_SetVisibleSize (rel);
}
\ No newline at end of file
+/*
 
 HyPhy - Hypothesis Testing Using Phylogenies.
 
 Copyright (C) 1997-now
 Core Developers:
 Sergei L Kosakovsky Pond (spond at ucsd.edu)
 Art FY Poon    (apoon at cfenet.ubc.ca)
 Steven Weaver (sweaver at ucsd.edu)
 
 Module Developers:
 Lance Hepler (nlhepler at gmail.com)
 Martin Smith (martin.audacis at gmail.com)
 
 Significant contributions from:
 Spencer V Muse (muse at stat.ncsu.edu)
 Simon DW Frost (sdf22 at cam.ac.uk)
 
 Permission is hereby granted, free of charge, to any person obtaining a
 copy of this software and associated documentation files (the
 "Software"), to deal in the Software without restriction, including
 without limitation the rights to use, copy, modify, merge, publish,
 distribute, sublicense, and/or sell copies of the Software, and to
 permit persons to whom the Software is furnished to do so, subject to
 the following conditions:
 
 The above copyright notice and this permission notice shall be included
 in all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 */

#include "HYEventTypes.h"
#include "HYLabel.h"
#include "HYGraphicPane.h"

#ifdef    __HYPHYDMALLOC__
#include "dmalloc.h"
#endif
//__________________________________________________________________

_HYCheckbox::_HYCheckbox (_HYRect r,Ptr p, bool isR):_HYLabel (r,p), _HYPlatformCheckbox (isR)
{
    checkState   = false;
    isEnabled    = true;
    checkSpacing = 5;
}

//__________________________________________________________________

_HYCheckbox::~_HYCheckbox()
{
}

//__________________________________________________________________

void    _HYCheckbox::SetState(bool ns, bool sendMessage)
{
    if (checkState!=ns) {
        checkState = ns;
        _SetState (ns);
        if (sendMessage&&messageRecipient) {
            messageRecipient->ProcessEvent (generateButtonPushEvent (GetID(), ns));
        }
    }
}

//__________________________________________________________________

void    _HYCheckbox::SetSpacing (long ns)
{
    if (checkSpacing!=ns) {
        checkSpacing = ns;
        SetVisibleSize (rel);
    }
}

//__________________________________________________________________

void    _HYCheckbox::Enable (bool e)
{
    if (isEnabled!=e) {
        isEnabled = e;
        _Enable (e);
    }
}


//__________________________________________________________________
void        _HYCheckbox::SetVisibleSize  (_HYRect rel)
{
    _HYComponent::SetVisibleSize (rel);
    _HYPlatformCheckbox::_SetVisibleSize (rel);
}
\ No newline at end of file
diff --git a/src/gui/Components/HYLabel.cpp b/src/gui/Components/HYLabel.cpp
index b7c259e..b1dba0d 100644
--- a/src/gui/Components/HYLabel.cpp
+++ b/src/gui/Components/HYLabel.cpp
@@ -1 +1 @@
-/*
    Static Label component

    Sergei L. Kosakovsky Pond, May 2000 - November 2001.
*/

#include "HYEventTypes.h"
#include "HYLabel.h"
#include "HYGraphicPane.h"

#ifdef    __HYPHYDMALLOC__
#include "dmalloc.h"
#endif

//__________________________________________________________________

_HYLabel::_HYLabel(_HYRect r,Ptr p):_HYComponent (r,p)
{
    backColor.R = backColor.G = backColor.B = 255;
    foreColor.R = foreColor.G = foreColor.B = 0;
    labelFont.size = 9;
    labelFont.style = HY_FONT_PLAIN;
    labelFont.face = "Monaco";
    alignFlags = 0;
    visFlags = 0;
}

//__________________________________________________________________

_HYLabel::~_HYLabel()
{
}

//__________________________________________________________________
void        _HYLabel::SetBackColor (_HYColor c)
{
    if ((c.R!=backColor.R)||(c.G!=backColor.G)||(c.B!=backColor.B)) {
        backColor = c;
        _SetBackColor (c);
        _MarkForUpdate();
    }
}


//__________________________________________________________________

_HYColor&       _HYLabel::GetBackColor (void)
{
    return backColor;
}

//__________________________________________________________________
void        _HYLabel::SetForeColor (_HYColor c)
{
    if ((c.R!=foreColor.R)||(c.G!=foreColor.G)||(c.B!=foreColor.B)) {
        foreColor = c;
        _SetForeColor (c);
        _MarkForUpdate();
    }
}

//__________________________________________________________________

_HYColor&       _HYLabel::GetForeColor (void)
{
    return foreColor;
}

//__________________________________________________________________
void        _HYLabel::SetText (_String newText)
{
    if (labelText.Equal(&newText)) {
        return;
    }

    labelText = newText;
    _SetText ();
    _MarkForUpdate();
}

//__________________________________________________________________

_String&        _HYLabel::GetText (void)
{
    return labelText;
}

//__________________________________________________________________

_HYFont&        _HYLabel::GetFont (void)
{
    return labelFont;
}

//__________________________________________________________________

void        _HYLabel::SetShadow (bool toggle)
{
    if (toggle) {
        if (!(HY_LABEL_SHADOW&visFlags)) {
            visFlags|=HY_LABEL_SHADOW;
            _MarkForUpdate();
        }
    } else {
        if (HY_LABEL_SHADOW&visFlags) {
            visFlags&=(0xff-HY_LABEL_SHADOW);
            _MarkForUpdate();
        }
    }
}

//__________________________________________________________________

void            _HYLabel::SetFont (_HYFont&f)
{
    if ((f.face!=labelFont.face)||(f.size!=labelFont.size)||(f.style!=labelFont.style)) {
        _SetFont (f);
        labelFont.face = f.face;
        labelFont.size = f.size;
        labelFont.style = f.style;
        _HYPlatformLabel::_SetVisibleSize (rel);
        _MarkForUpdate();
    }
}

//__________________________________________________________________
void        _HYLabel::SetVisibleSize     (_HYRect rel)
{
    _HYComponent::SetVisibleSize (rel);
    _HYPlatformLabel::_SetVisibleSize (rel);
}
\ No newline at end of file
+/*
 
 HyPhy - Hypothesis Testing Using Phylogenies.
 
 Copyright (C) 1997-now
 Core Developers:
 Sergei L Kosakovsky Pond (spond at ucsd.edu)
 Art FY Poon    (apoon at cfenet.ubc.ca)
 Steven Weaver (sweaver at ucsd.edu)
 
 Module Developers:
 Lance Hepler (nlhepler at gmail.com)
 Martin Smith (martin.audacis at gmail.com)
 
 Significant contributions from:
 Spencer V Muse (muse at stat.ncsu.edu)
 Simon DW Frost (sdf22 at cam.ac.uk)
 
 Permission is hereby granted, free of charge, to any person obtaining a
 copy of this software and associated documentation files (the
 "Software"), to deal in the Software without restriction, including
 without limitation the rights to use, copy, modify, merge, publish,
 distribute, sublicense, and/or sell copies of the Software, and to
 permit persons to whom the Software is furnished to do so, subject to
 the following conditions:
 
 The above copyright notice and this permission notice shall be included
 in all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 */

#include "HYEventTypes.h"
#include "HYLabel.h"
#include "HYGraphicPane.h"

#ifdef    __HYPHYDMALLOC__
#include "dmalloc.h"
#endif

//__________________________________________________________________

_HYLabel::_HYLabel(_HYRect r,Ptr p):_HYComponent (r,p)
{
    backColor.R = backColor.G = backColor.B = 255;
    foreColor.R = foreColor.G = foreColor.B = 0;
    labelFont.size = 9;
    labelFont.style = HY_FONT_PLAIN;
    labelFont.face = "Monaco";
    alignFlags = 0;
    visFlags = 0;
}

//__________________________________________________________________

_HYLabel::~_HYLabel()
{
}

//__________________________________________________________________
void        _HYLabel::SetBackColor (_HYColor c)
{
    if ((c.R!=backColor.R)||(c.G!=backColor.G)||(c.B!=backColor.B)) {
        backColor = c;
        _SetBackColor (c);
        _MarkForUpdate();
    }
}


//__________________________________________________________________

_HYColor&       _HYLabel::GetBackColor (void)
{
    return backColor;
}

//__________________________________________________________________
void        _HYLabel::SetForeColor (_HYColor c)
{
    if ((c.R!=foreColor.R)||(c.G!=foreColor.G)||(c.B!=foreColor.B)) {
        foreColor = c;
        _SetForeColor (c);
        _MarkForUpdate();
    }
}

//__________________________________________________________________

_HYColor&       _HYLabel::GetForeColor (void)
{
    return foreColor;
}

//__________________________________________________________________
void        _HYLabel::SetText (_String newText)
{
    if (labelText.Equal(&newText)) {
        return;
    }

    labelText = newText;
    _SetText ();
    _MarkForUpdate();
}

//__________________________________________________________________

_String&        _HYLabel::GetText (void)
{
    return labelText;
}

//__________________________________________________________________

_HYFont&        _HYLabel::GetFont (void)
{
    return labelFont;
}

//__________________________________________________________________

void        _HYLabel::SetShadow (bool toggle)
{
    if (toggle) {
        if (!(HY_LABEL_SHADOW&visFlags)) {
            visFlags|=HY_LABEL_SHADOW;
            _MarkForUpdate();
        }
    } else {
        if (HY_LABEL_SHADOW&visFlags) {
            visFlags&=(0xff-HY_LABEL_SHADOW);
            _MarkForUpdate();
        }
    }
}

//__________________________________________________________________

void            _HYLabel::SetFont (_HYFont&f)
{
    if ((f.face!=labelFont.face)||(f.size!=labelFont.size)||(f.style!=labelFont.style)) {
        _SetFont (f);
        labelFont.face = f.face;
        labelFont.size = f.size;
        labelFont.style = f.style;
        _HYPlatformLabel::_SetVisibleSize (rel);
        _MarkForUpdate();
    }
}

//__________________________________________________________________
void        _HYLabel::SetVisibleSize     (_HYRect rel)
{
    _HYComponent::SetVisibleSize (rel);
    _HYPlatformLabel::_SetVisibleSize (rel);
}
\ No newline at end of file
diff --git a/src/gui/Components/HYPullDown.cpp b/src/gui/Components/HYPullDown.cpp
index 0e408e8..23123d4 100644
--- a/src/gui/Components/HYPullDown.cpp
+++ b/src/gui/Components/HYPullDown.cpp
@@ -1,8 +1,41 @@
 /*
-    Pull-down menu component
-
-    Sergei L. Kosakovsky Pond, May 2000 - November 2001.
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include "HYEventTypes.h"
 #include "HYPullDown.h"
@@ -189,4 +222,4 @@ bool        _HYPullDown::ProcessEvent (_HYEvent* e)
 {
     DeleteObject (e);
     return false;
-}
\ No newline at end of file
+}
diff --git a/src/gui/Components/HYSequencePanel.cpp b/src/gui/Components/HYSequencePanel.cpp
index 3e8b27e..6565f31 100644
--- a/src/gui/Components/HYSequencePanel.cpp
+++ b/src/gui/Components/HYSequencePanel.cpp
@@ -1,8 +1,41 @@
 /*
-    Sequence panel code
-
-    Sergei L. Kosakovsky Pond, August 2000.
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include "HYComponent.h"
 #include "HYEventTypes.h"
@@ -1664,4 +1697,4 @@ void        _HYSequencePane::ProcessContextualPopUp (long l, long t)
 
 
 
-//EOF
\ No newline at end of file
+//EOF
diff --git a/src/gui/Components/HYTable.cpp b/src/gui/Components/HYTable.cpp
index 730faac..4409b87 100644
--- a/src/gui/Components/HYTable.cpp
+++ b/src/gui/Components/HYTable.cpp
@@ -1 +1 @@
-/*
    A table GUI object

    Sergei L. Kosakovsky Pond, January 2001.
*/

#include "HYTableComponent.h"
#include "HYUtils.h"
#include "HYPlatformWindow.h"
#include "HYTableWindow.h"
#include "HYGraphicPane.h"
#include "HYEventTypes.h"
#include "HYDialogs.h"
#include "batchlan.h"

#include "math.h"

#ifdef    __HYPHYDMALLOC__
#include "dmalloc.h"
#endif

//extern     _HYColor   _BLACK_;


_HYColor tableDefaultBk  = {235,235,235},
         tableDefaultBk2 = {200,200,200};

_String  iconExportString ("[ICON]");

//__________________________________________________________________

_HYTable::_HYTable(_HYRect rel,Ptr w,long r, long c, long h, long v, long defType):
    _HYComponent (rel,w)
{
    SetTableSize (r,c,defType,h,v);
    SetTextColor ((_HYColor) {
        0,0,0
    });
    SetBackColor (tableDefaultBk);
    SetBackColor2(tableDefaultBk2);
    _HYFont      defFont;

#ifdef __MAC__
    defFont.face = "Times";
    defFont.size = 12;
#else
#ifdef __HYPHY_GTK__
    defFont.face = _HY_SANS_FONT;
    defFont.size = 11;
#else
    defFont.face = "Verdana";
    defFont.size = 12;
#endif
#endif

    defFont.style = HY_FONT_PLAIN;
    SetFont      (defFont);
    editCellID      = -1;
    selectionType   = 0;
    undoString      = nil;
    undoIndex       = undoIndex2 = -1;
    stretchWidth    = -1;
    stretchHeight   = -1;
}

//__________________________________________________________________

_HYTable::~_HYTable(void)
{
}

//__________________________________________________________________

void    _HYTable::SetTableSize(long r, long c, long defType, long h, long v)
{
    long      i;
    for (i=h; i<=c*h; i+=h) {
        horizontalSpaces<<i;
    }

    for (i=0; i<r; i++) {
        AddRow (-1,v,defType);
    }
}

//__________________________________________________________________

void    _HYTable::AddRow (long where, long h, long defType)
{
    long        i,w;
    if (where==-1) {
        where = verticalSpaces.lLength;
    }
    verticalSpaces<<0;
    for (i=verticalSpaces.lLength-1; i>where; i--) {
        verticalSpaces.lData[i]=verticalSpaces.lData[i-1]+h;
    }
    if (where) {
        verticalSpaces.lData[where]=verticalSpaces.lData[where-1]+h;
    } else {
        verticalSpaces.lData[0] = h;
    }

    w = where*horizontalSpaces.lLength;
    if ((defType&HY_TABLE_STATIC_TEXT)||(defType&HY_TABLE_EDIT_TEXT))
        // text
    {
        _String dummy;
        for (i=0; i<horizontalSpaces.lLength; i++) {
            cellData.InsertElement (&dummy,w,true);
            cellTypes.InsertElement((BaseRef)defType,w,false,false);
        }
    } else
        // icons
    {
        _SimpleList dummy;
        for (i=0; i<horizontalSpaces.lLength; i++) {
            cellData.InsertElement (&dummy,w,true);
            cellTypes.InsertElement((BaseRef)defType,w,false,false);
        }
    }

    stretchHeight = -1;
}

//__________________________________________________________________

void    _HYTable::RequestSpace (long r, long c)
{
    verticalSpaces.RequestSpace (r);
    cellData.RequestSpace (r*c);
    cellTypes.RequestSpace (r*c);
}

//__________________________________________________________________

void    _HYTable::DeleteRow (long where)
{
    long        i,h;
    if ((where<0)||(where>=verticalSpaces.lLength)) {
        return;
    }
    h = GetRowSpacing (where);

    for (i=where; i<verticalSpaces.lLength-1; i++) {
        verticalSpaces.lData[i]=verticalSpaces.lData[i+1]-h;
    }

    h = where*horizontalSpaces.lLength;
    for (i=0; i<horizontalSpaces.lLength; i++) {
        cellData.Delete (h);
        cellTypes.Delete(h);
    }
    verticalSpaces.Delete (verticalSpaces.lLength-1);

    stretchHeight = -1;
}

//__________________________________________________________________

void    _HYTable::AddColumn (long where, long h, long defType)
{
    long        i,w;
    if (where==-1) {
        where = horizontalSpaces.lLength;
    }
    horizontalSpaces<<0;
    for (i=horizontalSpaces.lLength-1; i>where; i--) {
        horizontalSpaces.lData[i]=horizontalSpaces.lData[i-1]+h;
    }
    if (where) {
        horizontalSpaces.lData[where]=horizontalSpaces.lData[where-1]+h;
    } else {
        horizontalSpaces.lData[0] = h;
    }
    w = where*horizontalSpaces.lLength;
    if ((defType&HY_TABLE_STATIC_TEXT)||(defType&HY_TABLE_EDIT_TEXT))
        // text
    {
        _String dummy;
        for (i=0; (i<horizontalSpaces.lLength)&&(w<cellData.lLength); i++, w+=verticalSpaces.lLength) {
            cellData.InsertElement (&dummy,w,true);
            cellTypes.InsertElement((BaseRef)defType,w,false,false);
        }
    } else
        // icons
    {
        _SimpleList dummy;
        for (i=0; (i<horizontalSpaces.lLength)&&(w<cellData.lLength); i++, w+=verticalSpaces.lLength) {
            cellData.InsertElement (&dummy,w,true);
            cellTypes.InsertElement((BaseRef)defType,w,false,false);
        }
    }

    stretchWidth = -1;
}

//__________________________________________________________________

void    _HYTable::DeleteColumn (long where)
{
    long        i,h;
    if ((where<0)||(where>=horizontalSpaces.lLength)) {
        return;
    }
    h = GetColumnSpacing (where);
    for (i=where; i<horizontalSpaces.lLength; i++) {
        horizontalSpaces.lData[i]=horizontalSpaces.lData[i+1]-h;
    }
    for (i=cellData.lLength-verticalSpaces.lLength-1+where; i>=0; i-=verticalSpaces.lLength) {
        cellData.Delete (i);
        cellTypes.Delete(i);
    }
    stretchWidth = -1;
}

//__________________________________________________________________

long    _HYTable::GetRowSpacing (long index)
{
    if (index>0) {
        return verticalSpaces.lData[index]-verticalSpaces.lData[index-1];
    }
    return verticalSpaces.lData[0];
}

//__________________________________________________________________

long    _HYTable::GetColumnSpacing (long index)
{
    if (index>0) {
        return horizontalSpaces.lData[index]-horizontalSpaces.lData[index-1];
    }
    return horizontalSpaces.lData[0];
}

//__________________________________________________________________

void    _HYTable::ClearTable (bool all)
{
    cellData.Clear();
    cellTypes.Clear();
    if (all) {
        horizontalSpaces.Clear();
    }
    verticalSpaces.Clear();
    hOrigin = vOrigin = 0;
}

//__________________________________________________________________

void    _HYTable::SetTableFromMx (_Matrix* data, long rowWidth, long colHeight, long cellType)
{
    ClearTable (true);
    long        rc = data->GetHDim(),
                cc = data->GetVDim(),
                spacer = rowWidth;

    verticalSpaces.RequestSpace (rc);

    for (long k=0; k<rc; k++) {
        verticalSpaces.lData[k] = spacer;
        spacer+=rowWidth;
    }
    verticalSpaces.lLength = rc;

    spacer = colHeight;
    horizontalSpaces.RequestSpace (cc);

    for (long k=0; k<cc; k++) {
        horizontalSpaces.lData[k] = spacer;
        spacer+=colHeight;
    }
    horizontalSpaces.lLength = cc;

    cellTypes.RequestSpace (cc*rc);
    for (long k=0; k<rc*cc; k++) {
        cellTypes.lData[k] = cellType;
    }

    cellTypes.lLength = rc*cc;

    cellData.RequestSpace (cc*rc);

    BaseRef * brf = (BaseRef*)(cellData.lData);

    for (long h=0; h<rc*cc; h++) {
        _String* cellData = new _String ((*data)(h/cc,h%cc));
        if (!(brf[h] = cellData)) {
            checkPointer (cellData);
        }
    }


    cellData.lLength = rc*cc;
}

//__________________________________________________________________

void    _HYTable::SetBackColor (_HYColor nc)
{
    backColor = nc;
    _SetBackColor (nc);
}

//__________________________________________________________________

void    _HYTable::SetBackColor2 (_HYColor nc)
{
    backColor2 = nc;
    _SetBackColor2 (nc);
}

//__________________________________________________________________

void    _HYTable::SetTextColor (_HYColor nc)
{
    textColor = nc;
}

//__________________________________________________________________

void    _HYTable::SetFont (_HYFont& nf)
{
    bool  t = !textFont.face.Equal(&nf.face);
    if ( textFont.size!=nf.size || textFont.style!=nf.style ||t) {
        textFont.size = nf.size;
        textFont.style = nf.style;
        if (t) {
            textFont.face = nf.face;
            _SetFont ();
        }
    }
}

//__________________________________________________________________

int     _HYTable::GetMaxW(void)
{
    long res = horizontalSpaces.lData[horizontalSpaces.lLength-1]+((settings.width&HY_COMPONENT_V_SCROLL)?HY_SCROLLER_WIDTH:0);
    if (res > 0x7ffff) {
        return 0x7ffff;
    }
    return res;
}

//__________________________________________________________________

int     _HYTable::GetMaxH(void)
{
    long res = verticalSpaces.lData[verticalSpaces.lLength-1]+((settings.width&HY_COMPONENT_H_SCROLL)?HY_SCROLLER_WIDTH:0);
    if (res > 0x7ffff) {
        return 0x7ffff;
    }
    return res;
}

//__________________________________________________________________

int     _HYTable::GetMaxLW(void)
{
    if (selectionType&HY_TABLE_DONT_GROW_HORIZ) {
        return _HYComponent::GetMaxW();
    } else if (selectionType&HY_TABLE_HORZ_STRETCH) {
        return 0x7ffff;
    } else {
        return GetMaxW();
    }
}

//__________________________________________________________________

int     _HYTable::GetMaxLH(void)
{
    if (selectionType&HY_TABLE_DONT_GROW_VERT) {
        return _HYComponent::GetMaxH();
    } else if (selectionType&HY_TABLE_VERT_STRETCH) {
        return 0x7ffff;
    } else {
        return GetMaxH();
    }
}

//__________________________________________________________________

bool        _HYTable::CheckForHSizeLocation (long h)
{
    h += hOrigin;
    for (long k = 0; k<horizontalSpaces.lLength; k++)
        if ((h>=horizontalSpaces.lData[k]-2)&&(h<=horizontalSpaces.lData[k]+2)) {
            return true;
        }
    return false;
}

//__________________________________________________________________

void        _HYTable::DragRow(long row, long after)
{
    if ((row>=0)&&(row<verticalSpaces.lLength)&&(after<verticalSpaces.lLength)&&(row!=after)) {
        cellTypes.Displace (row*horizontalSpaces.lLength,(row+1)*horizontalSpaces.lLength-1,
                            (after-row)*horizontalSpaces.lLength);
        cellData.Displace (row*horizontalSpaces.lLength,(row+1)*horizontalSpaces.lLength-1,
                           (after-row)*horizontalSpaces.lLength);
        _MarkForUpdate();
    }
}

//__________________________________________________________________

long        _HYTable::FindString (_String* s, long startat)
{
    for (long k=(startat>=0?startat:0); k<cellData.lLength; k++)
        if ((cellTypes.lData[k]&(HY_TABLE_STATIC_TEXT+HY_TABLE_EDIT_TEXT))&&
                (s->Equal((_String*)cellData(k))))

        {
            return k;
        }
    return -1;
}

//__________________________________________________________________

long        _HYTable::FindClickedTableCell (long hc,long vc,long& h, long& v)
{
    hc+=hOrigin;
    vc+=vOrigin;

    for (h = 0; h<horizontalSpaces.lLength; h++)
        if (hc<horizontalSpaces.lData[h]-2) {
            break;
        }
    if (h<horizontalSpaces.lLength) {
        for (v = 0; v<verticalSpaces.lLength; v++)
            if (vc<verticalSpaces.lData[v]-2) {
                break;
            }

        if (v<verticalSpaces.lLength) {
            long index = v*horizontalSpaces.lLength+h;
            if (cellTypes.lData[index]&HY_TABLE_PULLDOWN) {
                if ((hc>horizontalSpaces.lData[h]-15)&&(abs(2*(verticalSpaces.lData[v]-vc)-GetRowSpacing(v))<tPDMh)) {
                    return -2;
                }
            }
            return index;
        }
    }
    return -1;
}

//__________________________________________________________________

/*void      _HYTable::PlotAlignedIcon (_HYRect& store, long iconW, long iconH)
{

}*/

//__________________________________________________________________

void        _HYTable::EditBoxHandler (long index, _HYRect& r)
{
    if (_HasTextBox()) {
        _String editRes = _RetrieveTextValue();
        _KillTextBox();
        if (!editRes.Equal ((_String*)GetCellData(editCellID%horizontalSpaces.lLength,
                            editCellID/horizontalSpaces.lLength))) {
            SetCellData (&editRes,editCellID/horizontalSpaces.lLength,
                         editCellID%horizontalSpaces.lLength,
                         cellTypes.lData[editCellID],
                         true);
            if (messageRecipient) {
                messageRecipient->ProcessEvent (generateTableEditCellEvent(GetID(),editCellID));
            }
        }
        _SimpleList     dummy;
        dummy           <<  editCellID;
        _MarkCellsForUpdate (dummy);
        editCellID      = -1;
    }

    if (index>=0) {
        editCellID= index;
        long    v = index/horizontalSpaces.lLength;
        index     = index%horizontalSpaces.lLength;

        _HYRect textRect = r;

        if (index) {
            textRect.left += horizontalSpaces.lData[index-1] - hOrigin;
        } else {
            textRect.left -= hOrigin;
        }
        if (v) {
            textRect.top  += verticalSpaces.lData[v-1] - vOrigin;
        } else {
            textRect.top  -= vOrigin;
        }

        textRect.right     = r.left+horizontalSpaces.lData[index] - hOrigin;
        textRect.bottom    = r.top+verticalSpaces.lData[v] - vOrigin;

        if (settings.width&HY_COMPONENT_V_SCROLL) {
            if (textRect.right > r.right - HY_SCROLLER_WIDTH) {
                textRect.right = r.right - HY_SCROLLER_WIDTH;
            }
        } else if (textRect.right >= r.right) {
            textRect.right = r.right - 1;
        }

        if (settings.width&HY_COMPONENT_H_SCROLL) {
            if (textRect.bottom > r.bottom - HY_SCROLLER_WIDTH) {
                textRect.bottom = r.bottom - HY_SCROLLER_WIDTH;
            }
        } else if (textRect.bottom >= r.bottom) {
            textRect.bottom = r.bottom - 1;
        }


        textRect.left   +=2;
        //textRect.top  +=2;
        textRect.right  -=2;
        //textRect.bottom -=3;

        if ((textRect.right>textRect.left+textFont.size)&&(textRect.bottom>textRect.top+textFont.size)) {
            if (messageRecipient) {
                messageRecipient->ProcessEvent(generateKeyboardFocusEvent(GetID()));
            }
            _CreateTextBox (textRect, *(_String*)GetCellData(index,v));
            _SimpleList     dummy;
            dummy           <<  v*horizontalSpaces.lLength+index;
            _MarkCellsForUpdate (dummy);
        }
    } else {
        if ((messageRecipient)&&((selectionType&HY_TABLE_IS_FOCUSED)==0)) {
            messageRecipient->ProcessEvent(generateKeyboardFocusEvent(-1));
        }
    }
}

//__________________________________________________________________

void        _HYTable::ClearSelection (bool standAlone)
{
    _SimpleList modCells;
    for (long c = 0; c<cellTypes.lLength; c++) {
        if (cellTypes.lData[c]&HY_TABLE_SELECTED) {
            cellTypes.lData[c] -= HY_TABLE_SELECTED;
            modCells << c;
        }
    }
    if (modCells.lLength) {
        _MarkCellsForUpdate(modCells);
        if (_HasTextBox()) {
            _HYRect        dummy;
            EditBoxHandler (-1,dummy);
        }
        if (standAlone&&messageRecipient) {
            messageRecipient->ProcessEvent (generateTableChangeSelEvent(GetID()));
        }
    }
}

//__________________________________________________________________

void        _HYTable::SetRowSelection (const _SimpleList& rows)
{
    ClearSelection (false);
    _SimpleList modCells;
    modCells.RequestSpace (rows.lLength * horizontalSpaces.lLength);
    for (long t=0; t<rows.lLength; t++) {
        long rowN = rows.lData[t];
        if ((rowN>=0)&&(rowN<verticalSpaces.lLength)) {
            for (long k=rowN*horizontalSpaces.lLength; k<(rowN+1)*horizontalSpaces.lLength; k++) {
                if (!(cellTypes.lData[k]&HY_TABLE_CANTSELECT)) {
                    cellTypes.lData[k]|=HY_TABLE_SELECTED;
                    modCells << k;
                }
            }
        }
    }
    if (modCells.lLength) {
        for (long t=0; t<rows.lLength; t++) {
            _MarkRowForUpdate(rows.lData[t]);
        }

        if (_HasTextBox()) {
            _HYRect        dummy;
            EditBoxHandler (-1,dummy);
        }
        if (messageRecipient) {
            messageRecipient->ProcessEvent (generateTableChangeSelEvent(GetID()));
        }
    }
}

//__________________________________________________________________

void        _HYTable::SetColumnSelection (const _SimpleList& columns)
{
    ClearSelection (false);
    _SimpleList modCells;
    modCells.RequestSpace (columns.lLength * verticalSpaces.lLength);
    for (long t=0; t<columns.lLength; t++) {
        long rowN = columns.lData[t];
        if ((rowN>=0)&&(rowN<verticalSpaces.lLength)) {
            for (long k=rowN; k<cellTypes.lLength; k+=horizontalSpaces.lLength) {
                if (!(cellTypes.lData[k]&HY_TABLE_CANTSELECT)) {
                    cellTypes.lData[k]|=HY_TABLE_SELECTED;
                    modCells << k;
                }
            }
        }
    }
    if (modCells.lLength) {
        for (long t=0; t<columns.lLength; t++) {
            _MarkColumnForUpdate(columns.lData[t]);
        }

        if (_HasTextBox()) {
            _HYRect        dummy;
            EditBoxHandler (-1,dummy);
        }
        if (messageRecipient) {
            messageRecipient->ProcessEvent (generateTableChangeSelEvent(GetID()));
        }
    }
}


//__________________________________________________________________

void        _HYTable::ModifySelection (long h,long v, bool shift, bool control, bool message)
{
    long t = v*horizontalSpaces.lLength+h,t2;

    if (selectionType & HY_TABLE_SINGLE_SELECTION) {
        shift   = false;
        control = false;
    }

    if (cellTypes.lData[t]&HY_TABLE_CANTSELECT) {
        if (!shift) {
            ClearSelection();
            return;
        }
    }

    bool sel = cellTypes.lData[t]&HY_TABLE_SELECTED;

    _SimpleList  modCells;

    if (control) {
        _SimpleList  selection;
        GetSelection (selection);

        if (selection.lLength != 1) {
            return;
        }

        long    selRow = selection.lData[0]/horizontalSpaces.lLength,
                selCol = selection.lData[0]%horizontalSpaces.lLength,
                minRow,
                minCol,
                maxRow,
                maxCol;

        if (v<selRow) {
            minRow = v;
            maxRow = selRow;
        } else {
            maxRow = v;
            minRow = selRow;
        }

        if (h<selCol) {
            minCol = h;
            maxCol = selCol;
        } else {
            maxCol = h;
            minCol = selCol;
        }

        modCells.RequestSpace ((maxRow-minRow+1)*(maxCol-minCol+1));
        for (long r = minRow; r<=maxRow; r++)
            for (long c = r*horizontalSpaces.lLength+minCol; c<=r*horizontalSpaces.lLength+maxCol; c++) {
                if (!(cellTypes.lData[c]&HY_TABLE_CANTSELECT)) {
                    cellTypes.lData[c]|=HY_TABLE_SELECTED;
                }
                modCells<<c;
            }
    } else {
        if (shift) {
            if (!(cellTypes.lData[t]&HY_TABLE_CANTSELECT)) {
                if (sel) {
                    cellTypes.lData[t]-=HY_TABLE_SELECTED;
                } else {
                    cellTypes.lData[t]+=HY_TABLE_SELECTED;
                }
                modCells<<t;
            }
        } else {
            if (!sel) {
                for (long k=0; k<horizontalSpaces.lLength; k++)
                    for (long l=0; l<verticalSpaces.lLength; l++) {
                        t2 = l*horizontalSpaces.lLength+k;
                        if (t==t2) {
                            continue;
                        }
                        if (cellTypes.lData[t2]&HY_TABLE_CANTSELECT) {
                            continue;
                        }

                        if (cellTypes.lData[t2]&HY_TABLE_SELECTED) {
                            cellTypes.lData[t2]-=HY_TABLE_SELECTED;
                            modCells<<t2;
                        }
                    }
                if (!(cellTypes.lData[t]&HY_TABLE_CANTSELECT)) {
                    cellTypes.lData[t]+=HY_TABLE_SELECTED;
                }

                modCells<<t;
            } else {
                return;
            }
        }
    }

    if (selectionType&HY_TABLE_SEL_ROWS) {
        sel = cellTypes.lData[t]&HY_TABLE_SELECTED;
        if (sel)
            for (long k=v*horizontalSpaces.lLength; k<(v+1)*horizontalSpaces.lLength; k++) {
                if ((k==t)||(cellTypes.lData[k]&HY_TABLE_CANTSELECT)) {
                    continue;
                }
                cellTypes.lData[k]|=HY_TABLE_SELECTED;
                modCells<<k;
            }
        else
            for (long k=v*horizontalSpaces.lLength; k<(v+1)*horizontalSpaces.lLength; k++) {
                if ((k==t)||(cellTypes.lData[k]&HY_TABLE_CANTSELECT)) {
                    continue;
                }
                cellTypes.lData[k]&=HY_TABLE_DESELECT;
                modCells<<k;
            }
    } else if (selectionType&HY_TABLE_SEL_COLS) {
        sel = cellTypes.lData[t]&HY_TABLE_SELECTED;
        if (sel)
            for (long k=h; k<verticalSpaces.lLength*horizontalSpaces.lLength; k+=horizontalSpaces.lLength) {
                if ((k==t)||(cellTypes.lData[k]&HY_TABLE_CANTSELECT)) {
                    continue;
                }
                cellTypes.lData[k]|=HY_TABLE_SELECTED;
                modCells<<k;
            }
        else
            for (long k=h; k<verticalSpaces.lLength*horizontalSpaces.lLength; k+=horizontalSpaces.lLength) {
                if ((k==t)||(cellTypes.lData[k]&HY_TABLE_CANTSELECT)) {
                    continue;
                }
                cellTypes.lData[k]&=HY_TABLE_DESELECT;
                modCells<<k;
            }
    }

    if (modCells.lLength) {
        _MarkCellsForUpdate(modCells);
        if (_HasTextBox()) {
            _HYRect        dummy;
            EditBoxHandler (-1,dummy);
        }
        if (message&&messageRecipient) {
            messageRecipient->ProcessEvent (generateTableChangeSelEvent(GetID()));
        }
    }
}

//__________________________________________________________________

void        _HYTable::ExpungeSelection (void)
{
    _SimpleList  updateCells;
    for (long k=0; k<horizontalSpaces.lLength*verticalSpaces.lLength; k++) {
        if (cellTypes.lData[k]&HY_TABLE_SELECTED) {
            cellTypes.lData[k]&=HY_TABLE_DESELECT;
            updateCells<<k;
        }
    }
    _MarkCellsForUpdate (updateCells);
}

//__________________________________________________________________

void        _HYTable::SetColumnSpacing (long index, long h, bool update)
{
    if (h) {
        for (long k=index; k<horizontalSpaces.lLength; k++) {
            horizontalSpaces.lData[k]+=h;
        }
        if (update) {
            SetVisibleSize (rel);
            _MarkForUpdate();
        }
    }
    if (stretchWidth >= 0) {
        stretchWidth += h;
        if (stretchWidth < 0) {
            stretchWidth = -1;
        }
    }
}

//__________________________________________________________________

void        _HYTable::SetRowSpacing (long index, long v, bool update)
{
    if (v) {
        for (long k=index; k<verticalSpaces.lLength; k++) {
            verticalSpaces.lData[k]+=v;
        }
        if (update) {
            SetVisibleSize (rel);
            _MarkForUpdate();
        }

    }
    if (stretchHeight >= 0) {
        stretchHeight += v;
        if (stretchHeight < 0) {
            stretchHeight = -1;
        }
    }
}


//__________________________________________________________________

void        _HYTable::AutoFitColumn (long index, bool, bool increaseOnly)
{
    long maxWidth  = 0,
         cellWidth = 5;

    bool iconsOnly = true;

    for (long k=index; k<verticalSpaces.lLength*horizontalSpaces.lLength; k+=horizontalSpaces.lLength) {
        if (cellTypes.lData[k]&HY_TABLE_ICON) {
            cellWidth = ((_SimpleList*)cellData[k])->lData[1]+2;
        } else {
            _String*  cellValue = (_String*) cellData[k];
            if (cellTypes.lData[k]&HY_TABLE_BOLD) {
                textFont.style |= HY_FONT_BOLD;
            }
            if (cellTypes.lData[k]&HY_TABLE_ITALIC) {
                textFont.style |= HY_FONT_ITALIC;
            }
            cellWidth = GetVisibleStringWidth (*cellValue, textFont);
            if (cellTypes.lData[k]&HY_TABLE_PULLDOWN) {
                cellWidth += 5+tPDMw;
            }
            textFont.style = HY_FONT_PLAIN;
            iconsOnly = false;
        }
        if (cellWidth > maxWidth) {
            maxWidth = cellWidth;
        }
    }

    if (iconsOnly) {
        maxWidth+=2;
    } else {
        maxWidth+=textFont.size;
    }

    if (increaseOnly && (GetColumnSpacing(index)>maxWidth)) {
        return;
    }

    SetColumnSpacing (index,maxWidth-GetColumnSpacing(index),false);
}

//__________________________________________________________________

void        _HYTable::EnforceWidth (long width, long index, bool l)
{
    if ((index>=horizontalSpaces.lLength)||l) {
        index = horizontalSpaces.lLength-1;
    }

    if (horizontalSpaces.lData[index]<width) {
        long step = (width-horizontalSpaces.lData[index])/(index+1);
        if (!l)
            for (long k=0; k<index; k++) {
                horizontalSpaces.lData[k] += step*(k+1);
            }
        horizontalSpaces.lData[index] = width;
    }
}

//__________________________________________________________________

void        _HYTable::EnforceHeight (long height, long index, bool l)
{
    if ((index>=verticalSpaces.lLength)||l) {
        index = verticalSpaces.lLength-1;
    }

    if (verticalSpaces.lData[index]<height) {
        long step = (height-verticalSpaces.lData[index])/(index+1);
        if (!l)
            for (long k=0; k<index; k++) {
                verticalSpaces.lData[k] += step*(k+1);
            }
        verticalSpaces.lData[index] = height;
    }
}

//__________________________________________________________________

void        _HYTable::AutoFitWidth (void)
{
    for (long k=0; k<horizontalSpaces.lLength-1; k++) {
        AutoFitColumn (k,false);
    }
    AutoFitColumn (horizontalSpaces.lLength-1,true);
}


//__________________________________________________________________

void        _HYTable::AutoFitWidth (_HYTable& table2, long cshift)
{
    long k,
         w1,
         w2;

    AutoFitWidth();
    table2.AutoFitWidth();

    _SimpleList newWidths,
                oldWidths,
                oldWidths2;

    if (horizontalSpaces.lLength==table2.horizontalSpaces.lLength)
        for (k=0; k<horizontalSpaces.lLength; k++) {
            w1 = GetColumnSpacing (k);
            w2 = table2.GetColumnSpacing (k);
            if (k==horizontalSpaces.lLength-1)
                if ((settings.width&HY_COMPONENT_V_SCROLL)&&!(table2.settings.width&HY_COMPONENT_V_SCROLL)) {
                    w1 += HY_SCROLLER_WIDTH;
                } else if (!(settings.width&HY_COMPONENT_V_SCROLL)&&(table2.settings.width&HY_COMPONENT_V_SCROLL)) {
                    w2 += HY_SCROLLER_WIDTH;
                }

            if (w1>w2) {
                newWidths << w1;
            } else {
                newWidths << w2;
            }
            oldWidths << w1;
            oldWidths2 << w2;
        }
    else
        for (k=0; k<horizontalSpaces.lLength; k++) {
            w1 = GetColumnSpacing (k);
            w2 = table2.GetColumnSpacing (k+cshift);

            if (w1>w2) {
                newWidths << w1;
            } else {
                newWidths << w2;
            }
            oldWidths << w1;
            oldWidths2 << w2;
        }

    long shift1 = 0,
         shift2 = 0;

    for (k=0; k<newWidths.lLength; k++) {
        shift1 += newWidths.lData[k] - oldWidths.lData[k];
        shift2 += newWidths.lData[k] - oldWidths2.lData[k];
        horizontalSpaces.lData[k] += shift1;
        table2.horizontalSpaces.lData[k+cshift] += shift2;
    }

    for (; k < table2.horizontalSpaces.lLength; k++) {
        table2.horizontalSpaces.lData[k] += shift2;
    }


}

//__________________________________________________________________
bool    _HYTable::ProcessEvent(_HYEvent* e)
{
    if (e->EventClass() == _hyScrollingEvent) {
        long h,v,k,w;
        _String firstArg = e->EventCode().Cut (0,(v=e->EventCode().Find(','))-1);
        h = firstArg.toNum();
        firstArg = e->EventCode().Cut (v+1,-1);
        v = firstArg.toNum();
        if (h||v) {
            if (h) {
                w = horizontalSpaces.lData[horizontalSpaces.lLength-1]-hSize;
                if (settings.width&HY_COMPONENT_V_SCROLL) {
                    w += HY_SCROLLER_WIDTH;
                }
                k = (double)h/MAX_CONTROL_VALUE * w;
                if (!k) {
                    k = h>0?5:-5;
                }
                _SetHScrollerPos (_GetHScrollerPos()+(double)k*MAX_CONTROL_VALUE/w-h);
                hOrigin += k;
                if (hOrigin<0) {
                    hOrigin -= k;
                    k=-hOrigin;
                    hOrigin = 0;
                    _SetHScrollerPos (0);
                } else if (hOrigin+hSize > w+hSize) {
                    hOrigin -= k;
                    k = w-hOrigin;
                    hOrigin = w;
                    _SetHScrollerPos (MAX_CONTROL_VALUE);
                }
                _HScrollTable(k);

                if (messageRecipient) {
                    messageRecipient->ProcessEvent (generateScrollEvent(h,0,GetID()));
                }
            } else {
                w = verticalSpaces.lData[verticalSpaces.lLength-1]-vSize;
                if (settings.width&HY_COMPONENT_H_SCROLL) {
                    w += HY_SCROLLER_WIDTH;
                }
                k = ((double)v/MAX_CONTROL_VALUE) * w;
                if (!k) {
                    k = v>0?10:-10;
                }

                _SetVScrollerPos (_GetVScrollerPos()+(double)k*MAX_CONTROL_VALUE/w-v);
                vOrigin += k;
                if (vOrigin<0) {
                    vOrigin -= k;
                    k = - vOrigin;
                    vOrigin = 0;
                    _SetVScrollerPos (0);
                } else if (vOrigin+vSize > w+vSize) {
                    vOrigin -= k;
                    k = w-vOrigin;
                    vOrigin = w;
                    _SetVScrollerPos (MAX_CONTROL_VALUE);
                }
                _VScrollTable(k);

                if (messageRecipient) {
                    messageRecipient->ProcessEvent (generateScrollEvent(0,v,GetID()));
                }
            }
        }
        DeleteObject(e);
        return true;
    }
    DeleteObject (e);
    return false;
}
//__________________________________________________________________

BaseRef _HYTable::GetCellData (long h, long v)
{
    return cellData(v*horizontalSpaces.lLength+h);
}

//__________________________________________________________________

void    _HYTable::SetCellData (BaseRef data, long h, long v, long type, bool copy)
{
    long idx = h*horizontalSpaces.lLength+v;
    cellTypes.lData[idx] = type;
    cellData.Replace (idx,data,copy);
}

//__________________________________________________________________

void    _HYTable::SetRowOrder (_SimpleList& order)
{
    if ((order.lLength == verticalSpaces.lLength)&&(order.lLength)) {
        _List           newData(cellData.lLength);
        _SimpleList     newTypes(cellTypes.lLength),
                        newSpaces;

        long            k,m,p;
        for (k=0; k<verticalSpaces.lLength; k++)
            for (m=0; m<horizontalSpaces.lLength; m++) {
                newTypes<<-1;
            }

        for (k=0; k<verticalSpaces.lLength; k++) {
            p = order.lData[k];
            for (m=0; m<horizontalSpaces.lLength; m++) {
                newTypes.lData[k*horizontalSpaces.lLength+m] = cellTypes.lData[p*horizontalSpaces.lLength+m];
                newData << GetCellData(m,p);
            }
        }
        if (newTypes.Find(-1)>=0) {
            return;
        }
        newSpaces << GetRowSpacing (order.lData[0]);
        for (k=1; k<verticalSpaces.lLength; k++) {
            newSpaces << GetRowSpacing (order.lData[k])+newSpaces.lData[k-1];
        }
        cellData.Clear();
        cellTypes.Clear();
        verticalSpaces.Clear();
        cellData.Duplicate(&newData);
        cellTypes.Duplicate(&newTypes);
        verticalSpaces.Duplicate(&newSpaces);

        _MarkForUpdate();
    }

}

//__________________________________________________________________

bool    _HYTable::ScrollToRow (long where)
{
    if ((where>=0)&&(where<verticalSpaces.lLength)) {
        long hs, hf, vs, vf;
        GetDisplayRange (&rel,vs,vf,hs,hf);
        if ((where<hs)||(where>=hf)) {
            if (where<hs) {
                if (where==0) {
                    vs = 0;
                } else {
                    vs = verticalSpaces.lData[where-1];
                }

                vs -= vOrigin;
            } else {
                vs = verticalSpaces.lData[where]-(rel.bottom-rel.top)/2-vOrigin;
            }

            vf = verticalSpaces.lData[verticalSpaces.lLength-1]-vSize;
            if (settings.width&HY_COMPONENT_H_SCROLL) {
                vf += HY_SCROLLER_WIDTH;
            }
            vs =(_Parameter) MAX_CONTROL_VALUE * (_Parameter)vs/(_Parameter)vf;
            _SetVScrollerPos (_GetVScrollerPos()+vs);
            ProcessEvent (generateScrollEvent(0,vs));
            return true;
        }
    }
    return false;
}

//__________________________________________________________________

bool    _HYTable::ScrollToColumn (long where)
{
    if ((where>=0)&&(where<horizontalSpaces.lLength)) {
        long hs, hf, vs, vf;
        GetDisplayRange (&rel,vs,vf,hs,hf);
        if ((where<vs)||(where>=vf)) {
            if (where<vs) {
                if (where==0) {
                    hs = 0;
                } else {
                    hs = verticalSpaces.lData[where-1];
                }

                hs -= hOrigin;
            } else {
                hs = horizontalSpaces.lData[where]-(rel.right-rel.left)/2-hOrigin;
            }

            hf = horizontalSpaces.lData[horizontalSpaces.lLength-1]-hSize;
            if (settings.width&HY_COMPONENT_V_SCROLL) {
                hf += HY_SCROLLER_WIDTH;
            }
            hs = (_Parameter)MAX_CONTROL_VALUE * (_Parameter)hs/(_Parameter)hf;
            _SetHScrollerPos (_GetHScrollerPos()+hs);
            ProcessEvent (generateScrollEvent(hs,0));
            return true;
        }
    }
    return false;
}

//__________________________________________________________________

void    _HYTable::SetVisibleSize (_HYRect r)
{
    EditBoxHandler  (-1,r);

    if (settings.width&HY_COMPONENT_V_SCROLL) {
        horizontalSpaces.lData[horizontalSpaces.lLength-1]+=HY_SCROLLER_WIDTH-1;
    }
    if (settings.width&HY_COMPONENT_H_SCROLL) {
        verticalSpaces.lData[verticalSpaces.lLength-1]+=HY_SCROLLER_WIDTH-1;
    }
    _HYComponent::SetVisibleSize(r);
    if (settings.width&HY_COMPONENT_V_SCROLL) {
        horizontalSpaces.lData[horizontalSpaces.lLength-1]-=HY_SCROLLER_WIDTH-1;
    }
    if (settings.width&HY_COMPONENT_H_SCROLL) {
        verticalSpaces.lData[verticalSpaces.lLength-1]-=HY_SCROLLER_WIDTH-1;
    }



    if (selectionType&HY_TABLE_HORZ_STRETCH) {
        if (stretchWidth>0) {
            SetColumnSpacing ( horizontalSpaces.lLength-1,-stretchWidth,false);
        }

        stretchWidth = horizontalSpaces.lData[horizontalSpaces.lLength-1];
        EnforceWidth (r.right-r.left+1-(settings.width&HY_COMPONENT_V_SCROLL?HY_SCROLLER_WIDTH:0), 0x7fffffff,true);
        stretchWidth = horizontalSpaces.lData[horizontalSpaces.lLength-1]-stretchWidth;
        //EnforceWidth (r.right-r.left+1, 0x7fffffff,true);
    }

    if (selectionType&HY_TABLE_VERT_STRETCH) {
        if (stretchHeight>0) {
            SetRowSpacing ( verticalSpaces.lLength-1,-stretchHeight,false);
        }

        stretchHeight = verticalSpaces.lData[verticalSpaces.lLength-1];
        EnforceHeight (r.bottom-r.top+1-(settings.width&HY_COMPONENT_H_SCROLL?HY_SCROLLER_WIDTH:0), 0x7fffffff,true);
        stretchHeight = verticalSpaces.lData[verticalSpaces.lLength-1]-stretchHeight;

    }

    long        t = GetMaxW();

    if (hOrigin+r.right-r.left>t) {
        hOrigin = t-r.right+r.left;
        _SetHScrollerPos (MAX_CONTROL_VALUE);
    }

    if (settings.width&HY_COMPONENT_H_SCROLL) {
        _Parameter c2 = hOrigin/(_Parameter)(t-r.right+r.left); // invisible section
        _SetHScrollerPos (c2*MAX_CONTROL_VALUE);
    }

    t = GetMaxH();
    if (vOrigin+r.bottom-r.top>t) {
        vOrigin = t-r.bottom+r.top;
        _SetVScrollerPos (MAX_CONTROL_VALUE);
    }

    if (settings.width&HY_COMPONENT_V_SCROLL) {
        _Parameter c2 = vOrigin/(_Parameter)(t-r.bottom+r.top); // invisible section
        _SetVScrollerPos (c2*MAX_CONTROL_VALUE);
    }
}

//__________________________________________________________________

void    _HYTable::GetDisplayRange (_HYRect* relRect, long& hs, long& hf, long& vs, long& vf )
{
    long    t = hOrigin;
    for (hs=0; hs<horizontalSpaces.lLength; hs++)
        if (horizontalSpaces.lData[hs]>t) {
            break;
        }
    if (hs==horizontalSpaces.lLength) {
        hs--;
    }
    t = relRect->right-relRect->left+hOrigin;
    if (settings.width&HY_COMPONENT_V_SCROLL) {
        t-=HY_SCROLLER_WIDTH;
    }

    for (hf=hs; hf<horizontalSpaces.lLength; hf++)
        if (horizontalSpaces.lData[hf]>t) {
            break;
        }
    if (hf==horizontalSpaces.lLength) {
        hf--;
    }

    t = vOrigin;
    for (vs=0; vs<verticalSpaces.lLength; vs++)
        if (verticalSpaces.lData[vs]>t) {
            break;
        }
    if (vs==verticalSpaces.lLength) {
        vs--;
    }
    t = relRect->bottom-relRect->top+vOrigin;
    if (settings.width&HY_COMPONENT_H_SCROLL) {
        t-=HY_SCROLLER_WIDTH;
    }

    for (vf=vs; vf<verticalSpaces.lLength; vf++)
        if (verticalSpaces.lData[vf]>t) {
            break;
        }
    if (vf==verticalSpaces.lLength) {
        vf--;
    }
}

//__________________________________________________________________

void    _HYTable::GetSelection (_SimpleList& rec)
{
    long selectedCount = 0;
    for (long k=0; k<cellTypes.lLength; k++)
        if (cellTypes.lData[k]&HY_TABLE_SELECTED) {
            selectedCount ++;
        }

    rec.RequestSpace (rec.lLength+selectedCount);
    for (long k=0; k<cellTypes.lLength; k++)
        if (cellTypes.lData[k]&HY_TABLE_SELECTED) {
            rec << k;
        }

}

//__________________________________________________________________

void    _HYTable::SetSelection (_SimpleList& rec, bool update)
{
    for (long k=0; k<rec.lLength; k++) {
        long idx = rec.lData[k];
        if (idx<cellTypes.lLength)
            if (!(cellTypes.lData[idx]&HY_TABLE_CANTSELECT)) {
                cellTypes.lData[idx] |= HY_TABLE_SELECTED;
            }
    }
    if (update&&messageRecipient) {
        messageRecipient->ProcessEvent (generateTableChangeSelEvent(GetID()));
    }
}

//__________________________________________________________________

void    _HYTable::InvertSelection (void)
{
    for (long idx=0; idx<cellTypes.lLength; idx++) {
        if (!(cellTypes.lData[idx]&HY_TABLE_CANTSELECT)) {
            if (cellTypes.lData[idx] & HY_TABLE_SELECTED) {
                cellTypes.lData[idx] -= HY_TABLE_SELECTED;
            } else {
                cellTypes.lData[idx] += HY_TABLE_SELECTED;
            }
        }
    }
    if (messageRecipient) {
        messageRecipient->ProcessEvent (generateTableChangeSelEvent(GetID()));
    }
}

//__________________________________________________________________

void    _HYTable::GetRowSelection (_SimpleList& rec, long shift)
{
    for (long k=0; k<cellTypes.lLength; k+=horizontalSpaces.lLength) {
        if (cellTypes.lData[k+shift]&HY_TABLE_SELECTED) {
            rec<<k/horizontalSpaces.lLength;
        }
    }
}

//__________________________________________________________________

void    _HYTable::ScanRowSelection (_SimpleList& rec)
{
    for (long k=0; k<cellTypes.lLength; k+=horizontalSpaces.lLength)
        for (long k2=0; k2<horizontalSpaces.lLength; k2++)
            if (cellTypes.lData[k+k2]&HY_TABLE_SELECTED) {
                rec << k/horizontalSpaces.lLength;
                break;
            }
}

//__________________________________________________________________

void    _HYTable::ScanColumnSelection (_SimpleList& rec)
{
    for (long k2=0; k2<horizontalSpaces.lLength; k2++)
        for (long k=k2; k<cellTypes.lLength; k+=horizontalSpaces.lLength)
            if (cellTypes.lData[k]&HY_TABLE_SELECTED) {
                rec << k2;
                break;
            }
}

//__________________________________________________________________

long    _HYTable::GetFirstRowSelection (void)
{
    _SimpleList rs;
    GetRowSelection (rs);
    if (rs.lLength) {
        return rs.lData[0];
    }
    return -1;
}

//__________________________________________________________________

bool    _HYTable::IsRowSelectionSimple (void)
{
    bool    res = false;
    for (long k=0; k<cellTypes.lLength; k+=horizontalSpaces.lLength) {
        if (cellTypes.lData[k]&HY_TABLE_SELECTED)
            if (res) {
                return false;
            } else {
                res = true;
            }
    }
    return res;
}

//__________________________________________________________________
bool    _HYTable::CanCopy (void)
{
    _SimpleList   sel;
    GetSelection (sel);

    return      sel.lLength;
}

//__________________________________________________________________
BaseRef _HYTable::CanPaste (_String& clip)
{
    _SimpleList   sel;
    GetSelection (sel);

    if (sel.lLength!=1) {
        return nil;
    }

    long rIdx = sel.lData[0]/horizontalSpaces.lLength,
         cIdx = sel.lData[0]%horizontalSpaces.lLength;

    _List        clipContents;

    _ElementaryCommand::ExtractConditions (clip,0,clipContents,';');

    if (verticalSpaces.lLength+1-rIdx < clipContents.lLength) {
        return nil;
    }

    _List*       clipData = new _List;

    if (!clipData) {
        return nil;
    }

    for (long k=0; k<clipContents.lLength; k++) {
        _List thisRow;
        _ElementaryCommand::ExtractConditions ((*(_String*)clipContents(k)),0,thisRow,',');
        if (horizontalSpaces.lLength+1-cIdx < thisRow.lLength) {
            DeleteObject (clipData);
            return       nil;
        }
        for (long kk=0; kk<thisRow.lLength; kk++) {
            ((_String*)thisRow(kk))->StripQuotes();
        }

        (*clipData) && & thisRow;
    }
    return clipData;
}

//__________________________________________________________________
_String*    _HYTable::HandleCopy (void)
{
    _String*     res = new _String (128L, true);

    _SimpleList  sel;
    GetSelection (sel);

    long         lastRow = -1;

    for (long k=0; k<sel.lLength; k++) {
        long rIndex = sel.lData[k]/horizontalSpaces.lLength,
             cIndex = sel.lData[k]%horizontalSpaces.lLength;

        if  (rIndex!=lastRow) {
            lastRow = rIndex;
            if (k) {
                (*res) << ';';
            }
        } else {
            (*res) << ',';
        }

        (*res) << '"';
        (*res) << (_String*)GetCellData (cIndex, rIndex);
        (*res) << '"';
    }

    res->Finalize();
    return       res;
}

//__________________________________________________________________

void    _HYTable::HandlePaste (BaseRef data)
{
    _List * pasteData = (_List*)data;

    _SimpleList  sel;
    GetSelection (sel);

    if (sel.lLength!=1) {
        return;
    }

    long rIdx = sel.lData[0]/horizontalSpaces.lLength,
         cIdx = sel.lData[0]%horizontalSpaces.lLength;

    _SimpleList taint;

    for (long k=0; k<pasteData->lLength; k++) {
        _List *thisRow = (_List*)(*pasteData)(k);

        for (long kk=0; kk<thisRow->lLength; kk++) {
            long idx = (rIdx+k)*horizontalSpaces.lLength + cIdx+kk;
            SetCellData ((_String*)(*thisRow)(kk),rIdx+k, cIdx+kk, cellTypes.lData[idx],true);
            taint << idx;
        }

    }

    _MarkCellsForUpdate (taint);

    if (messageRecipient) {
        messageRecipient->ProcessEvent (generateTableEditCellEvent(GetID(),sel.lData[0]));
    }

}


//__________________________________________________________________
void    _HYTable::GetColumnSelection (_SimpleList& rec)
{
    for (long k=0; k<horizontalSpaces.lLength; k++) {
        if (cellTypes.lData[k]&HY_TABLE_SELECTED) {
            rec<<k;
        }
    }
}

//__________________________________________________________________
void    _HYTable::UnfocusComponent (void)
{
    if (_HasTextBox()) {
        _HYRect        dummy;
        EditBoxHandler (-1,dummy);
    }
    if (selectionType&HY_TABLE_IS_FOCUSED) {
        selectionType -= HY_TABLE_IS_FOCUSED;
    }

    _HYComponent::UnfocusComponent();
}

//__________________________________________________________________
void    _HYTable::FocusComponent (void)
{
    if (!(selectionType&HY_TABLE_IS_FOCUSED)) {
        selectionType += HY_TABLE_IS_FOCUSED;
    }

    _SimpleList    cs;
    GetSelection   (cs);

    if (cs.lLength == 0) {
        long k;
        for (k=0; k<cellTypes.lLength; k++)
            if (cellTypes.lData[k]&HY_TABLE_CANTSELECT) {
                break;
            }

        if  (k<cellTypes.lLength) {
            cs << k;
            if ((selectionType&HY_TABLE_SEL_ROWS)==0) {
                cs.lData[0] /= horizontalSpaces.lLength;
                SetRowSelection (cs);
            }
            if (selectionType&HY_TABLE_SEL_COLS) {
                cs.lData[0] %= horizontalSpaces.lLength;
                SetColumnSelection (cs);
            } else {
                SetSelection (cs);
            }
        }
    }

    _FocusComponent ();
    _HYComponent::FocusComponent();
}

//__________________________________________________________________
void    _HYTable::_PrintTable (_HYTable* ch)
{
    _SimpleList rows,
                columns;

    long        k;

    for (k=0; k<horizontalSpaces.lLength; k++) {
        columns << k;
    }

    for (k=0; k<verticalSpaces.lLength; k++) {
        rows << k;
    }

    _PrintTable (columns, rows, ch);
}

//__________________________________________________________________
void    _HYTable::_PrintTable (_SimpleList& columns, _HYTable* ch)
{
    _SimpleList rows;

    long        k;

    for (k=0; k<verticalSpaces.lLength; k++) {
        rows << k;
    }

    _PrintTable (columns, rows, ch);
}

//__________________________________________________________________

void    _HYTable::SaveTable (_HYTable* ch, _HYTable *rh, long format, FILE * dest, _String& title)
{
    _SimpleList rows,
                columns;

    long        k;

    for (k=0; k<horizontalSpaces.lLength; k++) {
        columns << k;
    }

    for (k=0; k<verticalSpaces.lLength; k++) {
        rows << k;
    }

    SaveTable (ch,rh, format,dest,title, columns, rows);
}

//__________________________________________________________________

void    _HYTable::SaveTable (_HYTable* ch, _HYTable *rh, long format, FILE * dest, _String& title, _SimpleList& columns, _SimpleList& rows)
{
    long        i,j,k,t;
    if (columns.lLength&&rows.lLength&&dest) {
        switch (format) {
        case 0: // comma separated
        case 1: { // tab     separated
            char sep = format?'\t':',';
            if (ch) {
                if (rh) {
                    fputc (sep,dest);
                }
                for (i=0; i<columns.lLength-1; i++) {
                    ch->ExportCell (dest,format,0,columns.lData[i]);
                    fputc (sep,dest);
                }
                ch->ExportCell (dest,format,0,columns.lData[i]);
                fprintf (dest,"\n");
            }
            for (j=0; j<rows.lLength; j++) {
                if (rh) {
                    rh->ExportCell (dest,format,rows.lData[j],0);
                    fputc (sep,dest);
                }
                for (i=0; i<columns.lLength-1; i++) {
                    ExportCell (dest,format,rows.lData[j],columns.lData[i]);
                    fputc (sep,dest);
                }
                ExportCell (dest,format,rows.lData[j],columns.lData[i]);
                fprintf (dest,"\n");
            }
        }
        break;

        case 2: { // LaTEX table
            fprintf (dest, "{\\small\n\\begin{table}[t]\n\\begin{tabular}{");
            if (rh) {
                fprintf (dest,"r");
            }

            for (i=0; i<columns.lLength; i++) {
                fprintf (dest,"r");
            }

            fprintf (dest, "}\n\\hline\n");
            if (ch) {
                if (rh) {
                    fputc ('&',dest);
                }

                for (i=0; i<columns.lLength-1; i++) {
                    ch->ExportCell (dest,format,0,columns.lData[i]);
                    fputc ('&',dest);
                }
                ch->ExportCell (dest,format,0,columns.lData[i]);
                fprintf (dest, "\\\\\n\\hline\n");
            }
            for (j=0; j<rows.lLength; j++) {
                if (rh) {
                    rh->ExportCell (dest,format,rows.lData[j],0);
                    fputc ('&',dest);
                }
                for (i=0; i<columns.lLength-1; i++) {
                    ExportCell (dest,format,rows.lData[j],columns.lData[i]);
                    fputc ('&',dest);
                }
                ExportCell (dest,format,rows.lData[j],columns.lData[i]);
                fprintf (dest, "\\\\\n");
            }
            fprintf (dest,"\n\\end{tabular}\n\\caption{%s}\n\\end{table}\n}\n",title.sData);
        }
        break;

        case 3: { // HTML  table
            fprintf (dest, "<html>\n<head>\n<title>\n%s</title></head><body bgcolor = \"#FFFFFF\">\n<table border = \"0\" cellpadding = \"0\" cellspacing = \"1\">",title.sData);
            if (ch) {
                fprintf (dest, "\n<tr>\n");
                if (rh) {
                    fprintf (dest,"<td></td>");
                }
                for (i=0; i<columns.lLength; i++) {
                    ch->ExportCell (dest,format,0,columns.lData[i]);
                }
                fprintf (dest, "\n</tr>\n");
            }
            for (j=0; j<rows.lLength; j++) {
                fprintf (dest, "\n<tr>\n");
                if (rh) {
                    rh->ExportCell (dest,format,rows.lData[j],0);
                }
                for (i=0; i<columns.lLength; i++) {
                    ExportCell (dest,format,rows.lData[j],columns.lData[i]);
                }
                fprintf (dest, "\n</tr>\n");
            }
            fprintf (dest, "\n</table>\n</body>\n</html>\n");
        }
        break;

        case 4: { // ASCII art table
            _SimpleList width;

            for (i=0; i<columns.lLength; i++) {
                k = ch?ch->GetCellWidth (0,columns.lData[i]):2;

                for (j=0; j<rows.lLength; j++) {
                    t = GetCellWidth (rows.lData[j],columns.lData[i]);
                    if (t>k) {
                        k = t;
                    }
                }
                width << k;
            }

            fprintf (dest,"%s\n\n", title.sData);

            _String rowSeparator (128L, true);
            rowSeparator << '+';
            for (i=0; i<columns.lLength; i++) {
                for (j=-1; j<=width.lData[i]; j++) {
                    rowSeparator << '-';
                }
                rowSeparator << '+';
            }
            rowSeparator.Finalize();

            fprintf (dest, "%s\n", rowSeparator.sData);

            if (ch) {
                fputc ('|', dest);
                for (i=0; i<columns.lLength; i++) {
                    k = ch->GetCellWidth (0,columns.lData[i]);
                    ch->ExportCell (dest,format,0,columns.lData[i]);
                    for (t = k; t < width.lData[i]; t++) {
                        fputc (' ', dest);
                    }
                    fputc ('|', dest);
                }
                fprintf (dest, "\n%s\n", rowSeparator.sData);
            }

            for (j=0; j<rows.lLength; j++) {
                fputc ('|', dest);
                for (i=0; i<columns.lLength; i++) {
                    k = GetCellWidth (rows.lData[j],columns.lData[i]);
                    ExportCell (dest,format,rows.lData[j],columns.lData[i]);
                    for (t = k; t < width.lData[i]; t++) {
                        fputc (' ', dest);
                    }
                    fputc ('|', dest);
                }
                fprintf (dest, "\n%s\n", rowSeparator.sData);
            }
        }
        case 5: { // hyphy matrix
            fprintf (dest,"\n{\n");
            for (j=0; j<rows.lLength; j++) {
                fputc ('{',dest);
                for (i=0; i<columns.lLength-1; i++) {
                    ExportCell (dest,format,rows.lData[j],columns.lData[i]);
                    fputc (',',dest);
                }
                ExportCell (dest,format,rows.lData[j],columns.lData[i]);
                fprintf (dest,"}\n");
            }
            fprintf (dest,"}");
        }
        break;
        break;
        default: {
            _String wrongFormat ("SaveTable was passed an invalid format code");
            ProblemReport (wrongFormat);
        }
        }
    }
}

//__________________________________________________________________

long    _HYTable::GetCellWidth (long r, long c)
{
    long idx  = r*horizontalSpaces.lLength+c,
         type = cellTypes.lData[idx];

    if (type&HY_TABLE_ICON) {
        return iconExportString.sLength;
    }

    return ((_String*)GetCellData (c,r))->sLength;
}

//__________________________________________________________________

void    _HYTable::ExportCell (FILE* dest, long format, long r, long c)
{
    long idx  = r*horizontalSpaces.lLength+c,
         type = cellTypes.lData[idx];

    _String * contents;

    bool boldOn   = type&HY_TABLE_BOLD,
         italicOn = type&HY_TABLE_ITALIC;

    if (type&HY_TABLE_ICON) {
        contents = &iconExportString;
    } else {
        contents = ((_String*)GetCellData (c,r));
    }

    switch  (format) {
    case 2: { // LaTEX table
        if (boldOn) {
            fprintf (dest, "{\\bf ");
        }
        if (italicOn) {
            fprintf (dest, "{\\it ");
        }
    }
    break;
    case 3: { // HTML table
        fprintf (dest, "\n\t<td align = \"left\" valign = \"center\" bgcolor = \"#%s\">",
                 ((type&HY_TABLE_BEVELED)?backColor2:backColor).HTMLColor().getStr());
        if (boldOn) {
            fprintf (dest, "<b>");
        }
        if (italicOn) {
            fprintf (dest, "<i>");
        }
        fprintf (dest,"<font color = \"#%s\"> ",textColor.HTMLColor().getStr());
    }
    break;
    case 4:
        fputc (' ', dest);
        break;
    }

    if (format == 2) {
        fprintf (dest, "%s", contents->Replace ("_","\\_",true).sData);
    } else {
        fprintf (dest, "%s", contents->sData);
    }

    switch  (format) {
    case 2: { // LaTEX table
        if (italicOn) {
            fprintf (dest, "}");
        }
        if (boldOn) {
            fprintf (dest, "}");
        }
    }
    break;
    case 3: { // HTML table
        fprintf (dest,"</font>");
        if (italicOn) {
            fprintf (dest, "</i>");
        }
        if (boldOn) {
            fprintf (dest, "</b>");
        }
        fprintf (dest, " </td>");
    }
    case 4:
        fputc (' ', dest);
        break;
    }
}

//__________________________________________________________________

void    _HYTable::GetTableFormats (_List& rec)
{
    _String format ("Comma Separated");
    rec && & format;
    format = "Tab Separated";
    rec && & format;
    format = "LaTEX Table";
    rec && & format;
    format = "HTML Table";
    rec && & format;
    format = "ASCII Table";
    rec && & format;
    format = "HyPhy Matrix";
    rec && & format;
}

//__________________________________________________________________

void    _HYTable::HandleKeyMove (char dir, bool )
{
    bool         rowSel = selectionType&HY_TABLE_SEL_ROWS;

    _SimpleList  ts;

    if (rowSel) {
        GetRowSelection(ts);
        if (ts.lLength<=1) {
            long adder = -1,
                 startIndex = -1;

            if (dir) {
                adder = 1;
            }

            if (ts.lLength == 1) {
                startIndex = ts.lData[0];
            } else {
                if (dir) {
                    startIndex = -1;
                } else {
                    startIndex = verticalSpaces.lLength;
                }
            }

            startIndex += adder;
            ts.Clear();
            while ((startIndex>=0)&&(startIndex<verticalSpaces.lLength)) {
                if ((cellTypes.lData[startIndex*horizontalSpaces.lLength]&HY_TABLE_CANTSELECT)==0) {
                    ts << startIndex;
                    bool mod;
                    mod = ScrollToRow(startIndex);

                    ExpungeSelection ();
                    SetRowSelection (ts);
                    if (mod) {
                        forceUpdateForScrolling = true;
                        _MarkForUpdate();
                        forceUpdateForScrolling = false;
                    } else {
                        _MarkCellsForUpdate (ts);
                    }
                    break;
                }
                startIndex += adder;
            }
        }
    } else {
        GetSelection (ts);
        if (ts.lLength<=1) {
            long adder = 1,
                 startIndex = -1;

            switch (dir) {
            case 0: // up
                adder = -horizontalSpaces.lLength;
                break;
            case 1: // down
                adder = horizontalSpaces.lLength;
                break;
            case 2: // left
                adder = -1;
                break;
            }

            if (ts.lLength == 1) {
                startIndex = ts.lData[0];
            } else {
                switch (dir) {
                case 0: // up
                    startIndex = cellTypes.lLength;
                    break;
                case 1: // down
                    startIndex = -adder;
                    break;
                case 3: // right
                    startIndex = horizontalSpaces.lLength;
                    break;
                }
            }

            startIndex += adder;
            ts.Clear();
            while ((startIndex>=0)&&(startIndex<cellTypes.lLength)) {
                if ((cellTypes.lData[startIndex]&HY_TABLE_CANTSELECT)==0) {
                    ts << startIndex;
                    bool mod;
                    if (dir<2) {
                        mod = ScrollToRow(startIndex/horizontalSpaces.lLength);
                    } else {
                        mod = ScrollToColumn(startIndex%horizontalSpaces.lLength);
                    }
                    ExpungeSelection ();
                    SetSelection (ts,true);
                    if (mod) {
                        forceUpdateForScrolling = true;
                        _MarkForUpdate();
                        forceUpdateForScrolling = false;
                    } else {
                        _MarkCellsForUpdate (ts);
                    }
                    break;
                }
                startIndex += adder;
            }
        }
    }
}

//__________________________________________________________________
// HYHList
//__________________________________________________________________

_SimpleList*          openArrow   = nil,
                      *       closedArrow = nil;

//__________________________________________________________________

_HYHList::_HYHList (_HYRect relr,Ptr w,_List& ld, bool sing):
    _HYTable (relr,w,ld.lLength,2,20,20,HY_TABLE_STATIC_TEXT)
{
    listData.Duplicate (&ld);

    if (!openArrow) {
        openArrow = new _SimpleList ((unsigned long)3);
        checkPointer (openArrow);

        (*openArrow) << (long) ProcureIconResource(131);
        (*openArrow) << 16;
        (*openArrow) << 16;

        closedArrow = new _SimpleList ((unsigned long)3);
        checkPointer (closedArrow);

        (*closedArrow) << (long) ProcureIconResource(132);
        (*closedArrow) << 16;
        (*closedArrow) << 16;
    }

    _HYFont     df;
#ifdef __MAC__
    df.face = "Times";
    df.size = 12;
#else
#ifdef __HYPHY_GTK__
    df.face = _HY_SANS_FONT;
    df.size = 12;
#else
    df.face = "Arial";
    df.size = 14;
#endif
#endif

    df.style = HY_FONT_PLAIN;
    SetFont (df);

    for (long k=0; k<ld.lLength; k++) {
        _List * thisEntry = (_List*) listData (k);
        SetCellData (closedArrow, k, 0, HY_TABLE_ICON | HY_TABLE_CANTSELECT,true);
        SetCellData ((*thisEntry)(0), k, 1, HY_TABLE_STATIC_TEXT|HY_TABLE_BOLD ,true);
        rubrikIndex << k;
    }

    SetColumnSpacing  (1,relr.right-40-HY_SCROLLER_WIDTH,false);

    if (settings.width & HY_COMPONENT_H_SCROLL) {
        FitToHeight (relr.bottom-HY_SCROLLER_WIDTH);
    } else {
        FitToHeight (relr.bottom);
    }

    selectionType = HY_TABLE_DONT_SIZE|HY_TABLE_NO_COLS_LINES|HY_TABLE_DONT_GROW_HORIZ|HY_TABLE_DONT_GROW_VERT;
    single        = sing;
}

//__________________________________________________________________

void    _HYHList::AddRubrik (_String& rubrikName, _List& rubrikItems, long index)
{
    long        insertionPoint = 0;
    if ((index < 0) && (index >= rubrikIndex.lLength)) {
        index          = rubrikIndex.lLength;
        if (HasPadding()) {
            insertionPoint = verticalSpaces.lLength-1;
        } else {
            insertionPoint = verticalSpaces.lLength;
        }
    } else {
        insertionPoint = rubrikIndex.lData[index];
    }

    _List * newRubrik = new _List;

    checkPointer (newRubrik);

    (*newRubrik) && & rubrikName;
    (*newRubrik) && & rubrikItems;

    listData.InsertElement (newRubrik, index, false);
    rubrikIndex.InsertElement ((BaseRef)insertionPoint, index, false, false);
    DeleteObject (newRubrik);


    for (long   k = index+1; k < rubrikIndex.lLength; k++) {
        rubrikIndex.lData[k] ++;
    }


    AddRow      (insertionPoint, 20, HY_TABLE_STATIC_TEXT);
    SetCellData (closedArrow, insertionPoint, 0, HY_TABLE_ICON | HY_TABLE_CANTSELECT,true);
    SetCellData (&rubrikName, insertionPoint, 1, HY_TABLE_STATIC_TEXT|HY_TABLE_BOLD ,true);

    if (settings.width & HY_COMPONENT_H_SCROLL) {
        FitToHeight (rel.bottom-rel.top-HY_SCROLLER_WIDTH+1);
    } else {
        FitToHeight (rel.bottom-rel.top+1);
    }

    _MarkForUpdate();

}

//__________________________________________________________________

long    _HYHList::IsSingleRubrik (_SimpleList& sl)
{
    if (sl.lLength == 0) {
        return -1;
    }

    if (rubrikIndex.lLength == 0) {
        return 0;
    }

    long rIndex = 1;
    while ((sl.lData[0] >= rubrikIndex.lData[rIndex]) && (rIndex < rubrikIndex.lLength)) {
        rIndex ++;
    }

    if (rIndex == rubrikIndex.lLength) {
        sl.Offset (-rubrikIndex.lData[rIndex-1]);
        return rIndex-1;
    } else {
        long nextB = rubrikIndex.lData[rIndex],
             i = 1;

        for (; (i< sl.lLength)&&(sl.lData[i]<nextB); i++) ;

        if (i == sl.lLength) {
            sl.Offset (-rubrikIndex.lData[rIndex-1]);
            return rIndex-1;
        }
    }

    return -1;
}

//__________________________________________________________________

void    _HYHList::DeleteRubrik (long index)
{
    if ((index>=0) && (index<rubrikIndex.lLength)) {
        long delCount;

        if (index <  rubrikIndex.lLength - 1) {
            delCount = rubrikIndex.lData[index+1] - rubrikIndex.lData[index];
        } else {
            delCount = HasPadding()?verticalSpaces.lLength - rubrikIndex.lData[index]-1:verticalSpaces.lLength - rubrikIndex.lData[index];
        }

        for (long k=index+1; k<rubrikIndex.lLength; k++) {
            rubrikIndex.lData[k] -= delCount;
        }

        while (delCount) {
            DeleteRow (rubrikIndex.lData[index]);
            delCount --;
        }

        rubrikIndex.Delete (index);
        listData.Delete (index);

        if (settings.width & HY_COMPONENT_H_SCROLL) {
            FitToHeight (rel.bottom-rel.top-HY_SCROLLER_WIDTH+1);
        } else {
            FitToHeight (rel.bottom-rel.top+1);
        }
    }
    _MarkForUpdate();
}


//__________________________________________________________________

long    _HYHList::IsARubrik (long index)
{
    return rubrikIndex.Find (index);
}

//__________________________________________________________________

long    _HYHList::FindString (_String* s, long startat)
{
    for (long k=(startat>=0?startat:0); k<listData.lLength; k++) {
        _List * thisRubrik = (_List*)(*((_List*)listData(k)))(1);
        for (long j=0; j<thisRubrik->lLength; j++)
            if (s->Equal((_String*)(*thisRubrik)(j))) {
                return (k<<16)+j;
            }
    }
    return -1;
}

//__________________________________________________________________

bool    _HYHList::IsRubrikOpen (long index)
{
    if ((index>=0)&&(index<listData.lLength)) {
        if (index<listData.lLength-1) {
            return (rubrikIndex[index+1]-rubrikIndex[index]-1>0);
        } else {
            if (HasPadding()) {
                return rubrikIndex[index]<verticalSpaces.lLength-2;
            } else {
                return rubrikIndex[index]<verticalSpaces.lLength-1;
            }
        }
    }
    return false;
}

//__________________________________________________________________

long    _HYHList::RubrikIndex (long index)
{
    long result = 0;
    while ((result<rubrikIndex.lLength)&&(rubrikIndex.lData[result]<index)) {
        result ++;
    }

    if ((rubrikIndex.lData[result]>index)||(result==rubrikIndex.lLength)) {
        result--;
    }

    return (result<<16)+(index-rubrikIndex.lData[result]);
}


//__________________________________________________________________

long    _HYHList::AbsoluteIndex (long rubrik, long item)
{
    long result = 0,
         k;

    for (k=0; k<rubrik; k++) {
        _List * thisEntry = (_List*) listData (k);
        result = result + ((_List*)(*thisEntry)(1))->lLength + 1;
    }
    return result+item;
}

//__________________________________________________________________

void        _HYHList::ModifySelection (long h,long v, bool shift, bool control, bool message)
{
    if (h==0) {
        long f = IsARubrik(v);
        if (f>=0) {
            _List       * rubrikItems = (_List*) (*(_List*) listData (f))(1);
            if (IsRubrikOpen(f)) {
                SetCellData (closedArrow, v, 0, HY_TABLE_ICON | HY_TABLE_CANTSELECT,true);
                for (f=f+1; f<listData.lLength; f++) {
                    rubrikIndex.lData[f] -= rubrikItems->lLength;
                }

                for (f = v+1; f <= v+rubrikItems->lLength; f++) {
                    DeleteRow (v+1);
                }


                if (settings.width & HY_COMPONENT_H_SCROLL) {
                    FitToHeight (rel.bottom-rel.top-HY_SCROLLER_WIDTH+1);
                } else {
                    FitToHeight (rel.bottom-rel.top+1);
                }
            } else {
                for (f=f+1; f<listData.lLength; f++) {
                    rubrikIndex.lData[f] += rubrikItems->lLength;
                }

                SetCellData (openArrow, v, 0, HY_TABLE_ICON | HY_TABLE_CANTSELECT,true);

                for (f = v+1; f <= v+rubrikItems->lLength; f++) {
                    AddRow      (f,20, HY_TABLE_STATIC_TEXT);
                    SetCellData (&empty, f, 0, HY_TABLE_STATIC_TEXT | HY_TABLE_CANTSELECT,true);
                    SetCellData ((*rubrikItems)(f-v-1), f, 1, HY_TABLE_STATIC_TEXT,true);
                }

                if (settings.width & HY_COMPONENT_H_SCROLL) {
                    FitToHeight (rel.bottom-rel.top-HY_SCROLLER_WIDTH+1);
                } else {
                    FitToHeight (rel.bottom-rel.top+1);
                }
            }
            _SimpleList modRows;
            for (f=v; f<verticalSpaces.lLength; f++) {
                modRows << 2*f;
                modRows << 2*f+1;
            }
            _MarkCellsForUpdate (modRows);

            _HYTable::ModifySelection (1,v,false,false,message);
            return;
        }
    }
    _HYTable::ModifySelection (h,v,(!single)&&shift,(!single)&&control,message);
}

//__________________________________________________________________

void    _HYHList::FitToHeight (long height)
{
    bool           hasPadding = HasPadding();
    long           h = verticalSpaces.lData[verticalSpaces.lLength-(hasPadding?2:1)];

    if (hasPadding) {
        if (h<height) {
            SetRowSpacing (verticalSpaces.lLength-1,height-h-GetRowSpacing (verticalSpaces.lLength-1),false);
        } else {
            DeleteRow (verticalSpaces.lLength-1);
        }
    } else if (h<height) {
        AddRow (-1,height-h,HY_TABLE_STATIC_TEXT|HY_TABLE_CANTSELECT);
    }

    SetVisibleSize (rel);
}

//__________________________________________________________________

bool    _HYHList::HasPadding (void)
{
    if (cellTypes.lLength) {
        return (cellTypes.lData[cellTypes.lLength-1] & HY_TABLE_CANTSELECT);
    } else {
        return false;
    }
}

//__________________________________________________________________

void    _HYHList::HandleKeyMove (char dir, bool mod)
{
    _SimpleList  ts;
    GetSelection (ts);
    if (ts.lLength<=1) {
        if (dir<2) {
            _HYTable::HandleKeyMove (dir,mod);
            return;
        }

        if (ts.lLength == 1) {
            long f = IsARubrik (ts.lData[0]/2);
            if ((f>=0)&&(((dir == 3)&&(!IsRubrikOpen(f)))||((dir == 2)&&(IsRubrikOpen(f))))) {
                ModifySelection (0, ts.lData[0]/2, false, false,false);
            }
        }
    }
}
\ No newline at end of file
+/*
 
 HyPhy - Hypothesis Testing Using Phylogenies.
 
 Copyright (C) 1997-now
 Core Developers:
 Sergei L Kosakovsky Pond (spond at ucsd.edu)
 Art FY Poon    (apoon at cfenet.ubc.ca)
 Steven Weaver (sweaver at ucsd.edu)
 
 Module Developers:
 Lance Hepler (nlhepler at gmail.com)
 Martin Smith (martin.audacis at gmail.com)
 
 Significant contributions from:
 Spencer V Muse (muse at stat.ncsu.edu)
 Simon DW Frost (sdf22 at cam.ac.uk)
 
 Permission is hereby granted, free of charge, to any person obtaining a
 copy of this software and associated documentation files (the
 "Software"), to deal in the Software without restriction, including
 without limitation the rights to use, copy, modify, merge, publish,
 distribute, sublicense, and/or sell copies of the Software, and to
 permit persons to whom the Software is furnished to do so, subject to
 the following conditions:
 
 The above copyright notice and this permission notice shall be included
 in all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 */

#include "HYTableComponent.h"
#include "HYUtils.h"
#include "HYPlatformWindow.h"
#include "HYTableWindow.h"
#include "HYGraphicPane.h"
#include "HYEventTypes.h"
#include "HYDialogs.h"
#include "batchlan.h"

#include "math.h"

#ifdef    __HYPHYDMALLOC__
#include "dmalloc.h"
#endif

//extern     _HYColor   _BLACK_;


_HYColor tableDefaultBk  = {235,235,235},
         tableDefaultBk2 = {200,200,200};

_String  iconExportString ("[ICON]");

//__________________________________________________________________

_HYTable::_HYTable(_HYRect rel,Ptr w,long r, long c, long h, long v, long defType):
    _HYComponent (rel,w)
{
    SetTableSize (r,c,defType,h,v);
    SetTextColor ((_HYColor) {
        0,0,0
    });
    SetBackColor (tableDefaultBk);
    SetBackColor2(tableDefaultBk2);
    _HYFont      defFont;

#ifdef __MAC__
    defFont.face = "Times";
    defFont.size = 12;
#else
#ifdef __HYPHY_GTK__
    defFont.face = _HY_SANS_FONT;
    defFont.size = 11;
#else
    defFont.face = "Verdana";
    defFont.size = 12;
#endif
#endif

    defFont.style = HY_FONT_PLAIN;
    SetFont      (defFont);
    editCellID      = -1;
    selectionType   = 0;
    undoString      = nil;
    undoIndex       = undoIndex2 = -1;
    stretchWidth    = -1;
    stretchHeight   = -1;
}

//__________________________________________________________________

_HYTable::~_HYTable(void)
{
}

//__________________________________________________________________

void    _HYTable::SetTableSize(long r, long c, long defType, long h, long v)
{
    long      i;
    for (i=h; i<=c*h; i+=h) {
        horizontalSpaces<<i;
    }

    for (i=0; i<r; i++) {
        AddRow (-1,v,defType);
    }
}

//__________________________________________________________________

void    _HYTable::AddRow (long where, long h, long defType)
{
    long        i,w;
    if (where==-1) {
        where = verticalSpaces.lLength;
    }
    verticalSpaces<<0;
    for (i=verticalSpaces.lLength-1; i>where; i--) {
        verticalSpaces.lData[i]=verticalSpaces.lData[i-1]+h;
    }
    if (where) {
        verticalSpaces.lData[where]=verticalSpaces.lData[where-1]+h;
    } else {
        verticalSpaces.lData[0] = h;
    }

    w = where*horizontalSpaces.lLength;
    if ((defType&HY_TABLE_STATIC_TEXT)||(defType&HY_TABLE_EDIT_TEXT))
        // text
    {
        _String dummy;
        for (i=0; i<horizontalSpaces.lLength; i++) {
            cellData.InsertElement (&dummy,w,true);
            cellTypes.InsertElement((BaseRef)defType,w,false,false);
        }
    } else
        // icons
    {
        _SimpleList dummy;
        for (i=0; i<horizontalSpaces.lLength; i++) {
            cellData.InsertElement (&dummy,w,true);
            cellTypes.InsertElement((BaseRef)defType,w,false,false);
        }
    }

    stretchHeight = -1;
}

//__________________________________________________________________

void    _HYTable::RequestSpace (long r, long c)
{
    verticalSpaces.RequestSpace (r);
    cellData.RequestSpace (r*c);
    cellTypes.RequestSpace (r*c);
}

//__________________________________________________________________

void    _HYTable::DeleteRow (long where)
{
    long        i,h;
    if ((where<0)||(where>=verticalSpaces.lLength)) {
        return;
    }
    h = GetRowSpacing (where);

    for (i=where; i<verticalSpaces.lLength-1; i++) {
        verticalSpaces.lData[i]=verticalSpaces.lData[i+1]-h;
    }

    h = where*horizontalSpaces.lLength;
    for (i=0; i<horizontalSpaces.lLength; i++) {
        cellData.Delete (h);
        cellTypes.Delete(h);
    }
    verticalSpaces.Delete (verticalSpaces.lLength-1);

    stretchHeight = -1;
}

//__________________________________________________________________

void    _HYTable::AddColumn (long where, long h, long defType)
{
    long        i,w;
    if (where==-1) {
        where = horizontalSpaces.lLength;
    }
    horizontalSpaces<<0;
    for (i=horizontalSpaces.lLength-1; i>where; i--) {
        horizontalSpaces.lData[i]=horizontalSpaces.lData[i-1]+h;
    }
    if (where) {
        horizontalSpaces.lData[where]=horizontalSpaces.lData[where-1]+h;
    } else {
        horizontalSpaces.lData[0] = h;
    }
    w = where*horizontalSpaces.lLength;
    if ((defType&HY_TABLE_STATIC_TEXT)||(defType&HY_TABLE_EDIT_TEXT))
        // text
    {
        _String dummy;
        for (i=0; (i<horizontalSpaces.lLength)&&(w<cellData.lLength); i++, w+=verticalSpaces.lLength) {
            cellData.InsertElement (&dummy,w,true);
            cellTypes.InsertElement((BaseRef)defType,w,false,false);
        }
    } else
        // icons
    {
        _SimpleList dummy;
        for (i=0; (i<horizontalSpaces.lLength)&&(w<cellData.lLength); i++, w+=verticalSpaces.lLength) {
            cellData.InsertElement (&dummy,w,true);
            cellTypes.InsertElement((BaseRef)defType,w,false,false);
        }
    }

    stretchWidth = -1;
}

//__________________________________________________________________

void    _HYTable::DeleteColumn (long where)
{
    long        i,h;
    if ((where<0)||(where>=horizontalSpaces.lLength)) {
        return;
    }
    h = GetColumnSpacing (where);
    for (i=where; i<horizontalSpaces.lLength; i++) {
        horizontalSpaces.lData[i]=horizontalSpaces.lData[i+1]-h;
    }
    for (i=cellData.lLength-verticalSpaces.lLength-1+where; i>=0; i-=verticalSpaces.lLength) {
        cellData.Delete (i);
        cellTypes.Delete(i);
    }
    stretchWidth = -1;
}

//__________________________________________________________________

long    _HYTable::GetRowSpacing (long index)
{
    if (index>0) {
        return verticalSpaces.lData[index]-verticalSpaces.lData[index-1];
    }
    return verticalSpaces.lData[0];
}

//__________________________________________________________________

long    _HYTable::GetColumnSpacing (long index)
{
    if (index>0) {
        return horizontalSpaces.lData[index]-horizontalSpaces.lData[index-1];
    }
    return horizontalSpaces.lData[0];
}

//__________________________________________________________________

void    _HYTable::ClearTable (bool all)
{
    cellData.Clear();
    cellTypes.Clear();
    if (all) {
        horizontalSpaces.Clear();
    }
    verticalSpaces.Clear();
    hOrigin = vOrigin = 0;
}

//__________________________________________________________________

void    _HYTable::SetTableFromMx (_Matrix* data, long rowWidth, long colHeight, long cellType)
{
    ClearTable (true);
    long        rc = data->GetHDim(),
                cc = data->GetVDim(),
                spacer = rowWidth;

    verticalSpaces.RequestSpace (rc);

    for (long k=0; k<rc; k++) {
        verticalSpaces.lData[k] = spacer;
        spacer+=rowWidth;
    }
    verticalSpaces.lLength = rc;

    spacer = colHeight;
    horizontalSpaces.RequestSpace (cc);

    for (long k=0; k<cc; k++) {
        horizontalSpaces.lData[k] = spacer;
        spacer+=colHeight;
    }
    horizontalSpaces.lLength = cc;

    cellTypes.RequestSpace (cc*rc);
    for (long k=0; k<rc*cc; k++) {
        cellTypes.lData[k] = cellType;
    }

    cellTypes.lLength = rc*cc;

    cellData.RequestSpace (cc*rc);

    BaseRef * brf = (BaseRef*)(cellData.lData);

    for (long h=0; h<rc*cc; h++) {
        _String* cellData = new _String ((*data)(h/cc,h%cc));
        if (!(brf[h] = cellData)) {
            checkPointer (cellData);
        }
    }


    cellData.lLength = rc*cc;
}

//__________________________________________________________________

void    _HYTable::SetBackColor (_HYColor nc)
{
    backColor = nc;
    _SetBackColor (nc);
}

//__________________________________________________________________

void    _HYTable::SetBackColor2 (_HYColor nc)
{
    backColor2 = nc;
    _SetBackColor2 (nc);
}

//__________________________________________________________________

void    _HYTable::SetTextColor (_HYColor nc)
{
    textColor = nc;
}

//__________________________________________________________________

void    _HYTable::SetFont (_HYFont& nf)
{
    bool  t = !textFont.face.Equal(&nf.face);
    if ( textFont.size!=nf.size || textFont.style!=nf.style ||t) {
        textFont.size = nf.size;
        textFont.style = nf.style;
        if (t) {
            textFont.face = nf.face;
            _SetFont ();
        }
    }
}

//__________________________________________________________________

int     _HYTable::GetMaxW(void)
{
    long res = horizontalSpaces.lData[horizontalSpaces.lLength-1]+((settings.width&HY_COMPONENT_V_SCROLL)?HY_SCROLLER_WIDTH:0);
    if (res > 0x7ffff) {
        return 0x7ffff;
    }
    return res;
}

//__________________________________________________________________

int     _HYTable::GetMaxH(void)
{
    long res = verticalSpaces.lData[verticalSpaces.lLength-1]+((settings.width&HY_COMPONENT_H_SCROLL)?HY_SCROLLER_WIDTH:0);
    if (res > 0x7ffff) {
        return 0x7ffff;
    }
    return res;
}

//__________________________________________________________________

int     _HYTable::GetMaxLW(void)
{
    if (selectionType&HY_TABLE_DONT_GROW_HORIZ) {
        return _HYComponent::GetMaxW();
    } else if (selectionType&HY_TABLE_HORZ_STRETCH) {
        return 0x7ffff;
    } else {
        return GetMaxW();
    }
}

//__________________________________________________________________

int     _HYTable::GetMaxLH(void)
{
    if (selectionType&HY_TABLE_DONT_GROW_VERT) {
        return _HYComponent::GetMaxH();
    } else if (selectionType&HY_TABLE_VERT_STRETCH) {
        return 0x7ffff;
    } else {
        return GetMaxH();
    }
}

//__________________________________________________________________

bool        _HYTable::CheckForHSizeLocation (long h)
{
    h += hOrigin;
    for (long k = 0; k<horizontalSpaces.lLength; k++)
        if ((h>=horizontalSpaces.lData[k]-2)&&(h<=horizontalSpaces.lData[k]+2)) {
            return true;
        }
    return false;
}

//__________________________________________________________________

void        _HYTable::DragRow(long row, long after)
{
    if ((row>=0)&&(row<verticalSpaces.lLength)&&(after<verticalSpaces.lLength)&&(row!=after)) {
        cellTypes.Displace (row*horizontalSpaces.lLength,(row+1)*horizontalSpaces.lLength-1,
                            (after-row)*horizontalSpaces.lLength);
        cellData.Displace (row*horizontalSpaces.lLength,(row+1)*horizontalSpaces.lLength-1,
                           (after-row)*horizontalSpaces.lLength);
        _MarkForUpdate();
    }
}

//__________________________________________________________________

long        _HYTable::FindString (_String* s, long startat)
{
    for (long k=(startat>=0?startat:0); k<cellData.lLength; k++)
        if ((cellTypes.lData[k]&(HY_TABLE_STATIC_TEXT+HY_TABLE_EDIT_TEXT))&&
                (s->Equal((_String*)cellData(k))))

        {
            return k;
        }
    return -1;
}

//__________________________________________________________________

long        _HYTable::FindClickedTableCell (long hc,long vc,long& h, long& v)
{
    hc+=hOrigin;
    vc+=vOrigin;

    for (h = 0; h<horizontalSpaces.lLength; h++)
        if (hc<horizontalSpaces.lData[h]-2) {
            break;
        }
    if (h<horizontalSpaces.lLength) {
        for (v = 0; v<verticalSpaces.lLength; v++)
            if (vc<verticalSpaces.lData[v]-2) {
                break;
            }

        if (v<verticalSpaces.lLength) {
            long index = v*horizontalSpaces.lLength+h;
            if (cellTypes.lData[index]&HY_TABLE_PULLDOWN) {
                if ((hc>horizontalSpaces.lData[h]-15)&&(abs(2*(verticalSpaces.lData[v]-vc)-GetRowSpacing(v))<tPDMh)) {
                    return -2;
                }
            }
            return index;
        }
    }
    return -1;
}

//__________________________________________________________________

/*void      _HYTable::PlotAlignedIcon (_HYRect& store, long iconW, long iconH)
{

}*/

//__________________________________________________________________

void        _HYTable::EditBoxHandler (long index, _HYRect& r)
{
    if (_HasTextBox()) {
        _String editRes = _RetrieveTextValue();
        _KillTextBox();
        if (!editRes.Equal ((_String*)GetCellData(editCellID%horizontalSpaces.lLength,
                            editCellID/horizontalSpaces.lLength))) {
            SetCellData (&editRes,editCellID/horizontalSpaces.lLength,
                         editCellID%horizontalSpaces.lLength,
                         cellTypes.lData[editCellID],
                         true);
            if (messageRecipient) {
                messageRecipient->ProcessEvent (generateTableEditCellEvent(GetID(),editCellID));
            }
        }
        _SimpleList     dummy;
        dummy           <<  editCellID;
        _MarkCellsForUpdate (dummy);
        editCellID      = -1;
    }

    if (index>=0) {
        editCellID= index;
        long    v = index/horizontalSpaces.lLength;
        index     = index%horizontalSpaces.lLength;

        _HYRect textRect = r;

        if (index) {
            textRect.left += horizontalSpaces.lData[index-1] - hOrigin;
        } else {
            textRect.left -= hOrigin;
        }
        if (v) {
            textRect.top  += verticalSpaces.lData[v-1] - vOrigin;
        } else {
            textRect.top  -= vOrigin;
        }

        textRect.right     = r.left+horizontalSpaces.lData[index] - hOrigin;
        textRect.bottom    = r.top+verticalSpaces.lData[v] - vOrigin;

        if (settings.width&HY_COMPONENT_V_SCROLL) {
            if (textRect.right > r.right - HY_SCROLLER_WIDTH) {
                textRect.right = r.right - HY_SCROLLER_WIDTH;
            }
        } else if (textRect.right >= r.right) {
            textRect.right = r.right - 1;
        }

        if (settings.width&HY_COMPONENT_H_SCROLL) {
            if (textRect.bottom > r.bottom - HY_SCROLLER_WIDTH) {
                textRect.bottom = r.bottom - HY_SCROLLER_WIDTH;
            }
        } else if (textRect.bottom >= r.bottom) {
            textRect.bottom = r.bottom - 1;
        }


        textRect.left   +=2;
        //textRect.top  +=2;
        textRect.right  -=2;
        //textRect.bottom -=3;

        if ((textRect.right>textRect.left+textFont.size)&&(textRect.bottom>textRect.top+textFont.size)) {
            if (messageRecipient) {
                messageRecipient->ProcessEvent(generateKeyboardFocusEvent(GetID()));
            }
            _CreateTextBox (textRect, *(_String*)GetCellData(index,v));
            _SimpleList     dummy;
            dummy           <<  v*horizontalSpaces.lLength+index;
            _MarkCellsForUpdate (dummy);
        }
    } else {
        if ((messageRecipient)&&((selectionType&HY_TABLE_IS_FOCUSED)==0)) {
            messageRecipient->ProcessEvent(generateKeyboardFocusEvent(-1));
        }
    }
}

//__________________________________________________________________

void        _HYTable::ClearSelection (bool standAlone)
{
    _SimpleList modCells;
    for (long c = 0; c<cellTypes.lLength; c++) {
        if (cellTypes.lData[c]&HY_TABLE_SELECTED) {
            cellTypes.lData[c] -= HY_TABLE_SELECTED;
            modCells << c;
        }
    }
    if (modCells.lLength) {
        _MarkCellsForUpdate(modCells);
        if (_HasTextBox()) {
            _HYRect        dummy;
            EditBoxHandler (-1,dummy);
        }
        if (standAlone&&messageRecipient) {
            messageRecipient->ProcessEvent (generateTableChangeSelEvent(GetID()));
        }
    }
}

//__________________________________________________________________

void        _HYTable::SetRowSelection (const _SimpleList& rows)
{
    ClearSelection (false);
    _SimpleList modCells;
    modCells.RequestSpace (rows.lLength * horizontalSpaces.lLength);
    for (long t=0; t<rows.lLength; t++) {
        long rowN = rows.lData[t];
        if ((rowN>=0)&&(rowN<verticalSpaces.lLength)) {
            for (long k=rowN*horizontalSpaces.lLength; k<(rowN+1)*horizontalSpaces.lLength; k++) {
                if (!(cellTypes.lData[k]&HY_TABLE_CANTSELECT)) {
                    cellTypes.lData[k]|=HY_TABLE_SELECTED;
                    modCells << k;
                }
            }
        }
    }
    if (modCells.lLength) {
        for (long t=0; t<rows.lLength; t++) {
            _MarkRowForUpdate(rows.lData[t]);
        }

        if (_HasTextBox()) {
            _HYRect        dummy;
            EditBoxHandler (-1,dummy);
        }
        if (messageRecipient) {
            messageRecipient->ProcessEvent (generateTableChangeSelEvent(GetID()));
        }
    }
}

//__________________________________________________________________

void        _HYTable::SetColumnSelection (const _SimpleList& columns)
{
    ClearSelection (false);
    _SimpleList modCells;
    modCells.RequestSpace (columns.lLength * verticalSpaces.lLength);
    for (long t=0; t<columns.lLength; t++) {
        long rowN = columns.lData[t];
        if ((rowN>=0)&&(rowN<verticalSpaces.lLength)) {
            for (long k=rowN; k<cellTypes.lLength; k+=horizontalSpaces.lLength) {
                if (!(cellTypes.lData[k]&HY_TABLE_CANTSELECT)) {
                    cellTypes.lData[k]|=HY_TABLE_SELECTED;
                    modCells << k;
                }
            }
        }
    }
    if (modCells.lLength) {
        for (long t=0; t<columns.lLength; t++) {
            _MarkColumnForUpdate(columns.lData[t]);
        }

        if (_HasTextBox()) {
            _HYRect        dummy;
            EditBoxHandler (-1,dummy);
        }
        if (messageRecipient) {
            messageRecipient->ProcessEvent (generateTableChangeSelEvent(GetID()));
        }
    }
}


//__________________________________________________________________

void        _HYTable::ModifySelection (long h,long v, bool shift, bool control, bool message)
{
    long t = v*horizontalSpaces.lLength+h,t2;

    if (selectionType & HY_TABLE_SINGLE_SELECTION) {
        shift   = false;
        control = false;
    }

    if (cellTypes.lData[t]&HY_TABLE_CANTSELECT) {
        if (!shift) {
            ClearSelection();
            return;
        }
    }

    bool sel = cellTypes.lData[t]&HY_TABLE_SELECTED;

    _SimpleList  modCells;

    if (control) {
        _SimpleList  selection;
        GetSelection (selection);

        if (selection.lLength != 1) {
            return;
        }

        long    selRow = selection.lData[0]/horizontalSpaces.lLength,
                selCol = selection.lData[0]%horizontalSpaces.lLength,
                minRow,
                minCol,
                maxRow,
                maxCol;

        if (v<selRow) {
            minRow = v;
            maxRow = selRow;
        } else {
            maxRow = v;
            minRow = selRow;
        }

        if (h<selCol) {
            minCol = h;
            maxCol = selCol;
        } else {
            maxCol = h;
            minCol = selCol;
        }

        modCells.RequestSpace ((maxRow-minRow+1)*(maxCol-minCol+1));
        for (long r = minRow; r<=maxRow; r++)
            for (long c = r*horizontalSpaces.lLength+minCol; c<=r*horizontalSpaces.lLength+maxCol; c++) {
                if (!(cellTypes.lData[c]&HY_TABLE_CANTSELECT)) {
                    cellTypes.lData[c]|=HY_TABLE_SELECTED;
                }
                modCells<<c;
            }
    } else {
        if (shift) {
            if (!(cellTypes.lData[t]&HY_TABLE_CANTSELECT)) {
                if (sel) {
                    cellTypes.lData[t]-=HY_TABLE_SELECTED;
                } else {
                    cellTypes.lData[t]+=HY_TABLE_SELECTED;
                }
                modCells<<t;
            }
        } else {
            if (!sel) {
                for (long k=0; k<horizontalSpaces.lLength; k++)
                    for (long l=0; l<verticalSpaces.lLength; l++) {
                        t2 = l*horizontalSpaces.lLength+k;
                        if (t==t2) {
                            continue;
                        }
                        if (cellTypes.lData[t2]&HY_TABLE_CANTSELECT) {
                            continue;
                        }

                        if (cellTypes.lData[t2]&HY_TABLE_SELECTED) {
                            cellTypes.lData[t2]-=HY_TABLE_SELECTED;
                            modCells<<t2;
                        }
                    }
                if (!(cellTypes.lData[t]&HY_TABLE_CANTSELECT)) {
                    cellTypes.lData[t]+=HY_TABLE_SELECTED;
                }

                modCells<<t;
            } else {
                return;
            }
        }
    }

    if (selectionType&HY_TABLE_SEL_ROWS) {
        sel = cellTypes.lData[t]&HY_TABLE_SELECTED;
        if (sel)
            for (long k=v*horizontalSpaces.lLength; k<(v+1)*horizontalSpaces.lLength; k++) {
                if ((k==t)||(cellTypes.lData[k]&HY_TABLE_CANTSELECT)) {
                    continue;
                }
                cellTypes.lData[k]|=HY_TABLE_SELECTED;
                modCells<<k;
            }
        else
            for (long k=v*horizontalSpaces.lLength; k<(v+1)*horizontalSpaces.lLength; k++) {
                if ((k==t)||(cellTypes.lData[k]&HY_TABLE_CANTSELECT)) {
                    continue;
                }
                cellTypes.lData[k]&=HY_TABLE_DESELECT;
                modCells<<k;
            }
    } else if (selectionType&HY_TABLE_SEL_COLS) {
        sel = cellTypes.lData[t]&HY_TABLE_SELECTED;
        if (sel)
            for (long k=h; k<verticalSpaces.lLength*horizontalSpaces.lLength; k+=horizontalSpaces.lLength) {
                if ((k==t)||(cellTypes.lData[k]&HY_TABLE_CANTSELECT)) {
                    continue;
                }
                cellTypes.lData[k]|=HY_TABLE_SELECTED;
                modCells<<k;
            }
        else
            for (long k=h; k<verticalSpaces.lLength*horizontalSpaces.lLength; k+=horizontalSpaces.lLength) {
                if ((k==t)||(cellTypes.lData[k]&HY_TABLE_CANTSELECT)) {
                    continue;
                }
                cellTypes.lData[k]&=HY_TABLE_DESELECT;
                modCells<<k;
            }
    }

    if (modCells.lLength) {
        _MarkCellsForUpdate(modCells);
        if (_HasTextBox()) {
            _HYRect        dummy;
            EditBoxHandler (-1,dummy);
        }
        if (message&&messageRecipient) {
            messageRecipient->ProcessEvent (generateTableChangeSelEvent(GetID()));
        }
    }
}

//__________________________________________________________________

void        _HYTable::ExpungeSelection (void)
{
    _SimpleList  updateCells;
    for (long k=0; k<horizontalSpaces.lLength*verticalSpaces.lLength; k++) {
        if (cellTypes.lData[k]&HY_TABLE_SELECTED) {
            cellTypes.lData[k]&=HY_TABLE_DESELECT;
            updateCells<<k;
        }
    }
    _MarkCellsForUpdate (updateCells);
}

//__________________________________________________________________

void        _HYTable::SetColumnSpacing (long index, long h, bool update)
{
    if (h) {
        for (long k=index; k<horizontalSpaces.lLength; k++) {
            horizontalSpaces.lData[k]+=h;
        }
        if (update) {
            SetVisibleSize (rel);
            _MarkForUpdate();
        }
    }
    if (stretchWidth >= 0) {
        stretchWidth += h;
        if (stretchWidth < 0) {
            stretchWidth = -1;
        }
    }
}

//__________________________________________________________________

void        _HYTable::SetRowSpacing (long index, long v, bool update)
{
    if (v) {
        for (long k=index; k<verticalSpaces.lLength; k++) {
            verticalSpaces.lData[k]+=v;
        }
        if (update) {
            SetVisibleSize (rel);
            _MarkForUpdate();
        }

    }
    if (stretchHeight >= 0) {
        stretchHeight += v;
        if (stretchHeight < 0) {
            stretchHeight = -1;
        }
    }
}


//__________________________________________________________________

void        _HYTable::AutoFitColumn (long index, bool, bool increaseOnly)
{
    long maxWidth  = 0,
         cellWidth = 5;

    bool iconsOnly = true;

    for (long k=index; k<verticalSpaces.lLength*horizontalSpaces.lLength; k+=horizontalSpaces.lLength) {
        if (cellTypes.lData[k]&HY_TABLE_ICON) {
            cellWidth = ((_SimpleList*)cellData[k])->lData[1]+2;
        } else {
            _String*  cellValue = (_String*) cellData[k];
            if (cellTypes.lData[k]&HY_TABLE_BOLD) {
                textFont.style |= HY_FONT_BOLD;
            }
            if (cellTypes.lData[k]&HY_TABLE_ITALIC) {
                textFont.style |= HY_FONT_ITALIC;
            }
            cellWidth = GetVisibleStringWidth (*cellValue, textFont);
            if (cellTypes.lData[k]&HY_TABLE_PULLDOWN) {
                cellWidth += 5+tPDMw;
            }
            textFont.style = HY_FONT_PLAIN;
            iconsOnly = false;
        }
        if (cellWidth > maxWidth) {
            maxWidth = cellWidth;
        }
    }

    if (iconsOnly) {
        maxWidth+=2;
    } else {
        maxWidth+=textFont.size;
    }

    if (increaseOnly && (GetColumnSpacing(index)>maxWidth)) {
        return;
    }

    SetColumnSpacing (index,maxWidth-GetColumnSpacing(index),false);
}

//__________________________________________________________________

void        _HYTable::EnforceWidth (long width, long index, bool l)
{
    if ((index>=horizontalSpaces.lLength)||l) {
        index = horizontalSpaces.lLength-1;
    }

    if (horizontalSpaces.lData[index]<width) {
        long step = (width-horizontalSpaces.lData[index])/(index+1);
        if (!l)
            for (long k=0; k<index; k++) {
                horizontalSpaces.lData[k] += step*(k+1);
            }
        horizontalSpaces.lData[index] = width;
    }
}

//__________________________________________________________________

void        _HYTable::EnforceHeight (long height, long index, bool l)
{
    if ((index>=verticalSpaces.lLength)||l) {
        index = verticalSpaces.lLength-1;
    }

    if (verticalSpaces.lData[index]<height) {
        long step = (height-verticalSpaces.lData[index])/(index+1);
        if (!l)
            for (long k=0; k<index; k++) {
                verticalSpaces.lData[k] += step*(k+1);
            }
        verticalSpaces.lData[index] = height;
    }
}

//__________________________________________________________________

void        _HYTable::AutoFitWidth (void)
{
    for (long k=0; k<horizontalSpaces.lLength-1; k++) {
        AutoFitColumn (k,false);
    }
    AutoFitColumn (horizontalSpaces.lLength-1,true);
}


//__________________________________________________________________

void        _HYTable::AutoFitWidth (_HYTable& table2, long cshift)
{
    long k,
         w1,
         w2;

    AutoFitWidth();
    table2.AutoFitWidth();

    _SimpleList newWidths,
                oldWidths,
                oldWidths2;

    if (horizontalSpaces.lLength==table2.horizontalSpaces.lLength)
        for (k=0; k<horizontalSpaces.lLength; k++) {
            w1 = GetColumnSpacing (k);
            w2 = table2.GetColumnSpacing (k);
            if (k==horizontalSpaces.lLength-1)
                if ((settings.width&HY_COMPONENT_V_SCROLL)&&!(table2.settings.width&HY_COMPONENT_V_SCROLL)) {
                    w1 += HY_SCROLLER_WIDTH;
                } else if (!(settings.width&HY_COMPONENT_V_SCROLL)&&(table2.settings.width&HY_COMPONENT_V_SCROLL)) {
                    w2 += HY_SCROLLER_WIDTH;
                }

            if (w1>w2) {
                newWidths << w1;
            } else {
                newWidths << w2;
            }
            oldWidths << w1;
            oldWidths2 << w2;
        }
    else
        for (k=0; k<horizontalSpaces.lLength; k++) {
            w1 = GetColumnSpacing (k);
            w2 = table2.GetColumnSpacing (k+cshift);

            if (w1>w2) {
                newWidths << w1;
            } else {
                newWidths << w2;
            }
            oldWidths << w1;
            oldWidths2 << w2;
        }

    long shift1 = 0,
         shift2 = 0;

    for (k=0; k<newWidths.lLength; k++) {
        shift1 += newWidths.lData[k] - oldWidths.lData[k];
        shift2 += newWidths.lData[k] - oldWidths2.lData[k];
        horizontalSpaces.lData[k] += shift1;
        table2.horizontalSpaces.lData[k+cshift] += shift2;
    }

    for (; k < table2.horizontalSpaces.lLength; k++) {
        table2.horizontalSpaces.lData[k] += shift2;
    }


}

//__________________________________________________________________
bool    _HYTable::ProcessEvent(_HYEvent* e)
{
    if (e->EventClass() == _hyScrollingEvent) {
        long h,v,k,w;
        _String firstArg = e->EventCode().Cut (0,(v=e->EventCode().Find(','))-1);
        h = firstArg.toNum();
        firstArg = e->EventCode().Cut (v+1,-1);
        v = firstArg.toNum();
        if (h||v) {
            if (h) {
                w = horizontalSpaces.lData[horizontalSpaces.lLength-1]-hSize;
                if (settings.width&HY_COMPONENT_V_SCROLL) {
                    w += HY_SCROLLER_WIDTH;
                }
                k = (double)h/MAX_CONTROL_VALUE * w;
                if (!k) {
                    k = h>0?5:-5;
                }
                _SetHScrollerPos (_GetHScrollerPos()+(double)k*MAX_CONTROL_VALUE/w-h);
                hOrigin += k;
                if (hOrigin<0) {
                    hOrigin -= k;
                    k=-hOrigin;
                    hOrigin = 0;
                    _SetHScrollerPos (0);
                } else if (hOrigin+hSize > w+hSize) {
                    hOrigin -= k;
                    k = w-hOrigin;
                    hOrigin = w;
                    _SetHScrollerPos (MAX_CONTROL_VALUE);
                }
                _HScrollTable(k);

                if (messageRecipient) {
                    messageRecipient->ProcessEvent (generateScrollEvent(h,0,GetID()));
                }
            } else {
                w = verticalSpaces.lData[verticalSpaces.lLength-1]-vSize;
                if (settings.width&HY_COMPONENT_H_SCROLL) {
                    w += HY_SCROLLER_WIDTH;
                }
                k = ((double)v/MAX_CONTROL_VALUE) * w;
                if (!k) {
                    k = v>0?10:-10;
                }

                _SetVScrollerPos (_GetVScrollerPos()+(double)k*MAX_CONTROL_VALUE/w-v);
                vOrigin += k;
                if (vOrigin<0) {
                    vOrigin -= k;
                    k = - vOrigin;
                    vOrigin = 0;
                    _SetVScrollerPos (0);
                } else if (vOrigin+vSize > w+vSize) {
                    vOrigin -= k;
                    k = w-vOrigin;
                    vOrigin = w;
                    _SetVScrollerPos (MAX_CONTROL_VALUE);
                }
                _VScrollTable(k);

                if (messageRecipient) {
                    messageRecipient->ProcessEvent (generateScrollEvent(0,v,GetID()));
                }
            }
        }
        DeleteObject(e);
        return true;
    }
    DeleteObject (e);
    return false;
}
//__________________________________________________________________

BaseRef _HYTable::GetCellData (long h, long v)
{
    return cellData(v*horizontalSpaces.lLength+h);
}

//__________________________________________________________________

void    _HYTable::SetCellData (BaseRef data, long h, long v, long type, bool copy)
{
    long idx = h*horizontalSpaces.lLength+v;
    cellTypes.lData[idx] = type;
    cellData.Replace (idx,data,copy);
}

//__________________________________________________________________

void    _HYTable::SetRowOrder (_SimpleList& order)
{
    if ((order.lLength == verticalSpaces.lLength)&&(order.lLength)) {
        _List           newData(cellData.lLength);
        _SimpleList     newTypes(cellTypes.lLength),
                        newSpaces;

        long            k,m,p;
        for (k=0; k<verticalSpaces.lLength; k++)
            for (m=0; m<horizontalSpaces.lLength; m++) {
                newTypes<<-1;
            }

        for (k=0; k<verticalSpaces.lLength; k++) {
            p = order.lData[k];
            for (m=0; m<horizontalSpaces.lLength; m++) {
                newTypes.lData[k*horizontalSpaces.lLength+m] = cellTypes.lData[p*horizontalSpaces.lLength+m];
                newData << GetCellData(m,p);
            }
        }
        if (newTypes.Find(-1)>=0) {
            return;
        }
        newSpaces << GetRowSpacing (order.lData[0]);
        for (k=1; k<verticalSpaces.lLength; k++) {
            newSpaces << GetRowSpacing (order.lData[k])+newSpaces.lData[k-1];
        }
        cellData.Clear();
        cellTypes.Clear();
        verticalSpaces.Clear();
        cellData.Duplicate(&newData);
        cellTypes.Duplicate(&newTypes);
        verticalSpaces.Duplicate(&newSpaces);

        _MarkForUpdate();
    }

}

//__________________________________________________________________

bool    _HYTable::ScrollToRow (long where)
{
    if ((where>=0)&&(where<verticalSpaces.lLength)) {
        long hs, hf, vs, vf;
        GetDisplayRange (&rel,vs,vf,hs,hf);
        if ((where<hs)||(where>=hf)) {
            if (where<hs) {
                if (where==0) {
                    vs = 0;
                } else {
                    vs = verticalSpaces.lData[where-1];
                }

                vs -= vOrigin;
            } else {
                vs = verticalSpaces.lData[where]-(rel.bottom-rel.top)/2-vOrigin;
            }

            vf = verticalSpaces.lData[verticalSpaces.lLength-1]-vSize;
            if (settings.width&HY_COMPONENT_H_SCROLL) {
                vf += HY_SCROLLER_WIDTH;
            }
            vs =(_Parameter) MAX_CONTROL_VALUE * (_Parameter)vs/(_Parameter)vf;
            _SetVScrollerPos (_GetVScrollerPos()+vs);
            ProcessEvent (generateScrollEvent(0,vs));
            return true;
        }
    }
    return false;
}

//__________________________________________________________________

bool    _HYTable::ScrollToColumn (long where)
{
    if ((where>=0)&&(where<horizontalSpaces.lLength)) {
        long hs, hf, vs, vf;
        GetDisplayRange (&rel,vs,vf,hs,hf);
        if ((where<vs)||(where>=vf)) {
            if (where<vs) {
                if (where==0) {
                    hs = 0;
                } else {
                    hs = verticalSpaces.lData[where-1];
                }

                hs -= hOrigin;
            } else {
                hs = horizontalSpaces.lData[where]-(rel.right-rel.left)/2-hOrigin;
            }

            hf = horizontalSpaces.lData[horizontalSpaces.lLength-1]-hSize;
            if (settings.width&HY_COMPONENT_V_SCROLL) {
                hf += HY_SCROLLER_WIDTH;
            }
            hs = (_Parameter)MAX_CONTROL_VALUE * (_Parameter)hs/(_Parameter)hf;
            _SetHScrollerPos (_GetHScrollerPos()+hs);
            ProcessEvent (generateScrollEvent(hs,0));
            return true;
        }
    }
    return false;
}

//__________________________________________________________________

void    _HYTable::SetVisibleSize (_HYRect r)
{
    EditBoxHandler  (-1,r);

    if (settings.width&HY_COMPONENT_V_SCROLL) {
        horizontalSpaces.lData[horizontalSpaces.lLength-1]+=HY_SCROLLER_WIDTH-1;
    }
    if (settings.width&HY_COMPONENT_H_SCROLL) {
        verticalSpaces.lData[verticalSpaces.lLength-1]+=HY_SCROLLER_WIDTH-1;
    }
    _HYComponent::SetVisibleSize(r);
    if (settings.width&HY_COMPONENT_V_SCROLL) {
        horizontalSpaces.lData[horizontalSpaces.lLength-1]-=HY_SCROLLER_WIDTH-1;
    }
    if (settings.width&HY_COMPONENT_H_SCROLL) {
        verticalSpaces.lData[verticalSpaces.lLength-1]-=HY_SCROLLER_WIDTH-1;
    }



    if (selectionType&HY_TABLE_HORZ_STRETCH) {
        if (stretchWidth>0) {
            SetColumnSpacing ( horizontalSpaces.lLength-1,-stretchWidth,false);
        }

        stretchWidth = horizontalSpaces.lData[horizontalSpaces.lLength-1];
        EnforceWidth (r.right-r.left+1-(settings.width&HY_COMPONENT_V_SCROLL?HY_SCROLLER_WIDTH:0), 0x7fffffff,true);
        stretchWidth = horizontalSpaces.lData[horizontalSpaces.lLength-1]-stretchWidth;
        //EnforceWidth (r.right-r.left+1, 0x7fffffff,true);
    }

    if (selectionType&HY_TABLE_VERT_STRETCH) {
        if (stretchHeight>0) {
            SetRowSpacing ( verticalSpaces.lLength-1,-stretchHeight,false);
        }

        stretchHeight = verticalSpaces.lData[verticalSpaces.lLength-1];
        EnforceHeight (r.bottom-r.top+1-(settings.width&HY_COMPONENT_H_SCROLL?HY_SCROLLER_WIDTH:0), 0x7fffffff,true);
        stretchHeight = verticalSpaces.lData[verticalSpaces.lLength-1]-stretchHeight;

    }

    long        t = GetMaxW();

    if (hOrigin+r.right-r.left>t) {
        hOrigin = t-r.right+r.left;
        _SetHScrollerPos (MAX_CONTROL_VALUE);
    }

    if (settings.width&HY_COMPONENT_H_SCROLL) {
        _Parameter c2 = hOrigin/(_Parameter)(t-r.right+r.left); // invisible section
        _SetHScrollerPos (c2*MAX_CONTROL_VALUE);
    }

    t = GetMaxH();
    if (vOrigin+r.bottom-r.top>t) {
        vOrigin = t-r.bottom+r.top;
        _SetVScrollerPos (MAX_CONTROL_VALUE);
    }

    if (settings.width&HY_COMPONENT_V_SCROLL) {
        _Parameter c2 = vOrigin/(_Parameter)(t-r.bottom+r.top); // invisible section
        _SetVScrollerPos (c2*MAX_CONTROL_VALUE);
    }
}

//__________________________________________________________________

void    _HYTable::GetDisplayRange (_HYRect* relRect, long& hs, long& hf, long& vs, long& vf )
{
    long    t = hOrigin;
    for (hs=0; hs<horizontalSpaces.lLength; hs++)
        if (horizontalSpaces.lData[hs]>t) {
            break;
        }
    if (hs==horizontalSpaces.lLength) {
        hs--;
    }
    t = relRect->right-relRect->left+hOrigin;
    if (settings.width&HY_COMPONENT_V_SCROLL) {
        t-=HY_SCROLLER_WIDTH;
    }

    for (hf=hs; hf<horizontalSpaces.lLength; hf++)
        if (horizontalSpaces.lData[hf]>t) {
            break;
        }
    if (hf==horizontalSpaces.lLength) {
        hf--;
    }

    t = vOrigin;
    for (vs=0; vs<verticalSpaces.lLength; vs++)
        if (verticalSpaces.lData[vs]>t) {
            break;
        }
    if (vs==verticalSpaces.lLength) {
        vs--;
    }
    t = relRect->bottom-relRect->top+vOrigin;
    if (settings.width&HY_COMPONENT_H_SCROLL) {
        t-=HY_SCROLLER_WIDTH;
    }

    for (vf=vs; vf<verticalSpaces.lLength; vf++)
        if (verticalSpaces.lData[vf]>t) {
            break;
        }
    if (vf==verticalSpaces.lLength) {
        vf--;
    }
}

//__________________________________________________________________

void    _HYTable::GetSelection (_SimpleList& rec)
{
    long selectedCount = 0;
    for (long k=0; k<cellTypes.lLength; k++)
        if (cellTypes.lData[k]&HY_TABLE_SELECTED) {
            selectedCount ++;
        }

    rec.RequestSpace (rec.lLength+selectedCount);
    for (long k=0; k<cellTypes.lLength; k++)
        if (cellTypes.lData[k]&HY_TABLE_SELECTED) {
            rec << k;
        }

}

//__________________________________________________________________

void    _HYTable::SetSelection (_SimpleList& rec, bool update)
{
    for (long k=0; k<rec.lLength; k++) {
        long idx = rec.lData[k];
        if (idx<cellTypes.lLength)
            if (!(cellTypes.lData[idx]&HY_TABLE_CANTSELECT)) {
                cellTypes.lData[idx] |= HY_TABLE_SELECTED;
            }
    }
    if (update&&messageRecipient) {
        messageRecipient->ProcessEvent (generateTableChangeSelEvent(GetID()));
    }
}

//__________________________________________________________________

void    _HYTable::InvertSelection (void)
{
    for (long idx=0; idx<cellTypes.lLength; idx++) {
        if (!(cellTypes.lData[idx]&HY_TABLE_CANTSELECT)) {
            if (cellTypes.lData[idx] & HY_TABLE_SELECTED) {
                cellTypes.lData[idx] -= HY_TABLE_SELECTED;
            } else {
                cellTypes.lData[idx] += HY_TABLE_SELECTED;
            }
        }
    }
    if (messageRecipient) {
        messageRecipient->ProcessEvent (generateTableChangeSelEvent(GetID()));
    }
}

//__________________________________________________________________

void    _HYTable::GetRowSelection (_SimpleList& rec, long shift)
{
    for (long k=0; k<cellTypes.lLength; k+=horizontalSpaces.lLength) {
        if (cellTypes.lData[k+shift]&HY_TABLE_SELECTED) {
            rec<<k/horizontalSpaces.lLength;
        }
    }
}

//__________________________________________________________________

void    _HYTable::ScanRowSelection (_SimpleList& rec)
{
    for (long k=0; k<cellTypes.lLength; k+=horizontalSpaces.lLength)
        for (long k2=0; k2<horizontalSpaces.lLength; k2++)
            if (cellTypes.lData[k+k2]&HY_TABLE_SELECTED) {
                rec << k/horizontalSpaces.lLength;
                break;
            }
}

//__________________________________________________________________

void    _HYTable::ScanColumnSelection (_SimpleList& rec)
{
    for (long k2=0; k2<horizontalSpaces.lLength; k2++)
        for (long k=k2; k<cellTypes.lLength; k+=horizontalSpaces.lLength)
            if (cellTypes.lData[k]&HY_TABLE_SELECTED) {
                rec << k2;
                break;
            }
}

//__________________________________________________________________

long    _HYTable::GetFirstRowSelection (void)
{
    _SimpleList rs;
    GetRowSelection (rs);
    if (rs.lLength) {
        return rs.lData[0];
    }
    return -1;
}

//__________________________________________________________________

bool    _HYTable::IsRowSelectionSimple (void)
{
    bool    res = false;
    for (long k=0; k<cellTypes.lLength; k+=horizontalSpaces.lLength) {
        if (cellTypes.lData[k]&HY_TABLE_SELECTED)
            if (res) {
                return false;
            } else {
                res = true;
            }
    }
    return res;
}

//__________________________________________________________________
bool    _HYTable::CanCopy (void)
{
    _SimpleList   sel;
    GetSelection (sel);

    return      sel.lLength;
}

//__________________________________________________________________
BaseRef _HYTable::CanPaste (_String& clip)
{
    _SimpleList   sel;
    GetSelection (sel);

    if (sel.lLength!=1) {
        return nil;
    }

    long rIdx = sel.lData[0]/horizontalSpaces.lLength,
         cIdx = sel.lData[0]%horizontalSpaces.lLength;

    _List        clipContents;

    _ElementaryCommand::ExtractConditions (clip,0,clipContents,';');

    if (verticalSpaces.lLength+1-rIdx < clipContents.lLength) {
        return nil;
    }

    _List*       clipData = new _List;

    if (!clipData) {
        return nil;
    }

    for (long k=0; k<clipContents.lLength; k++) {
        _List thisRow;
        _ElementaryCommand::ExtractConditions ((*(_String*)clipContents(k)),0,thisRow,',');
        if (horizontalSpaces.lLength+1-cIdx < thisRow.lLength) {
            DeleteObject (clipData);
            return       nil;
        }
        for (long kk=0; kk<thisRow.lLength; kk++) {
            ((_String*)thisRow(kk))->StripQuotes();
        }

        (*clipData) && & thisRow;
    }
    return clipData;
}

//__________________________________________________________________
_String*    _HYTable::HandleCopy (void)
{
    _String*     res = new _String (128L, true);

    _SimpleList  sel;
    GetSelection (sel);

    long         lastRow = -1;

    for (long k=0; k<sel.lLength; k++) {
        long rIndex = sel.lData[k]/horizontalSpaces.lLength,
             cIndex = sel.lData[k]%horizontalSpaces.lLength;

        if  (rIndex!=lastRow) {
            lastRow = rIndex;
            if (k) {
                (*res) << ';';
            }
        } else {
            (*res) << ',';
        }

        (*res) << '"';
        (*res) << (_String*)GetCellData (cIndex, rIndex);
        (*res) << '"';
    }

    res->Finalize();
    return       res;
}

//__________________________________________________________________

void    _HYTable::HandlePaste (BaseRef data)
{
    _List * pasteData = (_List*)data;

    _SimpleList  sel;
    GetSelection (sel);

    if (sel.lLength!=1) {
        return;
    }

    long rIdx = sel.lData[0]/horizontalSpaces.lLength,
         cIdx = sel.lData[0]%horizontalSpaces.lLength;

    _SimpleList taint;

    for (long k=0; k<pasteData->lLength; k++) {
        _List *thisRow = (_List*)(*pasteData)(k);

        for (long kk=0; kk<thisRow->lLength; kk++) {
            long idx = (rIdx+k)*horizontalSpaces.lLength + cIdx+kk;
            SetCellData ((_String*)(*thisRow)(kk),rIdx+k, cIdx+kk, cellTypes.lData[idx],true);
            taint << idx;
        }

    }

    _MarkCellsForUpdate (taint);

    if (messageRecipient) {
        messageRecipient->ProcessEvent (generateTableEditCellEvent(GetID(),sel.lData[0]));
    }

}


//__________________________________________________________________
void    _HYTable::GetColumnSelection (_SimpleList& rec)
{
    for (long k=0; k<horizontalSpaces.lLength; k++) {
        if (cellTypes.lData[k]&HY_TABLE_SELECTED) {
            rec<<k;
        }
    }
}

//__________________________________________________________________
void    _HYTable::UnfocusComponent (void)
{
    if (_HasTextBox()) {
        _HYRect        dummy;
        EditBoxHandler (-1,dummy);
    }
    if (selectionType&HY_TABLE_IS_FOCUSED) {
        selectionType -= HY_TABLE_IS_FOCUSED;
    }

    _HYComponent::UnfocusComponent();
}

//__________________________________________________________________
void    _HYTable::FocusComponent (void)
{
    if (!(selectionType&HY_TABLE_IS_FOCUSED)) {
        selectionType += HY_TABLE_IS_FOCUSED;
    }

    _SimpleList    cs;
    GetSelection   (cs);

    if (cs.lLength == 0) {
        long k;
        for (k=0; k<cellTypes.lLength; k++)
            if (cellTypes.lData[k]&HY_TABLE_CANTSELECT) {
                break;
            }

        if  (k<cellTypes.lLength) {
            cs << k;
            if ((selectionType&HY_TABLE_SEL_ROWS)==0) {
                cs.lData[0] /= horizontalSpaces.lLength;
                SetRowSelection (cs);
            }
            if (selectionType&HY_TABLE_SEL_COLS) {
                cs.lData[0] %= horizontalSpaces.lLength;
                SetColumnSelection (cs);
            } else {
                SetSelection (cs);
            }
        }
    }

    _FocusComponent ();
    _HYComponent::FocusComponent();
}

//__________________________________________________________________
void    _HYTable::_PrintTable (_HYTable* ch)
{
    _SimpleList rows,
                columns;

    long        k;

    for (k=0; k<horizontalSpaces.lLength; k++) {
        columns << k;
    }

    for (k=0; k<verticalSpaces.lLength; k++) {
        rows << k;
    }

    _PrintTable (columns, rows, ch);
}

//__________________________________________________________________
void    _HYTable::_PrintTable (_SimpleList& columns, _HYTable* ch)
{
    _SimpleList rows;

    long        k;

    for (k=0; k<verticalSpaces.lLength; k++) {
        rows << k;
    }

    _PrintTable (columns, rows, ch);
}

//__________________________________________________________________

void    _HYTable::SaveTable (_HYTable* ch, _HYTable *rh, long format, FILE * dest, _String& title)
{
    _SimpleList rows,
                columns;

    long        k;

    for (k=0; k<horizontalSpaces.lLength; k++) {
        columns << k;
    }

    for (k=0; k<verticalSpaces.lLength; k++) {
        rows << k;
    }

    SaveTable (ch,rh, format,dest,title, columns, rows);
}

//__________________________________________________________________

void    _HYTable::SaveTable (_HYTable* ch, _HYTable *rh, long format, FILE * dest, _String& title, _SimpleList& columns, _SimpleList& rows)
{
    long        i,j,k,t;
    if (columns.lLength&&rows.lLength&&dest) {
        switch (format) {
        case 0: // comma separated
        case 1: { // tab     separated
            char sep = format?'\t':',';
            if (ch) {
                if (rh) {
                    fputc (sep,dest);
                }
                for (i=0; i<columns.lLength-1; i++) {
                    ch->ExportCell (dest,format,0,columns.lData[i]);
                    fputc (sep,dest);
                }
                ch->ExportCell (dest,format,0,columns.lData[i]);
                fprintf (dest,"\n");
            }
            for (j=0; j<rows.lLength; j++) {
                if (rh) {
                    rh->ExportCell (dest,format,rows.lData[j],0);
                    fputc (sep,dest);
                }
                for (i=0; i<columns.lLength-1; i++) {
                    ExportCell (dest,format,rows.lData[j],columns.lData[i]);
                    fputc (sep,dest);
                }
                ExportCell (dest,format,rows.lData[j],columns.lData[i]);
                fprintf (dest,"\n");
            }
        }
        break;

        case 2: { // LaTEX table
            fprintf (dest, "{\\small\n\\begin{table}[t]\n\\begin{tabular}{");
            if (rh) {
                fprintf (dest,"r");
            }

            for (i=0; i<columns.lLength; i++) {
                fprintf (dest,"r");
            }

            fprintf (dest, "}\n\\hline\n");
            if (ch) {
                if (rh) {
                    fputc ('&',dest);
                }

                for (i=0; i<columns.lLength-1; i++) {
                    ch->ExportCell (dest,format,0,columns.lData[i]);
                    fputc ('&',dest);
                }
                ch->ExportCell (dest,format,0,columns.lData[i]);
                fprintf (dest, "\\\\\n\\hline\n");
            }
            for (j=0; j<rows.lLength; j++) {
                if (rh) {
                    rh->ExportCell (dest,format,rows.lData[j],0);
                    fputc ('&',dest);
                }
                for (i=0; i<columns.lLength-1; i++) {
                    ExportCell (dest,format,rows.lData[j],columns.lData[i]);
                    fputc ('&',dest);
                }
                ExportCell (dest,format,rows.lData[j],columns.lData[i]);
                fprintf (dest, "\\\\\n");
            }
            fprintf (dest,"\n\\end{tabular}\n\\caption{%s}\n\\end{table}\n}\n",title.sData);
        }
        break;

        case 3: { // HTML  table
            fprintf (dest, "<html>\n<head>\n<title>\n%s</title></head><body bgcolor = \"#FFFFFF\">\n<table border = \"0\" cellpadding = \"0\" cellspacing = \"1\">",title.sData);
            if (ch) {
                fprintf (dest, "\n<tr>\n");
                if (rh) {
                    fprintf (dest,"<td></td>");
                }
                for (i=0; i<columns.lLength; i++) {
                    ch->ExportCell (dest,format,0,columns.lData[i]);
                }
                fprintf (dest, "\n</tr>\n");
            }
            for (j=0; j<rows.lLength; j++) {
                fprintf (dest, "\n<tr>\n");
                if (rh) {
                    rh->ExportCell (dest,format,rows.lData[j],0);
                }
                for (i=0; i<columns.lLength; i++) {
                    ExportCell (dest,format,rows.lData[j],columns.lData[i]);
                }
                fprintf (dest, "\n</tr>\n");
            }
            fprintf (dest, "\n</table>\n</body>\n</html>\n");
        }
        break;

        case 4: { // ASCII art table
            _SimpleList width;

            for (i=0; i<columns.lLength; i++) {
                k = ch?ch->GetCellWidth (0,columns.lData[i]):2;

                for (j=0; j<rows.lLength; j++) {
                    t = GetCellWidth (rows.lData[j],columns.lData[i]);
                    if (t>k) {
                        k = t;
                    }
                }
                width << k;
            }

            fprintf (dest,"%s\n\n", title.sData);

            _String rowSeparator (128L, true);
            rowSeparator << '+';
            for (i=0; i<columns.lLength; i++) {
                for (j=-1; j<=width.lData[i]; j++) {
                    rowSeparator << '-';
                }
                rowSeparator << '+';
            }
            rowSeparator.Finalize();

            fprintf (dest, "%s\n", rowSeparator.sData);

            if (ch) {
                fputc ('|', dest);
                for (i=0; i<columns.lLength; i++) {
                    k = ch->GetCellWidth (0,columns.lData[i]);
                    ch->ExportCell (dest,format,0,columns.lData[i]);
                    for (t = k; t < width.lData[i]; t++) {
                        fputc (' ', dest);
                    }
                    fputc ('|', dest);
                }
                fprintf (dest, "\n%s\n", rowSeparator.sData);
            }

            for (j=0; j<rows.lLength; j++) {
                fputc ('|', dest);
                for (i=0; i<columns.lLength; i++) {
                    k = GetCellWidth (rows.lData[j],columns.lData[i]);
                    ExportCell (dest,format,rows.lData[j],columns.lData[i]);
                    for (t = k; t < width.lData[i]; t++) {
                        fputc (' ', dest);
                    }
                    fputc ('|', dest);
                }
                fprintf (dest, "\n%s\n", rowSeparator.sData);
            }
        }
        case 5: { // hyphy matrix
            fprintf (dest,"\n{\n");
            for (j=0; j<rows.lLength; j++) {
                fputc ('{',dest);
                for (i=0; i<columns.lLength-1; i++) {
                    ExportCell (dest,format,rows.lData[j],columns.lData[i]);
                    fputc (',',dest);
                }
                ExportCell (dest,format,rows.lData[j],columns.lData[i]);
                fprintf (dest,"}\n");
            }
            fprintf (dest,"}");
        }
        break;
        break;
        default: {
            _String wrongFormat ("SaveTable was passed an invalid format code");
            ProblemReport (wrongFormat);
        }
        }
    }
}

//__________________________________________________________________

long    _HYTable::GetCellWidth (long r, long c)
{
    long idx  = r*horizontalSpaces.lLength+c,
         type = cellTypes.lData[idx];

    if (type&HY_TABLE_ICON) {
        return iconExportString.sLength;
    }

    return ((_String*)GetCellData (c,r))->sLength;
}

//__________________________________________________________________

void    _HYTable::ExportCell (FILE* dest, long format, long r, long c)
{
    long idx  = r*horizontalSpaces.lLength+c,
         type = cellTypes.lData[idx];

    _String * contents;

    bool boldOn   = type&HY_TABLE_BOLD,
         italicOn = type&HY_TABLE_ITALIC;

    if (type&HY_TABLE_ICON) {
        contents = &iconExportString;
    } else {
        contents = ((_String*)GetCellData (c,r));
    }

    switch  (format) {
    case 2: { // LaTEX table
        if (boldOn) {
            fprintf (dest, "{\\bf ");
        }
        if (italicOn) {
            fprintf (dest, "{\\it ");
        }
    }
    break;
    case 3: { // HTML table
        fprintf (dest, "\n\t<td align = \"left\" valign = \"center\" bgcolor = \"#%s\">",
                 ((type&HY_TABLE_BEVELED)?backColor2:backColor).HTMLColor().getStr());
        if (boldOn) {
            fprintf (dest, "<b>");
        }
        if (italicOn) {
            fprintf (dest, "<i>");
        }
        fprintf (dest,"<font color = \"#%s\"> ",textColor.HTMLColor().getStr());
    }
    break;
    case 4:
        fputc (' ', dest);
        break;
    }

    if (format == 2) {
        fprintf (dest, "%s", contents->Replace ("_","\\_",true).sData);
    } else {
        fprintf (dest, "%s", contents->sData);
    }

    switch  (format) {
    case 2: { // LaTEX table
        if (italicOn) {
            fprintf (dest, "}");
        }
        if (boldOn) {
            fprintf (dest, "}");
        }
    }
    break;
    case 3: { // HTML table
        fprintf (dest,"</font>");
        if (italicOn) {
            fprintf (dest, "</i>");
        }
        if (boldOn) {
            fprintf (dest, "</b>");
        }
        fprintf (dest, " </td>");
    }
    case 4:
        fputc (' ', dest);
        break;
    }
}

//__________________________________________________________________

void    _HYTable::GetTableFormats (_List& rec)
{
    _String format ("Comma Separated");
    rec && & format;
    format = "Tab Separated";
    rec && & format;
    format = "LaTEX Table";
    rec && & format;
    format = "HTML Table";
    rec && & format;
    format = "ASCII Table";
    rec && & format;
    format = "HyPhy Matrix";
    rec && & format;
}

//__________________________________________________________________

void    _HYTable::HandleKeyMove (char dir, bool )
{
    bool         rowSel = selectionType&HY_TABLE_SEL_ROWS;

    _SimpleList  ts;

    if (rowSel) {
        GetRowSelection(ts);
        if (ts.lLength<=1) {
            long adder = -1,
                 startIndex = -1;

            if (dir) {
                adder = 1;
            }

            if (ts.lLength == 1) {
                startIndex = ts.lData[0];
            } else {
                if (dir) {
                    startIndex = -1;
                } else {
                    startIndex = verticalSpaces.lLength;
                }
            }

            startIndex += adder;
            ts.Clear();
            while ((startIndex>=0)&&(startIndex<verticalSpaces.lLength)) {
                if ((cellTypes.lData[startIndex*horizontalSpaces.lLength]&HY_TABLE_CANTSELECT)==0) {
                    ts << startIndex;
                    bool mod;
                    mod = ScrollToRow(startIndex);

                    ExpungeSelection ();
                    SetRowSelection (ts);
                    if (mod) {
                        forceUpdateForScrolling = true;
                        _MarkForUpdate();
                        forceUpdateForScrolling = false;
                    } else {
                        _MarkCellsForUpdate (ts);
                    }
                    break;
                }
                startIndex += adder;
            }
        }
    } else {
        GetSelection (ts);
        if (ts.lLength<=1) {
            long adder = 1,
                 startIndex = -1;

            switch (dir) {
            case 0: // up
                adder = -horizontalSpaces.lLength;
                break;
            case 1: // down
                adder = horizontalSpaces.lLength;
                break;
            case 2: // left
                adder = -1;
                break;
            }

            if (ts.lLength == 1) {
                startIndex = ts.lData[0];
            } else {
                switch (dir) {
                case 0: // up
                    startIndex = cellTypes.lLength;
                    break;
                case 1: // down
                    startIndex = -adder;
                    break;
                case 3: // right
                    startIndex = horizontalSpaces.lLength;
                    break;
                }
            }

            startIndex += adder;
            ts.Clear();
            while ((startIndex>=0)&&(startIndex<cellTypes.lLength)) {
                if ((cellTypes.lData[startIndex]&HY_TABLE_CANTSELECT)==0) {
                    ts << startIndex;
                    bool mod;
                    if (dir<2) {
                        mod = ScrollToRow(startIndex/horizontalSpaces.lLength);
                    } else {
                        mod = ScrollToColumn(startIndex%horizontalSpaces.lLength);
                    }
                    ExpungeSelection ();
                    SetSelection (ts,true);
                    if (mod) {
                        forceUpdateForScrolling = true;
                        _MarkForUpdate();
                        forceUpdateForScrolling = false;
                    } else {
                        _MarkCellsForUpdate (ts);
                    }
                    break;
                }
                startIndex += adder;
            }
        }
    }
}

//__________________________________________________________________
// HYHList
//__________________________________________________________________

_SimpleList*          openArrow   = nil,
                      *       closedArrow = nil;

//__________________________________________________________________

_HYHList::_HYHList (_HYRect relr,Ptr w,_List& ld, bool sing):
    _HYTable (relr,w,ld.lLength,2,20,20,HY_TABLE_STATIC_TEXT)
{
    listData.Duplicate (&ld);

    if (!openArrow) {
        openArrow = new _SimpleList ((unsigned long)3);
        checkPointer (openArrow);

        (*openArrow) << (long) ProcureIconResource(131);
        (*openArrow) << 16;
        (*openArrow) << 16;

        closedArrow = new _SimpleList ((unsigned long)3);
        checkPointer (closedArrow);

        (*closedArrow) << (long) ProcureIconResource(132);
        (*closedArrow) << 16;
        (*closedArrow) << 16;
    }

    _HYFont     df;
#ifdef __MAC__
    df.face = "Times";
    df.size = 12;
#else
#ifdef __HYPHY_GTK__
    df.face = _HY_SANS_FONT;
    df.size = 12;
#else
    df.face = "Arial";
    df.size = 14;
#endif
#endif

    df.style = HY_FONT_PLAIN;
    SetFont (df);

    for (long k=0; k<ld.lLength; k++) {
        _List * thisEntry = (_List*) listData (k);
        SetCellData (closedArrow, k, 0, HY_TABLE_ICON | HY_TABLE_CANTSELECT,true);
        SetCellData ((*thisEntry)(0), k, 1, HY_TABLE_STATIC_TEXT|HY_TABLE_BOLD ,true);
        rubrikIndex << k;
    }

    SetColumnSpacing  (1,relr.right-40-HY_SCROLLER_WIDTH,false);

    if (settings.width & HY_COMPONENT_H_SCROLL) {
        FitToHeight (relr.bottom-HY_SCROLLER_WIDTH);
    } else {
        FitToHeight (relr.bottom);
    }

    selectionType = HY_TABLE_DONT_SIZE|HY_TABLE_NO_COLS_LINES|HY_TABLE_DONT_GROW_HORIZ|HY_TABLE_DONT_GROW_VERT;
    single        = sing;
}

//__________________________________________________________________

void    _HYHList::AddRubrik (_String& rubrikName, _List& rubrikItems, long index)
{
    long        insertionPoint = 0;
    if ((index < 0) && (index >= rubrikIndex.lLength)) {
        index          = rubrikIndex.lLength;
        if (HasPadding()) {
            insertionPoint = verticalSpaces.lLength-1;
        } else {
            insertionPoint = verticalSpaces.lLength;
        }
    } else {
        insertionPoint = rubrikIndex.lData[index];
    }

    _List * newRubrik = new _List;

    checkPointer (newRubrik);

    (*newRubrik) && & rubrikName;
    (*newRubrik) && & rubrikItems;

    listData.InsertElement (newRubrik, index, false);
    rubrikIndex.InsertElement ((BaseRef)insertionPoint, index, false, false);
    DeleteObject (newRubrik);


    for (long   k = index+1; k < rubrikIndex.lLength; k++) {
        rubrikIndex.lData[k] ++;
    }


    AddRow      (insertionPoint, 20, HY_TABLE_STATIC_TEXT);
    SetCellData (closedArrow, insertionPoint, 0, HY_TABLE_ICON | HY_TABLE_CANTSELECT,true);
    SetCellData (&rubrikName, insertionPoint, 1, HY_TABLE_STATIC_TEXT|HY_TABLE_BOLD ,true);

    if (settings.width & HY_COMPONENT_H_SCROLL) {
        FitToHeight (rel.bottom-rel.top-HY_SCROLLER_WIDTH+1);
    } else {
        FitToHeight (rel.bottom-rel.top+1);
    }

    _MarkForUpdate();

}

//__________________________________________________________________

long    _HYHList::IsSingleRubrik (_SimpleList& sl)
{
    if (sl.lLength == 0) {
        return -1;
    }

    if (rubrikIndex.lLength == 0) {
        return 0;
    }

    long rIndex = 1;
    while ((sl.lData[0] >= rubrikIndex.lData[rIndex]) && (rIndex < rubrikIndex.lLength)) {
        rIndex ++;
    }

    if (rIndex == rubrikIndex.lLength) {
        sl.Offset (-rubrikIndex.lData[rIndex-1]);
        return rIndex-1;
    } else {
        long nextB = rubrikIndex.lData[rIndex],
             i = 1;

        for (; (i< sl.lLength)&&(sl.lData[i]<nextB); i++) ;

        if (i == sl.lLength) {
            sl.Offset (-rubrikIndex.lData[rIndex-1]);
            return rIndex-1;
        }
    }

    return -1;
}

//__________________________________________________________________

void    _HYHList::DeleteRubrik (long index)
{
    if ((index>=0) && (index<rubrikIndex.lLength)) {
        long delCount;

        if (index <  rubrikIndex.lLength - 1) {
            delCount = rubrikIndex.lData[index+1] - rubrikIndex.lData[index];
        } else {
            delCount = HasPadding()?verticalSpaces.lLength - rubrikIndex.lData[index]-1:verticalSpaces.lLength - rubrikIndex.lData[index];
        }

        for (long k=index+1; k<rubrikIndex.lLength; k++) {
            rubrikIndex.lData[k] -= delCount;
        }

        while (delCount) {
            DeleteRow (rubrikIndex.lData[index]);
            delCount --;
        }

        rubrikIndex.Delete (index);
        listData.Delete (index);

        if (settings.width & HY_COMPONENT_H_SCROLL) {
            FitToHeight (rel.bottom-rel.top-HY_SCROLLER_WIDTH+1);
        } else {
            FitToHeight (rel.bottom-rel.top+1);
        }
    }
    _MarkForUpdate();
}


//__________________________________________________________________

long    _HYHList::IsARubrik (long index)
{
    return rubrikIndex.Find (index);
}

//__________________________________________________________________

long    _HYHList::FindString (_String* s, long startat)
{
    for (long k=(startat>=0?startat:0); k<listData.lLength; k++) {
        _List * thisRubrik = (_List*)(*((_List*)listData(k)))(1);
        for (long j=0; j<thisRubrik->lLength; j++)
            if (s->Equal((_String*)(*thisRubrik)(j))) {
                return (k<<16)+j;
            }
    }
    return -1;
}

//__________________________________________________________________

bool    _HYHList::IsRubrikOpen (long index)
{
    if ((index>=0)&&(index<listData.lLength)) {
        if (index<listData.lLength-1) {
            return (rubrikIndex[index+1]-rubrikIndex[index]-1>0);
        } else {
            if (HasPadding()) {
                return rubrikIndex[index]<verticalSpaces.lLength-2;
            } else {
                return rubrikIndex[index]<verticalSpaces.lLength-1;
            }
        }
    }
    return false;
}

//__________________________________________________________________

long    _HYHList::RubrikIndex (long index)
{
    long result = 0;
    while ((result<rubrikIndex.lLength)&&(rubrikIndex.lData[result]<index)) {
        result ++;
    }

    if ((rubrikIndex.lData[result]>index)||(result==rubrikIndex.lLength)) {
        result--;
    }

    return (result<<16)+(index-rubrikIndex.lData[result]);
}


//__________________________________________________________________

long    _HYHList::AbsoluteIndex (long rubrik, long item)
{
    long result = 0,
         k;

    for (k=0; k<rubrik; k++) {
        _List * thisEntry = (_List*) listData (k);
        result = result + ((_List*)(*thisEntry)(1))->lLength + 1;
    }
    return result+item;
}

//__________________________________________________________________

void        _HYHList::ModifySelection (long h,long v, bool shift, bool control, bool message)
{
    if (h==0) {
        long f = IsARubrik(v);
        if (f>=0) {
            _List       * rubrikItems = (_List*) (*(_List*) listData (f))(1);
            if (IsRubrikOpen(f)) {
                SetCellData (closedArrow, v, 0, HY_TABLE_ICON | HY_TABLE_CANTSELECT,true);
                for (f=f+1; f<listData.lLength; f++) {
                    rubrikIndex.lData[f] -= rubrikItems->lLength;
                }

                for (f = v+1; f <= v+rubrikItems->lLength; f++) {
                    DeleteRow (v+1);
                }


                if (settings.width & HY_COMPONENT_H_SCROLL) {
                    FitToHeight (rel.bottom-rel.top-HY_SCROLLER_WIDTH+1);
                } else {
                    FitToHeight (rel.bottom-rel.top+1);
                }
            } else {
                for (f=f+1; f<listData.lLength; f++) {
                    rubrikIndex.lData[f] += rubrikItems->lLength;
                }

                SetCellData (openArrow, v, 0, HY_TABLE_ICON | HY_TABLE_CANTSELECT,true);

                for (f = v+1; f <= v+rubrikItems->lLength; f++) {
                    AddRow      (f,20, HY_TABLE_STATIC_TEXT);
                    SetCellData (&empty, f, 0, HY_TABLE_STATIC_TEXT | HY_TABLE_CANTSELECT,true);
                    SetCellData ((*rubrikItems)(f-v-1), f, 1, HY_TABLE_STATIC_TEXT,true);
                }

                if (settings.width & HY_COMPONENT_H_SCROLL) {
                    FitToHeight (rel.bottom-rel.top-HY_SCROLLER_WIDTH+1);
                } else {
                    FitToHeight (rel.bottom-rel.top+1);
                }
            }
            _SimpleList modRows;
            for (f=v; f<verticalSpaces.lLength; f++) {
                modRows << 2*f;
                modRows << 2*f+1;
            }
            _MarkCellsForUpdate (modRows);

            _HYTable::ModifySelection (1,v,false,false,message);
            return;
        }
    }
    _HYTable::ModifySelection (h,v,(!single)&&shift,(!single)&&control,message);
}

//__________________________________________________________________

void    _HYHList::FitToHeight (long height)
{
    bool           hasPadding = HasPadding();
    long           h = verticalSpaces.lData[verticalSpaces.lLength-(hasPadding?2:1)];

    if (hasPadding) {
        if (h<height) {
            SetRowSpacing (verticalSpaces.lLength-1,height-h-GetRowSpacing (verticalSpaces.lLength-1),false);
        } else {
            DeleteRow (verticalSpaces.lLength-1);
        }
    } else if (h<height) {
        AddRow (-1,height-h,HY_TABLE_STATIC_TEXT|HY_TABLE_CANTSELECT);
    }

    SetVisibleSize (rel);
}

//__________________________________________________________________

bool    _HYHList::HasPadding (void)
{
    if (cellTypes.lLength) {
        return (cellTypes.lData[cellTypes.lLength-1] & HY_TABLE_CANTSELECT);
    } else {
        return false;
    }
}

//__________________________________________________________________

void    _HYHList::HandleKeyMove (char dir, bool mod)
{
    _SimpleList  ts;
    GetSelection (ts);
    if (ts.lLength<=1) {
        if (dir<2) {
            _HYTable::HandleKeyMove (dir,mod);
            return;
        }

        if (ts.lLength == 1) {
            long f = IsARubrik (ts.lData[0]/2);
            if ((f>=0)&&(((dir == 3)&&(!IsRubrikOpen(f)))||((dir == 2)&&(IsRubrikOpen(f))))) {
                ModifySelection (0, ts.lData[0]/2, false, false,false);
            }
        }
    }
}
\ No newline at end of file
diff --git a/src/gui/Components/HYTextBox.cpp b/src/gui/Components/HYTextBox.cpp
index 219971b..450242c 100644
--- a/src/gui/Components/HYTextBox.cpp
+++ b/src/gui/Components/HYTextBox.cpp
@@ -1 +1 @@
-/*
    Text field component

    Sergei L. Kosakovsky Pond, May 2000 - December 2002.
*/

#include "HYEventTypes.h"
#include "HYTextBox.h"
#include "HYGraphicPane.h"

#ifdef    __HYPHYDMALLOC__
#include "dmalloc.h"
#endif
//__________________________________________________________________

_HYTextBox::_HYTextBox (_HYRect r,Ptr p, bool bt):_HYComponent (r,p),_HYPlatformTextBox()
{
    backColor.R       = backColor.G
                        = backColor.B
                          = 255;

    foreColor.R       = foreColor.G
                        = foreColor.B
                          = 0;


    editBoxFont.size  = 10;
    editBoxFont.style = HY_FONT_PLAIN;
    editBoxFont.face  = "Helvetica";

    alignFlags        = HY_ALIGN_LEFT;

    margins.left      = margins.right
                        = margins.top
                          = margins.bottom
                            = 5;

    boxFlags = HY_TB_ENABLED | (bt?HY_TB_BIGBOX:0);

    //boxType             = bt;
}

//__________________________________________________________________

_HYTextBox::~_HYTextBox()
{
}

//__________________________________________________________________

void            _HYTextBox::SetBackColor (_HYColor c)
{
    if ((c.R!=backColor.R)||(c.G!=backColor.G)||(c.B!=backColor.B)) {
        backColor = c;
        _SetBackColor (c);
        _MarkForUpdate();
    }
}

//__________________________________________________________________

_HYColor&       _HYTextBox::GetBackColor (void)
{
    return backColor;
}

//__________________________________________________________________

void            _HYTextBox::SetForeColor (_HYColor c)
{
    if ((c.R!=foreColor.R)||(c.G!=foreColor.G)||(c.B!=foreColor.B)) {
        foreColor = c;
        _SetForeColor (c);
        _MarkForUpdate();
    }
}

//__________________________________________________________________

void            _HYTextBox::SetBackTColor (_HYColor c)
{
    if ((c.R!=backTextColor.R)||(c.G!=backTextColor.G)||(c.B!=backTextColor.B)) {
        backTextColor = c;
        _SetBackTColor (c);
        _MarkForUpdate();
    }
}

//__________________________________________________________________

_HYColor&       _HYTextBox::GetForeColor (void)
{
    return foreColor;
}

//__________________________________________________________________

_HYColor&       _HYTextBox::GetBackTColor (void)
{
    return backTextColor;
}


//__________________________________________________________________
void            _HYTextBox::SetText (const _String& newText, bool update)
{
    _SetText (newText);
    _MarkForUpdate();
    if (messageRecipient && update) {
        messageRecipient->ProcessEvent (generateTextEditChangeEvent (GetID(),1));
    }
}

//__________________________________________________________________
void            _HYTextBox::InsertText (const _String& newText, bool update, bool append)
{
    _InsertText (newText, append);
    _MarkForUpdate();
    if (messageRecipient && update) {
        messageRecipient->ProcessEvent (generateTextEditChangeEvent (GetID(),1));
    }
}

//__________________________________________________________________

_String         _HYTextBox::GetText (void)
{
    return _GetText();
}


//__________________________________________________________________

void            _HYTextBox::StoreText (_String*& rec, bool selOnly)
{
    return _StoreText(rec, selOnly);
}

//__________________________________________________________________

_HYFont&        _HYTextBox::GetFont (void)
{
    return editBoxFont;
}

//__________________________________________________________________
void            _HYTextBox::SetMargins (_HYRect m)
{
    if ((m.top!=margins.top)||(m.bottom!=margins.bottom)
            ||(m.left!=margins.left)||(m.right!=margins.right)) {
        margins = m;
        SetVisibleSize (rel);
        _MarkForUpdate ();
    }
}

//__________________________________________________________________

void            _HYTextBox::SetFont (_HYFont&f)
{
    if ((!f.face.Equal(&editBoxFont.face))||(f.size!=editBoxFont.size)||(f.style!=editBoxFont.style)) {
        _SetFont (f);
        editBoxFont.face  = f.face;
        editBoxFont.size  = f.size;
        editBoxFont.style = f.style;
        _MarkForUpdate();
    }
}

//__________________________________________________________________
void            _HYTextBox::SetVisibleSize (_HYRect rel)
{
    _HYComponent::SetVisibleSize (rel);
    _HYPlatformTextBox::_SetVisibleSize (rel);
}

//__________________________________________________________________

void            _HYTextBox::EnableTextEdit (bool e)
{
    bool ie = boxFlags&HY_TB_ENABLED;
    if (ie!=e) {
        if (e) {
            boxFlags |= HY_TB_ENABLED;
        } else {
            boxFlags -= HY_TB_ENABLED;
        }

        _EnableTextBox (e);
        _MarkForUpdate ();
    }
}

//__________________________________________________________________

void            _HYTextBox::FocusComponent (void)
{
#ifndef __WINDOZE__
    if (!(boxFlags&HY_TB_FOCUSED))
#endif
    {
        boxFlags |= HY_TB_FOCUSED;
        if (!(boxFlags&HY_TB_BIGBOX)) {
            SetSelection   (0,0x7fffffff);
        }
        _FocusComponent();
        _MarkForUpdate();
    }
}

//__________________________________________________________________

void            _HYTextBox::UnfocusComponent (void)
{
    if (boxFlags&HY_TB_FOCUSED) {
        boxFlags -= HY_TB_FOCUSED;
        _UnfocusComponent();
        _MarkForUpdate();
    }
}
\ No newline at end of file
+/*
 
 HyPhy - Hypothesis Testing Using Phylogenies.
 
 Copyright (C) 1997-now
 Core Developers:
 Sergei L Kosakovsky Pond (spond at ucsd.edu)
 Art FY Poon    (apoon at cfenet.ubc.ca)
 Steven Weaver (sweaver at ucsd.edu)
 
 Module Developers:
 Lance Hepler (nlhepler at gmail.com)
 Martin Smith (martin.audacis at gmail.com)
 
 Significant contributions from:
 Spencer V Muse (muse at stat.ncsu.edu)
 Simon DW Frost (sdf22 at cam.ac.uk)
 
 Permission is hereby granted, free of charge, to any person obtaining a
 copy of this software and associated documentation files (the
 "Software"), to deal in the Software without restriction, including
 without limitation the rights to use, copy, modify, merge, publish,
 distribute, sublicense, and/or sell copies of the Software, and to
 permit persons to whom the Software is furnished to do so, subject to
 the following conditions:
 
 The above copyright notice and this permission notice shall be included
 in all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 */

#include "HYEventTypes.h"
#include "HYTextBox.h"
#include "HYGraphicPane.h"

#ifdef    __HYPHYDMALLOC__
#include "dmalloc.h"
#endif
//__________________________________________________________________

_HYTextBox::_HYTextBox (_HYRect r,Ptr p, bool bt):_HYComponent (r,p),_HYPlatformTextBox()
{
    backColor.R       = backColor.G
                        = backColor.B
                          = 255;

    foreColor.R       = foreColor.G
                        = foreColor.B
                          = 0;


    editBoxFont.size  = 10;
    editBoxFont.style = HY_FONT_PLAIN;
    editBoxFont.face  = "Helvetica";

    alignFlags        = HY_ALIGN_LEFT;

    margins.left      = margins.right
                        = margins.top
                          = margins.bottom
                            = 5;

    boxFlags = HY_TB_ENABLED | (bt?HY_TB_BIGBOX:0);

    //boxType             = bt;
}

//__________________________________________________________________

_HYTextBox::~_HYTextBox()
{
}

//__________________________________________________________________

void            _HYTextBox::SetBackColor (_HYColor c)
{
    if ((c.R!=backColor.R)||(c.G!=backColor.G)||(c.B!=backColor.B)) {
        backColor = c;
        _SetBackColor (c);
        _MarkForUpdate();
    }
}

//__________________________________________________________________

_HYColor&       _HYTextBox::GetBackColor (void)
{
    return backColor;
}

//__________________________________________________________________

void            _HYTextBox::SetForeColor (_HYColor c)
{
    if ((c.R!=foreColor.R)||(c.G!=foreColor.G)||(c.B!=foreColor.B)) {
        foreColor = c;
        _SetForeColor (c);
        _MarkForUpdate();
    }
}

//__________________________________________________________________

void            _HYTextBox::SetBackTColor (_HYColor c)
{
    if ((c.R!=backTextColor.R)||(c.G!=backTextColor.G)||(c.B!=backTextColor.B)) {
        backTextColor = c;
        _SetBackTColor (c);
        _MarkForUpdate();
    }
}

//__________________________________________________________________

_HYColor&       _HYTextBox::GetForeColor (void)
{
    return foreColor;
}

//__________________________________________________________________

_HYColor&       _HYTextBox::GetBackTColor (void)
{
    return backTextColor;
}


//__________________________________________________________________
void            _HYTextBox::SetText (const _String& newText, bool update)
{
    _SetText (newText);
    _MarkForUpdate();
    if (messageRecipient && update) {
        messageRecipient->ProcessEvent (generateTextEditChangeEvent (GetID(),1));
    }
}

//__________________________________________________________________
void            _HYTextBox::InsertText (const _String& newText, bool update, bool append)
{
    _InsertText (newText, append);
    _MarkForUpdate();
    if (messageRecipient && update) {
        messageRecipient->ProcessEvent (generateTextEditChangeEvent (GetID(),1));
    }
}

//__________________________________________________________________

_String         _HYTextBox::GetText (void)
{
    return _GetText();
}


//__________________________________________________________________

void            _HYTextBox::StoreText (_String*& rec, bool selOnly)
{
    return _StoreText(rec, selOnly);
}

//__________________________________________________________________

_HYFont&        _HYTextBox::GetFont (void)
{
    return editBoxFont;
}

//__________________________________________________________________
void            _HYTextBox::SetMargins (_HYRect m)
{
    if ((m.top!=margins.top)||(m.bottom!=margins.bottom)
            ||(m.left!=margins.left)||(m.right!=margins.right)) {
        margins = m;
        SetVisibleSize (rel);
        _MarkForUpdate ();
    }
}

//__________________________________________________________________

void            _HYTextBox::SetFont (_HYFont&f)
{
    if ((!f.face.Equal(&editBoxFont.face))||(f.size!=editBoxFont.size)||(f.style!=editBoxFont.style)) {
        _SetFont (f);
        editBoxFont.face  = f.face;
        editBoxFont.size  = f.size;
        editBoxFont.style = f.style;
        _MarkForUpdate();
    }
}

//__________________________________________________________________
void            _HYTextBox::SetVisibleSize (_HYRect rel)
{
    _HYComponent::SetVisibleSize (rel);
    _HYPlatformTextBox::_SetVisibleSize (rel);
}

//__________________________________________________________________

void            _HYTextBox::EnableTextEdit (bool e)
{
    bool ie = boxFlags&HY_TB_ENABLED;
    if (ie!=e) {
        if (e) {
            boxFlags |= HY_TB_ENABLED;
        } else {
            boxFlags -= HY_TB_ENABLED;
        }

        _EnableTextBox (e);
        _MarkForUpdate ();
    }
}

//__________________________________________________________________

void            _HYTextBox::FocusComponent (void)
{
#ifndef __WINDOZE__
    if (!(boxFlags&HY_TB_FOCUSED))
#endif
    {
        boxFlags |= HY_TB_FOCUSED;
        if (!(boxFlags&HY_TB_BIGBOX)) {
            SetSelection   (0,0x7fffffff);
        }
        _FocusComponent();
        _MarkForUpdate();
    }
}

//__________________________________________________________________

void            _HYTextBox::UnfocusComponent (void)
{
    if (boxFlags&HY_TB_FOCUSED) {
        boxFlags -= HY_TB_FOCUSED;
        _UnfocusComponent();
        _MarkForUpdate();
    }
}
\ No newline at end of file
diff --git a/src/gui/gtk/Components/HYPlatformButton.cpp b/src/gui/gtk/Components/HYPlatformButton.cpp
index ea10295..cd22836 100644
--- a/src/gui/gtk/Components/HYPlatformButton.cpp
+++ b/src/gui/gtk/Components/HYPlatformButton.cpp
@@ -1,8 +1,41 @@
 /*
-    Button component for GTK.
-
-    Sergei L. Kosakovsky Pond, November 2004
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include "errorfns.h"
 #include "HYButton.h"
diff --git a/src/gui/gtk/Components/HYPlatformButtonBar.cpp b/src/gui/gtk/Components/HYPlatformButtonBar.cpp
index aec475e..ae8cdb2 100644
--- a/src/gui/gtk/Components/HYPlatformButtonBar.cpp
+++ b/src/gui/gtk/Components/HYPlatformButtonBar.cpp
@@ -1,8 +1,41 @@
 /*
-    Toolbar component glue for GTK+
-
-    Sergei L. Kosakovsky Pond, November 2004
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include "HYPlatformGraphicPane.h"
 
@@ -501,4 +534,4 @@ void        _HYButtonBar::_DisplayToolTip      (void)
         }
     }
 }
-//EOF
\ No newline at end of file
+//EOF
diff --git a/src/gui/gtk/Components/HYPlatformCheckBox.cpp b/src/gui/gtk/Components/HYPlatformCheckBox.cpp
index c5b6a94..656faf7 100644
--- a/src/gui/gtk/Components/HYPlatformCheckBox.cpp
+++ b/src/gui/gtk/Components/HYPlatformCheckBox.cpp
@@ -1,8 +1,41 @@
 /*
-    Check box glue for GTK.
-
-    Sergei L. Kosakovsky Pond, November 2004
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include "HYLabel.h"
 #include "HYWindow.h"
@@ -196,4 +229,4 @@ void    _HYPlatformCheckbox::_SetState (bool v)
         }
 }
 
-//EOF
\ No newline at end of file
+//EOF
diff --git a/src/gui/gtk/Components/HYPlatformLabel.cpp b/src/gui/gtk/Components/HYPlatformLabel.cpp
index 0ddf9d4..f2b60ba 100644
--- a/src/gui/gtk/Components/HYPlatformLabel.cpp
+++ b/src/gui/gtk/Components/HYPlatformLabel.cpp
@@ -1,8 +1,41 @@
 /*
-    Label component glue for GTK
-
-    Sergei L. Kosakovsky Pond, November 2, 2004
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include "HYLabel.h"
 #include "HYUtils.h"
@@ -183,4 +216,4 @@ void        _HYPlatformLabel::_Paint (Ptr p)
     (*theParent)._HYPlatformComponent::_Paint(p);
 }
 
-// EOF
\ No newline at end of file
+// EOF
diff --git a/src/gui/gtk/Components/HYPlatformPullDown.cpp b/src/gui/gtk/Components/HYPlatformPullDown.cpp
index 7b9a1a7..0759178 100644
--- a/src/gui/gtk/Components/HYPlatformPullDown.cpp
+++ b/src/gui/gtk/Components/HYPlatformPullDown.cpp
@@ -1,8 +1,41 @@
 /*
-    Pulldown component glue for GTK+.
-
-    Sergei L. Kosakovsky Pond, November 2004.
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include "errorfns.h"
 #include "HYPullDown.h"
@@ -421,4 +454,4 @@ bool _HYPullDown::_ProcessOSEvent (Ptr vEvent)
 }
 
 
-//EOF
\ No newline at end of file
+//EOF
diff --git a/src/gui/gtk/Components/HYPlatformSequencePane.cpp b/src/gui/gtk/Components/HYPlatformSequencePane.cpp
index 7a5432a..4e85986 100644
--- a/src/gui/gtk/Components/HYPlatformSequencePane.cpp
+++ b/src/gui/gtk/Components/HYPlatformSequencePane.cpp
@@ -1,8 +1,41 @@
 /*
-    Sequence Panel for Win32 API
-
-    Sergei L. Kosakovsky Pond, May 2000-January 2003
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include "errorfns.h"
 #include "HYSequencePanel.h"
@@ -304,4 +337,4 @@ bool _HYSequencePane::_ProcessOSEvent (Ptr vEvent)
 }
 
 
-//EOF
\ No newline at end of file
+//EOF
diff --git a/src/gui/gtk/Components/HYPlatformTable.cpp b/src/gui/gtk/Components/HYPlatformTable.cpp
index d20e5ec..325f87e 100644
--- a/src/gui/gtk/Components/HYPlatformTable.cpp
+++ b/src/gui/gtk/Components/HYPlatformTable.cpp
@@ -1,8 +1,41 @@
 /*
-    Table component for GTK API
-
-    Sergei L. Kosakovsky Pond, March 2005
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include "errorfns.h"
 #include "HYTableComponent.h"
@@ -1602,4 +1635,4 @@ void        _HYTable::_PrintTable (_SimpleList& columns, _SimpleList& rows, _HYT
 }
 
 
-//EOF
\ No newline at end of file
+//EOF
diff --git a/src/gui/gtk/Components/HYPlatformTextBox.cpp b/src/gui/gtk/Components/HYPlatformTextBox.cpp
index 712eca8..58fc263 100644
--- a/src/gui/gtk/Components/HYPlatformTextBox.cpp
+++ b/src/gui/gtk/Components/HYPlatformTextBox.cpp
@@ -1,8 +1,41 @@
 /*
-    Text input box for GTK+ Glue
-
-    Sergei L. Kosakovsky Pond, November 2004
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include "errorfns.h"
 #include "HYTextBox.h"
@@ -582,4 +615,4 @@ void        _HYPlatformTextBox::_CreateTE (void)
         }
     }
 }
-//EOF
\ No newline at end of file
+//EOF
diff --git a/src/gui/gtk/HYPlatformComponent.cpp b/src/gui/gtk/HYPlatformComponent.cpp
index 8936524..d3e50ab 100644
--- a/src/gui/gtk/HYPlatformComponent.cpp
+++ b/src/gui/gtk/HYPlatformComponent.cpp
@@ -1,4 +1,44 @@
 /*
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
+
+
+/*
     A general composite window component object, GTK+ glue
 
     Sergei L. Kosakovsky Pond, October 2004.
diff --git a/src/gui/gtk/HYPlatformGraphicPane.cpp b/src/gui/gtk/HYPlatformGraphicPane.cpp
index ba76575..30ec3ff 100644
--- a/src/gui/gtk/HYPlatformGraphicPane.cpp
+++ b/src/gui/gtk/HYPlatformGraphicPane.cpp
@@ -1,4 +1,44 @@
 /*
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
+
+
+/*
     A painting canvas with double buffer glue for GTK+
 
     Sergei L. Kosakovsky Pond, October 2004.
@@ -545,4 +585,4 @@ void _HYPlatformGraphicPane::_ErasePolygon (Ptr rgn)
 
 
 
-//EOF
\ No newline at end of file
+//EOF
diff --git a/src/gui/gtk/HYPlatformUtils.cpp b/src/gui/gtk/HYPlatformUtils.cpp
index fa741c1..600c0b7 100644
--- a/src/gui/gtk/HYPlatformUtils.cpp
+++ b/src/gui/gtk/HYPlatformUtils.cpp
@@ -1,3 +1,43 @@
+/*
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
+
+
 #include "HYUtils.h"
 #include "HYWindow.h"
 #include "hy_strings.h"
diff --git a/src/gui/gtk/HYPlatformWindow.cpp b/src/gui/gtk/HYPlatformWindow.cpp
index 57b9b4c..3e41e20 100644
--- a/src/gui/gtk/HYPlatformWindow.cpp
+++ b/src/gui/gtk/HYPlatformWindow.cpp
@@ -1,4 +1,44 @@
 /*
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
+
+
+/*
     A  window object - GTK glue.
 
     Sergei L. Kosakovsky Pond, Fall 2004.
@@ -721,4 +761,4 @@ void _HYPlatformWindow::_SelectWindow (void)
     _Show();
 }
 
-//EOF
\ No newline at end of file
+//EOF
diff --git a/src/gui/gtk/WindowClasses/HYPlatformBootsrapWindow.cpp b/src/gui/gtk/WindowClasses/HYPlatformBootsrapWindow.cpp
index cfe8973..2b6b795 100644
--- a/src/gui/gtk/WindowClasses/HYPlatformBootsrapWindow.cpp
+++ b/src/gui/gtk/WindowClasses/HYPlatformBootsrapWindow.cpp
@@ -1,4 +1,43 @@
 /*
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
+
+/*
     GTK+ portions of the bootstrap window class
 
     Sergei L. Kosakovsky Pond, Spring 2005.
@@ -38,4 +77,4 @@ bool        _HYBootstrapWindow::_ProcessMenuSelection (long msel)
 
 
 
-//EOF
\ No newline at end of file
+//EOF
diff --git a/src/gui/gtk/WindowClasses/HYPlatformChartWindow.cpp b/src/gui/gtk/WindowClasses/HYPlatformChartWindow.cpp
index 56fc33b..1423bb7 100644
--- a/src/gui/gtk/WindowClasses/HYPlatformChartWindow.cpp
+++ b/src/gui/gtk/WindowClasses/HYPlatformChartWindow.cpp
@@ -1,4 +1,43 @@
 /*
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
+
+/*
     GTK+ Portions of the chart window class
 
     Sergei L. Kosakovsky Pond, March 2005.
@@ -335,4 +374,4 @@ bool _HYDistributionChartWindow::_ProcessMenuSelection (long msel)
 
 
 
-//EOF
\ No newline at end of file
+//EOF
diff --git a/src/gui/gtk/WindowClasses/HYPlatformConsoleWindow.cpp b/src/gui/gtk/WindowClasses/HYPlatformConsoleWindow.cpp
index 7ecb6d8..68fb2cd 100644
--- a/src/gui/gtk/WindowClasses/HYPlatformConsoleWindow.cpp
+++ b/src/gui/gtk/WindowClasses/HYPlatformConsoleWindow.cpp
@@ -1,4 +1,43 @@
 /*
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
+
+/*
     GTK Portions of the console window class
 
     Sergei L. Kosakovsky Pond, Spring 2005.
diff --git a/src/gui/gtk/WindowClasses/HYPlatformDBWindow.cpp b/src/gui/gtk/WindowClasses/HYPlatformDBWindow.cpp
index 4278975..8eb98f0 100644
--- a/src/gui/gtk/WindowClasses/HYPlatformDBWindow.cpp
+++ b/src/gui/gtk/WindowClasses/HYPlatformDBWindow.cpp
@@ -1 +1 @@
-/*
    GTK Portions of the DB Window class

    Sergei L. Kosakovsky Pond, Fall 2005.
*/

#include "HYDBWindow.h"

//__________________________________________________________________


bool        _HYDBWindow::_ProcessMenuSelection (long msel)
{
    // TBI
    return _HYTWindow::_ProcessMenuSelection(msel);
}

//EOF
\ No newline at end of file
+/*
 
 HyPhy - Hypothesis Testing Using Phylogenies.
 
 Copyright (C) 1997-now
 Core Developers:
 Sergei L Kosakovsky Pond (spond at ucsd.edu)
 Art FY Poon    (apoon at cfenet.ubc.ca)
 Steven Weaver (sweaver at ucsd.edu)
 
 Module Developers:
 Lance Hepler (nlhepler at gmail.com)
 Martin Smith (martin.audacis at gmail.com)
 
 Significant contributions from:
 Spencer V Muse (muse at stat.ncsu.edu)
 Simon DW Frost (sdf22 at cam.ac.uk)
 
 Permission is hereby granted, free of charge, to any person obtaining a
 copy of this software and associated documentation files (the
 "Software"), to deal in the Software without restriction, including
 without limitation the rights to use, copy, modify, merge, publish,
 distribute, sublicense, and/or sell copies of the Software, and to
 permit persons to whom the Software is furnished to do so, subject to
 the following conditions:
 
 The above copyright notice and this permission notice shall be included
 in all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 */


/*
    GTK Portions of the DB Window class

    Sergei L. Kosakovsky Pond, Fall 2005.
*/

#include "HYDBWindow.h"

//__________________________________________________________________


bool        _HYDBWindow::_ProcessMenuSelection (long msel)
{
    // TBI
    return _HYTWindow::_ProcessMenuSelection(msel);
}

//EOF
\ No newline at end of file
diff --git a/src/gui/gtk/WindowClasses/HYPlatformDataPanel.cpp b/src/gui/gtk/WindowClasses/HYPlatformDataPanel.cpp
index 10d94ba..36f4813 100644
--- a/src/gui/gtk/WindowClasses/HYPlatformDataPanel.cpp
+++ b/src/gui/gtk/WindowClasses/HYPlatformDataPanel.cpp
@@ -1,4 +1,44 @@
 /*
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
+
+
+/*
     GTK Portions of the data panel class
 
     Sergei L. Kosakovsky Pond, Spring 2005.
@@ -749,4 +789,4 @@ bool _HYDataPanel::_ProcessOSEvent (Ptr vEvent)
 
 
 
-//EOF
\ No newline at end of file
+//EOF
diff --git a/src/gui/gtk/WindowClasses/HYPlatformGWindow.cpp b/src/gui/gtk/WindowClasses/HYPlatformGWindow.cpp
index 01229f1..89e257a 100644
--- a/src/gui/gtk/WindowClasses/HYPlatformGWindow.cpp
+++ b/src/gui/gtk/WindowClasses/HYPlatformGWindow.cpp
@@ -1,4 +1,44 @@
 /*
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
+
+
+/*
     Graphics Window Object  glue for GTK+
 
     Sergei L. Kosakovsky Pond, October 2004
@@ -66,4 +106,4 @@ void _HYGWindow::_UnsetMenuBar(void)
 }
 
 
-//EOF
\ No newline at end of file
+//EOF
diff --git a/src/gui/gtk/WindowClasses/HYPlatformModelWindow.cpp b/src/gui/gtk/WindowClasses/HYPlatformModelWindow.cpp
index da16d45..f4c77ea 100644
--- a/src/gui/gtk/WindowClasses/HYPlatformModelWindow.cpp
+++ b/src/gui/gtk/WindowClasses/HYPlatformModelWindow.cpp
@@ -1,4 +1,44 @@
 /*
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
+
+
+/*
     GTK+ Portions of the model window
 
     Sergei L. Kosakovsky Pond, Spring 2005.
@@ -153,4 +193,4 @@ void _HYModelWindow::_SetClipboard (void)
     //  PlaceStringInClipboard (clipboardString, (Ptr)theWindow);
 }
 
-//EOF
\ No newline at end of file
+//EOF
diff --git a/src/gui/gtk/WindowClasses/HYPlatformPWindow.cpp b/src/gui/gtk/WindowClasses/HYPlatformPWindow.cpp
index 35855ef..29af364 100644
--- a/src/gui/gtk/WindowClasses/HYPlatformPWindow.cpp
+++ b/src/gui/gtk/WindowClasses/HYPlatformPWindow.cpp
@@ -1,4 +1,44 @@
 /*
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
+
+
+/*
     TBI parts of HYPWindow for GTK
 */
 
@@ -222,4 +262,4 @@ bool _HYPWindow::_ProcessOSEvent (Ptr vEvent)
 }
 
 //__________________________________________________________________
-//EOF
\ No newline at end of file
+//EOF
diff --git a/src/gui/gtk/WindowClasses/HYPlatformParameterTable.cpp b/src/gui/gtk/WindowClasses/HYPlatformParameterTable.cpp
index d4cca5d..cd58948 100644
--- a/src/gui/gtk/WindowClasses/HYPlatformParameterTable.cpp
+++ b/src/gui/gtk/WindowClasses/HYPlatformParameterTable.cpp
@@ -1,4 +1,44 @@
 /*
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
+
+
+/*
     GTK+ Portions of the parameter table class
 
     Sergei L. Kosakovsky Pond, Spring 2005.
@@ -248,4 +288,4 @@ void _HYParameterTable::_UpdateUndoMenu(_String* command, _String* desc)
     }
 }
 
-//EOF
\ No newline at end of file
+//EOF
diff --git a/src/gui/gtk/WindowClasses/HYPlatformTWindow.cpp b/src/gui/gtk/WindowClasses/HYPlatformTWindow.cpp
index 6969233..3cb5383 100644
--- a/src/gui/gtk/WindowClasses/HYPlatformTWindow.cpp
+++ b/src/gui/gtk/WindowClasses/HYPlatformTWindow.cpp
@@ -1,4 +1,44 @@
 /*
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
+
+
+/*
     GTK+ glue for the container window
 
     Sergei L. Kosakovsky Pond, October-November 2004
@@ -542,4 +582,4 @@ _HYPlatformTWindow::~_HYPlatformTWindow(void)
         theTimer = 0;
     }
 }
-//EOF
\ No newline at end of file
+//EOF
diff --git a/src/gui/gtk/WindowClasses/HYPlatformTreePanel.cpp b/src/gui/gtk/WindowClasses/HYPlatformTreePanel.cpp
index b9cb3bb..55ad859 100644
--- a/src/gui/gtk/WindowClasses/HYPlatformTreePanel.cpp
+++ b/src/gui/gtk/WindowClasses/HYPlatformTreePanel.cpp
@@ -1,4 +1,44 @@
 /*
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
+
+
+/*
     Tree  Panel Object  for GTK
 
     Sergei L. Kosakovsky Pond, March 2005
@@ -850,4 +890,4 @@ void        _HYTreePanel::_PaintLFStatus(Ptr p)
     }
 }
 
-//EOF
\ No newline at end of file
+//EOF
diff --git a/src/gui/gtk/include/Components/HYPlatformButton.h b/src/gui/gtk/include/Components/HYPlatformButton.h
index de953c6..ca20934 100644
--- a/src/gui/gtk/include/Components/HYPlatformButton.h
+++ b/src/gui/gtk/include/Components/HYPlatformButton.h
@@ -1,8 +1,41 @@
 /*
-    A button object glue for GTK.
-
-    Sergei L. Kosakovsky Pond, November 2004.
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #ifndef _HYPBUTTON_
 #define _HYPBUTTON_
@@ -40,4 +73,4 @@ public:
     _HYRect                 lastButtonDimension;
 };
 
-#endif
\ No newline at end of file
+#endif
diff --git a/src/gui/gtk/include/Components/HYPlatformButtonBar.h b/src/gui/gtk/include/Components/HYPlatformButtonBar.h
index 54b61e9..dbe266e 100644
--- a/src/gui/gtk/include/Components/HYPlatformButtonBar.h
+++ b/src/gui/gtk/include/Components/HYPlatformButtonBar.h
@@ -1,8 +1,41 @@
 /*
-    At toolbar menu object glue for GTK+
-
-    Sergei L. Kosakovsky Pond, November 2004.
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #ifndef _HYPBUTTONBAR_
 #define _HYPBUTTONBAR_
@@ -57,4 +90,4 @@ public:
 
 
 
-#endif
\ No newline at end of file
+#endif
diff --git a/src/gui/gtk/include/Components/HYPlatformCheckbox.h b/src/gui/gtk/include/Components/HYPlatformCheckbox.h
index 579790d..d6e43ed 100644
--- a/src/gui/gtk/include/Components/HYPlatformCheckbox.h
+++ b/src/gui/gtk/include/Components/HYPlatformCheckbox.h
@@ -1,8 +1,41 @@
 /*
-    A checkbox with optional static label object for GTK glue.
-
-    Sergei L. Kosakovsky Pond, November 3rd (this is the end...) 2004
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #ifndef _HYPLCHECKBOX_
 #define _HYPLCHECKBOX_
@@ -36,4 +69,4 @@ public:
     bool            isRadio;
 };
 
-#endif
\ No newline at end of file
+#endif
diff --git a/src/gui/gtk/include/Components/HYPlatformLabel.h b/src/gui/gtk/include/Components/HYPlatformLabel.h
index b923f4e..7665126 100644
--- a/src/gui/gtk/include/Components/HYPlatformLabel.h
+++ b/src/gui/gtk/include/Components/HYPlatformLabel.h
@@ -1,8 +1,41 @@
 /*
-    A static label object glue for GTK.
-
-    Sergei L. Kosakovsky Pond, November 2nd, 2004.
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #ifndef _HYPLABEL_
 #define _HYPLABEL_
@@ -38,4 +71,4 @@ public:
     GdkRectangle            labelRect;
 };
 
-#endif
\ No newline at end of file
+#endif
diff --git a/src/gui/gtk/include/Components/HYPlatformPullDown.h b/src/gui/gtk/include/Components/HYPlatformPullDown.h
index 7a18ba0..c0bae90 100644
--- a/src/gui/gtk/include/Components/HYPlatformPullDown.h
+++ b/src/gui/gtk/include/Components/HYPlatformPullDown.h
@@ -1,8 +1,41 @@
 /*
-    A pull down menu object glue for GTK+.
-
-    Sergei L. Kosakovsky Pond, November 2004.
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #ifndef _HYPPULLDOWNMENU_
 #define _HYPPULLDOWNMENU_
@@ -58,4 +91,4 @@ extern  GdkColor    buttonBorder1,
         buttonBorder2;
 
 
-#endif
\ No newline at end of file
+#endif
diff --git a/src/gui/gtk/include/Components/HYPlatformTable.h b/src/gui/gtk/include/Components/HYPlatformTable.h
index a970abf..347195e 100644
--- a/src/gui/gtk/include/Components/HYPlatformTable.h
+++ b/src/gui/gtk/include/Components/HYPlatformTable.h
@@ -1,8 +1,41 @@
 /*
-    A table object glue for GTK+
-
-    Sergei L. Kosakovsky Pond, March 2005.
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #ifndef _HYPLTABLE_
 #define _HYPLTABLE_
@@ -67,4 +100,4 @@ public:
 
 };
 
-#endif
\ No newline at end of file
+#endif
diff --git a/src/gui/gtk/include/Components/HYPlatformTextbox.h b/src/gui/gtk/include/Components/HYPlatformTextbox.h
index b8e27bc..44d3a17 100644
--- a/src/gui/gtk/include/Components/HYPlatformTextbox.h
+++ b/src/gui/gtk/include/Components/HYPlatformTextbox.h
@@ -1,8 +1,41 @@
 /*
-    A text input box object glue for GTK+
-
-    Sergei L. Kosakovsky Pond, November 2004
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #ifndef _HYPLTEXTBOX_
 #define _HYPLTEXTBOX_
@@ -61,4 +94,4 @@ public:
 //_String                   retrieveEditControlText (HWND);
 //void                  retrieveEditControlText (HWND, _String*&);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/src/gui/gtk/include/HYPlatformComponent.h b/src/gui/gtk/include/HYPlatformComponent.h
index 8f9e588..1eca6f7 100644
--- a/src/gui/gtk/include/HYPlatformComponent.h
+++ b/src/gui/gtk/include/HYPlatformComponent.h
@@ -1,8 +1,41 @@
 /*
-    A general composite window component object, FLTK glue
-
-    Sergei L. Kosakovsky Pond, October 2004.
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #ifndef _HYPCOMPONENT_
 #define _HYPCOMPONENT_
@@ -75,4 +108,4 @@ extern          double  fontConversionFactor;
 
 #endif
 
-//EOF
\ No newline at end of file
+//EOF
diff --git a/src/gui/gtk/include/HYPlatformGraphicPane.h b/src/gui/gtk/include/HYPlatformGraphicPane.h
index f39b702..cfa4130 100644
--- a/src/gui/gtk/include/HYPlatformGraphicPane.h
+++ b/src/gui/gtk/include/HYPlatformGraphicPane.h
@@ -1,8 +1,41 @@
 /*
-    A painting canvas glue for GTK
-
-    Sergei L. Kosakovsky Pond, October 2004.
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #ifndef _HYPGRAPHICPANE_
 #define _HYPGRAPHICPANE_
@@ -94,4 +127,4 @@ void            findGraphicsExporterComponents (_List&);
 extern                      PangoContext* screenPContext;
 #endif
 
-//EOF
\ No newline at end of file
+//EOF
diff --git a/src/gui/gtk/include/HYPlatformWindow.h b/src/gui/gtk/include/HYPlatformWindow.h
index f14faba..8f193a0 100644
--- a/src/gui/gtk/include/HYPlatformWindow.h
+++ b/src/gui/gtk/include/HYPlatformWindow.h
@@ -1,8 +1,42 @@
 /*
-    GTK window object glue - a window/title/size-box/scroll-bars handler.
 
-    Sergei L. Kosakovsky Pond, October 2004.
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #ifndef _HYPWINDOW_
 #define _HYPWINDOW_
@@ -172,4 +206,4 @@ void                        SetUpStatusBarStuff             (GtkWidget *);
 
 #endif
 
-//EOF
\ No newline at end of file
+//EOF
diff --git a/src/gui/preferences.cpp b/src/gui/preferences.cpp
index ca85921..c043d59 100644
--- a/src/gui/preferences.cpp
+++ b/src/gui/preferences.cpp
@@ -1,38 +1,41 @@
 /*
-
-HyPhy - Hypothesis Testing Using Phylogenies.
-
-This file implements shared and platform specific
-(via ifdefs) functions for reading/writing and
-setting preferences.
-
-Written by SL Kosakovsky Pond
-June 8, 2007
-
-Copyright (C) 1997-2009
-  Sergei L Kosakovsky Pond (spond at ucsd.edu)
-  Art FY Poon              (apoon at cfenet.ubc.ca)
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #include "likefunc.h"
 #include "preferences.h"
diff --git a/src/mains/mac.cpp b/src/mains/mac.cpp
index 2eaba05..bff716c 100644
--- a/src/mains/mac.cpp
+++ b/src/mains/mac.cpp
@@ -1,31 +1,41 @@
 /*
-
-HyPhy - Hypothesis Testing Using Phylogenies.
-
-Copyright (C) 1997-2009
-  Sergei L Kosakovsky Pond (spond at ucsd.edu)
-  Art FY Poon              (apoon at cfenet.ubc.ca)
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
 
 #ifndef __HYPHYXCODE__
 #include <unix.h>
diff --git a/src/new/HYNetInterface.cpp b/src/new/HYNetInterface.cpp
deleted file mode 100644
index d45fa09..0000000
--- a/src/new/HYNetInterface.cpp
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
-
-    This is a file which does NN interfacing with HBL model structures.
-
-    September 2003, Sergei L Kosakovsky Pond
-
-*/
-
-#include "HYNetInterface.h"
-#include "baseobj.h"
-#include "parser.h"
-
-_String   ModelTrainNNFlag          ("TRAIN_MODEL_NN"),
-          ModelLoadNNFlag             ("LOAD_MODEL_NN"),
-          ModelNNTrainingSteps        ("MODEL_NN_TRAINING_STEPS"),
-          ModelNNVerificationSample   ("MODEL_NN_VERIFICATION_STEPS"),
-          ModelNNPrecision            ("MODEL_NN_PRECISION"),
-          ModelNNLoops                ("MODEL_MAX_LOOPS"),
-          ModelNNHiddenNodes      ("MODEL_NN_HIDDEN_NODES"),
-          ModelNNFile             ("MODEL_NN_FILE_PATH"),
-          ModelNNLearningRate     ("MODEL_NN_LEARNING_RATE"),
-          ModelNNPersistenceRate  ("MODEL_NN_PERSISTENCE_RATE");
-
-
-
-/*______________________________________________________________________*/
-
-void         TrainModelNN   (_String* model, _String* matrix)
-{
-    _String         errMsg;
-
-    long            modelIdx = modelNames.Find(model);
-
-    _Parameter      verbI;
-
-    checkParameter (VerbosityLevelString, verbI, 0.0);
-
-    char            buffer [128];
-
-    if (modelIdx < 0) {
-        errMsg = *model & " did not refer to an existring model";
-    } else {
-        _Variable*    boundsMatrix              =   FetchVar  (LocateVarByName (*matrix));
-
-        if (boundsMatrix && (boundsMatrix->ObjectClass() == MATRIX)) {
-            _Matrix  *    bmatrix               =   (_Matrix*)      boundsMatrix->GetValue ();
-
-            if (bmatrix->IsAStringMatrix() && (bmatrix->GetVDim () == 3)) {
-                _Variable*    modelMatrix           =   LocateVar       (modelMatrixIndices.lData[modelIdx]);
-                _SimpleList   modelVariableList;
-                {
-                    _AVLList mvla (&modelVariableList);
-                    modelMatrix->ScanForVariables       (mvla, true);
-                    mvla.ReorderList();
-                }
-
-                if (bmatrix->GetHDim () == modelVariableList.lLength) {
-                    // now map model variables to bounds matrix
-                    _SimpleList          variableMap;
-                    _String             *myName;
-
-                    for (long k = 0; k < modelVariableList.lLength; k++) {
-                        myName = ((_FString*)bmatrix->GetFormula(k,0)->Compute())->theString;
-                        long      vID    = LocateVarByName (*myName);
-
-                        if (vID < 0) {
-                            break;
-                        }
-
-                        vID = variableNames.GetXtra (vID);
-                        vID = modelVariableList.Find(vID);
-
-                        if (vID < 0) {
-                            break;
-                        }
-
-                        variableMap << vID;
-                    }
-
-                    if (variableMap.lLength == modelVariableList.lLength) {
-                        _Matrix     vBounds (variableMap.lLength,2, false, true);
-
-                        long        k2 = 0;
-
-                        for (; k2 < variableMap.lLength; k2++) {
-                            _Parameter lb = ((_FString*)bmatrix->GetFormula(k2,1)->Compute())->theString->toNum(),
-                                       ub = ((_FString*)bmatrix->GetFormula(k2,2)->Compute())->theString->toNum();
-
-                            if ( ub>lb || k2) {
-                                vBounds.Store (k2,0,lb);
-                                vBounds.Store (k2,1,ub);
-                                if (ub<=lb && vBounds (k2-1,0) <= vBounds (k2-1,1) && (!CheckEqual(vBounds (k2-1,0),0.0) || !CheckEqual(vBounds (k2-1,1),1.0))) {
-                                    break;
-                                }
-                            }
-
-                        }
-                        if (k2 == modelVariableList.lLength) {
-                            // set up the sampling now
-                            _String             fName       = ProcessLiteralArgument (&ModelNNFile,nil);
-                            FILE*               nnFile      = doFileOpen (fName.getStr(), "w");
-                            if (nnFile) {
-                                _Matrix*            modelMatrix = (_Matrix*) LocateVar(modelMatrixIndices.lData[modelIdx])->GetValue();
-
-                                _Parameter          mainSteps,
-                                                    checkSteps,
-                                                    errorTerm,
-                                                    loopMax,
-                                                    hiddenNodes,
-                                                    absError,
-                                                    nn1,
-                                                    nn2;
-
-                                long                fullDimension = modelMatrix->GetHDim() * modelMatrix->GetVDim();
-
-
-                                checkParameter      (ModelNNTrainingSteps,      mainSteps,      10000.0);
-                                checkParameter      (ModelNNVerificationSample, checkSteps,     500.0);
-                                checkParameter      (ModelNNPrecision,          errorTerm,      0.01);
-                                checkParameter      (ModelNNTrainingSteps,      loopMax,        10);
-                                checkParameter      (ModelNNHiddenNodes,        hiddenNodes,    5);
-                                checkParameter      (ModelNNLearningRate,       nn1,            .3);
-                                checkParameter      (ModelNNPersistenceRate,    nn2,            .1);
-
-                                Net**               matrixNet = new Net* [fullDimension] ;
-
-                                for (long i = 0; i < fullDimension; i++) {
-                                    checkPointer (matrixNet [i] = new Net (variableMap.lLength,(long)hiddenNodes,1,errorTerm,nn1,nn2,100,200,true));
-                                    //matrixNet[i]->verbose = true;
-                                }
-
-                                checkPointer        (matrixNet);
-
-                                _List               tIn,
-                                                    tOut;
-
-                                FILE*               varSamples = doFileOpen ("variableSamples.out", "w");
-
-                                fprintf (varSamples, "%s" ,LocateVar(modelVariableList.lData[0])->GetName()->getStr());
-                                for (long vc = 1; vc < modelVariableList.lLength; vc++) {
-                                    fprintf (varSamples, ",%s" ,LocateVar(modelVariableList.lData[variableMap.lData[vc]])->GetName()->getStr());
-                                }
-
-                                fprintf (varSamples, "\n");
-
-                                for (long itCount = 0; itCount < loopMax; itCount ++) {
-                                    if (verbI > 5) {
-                                        snprintf (buffer, sizeof(buffer), "\nNeural Network Pass %ld. Building a training set...\n", itCount);
-                                        BufferToConsole (buffer);
-                                    }
-
-                                    while   (tIn.countitems() < mainSteps) {
-                                        NNMatrixSampler     (0, vBounds, modelVariableList, variableMap, modelMatrix, tIn, tOut);
-                                    }
-
-                                    _Matrix             inData (mainSteps, variableMap.lLength, false, true);
-                                    _Parameter          *md = inData.theData;
-
-                                    for (long matrixC = 0; matrixC < mainSteps; matrixC++) {
-                                        _Parameter  *   ed = ((_Matrix*)tIn (matrixC))->theData;
-                                        fprintf (varSamples, "\n%g",*ed);
-                                        *md = *ed;
-                                        ed++;
-                                        md++;
-                                        for (long entryC = 1; entryC < variableMap.lLength; entryC++, ed++, md++) {
-                                            *md = *ed;
-                                            fprintf (varSamples, ",%g", *md);
-                                        }
-                                    }
-
-                                    tIn.Clear();
-
-                                    if (verbI > 5) {
-                                        BufferToConsole ( "Done Building Training Set. Training...\n");
-                                    }
-
-                                    long lastDone = 0;
-
-                                    for (long cellCount = 0; cellCount < fullDimension; cellCount++) {
-                                        Net* thisCell = matrixNet[cellCount];
-                                        _Matrix outVector (mainSteps, 1, false, true);
-
-                                        for (long oc = 0; oc < mainSteps; oc++) {
-                                            outVector.theData[oc] = ((_Matrix*)tOut(oc))->theData[cellCount];
-                                        }
-
-                                        thisCell->studyAll (inData.theData, outVector.theData, mainSteps);
-
-                                        long    nowDone = (cellCount+1)*100./fullDimension;
-                                        if (nowDone > lastDone) {
-                                            snprintf (buffer, sizeof(buffer),"%ld%% done\n", lastDone = nowDone);
-                                            BufferToConsole (buffer);
-                                        }
-                                    }
-                                    tOut.Clear();
-
-                                    if (verbI > 5) {
-                                        BufferToConsole ( "Done Training. Resampling...\n");
-                                    }
-
-                                    _PMathObj  tObj = _Constant(0).Time();
-                                    _Parameter time1 = tObj->Value(),
-                                               time2;
-
-                                    while   (tIn.countitems() < checkSteps) {
-                                        NNMatrixSampler     (0, vBounds, modelVariableList, variableMap, modelMatrix, tIn, tOut);
-                                    }
-
-                                    absError = 0.0;
-
-                                    DeleteObject (tObj);
-                                    tObj = _Constant(0).Time();
-                                    time2 = tObj->Value();
-
-                                    if (verbI > 5) {
-                                        snprintf (buffer, sizeof(buffer),"Done Resampling in %g seconds. Computing Error...\n", time2-time1);
-                                        BufferToConsole (buffer);
-                                    }
-
-                                    _Parameter  maxValT,
-                                                maxValE;
-
-                                    for (long verCount = 0; verCount < checkSteps; verCount++) {
-                                        _Parameter*  inData     = ((_Matrix*)tIn(verCount))->theData,
-                                                     *  outData  = ((_Matrix*)tOut(verCount))->theData;
-
-                                        for (long cellCount = 0; cellCount < fullDimension; cellCount++) {
-                                            Net         *thisCell = matrixNet[cellCount];
-
-                                            _Parameter estVal     = thisCell->eval(inData)[0],
-                                                       trueVal      = outData[cellCount],
-                                                       localError;
-
-                                            localError = estVal-trueVal;
-
-                                            if (localError < 0) {
-                                                localError = -localError;
-                                            }
-
-                                            if (absError < localError) {
-                                                maxValT  = trueVal;
-                                                maxValE  = estVal;
-                                                absError = localError;
-                                            }
-                                        }
-                                    }
-
-                                    DeleteObject (tObj);
-                                    tObj = _Constant(0).Time();
-                                    time1 = tObj->Value();
-                                    DeleteObject (tObj);
-
-
-                                    if (verbI > 5) {
-                                        snprintf (buffer, sizeof(buffer), "Done Error Checking in %g seconds. Got max abs error %g on the pair %g %g\n", time1-time2, absError, maxValT, maxValE);
-                                        BufferToConsole (buffer);
-                                    }
-                                    if (absError <= errorTerm) {
-                                        break;
-                                    }
-                                }
-
-                                if (absError > errorTerm) {
-                                    ReportWarning (_String("Couldn't achive desired precision in TrainModelNN. Achieved error of ") & absError);
-                                }
-                                fclose  (varSamples);
-                                fprintf (nnFile,"{{\n\"%s\"", LocateVar(modelVariableList.lData[0])->GetName()->getStr());
-                                _Matrix newBounds (modelVariableList.lLength, 2, false, true);
-                                if (vBounds(0,0)>vBounds(0,1)) {
-                                    newBounds.Store (variableMap.lData[0],0,0.);
-                                    newBounds.Store (variableMap.lData[0],1,1.);
-                                } else {
-                                    newBounds.Store (variableMap.lData[0],0,vBounds(0,0));
-                                    newBounds.Store (variableMap.lData[0],1,vBounds(0,1));
-                                }
-                                for (long varCounter = 1; varCounter < modelVariableList.lLength; varCounter ++) {
-                                    fprintf (nnFile,",\n\"%s\"", LocateVar(modelVariableList.lData[varCounter])->GetName()->getStr());
-                                    if (vBounds(varCounter,0)>vBounds(varCounter,1)) {
-                                        newBounds.Store (variableMap.lData[varCounter],0,0.);
-                                        newBounds.Store (variableMap.lData[varCounter],1,1.);
-                                    } else {
-                                        newBounds.Store (variableMap.lData[varCounter],0,vBounds(varCounter,0));
-                                        newBounds.Store (variableMap.lData[varCounter],1,vBounds(varCounter,1));
-                                    }
-                                }
-
-                                fprintf (nnFile,"\n}}\n");
-                                newBounds.toFileStr (nnFile);
-
-
-                                for (long i2 = 0; i2 < fullDimension; i2++) {
-                                    matrixNet[i2]->save(nnFile);
-                                    delete matrixNet [i2];
-                                }
-
-                                fclose (nnFile);
-                                delete              matrixNet;
-                            } else {
-                                errMsg = _String ("Failed to open ") & fName & " for writing";
-                            }
-                        } else {
-                            errMsg = _String ("Invalid variable bounds in row ") & (k2+1) & " of the bounds matrix";
-                        }
-                    } else {
-                        errMsg = *myName & " was not one of the model parameters";
-                    }
-
-                } else {
-                    errMsg = *matrix & " must be a have the same number of rows as the number of model parameters";
-                }
-
-            } else {
-                errMsg = *matrix & " must be a string matrix with 3 columns";
-            }
-        } else {
-            errMsg = *matrix & " was not the identifier of a valid matrix variable";
-        }
-
-
-
-    }
-
-    if (errMsg.sLength) {
-        errMsg = errMsg & _String(" in call to TrainModelNN.");
-        WarnError (errMsg);
-    }
-}
-
-/*______________________________________________________________________*/
-
-void        NNMatrixSampler (long index, _Matrix& bnds, _SimpleList& varList, _SimpleList& reidx, _Matrix* modelMatrix, _List& trainIn, _List& trainOut)
-{
-    _Parameter lb = bnds (index,0),
-               ub = bnds (index,1);
-
-    if (ub<=lb)
-        // freq parameter
-    {
-        ub = 1.;
-        lb = 0.;
-        for (long k = index-1; k>=0; k--) {
-            ub -= LocateVar (varList.lData[reidx.lData[k]])->Value();
-            if (bnds (k,1) > bnds (k,0)) {
-                break;
-            }
-        }
-
-        if ((index == varList.lLength - 1)||(bnds (index+1,1) > bnds (index+1,0))) {
-            lb = ub;
-        }
-    }
-
-    _Constant cv (lb + genrand_real2 () * (ub-lb));
-    LocateVar (varList.lData[reidx.lData[index]])->SetValue (&cv);
-
-    if (index == varList.lLength - 1) {
-        _Matrix*  inMx = new _Matrix (index+1,1,false,true);
-
-        checkPointer (inMx);
-
-        for (long m = 0; m <= index; m++) {
-            inMx->Store (m,0,LocateVar (varList.lData[reidx.lData[m]])->Value());
-        }
-
-        trainIn << inMx;
-
-        DeleteObject (inMx);
-
-        _Matrix  *em = ((_Matrix*)modelMatrix->ComputeNumeric())->Exponentiate();
-        trainOut <<  em;
-        DeleteObject (em);
-    } else {
-        NNMatrixSampler (index+1, bnds, varList, reidx, modelMatrix, trainIn, trainOut);
-    }
-}
diff --git a/src/new/Net.cpp b/src/new/Net.cpp
deleted file mode 100644
index c22e8e7..0000000
--- a/src/new/Net.cpp
+++ /dev/null
@@ -1,606 +0,0 @@
-// copyright Oliver Serang, 2003
-// this document may not be duplicated, not redistributed without
-// written consent of the author
-
-#include "SerangNet.h"
-#include "parser.h"
-//#include <iostream.h>
-
-Net::Net(int innum, int hiddennum, int outnum, _Parameter eps, _Parameter c, _Parameter m,int d, int t, bool v)
-{
-    init(innum, hiddennum, outnum, eps);
-    coef=c;
-    mom=m;
-    timeout=t;
-    verbose=v;
-    density=d;
-}
-
-Net::Net(int innum, int hiddennum, int outnum, _Parameter eps)
-{
-    init(innum, hiddennum, outnum, eps);
-    coef=.3;
-    mom=.1;
-    timeout=600;
-    verbose=false;
-    density=100;
-}
-
-void Net::init(int innum, int hiddennum, int outnum, _Parameter eps)
-{
-//  cout << innum << " " << hiddennum << " " << outnum << endl;
-    inNum=innum;
-    hiddenNum=hiddennum;
-    outNum=outnum;
-    in=new Node[innum+1];
-    hidden=new Node[hiddennum+1];
-    out= new _Parameter[outnum];
-    temp= new _Parameter[outnum];
-    int k, i;
-    for (k=0; k<=innum; k++) {
-        in[k].weights=new _Parameter[hiddennum];
-        in[k].lastDelta=new _Parameter[hiddennum];
-        for (i=0; i<hiddennum; i++) {
-            in[k].weights[i]=randReal(.1);
-            in[k].lastDelta[i]=0;
-//          in[k].weights[i]=.1;
-        }
-    }
-    for (k=0; k<=hiddennum; k++) {
-        hidden[k].weights= new _Parameter[outnum];
-        hidden[k].lastDelta=new _Parameter[outnum];
-        for (i=0; i<outnum; i++) {
-            hidden[k].weights[i]=randReal(.1);
-            hidden[k].lastDelta[i]=0;
-//          hidden[k].weights[i]=.1;
-        }
-    }
-    hidden[hiddenNum].value=1;
-    in[inNum].value=1;
-    LR=learningRate= .1;
-    epsilon= eps;
-    momentum=.01;
-//  cout << "INIT" << endl;
-}
-
-void Net::randomize()
-{
-    //if (verbose)
-    //cout << "RANDING" << endl;
-    int k,i;
-    for (k=0; k<=inNum; k++) {
-        for (i=0; i<hiddenNum; i++) {
-            in[k].weights[i]=randReal(.1);
-            in[k].lastDelta[i]=0;
-        }
-    }
-    for (k=0; k<=hiddenNum; k++) {
-        for (i=0; i<outNum; i++) {
-            hidden[k].weights[i]=randReal(.1);
-            hidden[k].lastDelta[i]=0;
-        }
-    }
-}
-
-void Net::destroy()
-{
-    int k;
-    for (k=0; k<=inNum; k++) {
-        delete in[k].weights;
-        delete in[k].lastDelta;
-    }
-    delete in;
-    for (k=0; k<hiddenNum; k++) {
-        delete hidden[k].weights;
-        delete hidden[k].lastDelta;
-    }
-    delete hidden;
-    delete out;
-    delete temp;
-}
-
-Net::~Net()
-{
-    destroy();
-}
-
-_Parameter Net::dOdW1(int cell, int w, int outN)
-{
-    // changed to make linear output
-    _Parameter dOdH= hidden[w].weights[outN];
-    _Parameter dHdW= (1-hidden[w].value)*hidden[w].value*in[cell].value;
-    return dOdH*dHdW;
-}
-
-void Net::adjust()
-{
-    learningRate=1*learningRate;
-}
-
-_Parameter Net::dOdW2(int cell, int)
-{
-    // changed to make linear ouput
-    return hidden[cell].value;
-}
-
-/*void Net::save(ofstream & fout)
-{
-    fout << endl;
-    fout << inNum << " " << hiddenNum << " " << outNum << endl;
-    int k, j;
-    for (k=0; k<=inNum; k++)
-    {
-        for (j=0; j<hiddenNum; j++)
-        {
-            fout << in[k].weights[j] << " ";
-        }
-    }
-    for (k=0; k<=hiddenNum; k++)
-    {
-        for (j=0; j<outNum; j++)
-        {
-            fout << hidden[k].weights[j] << " ";
-        }
-    }
-    fout << endl;
-}*/
-
-void Net::save(FILE* f)
-{
-    fprintf (f, "\n{{%d,%d,%d}}\n{{",inNum, hiddenNum, outNum);
-    int k, j;
-    for (k=0; k<=inNum; k++)
-        for (j=0; j<hiddenNum; j++)
-            if (k+j == 0) {
-                fprintf (f,"%g",in[k].weights[j]);
-            } else {
-                fprintf (f,",%g",in[k].weights[j]);
-            }
-
-    for (k=0; k<=hiddenNum; k++)
-        for (j=0; j<outNum; j++) {
-            fprintf (f,",%g",hidden[k].weights[j]);
-        }
-
-    fprintf (f,"\n}}");
-}
-
-void Net::load(FILE*)
-{
-    /*inNum       = dim[0];
-    hiddenNum = dim[0];
-    outNum    = (*dim)(2,0);
-
-    hidden=new Node[hiddenNum+1];
-    out= new _Parameter[outNum];
-    temp= new _Parameter[outNum];
-    int k, j, i;
-    for (k=0; k<=inNum; k++)
-    {
-        in[k].weights=new _Parameter[hiddenNum];
-        in[k].lastDelta=new _Parameter[hiddenNum];
-        for (i=0; i<hiddenNum; i++)
-        {
-            in[k].lastDelta[i]=0;
-        }
-    }
-    for (k=0; k<=hiddenNum; k++)
-    {
-        hidden[k].weights= new _Parameter[outNum];
-        hidden[k].lastDelta=new _Parameter[outNum];
-        for (i=0; i<outNum; i++)
-        {
-            hidden[k].lastDelta[i]=0;
-        }
-    }
-
-    hidden[hiddenNum].value=1;
-    in[inNum].value=1;
-    LR=learningRate= .25;
-    momentum=.25;
-
-    long cntr = 0;
-    for (k=0; k<=inNum; k++)
-    {
-        for (j=0; j<hiddenNum; j++)
-        {
-            in[k].weights[j] = (*coeff)(0,cntr++);
-        }
-    }
-    for (k=0; k<=hiddenNum; k++)
-    {
-        for (j=0; j<outNum; j++)
-        {
-            hidden[k].weights[j] = (*coeff)(0,cntr++);
-        }
-    }*/
-}
-
-/*void Net::load(ifstream & fin)
-{
-    destroy();
-    fin >> inNum >> hiddenNum >> outNum;
-    in=new Node[inNum+1];
-    hidden=new Node[hiddenNum+1];
-    out= new _Parameter[outNum];
-    temp= new _Parameter[outNum];
-    int k, j, i;
-    for (k=0; k<=inNum; k++)
-    {
-        in[k].weights=new _Parameter[hiddenNum];
-        in[k].lastDelta=new _Parameter[hiddenNum];
-        for (i=0; i<hiddenNum; i++)
-        {
-            in[k].lastDelta[i]=0;
-        }
-    }
-    for (k=0; k<=hiddenNum; k++)
-    {
-        hidden[k].weights= new _Parameter[outNum];
-        hidden[k].lastDelta=new _Parameter[outNum];
-        for (i=0; i<outNum; i++)
-        {
-            hidden[k].lastDelta[i]=0;
-        }
-    }
-    hidden[hiddenNum].value=1;
-    in[inNum].value=1;
-    LR=learningRate= .25;
-    momentum=.25;
-
-
-    for (k=0; k<=inNum; k++)
-    {
-        for (j=0; j<hiddenNum; j++)
-        {
-            fin >> in[k].weights[j];
-        }
-    }
-    for (k=0; k<=hiddenNum; k++)
-    {
-        for (j=0; j<outNum; j++)
-        {
-            fin >> hidden[k].weights[j];
-        }
-    }
-}*/
-
-void Net::learn(_Parameter * input, _Parameter * output)
-{
-    int k/*, j*/;
-
-    if (outNum == 1) {
-        eval1(input);
-    } else {
-        eval(input);
-    }
-
-
-    for (k=0; k<outNum; k++) {
-        temp[k]=2.*(out[k]-output[k]);
-    }
-
-    _Parameter *p1 = output,
-                *p2 = out,
-                 *p3 = out+outNum,
-                  *p4 = temp;
-
-    for (; p2!=p3; p1++,p2++,p4++) {
-        *p4 = 2.*(*p2-*p1);
-    }
-
-
-    if (outNum == 1)
-        for (k=0; k<=inNum; k++) {
-            _Parameter* t1   = in[k].weights,
-                        *   t2   = in[k].lastDelta,
-                            iv   = in[k].value,
-                            * t5   = t1,
-                              * t5s  = t5+hiddenNum,
-                                * t6   = t2;
-
-            Node  *hn= hidden;
-
-            for (; t5!=t5s; t5++,t6++,hn++) {
-                // changed
-                _Parameter  delta = hn->value;
-
-                delta   = (1.-delta)*delta*iv* * hn->weights
-                          *learningRate * *temp +momentum* *t6;
-                *t5 -=  delta;
-                *t6 =   delta;
-            }
-        }
-    else
-        for (k=0; k<=inNum; k++) {
-            _Parameter* t1  = in[k].weights,
-                        *   t2  = in[k].lastDelta,
-                            * t3  = temp,
-                              * t3s = temp+outNum,
-                                iv  = in[k].value;
-
-            long  outN = 0;
-
-            for (; t3!=t3s; t3++, outN++) {
-                _Parameter*  t5  = t1,
-                             *  t5s = t5+hiddenNum,
-                                *  t6  = t2;
-
-                Node  *  hn  = hidden;
-
-                for (; t5!=t5s; t5++,t6++,hn++) {
-                    // changed
-                    _Parameter  delta = hn->value;
-
-                    delta   = (1.-delta)*delta*iv*hn->weights[outN]
-                              *learningRate * *t3 +momentum* *t6;
-                    *t5 -=  delta;
-                    *t6 =   delta;
-                }
-            }
-        }
-
-
-    /*for (k=0; k<=inNum; k++)
-    {
-        for (j=0; j<outNum; j++)
-        {
-            for (int w=0; w<hiddenNum; w++)
-            {
-            // changed
-                _Parameter delta=learningRate*dOdW1(k,w,j)*temp[j]+momentum*in[k].lastDelta[w];
-                in[k].weights[w]-=delta;
-                in[k].lastDelta[w]=delta;
-            }
-        }
-    }*/
-
-    Node   *hn  = hidden,
-            *hns = hidden+hiddenNum+1;
-
-    if (outNum > 1) {
-        for (; hn!=hns; hn++) {
-            _Parameter *x1  = temp,
-                        *x1s = temp+outNum,
-                         *x2    = hn->weights,
-                          *x3  = hn->lastDelta,
-                           hcv  = hn->value;
-
-            for (; x1!=x1s; x1++,x2++,x3++) {
-                _Parameter delta    =   learningRate* hcv * *x1 +momentum* *x3;
-                *x2 -= delta;
-                *x3  = delta;
-            }
-        }
-    } else {
-        for (; hn!=hns; hn++) {
-            _Parameter delta    = learningRate* hn->value * *temp +momentum* *hn->lastDelta;
-            *hn->weights   -= delta;
-            *hn->lastDelta  = delta;
-        }
-    }
-
-
-
-    /*for (k=0; k<=hiddenNum; k++)
-    {
-        for (j=0; j<outNum; j++)
-        {
-            _Parameter delta=learningRate*dOdW2(k,j)*temp[j]+momentum*hidden[k].lastDelta[j];
-            hidden[k].weights[j]-=delta;
-            hidden[k].lastDelta[j]=delta;
-        }
-    }*/
-}
-
-void Net::studyAll(_Parameter**input, _Parameter**output, int samp)
-{
-    _Parameter  max = 1.; // to make sure we enter for loop
-
-    int     rep;
-
-    for (rep=0 ; max>epsilon && rep<timeout; rep++) {
-        max=-1;
-        for (int count=0; count<density; count++) {
-            for (int k=0; k<samp; k++) {
-                learn(input[k],output[k]);
-            }
-        }
-
-        for (int k=0; k<samp; k++) {
-            _Parameter err=error();
-            if (err>max) {
-                max=err;
-            }
-            learn(input[k],output[k]);
-        }
-
-        learningRate=sigmaF(2*(max-.45))*coef;
-        momentum=learningRate*mom;
-    }
-
-    /*if (verbose)
-    {
-        if (rep>=timeout)
-            cout << "DIVERGE" << endl;
-        cout << "Cycles taken: " << rep << endl << "Largest Error: " << max << endl;
-    }*/
-
-    cycles=rep;
-//  cout << endl;
-}
-
-_Parameter Net::studyAll(_Parameter*input, _Parameter*output, int samp)
-{
-    _Parameter  max = 1.; // to make sure we enter for loop
-
-    int     rep;
-
-    for (rep=0 ; max>epsilon && rep<timeout; rep++) {
-        max=-1;
-        for (int count=0; count<density; count++) {
-            for (int k=0; k<samp; k++) {
-                learn(input + k*inNum ,output + k*outNum);
-            }
-        }
-        for (int k=0; k<samp; k++) {
-            _Parameter err=error();
-            if (err>max) {
-                max = err;
-            }
-            learn(input + k*inNum ,output + k*outNum);
-        }
-
-        learningRate=sigmaF(2*(max-.45))*coef;
-        momentum=learningRate*mom;
-    }
-
-    /*if (verbose)
-    {
-        if (rep>=timeout)
-            cout << "DIVERGE" << endl;
-        cout << "Cycles taken: " << rep << endl << "Largest Error: " << max << endl;
-    }*/
-
-    cycles=rep;
-    return max;
-//  cout << endl;
-}
-
-_Parameter Net::sum(_Parameter * x, int p)
-{
-    _Parameter total=0;
-    for (int k=0; k<p; k++) {
-        total+=x[k];
-    }
-    //cout << total << endl;
-    return total;
-}
-
-_Parameter Net::error()
-{
-    _Parameter tempTotal=0;
-    for (int y=0; y<outNum; y++) {
-        tempTotal+=fabs(temp[y] * .5);
-    }
-    // this is the Mean Squared Error
-    return tempTotal;
-}
-
-bool Net::accurate(_Parameter **, _Parameter**output, int samp)
-{
-    for (int k=0; k<samp; k++) {
-        if (!within(out,output[k])) {
-            return false;
-        }
-    }
-    return true;
-}
-
-bool Net::within(const _Parameter * pred, const _Parameter * act) const
-{
-    for (int k=0; k<outNum; k++) {
-        if (fabs(pred[k]-act[k])>epsilon) {
-            return false;
-        }
-    }
-    return true;
-}
-
-const _Parameter * Net::eval(_Parameter * input)
-{
-    int     k,
-            i;
-
-    /*for (k=0; k<inNum; k++)
-    {
-        in[k].value=input[k];
-    }*/
-
-    _Parameter* in1 = input, *in2 = input+inNum;
-    Node*   np  = in;
-
-    while (in1<in2) {
-        np->value = *in1;
-        in1++;
-        np++;
-    }
-
-    for (k=0; k<hiddenNum; k++) {
-        _Parameter total = 0.;
-        for (i=0; i<=inNum; i++) {
-            total+=in[i].value*in[i].weights[k];
-        }
-        hidden[k].value= sigmaF(total);
-    }
-
-    for (k=0; k<outNum; k++) {
-        _Parameter total = 0.;
-        for (i=0; i<=hiddenNum; i++) {
-            total+=hidden[i].value*hidden[i].weights[k];
-        }
-        out[k]= total;
-    }
-    return out;
-}
-
-const _Parameter * Net::eval1(_Parameter * input)
-{
-    int     k,
-            i;
-
-    _Parameter* in1 = input,
-                *in2 = input+inNum,
-                 temp [100]; // hack for serial access
-
-    Node*   np  = in;
-
-    while (in1<in2) {
-        np->value = *in1;
-        in1++;
-        np++;
-    }
-
-    np = in;
-    Node * nps = in+inNum+1;
-
-    in2 = temp+hiddenNum;
-
-    for (in1 = temp; in1 < in2; in1++) {
-        *in1 = 0.0;
-    }
-
-    for (; np<nps; np++) {
-        _Parameter iv  = np->value,
-                   *w1  = np->weights;
-
-        for (in1 = temp; in1<in2; in1++, w1++) {
-            *in1 += iv * *w1;
-        }
-    }
-
-    for (k=0; k<hiddenNum; k++) {
-        hidden[k].value = sigmaF (temp[k]);
-    }
-
-    /*for (k=0; k<hiddenNum; k++)
-    {
-        _Parameter total = 0.;
-        for (i=0; i<=inNum; i++)
-        {
-            total+=in[i].value*in[i].weights[k];
-        }
-        hidden[k].value= sigmaF(total);
-    }*/
-
-    {
-        _Parameter total = 0.;
-        for (i=0; i<=hiddenNum; i++) {
-            total+=hidden[i].value**hidden[i].weights;
-        }
-        out[0]= total;
-    }
-
-    return out;
-}
-
diff --git a/src/new/bgm.cpp b/src/new/bgm.cpp
index 14c62d0..08a3c7b 100644
--- a/src/new/bgm.cpp
+++ b/src/new/bgm.cpp
@@ -1,43 +1,43 @@
 /*
-
+ 
  HyPhy - Hypothesis Testing Using Phylogenies.
-
- Copyright (C) 1997-2006
- Primary Development:
- Sergei L Kosakovsky Pond (sergeilkp at mac.com)
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
  Significant contributions from:
  Spencer V Muse (muse at stat.ncsu.edu)
- Simon DW Frost (sdfrost at ucsd.edu)
- Art FY Poon    (apoon at biomail.ucsd.edu)
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
- _AVLList   structure inspired by the excellent documentation of
- GNU libavl 2.0.1 by Ben Pfaff (http://www.msu.edu/~pfaffben/avl/index.html)
-
-                                */
-
-/*
- *  Bgm.cpp
- *  HYPHY_XCode
- *
- *  Created by Art Poon on 2/5/07.
- *  Based on source code written in C by Fraser Iain Lewis.
- *
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
  */
 
+
 #if not defined __AFYP_REWRITE_BGM__
 
 #ifdef __HYPHYQT__
diff --git a/src/new/bgm2.cpp b/src/new/bgm2.cpp
index 67cf048..6ccf532 100644
--- a/src/new/bgm2.cpp
+++ b/src/new/bgm2.cpp
@@ -1,10 +1,40 @@
 /*
- *  bgm2.cpp
- *  HyPhyXCode
- *
- *  Created by Art Poon on 7/7/08.
- *  Copyright 2008 __MyCompanyName__. All rights reserved.
- *
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
  */
 
 #if not defined __AFYP_REWRITE_BGM__
diff --git a/src/new/include/HYNetInterface.h b/src/new/include/HYNetInterface.h
deleted file mode 100644
index 090da9c..0000000
--- a/src/new/include/HYNetInterface.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-
-    This is a file which declares NN interfacing with HBL model structures.
-
-    September 2003, Sergei L Kosakovsky Pond
-
-*/
-
-#ifndef __HYNNINTERFACE__
-#define __HYNNINTERFACE__
-
-#include "hy_strings.h"
-#include "batchlan.h"
-#include "matrix.h"
-#include "SerangNet.h"
-
-/*---------------------------------------------------------*/
-
-//class  _MatrixNN: public _SimpleList
-//{
-
-//  Net *
-//}
-
-/*---------------------------------------------------------*/
-
-
-void         TrainModelNN   (_String*, _String*);
-void         LoadModelNN    (_String*, _String*);
-_Matrix*     ComputeModel   (long);
-
-/*---------------------------------------------------------*/
-
-void         NNMatrixSampler(long, _Matrix&, _SimpleList&, _SimpleList&, _Matrix*, _List&, _List&);
-
-extern   _String            ModelTrainNNFlag,
-         ModelLoadNNFlag;
-
-
-#endif
\ No newline at end of file
diff --git a/src/new/include/SerangNet.h b/src/new/include/SerangNet.h
deleted file mode 100644
index 1fdbb9c..0000000
--- a/src/new/include/SerangNet.h
+++ /dev/null
@@ -1,95 +0,0 @@
-// Oliver Serang
-//
-// Net class implements a one hidden layer Neural Net with a
-// variable number of inputs, outputs, and hidden Nodes.
-//
-//
-// copyright Oliver Serang 2003
-
-// Modified to
-
-#ifndef _NET_H
-#define _NET_H
-
-#include <math.h>
-#include <stdlib.h>
-//#include <fstream.h>
-
-#include "baseobj.h"
-
-
-
-struct Node {
-    _Parameter value;
-    _Parameter*weights;
-    _Parameter*lastDelta;
-};
-
-class Net
-{
-public:
-    Net () {}
-    Net (int innum, int hiddennum, int outnum, _Parameter eps, _Parameter c, _Parameter m, int d, int t, bool v);
-    Net (int innum, int hiddennum, int outnum, _Parameter eps);
-
-
-    void learn(_Parameter*input, _Parameter*output);
-    const _Parameter* eval  (_Parameter*input);
-    const _Parameter* eval1 (_Parameter*input);
-    bool within(const _Parameter *, const _Parameter *) const;
-    bool accurate(_Parameter**input, _Parameter**output, int samp);
-    _Parameter bruteDelta;
-    void   studyAll(_Parameter**input,_Parameter**output,int samp);
-    _Parameter studyAll(_Parameter*input,_Parameter*output,int samp);
-    void destroy();
-    void randomize();
-    void init(int, int, int, _Parameter);
-    ~Net();
-    //void save(ofstream & fout);
-    //void load(ifstream & in);
-    void save(FILE*);
-    void load(FILE*);
-
-
-    int cycles,
-        timeout,
-        density;
-
-    bool verbose;
-
-    _Parameter coef,
-               mom;
-private:
-    _Parameter error();
-    Node*in;    // input nodes of the network
-    Node*hidden;    // hidden nodes of the network
-    _Parameter*out; // output of the network
-    int inNum, hiddenNum, outNum;
-    _Parameter*temp;
-    _Parameter dOdW1(int , int, int);
-    _Parameter dOdW2(int , int);
-    _Parameter sum(_Parameter*x,int p);
-    _Parameter LR;
-    _Parameter learningRate;
-    _Parameter momentum;
-    _Parameter epsilon;
-    void adjust();
-
-    inline _Parameter sigmaF(const _Parameter x) {
-        return 1./(1.+exp(-x));
-    }
-
-    inline _Parameter randReal(_Parameter magnitude) {
-        // return a real # in [-magnitude, magnitude]
-        //_Parameter x=rand()%1000;
-        //x=x-500;
-        // x is now an integer in [-500,500]
-        //x/=500;
-        // x is now a real [-1,1]
-        //x*=magnitude;
-        //return x;
-        return (genrand_int32 () - 2147483648.0) * magnitude / 2147483648.0;
-    }
-};
-
-#endif
diff --git a/src/new/include/bgm.h b/src/new/include/bgm.h
index 088877b..2e0f372 100644
--- a/src/new/include/bgm.h
+++ b/src/new/include/bgm.h
@@ -1,11 +1,42 @@
 /*
- *  Bgm.h
- *  HYPHY_XCode
- *
- *  Created by Art Poon on 2/5/07.
- *  Copyright 2007 __MyCompanyName__. All rights reserved.
- *
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
  */
+
 #if not defined __AFYP_REWRITE_BGM__
 
 #include "simplelist.h"
diff --git a/src/new/include/scfg.h b/src/new/include/scfg.h
index a0aaab3..d0f82c6 100644
--- a/src/new/include/scfg.h
+++ b/src/new/include/scfg.h
@@ -1,12 +1,40 @@
 /*
- *  scfg.h
- *  Class definition for the stochastic context free grammar (SCFG)
- *  and supporting classes
- *
- *  Created  by Art Poon on 11/18/05.
- *  Modified to use HyPhy class hooks by Sergei L Kosakovsky Pond in June 2006
- *
- *
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
  */
 
 #ifndef  _HY_INCLUDE_SCFG_
diff --git a/src/new/scfg.cpp b/src/new/scfg.cpp
index b63f435..75eebec 100644
--- a/src/new/scfg.cpp
+++ b/src/new/scfg.cpp
@@ -1,10 +1,40 @@
 /*
- *  Stochastic context free grammar classes
- *  Sources
- *
- *  Created by Art Poon on 11/18/05.
- *  Modified to work with the HyPhy API layer by Sergei L Kosakovsky Pond
- *  June 2006
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
  */
 
 #include    "scfg.h"
diff --git a/src/ocl/opencl_kernels.cl b/src/ocl/opencl_kernels.cl
index 960de85..27818fd 100644
--- a/src/ocl/opencl_kernels.cl
+++ b/src/ocl/opencl_kernels.cl
@@ -1,3 +1,43 @@
+/*
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+*/
+
+
  #define MIN(a,b) ((a)>(b)?(b):(a))
 __kernel void LeafKernel(  __global float* node_cache,                 // argument 0
                            __global const float* model,                // argument 1
diff --git a/src/utils/hyphyunixutils.cpp b/src/utils/hyphyunixutils.cpp
index aeaf74f..ad9eeab 100644
--- a/src/utils/hyphyunixutils.cpp
+++ b/src/utils/hyphyunixutils.cpp
@@ -1,3 +1,42 @@
+/*
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+ */
+
 #include <stdio.h>
 #include "likefunc.h"
 
diff --git a/tests/gtests/ut_avllists.cpp b/tests/gtests/ut_avllists.cpp
index ac49b30..4fb75cc 100755
--- a/tests/gtests/ut_avllists.cpp
+++ b/tests/gtests/ut_avllists.cpp
@@ -1,10 +1,40 @@
 /*
- *  ut_lists.cpp
- *  HyPhyXCode
- *
- *  Created by Steven Weaver on 6/17/11.
- *  Copyright 2011 __MyCompanyName__. All rights reserved.
- *
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
  */
 
 //#include <tr1/tuple>
diff --git a/tests/gtests/ut_list.cpp b/tests/gtests/ut_list.cpp
index 7c7895c..a9f4295 100755
--- a/tests/gtests/ut_list.cpp
+++ b/tests/gtests/ut_list.cpp
@@ -1,9 +1,40 @@
 /*
- *  ut_lists.cpp
- *  HyPhyXCode
- *
- *  Created by Steven Weaver on 6/17/11.
- *
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
  */
 
 //#include <tr1/tuple>
diff --git a/tests/gtests/ut_simplelists.cpp b/tests/gtests/ut_simplelists.cpp
index 28a431f..597065b 100755
--- a/tests/gtests/ut_simplelists.cpp
+++ b/tests/gtests/ut_simplelists.cpp
@@ -1,10 +1,40 @@
 /*
- *  ut_lists.cpp
- *  HyPhyXCode
- *
- *  Created by Steven Weaver on 6/17/11.
- *  Copyright 2011 __MyCompanyName__. All rights reserved.
- *
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
  */
 
 //#include <tr1/tuple>
diff --git a/tests/gtests/ut_strings.cpp b/tests/gtests/ut_strings.cpp
index e364562..5920892 100644
--- a/tests/gtests/ut_strings.cpp
+++ b/tests/gtests/ut_strings.cpp
@@ -1,10 +1,40 @@
 /*
- *  ut_strings.cpp
- *  HyPhyXCode
- *
- *  Created by Steven Weaver on 6/17/11.
- *  Copyright 2011 __MyCompanyName__. All rights reserved.
- *
+ 
+ HyPhy - Hypothesis Testing Using Phylogenies.
+ 
+ Copyright (C) 1997-now
+ Core Developers:
+ Sergei L Kosakovsky Pond (spond at ucsd.edu)
+ Art FY Poon    (apoon at cfenet.ubc.ca)
+ Steven Weaver (sweaver at ucsd.edu)
+ 
+ Module Developers:
+ Lance Hepler (nlhepler at gmail.com)
+ Martin Smith (martin.audacis at gmail.com)
+ 
+ Significant contributions from:
+ Spencer V Muse (muse at stat.ncsu.edu)
+ Simon DW Frost (sdf22 at cam.ac.uk)
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
  */
 
 //#include <tr1/tuple>
diff --git a/tests/hbltests/SimpleOptimizations/SmallCodon.bf b/tests/hbltests/SimpleOptimizations/SmallCodon.bf
index 1b7c450..43e9693 100644
--- a/tests/hbltests/SimpleOptimizations/SmallCodon.bf
+++ b/tests/hbltests/SimpleOptimizations/SmallCodon.bf
@@ -662,6 +662,8 @@ USE_ADAPTIVE_VARIABLE_STEP = 1;
 
 Optimize 			(res,lf);
 
+fprintf (stdout, "\n\n", res[1][0], "\n\n");
+
 /* test epilogue */
 	timeMatrix = endTestTimer 				  (_testDescription);
 	if (logTestResult    (Abs (res[1][0] - _expectedLL) < 2*OPTIMIZATION_PRECISION))
diff --git a/tests/hbltests/UnitTests/HBLCommands/AllCommands.bf b/tests/hbltests/UnitTests/HBLCommands/AllCommands.bf
index ab58ef6..cb78fa2 100644
--- a/tests/hbltests/UnitTests/HBLCommands/AllCommands.bf
+++ b/tests/hbltests/UnitTests/HBLCommands/AllCommands.bf
@@ -542,7 +542,6 @@ function hbl_functions()
 //MolecularClock
 //MPIReceive
 //MPISend
-//NeuralNet
 //OpenDataPanel
 //OpenWindow
 //Optimize

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/hyphy.git



More information about the debian-med-commit mailing list