[med-svn] [libbpp-phyl] 02/04: New upstream version 2.3.1

Andreas Tille tille at debian.org
Tue Jun 13 15:16:02 UTC 2017


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

tille pushed a commit to branch master
in repository libbpp-phyl.

commit f5b5b84789b06259cfc15f9c3773e1af13096150
Author: Andreas Tille <tille at debian.org>
Date:   Tue Jun 13 16:03:05 2017 +0200

    New upstream version 2.3.1
---
 AUTHORS.txt                                        |    3 +
 CMakeLists.txt                                     |  176 +-
 CTestConfig.cmake                                  |   13 +
 ChangeLog                                          |   24 +
 Doxyfile                                           | 2662 ++++++++++++--------
 INSTALL.txt                                        |   19 +-
 bpp-phyl.spec                                      |  133 +-
 debian/changelog                                   |   85 -
 debian/compat                                      |    1 -
 debian/control                                     |   25 -
 debian/copyright                                   |   66 -
 debian/docs                                        |    0
 debian/libbpp-phyl-dev.install                     |    3 -
 debian/libbpp-phyl9.install                        |    1 -
 debian/postinst                                    |   57 -
 debian/postrm                                      |   59 -
 debian/prerm                                       |   41 -
 debian/rules                                       |  122 -
 debian/source/format                               |    1 -
 genIncludes.sh                                     |   35 -
 package.cmake.in                                   |   27 +
 src/Bpp/Phyl/App/PhylogeneticsApplicationTools.cpp |  413 +--
 src/Bpp/Phyl/App/PhylogeneticsApplicationTools.h   | 1197 ++++-----
 src/Bpp/Phyl/BipartitionList.h                     |    7 +-
 .../Distance/AbstractAgglomerativeDistanceMethod.h |    8 +-
 src/Bpp/Phyl/Distance/DistanceEstimation.cpp       |    2 +-
 src/Bpp/Phyl/Distance/DistanceEstimation.h         |   40 +-
 src/Bpp/Phyl/Graphics/AbstractTreeDrawing.h        |   11 +-
 src/Bpp/Phyl/Graphics/CladogramPlot.cpp            |    6 +-
 src/Bpp/Phyl/Graphics/PhylogramPlot.cpp            |    6 +-
 src/Bpp/Phyl/Graphics/TreeDrawing.h                |    4 +-
 src/Bpp/Phyl/Graphics/TreeDrawingListener.h        |    8 +-
 src/Bpp/Phyl/Io/BppOFrequenciesSetFormat.cpp       |  354 ++-
 src/Bpp/Phyl/Io/BppOFrequenciesSetFormat.h         |    1 +
 .../BppOMultiTreeReaderFormat.cpp}                 |   68 +-
 .../BppOMultiTreeReaderFormat.h}                   |   66 +-
 .../BppOMultiTreeWriterFormat.cpp}                 |   68 +-
 .../BppOMultiTreeWriterFormat.h}                   |   66 +-
 src/Bpp/Phyl/Io/BppORateDistributionFormat.cpp     |    6 +-
 src/Bpp/Phyl/Io/BppOSubstitutionModelFormat.cpp    |  845 +++++--
 src/Bpp/Phyl/Io/BppOSubstitutionModelFormat.h      |  337 +--
 src/Bpp/Phyl/Io/BppOTransitionModelFormat.cpp      |  114 +
 src/Bpp/Phyl/Io/BppOTransitionModelFormat.h        |   94 +
 .../BppOTreeReaderFormat.cpp}                      |   68 +-
 .../BppOTreeReaderFormat.h}                        |   66 +-
 .../BppOTreeWriterFormat.cpp}                      |   68 +-
 .../BppOTreeWriterFormat.h}                        |   66 +-
 src/Bpp/Phyl/Io/IoFrequenciesSet.h                 |    3 +
 src/Bpp/Phyl/Io/IoSubstitutionModel.h              |    5 +-
 src/Bpp/Phyl/Io/IoTree.h                           |  172 +-
 src/Bpp/Phyl/Io/Newick.cpp                         |   11 +-
 src/Bpp/Phyl/Io/Newick.h                           |  161 +-
 src/Bpp/Phyl/Io/NexusIoTree.cpp                    |    9 +-
 src/Bpp/Phyl/Io/NexusIoTree.h                      |  142 +-
 src/Bpp/Phyl/Io/Nhx.cpp                            |   11 +-
 src/Bpp/Phyl/Io/Nhx.h                              |  140 +-
 .../AbstractHomogeneousTreeLikelihood.cpp          |   25 +-
 .../Likelihood/AbstractHomogeneousTreeLikelihood.h |  466 ++--
 .../AbstractNonHomogeneousTreeLikelihood.cpp       |   51 +-
 .../AbstractNonHomogeneousTreeLikelihood.h         |    8 +-
 src/Bpp/Phyl/Likelihood/AbstractTreeLikelihood.h   |  276 +-
 src/Bpp/Phyl/Likelihood/ClockTreeLikelihood.h      |    4 -
 .../Phyl/Likelihood/DRASDRTreeLikelihoodData.cpp   |    7 +-
 src/Bpp/Phyl/Likelihood/DRASDRTreeLikelihoodData.h |   18 +-
 .../Phyl/Likelihood/DRASRTreeLikelihoodData.cpp    |   15 +-
 src/Bpp/Phyl/Likelihood/DRASRTreeLikelihoodData.h  |   13 +-
 .../DRHomogeneousMixedTreeLikelihood.cpp           |    6 +-
 .../Likelihood/DRHomogeneousMixedTreeLikelihood.h  |    4 +-
 .../Likelihood/DRHomogeneousTreeLikelihood.cpp     |    4 +-
 .../Phyl/Likelihood/DRHomogeneousTreeLikelihood.h  |    4 +-
 src/Bpp/Phyl/Likelihood/DRTreeLikelihood.h         |    2 -
 src/Bpp/Phyl/Likelihood/DRTreeLikelihoodTools.cpp  |   12 +-
 .../Phyl/Likelihood/HomogeneousTreeLikelihood.h    |   13 +-
 .../MarginalAncestralStateReconstruction.cpp       |   12 +-
 .../MarginalAncestralStateReconstruction.h         |   15 +-
 .../Likelihood/NNIHomogeneousTreeLikelihood.cpp    |    6 +-
 .../Phyl/Likelihood/NNIHomogeneousTreeLikelihood.h |   15 +-
 .../Phyl/Likelihood/NonHomogeneousTreeLikelihood.h |   11 +-
 .../Likelihood/RHomogeneousClockTreeLikelihood.cpp |   12 +-
 .../Likelihood/RHomogeneousClockTreeLikelihood.h   |    6 +-
 .../Likelihood/RHomogeneousMixedTreeLikelihood.cpp |    6 +-
 .../Likelihood/RHomogeneousMixedTreeLikelihood.h   |   14 +-
 .../Phyl/Likelihood/RHomogeneousTreeLikelihood.cpp |    7 +-
 .../Phyl/Likelihood/RHomogeneousTreeLikelihood.h   |    4 +-
 .../RNonHomogeneousMixedTreeLikelihood.cpp         |    8 +-
 .../Phyl/Likelihood/SitePartitionTreeLikelihood.h  |   11 +-
 src/Bpp/Phyl/Likelihood/TreeLikelihood.h           |  166 +-
 src/Bpp/Phyl/Likelihood/TreeLikelihoodData.h       |    9 +-
 .../Phyl/Mapping/CategorySubstitutionRegister.h    |  405 +++
 src/Bpp/Phyl/Mapping/DecompositionReward.cpp       |    6 +-
 .../Mapping/DecompositionSubstitutionCount.cpp     |  118 +-
 .../Phyl/Mapping/DecompositionSubstitutionCount.h  |   20 +-
 src/Bpp/Phyl/Mapping/Mapping.h                     |    6 +-
 src/Bpp/Phyl/Mapping/RewardMapping.h               |    4 -
 src/Bpp/Phyl/Mapping/RewardMappingTools.cpp        |   14 +-
 src/Bpp/Phyl/Mapping/SubstitutionCount.h           |    3 +-
 src/Bpp/Phyl/Mapping/SubstitutionMapping.h         |    4 -
 src/Bpp/Phyl/Mapping/SubstitutionMappingTools.cpp  |  199 +-
 src/Bpp/Phyl/Mapping/SubstitutionMappingTools.h    |   45 +-
 src/Bpp/Phyl/Mapping/SubstitutionRegister.h        | 1599 ++++++------
 .../Mapping/UniformizationSubstitutionCount.cpp    |   10 +-
 .../Phyl/Mapping/UniformizationSubstitutionCount.h |   20 +-
 .../Model/AbstractBiblioMixedSubstitutionModel.h   |   14 +-
 .../Phyl/Model/AbstractBiblioSubstitutionModel.cpp |   41 +-
 .../Phyl/Model/AbstractBiblioSubstitutionModel.h   |  279 +-
 ...stractFromSubstitutionModelTransitionModel.cpp} |   71 +-
 .../AbstractFromSubstitutionModelTransitionModel.h |  201 ++
 .../AbstractKroneckerWordSubstitutionModel.cpp     |  253 ++
 .../Model/AbstractKroneckerWordSubstitutionModel.h |  218 ++
 src/Bpp/Phyl/Model/AbstractSubstitutionModel.cpp   |   52 +-
 src/Bpp/Phyl/Model/AbstractSubstitutionModel.h     |   78 +-
 .../Phyl/Model/AbstractWordSubstitutionModel.cpp   |  284 ++-
 src/Bpp/Phyl/Model/AbstractWordSubstitutionModel.h |   95 +-
 src/Bpp/Phyl/Model/BinarySubstitutionModel.cpp     |   12 +-
 ...l.cpp => AbstractCodonCpGSubstitutionModel.cpp} |   43 +-
 ...Model.h => AbstractCodonCpGSubstitutionModel.h} |   70 +-
 .../Codon/AbstractCodonDistanceSubstitutionModel.h |    2 +-
 .../AbstractCodonFrequenciesSubstitutionModel.h    |    2 +-
 ...bstractCodonPhaseFrequenciesSubstitutionModel.h |    2 +-
 .../Model/Codon/AbstractCodonSubstitutionModel.cpp |    2 +-
 .../Model/Codon/AbstractCodonSubstitutionModel.h   |  233 +-
 ...=> AbstractKroneckerCodonSubstitutionModel.cpp} |  131 +-
 .../AbstractKroneckerCodonSubstitutionModel.h      |  201 ++
 .../Codon/CodonDistanceCpGSubstitutionModel.cpp    |   93 +
 .../Codon/CodonDistanceCpGSubstitutionModel.h      |  133 +
 .../CodonDistanceFrequenciesSubstitutionModel.h    |    8 +-
 .../Codon/CodonRateFrequenciesSubstitutionModel.h  |    7 +-
 .../Model/Codon/CodonRateSubstitutionModel.cpp     |    9 -
 .../Phyl/Model/Codon/CodonRateSubstitutionModel.h  |    3 -
 src/Bpp/Phyl/Model/Codon/CodonSubstitutionModel.h  |   20 +-
 src/Bpp/Phyl/Model/Codon/GY94.h                    |    2 +-
 .../{CodonRateSubstitutionModel.cpp => KCM.cpp}    |   76 +-
 src/Bpp/Phyl/Model/Codon/KCM.h                     |  119 +
 ...erCodonDistanceFrequenciesSubstitutionModel.cpp |  137 +
 ...kerCodonDistanceFrequenciesSubstitutionModel.h} |  120 +-
 .../KroneckerCodonDistanceSubstitutionModel.cpp    |  121 +
 .../KroneckerCodonDistanceSubstitutionModel.h      |  190 ++
 src/Bpp/Phyl/Model/Codon/MG94.h                    |   17 +-
 ...eFrequenciesSubstitutionModel.cpp => SENCA.cpp} |   76 +-
 ...PhaseFrequenciesSubstitutionModel.h => SENCA.h} |   55 +-
 .../Phyl/Model/Codon/TripletSubstitutionModel.h    |    7 +-
 src/Bpp/Phyl/Model/Codon/YN98.h                    |    5 +-
 .../Phyl/Model/Codon/{YNGKP_M1.cpp => YNGP_M1.cpp} |   26 +-
 src/Bpp/Phyl/Model/Codon/{YNGKP_M1.h => YNGP_M1.h} |   24 +-
 .../Model/Codon/{YNGKP_M8.cpp => YNGP_M10.cpp}     |   73 +-
 .../Phyl/Model/Codon/{YNGKP_M8.h => YNGP_M10.h}    |   54 +-
 .../Phyl/Model/Codon/{YNGKP_M2.cpp => YNGP_M2.cpp} |   28 +-
 src/Bpp/Phyl/Model/Codon/{YNGKP_M2.h => YNGP_M2.h} |   24 +-
 .../Phyl/Model/Codon/{YNGKP_M3.cpp => YNGP_M3.cpp} |   28 +-
 src/Bpp/Phyl/Model/Codon/{YNGKP_M3.h => YNGP_M3.h} |   24 +-
 .../Phyl/Model/Codon/{YNGKP_M7.cpp => YNGP_M7.cpp} |   27 +-
 src/Bpp/Phyl/Model/Codon/{YNGKP_M7.h => YNGP_M7.h} |   24 +-
 .../Phyl/Model/Codon/{YNGKP_M8.cpp => YNGP_M8.cpp} |   30 +-
 src/Bpp/Phyl/Model/Codon/{YNGKP_M8.h => YNGP_M8.h} |   30 +-
 .../Phyl/Model/Codon/{YNGKP_M8.cpp => YNGP_M9.cpp} |   72 +-
 src/Bpp/Phyl/Model/Codon/{YNGKP_M8.h => YNGP_M9.h} |   52 +-
 .../Model/FrequenciesSet/CodonFrequenciesSet.cpp   |   84 +-
 .../Model/FrequenciesSet/CodonFrequenciesSet.h     |   93 +-
 .../Phyl/Model/FrequenciesSet/FrequenciesSet.cpp   |   63 +-
 src/Bpp/Phyl/Model/FrequenciesSet/FrequenciesSet.h |  564 +++--
 .../Model/FrequenciesSet/MvaFrequenciesSet.cpp     |    1 +
 .../Phyl/Model/FrequenciesSet/MvaFrequenciesSet.h  |    8 +-
 .../FrequenciesSet/NucleotideFrequenciesSet.cpp    |    2 +
 .../FrequenciesSet/NucleotideFrequenciesSet.h      |   33 +-
 .../Model/FrequenciesSet/ProteinFrequenciesSet.h   |   21 +-
 .../Model/FrequenciesSet/WordFrequenciesSet.cpp    |    2 +
 .../Phyl/Model/FrequenciesSet/WordFrequenciesSet.h |   22 +-
 .../Phyl/Model/FromMixtureSubstitutionModel.cpp    |   93 +
 ...utionModel.h => FromMixtureSubstitutionModel.h} |  130 +-
 .../Phyl/Model/KroneckerWordSubstitutionModel.cpp  |  125 +
 .../Phyl/Model/KroneckerWordSubstitutionModel.h    |  148 ++
 .../Model/MarkovModulatedSubstitutionModel.cpp     |    9 +-
 .../Phyl/Model/MarkovModulatedSubstitutionModel.h  |   30 +-
 src/Bpp/Phyl/Model/MixedSubstitutionModel.h        |    9 +
 src/Bpp/Phyl/Model/MixedSubstitutionModelSet.cpp   |   14 +-
 src/Bpp/Phyl/Model/MixedSubstitutionModelSet.h     |    7 +-
 src/Bpp/Phyl/Model/MixtureOfASubstitutionModel.cpp |   13 +-
 src/Bpp/Phyl/Model/MixtureOfASubstitutionModel.h   |    9 +
 src/Bpp/Phyl/Model/MixtureOfSubstitutionModels.cpp |   23 +-
 src/Bpp/Phyl/Model/MixtureOfSubstitutionModels.h   |    9 +
 src/Bpp/Phyl/Model/Nucleotide/F84.cpp              |    7 +-
 src/Bpp/Phyl/Model/Nucleotide/F84.h                |   15 +-
 src/Bpp/Phyl/Model/Nucleotide/GTR.cpp              |    6 +-
 src/Bpp/Phyl/Model/Nucleotide/GTR.h                |   10 +-
 src/Bpp/Phyl/Model/Nucleotide/HKY85.cpp            |    7 +-
 src/Bpp/Phyl/Model/Nucleotide/HKY85.h              |   52 +-
 src/Bpp/Phyl/Model/Nucleotide/JCnuc.cpp            |    2 +-
 src/Bpp/Phyl/Model/Nucleotide/JCnuc.h              |   10 +-
 src/Bpp/Phyl/Model/Nucleotide/K80.cpp              |    6 +-
 src/Bpp/Phyl/Model/Nucleotide/K80.h                |   10 +-
 src/Bpp/Phyl/Model/Nucleotide/L95.cpp              |    5 +-
 src/Bpp/Phyl/Model/Nucleotide/L95.h                |   10 +-
 .../Model/Nucleotide/NucleotideSubstitutionModel.h |   83 +-
 src/Bpp/Phyl/Model/Nucleotide/RN95.cpp             |    8 +-
 src/Bpp/Phyl/Model/Nucleotide/RN95.h               |   10 +-
 src/Bpp/Phyl/Model/Nucleotide/RN95s.cpp            |    8 +-
 src/Bpp/Phyl/Model/Nucleotide/RN95s.h              |   10 +-
 src/Bpp/Phyl/Model/Nucleotide/SSR.cpp              |    2 +-
 src/Bpp/Phyl/Model/Nucleotide/SSR.h                |   18 +-
 src/Bpp/Phyl/Model/Nucleotide/T92.cpp              |    7 +-
 src/Bpp/Phyl/Model/Nucleotide/T92.h                |   10 +-
 src/Bpp/Phyl/Model/Nucleotide/TN93.cpp             |  599 ++---
 src/Bpp/Phyl/Model/Nucleotide/TN93.h               |   52 +-
 src/Bpp/Phyl/Model/Nucleotide/YpR.cpp              |   19 +-
 src/Bpp/Phyl/Model/Nucleotide/YpR.h                |    4 +-
 src/Bpp/Phyl/Model/Nucleotide/gBGC.cpp             |  179 +-
 src/Bpp/Phyl/Model/Nucleotide/gBGC.h               |  144 +-
 src/Bpp/Phyl/Model/OneChangeTransitionModel.cpp    |  303 +++
 .../gBGC.h => OneChangeTransitionModel.h}          |  114 +-
 src/Bpp/Phyl/Model/Protein/Coala.cpp               |    3 +-
 src/Bpp/Phyl/Model/Protein/Coala.h                 |   14 +-
 src/Bpp/Phyl/Model/Protein/CoalaCore.cpp           |    3 +-
 src/Bpp/Phyl/Model/Protein/CoalaCore.h             |    8 +-
 src/Bpp/Phyl/Model/Protein/DSO78.cpp               |    9 +-
 src/Bpp/Phyl/Model/Protein/DSO78.h                 |   16 +-
 src/Bpp/Phyl/Model/Protein/JCprot.cpp              |    4 +-
 src/Bpp/Phyl/Model/Protein/JCprot.h                |   16 +-
 src/Bpp/Phyl/Model/Protein/JTT92.cpp               |    4 +-
 src/Bpp/Phyl/Model/Protein/JTT92.h                 |   30 +-
 src/Bpp/Phyl/Model/Protein/LG08.cpp                |   12 +-
 src/Bpp/Phyl/Model/Protein/LG08.h                  |   16 +-
 src/Bpp/Phyl/Model/Protein/LG10_EX_EHO.cpp         |    4 +-
 src/Bpp/Phyl/Model/Protein/LG10_EX_EHO.h           |    8 +-
 src/Bpp/Phyl/Model/Protein/LGL08_CAT.cpp           |   32 +-
 src/Bpp/Phyl/Model/Protein/LGL08_CAT.h             |    7 +-
 src/Bpp/Phyl/Model/Protein/LLG08_EHO.cpp           |    4 +-
 src/Bpp/Phyl/Model/Protein/LLG08_EHO.h             |    7 +-
 src/Bpp/Phyl/Model/Protein/LLG08_EX2.cpp           |    4 +-
 src/Bpp/Phyl/Model/Protein/LLG08_EX2.h             |    9 +-
 src/Bpp/Phyl/Model/Protein/LLG08_EX3.cpp           |    4 +-
 src/Bpp/Phyl/Model/Protein/LLG08_EX3.h             |    5 +-
 src/Bpp/Phyl/Model/Protein/LLG08_UL2.cpp           |    4 +-
 src/Bpp/Phyl/Model/Protein/LLG08_UL2.h             |    7 +-
 src/Bpp/Phyl/Model/Protein/LLG08_UL3.cpp           |    4 +-
 src/Bpp/Phyl/Model/Protein/LLG08_UL3.h             |    7 +-
 .../Phyl/Model/Protein/ProteinSubstitutionModel.h  |   89 +-
 .../Model/Protein/UserProteinSubstitutionModel.cpp |    8 +-
 .../Model/Protein/UserProteinSubstitutionModel.h   |   16 +-
 src/Bpp/Phyl/Model/Protein/WAG01.cpp               |    4 +-
 src/Bpp/Phyl/Model/Protein/WAG01.h                 |   17 +-
 src/Bpp/Phyl/Model/RE08.cpp                        |    2 +-
 src/Bpp/Phyl/Model/RE08.h                          |  135 +-
 .../RateDistribution/ConstantRateDistribution.h    |    2 +-
 src/Bpp/Phyl/Model/RateDistributionFactory.h       |  110 -
 src/Bpp/Phyl/Model/StateMap.cpp                    |    4 +-
 src/Bpp/Phyl/Model/StateMap.h                      |  259 +-
 src/Bpp/Phyl/Model/SubstitutionModel.h             |  744 +++---
 src/Bpp/Phyl/Model/SubstitutionModelFactory.cpp    |  188 --
 src/Bpp/Phyl/Model/SubstitutionModelFactory.h      |  131 -
 src/Bpp/Phyl/Model/SubstitutionModelSet.cpp        |   23 +-
 src/Bpp/Phyl/Model/SubstitutionModelSet.h          |  120 +-
 src/Bpp/Phyl/Model/SubstitutionModelSetTools.cpp   |  104 +-
 src/Bpp/Phyl/Model/SubstitutionModelSetTools.h     |    6 +-
 src/Bpp/Phyl/Model/TS98.h                          |    7 +-
 src/Bpp/Phyl/Model/WordSubstitutionModel.cpp       |   18 +-
 src/Bpp/Phyl/Model/WordSubstitutionModel.h         |    8 +-
 src/Bpp/Phyl/NNISearchable.h                       |    2 -
 src/Bpp/Phyl/OptimizationTools.cpp                 |   28 +-
 src/Bpp/Phyl/OptimizationTools.h                   |    7 +-
 src/Bpp/Phyl/Parsimony/DRTreeParsimonyScore.h      |    7 +-
 src/Bpp/Phyl/Parsimony/TreeParsimonyData.h         |    4 -
 src/Bpp/Phyl/Parsimony/TreeParsimonyScore.h        |    4 -
 src/Bpp/Phyl/PhyloStatistics.h                     |    7 +-
 src/Bpp/Phyl/Simulation/DetailedSiteSimulator.h    |    2 +-
 .../Phyl/Simulation/HomogeneousSequenceSimulator.h |   78 +-
 .../Simulation/NonHomogeneousSequenceSimulator.cpp |  168 +-
 .../Simulation/NonHomogeneousSequenceSimulator.h   |   81 +-
 src/Bpp/Phyl/Simulation/SequenceSimulator.h        |    2 -
 src/Bpp/Phyl/SitePatterns.h                        |    7 +-
 src/Bpp/Phyl/TopologySearch.h                      |    2 -
 src/Bpp/Phyl/Tree.h                                |    2 +-
 src/Bpp/Phyl/TreeTemplate.h                        |   19 +-
 src/Bpp/Phyl/TreeTemplateTools.cpp                 |   43 +-
 src/Bpp/Phyl/TreeTemplateTools.h                   |   11 +-
 src/CMakeLists.txt                                 |  397 +--
 test/CMakeLists.txt                                |  104 +-
 test/test_bowker.cpp                               |   20 +-
 test/test_likelihood.cpp                           |    6 +-
 test/test_likelihood_clock.cpp                     |    8 +-
 test/test_likelihood_nh.cpp                        |   10 +-
 test/test_mapping.cpp                              |   20 +-
 test/test_mapping_codon.cpp                        |    2 +-
 test/test_parsimony.cpp                            |    4 +-
 test/test_simulations.cpp                          |    8 +-
 test/test_tree.cpp                                 |   70 +-
 test/{test_parsimony.cpp => test_tree_getpath.cpp} |   55 +-
 .../test_tree_rootat.cpp                           |   59 +-
 287 files changed, 13223 insertions(+), 9349 deletions(-)

diff --git a/AUTHORS.txt b/AUTHORS.txt
index 0aba1e4..652f939 100644
--- a/AUTHORS.txt
+++ b/AUTHORS.txt
@@ -5,6 +5,8 @@ Bastien Boussau    <bastien.boussau at univ-lyon1.fr>
 Céline Scornavacca <celine.scornavacca at lirmm.fr>
 Laurent Guéguen    <laurent.gueguen at univ-lyon1.fr>
 Nicolas Rochette   <nicolas.rochette at univ-lyon1.fr>
+Fanny Pouyet       <fanny.pouyet at univ-lyon1.fr>
+François Gindraud  <francois.gindraud at gmail.com>
 
 Contributed code to Bio++ was enabled thanks to the following institutions and resources:
 
@@ -21,3 +23,4 @@ Contributed code to Bio++ was enabled thanks to the following institutions and r
 2009 - 2010 Berkeley University (Bastien Boussau)
 2010 -      Laboratoire BBE - UMR CNRS 5558 Université Lyon 1 (Bastien Boussau)   
 2008 -      Laboratoire BBE - UMR CNRS 5558 Université Lyon 1 (Laurent Guéguen)
+2017 - 2018 Projet GrASP - LabEX Ecofect - Université de Lyon (François Gindraud)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 054be2b..75a7464 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,28 +1,22 @@
-# CMake script for Bio++ PhylLib
-# Author: Sylvain Gaillard and Julien Dutheil
+# CMake script for Bio++ Phylogenetic Library
+# Authors:
+#   Sylvain Gaillard
+#   Julien Dutheil
+#   Francois Gindraud (2017)
 # Created: 20/08/2009
 
-# Global parameters
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(bpp-phyl CXX)
+cmake_minimum_required (VERSION 2.8.11)
+project (bpp-phyl CXX)
+
+# Compile options
+set (CMAKE_CXX_FLAGS "-std=c++11 -Wall -Weffc++ -Wshadow -Wconversion")
+
 IF(NOT CMAKE_BUILD_TYPE)
   SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
       "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
       FORCE)
 ENDIF(NOT CMAKE_BUILD_TYPE)
 
-SET(CMAKE_CXX_FLAGS "-Wall -Wshadow -Weffc++ -Wconversion")
-IF(NOT NO_VIRTUAL_COV)
-  SET(NO_VIRTUAL_COV FALSE CACHE BOOL
-      "Disable covariant return type with virtual inheritance, for compilers that do not support it."
-      FORCE)
-ENDIF(NOT NO_VIRTUAL_COV)
-
-IF(NO_VIRTUAL_COV)
-  MESSAGE("-- Covariant return with virtual inheritance disabled.")
-  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNO_VIRTUAL_COV=1")
-ENDIF(NO_VIRTUAL_COV)
-
 IF(NOT NO_DEP_CHECK)
   SET(NO_DEP_CHECK FALSE CACHE BOOL
       "Disable dependencies check for building distribution only."
@@ -41,48 +35,46 @@ ELSE(NO_DEP_CHECK)
 #           library implements.
 # In other words, the library implements all the interface numbers in the
 # range from number current - age to current.
-SET(BPPPHYL_VERSION_CURRENT "10")
-SET(BPPPHYL_VERSION_REVISION "3")
-SET(BPPPHYL_VERSION_AGE "1")
+SET(${PROJECT_NAME}_VERSION_CURRENT "11")
+SET(${PROJECT_NAME}_VERSION_REVISION "0")
+SET(${PROJECT_NAME}_VERSION_AGE "0")
 
 # Effective version number computation
-MATH(EXPR BPPPHYL_VERSION_MAJOR "${BPPPHYL_VERSION_CURRENT} - ${BPPPHYL_VERSION_AGE}")
-SET(BPPPHYL_VERSION_MINOR ${BPPPHYL_VERSION_AGE})
-SET(BPPPHYL_VERSION_PATCH ${BPPPHYL_VERSION_REVISION})
-SET(BPPPHYL_VERSION "${BPPPHYL_VERSION_MAJOR}.${BPPPHYL_VERSION_MINOR}.${BPPPHYL_VERSION_PATCH}")
-
-# Set the CMAKE_PREFIX_PATH for the find_library fonction when using non
-# standard install location
-IF(CMAKE_INSTALL_PREFIX)
-  SET(CMAKE_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}" ${CMAKE_PREFIX_PATH})
-ENDIF(CMAKE_INSTALL_PREFIX)
-
-#here is a useful function:
-MACRO(IMPROVED_FIND_LIBRARY OUTPUT_LIBS lib_name include_to_find)
-  #start:
-  FIND_PATH(${lib_name}_INCLUDE_DIR ${include_to_find})
-  SET(${lib_name}_NAMES ${lib_name} ${lib_name}lib ${lib_name}dll)
-  FIND_LIBRARY(${lib_name}_LIBRARY NAMES ${${lib_name}_NAMES} PATH_SUFFIXES lib${LIB_SUFFIX})
-
-  IF(${${lib_name}_INCLUDE_DIR} MATCHES ${lib_name}_INCLUDE_DIR-NOTFOUND)
-    MESSAGE(FATAL_ERROR "${lib_name} required but not found.")
-  ELSE(${${lib_name}_INCLUDE_DIR} MATCHES ${lib_name}_INCLUDE_DIR-NOTFOUND)
-    MESSAGE("-- Library ${lib_name} found here:")
-    MESSAGE("   includes : ${${lib_name}_INCLUDE_DIR}")
-    MESSAGE("   libraries: ${${lib_name}_LIBRARY}")
-  ENDIF(${${lib_name}_INCLUDE_DIR} MATCHES ${lib_name}_INCLUDE_DIR-NOTFOUND)
-  
-  #add the dependency:
-  INCLUDE_DIRECTORIES(${${lib_name}_INCLUDE_DIR})
-  SET(${OUTPUT_LIBS} ${${OUTPUT_LIBS}} ${${lib_name}_LIBRARY})
-ENDMACRO(IMPROVED_FIND_LIBRARY)
-
-#Find the Bio++ libraries:
-IMPROVED_FIND_LIBRARY(LIBS bpp-seq Bpp/Seq/Alphabet/Alphabet.h)
-IMPROVED_FIND_LIBRARY(LIBS bpp-core Bpp/Clonable.h)
-
-# Subdirectories
-ADD_SUBDIRECTORY(src)
+MATH(EXPR ${PROJECT_NAME}_VERSION_MAJOR "${${PROJECT_NAME}_VERSION_CURRENT} - ${${PROJECT_NAME}_VERSION_AGE}")
+SET(${PROJECT_NAME}_VERSION_MINOR ${${PROJECT_NAME}_VERSION_AGE})
+SET(${PROJECT_NAME}_VERSION_PATCH ${${PROJECT_NAME}_VERSION_REVISION})
+SET(${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}")
+
+set (PROJECT_VERSION ${${PROJECT_NAME}_VERSION})
+
+# Find dependencies (add install directory to search)
+if (CMAKE_INSTALL_PREFIX)
+  set (CMAKE_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}" ${CMAKE_PREFIX_PATH})
+endif (CMAKE_INSTALL_PREFIX)
+
+include (GNUInstallDirs)
+find_package (bpp-seq 11.0.0 REQUIRED)
+
+# CMake package
+set (cmake-package-location ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
+include (CMakePackageConfigHelpers)
+configure_package_config_file (
+  package.cmake.in
+  ${CMAKE_CURRENT_BINARY_DIR}/package.cmake
+  INSTALL_DESTINATION ${cmake-package-location}
+  )
+write_basic_package_version_file (
+  ${CMAKE_CURRENT_BINARY_DIR}/package-version.cmake
+  VERSION ${PROJECT_VERSION}
+  COMPATIBILITY SameMajorVersion
+  )
+install (FILES ${CMAKE_CURRENT_BINARY_DIR}/package.cmake DESTINATION ${cmake-package-location}
+  RENAME ${PROJECT_NAME}-config.cmake)
+install (FILES ${CMAKE_CURRENT_BINARY_DIR}/package-version.cmake DESTINATION ${cmake-package-location}
+  RENAME ${PROJECT_NAME}-config-version.cmake)
+
+# Define the libraries
+add_subdirectory (src)
 
 # Doxygen
 FIND_PACKAGE(Doxygen)
@@ -103,49 +95,22 @@ ENDIF(NO_DEP_CHECK)
 # Packager
 SET(CPACK_PACKAGE_NAME "libbpp-phyl")
 SET(CPACK_PACKAGE_VENDOR "Bio++ Development Team")
-SET(CPACK_PACKAGE_VERSION "2.2.0")
+SET(CPACK_PACKAGE_VERSION "2.3.1")
 SET(CPACK_PACKAGE_VERSION_MAJOR "2")
-SET(CPACK_PACKAGE_VERSION_MINOR "2")
-SET(CPACK_PACKAGE_VERSION_PATCH "0")
+SET(CPACK_PACKAGE_VERSION_MINOR "3")
+SET(CPACK_PACKAGE_VERSION_PATCH "1")
 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The Bio++ Phylogenetics library")
 SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING.txt")
 SET(CPACK_RESOURCE_FILE_AUTHORS "${CMAKE_SOURCE_DIR}/AUTHORS.txt")
 SET(CPACK_RESOURCE_FILE_INSTALL "${CMAKE_SOURCE_DIR}/INSTALL.txt")
 SET(CPACK_SOURCE_GENERATOR "TGZ")
-SET(CPACK_SOURCE_IGNORE_FILES
- "CMakeFiles"
- "Makefile"
- "_CPack_Packages"
- "CMakeCache.txt"
- ".*\\\\.cmake"
- ".*\\\\.git"
- ".*\\\\.gz"
- ".*\\\\.deb"
- ".*\\\\.rpm"
- ".*\\\\.dmg"
- ".*\\\\..*\\\\.swp"
- "src/\\\\..*"
- "src/libbpp*"
- "test/tmp_*"
- "tmp_*"
- "debian/tmp"
- "debian/libbpp.*/"
- "debian/libbpp.*\\\\.so.*"
- "debian/libbpp.*\\\\.a"
- "debian/libbpp.*\\\\.substvars"
- "debian/libbpp.*\\\\.debhelper"
- "debian/debhelper\\\\.log"
- "html"
- "Phyl.tag"
- "Testing"
- "build-stamp"
- "install_manifest.txt"
- "DartConfiguration.tcl"
- ${CPACK_SOURCE_IGNORE_FILES}
-)
-IF (MACOS)
-  SET(CPACK_GENERATOR "Bundle")
-ENDIF()
+# /!\ This assumes that an external build is used
+SET(CPACK_SOURCE_IGNORE_FILES 
+       "/build/" 
+       "/\\\\.git/" 
+       "/\\\\.gitignore" 
+       ${CPACK_SOURCE_IGNORE_FILES}
+       )
 
 SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
 SET(CPACK_DEBSOURCE_PACKAGE_FILE_NAME "lib${CMAKE_PROJECT_NAME}_${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}.orig")
@@ -153,22 +118,9 @@ INCLUDE(CPack)
 
 #This adds the 'dist' target
 ADD_CUSTOM_TARGET(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
-# 'clean' is not (yet) a first class target. However, we need to clean the directories before building the sources:
-IF("${CMAKE_GENERATOR}" MATCHES "Make")
-  ADD_CUSTOM_TARGET(make_clean
-  COMMAND ${CMAKE_MAKE_PROGRAM} clean
-  WORKING_DIRECTORY ${CMAKE_CURRENT_DIR}
-  )
-  ADD_DEPENDENCIES(dist make_clean)
-ENDIF()
 
 IF(NOT NO_DEP_CHECK)
 IF (UNIX)
-#This creates deb packages:
-ADD_CUSTOM_TARGET(origdist COMMAND cp ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz ../${CPACK_DEBSOURCE_PACKAGE_FILE_NAME}.tar.gz)
-ADD_DEPENDENCIES(origdist dist)
-ADD_CUSTOM_TARGET(deb dpkg-buildpackage -uc -us -i${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz)
-ADD_DEPENDENCIES(deb origdist)
 
 #This creates rpm packages:
 ADD_CUSTOM_TARGET(rpm rpmbuild -ta ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz)
@@ -180,10 +132,10 @@ SET(CTEST_UPDATE_TYPE git)
 SET(UPDATE_COMMAND "git")
 SET(UPDATE_OPTIONS "")
 
-ENABLE_TESTING()
-INCLUDE(CTest)
-IF (BUILD_TESTING)
-  ADD_SUBDIRECTORY(test)
-ENDIF(BUILD_TESTING)
+enable_testing ()
+include (CTest)
+if (BUILD_TESTING)
+  add_subdirectory (test)
+endif (BUILD_TESTING)
 
 ENDIF(NOT NO_DEP_CHECK)
diff --git a/CTestConfig.cmake b/CTestConfig.cmake
new file mode 100644
index 0000000..ab6df4d
--- /dev/null
+++ b/CTestConfig.cmake
@@ -0,0 +1,13 @@
+## This file should be placed in the root directory of your project.
+## Then modify the CMakeLists.txt file in the root directory of your
+## project to incorporate the testing dashboard.
+## # The following are required to uses Dart and the Cdash dashboard
+##   ENABLE_TESTING()
+##   INCLUDE(CTest)
+set(CTEST_PROJECT_NAME "bpp-phyl")
+set(CTEST_NIGHTLY_START_TIME "00:00:00 CEST")
+
+set(CTEST_DROP_METHOD "http")
+set(CTEST_DROP_SITE "biopp.univ-montp2.fr")
+set(CTEST_DROP_LOCATION "/dashboard/submit.php?project=bpp-phyl")
+set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/ChangeLog b/ChangeLog
index 575a136..2437ecb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+10/05/17 -*- Version 2.3.0 -*-
+
+23/09/16 Laurent Gueguen
+* KCM model
+
+26/04/16 Julien Dutheil
+* Moved to C++11
+
+07/04/16 Julien Dutheil
+* Fixed bug in EB calculation for states at leaf nodes.
+
+03/03/15 Julien Dutheil
+* Added KrKcSubstitutionRegister for proteins.
+* Refactoring of SubstitutionModel hierarchy.
+
+10/11/14 Julien Dutheil
+* Fixed bug #92: RE08+codon works again.
+
+09/10/14 Julien Dutheil
+* Fixed bug #90: setRootNode now reset father node pointer.
+
+02/10/14 Julien Dutheil
+* Added progress bar in tree parsing (for large trees).
+
 28/09/14 -*- Version 2.2.0 -*-
 
 26/09/14 Julien Dutheil
diff --git a/Doxyfile b/Doxyfile
index a07d8a0..a99cf18 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -1,358 +1,406 @@
-# Doxyfile 1.8.3.1-20130209
+# Doxyfile 1.8.11
 
 # This file describes the settings to be used by the documentation system
-# doxygen (www.doxygen.org) for a project
+# doxygen (www.doxygen.org) for a project.
 #
-# All text after a hash (#) is considered a comment and will be ignored
+# All text after a double hash (##) is considered a comment and is placed in
+# front of the TAG it is preceding.
+#
+# All text after a single hash (#) is considered a comment and will be ignored.
 # The format is:
-#       TAG = value [value, ...]
-# For lists items can also be appended using:
-#       TAG += value [value, ...]
-# Values that contain spaces should be placed between quotes (" ")
+# TAG = value [value, ...]
+# For lists, items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (\" \").
 
 #---------------------------------------------------------------------------
 # Project related configuration options
 #---------------------------------------------------------------------------
 
-# This tag specifies the encoding used for all characters in the config file 
-# that follow. The default is UTF-8 which is also the encoding used for all 
-# text before the first occurrence of this tag. Doxygen uses libiconv (or the 
-# iconv built into libc) for the transcoding. See 
-# http://www.gnu.org/software/libiconv for the list of possible encodings.
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all text
+# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv
+# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv
+# for the list of possible encodings.
+# The default value is: UTF-8.
 
 DOXYFILE_ENCODING      = UTF-8
 
-# The PROJECT_NAME tag is a single word (or sequence of words) that should 
-# identify the project. Note that if you do not use Doxywizard you need 
-# to put quotes around the project name if it contains spaces.
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by
+# double-quotes, unless you are using Doxywizard) that should identify the
+# project for which the documentation is generated. This name is used in the
+# title of most generated pages and in a few other places.
+# The default value is: My Project.
 
 PROJECT_NAME           = bpp-phyl
 
-# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
-# This could be handy for archiving the generated documentation or 
-# if some version control system is used.
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
+# could be handy for archiving the generated documentation or if some version
+# control system is used.
 
-PROJECT_NUMBER         = 2.2.0
+PROJECT_NUMBER         = 2.3.0
 
-# Using the PROJECT_BRIEF tag one can provide an optional one line description 
-# for a project that appears at the top of each page and should give viewer 
-# a quick idea about the purpose of the project. Keep the description short.
+# Using the PROJECT_BRIEF tag one can provide an optional one line description
+# for a project that appears at the top of each page and should give viewer a
+# quick idea about the purpose of the project. Keep the description short.
 
 PROJECT_BRIEF          = 
 
-# With the PROJECT_LOGO tag one can specify an logo or icon that is 
-# included in the documentation. The maximum height of the logo should not 
-# exceed 55 pixels and the maximum width should not exceed 200 pixels. 
-# Doxygen will copy the logo to the output directory.
+# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
+# in the documentation. The maximum height of the logo should not exceed 55
+# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
+# the logo to the output directory.
 
 PROJECT_LOGO           = 
 
-# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
-# base path where the generated documentation will be put. 
-# If a relative path is entered, it will be relative to the location 
-# where doxygen was started. If left blank the current directory will be used.
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
+# into which the generated documentation will be written. If a relative path is
+# entered, it will be relative to the location where doxygen was started. If
+# left blank the current directory will be used.
 
 OUTPUT_DIRECTORY       = 
 
-# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 
-# 4096 sub-directories (in 2 levels) under the output directory of each output 
-# format and will distribute the generated files over these directories. 
-# Enabling this option can be useful when feeding doxygen a huge amount of 
-# source files, where putting all generated files in the same directory would 
-# otherwise cause performance problems for the file system.
+# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
+# directories (in 2 levels) under the output directory of each output format and
+# will distribute the generated files over these directories. Enabling this
+# option can be useful when feeding doxygen a huge amount of source files, where
+# putting all generated files in the same directory would otherwise causes
+# performance problems for the file system.
+# The default value is: NO.
 
 CREATE_SUBDIRS         = NO
 
-# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
-# documentation generated by doxygen is written. Doxygen will use this 
-# information to generate all constant output in the proper language. 
-# The default language is English, other supported languages are: 
-# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, 
-# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, 
-# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English 
-# messages), Korean, Korean-en, Latvian, Lithuanian, Norwegian, Macedonian, Persian, 
-# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, 
-# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
+# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII
+# characters to appear in the names of generated files. If set to NO, non-ASCII
+# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode
+# U+3044.
+# The default value is: NO.
+
+ALLOW_UNICODE_NAMES    = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese,
+# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States),
+# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian,
+# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages),
+# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian,
+# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian,
+# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish,
+# Ukrainian and Vietnamese.
+# The default value is: English.
 
 OUTPUT_LANGUAGE        = English
 
-# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
-# include brief member descriptions after the members that are listed in 
-# the file and class documentation (similar to JavaDoc). 
-# Set to NO to disable this.
+# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member
+# descriptions after the members that are listed in the file and class
+# documentation (similar to Javadoc). Set to NO to disable this.
+# The default value is: YES.
 
 BRIEF_MEMBER_DESC      = YES
 
-# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
-# the brief description of a member or function before the detailed description. 
-# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
+# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief
+# description of a member or function before the detailed description
+#
+# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
 # brief descriptions will be completely suppressed.
+# The default value is: YES.
 
 REPEAT_BRIEF           = YES
 
-# This tag implements a quasi-intelligent brief description abbreviator 
-# that is used to form the text in various listings. Each string 
-# in this list, if found as the leading text of the brief description, will be 
-# stripped from the text and the result after processing the whole list, is 
-# used as the annotated text. Otherwise, the brief description is used as-is. 
-# If left blank, the following values are used ("$name" is automatically 
-# replaced with the name of the entity): "The $name class" "The $name widget" 
-# "The $name file" "is" "provides" "specifies" "contains" 
-# "represents" "a" "an" "the"
+# This tag implements a quasi-intelligent brief description abbreviator that is
+# used to form the text in various listings. Each string in this list, if found
+# as the leading text of the brief description, will be stripped from the text
+# and the result, after processing the whole list, is used as the annotated
+# text. Otherwise, the brief description is used as-is. If left blank, the
+# following values are used ($name is automatically replaced with the name of
+# the entity):The $name class, The $name widget, The $name file, is, provides,
+# specifies, contains, represents, a, an and the.
 
 ABBREVIATE_BRIEF       = 
 
-# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
-# Doxygen will generate a detailed section even if there is only a brief 
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# doxygen will generate a detailed section even if there is only a brief
 # description.
+# The default value is: NO.
 
 ALWAYS_DETAILED_SEC    = NO
 
-# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all 
-# inherited members of a class in the documentation of that class as if those 
-# members were ordinary class members. Constructors, destructors and assignment 
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
 # operators of the base classes will not be shown.
+# The default value is: NO.
 
 INLINE_INHERITED_MEMB  = YES
 
-# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 
-# path before files name in the file list and in the header files. If set 
-# to NO the shortest path that makes the file name unique will be used.
+# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path
+# before files name in the file list and in the header files. If set to NO the
+# shortest path that makes the file name unique will be used
+# The default value is: YES.
 
 FULL_PATH_NAMES        = YES
 
-# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
-# can be used to strip a user-defined part of the path. Stripping is 
-# only done if one of the specified strings matches the left-hand part of 
-# the path. The tag can be used to show relative paths in the file list. 
-# If left blank the directory from which doxygen is run is used as the 
-# path to strip. Note that you specify absolute paths here, but also 
-# relative paths, which will be relative from the directory where doxygen is 
-# started.
+# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path.
+# Stripping is only done if one of the specified strings matches the left-hand
+# part of the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the path to
+# strip.
+#
+# Note that you can specify absolute paths here, but also relative paths, which
+# will be relative from the directory where doxygen is started.
+# This tag requires that the tag FULL_PATH_NAMES is set to YES.
 
 STRIP_FROM_PATH        = ./src/
 
-# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of 
-# the path mentioned in the documentation of a class, which tells 
-# the reader which header file to include in order to use a class. 
-# If left blank only the name of the header file containing the class 
-# definition is used. Otherwise one should specify the include paths that 
-# are normally passed to the compiler using the -I flag.
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
+# path mentioned in the documentation of a class, which tells the reader which
+# header file to include in order to use a class. If left blank only the name of
+# the header file containing the class definition is used. Otherwise one should
+# specify the list of include paths that are normally passed to the compiler
+# using the -I flag.
 
 STRIP_FROM_INC_PATH    = ./src/
 
-# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 
-# (but less readable) file names. This can be useful if your file system 
-# doesn't support long names like on DOS, Mac, or CD-ROM.
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but
+# less readable) file names. This can be useful is your file systems doesn't
+# support long names like on DOS, Mac, or CD-ROM.
+# The default value is: NO.
 
 SHORT_NAMES            = NO
 
-# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
-# will interpret the first line (until the first dot) of a JavaDoc-style 
-# comment as the brief description. If set to NO, the JavaDoc 
-# comments will behave just like regular Qt-style comments 
-# (thus requiring an explicit @brief command for a brief description.)
+# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the
+# first line (until the first dot) of a Javadoc-style comment as the brief
+# description. If set to NO, the Javadoc-style will behave just like regular Qt-
+# style comments (thus requiring an explicit @brief command for a brief
+# description.)
+# The default value is: NO.
 
 JAVADOC_AUTOBRIEF      = NO
 
-# If the QT_AUTOBRIEF tag is set to YES then Doxygen will 
-# interpret the first line (until the first dot) of a Qt-style 
-# comment as the brief description. If set to NO, the comments 
-# will behave just like regular Qt-style comments (thus requiring 
-# an explicit \brief command for a brief description.)
+# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first
+# line (until the first dot) of a Qt-style comment as the brief description. If
+# set to NO, the Qt-style will behave just like regular Qt-style comments (thus
+# requiring an explicit \brief command for a brief description.)
+# The default value is: NO.
 
 QT_AUTOBRIEF           = NO
 
-# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 
-# treat a multi-line C++ special comment block (i.e. a block of //! or /// 
-# comments) as a brief description. This used to be the default behaviour. 
-# The new default is to treat a multi-line C++ comment block as a detailed 
-# description. Set this tag to YES if you prefer the old behaviour instead.
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a
+# multi-line C++ special comment block (i.e. a block of //! or /// comments) as
+# a brief description. This used to be the default behavior. The new default is
+# to treat a multi-line C++ comment block as a detailed description. Set this
+# tag to YES if you prefer the old behavior instead.
+#
+# Note that setting this tag to YES also means that rational rose comments are
+# not recognized any more.
+# The default value is: NO.
 
 MULTILINE_CPP_IS_BRIEF = NO
 
-# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 
-# member inherits the documentation from any documented member that it 
-# re-implements.
+# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the
+# documentation from any documented member that it re-implements.
+# The default value is: YES.
 
 INHERIT_DOCS           = YES
 
-# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce 
-# a new page for each member. If set to NO, the documentation of a member will 
-# be part of the file/class/namespace that contains it.
+# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new
+# page for each member. If set to NO, the documentation of a member will be part
+# of the file/class/namespace that contains it.
+# The default value is: NO.
 
 SEPARATE_MEMBER_PAGES  = NO
 
-# The TAB_SIZE tag can be used to set the number of spaces in a tab. 
-# Doxygen uses this value to replace tabs by spaces in code fragments.
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen
+# uses this value to replace tabs by spaces in code fragments.
+# Minimum value: 1, maximum value: 16, default value: 4.
 
 TAB_SIZE               = 2
 
-# This tag can be used to specify a number of aliases that acts 
-# as commands in the documentation. An alias has the form "name=value". 
-# For example adding "sideeffect=\par Side Effects:\n" will allow you to 
-# put the command \sideeffect (or @sideeffect) in the documentation, which 
-# will result in a user-defined paragraph with heading "Side Effects:". 
-# You can put \n's in the value part of an alias to insert newlines.
+# This tag can be used to specify a number of aliases that act as commands in
+# the documentation. An alias has the form:
+# name=value
+# For example adding
+# "sideeffect=@par Side Effects:\n"
+# will allow you to put the command \sideeffect (or @sideeffect) in the
+# documentation, which will result in a user-defined paragraph with heading
+# "Side Effects:". You can put \n's in the value part of an alias to insert
+# newlines.
 
 ALIASES                = 
 
-# This tag can be used to specify a number of word-keyword mappings (TCL only). 
-# A mapping has the form "name=value". For example adding 
-# "class=itcl::class" will allow you to use the command class in the 
-# itcl::class meaning.
+# This tag can be used to specify a number of word-keyword mappings (TCL only).
+# A mapping has the form "name=value". For example adding "class=itcl::class"
+# will allow you to use the command class in the itcl::class meaning.
 
 TCL_SUBST              = 
 
-# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C 
-# sources only. Doxygen will then generate output that is more tailored for C. 
-# For instance, some of the names that are used will be different. The list 
-# of all members will be omitted, etc.
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
+# only. Doxygen will then generate output that is more tailored for C. For
+# instance, some of the names that are used will be different. The list of all
+# members will be omitted, etc.
+# The default value is: NO.
 
 OPTIMIZE_OUTPUT_FOR_C  = NO
 
-# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java 
-# sources only. Doxygen will then generate output that is more tailored for 
-# Java. For instance, namespaces will be presented as packages, qualified 
-# scopes will look different, etc.
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or
+# Python sources only. Doxygen will then generate output that is more tailored
+# for that language. For instance, namespaces will be presented as packages,
+# qualified scopes will look different, etc.
+# The default value is: NO.
 
 OPTIMIZE_OUTPUT_JAVA   = NO
 
-# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran 
-# sources only. Doxygen will then generate output that is more tailored for 
-# Fortran.
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources. Doxygen will then generate output that is tailored for Fortran.
+# The default value is: NO.
 
 OPTIMIZE_FOR_FORTRAN   = NO
 
-# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL 
-# sources. Doxygen will then generate output that is tailored for 
-# VHDL.
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for VHDL.
+# The default value is: NO.
 
 OPTIMIZE_OUTPUT_VHDL   = NO
 
-# Doxygen selects the parser to use depending on the extension of the files it 
-# parses. With this tag you can assign which parser to use for a given 
-# extension. Doxygen has a built-in mapping, but you can override or extend it 
-# using this tag. The format is ext=language, where ext is a file extension, 
-# and language is one of the parsers supported by doxygen: IDL, Java, 
-# Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, 
-# C++. For instance to make doxygen treat .inc files as Fortran files (default 
-# is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note 
-# that for custom extensions you also need to set FILE_PATTERNS otherwise the 
-# files are not read by doxygen.
+# Doxygen selects the parser to use depending on the extension of the files it
+# parses. With this tag you can assign which parser to use for a given
+# extension. Doxygen has a built-in mapping, but you can override or extend it
+# using this tag. The format is ext=language, where ext is a file extension, and
+# language is one of the parsers supported by doxygen: IDL, Java, Javascript,
+# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran:
+# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran:
+# Fortran. In the later case the parser tries to guess whether the code is fixed
+# or free formatted code, this is the default for Fortran type files), VHDL. For
+# instance to make doxygen treat .inc files as Fortran files (default is PHP),
+# and .f files as C (default is Fortran), use: inc=Fortran f=C.
+#
+# Note: For files without extension you can use no_extension as a placeholder.
+#
+# Note that for custom extensions you also need to set FILE_PATTERNS otherwise
+# the files are not read by doxygen.
 
 EXTENSION_MAPPING      = 
 
-# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all 
-# comments according to the Markdown format, which allows for more readable 
-# documentation. See http://daringfireball.net/projects/markdown/ for details. 
-# The output of markdown processing is further processed by doxygen, so you 
-# can mix doxygen, HTML, and XML commands with Markdown formatting. 
-# Disable only in case of backward compatibilities issues.
+# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments
+# according to the Markdown format, which allows for more readable
+# documentation. See http://daringfireball.net/projects/markdown/ for details.
+# The output of markdown processing is further processed by doxygen, so you can
+# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in
+# case of backward compatibilities issues.
+# The default value is: YES.
 
 MARKDOWN_SUPPORT       = YES
 
-# When enabled doxygen tries to link words that correspond to documented classes, 
-# or namespaces to their corresponding documentation. Such a link can be 
-# prevented in individual cases by by putting a % sign in front of the word or 
+# When enabled doxygen tries to link words that correspond to documented
+# classes, or namespaces to their corresponding documentation. Such a link can
+# be prevented in individual cases by putting a % sign in front of the word or
 # globally by setting AUTOLINK_SUPPORT to NO.
+# The default value is: YES.
 
 AUTOLINK_SUPPORT       = YES
 
-# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want 
-# to include (a tag file for) the STL sources as input, then you should 
-# set this tag to YES in order to let doxygen match functions declarations and 
-# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. 
-# func(std::string) {}). This also makes the inheritance and collaboration 
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should set this
+# tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string);
+# versus func(std::string) {}). This also make the inheritance and collaboration
 # diagrams that involve STL classes more complete and accurate.
+# The default value is: NO.
 
 BUILTIN_STL_SUPPORT    = YES
 
-# If you use Microsoft's C++/CLI language, you should set this option to YES to 
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
 # enable parsing support.
+# The default value is: NO.
 
 CPP_CLI_SUPPORT        = NO
 
-# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. 
-# Doxygen will parse them like normal C++ but will assume all classes use public 
-# instead of private inheritance when no explicit protection keyword is present.
+# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:
+# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen
+# will parse them like normal C++ but will assume all classes use public instead
+# of private inheritance when no explicit protection keyword is present.
+# The default value is: NO.
 
 SIP_SUPPORT            = NO
 
-# For Microsoft's IDL there are propget and propput attributes to indicate 
-# getter and setter methods for a property. Setting this option to YES (the 
-# default) will make doxygen replace the get and set methods by a property in 
-# the documentation. This will only work if the methods are indeed getting or 
-# setting a simple type. If this is not the case, or you want to show the 
-# methods anyway, you should set this option to NO.
+# For Microsoft's IDL there are propget and propput attributes to indicate
+# getter and setter methods for a property. Setting this option to YES will make
+# doxygen to replace the get and set methods by a property in the documentation.
+# This will only work if the methods are indeed getting or setting a simple
+# type. If this is not the case, or you want to show the methods anyway, you
+# should set this option to NO.
+# The default value is: YES.
 
 IDL_PROPERTY_SUPPORT   = YES
 
-# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
-# tag is set to YES, then doxygen will reuse the documentation of the first 
-# member in the group (if any) for the other members of the group. By default 
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
 # all members of a group must be documented explicitly.
+# The default value is: NO.
 
 DISTRIBUTE_GROUP_DOC   = NO
 
-# Set the SUBGROUPING tag to YES (the default) to allow class member groups of 
-# the same type (for instance a group of public functions) to be put as a 
-# subgroup of that type (e.g. under the Public Functions section). Set it to 
-# NO to prevent subgrouping. Alternatively, this can be done per class using 
-# the \nosubgrouping command.
+# If one adds a struct or class to a group and this option is enabled, then also
+# any nested class or struct is added to the same group. By default this option
+# is disabled and one has to add nested compounds explicitly via \ingroup.
+# The default value is: NO.
+
+GROUP_NESTED_COMPOUNDS = NO
+
+# Set the SUBGROUPING tag to YES to allow class member groups of the same type
+# (for instance a group of public functions) to be put as a subgroup of that
+# type (e.g. under the Public Functions section). Set it to NO to prevent
+# subgrouping. Alternatively, this can be done per class using the
+# \nosubgrouping command.
+# The default value is: YES.
 
 SUBGROUPING            = YES
 
-# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and 
-# unions are shown inside the group in which they are included (e.g. using 
-# @ingroup) instead of on a separate page (for HTML and Man pages) or 
-# section (for LaTeX and RTF).
+# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions
+# are shown inside the group in which they are included (e.g. using \ingroup)
+# instead of on a separate page (for HTML and Man pages) or section (for LaTeX
+# and RTF).
+#
+# Note that this feature does not work in combination with
+# SEPARATE_MEMBER_PAGES.
+# The default value is: NO.
 
 INLINE_GROUPED_CLASSES = NO
 
-# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and 
-# unions with only public data fields or simple typedef fields will be shown 
-# inline in the documentation of the scope in which they are defined (i.e. file, 
-# namespace, or group documentation), provided this scope is documented. If set 
-# to NO (the default), structs, classes, and unions are shown on a separate 
-# page (for HTML and Man pages) or section (for LaTeX and RTF).
+# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions
+# with only public data fields or simple typedef fields will be shown inline in
+# the documentation of the scope in which they are defined (i.e. file,
+# namespace, or group documentation), provided this scope is documented. If set
+# to NO, structs, classes, and unions are shown on a separate page (for HTML and
+# Man pages) or section (for LaTeX and RTF).
+# The default value is: NO.
 
 INLINE_SIMPLE_STRUCTS  = NO
 
-# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum 
-# is documented as struct, union, or enum with the name of the typedef. So 
-# typedef struct TypeS {} TypeT, will appear in the documentation as a struct 
-# with name TypeT. When disabled the typedef will appear as a member of a file, 
-# namespace, or class. And the struct will be named TypeS. This can typically 
-# be useful for C code in case the coding convention dictates that all compound 
+# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or
+# enum is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically be
+# useful for C code in case the coding convention dictates that all compound
 # types are typedef'ed and only the typedef is referenced, never the tag name.
+# The default value is: NO.
 
 TYPEDEF_HIDES_STRUCT   = NO
 
-# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to 
-# determine which symbols to keep in memory and which to flush to disk. 
-# When the cache is full, less often used symbols will be written to disk. 
-# For small to medium size projects (<1000 input files) the default value is 
-# probably good enough. For larger projects a too small cache size can cause 
-# doxygen to be busy swapping symbols to and from disk most of the time 
-# causing a significant performance penalty. 
-# If the system has enough physical memory increasing the cache will improve the 
-# performance by keeping more symbols in memory. Note that the value works on 
-# a logarithmic scale so increasing the size by one will roughly double the 
-# memory usage. The cache size is given by this formula: 
-# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, 
-# corresponding to a cache size of 2^16 = 65536 symbols.
-
-# SYMBOL_CACHE_SIZE      = 0
-
-# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be 
-# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given 
-# their name and scope. Since this can be an expensive process and often the 
-# same symbol appear multiple times in the code, doxygen keeps a cache of 
-# pre-resolved symbols. If the cache is too small doxygen will become slower. 
-# If the cache is too large, memory is wasted. The cache size is given by this 
-# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, 
-# corresponding to a cache size of 2^16 = 65536 symbols.
+# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This
+# cache is used to resolve symbols given their name and scope. Since this can be
+# an expensive process and often the same symbol appears multiple times in the
+# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small
+# doxygen will become slower. If the cache is too large, memory is wasted. The
+# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range
+# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536
+# symbols. At the end of a run doxygen will report the cache usage and suggest
+# the optimal cache size from a speed point of view.
+# Minimum value: 0, maximum value: 9, default value: 0.
 
 LOOKUP_CACHE_SIZE      = 0
 
@@ -360,1195 +408,1576 @@ LOOKUP_CACHE_SIZE      = 0
 # Build related configuration options
 #---------------------------------------------------------------------------
 
-# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
-# documentation are documented, even if no documentation was available. 
-# Private class members and static file members will be hidden unless 
-# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in
+# documentation are documented, even if no documentation was available. Private
+# class members and static file members will be hidden unless the
+# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES.
+# Note: This will also disable the warnings about undocumented members that are
+# normally produced when WARNINGS is set to YES.
+# The default value is: NO.
 
 EXTRACT_ALL            = YES
 
-# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
-# will be included in the documentation.
+# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will
+# be included in the documentation.
+# The default value is: NO.
 
 EXTRACT_PRIVATE        = YES
 
-# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal 
+# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal
 # scope will be included in the documentation.
+# The default value is: NO.
 
 EXTRACT_PACKAGE        = NO
 
-# If the EXTRACT_STATIC tag is set to YES all static members of a file 
-# will be included in the documentation.
+# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be
+# included in the documentation.
+# The default value is: NO.
 
 EXTRACT_STATIC         = YES
 
-# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 
-# defined locally in source files will be included in the documentation. 
-# If set to NO only classes defined in header files are included.
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
+# locally in source files will be included in the documentation. If set to NO,
+# only classes defined in header files are included. Does not have any effect
+# for Java sources.
+# The default value is: YES.
 
 EXTRACT_LOCAL_CLASSES  = YES
 
-# This flag is only useful for Objective-C code. When set to YES local 
-# methods, which are defined in the implementation section but not in 
-# the interface are included in the documentation. 
-# If set to NO (the default) only methods in the interface are included.
+# This flag is only useful for Objective-C code. If set to YES, local methods,
+# which are defined in the implementation section but not in the interface are
+# included in the documentation. If set to NO, only methods in the interface are
+# included.
+# The default value is: NO.
 
 EXTRACT_LOCAL_METHODS  = NO
 
-# If this flag is set to YES, the members of anonymous namespaces will be 
-# extracted and appear in the documentation as a namespace called 
-# 'anonymous_namespace{file}', where file will be replaced with the base 
-# name of the file that contains the anonymous namespace. By default 
-# anonymous namespaces are hidden.
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base name of
+# the file that contains the anonymous namespace. By default anonymous namespace
+# are hidden.
+# The default value is: NO.
 
 EXTRACT_ANON_NSPACES   = NO
 
-# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
-# undocumented members of documented classes, files or namespaces. 
-# If set to NO (the default) these members will be included in the 
-# various overviews, but no documentation section is generated. 
-# This option has no effect if EXTRACT_ALL is enabled.
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all
+# undocumented members inside documented classes or files. If set to NO these
+# members will be included in the various overviews, but no documentation
+# section is generated. This option has no effect if EXTRACT_ALL is enabled.
+# The default value is: NO.
 
 HIDE_UNDOC_MEMBERS     = NO
 
-# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
-# undocumented classes that are normally visible in the class hierarchy. 
-# If set to NO (the default) these classes will be included in the various 
-# overviews. This option has no effect if EXTRACT_ALL is enabled.
+# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy. If set
+# to NO, these classes will be included in the various overviews. This option
+# has no effect if EXTRACT_ALL is enabled.
+# The default value is: NO.
 
 HIDE_UNDOC_CLASSES     = NO
 
-# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 
-# friend (class|struct|union) declarations. 
-# If set to NO (the default) these declarations will be included in the 
-# documentation.
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend
+# (class|struct|union) declarations. If set to NO, these declarations will be
+# included in the documentation.
+# The default value is: NO.
 
 HIDE_FRIEND_COMPOUNDS  = NO
 
-# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 
-# documentation blocks found inside the body of a function. 
-# If set to NO (the default) these blocks will be appended to the 
-# function's detailed documentation block.
+# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any
+# documentation blocks found inside the body of a function. If set to NO, these
+# blocks will be appended to the function's detailed documentation block.
+# The default value is: NO.
 
 HIDE_IN_BODY_DOCS      = NO
 
-# The INTERNAL_DOCS tag determines if documentation 
-# that is typed after a \internal command is included. If the tag is set 
-# to NO (the default) then the documentation will be excluded. 
-# Set it to YES to include the internal documentation.
+# The INTERNAL_DOCS tag determines if documentation that is typed after a
+# \internal command is included. If the tag is set to NO then the documentation
+# will be excluded. Set it to YES to include the internal documentation.
+# The default value is: NO.
 
 INTERNAL_DOCS          = NO
 
-# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
-# file names in lower-case letters. If set to YES upper-case letters are also 
-# allowed. This is useful if you have classes or files whose names only differ 
-# in case and if your file system supports case sensitive file names. Windows 
+# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file
+# names in lower-case letters. If set to YES, upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
 # and Mac users are advised to set this option to NO.
+# The default value is: system dependent.
 
 CASE_SENSE_NAMES       = YES
 
-# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
-# will show members with their full class and namespace scopes in the 
-# documentation. If set to YES the scope will be hidden.
+# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with
+# their full class and namespace scopes in the documentation. If set to YES, the
+# scope will be hidden.
+# The default value is: NO.
 
 HIDE_SCOPE_NAMES       = NO
 
-# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
-# will put a list of the files that are included by a file in the documentation 
-# of that file.
+# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will
+# append additional text to a page's title, such as Class Reference. If set to
+# YES the compound reference will be hidden.
+# The default value is: NO.
+
+HIDE_COMPOUND_REFERENCE= NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of
+# the files that are included by a file in the documentation of that file.
+# The default value is: YES.
 
 SHOW_INCLUDE_FILES     = YES
 
-# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen 
-# will list include files with double quotes in the documentation 
-# rather than with sharp brackets.
+# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each
+# grouped member an include statement to the documentation, telling the reader
+# which file to include in order to use the member.
+# The default value is: NO.
+
+SHOW_GROUPED_MEMB_INC  = NO
+
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include
+# files with double quotes in the documentation rather than with sharp brackets.
+# The default value is: NO.
 
 FORCE_LOCAL_INCLUDES   = NO
 
-# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
-# is inserted in the documentation for inline members.
+# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the
+# documentation for inline members.
+# The default value is: YES.
 
 INLINE_INFO            = YES
 
-# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
-# will sort the (detailed) documentation of file and class members 
-# alphabetically by member name. If set to NO the members will appear in 
-# declaration order.
+# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the
+# (detailed) documentation of file and class members alphabetically by member
+# name. If set to NO, the members will appear in declaration order.
+# The default value is: YES.
 
 SORT_MEMBER_DOCS       = YES
 
-# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the 
-# brief documentation of file, namespace and class members alphabetically 
-# by member name. If set to NO (the default) the members will appear in 
-# declaration order.
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief
+# descriptions of file, namespace and class members alphabetically by member
+# name. If set to NO, the members will appear in declaration order. Note that
+# this will also influence the order of the classes in the class list.
+# The default value is: NO.
 
 SORT_BRIEF_DOCS        = NO
 
-# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen 
-# will sort the (brief and detailed) documentation of class members so that 
-# constructors and destructors are listed first. If set to NO (the default) 
-# the constructors will appear in the respective orders defined by 
-# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. 
-# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO 
-# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the
+# (brief and detailed) documentation of class members so that constructors and
+# destructors are listed first. If set to NO the constructors will appear in the
+# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS.
+# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief
+# member documentation.
+# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting
+# detailed member documentation.
+# The default value is: NO.
 
 SORT_MEMBERS_CTORS_1ST = NO
 
-# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the 
-# hierarchy of group names into alphabetical order. If set to NO (the default) 
-# the group names will appear in their defined order.
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy
+# of group names into alphabetical order. If set to NO the group names will
+# appear in their defined order.
+# The default value is: NO.
 
 SORT_GROUP_NAMES       = NO
 
-# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be 
-# sorted by fully-qualified names, including namespaces. If set to 
-# NO (the default), the class list will be sorted only by class name, 
-# not including the namespace part. 
-# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. 
-# Note: This option applies only to the class list, not to the 
-# alphabetical list.
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by
+# fully-qualified names, including namespaces. If set to NO, the class list will
+# be sorted only by class name, not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the alphabetical
+# list.
+# The default value is: NO.
 
 SORT_BY_SCOPE_NAME     = NO
 
-# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to 
-# do proper type resolution of all parameters of a function it will reject a 
-# match between the prototype and the implementation of a member function even 
-# if there is only one candidate or it is obvious which candidate to choose 
-# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen 
-# will still accept a match between prototype and implementation in such cases.
+# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper
+# type resolution of all parameters of a function it will reject a match between
+# the prototype and the implementation of a member function even if there is
+# only one candidate or it is obvious which candidate to choose by doing a
+# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still
+# accept a match between prototype and implementation in such cases.
+# The default value is: NO.
 
 STRICT_PROTO_MATCHING  = NO
 
-# The GENERATE_TODOLIST tag can be used to enable (YES) or 
-# disable (NO) the todo list. This list is created by putting \todo 
-# commands in the documentation.
+# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo
+# list. This list is created by putting \todo commands in the documentation.
+# The default value is: YES.
 
 GENERATE_TODOLIST      = NO
 
-# The GENERATE_TESTLIST tag can be used to enable (YES) or 
-# disable (NO) the test list. This list is created by putting \test 
-# commands in the documentation.
+# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test
+# list. This list is created by putting \test commands in the documentation.
+# The default value is: YES.
 
 GENERATE_TESTLIST      = NO
 
-# The GENERATE_BUGLIST tag can be used to enable (YES) or 
-# disable (NO) the bug list. This list is created by putting \bug 
-# commands in the documentation.
+# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug
+# list. This list is created by putting \bug commands in the documentation.
+# The default value is: YES.
 
 GENERATE_BUGLIST       = NO
 
-# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 
-# disable (NO) the deprecated list. This list is created by putting 
-# \deprecated commands in the documentation.
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO)
+# the deprecated list. This list is created by putting \deprecated commands in
+# the documentation.
+# The default value is: YES.
 
 GENERATE_DEPRECATEDLIST= YES
 
-# The ENABLED_SECTIONS tag can be used to enable conditional 
-# documentation sections, marked by \if section-label ... \endif 
-# and \cond section-label ... \endcond blocks.
+# The ENABLED_SECTIONS tag can be used to enable conditional documentation
+# sections, marked by \if <section_label> ... \endif and \cond <section_label>
+# ... \endcond blocks.
 
 ENABLED_SECTIONS       = 
 
-# The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
-# the initial value of a variable or macro consists of for it to appear in 
-# the documentation. If the initializer consists of more lines than specified 
-# here it will be hidden. Use a value of 0 to hide initializers completely. 
-# The appearance of the initializer of individual variables and macros in the 
-# documentation can be controlled using \showinitializer or \hideinitializer 
-# command in the documentation regardless of this setting.
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the
+# initial value of a variable or macro / define can have for it to appear in the
+# documentation. If the initializer consists of more lines than specified here
+# it will be hidden. Use a value of 0 to hide initializers completely. The
+# appearance of the value of individual variables and macros / defines can be
+# controlled using \showinitializer or \hideinitializer command in the
+# documentation regardless of this setting.
+# Minimum value: 0, maximum value: 10000, default value: 30.
 
 MAX_INITIALIZER_LINES  = 30
 
-# Set the SHOW_USED_FILES tag to NO to disable the list of files generated 
-# at the bottom of the documentation of classes and structs. If set to YES the 
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at
+# the bottom of the documentation of classes and structs. If set to YES, the
 # list will mention the files that were used to generate the documentation.
+# The default value is: YES.
 
 SHOW_USED_FILES        = YES
 
-# Set the SHOW_FILES tag to NO to disable the generation of the Files page. 
-# This will remove the Files entry from the Quick Index and from the 
-# Folder Tree View (if specified). The default is YES.
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This
+# will remove the Files entry from the Quick Index and from the Folder Tree View
+# (if specified).
+# The default value is: YES.
 
 SHOW_FILES             = YES
 
-# Set the SHOW_NAMESPACES tag to NO to disable the generation of the 
-# Namespaces page.  This will remove the Namespaces entry from the Quick Index 
-# and from the Folder Tree View (if specified). The default is YES.
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces
+# page. This will remove the Namespaces entry from the Quick Index and from the
+# Folder Tree View (if specified).
+# The default value is: YES.
 
 SHOW_NAMESPACES        = YES
 
-# The FILE_VERSION_FILTER tag can be used to specify a program or script that 
-# doxygen should invoke to get the current version for each file (typically from 
-# the version control system). Doxygen will invoke the program by executing (via 
-# popen()) the command <command> <input-file>, where <command> is the value of 
-# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file 
-# provided by doxygen. Whatever the program writes to standard output 
-# is used as the file version. See the manual for examples.
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command command input-file, where command is the value of the
+# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided
+# by doxygen. Whatever the program writes to standard output is used as the file
+# version. For an example see the documentation.
 
 FILE_VERSION_FILTER    = 
 
-# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed 
-# by doxygen. The layout file controls the global structure of the generated 
-# output files in an output format independent way. To create the layout file 
-# that represents doxygen's defaults, run doxygen with the -l option. 
-# You can optionally specify a file name after the option, if omitted 
-# DoxygenLayout.xml will be used as the name of the layout file.
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
+# by doxygen. The layout file controls the global structure of the generated
+# output files in an output format independent way. To create the layout file
+# that represents doxygen's defaults, run doxygen with the -l option. You can
+# optionally specify a file name after the option, if omitted DoxygenLayout.xml
+# will be used as the name of the layout file.
+#
+# Note that if you run doxygen from a directory containing a file called
+# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE
+# tag is left empty.
 
 LAYOUT_FILE            = 
 
-# The CITE_BIB_FILES tag can be used to specify one or more bib files 
-# containing the references data. This must be a list of .bib files. The 
-# .bib extension is automatically appended if omitted. Using this command 
-# requires the bibtex tool to be installed. See also 
-# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style 
-# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this 
-# feature you need bibtex and perl available in the search path. Do not use 
-# file names with spaces, bibtex cannot handle them.
+# The CITE_BIB_FILES tag can be used to specify one or more bib files containing
+# the reference definitions. This must be a list of .bib files. The .bib
+# extension is automatically appended if omitted. This requires the bibtex tool
+# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info.
+# For LaTeX the style of the bibliography can be controlled using
+# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the
+# search path. See also \cite for info how to create references.
 
 CITE_BIB_FILES         = 
 
 #---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
+# Configuration options related to warning and progress messages
 #---------------------------------------------------------------------------
 
-# The QUIET tag can be used to turn on/off the messages that are generated 
-# by doxygen. Possible values are YES and NO. If left blank NO is used.
+# The QUIET tag can be used to turn on/off the messages that are generated to
+# standard output by doxygen. If QUIET is set to YES this implies that the
+# messages are off.
+# The default value is: NO.
 
 QUIET                  = NO
 
-# The WARNINGS tag can be used to turn on/off the warning messages that are 
-# generated by doxygen. Possible values are YES and NO. If left blank 
-# NO is used.
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES
+# this implies that the warnings are on.
+#
+# Tip: Turn warnings on while writing the documentation.
+# The default value is: YES.
 
 WARNINGS               = YES
 
-# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 
-# for undocumented members. If EXTRACT_ALL is set to YES then this flag will 
-# automatically be disabled.
+# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate
+# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag
+# will automatically be disabled.
+# The default value is: YES.
 
 WARN_IF_UNDOCUMENTED   = YES
 
-# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 
-# potential errors in the documentation, such as not documenting some 
-# parameters in a documented function, or documenting parameters that 
-# don't exist or using markup commands wrongly.
+# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some parameters
+# in a documented function, or documenting parameters that don't exist or using
+# markup commands wrongly.
+# The default value is: YES.
 
 WARN_IF_DOC_ERROR      = YES
 
-# The WARN_NO_PARAMDOC option can be enabled to get warnings for 
-# functions that are documented, but have no documentation for their parameters 
-# or return value. If set to NO (the default) doxygen will only warn about 
-# wrong or incomplete parameter documentation, but not about the absence of 
-# documentation.
+# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that
+# are documented, but have no documentation for their parameters or return
+# value. If set to NO, doxygen will only warn about wrong or incomplete
+# parameter documentation, but not about the absence of documentation.
+# The default value is: NO.
 
 WARN_NO_PARAMDOC       = NO
 
-# The WARN_FORMAT tag determines the format of the warning messages that 
-# doxygen can produce. The string should contain the $file, $line, and $text 
-# tags, which will be replaced by the file and line number from which the 
-# warning originated and the warning text. Optionally the format may contain 
-# $version, which will be replaced by the version of the file (if it could 
-# be obtained via FILE_VERSION_FILTER)
+# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when
+# a warning is encountered.
+# The default value is: NO.
+
+WARN_AS_ERROR          = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that doxygen
+# can produce. The string should contain the $file, $line, and $text tags, which
+# will be replaced by the file and line number from which the warning originated
+# and the warning text. Optionally the format may contain $version, which will
+# be replaced by the version of the file (if it could be obtained via
+# FILE_VERSION_FILTER)
+# The default value is: $file:$line: $text.
 
 WARN_FORMAT            = "$file:$line: $text"
 
-# The WARN_LOGFILE tag can be used to specify a file to which warning 
-# and error messages should be written. If left blank the output is written 
-# to stderr.
+# The WARN_LOGFILE tag can be used to specify a file to which warning and error
+# messages should be written. If left blank the output is written to standard
+# error (stderr).
 
 WARN_LOGFILE           = 
 
 #---------------------------------------------------------------------------
-# configuration options related to the input files
+# Configuration options related to the input files
 #---------------------------------------------------------------------------
 
-# The INPUT tag can be used to specify the files and/or directories that contain 
-# documented source files. You may enter file names like "myfile.cpp" or 
-# directories like "/usr/src/myproject". Separate the files or directories 
-# with spaces.
+# The INPUT tag is used to specify the files and/or directories that contain
+# documented source files. You may enter file names like myfile.cpp or
+# directories like /usr/src/myproject. Separate the files or directories with
+# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
+# Note: If this tag is empty the current directory is searched.
 
 INPUT                  = src
 
-# This tag can be used to specify the character encoding of the source files 
-# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is 
-# also the default input encoding. Doxygen uses libiconv (or the iconv built 
-# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for 
-# the list of possible encodings.
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
+# libiconv (or the iconv built into libc) for the transcoding. See the libiconv
+# documentation (see: http://www.gnu.org/software/libiconv) for the list of
+# possible encodings.
+# The default value is: UTF-8.
 
 INPUT_ENCODING         = UTF-8
 
-# If the value of the INPUT tag contains directories, you can use the 
-# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
-# and *.h) to filter out the source-files in the directories. If left 
-# blank the following patterns are tested: 
-# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh 
-# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py 
-# *.f90 *.f *.for *.vhd *.vhdl
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and
+# *.h) to filter out the source-files in the directories.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# read by doxygen.
+#
+# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp,
+# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h,
+# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc,
+# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f, *.for, *.tcl,
+# *.vhd, *.vhdl, *.ucf, *.qsf, *.as and *.js.
 
 FILE_PATTERNS          = *.h \
                          *.cpp
 
-# The RECURSIVE tag can be used to turn specify whether or not subdirectories 
-# should be searched for input files as well. Possible values are YES and NO. 
-# If left blank NO is used.
+# The RECURSIVE tag can be used to specify whether or not subdirectories should
+# be searched for input files as well.
+# The default value is: NO.
 
 RECURSIVE              = YES
 
-# The EXCLUDE tag can be used to specify files and/or directories that should be 
-# excluded from the INPUT source files. This way you can easily exclude a 
-# subdirectory from a directory tree whose root is specified with the INPUT tag. 
-# Note that relative paths are relative to the directory from which doxygen is 
+# The EXCLUDE tag can be used to specify files and/or directories that should be
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+#
+# Note that relative paths are relative to the directory from which doxygen is
 # run.
 
 EXCLUDE                = 
 
-# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or 
-# directories that are symbolic links (a Unix file system feature) are excluded 
+# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
+# directories that are symbolic links (a Unix file system feature) are excluded
 # from the input.
+# The default value is: NO.
 
 EXCLUDE_SYMLINKS       = NO
 
-# If the value of the INPUT tag contains directories, you can use the 
-# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
-# certain files from those directories. Note that the wildcards are matched 
-# against the file with absolute path, so to exclude all test directories 
-# for example use the pattern */test/*
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories.
+#
+# Note that the wildcards are matched against the file with absolute path, so to
+# exclude all test directories for example use the pattern */test/*
 
 EXCLUDE_PATTERNS       = 
 
-# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names 
-# (namespaces, classes, functions, etc.) that should be excluded from the 
-# output. The symbol name can be a fully qualified name, a word, or if the 
-# wildcard * is used, a substring. Examples: ANamespace, AClass, 
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
 # AClass::ANamespace, ANamespace::*Test
+#
+# Note that the wildcards are matched against the file with absolute path, so to
+# exclude all test directories use the pattern */test/*
 
 EXCLUDE_SYMBOLS        = 
 
-# The EXAMPLE_PATH tag can be used to specify one or more files or 
-# directories that contain example code fragments that are included (see 
-# the \include command).
+# The EXAMPLE_PATH tag can be used to specify one or more files or directories
+# that contain example code fragments that are included (see the \include
+# command).
 
 EXAMPLE_PATH           = 
 
-# If the value of the EXAMPLE_PATH tag contains directories, you can use the 
-# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
-# and *.h) to filter out the source-files in the directories. If left 
-# blank all files are included.
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
+# *.h) to filter out the source-files in the directories. If left blank all
+# files are included.
 
 EXAMPLE_PATTERNS       = 
 
-# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 
-# searched for input files to be used with the \include or \dontinclude 
-# commands irrespective of the value of the RECURSIVE tag. 
-# Possible values are YES and NO. If left blank NO is used.
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude commands
+# irrespective of the value of the RECURSIVE tag.
+# The default value is: NO.
 
 EXAMPLE_RECURSIVE      = NO
 
-# The IMAGE_PATH tag can be used to specify one or more files or 
-# directories that contain image that are included in the documentation (see 
-# the \image command).
+# The IMAGE_PATH tag can be used to specify one or more files or directories
+# that contain images that are to be included in the documentation (see the
+# \image command).
 
 IMAGE_PATH             = 
 
-# The INPUT_FILTER tag can be used to specify a program that doxygen should 
-# invoke to filter for each input file. Doxygen will invoke the filter program 
-# by executing (via popen()) the command <filter> <input-file>, where <filter> 
-# is the value of the INPUT_FILTER tag, and <input-file> is the name of an 
-# input file. Doxygen will then use the output that the filter program writes 
-# to standard output.  If FILTER_PATTERNS is specified, this tag will be 
-# ignored.
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command:
+#
+# <filter> <input-file>
+#
+# where <filter> is the value of the INPUT_FILTER tag, and <input-file> is the
+# name of an input file. Doxygen will then use the output that the filter
+# program writes to standard output. If FILTER_PATTERNS is specified, this tag
+# will be ignored.
+#
+# Note that the filter must not add or remove lines; it is applied before the
+# code is scanned, but not when the output code is generated. If lines are added
+# or removed, the anchors will not be placed correctly.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# properly processed by doxygen.
 
 INPUT_FILTER           = 
 
-# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern 
-# basis.  Doxygen will compare the file name with each pattern and apply the 
-# filter if there is a match.  The filters are a list of the form: 
-# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further 
-# info on how filters are used. If FILTER_PATTERNS is empty or if 
-# non of the patterns match the file name, INPUT_FILTER is applied.
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis. Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match. The filters are a list of the form: pattern=filter
+# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how
+# filters are used. If the FILTER_PATTERNS tag is empty or if none of the
+# patterns match the file name, INPUT_FILTER is applied.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# properly processed by doxygen.
 
 FILTER_PATTERNS        = 
 
-# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
-# INPUT_FILTER) will be used to filter the input files when producing source 
-# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will also be used to filter the input files that are used for
+# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES).
+# The default value is: NO.
 
 FILTER_SOURCE_FILES    = NO
 
-# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file 
-# pattern. A pattern will override the setting for FILTER_PATTERN (if any) 
-# and it is also possible to disable source filtering for a specific pattern 
-# using *.ext= (so without naming a filter). This option only has effect when 
-# FILTER_SOURCE_FILES is enabled.
+# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
+# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and
+# it is also possible to disable source filtering for a specific pattern using
+# *.ext= (so without naming a filter).
+# This tag requires that the tag FILTER_SOURCE_FILES is set to YES.
 
 FILTER_SOURCE_PATTERNS = 
 
-# If the USE_MD_FILE_AS_MAINPAGE tag refers to the name of a markdown file that 
-# is part of the input, its contents will be placed on the main page (index.html). 
-# This can be useful if you have a project on for instance GitHub and want reuse 
-# the introduction page also for the doxygen output.
+# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that
+# is part of the input, its contents will be placed on the main page
+# (index.html). This can be useful if you have a project on for instance GitHub
+# and want to reuse the introduction page also for the doxygen output.
 
 USE_MDFILE_AS_MAINPAGE = 
 
 #---------------------------------------------------------------------------
-# configuration options related to source browsing
+# Configuration options related to source browsing
 #---------------------------------------------------------------------------
 
-# If the SOURCE_BROWSER tag is set to YES then a list of source files will 
-# be generated. Documented entities will be cross-referenced with these sources. 
-# Note: To get rid of all source code in the generated output, make sure also 
-# VERBATIM_HEADERS is set to NO.
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will be
+# generated. Documented entities will be cross-referenced with these sources.
+#
+# Note: To get rid of all source code in the generated output, make sure that
+# also VERBATIM_HEADERS is set to NO.
+# The default value is: NO.
 
 SOURCE_BROWSER         = YES
 
-# Setting the INLINE_SOURCES tag to YES will include the body 
-# of functions and classes directly in the documentation.
+# Setting the INLINE_SOURCES tag to YES will include the body of functions,
+# classes and enums directly into the documentation.
+# The default value is: NO.
 
 INLINE_SOURCES         = NO
 
-# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
-# doxygen to hide any special comment blocks from generated source code 
-# fragments. Normal C, C++ and Fortran comments will always remain visible.
+# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any
+# special comment blocks from generated source code fragments. Normal C, C++ and
+# Fortran comments will always remain visible.
+# The default value is: YES.
 
 STRIP_CODE_COMMENTS    = YES
 
-# If the REFERENCED_BY_RELATION tag is set to YES 
-# then for each documented function all documented 
-# functions referencing it will be listed.
+# If the REFERENCED_BY_RELATION tag is set to YES then for each documented
+# function all documented functions referencing it will be listed.
+# The default value is: NO.
 
 REFERENCED_BY_RELATION = YES
 
-# If the REFERENCES_RELATION tag is set to YES 
-# then for each documented function all documented entities 
-# called/used by that function will be listed.
+# If the REFERENCES_RELATION tag is set to YES then for each documented function
+# all documented entities called/used by that function will be listed.
+# The default value is: NO.
 
 REFERENCES_RELATION    = YES
 
-# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) 
-# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from 
-# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will 
-# link to the source code.  Otherwise they will link to the documentation.
+# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set
+# to YES then the hyperlinks from functions in REFERENCES_RELATION and
+# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will
+# link to the documentation.
+# The default value is: YES.
 
 REFERENCES_LINK_SOURCE = YES
 
-# If the USE_HTAGS tag is set to YES then the references to source code 
-# will point to the HTML generated by the htags(1) tool instead of doxygen 
-# built-in source browser. The htags tool is part of GNU's global source 
-# tagging system (see http://www.gnu.org/software/global/global.html). You 
-# will need version 4.8.6 or higher.
+# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the
+# source code will show a tooltip with additional information such as prototype,
+# brief description and links to the definition and documentation. Since this
+# will make the HTML file larger and loading of large files a bit slower, you
+# can opt to disable this feature.
+# The default value is: YES.
+# This tag requires that the tag SOURCE_BROWSER is set to YES.
+
+SOURCE_TOOLTIPS        = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code will
+# point to the HTML generated by the htags(1) tool instead of doxygen built-in
+# source browser. The htags tool is part of GNU's global source tagging system
+# (see http://www.gnu.org/software/global/global.html). You will need version
+# 4.8.6 or higher.
+#
+# To use it do the following:
+# - Install the latest version of global
+# - Enable SOURCE_BROWSER and USE_HTAGS in the config file
+# - Make sure the INPUT points to the root of the source tree
+# - Run doxygen as normal
+#
+# Doxygen will invoke htags (and that will in turn invoke gtags), so these
+# tools must be available from the command line (i.e. in the search path).
+#
+# The result: instead of the source browser generated by doxygen, the links to
+# source code will now point to the output of htags.
+# The default value is: NO.
+# This tag requires that the tag SOURCE_BROWSER is set to YES.
 
 USE_HTAGS              = NO
 
-# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
-# will generate a verbatim copy of the header file for each class for 
-# which an include is specified. Set to NO to disable this.
+# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a
+# verbatim copy of the header file for each class for which an include is
+# specified. Set to NO to disable this.
+# See also: Section \class.
+# The default value is: YES.
 
 VERBATIM_HEADERS       = YES
 
+# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the
+# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the
+# cost of reduced performance. This can be particularly helpful with template
+# rich C++ code for which doxygen's built-in parser lacks the necessary type
+# information.
+# Note: The availability of this option depends on whether or not doxygen was
+# generated with the -Duse-libclang=ON option for CMake.
+# The default value is: NO.
+
+CLANG_ASSISTED_PARSING = NO
+
+# If clang assisted parsing is enabled you can provide the compiler with command
+# line options that you would normally use when invoking the compiler. Note that
+# the include paths will already be set by doxygen for the files and directories
+# specified with INPUT and INCLUDE_PATH.
+# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES.
+
+CLANG_OPTIONS          = 
+
 #---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
+# Configuration options related to the alphabetical class index
 #---------------------------------------------------------------------------
 
-# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 
-# of all compounds will be generated. Enable this if the project 
-# contains a lot of classes, structs, unions or interfaces.
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all
+# compounds will be generated. Enable this if the project contains a lot of
+# classes, structs, unions or interfaces.
+# The default value is: YES.
 
 ALPHABETICAL_INDEX     = NO
 
-# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 
-# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 
-# in which this list will be split (can be a number in the range [1..20])
+# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in
+# which the alphabetical index list will be split.
+# Minimum value: 1, maximum value: 20, default value: 5.
+# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
 
 COLS_IN_ALPHA_INDEX    = 5
 
-# In case all classes in a project start with a common prefix, all 
-# classes will be put under the same header in the alphabetical index. 
-# The IGNORE_PREFIX tag can be used to specify one or more prefixes that 
-# should be ignored while generating the index headers.
+# In case all classes in a project start with a common prefix, all classes will
+# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag
+# can be used to specify a prefix (or a list of prefixes) that should be ignored
+# while generating the index headers.
+# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
 
 IGNORE_PREFIX          = 
 
 #---------------------------------------------------------------------------
-# configuration options related to the HTML output
+# Configuration options related to the HTML output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
-# generate HTML output.
+# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output
+# The default value is: YES.
 
 GENERATE_HTML          = YES
 
-# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
-# put in front of it. If left blank `html' will be used as the default path.
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: html.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_OUTPUT            = html
 
-# The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
-# each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
-# doxygen will generate files with .html extension.
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each
+# generated HTML page (for example: .htm, .php, .asp).
+# The default value is: .html.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_FILE_EXTENSION    = .html
 
-# The HTML_HEADER tag can be used to specify a personal HTML header for 
-# each generated HTML page. If it is left blank doxygen will generate a 
-# standard header. Note that when using a custom header you are responsible  
-# for the proper inclusion of any scripts and style sheets that doxygen 
-# needs, which is dependent on the configuration options used. 
-# It is advised to generate a default header using "doxygen -w html 
-# header.html footer.html stylesheet.css YourConfigFile" and then modify 
-# that header. Note that the header is subject to change so you typically 
-# have to redo this when upgrading to a newer version of doxygen or when 
-# changing the value of configuration settings such as GENERATE_TREEVIEW!
+# The HTML_HEADER tag can be used to specify a user-defined HTML header file for
+# each generated HTML page. If the tag is left blank doxygen will generate a
+# standard header.
+#
+# To get valid HTML the header file that includes any scripts and style sheets
+# that doxygen needs, which is dependent on the configuration options used (e.g.
+# the setting GENERATE_TREEVIEW). It is highly recommended to start with a
+# default header using
+# doxygen -w html new_header.html new_footer.html new_stylesheet.css
+# YourConfigFile
+# and then modify the file new_header.html. See also section "Doxygen usage"
+# for information on how to generate the default header that doxygen normally
+# uses.
+# Note: The header is subject to change so you typically have to regenerate the
+# default header when upgrading to a newer version of doxygen. For a description
+# of the possible markers and block names see the documentation.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_HEADER            = 
 
-# The HTML_FOOTER tag can be used to specify a personal HTML footer for 
-# each generated HTML page. If it is left blank doxygen will generate a 
-# standard footer.
+# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
+# generated HTML page. If the tag is left blank doxygen will generate a standard
+# footer. See HTML_HEADER for more information on how to generate a default
+# footer and what special commands can be used inside the footer. See also
+# section "Doxygen usage" for information on how to generate the default footer
+# that doxygen normally uses.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_FOOTER            = 
 
-# The HTML_STYLESHEET tag can be used to specify a user-defined cascading 
-# style sheet that is used by each HTML page. It can be used to 
-# fine-tune the look of the HTML output. If left blank doxygen will 
-# generate a default style sheet. Note that it is recommended to use 
-# HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this 
-# tag will in the future become obsolete.
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style
+# sheet that is used by each HTML page. It can be used to fine-tune the look of
+# the HTML output. If left blank doxygen will generate a default style sheet.
+# See also section "Doxygen usage" for information on how to generate the style
+# sheet that doxygen normally uses.
+# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as
+# it is more robust and this tag (HTML_STYLESHEET) will in the future become
+# obsolete.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_STYLESHEET        = 
 
-# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional 
-# user-defined cascading style sheet that is included after the standard 
-# style sheets created by doxygen. Using this option one can overrule 
-# certain style aspects. This is preferred over using HTML_STYLESHEET 
-# since it does not replace the standard style sheet and is therefor more 
-# robust against future updates. Doxygen will copy the style sheet file to 
-# the output directory.
+# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined
+# cascading style sheets that are included after the standard style sheets
+# created by doxygen. Using this option one can overrule certain style aspects.
+# This is preferred over using HTML_STYLESHEET since it does not replace the
+# standard style sheet and is therefore more robust against future updates.
+# Doxygen will copy the style sheet files to the output directory.
+# Note: The order of the extra style sheet files is of importance (e.g. the last
+# style sheet in the list overrules the setting of the previous ones in the
+# list). For an example see the documentation.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_EXTRA_STYLESHEET  = 
 
-# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or 
-# other source files which should be copied to the HTML output directory. Note 
-# that these files will be copied to the base HTML output directory. Use the 
-# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these 
-# files. In the HTML_STYLESHEET file, use the file name only. Also note that 
-# the files will be copied as-is; there are no commands or markers available.
+# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the HTML output directory. Note
+# that these files will be copied to the base HTML output directory. Use the
+# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
+# files. In the HTML_STYLESHEET file, use the file name only. Also note that the
+# files will be copied as-is; there are no commands or markers available.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_EXTRA_FILES       = 
 
-# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. 
-# Doxygen will adjust the colors in the style sheet and background images 
-# according to this color. Hue is specified as an angle on a colorwheel, 
-# see http://en.wikipedia.org/wiki/Hue for more information. 
-# For instance the value 0 represents red, 60 is yellow, 120 is green, 
-# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. 
-# The allowed range is 0 to 359.
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
+# will adjust the colors in the style sheet and background images according to
+# this color. Hue is specified as an angle on a colorwheel, see
+# http://en.wikipedia.org/wiki/Hue for more information. For instance the value
+# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300
+# purple, and 360 is red again.
+# Minimum value: 0, maximum value: 359, default value: 220.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_COLORSTYLE_HUE    = 220
 
-# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of 
-# the colors in the HTML output. For a value of 0 the output will use 
-# grayscales only. A value of 255 will produce the most vivid colors.
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors
+# in the HTML output. For a value of 0 the output will use grayscales only. A
+# value of 255 will produce the most vivid colors.
+# Minimum value: 0, maximum value: 255, default value: 100.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_COLORSTYLE_SAT    = 100
 
-# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to 
-# the luminance component of the colors in the HTML output. Values below 
-# 100 gradually make the output lighter, whereas values above 100 make 
-# the output darker. The value divided by 100 is the actual gamma applied, 
-# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, 
-# and 100 does not change the gamma.
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the
+# luminance component of the colors in the HTML output. Values below 100
+# gradually make the output lighter, whereas values above 100 make the output
+# darker. The value divided by 100 is the actual gamma applied, so 80 represents
+# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not
+# change the gamma.
+# Minimum value: 40, maximum value: 240, default value: 80.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_COLORSTYLE_GAMMA  = 80
 
-# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML 
-# page will contain the date and time when the page was generated. Setting 
-# this to NO can help when comparing the output of multiple runs.
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting this
+# to YES can help to show when doxygen was last run and thus if the
+# documentation is up to date.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_TIMESTAMP         = YES
 
-# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML 
-# documentation will contain sections that can be hidden and shown after the 
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
 # page has loaded.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_DYNAMIC_SECTIONS  = YES
 
-# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of 
-# entries shown in the various tree structured indices initially; the user 
-# can expand and collapse entries dynamically later on. Doxygen will expand 
-# the tree to such a level that at most the specified number of entries are 
-# visible (unless a fully collapsed tree already exceeds this amount). 
-# So setting the number of entries 1 will produce a full collapsed tree by 
-# default. 0 is a special value representing an infinite number of entries 
-# and will result in a full expanded tree by default.
+# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries
+# shown in the various tree structured indices initially; the user can expand
+# and collapse entries dynamically later on. Doxygen will expand the tree to
+# such a level that at most the specified number of entries are visible (unless
+# a fully collapsed tree already exceeds this amount). So setting the number of
+# entries 1 will produce a full collapsed tree by default. 0 is a special value
+# representing an infinite number of entries and will result in a full expanded
+# tree by default.
+# Minimum value: 0, maximum value: 9999, default value: 100.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_INDEX_NUM_ENTRIES = 100
 
-# If the GENERATE_DOCSET tag is set to YES, additional index files 
-# will be generated that can be used as input for Apple's Xcode 3 
-# integrated development environment, introduced with OSX 10.5 (Leopard). 
-# To create a documentation set, doxygen will generate a Makefile in the 
-# HTML output directory. Running make will produce the docset in that 
-# directory and running "make install" will install the docset in 
-# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find 
-# it at startup. 
-# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html 
+# If the GENERATE_DOCSET tag is set to YES, additional index files will be
+# generated that can be used as input for Apple's Xcode 3 integrated development
+# environment (see: http://developer.apple.com/tools/xcode/), introduced with
+# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a
+# Makefile in the HTML output directory. Running make will produce the docset in
+# that directory and running make install will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at
+# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
 # for more information.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 GENERATE_DOCSET        = YES
 
-# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the 
-# feed. A documentation feed provides an umbrella under which multiple 
-# documentation sets from a single provider (such as a company or product suite) 
-# can be grouped.
+# This tag determines the name of the docset feed. A documentation feed provides
+# an umbrella under which multiple documentation sets from a single provider
+# (such as a company or product suite) can be grouped.
+# The default value is: Doxygen generated docs.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
 
 DOCSET_FEEDNAME        = "Bio++ Phylogenetic Library"
 
-# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that 
-# should uniquely identify the documentation set bundle. This should be a 
-# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen 
-# will append .docset to the name.
+# This tag specifies a string that should uniquely identify the documentation
+# set bundle. This should be a reverse domain-name style string, e.g.
+# com.mycompany.MyDocSet. Doxygen will append .docset to the name.
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
 
 DOCSET_BUNDLE_ID       = bpp.phyl
 
-# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely 
-# identify the documentation publisher. This should be a reverse domain-name 
-# style string, e.g. com.mycompany.MyDocSet.documentation.
+# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify
+# the documentation publisher. This should be a reverse domain-name style
+# string, e.g. com.mycompany.MyDocSet.documentation.
+# The default value is: org.doxygen.Publisher.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
 
 DOCSET_PUBLISHER_ID    = org.doxygen.Publisher
 
-# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.
+# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher.
+# The default value is: Publisher.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
 
 DOCSET_PUBLISHER_NAME  = Publisher
 
-# If the GENERATE_HTMLHELP tag is set to YES, additional index files 
-# will be generated that can be used as input for tools like the 
-# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) 
-# of the generated HTML documentation.
+# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three
+# additional HTML index files: index.hhp, index.hhc, and index.hhk. The
+# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop
+# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on
+# Windows.
+#
+# The HTML Help Workshop contains a compiler that can convert all HTML output
+# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML
+# files are now used as the Windows 98 help format, and will replace the old
+# Windows help format (.hlp) on all Windows platforms in the future. Compressed
+# HTML files also contain an index, a table of contents, and you can search for
+# words in the documentation. The HTML workshop also contains a viewer for
+# compressed HTML files.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 GENERATE_HTMLHELP      = NO
 
-# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 
-# be used to specify the file name of the resulting .chm file. You 
-# can add a path in front of the file if the result should not be 
+# The CHM_FILE tag can be used to specify the file name of the resulting .chm
+# file. You can add a path in front of the file if the result should not be
 # written to the html output directory.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
 
 CHM_FILE               = 
 
-# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 
-# be used to specify the location (absolute path including file name) of 
-# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 
-# the HTML help compiler on the generated index.hhp.
+# The HHC_LOCATION tag can be used to specify the location (absolute path
+# including file name) of the HTML help compiler (hhc.exe). If non-empty,
+# doxygen will try to run the HTML help compiler on the generated index.hhp.
+# The file has to be specified with full path.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
 
 HHC_LOCATION           = 
 
-# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 
-# controls if a separate .chi index file is generated (YES) or that 
-# it should be included in the master .chm file (NO).
+# The GENERATE_CHI flag controls if a separate .chi index file is generated
+# (YES) or that it should be included in the master .chm file (NO).
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
 
 GENERATE_CHI           = NO
 
-# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING 
-# is used to encode HtmlHelp index (hhk), content (hhc) and project file 
-# content.
+# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc)
+# and project file content.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
 
 CHM_INDEX_ENCODING     = 
 
-# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 
-# controls whether a binary table of contents is generated (YES) or a 
-# normal table of contents (NO) in the .chm file.
+# The BINARY_TOC flag controls whether a binary table of contents is generated
+# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it
+# enables the Previous and Next buttons.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
 
 BINARY_TOC             = NO
 
-# The TOC_EXPAND flag can be set to YES to add extra items for group members 
-# to the contents of the HTML help documentation and to the tree view.
+# The TOC_EXPAND flag can be set to YES to add extra items for group members to
+# the table of contents of the HTML help documentation and to the tree view.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
 
 TOC_EXPAND             = NO
 
-# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and 
-# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated 
-# that can be used as input for Qt's qhelpgenerator to generate a 
-# Qt Compressed Help (.qch) of the generated HTML documentation.
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that
+# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help
+# (.qch) of the generated HTML documentation.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 GENERATE_QHP           = NO
 
-# If the QHG_LOCATION tag is specified, the QCH_FILE tag can 
-# be used to specify the file name of the resulting .qch file. 
-# The path specified is relative to the HTML output folder.
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify
+# the file name of the resulting .qch file. The path specified is relative to
+# the HTML output folder.
+# This tag requires that the tag GENERATE_QHP is set to YES.
 
 QCH_FILE               = 
 
-# The QHP_NAMESPACE tag specifies the namespace to use when generating 
-# Qt Help Project output. For more information please see 
-# http://doc.trolltech.com/qthelpproject.html#namespace
+# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
+# Project output. For more information please see Qt Help Project / Namespace
+# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace).
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_QHP is set to YES.
 
 QHP_NAMESPACE          = org.doxygen.Project
 
-# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating 
-# Qt Help Project output. For more information please see 
-# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
+# Help Project output. For more information please see Qt Help Project / Virtual
+# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual-
+# folders).
+# The default value is: doc.
+# This tag requires that the tag GENERATE_QHP is set to YES.
 
 QHP_VIRTUAL_FOLDER     = doc
 
-# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to 
-# add. For more information please see 
-# http://doc.trolltech.com/qthelpproject.html#custom-filters
+# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
+# filter to add. For more information please see Qt Help Project / Custom
+# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
+# filters).
+# This tag requires that the tag GENERATE_QHP is set to YES.
 
 QHP_CUST_FILTER_NAME   = 
 
-# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the 
-# custom filter to add. For more information please see 
-# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters"> 
-# Qt Help Project / Custom Filters</a>.
+# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
+# custom filter to add. For more information please see Qt Help Project / Custom
+# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
+# filters).
+# This tag requires that the tag GENERATE_QHP is set to YES.
 
 QHP_CUST_FILTER_ATTRS  = 
 
-# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this 
-# project's 
-# filter section matches. 
-# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes"> 
-# Qt Help Project / Filter Attributes</a>.
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
+# project's filter section matches. Qt Help Project / Filter Attributes (see:
+# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes).
+# This tag requires that the tag GENERATE_QHP is set to YES.
 
 QHP_SECT_FILTER_ATTRS  = 
 
-# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can 
-# be used to specify the location of Qt's qhelpgenerator. 
-# If non-empty doxygen will try to run qhelpgenerator on the generated 
-# .qhp file.
+# The QHG_LOCATION tag can be used to specify the location of Qt's
+# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the
+# generated .qhp file.
+# This tag requires that the tag GENERATE_QHP is set to YES.
 
 QHG_LOCATION           = 
 
-# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files  
-# will be generated, which together with the HTML files, form an Eclipse help 
-# plugin. To install this plugin and make it available under the help contents 
-# menu in Eclipse, the contents of the directory containing the HTML and XML 
-# files needs to be copied into the plugins directory of eclipse. The name of 
-# the directory within the plugins directory should be the same as 
-# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before 
-# the help appears.
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be
+# generated, together with the HTML files, they form an Eclipse help plugin. To
+# install this plugin and make it available under the help contents menu in
+# Eclipse, the contents of the directory containing the HTML and XML files needs
+# to be copied into the plugins directory of eclipse. The name of the directory
+# within the plugins directory should be the same as the ECLIPSE_DOC_ID value.
+# After copying Eclipse needs to be restarted before the help appears.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 GENERATE_ECLIPSEHELP   = NO
 
-# A unique identifier for the eclipse help plugin. When installing the plugin 
-# the directory name containing the HTML and XML files should also have 
-# this name.
+# A unique identifier for the Eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have this
+# name. Each documentation set should have its own identifier.
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES.
 
 ECLIPSE_DOC_ID         = org.doxygen.Project
 
-# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) 
-# at top of each HTML page. The value NO (the default) enables the index and 
-# the value YES disables it. Since the tabs have the same information as the 
-# navigation tree you can set this option to NO if you already set 
-# GENERATE_TREEVIEW to YES.
+# If you want full control over the layout of the generated HTML pages it might
+# be necessary to disable the index and replace it with your own. The
+# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top
+# of each HTML page. A value of NO enables the index and the value YES disables
+# it. Since the tabs in the index contain the same information as the navigation
+# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 DISABLE_INDEX          = NO
 
-# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index 
-# structure should be generated to display hierarchical information. 
-# If the tag value is set to YES, a side panel will be generated 
-# containing a tree-like index structure (just like the one that 
-# is generated for HTML Help). For this to work a browser that supports 
-# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). 
-# Windows users are probably better off using the HTML help feature. 
-# Since the tree basically has the same information as the tab index you 
-# could consider to set DISABLE_INDEX to NO when enabling this option.
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information. If the tag
+# value is set to YES, a side panel will be generated containing a tree-like
+# index structure (just like the one that is generated for HTML Help). For this
+# to work a browser that supports JavaScript, DHTML, CSS and frames is required
+# (i.e. any modern browser). Windows users are probably better off using the
+# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can
+# further fine-tune the look of the index. As an example, the default style
+# sheet generated by doxygen has an example that shows how to put an image at
+# the root of the tree instead of the PROJECT_NAME. Since the tree basically has
+# the same information as the tab index, you could consider setting
+# DISABLE_INDEX to YES when enabling this option.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 GENERATE_TREEVIEW      = YES
 
-# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values 
-# (range [0,1..20]) that doxygen will group on one line in the generated HTML 
-# documentation. Note that a value of 0 will completely suppress the enum 
-# values from appearing in the overview section.
+# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that
+# doxygen will group on one line in the generated HTML documentation.
+#
+# Note that a value of 0 will completely suppress the enum values from appearing
+# in the overview section.
+# Minimum value: 0, maximum value: 20, default value: 4.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 ENUM_VALUES_PER_LINE   = 4
 
-# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
-# used to set the initial width (in pixels) of the frame in which the tree 
-# is shown.
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used
+# to set the initial width (in pixels) of the frame in which the tree is shown.
+# Minimum value: 0, maximum value: 1500, default value: 250.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 TREEVIEW_WIDTH         = 250
 
-# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open 
-# links to external symbols imported via tag files in a separate window.
+# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to
+# external symbols imported via tag files in a separate window.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 EXT_LINKS_IN_WINDOW    = NO
 
-# Use this tag to change the font size of Latex formulas included 
-# as images in the HTML documentation. The default is 10. Note that 
-# when you change the font size after a successful doxygen run you need 
-# to manually remove any form_*.png images from the HTML output directory 
-# to force them to be regenerated.
+# Use this tag to change the font size of LaTeX formulas included as images in
+# the HTML documentation. When you change the font size after a successful
+# doxygen run you need to manually remove any form_*.png images from the HTML
+# output directory to force them to be regenerated.
+# Minimum value: 8, maximum value: 50, default value: 10.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 FORMULA_FONTSIZE       = 10
 
-# Use the FORMULA_TRANPARENT tag to determine whether or not the images 
-# generated for formulas are transparent PNGs. Transparent PNGs are 
-# not supported properly for IE 6.0, but are supported on all modern browsers. 
-# Note that when changing this option you need to delete any form_*.png files 
-# in the HTML output before the changes have effect.
+# Use the FORMULA_TRANPARENT tag to determine whether or not the images
+# generated for formulas are transparent PNGs. Transparent PNGs are not
+# supported properly for IE 6.0, but are supported on all modern browsers.
+#
+# Note that when changing this option you need to delete any form_*.png files in
+# the HTML output directory before the changes have effect.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 FORMULA_TRANSPARENT    = YES
 
-# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax 
-# (see http://www.mathjax.org) which uses client side Javascript for the 
-# rendering instead of using prerendered bitmaps. Use this if you do not 
-# have LaTeX installed or if you want to formulas look prettier in the HTML 
-# output. When enabled you may also need to install MathJax separately and 
-# configure the path to it using the MATHJAX_RELPATH option.
+# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
+# http://www.mathjax.org) which uses client side Javascript for the rendering
+# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
+# installed or if you want to formulas look prettier in the HTML output. When
+# enabled you may also need to install MathJax separately and configure the path
+# to it using the MATHJAX_RELPATH option.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 USE_MATHJAX            = NO
 
-# When MathJax is enabled you can set the default output format to be used for 
-# thA MathJax output. Supported types are HTML-CSS, NativeMML (i.e. MathML) and 
-# SVG. The default value is HTML-CSS, which is slower, but has the best 
-# compatibility.
+# When MathJax is enabled you can set the default output format to be used for
+# the MathJax output. See the MathJax site (see:
+# http://docs.mathjax.org/en/latest/output.html) for more details.
+# Possible values are: HTML-CSS (which is slower, but has the best
+# compatibility), NativeMML (i.e. MathML) and SVG.
+# The default value is: HTML-CSS.
+# This tag requires that the tag USE_MATHJAX is set to YES.
 
 MATHJAX_FORMAT         = HTML-CSS
 
-# When MathJax is enabled you need to specify the location relative to the 
-# HTML output directory using the MATHJAX_RELPATH option. The destination 
-# directory should contain the MathJax.js script. For instance, if the mathjax 
-# directory is located at the same level as the HTML output directory, then 
-# MATHJAX_RELPATH should be ../mathjax. The default value points to 
-# the MathJax Content Delivery Network so you can quickly see the result without 
-# installing MathJax.  However, it is strongly recommended to install a local 
-# copy of MathJax from http://www.mathjax.org before deployment.
+# When MathJax is enabled you need to specify the location relative to the HTML
+# output directory using the MATHJAX_RELPATH option. The destination directory
+# should contain the MathJax.js script. For instance, if the mathjax directory
+# is located at the same level as the HTML output directory, then
+# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
+# Content Delivery Network so you can quickly see the result without installing
+# MathJax. However, it is strongly recommended to install a local copy of
+# MathJax from http://www.mathjax.org before deployment.
+# The default value is: http://cdn.mathjax.org/mathjax/latest.
+# This tag requires that the tag USE_MATHJAX is set to YES.
 
 MATHJAX_RELPATH        = http://cdn.mathjax.org/mathjax/latest
 
-# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension 
-# names that should be enabled during MathJax rendering.
+# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax
+# extension names that should be enabled during MathJax rendering. For example
+# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols
+# This tag requires that the tag USE_MATHJAX is set to YES.
 
 MATHJAX_EXTENSIONS     = 
 
-# When the SEARCHENGINE tag is enabled doxygen will generate a search box 
-# for the HTML output. The underlying search engine uses javascript 
-# and DHTML and should work on any modern browser. Note that when using 
-# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets 
-# (GENERATE_DOCSET) there is already a search function so this one should 
-# typically be disabled. For large projects the javascript based search engine 
-# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
+# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces
+# of code that will be used on startup of the MathJax code. See the MathJax site
+# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an
+# example see the documentation.
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_CODEFILE       = 
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box for
+# the HTML output. The underlying search engine uses javascript and DHTML and
+# should work on any modern browser. Note that when using HTML help
+# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET)
+# there is already a search function so this one should typically be disabled.
+# For large projects the javascript based search engine can be slow, then
+# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to
+# search using the keyboard; to jump to the search box use <access key> + S
+# (what the <access key> is depends on the OS and browser, but it is typically
+# <CTRL>, <ALT>/<option>, or both). Inside the search box use the <cursor down
+# key> to jump into the search results window, the results can be navigated
+# using the <cursor keys>. Press <Enter> to select an item or <escape> to cancel
+# the search. The filter options can be selected when the cursor is inside the
+# search box by pressing <Shift>+<cursor down>. Also here use the <cursor keys>
+# to select a filter and <Enter> or <escape> to activate or cancel the filter
+# option.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
 
 SEARCHENGINE           = YES
 
-# When the SERVER_BASED_SEARCH tag is enabled the search engine will be 
-# implemented using a web server instead of a web client using Javascript. 
-# There are two flavours of web server based search depending on the 
-# EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for 
-# searching and an index file used by the script. When EXTERNAL_SEARCH is 
-# enabled the indexing and searching needs to be provided by external tools. 
-# See the manual for details.
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
+# implemented using a web server instead of a web client using Javascript. There
+# are two flavors of web server based searching depending on the EXTERNAL_SEARCH
+# setting. When disabled, doxygen will generate a PHP script for searching and
+# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing
+# and searching needs to be provided by external tools. See the section
+# "External Indexing and Searching" for details.
+# The default value is: NO.
+# This tag requires that the tag SEARCHENGINE is set to YES.
 
 SERVER_BASED_SEARCH    = NO
 
-# When EXTERNAL_SEARCH is enabled doxygen will no longer generate the PHP 
-# script for searching. Instead the search results are written to an XML file 
-# which needs to be processed by an external indexer. Doxygen will invoke an 
-# external search engine pointed to by the SEARCHENGINE_URL option to obtain 
-# the search results. Doxygen ships with an example indexer (doxyindexer) and 
-# search engine (doxysearch.cgi) which are based on the open source search engine 
-# library Xapian. See the manual for configuration details.
+# When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP
+# script for searching. Instead the search results are written to an XML file
+# which needs to be processed by an external indexer. Doxygen will invoke an
+# external search engine pointed to by the SEARCHENGINE_URL option to obtain the
+# search results.
+#
+# Doxygen ships with an example indexer (doxyindexer) and search engine
+# (doxysearch.cgi) which are based on the open source search engine library
+# Xapian (see: http://xapian.org/).
+#
+# See the section "External Indexing and Searching" for details.
+# The default value is: NO.
+# This tag requires that the tag SEARCHENGINE is set to YES.
 
 EXTERNAL_SEARCH        = NO
 
-# The SEARCHENGINE_URL should point to a search engine hosted by a web server 
-# which will returned the search results when EXTERNAL_SEARCH is enabled. 
-# Doxygen ships with an example search engine (doxysearch) which is based on 
-# the open source search engine library Xapian. See the manual for configuration 
-# details.
+# The SEARCHENGINE_URL should point to a search engine hosted by a web server
+# which will return the search results when EXTERNAL_SEARCH is enabled.
+#
+# Doxygen ships with an example indexer (doxyindexer) and search engine
+# (doxysearch.cgi) which are based on the open source search engine library
+# Xapian (see: http://xapian.org/). See the section "External Indexing and
+# Searching" for details.
+# This tag requires that the tag SEARCHENGINE is set to YES.
 
 SEARCHENGINE_URL       = 
 
-# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed 
-# search data is written to a file for indexing by an external tool. With the 
+# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed
+# search data is written to a file for indexing by an external tool. With the
 # SEARCHDATA_FILE tag the name of this file can be specified.
+# The default file is: searchdata.xml.
+# This tag requires that the tag SEARCHENGINE is set to YES.
 
 SEARCHDATA_FILE        = searchdata.xml
 
-# When SERVER_BASED_SEARCH AND EXTERNAL_SEARCH are both enabled the 
-# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is 
-# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple 
+# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the
+# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is
+# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple
 # projects and redirect the results back to the right project.
+# This tag requires that the tag SEARCHENGINE is set to YES.
 
 EXTERNAL_SEARCH_ID     = 
 
-# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen 
-# projects other than the one defined by this configuration file, but that are 
-# all added to the same external search index. Each project needs to have a 
-# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id 
-# of to a relative location where the documentation can be found. 
-# The format is: EXTRA_SEARCH_MAPPINGS = id1=loc1 id2=loc2 ...
+# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen
+# projects other than the one defined by this configuration file, but that are
+# all added to the same external search index. Each project needs to have a
+# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id of
+# to a relative location where the documentation can be found. The format is:
+# EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ...
+# This tag requires that the tag SEARCHENGINE is set to YES.
 
 EXTRA_SEARCH_MAPPINGS  = 
 
 #---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
+# Configuration options related to the LaTeX output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
-# generate Latex output.
+# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output.
+# The default value is: YES.
 
 GENERATE_LATEX         = NO
 
-# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
-# put in front of it. If left blank `latex' will be used as the default path.
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: latex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
 
 LATEX_OUTPUT           = latex
 
-# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 
-# invoked. If left blank `latex' will be used as the default command name. 
-# Note that when enabling USE_PDFLATEX this option is only used for 
-# generating bitmaps for formulas in the HTML output, but not in the 
-# Makefile that is written to the output directory.
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked.
+#
+# Note that when enabling USE_PDFLATEX this option is only used for generating
+# bitmaps for formulas in the HTML output, but not in the Makefile that is
+# written to the output directory.
+# The default file is: latex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
 
 LATEX_CMD_NAME         = latex
 
-# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 
-# generate index for LaTeX. If left blank `makeindex' will be used as the 
-# default command name.
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate
+# index for LaTeX.
+# The default file is: makeindex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
 
 MAKEINDEX_CMD_NAME     = makeindex
 
-# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 
-# LaTeX documents. This may be useful for small projects and may help to 
-# save some trees in general.
+# If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX
+# documents. This may be useful for small projects and may help to save some
+# trees in general.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
 
 COMPACT_LATEX          = NO
 
-# The PAPER_TYPE tag can be used to set the paper type that is used 
-# by the printer. Possible values are: a4, letter, legal and 
-# executive. If left blank a4wide will be used.
+# The PAPER_TYPE tag can be used to set the paper type that is used by the
+# printer.
+# Possible values are: a4 (210 x 297 mm), letter (8.5 x 11 inches), legal (8.5 x
+# 14 inches) and executive (7.25 x 10.5 inches).
+# The default value is: a4.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
 
 PAPER_TYPE             = a4wide
 
-# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 
-# packages that should be included in the LaTeX output.
+# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names
+# that should be included in the LaTeX output. The package can be specified just
+# by its name or with the correct syntax as to be used with the LaTeX
+# \usepackage command. To get the times font for instance you can specify :
+# EXTRA_PACKAGES=times or EXTRA_PACKAGES={times}
+# To use the option intlimits with the amsmath package you can specify:
+# EXTRA_PACKAGES=[intlimits]{amsmath}
+# If left blank no extra packages will be included.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
 
 EXTRA_PACKAGES         = amsmath
 
-# The LATEX_HEADER tag can be used to specify a personal LaTeX header for 
-# the generated latex document. The header should contain everything until 
-# the first chapter. If it is left blank doxygen will generate a 
-# standard header. Notice: only use this tag if you know what you are doing!
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the
+# generated LaTeX document. The header should contain everything until the first
+# chapter. If it is left blank doxygen will generate a standard header. See
+# section "Doxygen usage" for information on how to let doxygen write the
+# default header to a separate file.
+#
+# Note: Only use a user-defined header if you know what you are doing! The
+# following commands have a special meaning inside the header: $title,
+# $datetime, $date, $doxygenversion, $projectname, $projectnumber,
+# $projectbrief, $projectlogo. Doxygen will replace $title with the empty
+# string, for the replacement values of the other commands the user is referred
+# to HTML_HEADER.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
 
 LATEX_HEADER           = 
 
-# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for 
-# the generated latex document. The footer should contain everything after 
-# the last chapter. If it is left blank doxygen will generate a 
-# standard footer. Notice: only use this tag if you know what you are doing!
+# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the
+# generated LaTeX document. The footer should contain everything after the last
+# chapter. If it is left blank doxygen will generate a standard footer. See
+# LATEX_HEADER for more information on how to generate a default footer and what
+# special commands can be used inside the footer.
+#
+# Note: Only use a user-defined footer if you know what you are doing!
+# This tag requires that the tag GENERATE_LATEX is set to YES.
 
 LATEX_FOOTER           = 
 
-# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images 
-# or other source files which should be copied to the LaTeX output directory. 
-# Note that the files will be copied as-is; there are no commands or markers 
-# available.
+# The LATEX_EXTRA_STYLESHEET tag can be used to specify additional user-defined
+# LaTeX style sheets that are included after the standard style sheets created
+# by doxygen. Using this option one can overrule certain style aspects. Doxygen
+# will copy the style sheet files to the output directory.
+# Note: The order of the extra style sheet files is of importance (e.g. the last
+# style sheet in the list overrules the setting of the previous ones in the
+# list).
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_EXTRA_STYLESHEET = 
+
+# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the LATEX_OUTPUT output
+# directory. Note that the files will be copied as-is; there are no commands or
+# markers available.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
 
 LATEX_EXTRA_FILES      = 
 
-# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 
-# is prepared for conversion to pdf (using ps2pdf). The pdf file will 
-# contain links (just like the HTML output) instead of page references 
-# This makes the output suitable for online browsing using a pdf viewer.
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is
+# prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will
+# contain links (just like the HTML output) instead of page references. This
+# makes the output suitable for online browsing using a PDF viewer.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
 
 PDF_HYPERLINKS         = NO
 
-# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
-# plain latex in the generated Makefile. Set this option to YES to get a 
+# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate
+# the PDF file directly from the LaTeX files. Set this option to YES, to get a
 # higher quality PDF documentation.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
 
 USE_PDFLATEX           = YES
 
-# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
-# command to the generated LaTeX files. This will instruct LaTeX to keep 
-# running if errors occur, instead of asking the user for help. 
-# This option is also used when generating formulas in HTML.
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode
+# command to the generated LaTeX files. This will instruct LaTeX to keep running
+# if errors occur, instead of asking the user for help. This option is also used
+# when generating formulas in HTML.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
 
 LATEX_BATCHMODE        = NO
 
-# If LATEX_HIDE_INDICES is set to YES then doxygen will not 
-# include the index chapters (such as File Index, Compound Index, etc.) 
-# in the output.
+# If the LATEX_HIDE_INDICES tag is set to YES then doxygen will not include the
+# index chapters (such as File Index, Compound Index, etc.) in the output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
 
 LATEX_HIDE_INDICES     = NO
 
-# If LATEX_SOURCE_CODE is set to YES then doxygen will include 
-# source code with syntax highlighting in the LaTeX output. 
-# Note that which sources are shown also depends on other settings 
-# such as SOURCE_BROWSER.
+# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source
+# code with syntax highlighting in the LaTeX output.
+#
+# Note that which sources are shown also depends on other settings such as
+# SOURCE_BROWSER.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
 
 LATEX_SOURCE_CODE      = NO
 
-# The LATEX_BIB_STYLE tag can be used to specify the style to use for the 
-# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See 
-# http://en.wikipedia.org/wiki/BibTeX for more info.
+# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
+# bibliography, e.g. plainnat, or ieeetr. See
+# http://en.wikipedia.org/wiki/BibTeX and \cite for more info.
+# The default value is: plain.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
 
 LATEX_BIB_STYLE        = plain
 
+# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated
+# page will contain the date and time when the page was generated. Setting this
+# to NO can help when comparing the output of multiple runs.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_TIMESTAMP        = NO
+
 #---------------------------------------------------------------------------
-# configuration options related to the RTF output
+# Configuration options related to the RTF output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 
-# The RTF output is optimized for Word 97 and may not look very pretty with 
-# other RTF readers or editors.
+# If the GENERATE_RTF tag is set to YES, doxygen will generate RTF output. The
+# RTF output is optimized for Word 97 and may not look too pretty with other RTF
+# readers/editors.
+# The default value is: NO.
 
 GENERATE_RTF           = NO
 
-# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
-# put in front of it. If left blank `rtf' will be used as the default path.
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: rtf.
+# This tag requires that the tag GENERATE_RTF is set to YES.
 
 RTF_OUTPUT             = rtf
 
-# If the COMPACT_RTF tag is set to YES Doxygen generates more compact 
-# RTF documents. This may be useful for small projects and may help to 
-# save some trees in general.
+# If the COMPACT_RTF tag is set to YES, doxygen generates more compact RTF
+# documents. This may be useful for small projects and may help to save some
+# trees in general.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
 
 COMPACT_RTF            = NO
 
-# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
-# will contain hyperlink fields. The RTF file will 
-# contain links (just like the HTML output) instead of page references. 
-# This makes the output suitable for online browsing using WORD or other 
-# programs which support those fields. 
-# Note: wordpad (write) and others do not support links.
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated will
+# contain hyperlink fields. The RTF file will contain links (just like the HTML
+# output) instead of page references. This makes the output suitable for online
+# browsing using Word or some other Word compatible readers that support those
+# fields.
+#
+# Note: WordPad (write) and others do not support links.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
 
 RTF_HYPERLINKS         = NO
 
-# Load style sheet definitions from file. Syntax is similar to doxygen's 
-# config file, i.e. a series of assignments. You only have to provide 
-# replacements, missing definitions are set to their default value.
+# Load stylesheet definitions from file. Syntax is similar to doxygen's config
+# file, i.e. a series of assignments. You only have to provide replacements,
+# missing definitions are set to their default value.
+#
+# See also section "Doxygen usage" for information on how to generate the
+# default style sheet that doxygen normally uses.
+# This tag requires that the tag GENERATE_RTF is set to YES.
 
 RTF_STYLESHEET_FILE    = 
 
-# Set optional variables used in the generation of an rtf document. 
-# Syntax is similar to doxygen's config file.
+# Set optional variables used in the generation of an RTF document. Syntax is
+# similar to doxygen's config file. A template extensions file can be generated
+# using doxygen -e rtf extensionFile.
+# This tag requires that the tag GENERATE_RTF is set to YES.
 
 RTF_EXTENSIONS_FILE    = 
 
+# If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code
+# with syntax highlighting in the RTF output.
+#
+# Note that which sources are shown also depends on other settings such as
+# SOURCE_BROWSER.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_SOURCE_CODE        = NO
+
 #---------------------------------------------------------------------------
-# configuration options related to the man page output
+# Configuration options related to the man page output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
-# generate man pages
+# If the GENERATE_MAN tag is set to YES, doxygen will generate man pages for
+# classes and files.
+# The default value is: NO.
 
 GENERATE_MAN           = NO
 
-# The MAN_OUTPUT tag is used to specify where the man pages will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
-# put in front of it. If left blank `man' will be used as the default path.
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it. A directory man3 will be created inside the directory specified by
+# MAN_OUTPUT.
+# The default directory is: man.
+# This tag requires that the tag GENERATE_MAN is set to YES.
 
 MAN_OUTPUT             = man
 
-# The MAN_EXTENSION tag determines the extension that is added to 
-# the generated man pages (default is the subroutine's section .3)
+# The MAN_EXTENSION tag determines the extension that is added to the generated
+# man pages. In case the manual section does not start with a number, the number
+# 3 is prepended. The dot (.) at the beginning of the MAN_EXTENSION tag is
+# optional.
+# The default value is: .3.
+# This tag requires that the tag GENERATE_MAN is set to YES.
 
 MAN_EXTENSION          = .3
 
-# If the MAN_LINKS tag is set to YES and Doxygen generates man output, 
-# then it will generate one additional man file for each entity 
-# documented in the real man page(s). These additional files 
-# only source the real man page, but without them the man command 
-# would be unable to find the correct page. The default is NO.
+# The MAN_SUBDIR tag determines the name of the directory created within
+# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by
+# MAN_EXTENSION with the initial . removed.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_SUBDIR             = 
+
+# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it
+# will generate one additional man file for each entity documented in the real
+# man page(s). These additional files only source the real man page, but without
+# them the man command would be unable to find the correct page.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_MAN is set to YES.
 
 MAN_LINKS              = NO
 
 #---------------------------------------------------------------------------
-# configuration options related to the XML output
+# Configuration options related to the XML output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_XML tag is set to YES Doxygen will 
-# generate an XML file that captures the structure of 
-# the code including all documentation.
+# If the GENERATE_XML tag is set to YES, doxygen will generate an XML file that
+# captures the structure of the code including all documentation.
+# The default value is: NO.
 
 GENERATE_XML           = NO
 
-# The XML_OUTPUT tag is used to specify where the XML pages will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
-# put in front of it. If left blank `xml' will be used as the default path.
+# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: xml.
+# This tag requires that the tag GENERATE_XML is set to YES.
 
 XML_OUTPUT             = xml
 
-# The XML_SCHEMA tag can be used to specify an XML schema, 
-# which can be used by a validating XML parser to check the 
-# syntax of the XML files.
-
-XML_SCHEMA             = 
-
-# The XML_DTD tag can be used to specify an XML DTD, 
-# which can be used by a validating XML parser to check the 
-# syntax of the XML files.
-
-XML_DTD                = 
-
-# If the XML_PROGRAMLISTING tag is set to YES Doxygen will 
-# dump the program listings (including syntax highlighting 
-# and cross-referencing information) to the XML output. Note that 
-# enabling this will significantly increase the size of the XML output.
+# If the XML_PROGRAMLISTING tag is set to YES, doxygen will dump the program
+# listings (including syntax highlighting and cross-referencing information) to
+# the XML output. Note that enabling this will significantly increase the size
+# of the XML output.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_XML is set to YES.
 
 XML_PROGRAMLISTING     = YES
 
 #---------------------------------------------------------------------------
-# configuration options related to the DOCBOOK output
+# Configuration options related to the DOCBOOK output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_DOCBOOK tag is set to YES Doxygen will generate DOCBOOK files 
+# If the GENERATE_DOCBOOK tag is set to YES, doxygen will generate Docbook files
 # that can be used to generate PDF.
+# The default value is: NO.
 
 GENERATE_DOCBOOK       = NO
 
-# The DOCBOOK_OUTPUT tag is used to specify where the DOCBOOK pages will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in 
-# front of it. If left blank docbook will be used as the default path.
+# The DOCBOOK_OUTPUT tag is used to specify where the Docbook pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in
+# front of it.
+# The default directory is: docbook.
+# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
 
 DOCBOOK_OUTPUT         = docbook
 
+# If the DOCBOOK_PROGRAMLISTING tag is set to YES, doxygen will include the
+# program listings (including syntax highlighting and cross-referencing
+# information) to the DOCBOOK output. Note that enabling this will significantly
+# increase the size of the DOCBOOK output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
+
+DOCBOOK_PROGRAMLISTING = NO
+
 #---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
+# Configuration options for the AutoGen Definitions output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 
-# generate an AutoGen Definitions (see autogen.sf.net) file 
-# that captures the structure of the code including all 
-# documentation. Note that this feature is still experimental 
-# and incomplete at the moment.
+# If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an
+# AutoGen Definitions (see http://autogen.sf.net) file that captures the
+# structure of the code including all documentation. Note that this feature is
+# still experimental and incomplete at the moment.
+# The default value is: NO.
 
 GENERATE_AUTOGEN_DEF   = NO
 
 #---------------------------------------------------------------------------
-# configuration options related to the Perl module output
+# Configuration options related to the Perl module output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_PERLMOD tag is set to YES Doxygen will 
-# generate a Perl module file that captures the structure of 
-# the code including all documentation. Note that this 
-# feature is still experimental and incomplete at the 
-# moment.
+# If the GENERATE_PERLMOD tag is set to YES, doxygen will generate a Perl module
+# file that captures the structure of the code including all documentation.
+#
+# Note that this feature is still experimental and incomplete at the moment.
+# The default value is: NO.
 
 GENERATE_PERLMOD       = NO
 
-# If the PERLMOD_LATEX tag is set to YES Doxygen will generate 
-# the necessary Makefile rules, Perl scripts and LaTeX code to be able 
-# to generate PDF and DVI output from the Perl module output.
+# If the PERLMOD_LATEX tag is set to YES, doxygen will generate the necessary
+# Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI
+# output from the Perl module output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
 
 PERLMOD_LATEX          = NO
 
-# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 
-# nicely formatted so it can be parsed by a human reader.  This is useful 
-# if you want to understand what is going on.  On the other hand, if this 
-# tag is set to NO the size of the Perl module output will be much smaller 
-# and Perl will parse it just the same.
+# If the PERLMOD_PRETTY tag is set to YES, the Perl module output will be nicely
+# formatted so it can be parsed by a human reader. This is useful if you want to
+# understand what is going on. On the other hand, if this tag is set to NO, the
+# size of the Perl module output will be much smaller and Perl will parse it
+# just the same.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
 
 PERLMOD_PRETTY         = YES
 
-# The names of the make variables in the generated doxyrules.make file 
-# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 
-# This is useful so different doxyrules.make files included by the same 
-# Makefile don't overwrite each other's variables.
+# The names of the make variables in the generated doxyrules.make file are
+# prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. This is useful
+# so different doxyrules.make files included by the same Makefile don't
+# overwrite each other's variables.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
 
 PERLMOD_MAKEVAR_PREFIX = 
 
@@ -1556,111 +1985,130 @@ PERLMOD_MAKEVAR_PREFIX =
 # Configuration options related to the preprocessor
 #---------------------------------------------------------------------------
 
-# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 
-# evaluate all C-preprocessor directives found in the sources and include 
-# files.
+# If the ENABLE_PREPROCESSING tag is set to YES, doxygen will evaluate all
+# C-preprocessor directives found in the sources and include files.
+# The default value is: YES.
 
 ENABLE_PREPROCESSING   = YES
 
-# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 
-# names in the source code. If set to NO (the default) only conditional 
-# compilation will be performed. Macro expansion can be done in a controlled 
-# way by setting EXPAND_ONLY_PREDEF to YES.
+# If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names
+# in the source code. If set to NO, only conditional compilation will be
+# performed. Macro expansion can be done in a controlled way by setting
+# EXPAND_ONLY_PREDEF to YES.
+# The default value is: NO.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
 
 MACRO_EXPANSION        = NO
 
-# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
-# then the macro expansion is limited to the macros specified with the 
-# PREDEFINED and EXPAND_AS_DEFINED tags.
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
+# the macro expansion is limited to the macros specified with the PREDEFINED and
+# EXPAND_AS_DEFINED tags.
+# The default value is: NO.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
 
 EXPAND_ONLY_PREDEF     = NO
 
-# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
-# pointed to by INCLUDE_PATH will be searched when a #include is found.
+# If the SEARCH_INCLUDES tag is set to YES, the include files in the
+# INCLUDE_PATH will be searched if a #include is found.
+# The default value is: YES.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
 
 SEARCH_INCLUDES        = YES
 
-# The INCLUDE_PATH tag can be used to specify one or more directories that 
-# contain include files that are not input files but should be processed by 
-# the preprocessor.
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by the
+# preprocessor.
+# This tag requires that the tag SEARCH_INCLUDES is set to YES.
 
 INCLUDE_PATH           = 
 
-# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
-# patterns (like *.h and *.hpp) to filter out the header-files in the 
-# directories. If left blank, the patterns specified with FILE_PATTERNS will 
-# be used.
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will be
+# used.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
 
 INCLUDE_FILE_PATTERNS  = 
 
-# The PREDEFINED tag can be used to specify one or more macro names that 
-# are defined before the preprocessor is started (similar to the -D option of 
-# gcc). The argument of the tag is a list of macros of the form: name 
-# or name=definition (no spaces). If the definition and the = are 
-# omitted =1 is assumed. To prevent a macro definition from being 
-# undefined via #undef or recursively expanded use the := operator 
-# instead of the = operator.
+# The PREDEFINED tag can be used to specify one or more macro names that are
+# defined before the preprocessor is started (similar to the -D option of e.g.
+# gcc). The argument of the tag is a list of macros of the form: name or
+# name=definition (no spaces). If the definition and the "=" are omitted, "=1"
+# is assumed. To prevent a macro definition from being undefined via #undef or
+# recursively expanded use the := operator instead of the = operator.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
 
 PREDEFINED             = 
 
-# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
-# this tag can be used to specify a list of macro names that should be expanded. 
-# The macro definition that is found in the sources will be used. 
-# Use the PREDEFINED tag if you want to use a different macro definition that 
-# overrules the definition found in the source code.
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
+# tag can be used to specify a list of macro names that should be expanded. The
+# macro definition that is found in the sources will be used. Use the PREDEFINED
+# tag if you want to use a different macro definition that overrules the
+# definition found in the source code.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
 
 EXPAND_AS_DEFINED      = 
 
-# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
-# doxygen's preprocessor will remove all references to function-like macros 
-# that are alone on a line, have an all uppercase name, and do not end with a 
-# semicolon, because these will confuse the parser if not removed.
+# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will
+# remove all references to function-like macros that are alone on a line, have
+# an all uppercase name, and do not end with a semicolon. Such function macros
+# are typically used for boiler-plate code, and will confuse the parser if not
+# removed.
+# The default value is: YES.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
 
 SKIP_FUNCTION_MACROS   = YES
 
 #---------------------------------------------------------------------------
-# Configuration::additions related to external references
+# Configuration options related to external references
 #---------------------------------------------------------------------------
 
-# The TAGFILES option can be used to specify one or more tagfiles. For each 
-# tag file the location of the external documentation should be added. The 
-# format of a tag file without this location is as follows: 
-#   TAGFILES = file1 file2 ... 
-# Adding location for the tag files is done as follows: 
-#   TAGFILES = file1=loc1 "file2 = loc2" ... 
-# where "loc1" and "loc2" can be relative or absolute paths 
-# or URLs. Note that each tag file must have a unique name (where the name does 
-# NOT include the path). If a tag file is not located in the directory in which 
-# doxygen is run, you must also specify the path to the tagfile here.
+# The TAGFILES tag can be used to specify one or more tag files. For each tag
+# file the location of the external documentation should be added. The format of
+# a tag file without this location is as follows:
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where loc1 and loc2 can be relative or absolute paths or URLs. See the
+# section "Linking to external documentation" for more information about the use
+# of tag files.
+# Note: Each tag file must have a unique name (where the name does NOT include
+# the path). If a tag file is not located in the directory in which doxygen is
+# run, you must also specify the path to the tagfile here.
 
 TAGFILES               = ../bpp-core/BppCore.tag=../../bpp-core/html \
                          ../bpp-seq/BppSeq.tag=../../bpp-seq/html
 
-# When a file name is specified after GENERATE_TAGFILE, doxygen will create 
-# a tag file that is based on the input files it reads.
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create a
+# tag file that is based on the input files it reads. See section "Linking to
+# external documentation" for more information about the usage of tag files.
 
 GENERATE_TAGFILE       = BppPhyl.tag
 
-# If the ALLEXTERNALS tag is set to YES all external classes will be listed 
-# in the class index. If set to NO only the inherited external classes 
-# will be listed.
+# If the ALLEXTERNALS tag is set to YES, all external class will be listed in
+# the class index. If set to NO, only the inherited external classes will be
+# listed.
+# The default value is: NO.
 
 ALLEXTERNALS           = NO
 
-# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 
-# in the modules index. If set to NO, only the current project's groups will 
-# be listed.
+# If the EXTERNAL_GROUPS tag is set to YES, all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will be
+# listed.
+# The default value is: YES.
 
 EXTERNAL_GROUPS        = YES
 
-# If the EXTERNAL_PAGES tag is set to YES all external pages will be listed 
-# in the related pages index. If set to NO, only the current project's 
-# pages will be listed.
+# If the EXTERNAL_PAGES tag is set to YES, all external pages will be listed in
+# the related pages index. If set to NO, only the current project's pages will
+# be listed.
+# The default value is: YES.
 
 EXTERNAL_PAGES         = YES
 
-# The PERL_PATH should be the absolute path and name of the perl script 
-# interpreter (i.e. the result of `which perl').
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of 'which perl').
+# The default file (with absolute path) is: /usr/bin/perl.
 
 PERL_PATH              = /usr/bin/perl
 
@@ -1668,222 +2116,314 @@ PERL_PATH              = /usr/bin/perl
 # Configuration options related to the dot tool
 #---------------------------------------------------------------------------
 
-# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
-# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base 
-# or super classes. Setting the tag to NO turns the diagrams off. Note that 
-# this option also works with HAVE_DOT disabled, but it is recommended to 
-# install and use dot, since it yields more powerful graphs.
+# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram
+# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to
+# NO turns the diagrams off. Note that this option also works with HAVE_DOT
+# disabled, but it is recommended to install and use dot, since it yields more
+# powerful graphs.
+# The default value is: YES.
 
 CLASS_DIAGRAMS         = YES
 
-# You can define message sequence charts within doxygen comments using the \msc 
-# command. Doxygen will then run the mscgen tool (see 
-# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the 
-# documentation. The MSCGEN_PATH tag allows you to specify the directory where 
-# the mscgen tool resides. If left empty the tool is assumed to be found in the 
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see:
+# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
 # default search path.
 
 MSCGEN_PATH            = 
 
-# If set to YES, the inheritance and collaboration graphs will hide 
-# inheritance and usage relations if the target is undocumented 
-# or is not a class.
+# You can include diagrams made with dia in doxygen documentation. Doxygen will
+# then run dia to produce the diagram and insert it in the documentation. The
+# DIA_PATH tag allows you to specify the directory where the dia binary resides.
+# If left empty dia is assumed to be found in the default search path.
+
+DIA_PATH               = 
+
+# If set to YES the inheritance and collaboration graphs will hide inheritance
+# and usage relations if the target is undocumented or is not a class.
+# The default value is: YES.
 
 HIDE_UNDOC_RELATIONS   = YES
 
-# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 
-# available from the path. This tool is part of Graphviz, a graph visualization 
-# toolkit from AT&T and Lucent Bell Labs. The other options in this section 
-# have no effect if this option is set to NO (the default)
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz (see:
+# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent
+# Bell Labs. The other options in this section have no effect if this option is
+# set to NO
+# The default value is: YES.
 
 HAVE_DOT               = YES
 
-# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is 
-# allowed to run in parallel. When set to 0 (the default) doxygen will 
-# base this on the number of processors available in the system. You can set it 
-# explicitly to a value larger than 0 to get control over the balance 
-# between CPU load and processing speed.
+# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
+# to run in parallel. When set to 0 doxygen will base this on the number of
+# processors available in the system. You can set it explicitly to a value
+# larger than 0 to get control over the balance between CPU load and processing
+# speed.
+# Minimum value: 0, maximum value: 32, default value: 0.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 DOT_NUM_THREADS        = 0
 
-# By default doxygen will use the Helvetica font for all dot files that 
-# doxygen generates. When you want a differently looking font you can specify 
-# the font name using DOT_FONTNAME. You need to make sure dot is able to find 
-# the font, which can be done by putting it in a standard location or by setting 
-# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the 
-# directory containing the font.
+# When you want a differently looking font in the dot files that doxygen
+# generates you can specify the font name using DOT_FONTNAME. You need to make
+# sure dot is able to find the font, which can be done by putting it in a
+# standard location or by setting the DOTFONTPATH environment variable or by
+# setting DOT_FONTPATH to the directory containing the font.
+# The default value is: Helvetica.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
-# DOT_FONTNAME           = FreeSans
+DOT_FONTNAME           = Helvetica
 
-# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. 
-# The default size is 10pt.
+# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of
+# dot graphs.
+# Minimum value: 4, maximum value: 24, default value: 10.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 DOT_FONTSIZE           = 10
 
-# By default doxygen will tell dot to use the Helvetica font. 
-# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to 
-# set the path where dot can find it.
+# By default doxygen will tell dot to use the default font as specified with
+# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set
+# the path where dot can find it using this tag.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 DOT_FONTPATH           = 
 
-# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 
-# will generate a graph for each documented class showing the direct and 
-# indirect inheritance relations. Setting this tag to YES will force the 
-# CLASS_DIAGRAMS tag to NO.
+# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for
+# each documented class showing the direct and indirect inheritance relations.
+# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 CLASS_GRAPH            = YES
 
-# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 
-# will generate a graph for each documented class showing the direct and 
-# indirect implementation dependencies (inheritance, containment, and 
-# class references variables) of the class with other documented classes.
+# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a
+# graph for each documented class showing the direct and indirect implementation
+# dependencies (inheritance, containment, and class references variables) of the
+# class with other documented classes.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 COLLABORATION_GRAPH    = YES
 
-# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen 
-# will generate a graph for groups, showing the direct groups dependencies
+# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for
+# groups, showing the direct groups dependencies.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 GROUP_GRAPHS           = YES
 
-# If the UML_LOOK tag is set to YES doxygen will generate inheritance and 
-# collaboration diagrams in a style similar to the OMG's Unified Modeling 
+# If the UML_LOOK tag is set to YES, doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
 # Language.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 UML_LOOK               = NO
 
-# If the UML_LOOK tag is enabled, the fields and methods are shown inside 
-# the class node. If there are many fields or methods and many nodes the 
-# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS 
-# threshold limits the number of items for each type to make the size more 
-# managable. Set this to 0 for no limit. Note that the threshold may be 
-# exceeded by 50% before the limit is enforced.
+# If the UML_LOOK tag is enabled, the fields and methods are shown inside the
+# class node. If there are many fields or methods and many nodes the graph may
+# become too big to be useful. The UML_LIMIT_NUM_FIELDS threshold limits the
+# number of items for each type to make the size more manageable. Set this to 0
+# for no limit. Note that the threshold may be exceeded by 50% before the limit
+# is enforced. So when you set the threshold to 10, up to 15 fields may appear,
+# but if the number exceeds 15, the total amount of fields shown is limited to
+# 10.
+# Minimum value: 0, maximum value: 100, default value: 10.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 UML_LIMIT_NUM_FIELDS   = 10
 
-# If set to YES, the inheritance and collaboration graphs will show the 
-# relations between templates and their instances.
+# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and
+# collaboration graphs will show the relations between templates and their
+# instances.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 TEMPLATE_RELATIONS     = YES
 
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 
-# tags are set to YES then doxygen will generate a graph for each documented 
-# file showing the direct and indirect include dependencies of the file with 
-# other documented files.
+# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to
+# YES then doxygen will generate a graph for each documented file showing the
+# direct and indirect include dependencies of the file with other documented
+# files.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 INCLUDE_GRAPH          = YES
 
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 
-# HAVE_DOT tags are set to YES then doxygen will generate a graph for each 
-# documented header file showing the documented files that directly or 
-# indirectly include this file.
+# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are
+# set to YES then doxygen will generate a graph for each documented file showing
+# the direct and indirect include dependencies of the file with other documented
+# files.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 INCLUDED_BY_GRAPH      = YES
 
-# If the CALL_GRAPH and HAVE_DOT options are set to YES then 
-# doxygen will generate a call dependency graph for every global function 
-# or class method. Note that enabling this option will significantly increase 
-# the time of a run. So in most cases it will be better to enable call graphs 
-# for selected functions only using the \callgraph command.
+# If the CALL_GRAPH tag is set to YES then doxygen will generate a call
+# dependency graph for every global function or class method.
+#
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable call graphs for selected
+# functions only using the \callgraph command. Disabling a call graph can be
+# accomplished by means of the command \hidecallgraph.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 CALL_GRAPH             = NO
 
-# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then 
-# doxygen will generate a caller dependency graph for every global function 
-# or class method. Note that enabling this option will significantly increase 
-# the time of a run. So in most cases it will be better to enable caller 
-# graphs for selected functions only using the \callergraph command.
+# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller
+# dependency graph for every global function or class method.
+#
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable caller graphs for selected
+# functions only using the \callergraph command. Disabling a caller graph can be
+# accomplished by means of the command \hidecallergraph.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 CALLER_GRAPH           = NO
 
-# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
-# will generate a graphical hierarchy of all classes instead of a textual one.
+# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical
+# hierarchy of all classes instead of a textual one.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 GRAPHICAL_HIERARCHY    = YES
 
-# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES 
-# then doxygen will show the dependencies a directory has on other directories 
-# in a graphical way. The dependency relations are determined by the #include 
-# relations between the files in the directories.
+# If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the
+# dependencies a directory has on other directories in a graphical way. The
+# dependency relations are determined by the #include relations between the
+# files in the directories.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 DIRECTORY_GRAPH        = YES
 
-# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 
-# generated by dot. Possible values are svg, png, jpg, or gif. 
-# If left blank png will be used. If you choose svg you need to set 
-# HTML_FILE_EXTENSION to xhtml in order to make the SVG files 
-# visible in IE 9+ (other browsers do not have this requirement).
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. For an explanation of the image formats see the section
+# output formats in the documentation of the dot tool (Graphviz (see:
+# http://www.graphviz.org/)).
+# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order
+# to make the SVG files visible in IE 9+ (other browsers do not have this
+# requirement).
+# Possible values are: png, png:cairo, png:cairo:cairo, png:cairo:gd, png:gd,
+# png:gd:gd, jpg, jpg:cairo, jpg:cairo:gd, jpg:gd, jpg:gd:gd, gif, gif:cairo,
+# gif:cairo:gd, gif:gd, gif:gd:gd, svg, png:gd, png:gd:gd, png:cairo,
+# png:cairo:gd, png:cairo:cairo, png:cairo:gdiplus, png:gdiplus and
+# png:gdiplus:gdiplus.
+# The default value is: png.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 DOT_IMAGE_FORMAT       = png
 
-# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to 
-# enable generation of interactive SVG images that allow zooming and panning. 
-# Note that this requires a modern browser other than Internet Explorer. 
-# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you 
-# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files 
-# visible. Older versions of IE do not have SVG support.
+# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
+# enable generation of interactive SVG images that allow zooming and panning.
+#
+# Note that this requires a modern browser other than Internet Explorer. Tested
+# and working are Firefox, Chrome, Safari, and Opera.
+# Note: For IE 9+ you need to set HTML_FILE_EXTENSION to xhtml in order to make
+# the SVG files visible. Older versions of IE do not have SVG support.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 INTERACTIVE_SVG        = NO
 
-# The tag DOT_PATH can be used to specify the path where the dot tool can be 
+# The DOT_PATH tag can be used to specify the path where the dot tool can be
 # found. If left blank, it is assumed the dot tool can be found in the path.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 DOT_PATH               = 
 
-# The DOTFILE_DIRS tag can be used to specify one or more directories that 
-# contain dot files that are included in the documentation (see the 
-# \dotfile command).
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the \dotfile
+# command).
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 DOTFILE_DIRS           = 
 
-# The MSCFILE_DIRS tag can be used to specify one or more directories that 
-# contain msc files that are included in the documentation (see the 
-# \mscfile command).
+# The MSCFILE_DIRS tag can be used to specify one or more directories that
+# contain msc files that are included in the documentation (see the \mscfile
+# command).
 
 MSCFILE_DIRS           = 
 
-# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of 
-# nodes that will be shown in the graph. If the number of nodes in a graph 
-# becomes larger than this value, doxygen will truncate the graph, which is 
-# visualized by representing a node as a red box. Note that doxygen if the 
-# number of direct children of the root node in a graph is already larger than 
-# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note 
-# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+# The DIAFILE_DIRS tag can be used to specify one or more directories that
+# contain dia files that are included in the documentation (see the \diafile
+# command).
+
+DIAFILE_DIRS           = 
+
+# When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the
+# path where java can find the plantuml.jar file. If left blank, it is assumed
+# PlantUML is not used or called during a preprocessing step. Doxygen will
+# generate a warning when it encounters a \startuml command in this case and
+# will not generate output for the diagram.
+
+PLANTUML_JAR_PATH      = 
+
+# When using plantuml, the specified paths are searched for files specified by
+# the !include statement in a plantuml block.
+
+PLANTUML_INCLUDE_PATH  = 
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes
+# that will be shown in the graph. If the number of nodes in a graph becomes
+# larger than this value, doxygen will truncate the graph, which is visualized
+# by representing a node as a red box. Note that doxygen if the number of direct
+# children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note that
+# the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+# Minimum value: 0, maximum value: 10000, default value: 50.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 DOT_GRAPH_MAX_NODES    = 100
 
-# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 
-# graphs generated by dot. A depth value of 3 means that only nodes reachable 
-# from the root by following a path via at most 3 edges will be shown. Nodes 
-# that lay further from the root node will be omitted. Note that setting this 
-# option to 1 or 2 may greatly reduce the computation time needed for large 
-# code bases. Also note that the size of a graph can be further restricted by 
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs
+# generated by dot. A depth value of 3 means that only nodes reachable from the
+# root by following a path via at most 3 edges will be shown. Nodes that lay
+# further from the root node will be omitted. Note that setting this option to 1
+# or 2 may greatly reduce the computation time needed for large code bases. Also
+# note that the size of a graph can be further restricted by
 # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+# Minimum value: 0, maximum value: 1000, default value: 0.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 MAX_DOT_GRAPH_DEPTH    = 0
 
-# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent 
-# background. This is disabled by default, because dot on Windows does not 
-# seem to support this out of the box. Warning: Depending on the platform used, 
-# enabling this option may lead to badly anti-aliased labels on the edges of 
-# a graph (i.e. they become hard to read).
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not seem
+# to support this out of the box.
+#
+# Warning: Depending on the platform used, enabling this option may lead to
+# badly anti-aliased labels on the edges of a graph (i.e. they become hard to
+# read).
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 DOT_TRANSPARENT        = NO
 
-# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output 
-# files in one run (i.e. multiple -o and -T options on the command line). This 
-# makes dot run faster, but since only newer versions of dot (>1.8.10) 
-# support this, this feature is disabled by default.
+# Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10) support
+# this, this feature is disabled by default.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 DOT_MULTI_TARGETS      = YES
 
-# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 
-# generate a legend page explaining the meaning of the various boxes and 
-# arrows in the dot generated graphs.
+# If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page
+# explaining the meaning of the various boxes and arrows in the dot generated
+# graphs.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 GENERATE_LEGEND        = YES
 
-# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 
-# remove the intermediate dot files that are used to generate 
-# the various graphs.
+# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot
+# files that are used to generate the various graphs.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
 
 DOT_CLEANUP            = YES
diff --git a/INSTALL.txt b/INSTALL.txt
index c8859da..8c499db 100644
--- a/INSTALL.txt
+++ b/INSTALL.txt
@@ -1,12 +1,23 @@
-This software needs cmake >= 2.6 to build.
+This software needs cmake >= 2.8.11 and a C++11 capable compiler to build
 
 After installing cmake, run it with the following command:
-cmake -DCMAKE_INSTALL_PREFIX=[where to install, for instance /usr/local or $HOME/.local] .
+$ cmake -DCMAKE_INSTALL_PREFIX=[where to install, for instance /usr/local or $HOME/.local] .
 
 If available, you can also use ccmake instead of cmake for a more user-friendly interface.
 
-Then compile and install the software with
-make install
+Then compile and install the software with:
+$ make install
 
 You may also consider installing and using the software checkinstall for easier system administration.
 
+If you install Bio++ in a non standard path (not /usr/), remember that:
+-> if you compile your project with CMake, give it the path with -DCMAKE_PREFIX_PATH=<path>
+-> if you compile with something else, give the path to the compiler (-I / -L options)
+-> if you use shared libraries, you must also tell programs where to find them at startup:
+  -> either by adding the path to LD_LIBRARY_PATH environment variable.
+  -> or by using RPATHs to hard code the path in the executable (generates NON PORTABLE executables !)
+    -> with CMake, see documentation in bpp-core/cmake/project-template
+    -> or see your compiler documentation ("-Wl,-rpath,<path>" for clang/gcc)
+    -> consider installing Bio++ with the "-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE" option
+
+Detailed documentation for using Bio++ with CMake are available in bpp-core/cmake/
diff --git a/bpp-phyl.spec b/bpp-phyl.spec
index c3ecea2..6383cd1 100644
--- a/bpp-phyl.spec
+++ b/bpp-phyl.spec
@@ -1,5 +1,5 @@
 %define _basename bpp-phyl
-%define _version 2.2.0
+%define _version 2.3.1
 %define _release 1
 %define _prefix /usr
 
@@ -17,11 +17,11 @@ Requires: bpp-core = %{_version}
 Requires: bpp-seq = %{_version}
 
 BuildRoot: %{_builddir}/%{_basename}-root
-BuildRequires: cmake >= 2.6.0
-BuildRequires: gcc-c++ >= 4.0.0
-BuildRequires: libbpp-core2 = %{_version}
+BuildRequires: cmake >= 2.8.11
+BuildRequires: gcc-c++ >= 4.7.0
+BuildRequires: libbpp-core3 = %{_version}
 BuildRequires: libbpp-core-devel = %{_version}
-BuildRequires: libbpp-seq9 = %{_version}
+BuildRequires: libbpp-seq11 = %{_version}
 BuildRequires: libbpp-seq-devel = %{_version}
 
 AutoReq: yes
@@ -31,11 +31,11 @@ AutoProv: yes
 This library contains utilitary and classes for phylogenetics and molecular evolution analysis.
 It is part of the Bio++ project.
 
-%package -n libbpp-phyl9
+%package -n libbpp-phyl11
 Summary: Bio++ Phylogenetics library
 Group: Development/Libraries/C and C++
 
-%description -n libbpp-phyl9
+%description -n libbpp-phyl11
 This library contains utilitary and classes for phylogenetics and molecular evolution analysis.
 It is part of the Bio++ project.
 
@@ -43,10 +43,10 @@ It is part of the Bio++ project.
 %package -n libbpp-phyl-devel
 Summary: Libraries, includes to develop applications with %{_basename}
 Group: Development/Libraries/C and C++
-Requires: libbpp-phyl9 = %{_version}
-Requires: libbpp-seq9 = %{_version}
+Requires: libbpp-phyl11 = %{_version}
+Requires: libbpp-seq11 = %{_version}
 Requires: libbpp-seq-devel = %{_version}
-Requires: libbpp-core2 = %{_version}
+Requires: libbpp-core3 = %{_version}
 Requires: libbpp-core-devel = %{_version}
 
 %description -n libbpp-phyl-devel
@@ -59,9 +59,6 @@ building applications which use %{_basename}.
 %build
 CFLAGS="$RPM_OPT_FLAGS"
 CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=%{_prefix} -DBUILD_TESTING=OFF"
-if [ %{_lib} == 'lib64' ] ; then
-  CMAKE_FLAGS="$CMAKE_FLAGS -DLIB_SUFFIX=64"
-fi
 cmake $CMAKE_FLAGS .
 make
 
@@ -71,103 +68,11 @@ make DESTDIR=$RPM_BUILD_ROOT install
 %clean
 rm -rf $RPM_BUILD_ROOT
 
-%post -n libbpp-phyl9 -p /sbin/ldconfig
-
-%post -n libbpp-phyl-devel
-createGeneric() {
-  echo "-- Creating generic include file: $1.all"
-  #Make sure we run into subdirectories first:
-  dirs=()
-  for file in "$1"/*
-  do
-    if [ -d "$file" ]
-    then
-      # Recursion:
-      dirs+=( "$file" )
-    fi
-  done
-  for dir in ${dirs[@]}
-  do
-    createGeneric $dir
-  done
-  #Now list all files, including newly created .all files:
-  if [ -f $1.all ]
-  then
-    rm $1.all
-  fi
-  dir=`basename $1`
-  for file in "$1"/*
-  do
-    if [ -f "$file" ] && ( [ "${file##*.}" == "h" ] || [ "${file##*.}" == "all" ] )
-    then
-      file=`basename $file`
-      echo "#include \"$dir/$file\"" >> $1.all
-    fi
-  done;
-}
-# Actualize .all files
-createGeneric %{_prefix}/include/Bpp
-exit 0
-
-%preun -n libbpp-phyl-devel
-removeGeneric() {
-  if [ -f $1.all ]
-  then
-    echo "-- Remove generic include file: $1.all"
-    rm $1.all
-  fi
-  for file in "$1"/*
-  do
-    if [ -d "$file" ]
-    then
-      # Recursion:
-      removeGeneric $file
-    fi
-  done
-}
-# Actualize .all files
-removeGeneric %{_prefix}/include/Bpp
-exit 0
-
-%postun -n libbpp-phyl9 -p /sbin/ldconfig
-
-%postun -n libbpp-phyl-devel
-createGeneric() {
-  echo "-- Creating generic include file: $1.all"
-  #Make sure we run into subdirectories first:
-  dirs=()
-  for file in "$1"/*
-  do
-    if [ -d "$file" ]
-    then
-      # Recursion:
-      dirs+=( "$file" )
-    fi
-  done
-  for dir in ${dirs[@]}
-  do
-    createGeneric $dir
-  done
-  #Now list all files, including newly created .all files:
-  if [ -f $1.all ]
-  then
-    rm $1.all
-  fi
-  dir=`basename $1`
-  for file in "$1"/*
-  do
-    if [ -f "$file" ] && ( [ "${file##*.}" == "h" ] || [ "${file##*.}" == "all" ] )
-    then
-      file=`basename $file`
-      echo "#include \"$dir/$file\"" >> $1.all
-    fi
-  done;
-}
-# Actualize .all files
-createGeneric %{_prefix}/include/Bpp
-exit 0
-
-%files -n libbpp-phyl9
+%post -n libbpp-phyl11 -p /sbin/ldconfig
+
+%postun -n libbpp-phyl11 -p /sbin/ldconfig
+
+%files -n libbpp-phyl11
 %defattr(-,root,root)
 %doc AUTHORS.txt COPYING.txt INSTALL.txt ChangeLog
 %{_prefix}/%{_lib}/lib*.so.*
@@ -175,11 +80,19 @@ exit 0
 %files -n libbpp-phyl-devel
 %defattr(-,root,root)
 %doc AUTHORS.txt COPYING.txt INSTALL.txt ChangeLog
+%dir %{_prefix}/%{_lib}/cmake/
+%dir %{_prefix}/%{_lib}/cmake/bpp-phyl
 %{_prefix}/%{_lib}/lib*.so
 %{_prefix}/%{_lib}/lib*.a
+%{_prefix}/%{_lib}/cmake/bpp-phyl/bpp-phyl*.cmake
 %{_prefix}/include/*
 
 %changelog
+* Tue Jun 06 2017 Julien Dutheil <julien.dutheil at univ-montp2.fr> 2.3.1-1
+- Increased interface number
+* Wed May 10 2017 Julien Dutheil <julien.dutheil at univ-montp2.fr> 2.3.0-1
+- Several bugs fixed and performance improvements
+- Upgrade to C++11
 * Mon Sep 28 2014 Julien Dutheil <julien.dutheil at univ-montp2.fr> 2.2.0-1
 - Bugs fixed + code improvements
 - More efficient DR likelihood derivatives.
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index b315098..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,85 +0,0 @@
-libbpp-phyl (2.2.0-1) unstable; urgency=low
-
-  * Bugs fixed + code improvements
-  * More efficient DR likelihood derivatives.
-
- -- Julien Dutheil <julien.dutheil at univ-montp2.fr>  Mon, 28 Sep 2014 14:00:00 +0100
-
-libbpp-phyl (2.1.0-1) unstable; urgency=low
-
-  * New RateDistribution classes
-  * New models for protein sequences (COaLA)
-  * Support for gaps in parsimony score
-  * Improved and extended support for BppO
-  * Several bugs fixed and warnings removed
-
- -- Julien Dutheil <julien.dutheil at univ-montp2.fr>  Thu, 07 Mar 2013 15:58:00 +0100
-
-libbpp-phyl (2.0.3-1) unstable; urgency=low
-
-  * Reorganized model hierarchy
-  * New pairwise models
-  * Several bugs fixed
-
- -- Julien Dutheil <julien.dutheil at univ-montp2.fr>  Thu, 09 Feb 2013 16:00:00 +0100
-
-libbpp-phyl (2.0.2-1) unstable; urgency=low
-
-  * RFP: Bio++ -- The Bio++ bioinformatics libraries. (Closes: #616373).
-  * Packages are now non-native.
-  * Exact substitution mapping with detailled counts.
-  * Backup system for ML estimation.
-
- -- Julien Dutheil <julien.dutheil at univ-montp2.fr>  Thu, 09 Jun 2011 11:00:00 +0100
-
-libbpp-phyl (2.0.1) unstable; urgency=low
-
-  * Fixed bug #27
-  * Improved tree drawing algorithms.
-
- -- Julien Dutheil <julien.dutheil at univ-montp2.fr>  Mon, 28 Feb 2011 09:00:00 +0100
-
-libbpp-phyl (2.0.0) unstable; urgency=low
-
-  * Better mixed models
-  * Extended substitution mapping framework
-  * More bug fixed, notably in simulation procedures
-  * Topology comparison tools (ELW)
-  * Improved graphic classes
-
- -- Julien Dutheil <julien.dutheil at univ-montp2.fr>  Mon, 07 Feb 2011 09:00:00 +0100
-
-libbpp-phyl (1.9.0) unstable; urgency=low
-
-  * Several bugs fixed and improvements, compilation with -Weffc++
-  * Codon models
-  * Improved non-homogeneous classes
-  * Improved tree drawing classes
-
- -- Julien Dutheil <julien.dutheil at univ-montp2.fr>  Thu, 25 Mar 2010 13:47:24 +0100
-
-libbpp-phyl (1.8.0) unstable; urgency=low
-
-  * Several buf fixed and improvements.
-  * New support for Nexus tree files.
-  * New syntax for model description using keyvals.
-
- -- Julien Dutheil <jdutheil at birc.au.dk>  Wed, 10 Jun 2009 11:28:58 +0100
-
-libbpp-phyl (1.7.0) unstable; urgency=low
-
-  * Several bug fixed and improvements...
-
- -- Julien Dutheil <jdutheil at birc.au.dk>  Thu, 11 Dec 2008 12:21:37 +0100
-
-libbpp-phyl (1.6.0) unstable; urgency=low
-
-  * New +F protein models + bugs fixed.
-
- -- Julien Dutheil <jdutheil at birc.au.dk>  Wed, 24 Sep 2008 14:07:26 +0200
-
-libbpp-phyl (1.5.1) unstable; urgency=low
-
-  * Initial Release.
-
- -- Julien Dutheil <jdutheil at birc.au.dk>  Mon, 21 Jul 2008 15:17:26 +0200
diff --git a/debian/compat b/debian/compat
deleted file mode 100644
index 7ed6ff8..0000000
--- a/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-5
diff --git a/debian/control b/debian/control
deleted file mode 100644
index 98880fb..0000000
--- a/debian/control
+++ /dev/null
@@ -1,25 +0,0 @@
-Source: libbpp-phyl
-Section: libs
-Priority: optional
-Maintainer: Loic Dachary <loic at dachary.org>
-Uploaders: Julien Dutheil <julien.dutheil at univ-montp2.fr>
-Build-Depends: debhelper (>= 5), cmake (>= 2.6),
-  libbpp-seq-dev (>= 2.2.0)
-Standards-Version: 3.9.4
-
-Package: libbpp-phyl-dev
-Section: libdevel
-Architecture: any
-Depends: libbpp-phyl9 (= ${binary:Version}), ${misc:Depends},
-  libbpp-seq-dev (>= 2.2.0)
-Description: Bio++ Phylogenetic library development files.
- Contains the Bio++ classes for phylogenetics.
-
-Package: libbpp-phyl9
-Section: libs
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends},
-  libbpp-seq9 (>= 2.2.0)
-Description: Bio++ Phylogenetic library.
- Contains the Bio++ classes for phylogenetics.
-
diff --git a/debian/copyright b/debian/copyright
deleted file mode 100644
index ced4d0e..0000000
--- a/debian/copyright
+++ /dev/null
@@ -1,66 +0,0 @@
-This package was debianized by Julien Dutheil <julien.dutheil at univ-montp2.fr> on
-Mon, 28 Sep 2014 14:00:00 +0100
-
-It was downloaded from <http://biopp.univ-montp2.fr/Repositories/sources>
-
-Upstream Author: 
-
-    Julien Dutheil <julien.dutheil at univ-montp2.fr>
-
-Copyright: 
-
-    Copyright (C) 2014 Bio++ Development Team
-
-License:
-
-    This package 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 package 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 package; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
-
-On Debian systems, the complete text of the GNU General
-Public License can be found in `/usr/share/common-licenses/GPL'.
-
-The Debian packaging is (C) 2014, Julien Dutheil <julien.dutheil at univ-montp2.fr> and
-is licensed under the GPL, see above.
-
-The provided software is distributed under the CeCILL license:
-
-    This software is governed by the CeCILL license under French law and
-    abiding by the rules of distribution of free software.  You can  use, 
-    modify and/ or redistribute the software under the terms of the CeCILL
-    license as circulated by CEA, CNRS and INRIA at the following URL
-    "http://www.cecill.info". 
-
-    As a counterpart to the access to the source code and  rights to copy,
-    modify and redistribute granted by the license, users are provided only
-    with a limited warranty  and the software's author,  the holder of the
-    economic rights,  and the successive licensors  have only  limited
-    liability. 
-
-    In this respect, the user's attention is drawn to the risks associated
-    with loading,  using,  modifying and/or developing or reproducing the
-    software by the user in light of its specific status of free software,
-    that may mean  that it is complicated to manipulate,  and  that  also
-    therefore means  that it is reserved for developers  and  experienced
-    professionals having in-depth computer knowledge. Users are therefore
-    encouraged to load and test the software's suitability as regards their
-    requirements in conditions enabling the security of their systems and/or 
-    data to be ensured and,  more generally, to use and operate it in the 
-    same conditions as regards security. 
-
-    The fact that you are presently reading this means that you have had
-    knowledge of the CeCILL license and that you accept its terms.
-    
-The complete text of the license may be found here:
-http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
-
diff --git a/debian/docs b/debian/docs
deleted file mode 100644
index e69de29..0000000
diff --git a/debian/libbpp-phyl-dev.install b/debian/libbpp-phyl-dev.install
deleted file mode 100644
index 7d74f2b..0000000
--- a/debian/libbpp-phyl-dev.install
+++ /dev/null
@@ -1,3 +0,0 @@
-debian/tmp/usr/include/*
-debian/tmp/usr/lib/lib*.a
-debian/tmp/usr/lib/lib*.so
diff --git a/debian/libbpp-phyl9.install b/debian/libbpp-phyl9.install
deleted file mode 100644
index c45ebcf..0000000
--- a/debian/libbpp-phyl9.install
+++ /dev/null
@@ -1 +0,0 @@
-debian/tmp/usr/lib/lib*.so.*
diff --git a/debian/postinst b/debian/postinst
deleted file mode 100755
index cff89b1..0000000
--- a/debian/postinst
+++ /dev/null
@@ -1,57 +0,0 @@
-#! /bin/bash
-
-# Abort if any command returns an error value
-set -e
-
-createGeneric() {
-  echo "-- Creating generic include file: $1.all"
-  #Make sure we run into subdirectories first:
-  dirs=()
-  for file in "$1"/*
-  do
-    if [ -d "$file" ]
-    then
-      # Recursion:
-      dirs+=( "$file" )
-    fi
-  done
-  for dir in ${dirs[@]}
-  do
-    createGeneric $dir
-  done
-  #Now list all files, including newly created .all files:
-  if [ -f $1.all ]
-  then
-    rm $1.all
-  fi
-  dir=`basename $1`
-  for file in "$1"/*
-  do
-    if [ -f "$file" ] && ( [ "${file##*.}" == "h" ] || [ "${file##*.}" == "all" ] )
-    then
-      file=`basename $file`
-      echo "#include \"$dir/$file\"" >> $1.all
-    fi
-  done;
-}
-
-case "$1" in
-  configure)
-    # Actualize .all files
-    createGeneric /usr/include/Bpp
-  ;;
-  abort-upgrade|abort-remove|abort-deconfigure)
-    echo "$1"
-  ;;
-  *)
-    echo "postinst called with unknown argument \`\$1'" >&2
-    exit 0
-  ;;
-esac
-
-# dh_installdeb will replace this with shell code automatically
-# generated by other debhelper scripts.
-
-#DEBHELPER#
-
-exit 0
diff --git a/debian/postrm b/debian/postrm
deleted file mode 100755
index 744f8b1..0000000
--- a/debian/postrm
+++ /dev/null
@@ -1,59 +0,0 @@
-#! /bin/bash
-
-# Abort if any command returns an error value
-set -e
-
-createGeneric() {
-  echo "-- Creating generic include file: $1.all"
-  #Make sure we run into subdirectories first:
-  dirs=()
-  for file in "$1"/*
-  do
-    if [ -d "$file" ]
-    then
-      # Recursion:
-      dirs+=( "$file" )
-    fi
-  done
-  for dir in ${dirs[@]}
-  do
-    createGeneric $dir
-  done
-  #Now list all files, including newly created .all files:
-  if [ -f $1.all ]
-  then
-    rm $1.all
-  fi
-  dir=`basename $1`
-  for file in "$1"/*
-  do
-    if [ -f "$file" ] && ( [ "${file##*.}" == "h" ] || [ "${file##*.}" == "all" ] )
-    then
-      file=`basename $file`
-      echo "#include \"$dir/$file\"" >> $1.all
-    fi
-  done;
-}
-
-case "$1" in
-  remove)
-    # Automatically added by dh_makeshlibs
-    ldconfig
-    # Actualize .all files
-    createGeneric /usr/include/Bpp
-  ;;
-  purge|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
-    echo $1
-  ;;
-  *)
-    echo "postrm called with unknown argument \`\$1'" >&2
-    exit 0
-  ;;
-esac
-
-# dh_installdeb will replace this with shell code automatically
-# generated by other debhelper scripts.
-
-#DEBHELPER#
-
-exit 0
diff --git a/debian/prerm b/debian/prerm
deleted file mode 100755
index 8fab52e..0000000
--- a/debian/prerm
+++ /dev/null
@@ -1,41 +0,0 @@
-#! /bin/bash
-
-# Abort if any command returns an error value
-set -e
-
-removeGeneric() {
-  if [ -f $1.all ]
-  then
-    echo "-- Remove generic include file: $1.all"
-    rm $1.all
-  fi
-  for file in "$1"/*
-  do
-    if [ -d "$file" ]
-    then
-      # Recursion:
-      removeGeneric $file
-    fi
-  done
-}
-
-case "$1" in
-  remove|upgrade|deconfigure)
-    # Actualize .all files
-    removeGeneric /usr/include/Bpp
-  ;;
-  failed-upgrade)
-    echo "$1"
-  ;;
-  *)
-    echo "prerm called with unknown argument \`$1'" >&2
-    exit 1
-  ;;
-esac
-
-# dh_installdeb will replace this with shell code automatically
-# generated by other debhelper scripts.
-
-#DEBHELPER#
-
-exit 0
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index 34313ef..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,122 +0,0 @@
-#!/usr/bin/make -f
-# -*- makefile -*-
-# Sample debian/rules that uses debhelper.
-# This file was originally written by Joey Hess and Craig Small.
-# As a special exception, when this file is copied by dh-make into a
-# dh-make output file, you may use that output file without restriction.
-# This special exception was added by Craig Small in version 0.37 of dh-make.
-
-# 24/01/10 Modification for use with CMake by Julien Dutheil.
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-
-# These are used for cross-compiling and for saving the configure script
-# from having to guess our platform (since we know it already)
-DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
-DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
-
-
-CFLAGS = -Wall -g
-
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
-	CFLAGS += -O0
-else
-	CFLAGS += -O2
-endif
-
-# shared library versions
-version=`ls src/lib*.so.* | \
- awk '{if (match($$0,/[0-9]+\.[0-9]+\.[0-9]+$$/)) print substr($$0,RSTART)}'`
-major=`ls src/lib*.so.* | \
- awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'`
-
-configure:
-	cmake -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_TESTING=OFF .
-
-config.status: configure
-	dh_testdir
-
-build: build-arch build-indep
-build-arch: build-stamp
-build-indep: build-stamp
-build-stamp:  config.status
-	dh_testdir
-
-	# Add here commands to compile the package.
-	$(MAKE)
-
-	touch $@
-
-clean:
-	dh_testdir
-	dh_testroot
-
-	# Add here commands to clean up after the build process.
-	[ ! -f Makefile ] || $(MAKE) clean;
-	[ ! -f Makefile ] || rm Makefile;
-	[ ! -f src/Makefile ] || rm src/Makefile;
-	[ ! -f test/Makefile ] || rm test/Makefile;
-	rm -f config.sub config.guess
-	rm -f build-stamp
-	rm -f CMakeCache.txt
-	rm -f *.cmake
-	rm -f src/*.cmake
-	rm -f test/*.cmake
-	rm -rf CMakeFiles
-	rm -rf src/CMakeFiles
-	rm -rf test/CMakeFiles
-	rm -rf _CPack_Packages
-	rm -rf Testing
-	rm -f DartConfiguration.tcl
-
-	dh_clean 
-
-install: build
-	dh_testdir
-	dh_testroot
-	dh_prep 
-	dh_installdirs
-
-	# Add here commands to install the package into debian/tmp
-	$(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
-
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
-	dh_testdir
-	dh_testroot
-	dh_installchangelogs ChangeLog
-	dh_installdocs
-	dh_installexamples
-	dh_install
-#	dh_installmenu
-#	dh_installdebconf	
-#	dh_installlogrotate
-#	dh_installemacsen
-#	dh_installpam
-#	dh_installmime
-#	dh_installinit
-#	dh_installcron
-#	dh_installinfo
-	dh_installman
-	dh_link
-	dh_strip
-	dh_compress
-	dh_fixperms
-#	dh_perl
-#	dh_python
-	dh_makeshlibs
-	dh_installdeb
-	dh_shlibdeps
-	dh_gencontrol
-	dh_md5sums
-	dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install 
diff --git a/debian/source/format b/debian/source/format
deleted file mode 100644
index 163aaf8..0000000
--- a/debian/source/format
+++ /dev/null
@@ -1 +0,0 @@
-3.0 (quilt)
diff --git a/genIncludes.sh b/genIncludes.sh
deleted file mode 100755
index 56710e9..0000000
--- a/genIncludes.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#! /bin/bash
-
-createGeneric() {
-  echo "-- Creating generic include file: $1.all"
-  #Make sure we run into subdirectories first:
-  dirs=()
-  for file in "$1"/*
-  do
-    if [ -d "$file" ]
-    then
-      # Recursion:
-      dirs+=( "$file" )
-    fi
-  done
-  for dir in ${dirs[@]}
-  do
-    createGeneric $dir
-  done
-  #Now list all files, including newly created .all files:
-  if [ -f $1.all ]
-  then
-    rm $1.all
-  fi
-  dir=`basename $1`
-  for file in "$1"/*
-  do
-    if [ -f "$file" ] && ( [ "${file##*.}" == "h" ] || [ "${file##*.}" == "all" ] )
-    then
-      file=`basename $file`
-      echo "#include \"$dir/$file\"" >> $1.all
-    fi
-  done;
-}
-
-createGeneric $1
diff --git a/package.cmake.in b/package.cmake.in
new file mode 100644
index 0000000..2c6a4a3
--- /dev/null
+++ b/package.cmake.in
@@ -0,0 +1,27 @@
+# CMake package file for Bio++ PhylLib
+# Authors:
+#   Francois Gindraud (2017)
+# Created: 08/03/2017
+ at PACKAGE_INIT@
+
+if (NOT @PROJECT_NAME at _FOUND)
+  # Deps
+  find_package (bpp-core @bpp-core_VERSION@ REQUIRED)
+  find_package (bpp-seq @bpp-seq_VERSION@ REQUIRED)
+  # Add targets
+  include ("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME at -targets.cmake")
+  # Append targets to convenient lists
+  set (BPP_LIBS_STATIC "${BPP_LIBS_STATIC}" @PROJECT_NAME at -static)
+  set (BPP_LIBS_SHARED "${BPP_LIBS_SHARED}" @PROJECT_NAME at -shared)
+  # Print some path info for targets
+  get_property (static-location TARGET @PROJECT_NAME at -static PROPERTY LOCATION)
+  get_property (shared-location TARGET @PROJECT_NAME at -shared PROPERTY LOCATION)
+  get_property (header-location TARGET @PROJECT_NAME at -static PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
+  message (STATUS "@PROJECT_NAME@ @PROJECT_VERSION@ found:")
+  message (STATUS "  static lib: ${static-location}")
+  message (STATUS "  shared lib: ${shared-location}")
+  message (STATUS "  includes: ${header-location}")
+  unset (static-location)
+  unset (shared-location)
+  unset (header-location)
+endif (NOT @PROJECT_NAME at _FOUND)
diff --git a/src/Bpp/Phyl/App/PhylogeneticsApplicationTools.cpp b/src/Bpp/Phyl/App/PhylogeneticsApplicationTools.cpp
index 096e8e8..f42aade 100644
--- a/src/Bpp/Phyl/App/PhylogeneticsApplicationTools.cpp
+++ b/src/Bpp/Phyl/App/PhylogeneticsApplicationTools.cpp
@@ -50,10 +50,12 @@
 #include "../Mapping/OneJumpSubstitutionCount.h"
 #include "../OptimizationTools.h"
 #include "../Tree.h"
-#include "../Io/Newick.h"
-#include "../Io/NexusIoTree.h"
-#include "../Io/Nhx.h"
+#include "../Io/BppOTreeReaderFormat.h"
+#include "../Io/BppOMultiTreeReaderFormat.h"
+#include "../Io/BppOTreeWriterFormat.h"
+#include "../Io/BppOMultiTreeWriterFormat.h"
 #include "../Io/BppOSubstitutionModelFormat.h"
+#include "../Io/BppOTransitionModelFormat.h"
 #include "../Io/BppOFrequenciesSetFormat.h"
 #include "../Io/BppORateDistributionFormat.h"
 
@@ -104,20 +106,14 @@ Tree* PhylogeneticsApplicationTools::getTree(
   string format = ApplicationTools::getStringParameter(prefix + "tree.format", params, "Newick", suffix, suffixIsOptional, warn);
   string treeFilePath = ApplicationTools::getAFilePath(prefix + "tree.file", params, true, true, suffix, suffixIsOptional, "none", warn);
 
-  ITree* treeReader;
-  if (format == "Newick")
-    treeReader = new Newick(true);
-  else if (format == "Nexus")
-    treeReader = new NexusIOTree();
-  else if (format == "NHX")
-    treeReader = new Nhx();
-  else
-    throw Exception("Unknow format for tree reading: " + format);
-  Tree* tree = treeReader->read(treeFilePath);
-  delete treeReader;
-
+  BppOTreeReaderFormat bppoReader(warn);
+  unique_ptr<ITree> iTree(bppoReader.read(format));
   if (verbose)
-    ApplicationTools::displayResult("Tree file", treeFilePath);
+  {
+    ApplicationTools::displayResult("Input tree file " + suffix, treeFilePath);
+    ApplicationTools::displayResult("Input tree format " + suffix, iTree->getFormatName());
+  }
+  Tree* tree = iTree->read(treeFilePath);
   return tree;
 }
 
@@ -134,22 +130,18 @@ vector<Tree*> PhylogeneticsApplicationTools::getTrees(
   string format = ApplicationTools::getStringParameter(prefix + "trees.format", params, "Newick", suffix, suffixIsOptional, warn);
   string treeFilePath = ApplicationTools::getAFilePath(prefix + "trees.file", params, true, true, suffix, suffixIsOptional, "none", warn);
 
-  IMultiTree* treeReader;
-  if (format == "Newick")
-    treeReader = new Newick(true);
-  else if (format == "Nexus")
-    treeReader = new NexusIOTree();
-  else if (format == "NHX")
-    treeReader = new Nhx();
-  else
-    throw Exception("Unknow format for tree reading: " + format);
+  BppOMultiTreeReaderFormat bppoReader(warn);
+  unique_ptr<IMultiTree> iTrees(bppoReader.read(format));
+  if (verbose)
+  {
+    ApplicationTools::displayResult("Input trees file " + suffix, treeFilePath);
+    ApplicationTools::displayResult("Input trees format " + suffix, iTrees->getFormatName());
+  }
   vector<Tree*> trees;
-  treeReader->read(treeFilePath, trees);
-  delete treeReader;
+  iTrees->read(treeFilePath, trees);
 
   if (verbose)
   {
-    ApplicationTools::displayResult("Tree file", treeFilePath);
     ApplicationTools::displayResult("Number of trees in file", trees.size());
   }
   return trees;
@@ -175,12 +167,14 @@ SubstitutionModel* PhylogeneticsApplicationTools::getSubstitutionModel(
   BppOSubstitutionModelFormat bIO(BppOSubstitutionModelFormat::ALL, true, true, true, verbose, warn + 1);
   string modelDescription;
   const CodonAlphabet* ca = dynamic_cast<const CodonAlphabet*>(alphabet);
-  if (ca) {
+  if (ca)
+  {
     modelDescription = ApplicationTools::getStringParameter("model", params, "CodonRate(model=JC69)", suffix, suffixIsOptional, warn);
     if (!gCode)
       throw Exception("PhylogeneticsApplicationTools::getSubstitutionModel(): a GeneticCode instance is required for instanciating a codon model.");
     bIO.setGeneticCode(gCode);
-  } else if (AlphabetTools::isWordAlphabet(alphabet))
+  }
+  else if (AlphabetTools::isWordAlphabet(alphabet))
     modelDescription = ApplicationTools::getStringParameter("model", params, "Word(model=JC69)", suffix, suffixIsOptional, warn);
   else
     modelDescription = ApplicationTools::getStringParameter("model", params, "JC69", suffix, suffixIsOptional, warn);
@@ -189,18 +183,46 @@ SubstitutionModel* PhylogeneticsApplicationTools::getSubstitutionModel(
   return model;
 }
 
+TransitionModel* PhylogeneticsApplicationTools::getTransitionModel(
+  const Alphabet* alphabet,
+  const GeneticCode* gCode,
+  const SiteContainer* data,
+  std::map<std::string, std::string>& params,
+  const string& suffix,
+  bool suffixIsOptional,
+  bool verbose,
+  int warn) throw (Exception)
+{
+  BppOTransitionModelFormat bIO(BppOSubstitutionModelFormat::ALL, true, true, true, verbose, warn + 1);
+  string modelDescription;
+  const CodonAlphabet* ca = dynamic_cast<const CodonAlphabet*>(alphabet);
+  if (ca)
+  {
+    modelDescription = ApplicationTools::getStringParameter("model", params, "CodonRate(model=JC69)", suffix, suffixIsOptional, warn);
+    if (!gCode)
+      throw Exception("PhylogeneticsApplicationTools::getSubstitutionModel(): a GeneticCode instance is required for instanciating a codon model.");
+    bIO.setGeneticCode(gCode);
+  }
+  else if (AlphabetTools::isWordAlphabet(alphabet))
+    modelDescription = ApplicationTools::getStringParameter("model", params, "Word(model=JC69)", suffix, suffixIsOptional, warn);
+  else
+    modelDescription = ApplicationTools::getStringParameter("model", params, "JC69", suffix, suffixIsOptional, warn);
+
+  TransitionModel* model = bIO.readTransitionModel(alphabet, modelDescription, data, true);
+  return model;
+}
+
 /******************************************************************************/
 
 void PhylogeneticsApplicationTools::setSubstitutionModelParametersInitialValuesWithAliases(
-  SubstitutionModel& model,
+  TransitionModel& model,
   std::map<std::string, std::string>& unparsedParameterValues,
   size_t modelNumber,
   const SiteContainer* data,
-  std::map<std::string, double>& existingParams,
   std::map<std::string, std::string>& sharedParams,
   bool verbose) throw (Exception)
 {
-  string initFreqs = ApplicationTools::getStringParameter(model.getNamespace() + "initFreqs", unparsedParameterValues, "", "", true, false);
+  string initFreqs = ApplicationTools::getStringParameter(model.getNamespace() + "initFreqs", unparsedParameterValues, "", "", true, 2);
 
   if (verbose)
     ApplicationTools::displayResult("Frequencies Initialization for model", (initFreqs == "") ? "None" : initFreqs);
@@ -231,7 +253,6 @@ void PhylogeneticsApplicationTools::setSubstitutionModelParametersInitialValuesW
   }
 
 
-  
   ParameterList pl = model.getIndependentParameters();
   for (size_t i = 0; i < pl.size(); ++i)
   {
@@ -248,31 +269,27 @@ void PhylogeneticsApplicationTools::setSubstitutionModelParametersInitialValuesW
     bool test1 = (initFreqs == "");
     bool test2 = (model.getParameterNameWithoutNamespace(pName).substr(posp + 1, 5) != "theta");
     bool test3 = (unparsedParameterValues.find(pName) != unparsedParameterValues.end());
+
     if (test1 || test2 || test3)
     {
       if (!test1 && !test2 && test3)
         ApplicationTools::displayWarning("Warning, initFreqs argument is set and a value is set for parameter " + pName);
+
       value = ApplicationTools::getStringParameter(pName, unparsedParameterValues, TextTools::toString(pl[i].getValue()));
-      if (value.rfind("_")!=string::npos)
+
+      try
       {
-        if (existingParams.find(value) != existingParams.end())
-          {
-            pl[i].setValue(existingParams[value]);
-            sharedParams[pl[i].getName()+"_"+TextTools::toString(modelNumber)]=value;
-          }
-        else
-          throw Exception("Error, unknown parameter " + value);
-      }
-      else
         pl[i].setValue(TextTools::toDouble(value));
+        if (verbose)
+          ApplicationTools::displayResult("Parameter found", pName + +"_" + TextTools::toString(modelNumber) + "=" + TextTools::toString(pl[i].getValue()));
+      }
+      catch (Exception& e)
+      {
+        sharedParams[pl[i].getName() + "_" + TextTools::toString(modelNumber)] = value;
+      }
     }
-
-    existingParams[pName+"_"+TextTools::toString(modelNumber)] = pl[i].getValue();
-    
-    if (verbose)
-      ApplicationTools::displayResult("Parameter found", pName + +"_"+TextTools::toString(modelNumber) + "=" + TextTools::toString(pl[i].getValue()));
   }
-  
+
   model.matchParametersValues(pl);
 }
 
@@ -288,6 +305,7 @@ FrequenciesSet* PhylogeneticsApplicationTools::getRootFrequenciesSet(
   const GeneticCode* gCode,
   const SiteContainer* data,
   std::map<std::string, std::string>& params,
+  std::map<std::string, std::string>& sharedparams,
   const std::vector<double>& rateFreqs,
   const std::string& suffix,
   bool suffixIsOptional,
@@ -301,7 +319,17 @@ FrequenciesSet* PhylogeneticsApplicationTools::getRootFrequenciesSet(
   }
   else
   {
-    FrequenciesSet* freq = getFrequenciesSet(alphabet, gCode, freqDescription, data, rateFreqs, verbose, warn + 1);
+    map<string, string> unparams;
+
+    FrequenciesSet* freq = getFrequenciesSet(alphabet, gCode, freqDescription, data, unparams, rateFreqs, verbose, warn + 1);
+    freq->setNamespace("root." + freq->getNamespace());
+
+    map<string, string>::iterator it;
+    for (it = unparams.begin(); it != unparams.end(); it++)
+    {
+      sharedparams["root." + it->first] = it->second;
+    }
+
     if (verbose)
       ApplicationTools::displayResult("Root frequencies ", freq->getName());
     return freq;
@@ -315,19 +343,25 @@ FrequenciesSet* PhylogeneticsApplicationTools::getFrequenciesSet(
   const GeneticCode* gCode,
   const std::string& freqDescription,
   const SiteContainer* data,
+  std::map<std::string, std::string>& sharedparams,
   const std::vector<double>& rateFreqs,
   bool verbose,
   int warn) throw (Exception)
 {
   map<string, string> unparsedParameterValues;
   BppOFrequenciesSetFormat bIO(BppOFrequenciesSetFormat::ALL, verbose, warn);
-  if (AlphabetTools::isCodonAlphabet(alphabet)) {
+  if (AlphabetTools::isCodonAlphabet(alphabet))
+  {
     if (!gCode)
       throw Exception("PhylogeneticsApplicationTools::getFrequenciesSet(): a GeneticCode instance is required for instanciating a codon frequencies set.");
     bIO.setGeneticCode(gCode);
   }
-  auto_ptr<FrequenciesSet> pFS(bIO.read(alphabet, freqDescription, data, true));
-  
+  unique_ptr<FrequenciesSet> pFS(bIO.read(alphabet, freqDescription, data, true));
+
+  std::map<std::string, std::string> unparsedparam = bIO.getUnparsedArguments();
+
+  sharedparams.insert(unparsedparam.begin(), unparsedparam.end());
+
   // /////// To be changed for input normalization
   if (rateFreqs.size() > 0)
   {
@@ -359,16 +393,16 @@ SubstitutionModelSet* PhylogeneticsApplicationTools::getSubstitutionModelSet(
   if (nbModels == 0)
     throw Exception("The number of models can't be 0 !");
 
-  bool nomix = true;
-  for (size_t i = 0; nomix &(i < nbModels); i++)
-  {
-    string prefix = "model" + TextTools::toString(i + 1);
-    string modelDesc;
-    modelDesc = ApplicationTools::getStringParameter(prefix, params, "", suffix, suffixIsOptional, warn);
+  // bool nomix = true;
+  // for (size_t i = 0; nomix &(i < nbModels); i++)
+  // {
+  //   string prefix = "model" + TextTools::toString(i + 1);
+  //   string modelDesc;
+  //   modelDesc = ApplicationTools::getStringParameter(prefix, params, "", suffix, suffixIsOptional, warn);
 
-    if (modelDesc.find("Mixed") != string::npos)
-      nomix = false;
-  }
+  //   if (modelDesc.find("Mixed") != string::npos)
+  //     nomix = false;
+  // }
 
   SubstitutionModelSet* modelSet, * modelSet1 = 0;
   modelSet1 = new SubstitutionModelSet(alphabet);
@@ -408,25 +442,26 @@ void PhylogeneticsApplicationTools::setSubstitutionModelSet(
   if (verbose)
     ApplicationTools::displayResult("Number of distinct models", TextTools::toString(nbModels));
 
-  BppOSubstitutionModelFormat bIO(BppOSubstitutionModelFormat::ALL, true, true, true, false, warn);
+  BppOTransitionModelFormat bIO(BppOSubstitutionModelFormat::ALL, true, true, true, false, warn);
 
   // ///////////////////////////////////////////
   // Build a new model set object:
 
   vector<double> rateFreqs;
   string tmpDesc;
-  if (AlphabetTools::isCodonAlphabet(alphabet)) {
+  if (AlphabetTools::isCodonAlphabet(alphabet))
+  {
     if (!gCode)
       throw Exception("PhylogeneticsApplicationTools::setSubstitutionModelSet(): a GeneticCode instance is required for instanciating a codon model.");
     bIO.setGeneticCode(gCode);
     tmpDesc = ApplicationTools::getStringParameter("model1", params, "CodonRate(model=JC69)", suffix, suffixIsOptional, warn);
-  } else if (AlphabetTools::isWordAlphabet(alphabet))
+  }
+  else if (AlphabetTools::isWordAlphabet(alphabet))
     tmpDesc = ApplicationTools::getStringParameter("model1", params, "Word(model=JC69)", suffix, suffixIsOptional, warn);
   else
     tmpDesc = ApplicationTools::getStringParameter("model1", params, "JC69", suffix, suffixIsOptional, warn);
 
-  auto_ptr<SubstitutionModel> tmp(bIO.read(alphabet, tmpDesc, data, false));
-  //  map<string, string> tmpUnparsedParameterValues(bIO.getUnparsedArguments());
+  unique_ptr<TransitionModel> tmp(bIO.readTransitionModel(alphabet, tmpDesc, data, false));
 
   if (tmp->getNumberOfStates() != alphabet->getSize())
   {
@@ -438,11 +473,13 @@ void PhylogeneticsApplicationTools::setSubstitutionModelSet(
   // ////////////////////////////////////
   // Deal with root frequencies
 
+  map<string, string> unparsedParameters;
+
   bool stationarity = ApplicationTools::getBooleanParameter("nonhomogeneous.stationarity", params, false, "", true, warn);
   FrequenciesSet* rootFrequencies = 0;
   if (!stationarity)
   {
-    rootFrequencies = getRootFrequenciesSet(alphabet, gCode, data, params, rateFreqs, suffix, suffixIsOptional, verbose);
+    rootFrequencies = getRootFrequenciesSet(alphabet, gCode, data, params, unparsedParameters, rateFreqs, suffix, suffixIsOptional, verbose);
     stationarity = !rootFrequencies;
     string freqDescription = ApplicationTools::getStringParameter("nonhomogeneous.root_freq", params, "", suffix, suffixIsOptional, warn);
     if (freqDescription.substr(0, 10) == "MVAprotein")
@@ -453,17 +490,17 @@ void PhylogeneticsApplicationTools::setSubstitutionModelSet(
         throw Exception("The MVAprotein frequencies set at the root can only be used if a Coala model is used on branches.");
     }
   }
+
   ApplicationTools::displayBooleanResult("Stationarity assumed", stationarity);
 
   if (!stationarity)
     modelSet.setRootFrequencies(rootFrequencies);
 
+
   // //////////////////////////////////////
   // Now parse all models:
 
   bIO.setVerbose(true);
-  
-  map<string, double> existingParameters;
 
   for (size_t i = 0; i < nbModels; i++)
   {
@@ -476,31 +513,27 @@ void PhylogeneticsApplicationTools::setSubstitutionModelSet(
     else
       modelDesc = ApplicationTools::getStringParameter(prefix, params, "JC69", suffix, suffixIsOptional, warn);
 
-    auto_ptr<SubstitutionModel> model(bIO.read(alphabet, modelDesc, data, false));
-    map<string, string> unparsedParameterValues(bIO.getUnparsedArguments());
+    unique_ptr<TransitionModel> model(bIO.readTransitionModel(alphabet, modelDesc, data, false));
 
+    map<string, string> unparsedModelParameters = bIO.getUnparsedArguments();
     map<string, string> sharedParameters;
+
     setSubstitutionModelParametersInitialValuesWithAliases(
       *model,
-      unparsedParameterValues, i+1, data,
-      existingParameters, sharedParameters,
+      unparsedModelParameters, i + 1, data,
+      sharedParameters,
       verbose);
 
+    unparsedParameters.insert(sharedParameters.begin(), sharedParameters.end());
+
     vector<int> nodesId = ApplicationTools::getVectorParameter<int>(prefix + ".nodes_id", params, ',', ':', TextTools::toString(i), suffix, suffixIsOptional, warn);
 
     if (verbose)
       ApplicationTools::displayResult("Model" + TextTools::toString(i + 1) + " is associated to", TextTools::toString(nodesId.size()) + " node(s).");
 
-    modelSet.addModel(model.get(), nodesId);
-
-    // Now set shared parameters:
-    map<string, string>::const_iterator it;
-    for (it=sharedParameters.begin(); it!=sharedParameters.end(); it++)
-      modelSet.aliasParameters(it->second, it->first);
-    
-    model.release();
+    modelSet.addModel(model.release(), nodesId);
   }
-  
+
   // Finally check parameter aliasing:
   string aliasDesc = ApplicationTools::getStringParameter("nonhomogeneous.alias", params, "", suffix, suffixIsOptional, warn);
   StringTokenizer st(aliasDesc, ",");
@@ -509,12 +542,13 @@ void PhylogeneticsApplicationTools::setSubstitutionModelSet(
     string alias = st.nextToken();
     string::size_type index = alias.find("->");
     if (index == string::npos)
-      throw Exception("PhylogeneticsApplicationTools::getSubstitutionModelSet. Bad alias syntax, should contain `->' symbol: " + alias);
-    string p1 = alias.substr(0, index);
-    string p2 = alias.substr(index + 2);
-    ApplicationTools::displayResult("Parameter alias found", p1 + "->" + p2);
-    modelSet.aliasParameters(p1, p2);
+      throw Exception("PhylogeneticsApplicationTools::setSubstitutionModelSet. Bad alias syntax, should contain `->' symbol: " + alias);
+    unparsedParameters[alias.substr(0, index)] = alias.substr(index + 2);
   }
+
+  // alias unparsedParameters
+
+  modelSet.aliasParameters(unparsedParameters, verbose);
 }
 
 /******************************************************************************/
@@ -572,7 +606,7 @@ void PhylogeneticsApplicationTools::completeMixedSubstitutionModelSet(
       size_t num = TextTools::to<size_t>(submodel.substr(5, indexo - 5));
       string p2 = submodel.substr(indexo + 1, indexf - indexo - 1);
 
-      const MixedSubstitutionModel* pSM = dynamic_cast<const MixedSubstitutionModel*>(mixedModelSet.getModel(num - 1));
+      const MixedSubstitutionModel* pSM = dynamic_cast<const MixedSubstitutionModel*>(mixedModelSet.getSubstitutionModel(num - 1));
       if (!pSM)
         throw BadIntegerException("PhylogeneticsApplicationTools::setMixedSubstitutionModelSet: Wrong model for number", static_cast<int>(num - 1));
       Vint submodnb = pSM->getSubmodelNumbers(p2);
@@ -671,7 +705,7 @@ DiscreteDistribution* PhylogeneticsApplicationTools::getRateDistribution(
   KeyvalTools::parseProcedure(distDescription, distName, args);
 
   BppORateDistributionFormat bIO(true);
-  auto_ptr<DiscreteDistribution> rDist(bIO.read(distDescription, true));
+  unique_ptr<DiscreteDistribution> rDist(bIO.read(distDescription, true));
 
   if (verbose)
   {
@@ -751,7 +785,7 @@ throw (Exception)
   // Should I ignore some parameters?
   ParameterList parametersToEstimate = parameters;
   vector<string> parNames = parametersToEstimate.getParameterNames();
-  
+
   if (params.find("optimization.ignore_parameter") != params.end())
     throw Exception("optimization.ignore_parameter is deprecated, use optimization.ignore_parameters instead!");
   string paramListDesc = ApplicationTools::getStringParameter("optimization.ignore_parameters", params, "", suffix, suffixIsOptional, warn + 1);
@@ -782,25 +816,26 @@ throw (Exception)
           ApplicationTools::displayResult("Parameter ignored", string("Root frequencies"));
       }
       else if (param == "Model")
+      {
+        vector<string> vs;
+        vector<string> vs1 = tl->getSubstitutionModelParameters().getParameterNames();
+        NonHomogeneousTreeLikelihood* nhtl = dynamic_cast<NonHomogeneousTreeLikelihood*>(tl);
+        if (nhtl != NULL)
         {
-          vector<string> vs;
-          vector<string> vs1 = tl->getSubstitutionModelParameters().getParameterNames();
-          NonHomogeneousTreeLikelihood* nhtl = dynamic_cast<NonHomogeneousTreeLikelihood*>(tl);
-          if (nhtl!=NULL){
-            vector<string> vs2 = nhtl->getRootFrequenciesParameters().getParameterNames();
-            VectorTools::diff(vs1,vs2,vs);
-            }
-          else
-            vs=vs1;
-
-          parametersToEstimate.deleteParameters(vs);
-          if (verbose)
-            ApplicationTools::displayResult("Parameter ignored", string("Model"));          
+          vector<string> vs2 = nhtl->getRootFrequenciesParameters().getParameterNames();
+          VectorTools::diff(vs1, vs2, vs);
         }
+        else
+          vs = vs1;
+
+        parametersToEstimate.deleteParameters(vs);
+        if (verbose)
+          ApplicationTools::displayResult("Parameter ignored", string("Model"));
+      }
       else if (param.find("*") != string::npos)
       {
-        vector<string> vs=ApplicationTools::matchingParameters(param,parNames);
-        
+        vector<string> vs = ApplicationTools::matchingParameters(param, parNames);
+
         for (vector<string>::iterator it = vs.begin(); it != vs.end(); it++)
         {
           parametersToEstimate.deleteParameter(*it);
@@ -823,14 +858,14 @@ throw (Exception)
 
   // Should I constrain some parameters?
   vector<string> parToEstNames = parametersToEstimate.getParameterNames();
-  
+
   if (params.find("optimization.constrain_parameter") != params.end())
     throw Exception("optimization.constrain_parameter is deprecated, use optimization.constrain_parameters instead!");
   paramListDesc = ApplicationTools::getStringParameter("optimization.constrain_parameters", params, "", suffix, suffixIsOptional, warn + 1);
 
-  string constraint="";
-  string pc, param="";
-  
+  string constraint = "";
+  string pc, param = "";
+
   StringTokenizer st2(paramListDesc, ",");
   while (st2.hasMoreToken())
   {
@@ -843,12 +878,13 @@ throw (Exception)
       param = pc.substr(0, index);
       constraint = pc.substr(index + 1);
       IntervalConstraint ic(constraint);
-      
+
       vector<string> parNames2;
-      
+
       if (param == "BrLen")
         parNames2  = tl->getBranchLengthsParameters().getParameterNames();
-      else if (param == "Ancient"){
+      else if (param == "Ancient")
+      {
         NonHomogeneousTreeLikelihood* nhtl = dynamic_cast<NonHomogeneousTreeLikelihood*>(tl);
         if (!nhtl)
           ApplicationTools::displayWarning("The 'Ancient' parameters do not exist in homogeneous models, and will be ignored.");
@@ -862,23 +898,25 @@ throw (Exception)
       {
         vector<string> vs1 = tl->getSubstitutionModelParameters().getParameterNames();
         NonHomogeneousTreeLikelihood* nhtl = dynamic_cast<NonHomogeneousTreeLikelihood*>(tl);
-        if (nhtl!=NULL){
+        if (nhtl != NULL)
+        {
           vector<string> vs2 = nhtl->getRootFrequenciesParameters().getParameterNames();
-          VectorTools::diff(vs1,vs2,parNames2);
+          VectorTools::diff(vs1, vs2, parNames2);
         }
         else
-          parNames2=vs1;
+          parNames2 = vs1;
       }
       else if (param.find("*") != string::npos)
-        parNames2=ApplicationTools::matchingParameters(param,parToEstNames);
+        parNames2 = ApplicationTools::matchingParameters(param, parToEstNames);
       else
         parNames2.push_back(param);
 
-      
-      for (size_t i=0; i<parNames2.size(); i++)
+
+      for (size_t i = 0; i < parNames2.size(); i++)
       {
-        Parameter& par=parametersToEstimate.getParameter(parNames2[i]);
-        if (par.hasConstraint()){
+        Parameter& par = parametersToEstimate.getParameter(parNames2[i]);
+        if (par.hasConstraint())
+        {
           par.setConstraint(ic & (*par.getConstraint()), true);
           if (par.getConstraint()->isEmpty())
             throw Exception("Empty interval for parameter " + parNames[i] + par.getConstraint()->getDescription());
@@ -900,10 +938,10 @@ throw (Exception)
     }
   }
 
-  
-  ///////
-  /// optimization options
-  
+
+  // /////
+  // / optimization options
+
   unsigned int nbEvalMax = ApplicationTools::getParameter<unsigned int>("optimization.max_number_f_eval", params, 1000000, suffix, suffixIsOptional, warn + 1);
   if (verbose)
     ApplicationTools::displayResult("Max # ML evaluations", TextTools::toString(nbEvalMax));
@@ -913,7 +951,7 @@ throw (Exception)
     ApplicationTools::displayResult("Tolerance", TextTools::toString(tolerance));
 
   // Backing up or restoring?
-  auto_ptr<BackupListener> backupListener;
+  unique_ptr<BackupListener> backupListener;
   string backupFile = ApplicationTools::getAFilePath("optimization.backup.file", params, false, false, suffix, suffixIsOptional, "none", warn + 1);
   if (backupFile != "none")
   {
@@ -946,7 +984,7 @@ throw (Exception)
       bck.close();
       tl->setParameters(pl);
       if (abs(tl->getValue() - fval) > 0.000001)
-        throw Exception("Incorrect likelihood value after restoring, from backup file. Remove backup file and start from scratch :s");
+        ApplicationTools::displayWarning("Warning, incorrect likelihood value after restoring from backup file.");
       ApplicationTools::displayResult("Restoring log-likelihood", -fval);
     }
   }
@@ -1100,7 +1138,8 @@ throw (Exception)
     ApplicationTools::displayResult("Performed", TextTools::toString(n) + " function evaluations.");
   if (backupFile != "none")
   {
-    remove(backupFile.c_str());
+    string bf=backupFile+".def";
+    rename(backupFile.c_str(),bf.c_str());
   }
   return tl;
 }
@@ -1215,7 +1254,7 @@ throw (Exception)
     ApplicationTools::displayResult("Algorithm used for derivable parameters", order);
 
   // Backing up or restoring?
-  auto_ptr<BackupListener> backupListener;
+  unique_ptr<BackupListener> backupListener;
   string backupFile = ApplicationTools::getAFilePath("optimization.backup.file", params, false, false, suffix, suffixIsOptional, "none", warn + 1);
   if (backupFile != "none")
   {
@@ -1324,7 +1363,8 @@ throw (Exception)
     ApplicationTools::displayResult("Performed", TextTools::toString(n) + " function evaluations.");
   if (backupFile != "none")
   {
-    remove(backupFile.c_str());
+    string bf=backupFile+".def";
+    rename(backupFile.c_str(),bf.c_str());
   }
 }
 
@@ -1359,21 +1399,17 @@ void PhylogeneticsApplicationTools::writeTree(
   int warn) throw (Exception)
 {
   string format = ApplicationTools::getStringParameter(prefix + "tree.format", params, "Newick", suffix, suffixIsOptional, warn);
-  string file = ApplicationTools::getAFilePath(prefix + "tree.file", params, true, false, suffix, suffixIsOptional, "none", warn);
-  OTree* treeWriter;
-  if (format == "Newick")
-    treeWriter = new Newick();
-  else if (format == "Nexus")
-    treeWriter = new NexusIOTree();
-  else if (format == "NHX")
-    treeWriter = new Nhx(false);
-  else
-    throw Exception("Unknown format for tree writing: " + format);
-  if (!checkOnly)
-    treeWriter->write(tree, file, true);
-  delete treeWriter;
+  string file = ApplicationTools::getAFilePath(prefix + "tree.file", params, false, false, suffix, suffixIsOptional, "none", warn);
+ 
+  BppOTreeWriterFormat bppoWriter(warn);
+  unique_ptr<OTree> oTree(bppoWriter.read(format));
   if (verbose)
-    ApplicationTools::displayResult("Wrote tree to file ", file);
+  {
+    ApplicationTools::displayResult("Output tree file " + suffix, file);
+    ApplicationTools::displayResult("Output tree format " + suffix, oTree->getFormatName());
+  }
+  if (!checkOnly && file != "none")
+    oTree->write(tree, file, true);  
 }
 
 /******************************************************************************/
@@ -1390,25 +1426,22 @@ void PhylogeneticsApplicationTools::writeTrees(
 {
   string format = ApplicationTools::getStringParameter(prefix + "trees.format", params, "Newick", suffix, suffixIsOptional, warn);
   string file = ApplicationTools::getAFilePath(prefix + "trees.file", params, true, false, suffix, suffixIsOptional, "none", warn);
-  OMultiTree* treeWriter;
-  if (format == "Newick")
-    treeWriter = new Newick();
-  else if (format == "Nexus")
-    treeWriter = new NexusIOTree();
-  else if (format == "NHX")
-    treeWriter = new Nhx();
-  else
-    throw Exception("Unknow format for tree writing: " + format);
-  if (!checkOnly)
-    treeWriter->write(trees, file, true);
-  delete treeWriter;
+
+  BppOMultiTreeWriterFormat bppoWriter(warn);
+  unique_ptr<OMultiTree> oTrees(bppoWriter.read(format));
   if (verbose)
-    ApplicationTools::displayResult("Wrote trees to file ", file);
+  {
+    ApplicationTools::displayResult("Output trees file " + suffix, file);
+    ApplicationTools::displayResult("Output trees format " + suffix, oTrees->getFormatName());
+  }
+  if (!checkOnly && file != "none")
+    oTrees->write(trees, file, true);
+  
 }
 
 /******************************************************************************/
 
-void PhylogeneticsApplicationTools::printParameters(const SubstitutionModel* model, OutputStream& out, int warn)
+void PhylogeneticsApplicationTools::printParameters(const TransitionModel* model, OutputStream& out, int warn, bool withAlias)
 {
   out << "model=";
   map<string, string> globalAliases;
@@ -1420,11 +1453,14 @@ void PhylogeneticsApplicationTools::printParameters(const SubstitutionModel* mod
 
 /******************************************************************************/
 
-void PhylogeneticsApplicationTools::printParameters(const SubstitutionModelSet* modelSet, OutputStream& out, int warn)
+void PhylogeneticsApplicationTools::printParameters(const SubstitutionModelSet* modelSet, OutputStream& out, int warn, bool withAlias)
 {
   (out << "nonhomogeneous=general").endLine();
   (out << "nonhomogeneous.number_of_models=" << modelSet->getNumberOfModels()).endLine();
 
+  if (modelSet->isStationary())
+    (out << "nonhomogeneous.stationarity = yes");
+    
   // Get the parameter links:
   map< size_t, vector<string> > modelLinks; // for each model index, stores the list of global parameters.
   map< string, set<size_t> > parameterLinks; // for each parameter name, stores the list of model indices, wich should be sorted.
@@ -1433,26 +1469,30 @@ void PhylogeneticsApplicationTools::printParameters(const SubstitutionModelSet*
   // Loop over all models:
   for (size_t i = 0; i < modelSet->getNumberOfModels(); i++)
   {
-    const SubstitutionModel* model = modelSet->getModel(i);
+    const TransitionModel* model = modelSet->getTransitionModel(i);
 
-    // First get the aliases for this model:
     map<string, string> aliases;
 
-    ParameterList pl=model->getParameters();
+    // First get the aliases for this model:
+
+    if (withAlias)
+    {
+      ParameterList pl = model->getParameters();
 
-    for (size_t np = 0 ; np< pl.size() ; np++)
+      for (size_t np = 0; np < pl.size(); np++)
       {
         string nfrom = modelSet->getFrom(pl[np].getName() + "_" + TextTools::toString(i + 1));
         if (nfrom != "")
           aliases[pl[np].getName()] = nfrom;
       }
+    }
 
     // Now print it:
     writtenNames.clear();
     out.endLine() << "model" << (i + 1) << "=";
     BppOSubstitutionModelFormat bIOsm(BppOSubstitutionModelFormat::ALL, true, true, true, false, warn);
-    map<string, string>::iterator it;
     bIOsm.write(*model, out, aliases, writtenNames);
+
     out.endLine();
     vector<int> ids = modelSet->getNodesWithModel(i);
     out << "model" << (i + 1) << ".nodes_id=" << ids[0];
@@ -1463,18 +1503,41 @@ void PhylogeneticsApplicationTools::printParameters(const SubstitutionModelSet*
     out.endLine();
   }
 
-  // Root frequencies:
-  out.endLine();
-  (out << "# Root frequencies:").endLine();
-  out << "nonhomogeneous.root_freq=";
+  // First get the aliases for this frequencies set
 
-  BppOFrequenciesSetFormat bIO(BppOFrequenciesSetFormat::ALL, false, warn);
-  bIO.write(modelSet->getRootFrequenciesSet(), out, writtenNames);
+  if (!modelSet->isStationary())
+  {
+    
+    const FrequenciesSet* pFS = modelSet->getRootFrequenciesSet();
+
+    ParameterList plf = pFS->getParameters();
+
+    map<string, string> aliases;
+    
+    if (withAlias)
+    {
+      for (size_t np = 0; np < plf.size(); np++)
+      {
+        string nfrom = modelSet->getFrom(plf[np].getName());
+        if (nfrom != "")
+          aliases[plf[np].getName()] = nfrom;
+      }
+    }
+    
+    // Root frequencies:
+    out.endLine();
+    (out << "# Root frequencies:").endLine();
+    out << "nonhomogeneous.root_freq=";
+    
+    BppOFrequenciesSetFormat bIO(BppOFrequenciesSetFormat::ALL, false, warn);
+    bIO.write(pFS, out, aliases, writtenNames);
+  }
+  
 }
 
 /******************************************************************************/
 
-void PhylogeneticsApplicationTools::printParameters(const DiscreteDistribution* rDist, OutputStream& out)
+void PhylogeneticsApplicationTools::printParameters(const DiscreteDistribution* rDist, OutputStream& out, bool withAlias)
 {
   out << "rate_distribution=";
   map<string, string> globalAliases;
@@ -1487,9 +1550,8 @@ void PhylogeneticsApplicationTools::printParameters(const DiscreteDistribution*
 }
 
 /************************
- * Substitution Mapping *
- ************************/
-
+* Substitution Mapping *
+************************/
 SubstitutionCount* PhylogeneticsApplicationTools::getSubstitutionCount(
   const Alphabet* alphabet,
   const SubstitutionModel* model,
@@ -1551,4 +1613,3 @@ SubstitutionCount* PhylogeneticsApplicationTools::getSubstitutionCount(
 }
 
 /******************************************************************************/
-
diff --git a/src/Bpp/Phyl/App/PhylogeneticsApplicationTools.h b/src/Bpp/Phyl/App/PhylogeneticsApplicationTools.h
index 73957e3..7e503b0 100644
--- a/src/Bpp/Phyl/App/PhylogeneticsApplicationTools.h
+++ b/src/Bpp/Phyl/App/PhylogeneticsApplicationTools.h
@@ -6,37 +6,37 @@
 //
 
 /*
-  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
-
-  This software is a computer program whose purpose is to provide classes
-  for phylogenetic data analysis.
-
-  This software is governed by the CeCILL  license under French law and
-  abiding by the rules of distribution of free software.  You can  use, 
-  modify and/ or redistribute the software under the terms of the CeCILL
-  license as circulated by CEA, CNRS and INRIA at the following URL
-  "http://www.cecill.info". 
-
-  As a counterpart to the access to the source code and  rights to copy,
-  modify and redistribute granted by the license, users are provided only
-  with a limited warranty  and the software's author,  the holder of the
-  economic rights,  and the successive licensors  have only  limited
-  liability. 
-
-  In this respect, the user's attention is drawn to the risks associated
-  with loading,  using,  modifying and/or developing or reproducing the
-  software by the user in light of its specific status of free software,
-  that may mean  that it is complicated to manipulate,  and  that  also
-  therefore means  that it is reserved for developers  and  experienced
-  professionals having in-depth computer knowledge. Users are therefore
-  encouraged to load and test the software's suitability as regards their
-  requirements in conditions enabling the security of their systems and/or 
-  data to be ensured and,  more generally, to use and operate it in the 
-  same conditions as regards security. 
-
-  The fact that you are presently reading this means that you have had
-  knowledge of the CeCILL license and that you accept its terms.
-*/
+   Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+
+   This software is a computer program whose purpose is to provide classes
+   for phylogenetic data analysis.
+
+   This software is governed by the CeCILL  license under French law and
+   abiding by the rules of distribution of free software.  You can  use,
+   modify and/ or redistribute the software under the terms of the CeCILL
+   license as circulated by CEA, CNRS and INRIA at the following URL
+   "http://www.cecill.info".
+
+   As a counterpart to the access to the source code and  rights to copy,
+   modify and redistribute granted by the license, users are provided only
+   with a limited warranty  and the software's author,  the holder of the
+   economic rights,  and the successive licensors  have only  limited
+   liability.
+
+   In this respect, the user's attention is drawn to the risks associated
+   with loading,  using,  modifying and/or developing or reproducing the
+   software by the user in light of its specific status of free software,
+   that may mean  that it is complicated to manipulate,  and  that  also
+   therefore means  that it is reserved for developers  and  experienced
+   professionals having in-depth computer knowledge. Users are therefore
+   encouraged to load and test the software's suitability as regards their
+   requirements in conditions enabling the security of their systems and/or
+   data to be ensured and,  more generally, to use and operate it in the
+   same conditions as regards security.
+
+   The fact that you are presently reading this means that you have had
+   knowledge of the CeCILL license and that you accept its terms.
+ */
 
 #ifndef _PHYLOGENETICSAPPLICATIONTOOLS_H_
 #define _PHYLOGENETICSAPPLICATIONTOOLS_H_
@@ -66,558 +66,605 @@
 
 namespace bpp
 {
+/**
+ * @brief This class provides some common tools for applications.
+ *
+ * The functions parse some option file, create corresponding objects and send
+ * a pointer toward it.
+ *
+ * The option files are supposed to follow this simple format:
+ * @code
+ * parameterName = parameterContent
+ * @endcode
+ * with one parameter per line.
+ *
+ * @see ApplicationTools
+ */
+class PhylogeneticsApplicationTools
+{
+public:
+  PhylogeneticsApplicationTools();
+  virtual ~PhylogeneticsApplicationTools();
+
+
+  /**
+   * @brief Build a Tree object according to options.
+   *
+   * See the Bio++ Program Suite manual for a description of available options.
+   *
+   * @param params           The attribute map where options may be found.
+   * @param prefix           A prefix to be applied to each attribute name.
+   * @param suffix           A suffix to be applied to each attribute name.
+   * @param suffixIsOptional Tell if the suffix is absolutely required.
+   * @param verbose          Print some info to the 'message' output stream.
+   * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
+   * @return A new Tree object according to the specified options.
+   * @throw Exception if an error occured.
+   */
+  static Tree* getTree(
+    std::map<std::string, std::string>& params,
+    const std::string& prefix = "input.",
+    const std::string& suffix = "",
+    bool suffixIsOptional = true,
+    bool verbose = true,
+    int warn = 1) throw (Exception);
+
+  /**
+   * @brief Build a list ofTree objects according to options.
+   *
+   * See the Bio++ Program Suite manual for a description of available options.
+   *
+   * @param params           The attribute map where options may be found.
+   * @param prefix           A prefix to be applied to each attribute name.
+   * @param suffix           A suffix to be applied to each attribute name.
+   * @param suffixIsOptional Tell if the suffix is absolutely required.
+   * @param verbose          Print some info to the 'message' output stream.
+   * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
+   * @return A new vector of Tree objects according to the specified options.
+   * @throw Exception if an error occured.
+   */
+  static std::vector<Tree*> getTrees(
+    std::map<std::string, std::string>& params,
+    const std::string& prefix = "input.",
+    const std::string& suffix = "",
+    bool suffixIsOptional = true,
+    bool verbose = true,
+    int warn = 1) throw (Exception);
+
+  /**
+   * @brief Build a SubstitutionModel object according to options.
+   *
+   * Creates a new substitution model object according to model description syntax
+   * (see the Bio++ Progam Suite manual for a detailed description of this syntax). The
+   * function also parses the parameter values and set them accordingly.
+   *
+   * @param alphabet         The alphabet to use in the model.
+   * @param gCode            The genetic code to use (only for codon models, otherwise can be set to 0).
+   *                         If set to NULL and a codon model is requested, an Exception will be thrown.
+   * @param data             A pointer toward the SiteContainer for which the substitution model is designed.
+   *                         The alphabet associated to the data must be of the same type as the one specified for the model.
+   *                         May be equal to NULL, but in this case use_observed_freq option will be unavailable.
+   * @param params           The attribute map where options may be found.
+   * @param suffix           A suffix to be applied to each attribute name.
+   * @param suffixIsOptional Tell if the suffix is absolutely required.
+   * @param verbose          Print some info to the 'message' output stream.
+   * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
+   * @return A new SubstitutionModel object according to options specified.
+   * @throw Exception if an error occured.
+   */
+
+  static SubstitutionModel* getSubstitutionModel(
+    const Alphabet* alphabet,
+    const GeneticCode* gCode,
+    const SiteContainer* data,
+    std::map<std::string, std::string>& params,
+    const std::string& suffix = "",
+    bool suffixIsOptional = true,
+    bool verbose = true,
+    int warn = 1) throw (Exception);
+
+  
+  static TransitionModel* getTransitionModel(
+    const Alphabet* alphabet,
+    const GeneticCode* gCode,
+    const SiteContainer* data,
+    std::map<std::string, std::string>& params,
+    const std::string& suffix = "",
+    bool suffixIsOptional = true,
+    bool verbose = true,
+    int warn = 1) throw (Exception);
+
+  /**
+   * @brief Set parameter initial values of a given model in a set according to options.
+   *
+   * Parameters actually depends on the model passed as argument.
+   * See getSubstitutionModelSet for more information.
+   *
+   * This function is mainly for internal usage, you're probably looking for the getSubstitutionModel or getSubstitutionModelSet function.
+   *
+   * @param model                   The model to set.
+   * @param unparsedParameterValues A map that contains all the model parameters
+   *                                names and their corresponding unparsed value, if they were found.
+   * @param modelNumber The number of this model in the SubstitutionModelSet.
+   * @param data   A pointer toward the SiteContainer for which the substitution model is designed.
+   *               The alphabet associated to the data must be of the same type as the one specified for the model.
+   *               May be equal to NULL, but in this case use_observed_freq option will be unavailable.
+   * @param sharedParams (out) remote parameters will be recorded here.
+   * @param verbose Print some info to the 'message' output stream.
+   * @throw Exception if an error occured.
+   */
+  static void setSubstitutionModelParametersInitialValuesWithAliases(
+    TransitionModel& model,
+    std::map<std::string, std::string>& unparsedParameterValues,
+    size_t modelNumber,
+    const SiteContainer* data,
+    std::map<std::string, std::string>& sharedParams,
+    bool verbose) throw (Exception);
+
+  /**
+   * @brief Get A FrequenciesSet object for root frequencies (NH models) according to options.
+   *
+   * @param alphabet         The alpabet to use.
+   * @param gCode            The genetic code to use (only for codon alphabets, otherwise can be set to 0).
+   *                         If set to NULL and a codon frequencies set is requested, an Exception will be thrown.
+   * @param data             A pointer toward the SiteContainer for which the substitution model is designed.
+   *                         The alphabet associated to the data must be of the same type as the one specified for the model.
+   *                         May be equal to NULL, but in this cas use_observed_freq option will be unavailable.
+   * @param params           The attribute map where options may be found.
+   * @param sharedParams (out) remote parameters will be recorded here.
+   * @param rateFreqs        A vector of rate catégories frequencies in case of a Markov Modulated Markov Model.
+   *                         Ignored if a vector with size 0 is passed.
+   * @param suffix           A suffix to be applied to each attribute name.
+   * @param suffixIsOptional Tell if the suffix is absolutely required.
+   * @param verbose          Print some info to the 'message' output stream.
+   * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
+   * @return A new FrequenciesSet object according to options specified.
+   * @throw Exception if an error occured.
+   */
+  static FrequenciesSet* getRootFrequenciesSet(
+    const Alphabet* alphabet,
+    const GeneticCode* gCode,
+    const SiteContainer* data,
+    std::map<std::string, std::string>& params,
+    std::map<std::string, std::string>& sharedParams,
+    const std::vector<double>& rateFreqs,
+    const std::string& suffix = "",
+    bool suffixIsOptional = true,
+    bool verbose = true,
+    int warn = 1) throw (Exception);
+
+  /**
+   * @brief Get A FrequenciesSet object according to options.
+   *
+   * @param alphabet         The alpabet to use.
+   * @param gCode            The genetic code to use (only for codon alphabets, otherwise can be set to 0).
+   *                         If set to NULL and a codon frequencies set is requested, an Exception will be thrown.
+   * @param freqDescription  A string in the keyval syntaxe describing the frequency set to use.:if expand("%") == ""|browse confirm w|else|confirm w|endif
+   *
+   * @param data             A pointer toward the SiteContainer for which the substitution model is designed.
+   *                         The alphabet associated to the data must be of the same type as the one specified for the model.
+   *                         May be equal to NULL, but in this cas use_observed_freq option will be unavailable.
+   * @param sharedParams     (out) remote parameters will be recorded here.
+   * @param rateFreqs        A vector of rate catégories frequencies in case of a Markov Modulated Markov Model.
+   *                         Ignored if a vector with size 0 is passed.
+   * @param verbose          Print some info to the 'message' output stream.
+   * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
+   * @return A new FrequenciesSet object according to options specified.
+   * @throw Exception if an error occured.
+   */
+  static FrequenciesSet* getFrequenciesSet(
+    const Alphabet* alphabet,
+    const GeneticCode* gCode,
+    const std::string& freqDescription,
+    const SiteContainer* data,
+    std::map<std::string, std::string>& sharedParams,
+    const std::vector<double>& rateFreqs,
+    bool verbose = true,
+    int warn = 1)
+  throw (Exception);
 
+  /**
+   * @brief Get A FrequenciesSet object according to options.
+   *
+   * @param alphabet         The alpabet to use.
+   * @param gCode            The genetic code to use (only for codon alphabets, otherwise can be set to 0).
+   *                         If set to NULL and a codon frequencies set is requested, an Exception will be thrown.
+   * @param freqDescription  A string in the keyval syntaxe describing the frequency set to use.:if expand("%") == ""|browse confirm w|else|confirm w|endif
+   *
+   * @param data             A pointer toward the SiteContainer for which the substitution model is designed.
+   *                         The alphabet associated to the data must be of the same type as the one specified for the model.
+   *                         May be equal to NULL, but in this cas use_observed_freq option will be unavailable.
+   * @param rateFreqs        A vector of rate catégories frequencies in case of a Markov Modulated Markov Model.
+   *                         Ignored if a vector with size 0 is passed.
+   * @param verbose          Print some info to the 'message' output stream.
+   * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
+   * @return A new FrequenciesSet object according to options specified.
+   * @throw Exception if an error occured.
+   */
+  static FrequenciesSet* getFrequenciesSet(
+    const Alphabet* alphabet,
+    const GeneticCode* gCode,
+    const std::string& freqDescription,
+    const SiteContainer* data,
+    const std::vector<double>& rateFreqs,
+    bool verbose = true,
+    int warn = 1)
+  throw (Exception)
+  {
+    std::map<std::string, std::string> sharedParams;
+    return getFrequenciesSet(alphabet, gCode, freqDescription, data, sharedParams, rateFreqs, verbose, warn);
+  }
 
   /**
-   * @brief This class provides some common tools for applications.
+   * @brief Gets a SubstitutionModelSet object according to options.
    *
-   * The functions parse some option file, create corresponding objects and send
-   * a pointer toward it.
-   * 
-   * The option files are supposed to follow this simple format:
+   * See setSubstitutionModelSet and setMixedSubstitutionModelSet
+   * methods.
+   */
+  static SubstitutionModelSet* getSubstitutionModelSet(
+    const Alphabet* alphabet,
+    const GeneticCode* gcode,
+    const SiteContainer* data,
+    std::map<std::string, std::string>& params,
+    const std::string& suffix = "",
+    bool suffixIsOptional = true,
+    bool verbose = true,
+    int warn = 1);
+
+  /**
+   * @brief Sets a SubstitutionModelSet object according to options.
+   *
+   * This model set is meant to be used with non-homogeneous substitution models of sequence evolution.
+   *
+   * Recognized options are:
+   * - number_of_models: the number of distinct SubstitutionModel to use.
+   *
+   * Then, for each of the models, the following information must be provided:
+   * - model1='model name(parameters'='value',...)
+   * Model names and parameters follow the same syntaxe as for the getSubstitutionModel method.
+   * - model1.nodes='list of nodes id, separated by comas'.
+   * And then
+   * - model2=...
+   * etc.
+   *
+   * All models must be fully specified, and at the end of the description, all nodes must be attributed to a model,
+   * otherwise an exception is thrown.
+   *
+   * Finally, this is also allowed for models to share one or several parameters.
+   * for instance:
+   * @code
+   * model1=T92(kappa=2.0, theta=0.5)
+   * model2=T92(kappa=model1.kappa, theta=0.5)
+   * @endcode
+   * In this case model1 and model2 with have their own and independent theta parameter, but only one kappa parameter will be used for both models.
+   * Note that
    * @code
-   * parameterName = parameterContent
+   * model1=T92(kappa=2.0, theta=0.5)
+   * model1.nodes=1,2,3
+   * model2=T92(kappa= model1.kappa, theta=model1.theta)
+   * model2.nodes=4,5,6
    * @endcode
-   * with one parameter per line.
+   * is equivalent to
+   * @code
+   * model1=T92(kappa=2.0, theta=0.5)
+   * model1.nodes=1,2,3,4,5,6
+   * @endcode
+   * but will require more memory and use more CPU, since some calculations will be performed twice.
    *
-   * @see ApplicationTools
+   * @param modelSet         The modified SubstitutionModelSet object according to options specified.
+   * @param alphabet         The alpabet to use in all models.
+   * @param gcode            The genetic code to use (only for codon models, otherwise can be set to 0).
+   *                         If set to NULL and a codon model is requested, an Exception will be thrown.
+   * @param data             A pointer toward the SiteContainer for which the substitution model is designed.
+   *                         The alphabet associated to the data must be of the same type as the one specified for the model.
+   *                         May be equal to NULL, but in this cas use_observed_freq option will be unavailable.
+   * @param params           The attribute map where options may be found.
+   * @param suffix           A suffix to be applied to each attribute name.
+   * @param suffixIsOptional Tell if the suffix is absolutely required.
+   * @param verbose          Print some info to the 'message' output stream.
+   * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
+   * @throw Exception if an error occured.
    */
-  class PhylogeneticsApplicationTools
-  {
-  
-  public:
-    PhylogeneticsApplicationTools();
-    virtual ~PhylogeneticsApplicationTools();
-  
+  static void setSubstitutionModelSet(
+    SubstitutionModelSet& modelSet,
+    const Alphabet* alphabet,
+    const GeneticCode* gcode,
+    const SiteContainer* data,
+    std::map<std::string, std::string>& params,
+    const std::string& suffix = "",
+    bool suffixIsOptional = true,
+    bool verbose = true,
+    int warn = 1);
 
-    /**
-     * @brief Build a Tree object according to options.
-     *
-     * See the Bio++ Program Suite manual for a description of available options.
-     *
-     * @param params           The attribute map where options may be found.
-     * @param prefix           A prefix to be applied to each attribute name.
-     * @param suffix           A suffix to be applied to each attribute name.
-     * @param suffixIsOptional Tell if the suffix is absolutely required.
-     * @param verbose          Print some info to the 'message' output stream.
-     * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
-     * @return A new Tree object according to the specified options.
-     * @throw Exception if an error occured.
-     */
-    static Tree* getTree(
-        std::map<std::string, std::string>& params,
-        const std::string& prefix = "input.",
-        const std::string& suffix = "",
-        bool suffixIsOptional = true,
-        bool verbose = true,
-        int warn = 1) throw (Exception);
- 
-    /**
-     * @brief Build a list ofTree objects according to options.
-     *
-     * See the Bio++ Program Suite manual for a description of available options.
-     *
-     * @param params           The attribute map where options may be found.
-     * @param prefix           A prefix to be applied to each attribute name.
-     * @param suffix           A suffix to be applied to each attribute name.
-     * @param suffixIsOptional Tell if the suffix is absolutely required.
-     * @param verbose          Print some info to the 'message' output stream.
-     * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
-     * @return A new vector of Tree objects according to the specified options.
-     * @throw Exception if an error occured.
-     */
-    static std::vector<Tree*> getTrees(
-        std::map<std::string, std::string>& params,
-        const std::string& prefix = "input.",
-        const std::string& suffix = "",
-        bool suffixIsOptional = true,
-        bool verbose = true,
-        int warn = 1) throw (Exception);
-  
-    /**
-     * @brief Build a SubstitutionModel object according to options.
-     *
-     * Creates a new substitution model object according to model description syntax
-     * (see the Bio++ Progam Suite manual for a detailed description of this syntax). The
-     * function also parses the parameter values and set them accordingly.
-     *
-     * @param alphabet         The alphabet to use in the model.
-     * @param gCode            The genetic code to use (only for codon models, otherwise can be set to 0).
-     *                         If set to NULL and a codon model is requested, an Exception will be thrown.
-     * @param data             A pointer toward the SiteContainer for which the substitution model is designed.
-     *                         The alphabet associated to the data must be of the same type as the one specified for the model.
-     *                         May be equal to NULL, but in this case use_observed_freq option will be unavailable.
-     * @param params           The attribute map where options may be found.
-     * @param suffix           A suffix to be applied to each attribute name.
-     * @param suffixIsOptional Tell if the suffix is absolutely required.
-     * @param verbose          Print some info to the 'message' output stream.
-     * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
-     * @return A new SubstitutionModel object according to options specified.
-     * @throw Exception if an error occured.
-     */
-    static SubstitutionModel* getSubstitutionModel(
-        const Alphabet* alphabet,
-        const GeneticCode* gCode,
-        const SiteContainer* data, 
-        std::map<std::string, std::string>& params,
-        const std::string& suffix = "",
-        bool suffixIsOptional = true,
-        bool verbose = true,
-        int warn = 1) throw (Exception);
-  
+  /**
+   * @brief Complete a MixedSubstitutionModelSet object according to
+   * options, given this model has already been filled through
+   * setSubstitutionModelSet method.
+   *
+   * In addition, this method builds the allowed combinations of
+   * submodels of the different mixed models.
+   *
+   * If none combination is given, then all possible submodels
+   * combinations will be considered.
+   *
+   * The submodels dependencies are given a sets of combinations of
+   * the mixed variables of the mixed models. For instance, if we
+   * have:
+   *
+   * @code
+   * model1=MixedModel(model=T92(kappa=Gamma(n=4), theta=0.5))
+   * model2=MixedModel(model=T92(kappa=Gaussian(n=5), theta=Beta(n=3)))
+   * @endcode
+   *
+   * In this case model1 is a mixture of 4 T92 submodels and model2
+   * a mixture of 15 T92 submodels. These submodels are denoted with
+   * the parameter name and the class number. For example, the
+   * submodels of model1 are denoted model1[kappa_1], ...,
+   * model1[kappa_4], and the submodels of model2 are denoted
+   * model2[kappa_1,theta_1], ..., model2[kappa_5, theta_3].
+   * Additionnaly, for instance, model2[kappa_2] denotes all the
+   * submodels whose description has kappa_2.
+   *
+   * By default, when switching from model1 to model2, a site is
+   * allowed to switch between any submodel of model1 and any
+   * submodel of model2. If the only allowed combination is that a
+   * site follows submodels model1(kappa_1) and
+   * model2(kappa_3,theta_2), it is denoted:
+   *
+   * @code
+   * site.allowedpaths= model1[kappa_1] & model2[kappa_3,theta_2]
+   * @endcode
+   *
+   * With additional combination saying that a site can follow
+   * submodels model1[kappa_2] and any submodel of model2[kappa_3]
+   * is denoted:
+   *
+   * @code
+   * site.allowedpaths= model1[kappa_1] & model2[kappa_3,theta_2] |
+   *                    model1[kappa_2] & model2[kappa_3]
+   * @endcode
+   *
+   * See MixedSubstitutionModelSet description for further
+   * information.
+   *
+   * @param mixedModelSet    The modified MixedSubstitutionModelSet object according to options specified.
+   * @param alphabet         The alpabet to use in all models.
+   * @param data             A pointer toward the SiteContainer for which the substitution model is designed.
+   *                         The alphabet associated to the data must be of the same type as the one specified for the model.
+   *                         May be equal to NULL, but in this cas use_observed_freq option will be unavailable.
+   * @param params           The attribute map where options may be found.
+   * @param suffix           A suffix to be applied to each attribute name.
+   * @param suffixIsOptional Tell if the suffix is absolutely required.
+   * @param verbose          Print some info to the 'message' output stream.
+   * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
+   * @throw Exception if an error occured.
+   */
+  static void completeMixedSubstitutionModelSet(
+    MixedSubstitutionModelSet& mixedModelSet,
+    const Alphabet* alphabet,
+    const SiteContainer* data,
+    std::map<std::string, std::string>& params,
+    const std::string& suffix = "",
+    bool suffixIsOptional = true,
+    bool verbose = true,
+    int warn = 1);
+
+  /**
+   * @brief Build a multi-dimension distribution as a
+   * MultipleDiscreteDistribution object with default parameter
+   * values according to a keyval description.
+   *
+   * Check the Bio++ Program Suite documentation for a description of the syntax.
+   * It is mainly for internal usage, you're probably looking for the getRateDistribution function.
+   *
+   * @param distDescription         A string describing the model in the keyval syntax.
+   * @param unparsedParameterValues [out] a map that will contain all the distribution parameters
+   *                                names and their corresponding unparsed value, if they were found.
+   * @param verbose                 Print some info to the 'message' output stream.
+   * @return A new MultipleDiscreteDistribution object according to options specified.
+   * @throw Exception if an error occured.
+   */
+  static MultipleDiscreteDistribution* getMultipleDistributionDefaultInstance(
+    const std::string& distDescription,
+    std::map<std::string, std::string>& unparsedParameterValues,
+    bool verbose = true);
 
-    /**
-     * @brief Set parameter initial values of a given model in a set according to options.
-     *
-     * Parameters actually depends on the model passed as argument.
-     * See getSubstitutionModelSet for more information.
-     *
-     * This function is mainly for internal usage, you're probably looking for the getSubstitutionModel or getSubstitutionModelSet function.
-     *
-     * @param model                   The model to set.
-     * @param unparsedParameterValues A map that contains all the model parameters
-     *                                names and their corresponding unparsed value, if they were found.
-     * @param modelNumber The number of this model in the SubstitutionModelSet.
-     * @param data   A pointer toward the SiteContainer for which the substitution model is designed.
-     *               The alphabet associated to the data must be of the same type as the one specified for the model.
-     *               May be equal to NULL, but in this case use_observed_freq option will be unavailable.
-     * @param existingParams (in/out) A map with already existing value that have been found in previous calls, and may be recalled here.
-     *                       New parameters found here will be added.
-     * @param sharedParams (out) remote parameters will be recorded here.
-     * @param verbose Print some info to the 'message' output stream.
-     * @throw Exception if an error occured.
-     */
-    static void setSubstitutionModelParametersInitialValuesWithAliases(
-                                                                       SubstitutionModel& model,
-                                                                       std::map<std::string, std::string>& unparsedParameterValues,
-                                                                       size_t modelNumber,
-                                                                       const SiteContainer* data,
-                                                                       std::map<std::string, double>& existingParams,
-                                                                       std::map<std::string, std::string>& sharedParams,
-                                                                       bool verbose) throw (Exception);
-
-    /**
-     * @brief Get A FrequenciesSet object for root frequencies (NH models) according to options.
-     *
-     * @param alphabet         The alpabet to use.
-     * @param gCode            The genetic code to use (only for codon alphabets, otherwise can be set to 0).
-     *                         If set to NULL and a codon frequencies set is requested, an Exception will be thrown.
-     * @param data             A pointer toward the SiteContainer for which the substitution model is designed.
-     *                         The alphabet associated to the data must be of the same type as the one specified for the model.
-     *                         May be equal to NULL, but in this cas use_observed_freq option will be unavailable.
-     * @param params           The attribute map where options may be found.
-     * @param rateFreqs        A vector of rate catégories frequencies in case of a Markov Modulated Markov Model.
-     *                         Ignored if a vector with size 0 is passed.
-     * @param suffix           A suffix to be applied to each attribute name.
-     * @param suffixIsOptional Tell if the suffix is absolutely required.
-     * @param verbose          Print some info to the 'message' output stream.
-     * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
-     * @return A new FrequenciesSet object according to options specified.
-     * @throw Exception if an error occured.
-     */
-    static FrequenciesSet* getRootFrequenciesSet(
-        const Alphabet* alphabet,
-        const GeneticCode* gCode,
-        const SiteContainer* data, 
-        std::map<std::string, std::string>& params,
-        const std::vector<double>& rateFreqs,
-        const std::string& suffix = "",
-        bool suffixIsOptional = true,
-        bool verbose = true,
-        int warn = 1) throw (Exception);
-
-    /**
-     * @brief Get A FrequenciesSet object according to options.
-     *
-     * @param alphabet         The alpabet to use.
-     * @param gCode            The genetic code to use (only for codon alphabets, otherwise can be set to 0).
-     *                         If set to NULL and a codon frequencies set is requested, an Exception will be thrown.
-     * @param freqDescription  A string in the keyval syntaxe describing the frequency set to use.:if expand("%") == ""|browse confirm w|else|confirm w|endif
-     * 
-     * @param data             A pointer toward the SiteContainer for which the substitution model is designed.
-     *                         The alphabet associated to the data must be of the same type as the one specified for the model.
-     *                         May be equal to NULL, but in this cas use_observed_freq option will be unavailable.
-     * @param rateFreqs        A vector of rate catégories frequencies in case of a Markov Modulated Markov Model.
-     *                         Ignored if a vector with size 0 is passed.
-     * @param verbose          Print some info to the 'message' output stream.
-     * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
-     * @return A new FrequenciesSet object according to options specified.
-     * @throw Exception if an error occured.
-     */
-    static FrequenciesSet* getFrequenciesSet(
-        const Alphabet* alphabet,
-        const GeneticCode* gCode,
-        const std::string& freqDescription,
-        const SiteContainer* data, 
-        const std::vector<double>& rateFreqs,
-        bool verbose = true,
-        int warn = 1)
-      throw (Exception);
-
-    /**
-     * @brief Gets a SubstitutionModelSet object according to options.
-     *
-     * See setSubstitutionModelSet and setMixedSubstitutionModelSet
-     * methods.
-     */
-     static SubstitutionModelSet* getSubstitutionModelSet(
-         const Alphabet* alphabet,
-         const GeneticCode* gcode,
-         const SiteContainer* data, 
-         std::map<std::string, std::string>& params,
-         const std::string& suffix = "",
-         bool suffixIsOptional = true,
-         bool verbose = true,
-         int warn = 1);    
-
-    /**
-     * @brief Sets a SubstitutionModelSet object according to options.
-     *
-     * This model set is meant to be used with non-homogeneous substitution models of sequence evolution.
-     *
-     * Recognized options are:
-     * - number_of_models: the number of distinct SubstitutionModel to use.
-     *
-     * Then, for each of the models, the following information must be provided:
-     * - model1='model name(parameters'='value',...)
-     * Model names and parameters follow the same syntaxe as for the getSubstitutionModel method.
-     * - model1.nodes='list of nodes id, separated by comas'.
-     * And then
-     * - model2=...
-     * etc.
-     *
-     * All models must be fully specified, and at the end of the description, all nodes must be attributed to a model,
-     * otherwise an exception is thrown.
-     * 
-     * Finally, this is also allowed for models to share one or several parameters.
-     * for instance:
-     * @code
-     * model1=T92(kappa=2.0, theta=0.5)
-     * model2=T92(kappa=model1.kappa, theta=0.5)
-     * @endcode
-     * In this case model1 and model2 with have their own and independent theta parameter, but only one kappa parameter will be used for both models.
-     * Note that
-     * @code
-     * model1=T92(kappa=2.0, theta=0.5)
-     * model1.nodes=1,2,3
-     * model2=T92(kappa= model1.kappa, theta=model1.theta)
-     * model2.nodes=4,5,6
-     * @endcode
-     * is equivalent to
-     * @code
-     * model1=T92(kappa=2.0, theta=0.5)
-     * model1.nodes=1,2,3,4,5,6
-     * @endcode
-     * but will require more memory and use more CPU, since some calculations will be performed twice.
-     *
-     * @param modelSet         The modified SubstitutionModelSet object according to options specified.
-     * @param alphabet         The alpabet to use in all models.
-     * @param gcode            The genetic code to use (only for codon models, otherwise can be set to 0).
-     *                         If set to NULL and a codon model is requested, an Exception will be thrown.
-     * @param data             A pointer toward the SiteContainer for which the substitution model is designed.
-     *                         The alphabet associated to the data must be of the same type as the one specified for the model.
-     *                         May be equal to NULL, but in this cas use_observed_freq option will be unavailable.
-     * @param params           The attribute map where options may be found.
-     * @param suffix           A suffix to be applied to each attribute name.
-     * @param suffixIsOptional Tell if the suffix is absolutely required.
-     * @param verbose          Print some info to the 'message' output stream.
-     * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
-     * @throw Exception if an error occured.
-     */
-    static void setSubstitutionModelSet(
-        SubstitutionModelSet& modelSet,
-        const Alphabet* alphabet,
-        const GeneticCode* gcode,
-        const SiteContainer* data, 
-        std::map<std::string, std::string>& params,
-        const std::string& suffix = "",
-        bool suffixIsOptional = true,
-        bool verbose = true,
-        int warn = 1);
-    
-    /**
-     * @brief Complete a MixedSubstitutionModelSet object according to
-     * options, given this model has already been filled through
-     * setSubstitutionModelSet method.
-     *
-     * In addition, this method builds the allowed combinations of
-     * submodels of the different mixed models.
-     *
-     * If none combination is given, then all possible submodels
-     * combinations will be considered.
-     *
-     * The submodels dependencies are given a sets of combinations of
-     * the mixed variables of the mixed models. For instance, if we
-     * have:
-     *
-     * @code
-     * model1=MixedModel(model=T92(kappa=Gamma(n=4), theta=0.5))
-     * model2=MixedModel(model=T92(kappa=Gaussian(n=5), theta=Beta(n=3)))
-     * @endcode
-     *
-     * In this case model1 is a mixture of 4 T92 submodels and model2
-     * a mixture of 15 T92 submodels. These submodels are denoted with
-     * the parameter name and the class number. For example, the
-     * submodels of model1 are denoted model1[kappa_1], ...,
-     * model1[kappa_4], and the submodels of model2 are denoted
-     * model2[kappa_1,theta_1], ..., model2[kappa_5, theta_3].
-     * Additionnaly, for instance, model2[kappa_2] denotes all the
-     * submodels whose description has kappa_2.
-     *
-     * By default, when switching from model1 to model2, a site is
-     * allowed to switch between any submodel of model1 and any
-     * submodel of model2. If the only allowed combination is that a
-     * site follows submodels model1(kappa_1) and
-     * model2(kappa_3,theta_2), it is denoted:
-     *
-     * @code
-     * site.allowedpaths= model1[kappa_1] & model2[kappa_3,theta_2]
-     * @endcode
-     *
-     * With additional combination saying that a site can follow
-     * submodels model1[kappa_2] and any submodel of model2[kappa_3]
-     * is denoted:
-     *
-     * @code
-     * site.allowedpaths= model1[kappa_1] & model2[kappa_3,theta_2] |
-     *                    model1[kappa_2] & model2[kappa_3]
-     * @endcode
-     *
-     * See MixedSubstitutionModelSet description for further
-     * information.
-     *
-     * @param mixedModelSet    The modified MixedSubstitutionModelSet object according to options specified.
-     * @param alphabet         The alpabet to use in all models.
-     * @param data             A pointer toward the SiteContainer for which the substitution model is designed.
-     *                         The alphabet associated to the data must be of the same type as the one specified for the model.
-     *                         May be equal to NULL, but in this cas use_observed_freq option will be unavailable.
-     * @param params           The attribute map where options may be found.
-     * @param suffix           A suffix to be applied to each attribute name.
-     * @param suffixIsOptional Tell if the suffix is absolutely required.
-     * @param verbose          Print some info to the 'message' output stream.
-     * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
-     * @throw Exception if an error occured.
-     */
-    static void completeMixedSubstitutionModelSet(
-        MixedSubstitutionModelSet& mixedModelSet,
-        const Alphabet* alphabet,
-        const SiteContainer* data, 
-        std::map<std::string, std::string>& params,
-        const std::string& suffix = "",
-        bool suffixIsOptional = true,
-        bool verbose = true,
-        int warn = 1);
-
-    /**
-     * @brief Build a multi-dimension distribution as a
-     * MultipleDiscreteDistribution object with default parameter
-     * values according to a keyval description.
-     *
-     * Check the Bio++ Program Suite documentation for a description of the syntax.
-     * It is mainly for internal usage, you're probably looking for the getRateDistribution function.
-     *
-     * @param distDescription         A string describing the model in the keyval syntax.
-     * @param unparsedParameterValues [out] a map that will contain all the distribution parameters
-     *                                names and their corresponding unparsed value, if they were found.
-     * @param verbose                 Print some info to the 'message' output stream.
-     * @return A new MultipleDiscreteDistribution object according to options specified.
-     * @throw Exception if an error occured.
-     */
-    static MultipleDiscreteDistribution* getMultipleDistributionDefaultInstance(
-        const std::string& distDescription,
-        std::map<std::string, std::string>& unparsedParameterValues,
-        bool verbose = true);
-
-    /**
-     * @brief Build a DiscreteDistribution object according to options.
-     *
-     * Creates a new rate distribution object according to distribution description syntax
-     * (see the Bio++ Progam Suite manual for a detailed description of this syntax). The
-     * function also parses the parameter values and set them accordingly.
-     *
-     * @param params  The attribute map where options may be found.
-     * @param suffix  A suffix to be applied to each attribute name.
-     * @param suffixIsOptional Tell if the suffix is absolutely required.
-     * @param verbose Print some info to the 'message' output stream.
-     * @return A new DiscreteDistribution object according to options specified.
-     * @throw Exception if an error occured.
-     */
-    static DiscreteDistribution* getRateDistribution(
-        std::map<std::string, std::string>& params,
-        const std::string& suffix = "",
-        bool suffixIsOptional = true,
-        bool verbose = true)
-      throw (Exception);
-      
-    /**
-     * @brief Optimize parameters according to options.
-     *
-     * @param tl               The TreeLikelihood function to optimize.
-     * @param parameters       The initial list of parameters to optimize.
-     *                         Use tl->getIndependentParameters() in order to estimate all parameters.
-     * @param params           The attribute map where options may be found.
-     * @param suffix           A suffix to be applied to each attribute name.
-     * @param suffixIsOptional Tell if the suffix is absolutely required.
-     * @param verbose          Print some info to the 'message' output stream.
-     * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
-     * @throw Exception        Any exception that may happen during the optimization process.
-     * @return A pointer toward the final likelihood object.
-     * This pointer may be the same as passed in argument (tl), but in some cases the algorithm
-     * clone this object. We may change this bahavior in the future...
-     * You hence should write something like
-     * @code
-     * tl = PhylogeneticsApplicationTools::optimizeParameters(tl, ...);
-     * @endcode
-     */
-    static TreeLikelihood* optimizeParameters(
-        TreeLikelihood* tl,
-        const ParameterList& parameters,
-        std::map<std::string, std::string>& params,
-        const std::string& suffix = "",
-        bool suffixIsOptional = true,
-        bool verbose = true,
-        int warn = 1)
-      throw (Exception);
-    
-    /**
-     * @brief Optimize parameters according to options, with a molecular clock.
-     *
-     * @param tl               The ClockTreeLikelihood function to optimize.
-     * @param parameters       The initial list of parameters to optimize.
-     *                         Use tl->getIndependentParameters() in order to estimate all parameters.
-     * @param params           The attribute map where options may be found.
-     * @param suffix           A suffix to be applied to each attribute name.
-     * @param suffixIsOptional Tell if the suffix is absolutely required.
-     * @param verbose          Print some info to the 'message' output stream.
-     * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
-     * @throw Exception        Any exception that may happen during the optimization process.
-     */
-    static void optimizeParameters(
-        DiscreteRatesAcrossSitesClockTreeLikelihood* tl,
-        const ParameterList& parameters,
-        std::map<std::string, std::string>& params,
-        const std::string& suffix = "",
-        bool suffixIsOptional = true,
-        bool verbose = true,
-        int warn = 1)
-      throw (Exception);
-    
-    /**
-     * @brief Check if parameter values are close to their definition boundary.
-     *
-     * This allows the detection of potential optimization issues.
-     * A warning message will be output for each problematic parameter.
-     *
-     * @param pl A list of parameters. Parameters without constraint will be ignored.
-     */
-    static void checkEstimatedParameters(const ParameterList& pl);
-
-    /**
-     * @brief Get a SubstitutionCount instance.
-     *
-     * @param alphabet The alphabet to use.
-     * @param model The model to use.
-     * @param params The attribute map where options may be found.
-     * @param suffix Optional suffix for command name.
-     * @param verbose          Print some info to the 'message' output stream.
-     * @param warn Set the warning level (0: always display warnings, >0 display warnings on demand).
-     * @return A SubstitutionCount object.
-     */
-    static SubstitutionCount* getSubstitutionCount(
-        const Alphabet* alphabet,
-        const SubstitutionModel* model,
-        map<string, string>& params,
-        string suffix = "",
-        bool verbose = true,
-        int warn = 1);
-   
-    /**
-     * @brief Write a tree according to options.
-     *
-     * See the Bio++ Program Suite manual for a descriptio of all available options.
-     *
-     * @param tree    The tree to write.
-     * @param params  The attribute map where options may be found.
-     * @param prefix  A prefix to be applied to each attribute name.
-     * @param suffix  A suffix to be applied to each attribute name.
-     * @param suffixIsOptional Tell if the suffix is absolutely required.
-     * @param verbose Print some info to the 'message' output stream.
-     * @param checkOnly If this parameter is set to true, then all options are
-     * checked and error messages sent, but no file is written.
-     * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
-     * @throw Exception if an error occured.
-     */
-    static void writeTree(
-        const TreeTemplate<Node>& tree,
-        std::map<std::string, std::string>& params,
-        const std::string& prefix = "output.",
-        const std::string& suffix = "",
-        bool suffixIsOptional = true,
-        bool verbose = true,
-        bool checkOnly = false,
-        int warn = 1) throw (Exception);
-    
-    /**
-     * @brief Write a tree according to options.
-     *
-     * See the Bio++ Program Suite manual for a descriptio of all available options.
-     *
-     * @param trees            The trees to write.
-     * @param params           The attribute map where options may be found.
-     * @param prefix           A prefix to be applied to each attribute name.
-     * @param suffix           A suffix to be applied to each attribute name.
-     * @param suffixIsOptional Tell if the suffix is absolutely required.
-     * @param verbose          Print some info to the 'message' output stream.
-     * @param checkOnly        If this parameter is set to true, then all options are
-     *                         checked and error messages sent, but no file is written.
-     * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
-     * @throw Exception if an error occured.
-     */
-    static void writeTrees(
-        const std::vector<Tree*>& trees,
-        std::map<std::string, std::string>& params,
-        const std::string& prefix = "output.",
-        const std::string& suffix = "",
-        bool suffixIsOptional = true,
-        bool verbose = true,
-        bool checkOnly = false,
-        int warn = 1) throw (Exception);
-
-
-    
-    /**
-     * @brief Output a SubstitutionModel description to a file.
-     *
-     * @param model The model to serialize.
-     * @param out   The stream where to print.
-     * @param warn  Set the warning level (0: always display warnings, >0 display warnings on demand).
-     */
-    static void printParameters(const SubstitutionModel* model, OutputStream& out,int warn = 1);
-
-
-
-    /**
-     * @brief Output a SubstitutionModelSet description to a file.
-     *
-     * @param modelSet The model set to serialize.
-     * @param out      The stream where to print.
-     * @param warn  Set the warning level (0: always display warnings, >0 display warnings on demand).
-     */
-    static void printParameters(const SubstitutionModelSet* modelSet, OutputStream& out, int warn = 1);
-
-
-
-    /**
-     * @brief Output a DiscreteDistribution description to a file.
-     *
-     * @param rDist The rate distribution to serialize.
-     * @param out   The stream where to print.
-     */
-    static void printParameters(const DiscreteDistribution* rDist, OutputStream& out);
-
-  };
-
-} //end of namespace bpp.
-
-#endif  //_PHYLOGENETICSAPPLICATIONTOOLS_H_
+  /**
+   * @brief Build a DiscreteDistribution object according to options.
+   *
+   * Creates a new rate distribution object according to distribution description syntax
+   * (see the Bio++ Progam Suite manual for a detailed description of this syntax). The
+   * function also parses the parameter values and set them accordingly.
+   *
+   * @param params  The attribute map where options may be found.
+   * @param suffix  A suffix to be applied to each attribute name.
+   * @param suffixIsOptional Tell if the suffix is absolutely required.
+   * @param verbose Print some info to the 'message' output stream.
+   * @return A new DiscreteDistribution object according to options specified.
+   * @throw Exception if an error occured.
+   */
+  static DiscreteDistribution* getRateDistribution(
+    std::map<std::string, std::string>& params,
+    const std::string& suffix = "",
+    bool suffixIsOptional = true,
+    bool verbose = true)
+  throw (Exception);
+
+  /**
+   * @brief Optimize parameters according to options.
+   *
+   * @param tl               The TreeLikelihood function to optimize.
+   * @param parameters       The initial list of parameters to optimize.
+   *                         Use tl->getIndependentParameters() in order to estimate all parameters.
+   * @param params           The attribute map where options may be found.
+   * @param suffix           A suffix to be applied to each attribute name.
+   * @param suffixIsOptional Tell if the suffix is absolutely required.
+   * @param verbose          Print some info to the 'message' output stream.
+   * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
+   * @throw Exception        Any exception that may happen during the optimization process.
+   * @return A pointer toward the final likelihood object.
+   * This pointer may be the same as passed in argument (tl), but in some cases the algorithm
+   * clone this object. We may change this bahavior in the future...
+   * You hence should write something like
+   * @code
+   * tl = PhylogeneticsApplicationTools::optimizeParameters(tl, ...);
+   * @endcode
+   */
+  static TreeLikelihood* optimizeParameters(
+    TreeLikelihood* tl,
+    const ParameterList& parameters,
+    std::map<std::string, std::string>& params,
+    const std::string& suffix = "",
+    bool suffixIsOptional = true,
+    bool verbose = true,
+    int warn = 1)
+  throw (Exception);
+
+  /**
+   * @brief Optimize parameters according to options, with a molecular clock.
+   *
+   * @param tl               The ClockTreeLikelihood function to optimize.
+   * @param parameters       The initial list of parameters to optimize.
+   *                         Use tl->getIndependentParameters() in order to estimate all parameters.
+   * @param params           The attribute map where options may be found.
+   * @param suffix           A suffix to be applied to each attribute name.
+   * @param suffixIsOptional Tell if the suffix is absolutely required.
+   * @param verbose          Print some info to the 'message' output stream.
+   * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
+   * @throw Exception        Any exception that may happen during the optimization process.
+   */
+  static void optimizeParameters(
+    DiscreteRatesAcrossSitesClockTreeLikelihood* tl,
+    const ParameterList& parameters,
+    std::map<std::string, std::string>& params,
+    const std::string& suffix = "",
+    bool suffixIsOptional = true,
+    bool verbose = true,
+    int warn = 1)
+  throw (Exception);
+
+  /**
+   * @brief Check if parameter values are close to their definition boundary.
+   *
+   * This allows the detection of potential optimization issues.
+   * A warning message will be output for each problematic parameter.
+   *
+   * @param pl A list of parameters. Parameters without constraint will be ignored.
+   */
+  static void checkEstimatedParameters(const ParameterList& pl);
+
+  /**
+   * @brief Get a SubstitutionCount instance.
+   *
+   * @param alphabet The alphabet to use.
+   * @param model The model to use.
+   * @param params The attribute map where options may be found.
+   * @param suffix Optional suffix for command name.
+   * @param verbose          Print some info to the 'message' output stream.
+   * @param warn Set the warning level (0: always display warnings, >0 display warnings on demand).
+   * @return A SubstitutionCount object.
+   */
+  static SubstitutionCount* getSubstitutionCount(
+    const Alphabet* alphabet,
+    const SubstitutionModel* model,
+    map<string, string>& params,
+    string suffix = "",
+    bool verbose = true,
+    int warn = 1);
+
+  /**
+   * @brief Write a tree according to options.
+   *
+   * See the Bio++ Program Suite manual for a descriptio of all available options.
+   *
+   * @param tree    The tree to write.
+   * @param params  The attribute map where options may be found.
+   * @param prefix  A prefix to be applied to each attribute name.
+   * @param suffix  A suffix to be applied to each attribute name.
+   * @param suffixIsOptional Tell if the suffix is absolutely required.
+   * @param verbose Print some info to the 'message' output stream.
+   * @param checkOnly If this parameter is set to true, then all options are
+   * checked and error messages sent, but no file is written.
+   * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
+   * @throw Exception if an error occured.
+   */
+  static void writeTree(
+    const TreeTemplate<Node>& tree,
+    std::map<std::string, std::string>& params,
+    const std::string& prefix = "output.",
+    const std::string& suffix = "",
+    bool suffixIsOptional = true,
+    bool verbose = true,
+    bool checkOnly = false,
+    int warn = 1) throw (Exception);
+
+  /**
+   * @brief Write a tree according to options.
+   *
+   * See the Bio++ Program Suite manual for a descriptio of all available options.
+   *
+   * @param trees            The trees to write.
+   * @param params           The attribute map where options may be found.
+   * @param prefix           A prefix to be applied to each attribute name.
+   * @param suffix           A suffix to be applied to each attribute name.
+   * @param suffixIsOptional Tell if the suffix is absolutely required.
+   * @param verbose          Print some info to the 'message' output stream.
+   * @param checkOnly        If this parameter is set to true, then all options are
+   *                         checked and error messages sent, but no file is written.
+   * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
+   * @throw Exception if an error occured.
+   */
+  static void writeTrees(
+    const std::vector<Tree*>& trees,
+    std::map<std::string, std::string>& params,
+    const std::string& prefix = "output.",
+    const std::string& suffix = "",
+    bool suffixIsOptional = true,
+    bool verbose = true,
+    bool checkOnly = false,
+    int warn = 1) throw (Exception);
+
+
+  /**
+   * @brief Output a SubstitutionModel description to a file.
+   *
+   * @param model The model to serialize.
+   * @param out   The stream where to print.
+   * @param warn  Set the warning level (0: always display warnings,
+   *                      >0 display warnings on demand).
+   * @param withAlias outputs the alias names of the aliased
+   *                      Parameters instead of the values (default
+   *                      : true).
+   */
+
+  static void printParameters(const TransitionModel* model, OutputStream& out, int warn = 1, bool withAlias = true);
+
+
+  /**
+   * @brief Output a SubstitutionModelSet description to a file.
+   *
+   * @param modelSet The model set to serialize.
+   * @param out      The stream where to print.
+   * @param warn  Set the warning level (0: always display warnings, >0 display warnings on demand).
+   * @param withAlias outputs the alias names of the aliased
+   *                      Parameters instead of the values (default
+   *                      : true).
+   */
+
+  static void printParameters(const SubstitutionModelSet* modelSet, OutputStream& out, int warn = 1, bool withAlias = true);
+
+
+  /**
+   * @brief Output a DiscreteDistribution description to a file.
+   *
+   * @param rDist The rate distribution to serialize.
+   * @param out   The stream where to print.
+   * @param withAlias outputs the alias names of the aliased
+   *                      Parameters instead of the values (default
+   *                      : true).
+   */
+  static void printParameters(const DiscreteDistribution* rDist, OutputStream& out, bool withAlias = true);
+};
+} // end of namespace bpp.
 
+#endif  // _PHYLOGENETICSAPPLICATIONTOOLS_H_
diff --git a/src/Bpp/Phyl/BipartitionList.h b/src/Bpp/Phyl/BipartitionList.h
index db1b24c..0d42239 100644
--- a/src/Bpp/Phyl/BipartitionList.h
+++ b/src/Bpp/Phyl/BipartitionList.h
@@ -120,12 +120,7 @@ class BipartitionList:
 
     virtual ~BipartitionList();
 
-#ifndef NO_VIRTUAL_COV
-    BipartitionList*
-#else
-    Clonable*
-#endif
-    clone() const { return new BipartitionList(*this); }
+    BipartitionList* clone() const { return new BipartitionList(*this); }
 
   public:
 
diff --git a/src/Bpp/Phyl/Distance/AbstractAgglomerativeDistanceMethod.h b/src/Bpp/Phyl/Distance/AbstractAgglomerativeDistanceMethod.h
index 4041be6..ad2547d 100755
--- a/src/Bpp/Phyl/Distance/AbstractAgglomerativeDistanceMethod.h
+++ b/src/Bpp/Phyl/Distance/AbstractAgglomerativeDistanceMethod.h
@@ -119,12 +119,8 @@ class AbstractAgglomerativeDistanceMethod:
      * @return A copy of the computed tree if there is one, 0 otherwise.
      */
     virtual
-#if defined(NO_VIRTUAL_COV)
-		Tree *
-#else
-		TreeTemplate<Node> * 
-#endif
-		getTree() const
+		
+		TreeTemplate<Node> * getTree() const
     {
     	//Node * root = TreeTools::cloneSubtree<Node>(* dynamic_cast<TreeTemplate<Node> *>(tree_) -> getRootNode());
 	    //return new TreeTemplate<Node>(* root);
diff --git a/src/Bpp/Phyl/Distance/DistanceEstimation.cpp b/src/Bpp/Phyl/Distance/DistanceEstimation.cpp
index 7fa7d70..2a550b9 100755
--- a/src/Bpp/Phyl/Distance/DistanceEstimation.cpp
+++ b/src/Bpp/Phyl/Distance/DistanceEstimation.cpp
@@ -68,7 +68,7 @@ using namespace std;
 TwoTreeLikelihood::TwoTreeLikelihood(
     const std::string& seq1, const std::string& seq2,
     const SiteContainer& data,
-    SubstitutionModel* model,
+    TransitionModel* model,
     DiscreteDistribution* rDist,
     bool verbose) throw (Exception) :
   AbstractDiscreteRatesAcrossSitesTreeLikelihood(rDist, verbose),
diff --git a/src/Bpp/Phyl/Distance/DistanceEstimation.h b/src/Bpp/Phyl/Distance/DistanceEstimation.h
index 3227098..0c63d6f 100755
--- a/src/Bpp/Phyl/Distance/DistanceEstimation.h
+++ b/src/Bpp/Phyl/Distance/DistanceEstimation.h
@@ -53,9 +53,12 @@ knowledge of the CeCILL license and that you accept its terms.
 #include <Bpp/Numeric/Function/SimpleMultiDimensions.h>
 #include <Bpp/Numeric/Function/MetaOptimizer.h>
 
-// From SeqLib:
+// From bpp-seq:
 #include <Bpp/Seq/Container/SiteContainer.h>
 
+// From the STL:
+#include <memory>
+
 namespace bpp
 {
 
@@ -68,7 +71,7 @@ class TwoTreeLikelihood:
   private:
     SiteContainer* shrunkData_;
     std::vector<std::string> seqnames_;
-    SubstitutionModel* model_;
+    TransitionModel* model_;
     ParameterList brLenParameters_;
     
     mutable VVVdouble pxy_;
@@ -116,7 +119,7 @@ class TwoTreeLikelihood:
     TwoTreeLikelihood(
       const std::string& seq1, const std::string& seq2,  
       const SiteContainer& data,
-      SubstitutionModel* model,
+      TransitionModel* model,
       DiscreteDistribution* rDist,
       bool verbose)  throw (Exception);
 
@@ -159,8 +162,8 @@ class TwoTreeLikelihood:
     double getLogLikelihoodForASite(size_t site) const;
     ParameterList getBranchLengthsParameters() const;
     ParameterList getSubstitutionModelParameters() const;
-    SubstitutionModel* getSubstitutionModel(int nodeId, size_t siteIndex) throw (NodeNotFoundException) { return model_; }
-    const SubstitutionModel* getSubstitutionModel(int nodeId, size_t siteIndex) const throw (NodeNotFoundException) { return model_; }
+    TransitionModel* getSubstitutionModel(int nodeId, size_t siteIndex) throw (NodeNotFoundException) { return model_; }
+    const TransitionModel* getSubstitutionModel(int nodeId, size_t siteIndex) const throw (NodeNotFoundException) { return model_; }
     const std::vector<double>& getRootFrequencies(size_t siteIndex) const { return model_->getFrequencies(); }
     size_t getSiteIndex(size_t site) const throw (IndexOutOfBoundsException) { return rootPatternLinks_[site]; }
     /**
@@ -187,14 +190,14 @@ class TwoTreeLikelihood:
      *
      * @return A const pointer toward the substitution model of this instance.
      */
-    const SubstitutionModel* getSubstitutionModel() const { return model_; }
+    const TransitionModel* getSubstitutionModel() const { return model_; }
     
     /**
      * @brief Get the substitution model used for the computation.
      *
      * @return A pointer toward the substitution model of this instance.
      */
-    SubstitutionModel* getSubstitutionModel() { return model_; }
+    TransitionModel* getSubstitutionModel() { return model_; }
 
     ConstBranchModelIterator* getNewBranchModelIterator(int nodeId) const throw (NotImplementedException)
     {
@@ -307,8 +310,8 @@ class DistanceEstimation:
   public virtual Clonable
 {
   private:
-    auto_ptr<SubstitutionModel> model_;
-    auto_ptr<DiscreteDistribution> rateDist_;
+    std::unique_ptr<TransitionModel> model_;
+    std::unique_ptr<DiscreteDistribution> rateDist_;
     const SiteContainer* sites_;
     DistanceMatrix* dist_;
     Optimizer* optimizer_;
@@ -333,7 +336,7 @@ class DistanceEstimation:
      *  - 4=3 + likelihood object verbose enabled
      */
     DistanceEstimation(
-        SubstitutionModel* model,
+        TransitionModel* model,
         DiscreteDistribution* rateDist,
         size_t verbose = 1) :
       model_(model),
@@ -366,7 +369,7 @@ class DistanceEstimation:
      *  @param computeMat if true the computeMatrix() method is called.
      */
     DistanceEstimation(
-        SubstitutionModel* model,
+        TransitionModel* model,
         DiscreteDistribution* rateDist,
         const SiteContainer* sites,
         size_t verbose = 1,
@@ -438,12 +441,7 @@ class DistanceEstimation:
       delete optimizer_;
     }
 
-#ifndef NO_VIRTUAL_COV
-    DistanceEstimation*
-#else
-    Clonable*
-#endif
-    clone() const { return new DistanceEstimation(*this); }
+    DistanceEstimation* clone() const { return new DistanceEstimation(*this); }
     
   private:
     void init_()
@@ -481,16 +479,16 @@ class DistanceEstimation:
      */
     DistanceMatrix* getMatrix() const { return dist_ == 0 ? 0 : new DistanceMatrix(*dist_); }
 
-    bool hasSubstitutionModel() const { return model_.get(); }
+    bool hasModel() const { return model_.get(); }
 
-    const SubstitutionModel& getSubstitutionModel() const throw (Exception) {
-      if (hasSubstitutionModel())
+    const TransitionModel& getSubstitutionModel() const throw (Exception) {
+      if (hasModel())
         return *model_;
       else
         throw Exception("DistanceEstimation::getSubstitutionModel(). No model assciated to this instance.");
     }
 
-    void resetSubstitutionModel(SubstitutionModel* model = 0) { model_.reset(model); }
+    void resetSubstitutionModel(TransitionModel* model = 0) { model_.reset(model); }
 
     bool hasRateDistribution() const { return rateDist_.get(); }
 
diff --git a/src/Bpp/Phyl/Graphics/AbstractTreeDrawing.h b/src/Bpp/Phyl/Graphics/AbstractTreeDrawing.h
index f0df0b1..b0c80d3 100755
--- a/src/Bpp/Phyl/Graphics/AbstractTreeDrawing.h
+++ b/src/Bpp/Phyl/Graphics/AbstractTreeDrawing.h
@@ -156,14 +156,14 @@ class AbstractTreeDrawing:
   public virtual TreeDrawing
 {
   private:
-    std::auto_ptr<TreeTemplate<INode> > tree_;
+    std::unique_ptr<TreeTemplate<INode> > tree_;
     double xUnit_;
     double yUnit_;
     const TreeDrawingSettings* settings_;
     std::vector<TreeDrawingListener*> listeners_;
  
   public:
-    AbstractTreeDrawing(): tree_(0), xUnit_(1.), yUnit_(1.), settings_(&DEFAULT_SETTINGS), listeners_() {};
+    AbstractTreeDrawing(): tree_(), xUnit_(1.), yUnit_(1.), settings_(&DEFAULT_SETTINGS), listeners_() {};
     
     AbstractTreeDrawing(const AbstractTreeDrawing& atd) :
       tree_(atd.tree_.get() ? dynamic_cast<TreeTemplate<INode> *>(atd.tree_->clone()) : 0),
@@ -211,12 +211,7 @@ class AbstractTreeDrawing:
     
     bool hasTree() const { return tree_.get() != 0; }
 
-#ifdef NO_VIRTUAL_COV
-    Tree*
-#else
-    const TreeTemplate<INode>*
-#endif
-    getTree() const { return tree_.get(); }
+    const TreeTemplate<INode>* getTree() const { return tree_.get(); }
     
     void setTree(const Tree* tree)
     {
diff --git a/src/Bpp/Phyl/Graphics/CladogramPlot.cpp b/src/Bpp/Phyl/Graphics/CladogramPlot.cpp
index 6795c47..3c34b8b 100755
--- a/src/Bpp/Phyl/Graphics/CladogramPlot.cpp
+++ b/src/Bpp/Phyl/Graphics/CladogramPlot.cpp
@@ -91,9 +91,9 @@ void CladogramPlot::recursivePlot_(GraphicDevice& gDevice, INode& node, double x
 {
   double depth = static_cast<double>(TreeTemplateTools::getDepth(node));
   double x2 = ((getHorizontalOrientation() == ORIENTATION_LEFT_TO_RIGHT ? totalDepth_ : 0) - depth) * getXUnit() * hDirection;
-  auto_ptr<Cursor> cursor;
-  auto_ptr<DrawINodeEvent> nodeEvent;
-  auto_ptr<DrawIBranchEvent> branchEvent;
+  unique_ptr<Cursor> cursor;
+  unique_ptr<DrawINodeEvent> nodeEvent;
+  unique_ptr<DrawIBranchEvent> branchEvent;
   short hpos = (getHorizontalOrientation() == ORIENTATION_LEFT_TO_RIGHT ? GraphicDevice::TEXT_HORIZONTAL_LEFT : GraphicDevice::TEXT_HORIZONTAL_RIGHT);
   if (node.isLeaf())
   {
diff --git a/src/Bpp/Phyl/Graphics/PhylogramPlot.cpp b/src/Bpp/Phyl/Graphics/PhylogramPlot.cpp
index 789c70e..7d7d7dc 100755
--- a/src/Bpp/Phyl/Graphics/PhylogramPlot.cpp
+++ b/src/Bpp/Phyl/Graphics/PhylogramPlot.cpp
@@ -113,9 +113,9 @@ void PhylogramPlot::recursivePlot_(GraphicDevice& gDevice, INode& node, double x
     drawBranch = false;
   }
  
-  auto_ptr<Cursor> cursor;
-  auto_ptr<DrawINodeEvent> nodeEvent;
-  auto_ptr<DrawIBranchEvent> branchEvent;
+  unique_ptr<Cursor> cursor;
+  unique_ptr<DrawINodeEvent> nodeEvent;
+  unique_ptr<DrawIBranchEvent> branchEvent;
   short hpos = (getHorizontalOrientation() == ORIENTATION_LEFT_TO_RIGHT ? GraphicDevice::TEXT_HORIZONTAL_LEFT : GraphicDevice::TEXT_HORIZONTAL_RIGHT);
   if (node.isLeaf())
   {
diff --git a/src/Bpp/Phyl/Graphics/TreeDrawing.h b/src/Bpp/Phyl/Graphics/TreeDrawing.h
index 6b14891..5a96359 100644
--- a/src/Bpp/Phyl/Graphics/TreeDrawing.h
+++ b/src/Bpp/Phyl/Graphics/TreeDrawing.h
@@ -243,7 +243,7 @@ class DrawTreeEvent
 /**
  * @brief Basal interface for tree drawing classes.
  *
- * Basicly, a TreeDrawing object draw a graph of the tree and compute the coordinates
+ * Basically, a TreeDrawing object draws a graph of the tree and computes the coordinates
  * of each node on the graph. These coordinates may be retrieved by dedicated functions.
  * The drawing is performed on a GraphicDevice object.
  *
@@ -268,9 +268,7 @@ class TreeDrawing:
     TreeDrawing() {}
     virtual ~TreeDrawing() {}
  
-#ifndef NO_VIRTUAL_COV
     TreeDrawing* clone() const = 0;
-#endif
 
   public:
     /**
diff --git a/src/Bpp/Phyl/Graphics/TreeDrawingListener.h b/src/Bpp/Phyl/Graphics/TreeDrawingListener.h
index 6b2f88a..05163e1 100644
--- a/src/Bpp/Phyl/Graphics/TreeDrawingListener.h
+++ b/src/Bpp/Phyl/Graphics/TreeDrawingListener.h
@@ -56,12 +56,8 @@ class TreeDrawingListener :
   public virtual Clonable
 {
 public:
-#ifndef NO_VIRTUAL_COV
-  TreeDrawingListener*
-#else
-  Clonable*
-#endif
-  clone() const = 0;
+
+  TreeDrawingListener* clone() const = 0;
 
   virtual void beforeDrawTree(const DrawTreeEvent& event) = 0;
   virtual void afterDrawTree(const DrawTreeEvent& event) = 0;
diff --git a/src/Bpp/Phyl/Io/BppOFrequenciesSetFormat.cpp b/src/Bpp/Phyl/Io/BppOFrequenciesSetFormat.cpp
index 66a99fb..007577e 100644
--- a/src/Bpp/Phyl/Io/BppOFrequenciesSetFormat.cpp
+++ b/src/Bpp/Phyl/Io/BppOFrequenciesSetFormat.cpp
@@ -47,6 +47,7 @@
 
 //From bpp-core:
 #include <Bpp/Io/FileTools.h>
+#include <Bpp/Io/BppOParametrizableFormat.h>
 #include <Bpp/Text/TextTools.h>
 #include <Bpp/Text/StringTokenizer.h>
 #include <Bpp/Text/KeyvalTools.h>
@@ -63,6 +64,8 @@ using namespace bpp;
 // From the STL:
 #include <iomanip>
 
+#include "BppOSubstitutionModelFormat.h"
+
 using namespace std;
 
 unsigned char BppOFrequenciesSetFormat::DNA = 1;
@@ -79,7 +82,7 @@ FrequenciesSet* BppOFrequenciesSetFormat::read(const Alphabet* alphabet, const s
   string freqName;
   map<string, string> args;
   KeyvalTools::parseProcedure(freqDescription, freqName, args);
-  auto_ptr<FrequenciesSet> pFS;
+  unique_ptr<FrequenciesSet> pFS;
 
   if (freqName == "Fixed")
   {
@@ -186,7 +189,7 @@ FrequenciesSet* BppOFrequenciesSetFormat::read(const Alphabet* alphabet, const s
       }
 
       BppOFrequenciesSetFormat nestedReader(alphabetCode_, false, warningLevel_);
-      auto_ptr<FrequenciesSet> pFS2(nestedReader.read(pWA->getNAlphabet(0), sAFS, data, false));
+      unique_ptr<FrequenciesSet> pFS2(nestedReader.read(pWA->getNAlphabet(0), sAFS, data, false));
       map<string, string> unparsedParameterValuesNested(nestedReader.getUnparsedArguments());
       for (map<string, string>::iterator it = unparsedParameterValuesNested.begin(); it != unparsedParameterValuesNested.end(); it++)
       {
@@ -225,6 +228,26 @@ FrequenciesSet* BppOFrequenciesSetFormat::read(const Alphabet* alphabet, const s
       pFS.reset(new WordFromIndependentFrequenciesSet(pWA, v_AFS));
     }
   }
+  //From Model
+  else if (freqName == "FromModel")
+  {
+    if (args.find("model") == args.end())
+      throw Exception("Missing argument 'model' for frequencies " + freqName + ".");
+    
+    BppOSubstitutionModelFormat nestedReader(alphabetCode_, false, true, false, false, warningLevel_);
+    if (geneticCode_)
+      nestedReader.setGeneticCode(geneticCode_);
+
+    TransitionModel* model=nestedReader.read(alphabet, args["model"], data, false);
+    pFS.reset(new FromModelFrequenciesSet(model));
+    map<string, string> unparsedParameterValuesNested(nestedReader.getUnparsedArguments());
+    for (map<string, string>::iterator it = unparsedParameterValuesNested.begin(); it != unparsedParameterValuesNested.end(); it++)
+    {
+      unparsedArguments_["FromModel." + it->first] = it->second;
+    }
+  }
+  
+  
   // INDEPENDENT CODON
   else if (freqName == "Codon")
   {
@@ -243,7 +266,7 @@ FrequenciesSet* BppOFrequenciesSetFormat::read(const Alphabet* alphabet, const s
       string sAFS = args["frequency"];
 
       BppOFrequenciesSetFormat nestedReader(alphabetCode_, false, warningLevel_);
-      auto_ptr<FrequenciesSet> pFS2(nestedReader.read(pWA->getNAlphabet(0), sAFS, data, false));
+      unique_ptr<FrequenciesSet> pFS2(nestedReader.read(pWA->getNAlphabet(0), sAFS, data, false));
       map<string, string> unparsedParameterValuesNested(nestedReader.getUnparsedArguments());
 
       for (map<string, string>::iterator it = unparsedParameterValuesNested.begin(); it != unparsedParameterValuesNested.end(); it++)
@@ -314,7 +337,7 @@ FrequenciesSet* BppOFrequenciesSetFormat::read(const Alphabet* alphabet, const s
     {
       string sPFS = args["protein_frequencies"];
       BppOFrequenciesSetFormat nestedReader(alphabetCode_, false, warningLevel_);
-      auto_ptr<ProteinFrequenciesSet> pPFS(dynamic_cast<ProteinFrequenciesSet*>(nestedReader.read(pPA, sPFS, data, false)));
+      unique_ptr<ProteinFrequenciesSet> pPFS(dynamic_cast<ProteinFrequenciesSet*>(nestedReader.read(pPA, sPFS, data, false)));
       map<string, string> unparsedParameterValuesNested(nestedReader.getUnparsedArguments());
 
       for (map<string, string>::iterator it = unparsedParameterValuesNested.begin(); it != unparsedParameterValuesNested.end(); it++)
@@ -353,26 +376,30 @@ FrequenciesSet* BppOFrequenciesSetFormat::read(const Alphabet* alphabet, const s
     {
       opt = CodonFrequenciesSet::F1X4;
       
-      if (args.find("mgmtStopCodon") != args.end()){
+      if (args.find("mgmtStopCodons") != args.end())
+        mgmtStopCodon = args["mgmtStopCodons"];
+      else if (args.find("mgmtStopCodon") != args.end())
         mgmtStopCodon = args["mgmtStopCodon"];
-        ApplicationTools::displayResult("StopCodon frequencies distribution ", mgmtStopCodon);
-      }
+      
+      ApplicationTools::displayResult("StopCodon frequencies distribution ", mgmtStopCodon);
+
       if (args.find("frequency") != args.end())
+      {
+        string sAFS = args["frequency"];
+        
+        BppOFrequenciesSetFormat nestedReader(alphabetCode_, false, warningLevel_);
+        unique_ptr<FrequenciesSet> pFS2(nestedReader.read(pWA->getNAlphabet(0), sAFS, data, false));
+        if (pFS2->getName()!="Full")
+          throw Exception("BppOFrequenciesSetFormat::read. The frequency option in F1X4 can only be Full");
+        
+        map<string, string> unparsedParameterValuesNested(nestedReader.getUnparsedArguments());
+        
+        for (map<string, string>::iterator it = unparsedParameterValuesNested.begin(); it != unparsedParameterValuesNested.end(); it++)
         {
-          string sAFS = args["frequency"];
-
-          BppOFrequenciesSetFormat nestedReader(alphabetCode_, false, warningLevel_);
-          auto_ptr<FrequenciesSet> pFS2(nestedReader.read(pWA->getNAlphabet(0), sAFS, data, false));
-          if (pFS2->getName()!="Full")
-            throw Exception("BppOFrequenciesSetFormat::read. The frequency option in F1X4 can only be Full");
-            
-          map<string, string> unparsedParameterValuesNested(nestedReader.getUnparsedArguments());
-
-          for (map<string, string>::iterator it = unparsedParameterValuesNested.begin(); it != unparsedParameterValuesNested.end(); it++)
-            {
-              unparsedArguments_["123_" + it->first] = it->second;
-            }
+          unparsedArguments_["123_" + it->first] = it->second;
         }
+      }
+      
       if (args.find("123_theta") != args.end())
           unparsedArguments_["123_Full.theta"] = args["123_theta"];
       if (args.find("123_theta1") != args.end())
@@ -390,10 +417,12 @@ FrequenciesSet* BppOFrequenciesSetFormat::read(const Alphabet* alphabet, const s
     {
       opt = CodonFrequenciesSet::F3X4;
 
-      if (args.find("mgmtStopCodon") != args.end()){
-        mgmtStopCodon = args["mgmtStopCodon"];
-        ApplicationTools::displayResult("StopCodon frequencies distribution ", mgmtStopCodon);
-      }
+      if (args.find("mgmtStopCodons") != args.end())
+        mgmtStopCodon = args["mgmtStopCodons"];
+      else if (args.find("mgmtStopCodon") != args.end())
+          mgmtStopCodon = args["mgmtStopCodon"];
+      
+      ApplicationTools::displayResult("StopCodon frequencies distribution ", mgmtStopCodon);
 
       if (args.find("frequency1") != args.end() ||
           args.find("frequency2") != args.end() ||
@@ -455,12 +484,13 @@ FrequenciesSet* BppOFrequenciesSetFormat::read(const Alphabet* alphabet, const s
   //MVAprotein freq set for COaLA model
   else if (freqName == "MVAprotein")
   {
-	  pFS.reset(new MvaFrequenciesSet(dynamic_cast<const ProteicAlphabet*>(alphabet)));
-	  dynamic_cast<MvaFrequenciesSet*>(pFS.get())->setParamValues(args);
+    pFS.reset(new MvaFrequenciesSet(dynamic_cast<const ProteicAlphabet*>(alphabet)));
+    dynamic_cast<MvaFrequenciesSet*>(pFS.get())->setParamValues(args);
   }
   else
     throw Exception("Unknown frequency option: " + freqName);
 
+  // Update parameter args:
   vector<string> pnames = pFS->getParameters().getParameterNames();
 
   string pref = pFS->getNamespace();
@@ -471,30 +501,71 @@ FrequenciesSet* BppOFrequenciesSetFormat::read(const Alphabet* alphabet, const s
       unparsedArguments_[pref + name] = args[name];
   }
 
+  // Now look if some parameters are aliased:
+  ParameterList pl = pFS->getIndependentParameters();
+  string pname, pval, pname2;
+  for (size_t i = 0; i < pl.size(); i++)
+  {
+    pname = pFS->getParameterNameWithoutNamespace(pl[i].getName());
+
+    if (args.find(pname) == args.end())
+      continue;
+    pval = args[pname];
+
+    if (((pval.rfind("_") != string::npos) && (TextTools::isDecimalInteger(pval.substr(pval.rfind("_")+1,string::npos)))) ||
+        (pval.find("(") != string::npos))
+      continue;
+    bool found = false;
+    for (size_t j = 0; j < pl.size() && !found; j++)
+    {
+      pname2 = pFS->getParameterNameWithoutNamespace(pl[j].getName());
+
+      // if (j == i || args.find(pname2) == args.end()) continue; Julien 03/03/2010: This extra condition prevents complicated (nested) models to work properly...
+      if (j == i)
+        continue;
+      if (pval == pname2)
+      {
+        // This is an alias...
+        // NB: this may throw an exception if uncorrect! We leave it as is for now :s
+        pFS->aliasParameters(pname2, pname);
+        if (verbose_)
+          ApplicationTools::displayResult("Parameter alias found", pname + "->" + pname2);
+        found = true;
+      }
+    }
+    // if (!TextTools::isDecimalNumber(pval) && !found)
+    //   throw Exception("Incorrect parameter syntax: parameter " + pval + " was not found and can't be used as a value for parameter " + pname + ".");
+  }
+
   // Forward arguments:
   if (args.find("init") != args.end())
   {
     unparsedArguments_["init"] = args["init"];
     unparsedArguments_["initFreqs"] = args["init"];
   }
+  
   if (args.find("init.observedPseudoCount") != args.end())
   {
     unparsedArguments_["init.observedPseudoCount"] = args["init.observedPseudoCount"];
     unparsedArguments_["initFreqs.observedPseudoCount"] = args["init.observedPseudoCount"];
   }
+
   if (args.find("values") != args.end())
   {
     unparsedArguments_["initFreqs"] = "values" + args["values"];
     unparsedArguments_["init"] = "values" + args["values"];
+    initialize_(*pFS, data);    
   }
+  else 
+    if (parseArguments)
+      initialize_(*pFS, data);
 
-  if (parseArguments)
-    initialize_(*pFS, data);
   return pFS.release();
 }
 
 void BppOFrequenciesSetFormat::write(const FrequenciesSet* pfreqset,
                                      OutputStream& out,
+                                     std::map<std::string, std::string>& globalAliases,
                                      std::vector<std::string>& writtenNames) const
 {
   if (!pfreqset)
@@ -503,14 +574,16 @@ void BppOFrequenciesSetFormat::write(const FrequenciesSet* pfreqset,
     return;
   }
   ParameterList pl = pfreqset->getParameters();
+
   int p = out.getPrecision();
   out.setPrecision(12);
-  bool flag(false);
+  bool comma(false);
   string name = pfreqset->getName();
   out << name << "(";
 
-
-  if ((name == "Fixed") || (name == "F0"))
+  bool oValues=false;
+  
+  if ((name == "Fixed") || (name == "F0") || (name== "Full"))
   {
     vector<double> vf = pfreqset->getFrequencies();
     out << "values=(";
@@ -521,94 +594,137 @@ void BppOFrequenciesSetFormat::write(const FrequenciesSet* pfreqset,
       out << vf[i];
     }
     out << ")";
+
+    vector<string> npl=pl.getParameterNames();
+    writtenNames.insert(writtenNames.end(), npl.begin(), npl.end());
+
+    comma=true;
+    
+    oValues=true;
   }
-  else
+
+  
+  // For Word or Codon FS : length mgmt
+  const WordFromIndependentFrequenciesSet* pWFI = dynamic_cast<const WordFromIndependentFrequenciesSet*>(pfreqset);
+  if (name != "F3X4" && pWFI != NULL)
   {
-    if (dynamic_cast<const FullProteinFrequenciesSet*>(pfreqset))
+    for (size_t i = 0; i < pWFI->getLength(); i++)
     {
-      size_t meth=dynamic_cast<const FullProteinFrequenciesSet*>(pfreqset)->getMethod();
-      if (meth>1){
-        if (flag)
-          out << ",";
-        out << "method=" << ((meth==2)?"local":"binary");
-        flag=true;
-      }
+      if (i != 0)
+        out << ", ";
+      out << "frequency" << i + 1 << "=";
+      write(&pWFI->getFrequenciesSetForLetter(i), out, globalAliases, writtenNames);
     }
-    else
+      comma = true;
+  }
+  
+  const WordFromUniqueFrequenciesSet* pWFU = dynamic_cast<const WordFromUniqueFrequenciesSet*>(pfreqset);
+  if (name != "F1X4" && pWFU != NULL)
+  {
+    for (size_t i = 0; i < pWFU->getLength(); i++)
     {
-      if (name != "F1X4" && name != "F3X4" && name != "F61")
-      {
-        const WordFromIndependentFrequenciesSet* pWFI = dynamic_cast<const WordFromIndependentFrequenciesSet*>(pfreqset);
-        if (pWFI != NULL)
-        {
-          for (size_t i = 0; i < pWFI->getLength(); i++)
-          {
-            if (i != 0)
-              out << ", ";
-            out << "frequency" << i + 1 << "=";
-            write(&pWFI->getFrequenciesSetForLetter(i), out, writtenNames);
-          }
-          flag = true;
-        }
-        const WordFromUniqueFrequenciesSet* pWFU = dynamic_cast<const WordFromUniqueFrequenciesSet*>(pfreqset);
-        if (pWFU != NULL)
-        {
-          for (size_t i = 0; i < pWFU->getLength(); i++)
-          {
-            if (i != 0)
-              out << ", ";
-            out << "frequency=";
-            write(&pWFU->getFrequenciesSetForLetter(i), out, writtenNames);
-          }
-          flag = true;
-        }
-        const FullPerAACodonFrequenciesSet* pFPA=dynamic_cast<const FullPerAACodonFrequenciesSet*>(pfreqset);
-        if (pFPA != NULL)
-        {
-          const ProteinFrequenciesSet* ppfs=pFPA->getProteinFrequenciesSet();
-          out << "protein_frequencies=";
-          
-          write(ppfs, out, writtenNames);
-      
-          flag = true;
-              
-          unsigned short meth=pFPA->getMethod();
-          if (meth>1){
-            if (flag)
-              out << ",";
-            out << "method=" << ((meth==2)?"local":"binary");
-            flag=true;
-          }
-        }
-      }
+      if (i != 0)
+        out << ", ";
+      out << "frequency=";
+      write(&pWFU->getFrequenciesSetForLetter(i), out, globalAliases, writtenNames);
     }
+    comma = true;
+  }
 
+  //FromModel
+
+  const FromModelFrequenciesSet* pFMFS = dynamic_cast<const FromModelFrequenciesSet*>(pfreqset);
+  if (pFMFS != NULL)
+  {
+    if (comma)
+      out << ", ";
+    out << "model=";
     
-    for (size_t i = 0; i < pl.size(); i++)
+    BppOSubstitutionModelFormat bIO(BppOSubstitutionModelFormat::ALL, true, true, true, false, 0);
+
+    bIO.write(*(pFMFS->getModel()), out, globalAliases, writtenNames);
+    comma = true;
+  }
+
+  
+  // FullPerAA
+  const FullPerAACodonFrequenciesSet* pFPA=dynamic_cast<const FullPerAACodonFrequenciesSet*>(pfreqset);
+  if (pFPA != NULL)
+  {
+    const ProteinFrequenciesSet* ppfs=pFPA->getProteinFrequenciesSet();
+    out << "protein_frequencies=";
+    
+    write(ppfs, out, globalAliases, writtenNames);
+    
+    comma = true;
+    
+    unsigned short meth=pFPA->getMethod();
+    if (meth>1){
+      if (comma)
+        out << ",";
+      out << "method=" << ((meth==2)?"local":"binary");
+      comma=true;
+    }
+  }
+
+
+  // method 
+  if (dynamic_cast<const FullProteinFrequenciesSet*>(pfreqset))
+  {
+    size_t meth=dynamic_cast<const FullProteinFrequenciesSet*>(pfreqset)->getMethod();
+    if (meth>1){
+      if (comma)
+        out << ",";
+      out << "method=" << ((meth==2)?"local":"binary");
+      comma=true;
+    }
+  }
+  
+  const FullCodonFrequenciesSet* pF=dynamic_cast<const FullCodonFrequenciesSet*>(pfreqset);
+  if (pF != NULL)
+  {
+    unsigned short meth=pF->getMethod();
+    if (meth>1){
+      if (comma)
+        out << ",";
+      out << "method=" << ((meth==2)?"local":"binary");
+      comma=true;
+    }
+  }
+
+  // mgmtStopCodon 
+  const CodonFromUniqueFrequenciesSet* pCFU = dynamic_cast<const CodonFromUniqueFrequenciesSet*>(pfreqset);
+  if (pCFU != NULL)
+  {
+    if (pCFU->getMgmtStopCodon()!="quadratic")
     {
-      if (find(writtenNames.begin(), writtenNames.end(), pl[i].getName()) == writtenNames.end())
-      {
-        if (flag)
-          out << ",";
-        else
-          flag = true;
-        string pname = pfreqset->getParameterNameWithoutNamespace(pl[i].getName());
-        (out << pname << "=").enableScientificNotation(false) << pl[i].getValue();
-        writtenNames.push_back(pl[i].getName());
-      }
+      if (comma)
+        out << ",";
+      out << "mgmtStopCodons=" << pCFU->getMgmtStopCodon();
+      comma = true;
     }
-    const FullCodonFrequenciesSet* pF=dynamic_cast<const FullCodonFrequenciesSet*>(pfreqset);
-    if (pF != NULL)
+  }
+    
+  const CodonFromIndependentFrequenciesSet* pCFI = dynamic_cast<const CodonFromIndependentFrequenciesSet*>(pfreqset);
+  if (pCFI != NULL)
+  {
+    if (pCFI->getMgmtStopCodon()!="quadratic")
     {
-      unsigned short meth=pF->getMethod();
-      if (meth>1){
-        if (flag)
-          out << ",";
-        out << "method=" << ((meth==2)?"local":"binary");
-        flag=true;
-      }
+      if (comma)
+        out << ",";
+      out << "mgmtStopCodons=" << pCFI->getMgmtStopCodon();
+      comma = true;
     }
   }
+
+// All remaining parameters
+  if (!oValues)
+  {
+    const BppOParametrizableFormat* bIO = new BppOParametrizableFormat();
+  
+    bIO->write(pfreqset, out, globalAliases, pl.getParameterNames(), writtenNames, true, comma);
+    delete bIO;
+  }
   
   out << ")";
   out.setPrecision(p);
@@ -620,6 +736,7 @@ void BppOFrequenciesSetFormat::initialize_(FrequenciesSet& freqSet, const SiteCo
   {
     // Initialization using the "init" option
     string init = unparsedArguments_["init"];
+
     if (init == "observed")
     {
       if (!data)
@@ -650,12 +767,15 @@ void BppOFrequenciesSetFormat::initialize_(FrequenciesSet& freqSet, const SiteCo
     }
     else
       throw Exception("Unknown init argument");
+
+    unparsedArguments_.erase(unparsedArguments_.find("init"));
+    unparsedArguments_.erase(unparsedArguments_.find("initFreqs"));    
   }
   else
   {
     // Explicit initialization of each parameter
-    ParameterList pl = freqSet.getParameters();
-
+    ParameterList pl = freqSet.getIndependentParameters();
+      
     for (size_t i = 0; i < pl.size(); ++i)
     {
       AutoParameter ap(pl[i]);
@@ -667,13 +787,21 @@ void BppOFrequenciesSetFormat::initialize_(FrequenciesSet& freqSet, const SiteCo
     for (size_t i = 0; i < pl.size(); ++i)
     {
       const string pName = pl[i].getName();
-      double value = ApplicationTools::getDoubleParameter(pName, unparsedArguments_, pl[i].getValue(), "", true, warningLevel_);
+      
+      try {
+        double value = ApplicationTools::getDoubleParameter(pName, unparsedArguments_, pl[i].getValue(), "", true, warningLevel_);
 
-      pl[i].setValue(value);
-      if (verbose_)
-        ApplicationTools::displayResult("Parameter found", pName + "=" + TextTools::toString(pl[i].getValue()));
-    }
+        pl[i].setValue(value);
+
+        if (unparsedArguments_.find(pName) != unparsedArguments_.end())
+          unparsedArguments_.erase(unparsedArguments_.find(pName));
 
+        if (verbose_)
+          ApplicationTools::displayResult("Parameter found", pName + "=" + TextTools::toString(pl[i].getValue()));
+      }
+      catch (Exception& e) {}
+    }
+    
     freqSet.matchParametersValues(pl);
   }
 }
diff --git a/src/Bpp/Phyl/Io/BppOFrequenciesSetFormat.h b/src/Bpp/Phyl/Io/BppOFrequenciesSetFormat.h
index a86ccfa..8728681 100644
--- a/src/Bpp/Phyl/Io/BppOFrequenciesSetFormat.h
+++ b/src/Bpp/Phyl/Io/BppOFrequenciesSetFormat.h
@@ -127,6 +127,7 @@ public:
   void write(
       const FrequenciesSet* pfreqset,
       OutputStream& out,
+      std::map<std::string, std::string>& globalAliases,
       std::vector<std::string>& writtenNames) const;
 
 private:
diff --git a/src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h b/src/Bpp/Phyl/Io/BppOMultiTreeReaderFormat.cpp
old mode 100755
new mode 100644
similarity index 60%
copy from src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h
copy to src/Bpp/Phyl/Io/BppOMultiTreeReaderFormat.cpp
index 897ed67..939ebbd
--- a/src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h
+++ b/src/Bpp/Phyl/Io/BppOMultiTreeReaderFormat.cpp
@@ -1,11 +1,11 @@
 //
-// File: NucleicSubstitutionModel.h
+// File: BppOMultiTreeReaderFormat.cpp
 // Created by: Julien Dutheil
-// Created on: Tue May 27 11:03:53 2003
+// Created on: Sun Jun 19th, 13:16
 //
 
 /*
-  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+  Copyright or © or Copr. Bio++ Development Team, (November 2016)
 
   This software is a computer program whose purpose is to provide classes
   for phylogenetic data analysis.
@@ -37,39 +37,43 @@
   knowledge of the CeCILL license and that you accept its terms.
 */
 
-#ifndef _NUCLEICSUBSTITUTIONMODEL_H_
-#define _NUCLEICSUBSTITUTIONMODEL_H_
+#include "BppOMultiTreeReaderFormat.h"
+#include "Newick.h"
+#include "NexusIoTree.h"
+#include "Nhx.h"
 
-#include "../SubstitutionModel.h"
+#include <Bpp/Text/KeyvalTools.h>
 
-// From SeqLib:
-#include <Bpp/Seq/Alphabet/NucleicAlphabet.h>
+#include <string>
+#include <memory>
 
-namespace bpp
-{
+using namespace bpp;
+using namespace std;
 
-/**
- * @brief Specialisation interface for nucleotide substitution model.
- */
-  class NucleotideSubstitutionModel :
-    public virtual SubstitutionModel
+IMultiTree* BppOMultiTreeReaderFormat::read(const std::string& description) throw (Exception)
+{
+  unparsedArguments_.clear();
+  string format = "";
+  KeyvalTools::parseProcedure(description, format, unparsedArguments_);
+  unique_ptr<IMultiTree> iTrees;
+  if (format == "Newick")
   {
-  public:
-    virtual ~NucleotideSubstitutionModel() {}
-
-#ifndef NO_VIRTUAL_COV
-    NucleotideSubstitutionModel*
-#else
-    Clonable*
-#endif
-    clone() const = 0;
-
-  public:
-    virtual size_t getNumberOfStates() const { return 4; }
-
-  };
-
-} //end of namespace bpp.
+    bool allowComments = ApplicationTools::getBooleanParameter("allow_comments", unparsedArguments_, false, "", true, warningLevel_);
+    iTrees.reset(new Newick(allowComments));
+  }
+  else if (format == "Nhx")
+  {
+    iTrees.reset(new Nhx());
+  }
+  else if (format == "Nexus")
+  {
+    iTrees.reset(new NexusIOTree());
+  }
+  else
+  {
+    throw Exception("Trees format '" + format + "' unknown.");
+  }
 
-#endif	//_NUCLEICSUBSTITUTIONMODEL_H_
+  return iTrees.release();
+}
 
diff --git a/src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h b/src/Bpp/Phyl/Io/BppOMultiTreeReaderFormat.h
old mode 100755
new mode 100644
similarity index 51%
copy from src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h
copy to src/Bpp/Phyl/Io/BppOMultiTreeReaderFormat.h
index 897ed67..0777d40
--- a/src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h
+++ b/src/Bpp/Phyl/Io/BppOMultiTreeReaderFormat.h
@@ -1,11 +1,11 @@
 //
-// File: NucleicSubstitutionModel.h
+// File: BppOMultiTreeReaderFormat.h
 // Created by: Julien Dutheil
-// Created on: Tue May 27 11:03:53 2003
+// Created on: Sun Jun 19th, 13:14
 //
 
 /*
-  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+  Copyright or © or Copr. Bio++ Development Team, (2016)
 
   This software is a computer program whose purpose is to provide classes
   for phylogenetic data analysis.
@@ -37,39 +37,59 @@
   knowledge of the CeCILL license and that you accept its terms.
 */
 
-#ifndef _NUCLEICSUBSTITUTIONMODEL_H_
-#define _NUCLEICSUBSTITUTIONMODEL_H_
+#ifndef _BPPOMULTITREEREADERFORMAT_H_
+#define _BPPOMULTITREEREADERFORMAT_H_
 
-#include "../SubstitutionModel.h"
-
-// From SeqLib:
-#include <Bpp/Seq/Alphabet/NucleicAlphabet.h>
+#include "IoTreeFactory.h"
 
 namespace bpp
 {
 
-/**
- * @brief Specialisation interface for nucleotide substitution model.
- */
-  class NucleotideSubstitutionModel :
-    public virtual SubstitutionModel
+  /**
+   * @brief Tree I/O in BppO format.
+   *
+   * Creates a new IMultiTree object according to
+   * distribution description syntax (see the Bio++ Program Suite
+   * manual for a detailed description of this syntax).
+   *
+   */
+  class BppOMultiTreeReaderFormat:
+    public virtual IOFormat
   {
+  private:
+    std::map<std::string, std::string> unparsedArguments_;
+    int warningLevel_;
+
   public:
-    virtual ~NucleotideSubstitutionModel() {}
+    BppOMultiTreeReaderFormat(int warningLevel):
+      unparsedArguments_(), warningLevel_(warningLevel) {}
 
-#ifndef NO_VIRTUAL_COV
-    NucleotideSubstitutionModel*
-#else
-    Clonable*
-#endif
-    clone() const = 0;
+    virtual ~BppOMultiTreeReaderFormat() {}
 
   public:
-    virtual size_t getNumberOfStates() const { return 4; }
+    const std::string getFormatName() const { return "BppO"; }
+
+    const std::string getFormatDescription() const { return "Bpp Options format."; }
+
+    const std::string getDataType() const { return "Trees reader"; }
+
+    /**
+     * @brief Read a IMultiTree object from a string.
+     *
+     * @param description A string describing the reader in the keyval syntax.
+     * @return A new IMultiTree object according to options specified.
+     * @throw Exception if an error occured.
+     */
+    IMultiTree* read(const std::string& description) throw (Exception);
+
+    /**
+     * @return The arguments and their unparsed values from the last call of the read function, if there are any.
+     */
+    virtual const std::map<std::string, std::string>& getUnparsedArguments() const { return unparsedArguments_; }
 
   };
 
 } //end of namespace bpp.
 
-#endif	//_NUCLEICSUBSTITUTIONMODEL_H_
+#endif //_BPPOMULTITREEREADERFORMAT_H_
 
diff --git a/src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h b/src/Bpp/Phyl/Io/BppOMultiTreeWriterFormat.cpp
old mode 100755
new mode 100644
similarity index 60%
copy from src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h
copy to src/Bpp/Phyl/Io/BppOMultiTreeWriterFormat.cpp
index 897ed67..25be3f0
--- a/src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h
+++ b/src/Bpp/Phyl/Io/BppOMultiTreeWriterFormat.cpp
@@ -1,11 +1,11 @@
 //
-// File: NucleicSubstitutionModel.h
+// File: BppOMultiTreeWriterFormat.cpp
 // Created by: Julien Dutheil
-// Created on: Tue May 27 11:03:53 2003
+// Created on: Sun Jun 19th, 13:16
 //
 
 /*
-  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+  Copyright or © or Copr. Bio++ Development Team, (November 2016)
 
   This software is a computer program whose purpose is to provide classes
   for phylogenetic data analysis.
@@ -37,39 +37,43 @@
   knowledge of the CeCILL license and that you accept its terms.
 */
 
-#ifndef _NUCLEICSUBSTITUTIONMODEL_H_
-#define _NUCLEICSUBSTITUTIONMODEL_H_
+#include "BppOMultiTreeWriterFormat.h"
+#include "Newick.h"
+#include "NexusIoTree.h"
+#include "Nhx.h"
 
-#include "../SubstitutionModel.h"
+#include <Bpp/Text/KeyvalTools.h>
 
-// From SeqLib:
-#include <Bpp/Seq/Alphabet/NucleicAlphabet.h>
+#include <string>
+#include <memory>
 
-namespace bpp
-{
+using namespace bpp;
+using namespace std;
 
-/**
- * @brief Specialisation interface for nucleotide substitution model.
- */
-  class NucleotideSubstitutionModel :
-    public virtual SubstitutionModel
+OMultiTree* BppOMultiTreeWriterFormat::read(const std::string& description) throw (Exception)
+{
+  unparsedArguments_.clear();
+  string format = "";
+  KeyvalTools::parseProcedure(description, format, unparsedArguments_);
+  unique_ptr<OMultiTree> oTrees;
+  if (format == "Newick")
   {
-  public:
-    virtual ~NucleotideSubstitutionModel() {}
-
-#ifndef NO_VIRTUAL_COV
-    NucleotideSubstitutionModel*
-#else
-    Clonable*
-#endif
-    clone() const = 0;
-
-  public:
-    virtual size_t getNumberOfStates() const { return 4; }
-
-  };
-
-} //end of namespace bpp.
+    bool allowComments = ApplicationTools::getBooleanParameter("allow_comments", unparsedArguments_, false, "", true, warningLevel_);
+    oTrees.reset(new Newick(allowComments));
+  }
+  else if (format == "Nhx")
+  {
+    oTrees.reset(new Nhx());
+  }
+  else if (format == "Nexus")
+  {
+    oTrees.reset(new NexusIOTree());
+  }
+  else
+  {
+    throw Exception("Trees format '" + format + "' unknown.");
+  }
 
-#endif	//_NUCLEICSUBSTITUTIONMODEL_H_
+  return oTrees.release();
+}
 
diff --git a/src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h b/src/Bpp/Phyl/Io/BppOMultiTreeWriterFormat.h
old mode 100755
new mode 100644
similarity index 51%
copy from src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h
copy to src/Bpp/Phyl/Io/BppOMultiTreeWriterFormat.h
index 897ed67..e9a78a6
--- a/src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h
+++ b/src/Bpp/Phyl/Io/BppOMultiTreeWriterFormat.h
@@ -1,11 +1,11 @@
 //
-// File: NucleicSubstitutionModel.h
+// File: BppOMultiTreeWriterFormat.h
 // Created by: Julien Dutheil
-// Created on: Tue May 27 11:03:53 2003
+// Created on: Sun Jun 19th, 13:14
 //
 
 /*
-  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+  Copyright or © or Copr. Bio++ Development Team, (2016)
 
   This software is a computer program whose purpose is to provide classes
   for phylogenetic data analysis.
@@ -37,39 +37,59 @@
   knowledge of the CeCILL license and that you accept its terms.
 */
 
-#ifndef _NUCLEICSUBSTITUTIONMODEL_H_
-#define _NUCLEICSUBSTITUTIONMODEL_H_
+#ifndef _BPPOMULTITREEWRITERFORMAT_H_
+#define _BPPOMULTITREEWRITERFORMAT_H_
 
-#include "../SubstitutionModel.h"
-
-// From SeqLib:
-#include <Bpp/Seq/Alphabet/NucleicAlphabet.h>
+#include "IoTreeFactory.h"
 
 namespace bpp
 {
 
-/**
- * @brief Specialisation interface for nucleotide substitution model.
- */
-  class NucleotideSubstitutionModel :
-    public virtual SubstitutionModel
+  /**
+   * @brief Tree I/O in BppO format.
+   *
+   * Creates a new IMultiTree object according to
+   * distribution description syntax (see the Bio++ Program Suite
+   * manual for a detailed description of this syntax).
+   *
+   */
+  class BppOMultiTreeWriterFormat:
+    public virtual IOFormat
   {
+  private:
+    std::map<std::string, std::string> unparsedArguments_;
+    int warningLevel_;
+
   public:
-    virtual ~NucleotideSubstitutionModel() {}
+    BppOMultiTreeWriterFormat(int warningLevel):
+      unparsedArguments_(), warningLevel_(warningLevel) {}
 
-#ifndef NO_VIRTUAL_COV
-    NucleotideSubstitutionModel*
-#else
-    Clonable*
-#endif
-    clone() const = 0;
+    virtual ~BppOMultiTreeWriterFormat() {}
 
   public:
-    virtual size_t getNumberOfStates() const { return 4; }
+    const std::string getFormatName() const { return "BppO"; }
+
+    const std::string getFormatDescription() const { return "Bpp Options format."; }
+
+    const std::string getDataType() const { return "Trees writer"; }
+
+    /**
+     * @brief Read a OMultiTree object from a string.
+     *
+     * @param description A string describing the reader in the keyval syntax.
+     * @return A new OMultiTree object according to options specified.
+     * @throw Exception if an error occured.
+     */
+    OMultiTree* read(const std::string& description) throw (Exception);
+
+    /**
+     * @return The arguments and their unparsed values from the last call of the read function, if there are any.
+     */
+    virtual const std::map<std::string, std::string>& getUnparsedArguments() const { return unparsedArguments_; }
 
   };
 
 } //end of namespace bpp.
 
-#endif	//_NUCLEICSUBSTITUTIONMODEL_H_
+#endif //_BPPOMULTITREEWRITERFORMAT_H_
 
diff --git a/src/Bpp/Phyl/Io/BppORateDistributionFormat.cpp b/src/Bpp/Phyl/Io/BppORateDistributionFormat.cpp
index 5282803..38b6628 100644
--- a/src/Bpp/Phyl/Io/BppORateDistributionFormat.cpp
+++ b/src/Bpp/Phyl/Io/BppORateDistributionFormat.cpp
@@ -66,7 +66,7 @@ DiscreteDistribution* BppORateDistributionFormat::read(
   string distName;
   map<string, string> args;
   KeyvalTools::parseProcedure(distDescription, distName, args);
-  auto_ptr<DiscreteDistribution> rDist;
+  unique_ptr<DiscreteDistribution> rDist;
 
   if (distName == "Uniform")
     throw Exception("BppO Warning: Uniform distribution is deprecated, use Constant instead.");
@@ -102,7 +102,7 @@ DiscreteDistribution* BppORateDistributionFormat::read(
       throw Exception("BppORateDistributionFormat::read(). Constant distribution not allowed.");
 
     if (args.find("value") != args.end())
-      throw Exception("Found argument 'value' in Constant distribution. Constant distribution is defined to have an average of 1.");
+      ApplicationTools::displayMessage("Found argument 'value' in Constant distribution. Constant distribution is defined to have an average of 1.");
     rDist.reset(new ConstantRateDistribution());
   }
   else if (distName == "Simple")
@@ -183,7 +183,7 @@ DiscreteDistribution* BppORateDistributionFormat::read(
     for (unsigned i = 0; i < v_nestedDistrDescr.size(); i++)
     {
       BppORateDistributionFormat nestedReader(false);
-      auto_ptr<DiscreteDistribution> pdd(nestedReader.read(v_nestedDistrDescr[i], false));
+      unique_ptr<DiscreteDistribution> pdd(nestedReader.read(v_nestedDistrDescr[i], false));
       map<string, string> unparsedArgumentsNested(nestedReader.getUnparsedArguments());
 
       for (map<string, string>::iterator it = unparsedArgumentsNested.begin(); it != unparsedArgumentsNested.end(); it++)
diff --git a/src/Bpp/Phyl/Io/BppOSubstitutionModelFormat.cpp b/src/Bpp/Phyl/Io/BppOSubstitutionModelFormat.cpp
index 37a7e37..c73d0ae 100644
--- a/src/Bpp/Phyl/Io/BppOSubstitutionModelFormat.cpp
+++ b/src/Bpp/Phyl/Io/BppOSubstitutionModelFormat.cpp
@@ -5,37 +5,37 @@
 //
 
 /*
-   Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
-
-   This software is a computer program whose purpose is to provide classes
-   for phylogenetic data analysis.
-
-   This software is governed by the CeCILL  license under French law and
-   abiding by the rules of distribution of free software.  You can  use,
-   modify and/ or redistribute the software under the terms of the CeCILL
-   license as circulated by CEA, CNRS and INRIA at the following URL
-   "http://www.cecill.info".
-
-   As a counterpart to the access to the source code and  rights to copy,
-   modify and redistribute granted by the license, users are provided only
-   with a limited warranty  and the software's author,  the holder of the
-   economic rights,  and the successive licensors  have only  limited
-   liability.
-
-   In this respect, the user's attention is drawn to the risks associated
-   with loading,  using,  modifying and/or developing or reproducing the
-   software by the user in light of its specific status of free software,
-   that may mean  that it is complicated to manipulate,  and  that  also
-   therefore means  that it is reserved for developers  and  experienced
-   professionals having in-depth computer knowledge. Users are therefore
-   encouraged to load and test the software's suitability as regards their
-   requirements in conditions enabling the security of their systems and/or
-   data to be ensured and,  more generally, to use and operate it in the
-   same conditions as regards security.
-
-   The fact that you are presently reading this means that you have had
-   knowledge of the CeCILL license and that you accept its terms.
- */
+  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
+
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use,
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info".
+
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability.
+
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or
+  data to be ensured and,  more generally, to use and operate it in the
+  same conditions as regards security.
+
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
+*/
 
 #include "BppOSubstitutionModelFormat.h"
 #include "BppORateDistributionFormat.h"
@@ -45,21 +45,29 @@
 #include <Bpp/Text/StringTokenizer.h>
 #include <Bpp/Text/KeyvalTools.h>
 
+#include "../Model/WordSubstitutionModel.h"
+#include "../Model/KroneckerWordSubstitutionModel.h"
 #include "../Model/Codon/MG94.h"
 #include "../Model/Codon/GY94.h"
-#include "../Model/Codon/YNGKP_M1.h"
-#include "../Model/Codon/YNGKP_M2.h"
-#include "../Model/Codon/YNGKP_M3.h"
-#include "../Model/Codon/YNGKP_M7.h"
-#include "../Model/Codon/YNGKP_M8.h"
+#include "../Model/Codon/YNGP_M1.h"
+#include "../Model/Codon/YNGP_M2.h"
+#include "../Model/Codon/YNGP_M3.h"
+#include "../Model/Codon/YNGP_M7.h"
+#include "../Model/Codon/YNGP_M8.h"
+#include "../Model/Codon/YNGP_M9.h"
+#include "../Model/Codon/YNGP_M10.h"
 #include "../Model/Codon/YN98.h"
 #include "../Model/Codon/TripletSubstitutionModel.h"
 #include "../Model/Codon/CodonRateSubstitutionModel.h"
 #include "../Model/Codon/CodonDistanceSubstitutionModel.h"
+#include "../Model/Codon/CodonDistanceCpGSubstitutionModel.h"
 #include "../Model/Codon/CodonRateFrequenciesSubstitutionModel.h"
+#include "../Model/Codon/KroneckerCodonDistanceFrequenciesSubstitutionModel.h"
+#include "../Model/Codon/KroneckerCodonDistanceSubstitutionModel.h"
+#include "../Model/Codon/KCM.h"
 #include "../Model/Codon/CodonDistanceFrequenciesSubstitutionModel.h"
 #include "../Model/Codon/CodonDistancePhaseFrequenciesSubstitutionModel.h"
-#include "../Model/Codon/CodonDistanceFitnessPhaseFrequenciesSubstitutionModel.h"
+#include "../Model/Codon/SENCA.h"
 #include "../Model/RE08.h"
 #include "../Model/TS98.h"
 #include "../Model/G2001.h"
@@ -94,6 +102,8 @@
 #include "../Model/Protein/LLG08_EHO.h"
 #include "../Model/Protein/LG10_EX_EHO.h"
 #include "../Model/BinarySubstitutionModel.h"
+#include "../Model/FromMixtureSubstitutionModel.h"
+#include "../Model/OneChangeTransitionModel.h"
 
 #include "../App/PhylogeneticsApplicationTools.h"
 
@@ -111,10 +121,14 @@
 #include <Bpp/Numeric/Prob/ConstantDistribution.h>
 #include <Bpp/Numeric/AutoParameter.h>
 
+
+#include <Bpp/Text/StringTokenizer.h>
+
 using namespace bpp;
 
 // From the STL:
 #include <iomanip>
+#include <set>
 
 using namespace std;
 
@@ -129,17 +143,18 @@ unsigned char BppOSubstitutionModelFormat::ALL = 1 | 2 | 4 | 8 | 16 | 32;
 
 
 SubstitutionModel* BppOSubstitutionModelFormat::read(
-    const Alphabet* alphabet,
-    const std::string& modelDescription,
-    const SiteContainer* data,
-    bool parseArguments)
+  const Alphabet* alphabet,
+  const std::string& modelDescription,
+  const SiteContainer* data,
+  bool parseArguments)
 {
   unparsedArguments_.clear();
-  auto_ptr<SubstitutionModel> model;
+  unique_ptr<SubstitutionModel> model;
   string modelName = "";
   map<string, string> args;
   KeyvalTools::parseProcedure(modelDescription, modelName, args);
 
+  
   // //////////////////////////////////
   // / MIXED MODELS
   // ////////////////////////////////
@@ -152,7 +167,7 @@ SubstitutionModel* BppOSubstitutionModelFormat::read(
   // / WORDS and CODONS
   // ///////////////////////////////
 
-  else if ((modelName == "Word") || (modelName == "Triplet") || (modelName.substr(0, 5) == "Codon"))
+  else if ((modelName == "Word") || (modelName.substr(0,4) == "Kron") || (modelName == "Triplet") || (modelName.substr(0, 5) == "Codon") || (modelName == "SENCA") )
     model.reset(readWord_(alphabet, modelDescription, data));
 
 
@@ -161,7 +176,9 @@ SubstitutionModel* BppOSubstitutionModelFormat::read(
   // //////////////////////////////////////
 
   else if (((modelName == "MG94") || (modelName == "YN98") ||
-            (modelName == "GY94") || (modelName.substr(0, 5) == "YNGKP")) && (alphabetCode_ & CODON))
+            (modelName == "GY94") || (modelName.substr(0, 4) == "YNGP") ||
+            (modelName.substr(0,3) == "KCM")
+             ) && (alphabetCode_ & CODON))
   {
     if (!(alphabetCode_ & CODON))
       throw Exception("BppOSubstitutionModelFormat::read. Codon alphabet not supported.");
@@ -184,7 +201,7 @@ SubstitutionModel* BppOSubstitutionModelFormat::read(
     string freqOpt = ApplicationTools::getStringParameter("frequencies", args, "F0", "", true, warningLevel_);
     BppOFrequenciesSetFormat freqReader(BppOFrequenciesSetFormat::ALL, verbose_, warningLevel_);
     freqReader.setGeneticCode(geneticCode_); //This uses the same instance as the one that will be used by the model.
-    auto_ptr<FrequenciesSet> codonFreqs(freqReader.read(pCA, freqOpt, data, false));
+    unique_ptr<FrequenciesSet> codonFreqs(freqReader.read(pCA, freqOpt, data, false));
     map<string, string> unparsedParameterValuesNested(freqReader.getUnparsedArguments());
 
     for (map<string, string>::iterator it = unparsedParameterValuesNested.begin(); it != unparsedParameterValuesNested.end(); it++)
@@ -196,18 +213,18 @@ SubstitutionModel* BppOSubstitutionModelFormat::read(
       model.reset(new MG94(geneticCode_, codonFreqs.release()));
     else if (modelName == "GY94")
       model.reset(new GY94(geneticCode_, codonFreqs.release()));
-    else if ((modelName == "YN98") || (modelName == "YNGKP_M0"))
+    else if ((modelName == "YN98") || (modelName == "YNGP_M0"))
       model.reset(new YN98(geneticCode_, codonFreqs.release()));
-    else if (modelName == "YNGKP_M1")
-      model.reset(new YNGKP_M1(geneticCode_, codonFreqs.release()));
-    else if (modelName == "YNGKP_M2")
-      model.reset(new YNGKP_M2(geneticCode_, codonFreqs.release()));
-    else if (modelName == "YNGKP_M3")
+    else if (modelName == "YNGP_M1")
+      model.reset(new YNGP_M1(geneticCode_, codonFreqs.release()));
+    else if (modelName == "YNGP_M2")
+      model.reset(new YNGP_M2(geneticCode_, codonFreqs.release()));
+    else if (modelName == "YNGP_M3")
       if (args.find("n") == args.end())
-        model.reset(new YNGKP_M3(geneticCode_, codonFreqs.release()));
+        model.reset(new YNGP_M3(geneticCode_, codonFreqs.release()));
       else
-        model.reset(new YNGKP_M3(geneticCode_, codonFreqs.release(), TextTools::to<unsigned int>(args["n"])));
-    else if ((modelName == "YNGKP_M7") || modelName == "YNGKP_M8")
+        model.reset(new YNGP_M3(geneticCode_, codonFreqs.release(), TextTools::to<unsigned int>(args["n"])));
+    else if ((modelName == "YNGP_M7") || modelName == "YNGP_M8")
     {
       if (args.find("n") == args.end())
         throw Exception("Missing argument 'n' (number of classes) in " + modelName + " distribution");
@@ -215,45 +232,37 @@ SubstitutionModel* BppOSubstitutionModelFormat::read(
       if (verbose_)
         ApplicationTools::displayResult("Number of classes in model", nbClasses);
 
-      if (modelName == "YNGKP_M7")
-        model.reset(new YNGKP_M7(geneticCode_, codonFreqs.release(), nbClasses));
-      else if (modelName == "YNGKP_M8")
-        model.reset(new YNGKP_M8(geneticCode_, codonFreqs.release(), nbClasses));
+      if (modelName == "YNGP_M7")
+        model.reset(new YNGP_M7(geneticCode_, codonFreqs.release(), nbClasses));
+      else if (modelName == "YNGP_M8")
+        model.reset(new YNGP_M8(geneticCode_, codonFreqs.release(), nbClasses));
+    }
+    else if (modelName == "YNGP_M9" || modelName == "YNGP_M10")
+    {
+      if (args.find("nbeta") == args.end())
+        throw Exception("Missing argument 'nbeta' (number of classes of beta distribution) in " + modelName + " distribution");
+      unsigned int nbBeta = TextTools::to<unsigned int>(args["nbeta"]);
+      if (args.find("ngamma") == args.end())
+        throw Exception("Missing argument 'ngamma' (number of classes of gamma distribution) in " + modelName + " distribution");
+      unsigned int nbGamma = TextTools::to<unsigned int>(args["ngamma"]);
+      if (verbose_)
+        ApplicationTools::displayResult("Number of classes in model", nbBeta + nbGamma);
+
+      if (modelName == "YNGP_M9")
+        model.reset(new YNGP_M9(geneticCode_, codonFreqs.release(), nbBeta, nbGamma));
+      else
+        model.reset(new YNGP_M10(geneticCode_, codonFreqs.release(), nbBeta, nbGamma));
     }
+    else if (modelName == "KCM7")
+      model.reset(new KCM(geneticCode_, true));
+    else if (modelName == "KCM19")
+      model.reset(new KCM(geneticCode_, false));
     else
       throw Exception("Unknown Codon model: " + modelName);
   }
 
 
   // //////////////////////////////////
-  // gBGC
-  // //////////////////////////////////
-
-  else if (modelName == "gBGC")
-  {
-    if (!(alphabetCode_ & NUCLEOTIDE))
-      throw Exception("BppOSubstitutionModelFormat::read. Nucleotide alphabet not supported.");
-    // We have to parse the nested model first:
-    string nestedModelDescription = args["model"];
-    if (TextTools::isEmpty(nestedModelDescription))
-      throw Exception("BppOSubstitutionModelFormat::read. Missing argument 'model' for model 'gBGC'.");
-    if (verbose_)
-      ApplicationTools::displayResult("Biased gene conversion", modelName);
-    BppOSubstitutionModelFormat nestedReader(NUCLEOTIDE, true, true, false, verbose_, warningLevel_);
-    auto_ptr<NucleotideSubstitutionModel> nestedModel(dynamic_cast<NucleotideSubstitutionModel*>(nestedReader.read(alphabet, nestedModelDescription, data, false)));
-    map<string, string> unparsedParameterValuesNested(nestedReader.getUnparsedArguments());
-
-    // Now we create the gBGC substitution model:
-    model.reset(new gBGC(dynamic_cast<const NucleicAlphabet*>(alphabet), nestedModel.release()));
-
-    // Then we update the parameter set:
-    for (map<string, string>::iterator it = unparsedParameterValuesNested.begin(); it != unparsedParameterValuesNested.end(); it++)
-    {
-      unparsedArguments_["gBGC." + it->first] = it->second;
-    }
-  }
-
-  // //////////////////////////////////
   // YpR
   // //////////////////////////////////
 
@@ -271,7 +280,7 @@ SubstitutionModel* BppOSubstitutionModelFormat::read(
     if (verbose_)
       ApplicationTools::displayResult("Symetric YpR model", modelName);
     BppOSubstitutionModelFormat nestedReader(NUCLEOTIDE, false, false, false, verbose_, warningLevel_);
-    auto_ptr<NucleotideSubstitutionModel> nestedModel(dynamic_cast<NucleotideSubstitutionModel*>(nestedReader.read(&prny->getLetterAlphabet(), nestedModelDescription, data, false)));
+    unique_ptr<NucleotideSubstitutionModel> nestedModel(dynamic_cast<NucleotideSubstitutionModel*>(nestedReader.read(&prny->getLetterAlphabet(), nestedModelDescription, data, false)));
     map<string, string> unparsedParameterValuesNested(nestedReader.getUnparsedArguments());
     for (map<string, string>::iterator it = unparsedParameterValuesNested.begin(); it != unparsedParameterValuesNested.end(); it++)
     {
@@ -294,7 +303,7 @@ SubstitutionModel* BppOSubstitutionModelFormat::read(
     if (verbose_)
       ApplicationTools::displayResult("General YpR model", modelName);
     BppOSubstitutionModelFormat nestedReader(NUCLEOTIDE, false, false, false, verbose_, warningLevel_);
-    auto_ptr<NucleotideSubstitutionModel> nestedModel(dynamic_cast<NucleotideSubstitutionModel*>(nestedReader.read(&prny->getLetterAlphabet(), nestedModelDescription, data, false)));
+    unique_ptr<NucleotideSubstitutionModel> nestedModel(dynamic_cast<NucleotideSubstitutionModel*>(nestedReader.read(&prny->getLetterAlphabet(), nestedModelDescription, data, false)));
     map<string, string> unparsedParameterValuesNested(nestedReader.getUnparsedArguments());
 
     for (map<string, string>::iterator it = unparsedParameterValuesNested.begin(); it != unparsedParameterValuesNested.end(); it++)
@@ -322,11 +331,40 @@ SubstitutionModel* BppOSubstitutionModelFormat::read(
     if (verbose_)
       ApplicationTools::displayResult("Gap model", modelName);
     BppOSubstitutionModelFormat nestedReader(ALL, allowCovarions_, false, false, verbose_, warningLevel_);
-    auto_ptr<ReversibleSubstitutionModel> nestedModel(dynamic_cast<ReversibleSubstitutionModel*>(nestedReader.read(alphabet, nestedModelDescription, data, false)));
+    if (geneticCode_)
+      nestedReader.setGeneticCode(geneticCode_);
+    unique_ptr<ReversibleSubstitutionModel> nestedModel(dynamic_cast<ReversibleSubstitutionModel*>(nestedReader.read(alphabet, nestedModelDescription, data, false)));
     map<string, string> unparsedParameterValuesNested(nestedReader.getUnparsedArguments());
 
     // Now we create the RE08 substitution model:
-    model.reset(new RE08(nestedModel.release()));
+    if (AlphabetTools::isNucleicAlphabet(alphabet))
+    {
+      if (!(alphabetCode_ & NUCLEOTIDE))
+        throw Exception("BppOSubstitutionModelFormat::read. Nucleic alphabet not supported.");
+      model.reset(new RE08Nucleotide(dynamic_cast<NucleotideReversibleSubstitutionModel*>(nestedModel.release())));
+      if (!model.get())
+        throw Exception("BppOSubstitutionModelFormat::read(). Invalid submodel, must be 'reversible' and 'nucleotide'.");
+    }
+    else if (AlphabetTools::isProteicAlphabet(alphabet))
+    {
+      if (!(alphabetCode_ & PROTEIN))
+        throw Exception("BppOSubstitutionModelFormat::read. Protein alphabet not supported.");
+      model.reset(new RE08Protein(dynamic_cast<ProteinReversibleSubstitutionModel*>(nestedModel.release())));
+      if (!model.get())
+        throw Exception("BppOSubstitutionModelFormat::read(). Invalid submodel, must be 'reversible' and 'protein'.");
+    }
+    else if (AlphabetTools::isCodonAlphabet(alphabet))
+    {
+      if (!(alphabetCode_ & CODON))
+        throw Exception("BppOSubstitutionModelFormat::read. Codon alphabet not supported.");
+      model.reset(new RE08Codon(dynamic_cast<CodonReversibleSubstitutionModel*>(nestedModel.release())));
+      if (!model.get())
+        throw Exception("BppOSubstitutionModelFormat::read(). Invalid submodel, must be 'reversible' and 'codon'.");
+    }
+    else
+    {
+      model.reset(new RE08(nestedModel.release()));
+    }
 
     // Then we update the parameter set:
     for (map<string, string>::iterator it = unparsedParameterValuesNested.begin(); it != unparsedParameterValuesNested.end(); it++)
@@ -351,7 +389,9 @@ SubstitutionModel* BppOSubstitutionModelFormat::read(
     if (verbose_)
       ApplicationTools::displayResult("Covarion model", modelName);
     BppOSubstitutionModelFormat nestedReader(ALL, false, allowMixed_, allowGaps_, false, warningLevel_);
-    auto_ptr<ReversibleSubstitutionModel> nestedModel(dynamic_cast<ReversibleSubstitutionModel*>(nestedReader.read(alphabet, nestedModelDescription, data, false)));
+    if (geneticCode_)
+      nestedReader.setGeneticCode(geneticCode_);
+    unique_ptr<ReversibleSubstitutionModel> nestedModel(dynamic_cast<ReversibleSubstitutionModel*>(nestedReader.read(alphabet, nestedModelDescription, data, false)));
     map<string, string> unparsedParameterValuesNested(nestedReader.getUnparsedArguments());
 
     // Now we create the TS98 substitution model:
@@ -383,13 +423,15 @@ SubstitutionModel* BppOSubstitutionModelFormat::read(
     if (verbose_)
       ApplicationTools::displayResult("Covarion model", modelName);
     BppOSubstitutionModelFormat nestedReader(ALL, false, allowMixed_, allowGaps_, verbose_, warningLevel_);
-    auto_ptr<ReversibleSubstitutionModel> nestedModel(dynamic_cast<ReversibleSubstitutionModel*>(nestedReader.read(alphabet, nestedModelDescription, data, false)));
+    if (geneticCode_)
+      nestedReader.setGeneticCode(geneticCode_);
+    unique_ptr<ReversibleSubstitutionModel> nestedModel(dynamic_cast<ReversibleSubstitutionModel*>(nestedReader.read(alphabet, nestedModelDescription, data, false)));
     map<string, string> unparsedParameterValuesNestedModel(nestedReader.getUnparsedArguments());
     BppORateDistributionFormat rateReader(false);
-    auto_ptr<DiscreteDistribution> nestedRDist(rateReader.read(nestedRateDistDescription, false));
+    unique_ptr<DiscreteDistribution> nestedRDist(rateReader.read(nestedRateDistDescription, false));
     map<string, string> unparsedParameterValuesNestedDist(rateReader.getUnparsedArguments());
 
-    // Now we create the TS98 substitution model:
+    // Now we create the G01 substitution model:
     model.reset(new G2001(nestedModel.release(), nestedRDist.release()));
 
     // Then we update the parameter set:
@@ -402,6 +444,15 @@ SubstitutionModel* BppOSubstitutionModelFormat::read(
       unparsedArguments_["G01.rdist_" + it->first] = it->second;
     }
   }
+
+  ///////////////////////////////////////////////////////
+  ///
+  ///
+  ///  SIMPLE MODELS
+  ///
+  ///
+  //////////////////////////////////////////////////////////
+
   else
   {
     // This is a 'simple' model...
@@ -411,11 +462,41 @@ SubstitutionModel* BppOSubstitutionModelFormat::read(
         throw Exception("BppOSubstitutionModelFormat::read. Nucleotide alphabet not supported.");
       const NucleicAlphabet* alpha = dynamic_cast<const NucleicAlphabet*>(alphabet);
 
+      // //////////////////////////////////
+      // gBGC
+      // //////////////////////////////////
+      if (modelName.find("+gBGC") != string::npos)
+      {
+        string subModName=modelName.substr(0,modelName.find("+gBGC"));
+
+        if (verbose_)
+          ApplicationTools::displayResult("Biased gene conversion for", subModName);
+
+        string::size_type begin = modelDescription.find_first_of("(");
+        string::size_type end = modelDescription.find_last_of(")");
+
+        string nestedModelDescription = subModName+modelDescription.substr(begin,end-begin+1);
+        
+        BppOSubstitutionModelFormat nestedReader(NUCLEOTIDE, true, true, false, verbose_, warningLevel_);
+        unique_ptr<NucleotideSubstitutionModel> nestedModel(dynamic_cast<NucleotideSubstitutionModel*>(nestedReader.read(alphabet, nestedModelDescription, data, false)));
+        map<string, string> unparsedParameterValuesNested(nestedReader.getUnparsedArguments());
+
+        // Now we create the gBGC substitution model:
+        model.reset(new gBGC(alpha, nestedModel.release()));
+
+        // Then we update the parameter set:
+        for (map<string, string>::iterator it = unparsedParameterValuesNested.begin(); it != unparsedParameterValuesNested.end(); it++)
+        {
+          unparsedArguments_["gBGC." + it->first] = it->second;
+        }
+      }
+
+
       // /////////////////////////////////
       // / GTR
       // ///////////////////////////////
 
-      if (modelName == "GTR")
+      else if (modelName == "GTR")
       {
         model.reset(new GTR(alpha));
       }
@@ -516,40 +597,43 @@ SubstitutionModel* BppOSubstitutionModelFormat::read(
         throw Exception("Model '" + modelName + "' unknown.");
       }
     }
-    else
+    else if (AlphabetTools::isProteicAlphabet(alphabet))
     {
       if (!(alphabetCode_ & PROTEIN))
         throw Exception("BppOSubstitutionModelFormat::read. Protein alphabet not supported.");
       const ProteicAlphabet* alpha = dynamic_cast<const ProteicAlphabet*>(alphabet);
-
+      
       if (modelName.find("+F") != string::npos) {
         string freqOpt = ApplicationTools::getStringParameter("frequencies", args, "Full", "", true, warningLevel_);
         BppOFrequenciesSetFormat freqReader(BppOFrequenciesSetFormat::ALL, false, warningLevel_);
-        auto_ptr<FrequenciesSet> protFreq(freqReader.read(alpha, freqOpt, data, true));
+        unique_ptr<FrequenciesSet> protFreq(freqReader.read(alpha, freqOpt, data, true));
         map<string, string> unparsedParameterValuesNested(freqReader.getUnparsedArguments());
 
         for (map<string, string>::iterator it = unparsedParameterValuesNested.begin(); it != unparsedParameterValuesNested.end(); it++)
-          {
-            unparsedArguments_[modelName + "." + it->first] = it->second;
-          }
+        {
+          unparsedArguments_[modelName + "." + it->first] = it->second;
+        }
         
         if (modelName == "JC69+F")
-          model.reset(new JCprot(alpha, dynamic_cast<ProteinFrequenciesSet*>(protFreq.release()), true));
+          model.reset(new JCprot(alpha, dynamic_cast<ProteinFrequenciesSet*>(protFreq.release())));
         else if (modelName == "DSO78+F")
-          model.reset(new DSO78(alpha, dynamic_cast<ProteinFrequenciesSet*>(protFreq.release()), true));
+          model.reset(new DSO78(alpha, dynamic_cast<ProteinFrequenciesSet*>(protFreq.release())));
         else if (modelName == "JTT92+F")
-          model.reset(new JTT92(alpha, dynamic_cast<ProteinFrequenciesSet*>(protFreq.release()), true));
+          model.reset(new JTT92(alpha, dynamic_cast<ProteinFrequenciesSet*>(protFreq.release())));
         else if (modelName == "LG08+F")
-          model.reset(new LG08(alpha, dynamic_cast<ProteinFrequenciesSet*>(protFreq.release()), true));
+          model.reset(new LG08(alpha, dynamic_cast<ProteinFrequenciesSet*>(protFreq.release())));
         else if (modelName == "WAG01+F")
-          model.reset(new WAG01(alpha, dynamic_cast<ProteinFrequenciesSet*>(protFreq.release()), true));
+          model.reset(new WAG01(alpha, dynamic_cast<ProteinFrequenciesSet*>(protFreq.release())));
         else if (modelName == "Empirical+F")
-          {
-            string prefix = args["name"];
-            if (TextTools::isEmpty(prefix))
-              throw Exception("'name' argument missing for user-defined substitution model.");
-            model.reset(new UserProteinSubstitutionModel(alpha, args["file"], dynamic_cast<ProteinFrequenciesSet*>(protFreq.release()), prefix + "+F.", true));
-          }
+        {
+          string prefix = args["name"];
+          if (TextTools::isEmpty(prefix))
+            throw Exception("'name' argument missing for user-defined substitution model.");
+          string fname = args["file"];
+          if (TextTools::isEmpty(fname))
+            throw Exception("'file' argument missing for user-defined substitution model.");
+          model.reset(new UserProteinSubstitutionModel(alpha, args["file"], dynamic_cast<ProteinFrequenciesSet*>(protFreq.release()), prefix + "+F."));
+        }
       }
       else if (modelName == "JC69")
         model.reset(new JCprot(alpha));
@@ -575,9 +659,37 @@ SubstitutionModel* BppOSubstitutionModelFormat::read(
         model.reset(new LG10_EX_EHO(alpha));	
       else if (modelName == "LGL08_CAT")
       {
+        if (args.find("nbCat")==args.end())
+          throw Exception("'nbCat' argument is compulsory for model 'LGL08_CAT'");
+          
         unsigned int nbCat = TextTools::to<unsigned int>(args["nbCat"]);
         model.reset(new LGL08_CAT(alpha, nbCat));
       }
+      // submodels of mixture models
+      else if (modelName.substr(0,9) == "LGL08_CAT")
+      {
+        string subModelName = modelName.substr(10);
+
+        size_t posp=modelDescription.find("(");
+
+        string modelDesc2=modelName.substr(0,9)+modelDescription.substr(posp);
+        
+        BppOSubstitutionModelFormat nestedReader(PROTEIN, true, true, false, verbose_, warningLevel_);
+        
+        MixedSubstitutionModel* nestedModel=dynamic_cast<MixedSubstitutionModel*>(nestedReader.read(alphabet, modelDesc2, data, false));
+      
+        // Check that nestedModel is fine and has subModel of given name
+        if (nestedModel==NULL)
+          throw Exception("Unknown model " + modelName + ".");
+        
+        if (nestedModel->getSubModelWithName(subModelName)==NULL)
+          throw Exception("BppOSubstitutionModelFormat::read. " + nestedModel->getName() + "argument for model 'FromModel' has no submodel with name " + subModelName + ".");
+
+        // Now we create the FromModel substitution model:
+        model.reset(new FromMixtureSubstitutionModel(*nestedModel, subModelName, modelDesc2));
+        
+        delete nestedModel;
+      }      
       else if (modelName == "Empirical")
       {
         string prefix = args["name"];
@@ -594,7 +706,7 @@ SubstitutionModel* BppOSubstitutionModelFormat::read(
         if (exchangeability == "Empirical" && TextTools::isEmpty(prefix))
           throw Exception("'name' argument missing to specify the exchangeabilities of the user-defined empirical model.");  
         BppOSubstitutionModelFormat nestedReader(PROTEIN, false, allowMixed_, allowGaps_, verbose_, warningLevel_);
-        auto_ptr<ProteinSubstitutionModel> nestedModel(dynamic_cast<ProteinSubstitutionModel*>(nestedReader.read(alphabet, exchangeability, data, false)));
+        unique_ptr<ProteinSubstitutionModel> nestedModel(dynamic_cast<ProteinSubstitutionModel*>(nestedReader.read(alphabet, exchangeability, data, false)));
         string nbrOfParametersPerBranch = args["nbrAxes"];
         if (TextTools::isEmpty(nbrOfParametersPerBranch))
           throw Exception("'nbrAxes' argument missing to define the number of axis of the Correspondence Analysis.");
@@ -602,35 +714,49 @@ SubstitutionModel* BppOSubstitutionModelFormat::read(
         model.reset(new Coala(alpha, *nestedModel, TextTools::to<unsigned int>(nbrOfParametersPerBranch)));
         model->setFreqFromData(*data);
       }
+    }
+    else if (AlphabetTools::isBinaryAlphabet(alphabet))
+    {
+      if (!(alphabetCode_ & BINARY))
+        throw Exception("BppOSubstitutionModelFormat::read. Binary alphabet not supported.");
+      
+      const BinaryAlphabet* balpha = dynamic_cast<const BinaryAlphabet*>(alphabet);
 
-      else if (AlphabetTools::isBinaryAlphabet(alphabet))
-      {
-        if (!(alphabetCode_ & BINARY))
-          throw Exception("BppOSubstitutionModelFormat::read. Binary alphabet not supported.");
-        const BinaryAlphabet* balpha = dynamic_cast<const BinaryAlphabet*>(alphabet);
-
-        if (modelName == "Binary")
-          model.reset(new BinarySubstitutionModel(balpha));
-      }
-      else
-        throw Exception("Model '" + modelName + "' unknown.");
+      if (modelName == "Binary")
+        model.reset(new BinarySubstitutionModel(balpha));
     }
-    if (verbose_)
-      ApplicationTools::displayResult("Substitution model", modelName);
+    else
+      throw Exception("Model '" + modelName + "' unknown, or does not fit alphabet.");
+    
   }
+    
+  if (verbose_)
+    ApplicationTools::displayResult("Substitution model", modelName);
+  
+  updateParameters_(model.get(), args);
+  
+  if (parseArguments)
+    initialize_(*model, data);
+  
+  return model.release();  
+}
 
+  
+void BppOSubstitutionModelFormat::updateParameters_(TransitionModel* model, std::map<std::string, std::string>& args)
+{
+  
   // Update parameter args:
   vector<string> pnames = model->getParameters().getParameterNames();
-
+  
   string pref = model->getNamespace();
-
+  
   for (size_t i = 0; i < pnames.size(); i++)
   {
     string name = model->getParameterNameWithoutNamespace(pnames[i]);
     if (args.find(name) != args.end())
       unparsedArguments_[pref + name] = args[name];
   }
-
+  
   // Now look if some parameters are aliased:
   ParameterList pl = model->getIndependentParameters();
   string pname, pval, pname2;
@@ -646,7 +772,7 @@ SubstitutionModel* BppOSubstitutionModelFormat::read(
         (pval.find("(") != string::npos))
       continue;
     bool found = false;
-    for (unsigned int j = 0; j < pl.size() && !found; j++)
+    for (size_t j = 0; j < pl.size() && !found; j++)
     {
       pname2 = model->getParameterNameWithoutNamespace(pl[j].getName());
 
@@ -673,22 +799,22 @@ SubstitutionModel* BppOSubstitutionModelFormat::read(
   if (args.find("useObservedFreqs.pseudoCount") != args.end())
     throw Exception("useObservedFreqs.pseudoCount argument is obsolete. Please use 'initFreqs.observedPseudoCount' instead.");
 
-
   if (args.find("initFreqs") != args.end())
     unparsedArguments_[pref + "initFreqs"] = args["initFreqs"];
   if (args.find("initFreqs.observedPseudoCount") != args.end())
     unparsedArguments_[pref + "initFreqs.observedPseudoCount"] = args["initFreqs.observedPseudoCount"];
 
-  if (parseArguments)
-    initialize_(*model, data);
-
-  return model.release();
+  if (args.find("rate") != args.end())
+  {
+    model->addRateParameter();
+    unparsedArguments_[pref+"rate"] = args["rate"];
+  }  
 }
 
 
 SubstitutionModel* BppOSubstitutionModelFormat::readWord_(const Alphabet* alphabet, const std::string& modelDescription, const SiteContainer* data)
 {
-  auto_ptr<SubstitutionModel> model;
+  unique_ptr<SubstitutionModel> model;
   string modelName = "";
   map<string, string> args;
   KeyvalTools::parseProcedure(modelDescription, modelName, args);
@@ -700,17 +826,21 @@ SubstitutionModel* BppOSubstitutionModelFormat::readWord_(const Alphabet* alphab
   string s, nestedModelDescription;
   unsigned int nbmodels;
 
-  if ((modelName == "Word" && !AlphabetTools::isWordAlphabet(alphabet)) ||
-      (modelName != "Word" && !AlphabetTools::isCodonAlphabet(alphabet)))
+  if (((modelName == "Word" || modelName == "Kron") && !AlphabetTools::isWordAlphabet(alphabet)) ||
+      ((!(modelName == "Word" || modelName == "Kron")) && !AlphabetTools::isCodonAlphabet(alphabet)))
     throw Exception("Bad alphabet type "
                     + alphabet->getAlphabetType() + " for  model " + modelName + ".");
 
   pWA = dynamic_cast<const WordAlphabet*>(alphabet);
 
+  
+  ////////////////////////////////////
+  /// Reading the submodels
+  
   if (args.find("model") != args.end())
   {
     v_nestedModelDescription.push_back(args["model"]);
-    nbmodels = (modelName == "Word") ? pWA->getLength() : 3;
+    nbmodels = (modelName == "Word" || modelName == "Kron") ? pWA->getLength() : 3;
   }
   else
   {
@@ -765,15 +895,89 @@ SubstitutionModel* BppOSubstitutionModelFormat::readWord_(const Alphabet* alphab
     }
   }
 
+  // //////////////////////////////
+  // In case of a Kron... model, mgmt of the positions
+
+  // check the vector of simultaneous changing positions
+    
+  vector<set<size_t> > vposKron;
+  if (modelName.substr(0,4) == "Kron")
+  {
+    if (args.find("positions")!=args.end())
+    {
+      StringTokenizer nst(args["positions"], "+");
+    
+      while (nst.hasMoreToken())
+      {
+        string spos=nst.nextToken();
+        StringTokenizer nst2(spos, "*");
+
+        set<size_t> ss;
+        
+        while (nst2.hasMoreToken())
+        {
+          ss.insert((size_t)TextTools::toInt(nst2.nextToken()));
+        }
+
+        vposKron.push_back(ss);
+      }
+    }
+  }
+  
   // /////////////////////////////////
   // / WORD
   // ///////////////////////////////
 
   if (modelName == "Word")
   {
-    model.reset((v_nestedModelDescription.size() != nbmodels)
-                ? new WordSubstitutionModel(v_pSM[0], nbmodels)
-                : new WordSubstitutionModel(v_pSM));
+    vector<SubstitutionModel*> vsm;
+    
+    for (auto mod : v_pSM)
+      if (dynamic_cast<SubstitutionModel*>(mod)==0)
+        throw Exception("Need Markov SubstitutionModel for Words");
+      else
+        vsm.push_back(dynamic_cast<SubstitutionModel*>(mod));
+    
+    if (v_nestedModelDescription.size() != nbmodels) {
+      model.reset(new WordSubstitutionModel(vsm[0], nbmodels));
+    } else {
+      ModelList ml(vsm);
+      model.reset(new WordSubstitutionModel(ml));
+    }
+  }
+
+  // /////////////////////////////////
+  // / KRON
+  // ///////////////////////////////
+
+  else if (modelName == "Kron")
+  {
+    vector<SubstitutionModel*> vsm;
+    
+    for (auto mod : v_pSM)
+      if (dynamic_cast<SubstitutionModel*>(mod)==0)
+        throw Exception("Need Markov SubstitutionModel for Krons");
+      else
+        vsm.push_back(dynamic_cast<SubstitutionModel*>(mod));
+
+    if (vposKron.size()==0)
+    {
+      if (v_nestedModelDescription.size() != nbmodels) {
+        model.reset(new KroneckerWordSubstitutionModel(vsm[0], nbmodels));
+      } else {
+        ModelList ml(vsm);
+        model.reset(new KroneckerWordSubstitutionModel(ml));
+      }
+    }
+    else
+    {
+      if (v_nestedModelDescription.size() != nbmodels) {
+        model.reset(new KroneckerWordSubstitutionModel(vsm[0], nbmodels, vposKron));
+      } else {
+        ModelList ml(vsm);
+        model.reset(new KroneckerWordSubstitutionModel(ml, vposKron));
+      }
+    }
   }
 
   // /////////////////////////////////
@@ -786,8 +990,8 @@ SubstitutionModel* BppOSubstitutionModelFormat::readWord_(const Alphabet* alphab
     if (pCA == 0)
       throw Exception("Non codon Alphabet for model" + modelName + ".");
 
-    auto_ptr< AlphabetIndex2 > pai2;
-    auto_ptr<FrequenciesSet> pFS;
+    unique_ptr< AlphabetIndex2 > pai2;
+    unique_ptr<FrequenciesSet> pFS;
 
     if ((dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[0]) == 0) ||
         ((v_nestedModelDescription.size() == 3) &&
@@ -802,11 +1006,16 @@ SubstitutionModel* BppOSubstitutionModelFormat::readWord_(const Alphabet* alphab
     if (!geneticCode_)
       throw Exception("BppOSubstitutionModelFormat::readWord_(). No genetic code specified! Consider using 'setGeneticCode'.");
 
+
+    ///////////////////////////////////
+    /// Dist
     
-    if (modelName.find("Dist") != string::npos)
+    if ((modelName.find("Dist") != string::npos) || (modelName=="SENCA"))
       pai2.reset((args.find("aadistance") == args.end()) ? 0 : SequenceApplicationTools::getAlphabetIndex2(&AlphabetTools::PROTEIN_ALPHABET, args["aadistance"]));
     
-
+    //////////////////////////////////
+    /// Freq
+    
     if (modelName.find("Freq") != string::npos)
     {
       if (args.find("frequencies") == args.end())
@@ -823,8 +1032,8 @@ SubstitutionModel* BppOSubstitutionModelFormat::readWord_(const Alphabet* alphab
       }
     }
 
-
-    // //
+    // //////////////
+    // // Triplet
 
     if (modelName == "Triplet")
       model.reset((v_nestedModelDescription.size() != 3)
@@ -861,22 +1070,34 @@ SubstitutionModel* BppOSubstitutionModelFormat::readWord_(const Alphabet* alphab
                       dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[2]), pai2.release()));
     }
 
+    else if (modelName == "CodonDistCpG")
+    {
+      if (v_nestedModelDescription.size() != 3)
+        model.reset(new CodonDistanceCpGSubstitutionModel(geneticCode_, dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[0]), pai2.release()));
+      else
+        model.reset(new CodonDistanceCpGSubstitutionModel(
+                      geneticCode_,
+                      dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[0]),
+                      dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[1]),
+                      dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[2]), pai2.release()));
+    }
+
     else if (modelName == "CodonRateFreq")
     {
       if (v_nestedModelDescription.size() != 3)
         model.reset(
-            new CodonRateFrequenciesSubstitutionModel(
-              geneticCode_,
-              dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[0]),
-              pFS.release()));
+          new CodonRateFrequenciesSubstitutionModel(
+            geneticCode_,
+            dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[0]),
+            pFS.release()));
       else
         model.reset(
-            new CodonRateFrequenciesSubstitutionModel(
-              geneticCode_,
-              dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[0]),
-              dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[1]),
-              dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[2]),
-              pFS.release()));
+          new CodonRateFrequenciesSubstitutionModel(
+            geneticCode_,
+            dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[0]),
+            dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[1]),
+            dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[2]),
+            pFS.release()));
     }
 
     else if (modelName == "CodonDistFreq")
@@ -896,6 +1117,82 @@ SubstitutionModel* BppOSubstitutionModelFormat::readWord_(const Alphabet* alphab
                       pai2.release()));
     }
 
+    
+    else if (modelName == "KronDistFreq")
+    {
+      if (v_nestedModelDescription.size() != 3){
+        
+        if (vposKron.size()==0)
+          model.reset(new KroneckerCodonDistanceFrequenciesSubstitutionModel(geneticCode_,
+                                                                             dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[0]),
+                                                                             pFS.release(),
+                                                                             pai2.release()));
+        else
+          model.reset(new KroneckerCodonDistanceFrequenciesSubstitutionModel(geneticCode_,
+                                                                             dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[0]),
+                                                                             vposKron,
+                                                                             pFS.release(),
+                                                                             pai2.release()));
+
+      }
+      else
+      {
+        if (vposKron.size()!=0)
+          model.reset(new KroneckerCodonDistanceFrequenciesSubstitutionModel(
+                        geneticCode_,
+                        dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[0]),
+                        dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[1]),
+                        dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[2]),
+                        pFS.release(),
+                        pai2.release()));
+        else
+          model.reset(new KroneckerCodonDistanceFrequenciesSubstitutionModel(
+                        geneticCode_,
+                        dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[0]),
+                        dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[1]),
+                        dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[2]),
+                        vposKron, 
+                        pFS.release(),
+                        pai2.release()));
+
+      }
+    }
+    else if (modelName == "KronDist")
+    {
+      if (v_nestedModelDescription.size() != 3){
+        
+        if (vposKron.size()==0)
+          model.reset(new KroneckerCodonDistanceSubstitutionModel(geneticCode_,
+                                                                  dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[0]),
+                                                                  pai2.release()));
+        else
+          model.reset(new KroneckerCodonDistanceSubstitutionModel(geneticCode_,
+                                                                  dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[0]),
+                                                                  vposKron,
+                                                                  pai2.release()));
+
+      }
+      else
+      {
+        if (vposKron.size()!=0)
+          model.reset(new KroneckerCodonDistanceSubstitutionModel(
+                        geneticCode_,
+                        dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[0]),
+                        dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[1]),
+                        dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[2]),
+                        pai2.release()));
+        else
+          model.reset(new KroneckerCodonDistanceSubstitutionModel(
+                        geneticCode_,
+                        dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[0]),
+                        dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[1]),
+                        dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[2]),
+                        vposKron, 
+                        pai2.release()));
+
+      }
+    }
+    
     else if (modelName == "CodonDistPhasFreq")
     {
       if (v_nestedModelDescription.size() != 3)
@@ -912,14 +1209,16 @@ SubstitutionModel* BppOSubstitutionModelFormat::readWord_(const Alphabet* alphab
                       pFS.release(),
                       pai2.release()));
     }
-    else if (modelName == "CodonDistFitPhasFreq")
+    
+    else if (modelName == "SENCA")
     {
       if (args.find("fitness") == args.end())
         throw Exception("Missing fitness in model " + modelName + ".");
 
       BppOFrequenciesSetFormat bIOFreq(alphabetCode_, verbose_, warningLevel_);
-      bIOFreq.setGeneticCode(geneticCode_); 
-      auto_ptr<FrequenciesSet> pFit(bIOFreq.read(pCA, args["fitness"], data, false));
+      bIOFreq.setGeneticCode(geneticCode_);
+      
+      unique_ptr<FrequenciesSet> pFit(bIOFreq.read(pCA, args["fitness"], data, false));
       map<string, string> unparsedParameterValuesNested(bIOFreq.getUnparsedArguments());
 
       for (map<string, string>::iterator it = unparsedParameterValuesNested.begin(); it != unparsedParameterValuesNested.end(); it++)
@@ -929,35 +1228,34 @@ SubstitutionModel* BppOSubstitutionModelFormat::readWord_(const Alphabet* alphab
 
       if (v_nestedModelDescription.size() != 3)
       {
-        model.reset(new CodonDistanceFitnessPhaseFrequenciesSubstitutionModel(geneticCode_,
-                                                                              dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[0]),
-                                                                              pFit.release(),
-                                                                              pFS.release(),
-                                                                              pai2.release()));
+        model.reset(new SENCA(geneticCode_,
+                              dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[0]),
+                              pFit.release(),
+                              pai2.release()));
       }
       else
-        model.reset(new CodonDistanceFitnessPhaseFrequenciesSubstitutionModel(
+        model.reset(new SENCA(
                       geneticCode_,
                       dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[0]),
                       dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[1]),
                       dynamic_cast<NucleotideSubstitutionModel*>(v_pSM[2]),
                       pFit.release(),
-                      pFS.release(),
                       pai2.release()));
     }
   }
+
   return model.release();
 }
 
 
 MixedSubstitutionModel* BppOSubstitutionModelFormat::readMixed_(const Alphabet* alphabet, const std::string& modelDescription, const SiteContainer* data)
 {
-  auto_ptr<MixedSubstitutionModel> model;
+  unique_ptr<MixedSubstitutionModel> model;
 
   string modelName = "";
   map<string, string> args;
   KeyvalTools::parseProcedure(modelDescription, modelName, args);
-  auto_ptr<SubstitutionModel> pSM;
+  unique_ptr<SubstitutionModel> pSM;
 
   if (modelName == "MixedModel")
   {
@@ -965,7 +1263,17 @@ MixedSubstitutionModel* BppOSubstitutionModelFormat::readMixed_(const Alphabet*
       throw Exception("The argument 'model' is missing from MixedSubstitutionModel description");
     string nestedModelDescription = args["model"];
     BppOSubstitutionModelFormat nestedReader(alphabetCode_, allowCovarions_, true, allowGaps_, false, warningLevel_);
-    pSM.reset(nestedReader.read(alphabet, nestedModelDescription, data, false));
+    if (geneticCode_)
+      nestedReader.setGeneticCode(geneticCode_); //This uses the same
+    //instance as the one
+    //that will be used
+    //by the model.
+    SubstitutionModel* tm=nestedReader.read(alphabet, nestedModelDescription, data, false);
+    if (dynamic_cast<SubstitutionModel*>(tm)==0)
+      throw Exception("Need Markov SubstitutionModel for Mixtures");
+
+    pSM.reset(dynamic_cast<SubstitutionModel*>(tm));
+
     map<string, string> unparsedParameterValuesNested(nestedReader.getUnparsedArguments());
 
     map<string, DiscreteDistribution*> mdist;
@@ -1018,10 +1326,10 @@ MixedSubstitutionModel* BppOSubstitutionModelFormat::readMixed_(const Alphabet*
     }
 
     if (verbose_)
-      {
-        ApplicationTools::displayResult("Mixture Of A Substitution Model", sModN);
-        ApplicationTools::displayResult("Number of classes", model->getNumberOfModels());
-      }
+    {
+      ApplicationTools::displayResult("Mixture Of A Substitution Model", sModN);
+      ApplicationTools::displayResult("Number of classes", model->getNumberOfModels());
+    }
   }
 
 
@@ -1047,7 +1355,15 @@ MixedSubstitutionModel* BppOSubstitutionModelFormat::readMixed_(const Alphabet*
     for (unsigned i = 0; i < v_nestedModelDescription.size(); i++)
     {
       BppOSubstitutionModelFormat nestedReader(alphabetCode_, false, true, false, false, warningLevel_);
-      pSM.reset(nestedReader.read(alphabet, v_nestedModelDescription[i], data, false));
+      if (geneticCode_)
+        nestedReader.setGeneticCode(geneticCode_); //This uses the same instance as the one that will be used by the model.
+
+      SubstitutionModel* tm=nestedReader.read(alphabet, v_nestedModelDescription[i], data, false);
+      if (dynamic_cast<SubstitutionModel*>(tm)==0)
+        throw Exception("Need Markov SubstitutionModel for Mixtures");
+
+      pSM.reset(dynamic_cast<SubstitutionModel*>(tm));
+
       map<string, string> unparsedParameterValuesNested(nestedReader.getUnparsedArguments());
       for (map<string, string>::iterator it = unparsedParameterValuesNested.begin(); it != unparsedParameterValuesNested.end(); it++)
       {
@@ -1058,7 +1374,7 @@ MixedSubstitutionModel* BppOSubstitutionModelFormat::readMixed_(const Alphabet*
 
     model.reset(new MixtureOfSubstitutionModels(alphabet, v_pSM));
     if (verbose_)
-        ApplicationTools::displayResult("Mixture Of Substitution Models", modelName );
+      ApplicationTools::displayResult("Mixture Of Substitution Models", modelName );
   }
   else
     throw Exception("Unknown model name for mixture " + modelName);
@@ -1067,7 +1383,7 @@ MixedSubstitutionModel* BppOSubstitutionModelFormat::readMixed_(const Alphabet*
 }
 
 
-void BppOSubstitutionModelFormat::write(const SubstitutionModel& model,
+void BppOSubstitutionModelFormat::write(const TransitionModel& model,
                                         OutputStream& out,
                                         std::map<std::string, std::string>& globalAliases,
                                         std::vector<std::string>& writtenNames) const
@@ -1089,7 +1405,15 @@ void BppOSubstitutionModelFormat::write(const SubstitutionModel& model,
   if (userModel)
   {
     out << "file=" << userModel->getPath();
-    comma = true;
+    string ns=userModel->getNamespace();
+    
+    if (TextTools::hasSubstring(ns, "+F.") )
+      ns = ns.substr(0,ns.size()-3); 
+    else  
+      ns = ns.substr(0,ns.size()-1); 
+
+    out << ",name=" << ns;
+    comma = true;    
   }
 
   // Is it a markov-modulated model?
@@ -1097,7 +1421,7 @@ void BppOSubstitutionModelFormat::write(const SubstitutionModel& model,
   if (mmModel)
   {
     out << "model=";
-    const SubstitutionModel* nestedModel = mmModel->getNestedModel();
+    const TransitionModel* nestedModel = mmModel->getNestedModel();
     write(*nestedModel, out, globalAliases, writtenNames);
 
     const G2001* gModel = dynamic_cast<const G2001*>(&model);
@@ -1119,7 +1443,7 @@ void BppOSubstitutionModelFormat::write(const SubstitutionModel& model,
   if (reModel)
   {
     out << "model=";
-    const SubstitutionModel* nestedModel = reModel->getNestedModel();
+    const TransitionModel* nestedModel = reModel->getNestedModel();
     write(*nestedModel, out, globalAliases, writtenNames);
     comma = true;
   }
@@ -1129,18 +1453,37 @@ void BppOSubstitutionModelFormat::write(const SubstitutionModel& model,
   if (yprModel)
   {
     out << "model=";
-    const SubstitutionModel* nestedModel = yprModel->getNestedModel();
+    const TransitionModel* nestedModel = yprModel->getNestedModel();
     write(*nestedModel, out, globalAliases, writtenNames);
     comma = true;
   }
 
+  // Is it a OneChange model?
+  const OneChangeTransitionModel* onechangetransitionmodel = dynamic_cast<const OneChangeTransitionModel*>(&model);
+  if (onechangetransitionmodel)
+  {
+    out << "model=";
+    const SubstitutionModel& nestedModel = onechangetransitionmodel->getModel();
+    write(nestedModel, out, globalAliases, writtenNames);
+    comma = true;
+  }
+
   // Is it a gBGC model?
   const gBGC* gbgcModel = dynamic_cast<const gBGC*>(&model);
   if (gbgcModel)
   {
-    out << "model=";
-    const SubstitutionModel* nestedModel = gbgcModel->getNestedModel();
-    write(*nestedModel, out, globalAliases, writtenNames);
+    StdStr sout;
+    
+    const TransitionModel* nestedModel = gbgcModel->getNestedModel();
+    write(*nestedModel, sout, globalAliases, writtenNames);
+
+    string ss=sout.str();
+
+    string::size_type begin = ss.find_first_of("(");
+    string::size_type end = ss.find_last_of(")");
+
+    out << ss.substr(begin+1,end-begin-1);
+    
     comma = true;
   }
 
@@ -1150,7 +1493,7 @@ void BppOSubstitutionModelFormat::write(const SubstitutionModel& model,
   if (wM)
   {
     size_t nmod = wM->getNumberOfModels();
-    const SubstitutionModel* mod0 = wM->getNModel(0);
+    const TransitionModel* mod0 = wM->getNModel(0);
     if (nmod == 1)
     {
       out << "model=";
@@ -1158,7 +1501,7 @@ void BppOSubstitutionModelFormat::write(const SubstitutionModel& model,
     }
     else
     {
-      const SubstitutionModel* mod1 = wM->getNModel(1);
+      const TransitionModel* mod1 = wM->getNModel(1);
       if (mod1 == mod0)
       {
         out << "model=";
@@ -1186,6 +1529,15 @@ void BppOSubstitutionModelFormat::write(const SubstitutionModel& model,
     comma = true;
   }
 
+  // // Is it a FromMixture model?
+
+  // const FromMixtureSubstitutionModel* fromModel = dynamic_cast<const FromMixtureSubstitutionModel*>(&model);
+  // if (fromModel)
+  // {
+  //   out << "exch=" << coalaModel->getExch() << ",nbrAxes=" << coalaModel->getNbrOfAxes();
+  //   comma = true;
+  // }
+  
   // Regular model
   const FrequenciesSet* pfs = model.getFrequenciesSet();
   if (pfs)
@@ -1193,15 +1545,16 @@ void BppOSubstitutionModelFormat::write(const SubstitutionModel& model,
     if (comma)
       out << ",";
     out << "frequencies=";
-
+    
     BppOFrequenciesSetFormat bIOFreq(alphabetCode_, false, warningLevel_);
-    bIOFreq.write(pfs, out, writtenNames);
+    bIOFreq.write(pfs, out, globalAliases, writtenNames);
+    
     comma = true;
   }
 
-  // Specific case of CodonFitnessSubstitutionModel
+  // Specific case of SENCA
 
-  const CodonDistanceFitnessPhaseFrequenciesSubstitutionModel* pCF = dynamic_cast<const CodonDistanceFitnessPhaseFrequenciesSubstitutionModel*>(&model);
+  const SENCA* pCF = dynamic_cast<const SENCA*>(&model);
   if (pCF)
   {
     if (comma)
@@ -1209,14 +1562,70 @@ void BppOSubstitutionModelFormat::write(const SubstitutionModel& model,
     out << "fitness=";
 
     BppOFrequenciesSetFormat bIOFreq(alphabetCode_, false, warningLevel_);
-    bIOFreq.write(pCF->getFitness(), out, writtenNames);
+    bIOFreq.write(pCF->getFitness(), out, globalAliases, writtenNames);
     comma = true;
   }
 
-  // and the other parameters
+  // and bibliomixed models
+
+  const YNGP_M7* pM7 = dynamic_cast<const YNGP_M7*>(&model);
+  if (pM7)
+  {
+    if (comma)
+      out << ",";
+    out << "n=" << pM7->getNumberOfModels();
+    comma=true;
+  }
+
+  const YNGP_M8* pM8 = dynamic_cast<const YNGP_M8*>(&model);
+  if (pM8)
+  {
+    if (comma)
+      out << ",";
+    out << "n=" << pM8->getNumberOfModels()-1;
+    comma=true;
+  }
+
+  const YNGP_M9* pM9 = dynamic_cast<const YNGP_M9*>(&model);
+  if (pM9)
+  {
+    if (comma)
+      out << ",";
+    out << "nbeta=" << pM9->getNBeta() << ",ngamma=" << pM9->getNGamma();
+    
+    comma=true;
+  }
 
+  const YNGP_M10* pM10 = dynamic_cast<const YNGP_M10*>(&model);
+  if (pM10)
+  {
+    if (comma)
+      out << ",";
+    out << "nbeta=" << pM10->getNBeta() << ",ngamma=" << pM10->getNGamma();
+    
+    comma=true;
+  }
+  
   BppOParametrizableFormat bIO;
+
+  // case of Biblio models, update writtenNames
+
+  const AbstractBiblioSubstitutionModel* absm=dynamic_cast<const AbstractBiblioSubstitutionModel*>(&model);
   
+  if (absm)
+  {
+    size_t wNs=writtenNames.size();
+    
+    for (size_t i=0;i<wNs; i++)
+    {
+      try
+      {
+        writtenNames.push_back(absm->getNamespace()+absm->getParNameFromPmodel(writtenNames[i]));
+      }
+      catch (Exception& e) {}
+    }
+  }
+    
   bIO.write(&model, out, globalAliases, model.getIndependentParameters().getParameterNames(), writtenNames, true, comma);
   out << ")";
 }
@@ -1231,17 +1640,17 @@ void BppOSubstitutionModelFormat::writeMixed_(const MixedSubstitutionModel& mode
   {
     const MixtureOfSubstitutionModels* pMS = dynamic_cast<const MixtureOfSubstitutionModels*>(&model);
 
-    for (unsigned int i = 0; i < pMS->getNumberOfModels(); i++)
-    {
-      const SubstitutionModel* eM = pMS->getNModel(i);
+    // for (unsigned int i = 0; i < pMS->getNumberOfModels(); i++)
+    // {
+    //   const SubstitutionModel* eM = pMS->getNModel(i);
 
-      vector<string> vpl = eM->getIndependentParameters().getParameterNames();
-      for (unsigned j = 0; j < vpl.size(); j++)
-      {
-        if (eM->getParameterNameWithoutNamespace(vpl[j]) == "rate")
-          writtenNames.push_back(vpl[j]);
-      }
-    }
+    //   vector<string> vpl = eM->getIndependentParameters().getParameterNames();
+    //   for (unsigned j = 0; j < vpl.size(); j++)
+    //   {
+    //     if (eM->getParameterNameWithoutNamespace(vpl[j]) == "rate")
+    //       writtenNames.push_back(vpl[j]);
+    //   }
+    // }
 
     out << "Mixture(";
     for (unsigned int i = 0; i < pMS->getNumberOfModels(); i++)
@@ -1256,7 +1665,7 @@ void BppOSubstitutionModelFormat::writeMixed_(const MixedSubstitutionModel& mode
   {
     const MixtureOfASubstitutionModel* pMS = dynamic_cast<const MixtureOfASubstitutionModel*>(&model);
     out << "MixedModel(model=";
-    const SubstitutionModel* eM = pMS->getNModel(0);
+    const TransitionModel* eM = pMS->getNModel(0);
 
     ParameterList pl = eM->getIndependentParameters();
     vector<string> vpl = pl.getParameterNames();
@@ -1265,19 +1674,14 @@ void BppOSubstitutionModelFormat::writeMixed_(const MixedSubstitutionModel& mode
     {
       if (find(writtenNames.begin(), writtenNames.end(), vpl[j]) == writtenNames.end())
       {
-        if (eM->getParameterNameWithoutNamespace(vpl[j]) == "rate")
-          writtenNames.push_back(vpl[j]);
-        else
+        const DiscreteDistribution* pDD = pMS->getDistribution(vpl[j]);
+        if (pDD && dynamic_cast<const ConstantDistribution*>(pDD) == NULL)
         {
-          const DiscreteDistribution* pDD = pMS->getDistribution(vpl[j]);
-          if (pDD && dynamic_cast<const ConstantDistribution*>(pDD) == NULL)
-          {
-            const BppODiscreteDistributionFormat* bIO = new BppODiscreteDistributionFormat();
-            StdStr sout;
-            bIO->write(*pDD, sout, globalAliases, writtenNames);
-            globalAliases[vpl[j]] = sout.str();
-            delete bIO;
-          }
+          const BppODiscreteDistributionFormat* bIO = new BppODiscreteDistributionFormat();
+          StdStr sout;
+          bIO->write(*pDD, sout, globalAliases, writtenNames);
+          globalAliases[vpl[j]] = sout.str();
+          delete bIO;
         }
       }
     }
@@ -1296,7 +1700,7 @@ void BppOSubstitutionModelFormat::writeMixed_(const MixedSubstitutionModel& mode
 }
 
 void BppOSubstitutionModelFormat::initialize_(
-  SubstitutionModel& model,
+  TransitionModel& model,
   const SiteContainer* data) throw (Exception)
 {
   string initFreqs = ApplicationTools::getStringParameter(model.getNamespace() + "initFreqs", unparsedArguments_, "", "", true, warningLevel_);
@@ -1326,6 +1730,8 @@ void BppOSubstitutionModelFormat::initialize_(
     }
     else
       throw Exception("Unknown initFreqs argument");
+
+    unparsedArguments_.erase(unparsedArguments_.find(model.getNamespace() + "initFreqs"));
   }
 
   ParameterList pl = model.getIndependentParameters();
@@ -1335,13 +1741,15 @@ void BppOSubstitutionModelFormat::initialize_(
     ap.setMessageHandler(ApplicationTools::warning);
     pl.setParameter(i, ap);
   }
+  
   size_t posp;
   for (size_t i = 0; i < pl.size(); i++)
   {
     const string pName = pl[i].getName();
+    
     posp = pName.rfind(".");
     bool test1 = (initFreqs == "");
-    bool test2 = (model.getParameterNameWithoutNamespace(pName).size() < posp + 6) || (model.getParameterNameWithoutNamespace(pName).substr(posp + 1, 5) != "theta");
+    bool test2 = (pName.size() < posp + 6) || (pName.substr(posp + 1, 5) != "theta");
     bool test3 = (unparsedArguments_.find(pName) != unparsedArguments_.end());
     try {
       if (test1 || test2 || test3)
@@ -1362,7 +1770,6 @@ void BppOSubstitutionModelFormat::initialize_(
     catch (Exception& e) {}
   }
   
-
   model.matchParametersValues(pl);
 }
 
diff --git a/src/Bpp/Phyl/Io/BppOSubstitutionModelFormat.h b/src/Bpp/Phyl/Io/BppOSubstitutionModelFormat.h
index 5910f47..65bd076 100644
--- a/src/Bpp/Phyl/Io/BppOSubstitutionModelFormat.h
+++ b/src/Bpp/Phyl/Io/BppOSubstitutionModelFormat.h
@@ -5,37 +5,37 @@
 //
 
 /*
-   Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
-
-   This software is a computer program whose purpose is to provide classes
-   for phylogenetic data analysis.
-
-   This software is governed by the CeCILL  license under French law and
-   abiding by the rules of distribution of free software.  You can  use,
-   modify and/ or redistribute the software under the terms of the CeCILL
-   license as circulated by CEA, CNRS and INRIA at the following URL
-   "http://www.cecill.info".
-
-   As a counterpart to the access to the source code and  rights to copy,
-   modify and redistribute granted by the license, users are provided only
-   with a limited warranty  and the software's author,  the holder of the
-   economic rights,  and the successive licensors  have only  limited
-   liability.
-
-   In this respect, the user's attention is drawn to the risks associated
-   with loading,  using,  modifying and/or developing or reproducing the
-   software by the user in light of its specific status of free software,
-   that may mean  that it is complicated to manipulate,  and  that  also
-   therefore means  that it is reserved for developers  and  experienced
-   professionals having in-depth computer knowledge. Users are therefore
-   encouraged to load and test the software's suitability as regards their
-   requirements in conditions enabling the security of their systems and/or
-   data to be ensured and,  more generally, to use and operate it in the
-   same conditions as regards security.
-
-   The fact that you are presently reading this means that you have had
-   knowledge of the CeCILL license and that you accept its terms.
- */
+  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
+
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use,
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info".
+
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability.
+
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or
+  data to be ensured and,  more generally, to use and operate it in the
+  same conditions as regards security.
+
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
+*/
 
 #ifndef _BPPOSUBSTITUTIONMODELFORMAT_H_
 #define _BPPOSUBSTITUTIONMODELFORMAT_H_
@@ -56,140 +56,151 @@ namespace bpp
  *
  */
 
-class BppOSubstitutionModelFormat :
-  public ISubstitutionModel,
-  public OSubstitutionModel
-{
-public:
-  static unsigned char DNA;
-  static unsigned char RNA;
-  static unsigned char NUCLEOTIDE;
-  static unsigned char PROTEIN;
-  static unsigned char CODON;
-  static unsigned char WORD;
-  static unsigned char BINARY;
-  static unsigned char ALL;
-
-private:
-  unsigned char alphabetCode_;
-  bool allowCovarions_;
-  bool allowMixed_;
-  bool allowGaps_;
-  bool verbose_;
-  std::map<std::string, std::string> unparsedArguments_;
-  const GeneticCode* geneticCode_;
-  int warningLevel_;
-
-public:
-  /**
-   * @brief Create a new BppOSubstitutionModelFormat object.
-   *
-   * @param alphabetCode     Bit saying which alphabets are allowed in the model specification.
-   * @param allowCovarions   Tell is a covarion model can be returned.
-   * @param allowMixed       Tell is a mixture model can be returned.
-   * @param allowGaps        Tell is a gap model can be returned.
-   * @param verbose          Tell if the construction is verbose.
-   * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
-   */
-  BppOSubstitutionModelFormat(unsigned char alphabetCode, bool allowCovarions, bool allowMixed, bool allowGaps, bool verbose, int warn):
-    alphabetCode_(alphabetCode),
-    allowCovarions_(allowCovarions),
-    allowMixed_(allowMixed),
-    allowGaps_(allowGaps),
-    verbose_(verbose),
-    unparsedArguments_(),
-    geneticCode_(0),
-    warningLevel_(warn)
-  {}
-
-  BppOSubstitutionModelFormat(const BppOSubstitutionModelFormat& format):
-    alphabetCode_(format.alphabetCode_),
-    allowCovarions_(format.allowCovarions_),
-    allowMixed_(format.allowMixed_),
-    allowGaps_(format.allowGaps_),
-    verbose_(format.verbose_),
-    unparsedArguments_(format.unparsedArguments_),
-    geneticCode_(format.geneticCode_),
-    warningLevel_(format.warningLevel_)
-  {}
-
-  BppOSubstitutionModelFormat& operator=(const BppOSubstitutionModelFormat& format)
+  class BppOSubstitutionModelFormat :
+    public ISubstitutionModel,
+    public OSubstitutionModel
   {
-    alphabetCode_      = format.alphabetCode_;
-    allowCovarions_    = format.allowCovarions_;
-    allowMixed_        = format.allowMixed_;
-    allowGaps_         = format.allowGaps_;
-    verbose_           = format.verbose_;
-    unparsedArguments_ = format.unparsedArguments_;
-    geneticCode_       = format.geneticCode_;
-    warningLevel_      = format.warningLevel_;
-    return *this;
-  }
-
-  virtual ~BppOSubstitutionModelFormat() {}
-
-public:
-  const std::string getFormatName() const { return "BppO"; }
-
-  const std::string getFormatDescription() const { return "Bpp Options format."; }
-
-  /**
-   * @brief Set the genetic code to use in case a codon frequencies set should be built.
-   *
-   * @param gCode The genetic code to use.
-   */
-  void setGeneticCode(const GeneticCode* gCode) {
-    geneticCode_ = gCode;
-  }
-
-  SubstitutionModel* read(const Alphabet* alphabet, const std::string& modelDescription, const SiteContainer* data = 0, bool parseArguments = true);
-
-  const std::map<std::string, std::string>& getUnparsedArguments() const { return unparsedArguments_; }
-
-  /**
-   * @brief Write a substitution model to a stream.
-   *
-   * @param model A substitution model object;
-   * @param out The output stream;
-   * @param globalAliases parameters linked to global alias. The
-   * output will be "name=alias_name";
-   * @param writtenNames is the vector of the written
-   * parameters so far [in, out];
-   * @throw Exception If an error occured.
-   */
-  void write(const SubstitutionModel& model,
-             OutputStream& out,
-             std::map<std::string, std::string>& globalAliases,
-             std::vector<std::string>& writtenNames) const;
-
-  void setVerbose(bool verbose) { verbose_=verbose;}
+  public:
+    static unsigned char DNA;
+    static unsigned char RNA;
+    static unsigned char NUCLEOTIDE;
+    static unsigned char PROTEIN;
+    static unsigned char CODON;
+    static unsigned char WORD;
+    static unsigned char BINARY;
+    static unsigned char ALL;
+
+  protected:
+    unsigned char alphabetCode_;
+    bool allowCovarions_;
+    bool allowMixed_;
+    bool allowGaps_;
+    bool verbose_;
+    std::map<std::string, std::string> unparsedArguments_;
+    const GeneticCode* geneticCode_;
+    int warningLevel_;
+
+  public:
+    /**
+     * @brief Create a new BppOSubstitutionModelFormat object.
+     *
+     * @param alphabetCode     Bit saying which alphabets are allowed in the model specification.
+     * @param allowCovarions   Tell is a covarion model can be returned.
+     * @param allowMixed       Tell is a mixture model can be returned.
+     * @param allowGaps        Tell is a gap model can be returned.
+     * @param verbose          Tell if the construction is verbose.
+     * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
+     */
+    BppOSubstitutionModelFormat(unsigned char alphabetCode, bool allowCovarions, bool allowMixed, bool allowGaps, bool verbose, int warn):
+      alphabetCode_(alphabetCode),
+      allowCovarions_(allowCovarions),
+      allowMixed_(allowMixed),
+      allowGaps_(allowGaps),
+      verbose_(verbose),
+      unparsedArguments_(),
+      geneticCode_(0),
+      warningLevel_(warn)
+    {}
+
+    BppOSubstitutionModelFormat(const BppOSubstitutionModelFormat& format):
+      alphabetCode_(format.alphabetCode_),
+      allowCovarions_(format.allowCovarions_),
+      allowMixed_(format.allowMixed_),
+      allowGaps_(format.allowGaps_),
+      verbose_(format.verbose_),
+      unparsedArguments_(format.unparsedArguments_),
+      geneticCode_(format.geneticCode_),
+      warningLevel_(format.warningLevel_)
+    {}
+
+    BppOSubstitutionModelFormat& operator=(const BppOSubstitutionModelFormat& format)
+    {
+      alphabetCode_      = format.alphabetCode_;
+      allowCovarions_    = format.allowCovarions_;
+      allowMixed_        = format.allowMixed_;
+      allowGaps_         = format.allowGaps_;
+      verbose_           = format.verbose_;
+      unparsedArguments_ = format.unparsedArguments_;
+      geneticCode_       = format.geneticCode_;
+      warningLevel_      = format.warningLevel_;
+      return *this;
+    }
+
+    virtual ~BppOSubstitutionModelFormat() {}
+
+  public:
+    const std::string getFormatName() const { return "BppO"; }
+
+    const std::string getFormatDescription() const { return "Bpp Options format."; }
+
+    /**
+     * @brief Set the genetic code to use in case a codon frequencies set should be built.
+     *
+     * @param gCode The genetic code to use.
+     */
+    void setGeneticCode(const GeneticCode* gCode) {
+      geneticCode_ = gCode;
+    }
+
+    SubstitutionModel* read(const Alphabet* alphabet, const std::string& modelDescription, const SiteContainer* data = 0, bool parseArguments = true);
+  
+    const std::map<std::string, std::string>& getUnparsedArguments() const { return unparsedArguments_; }
+
+    /**
+     * @brief Write a substitution model to a stream.
+     *
+     * @param model A substitution model object;
+     * @param out The output stream;
+     * @param globalAliases parameters linked to global alias. The
+     * output will be "name=alias_name";
+     * @param writtenNames is the vector of the written
+     * parameters so far [in, out];
+     * @throw Exception If an error occured.
+     */
+  
+    void write(const TransitionModel& model,
+               OutputStream& out,
+               std::map<std::string, std::string>& globalAliases,
+               std::vector<std::string>& writtenNames) const;
+
+    void setVerbose(bool verbose) { verbose_=verbose;}
+  
+  private:
+    MixedSubstitutionModel* readMixed_(const Alphabet* alphabet, const std::string& modelDescription, const SiteContainer* data);
+
+    SubstitutionModel* readWord_(const Alphabet* alphabet, const std::string& modelDescription, const SiteContainer* data);
+
+    void writeMixed_(const MixedSubstitutionModel& model,
+                     OutputStream& out,
+                     std::map<std::string, std::string>& globalAliases,
+                     std::vector<std::string>& writtenNames) const;
+
+  protected:
+    /*
+     * @brief Finish parsing of parameters, taking care of aliases.
+     *
+     */
+  
+    void updateParameters_(TransitionModel* model, 
+                           std::map<std::string, std::string>& args);
   
-private:
-  MixedSubstitutionModel* readMixed_(const Alphabet* alphabet, const std::string& modelDescription, const SiteContainer* data);
-
-  SubstitutionModel* readWord_(const Alphabet* alphabet, const std::string& modelDescription, const SiteContainer* data);
-
-  /**
-   * @brief Set parameter initial values of a given model according to options.
-   *
-   * Parameters actually depends on the model passed as argument.
-   * See getSubstitutionModel for more information.
-   *
-   * This function is mainly for internal usage, you're probably looking for the getSubstitutionModel or getSubstitutionModelSet function.
-   *
-   * @param model                   The model to set.
-   * @param data   A pointer toward the SiteContainer for which the substitution model is designed.
-   *               The alphabet associated to the data must be of the same type as the one specified for the model.
-   *               May be equal to NULL, but in this case use_observed_freq option will be unavailable.
-   * @throw Exception if an error occured.
-   */
-  void initialize_(SubstitutionModel& model, const SiteContainer* data) throw (Exception);
-
-  void writeMixed_(const MixedSubstitutionModel& model,
-             OutputStream& out,
-             std::map<std::string, std::string>& globalAliases,
-             std::vector<std::string>& writtenNames) const;
-};
+    /**
+     * @brief Set parameter initial values of a given model according to options.
+     *
+     * Parameters actually depends on the model passed as argument.
+     * See getSubstitutionModel for more information.
+     *
+     * This function is mainly for internal usage, you're probably looking for the getSubstitutionModel or getSubstitutionModelSet function.
+     *
+     * @param model                   The model to set.
+     * @param data   A pointer toward the SiteContainer for which the substitution model is designed.
+     *               The alphabet associated to the data must be of the same type as the one specified for the model.
+     *               May be equal to NULL, but in this case use_observed_freq option will be unavailable.
+     * @throw Exception if an error occured.
+     */
+    void initialize_(TransitionModel& model, const SiteContainer* data) throw (Exception);
+
+  };
 
 } // end of namespace bpp.
 
diff --git a/src/Bpp/Phyl/Io/BppOTransitionModelFormat.cpp b/src/Bpp/Phyl/Io/BppOTransitionModelFormat.cpp
new file mode 100644
index 0000000..7db6b97
--- /dev/null
+++ b/src/Bpp/Phyl/Io/BppOTransitionModelFormat.cpp
@@ -0,0 +1,114 @@
+//
+// File: BppOTransitionModelFormat.cpp
+// Created by: Laurent Guéguen
+// Created on: mercredi 4 juillet 2012, à 13h 58
+//
+
+/*
+   Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+
+   This software is a computer program whose purpose is to provide classes
+   for phylogenetic data analysis.
+
+   This software is governed by the CeCILL  license under French law and
+   abiding by the rules of distribution of free software.  You can  use,
+   modify and/ or redistribute the software under the terms of the CeCILL
+   license as circulated by CEA, CNRS and INRIA at the following URL
+   "http://www.cecill.info".
+
+   As a counterpart to the access to the source code and  rights to copy,
+   modify and redistribute granted by the license, users are provided only
+   with a limited warranty  and the software's author,  the holder of the
+   economic rights,  and the successive licensors  have only  limited
+   liability.
+
+   In this respect, the user's attention is drawn to the risks associated
+   with loading,  using,  modifying and/or developing or reproducing the
+   software by the user in light of its specific status of free software,
+   that may mean  that it is complicated to manipulate,  and  that  also
+   therefore means  that it is reserved for developers  and  experienced
+   professionals having in-depth computer knowledge. Users are therefore
+   encouraged to load and test the software's suitability as regards their
+   requirements in conditions enabling the security of their systems and/or
+   data to be ensured and,  more generally, to use and operate it in the
+   same conditions as regards security.
+
+   The fact that you are presently reading this means that you have had
+   knowledge of the CeCILL license and that you accept its terms.
+ */
+
+#include "BppOTransitionModelFormat.h"
+#include "BppORateDistributionFormat.h"
+
+#include <Bpp/Io/FileTools.h>
+#include <Bpp/Text/TextTools.h>
+#include <Bpp/Text/StringTokenizer.h>
+#include <Bpp/Text/KeyvalTools.h>
+
+#include "../Model/OneChangeTransitionModel.h"
+
+#include "../App/PhylogeneticsApplicationTools.h"
+
+#include "BppOFrequenciesSetFormat.h"
+
+#include <Bpp/Seq/App/SequenceApplicationTools.h>
+#include <Bpp/Seq/Alphabet/AlphabetTools.h>
+
+#include <Bpp/Io/OutputStream.h>
+#include <Bpp/Io/BppOParametrizableFormat.h>
+#include <Bpp/Io/BppODiscreteDistributionFormat.h>
+
+//From Numeric
+
+#include <Bpp/Numeric/Prob/ConstantDistribution.h>
+#include <Bpp/Numeric/AutoParameter.h>
+
+
+#include <Bpp/Text/StringTokenizer.h>
+
+using namespace bpp;
+
+// From the STL:
+#include <iomanip>
+#include <set>
+
+using namespace std;
+
+TransitionModel* BppOTransitionModelFormat::readTransitionModel(
+  const Alphabet* alphabet,
+    const std::string& modelDescription,
+    const SiteContainer* data,
+    bool parseArguments)
+{
+  unparsedArguments_.clear();
+  unique_ptr<TransitionModel> model;
+  string modelName = "";
+  map<string, string> args;
+  KeyvalTools::parseProcedure(modelDescription, modelName, args);
+
+  if (modelName == "OneChange")
+  {
+    // We have to parse the nested model first:
+    string nestedModelDescription = args["model"];
+    if (TextTools::isEmpty(nestedModelDescription))
+      throw Exception("BppOTransitionModelFormat::read. Missing argument 'model' for model 'OneChange'.");
+    BppOSubstitutionModelFormat nestedReader(ALL, false, allowMixed_, allowGaps_, verbose_, warningLevel_);
+    if (geneticCode_)
+      nestedReader.setGeneticCode(geneticCode_);
+    
+    SubstitutionModel* nestedModel=nestedReader.read(alphabet, nestedModelDescription, data, false);
+    
+    // Now we create the FromModel substitution model:
+    model.reset(new OneChangeTransitionModel(*nestedModel));
+        
+    delete nestedModel;
+  }
+  else
+    model.reset(BppOSubstitutionModelFormat::read(alphabet, modelDescription, data, parseArguments));
+
+  updateParameters_(model.get(), args);
+  if (parseArguments)
+    initialize_(*model, data);
+
+  return model.release();
+}
diff --git a/src/Bpp/Phyl/Io/BppOTransitionModelFormat.h b/src/Bpp/Phyl/Io/BppOTransitionModelFormat.h
new file mode 100644
index 0000000..0e208b2
--- /dev/null
+++ b/src/Bpp/Phyl/Io/BppOTransitionModelFormat.h
@@ -0,0 +1,94 @@
+//
+// File: BppOTransitionModelFormat.h
+// Created by: Laurent Guéguen
+// Created on: mercredi 4 juillet 2012, à 13h 26
+//
+
+/*
+  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
+
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use,
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info".
+
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability.
+
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or
+  data to be ensured and,  more generally, to use and operate it in the
+  same conditions as regards security.
+
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
+*/
+
+#ifndef _BPPO_TRANSITION_MODELFORMAT_H_
+#define _BPPO_TRANSITION_MODELFORMAT_H_
+
+#include "BppOSubstitutionModelFormat.h"
+
+
+namespace bpp
+{
+/**
+ * @brief Transition model I/O in BppO format.
+ *
+ * Creates a new transition model object according to model description syntax
+ * (see the Bio++ Progam Suite manual for a detailed description of this syntax).
+ *
+ */
+
+  class BppOTransitionModelFormat :
+    public BppOSubstitutionModelFormat
+  {
+  public:
+    /**
+     * @brief Create a new BppOTransitionModelFormat object.
+     *
+     * @param alphabetCode     Bit saying which alphabets are allowed in the model specification.
+     * @param allowCovarions   Tell is a covarion model can be returned.
+     * @param allowMixed       Tell is a mixture model can be returned.
+     * @param allowGaps        Tell is a gap model can be returned.
+     * @param verbose          Tell if the construction is verbose.
+     * @param warn             Set the warning level (0: always display warnings, >0 display warnings on demand).
+     */
+    BppOTransitionModelFormat(unsigned char alphabetCode, bool allowCovarions, bool allowMixed, bool allowGaps, bool verbose, int warn):
+      BppOSubstitutionModelFormat(alphabetCode,allowCovarions,allowMixed,allowGaps,verbose,warn)
+    {}
+
+    BppOTransitionModelFormat(const BppOTransitionModelFormat& format):
+      BppOSubstitutionModelFormat(format)
+    {}
+
+    BppOTransitionModelFormat& operator=(const BppOTransitionModelFormat& format)
+    {
+      BppOSubstitutionModelFormat::operator=(format);
+      return *this;
+    }
+
+    virtual ~BppOTransitionModelFormat() {}
+
+  public:
+    TransitionModel* readTransitionModel(const Alphabet* alphabet, const std::string& modelDescription, const SiteContainer* data = 0, bool parseArguments = true);
+
+  };
+
+} // end of namespace bpp.
+
+#endif // _BPPOSUBSTITUTIONMODELFORMAT_H_
+
diff --git a/src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h b/src/Bpp/Phyl/Io/BppOTreeReaderFormat.cpp
old mode 100755
new mode 100644
similarity index 61%
copy from src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h
copy to src/Bpp/Phyl/Io/BppOTreeReaderFormat.cpp
index 897ed67..7f45330
--- a/src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h
+++ b/src/Bpp/Phyl/Io/BppOTreeReaderFormat.cpp
@@ -1,11 +1,11 @@
 //
-// File: NucleicSubstitutionModel.h
+// File: BppOTreeReaderFormat.cpp
 // Created by: Julien Dutheil
-// Created on: Tue May 27 11:03:53 2003
+// Created on: Sun Jun 19th, 13:16
 //
 
 /*
-  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+  Copyright or © or Copr. Bio++ Development Team, (November 2016)
 
   This software is a computer program whose purpose is to provide classes
   for phylogenetic data analysis.
@@ -37,39 +37,43 @@
   knowledge of the CeCILL license and that you accept its terms.
 */
 
-#ifndef _NUCLEICSUBSTITUTIONMODEL_H_
-#define _NUCLEICSUBSTITUTIONMODEL_H_
+#include "BppOTreeReaderFormat.h"
+#include "Newick.h"
+#include "NexusIoTree.h"
+#include "Nhx.h"
 
-#include "../SubstitutionModel.h"
+#include <Bpp/Text/KeyvalTools.h>
 
-// From SeqLib:
-#include <Bpp/Seq/Alphabet/NucleicAlphabet.h>
+#include <string>
+#include <memory>
 
-namespace bpp
-{
+using namespace bpp;
+using namespace std;
 
-/**
- * @brief Specialisation interface for nucleotide substitution model.
- */
-  class NucleotideSubstitutionModel :
-    public virtual SubstitutionModel
+ITree* BppOTreeReaderFormat::read(const std::string& description) throw (Exception)
+{
+  unparsedArguments_.clear();
+  string format = "";
+  KeyvalTools::parseProcedure(description, format, unparsedArguments_);
+  unique_ptr<ITree> iTree;
+  if (format == "Newick")
   {
-  public:
-    virtual ~NucleotideSubstitutionModel() {}
-
-#ifndef NO_VIRTUAL_COV
-    NucleotideSubstitutionModel*
-#else
-    Clonable*
-#endif
-    clone() const = 0;
-
-  public:
-    virtual size_t getNumberOfStates() const { return 4; }
-
-  };
-
-} //end of namespace bpp.
+    bool allowComments = ApplicationTools::getBooleanParameter("allow_comments", unparsedArguments_, false, "", true, warningLevel_);
+    iTree.reset(new Newick(allowComments));
+  }
+  else if (format == "Nhx")
+  {
+    iTree.reset(new Nhx());
+  }
+  else if (format == "Nexus")
+  {
+    iTree.reset(new NexusIOTree());
+  }
+  else
+  {
+    throw Exception("Tree format '" + format + "' unknown.");
+  }
 
-#endif	//_NUCLEICSUBSTITUTIONMODEL_H_
+  return iTree.release();
+}
 
diff --git a/src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h b/src/Bpp/Phyl/Io/BppOTreeReaderFormat.h
old mode 100755
new mode 100644
similarity index 51%
copy from src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h
copy to src/Bpp/Phyl/Io/BppOTreeReaderFormat.h
index 897ed67..5a81a7d
--- a/src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h
+++ b/src/Bpp/Phyl/Io/BppOTreeReaderFormat.h
@@ -1,11 +1,11 @@
 //
-// File: NucleicSubstitutionModel.h
+// File: BppOTreeReaderFormat.h
 // Created by: Julien Dutheil
-// Created on: Tue May 27 11:03:53 2003
+// Created on: Sun Jun 19th, 13:14
 //
 
 /*
-  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+  Copyright or © or Copr. Bio++ Development Team, (2016)
 
   This software is a computer program whose purpose is to provide classes
   for phylogenetic data analysis.
@@ -37,39 +37,59 @@
   knowledge of the CeCILL license and that you accept its terms.
 */
 
-#ifndef _NUCLEICSUBSTITUTIONMODEL_H_
-#define _NUCLEICSUBSTITUTIONMODEL_H_
+#ifndef _BPPOTREEREADERFORMAT_H_
+#define _BPPOTREEREADERFORMAT_H_
 
-#include "../SubstitutionModel.h"
-
-// From SeqLib:
-#include <Bpp/Seq/Alphabet/NucleicAlphabet.h>
+#include "IoTreeFactory.h"
 
 namespace bpp
 {
 
-/**
- * @brief Specialisation interface for nucleotide substitution model.
- */
-  class NucleotideSubstitutionModel :
-    public virtual SubstitutionModel
+  /**
+   * @brief Tree I/O in BppO format.
+   *
+   * Creates a new ITree object according to
+   * distribution description syntax (see the Bio++ Program Suite
+   * manual for a detailed description of this syntax).
+   *
+   */
+  class BppOTreeReaderFormat:
+    public virtual IOFormat
   {
+  private:
+    std::map<std::string, std::string> unparsedArguments_;
+    int warningLevel_;
+
   public:
-    virtual ~NucleotideSubstitutionModel() {}
+    BppOTreeReaderFormat(int warningLevel):
+      unparsedArguments_(), warningLevel_(warningLevel) {}
 
-#ifndef NO_VIRTUAL_COV
-    NucleotideSubstitutionModel*
-#else
-    Clonable*
-#endif
-    clone() const = 0;
+    virtual ~BppOTreeReaderFormat() {}
 
   public:
-    virtual size_t getNumberOfStates() const { return 4; }
+    const std::string getFormatName() const { return "BppO"; }
+
+    const std::string getFormatDescription() const { return "Bpp Options format."; }
+
+    const std::string getDataType() const { return "Tree reader"; }
+
+    /**
+     * @brief Read a ITree object from a string.
+     *
+     * @param description A string describing the reader in the keyval syntax.
+     * @return A new ITree object according to options specified.
+     * @throw Exception if an error occured.
+     */
+    ITree* read(const std::string& description) throw (Exception);
+
+    /**
+     * @return The arguments and their unparsed values from the last call of the read function, if there are any.
+     */
+    virtual const std::map<std::string, std::string>& getUnparsedArguments() const { return unparsedArguments_; }
 
   };
 
 } //end of namespace bpp.
 
-#endif	//_NUCLEICSUBSTITUTIONMODEL_H_
+#endif //_BPPOTREEREADERFORMAT_H_
 
diff --git a/src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h b/src/Bpp/Phyl/Io/BppOTreeWriterFormat.cpp
old mode 100755
new mode 100644
similarity index 61%
copy from src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h
copy to src/Bpp/Phyl/Io/BppOTreeWriterFormat.cpp
index 897ed67..c4d3d98
--- a/src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h
+++ b/src/Bpp/Phyl/Io/BppOTreeWriterFormat.cpp
@@ -1,11 +1,11 @@
 //
-// File: NucleicSubstitutionModel.h
+// File: BppOTreeWriterFormat.cpp
 // Created by: Julien Dutheil
-// Created on: Tue May 27 11:03:53 2003
+// Created on: Sun Jun 19th, 13:16
 //
 
 /*
-  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+  Copyright or © or Copr. Bio++ Development Team, (November 2016)
 
   This software is a computer program whose purpose is to provide classes
   for phylogenetic data analysis.
@@ -37,39 +37,43 @@
   knowledge of the CeCILL license and that you accept its terms.
 */
 
-#ifndef _NUCLEICSUBSTITUTIONMODEL_H_
-#define _NUCLEICSUBSTITUTIONMODEL_H_
+#include "BppOTreeWriterFormat.h"
+#include "Newick.h"
+#include "NexusIoTree.h"
+#include "Nhx.h"
 
-#include "../SubstitutionModel.h"
+#include <Bpp/Text/KeyvalTools.h>
 
-// From SeqLib:
-#include <Bpp/Seq/Alphabet/NucleicAlphabet.h>
+#include <string>
+#include <memory>
 
-namespace bpp
-{
+using namespace bpp;
+using namespace std;
 
-/**
- * @brief Specialisation interface for nucleotide substitution model.
- */
-  class NucleotideSubstitutionModel :
-    public virtual SubstitutionModel
+OTree* BppOTreeWriterFormat::read(const std::string& description) throw (Exception)
+{
+  unparsedArguments_.clear();
+  string format = "";
+  KeyvalTools::parseProcedure(description, format, unparsedArguments_);
+  unique_ptr<OTree> oTree;
+  if (format == "Newick")
   {
-  public:
-    virtual ~NucleotideSubstitutionModel() {}
-
-#ifndef NO_VIRTUAL_COV
-    NucleotideSubstitutionModel*
-#else
-    Clonable*
-#endif
-    clone() const = 0;
-
-  public:
-    virtual size_t getNumberOfStates() const { return 4; }
-
-  };
-
-} //end of namespace bpp.
+    bool allowComments = ApplicationTools::getBooleanParameter("allow_comments", unparsedArguments_, false, "", true, warningLevel_);
+    oTree.reset(new Newick(allowComments));
+  }
+  else if (format == "Nhx")
+  {
+    oTree.reset(new Nhx());
+  }
+  else if (format == "Nexus")
+  {
+    oTree.reset(new NexusIOTree());
+  }
+  else
+  {
+    throw Exception("Tree format '" + format + "' unknown.");
+  }
 
-#endif	//_NUCLEICSUBSTITUTIONMODEL_H_
+  return oTree.release();
+}
 
diff --git a/src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h b/src/Bpp/Phyl/Io/BppOTreeWriterFormat.h
old mode 100755
new mode 100644
similarity index 51%
copy from src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h
copy to src/Bpp/Phyl/Io/BppOTreeWriterFormat.h
index 897ed67..6fae396
--- a/src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h
+++ b/src/Bpp/Phyl/Io/BppOTreeWriterFormat.h
@@ -1,11 +1,11 @@
 //
-// File: NucleicSubstitutionModel.h
+// File: BppOTreeWriterFormat.h
 // Created by: Julien Dutheil
-// Created on: Tue May 27 11:03:53 2003
+// Created on: Sun Jun 19th, 13:14
 //
 
 /*
-  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+  Copyright or © or Copr. Bio++ Development Team, (2016)
 
   This software is a computer program whose purpose is to provide classes
   for phylogenetic data analysis.
@@ -37,39 +37,59 @@
   knowledge of the CeCILL license and that you accept its terms.
 */
 
-#ifndef _NUCLEICSUBSTITUTIONMODEL_H_
-#define _NUCLEICSUBSTITUTIONMODEL_H_
+#ifndef _BPPOTREEWRITERFORMAT_H_
+#define _BPPOTREEWRITERFORMAT_H_
 
-#include "../SubstitutionModel.h"
-
-// From SeqLib:
-#include <Bpp/Seq/Alphabet/NucleicAlphabet.h>
+#include "IoTreeFactory.h"
 
 namespace bpp
 {
 
-/**
- * @brief Specialisation interface for nucleotide substitution model.
- */
-  class NucleotideSubstitutionModel :
-    public virtual SubstitutionModel
+  /**
+   * @brief Tree I/O in BppO format.
+   *
+   * Creates a new OTree object according to
+   * distribution description syntax (see the Bio++ Program Suite
+   * manual for a detailed description of this syntax).
+   *
+   */
+  class BppOTreeWriterFormat:
+    public virtual IOFormat
   {
+  private:
+    std::map<std::string, std::string> unparsedArguments_;
+    int warningLevel_;
+
   public:
-    virtual ~NucleotideSubstitutionModel() {}
+    BppOTreeWriterFormat(int warningLevel):
+      unparsedArguments_(), warningLevel_(warningLevel) {}
 
-#ifndef NO_VIRTUAL_COV
-    NucleotideSubstitutionModel*
-#else
-    Clonable*
-#endif
-    clone() const = 0;
+    virtual ~BppOTreeWriterFormat() {}
 
   public:
-    virtual size_t getNumberOfStates() const { return 4; }
+    const std::string getFormatName() const { return "BppO"; }
+
+    const std::string getFormatDescription() const { return "Bpp Options format."; }
+
+    const std::string getDataType() const { return "Tree writer"; }
+
+    /**
+     * @brief Read a OTree object from a string.
+     *
+     * @param description A string describing the reader in the keyval syntax.
+     * @return A new OTree object according to options specified.
+     * @throw Exception if an error occured.
+     */
+    OTree* read(const std::string& description) throw (Exception);
+
+    /**
+     * @return The arguments and their unparsed values from the last call of the read function, if there are any.
+     */
+    virtual const std::map<std::string, std::string>& getUnparsedArguments() const { return unparsedArguments_; }
 
   };
 
 } //end of namespace bpp.
 
-#endif	//_NUCLEICSUBSTITUTIONMODEL_H_
+#endif //_BPPOTREEWRITERFORMAT_H_
 
diff --git a/src/Bpp/Phyl/Io/IoFrequenciesSet.h b/src/Bpp/Phyl/Io/IoFrequenciesSet.h
index 180c18f..7a8150a 100644
--- a/src/Bpp/Phyl/Io/IoFrequenciesSet.h
+++ b/src/Bpp/Phyl/Io/IoFrequenciesSet.h
@@ -114,11 +114,14 @@ namespace bpp
      *
      * @param pfreqset A pointer towards a frequencies set object;
      * @param out The output stream;
+     * @param globalAliases parameters linked to global alias. The
+     * output will be "name=alias_name";
      * @param writtenNames is the vector of the written
      * parameters so far [in, out];
      */
     virtual void write(const FrequenciesSet* pfreqset,
                        OutputStream& out,
+                       std::map<std::string, std::string>& globalAliases,
                        std::vector<std::string>& writtenNames) const = 0;
   };
 
diff --git a/src/Bpp/Phyl/Io/IoSubstitutionModel.h b/src/Bpp/Phyl/Io/IoSubstitutionModel.h
index 2c7d119..6880773 100755
--- a/src/Bpp/Phyl/Io/IoSubstitutionModel.h
+++ b/src/Bpp/Phyl/Io/IoSubstitutionModel.h
@@ -53,6 +53,7 @@
 namespace bpp
 {
 
+  class TransitionModel;
   class SubstitutionModel;
 
   /**
@@ -91,7 +92,7 @@ namespace bpp
      * @throw Exception if an error occured.
      */
 
-    virtual SubstitutionModel* read(const Alphabet* alphabet,
+    virtual TransitionModel* read(const Alphabet* alphabet,
                                     const std::string& modelDescription,
                                     const SiteContainer* data = 0,
                                     bool parseArguments = true) = 0;
@@ -125,7 +126,7 @@ namespace bpp
      * parameters so far [in, out];
      * @throw Exception if an error occured.
      */
-    virtual void write(const SubstitutionModel& model,
+    virtual void write(const TransitionModel& model,
                        OutputStream& out,
                        std::map<std::string, std::string>& globalAliases,
                        std::vector<std::string>& writtenNames) const = 0;
diff --git a/src/Bpp/Phyl/Io/IoTree.h b/src/Bpp/Phyl/Io/IoTree.h
index 97ad791..26ee5ac 100755
--- a/src/Bpp/Phyl/Io/IoTree.h
+++ b/src/Bpp/Phyl/Io/IoTree.h
@@ -60,12 +60,12 @@ namespace bpp
 class IOTree:
   public virtual IOFormat
 {
-	public:
-		IOTree() {}
-		virtual ~IOTree() {}
+  public:
+    IOTree() {}
+    virtual ~IOTree() {}
 
-	public:
-		virtual const std::string getDataType() const { return "Tree"; }
+  public:
+    virtual const std::string getDataType() const { return "Tree"; }
 };
 
 /**
@@ -74,11 +74,11 @@ class IOTree:
 class ITree:
   public virtual IOTree
 {
-	public:
-		ITree() {}
-		virtual ~ITree() {}
+  public:
+    ITree() {}
+    virtual ~ITree() {}
 
-	public:
+  public:
     /**
      * @brief Read a tree from a file.
      *
@@ -86,7 +86,7 @@ class ITree:
      * @return A new tree object.
      * @throw Exception If an error occured.
      */
-		virtual Tree* read(const std::string& path) const throw (Exception) = 0;
+    virtual Tree* read(const std::string& path) const throw (Exception) = 0;
     /**
      * @brief Read a tree from a stream.
      *
@@ -94,7 +94,7 @@ class ITree:
      * @return A new tree object.
      * @throw Exception If an error occured.
      */
-		virtual Tree* read(std::istream& in) const throw (Exception) = 0;
+    virtual Tree* read(std::istream& in) const throw (Exception) = 0;
 };
 
 /**
@@ -103,11 +103,11 @@ class ITree:
 class OTree:
   public virtual IOTree
 {
-	public:
-		OTree() {}
-		virtual ~OTree() {}
+  public:
+    OTree() {}
+    virtual ~OTree() {}
 
-	public:
+  public:
     /**
      * @brief Write a tree to a file.
      *
@@ -117,7 +117,7 @@ class OTree:
      * Otherwise append to the file.
      * @throw Exception If an error occured.
      */
-		virtual void write(const Tree& tree, const std::string& path, bool overwrite) const throw (Exception) = 0;
+    virtual void write(const Tree& tree, const std::string& path, bool overwrite) const throw (Exception) = 0;
     /**
      * @brief Write a tree to a stream.
      *
@@ -125,7 +125,7 @@ class OTree:
      * @param out The output stream.
      * @throw Exception If an error occured.
      */
-		virtual void write(const Tree& tree, std::ostream& out) const throw (Exception) = 0;
+    virtual void write(const Tree& tree, std::ostream& out) const throw (Exception) = 0;
 };
 
 /**
@@ -134,19 +134,19 @@ class OTree:
 class AbstractITree:
   public virtual ITree
 {
-	public:
-		AbstractITree() {}
-		virtual ~AbstractITree() {}
-
-	public:
-		virtual Tree* read(std::istream& in) const throw (Exception) = 0;
-		virtual Tree* read(const std::string& path) const throw (Exception)
-		{
+  public:
+    AbstractITree() {}
+    virtual ~AbstractITree() {}
+
+  public:
+    virtual Tree* read(std::istream& in) const throw (Exception) = 0;
+    virtual Tree* read(const std::string& path) const throw (Exception)
+    {
       std::ifstream input(path.c_str(), std::ios::in);
-			Tree* tree = read(input);
-			input.close();
-			return tree;
-		}
+      Tree* tree = read(input);
+      input.close();
+      return tree;
+    }
 
 };
 
@@ -156,29 +156,29 @@ class AbstractITree:
 class AbstractOTree:
   public virtual OTree
 {
-	public:
-		AbstractOTree() {}
-		virtual ~AbstractOTree() {}
-
-	public:
-		void write(const Tree& tree, std::ostream& out) const throw (Exception) = 0;
-		virtual void write(const Tree& tree, const std::string& path, bool overwrite) const throw (Exception)
-		{
-		  try {
-			// Open file in specified mode
-		    std::ofstream output(path.c_str(), overwrite ? (std::ios::out) : (std::ios::out|std::ios::app));
-		    write(tree, output);
-		    output.close();
-		  }
-		  catch (IOException e)
-		    {
-		      std::stringstream ss ;
-		      ss << e.what() <<"\nProblem writing tree to file "<< path <<"\n Is the file path correct and do \
+  public:
+    AbstractOTree() {}
+    virtual ~AbstractOTree() {}
+
+  public:
+    void write(const Tree& tree, std::ostream& out) const throw (Exception) = 0;
+    virtual void write(const Tree& tree, const std::string& path, bool overwrite) const throw (Exception)
+    {
+      try {
+      // Open file in specified mode
+        std::ofstream output(path.c_str(), overwrite ? (std::ios::out) : (std::ios::out|std::ios::app));
+        write(tree, output);
+        output.close();
+      }
+      catch (IOException e)
+        {
+          std::stringstream ss ;
+          ss << e.what() <<"\nProblem writing tree to file "<< path <<"\n Is the file path correct and do \
 you have the proper authorizations? ";
-		      throw (IOException ( ss.str() ) );
-		    }
+          throw (IOException ( ss.str() ) );
+        }
 
-		}
+    }
 };
 
 
@@ -193,11 +193,11 @@ you have the proper authorizations? ";
 class IMultiTree:
   public virtual IOTree
 {
-	public:
-		IMultiTree() {}
-		virtual ~IMultiTree() {}
+  public:
+    IMultiTree() {}
+    virtual ~IMultiTree() {}
 
-	public:
+  public:
     /**
      * @brief Read trees from a file.
      *
@@ -205,7 +205,7 @@ class IMultiTree:
      * @param trees The output trees container.
      * @throw Exception If an error occured.
      */
-		virtual void read(const std::string& path, std::vector<Tree*>& trees) const throw (Exception) = 0;
+    virtual void read(const std::string& path, std::vector<Tree*>& trees) const throw (Exception) = 0;
     /**
      * @brief Read trees from a stream.
      *
@@ -213,7 +213,7 @@ class IMultiTree:
      * @param trees The output trees container.
      * @throw Exception If an error occured.
      */
-		virtual void read(std::istream& in, std::vector<Tree*>& trees) const throw (Exception) = 0;
+    virtual void read(std::istream& in, std::vector<Tree*>& trees) const throw (Exception) = 0;
 };
 
 /**
@@ -222,11 +222,11 @@ class IMultiTree:
 class OMultiTree:
   public virtual IOTree
 {
-	public:
-		OMultiTree() {}
-		virtual ~OMultiTree() {}
+  public:
+    OMultiTree() {}
+    virtual ~OMultiTree() {}
 
-	public:
+  public:
     /**
      * @brief Write trees to a file.
      *
@@ -236,7 +236,7 @@ class OMultiTree:
      * Otherwise append to the file.
      * @throw Exception If an error occured.
      */
-		virtual void write(const std::vector<Tree*>& trees, const std::string& path, bool overwrite) const throw (Exception) = 0;
+    virtual void write(const std::vector<Tree*>& trees, const std::string& path, bool overwrite) const throw (Exception) = 0;
     /**
      * @brief Write trees to a stream.
      *
@@ -244,7 +244,7 @@ class OMultiTree:
      * @param out The output stream.
      * @throw Exception If an error occured.
      */
-		virtual void write(const std::vector<Tree*>& trees, std::ostream& out) const throw (Exception) = 0;
+    virtual void write(const std::vector<Tree*>& trees, std::ostream& out) const throw (Exception) = 0;
 };
 
 /**
@@ -253,18 +253,18 @@ class OMultiTree:
 class AbstractIMultiTree:
   public virtual IMultiTree
 {
-	public:
-		AbstractIMultiTree() {}
-		virtual ~AbstractIMultiTree() {}
-
-	public:
-		virtual void read(std::istream& in, std::vector<Tree*>& trees) const throw (Exception) = 0;
-		virtual void read(const std::string& path, std::vector<Tree*>& trees) const throw (Exception)
-		{
+  public:
+    AbstractIMultiTree() {}
+    virtual ~AbstractIMultiTree() {}
+
+  public:
+    virtual void read(std::istream& in, std::vector<Tree*>& trees) const throw (Exception) = 0;
+    virtual void read(const std::string& path, std::vector<Tree*>& trees) const throw (Exception)
+    {
       std::ifstream input(path.c_str(), std::ios::in);
-			read(input, trees);
-			input.close();
-		}
+      read(input, trees);
+      input.close();
+    }
 
 };
 
@@ -274,22 +274,22 @@ class AbstractIMultiTree:
 class AbstractOMultiTree:
   public virtual OMultiTree
 {
-	public:
-		AbstractOMultiTree() {}
-		virtual ~AbstractOMultiTree() {}
-
-	public:
-		void write(const std::vector<Tree*>& trees, std::ostream& out) const throw (Exception) = 0;
-		virtual void write(const std::vector<Tree*>& trees, const std::string& path, bool overwrite) const throw (Exception)
-		{
-			// Open file in specified mode
+  public:
+    AbstractOMultiTree() {}
+    virtual ~AbstractOMultiTree() {}
+
+  public:
+    void write(const std::vector<Tree*>& trees, std::ostream& out) const throw (Exception) = 0;
+    virtual void write(const std::vector<Tree*>& trees, const std::string& path, bool overwrite) const throw (Exception)
+    {
+      // Open file in specified mode
       std::ofstream output(path.c_str(), overwrite ? (std::ios::out) : (std::ios::out|std::ios::app));
-			write(trees, output);
-			output.close();
-		}
+      write(trees, output);
+      output.close();
+    }
 };
 
 } //end of namespace bpp.
 
-#endif	//_IOTREE_H_
+#endif  //_IOTREE_H_
 
diff --git a/src/Bpp/Phyl/Io/Newick.cpp b/src/Bpp/Phyl/Io/Newick.cpp
index 37f0aa3..c8a51fc 100755
--- a/src/Bpp/Phyl/Io/Newick.cpp
+++ b/src/Bpp/Phyl/Io/Newick.cpp
@@ -66,12 +66,7 @@ const string Newick::getFormatDescription() const
 
 /******************************************************************************/
 
-#if defined(NO_VIRTUAL_COV)
-    Tree*
-#else
-    TreeTemplate<Node> * 
-#endif
-Newick::read(istream& in) const throw (Exception)
+TreeTemplate<Node> * Newick::read(istream& in) const throw (Exception)
 {
   // Checking the existence of specified file
   if (! in) { throw IOException ("Newick::read: failed to read from stream"); }
@@ -93,7 +88,7 @@ Newick::read(istream& in) const throw (Exception)
   if (allowComments_) description = TextTools::removeSubstrings(description, '[', ']');
   if (TextTools::isEmpty(description))
     throw IOException("Newick::read: no tree was found!");
-  return TreeTemplateTools::parenthesisToTree(description, useBootstrap_, bootstrapPropertyName_);
+  return TreeTemplateTools::parenthesisToTree(description, useBootstrap_, bootstrapPropertyName_, false, verbose_);
 }
 
 /******************************************************************************/
@@ -147,7 +142,7 @@ void Newick::read(istream& in, vector<Tree*>& trees) const throw (Exception)
     {
       description += temp.substr(0, index + 1);
       if (allowComments_) description = TextTools::removeSubstrings(description, '[', ']');
-      trees.push_back(TreeTemplateTools::parenthesisToTree(description, useBootstrap_, bootstrapPropertyName_));
+      trees.push_back(TreeTemplateTools::parenthesisToTree(description, useBootstrap_, bootstrapPropertyName_, false, verbose_));
       description = temp.substr(index + 1);
     }
     else description += temp;
diff --git a/src/Bpp/Phyl/Io/Newick.h b/src/Bpp/Phyl/Io/Newick.h
index bac7a56..9db42f2 100755
--- a/src/Bpp/Phyl/Io/Newick.h
+++ b/src/Bpp/Phyl/Io/Newick.h
@@ -5,7 +5,7 @@
 //
 
 /*
-Copyright or © or Copr. CNRS, (November 16, 2004)
+Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
 
 This software is a computer program whose purpose is to provide classes
 for phylogenetic data analysis.
@@ -63,10 +63,10 @@ namespace bpp
  * 
  * Newick * newickReader = new Newick(false); //No comment allowed!
  * try {
- * 	Tree * tree = newickReader->read("MyTestTree.dnd"); // Tree in file MyTestTree.dnd
- * 	cout << "Tree has " << tree->getNumberOfLeaves() << " leaves." << endl;
+ *   Tree * tree = newickReader->read("MyTestTree.dnd"); // Tree in file MyTestTree.dnd
+ *   cout << "Tree has " << tree->getNumberOfLeaves() << " leaves." << endl;
  * } catch (Exception e) {
- *	cout << "Error when reading tree." << endl;
+ *  cout << "Error when reading tree." << endl;
  * }
  * delete tree;
  * delete newickReader;
@@ -86,31 +86,34 @@ class Newick:
   public AbstractIMultiTree,
   public AbstractOMultiTree
 {
-	protected:
-		bool allowComments_;
+  protected:
+    bool allowComments_;
     bool writeId_;
     bool useBootstrap_;
     std::string bootstrapPropertyName_;
-	
-	public:
-		
-		/**
-		 * @brief Build a new Newick reader/writer.
-		 *
-		 * Some newick format allow comments between hooks ('[' ']').
-		 * 
-		 * @param allowComments Tell if comments between [] are allowed in file.
-		 * @param writeId       If true, nodes ids will be written in place of bootstrap values.
-		 */
-		Newick(bool allowComments = false, bool writeId = false):
+    bool verbose_;
+  
+  public:
+    
+    /**
+     * @brief Build a new Newick reader/writer.
+     *
+     * Some newick format allow comments between hooks ('[' ']').
+     * 
+     * @param allowComments Tell if comments between [] are allowed in file.
+     * @param writeId       If true, nodes ids will be written in place of bootstrap values.
+     * @param verbose       If some info should be displayed, such as progress bar etc.
+     */
+    Newick(bool allowComments = false, bool writeId = false, bool verbose = false):
       allowComments_(allowComments),
       writeId_(writeId),
       useBootstrap_(true),
-      bootstrapPropertyName_(TreeTools::BOOTSTRAP) {}
+      bootstrapPropertyName_(TreeTools::BOOTSTRAP),
+      verbose_(verbose) {}
 
-		virtual ~Newick() {}
-	
-	public:
+    virtual ~Newick() {}
+  
+  public:
 
     void enableExtendedBootstrapProperty(const std::string& propertyName)
     {
@@ -123,77 +126,77 @@ class Newick:
       bootstrapPropertyName_ = TreeTools::BOOTSTRAP;
     }
 
-		/**
-		 * @name The IOTree interface
-		 *
-		 * @{
-		 */
-		const std::string getFormatName() const;
-		const std::string getFormatDescription() const;
-		/* @} */
-
-		/**
-		 * @name The ITree interface
-		 *
-		 * @{
-		 */		
-		TreeTemplate<Node>* read(const std::string& path) const throw (Exception)
-		{
-			return dynamic_cast<TreeTemplate<Node>*>(AbstractITree::read(path));
-		}
-		
-		TreeTemplate<Node>* read(std::istream& in) const throw (Exception);
-		/** @} */
-
-		/**
-		 * @name The OTree interface
-		 *
-		 * @{
-		 */
-		void write(const Tree& tree, const std::string& path, bool overwrite = true) const throw (Exception)
-		{
-			AbstractOTree::write(tree, path, overwrite);
-		}
-		
+    /**
+     * @name The IOTree interface
+     *
+     * @{
+     */
+    const std::string getFormatName() const;
+    const std::string getFormatDescription() const;
+    /* @} */
+
+    /**
+     * @name The ITree interface
+     *
+     * @{
+     */    
+    TreeTemplate<Node>* read(const std::string& path) const throw (Exception)
+    {
+      return dynamic_cast<TreeTemplate<Node>*>(AbstractITree::read(path));
+    }
+    
+    TreeTemplate<Node>* read(std::istream& in) const throw (Exception);
+    /** @} */
+
+    /**
+     * @name The OTree interface
+     *
+     * @{
+     */
+    void write(const Tree& tree, const std::string& path, bool overwrite = true) const throw (Exception)
+    {
+      AbstractOTree::write(tree, path, overwrite);
+    }
+    
     void write(const Tree& tree, std::ostream& out) const throw (Exception)
     {
       write_(tree, out);
     }
-		/** @} */
-
-		/**
-		 * @name The IMultiTree interface
-		 *
-		 * @{
-		 */
-		void read(const std::string& path, std::vector<Tree*>& trees) const throw (Exception)
-		{
-			AbstractIMultiTree::read(path, trees);
-		}
-		void read(std::istream& in, std::vector<Tree*>& trees) const throw (Exception);
+    /** @} */
+
+    /**
+     * @name The IMultiTree interface
+     *
+     * @{
+     */
+    void read(const std::string& path, std::vector<Tree*>& trees) const throw (Exception)
+    {
+      AbstractIMultiTree::read(path, trees);
+    }
+    void read(std::istream& in, std::vector<Tree*>& trees) const throw (Exception);
     /**@}*/
 
-		/**
-		 * @name The OMultiTree interface
-		 *
-		 * @{
-		 */
-		void write(const std::vector<Tree*>& trees, const std::string& path, bool overwrite = true) const throw (Exception)
-		{
-			AbstractOMultiTree::write(trees, path, overwrite);
-		}
-		void write(const std::vector<Tree*>& trees, std::ostream& out) const throw (Exception)
+    /**
+     * @name The OMultiTree interface
+     *
+     * @{
+     */
+    void write(const std::vector<Tree*>& trees, const std::string& path, bool overwrite = true) const throw (Exception)
+    {
+      AbstractOMultiTree::write(trees, path, overwrite);
+    }
+    void write(const std::vector<Tree*>& trees, std::ostream& out) const throw (Exception)
     {
       write_(trees, out);
     }
-		/** @} */
+    /** @} */
 
   protected:
     void write_(const Tree& tree, std::ostream& out) const throw (Exception);
     
     template<class N>
     void write_(const TreeTemplate<N>& tree, std::ostream& out) const throw (Exception);
-		
+    
     void write_(const std::vector<Tree*>& trees, std::ostream& out) const throw (Exception);
     
     template<class N>
@@ -203,5 +206,5 @@ class Newick:
 
 } //end of namespace bpp.
 
-#endif	//_NEWICK_H_
+#endif  //_NEWICK_H_
 
diff --git a/src/Bpp/Phyl/Io/NexusIoTree.cpp b/src/Bpp/Phyl/Io/NexusIoTree.cpp
index 740ece3..1b5b37a 100755
--- a/src/Bpp/Phyl/Io/NexusIoTree.cpp
+++ b/src/Bpp/Phyl/Io/NexusIoTree.cpp
@@ -48,7 +48,7 @@ knowledge of the CeCILL license and that you accept its terms.
 #include <Bpp/Text/NestedStringTokenizer.h>
 #include <Bpp/Numeric/VectorTools.h>
 
-//From SeqLib:
+//From bpp-seq:
 #include <Bpp/Seq/Io/NexusTools.h>
 
 using namespace bpp;
@@ -72,12 +72,7 @@ const string NexusIOTree::getFormatDescription() const
 
 /******************************************************************************/
 
-#if defined(NO_VIRTUAL_COV)
-		Tree *
-#else
-		TreeTemplate<Node> * 
-#endif
-NexusIOTree::read(istream &in) const throw (Exception)
+TreeTemplate<Node> * NexusIOTree::read(istream &in) const throw (Exception)
 {
   vector<Tree*> trees;
   read(in, trees);
diff --git a/src/Bpp/Phyl/Io/NexusIoTree.h b/src/Bpp/Phyl/Io/NexusIoTree.h
index 6712650..e9a43b6 100755
--- a/src/Bpp/Phyl/Io/NexusIoTree.h
+++ b/src/Bpp/Phyl/Io/NexusIoTree.h
@@ -64,92 +64,80 @@ class NexusIOTree:
   public virtual AbstractIMultiTree,
   public virtual AbstractOMultiTree
 {
-	public:
-		
-		/**
-		 * @brief Build a new Nexus tree parser.
-		 */
-		NexusIOTree() {}
-
-		virtual ~NexusIOTree() {}
-	
-	public:
-
-		/**
-		 * @name The IOTree interface
-		 *
-		 * @{
-		 */
-		const std::string getFormatName() const;
-		const std::string getFormatDescription() const;
-		/* @} */
-
-		/**
-		 * @name The ITree interface
-		 *
-		 * @{
-		 */
-#if defined(NO_VIRTUAL_COV)
-		Tree* read(const std::string& path) const throw (Exception)
-		{
-			return AbstractITree::read(path);
-		}
-#else
-		TreeTemplate<Node>* read(const std::string& path) const throw (Exception)
-		{
-			return dynamic_cast<TreeTemplate<Node>*>(AbstractITree::read(path));
-		}
-#endif
-		
-#if defined(NO_VIRTUAL_COV)
-		Tree*
-#else
-		TreeTemplate<Node>* 
-#endif
-		read(std::istream& in) const throw (Exception);
-		/** @} */
+  public:
+    
+    /**
+     * @brief Build a new Nexus tree parser.
+     */
+    NexusIOTree() {}
+
+    virtual ~NexusIOTree() {}
+  
+  public:
+
+    /**
+     * @name The IOTree interface
+     *
+     * @{
+     */
+    const std::string getFormatName() const;
+    const std::string getFormatDescription() const;
+    /* @} */
+
+    /**
+     * @name The ITree interface
+     *
+     * @{
+     */
+    TreeTemplate<Node>* read(const std::string& path) const throw (Exception)
+    {
+      return dynamic_cast<TreeTemplate<Node>*>(AbstractITree::read(path));
+    }
+    
+    TreeTemplate<Node>* read(std::istream& in) const throw (Exception);
+    /** @} */
 
     /**
-		 * @name The OTree interface
-		 *
-		 * @{
-		 */
-		void write(const Tree& tree, const std::string& path, bool overwrite = true) const throw (Exception)
-		{
-			AbstractOTree::write(tree, path, overwrite);
-		}
-		void write(const Tree& tree, std::ostream& out) const throw (Exception)
+     * @name The OTree interface
+     *
+     * @{
+     */
+    void write(const Tree& tree, const std::string& path, bool overwrite = true) const throw (Exception)
+    {
+      AbstractOTree::write(tree, path, overwrite);
+    }
+    void write(const Tree& tree, std::ostream& out) const throw (Exception)
     {
       write_(tree, out);
     }
-		/** @} */
-
-		/**
-		 * @name The IMultiTree interface
-		 *
-		 * @{
-		 */
-		void read(const std::string& path, std::vector<Tree*>& trees) const throw (Exception)
-		{
-			AbstractIMultiTree::read(path, trees);
-		}
-		void read(std::istream& in, std::vector<Tree*>& trees) const throw (Exception);
+    /** @} */
+
+    /**
+     * @name The IMultiTree interface
+     *
+     * @{
+     */
+    void read(const std::string& path, std::vector<Tree*>& trees) const throw (Exception)
+    {
+      AbstractIMultiTree::read(path, trees);
+    }
+    void read(std::istream& in, std::vector<Tree*>& trees) const throw (Exception);
     /**@}*/
 
-		/**
-		 * @name The OMultiTree interface
-		 *
-		 * @{
-		 */
-		void write(const std::vector<Tree*>& trees, const std::string& path, bool overwrite = true) const throw (Exception)
-		{
-			AbstractOMultiTree::write(trees, path, overwrite);
-		}
-		void write(const std::vector<Tree*>& trees, std::ostream& out) const throw (Exception)
+    /**
+     * @name The OMultiTree interface
+     *
+     * @{
+     */
+    void write(const std::vector<Tree*>& trees, const std::string& path, bool overwrite = true) const throw (Exception)
+    {
+      AbstractOMultiTree::write(trees, path, overwrite);
+    }
+    void write(const std::vector<Tree*>& trees, std::ostream& out) const throw (Exception)
     {
       write_(trees, out);
     }
-		/** @} */
+    /** @} */
 
   protected:
     void write_(const Tree& tree, std::ostream& out) const throw (Exception);
@@ -166,5 +154,5 @@ class NexusIOTree:
 
 } //end of namespace bpp.
 
-#endif	//_NEXUSIOTREE_H_
+#endif  //_NEXUSIOTREE_H_
 
diff --git a/src/Bpp/Phyl/Io/Nhx.cpp b/src/Bpp/Phyl/Io/Nhx.cpp
index 30f265d..519c20a 100755
--- a/src/Bpp/Phyl/Io/Nhx.cpp
+++ b/src/Bpp/Phyl/Io/Nhx.cpp
@@ -96,12 +96,7 @@ const string Nhx::getFormatDescription() const
 
 /******************************************************************************/
 
-#if defined(NO_VIRTUAL_COV)
-    Tree*
-#else
-    TreeTemplate<Node>* 
-#endif
-Nhx::read(istream& in) const throw (Exception)
+TreeTemplate<Node>* Nhx::read(istream& in) const throw (Exception)
 {
   // Checking the existence of specified file
   if (! in) { throw IOException ("Nhx ::read: failed to read from stream"); }
@@ -508,9 +503,9 @@ bool Nhx::setNodeProperties(Node& node, const string properties) const
       //Property found
       string ppt = (useTagsAsPropertyNames_ ? it->tag : it->name);
       if (it->onBranch) {
-        node.setBranchProperty(ppt, *auto_ptr<Clonable>(stringToProperty_(props[it->tag], it->type)));
+        node.setBranchProperty(ppt, *unique_ptr<Clonable>(stringToProperty_(props[it->tag], it->type)));
       } else {
-        node.setNodeProperty(ppt, *auto_ptr<Clonable>(stringToProperty_(props[it->tag], it->type)));
+        node.setNodeProperty(ppt, *unique_ptr<Clonable>(stringToProperty_(props[it->tag], it->type)));
       }
     }
   }
diff --git a/src/Bpp/Phyl/Io/Nhx.h b/src/Bpp/Phyl/Io/Nhx.h
index 88d5b87..1524ff9 100755
--- a/src/Bpp/Phyl/Io/Nhx.h
+++ b/src/Bpp/Phyl/Io/Nhx.h
@@ -5,36 +5,36 @@
 //
 
 /*
-Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
-
-This software is a computer program whose purpose is to provide classes
-for phylogenetic data analysis.
-
-This software is governed by the CeCILL  license under French law and
-abiding by the rules of distribution of free software.  You can  use, 
-modify and/ or redistribute the software under the terms of the CeCILL
-license as circulated by CEA, CNRS and INRIA at the following URL
-"http://www.cecill.info". 
-
-As a counterpart to the access to the source code and  rights to copy,
-modify and redistribute granted by the license, users are provided only
-with a limited warranty  and the software's author,  the holder of the
-economic rights,  and the successive licensors  have only  limited
-liability. 
-
-In this respect, the user's attention is drawn to the risks associated
-with loading,  using,  modifying and/or developing or reproducing the
-software by the user in light of its specific status of free software,
-that may mean  that it is complicated to manipulate,  and  that  also
-therefore means  that it is reserved for developers  and  experienced
-professionals having in-depth computer knowledge. Users are therefore
-encouraged to load and test the software's suitability as regards their
-requirements in conditions enabling the security of their systems and/or 
-data to be ensured and,  more generally, to use and operate it in the 
-same conditions as regards security. 
-
-The fact that you are presently reading this means that you have had
-knowledge of the CeCILL license and that you accept its terms.
+  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
+
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use, 
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info". 
+
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability. 
+
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or 
+  data to be ensured and,  more generally, to use and operate it in the 
+  same conditions as regards security. 
+
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
 */
 
 #ifndef _NHX_H_
@@ -84,53 +84,53 @@ namespace bpp
  * All node annotations are stored as node properties, with type bppString for all properties except for support values, where a Number is used.
  *
  */
-class Nhx:
-  public AbstractITree,
-  public AbstractOTree,
-  public AbstractIMultiTree,
-  public AbstractOMultiTree
-{
+  class Nhx:
+    public AbstractITree,
+    public AbstractOTree,
+    public AbstractIMultiTree,
+    public AbstractOMultiTree
+  {
   private:
     struct Element
     {
-      public:
-        std::string content;
-        std::string length;
-        std::string annotation;
-        bool isLeaf;
+    public:
+      std::string content;
+      std::string length;
+      std::string annotation;
+      bool isLeaf;
   
-      public:
-        Element() : content(), length(), annotation(), isLeaf(false) {}
+    public:
+      Element() : content(), length(), annotation(), isLeaf(false) {}
     };
   
   public:
     struct Property
     {
-      public:
-        /**
-         * @brief The name of the property, which will be used in parsed trees.
-         */
-        std::string name;
-        /**
-         * @brief The tag of the property, as it will be found in the tree file.
-         */
-        std::string tag;
-        /**
-         * @brief Tells if the property is a branch property instead of a node property.
-         */
-        bool onBranch;
-        /**
-         * @brief The type of the property. 0 is string, 1 is integer, 2 is double, 3 is boolean.
-         */
-        short type;
-
-      public:
-        Property(const std::string& pptName, const std::string& pptTag, bool pptOnBranch = false, short pptType = 0):
-          name(pptName), tag(pptTag), onBranch(pptOnBranch), type(pptType) {}
-
-        bool operator<(const Property& ppt) const {
-          return (name < ppt.name);
-        }
+    public:
+      /**
+       * @brief The name of the property, which will be used in parsed trees.
+       */
+      std::string name;
+      /**
+       * @brief The tag of the property, as it will be found in the tree file.
+       */
+      std::string tag;
+      /**
+       * @brief Tells if the property is a branch property instead of a node property.
+       */
+      bool onBranch;
+      /**
+       * @brief The type of the property. 0 is string, 1 is integer, 2 is double, 3 is boolean.
+       */
+      short type;
+
+    public:
+      Property(const std::string& pptName, const std::string& pptTag, bool pptOnBranch = false, short pptType = 0):
+        name(pptName), tag(pptTag), onBranch(pptOnBranch), type(pptType) {}
+
+      bool operator<(const Property& ppt) const {
+        return (name < ppt.name);
+      }
 
     };
 
@@ -264,6 +264,7 @@ class Nhx:
 
     Element getElement(const std::string& elt) const throw (IOException);
 
+  public:
     Node* parenthesisToNode(const std::string& description) const;
   
     std::string propertiesToParenthesis(const Node& node) const;
@@ -272,9 +273,10 @@ class Nhx:
   
     bool setNodeProperties(Node& node, const std::string properties) const;
 
+  protected:
     static std::string propertyToString_(const Clonable* pptObject, short type) throw (Exception);
     static Clonable* stringToProperty_(const std::string& pptDesc, short type) throw (Exception);
-};
+  };
 
 } //end of namespace bpp.
 
diff --git a/src/Bpp/Phyl/Likelihood/AbstractHomogeneousTreeLikelihood.cpp b/src/Bpp/Phyl/Likelihood/AbstractHomogeneousTreeLikelihood.cpp
index 99dcde2..be75c17 100644
--- a/src/Bpp/Phyl/Likelihood/AbstractHomogeneousTreeLikelihood.cpp
+++ b/src/Bpp/Phyl/Likelihood/AbstractHomogeneousTreeLikelihood.cpp
@@ -58,7 +58,7 @@ using namespace std;
 
 AbstractHomogeneousTreeLikelihood::AbstractHomogeneousTreeLikelihood(
   const Tree& tree,
-  SubstitutionModel* model,
+  TransitionModel* model,
   DiscreteDistribution* rDist,
   bool checkRooted,
   bool verbose)
@@ -132,7 +132,8 @@ AbstractHomogeneousTreeLikelihood& AbstractHomogeneousTreeLikelihood::operator=(
   verbose_         = lik.verbose_;
   minimumBrLen_    = lik.minimumBrLen_;
   maximumBrLen_    = lik.maximumBrLen_;
-  if (brLenConstraint_.get()) brLenConstraint_.release();
+  if (brLenConstraint_.get())
+    brLenConstraint_.release();
   brLenConstraint_.reset(lik.brLenConstraint_->clone());
   return *this;
 }
@@ -141,7 +142,7 @@ AbstractHomogeneousTreeLikelihood& AbstractHomogeneousTreeLikelihood::operator=(
 
 void AbstractHomogeneousTreeLikelihood::init_(
   const Tree& tree,
-  SubstitutionModel* model,
+  TransitionModel* model,
   DiscreteDistribution* rDist,
   bool checkRooted,
   bool verbose) throw (Exception)
@@ -169,7 +170,7 @@ void AbstractHomogeneousTreeLikelihood::init_(
 
 /******************************************************************************/
 
-void AbstractHomogeneousTreeLikelihood::setSubstitutionModel(SubstitutionModel* model) throw (Exception)
+void AbstractHomogeneousTreeLikelihood::setSubstitutionModel(TransitionModel* model) throw (Exception)
 {
   // Check:
   if (data_)
@@ -183,7 +184,7 @@ void AbstractHomogeneousTreeLikelihood::setSubstitutionModel(SubstitutionModel*
   if (data_)
   {
     if (model->getNumberOfStates() != model_->getNumberOfStates())
-      setData(*data_);  // Have to reinitialize the whole data structure.
+      setData(*data_);                          // Have to reinitialize the whole data structure.
   }
 
   nbStates_ = model->getNumberOfStates();
@@ -304,7 +305,7 @@ void AbstractHomogeneousTreeLikelihood::applyParameters() throw (Exception)
 
 /******************************************************************************/
 
-void AbstractHomogeneousTreeLikelihood::initBranchLengthsParameters()
+void AbstractHomogeneousTreeLikelihood::initBranchLengthsParameters(bool verbose)
 {
   brLenParameters_.reset();
   for (unsigned int i = 0; i < nbNodes_; i++)
@@ -312,7 +313,8 @@ void AbstractHomogeneousTreeLikelihood::initBranchLengthsParameters()
     double d = minimumBrLen_;
     if (!nodes_[i]->hasDistanceToFather())
     {
-      ApplicationTools::displayWarning("Missing branch length " + TextTools::toString(i) + ". Value is set to " + TextTools::toString(minimumBrLen_));
+      if (verbose)
+        ApplicationTools::displayWarning("Missing branch length " + TextTools::toString(i) + ". Value is set to " + TextTools::toString(minimumBrLen_));
       nodes_[i]->setDistanceToFather(minimumBrLen_);
     }
     else
@@ -320,13 +322,15 @@ void AbstractHomogeneousTreeLikelihood::initBranchLengthsParameters()
       d = nodes_[i]->getDistanceToFather();
       if (d < minimumBrLen_)
       {
-        ApplicationTools::displayWarning("Branch length " + TextTools::toString(i) + " is too small: " + TextTools::toString(d) + ". Value is set to " + TextTools::toString(minimumBrLen_));
+        if (verbose)
+          ApplicationTools::displayWarning("Branch length " + TextTools::toString(i) + " is too small: " + TextTools::toString(d) + ". Value is set to " + TextTools::toString(minimumBrLen_));
         nodes_[i]->setDistanceToFather(minimumBrLen_);
         d = minimumBrLen_;
       }
       if (d > maximumBrLen_)
       {
-        ApplicationTools::displayWarning("Branch length " + TextTools::toString(i) + " is too big: " + TextTools::toString(d) + ". Value is set to " + TextTools::toString(maximumBrLen_));
+        if (verbose)
+          ApplicationTools::displayWarning("Branch length " + TextTools::toString(i) + " is too big: " + TextTools::toString(d) + ". Value is set to " + TextTools::toString(maximumBrLen_));
         nodes_[i]->setDistanceToFather(maximumBrLen_);
         d = maximumBrLen_;
       }
@@ -370,7 +374,7 @@ void AbstractHomogeneousTreeLikelihood::computeTransitionProbabilitiesForNode(co
       }
     }
   }
-  
+
   if (computeFirstOrderDerivatives_)
   {
     // Computes all dpxy/dt once for all:
@@ -413,4 +417,3 @@ void AbstractHomogeneousTreeLikelihood::computeTransitionProbabilitiesForNode(co
 }
 
 /*******************************************************************************/
-
diff --git a/src/Bpp/Phyl/Likelihood/AbstractHomogeneousTreeLikelihood.h b/src/Bpp/Phyl/Likelihood/AbstractHomogeneousTreeLikelihood.h
old mode 100755
new mode 100644
index 2914fad..3dca3f3
--- a/src/Bpp/Phyl/Likelihood/AbstractHomogeneousTreeLikelihood.h
+++ b/src/Bpp/Phyl/Likelihood/AbstractHomogeneousTreeLikelihood.h
@@ -5,37 +5,37 @@
 //
 
 /*
-Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
-
-This software is a computer program whose purpose is to provide classes
-for phylogenetic data analysis.
-
-This software is governed by the CeCILL  license under French law and
-abiding by the rules of distribution of free software.  You can  use, 
-modify and/ or redistribute the software under the terms of the CeCILL
-license as circulated by CEA, CNRS and INRIA at the following URL
-"http://www.cecill.info". 
-
-As a counterpart to the access to the source code and  rights to copy,
-modify and redistribute granted by the license, users are provided only
-with a limited warranty  and the software's author,  the holder of the
-economic rights,  and the successive licensors  have only  limited
-liability. 
-
-In this respect, the user's attention is drawn to the risks associated
-with loading,  using,  modifying and/or developing or reproducing the
-software by the user in light of its specific status of free software,
-that may mean  that it is complicated to manipulate,  and  that  also
-therefore means  that it is reserved for developers  and  experienced
-professionals having in-depth computer knowledge. Users are therefore
-encouraged to load and test the software's suitability as regards their
-requirements in conditions enabling the security of their systems and/or 
-data to be ensured and,  more generally, to use and operate it in the 
-same conditions as regards security. 
-
-The fact that you are presently reading this means that you have had
-knowledge of the CeCILL license and that you accept its terms.
-*/
+   Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+
+   This software is a computer program whose purpose is to provide classes
+   for phylogenetic data analysis.
+
+   This software is governed by the CeCILL  license under French law and
+   abiding by the rules of distribution of free software.  You can  use,
+   modify and/ or redistribute the software under the terms of the CeCILL
+   license as circulated by CEA, CNRS and INRIA at the following URL
+   "http://www.cecill.info".
+
+   As a counterpart to the access to the source code and  rights to copy,
+   modify and redistribute granted by the license, users are provided only
+   with a limited warranty  and the software's author,  the holder of the
+   economic rights,  and the successive licensors  have only  limited
+   liability.
+
+   In this respect, the user's attention is drawn to the risks associated
+   with loading,  using,  modifying and/or developing or reproducing the
+   software by the user in light of its specific status of free software,
+   that may mean  that it is complicated to manipulate,  and  that  also
+   therefore means  that it is reserved for developers  and  experienced
+   professionals having in-depth computer knowledge. Users are therefore
+   encouraged to load and test the software's suitability as regards their
+   requirements in conditions enabling the security of their systems and/or
+   data to be ensured and,  more generally, to use and operate it in the
+   same conditions as regards security.
+
+   The fact that you are presently reading this means that you have had
+   knowledge of the CeCILL license and that you accept its terms.
+ */
 
 #ifndef _ABSTRACTHOMOGENEOUSTREELIKELIHOOD_H_
 #define _ABSTRACTHOMOGENEOUSTREELIKELIHOOD_H_
@@ -43,229 +43,223 @@ knowledge of the CeCILL license and that you accept its terms.
 #include "AbstractDiscreteRatesAcrossSitesTreeLikelihood.h"
 #include "HomogeneousTreeLikelihood.h"
 
-//From STL:
-#include<memory>
+// From STL:
+#include <memory>
 
 namespace bpp
 {
-
 /**
  * @brief Partial implementation for homogeneous model of the TreeLikelihood interface.
  *
  * This class provides a pointer toward a single substitution model + several utilitary variables.
  */
-class AbstractHomogeneousTreeLikelihood:
+class AbstractHomogeneousTreeLikelihood :
   public virtual HomogeneousTreeLikelihood,
   public AbstractDiscreteRatesAcrossSitesTreeLikelihood
 {
-  public:
-
-    class ConstHomogeneousSiteModelIterator :
-      public ConstSiteModelIterator
-    {
-      private:
-        ConstNoPartitionSiteModelDescription siteModelDescription_;
-        size_t index_;
-
-      public:
-        ConstHomogeneousSiteModelIterator(const Tree& tree, const SubstitutionModel* model) :
-          siteModelDescription_(model, tree.getBranchesId()), index_(0) {}
-
-      public:
-        ConstSiteModelDescription* next() throw (Exception)
-        {
-          if (!hasNext())
-            throw Exception("AbstractHomogeneousTreeLikelihood::ConstHomogeneousSiteModelIterator::next(). No more site in the set.");
-          index_++;
-          return &siteModelDescription_;
-        }
-
-        bool hasNext() const { return index_ == 0; }
-    };
-
-
-  protected:
-    SubstitutionModel* model_;
-    ParameterList brLenParameters_;
-    
-    mutable std::map<int, VVVdouble> pxy_;
-
-    mutable std::map<int, VVVdouble> dpxy_;
-
-    mutable std::map<int, VVVdouble> d2pxy_;
-
-    std::vector<double> rootFreqs_;
-        
-    /**
-     * @brief Pointer toward all nodes in the tree.
-     *
-     * The position in the array is the number used in the parameter name.
-     * This may be different from the node id, unless you used the resetNodeId method on the input tree.
-      */
-    std::vector<Node*> nodes_;
-
-    //some values we'll need:
-    size_t nbSites_,         //the number of sites in the container
-           nbDistinctSites_, //the number of distinct sites
-           nbClasses_,       //the number of rate classes
-           nbStates_,        //the number of states in the alphabet
-           nbNodes_;         //the number of nodes in the tree
-
-    bool verbose_;
-
-    double minimumBrLen_;
-    double maximumBrLen_;
-    std::auto_ptr<Constraint> brLenConstraint_;
-
-  public:
-    AbstractHomogeneousTreeLikelihood(
-      const Tree& tree,
-      SubstitutionModel* model,
-      DiscreteDistribution* rDist,
-      bool checkRooted = true,
-      bool verbose = true)
-      throw (Exception);
-
-    /**
-     * @brief Copy constructor
-     *
-     * This constructor is to be called by the derived class copy constructor.
-     */
-    AbstractHomogeneousTreeLikelihood(const AbstractHomogeneousTreeLikelihood& lik);
-    
-    /**
-     * @brief Assignation operator
-     *
-     * This operator is to be called by the derived class operator.
-     */
-    AbstractHomogeneousTreeLikelihood& operator=(const AbstractHomogeneousTreeLikelihood& lik);
- 
-    virtual ~AbstractHomogeneousTreeLikelihood() {}
-    
-  private:
-
-    /**
-     * @brief Method called by constructor.
-     */
-    void init_(const Tree& tree,
-      SubstitutionModel* model,
-      DiscreteDistribution* rDist,
-      bool checkRooted,
-      bool verbose) throw (Exception);
-
-  public:
-    
-    /**
-     * @name The TreeLikelihood interface.
-     *
-     * Other methods are implemented in the AbstractTreeLikelihood class.
-     *
-     * @{
-     */
-    size_t getNumberOfStates() const { return model_->getNumberOfStates(); } 
-    
-    const std::vector<int>& getAlphabetStates() const { return model_->getAlphabetStates(); } 
-    
-    int getAlphabetStateAsInt(size_t i) const { return model_->getAlphabetStateAsInt(i); }
-  
-    std::string getAlphabetStateAsChar(size_t i) const { return model_->getAlphabetStateAsChar(i); }
-     
-    void initialize() throw(Exception);
-    
-    ParameterList getBranchLengthsParameters() const;
-    
-    ParameterList getSubstitutionModelParameters() const;
-    
-    ParameterList getRateDistributionParameters() const
+public:
+  class ConstHomogeneousSiteModelIterator :
+    public ConstSiteModelIterator
+  {
+private:
+    ConstNoPartitionSiteModelDescription siteModelDescription_;
+    size_t index_;
+
+public:
+    ConstHomogeneousSiteModelIterator(const Tree& tree, const TransitionModel* model) :
+      siteModelDescription_(model, tree.getBranchesId()),
+      index_(0) {}
+
+public:
+    ConstSiteModelDescription* next() throw (Exception)
     {
-      return AbstractDiscreteRatesAcrossSitesTreeLikelihood::getRateDistributionParameters();
+      if (!hasNext())
+        throw Exception("AbstractHomogeneousTreeLikelihood::ConstHomogeneousSiteModelIterator::next(). No more site in the set.");
+      index_++;
+      return &siteModelDescription_;
     }
-    
-    const std::vector<double>& getRootFrequencies(size_t siteIndex) const { return model_->getFrequencies(); }
-    
-    VVVdouble getTransitionProbabilitiesPerRateClass(int nodeId, size_t siteIndex) const { return pxy_[nodeId]; }
 
-    ConstBranchModelIterator* getNewBranchModelIterator(int nodeId) const
-    {
-      return new ConstNoPartitionBranchModelIterator(model_, nbDistinctSites_);
-    }
+    bool hasNext() const { return index_ == 0; }
+  };
 
-    ConstSiteModelIterator* getNewSiteModelIterator(size_t siteIndex) const
-    {
-      return new ConstHomogeneousSiteModelIterator(*tree_, model_);
-    }
-   
-    /** @} */
-
-    /**
-     * @name The HomogeneousTreeLikelihood interface.
-     *
-     * Other methods are implemented in the AbstractTreeLikelihood class.
-     *
-     * @{
-     */
-    const SubstitutionModel* getSubstitutionModel() const { return model_; }
-    const SubstitutionModel* getSubstitutionModel(int nodeId, size_t siteIndex) const throw (NodeNotFoundException) { return model_; }
-    
-    SubstitutionModel* getSubstitutionModel() { return model_; }
-    SubstitutionModel* getSubstitutionModel(int nodeId, size_t siteIndex) throw (NodeNotFoundException) { return model_; }
-    
-    void setSubstitutionModel(SubstitutionModel* model) throw (Exception);
-    /** @} */
-    
-  public: //Specific methods:
-
-    /**
-     * @brief This builds the <i>parameters</i> list from all parametrizable objects,
-     * <i>i.e.</i> substitution model, rate distribution and tree.
-     */
-    virtual void initParameters();
-
-    /**
-     * @brief All parameters are stored in a parameter list.
-     * This function apply these parameters to the substitution model,
-     * to the rate distribution and to the branch lengths.
-     */
-    virtual void applyParameters() throw (Exception);  
-
-    virtual void initBranchLengthsParameters();
-
-    virtual void setMinimumBranchLength(double minimum) throw (Exception)
-    {
-      if (minimum > maximumBrLen_)
-        throw Exception("AbstractHomogeneousTreeLikelihood::setMinimumBranchLength. Minimum branch length sould be lower than the maximum one: " + TextTools::toString(maximumBrLen_));
-      minimumBrLen_ = minimum;
-      if (brLenConstraint_.get()) brLenConstraint_.release();
-      brLenConstraint_.reset(new IntervalConstraint(minimumBrLen_, maximumBrLen_, true, true));
-      initBranchLengthsParameters();
-    }
+protected:
+  TransitionModel* model_;
+  ParameterList brLenParameters_;
 
-    virtual void setMaximumBranchLength(double maximum) throw (Exception)
-    {
-      if (maximum < minimumBrLen_)
-        throw Exception("AbstractHomogeneousTreeLikelihood::setMaximumBranchLength. Maximum branch length sould be higher than the minimum one: " + TextTools::toString(minimumBrLen_));
-      maximumBrLen_ = maximum;
-      if (brLenConstraint_.get()) brLenConstraint_.release();
-      brLenConstraint_.reset(new IntervalConstraint(minimumBrLen_, maximumBrLen_, true, true));
-      initBranchLengthsParameters();
-    }
+  mutable std::map<int, VVVdouble> pxy_;
 
-    virtual double getMinimumBranchLength() const { return minimumBrLen_; }
-    virtual double getMaximumBranchLength() const { return maximumBrLen_; }
+  mutable std::map<int, VVVdouble> dpxy_;
+
+  mutable std::map<int, VVVdouble> d2pxy_;
 
-  protected:
-    /**
-     * @brief Fill the pxy_, dpxy_ and d2pxy_ arrays for all nodes.
-     */
-    virtual void computeAllTransitionProbabilities();
-    /**
-     * @brief Fill the pxy_, dpxy_ and d2pxy_ arrays for one node.
-     */
-    virtual void computeTransitionProbabilitiesForNode(const Node * node);
+  std::vector<double> rootFreqs_;
 
-};
-
-} //end of namespace bpp.
+  /**
+   * @brief Pointer toward all nodes in the tree.
+   *
+   * The position in the array is the number used in the parameter name.
+   * This may be different from the node id, unless you used the resetNodeId method on the input tree.
+   */
+  std::vector<Node*> nodes_;
+
+  // some values we'll need:
+  size_t nbSites_,         // the number of sites in the container
+         nbDistinctSites_, // the number of distinct sites
+         nbClasses_,       // the number of rate classes
+         nbStates_,        // the number of states in the alphabet
+         nbNodes_;         // the number of nodes in the tree
 
-#endif //_ABSTRACTHOMOGENEOUSTREELIKELIHOOD_H_
+  bool verbose_;
+
+  double minimumBrLen_;
+  double maximumBrLen_;
+  std::unique_ptr<Constraint> brLenConstraint_;
+
+public:
+  AbstractHomogeneousTreeLikelihood(
+    const Tree& tree,
+    TransitionModel* model,
+    DiscreteDistribution* rDist,
+    bool checkRooted = true,
+    bool verbose = true)
+  throw (Exception);
+
+  /**
+   * @brief Copy constructor
+   *
+   * This constructor is to be called by the derived class copy constructor.
+   */
+  AbstractHomogeneousTreeLikelihood(const AbstractHomogeneousTreeLikelihood& lik);
+
+  /**
+   * @brief Assignation operator
+   *
+   * This operator is to be called by the derived class operator.
+   */
+  AbstractHomogeneousTreeLikelihood& operator=(const AbstractHomogeneousTreeLikelihood& lik);
+
+  virtual ~AbstractHomogeneousTreeLikelihood() {}
+
+private:
+  /**
+   * @brief Method called by constructor.
+   */
+  void init_(const Tree& tree,
+             TransitionModel* model,
+             DiscreteDistribution* rDist,
+             bool checkRooted,
+             bool verbose) throw (Exception);
+
+public:
+  /**
+   * @name The TreeLikelihood interface.
+   *
+   * Other methods are implemented in the AbstractTreeLikelihood class.
+   *
+   * @{
+   */
+  size_t getNumberOfStates() const { return model_->getNumberOfStates(); }
+
+  const std::vector<int>& getAlphabetStates() const { return model_->getAlphabetStates(); }
+
+  int getAlphabetStateAsInt(size_t i) const { return model_->getAlphabetStateAsInt(i); }
+
+  std::string getAlphabetStateAsChar(size_t i) const { return model_->getAlphabetStateAsChar(i); }
+
+  void initialize() throw (Exception);
+
+  ParameterList getBranchLengthsParameters() const;
+
+  ParameterList getSubstitutionModelParameters() const;
+
+  ParameterList getRateDistributionParameters() const
+  {
+    return AbstractDiscreteRatesAcrossSitesTreeLikelihood::getRateDistributionParameters();
+  }
+
+  const std::vector<double>& getRootFrequencies(size_t siteIndex) const { return model_->getFrequencies(); }
+
+  VVVdouble getTransitionProbabilitiesPerRateClass(int nodeId, size_t siteIndex) const { return pxy_[nodeId]; }
+
+  ConstBranchModelIterator* getNewBranchModelIterator(int nodeId) const
+  {
+    return new ConstNoPartitionBranchModelIterator(model_, nbDistinctSites_);
+  }
+
+  ConstSiteModelIterator* getNewSiteModelIterator(size_t siteIndex) const
+  {
+    return new ConstHomogeneousSiteModelIterator(*tree_, model_);
+  }
+
+  /** @} */
+
+  /**
+   * @name The HomogeneousTreeLikelihood interface.
+   *
+   * Other methods are implemented in the AbstractTreeLikelihood class.
+   *
+   * @{
+   */
+  const TransitionModel* getSubstitutionModel() const { return model_; }
+  const TransitionModel* getSubstitutionModel(int nodeId, size_t siteIndex) const throw (NodeNotFoundException) { return model_; }
+
+  TransitionModel* getSubstitutionModel() { return model_; }
+  TransitionModel* getSubstitutionModel(int nodeId, size_t siteIndex) throw (NodeNotFoundException) { return model_; }
+
+  void setSubstitutionModel(TransitionModel* model) throw (Exception);
+  /** @} */
+
+public:
+  // Specific methods:
+
+  /**
+   * @brief This builds the <i>parameters</i> list from all parametrizable objects,
+   * <i>i.e.</i> substitution model, rate distribution and tree.
+   */
+  virtual void initParameters();
+
+  /**
+   * @brief All parameters are stored in a parameter list.
+   * This function apply these parameters to the substitution model,
+   * to the rate distribution and to the branch lengths.
+   */
+  virtual void applyParameters() throw (Exception);
+
+  virtual void initBranchLengthsParameters(bool verbose = true);
+
+  virtual void setMinimumBranchLength(double minimum) throw (Exception)
+  {
+    if (minimum > maximumBrLen_)
+      throw Exception("AbstractHomogeneousTreeLikelihood::setMinimumBranchLength. Minimum branch length sould be lower than the maximum one: " + TextTools::toString(maximumBrLen_));
+    minimumBrLen_ = minimum;
+    if (brLenConstraint_.get()) brLenConstraint_.release();
+    brLenConstraint_.reset(new IntervalConstraint(minimumBrLen_, maximumBrLen_, true, true));
+    initBranchLengthsParameters();
+  }
+
+  virtual void setMaximumBranchLength(double maximum) throw (Exception)
+  {
+    if (maximum < minimumBrLen_)
+      throw Exception("AbstractHomogeneousTreeLikelihood::setMaximumBranchLength. Maximum branch length sould be higher than the minimum one: " + TextTools::toString(minimumBrLen_));
+    maximumBrLen_ = maximum;
+    if (brLenConstraint_.get()) brLenConstraint_.release();
+    brLenConstraint_.reset(new IntervalConstraint(minimumBrLen_, maximumBrLen_, true, true));
+    initBranchLengthsParameters();
+  }
+
+  virtual double getMinimumBranchLength() const { return minimumBrLen_; }
+  virtual double getMaximumBranchLength() const { return maximumBrLen_; }
+
+protected:
+  /**
+   * @brief Fill the pxy_, dpxy_ and d2pxy_ arrays for all nodes.
+   */
+  virtual void computeAllTransitionProbabilities();
+  /**
+   * @brief Fill the pxy_, dpxy_ and d2pxy_ arrays for one node.
+   */
+  virtual void computeTransitionProbabilitiesForNode(const Node* node);
+};
+} // end of namespace bpp.
 
+#endif // _ABSTRACTHOMOGENEOUSTREELIKELIHOOD_H_
diff --git a/src/Bpp/Phyl/Likelihood/AbstractNonHomogeneousTreeLikelihood.cpp b/src/Bpp/Phyl/Likelihood/AbstractNonHomogeneousTreeLikelihood.cpp
index 0291f7f..5f0594c 100644
--- a/src/Bpp/Phyl/Likelihood/AbstractNonHomogeneousTreeLikelihood.cpp
+++ b/src/Bpp/Phyl/Likelihood/AbstractNonHomogeneousTreeLikelihood.cpp
@@ -79,7 +79,7 @@ AbstractNonHomogeneousTreeLikelihood::AbstractNonHomogeneousTreeLikelihood(
   verbose_(),
   minimumBrLen_(),
   maximumBrLen_(),
-  brLenConstraint_(0),
+  brLenConstraint_(),
   reparametrizeRoot_(reparametrizeRoot),
   root1_(),
   root2_()
@@ -316,26 +316,26 @@ void AbstractNonHomogeneousTreeLikelihood::applyParameters() throw (Exception)
   if (!initialized_) throw Exception("AbstractBranchNonHomogeneousTreeLikelihood::applyParameters(). Object not initialized.");
   //Apply branch lengths:
   for (unsigned int i = 0; i < nbNodes_; i++)
+  {
+    int id = nodes_[i]->getId();
+    if (reparametrizeRoot_ && id == root1_)
     {
-      int id = nodes_[i]->getId();
-      if (reparametrizeRoot_ && id == root1_)
-        {
-          const Parameter* rootBrLen = &getParameter("BrLenRoot");
-          const Parameter* rootPos = &getParameter("RootPosition");
-          nodes_[i]->setDistanceToFather(rootBrLen->getValue() * rootPos->getValue());
-        }
-      else if (reparametrizeRoot_ && id == root2_)
-        {
-          const Parameter* rootBrLen = &getParameter("BrLenRoot");
-          const Parameter* rootPos = &getParameter("RootPosition");
-          nodes_[i]->setDistanceToFather(rootBrLen->getValue() * (1. - rootPos->getValue()));
-        }
-      else
-        {
-          const Parameter* brLen = &getParameter(string("BrLen") + TextTools::toString(i));
-          if (brLen) nodes_[i]->setDistanceToFather(brLen->getValue());
-        }
+      const Parameter* rootBrLen = &getParameter("BrLenRoot");
+      const Parameter* rootPos = &getParameter("RootPosition");
+      nodes_[i]->setDistanceToFather(rootBrLen->getValue() * rootPos->getValue());
+    }
+    else if (reparametrizeRoot_ && id == root2_)
+    {
+      const Parameter* rootBrLen = &getParameter("BrLenRoot");
+      const Parameter* rootPos = &getParameter("RootPosition");
+      nodes_[i]->setDistanceToFather(rootBrLen->getValue() * (1. - rootPos->getValue()));
     }
+    else
+    {
+      const Parameter* brLen = &getParameter(string("BrLen") + TextTools::toString(i));
+      if (brLen) nodes_[i]->setDistanceToFather(brLen->getValue());
+    }
+  }
   //Apply substitution model parameters:
 
   modelSet_->matchParametersValues(getParameters());
@@ -345,7 +345,7 @@ void AbstractNonHomogeneousTreeLikelihood::applyParameters() throw (Exception)
 
 /******************************************************************************/
 
-void AbstractNonHomogeneousTreeLikelihood::initBranchLengthsParameters()
+void AbstractNonHomogeneousTreeLikelihood::initBranchLengthsParameters(bool verbose)
 {
   brLenParameters_.reset();
   double l1 = 0, l2 = 0;
@@ -354,7 +354,8 @@ void AbstractNonHomogeneousTreeLikelihood::initBranchLengthsParameters()
       double d = minimumBrLen_;
       if (!nodes_[i]->hasDistanceToFather())
         {
-          ApplicationTools::displayWarning("Missing branch length " + TextTools::toString(i) + ". Value is set to " + TextTools::toString(minimumBrLen_));
+          if (verbose)
+            ApplicationTools::displayWarning("Missing branch length " + TextTools::toString(i) + ". Value is set to " + TextTools::toString(minimumBrLen_));
           nodes_[i]->setDistanceToFather(minimumBrLen_);
         }
       else
@@ -362,13 +363,15 @@ void AbstractNonHomogeneousTreeLikelihood::initBranchLengthsParameters()
           d = nodes_[i]->getDistanceToFather();
           if (d < minimumBrLen_)
             {
-              ApplicationTools::displayWarning("Branch length " + TextTools::toString(i) + " is too small: " + TextTools::toString(d) + ". Value is set to " + TextTools::toString(minimumBrLen_));
+              if (verbose)
+                ApplicationTools::displayWarning("Branch length " + TextTools::toString(i) + " is too small: " + TextTools::toString(d) + ". Value is set to " + TextTools::toString(minimumBrLen_));
               nodes_[i]->setDistanceToFather(minimumBrLen_);
               d = minimumBrLen_;
             }
           if (d > maximumBrLen_)
             {
-              ApplicationTools::displayWarning("Branch length " + TextTools::toString(i) + " is too big: " + TextTools::toString(d) + ". Value is set to " + TextTools::toString(maximumBrLen_));
+              if (verbose)
+                ApplicationTools::displayWarning("Branch length " + TextTools::toString(i) + " is too big: " + TextTools::toString(d) + ". Value is set to " + TextTools::toString(maximumBrLen_));
               nodes_[i]->setDistanceToFather(maximumBrLen_);
               d = maximumBrLen_;
             }
@@ -405,7 +408,7 @@ void AbstractNonHomogeneousTreeLikelihood::computeAllTransitionProbabilities()
 
 void AbstractNonHomogeneousTreeLikelihood::computeTransitionProbabilitiesForNode(const Node* node)
 {
-  const SubstitutionModel* model = modelSet_->getModelForNode(node->getId());
+  const TransitionModel* model = modelSet_->getModelForNode(node->getId());
   double l = node->getDistanceToFather(); 
 
   //Computes all pxy and pyx once for all:
diff --git a/src/Bpp/Phyl/Likelihood/AbstractNonHomogeneousTreeLikelihood.h b/src/Bpp/Phyl/Likelihood/AbstractNonHomogeneousTreeLikelihood.h
index b17fada..cc1b85a 100644
--- a/src/Bpp/Phyl/Likelihood/AbstractNonHomogeneousTreeLikelihood.h
+++ b/src/Bpp/Phyl/Likelihood/AbstractNonHomogeneousTreeLikelihood.h
@@ -124,7 +124,7 @@ class AbstractNonHomogeneousTreeLikelihood:
 
     double minimumBrLen_;
     double maximumBrLen_;
-    std::auto_ptr<Constraint> brLenConstraint_;
+    std::unique_ptr<Constraint> brLenConstraint_;
 
     bool reparametrizeRoot_;
     int root1_, root2_;
@@ -193,12 +193,12 @@ class AbstractNonHomogeneousTreeLikelihood:
       return AbstractDiscreteRatesAcrossSitesTreeLikelihood::getRateDistributionParameters();
     }
 
-    const SubstitutionModel* getSubstitutionModelForNode(int nodeId) const throw (NodeNotFoundException) 
+    const TransitionModel* getSubstitutionModelForNode(int nodeId) const throw (NodeNotFoundException) 
     {
       return modelSet_->getModelForNode(nodeId);
     }
 
-    SubstitutionModel* getSubstitutionModelForNode(int nodeId) throw (NodeNotFoundException)
+    TransitionModel* getSubstitutionModelForNode(int nodeId) throw (NodeNotFoundException)
     {
       return modelSet_->getModelForNode(nodeId);
     }
@@ -253,7 +253,7 @@ class AbstractNonHomogeneousTreeLikelihood:
      */
     virtual void applyParameters() throw (Exception);  
 
-    virtual void initBranchLengthsParameters();
+    virtual void initBranchLengthsParameters(bool verbose = true);
 
     virtual void setMinimumBranchLength(double minimum) throw (Exception)
     {
diff --git a/src/Bpp/Phyl/Likelihood/AbstractTreeLikelihood.h b/src/Bpp/Phyl/Likelihood/AbstractTreeLikelihood.h
index 528cc78..5c1b844 100755
--- a/src/Bpp/Phyl/Likelihood/AbstractTreeLikelihood.h
+++ b/src/Bpp/Phyl/Likelihood/AbstractTreeLikelihood.h
@@ -5,36 +5,36 @@
 //
 
 /*
-Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
-
-This software is a computer program whose purpose is to provide classes
-for phylogenetic data analysis.
-
-This software is governed by the CeCILL  license under French law and
-abiding by the rules of distribution of free software.  You can  use, 
-modify and/ or redistribute the software under the terms of the CeCILL
-license as circulated by CEA, CNRS and INRIA at the following URL
-"http://www.cecill.info". 
-
-As a counterpart to the access to the source code and  rights to copy,
-modify and redistribute granted by the license, users are provided only
-with a limited warranty  and the software's author,  the holder of the
-economic rights,  and the successive licensors  have only  limited
-liability. 
-
-In this respect, the user's attention is drawn to the risks associated
-with loading,  using,  modifying and/or developing or reproducing the
-software by the user in light of its specific status of free software,
-that may mean  that it is complicated to manipulate,  and  that  also
-therefore means  that it is reserved for developers  and  experienced
-professionals having in-depth computer knowledge. Users are therefore
-encouraged to load and test the software's suitability as regards their
-requirements in conditions enabling the security of their systems and/or 
-data to be ensured and,  more generally, to use and operate it in the 
-same conditions as regards security. 
-
-The fact that you are presently reading this means that you have had
-knowledge of the CeCILL license and that you accept its terms.
+  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
+
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use, 
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info". 
+
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability. 
+
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or 
+  data to be ensured and,  more generally, to use and operate it in the 
+  same conditions as regards security. 
+
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
 */
 
 #ifndef _ABSTRACTTREELIKELIHOOD_H_
@@ -66,10 +66,10 @@ namespace bpp
  * 
  * It also adds an abstract method for recursive computations.
  */
-class AbstractTreeLikelihood :
-  public virtual TreeLikelihood,
-  public AbstractParametrizable
-{
+  class AbstractTreeLikelihood :
+    public virtual TreeLikelihood,
+    public AbstractParametrizable
+  {
   public:
     /**
      * @brief A very simple branch iterator.
@@ -79,23 +79,23 @@ class AbstractTreeLikelihood :
     class SimpleBranchIterator :
       public BranchIterator
     {
-      private:
-        std::vector<int> nodesId_;
-        size_t index_;
-
-      public:
-        SimpleBranchIterator(const std::vector<int>& nodesId) :
-          nodesId_(nodesId), index_(0) {}
-
-      public:
-        int next() throw (Exception)
-        {
-          if (!hasNext())
-            throw Exception("AbstractTreeLikelihood::SimpleBranchIterator::next(). No more branch in the set.");
-          return nodesId_[index_++];
-        }
-
-        bool hasNext() const { return index_ < nodesId_.size(); }
+    private:
+      std::vector<int> nodesId_;
+      size_t index_;
+
+    public:
+      SimpleBranchIterator(const std::vector<int>& nodesId) :
+        nodesId_(nodesId), index_(0) {}
+
+    public:
+      int next() throw (Exception)
+      {
+        if (!hasNext())
+          throw Exception("AbstractTreeLikelihood::SimpleBranchIterator::next(). No more branch in the set.");
+        return nodesId_[index_++];
+      }
+
+      bool hasNext() const { return index_ < nodesId_.size(); }
         
     };
 
@@ -109,24 +109,24 @@ class AbstractTreeLikelihood :
     class SimpleSiteIterator :
       public SiteIterator
     {
-      private:
-        size_t maxIndex_;
-        size_t index_;
-        size_t offset_;
-
-      public:
-        SimpleSiteIterator(size_t nbSites, size_t offset = 0) :
-          maxIndex_(nbSites), index_(0), offset_(offset) {}
-
-      public:
-        size_t next() throw (Exception)
-        {
-          if (!hasNext())
-            throw Exception("AbstractTreeLikelihood::SimpleSiteIterator::next(). No more site in the set.");
-          return offset_ + index_++;
-        }
-
-        bool hasNext() const { return index_ < maxIndex_; }
+    private:
+      size_t maxIndex_;
+      size_t index_;
+      size_t offset_;
+
+    public:
+      SimpleSiteIterator(size_t nbSites, size_t offset = 0) :
+        maxIndex_(nbSites), index_(0), offset_(offset) {}
+
+    public:
+      size_t next() throw (Exception)
+      {
+        if (!hasNext())
+          throw Exception("AbstractTreeLikelihood::SimpleSiteIterator::next(). No more site in the set.");
+        return offset_ + index_++;
+      }
+
+      bool hasNext() const { return index_ < maxIndex_; }
         
     };
    
@@ -138,85 +138,89 @@ class AbstractTreeLikelihood :
     class ConstNoPartitionBranchModelDescription :
       public ConstBranchModelDescription
     {
-      private:
-        const SubstitutionModel* model_;
-        size_t nbSites_;
-
-      public:
-        ConstNoPartitionBranchModelDescription(const SubstitutionModel* model, size_t nbSites) :
-          model_(model), nbSites_(nbSites) {}
-
-        ConstNoPartitionBranchModelDescription(const ConstNoPartitionBranchModelDescription& bmd) :
-          model_(bmd.model_),
-          nbSites_(bmd.nbSites_)
-        {}
-
-        ConstNoPartitionBranchModelDescription& operator=(const ConstNoPartitionBranchModelDescription& bmd)
-        {
-          model_ = bmd.model_;
-          nbSites_ = bmd.nbSites_;
-          return *this;
-        }
-
-      public:
-        const SubstitutionModel* getModel() const { return model_; }
-        
-        SiteIterator* getNewSiteIterator() const { return new SimpleSiteIterator(nbSites_); }
+    private:
+      const TransitionModel* model_;
+      size_t nbSites_;
+
+    public:
+      ConstNoPartitionBranchModelDescription(const TransitionModel* model, size_t nbSites) :
+        model_(model), nbSites_(nbSites) {}
+
+      ConstNoPartitionBranchModelDescription(const ConstNoPartitionBranchModelDescription& bmd) :
+        model_(bmd.model_),
+        nbSites_(bmd.nbSites_)
+      {}
+
+      ConstNoPartitionBranchModelDescription& operator=(const ConstNoPartitionBranchModelDescription& bmd)
+      {
+        model_ = bmd.model_;
+        nbSites_ = bmd.nbSites_;
+        return *this;
+      }
+
+    public:
+      const TransitionModel* getModel() const { return model_; }
+
+      const SubstitutionModel* getSubstitutionModel() const { return dynamic_cast<const SubstitutionModel*>(model_); }
+
+      SiteIterator* getNewSiteIterator() const { return new SimpleSiteIterator(nbSites_); }
     };
 
     class ConstNoPartitionBranchModelIterator :
       public ConstBranchModelIterator
     {
-      private:
-        ConstNoPartitionBranchModelDescription branchModelDescription_;
-        size_t index_;
-
-      public:
-        ConstNoPartitionBranchModelIterator(const SubstitutionModel* model, size_t nbSites) :
-          branchModelDescription_(model, nbSites), index_(0) {}
-
-      public:
-        ConstNoPartitionBranchModelDescription* next() throw (Exception)
-        {
-          if (!hasNext())
-            throw Exception("AbstractHomogeneousTreeLikelihood::ConstHomogeneousBranchModelIterator::next(). No more branch in the set.");
-          index_++;
-          return &branchModelDescription_;
-        }
-
-        bool hasNext() const { return index_ == 0; }
+    private:
+      ConstNoPartitionBranchModelDescription branchModelDescription_;
+      size_t index_;
+
+    public:
+      ConstNoPartitionBranchModelIterator(const TransitionModel* model, size_t nbSites) :
+        branchModelDescription_(model, nbSites), index_(0) {}
+
+    public:
+      ConstNoPartitionBranchModelDescription* next() throw (Exception)
+      {
+        if (!hasNext())
+          throw Exception("AbstractHomogeneousTreeLikelihood::ConstHomogeneousBranchModelIterator::next(). No more branch in the set.");
+        index_++;
+        return &branchModelDescription_;
+      }
+
+      bool hasNext() const { return index_ == 0; }
     };
  
     class ConstNoPartitionSiteModelDescription :
       public ConstSiteModelDescription
     {
-      private:
-        const SubstitutionModel* model_;
-        std::vector<int> nodesId_;
-
-      public:
-        ConstNoPartitionSiteModelDescription(const SubstitutionModel* model, const std::vector<int> nodesId) :
-          model_(model), nodesId_(nodesId) {}
-
-        ConstNoPartitionSiteModelDescription(const ConstNoPartitionSiteModelDescription& smd) :
-          model_(smd.model_),
-          nodesId_(smd.nodesId_)
-        {}
-
-        ConstNoPartitionSiteModelDescription& operator=(const ConstNoPartitionSiteModelDescription& smd)
-        {
-          model_ = smd.model_;
-          nodesId_ = smd.nodesId_;
-          return *this;
-        }
-
-      public:
-        const SubstitutionModel* getModel() const { return model_; }
+    private:
+      const TransitionModel* model_;
+      std::vector<int> nodesId_;
+
+    public:
+      ConstNoPartitionSiteModelDescription(const TransitionModel* model, const std::vector<int> nodesId) :
+        model_(model), nodesId_(nodesId) {}
+
+      ConstNoPartitionSiteModelDescription(const ConstNoPartitionSiteModelDescription& smd) :
+        model_(smd.model_),
+        nodesId_(smd.nodesId_)
+      {}
+
+      ConstNoPartitionSiteModelDescription& operator=(const ConstNoPartitionSiteModelDescription& smd)
+      {
+        model_ = smd.model_;
+        nodesId_ = smd.nodesId_;
+        return *this;
+      }
+
+    public:
+      const TransitionModel* getModel() const { return model_; }
         
-        BranchIterator* getNewBranchIterator() const { return new SimpleBranchIterator(nodesId_); }
+      const SubstitutionModel* getSubstitutionModel() const { return dynamic_cast<const SubstitutionModel*>(model_); }
+
+      BranchIterator* getNewBranchIterator() const { return new SimpleBranchIterator(nodesId_); }
     };
 
-   /** @} */
+    /** @} */
 
 
 
@@ -309,7 +313,7 @@ class AbstractTreeLikelihood :
 //     */
 //    virtual void fireParameterChanged(const ParameterList & params) = 0;
     
-};
+  };
 
 } //end of namespace bpp.
 
diff --git a/src/Bpp/Phyl/Likelihood/ClockTreeLikelihood.h b/src/Bpp/Phyl/Likelihood/ClockTreeLikelihood.h
index 3c16ad4..518b9cc 100644
--- a/src/Bpp/Phyl/Likelihood/ClockTreeLikelihood.h
+++ b/src/Bpp/Phyl/Likelihood/ClockTreeLikelihood.h
@@ -59,9 +59,7 @@ class ClockTreeLikelihood:
   public virtual TreeLikelihood
 {
   public:
-#ifndef NO_VIRTUAL_COV
     ClockTreeLikelihood * clone() const = 0;
-#endif
 
     virtual ~ClockTreeLikelihood() {}
 };
@@ -76,9 +74,7 @@ class DiscreteRatesAcrossSitesClockTreeLikelihood:
   public virtual DiscreteRatesAcrossSitesTreeLikelihood
 {
   public:
-#ifndef NO_VIRTUAL_COV
     DiscreteRatesAcrossSitesClockTreeLikelihood * clone() const = 0;
-#endif
 
     virtual ~DiscreteRatesAcrossSitesClockTreeLikelihood() {}
 
diff --git a/src/Bpp/Phyl/Likelihood/DRASDRTreeLikelihoodData.cpp b/src/Bpp/Phyl/Likelihood/DRASDRTreeLikelihoodData.cpp
index 91bebad..18d9750 100644
--- a/src/Bpp/Phyl/Likelihood/DRASDRTreeLikelihoodData.cpp
+++ b/src/Bpp/Phyl/Likelihood/DRASDRTreeLikelihoodData.cpp
@@ -48,7 +48,7 @@ using namespace bpp;
 
 /******************************************************************************/
 
-void DRASDRTreeLikelihoodData::initLikelihoods(const SiteContainer& sites, const SubstitutionModel& model) throw (Exception)
+void DRASDRTreeLikelihoodData::initLikelihoods(const SiteContainer& sites, const TransitionModel& model) throw (Exception)
 {
   if (sites.getNumberOfSequences() == 1)
     throw Exception("Error, only 1 sequence!");
@@ -101,7 +101,7 @@ void DRASDRTreeLikelihoodData::initLikelihoods(const SiteContainer& sites, const
 
 /******************************************************************************/
 
-void DRASDRTreeLikelihoodData::initLikelihoods(const Node* node, const SiteContainer& sites, const SubstitutionModel& model) throw (Exception)
+void DRASDRTreeLikelihoodData::initLikelihoods(const Node* node, const SiteContainer& sites, const TransitionModel& model) throw (Exception)
 {
   if (node->isLeaf())
   {
@@ -125,6 +125,7 @@ void DRASDRTreeLikelihoodData::initLikelihoods(const Node* node, const SiteConta
       leavesLikelihoods_leaf_i->resize(nbStates_);
       int state = seq->getValue(i);
       double test = 0.;
+
       for (size_t s = 0; s < nbStates_; s++)
       {
         // Leaves likelihood are set to 1 if the char correspond to the site in the sequence,
@@ -133,7 +134,7 @@ void DRASDRTreeLikelihoodData::initLikelihoods(const Node* node, const SiteConta
         test += ( *leavesLikelihoods_leaf_i)[s];
       }
       if (test < 0.000001)
-        std::cerr << "WARNING!!! Likelihood will be 0 for this site." << std::endl;
+        std::cerr << "WARNING!!! Likelihood will be 0 for site " << i << std::endl;
     }
   }
 
diff --git a/src/Bpp/Phyl/Likelihood/DRASDRTreeLikelihoodData.h b/src/Bpp/Phyl/Likelihood/DRASDRTreeLikelihoodData.h
index bb70f22..caeaefa 100644
--- a/src/Bpp/Phyl/Likelihood/DRASDRTreeLikelihoodData.h
+++ b/src/Bpp/Phyl/Likelihood/DRASDRTreeLikelihoodData.h
@@ -84,12 +84,7 @@ class DRASDRTreeLikelihoodLeafData :
       return *this;
     }
 
-#ifndef NO_VIRTUAL_COV
-    DRASDRTreeLikelihoodLeafData*
-#else
-    Clonable*
-#endif
-    clone() const
+    DRASDRTreeLikelihoodLeafData* clone() const
     { 
       return new DRASDRTreeLikelihoodLeafData(*this);
     }
@@ -173,12 +168,7 @@ class DRASDRTreeLikelihoodNodeData :
  
     virtual ~DRASDRTreeLikelihoodNodeData() {}
 
-#ifndef NO_VIRTUAL_COV
-    DRASDRTreeLikelihoodNodeData*
-#else 
-    Clonable*
-#endif
-    clone() const
+    DRASDRTreeLikelihoodNodeData* clone() const
     { 
       return new DRASDRTreeLikelihoodNodeData(*this);
     }
@@ -414,7 +404,7 @@ class DRASDRTreeLikelihoodData :
      * @param model The substitution model to use.
      * @throw Exception if an error occures.
      */
-    void initLikelihoods(const SiteContainer& sites, const SubstitutionModel& model) throw (Exception);
+    void initLikelihoods(const SiteContainer& sites, const TransitionModel& model) throw (Exception);
     
     /**
      * @brief Rebuild likelihood arrays at inner nodes.
@@ -444,7 +434,7 @@ class DRASDRTreeLikelihoodData :
      * @param sites The sequence container to use.
      * @param model The model, used for initializing leaves' likelihoods.
      */
-    void initLikelihoods(const Node* node, const SiteContainer& sites, const SubstitutionModel& model) throw (Exception);
+    void initLikelihoods(const Node* node, const SiteContainer& sites, const TransitionModel& model) throw (Exception);
     
 };
 
diff --git a/src/Bpp/Phyl/Likelihood/DRASRTreeLikelihoodData.cpp b/src/Bpp/Phyl/Likelihood/DRASRTreeLikelihoodData.cpp
index b9ac775..806b7da 100644
--- a/src/Bpp/Phyl/Likelihood/DRASRTreeLikelihoodData.cpp
+++ b/src/Bpp/Phyl/Likelihood/DRASRTreeLikelihoodData.cpp
@@ -48,10 +48,11 @@
 #include <Bpp/Seq/Container/VectorSiteContainer.h>
 
 using namespace bpp;
+using namespace std;
 
 /******************************************************************************/
 
-void DRASRTreeLikelihoodData::initLikelihoods(const SiteContainer& sites, const SubstitutionModel& model)
+void DRASRTreeLikelihoodData::initLikelihoods(const SiteContainer& sites, const TransitionModel& model)
 throw (Exception)
 {
   if (sites.getNumberOfSequences() == 1)
@@ -91,7 +92,7 @@ throw (Exception)
 
 /******************************************************************************/
 
-void DRASRTreeLikelihoodData::initLikelihoods(const Node* node, const SiteContainer& sequences, const SubstitutionModel& model) throw (Exception)
+void DRASRTreeLikelihoodData::initLikelihoods(const Node* node, const SiteContainer& sequences, const TransitionModel& model) throw (Exception)
 {
   // Initialize likelihood vector:
   DRASRTreeLikelihoodNodeData* nodeData = &nodeData_[node->getId()];
@@ -150,16 +151,17 @@ void DRASRTreeLikelihoodData::initLikelihoods(const Node* node, const SiteContai
       {
         Vdouble* _likelihoods_node_i_c = &(*_likelihoods_node_i)[c];
         double test = 0.;
+
         for (size_t s = 0; s < nbStates_; s++)
         {
           // Leaves likelihood are set to 1 if the char correspond to the site in the sequence,
           // otherwise value set to 0:
-          // cout << "i=" << i << "\tc=" << c << "\ts=" << s << endl;
+          
           (*_likelihoods_node_i_c)[s] = model.getInitValue(s, state);
           test += (*_likelihoods_node_i_c)[s];
         }
         if (test < 0.000001)
-          std::cerr << "WARNING!!! Likelihood will be 0 for this site." << std::endl;
+          std::cerr << "WARNING!!! Likelihood will be 0 for site " << i << std::endl;
       }
     }
   }
@@ -188,7 +190,7 @@ void DRASRTreeLikelihoodData::initLikelihoods(const Node* node, const SiteContai
 
 /******************************************************************************/
 
-SitePatterns* DRASRTreeLikelihoodData::initLikelihoodsWithPatterns(const Node* node, const SiteContainer& sequences, const SubstitutionModel& model) throw (Exception)
+SitePatterns* DRASRTreeLikelihoodData::initLikelihoodsWithPatterns(const Node* node, const SiteContainer& sequences, const TransitionModel& model) throw (Exception)
 {
   SiteContainer* tmp = PatternTools::getSequenceSubset(sequences, *node);
   SitePatterns* patterns = new SitePatterns(tmp, true);
@@ -248,6 +250,7 @@ SitePatterns* DRASRTreeLikelihoodData::initLikelihoodsWithPatterns(const Node* n
     {
       VVdouble* _likelihoods_node_i = &(*_likelihoods_node)[i];
       int state = seq->getValue(i);
+      
       for (size_t c = 0; c < nbClasses_; c++)
       {
         Vdouble* _likelihoods_node_i_c = &(*_likelihoods_node_i)[c];
@@ -261,7 +264,7 @@ SitePatterns* DRASRTreeLikelihoodData::initLikelihoodsWithPatterns(const Node* n
           test += (*_likelihoods_node_i_c)[s];
         }
         if (test < 0.000001)
-          std::cerr << "WARNING!!! Likelihood will be 0 for this site." << std::endl;
+          std::cerr << "WARNING!!! Likelihood will be 0 for site " << i << std::endl;
       }
     }
   }
diff --git a/src/Bpp/Phyl/Likelihood/DRASRTreeLikelihoodData.h b/src/Bpp/Phyl/Likelihood/DRASRTreeLikelihoodData.h
index 6c8b154..822de68 100644
--- a/src/Bpp/Phyl/Likelihood/DRASRTreeLikelihoodData.h
+++ b/src/Bpp/Phyl/Likelihood/DRASRTreeLikelihoodData.h
@@ -98,12 +98,7 @@ class DRASRTreeLikelihoodNodeData :
       return *this;
     }
  
-#ifndef NO_VIRTUAL_COV
-    DRASRTreeLikelihoodNodeData*
-#else
-    Clonable*
-#endif
-    clone() const
+    DRASRTreeLikelihoodNodeData* clone() const
     {
       return new DRASRTreeLikelihoodNodeData(*this);
     }
@@ -266,7 +261,7 @@ class DRASRTreeLikelihoodData :
     size_t getNumberOfStates() const { return nbStates_; }
     size_t getNumberOfClasses() const { return nbClasses_; }
     
-    void initLikelihoods(const SiteContainer& sites, const SubstitutionModel& model) throw (Exception);
+    void initLikelihoods(const SiteContainer& sites, const TransitionModel& model) throw (Exception);
 
   protected:
     /**
@@ -283,7 +278,7 @@ class DRASRTreeLikelihoodData :
      * @param sequences The data to be used for initialization.
      * @param model     The model to use.
      */
-    virtual void initLikelihoods(const Node* node, const SiteContainer& sequences, const SubstitutionModel& model) throw (Exception);
+    virtual void initLikelihoods(const Node* node, const SiteContainer& sequences, const TransitionModel& model) throw (Exception);
 
     /**
      * @brief This method initializes the leaves according to a sequence file.
@@ -301,7 +296,7 @@ class DRASRTreeLikelihoodData :
      * @param model     The model to use.
      * @return The shrunk sub-dataset + indices for the subtree defined by <i>node</i>.
      */
-    virtual SitePatterns* initLikelihoodsWithPatterns(const Node* node, const SiteContainer& sequences, const SubstitutionModel& model) throw (Exception);
+    virtual SitePatterns* initLikelihoodsWithPatterns(const Node* node, const SiteContainer& sequences, const TransitionModel& model) throw (Exception);
   
 };
 
diff --git a/src/Bpp/Phyl/Likelihood/DRHomogeneousMixedTreeLikelihood.cpp b/src/Bpp/Phyl/Likelihood/DRHomogeneousMixedTreeLikelihood.cpp
index 2d80c65..f53ccd4 100644
--- a/src/Bpp/Phyl/Likelihood/DRHomogeneousMixedTreeLikelihood.cpp
+++ b/src/Bpp/Phyl/Likelihood/DRHomogeneousMixedTreeLikelihood.cpp
@@ -53,7 +53,7 @@ using namespace std;
 
 DRHomogeneousMixedTreeLikelihood::DRHomogeneousMixedTreeLikelihood(
   const Tree& tree,
-  SubstitutionModel* model,
+  TransitionModel* model,
   DiscreteDistribution* rDist,
   bool checkRooted,
   bool verbose,
@@ -80,7 +80,7 @@ DRHomogeneousMixedTreeLikelihood::DRHomogeneousMixedTreeLikelihood(
 DRHomogeneousMixedTreeLikelihood::DRHomogeneousMixedTreeLikelihood(
   const Tree& tree,
   const SiteContainer& data,
-  SubstitutionModel* model,
+  TransitionModel* model,
   DiscreteDistribution* rDist,
   bool checkRooted,
   bool verbose,
@@ -178,7 +178,7 @@ void DRHomogeneousMixedTreeLikelihood::fireParameterChanged(const ParameterList&
 
   size_t s = mixedmodel->getNumberOfModels();
 
-  const SubstitutionModel* pm;
+  const TransitionModel* pm;
   for (size_t i = 0; i < s; i++)
   {
     ParameterList pl;
diff --git a/src/Bpp/Phyl/Likelihood/DRHomogeneousMixedTreeLikelihood.h b/src/Bpp/Phyl/Likelihood/DRHomogeneousMixedTreeLikelihood.h
index 64ba1c7..2ec3da8 100644
--- a/src/Bpp/Phyl/Likelihood/DRHomogeneousMixedTreeLikelihood.h
+++ b/src/Bpp/Phyl/Likelihood/DRHomogeneousMixedTreeLikelihood.h
@@ -90,7 +90,7 @@ public:
    */
   DRHomogeneousMixedTreeLikelihood(
     const Tree& tree,
-    SubstitutionModel* model,
+    TransitionModel* model,
     DiscreteDistribution* rDist,
     bool checkRooted = true,
     bool verbose = true,
@@ -116,7 +116,7 @@ public:
   DRHomogeneousMixedTreeLikelihood(
     const Tree& tree,
     const SiteContainer& data,
-    SubstitutionModel* model,
+    TransitionModel* model,
     DiscreteDistribution* rDist,
     bool checkRooted = true,
     bool verbose = true,
diff --git a/src/Bpp/Phyl/Likelihood/DRHomogeneousTreeLikelihood.cpp b/src/Bpp/Phyl/Likelihood/DRHomogeneousTreeLikelihood.cpp
index 97bd4a9..a59f922 100644
--- a/src/Bpp/Phyl/Likelihood/DRHomogeneousTreeLikelihood.cpp
+++ b/src/Bpp/Phyl/Likelihood/DRHomogeneousTreeLikelihood.cpp
@@ -59,7 +59,7 @@ using namespace std;
 
 DRHomogeneousTreeLikelihood::DRHomogeneousTreeLikelihood(
   const Tree& tree,
-  SubstitutionModel* model,
+  TransitionModel* model,
   DiscreteDistribution* rDist,
   bool checkRooted,
   bool verbose)
@@ -76,7 +76,7 @@ throw (Exception) :
 DRHomogeneousTreeLikelihood::DRHomogeneousTreeLikelihood(
   const Tree& tree,
   const SiteContainer& data,
-  SubstitutionModel* model,
+  TransitionModel* model,
   DiscreteDistribution* rDist,
   bool checkRooted,
   bool verbose)
diff --git a/src/Bpp/Phyl/Likelihood/DRHomogeneousTreeLikelihood.h b/src/Bpp/Phyl/Likelihood/DRHomogeneousTreeLikelihood.h
index cd5e147..1538a53 100755
--- a/src/Bpp/Phyl/Likelihood/DRHomogeneousTreeLikelihood.h
+++ b/src/Bpp/Phyl/Likelihood/DRHomogeneousTreeLikelihood.h
@@ -88,7 +88,7 @@ class DRHomogeneousTreeLikelihood:
      */
     DRHomogeneousTreeLikelihood(
       const Tree& tree,
-      SubstitutionModel* model,
+      TransitionModel* model,
       DiscreteDistribution* rDist,
       bool checkRooted = true,
       bool verbose = true)
@@ -111,7 +111,7 @@ class DRHomogeneousTreeLikelihood:
     DRHomogeneousTreeLikelihood(
       const Tree& tree,
       const SiteContainer& data,
-      SubstitutionModel* model,
+      TransitionModel* model,
       DiscreteDistribution* rDist,
       bool checkRooted = true,
       bool verbose = true)
diff --git a/src/Bpp/Phyl/Likelihood/DRTreeLikelihood.h b/src/Bpp/Phyl/Likelihood/DRTreeLikelihood.h
index 0b9eac8..dff0829 100644
--- a/src/Bpp/Phyl/Likelihood/DRTreeLikelihood.h
+++ b/src/Bpp/Phyl/Likelihood/DRTreeLikelihood.h
@@ -77,9 +77,7 @@ class DRTreeLikelihood:
     DRTreeLikelihood() {}
     virtual ~DRTreeLikelihood() {}
 
-#ifndef NO_VIRTUAL_COV
     DRTreeLikelihood* clone() const = 0;
-#endif
 
   public:
   
diff --git a/src/Bpp/Phyl/Likelihood/DRTreeLikelihoodTools.cpp b/src/Bpp/Phyl/Likelihood/DRTreeLikelihoodTools.cpp
index db7a910..d65cbf7 100755
--- a/src/Bpp/Phyl/Likelihood/DRTreeLikelihoodTools.cpp
+++ b/src/Bpp/Phyl/Likelihood/DRTreeLikelihoodTools.cpp
@@ -55,22 +55,24 @@ VVVdouble DRTreeLikelihoodTools::getPosteriorProbabilitiesForEachStateForEachRat
   
   const DiscreteDistribution* rDist = drl.getRateDistribution();
   Vdouble rcProbs = rDist->getProbabilities();
-  if(drl.getTree().isLeaf(nodeId))
+  if (drl.getTree().isLeaf(nodeId))
   {
     VVdouble larray = drl.getLikelihoodData()->getLeafLikelihoods(nodeId);
-    for(size_t i = 0; i < nSites; i++)
+    for (size_t i = 0; i < nSites; i++)
     {
       VVdouble * postProb_i = & postProb[i];
       postProb_i->resize(nClasses);
       Vdouble * larray_i = & larray[i];
-      for(size_t c = 0; c < nClasses; c++)
+      //In case of generic character:
+      double sumprobs = VectorTools::sum(*larray_i);
+      for (size_t c = 0; c < nClasses; c++)
       {
         Vdouble * postProb_i_c = & (* postProb_i)[c];
         postProb_i_c->resize(nStates);
         double * rcProb = & rcProbs[c];
-        for(size_t x = 0; x < nStates; x++)
+        for (size_t x = 0; x < nStates; x++)
         {
-          (* postProb_i_c)[x] = (* larray_i)[x] * (* rcProb);
+          (* postProb_i_c)[x] = (* larray_i)[x] * (* rcProb) / sumprobs;
         }
       }
     }
diff --git a/src/Bpp/Phyl/Likelihood/HomogeneousTreeLikelihood.h b/src/Bpp/Phyl/Likelihood/HomogeneousTreeLikelihood.h
index 8dab14b..6c52fd3 100755
--- a/src/Bpp/Phyl/Likelihood/HomogeneousTreeLikelihood.h
+++ b/src/Bpp/Phyl/Likelihood/HomogeneousTreeLikelihood.h
@@ -59,17 +59,16 @@ class HomogeneousTreeLikelihood :
 	public virtual TreeLikelihood
 {
 	public:
-#ifndef NO_VIRTUAL_COV
+
     HomogeneousTreeLikelihood* clone() const = 0;
-#endif
 
   public:
-    const SubstitutionModel* getSubstitutionModel(int nodeId, size_t siteIndex) const throw (NodeNotFoundException)
+    const TransitionModel* getSubstitutionModel(int nodeId, size_t siteIndex) const throw (NodeNotFoundException)
     {
       return getSubstitutionModel();
     }
 
-    SubstitutionModel* getSubstitutionModel(int nodeId, size_t siteIndex) throw (NodeNotFoundException)
+    TransitionModel* getSubstitutionModel(int nodeId, size_t siteIndex) throw (NodeNotFoundException)
     {
       return getSubstitutionModel();
     }
@@ -77,18 +76,18 @@ class HomogeneousTreeLikelihood :
     /**
      * @return The substitution model attached to this instance.
      */
-    virtual const SubstitutionModel* getSubstitutionModel() const = 0;
+    virtual const TransitionModel* getSubstitutionModel() const = 0;
     
     /**
      * @return The substitution model attached to this instance.
      */
-    virtual SubstitutionModel* getSubstitutionModel() = 0;
+    virtual TransitionModel* getSubstitutionModel() = 0;
 
     /**
      * @return Set the substitution model for this instance.
      * @throw Exception If the model could not be set (for instance, because of a wrong alphabet type).
      */
-    virtual void setSubstitutionModel(SubstitutionModel* model) throw (Exception) = 0;
+    virtual void setSubstitutionModel(TransitionModel* model) throw (Exception) = 0;
     
 };
 
diff --git a/src/Bpp/Phyl/Likelihood/MarginalAncestralStateReconstruction.cpp b/src/Bpp/Phyl/Likelihood/MarginalAncestralStateReconstruction.cpp
index 0093a18..8911b30 100644
--- a/src/Bpp/Phyl/Likelihood/MarginalAncestralStateReconstruction.cpp
+++ b/src/Bpp/Phyl/Likelihood/MarginalAncestralStateReconstruction.cpp
@@ -115,7 +115,7 @@ Sequence* MarginalAncestralStateReconstruction::getAncestralSequenceForNode(int
 {
   string name = tree_.hasNodeName(nodeId) ? tree_.getNodeName(nodeId) : ("" + TextTools::toString(nodeId));
   const vector<size_t>* rootPatternLinks = &likelihood_->getLikelihoodData()->getRootArrayPositions();
-  const SubstitutionModel* model = likelihood_->getSubstitutionModel(tree_.getNodesId()[0], 0); // We assume all nodes have a model with the same number of states.
+  const TransitionModel* model = likelihood_->getSubstitutionModel(tree_.getNodesId()[0], 0); // We assume all nodes have a model with the same number of states.
   vector<size_t> states;
   vector<int> allStates(nbSites_);
   VVdouble patternedProbs;
@@ -147,16 +147,16 @@ void MarginalAncestralStateReconstruction::recursiveMarginalAncestralStates(
 {
   if (node->isLeaf())
   {
-    vector<int> content = data.getContent(node->getName());
+    const Sequence& seq = data.getSequence(node->getName());
     vector<size_t>* v = &ancestors[node->getId()];
-    v->resize(content.size());
+    v->resize(seq.size());
     // This is a tricky way to store the real sequence as an ancestral one...
     // In case of Markov Modulated models, we consider that the real sequences
     // Are all in the first category.
-    const SubstitutionModel* model = likelihood_->getSubstitutionModel(tree_.getNodesId()[0], 0); // We assume all nodes have a model with the same number of states.
-    for (size_t i = 0; i < content.size(); i++)
+    const TransitionModel* model = likelihood_->getSubstitutionModel(tree_.getNodesId()[0], 0); // We assume all nodes have a model with the same number of states.
+    for (size_t i = 0; i < seq.size(); i++)
     {
-      (*v)[i] = model->getModelStates(content[i])[0];
+      (*v)[i] = model->getModelStates(seq[i])[0];
     }
   }
   else
diff --git a/src/Bpp/Phyl/Likelihood/MarginalAncestralStateReconstruction.h b/src/Bpp/Phyl/Likelihood/MarginalAncestralStateReconstruction.h
index 7c3a7ad..fc78b66 100755
--- a/src/Bpp/Phyl/Likelihood/MarginalAncestralStateReconstruction.h
+++ b/src/Bpp/Phyl/Likelihood/MarginalAncestralStateReconstruction.h
@@ -117,13 +117,7 @@ class MarginalAncestralStateReconstruction:
       return *this;
     }
 
-
-#ifndef NO_VIRTUAL_COV
-    MarginalAncestralStateReconstruction*
-#else
-    Clonable*
-#endif
-    clone() const { return new MarginalAncestralStateReconstruction(*this); }
+    MarginalAncestralStateReconstruction* clone() const { return new MarginalAncestralStateReconstruction(*this); }
 
 		virtual ~MarginalAncestralStateReconstruction() {}
 
@@ -177,12 +171,7 @@ class MarginalAncestralStateReconstruction:
       return getAncestralSequences(false);
     }
 
-#ifndef NO_VIRTUAL_COV
-    AlignedSequenceContainer *
-#else
-    SequenceContainer *
-#endif
-    getAncestralSequences(bool sample) const;
+    AlignedSequenceContainer * getAncestralSequences(bool sample) const;
 	
   private:
 		void recursiveMarginalAncestralStates(
diff --git a/src/Bpp/Phyl/Likelihood/NNIHomogeneousTreeLikelihood.cpp b/src/Bpp/Phyl/Likelihood/NNIHomogeneousTreeLikelihood.cpp
index 3908903..9b65c45 100644
--- a/src/Bpp/Phyl/Likelihood/NNIHomogeneousTreeLikelihood.cpp
+++ b/src/Bpp/Phyl/Likelihood/NNIHomogeneousTreeLikelihood.cpp
@@ -51,7 +51,7 @@ using namespace bpp;
 using namespace std;
 
 /*******************************************************************************/
-void BranchLikelihood::initModel(const SubstitutionModel* model, const DiscreteDistribution* rDist)
+void BranchLikelihood::initModel(const TransitionModel* model, const DiscreteDistribution* rDist)
 {
   model_ = model;
   rDist_ = rDist;
@@ -123,7 +123,7 @@ void BranchLikelihood::computeLogLikelihood()
 
 NNIHomogeneousTreeLikelihood::NNIHomogeneousTreeLikelihood(
   const Tree& tree,
-  SubstitutionModel* model,
+  TransitionModel* model,
   DiscreteDistribution* rDist,
   bool checkRooted,
   bool verbose)
@@ -146,7 +146,7 @@ throw (Exception) :
 NNIHomogeneousTreeLikelihood::NNIHomogeneousTreeLikelihood(
   const Tree& tree,
   const SiteContainer& data,
-  SubstitutionModel* model,
+  TransitionModel* model,
   DiscreteDistribution* rDist,
   bool checkRooted,
   bool verbose)
diff --git a/src/Bpp/Phyl/Likelihood/NNIHomogeneousTreeLikelihood.h b/src/Bpp/Phyl/Likelihood/NNIHomogeneousTreeLikelihood.h
index 8696147..2d41de0 100644
--- a/src/Bpp/Phyl/Likelihood/NNIHomogeneousTreeLikelihood.h
+++ b/src/Bpp/Phyl/Likelihood/NNIHomogeneousTreeLikelihood.h
@@ -65,7 +65,7 @@ class BranchLikelihood :
 {
 protected:
   const VVVdouble* array1_, * array2_;
-  const SubstitutionModel* model_;
+  const TransitionModel* model_;
   const DiscreteDistribution* rDist_;
   size_t nbStates_, nbClasses_;
   VVVdouble pxy_;
@@ -121,7 +121,7 @@ public:
   BranchLikelihood* clone() const { return new BranchLikelihood(*this); }
 
 public:
-  void initModel(const SubstitutionModel* model, const DiscreteDistribution* rDist);
+  void initModel(const TransitionModel* model, const DiscreteDistribution* rDist);
 
   /**
    * @warning No checking on alphabet size or number of rate classes is performed,
@@ -194,7 +194,7 @@ public:
    */
   NNIHomogeneousTreeLikelihood(
     const Tree& tree,
-    SubstitutionModel* model,
+    TransitionModel* model,
     DiscreteDistribution* rDist,
     bool checkRooted = true,
     bool verbose = true)
@@ -215,7 +215,7 @@ public:
   NNIHomogeneousTreeLikelihood(
     const Tree& tree,
     const SiteContainer& data,
-    SubstitutionModel* model,
+    TransitionModel* model,
     DiscreteDistribution* rDist,
     bool checkRooted = true,
     bool verbose = true)
@@ -230,12 +230,7 @@ public:
 
   virtual ~NNIHomogeneousTreeLikelihood();
 
-#ifndef NO_VIRTUAL_COV
-  NNIHomogeneousTreeLikelihood*
-#else
-  Clonable*
-#endif
-  clone() const { return new NNIHomogeneousTreeLikelihood(*this); }
+  NNIHomogeneousTreeLikelihood* clone() const { return new NNIHomogeneousTreeLikelihood(*this); }
 
 public:
   void setData(const SiteContainer& sites) throw (Exception)
diff --git a/src/Bpp/Phyl/Likelihood/NonHomogeneousTreeLikelihood.h b/src/Bpp/Phyl/Likelihood/NonHomogeneousTreeLikelihood.h
index 8afc6de..83833f7 100755
--- a/src/Bpp/Phyl/Likelihood/NonHomogeneousTreeLikelihood.h
+++ b/src/Bpp/Phyl/Likelihood/NonHomogeneousTreeLikelihood.h
@@ -61,17 +61,16 @@ class NonHomogeneousTreeLikelihood :
 	public virtual TreeLikelihood
 {
 	public:
-#ifndef NO_VIRTUAL_COV
+
     NonHomogeneousTreeLikelihood* clone() const = 0;
-#endif
 
   public:
-    const SubstitutionModel* getSubstitutionModel(int nodeId, size_t siteIndex) const throw (NodeNotFoundException)
+    const TransitionModel* getSubstitutionModel(int nodeId, size_t siteIndex) const throw (NodeNotFoundException)
     {
       return getSubstitutionModelForNode(nodeId);
     }
 
-    SubstitutionModel* getSubstitutionModel(int nodeId, size_t siteIndex) throw (NodeNotFoundException)
+    TransitionModel* getSubstitutionModel(int nodeId, size_t siteIndex) throw (NodeNotFoundException)
     {
       return getSubstitutionModelForNode(nodeId);
     }
@@ -83,7 +82,7 @@ class NonHomogeneousTreeLikelihood :
      * @return A pointer toward the corresponding model.
      * @throw NodeNotFoundException This exception may be thrown if the node is not found (depending on the implementation).
      */
-    virtual const SubstitutionModel* getSubstitutionModelForNode(int nodeId) const throw (NodeNotFoundException) = 0;
+    virtual const TransitionModel* getSubstitutionModelForNode(int nodeId) const throw (NodeNotFoundException) = 0;
 
     /**
      * @brief Get the substitution model associated to a given node.
@@ -92,7 +91,7 @@ class NonHomogeneousTreeLikelihood :
      * @return A pointer toward the corresponding model.
      * @throw NodeNotFoundException This exception may be thrown if the node is not found (depending on the implementation).
      */
-    virtual SubstitutionModel* getSubstitutionModelForNode(int nodeId) throw (NodeNotFoundException) = 0;
+    virtual TransitionModel* getSubstitutionModelForNode(int nodeId) throw (NodeNotFoundException) = 0;
 
     /**
      * @return The set of substitution models associated to this instance.
diff --git a/src/Bpp/Phyl/Likelihood/RHomogeneousClockTreeLikelihood.cpp b/src/Bpp/Phyl/Likelihood/RHomogeneousClockTreeLikelihood.cpp
index a82f034..dcea43c 100644
--- a/src/Bpp/Phyl/Likelihood/RHomogeneousClockTreeLikelihood.cpp
+++ b/src/Bpp/Phyl/Likelihood/RHomogeneousClockTreeLikelihood.cpp
@@ -53,7 +53,7 @@ using namespace bpp;
 
 RHomogeneousClockTreeLikelihood::RHomogeneousClockTreeLikelihood(
   const Tree & tree,
-  SubstitutionModel * model,
+  TransitionModel * model,
   DiscreteDistribution * rDist,
   bool checkRooted,
   bool verbose)
@@ -68,7 +68,7 @@ throw (Exception):
 RHomogeneousClockTreeLikelihood::RHomogeneousClockTreeLikelihood(
   const Tree & tree,
   const SiteContainer & data,
-  SubstitutionModel * model,
+  TransitionModel * model,
   DiscreteDistribution * rDist,
   bool checkRooted,
   bool verbose)
@@ -118,7 +118,7 @@ void RHomogeneousClockTreeLikelihood::fireParameterChanged(const ParameterList&
 
 /******************************************************************************/
 
-void RHomogeneousClockTreeLikelihood::initBranchLengthsParameters()
+void RHomogeneousClockTreeLikelihood::initBranchLengthsParameters(bool verbose)
 {
   //Check branch lengths first:
   for(unsigned int i = 0; i < nbNodes_; i++)
@@ -126,7 +126,8 @@ void RHomogeneousClockTreeLikelihood::initBranchLengthsParameters()
     double d = minimumBrLen_;
     if(!nodes_[i]->hasDistanceToFather())
     {
-      ApplicationTools::displayWarning("Missing branch length " + TextTools::toString(i) + ". Value is set to " + TextTools::toString(minimumBrLen_));
+      if (verbose)
+        ApplicationTools::displayWarning("Missing branch length " + TextTools::toString(i) + ". Value is set to " + TextTools::toString(minimumBrLen_));
       nodes_[i]->setDistanceToFather(minimumBrLen_);
     }
     else
@@ -134,7 +135,8 @@ void RHomogeneousClockTreeLikelihood::initBranchLengthsParameters()
       d = nodes_[i]->getDistanceToFather();
       if (d < minimumBrLen_)
       {
-        ApplicationTools::displayWarning("Branch length " + TextTools::toString(i) + " is too small: " + TextTools::toString(d) + ". Value is set to " + TextTools::toString(minimumBrLen_));
+        if (verbose)
+          ApplicationTools::displayWarning("Branch length " + TextTools::toString(i) + " is too small: " + TextTools::toString(d) + ". Value is set to " + TextTools::toString(minimumBrLen_));
         nodes_[i]->setDistanceToFather(minimumBrLen_);
       }
     }
diff --git a/src/Bpp/Phyl/Likelihood/RHomogeneousClockTreeLikelihood.h b/src/Bpp/Phyl/Likelihood/RHomogeneousClockTreeLikelihood.h
index 35e9e6a..6f06370 100644
--- a/src/Bpp/Phyl/Likelihood/RHomogeneousClockTreeLikelihood.h
+++ b/src/Bpp/Phyl/Likelihood/RHomogeneousClockTreeLikelihood.h
@@ -87,7 +87,7 @@ class RHomogeneousClockTreeLikelihood:
      */
     RHomogeneousClockTreeLikelihood(
       const Tree& tree,
-      SubstitutionModel* model,
+      TransitionModel* model,
       DiscreteDistribution* rDist,
       bool checkRooted = true,
       bool verbose = true)
@@ -112,7 +112,7 @@ class RHomogeneousClockTreeLikelihood:
     RHomogeneousClockTreeLikelihood(
       const Tree& tree,
       const SiteContainer& data,
-      SubstitutionModel* model,
+      TransitionModel* model,
       DiscreteDistribution* rDist,
       bool checkRooted = true,
       bool verbose = true)
@@ -138,7 +138,7 @@ class RHomogeneousClockTreeLikelihood:
      */
     void applyParameters() throw (Exception);
     void fireParameterChanged(const ParameterList& params);
-    void initBranchLengthsParameters();
+    void initBranchLengthsParameters(bool verbose = true);
     ParameterList getDerivableParameters() const throw (Exception);
     ParameterList getNonDerivableParameters() const throw (Exception);
     double getFirstOrderDerivative(const std::string& variable) const throw (Exception);
diff --git a/src/Bpp/Phyl/Likelihood/RHomogeneousMixedTreeLikelihood.cpp b/src/Bpp/Phyl/Likelihood/RHomogeneousMixedTreeLikelihood.cpp
index 2b42807..d708021 100644
--- a/src/Bpp/Phyl/Likelihood/RHomogeneousMixedTreeLikelihood.cpp
+++ b/src/Bpp/Phyl/Likelihood/RHomogeneousMixedTreeLikelihood.cpp
@@ -53,7 +53,7 @@ using namespace std;
 
 RHomogeneousMixedTreeLikelihood::RHomogeneousMixedTreeLikelihood(
   const Tree& tree,
-  SubstitutionModel* model,
+  TransitionModel* model,
   DiscreteDistribution* rDist,
   bool checkRooted,
   bool verbose,
@@ -77,7 +77,7 @@ RHomogeneousMixedTreeLikelihood::RHomogeneousMixedTreeLikelihood(
 RHomogeneousMixedTreeLikelihood::RHomogeneousMixedTreeLikelihood(
   const Tree& tree,
   const SiteContainer& data,
-  SubstitutionModel* model,
+  TransitionModel* model,
   DiscreteDistribution* rDist,
   bool checkRooted,
   bool verbose,
@@ -169,7 +169,7 @@ void RHomogeneousMixedTreeLikelihood::fireParameterChanged(const ParameterList&
   MixedSubstitutionModel* mixedmodel = dynamic_cast<MixedSubstitutionModel*>(model_);
   size_t s = mixedmodel->getNumberOfModels();
 
-  const SubstitutionModel* pm;
+  const TransitionModel* pm;
   for (size_t i = 0; i < s; i++)
   {
     ParameterList pl;
diff --git a/src/Bpp/Phyl/Likelihood/RHomogeneousMixedTreeLikelihood.h b/src/Bpp/Phyl/Likelihood/RHomogeneousMixedTreeLikelihood.h
index 185345a..be71c4a 100644
--- a/src/Bpp/Phyl/Likelihood/RHomogeneousMixedTreeLikelihood.h
+++ b/src/Bpp/Phyl/Likelihood/RHomogeneousMixedTreeLikelihood.h
@@ -84,7 +84,7 @@ public:
    */
   RHomogeneousMixedTreeLikelihood(
     const Tree& tree,
-    SubstitutionModel* model,
+    TransitionModel* model,
     DiscreteDistribution* rDist,
     bool checkRooted = true,
     bool verbose = true,
@@ -109,7 +109,7 @@ public:
   RHomogeneousMixedTreeLikelihood(
     const Tree& tree,
     const SiteContainer& data,
-    SubstitutionModel* model,
+    TransitionModel* model,
     DiscreteDistribution* rDist,
     bool checkRooted = true,
     bool verbose = true,
@@ -194,16 +194,6 @@ protected:
    */
   virtual void displayLikelihood(const Node* node);
 
-  virtual void setMinimumBranchLength(double brlen) throw (Exception) {
-    RHomogeneousMixedTreeLikelihood::setMinimumBranchLength(brlen);
-    for (size_t i = 0; i < treeLikelihoodsContainer_.size(); ++i)
-      treeLikelihoodsContainer_[i]->setMinimumBranchLength(brlen);
-  }
-  virtual void setMaximumBranchLength(double brlen) throw (Exception) {
-    RHomogeneousMixedTreeLikelihood::setMaximumBranchLength(brlen);
-    for (size_t i = 0; i < treeLikelihoodsContainer_.size(); ++i)
-      treeLikelihoodsContainer_[i]->setMaximumBranchLength(brlen);
-  }
 };
 } // end of namespace bpp.
 
diff --git a/src/Bpp/Phyl/Likelihood/RHomogeneousTreeLikelihood.cpp b/src/Bpp/Phyl/Likelihood/RHomogeneousTreeLikelihood.cpp
index f3422f1..2742377 100644
--- a/src/Bpp/Phyl/Likelihood/RHomogeneousTreeLikelihood.cpp
+++ b/src/Bpp/Phyl/Likelihood/RHomogeneousTreeLikelihood.cpp
@@ -54,7 +54,7 @@ using namespace std;
 
 RHomogeneousTreeLikelihood::RHomogeneousTreeLikelihood(
   const Tree& tree,
-  SubstitutionModel* model,
+  TransitionModel* model,
   DiscreteDistribution* rDist,
   bool checkRooted,
   bool verbose,
@@ -72,7 +72,7 @@ throw (Exception) :
 RHomogeneousTreeLikelihood::RHomogeneousTreeLikelihood(
   const Tree& tree,
   const SiteContainer& data,
-  SubstitutionModel* model,
+  TransitionModel* model,
   DiscreteDistribution* rDist,
   bool checkRooted,
   bool verbose,
@@ -859,9 +859,8 @@ void RHomogeneousTreeLikelihood::computeSubtreeLikelihood(const Node* node)
           Vdouble* pxy__son_c_x = &(*pxy__son_c)[x];
           double likelihood = 0;
           for (size_t y = 0; y < nbStates_; y++)
-          {
             likelihood += (*pxy__son_c_x)[y] * (*_likelihoods_son_i_c)[y];
-          }
+          
           (*_likelihoods_node_i_c)[x] *= likelihood;
         }
       }
diff --git a/src/Bpp/Phyl/Likelihood/RHomogeneousTreeLikelihood.h b/src/Bpp/Phyl/Likelihood/RHomogeneousTreeLikelihood.h
index c9f7e07..a5ae9a1 100644
--- a/src/Bpp/Phyl/Likelihood/RHomogeneousTreeLikelihood.h
+++ b/src/Bpp/Phyl/Likelihood/RHomogeneousTreeLikelihood.h
@@ -107,7 +107,7 @@ namespace bpp
      */
     RHomogeneousTreeLikelihood(
                                const Tree& tree,
-                               SubstitutionModel* model,
+                               TransitionModel* model,
                                DiscreteDistribution* rDist,
                                bool checkRooted = true,
                                bool verbose = true,
@@ -132,7 +132,7 @@ namespace bpp
     RHomogeneousTreeLikelihood(
                                const Tree& tree,
                                const SiteContainer& data,
-                               SubstitutionModel* model,
+                               TransitionModel* model,
                                DiscreteDistribution* rDist,
                                bool checkRooted = true,
                                bool verbose = true,
diff --git a/src/Bpp/Phyl/Likelihood/RNonHomogeneousMixedTreeLikelihood.cpp b/src/Bpp/Phyl/Likelihood/RNonHomogeneousMixedTreeLikelihood.cpp
index d727d92..b9a4515 100644
--- a/src/Bpp/Phyl/Likelihood/RNonHomogeneousMixedTreeLikelihood.cpp
+++ b/src/Bpp/Phyl/Likelihood/RNonHomogeneousMixedTreeLikelihood.cpp
@@ -316,8 +316,8 @@ RNonHomogeneousMixedTreeLikelihood::~RNonHomogeneousMixedTreeLikelihood()
   if (main_)
     initParameters();
   else {
-    initBranchLengthsParameters();
-    addParameters_(brLenParameters_);
+    initBranchLengthsParameters(false);
+    includeParameters_(brLenParameters_);
   }
 
   map<int, vector<RNonHomogeneousMixedTreeLikelihood*> >::iterator it;
@@ -720,10 +720,10 @@ void RNonHomogeneousMixedTreeLikelihood::computeDownSubtreeD2Likelihood(const No
 
 void RNonHomogeneousMixedTreeLikelihood::computeTransitionProbabilitiesForNode(const Node* node)
 {
-  const SubstitutionModel* model = modelSet_->getModelForNode(node->getId());
+  const TransitionModel* model = modelSet_->getModelForNode(node->getId());
   size_t modelnum = modelSet_->getModelIndexForNode(node->getId());
 
-  vector<const SubstitutionModel*> vModel;
+  vector<const TransitionModel*> vModel;
   vector<double> vProba;
   
   const MixedSubstitutionModelSet::HyperNode::Node& nd = hyperNode_.getNode(modelnum);
diff --git a/src/Bpp/Phyl/Likelihood/SitePartitionTreeLikelihood.h b/src/Bpp/Phyl/Likelihood/SitePartitionTreeLikelihood.h
index 81dc253..ce85a32 100644
--- a/src/Bpp/Phyl/Likelihood/SitePartitionTreeLikelihood.h
+++ b/src/Bpp/Phyl/Likelihood/SitePartitionTreeLikelihood.h
@@ -57,17 +57,16 @@ class SitePartitionHomogeneousTreeLikelihood :
   public virtual TreeLikelihood
 {
   public:
-#ifndef NO_VIRTUAL_COV
+
     SitePartitionHomogeneousTreeLikelihood* clone() const = 0;
-#endif
 
   public:
-    const SubstitutionModel* getSubstitutionModel(int nodeId, size_t siteIndex) const throw (NodeNotFoundException)
+    const TransitionModel* getSubstitutionModel(int nodeId, size_t siteIndex) const throw (NodeNotFoundException)
     {
       return getSubstitutionModelForSite(siteIndex);
     }
 
-    SubstitutionModel* getSubstitutionModel(int nodeId, size_t siteIndex) throw (NodeNotFoundException)
+    TransitionModel* getSubstitutionModel(int nodeId, size_t siteIndex) throw (NodeNotFoundException)
     {
       return getSubstitutionModelForSite(siteIndex);
     }
@@ -78,7 +77,7 @@ class SitePartitionHomogeneousTreeLikelihood :
      * @param siteIndex The position in the alignment.
      * @return A pointer toward the corresponding model.
      */
-    virtual const SubstitutionModel* getSubstitutionModelForSite(size_t siteIndex) const = 0;
+    virtual const TransitionModel* getSubstitutionModelForSite(size_t siteIndex) const = 0;
 
     /**
      * @brief Get the substitution model associated to a given node.
@@ -86,7 +85,7 @@ class SitePartitionHomogeneousTreeLikelihood :
      * @param siteIndex The position in the alignment.
      * @return A pointer toward the corresponding model.
      */
-    virtual SubstitutionModel* getSubstitutionModelForSite(size_t siteIndex) = 0;
+    virtual TransitionModel* getSubstitutionModelForSite(size_t siteIndex) = 0;
 
 };
 
diff --git a/src/Bpp/Phyl/Likelihood/TreeLikelihood.h b/src/Bpp/Phyl/Likelihood/TreeLikelihood.h
index 7fb8f53..dd47c84 100755
--- a/src/Bpp/Phyl/Likelihood/TreeLikelihood.h
+++ b/src/Bpp/Phyl/Likelihood/TreeLikelihood.h
@@ -5,36 +5,36 @@
 //
 
 /*
-Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
-
-This software is a computer program whose purpose is to provide classes
-for phylogenetic data analysis.
-
-This software is governed by the CeCILL  license under French law and
-abiding by the rules of distribution of free software.  You can  use, 
-modify and/ or redistribute the software under the terms of the CeCILL
-license as circulated by CEA, CNRS and INRIA at the following URL
-"http://www.cecill.info". 
-
-As a counterpart to the access to the source code and  rights to copy,
-modify and redistribute granted by the license, users are provided only
-with a limited warranty  and the software's author,  the holder of the
-economic rights,  and the successive licensors  have only  limited
-liability. 
-
-In this respect, the user's attention is drawn to the risks associated
-with loading,  using,  modifying and/or developing or reproducing the
-software by the user in light of its specific status of free software,
-that may mean  that it is complicated to manipulate,  and  that  also
-therefore means  that it is reserved for developers  and  experienced
-professionals having in-depth computer knowledge. Users are therefore
-encouraged to load and test the software's suitability as regards their
-requirements in conditions enabling the security of their systems and/or 
-data to be ensured and,  more generally, to use and operate it in the 
-same conditions as regards security. 
-
-The fact that you are presently reading this means that you have had
-knowledge of the CeCILL license and that you accept its terms.
+  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
+
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use, 
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info". 
+
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability. 
+
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or 
+  data to be ensured and,  more generally, to use and operate it in the 
+  same conditions as regards security. 
+
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
 */
 
 #ifndef _TREELIKELIHOOD_H_
@@ -63,27 +63,27 @@ namespace bpp
  * This interface defines the methods needed for computing the likelihood
  * of a phylogenetic tree, given a dataset.
  */ 
-class TreeLikelihood:
-  public virtual DerivableSecondOrder
-{
+  class TreeLikelihood:
+    public virtual DerivableSecondOrder
+  {
   public:
     /**
      * @brief An iterator over a set of branches, specified by their node ids.
      */
     class BranchIterator
     {
-      public:
-        virtual ~BranchIterator() {}
-
-      public:
-        /**
-         * @return The id of the next node in the set.
-         */
-        virtual int next() throw (Exception) = 0;
-        /**
-         * @return True if there is at least another node in the set.
-         */
-        virtual bool hasNext() const = 0;
+    public:
+      virtual ~BranchIterator() {}
+
+    public:
+      /**
+       * @return The id of the next node in the set.
+       */
+      virtual int next() throw (Exception) = 0;
+      /**
+       * @return True if there is at least another node in the set.
+       */
+      virtual bool hasNext() const = 0;
     };
 
     /**
@@ -93,18 +93,18 @@ class TreeLikelihood:
      */
     class SiteIterator
     {
-      public:
-        virtual ~SiteIterator() {}
-
-      public:
-        /**
-         * @return The position of the next site in the set.
-         */
-        virtual size_t next() throw (Exception) = 0;
-        /**
-         * @return True is there is at least another site in the set.
-         */
-        virtual bool hasNext() const = 0;
+    public:
+      virtual ~SiteIterator() {}
+
+    public:
+      /**
+       * @return The position of the next site in the set.
+       */
+      virtual size_t next() throw (Exception) = 0;
+      /**
+       * @return True is there is at least another site in the set.
+       */
+      virtual bool hasNext() const = 0;
     };
 
     /**
@@ -112,12 +112,13 @@ class TreeLikelihood:
      */
     class ConstBranchModelDescription
     {
-      public:
-        virtual ~ConstBranchModelDescription() {}
+    public:
+      virtual ~ConstBranchModelDescription() {}
 
-      public:
-        virtual const SubstitutionModel* getModel() const = 0;
-        virtual SiteIterator* getNewSiteIterator() const = 0;
+    public:
+      virtual const TransitionModel* getModel() const = 0;
+      virtual const SubstitutionModel* getSubstitutionModel() const = 0;
+      virtual SiteIterator* getNewSiteIterator() const = 0;
     };
 
     /**
@@ -125,12 +126,12 @@ class TreeLikelihood:
      */
     class ConstBranchModelIterator
     {
-      public:
-        virtual ~ConstBranchModelIterator() {}
+    public:
+      virtual ~ConstBranchModelIterator() {}
 
-      public:
-        virtual ConstBranchModelDescription* next() throw (Exception) = 0;
-        virtual bool hasNext() const = 0;
+    public:
+      virtual ConstBranchModelDescription* next() throw (Exception) = 0;
+      virtual bool hasNext() const = 0;
     };
 
     /**
@@ -138,12 +139,13 @@ class TreeLikelihood:
      */
     class ConstSiteModelDescription
     {
-      public:
-        virtual ~ConstSiteModelDescription() {}
+    public:
+      virtual ~ConstSiteModelDescription() {}
 
-      public:
-        virtual const SubstitutionModel* getModel() const = 0;
-        virtual BranchIterator* getNewBranchIterator() const = 0;
+    public:
+      virtual const TransitionModel* getModel() const = 0;
+      virtual const SubstitutionModel* getSubstitutionModel() const = 0;
+      virtual BranchIterator* getNewBranchIterator() const = 0;
     };
 
     /**
@@ -151,21 +153,19 @@ class TreeLikelihood:
      */
     class ConstSiteModelIterator
     {
-      public:
-        virtual ~ConstSiteModelIterator() {}
+    public:
+      virtual ~ConstSiteModelIterator() {}
 
-      public:
-        virtual ConstSiteModelDescription* next() throw (Exception) = 0;
-        virtual bool hasNext() const = 0;
+    public:
+      virtual ConstSiteModelDescription* next() throw (Exception) = 0;
+      virtual bool hasNext() const = 0;
     };
 
   public:
     TreeLikelihood() {}
     virtual ~TreeLikelihood() {}
 
-#ifndef NO_VIRTUAL_COV
     TreeLikelihood* clone() const = 0;
-#endif
 
   public:
 
@@ -288,7 +288,7 @@ class TreeLikelihood:
      * @brief Get the tree (topology and branch lengths).
      *
      * @return The tree of this TreeLikelihood object.
-      */
+     */
     virtual const Tree& getTree() const = 0;
 
     /**
@@ -354,7 +354,7 @@ class TreeLikelihood:
      * @return A pointer toward the corresponding model.
      * @throw NodeNotFoundException This exception may be thrown if the node is not found (depending on the implementation).
      */
-    virtual const SubstitutionModel* getSubstitutionModel(int nodeId, size_t siteIndex) const throw (NodeNotFoundException) = 0;
+    virtual const TransitionModel* getSubstitutionModel(int nodeId, size_t siteIndex) const throw (NodeNotFoundException) = 0;
 
     /**
      * @brief Get the substitution model associated to a given node and alignment column.
@@ -365,7 +365,7 @@ class TreeLikelihood:
      * @return A pointer toward the corresponding model.
      * @throw NodeNotFoundException This exception may be thrown if the node is not found (depending on the implementation).
      */
-    virtual SubstitutionModel* getSubstitutionModel(int nodeId, size_t siteIndex) throw (NodeNotFoundException) = 0;
+    virtual TransitionModel* getSubstitutionModel(int nodeId, size_t siteIndex) throw (NodeNotFoundException) = 0;
 
     /**
      * @brief Retrieves all Pij(t) for a particular branch, defined by the upper node and site.
@@ -435,7 +435,7 @@ class TreeLikelihood:
      */
     virtual ParameterList getNonDerivableParameters() const = 0;
 
-};
+  };
 
 } //end of namespace bpp.
 
diff --git a/src/Bpp/Phyl/Likelihood/TreeLikelihoodData.h b/src/Bpp/Phyl/Likelihood/TreeLikelihoodData.h
index eed1a53..4d96c4d 100644
--- a/src/Bpp/Phyl/Likelihood/TreeLikelihoodData.h
+++ b/src/Bpp/Phyl/Likelihood/TreeLikelihoodData.h
@@ -65,12 +65,7 @@ class TreeLikelihoodNodeData:
     TreeLikelihoodNodeData() {}
     virtual ~TreeLikelihoodNodeData() {}
 
-#ifndef NO_VIRTUAL_COV
-    TreeLikelihoodNodeData*
-#else
-    Clonable*
-#endif
-    clone() const = 0;
+    TreeLikelihoodNodeData* clone() const = 0;
 
   public:
     /**
@@ -106,9 +101,7 @@ class TreeLikelihoodData:
     TreeLikelihoodData() {}
     virtual ~TreeLikelihoodData() {}
     
-#ifndef NO_VIRTUAL_COV
     TreeLikelihoodData* clone() const = 0;
-#endif
 
   public:
     virtual const Alphabet* getAlphabet() const = 0;
diff --git a/src/Bpp/Phyl/Mapping/CategorySubstitutionRegister.h b/src/Bpp/Phyl/Mapping/CategorySubstitutionRegister.h
new file mode 100644
index 0000000..be5b8c6
--- /dev/null
+++ b/src/Bpp/Phyl/Mapping/CategorySubstitutionRegister.h
@@ -0,0 +1,405 @@
+//
+// File: SubstitutionRegister.h
+// Created by: Julien Dutheil
+// Created on: Mon Dec 6 16:32 2010
+//
+
+/*
+  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004, 2005, 2006)
+
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
+
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use,
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info".
+
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability.
+
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or
+  data to be ensured and,  more generally, to use and operate it in the
+  same conditions as regards security.
+
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
+*/
+
+
+#ifndef _CATEGORY_SUBSTITUTIONREGISTER_H_
+#define _CATEGORY_SUBSTITUTIONREGISTER_H_
+
+#include "SubstitutionRegister.h"
+
+namespace bpp
+{
+/**
+ * @brief The CategorySubstitutionRegisters
+ *
+ * @author Julien Dutheil
+ */
+
+  
+/**
+ * @brief Gather states into defined categories, and count the changes between categories.
+ *
+ * Optionally allows for within categories substitutions.
+ */
+  class CategorySubstitutionRegister :
+    public AbstractSubstitutionRegister
+  {
+  protected:
+    bool within_;
+    size_t nbCategories_;
+    mutable std::map<size_t, size_t> categories_;
+    std::vector<std::string> categoryNames_;
+    std::vector< std::vector<size_t> > index_;
+    std::vector< std::vector<size_t> > revIndex_;
+
+    bool stationarity_;
+    
+  public:
+    /**
+     * @brief Build a new substitution register with categories. This class is meant to be inherited.
+     *
+     * @param model The model defining the states.
+     * @param within Specifies if within categories substitutions should be counted as well.
+     */
+    CategorySubstitutionRegister(const SubstitutionModel* model, bool within = false) :
+      AbstractSubstitutionRegister(model),
+      within_(within),
+      nbCategories_(0),
+      categories_(),
+      categoryNames_(),
+      index_(),
+      revIndex_(),
+      stationarity_()
+    {}
+
+  protected:
+    template<class T>
+    void setAlphabetCategories(const std::map<int, T>& categories)
+    {
+      //We need to convert alphabet states into model states.
+      std::map<size_t, T> modelCategories;
+      for (typename std::map<int, T>::const_iterator it = categories.begin(); it != categories.end(); ++it)
+      {  
+        std::vector<size_t> states = model_->getModelStates(it->first);
+        for (size_t i = 0; i < states.size(); ++i) {
+          modelCategories[states[i]] = it->second;
+        }
+      }
+      //Then we forward the model categories:
+      setModelCategories<T>(modelCategories);
+    }
+
+    template<class T>
+    void setModelCategories(const std::map<size_t, T>& categories)
+    {
+      // First index categories:
+      nbCategories_ = 0;
+      std::map<T, size_t> cats;
+      for (typename std::map<size_t, T>::const_iterator it = categories.begin(); it != categories.end(); ++it)
+      {
+        if (cats.find(it->second) == cats.end())
+        {
+          ++nbCategories_;
+          cats[it->second] = nbCategories_;
+        }
+      }
+
+      // Now creates categories:
+      categories_.clear();
+      categoryNames_.resize(nbCategories_);
+      for (size_t i = 0; i < model_->getNumberOfStates(); ++i)
+      {
+        typename std::map<size_t, T>::const_iterator it = categories.find(i);
+        if (it != categories.end())
+        {
+          categories_[i] = cats[it->second];
+          categoryNames_[cats[it->second] - 1] += model_->getStateMap().getStateDescription(i);
+        }
+        else
+        {
+          categories_[i] = 0;
+        }
+      }
+
+      size_t count = 1;
+      index_.resize(nbCategories_);
+      for (size_t i = 0; i < index_.size(); ++i)
+      {
+        index_[i].resize(nbCategories_);
+        for (size_t j = 0; j < index_.size(); ++j)
+        {
+          if (j != i)
+          {
+            index_[i][j] = count++;
+            std::vector<size_t> pos(2);
+            pos[0] = i;
+            pos[1] = j;
+            revIndex_.push_back(pos);
+          }
+        }
+      }
+      if (within_)
+      {
+        for (size_t i = 0; i < index_.size(); ++i)
+        {
+          index_[i][i] = count++;
+          std::vector<size_t> pos(2);
+          pos[0] = i;
+          pos[1] = i;
+          revIndex_.push_back(pos);
+        }
+      }
+    }
+
+  public:
+    virtual size_t getCategory(size_t state) const
+    {
+      return categories_[state];
+    }
+
+    virtual size_t getCategoryFrom(size_t type) const
+    {
+      if (type <= nbCategories_ * (nbCategories_ - 1))
+      {
+        return revIndex_[type - 1][0] + 1;
+      }
+      else
+      {
+        if (within_)
+          return revIndex_[type - 1][0] + 1;
+        else
+          throw Exception("CategorySubstitutionRegister::getCategoryFrom. Bad substitution type.");
+      }
+    }
+
+    virtual size_t getCategoryTo(size_t type) const
+    {
+      if (type <= nbCategories_ * (nbCategories_ - 1))
+      {
+        return revIndex_[type - 1][1] + 1;
+      }
+      else
+      {
+        if (within_)
+          return revIndex_[type - 1][1] + 1;
+        else
+          throw Exception("CategorySubstitutionRegister::getCategoryTo. Bad substitution type.");
+      }
+    }
+
+    virtual std::string getCategoryName(size_t category) const
+    {
+      return categoryNames_[category - 1];
+    }
+
+    virtual bool allowWithin() const { return within_; }
+
+    bool isStationary() const
+    {
+      return stationarity_;
+    }
+
+    void setStationarity(bool stat)
+    {
+      stationarity_=stat;
+    }
+    
+    size_t getNumberOfCategories() const { return nbCategories_; }
+
+    size_t getNumberOfSubstitutionTypes() const { return nbCategories_ * (nbCategories_ - 1) + (within_ ? nbCategories_ : 0); }
+
+    virtual size_t getType(size_t fromState, size_t toState) const
+    {
+      size_t fromCat = categories_[fromState];
+      size_t toCat   = categories_[toState];
+      if (fromCat > 0 && toCat > 0)
+        return index_[fromCat - 1][toCat - 1];
+      else
+        return 0;
+    }
+
+    std::string getTypeName(size_t type) const
+    {
+      return getCategoryName(getCategoryFrom(type)) + "->" +  getCategoryName(getCategoryTo(type));
+    }
+  };
+
+
+/**
+ * @brief Distinguishes all types of substitutions.
+ *
+ * This register has all n * (n-1) substitution type, where n is the size of the alphabet, mapped as:
+ * - 0 not a substitution
+ * - x in [1, n(n-1)] a substitution
+ */
+  class ComprehensiveSubstitutionRegister :
+    public CategorySubstitutionRegister
+  {
+  public:
+    ComprehensiveSubstitutionRegister(const SubstitutionModel* model, bool within = false) :
+      CategorySubstitutionRegister(model, within)
+    {
+      std::map<int, int> categories;
+      for (int i = 0; i < static_cast<int>(model->getAlphabet()->getSize()); ++i)
+      {
+        categories[i] = i;
+      }
+      setAlphabetCategories<int>(categories);
+    }
+
+    ComprehensiveSubstitutionRegister* clone() const { return new ComprehensiveSubstitutionRegister(*this); }
+  };
+
+/**
+ * @brief Distinguishes AT<->GC from GC<->AT.
+ *
+ * This register has two substitution types, mapped as:
+ * - 0 not a substitution
+ * - 1 a AT->GC substitution
+ * - 2 a GC->AT substitution
+ */
+  class GCSubstitutionRegister :
+    public CategorySubstitutionRegister
+  {
+  public:
+    GCSubstitutionRegister(const NucleotideSubstitutionModel* model, bool within = false) :
+      CategorySubstitutionRegister(model, within)
+    {
+      std::map<int, int> categories;
+      categories[0] = 1;
+      categories[1] = 2;
+      categories[2] = 2;
+      categories[3] = 1;
+      setAlphabetCategories<int>(categories);
+    }
+
+    GCSubstitutionRegister* clone() const { return new GCSubstitutionRegister(*this); }
+  };
+
+
+/**
+ * @brief Distinguishes AT->GC vs GC->AT inside synonymous
+ * substitutions on third codon position.
+ *
+ * This register has two substitution types, mapped as:
+ * - 0 not a counted substitution
+ * - 1 a AT->GC synonymous substitution
+ * - 2 a GC->AT synonymous substitution
+ *
+ * Multiple substitutions are forbidden.
+ *
+ */
+
+  class GCSynonymousSubstitutionRegister :
+    public CategorySubstitutionRegister
+  {
+  private:
+    const GeneticCode* code_;
+
+  public:
+    GCSynonymousSubstitutionRegister(const CodonSubstitutionModel* model, bool within = false) :
+      CategorySubstitutionRegister(model, within),
+      code_(model->getGeneticCode())
+    {
+      const CodonAlphabet* pCA = dynamic_cast<const CodonAlphabet*>(code_->getSourceAlphabet());
+
+      std::map<int, int> categories;
+      for (int i = 0; i < static_cast<int>(pCA->getSize()); i++)
+      {
+        int n = pCA->getThirdPosition(i);
+        switch (n)
+        {
+        case 0:
+        case 3:
+          categories[i] = 1;
+          break;
+        case 1:
+        case 2:
+          categories[i] = 2;
+          break;
+        }
+      }
+      setAlphabetCategories<int>(categories);
+    }
+
+    GCSynonymousSubstitutionRegister(const GCSynonymousSubstitutionRegister& reg) :
+      CategorySubstitutionRegister(reg),
+      code_(reg.code_)
+    {}
+
+    GCSynonymousSubstitutionRegister& operator=(const GCSynonymousSubstitutionRegister& reg)
+    {
+      CategorySubstitutionRegister::operator=(reg);
+      code_ = reg.code_;
+      return *this;
+    }
+
+    GCSynonymousSubstitutionRegister* clone() const { return new GCSynonymousSubstitutionRegister(*this); }
+
+  public:
+    size_t getNumberOfSubstitutionTypes() const { return 2; }
+
+    size_t getType(size_t fromState, size_t toState) const
+    {
+      int x = model_->getAlphabetStateAsInt(fromState);
+      int y = model_->getAlphabetStateAsInt(toState);
+      const CodonAlphabet* pCA = dynamic_cast<const CodonAlphabet*>(code_->getSourceAlphabet());
+      if (code_->isStop(x) || code_->isStop( y) || !code_->areSynonymous(x, y))
+        return 0;
+
+      // only substitutions between 3rd positions
+
+      if ((pCA->getFirstPosition(x) != pCA->getFirstPosition(y)) ||
+          (pCA->getSecondPosition(x) != pCA->getSecondPosition(y)))
+        return 0;
+
+      size_t fromCat = categories_[fromState];
+      size_t toCat   = categories_[toState];
+
+      if (fromCat > 0 && toCat > 0)
+        return index_[fromCat - 1][toCat - 1];
+      else
+        return 0;
+    }
+
+    std::string getTypeName (size_t type) const
+    {
+      if (type == 0)
+      {
+        return "no AT<->GC substitution or non-synonymous substitution";
+      }
+      else if (type == 1)
+      {
+        return "AT->GC synonymous";
+      }
+      else if (type == 2)
+      {
+        return "GC->AT synonymous";
+      }
+      else
+      {
+        throw Exception("GCSynonymousSubstitutionRegister::getTypeName. Bad substitution type.");
+      }
+    }
+  };
+
+
+} // end of namespace bpp.
+
+#endif // _CATEGORY_SUBSTITUTIONREGISTER_H_
diff --git a/src/Bpp/Phyl/Mapping/DecompositionReward.cpp b/src/Bpp/Phyl/Mapping/DecompositionReward.cpp
index 3dcf9e8..5a7cb72 100644
--- a/src/Bpp/Phyl/Mapping/DecompositionReward.cpp
+++ b/src/Bpp/Phyl/Mapping/DecompositionReward.cpp
@@ -54,7 +54,7 @@ DecompositionReward::DecompositionReward(const SubstitutionModel* model, Alphabe
   jMat_(nbStates_, nbStates_),
   v_(nbStates_, nbStates_),
   vInv_(nbStates_, nbStates_),
-  lambda_(nbStates_, nbStates_),
+  lambda_(nbStates_),
   bMatrice_(nbStates_, nbStates_),
   insideProduct_(nbStates_, nbStates_),
   rewards_(nbStates_, nbStates_),
@@ -137,7 +137,7 @@ void DecompositionReward::computeRewards_(double length) const
   for (size_t j = 0; j < nbStates_; j++) {
     for (size_t k = 0; k < nbStates_; k++) {
       rewards_(j, k) /= P(j, k);
-      if (isnan(rewards_(j, k)))
+      if (std::isnan(rewards_(j, k)))
         rewards_(j, k) = 0.;
     }
   }
@@ -183,7 +183,7 @@ void DecompositionReward::setSubstitutionModel(const SubstitutionModel* model)
   if (model->getAlphabet()->getAlphabetType() != alphIndex_->getAlphabet()->getAlphabetType())
     throw Exception("DecompositionReward::setSubstitutionModel: alphabets do not match between alphabet index and model.");
   model_ = rModel;
-  unsigned int n = model->getAlphabet()->getSize();
+  size_t n = model->getNumberOfStates();
   if (n != nbStates_) {
     nbStates_ = n;
     resetStates_();
diff --git a/src/Bpp/Phyl/Mapping/DecompositionSubstitutionCount.cpp b/src/Bpp/Phyl/Mapping/DecompositionSubstitutionCount.cpp
index 69001b7..f457e75 100644
--- a/src/Bpp/Phyl/Mapping/DecompositionSubstitutionCount.cpp
+++ b/src/Bpp/Phyl/Mapping/DecompositionSubstitutionCount.cpp
@@ -5,36 +5,36 @@
 //
 
 /*
-Copyright or © or Copr. Bio++ Development Team, (November 16, 2004, 2005, 2006)
-
-This software is a computer program whose purpose is to provide classes
-for phylogenetic data analysis.
-
-This software is governed by the CeCILL  license under French law and
-abiding by the rules of distribution of free software.  You can  use, 
-modify and/ or redistribute the software under the terms of the CeCILL
-license as circulated by CEA, CNRS and INRIA at the following URL
-"http://www.cecill.info". 
-
-As a counterpart to the access to the source code and  rights to copy,
-modify and redistribute granted by the license, users are provided only
-with a limited warranty  and the software's author,  the holder of the
-economic rights,  and the successive licensors  have only  limited
-liability. 
-
-In this respect, the user's attention is drawn to the risks associated
-with loading,  using,  modifying and/or developing or reproducing the
-software by the user in light of its specific status of free software,
-that may mean  that it is complicated to manipulate,  and  that  also
-therefore means  that it is reserved for developers  and  experienced
-professionals having in-depth computer knowledge. Users are therefore
-encouraged to load and test the software's suitability as regards their
-requirements in conditions enabling the security of their systems and/or 
-data to be ensured and,  more generally, to use and operate it in the 
-same conditions as regards security. 
-
-The fact that you are presently reading this means that you have had
-knowledge of the CeCILL license and that you accept its terms.
+  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004, 2005, 2006)
+
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
+
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use, 
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info". 
+
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability. 
+
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or 
+  data to be ensured and,  more generally, to use and operate it in the 
+  same conditions as regards security. 
+
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
 */
 
 #include "DecompositionSubstitutionCount.h"
@@ -55,7 +55,7 @@ DecompositionSubstitutionCount::DecompositionSubstitutionCount(const ReversibleS
   jMat_(nbStates_, nbStates_),
   v_(nbStates_, nbStates_),
   vInv_(nbStates_, nbStates_),
-  lambda_(nbStates_, nbStates_),
+  lambda_(nbStates_),
   bMatrices_(reg->getNumberOfSubstitutionTypes()),
   insideProducts_(reg->getNumberOfSubstitutionTypes()),
   counts_(reg->getNumberOfSubstitutionTypes()),
@@ -135,17 +135,17 @@ void DecompositionSubstitutionCount::initBMatrices_()
 
 void DecompositionSubstitutionCount::jFunction_(const std::vector<double>& lambda, double t, RowMatrix<double>& result) const
 {
-	vector<double> expLam = VectorTools::exp(lambda * t);
-	for (unsigned int i = 0; i < nbStates_; ++i) {
-	  for (unsigned int j = 0; j < nbStates_; ++j) {
+  vector<double> expLam = VectorTools::exp(lambda * t);
+  for (unsigned int i = 0; i < nbStates_; ++i) {
+    for (unsigned int j = 0; j < nbStates_; ++j) {
       double dd = lambda[i] - lambda[j];
       if (dd == 0) {
-  		  result(i, j) = t * expLam[i];
+        result(i, j) = t * expLam[i];
       } else {
-  		  result(i, j) = (expLam[i] - expLam[j]) / dd;
+        result(i, j) = (expLam[i] - expLam[j]) / dd;
       }
     }
-	}
+  }
 }
 
 /******************************************************************************/
@@ -158,7 +158,7 @@ void DecompositionSubstitutionCount::computeCounts_(double length) const
     MatrixTools::hadamardMult(jMat_, insideProducts_[i], tmp1);
     MatrixTools::mult(v_, tmp1, tmp2);
     MatrixTools::mult(tmp2, vInv_, counts_[i]);
-	}
+  }
   // Now we must divide by pijt and account for putative weights:
   vector<int> supportedStates = model_->getAlphabetStates();
   RowMatrix<double> P = model_->getPij_t(length);
@@ -166,11 +166,11 @@ void DecompositionSubstitutionCount::computeCounts_(double length) const
     for (size_t j = 0; j < nbStates_; j++) {
       for (size_t k = 0; k < nbStates_; k++) {
         counts_[i](j, k) /= P(j, k);
-        if (isnan(counts_[i](j, k)) || counts_[i](j, k) < 0.) {
+        if (std::isnan(counts_[i](j, k)) || counts_[i](j, k) < 0.) {
           counts_[i](j, k) = 0.;
-        //Weights:
-        if (weights_)
-          counts_[i](j, k) *= weights_->getIndex(supportedStates[j], supportedStates[k]);
+          //Weights:
+          if (weights_)
+            counts_[i](j, k) *= weights_->getIndex(supportedStates[j], supportedStates[k]);
         }
       }
     }
@@ -185,22 +185,22 @@ Matrix<double>* DecompositionSubstitutionCount::getAllNumbersOfSubstitutions(dou
     throw Exception("DecompositionSubstitutionCount::getAllNumbersOfSubstitutions. Negative branch length: " + TextTools::toString(length) + ".");
   if (length != currentLength_)
   {
-  //if (length < 0.000001) // Limit case!
-  //{ 
-  //  unsigned int s = model_->getAlphabet()->getSize();
-  //  for (unsigned int i = 0; i < s; i++)
-  //  {
-  //    for (unsigned int j = 0; j < s; j++)
-  //    {
-  //      m_(i, j) = i == j ? 0. : 1.;
-  //    }
-  //  }
-  //}
-  //else
-  //{
-  // Else we need to recompute M:
+    //if (length < 0.000001) // Limit case!
+    //{ 
+    //  unsigned int s = model_->getAlphabet()->getSize();
+    //  for (unsigned int i = 0; i < s; i++)
+    //  {
+    //    for (unsigned int j = 0; j < s; j++)
+    //    {
+    //      m_(i, j) = i == j ? 0. : 1.;
+    //    }
+    //  }
+    //}
+    //else
+    //{
+    // Else we need to recompute M:
     computeCounts_(length);
-  //}
+    //}
 
     currentLength_ = length;
   }
@@ -251,7 +251,7 @@ void DecompositionSubstitutionCount::setSubstitutionModel(const SubstitutionMode
   if (model->getAlphabet()->getAlphabetType() != register_->getAlphabet()->getAlphabetType())
     throw Exception("DecompositionSubstitutionCount::setSubstitutionModel: alphabets do not match between register and model.");
   model_ = rModel;
-  unsigned int n = model->getAlphabet()->getSize();
+  size_t n = model->getNumberOfStates();
   if (n != nbStates_) {
     nbStates_ = n;
     resetStates_();
@@ -280,7 +280,7 @@ void DecompositionSubstitutionCount::substitutionRegisterHasChanged() throw (Exc
 
   //Recompute counts:
   if (currentLength_ > 0)
-   computeCounts_(currentLength_);
+    computeCounts_(currentLength_);
 }
 
 /******************************************************************************/
diff --git a/src/Bpp/Phyl/Mapping/DecompositionSubstitutionCount.h b/src/Bpp/Phyl/Mapping/DecompositionSubstitutionCount.h
index 9f5b133..8f8ea63 100644
--- a/src/Bpp/Phyl/Mapping/DecompositionSubstitutionCount.h
+++ b/src/Bpp/Phyl/Mapping/DecompositionSubstitutionCount.h
@@ -55,21 +55,21 @@ namespace bpp
  *
  * @author Julien Dutheil
  */
-class DecompositionSubstitutionCount:
-  public AbstractSubstitutionCount,
-  public AbstractWeightedSubstitutionCount
-{
-	private:
-		const ReversibleSubstitutionModel* model_;
+  class DecompositionSubstitutionCount:
+    public AbstractSubstitutionCount,
+    public AbstractWeightedSubstitutionCount
+  {
+  private:
+    const ReversibleSubstitutionModel* model_;
     size_t nbStates_;
-		mutable RowMatrix<double> jMat_, v_, vInv_;
+    mutable RowMatrix<double> jMat_, v_, vInv_;
     mutable std::vector<double> lambda_;
     std::vector< RowMatrix<double> > bMatrices_, insideProducts_;
     mutable std::vector< RowMatrix<double> > counts_;
     mutable double currentLength_;
 	
-	public:
-		DecompositionSubstitutionCount(const ReversibleSubstitutionModel* model, SubstitutionRegister* reg, const AlphabetIndex2* weights = 0);
+  public:
+    DecompositionSubstitutionCount(const ReversibleSubstitutionModel* model, SubstitutionRegister* reg, const AlphabetIndex2* weights = 0);
 		
     DecompositionSubstitutionCount(const DecompositionSubstitutionCount& dsc) :
       AbstractSubstitutionCount(dsc),
@@ -134,7 +134,7 @@ class DecompositionSubstitutionCount:
     void fillBMatrices_();
     void computeEigen_();
     void computeProducts_();
-};
+  };
 
 } //end of namespace bpp.
 
diff --git a/src/Bpp/Phyl/Mapping/Mapping.h b/src/Bpp/Phyl/Mapping/Mapping.h
index 8198a9f..ca2ad0c 100644
--- a/src/Bpp/Phyl/Mapping/Mapping.h
+++ b/src/Bpp/Phyl/Mapping/Mapping.h
@@ -64,9 +64,7 @@ namespace bpp
     Mapping() {}
     virtual ~Mapping() {}
 
-#ifndef NO_VIRTUAL_COV
     Mapping* clone() const = 0;
-#endif
 
   public:
     
@@ -131,7 +129,7 @@ namespace bpp
     virtual public Mapping
   {
   private:
-    std::auto_ptr<const TreeTemplate<Node> > tree_;
+    std::unique_ptr<const TreeTemplate<Node> > tree_;
     std::vector<int> sitesPositions_;
     std::vector<const Node *> nodes_;
     size_t nbSites_;
@@ -169,9 +167,7 @@ namespace bpp
       return *this;
     }
 
-#ifndef NO_VIRTUAL_COV
     AbstractMapping* clone() const = 0;
-#endif
   
     virtual ~AbstractMapping() {}
   
diff --git a/src/Bpp/Phyl/Mapping/RewardMapping.h b/src/Bpp/Phyl/Mapping/RewardMapping.h
index f61e681..dd29e0e 100644
--- a/src/Bpp/Phyl/Mapping/RewardMapping.h
+++ b/src/Bpp/Phyl/Mapping/RewardMapping.h
@@ -67,9 +67,7 @@ namespace bpp
     RewardMapping() {}
     virtual ~RewardMapping() {}
 
-#ifndef NO_VIRTUAL_COV
     RewardMapping* clone() const = 0;
-#endif
 
   public:
     
@@ -96,9 +94,7 @@ public:
   AbstractRewardMapping(const AbstractRewardMapping& arm):
     AbstractMapping(arm) {}
 
-#ifndef NO_VIRTUAL_COV
   AbstractRewardMapping* clone() const = 0;
-#endif
 
   AbstractRewardMapping& operator=(const AbstractRewardMapping& arm)
     {
diff --git a/src/Bpp/Phyl/Mapping/RewardMappingTools.cpp b/src/Bpp/Phyl/Mapping/RewardMappingTools.cpp
index e574b07..5aaea56 100644
--- a/src/Bpp/Phyl/Mapping/RewardMappingTools.cpp
+++ b/src/Bpp/Phyl/Mapping/RewardMappingTools.cpp
@@ -153,13 +153,13 @@ ProbabilisticRewardMapping* RewardMappingTools::computeRewardVectors(
         const VVVdouble* likelihoodsFather_son = &drtl.getLikelihoodData()->getLikelihoodArray(father->getId(), currentSon->getId());
 
         // Now iterate over all site partitions:
-        auto_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(currentSon->getId()));
+        unique_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(currentSon->getId()));
         VVVdouble pxy;
         bool first;
         while (mit->hasNext())
         {
           TreeLikelihood::ConstBranchModelDescription* bmd = mit->next();
-          auto_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
+          unique_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
           first = true;
           while (sit->hasNext())
           {
@@ -197,13 +197,13 @@ ProbabilisticRewardMapping* RewardMappingTools::computeRewardVectors(
       const Node* currentSon = father->getFather();
       const VVVdouble* likelihoodsFather_son = &drtl.getLikelihoodData()->getLikelihoodArray(father->getId(), currentSon->getId());
       // Now iterate over all site partitions:
-      auto_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(father->getId()));
+      unique_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(father->getId()));
       VVVdouble pxy;
       bool first;
       while (mit->hasNext())
       {
         TreeLikelihood::ConstBranchModelDescription* bmd = mit->next();
-        auto_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
+        unique_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
         first = true;
         while (sit->hasNext())
         {
@@ -259,13 +259,13 @@ ProbabilisticRewardMapping* RewardMappingTools::computeRewardVectors(
 
     // Iterate over all site partitions:
     const VVVdouble* likelihoodsFather_node = &(drtl.getLikelihoodData()->getLikelihoodArray(father->getId(), currentNode->getId()));
-    auto_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(currentNode->getId()));
+    unique_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(currentNode->getId()));
     VVVdouble pxy;
     bool first;
     while (mit->hasNext())
     {
       TreeLikelihood::ConstBranchModelDescription* bmd = mit->next();
-      reward.setSubstitutionModel(bmd->getModel());
+      reward.setSubstitutionModel(bmd->getSubstitutionModel());
       // compute all nxy first:
       VVVdouble nxy(nbClasses);
       for (size_t c = 0; c < nbClasses; ++c)
@@ -287,7 +287,7 @@ ProbabilisticRewardMapping* RewardMappingTools::computeRewardVectors(
       }
 
       // Now loop over sites:
-      auto_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
+      unique_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
       first = true;
       while (sit->hasNext())
       {
diff --git a/src/Bpp/Phyl/Mapping/SubstitutionCount.h b/src/Bpp/Phyl/Mapping/SubstitutionCount.h
index 1ef0ef6..86af8d9 100644
--- a/src/Bpp/Phyl/Mapping/SubstitutionCount.h
+++ b/src/Bpp/Phyl/Mapping/SubstitutionCount.h
@@ -41,6 +41,7 @@
 #define _SUBSTITUTIONCOUNT_H_
 
 #include "SubstitutionRegister.h"
+#include "CategorySubstitutionRegister.h"
 #include "../Model/SubstitutionModel.h"
 
 #include <Bpp/Numeric/Matrix/Matrix.h>
@@ -167,7 +168,7 @@ namespace bpp
     public virtual SubstitutionCount
   {
   protected:
-    std::auto_ptr<SubstitutionRegister> register_;
+    std::unique_ptr<SubstitutionRegister> register_;
 
   public:
     AbstractSubstitutionCount(SubstitutionRegister* reg):
diff --git a/src/Bpp/Phyl/Mapping/SubstitutionMapping.h b/src/Bpp/Phyl/Mapping/SubstitutionMapping.h
index a9fd011..6b4870a 100644
--- a/src/Bpp/Phyl/Mapping/SubstitutionMapping.h
+++ b/src/Bpp/Phyl/Mapping/SubstitutionMapping.h
@@ -70,9 +70,7 @@ namespace bpp
     SubstitutionMapping() {}
     virtual ~SubstitutionMapping() {}
 
-#ifndef NO_VIRTUAL_COV
     SubstitutionMapping* clone() const = 0;
-#endif
 
   public:
     /**
@@ -103,9 +101,7 @@ public:
   AbstractSubstitutionMapping(const AbstractSubstitutionMapping& absm):
     AbstractMapping(absm) {}
 
-#ifndef NO_VIRTUAL_COV
   AbstractSubstitutionMapping* clone() const = 0;
-#endif
 
   AbstractSubstitutionMapping& operator=(const AbstractSubstitutionMapping& absm)
     {
diff --git a/src/Bpp/Phyl/Mapping/SubstitutionMappingTools.cpp b/src/Bpp/Phyl/Mapping/SubstitutionMappingTools.cpp
index 97850fc..2ce3fd1 100644
--- a/src/Bpp/Phyl/Mapping/SubstitutionMappingTools.cpp
+++ b/src/Bpp/Phyl/Mapping/SubstitutionMappingTools.cpp
@@ -163,13 +163,13 @@ ProbabilisticSubstitutionMapping* SubstitutionMappingTools::computeSubstitutionV
         const VVVdouble* likelihoodsFather_son = &drtl.getLikelihoodData()->getLikelihoodArray(father->getId(), currentSon->getId());
 
         // Now iterate over all site partitions:
-        auto_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(currentSon->getId()));
+        unique_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(currentSon->getId()));
         VVVdouble pxy;
         bool first;
         while (mit->hasNext())
         {
           TreeLikelihood::ConstBranchModelDescription* bmd = mit->next();
-          auto_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
+          unique_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
           first = true;
           while (sit->hasNext())
           {
@@ -207,13 +207,13 @@ ProbabilisticSubstitutionMapping* SubstitutionMappingTools::computeSubstitutionV
       const Node* currentSon = father->getFather();
       const VVVdouble* likelihoodsFather_son = &drtl.getLikelihoodData()->getLikelihoodArray(father->getId(), currentSon->getId());
       // Now iterate over all site partitions:
-      auto_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(father->getId()));
+      unique_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(father->getId()));
       VVVdouble pxy;
       bool first;
       while (mit->hasNext())
       {
         TreeLikelihood::ConstBranchModelDescription* bmd = mit->next();
-        auto_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
+        unique_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
         first = true;
         while (sit->hasNext())
         {
@@ -270,13 +270,13 @@ ProbabilisticSubstitutionMapping* SubstitutionMappingTools::computeSubstitutionV
 
     // Iterate over all site partitions:
     const VVVdouble* likelihoodsFather_node = &(drtl.getLikelihoodData()->getLikelihoodArray(father->getId(), currentNode->getId()));
-    auto_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(currentNode->getId()));
+    unique_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(currentNode->getId()));
     VVVdouble pxy;
     bool first;
     while (mit->hasNext())
     {
       TreeLikelihood::ConstBranchModelDescription* bmd = mit->next();
-      substitutionCount.setSubstitutionModel(bmd->getModel());
+      substitutionCount.setSubstitutionModel(bmd->getSubstitutionModel());
       // compute all nxy first:
       VVVVdouble nxy(nbClasses);
       for (size_t c = 0; c < nbClasses; ++c)
@@ -303,7 +303,7 @@ ProbabilisticSubstitutionMapping* SubstitutionMappingTools::computeSubstitutionV
       }
 
       // Now loop over sites:
-      auto_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
+      unique_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
       first = true;
       while (sit->hasNext())
       {
@@ -474,13 +474,13 @@ ProbabilisticSubstitutionMapping* SubstitutionMappingTools::computeSubstitutionV
         const VVVdouble* likelihoodsFather_son = &drtl.getLikelihoodData()->getLikelihoodArray(father->getId(), currentSon->getId());
 
         // Now iterate over all site partitions:
-        auto_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(currentSon->getId()));
+        unique_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(currentSon->getId()));
         VVVdouble pxy;
         bool first;
         while (mit->hasNext())
         {
           TreeLikelihood::ConstBranchModelDescription* bmd = mit->next();
-          auto_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
+          unique_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
           first = true;
           while (sit->hasNext())
           {
@@ -518,13 +518,13 @@ ProbabilisticSubstitutionMapping* SubstitutionMappingTools::computeSubstitutionV
       const Node* currentSon = father->getFather();
       const VVVdouble* likelihoodsFather_son = &drtl.getLikelihoodData()->getLikelihoodArray(father->getId(), currentSon->getId());
       // Now iterate over all site partitions:
-      auto_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(father->getId()));
+      unique_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(father->getId()));
       VVVdouble pxy;
       bool first;
       while (mit->hasNext())
       {
         TreeLikelihood::ConstBranchModelDescription* bmd = mit->next();
-        auto_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
+        unique_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
         first = true;
         while (sit->hasNext())
         {
@@ -581,13 +581,13 @@ ProbabilisticSubstitutionMapping* SubstitutionMappingTools::computeSubstitutionV
 
     // Iterate over all site partitions:
     const VVVdouble* likelihoodsFather_node = &(drtl.getLikelihoodData()->getLikelihoodArray(father->getId(), currentNode->getId()));
-    auto_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(currentNode->getId()));
+    unique_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(currentNode->getId()));
     VVVdouble pxy;
     bool first;
     while (mit->hasNext())
     {
       TreeLikelihood::ConstBranchModelDescription* bmd = mit->next();
-      substitutionCount.setSubstitutionModel(modelSet.getModelForNode(currentNode->getId()));
+      substitutionCount.setSubstitutionModel(modelSet.getSubstitutionModelForNode(currentNode->getId()));
 
       // compute all nxy first:
       VVVVdouble nxy(nbClasses);
@@ -615,7 +615,7 @@ ProbabilisticSubstitutionMapping* SubstitutionMappingTools::computeSubstitutionV
       }
 
       // Now loop over sites:
-      auto_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
+      unique_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
       first = true;
       while (sit->hasNext())
       {
@@ -763,13 +763,13 @@ ProbabilisticSubstitutionMapping* SubstitutionMappingTools::computeSubstitutionV
         const VVVdouble* likelihoodsFather_son = &drtl.getLikelihoodData()->getLikelihoodArray(father->getId(), currentSon->getId());
 
         // Now iterate over all site partitions:
-        auto_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(currentSon->getId()));
+        unique_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(currentSon->getId()));
         VVVdouble pxy;
         bool first;
         while (mit->hasNext())
         {
           TreeLikelihood::ConstBranchModelDescription* bmd = mit->next();
-          auto_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
+          unique_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
           first = true;
           while (sit->hasNext())
           {
@@ -807,13 +807,13 @@ ProbabilisticSubstitutionMapping* SubstitutionMappingTools::computeSubstitutionV
       const Node* currentSon = father->getFather();
       const VVVdouble* likelihoodsFather_son = &drtl.getLikelihoodData()->getLikelihoodArray(father->getId(), currentSon->getId());
       // Now iterate over all site partitions:
-      auto_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(father->getId()));
+      unique_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(father->getId()));
       VVVdouble pxy;
       bool first;
       while (mit->hasNext())
       {
         TreeLikelihood::ConstBranchModelDescription* bmd = mit->next();
-        auto_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
+        unique_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
         first = true;
         while (sit->hasNext())
         {
@@ -869,13 +869,13 @@ ProbabilisticSubstitutionMapping* SubstitutionMappingTools::computeSubstitutionV
 
     // Iterate over all site partitions:
     const VVVdouble* likelihoodsFather_node = &drtl.getLikelihoodData()->getLikelihoodArray(father->getId(), currentNode->getId());
-    auto_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(currentNode->getId()));
+    unique_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(currentNode->getId()));
     VVVdouble pxy;
     bool first;
     while (mit->hasNext())
     {
       TreeLikelihood::ConstBranchModelDescription* bmd = mit->next();
-      substitutionCount.setSubstitutionModel(bmd->getModel());
+      substitutionCount.setSubstitutionModel(bmd->getSubstitutionModel());
       // compute all nxy first:
       VVVVdouble nxy(nbClasses);
       for (size_t c = 0; c < nbClasses; ++c)
@@ -902,7 +902,7 @@ ProbabilisticSubstitutionMapping* SubstitutionMappingTools::computeSubstitutionV
       }
 
       // Now loop over sites:
-      auto_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
+      unique_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
       first = true;
       while (sit->hasNext())
       {
@@ -1049,11 +1049,11 @@ ProbabilisticSubstitutionMapping* SubstitutionMappingTools::computeSubstitutionV
     // Then, we deal with the node of interest.
     // ('y' is the state at 'node' and 'x' the state at 'father'.)
     // Iterate over all site partitions:
-    auto_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(currentNode->getId()));
+    unique_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(currentNode->getId()));
     while (mit->hasNext())
     {
       TreeLikelihood::ConstBranchModelDescription* bmd = mit->next();
-      substitutionCount.setSubstitutionModel(bmd->getModel());
+      substitutionCount.setSubstitutionModel(bmd->getSubstitutionModel());
       // compute all nxy first:
       VVVdouble nxyt(nbTypes);
       for (size_t t = 0; t < nbTypes; ++t)
@@ -1071,7 +1071,7 @@ ProbabilisticSubstitutionMapping* SubstitutionMappingTools::computeSubstitutionV
         delete nxy;
       }
       // Now loop over sites:
-      auto_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
+      unique_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
       while (sit->hasNext())
       {
         size_t i = sit->next();
@@ -1171,11 +1171,11 @@ ProbabilisticSubstitutionMapping* SubstitutionMappingTools::computeSubstitutionV
     VVVdouble probsFather = DRTreeLikelihoodTools::getPosteriorProbabilitiesForEachStateForEachRate(drtl, father->getId());
 
     // Iterate over all site partitions:
-    auto_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(currentNode->getId()));
+    unique_ptr<TreeLikelihood::ConstBranchModelIterator> mit(drtl.getNewBranchModelIterator(currentNode->getId()));
     while (mit->hasNext())
     {
       TreeLikelihood::ConstBranchModelDescription* bmd = mit->next();
-      substitutionCount.setSubstitutionModel(bmd->getModel());
+      substitutionCount.setSubstitutionModel(bmd->getSubstitutionModel());
       // compute all nxy first:
       VVVVdouble nxy(nbClasses);
       for (size_t c = 0; c < nbClasses; ++c)
@@ -1202,7 +1202,7 @@ ProbabilisticSubstitutionMapping* SubstitutionMappingTools::computeSubstitutionV
       }
 
       // Now loop over sites:
-      auto_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
+      unique_ptr<TreeLikelihood::SiteIterator> sit(bmd->getNewSiteIterator());
       while (sit->hasNext())
       {
         size_t i = sit->next();
@@ -1329,7 +1329,7 @@ throw (IOException)
 
 /**************************************************************************************************/
 
-vector<double> SubstitutionMappingTools::computeTotalSubstitutionVectorForSite(const SubstitutionMapping& smap, size_t siteIndex)
+vector<double> SubstitutionMappingTools::computeTotalSubstitutionVectorForSitePerBranch(const SubstitutionMapping& smap, size_t siteIndex)
 {
   size_t nbBranches = smap.getNumberOfBranches();
   size_t nbTypes    = smap.getNumberOfSubstitutionTypes();
@@ -1347,6 +1347,24 @@ vector<double> SubstitutionMappingTools::computeTotalSubstitutionVectorForSite(c
 
 /**************************************************************************************************/
 
+vector<double> SubstitutionMappingTools::computeTotalSubstitutionVectorForSitePerType(const SubstitutionMapping& smap, size_t siteIndex)
+{
+  size_t nbBranches = smap.getNumberOfBranches();
+  size_t nbTypes    = smap.getNumberOfSubstitutionTypes();
+  Vdouble v(nbTypes);
+  for (size_t t = 0; t < nbTypes; ++t)
+  {
+    v[t] = 0;
+    for (size_t l = 0; l < nbBranches; ++l)
+    {
+      v[t] += smap(l, siteIndex, t);
+    }
+  }
+  return v;
+}
+
+/**************************************************************************************************/
+
 double SubstitutionMappingTools::computeNormForSite(const SubstitutionMapping& smap, size_t siteIndex)
 {
   double sumSquare = 0;
@@ -1397,6 +1415,7 @@ vector<double> SubstitutionMappingTools::computeSumForSite(const SubstitutionMap
 }
 
 /**************************************************************************************************/
+
 vector< vector<double> > SubstitutionMappingTools::getCountsPerBranch(
   DRTreeLikelihood& drtl,
   const vector<int>& ids,
@@ -1407,9 +1426,9 @@ vector< vector<double> > SubstitutionMappingTools::getCountsPerBranch(
 {
   SubstitutionRegister* reg2 = reg.clone();
 
-  auto_ptr<SubstitutionCount> count(new UniformizationSubstitutionCount(model, reg2));
+  unique_ptr<SubstitutionCount> count(new UniformizationSubstitutionCount(model, reg2));
 
-  auto_ptr<ProbabilisticSubstitutionMapping> mapping(SubstitutionMappingTools::computeSubstitutionVectors(drtl, ids, *count, false));
+  unique_ptr<ProbabilisticSubstitutionMapping> mapping(SubstitutionMappingTools::computeSubstitutionVectors(drtl, ids, *count, false));
 
   vector< vector<double> > counts(ids.size());
   size_t nbSites = mapping->getNumberOfSites();
@@ -1427,7 +1446,7 @@ vector< vector<double> > SubstitutionMappingTools::getCountsPerBranch(
       for (size_t t = 0; t < nbTypes; ++t)
       {
         tmp[t] = (*mapping)(mapping->getNodeIndex(ids[k]), i, t);
-        error = isnan(tmp[t]);
+        error = std::isnan(tmp[t]);
         if (error)
           goto ERROR;
         s += tmp[t];
@@ -1489,9 +1508,9 @@ vector< vector<double> > SubstitutionMappingTools::getCountsPerBranch(
 {
   SubstitutionRegister* reg2 = reg.clone();
 
-  auto_ptr<SubstitutionCount> count(new UniformizationSubstitutionCount(modelSet.getModel(0), reg2));
+  unique_ptr<SubstitutionCount> count(new UniformizationSubstitutionCount(modelSet.getSubstitutionModel(0), reg2));
 
-  auto_ptr<ProbabilisticSubstitutionMapping> mapping(SubstitutionMappingTools::computeSubstitutionVectors(drtl, modelSet, ids, *count, false));
+  unique_ptr<ProbabilisticSubstitutionMapping> mapping(SubstitutionMappingTools::computeSubstitutionVectors(drtl, modelSet, ids, *count, false));
 
   vector< vector<double> > counts(ids.size());
   size_t nbSites = mapping->getNumberOfSites();
@@ -1509,7 +1528,7 @@ vector< vector<double> > SubstitutionMappingTools::getCountsPerBranch(
       for (size_t t = 0; t < nbTypes; ++t)
       {
         tmp[t] = (*mapping)(mapping->getNodeIndex(ids[k]), i, t);
-        error = isnan(tmp[t]);
+        error = std::isnan(tmp[t]);
         if (error)
           goto ERROR;
         s += tmp[t];
@@ -1576,6 +1595,10 @@ vector< vector<double> > SubstitutionMappingTools::getNormalizationsPerBranch(
   // compute the AlphabetIndex for each substitutionType
   vector<UserAlphabetIndex1 > usai(nbTypes, UserAlphabetIndex1(nullModel->getAlphabet()));
 
+  for (size_t nbt = 0; nbt < nbTypes; nbt++)
+    for (size_t i = 0; i < nbStates; i++)
+      usai[nbt].setIndex(supportedStates[i], 0);
+
   for (size_t i = 0; i < nbStates; i++)
   {
     for (size_t j = 0; j < nbStates; j++)
@@ -1589,6 +1612,10 @@ vector< vector<double> > SubstitutionMappingTools::getNormalizationsPerBranch(
     }
   }
 
+  const WordAlphabet* wAlp=dynamic_cast<const WordAlphabet*>(nullModel->getAlphabet());
+  
+  float sizeWord=float(wAlp?wAlp->getLength():1);
+  
   // compute the normalization for each substitutionType
   vector< vector<double> > rewards(ids.size());
 
@@ -1599,9 +1626,9 @@ vector< vector<double> > SubstitutionMappingTools::getNormalizationsPerBranch(
 
   for (size_t nbt = 0; nbt < nbTypes; nbt++)
   {
-    auto_ptr<Reward> reward(new DecompositionReward(nullModel, &usai[nbt]));
+    unique_ptr<Reward> reward(new DecompositionReward(nullModel, &usai[nbt]));
 
-    auto_ptr<ProbabilisticRewardMapping> mapping(RewardMappingTools::computeRewardVectors(drtl, ids, *reward, false));
+    unique_ptr<ProbabilisticRewardMapping> mapping(RewardMappingTools::computeRewardVectors(drtl, ids, *reward, false));
 
     for (size_t k = 0; k < ids.size(); ++k)
     {
@@ -1609,7 +1636,7 @@ vector< vector<double> > SubstitutionMappingTools::getNormalizationsPerBranch(
       for (size_t i = 0; i < nbSites; ++i)
       {
         double tmp = (*mapping)(k, i);
-        if (isnan(tmp))
+        if (std::isnan(tmp))
         {
           if (verbose)
             ApplicationTools::displayWarning("On branch " + TextTools::toString(ids[k]) + ", reward for type " + reg.getTypeName(nbt + 1) + " could not be computed.");
@@ -1618,10 +1645,10 @@ vector< vector<double> > SubstitutionMappingTools::getNormalizationsPerBranch(
         }
         s += tmp;
       }
-      rewards[k][nbt] = s;
+      rewards[k][nbt] = s*sizeWord;
     }
-    reward.release();
-    mapping.release();
+    reward.reset();
+    mapping.reset();
   }
   return rewards;
 }
@@ -1651,13 +1678,16 @@ vector< vector<double> > SubstitutionMappingTools::getNormalizationsPerBranch(
 
   vector<UserAlphabetIndex1 >  usai(nbTypes, UserAlphabetIndex1(nullModelSet->getAlphabet()));
 
+  const WordAlphabet* wAlp=dynamic_cast<const WordAlphabet*>(nullModelSet->getAlphabet());
+  float sizeWord=float(wAlp?wAlp->getLength():1);
+
   for (size_t nbm = 0; nbm < nbModels; nbm++)
   {
     vector<int> mids = VectorTools::vectorIntersection(ids, nullModelSet->getNodesWithModel(nbm));
     
     if (mids.size()>0)
     {
-      const SubstitutionModel* modn = nullModelSet->getModel(nbm);
+      const SubstitutionModel* modn = nullModelSet->getSubstitutionModel(nbm);
       vector<int> supportedStates = modn->getAlphabetStates();
 
       for (size_t nbt = 0; nbt < nbTypes; nbt++)
@@ -1679,9 +1709,9 @@ vector< vector<double> > SubstitutionMappingTools::getNormalizationsPerBranch(
 
       for (size_t nbt = 0; nbt < nbTypes; nbt++)
       {
-        auto_ptr<Reward> reward(new DecompositionReward(nullModelSet->getModel(nbm), &usai[nbt]));
+        unique_ptr<Reward> reward(new DecompositionReward(nullModelSet->getSubstitutionModel(nbm), &usai[nbt]));
         
-        auto_ptr<ProbabilisticRewardMapping> mapping(RewardMappingTools::computeRewardVectors(drtl, mids, *reward, false));
+        unique_ptr<ProbabilisticRewardMapping> mapping(RewardMappingTools::computeRewardVectors(drtl, mids, *reward, false));
         
         for (size_t k = 0; k < mids.size(); k++)
         {
@@ -1689,7 +1719,7 @@ vector< vector<double> > SubstitutionMappingTools::getNormalizationsPerBranch(
           for (size_t i = 0; i < nbSites; ++i)
           {
             double tmp = (*mapping)(mapping->getNodeIndex(mids[k]), i);
-            if (isnan(tmp))
+            if (std::isnan(tmp))
             {
               if (verbose)
                 ApplicationTools::displayWarning("On branch " + TextTools::toString(mids[k]) + ", reward for type " + reg.getTypeName(nbt + 1) + " could not be computed.");
@@ -1700,10 +1730,10 @@ vector< vector<double> > SubstitutionMappingTools::getNormalizationsPerBranch(
               s += tmp;
           }
           
-          rewards[VectorTools::which(ids, mids[k])][nbt] = s;
+          rewards[VectorTools::which(ids, mids[k])][nbt] = s * sizeWord;
         }
-        reward.release();
-        mapping.release();
+        reward.reset();
+        mapping.reset();
       }
     }
   }
@@ -1767,7 +1797,7 @@ vector< vector<double> > SubstitutionMappingTools::getNormalizedCountsPerBranch(
   vector< vector<double> > counts;
   vector< vector<double> > factors;
 
-  counts = getCountsPerBranch(drtl, ids, modelSet->getModel(0), reg, -1, verbose);
+  counts = getCountsPerBranch(drtl, ids, modelSet->getSubstitutionModel(0), reg, -1, verbose);
   factors = getNormalizationsPerBranch(drtl, ids, nullModelSet, reg, verbose);
 
   size_t nbTypes = counts[0].size();
@@ -1804,23 +1834,14 @@ vector< vector<double> > SubstitutionMappingTools::getRelativeCountsPerBranch(
   const vector<int>& ids,
   SubstitutionModel* model,
   const SubstitutionRegister& reg,
-  bool stationarity,
   double threshold)
 {
   vector< vector<double> > counts = getCountsPerBranch(drtl, ids, model, reg, threshold);
 
-  const CategorySubstitutionRegister* creg;
-  if (!stationarity)
-  {
-    try
-    {
-      creg = &dynamic_cast<const CategorySubstitutionRegister&>(reg);
-    }
-    catch (Exception& ex)
-    {
-      throw Exception("The stationarity option can only be used with a category substitution register.");
-    }
+  const CategorySubstitutionRegister* creg = dynamic_cast<const CategorySubstitutionRegister*>(&reg);
 
+  if ((creg!=NULL) && !creg->isStationary())
+  {
     size_t nbTypes = counts[0].size();
 
     for (size_t k = 0; k < ids.size(); ++k)
@@ -1859,8 +1880,8 @@ void SubstitutionMappingTools::outputTotalCountsPerBranchPerSite(
   SubstitutionModel* model,
   const SubstitutionRegister& reg)
 {
-  auto_ptr<SubstitutionCount> count(new UniformizationSubstitutionCount(model, reg.clone()));
-  auto_ptr<ProbabilisticSubstitutionMapping> smap(SubstitutionMappingTools::computeSubstitutionVectors(drtl, ids, *count, false));
+  unique_ptr<SubstitutionCount> count(new UniformizationSubstitutionCount(model, reg.clone()));
+  unique_ptr<ProbabilisticSubstitutionMapping> smap(SubstitutionMappingTools::computeSubstitutionVectors(drtl, ids, *count, false));
 
   ofstream file;
   file.open(filename.c_str());
@@ -1877,13 +1898,13 @@ void SubstitutionMappingTools::outputTotalCountsPerBranchPerSite(
   file << "sites";
   for (size_t i = 0; i < nbBr; ++i)
   {
-    file << "\t" << i;
+    file << "\t" << ids[i];
   }
   file << endl;
 
   for (size_t k = 0; k < nbSites; ++k)
   {
-    vector<double> countsf = SubstitutionMappingTools::computeTotalSubstitutionVectorForSite(*smap, k);
+    vector<double> countsf = SubstitutionMappingTools::computeTotalSubstitutionVectorForSitePerBranch(*smap, k);
     file << k;
     for (size_t i = 0; i < nbBr; ++i)
     {
@@ -1896,6 +1917,45 @@ void SubstitutionMappingTools::outputTotalCountsPerBranchPerSite(
 
 /**************************************************************************************************/
 
+void SubstitutionMappingTools::outputTotalCountsPerTypePerSite(
+  string& filename,
+  DRTreeLikelihood& drtl,
+  const vector<int>& ids,
+  SubstitutionModel* model,
+  const SubstitutionRegister& reg)
+{
+  unique_ptr<SubstitutionCount> count(new UniformizationSubstitutionCount(model, reg.clone()));
+  unique_ptr<ProbabilisticSubstitutionMapping> smap(SubstitutionMappingTools::computeSubstitutionVectors(drtl, ids, *count, false));
+
+  ofstream file;
+  file.open(filename.c_str());
+
+  size_t nbSites = smap->getNumberOfSites();
+  size_t nbTypes = smap->getNumberOfSubstitutionTypes();
+
+  file << "sites";
+  for (size_t i = 0; i < nbTypes; ++i)
+  {
+    file << "\t" << reg.getTypeName(i + 1);
+  }
+  file << endl;
+
+  for (size_t k = 0; k < nbSites; ++k)
+  {
+    vector<double> countsf = SubstitutionMappingTools::computeTotalSubstitutionVectorForSitePerType(*smap, k);
+    file << k;
+    for (size_t i = 0; i < nbTypes; ++i)
+    {
+      file << "\t" << countsf[i];
+    }
+    file << endl;
+  }
+  file.close();
+}
+
+
+/**************************************************************************************************/
+
 void SubstitutionMappingTools::outputIndividualCountsPerBranchPerSite(
   const string& filenamePrefix,
   DRTreeLikelihood& drtl,
@@ -1903,8 +1963,8 @@ void SubstitutionMappingTools::outputIndividualCountsPerBranchPerSite(
   SubstitutionModel* model,
   const SubstitutionRegister& reg)
 {
-  auto_ptr<SubstitutionCount> count(new UniformizationSubstitutionCount(model, reg.clone()));
-  auto_ptr<ProbabilisticSubstitutionMapping> smap(SubstitutionMappingTools::computeSubstitutionVectors(drtl, ids, *count, false));
+  unique_ptr<SubstitutionCount> count(new UniformizationSubstitutionCount(model, reg.clone()));
+  unique_ptr<ProbabilisticSubstitutionMapping> smap(SubstitutionMappingTools::computeSubstitutionVectors(drtl, ids, *count, false));
 
   ofstream file;
 
@@ -1913,7 +1973,12 @@ void SubstitutionMappingTools::outputIndividualCountsPerBranchPerSite(
 
   for (size_t i = 0; i < reg.getNumberOfSubstitutionTypes(); ++i)
   {
-    string path = filenamePrefix + TextTools::toString(i + 1) + string(".count");
+    string name=reg.getTypeName(i+1);
+    if (name=="")
+      name=TextTools::toString(i + 1);
+
+    string path = filenamePrefix + name + string(".count");
+    
     ApplicationTools::displayResult(string("Output counts of type ") + TextTools::toString(i + 1) + string(" to file"), path);
     file.open(path.c_str());
 
diff --git a/src/Bpp/Phyl/Mapping/SubstitutionMappingTools.h b/src/Bpp/Phyl/Mapping/SubstitutionMappingTools.h
index b246c54..37eaf87 100644
--- a/src/Bpp/Phyl/Mapping/SubstitutionMappingTools.h
+++ b/src/Bpp/Phyl/Mapping/SubstitutionMappingTools.h
@@ -50,7 +50,8 @@ namespace bpp
 /**
  * @brief Provide methods to compute substitution mappings.
  *
- * For now, only 4 methods are implemented, and provide probabilistic substitution mappings.
+ * For now, only 4 methods are implemented, and provide probabilistic
+ * substitution mappings.
  *
  * See:
  * Dutheil J, Pupko T, Jean-Marie A, Galtier N.
@@ -236,8 +237,16 @@ public:
    * @param siteIndex The index of the substitution vector for which the counts should be computed.
    * @return A vector will all counts for all types of substitutions summed.
    */
-  static std::vector<double> computeTotalSubstitutionVectorForSite(const SubstitutionMapping& smap, size_t siteIndex);
+  static std::vector<double> computeTotalSubstitutionVectorForSitePerBranch(const SubstitutionMapping& smap, size_t siteIndex);
 
+  /**
+   * @brief Sum all type of substitutions for each type of a given position (specified by its index).
+   *
+   * @param smap The substitution map to use.
+   * @param siteIndex The index of the substitution vector for which the counts should be computed.
+   * @return A vector will all counts for all branches summed.
+   */
+  static std::vector<double> computeTotalSubstitutionVectorForSitePerType(const SubstitutionMapping& smap, size_t siteIndex);
 
   /**
    * @brief Compute the norm of a substitution vector for a given position (specified by its index).
@@ -252,7 +261,6 @@ public:
    */
   static double computeNormForSite(const SubstitutionMapping& smap, size_t siteIndex);
 
-
   /**
    * @brief Sum all substitutions for each type of a given branch (specified by its index).
    *
@@ -386,24 +394,25 @@ public:
    * @param ids               The numbers of the nodes of the tree
    * @param model             The model on which the SubstitutionCount is built
    * @param reg               the Substitution Register
-   * @param stationarity      if false, a correction is made if the SubstitutionRegister
-   *                             is a CategorySubstitutionRegister
+   *
+   *           If the SubstitutionRegister is a non-stationary
+   *           CategorySubstitutionRegister, a correction is made.
+   *
    * @param threshold         value above which counts are considered saturated
    *                                        (default: -1 means no threshold).
    *
    */
 
-  static std::vector< std::vector<double> >  getRelativeCountsPerBranch(
+  static std::vector< std::vector<double> > getRelativeCountsPerBranch(
     DRTreeLikelihood& drtl,
     const std::vector<int>& ids,
     SubstitutionModel* model,
     const SubstitutionRegister& reg,
-    bool stationarity = true,
     double threshold = -1);
 
   /**
-   * @brief Output the sum of the counts par branch per site, in a
-   * file.
+   * @brief Output the sum over all types of the counts per branch per site,
+   * in a file.
    *
    * @param filename          The name of the output file
    * @param drtl              A DRTreeLikelihood object.
@@ -419,6 +428,24 @@ public:
     SubstitutionModel* model,
     const SubstitutionRegister& reg);
 
+  /**
+   * @brief Output the sum over all branches of the counts per type per site,
+   * in a file.
+   *
+   * @param filename          The name of the output file
+   * @param drtl              A DRTreeLikelihood object.
+   * @param ids               The numbers of the nodes of the tree
+   * @param model             The model on which the SubstitutionCount is built
+   * @param reg               the Substitution Register
+   *
+   */
+  static void outputTotalCountsPerTypePerSite(
+    std::string& filename,
+    DRTreeLikelihood& drtl,
+    const std::vector<int>& ids,
+    SubstitutionModel* model,
+    const SubstitutionRegister& reg);
+
 
   /**
    * @brief Output individual counts par branch per site, in files.
diff --git a/src/Bpp/Phyl/Mapping/SubstitutionRegister.h b/src/Bpp/Phyl/Mapping/SubstitutionRegister.h
index ce02088..252b024 100644
--- a/src/Bpp/Phyl/Mapping/SubstitutionRegister.h
+++ b/src/Bpp/Phyl/Mapping/SubstitutionRegister.h
@@ -5,43 +5,44 @@
 //
 
 /*
-   Copyright or © or Copr. Bio++ Development Team, (November 16, 2004, 2005, 2006)
-
-   This software is a computer program whose purpose is to provide classes
-   for phylogenetic data analysis.
-
-   This software is governed by the CeCILL  license under French law and
-   abiding by the rules of distribution of free software.  You can  use,
-   modify and/ or redistribute the software under the terms of the CeCILL
-   license as circulated by CEA, CNRS and INRIA at the following URL
-   "http://www.cecill.info".
-
-   As a counterpart to the access to the source code and  rights to copy,
-   modify and redistribute granted by the license, users are provided only
-   with a limited warranty  and the software's author,  the holder of the
-   economic rights,  and the successive licensors  have only  limited
-   liability.
-
-   In this respect, the user's attention is drawn to the risks associated
-   with loading,  using,  modifying and/or developing or reproducing the
-   software by the user in light of its specific status of free software,
-   that may mean  that it is complicated to manipulate,  and  that  also
-   therefore means  that it is reserved for developers  and  experienced
-   professionals having in-depth computer knowledge. Users are therefore
-   encouraged to load and test the software's suitability as regards their
-   requirements in conditions enabling the security of their systems and/or
-   data to be ensured and,  more generally, to use and operate it in the
-   same conditions as regards security.
-
-   The fact that you are presently reading this means that you have had
-   knowledge of the CeCILL license and that you accept its terms.
- */
+  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004, 2005, 2006)
+
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
+
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use,
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info".
+
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability.
+
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or
+  data to be ensured and,  more generally, to use and operate it in the
+  same conditions as regards security.
+
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
+*/
 
 #ifndef _SUBSTITUTIONREGISTER_H_
 #define _SUBSTITUTIONREGISTER_H_
 
 #include "../Model/SubstitutionModel.h"
 #include "../Model/Nucleotide/NucleotideSubstitutionModel.h"
+#include "../Model/Protein/ProteinSubstitutionModel.h"
 #include "../Model/Codon/CodonSubstitutionModel.h"
 
 // From bpp-core:
@@ -51,6 +52,7 @@
 
 // From bpp-seq:
 #include <Bpp/Seq/Alphabet/NucleicAlphabet.h>
+#include <Bpp/Seq/Alphabet/ProteicAlphabet.h>
 #include <Bpp/Seq/Alphabet/CodonAlphabet.h>
 #include <Bpp/Seq/GeneticCode/GeneticCode.h>
 
@@ -69,400 +71,351 @@ namespace bpp
  *
  * @author Julien Dutheil
  */
-class SubstitutionRegister :
-  public virtual Clonable
-{
-public:
-  SubstitutionRegister() {}
-  virtual ~SubstitutionRegister() {}
+  class SubstitutionRegister :
+    public virtual Clonable
+  {
+  public:
+    SubstitutionRegister() {}
+    virtual ~SubstitutionRegister() {}
 
-#ifndef NO_VIRTUAL_COV
-  virtual SubstitutionRegister* clone() const = 0;
-#endif
+    virtual SubstitutionRegister* clone() const = 0;
 
-public:
-  /**
-   * @return The alphabet associated to this instance.
-   */
-  virtual const Alphabet* getAlphabet() const = 0;
+  public:
+    /**
+     * @return The alphabet associated to this instance.
+     */
+    virtual const Alphabet* getAlphabet() const = 0;
 
-  /**
-   * @return The substitution model associated to this instance.
-   */
-  virtual const SubstitutionModel* getSubstitutionModel() const = 0;
+    /**
+     * @return The substitution model associated to this instance.
+     */
+    virtual const SubstitutionModel* getSubstitutionModel() const = 0;
 
-  /**
-   * @return The number of substitution types supported by this class.
-   */
-  virtual size_t getNumberOfSubstitutionTypes() const = 0;
+    /**
+     * @return The number of substitution types supported by this class.
+     */
+    virtual size_t getNumberOfSubstitutionTypes() const = 0;
 
-  /**
-   * @brief Get the substitution type far a given pair of model states.
-   *
-   * @param fromState Initial state (should be a state supported by the specified alphabet).
-   * @param toState   Final state (should be a state supported by the specified alphabet).
-   * @return The index of the corresponding substitution type, ranging from 0 to 'getNumberOfSubstitutionTypes' + 1,
-   * as non-substitution (that is when fromState == toState) will always return 0.
-   */
-  virtual size_t getType(size_t fromState, size_t toState) const = 0;
+    /**
+     * @brief Get the substitution type far a given pair of model states.
+     *
+     * @param fromState Initial state (should be a state supported by the specified alphabet).
+     * @param toState   Final state (should be a state supported by the specified alphabet).
+     * @return The index of the corresponding substitution type, ranging from 0 to 'getNumberOfSubstitutionTypes' + 1,
+     * as non-substitution (that is when fromState == toState) will always return 0.
+     */
+    virtual size_t getType(size_t fromState, size_t toState) const = 0;
 
-  /**
-   * @brief Get the name of a given substitution type.
-   *
-   * This method is only used for user-friendlyness purposes, not computational goal.
-   * I can therefore be left unimplemented in some cases.
-   *
-   * @param type Index of the substitution (should be an size_t contained in the register).
-   * @return A string describing the substitution type.
-   */
-  virtual std::string getTypeName(size_t type) const = 0;
-};
+    /**
+     * @brief Get the name of a given substitution type.
+     *
+     * This method is only used for user-friendlyness purposes, not computational goal.
+     * I can therefore be left unimplemented in some cases.
+     *
+     * @param type Index of the substitution (should be an size_t contained in the register).
+     * @return A string describing the substitution type.
+     */
+    virtual std::string getTypeName(size_t type) const = 0;
+  };
 
-class AbstractSubstitutionRegister :
-  public virtual SubstitutionRegister
-{
-protected:
-  const SubstitutionModel* model_;
+  class AbstractSubstitutionRegister :
+    public virtual SubstitutionRegister
+  {
+  protected:
+    const SubstitutionModel* model_;
 
-public:
-  AbstractSubstitutionRegister(const SubstitutionModel* model) :
-    model_(model)
-  {}
+  public:
+    AbstractSubstitutionRegister(const SubstitutionModel* model) :
+      model_(model)
+    {}
 
-  AbstractSubstitutionRegister(const AbstractSubstitutionRegister& asr) :
-    model_(asr.model_)
-  {}
+    AbstractSubstitutionRegister(const AbstractSubstitutionRegister& asr) :
+      model_(asr.model_)
+    {}
 
-  AbstractSubstitutionRegister& operator=(const AbstractSubstitutionRegister& asr)
-  {
-    model_ = asr.model_;
-    return *this;
-  }
+    AbstractSubstitutionRegister& operator=(const AbstractSubstitutionRegister& asr)
+    {
+      model_ = asr.model_;
+      return *this;
+    }
 
-  virtual ~AbstractSubstitutionRegister() {}
+    virtual ~AbstractSubstitutionRegister() {}
 
-public:
-  const SubstitutionModel* getSubstitutionModel() const { return model_; }
+  public:
+    const SubstitutionModel* getSubstitutionModel() const { return model_; }
 
-  const Alphabet* getAlphabet() const { return model_->getAlphabet(); }
-};
+    const Alphabet* getAlphabet() const { return model_->getAlphabet(); }
+  };
 
 /**
- * @brief Gather states into defined categories, and count the changes between categories.
+ * @brief Count all substitutions.
  *
- * Optionally allows for within categories substitutions.
+ * This register has only 1 substitution type, mapped as:
+ * - 0 not a substitution
+ * - 1 a substitution
  */
-class CategorySubstitutionRegister :
-  public AbstractSubstitutionRegister
-{
-protected:
-  bool within_;
-  size_t nbCategories_;
-  mutable std::map<int, size_t> categories_;
-  std::vector<std::string> categoryNames_;
-  std::vector< std::vector<size_t> > index_;
-  std::vector< std::vector<size_t> > revIndex_;
-
-public:
-  /**
-   * @brief Build a new substitution register with categories. This class is meant to be inherited.
-   *
-   * @param model The model defining the states.
-   * @param within Specifies if within categories substitutions should be counted as well.
-   */
-  CategorySubstitutionRegister(const SubstitutionModel* model, bool within = false) :
-    AbstractSubstitutionRegister(model),
-    within_(within),
-    nbCategories_(0),
-    categories_(),
-    categoryNames_(),
-    index_(),
-    revIndex_()
-  {}
-
-protected:
-  template<class T>
-  void setCategories(const std::map<int, T>& categories)
+  class TotalSubstitutionRegister :
+    public AbstractSubstitutionRegister
   {
-    // First index categories:
-    nbCategories_ = 0;
-    std::map<T, size_t> cats;
-    for (typename std::map<int, T>::const_iterator it = categories.begin(); it != categories.end(); ++it)
+  public:
+    TotalSubstitutionRegister(const SubstitutionModel* model) :
+      AbstractSubstitutionRegister(model)
+    {}
+
+    TotalSubstitutionRegister* clone() const { return new TotalSubstitutionRegister(*this); }
+
+  public:
+    size_t getNumberOfSubstitutionTypes() const { return 1; }
+
+    size_t getType(size_t fromState, size_t toState) const
     {
-      if (cats.find(it->second) == cats.end())
-      {
-        ++nbCategories_;
-        cats[it->second] = nbCategories_;
-      }
+      return fromState == toState ? 0 : 1;
     }
 
-    // Now creates categories:
-    categories_.clear();
-    categoryNames_.resize(nbCategories_);
-    std::vector<int> types = model_->getAlphabetStates();
-    for (size_t i = 0; i < types.size(); ++i)
+    std::string getTypeName(size_t type) const
     {
-      typename std::map<int, T>::const_iterator it = categories.find(types[i]);
-      if (it != categories.end())
+      if (type == 0)
       {
-        categories_[types[i]] = cats[it->second];
-        categoryNames_[cats[it->second] - 1] += model_->getAlphabet()->intToChar(types[i]);
+        return "no substitution";
+      }
+      else if (type == 1)
+      {
+        return "substitution";
       }
       else
       {
-        categories_[types[i]] = 0;
+        throw Exception("TotalSubstitutionRegister::getTypeName. Bad substitution type.");
       }
     }
+  };
+
+/**
+ * @brief Completion of a given substitution register to consider
+ * all substitutions. The new substitutions are considered in an
+ * additional type.
+ */
+  class CompleteSubstitutionRegister :
+    public AbstractSubstitutionRegister
+  {
+  private:
+    const SubstitutionRegister* preg_;
+
+    bool isRegComplete_;
 
-    size_t count = 1;
-    index_.resize(nbCategories_);
-    for (size_t i = 0; i < index_.size(); ++i)
+  public:
+    CompleteSubstitutionRegister(const SubstitutionRegister& reg) :
+      AbstractSubstitutionRegister(reg.getSubstitutionModel()),
+      preg_(reg.clone()),
+      isRegComplete_(true)
     {
-      index_[i].resize(nbCategories_);
-      for (size_t j = 0; j < index_.size(); ++j)
+      size_t size = reg.getAlphabet()->getSize();
+      for (size_t i = 0; i < size; i++)
       {
-        if (j != i)
+        for (size_t j = 0; j < size; j++)
         {
-          index_[i][j] = count++;
-          std::vector<size_t> pos(2);
-          pos[0] = i;
-          pos[1] = j;
-          revIndex_.push_back(pos);
+          if ((i != j) && reg.getType(i, j) == 0)
+          {
+            isRegComplete_ = false;
+            return;
+          }
         }
       }
     }
-    if (within_)
-    {
-      for (size_t i = 0; i < index_.size(); ++i)
-      {
-        index_[i][i] = count++;
-        std::vector<size_t> pos(2);
-        pos[0] = i;
-        pos[1] = i;
-        revIndex_.push_back(pos);
-      }
-    }
-  }
 
-public:
-  virtual size_t getCategory(size_t state) const
-  {
-    int alphabetState = model_->getAlphabetStateAsInt(state);
-    return categories_[alphabetState];
-  }
+    CompleteSubstitutionRegister* clone() const { return new CompleteSubstitutionRegister(*this); }
 
-  virtual size_t getCategoryFrom(size_t type) const
-  {
-    if (type <= nbCategories_ * (nbCategories_ - 1))
+    CompleteSubstitutionRegister(const CompleteSubstitutionRegister& csr) :
+      AbstractSubstitutionRegister(csr),
+      preg_(csr.preg_->clone()),
+      isRegComplete_(csr.isRegComplete_)
+    {}
+
+    CompleteSubstitutionRegister& operator=(const CompleteSubstitutionRegister& csr)
     {
-      return revIndex_[type - 1][0] + 1;
+      AbstractSubstitutionRegister::operator=(csr);
+      preg_ = csr.preg_->clone();
+      isRegComplete_ = csr.isRegComplete_;
+      return *this;
     }
-    else
+
+    ~CompleteSubstitutionRegister()
     {
-      if (within_)
-        return revIndex_[type - 1][0] + 1;
-      else
-        throw Exception("CategorySubstitutionRegister::getCategoryFrom. Bad substitution type.");
+      if (preg_)
+        delete preg_;
+      preg_ = 0;
     }
-  }
 
-  virtual size_t getCategoryTo(size_t type) const
-  {
-    if (type <= nbCategories_ * (nbCategories_ - 1))
+  public:
+    size_t getNumberOfSubstitutionTypes() const
     {
-      return revIndex_[type - 1][1] + 1;
+      return preg_->getNumberOfSubstitutionTypes() + (isRegComplete_ ? 0 : 1);
     }
-    else
+
+    size_t getType(size_t fromState, size_t toState) const
     {
-      if (within_)
-        return revIndex_[type - 1][1] + 1;
+      if (fromState==toState)
+        return 0;
+      
+      size_t t = preg_->getType(fromState, toState);
+      if (t == 0)
+        return getNumberOfSubstitutionTypes();
       else
-        throw Exception("CategorySubstitutionRegister::getCategoryTo. Bad substitution type.");
+        return t;
     }
-  }
-
-  virtual std::string getCategoryName(size_t category) const
-  {
-    return categoryNames_[category - 1];
-  }
 
-  virtual bool allowWithin() const { return within_; }
+    std::string getTypeName(size_t type) const
+    {
+      try
+      {
+        return preg_->getTypeName(type);
+      }
+      catch (Exception& e)
+      {
+        if (type == getNumberOfSubstitutionTypes())
+          return "Completion substitution";
+        else
+          throw Exception("CompleteSubstitutionRegister::getTypeName. Bad substitution type.");
+      }
+    }
+  };
 
-  size_t getNumberOfCategories() const { return nbCategories_; }
 
-  size_t getNumberOfSubstitutionTypes() const { return nbCategories_ * (nbCategories_ - 1) + (within_ ? nbCategories_ : 0); }
+  /**
+   * @brief Sets a Register based on a vector of Registers. The
+   * categories are intersection of categories of those Registers.
+   *
+   * @author Laurent Guéguen
+   *
+   */
 
-  virtual size_t getType(size_t fromState, size_t toState) const
-  {
-    size_t fromCat = categories_[model_->getAlphabetStateAsInt(fromState)];
-    size_t toCat   = categories_[model_->getAlphabetStateAsInt(toState)];
-    if (fromCat > 0 && toCat > 0)
-      return index_[fromCat - 1][toCat - 1];
-    else
-      return 0;
-  }
-
-  std::string getTypeName(size_t type) const
+  class VectorOfSubstitionRegisters :
+    public AbstractSubstitutionRegister
   {
-    return getCategoryName(getCategoryFrom(type)) + "->" +  getCategoryName(getCategoryTo(type));
-  }
-};
-
-
-/**
- * @brief Count all substitutions.
- *
- * This register has only 1 substitution type, mapped as:
- * - 0 not a substitution
- * - 1 a substitution
- */
-class TotalSubstitutionRegister :
-  public AbstractSubstitutionRegister
-{
-public:
-  TotalSubstitutionRegister(const SubstitutionModel* model) :
-    AbstractSubstitutionRegister(model)
-  {}
+  private:
+    /**
+     * @brief the vector of pointers to SubstitutionRegisters.
+     *
+     *  These SubstitutionRegisters belong to the object.
+     */
 
-  TotalSubstitutionRegister* clone() const { return new TotalSubstitutionRegister(*this); }
+    std::vector<SubstitutionRegister*> vSubReg_;
 
-public:
-  size_t getNumberOfSubstitutionTypes() const { return 1; }
+  public:
 
-  size_t getType(size_t fromState, size_t toState) const
-  {
-    return fromState == toState ? 0 : 1;
-  }
+    VectorOfSubstitionRegisters(const SubstitutionModel* model) :
+      AbstractSubstitutionRegister(model),
+      vSubReg_()
+    {}
 
-  std::string getTypeName(size_t type) const
-  {
-    if (type == 0)
+    VectorOfSubstitionRegisters(const VectorOfSubstitionRegisters& vosr) :
+      AbstractSubstitutionRegister(vosr),
+      vSubReg_()
     {
-      return "no substitution";
+      for (size_t i = 0; i < vosr.vSubReg_.size(); i++)
+      {
+        vSubReg_.push_back(vosr.vSubReg_[i]->clone());
+      }
     }
-    else if (type == 1)
+    
+    VectorOfSubstitionRegisters& operator=(const VectorOfSubstitionRegisters& vosr)
     {
-      return "substitution";
+      AbstractSubstitutionRegister::operator=(vosr);
+
+      for (size_t i = 0; i < vSubReg_.size(); i++)
+        delete vSubReg_[i];
+
+      vSubReg_.clear();
+      
+      for (size_t i = 0; i < vosr.vSubReg_.size(); i++)
+        vSubReg_.push_back(vosr.vSubReg_[i]->clone());
+
+      return *this;
     }
-    else
+
+    VectorOfSubstitionRegisters* clone() const
     {
-      throw Exception("TotalSubstitutionRegister::getTypeName. Bad substitution type.");
+      return new VectorOfSubstitionRegisters(*this);
     }
-  }
-};
-
-/**
- * @brief Completion of a given substitution register to consider
- * all substitutions. The new substitutions are considered in an
- * additional type.
- */
-class CompleteSubstitutionRegister :
-  public AbstractSubstitutionRegister
-{
-private:
-  const SubstitutionRegister* preg_;
+    
+    ~VectorOfSubstitionRegisters()
+    {
+      for (size_t i = 0; i < vSubReg_.size(); i++)
+        delete vSubReg_[i];
 
-  bool isRegComplete_;
+      vSubReg_.clear();
+    }
 
-public:
-  CompleteSubstitutionRegister(const SubstitutionRegister& reg) :
-    AbstractSubstitutionRegister(reg.getSubstitutionModel()),
-    preg_(reg.clone()),
-    isRegComplete_(true)
-  {
-    size_t size = reg.getAlphabet()->getSize();
-    for (size_t i = 0; i < size; i++)
+    void addRegister(SubstitutionRegister* reg)
     {
-      for (size_t j = 0; j < size; j++)
-      {
-        if ((i != j) && reg.getType(i, j) == 0)
-        {
-          isRegComplete_ = false;
-          return;
-        }
+      if (reg){
+        if (reg->getSubstitutionModel()!=getSubstitutionModel())
+          throw Exception("VectorOfSubstitionRegisters::addRegister : mismatch between models");
+      
+        vSubReg_.push_back(reg);
       }
     }
-  }
-
-  CompleteSubstitutionRegister* clone() const { return new CompleteSubstitutionRegister(*this); }
-
-  CompleteSubstitutionRegister(const CompleteSubstitutionRegister& csr) :
-    AbstractSubstitutionRegister(csr),
-    preg_(csr.preg_->clone()),
-    isRegComplete_(csr.isRegComplete_)
-  {}
-
-  CompleteSubstitutionRegister& operator=(const CompleteSubstitutionRegister& csr)
-  {
-    AbstractSubstitutionRegister::operator=(csr);
-    preg_ = csr.preg_->clone();
-    isRegComplete_ = csr.isRegComplete_;
-    return *this;
-  }
+    
+    size_t getType(size_t i, size_t j) const
+    {
+      if (i==j)
+        return 0;
 
-  ~CompleteSubstitutionRegister()
-  {
-    if (preg_)
-      delete preg_;
-    preg_ = 0;
-  }
+      size_t x=0;
 
-public:
-  size_t getNumberOfSubstitutionTypes() const
-  {
-    return preg_->getNumberOfSubstitutionTypes() + (isRegComplete_ ? 0 : 1);
-  }
+      for (size_t p=0;p<vSubReg_.size();p++)
+      {
+        x*=vSubReg_[p]->getNumberOfSubstitutionTypes();
+        size_t z=vSubReg_[p]->getType(i,j);
+        if (z==0)
+          return 0;
+        x+=z-1;
+      }
 
-  size_t getType(size_t fromState, size_t toState) const
-  {
-    size_t t = preg_->getType(fromState, toState);
-    if (t == 0)
-      return getNumberOfSubstitutionTypes();
-    else
-      return t;
-  }
-
-  std::string getTypeName(size_t type) const
-  {
-    try
-    {
-      return preg_->getTypeName(type);
+      return x+1;
     }
-    catch (Exception& e)
+
+    size_t getNumberOfSubstitutionTypes() const
     {
-      if (type == getNumberOfSubstitutionTypes())
-        return "Completion substitution";
-      else
-        throw Exception("CompleteSubstitutionRegister::getTypeName. Bad substitution type.");
+      if (vSubReg_.size()==0)
+        return 0;
+      
+      size_t n=1;
+      
+      for (size_t i=0;i<vSubReg_.size();i++)
+        n*=vSubReg_[i]->getNumberOfSubstitutionTypes();
+
+      return n;
     }
-  }
-};
 
-/**
- * @brief Distinguishes all types of substitutions.
- *
- * This register has all n * (n-1) substitution type, where n is the size of the alphabet, mapped as:
- * - 0 not a substitution
- * - x in [1, n(n-1)] a substitution
- */
-class ComprehensiveSubstitutionRegister :
-  public CategorySubstitutionRegister
-{
-public:
-  ComprehensiveSubstitutionRegister(const SubstitutionModel* model, bool within = false) :
-    CategorySubstitutionRegister(model, within)
-  {
-    std::map<int, int> categories;
-    for (int i = 0; i < static_cast<int>(model->getAlphabet()->getSize()); ++i)
+    /**
+     * @brief names of the types are the list of their types in the
+     * registers (separated with _).
+     */
+    
+    std::string getTypeName(size_t type) const
     {
-      categories[i] = i;
-    }
-    setCategories<int>(categories);
-  }
+      if (type == 0)
+        return "no substitution";
 
-  ComprehensiveSubstitutionRegister* clone() const { return new ComprehensiveSubstitutionRegister(*this); }
-};
+      std::string res="";
+      size_t ty=type-1;
+      
+      for (size_t p=vSubReg_.size(); p>0; p--)
+      {
+        res+=vSubReg_[p-1]->getTypeName((ty%vSubReg_[p-1]->getNumberOfSubstitutionTypes())+1);
+
+        ty/=vSubReg_[p-1]->getNumberOfSubstitutionTypes();
+        
+        if (p!=1)
+          res+="_";
+      }
+
+      return res;
+    }
 
+  };
+  
+    
 /**
  * @brief Sets a Register based on a matrix of integers. If M is the
  *  matrix, M[i,j] is the number of the substitution type from i to j,
@@ -470,96 +423,96 @@ public:
  *
  * @author Laurent Guéguen
  */
-class GeneralSubstitutionRegister :
-  public AbstractSubstitutionRegister
-{
-protected:
-  /**
-   * @brief The size of the matrix, i.e. the number of states.
-   */
-  size_t size_;
+  class GeneralSubstitutionRegister :
+    public AbstractSubstitutionRegister
+  {
+  protected:
+    /**
+     * @brief The size of the matrix, i.e. the number of states.
+     */
+    size_t size_;
 
-  /**
-   * @brief The matrix of the substitution register.
-   */
+    /**
+     * @brief The matrix of the substitution register.
+     */
 
-  RowMatrix<size_t> matrix_;
+    RowMatrix<size_t> matrix_;
 
-  /**
-   * @brief The map from substitution types to the map of from states
-   * to the vector of target states.
-   *
-   * This is the reverse information of matrix_
-   *
-   */
+    /**
+     * @brief The map from substitution types to the map of from states
+     * to the vector of target states.
+     *
+     * This is the reverse information of matrix_
+     *
+     */
 
-  std::map<size_t, std::map<size_t, std::vector<size_t> > > types_;
-
-public:
-  GeneralSubstitutionRegister(const SubstitutionModel* model) :
-    AbstractSubstitutionRegister(model),
-    size_(model->getNumberOfStates()),
-    matrix_(size_, size_),
-    types_()
-  {}
-
-  GeneralSubstitutionRegister(const SubstitutionModel* model, const RowMatrix<size_t>& matrix) :
-    AbstractSubstitutionRegister(model),
-    size_(model->getNumberOfStates()),
-    matrix_(matrix),
-    types_()
-  {
-    if (matrix_.getNumberOfRows() != size_)
-      throw DimensionException("GeneralSubstitutionRegister", size_, matrix_.getNumberOfRows());
-    if (matrix_.getNumberOfColumns() != size_)
-      throw DimensionException("GeneralSubstitutionRegister", size_, matrix_.getNumberOfColumns());
-    updateTypes_();
-  }
-
-  GeneralSubstitutionRegister(const GeneralSubstitutionRegister& gsr) :
-    AbstractSubstitutionRegister(gsr),
-    size_(gsr.size_),
-    matrix_(gsr.matrix_),
-    types_(gsr.types_)
-  {}
-
-  GeneralSubstitutionRegister& operator=(const GeneralSubstitutionRegister& gsr)
-  {
-    AbstractSubstitutionRegister::operator=(gsr);
-    size_   = gsr.size_;
-    matrix_ = gsr.matrix_;
-    types_  = gsr.types_;
-    return *this;
-  }
+    std::map<size_t, std::map<size_t, std::vector<size_t> > > types_;
+
+  public:
+    GeneralSubstitutionRegister(const SubstitutionModel* model) :
+      AbstractSubstitutionRegister(model),
+      size_(model->getNumberOfStates()),
+      matrix_(size_, size_),
+      types_()
+    {}
+
+    GeneralSubstitutionRegister(const SubstitutionModel* model, const RowMatrix<size_t>& matrix) :
+      AbstractSubstitutionRegister(model),
+      size_(model->getNumberOfStates()),
+      matrix_(matrix),
+      types_()
+    {
+      if (matrix_.getNumberOfRows() != size_)
+        throw DimensionException("GeneralSubstitutionRegister", size_, matrix_.getNumberOfRows());
+      if (matrix_.getNumberOfColumns() != size_)
+        throw DimensionException("GeneralSubstitutionRegister", size_, matrix_.getNumberOfColumns());
+      updateTypes_();
+    }
 
-  GeneralSubstitutionRegister* clone() const { return new GeneralSubstitutionRegister(*this); }
+    GeneralSubstitutionRegister(const GeneralSubstitutionRegister& gsr) :
+      AbstractSubstitutionRegister(gsr),
+      size_(gsr.size_),
+      matrix_(gsr.matrix_),
+      types_(gsr.types_)
+    {}
 
-  virtual ~GeneralSubstitutionRegister() {}
+    GeneralSubstitutionRegister& operator=(const GeneralSubstitutionRegister& gsr)
+    {
+      AbstractSubstitutionRegister::operator=(gsr);
+      size_   = gsr.size_;
+      matrix_ = gsr.matrix_;
+      types_  = gsr.types_;
+      return *this;
+    }
 
-  size_t getType(size_t i, size_t j) const
-  {
-    return matrix_(i, j);
-  }
+    GeneralSubstitutionRegister* clone() const { return new GeneralSubstitutionRegister(*this); }
 
-  size_t getNumberOfSubstitutionTypes() const
-  {
-    return types_.find(0) == types_.end() ? types_.size() : types_.size() - 1;
-  }
+    virtual ~GeneralSubstitutionRegister() {}
 
-  /**
-   * @brief names of the types are their number.
-   */
-  std::string getTypeName(size_t type) const
-  {
-    if (types_.find(type) != types_.end())
-      return TextTools::toString(type);
+    size_t getType(size_t i, size_t j) const
+    {
+      return matrix_(i, j);
+    }
+
+    size_t getNumberOfSubstitutionTypes() const
+    {
+      return types_.find(0) == types_.end() ? types_.size() : types_.size() - 1;
+    }
 
-    throw Exception("Bad type number " + TextTools::toString(type) + " in GeneralSubstitutionRegister::getTypeName.");
-  }
+    /**
+     * @brief names of the types are their number.
+     */
+    std::string getTypeName(size_t type) const
+    {
+      if (types_.find(type) != types_.end())
+        return TextTools::toString(type);
+
+      throw Exception("Bad type number " + TextTools::toString(type) + " in GeneralSubstitutionRegister::getTypeName.");
+    }
 
-protected:
-  void updateTypes_();
-};
+  protected:
+    void updateTypes_();
+  };
 
 
 /**
@@ -570,72 +523,72 @@ protected:
  *  @author Juraj Michalik
  */
 
-class SelectedSubstitutionRegister :
-  public GeneralSubstitutionRegister
-{
-  std::map<size_t, std::string> categoryNames_;
-
-public:
-  SelectedSubstitutionRegister (const SubstitutionModel* model, std::string selectedSubstitutions) :
-    GeneralSubstitutionRegister(model),
-    categoryNames_()
+  class SelectedSubstitutionRegister :
+    public GeneralSubstitutionRegister
   {
-    selectedSubstitutions.erase(std::remove(selectedSubstitutions.begin(), selectedSubstitutions.end(), ' '), selectedSubstitutions.end());
-    /**
-     *  @brief This constructor creates an empty square matrix (nrow = ncol
-     *  = length of alphabet) and takes a string with specific
-     *  syntax to mark a substitutions with a certain index
-     *  depending on the string entered.
-     *
-     *  The same group of substitution is delimited by parentheses.
-     *  The name, if entered, is entered at the start of a string
-     *  and followed by ";". Substitutions are delimited by ",", and
-     *  each substitution is defined with a "->" symbol.
-     */
-    size_t typeSubs = 0;
-    size_t coord1 = 0;
-    size_t coord2 = 0;
-    std::string codon1 = "";
-    std::string codon2 = "";
-    StringTokenizer subsGroup(selectedSubstitutions, "()");
-    while (subsGroup.hasMoreToken())
+    std::map<size_t, std::string> categoryNames_;
+
+  public:
+    SelectedSubstitutionRegister (const SubstitutionModel* model, std::string selectedSubstitutions) :
+      GeneralSubstitutionRegister(model),
+      categoryNames_()
     {
-      typeSubs++;
-      StringTokenizer namesSubs(subsGroup.nextToken(), ":");
-      if (namesSubs.numberOfRemainingTokens() == 2)
-      {
-        categoryNames_[typeSubs] = namesSubs.nextToken();
-      }
-      else if (namesSubs.numberOfRemainingTokens() == 1)
-      {
-        categoryNames_[typeSubs] = TextTools::toString(typeSubs);
-      }
-      StringTokenizer substitutions(namesSubs.nextToken(), ",");
-      while (substitutions.hasMoreToken())
+      selectedSubstitutions.erase(std::remove(selectedSubstitutions.begin(), selectedSubstitutions.end(), ' '), selectedSubstitutions.end());
+      /**
+       *  @brief This constructor creates an empty square matrix (nrow = ncol
+       *  = length of alphabet) and takes a string with specific
+       *  syntax to mark a substitutions with a certain index
+       *  depending on the string entered.
+       *
+       *  The same group of substitution is delimited by parentheses.
+       *  The name, if entered, is entered at the start of a string
+       *  and followed by ";". Substitutions are delimited by ",", and
+       *  each substitution is defined with a "->" symbol.
+       */
+      size_t typeSubs = 0;
+      size_t coord1 = 0;
+      size_t coord2 = 0;
+      std::string codon1 = "";
+      std::string codon2 = "";
+      StringTokenizer subsGroup(selectedSubstitutions, "()");
+      while (subsGroup.hasMoreToken())
       {
-        StringTokenizer coordinates(substitutions.nextToken(), "->");
-        codon1 = coordinates.nextToken();
-        codon2 = coordinates.nextToken();
-        coord1 = model_->getAlphabet()->getStateIndex(codon1);
-        coord2 = model_->getAlphabet()->getStateIndex(codon2);
-        this->matrix_(coord1, coord2) = typeSubs;
+        typeSubs++;
+        StringTokenizer namesSubs(subsGroup.nextToken(), ":");
+        if (namesSubs.numberOfRemainingTokens() == 2)
+        {
+          categoryNames_[typeSubs] = namesSubs.nextToken();
+        }
+        else if (namesSubs.numberOfRemainingTokens() == 1)
+        {
+          categoryNames_[typeSubs] = TextTools::toString(typeSubs);
+        }
+        StringTokenizer substitutions(namesSubs.nextToken(), ",");
+        while (substitutions.hasMoreToken())
+        {
+          StringTokenizer coordinates(substitutions.nextToken(), "->");
+          codon1 = coordinates.nextToken();
+          codon2 = coordinates.nextToken();
+          coord1 = model_->getAlphabet()->getStateIndex(codon1);
+          coord2 = model_->getAlphabet()->getStateIndex(codon2);
+          this->matrix_(coord1, coord2) = typeSubs;
+        }
       }
+      updateTypes_();
     }
-    updateTypes_();
-  }
 
-  SelectedSubstitutionRegister* clone() const { return new SelectedSubstitutionRegister(*this); }
+    SelectedSubstitutionRegister* clone() const { return new SelectedSubstitutionRegister(*this); }
 
-  ~SelectedSubstitutionRegister() {}
+    ~SelectedSubstitutionRegister() {}
 
-  std::string getTypeName(size_t type) const
-  {
-    if (types_.find(type) != types_.end())
-      return TextTools::toString(categoryNames_.find(type)->second);
+    std::string getTypeName(size_t type) const
+    {
+      if (types_.find(type) != types_.end())
+        return TextTools::toString(categoryNames_.find(type)->second);
 
-    throw Exception("Bad type number " + TextTools::toString(type) + " in GeneralSubstitutionRegister::getTypeName.");
-  }
-};
+      throw Exception("Bad type number " + TextTools::toString(type) + " in GeneralSubstitutionRegister::getTypeName.");
+    }
+  };
 
 /**
  * @brief Indexes only intra amino-acid substitutions. Every group
@@ -645,60 +598,60 @@ public:
  * @author Juraj Michalik
  */
 
-class AAInteriorSubstitutionRegister :
-  public GeneralSubstitutionRegister
-{
-  std::map<std::string, size_t> categoryCorrespondance_;
-
-public:
-  AAInteriorSubstitutionRegister(const CodonSubstitutionModel* model) :
-    GeneralSubstitutionRegister(model),
-    categoryCorrespondance_()
+  class AAInteriorSubstitutionRegister :
+    public GeneralSubstitutionRegister
   {
-    size_t categoryIndex = 1;
-    for (size_t i = 0; i < model->getAlphabet()->getSize(); ++i)
+    std::map<std::string, size_t> categoryCorrespondance_;
+
+  public:
+    AAInteriorSubstitutionRegister(const CodonSubstitutionModel* model) :
+      GeneralSubstitutionRegister(model),
+      categoryCorrespondance_()
     {
-      int state1 = model->getAlphabet()->getStateAt(i).getNum();
-      for (size_t j = i + 1; j < model->getAlphabet()->getSize(); ++j)
+      size_t categoryIndex = 1;
+      for (size_t i = 1; i <= model->getAlphabet()->getSize(); ++i)
       {
-        int state2 = model->getAlphabet()->getStateAt(j).getNum();
-        if (!(model->getGeneticCode()->isStop(state1)) && !(model->getGeneticCode()->isStop(state2)))
+        int state1 = model->getAlphabet()->getStateAt(i).getNum();
+        for (size_t j = i + 1; j <= model->getAlphabet()->getSize(); ++j)
         {
-          if (model->getGeneticCode()->translate(state1) == model->getGeneticCode()->translate(state2))
+          int state2 = model->getAlphabet()->getStateAt(j).getNum();
+          if (!(model->getGeneticCode()->isStop(state1)) && !(model->getGeneticCode()->isStop(state2)))
           {
-            std::string aminoAcid = model->getGeneticCode()->getTargetAlphabet()->intToChar(model->getGeneticCode()->translate(state1));
-            if (categoryCorrespondance_.find(aminoAcid) == categoryCorrespondance_.end())
+            if (model->getGeneticCode()->translate(state1) == model->getGeneticCode()->translate(state2))
             {
-              categoryCorrespondance_[aminoAcid] = categoryIndex;
-              categoryIndex++;
+              std::string aminoAcid = model->getGeneticCode()->getTargetAlphabet()->intToChar(model->getGeneticCode()->translate(state1));
+              if (categoryCorrespondance_.find(aminoAcid) == categoryCorrespondance_.end())
+              {
+                categoryCorrespondance_[aminoAcid] = categoryIndex;
+                categoryIndex++;
+              }
+              matrix_(i, j) = categoryCorrespondance_[aminoAcid];
+              matrix_(j, i) = categoryCorrespondance_[aminoAcid];
             }
-            matrix_(i, j) = categoryCorrespondance_[aminoAcid];
-            matrix_(j, i) = categoryCorrespondance_[aminoAcid];
           }
         }
       }
+      updateTypes_();
     }
-    updateTypes_();
-  }
 
-  AAInteriorSubstitutionRegister* clone() const { return new AAInteriorSubstitutionRegister(*this); }
+    AAInteriorSubstitutionRegister* clone() const { return new AAInteriorSubstitutionRegister(*this); }
 
-  ~AAInteriorSubstitutionRegister() {}
+    ~AAInteriorSubstitutionRegister() {}
 
 
-  std::string getTypeName(size_t type) const
-  {
-    if (types_.find(type) != types_.end())
+    std::string getTypeName(size_t type) const
     {
-      for (std::map<std::string, size_t>::const_iterator it = categoryCorrespondance_.begin(); it != categoryCorrespondance_.end(); it++)
+      if (types_.find(type) != types_.end())
       {
-        if (it->second == type)
-          return TextTools::toString(it->first);
+        for (std::map<std::string, size_t>::const_iterator it = categoryCorrespondance_.begin(); it != categoryCorrespondance_.end(); it++)
+        {
+          if (it->second == type)
+            return TextTools::toString(it->first);
+        }
       }
+      throw Exception("Bad type number " + TextTools::toString(type) + " in GeneralSubstitutionRegister::getTypeName.");
     }
-    throw Exception("Bad type number " + TextTools::toString(type) + " in GeneralSubstitutionRegister::getTypeName.");
-  }
-};
+  };
 
 /**
  * @brief Indexes only substitutions between amino-acids. Groups are
@@ -707,93 +660,67 @@ public:
  * @author Juraj Michalik
  */
 
-class AAExteriorSubstitutionRegister :
-  public GeneralSubstitutionRegister
-{
-  std::map<std::string, size_t> categoryCorrespondance_;
-
-public:
-  AAExteriorSubstitutionRegister (const CodonSubstitutionModel* model) :
-    GeneralSubstitutionRegister(model),
-    categoryCorrespondance_()
+  class AAExteriorSubstitutionRegister :
+    public GeneralSubstitutionRegister
   {
-    size_t categoryIndex = 1;
-    for (size_t i = 0; i < model->getAlphabet()->getSize(); ++i)
+    std::map<std::string, size_t> categoryCorrespondance_;
+
+  public:
+    AAExteriorSubstitutionRegister (const CodonSubstitutionModel* model) :
+      GeneralSubstitutionRegister(model),
+      categoryCorrespondance_()
     {
-      int state1 = model->getAlphabet()->getStateAt(i).getNum();
-      for (size_t j = i + 1; j < model->getAlphabet()->getSize(); ++j)
+      size_t categoryIndex = 1;
+      for (size_t i = 1; i <= model->getAlphabet()->getSize(); ++i)
       {
-        int state2 = model->getAlphabet()->getStateAt(j).getNum();
-        if (!(model->getGeneticCode()->isStop(state1)) && !(model->getGeneticCode()->isStop(state2)))
+        int state1 = model->getAlphabet()->getStateAt(i).getNum();
+        for (size_t j = i + 1; j <= model->getAlphabet()->getSize(); ++j)
         {
-          if (model->getGeneticCode()->translate(state1) != model->getGeneticCode()->translate(state2))
+          int state2 = model->getAlphabet()->getStateAt(j).getNum();
+          if (!(model->getGeneticCode()->isStop(state1)) && !(model->getGeneticCode()->isStop(state2)))
           {
-            std::string aminoAcid1 = model->getGeneticCode()->getTargetAlphabet()->intToChar(model->getGeneticCode()->translate(state1));
-            std::string aminoAcid2 = model->getGeneticCode()->getTargetAlphabet()->intToChar(model->getGeneticCode()->translate(state2));
-            bool AA1IsNotInGroup = ((categoryCorrespondance_.find(aminoAcid1 + "->" + aminoAcid2) == categoryCorrespondance_.end()));
-            bool AA2IsNotInGroup = ((categoryCorrespondance_.find(aminoAcid2 + "->" + aminoAcid1) == categoryCorrespondance_.end()));
-            if (AA1IsNotInGroup)
-            {
-              categoryCorrespondance_[aminoAcid1 + "->" + aminoAcid2] = categoryIndex;
-              categoryIndex++;
-            }
-            this->matrix_(i, j) = categoryCorrespondance_[aminoAcid1 + "->" + aminoAcid2];
-            if (AA2IsNotInGroup)
+            if (model->getGeneticCode()->translate(state1) != model->getGeneticCode()->translate(state2))
             {
-              categoryCorrespondance_[aminoAcid2 + "->" + aminoAcid1] = categoryIndex;
-              categoryIndex++;
+              std::string aminoAcid1 = model->getGeneticCode()->getTargetAlphabet()->intToChar(model->getGeneticCode()->translate(state1));
+              std::string aminoAcid2 = model->getGeneticCode()->getTargetAlphabet()->intToChar(model->getGeneticCode()->translate(state2));
+              bool AA1IsNotInGroup = ((categoryCorrespondance_.find(aminoAcid1 + "->" + aminoAcid2) == categoryCorrespondance_.end()));
+              bool AA2IsNotInGroup = ((categoryCorrespondance_.find(aminoAcid2 + "->" + aminoAcid1) == categoryCorrespondance_.end()));
+              if (AA1IsNotInGroup)
+              {
+                categoryCorrespondance_[aminoAcid1 + "->" + aminoAcid2] = categoryIndex;
+                categoryIndex++;
+              }
+              this->matrix_(i, j) = categoryCorrespondance_[aminoAcid1 + "->" + aminoAcid2];
+              if (AA2IsNotInGroup)
+              {
+                categoryCorrespondance_[aminoAcid2 + "->" + aminoAcid1] = categoryIndex;
+                categoryIndex++;
+              }
+              this->matrix_(j, i) = categoryCorrespondance_[aminoAcid2 + "->" + aminoAcid1];
             }
-            this->matrix_(j, i) = categoryCorrespondance_[aminoAcid2 + "->" + aminoAcid1];
           }
         }
       }
+      updateTypes_();
     }
-    updateTypes_();
-  }
 
-  AAExteriorSubstitutionRegister* clone() const { return new AAExteriorSubstitutionRegister(*this); }
+    AAExteriorSubstitutionRegister* clone() const { return new AAExteriorSubstitutionRegister(*this); }
 
-  ~AAExteriorSubstitutionRegister() {}
+    ~AAExteriorSubstitutionRegister() {}
 
-  std::string getTypeName(size_t type) const
-  {
-    if (types_.find(type) != types_.end())
+    std::string getTypeName(size_t type) const
     {
-      for (std::map<std::string, size_t>::const_iterator it = categoryCorrespondance_.begin(); it != categoryCorrespondance_.end(); it++)
+      if (types_.find(type) != types_.end())
       {
-        if (it->second == type)
-          return TextTools::toString(it->first);
+        for (std::map<std::string, size_t>::const_iterator it = categoryCorrespondance_.begin(); it != categoryCorrespondance_.end(); it++)
+        {
+          if (it->second == type)
+            return TextTools::toString(it->first);
+        }
       }
+      throw Exception("Bad type number " + TextTools::toString(type) + " in GeneralSubstitutionRegister::getTypeName.");
     }
-    throw Exception("Bad type number " + TextTools::toString(type) + " in GeneralSubstitutionRegister::getTypeName.");
-  }
-};
-
-/**
- * @brief Distinguishes AT<->GC from GC<->AT.
- *
- * This register has two substitution types, mapped as:
- * - 0 not a substitution
- * - 1 a AT->GC substitution
- * - 2 a GC->AT substitution
- */
-class GCSubstitutionRegister :
-  public CategorySubstitutionRegister
-{
-public:
-  GCSubstitutionRegister(const NucleotideSubstitutionModel* model, bool within = false) :
-    CategorySubstitutionRegister(model, within)
-  {
-    std::map<int, int> categories;
-    categories[0] = 1;
-    categories[1] = 2;
-    categories[2] = 2;
-    categories[3] = 1;
-    setCategories<int>(categories);
-  }
-
-  GCSubstitutionRegister* clone() const { return new GCSubstitutionRegister(*this); }
-};
+  };
 
 /**
  * @brief Distinguishes transitions from transversions.
@@ -803,53 +730,106 @@ public:
  * - 1 a transition
  * - 2 a transversion
  */
-class TsTvSubstitutionRegister :
-  public AbstractSubstitutionRegister
-{
-public:
-  TsTvSubstitutionRegister(const NucleotideSubstitutionModel* model) :
-    AbstractSubstitutionRegister(model)
-  {}
-
-  TsTvSubstitutionRegister* clone() const { return new TsTvSubstitutionRegister(*this); }
-
-public:
-  size_t getNumberOfSubstitutionTypes() const { return 2; }
 
-  size_t getType(size_t fromState, size_t toState) const
+  class TsTvSubstitutionRegister :
+    public AbstractSubstitutionRegister
   {
-    int x = model_->getAlphabetStateAsInt(fromState);
-    int y = model_->getAlphabetStateAsInt(toState);
-    if (x == y)
-      return 0;                     // nothing happens
-    if ((x == 0 && y == 2)
-        || (x == 2 && y == 0)
-        || (x == 1 && y == 3)
-        || (x == 3 && y == 1))
-      return 1;                     // This is a transition
-    return 2; // This is a transversion
-  }
-
-  std::string getTypeName(size_t type) const
-  {
-    if (type == 0)
-    {
-      return "no substitution";
-    }
-    else if (type == 1)
+  private:
+    /**
+     *  @brief useful for codon alphabet
+     *
+     */
+    
+    const GeneticCode* code_;
+
+  public:
+    TsTvSubstitutionRegister(const NucleotideSubstitutionModel* model) :
+      AbstractSubstitutionRegister(model),
+      code_()
+    {}
+
+    TsTvSubstitutionRegister(const CodonSubstitutionModel* model) :
+      AbstractSubstitutionRegister(model),
+      code_(model->getGeneticCode())
+    {}
+
+    TsTvSubstitutionRegister(const TsTvSubstitutionRegister& reg) :
+      AbstractSubstitutionRegister(reg),
+      code_(reg.code_)
+    {}
+
+    TsTvSubstitutionRegister& operator=(const TsTvSubstitutionRegister& reg)
     {
-      return "transition";
+      AbstractSubstitutionRegister::operator=(reg);
+      code_ = reg.code_;
+      return *this;
     }
-    else if (type == 2)
+
+    TsTvSubstitutionRegister* clone() const { return new TsTvSubstitutionRegister(*this); }
+
+  public:
+    size_t getNumberOfSubstitutionTypes() const { return 2; }
+
+    size_t getType(size_t fromState, size_t toState) const
     {
-      return "transversion";
+      int x = model_->getAlphabetStateAsInt(fromState);
+      int y = model_->getAlphabetStateAsInt(toState);
+      if (x == y)
+        return 0;                     // nothing happens
+
+      const CodonAlphabet* cAlpha = dynamic_cast<const CodonAlphabet*>(model_->getAlphabet());
+      if (cAlpha)
+      {
+        if (code_->getSourceAlphabet()->isGap(x)
+            || code_->getSourceAlphabet()->isGap(y)
+            || code_->isStop(x)
+            || code_->isStop(y))
+          return 0;
+        
+        size_t countPos = 0;
+        if (cAlpha->getFirstPosition(x) != cAlpha->getFirstPosition(y))
+          countPos++;
+        if (cAlpha->getSecondPosition(x) != cAlpha->getSecondPosition(y))
+          countPos++;
+        if (cAlpha->getThirdPosition(x) != cAlpha->getThirdPosition(y))
+          countPos++;
+        if (countPos > 1)
+          return 0;
+      }
+
+      int d=abs(x-y);
+
+      while (d!=0)
+      {
+        if (d==2)
+          return 1;                     // This is a transition
+        else
+          d/=4;
+      }
+      
+      return 2; // This is a transversion
     }
-    else
+
+    std::string getTypeName(size_t type) const
     {
-      throw Exception("TsTvSubstitutionRegister::getTypeName. Bad substitution type.");
+      if (type == 0)
+      {
+        return "no substitution";
+      }
+      else if (type == 1)
+      {
+        return "transition";
+      }
+      else if (type == 2)
+      {
+        return "transversion";
+      }
+      else
+      {
+        throw Exception("TsTvSubstitutionRegister::getTypeName. Bad substitution type.");
+      }
     }
-  }
-};
+  };
 
 /**
  * @brief Distinguishes synonymous from non-synonymous substitutions.
@@ -859,189 +839,242 @@ public:
  * - 1 a synonymous substitution
  * - 2 a non-synonymous substitution
  */
-class DnDsSubstitutionRegister :
-  public AbstractSubstitutionRegister
-{
-private:
-  const GeneticCode* code_;
-  bool countMultiple_;
-
-public:
-  DnDsSubstitutionRegister(const CodonSubstitutionModel* model, bool countMultiple = false) :
-    AbstractSubstitutionRegister(model),
-    code_(model->getGeneticCode()),
-    countMultiple_(countMultiple)
-  {}
-
-  DnDsSubstitutionRegister(const DnDsSubstitutionRegister& reg) :
-    AbstractSubstitutionRegister(reg),
-    code_(reg.code_),
-    countMultiple_(reg.countMultiple_)
-  {}
-
-  DnDsSubstitutionRegister& operator=(const DnDsSubstitutionRegister& reg)
+  class DnDsSubstitutionRegister :
+    public AbstractSubstitutionRegister
   {
-    AbstractSubstitutionRegister::operator=(reg);
-    code_ = reg.code_;
-    countMultiple_ = reg.countMultiple_;
-    return *this;
-  }
+  private:
+    const GeneticCode* code_;
+    bool countMultiple_;
+
+  public:
+    DnDsSubstitutionRegister(const CodonSubstitutionModel* model, bool countMultiple = false) :
+      AbstractSubstitutionRegister(model),
+      code_(model->getGeneticCode()),
+      countMultiple_(countMultiple)
+    {}
+
+    DnDsSubstitutionRegister(const DnDsSubstitutionRegister& reg) :
+      AbstractSubstitutionRegister(reg),
+      code_(reg.code_),
+      countMultiple_(reg.countMultiple_)
+    {}
+
+    DnDsSubstitutionRegister& operator=(const DnDsSubstitutionRegister& reg)
+    {
+      AbstractSubstitutionRegister::operator=(reg);
+      code_ = reg.code_;
+      countMultiple_ = reg.countMultiple_;
+      return *this;
+    }
 
-  DnDsSubstitutionRegister* clone() const { return new DnDsSubstitutionRegister(*this); }
+    DnDsSubstitutionRegister* clone() const { return new DnDsSubstitutionRegister(*this); }
 
-public:
-  size_t getNumberOfSubstitutionTypes() const { return 2; }
+  public:
+    size_t getNumberOfSubstitutionTypes() const { return 2; }
 
-  size_t getType(size_t fromState, size_t toState) const
-  {
-    int x = model_->getAlphabetStateAsInt(fromState);
-    int y = model_->getAlphabetStateAsInt(toState);
-    const CodonAlphabet* cAlpha = dynamic_cast<const CodonAlphabet*>(model_->getAlphabet());
-    if (code_->isStop(x) || code_->isStop(y))
-      return 0;
-    if (x == y)
-      return 0;                     // nothing happens
-    if (!countMultiple_)
+    size_t getType(size_t fromState, size_t toState) const
     {
-      size_t countPos = 0;
-      if (cAlpha->getFirstPosition(x) != cAlpha->getFirstPosition(y))
-        countPos++;
-      if (cAlpha->getSecondPosition(x) != cAlpha->getSecondPosition(y))
-        countPos++;
-      if (cAlpha->getThirdPosition(x) != cAlpha->getThirdPosition(y))
-        countPos++;
-      if (countPos > 1)
+      int x = model_->getAlphabetStateAsInt(fromState);
+      int y = model_->getAlphabetStateAsInt(toState);
+      const CodonAlphabet* cAlpha = dynamic_cast<const CodonAlphabet*>(model_->getAlphabet());
+      if (code_->getSourceAlphabet()->isGap(x)
+          || code_->getSourceAlphabet()->isGap(y)
+          || code_->isStop(x)
+          || code_->isStop(y))
         return 0;
+      if (x == y)
+        return 0;                     // nothing happens
+      if (!countMultiple_)
+      {
+        size_t countPos = 0;
+        if (cAlpha->getFirstPosition(x) != cAlpha->getFirstPosition(y))
+          countPos++;
+        if (cAlpha->getSecondPosition(x) != cAlpha->getSecondPosition(y))
+          countPos++;
+        if (cAlpha->getThirdPosition(x) != cAlpha->getThirdPosition(y))
+          countPos++;
+        if (countPos > 1)
+          return 0;
+      }
+      return code_->areSynonymous(x, y) ? 1 : 2;
     }
-    return code_->areSynonymous(x, y) ? 1 : 2;
-  }
 
-  std::string getTypeName (size_t type) const
-  {
-    if (type == 0)
-    {
-      return "no substitution";
-    }
-    else if (type == 1)
-    {
-      return "synonymous";
-    }
-    else if (type == 2)
-    {
-      return "non synonymous";
-    }
-    else
+    std::string getTypeName (size_t type) const
     {
-      throw Exception("DnDsSubstitutionRegister::getTypeName. Bad substitution type.");
+      if (type == 0)
+      {
+        return "no substitution";
+      }
+      else if (type == 1)
+      {
+        return "dS";
+      }
+      else if (type == 2)
+      {
+        return "dN";
+      }
+      else
+      {
+        throw Exception("DnDsSubstitutionRegister::getTypeName. Bad substitution type.");
+      }
     }
-  }
-};
+  };
 
 /**
- * @brief Distinguishes AT->GC vs GC->AT inside synonymous
- * substitutions on third codon position.
- *
- * This register has two substitution types, mapped as:
- * - 0 not a counted substitution
- * - 1 a AT->GC synonymous substitution
- * - 2 a GC->AT synonymous substitution
+ * @brief Count conservative and radical amino-acid substitutions.
  *
- * Multiple substitutions are forbidden.
+ * Categories are defined as in Sainudiin et al (2005).
+ * - 1 a conservative (C) substitution
+ * - 2 a radical (R) substitution
  *
+ * @author Jonathan Romiguier, Emeric Figuet, Julien Dutheil
  */
-
-class GCSynonymousSubstitutionRegister :
-  public CategorySubstitutionRegister
-{
-private:
-  const GeneticCode* code_;
-
-public:
-  GCSynonymousSubstitutionRegister(const CodonSubstitutionModel* model, bool within = false) :
-    CategorySubstitutionRegister(model, within),
-    code_(model->getGeneticCode())
+  class KrKcSubstitutionRegister :
+    public AbstractSubstitutionRegister
   {
-    const CodonAlphabet* pCA = dynamic_cast<const CodonAlphabet*>(code_->getSourceAlphabet());
+  private:
+    std::vector< std::vector<bool> > types_;
 
-    std::map<int, int> categories;
-    for (int i = 0; i < static_cast<int>(pCA->getSize()); i++)
+  public:
+    KrKcSubstitutionRegister(const ProteinSubstitutionModel* model) :
+      AbstractSubstitutionRegister(model),
+      types_(20)
     {
-      int n = pCA->getThirdPosition(i);
-      switch (n)
-      {
-      case 0:
-      case 3:
-        categories[i] = 1;
-        break;
-      case 1:
-      case 2:
-        categories[i] = 2;
-        break;
+      for (size_t i = 0; i < 20; ++i) {
+        types_[i].resize(20);
+        for (size_t j = 0; j < 20; ++j) {
+          types_[i][j] = false;
+        }
       }
-    }
-    setCategories<int>(categories);
-  }
-
-  GCSynonymousSubstitutionRegister(const GCSynonymousSubstitutionRegister& reg) :
-    CategorySubstitutionRegister(reg),
-    code_(reg.code_)
-  {}
-
-  GCSynonymousSubstitutionRegister& operator=(const GCSynonymousSubstitutionRegister& reg)
-  {
-    CategorySubstitutionRegister::operator=(reg);
-    code_ = reg.code_;
-    return *this;
-  }
-
-  GCSynonymousSubstitutionRegister* clone() const { return new GCSynonymousSubstitutionRegister(*this); }
-
-public:
-  size_t getNumberOfSubstitutionTypes() const { return 2; }
-
-  size_t getType(size_t fromState, size_t toState) const
-  {
-    int x = model_->getAlphabetStateAsInt(fromState);
-    int y = model_->getAlphabetStateAsInt(toState);
-    const CodonAlphabet* pCA = dynamic_cast<const CodonAlphabet*>(code_->getSourceAlphabet());
-    if (code_->isStop(x) || code_->isStop( y) || !code_->areSynonymous(x, y))
-      return 0;
-
-    // only substitutions between 3rd positions
 
-    if ((pCA->getFirstPosition(x) != pCA->getFirstPosition(y)) ||
-        (pCA->getSecondPosition(x) != pCA->getSecondPosition(y)))
-      return 0;
+      types_[0][7] = true;
+      types_[0][14] = true;
+      types_[0][19] = true;
+      types_[7][0] = true;
+      types_[7][14] = true;
+      types_[7][19] = true;
+      types_[14][0] = true;
+      types_[14][7] = true;
+      types_[14][19] = true;
+      types_[19][0] = true;
+      types_[19][7] = true;
+      types_[19][14] = true;
+    
+      types_[1][5] = true;
+      types_[1][6] = true;
+      types_[1][8] = true;
+      types_[1][11] = true;
+      types_[1][17] = true;
+      types_[1][18] = true;
+      types_[5][6] = true;
+      types_[5][8] = true;
+      types_[5][11] = true;
+      types_[5][1] = true;
+      types_[5][17] = true;
+      types_[5][18] = true;
+      types_[6][8] = true;
+      types_[6][11] = true;
+      types_[6][5] = true;
+      types_[6][1] = true;
+      types_[6][17] = true;
+      types_[6][18] = true;
+      types_[8][6] = true;
+      types_[8][11] = true;
+      types_[8][5] = true;
+      types_[8][1] = true;
+      types_[8][17] = true;
+      types_[8][18] = true;
+      types_[11][1] = true;
+      types_[11][5] = true;
+      types_[11][6] = true;
+      types_[11][8] = true;
+      types_[11][17] = true;
+      types_[11][18] = true;
+      types_[17][1] = true;
+      types_[17][5] = true;
+      types_[17][6] = true;
+      types_[17][8] = true;
+      types_[17][11] = true;
+      types_[17][18] = true;
+      types_[18][1] = true;
+      types_[18][6] = true;
+      types_[18][8] = true;
+      types_[18][11] = true;
+      types_[18][5] = true;
+      types_[18][17] = true;
+    
+      types_[2][3] = true;
+      types_[2][4] = true;
+      types_[2][15] = true;
+      types_[2][16] = true;
+      types_[3][2] = true;
+      types_[3][4] = true;
+      types_[3][15] = true;
+      types_[3][16] = true;
+      types_[4][2] = true;
+      types_[4][3] = true;
+      types_[4][15] = true;
+      types_[4][16] = true;
+      types_[15][2] = true;
+      types_[15][3] = true;
+      types_[15][4] = true;
+      types_[15][16] = true;
+      types_[16][2] = true;
+      types_[16][3] = true;
+      types_[16][4] = true;
+      types_[16][15] = true;
+    
+      types_[9][10] = true;
+      types_[9][12] = true;
+      types_[9][13] = true;
+      types_[10][9] = true;
+      types_[10][12] = true;
+      types_[10][13] = true;
+      types_[12][9] = true;
+      types_[12][10] = true;
+      types_[12][13] = true;
+      types_[13][9] = true;
+      types_[13][10] = true;
+      types_[13][12] = true;
+    }
 
-    size_t fromCat = categories_[x];
-    size_t toCat   = categories_[y];
+    KrKcSubstitutionRegister* clone() const { return new KrKcSubstitutionRegister(*this); }
 
-    if (fromCat > 0 && toCat > 0)
-      return index_[fromCat - 1][toCat - 1];
-    else
-      return 0;
-  }
+  public:
+    size_t getNumberOfSubstitutionTypes() const { return 2; }
 
-  std::string getTypeName (size_t type) const
-  {
-    if (type == 0)
-    {
-      return "no AT<->GC substitution or non-synonymous substitution";
-    }
-    else if (type == 1)
-    {
-      return "AT->GC synonymous";
-    }
-    else if (type == 2)
+    size_t getType(size_t fromState, size_t toState) const
     {
-      return "GC->AT synonymous";
+      if (fromState == toState)
+        return 0;  // nothing happens
+      int x = model_->getAlphabetStateAsInt(fromState);
+      int y = model_->getAlphabetStateAsInt(toState);
+      return types_[static_cast<size_t>(x)][static_cast<size_t>(y)] ? 1 : 2;
     }
-    else
+
+    std::string getTypeName(size_t type) const
     {
-      throw Exception("GCSynonymousSubstitutionRegister::getTypeName. Bad substitution type.");
+      if (type == 0)
+      {
+        return "no substitution";
+      }
+      else if (type == 1)
+      {
+        return "conservative";
+      }
+      else if (type == 2)
+      {
+        return "radical";
+      }
+      else
+      {
+        throw Exception("KrKcSubstitutionRegister::getTypeName. Bad substitution type.");
+      }
     }
-  }
-};
+  };
+
+
+
 } // end of namespace bpp.
 
 #endif // _SUBSTITUTIONREGISTER_H_
diff --git a/src/Bpp/Phyl/Mapping/UniformizationSubstitutionCount.cpp b/src/Bpp/Phyl/Mapping/UniformizationSubstitutionCount.cpp
index bf31932..f62b0dc 100644
--- a/src/Bpp/Phyl/Mapping/UniformizationSubstitutionCount.cpp
+++ b/src/Bpp/Phyl/Mapping/UniformizationSubstitutionCount.cpp
@@ -163,7 +163,7 @@ void UniformizationSubstitutionCount::computeCounts_(double length) const
     for (size_t j = 0; j < nbStates_; j++) {
       for(size_t k = 0; k < nbStates_; k++) {
         counts_[i](j, k) /= P(j, k);
-        if (isnan(counts_[i](j, k)) || counts_[i](j, k) < 0.)
+        if (std::isnan(counts_[i](j, k)) || counts_[i](j, k) < 0.)
           counts_[i](j, k) = 0;
         //Weights:
         if (weights_)
@@ -228,7 +228,7 @@ void UniformizationSubstitutionCount::setSubstitutionModel(const SubstitutionMod
     throw Exception("UniformizationSubstitutionCount::setSubstitutionModel: alphabets do not match between register and model.");
 
   model_ = model;
-  unsigned int n = model->getAlphabet()->getSize();
+  size_t n = model->getNumberOfStates();
   if (n != nbStates_) {
     nbStates_ = n;
     //Re-initialize all B matrices according to substitution register.
@@ -237,14 +237,14 @@ void UniformizationSubstitutionCount::setSubstitutionModel(const SubstitutionMod
   fillBMatrices_();
   
   miu_ = 0;
-  for (unsigned int i = 0; i < nbStates_; ++i) {
+  for (size_t i = 0; i < nbStates_; ++i) {
     double diagQ = abs(model_->Qij(i, i));
     if (diagQ > miu_)
       miu_ = diagQ;
   }
 
-  if (miu_>10000)
-    throw Exception("UniformizationSubstitutionCount::setSubstitutionModel The maximum diagonal values of generator is above 10000. Abort, chose another mapping method.");
+  if (miu_ > 10000)
+    throw Exception("UniformizationSubstitutionCount::setSubstitutionModel(). The maximum diagonal values of generator is above 10000. Abort, chose another mapping method.");
 
   //Recompute counts:
   computeCounts_(currentLength_);
diff --git a/src/Bpp/Phyl/Mapping/UniformizationSubstitutionCount.h b/src/Bpp/Phyl/Mapping/UniformizationSubstitutionCount.h
index 0a6a50e..c41cf73 100644
--- a/src/Bpp/Phyl/Mapping/UniformizationSubstitutionCount.h
+++ b/src/Bpp/Phyl/Mapping/UniformizationSubstitutionCount.h
@@ -58,8 +58,8 @@ class UniformizationSubstitutionCount:
   public AbstractSubstitutionCount,
   public AbstractWeightedSubstitutionCount
 {
-	private:
-		const SubstitutionModel* model_;
+  private:
+    const SubstitutionModel* model_;
     size_t nbStates_;
     std::vector< RowMatrix<double> > bMatrices_;
     mutable std::vector< RowMatrix<double> > power_;
@@ -67,10 +67,10 @@ class UniformizationSubstitutionCount:
     double miu_;
     mutable std::vector< RowMatrix<double> > counts_;
     mutable double currentLength_;
-	
-	public:
-		UniformizationSubstitutionCount(const SubstitutionModel* model, SubstitutionRegister* reg, const AlphabetIndex2* weights = 0);
-		
+  
+  public:
+    UniformizationSubstitutionCount(const SubstitutionModel* model, SubstitutionRegister* reg, const AlphabetIndex2* weights = 0);
+    
     UniformizationSubstitutionCount(const UniformizationSubstitutionCount& usc) :
       AbstractSubstitutionCount(usc), 
       AbstractWeightedSubstitutionCount(usc),
@@ -82,7 +82,7 @@ class UniformizationSubstitutionCount:
       miu_(usc.miu_),
       counts_(usc.counts_),
       currentLength_(usc.currentLength_)
-    {}				
+    {}        
     
     UniformizationSubstitutionCount& operator=(const UniformizationSubstitutionCount& usc)
     {
@@ -97,10 +97,10 @@ class UniformizationSubstitutionCount:
       counts_         = usc.counts_;
       currentLength_  = usc.currentLength_;
       return *this;
-    }				
-		
+    }        
+    
     virtual ~UniformizationSubstitutionCount() {}
-		
+    
     UniformizationSubstitutionCount* clone() const { return new UniformizationSubstitutionCount(*this); }
 
 public:
diff --git a/src/Bpp/Phyl/Model/AbstractBiblioMixedSubstitutionModel.h b/src/Bpp/Phyl/Model/AbstractBiblioMixedSubstitutionModel.h
index a118063..79c4789 100644
--- a/src/Bpp/Phyl/Model/AbstractBiblioMixedSubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/AbstractBiblioMixedSubstitutionModel.h
@@ -63,9 +63,7 @@ public:
 
   virtual ~AbstractBiblioMixedSubstitutionModel();
 
-#ifndef NO_VIRTUAL_COV
   virtual AbstractBiblioMixedSubstitutionModel* clone() const = 0;
-#endif
 
 public:
   virtual const MixedSubstitutionModel& getMixedModel() const = 0;
@@ -157,6 +155,18 @@ public:
     return getMixedModel().getNRate(i);
   }
 
+  /**
+   * @brief retrieve a pointer to the submodel with the given name.
+   *
+   * Return Null if not found.
+   *
+   */
+  
+  const SubstitutionModel* getSubModelWithName(const std::string& name) const
+  {
+    return getMixedModel().getSubModelWithName(name);
+  }
+  
   /*
      *@brief Returns the vector of numbers of the submodels in the
      *mixture that match a description.
diff --git a/src/Bpp/Phyl/Model/AbstractBiblioSubstitutionModel.cpp b/src/Bpp/Phyl/Model/AbstractBiblioSubstitutionModel.cpp
index 090d054..00bad09 100644
--- a/src/Bpp/Phyl/Model/AbstractBiblioSubstitutionModel.cpp
+++ b/src/Bpp/Phyl/Model/AbstractBiblioSubstitutionModel.cpp
@@ -65,6 +65,18 @@ AbstractBiblioSubstitutionModel& AbstractBiblioSubstitutionModel::operator=(cons
   return *this;
 }
 
+
+/******************************************************************************/
+
+std::string AbstractBiblioSubstitutionModel::getParNameFromPmodel(const std::string& name) const
+{
+  auto it = mapParNamesFromPmodel_.find(name);
+  if (it==mapParNamesFromPmodel_.end())
+    throw Exception("AbstractBiblioSubstitutionModel::getParNameFromPmodel : unknown parameter " + name);
+  return it->second;
+}
+    
+
 /******************************************************************************/
 
 void AbstractBiblioSubstitutionModel::updateMatrices()
@@ -75,7 +87,7 @@ void AbstractBiblioSubstitutionModel::updateMatrices()
       lParPmodel_[i].setValue(getParameter(getParameterNameWithoutNamespace(mapParNamesFromPmodel_[lParPmodel_[i].getName()])).getValue());
     }
   }
-
+  
   getModel().matchParametersValues(lParPmodel_);
 }
 
@@ -92,13 +104,33 @@ void AbstractBiblioSubstitutionModel::addRateParameter()
 
 /******************************************************************************/
 
+void AbstractBiblioSubstitutionModel::setNamespace(const std::string& name)
+{
+  AbstractParameterAliasable::setNamespace(name);
+
+  std::map<std::string, std::string> mapParNamesFromPmodel_new;
+
+  for (auto it=mapParNamesFromPmodel_.begin(); it!=mapParNamesFromPmodel_.end(); it++)
+    mapParNamesFromPmodel_new[name+getModel().getParameterNameWithoutNamespace(it->first)]=it->second;
+  
+  mapParNamesFromPmodel_.clear();
+  mapParNamesFromPmodel_=mapParNamesFromPmodel_new;
+
+  getModel().setNamespace(name);
+
+  lParPmodel_.reset();
+  lParPmodel_.addParameters(getModel().getParameters());
+}
+
+
+/******************************************************************************/
+
 void AbstractBiblioSubstitutionModel::setFreq(std::map<int, double>& m)
 {
   getModel().setFreq(m);
 
-  map<string, string>::iterator it;
   ParameterList pl;
-  for (it = mapParNamesFromPmodel_.begin(); it != mapParNamesFromPmodel_.end(); it++)
+  for (auto it = mapParNamesFromPmodel_.begin(); it != mapParNamesFromPmodel_.end(); it++)
   {
     pl.addParameter(Parameter(getNamespace() + it->second, getModel().getParameterValue(getModel().getParameterNameWithoutNamespace(it->first))));
   }
@@ -110,9 +142,8 @@ void AbstractBiblioSubstitutionModel::setFreq(std::map<int, double>& m)
 void AbstractBiblioSubstitutionModel::setFreqFromData(const SequenceContainer& data, double pseudoCount)
 {
   getModel().setFreqFromData(data, pseudoCount);
-  map<string, string>::iterator it;
   ParameterList pl;
-  for (it = mapParNamesFromPmodel_.begin(); it != mapParNamesFromPmodel_.end(); it++)
+  for (auto it = mapParNamesFromPmodel_.begin(); it != mapParNamesFromPmodel_.end(); it++)
   {
     pl.addParameter(Parameter(getNamespace() + it->second, getModel().getParameterValue(getModel().getParameterNameWithoutNamespace(it->first))));
   }
diff --git a/src/Bpp/Phyl/Model/AbstractBiblioSubstitutionModel.h b/src/Bpp/Phyl/Model/AbstractBiblioSubstitutionModel.h
index 64ca8fd..f2d1095 100644
--- a/src/Bpp/Phyl/Model/AbstractBiblioSubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/AbstractBiblioSubstitutionModel.h
@@ -5,43 +5,42 @@
 //
 
 /*
-   Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
-
-   This software is a computer program whose purpose is to provide classes
-   for phylogenetic data analysis.
-
-   This software is governed by the CeCILL  license under French law and
-   abiding by the rules of distribution of free software.  You can  use,
-   modify and/ or redistribute the software under the terms of the CeCILL
-   license as circulated by CEA, CNRS and INRIA at the following URL
-   "http://www.cecill.info".
-
-   As a counterpart to the access to the source code and  rights to copy,
-   modify and redistribute granted by the license, users are provided only
-   with a limited warranty  and the software's author,  the holder of the
-   economic rights,  and the successive licensors  have only  limited
-   liability.
-
-   In this respect, the user's attention is drawn to the risks associated
-   with loading,  using,  modifying and/or developing or reproducing the
-   software by the user in light of its specific status of free software,
-   that may mean  that it is complicated to manipulate,  and  that  also
-   therefore means  that it is reserved for developers  and  experienced
-   professionals having in-depth computer knowledge. Users are therefore
-   encouraged to load and test the software's suitability as regards their
-   requirements in conditions enabling the security of their systems and/or
-   data to be ensured and,  more generally, to use and operate it in the
-   same conditions as regards security.
-
-   The fact that you are presently reading this means that you have had
-   knowledge of the CeCILL license and that you accept its terms.
- */
+  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
+
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use,
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info".
+
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability.
+
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or
+  data to be ensured and,  more generally, to use and operate it in the
+  same conditions as regards security.
+
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
+*/
 
 #ifndef _ABSTRACTBIBLIOSUBSTITUTIONMODEL_H_
 #define _ABSTRACTBIBLIOSUBSTITUTIONMODEL_H_
 
 #include "SubstitutionModel.h"
-#include "AbstractSubstitutionModel.h"
 
 #include <Bpp/Numeric/AbstractParameterAliasable.h>
 
@@ -54,147 +53,181 @@ namespace bpp
  *
  */
 
-class AbstractBiblioSubstitutionModel :
-  public virtual SubstitutionModel,
-  public AbstractParameterAliasable
-{
-protected:
-  /**
-   * @brief Tools to make the link between the Parameters of the
-   * object and those of pmixmodel_.
-   *
-   */
+  class AbstractBiblioSubstitutionModel :
+    public virtual SubstitutionModel,
+    public AbstractParameterAliasable
+  {
+  protected:
+    /**
+     * @brief Tools to make the link between the Parameters of the
+     * object and those of pmixmodel_.
+     *
+     */
 
-  std::map<std::string, std::string> mapParNamesFromPmodel_;
+    std::map<std::string, std::string> mapParNamesFromPmodel_;
 
-  ParameterList lParPmodel_;
+    ParameterList lParPmodel_;
 
-public:
-  AbstractBiblioSubstitutionModel(const std::string& prefix);
+  public:
+    AbstractBiblioSubstitutionModel(const std::string& prefix);
 
-  AbstractBiblioSubstitutionModel(const AbstractBiblioSubstitutionModel& model);
+    AbstractBiblioSubstitutionModel(const AbstractBiblioSubstitutionModel& model);
 
-  AbstractBiblioSubstitutionModel& operator=(const AbstractBiblioSubstitutionModel& model);
+    AbstractBiblioSubstitutionModel& operator=(const AbstractBiblioSubstitutionModel& model);
 
-  virtual ~AbstractBiblioSubstitutionModel() {}
+    virtual ~AbstractBiblioSubstitutionModel() {}
 
-#ifndef NO_VIRTUAL_COV
-  virtual AbstractBiblioSubstitutionModel* clone() const = 0;
-#endif
+    virtual AbstractBiblioSubstitutionModel* clone() const = 0;
 
-public:
-  virtual const SubstitutionModel& getModel() const = 0;
+  public:
+    virtual const SubstitutionModel& getModel() const = 0;
 
-  /*
+  protected:
+    virtual void updateMatrices();
+
+    virtual SubstitutionModel& getModel() = 0;
+    
+  public:
+
+    
+    /*
+     * @brief get the name of a parameter from its name in a submodel
+     *
+     * @var name the name of the parameter in the submodel
+     *
+     */
+    
+    std::string getParNameFromPmodel(const std::string& name) const;
+    
+    /*
      *@ brief Methods to supersede SubstitutionModel methods.
-   *
-   * @{
-   */
+     *
+     * @{
+     */
 
-  const std::vector<int>& getAlphabetStates() const { return getModel().getAlphabetStates(); }
+    const std::vector<int>& getAlphabetStates() const { return getModel().getAlphabetStates(); }
 
-  const StateMap& getStateMap() const { return getModel().getStateMap(); }
+    const StateMap& getStateMap() const { return getModel().getStateMap(); }
 
-  int getAlphabetStateAsInt(size_t i) const { return getModel().getAlphabetStateAsInt(i); }
+    int getAlphabetStateAsInt(size_t i) const { return getModel().getAlphabetStateAsInt(i); }
   
-  std::string getAlphabetStateAsChar(size_t i) const { return getModel().getAlphabetStateAsChar(i); }
+    std::string getAlphabetStateAsChar(size_t i) const { return getModel().getAlphabetStateAsChar(i); }
 
-  std::vector<size_t> getModelStates(int code) const { return getModel().getModelStates(code); }
+    std::vector<size_t> getModelStates(int code) const { return getModel().getModelStates(code); }
   
-  std::vector<size_t> getModelStates(const std::string& code) const { return getModel().getModelStates(code); }
+    std::vector<size_t> getModelStates(const std::string& code) const { return getModel().getModelStates(code); }
 
-  virtual double freq(size_t i) const { return getModel().freq(i); }
+    virtual double freq(size_t i) const { return getModel().freq(i); }
 
-  virtual double Qij(size_t i, size_t j) const { return getModel().Qij(i, j); }
+    virtual double Qij(size_t i, size_t j) const { return getModel().Qij(i, j); }
 
-  virtual double Pij_t    (size_t i, size_t j, double t) const { return getModel().Pij_t(i, j, t); }
-  virtual double dPij_dt  (size_t i, size_t j, double t) const { return getModel().dPij_dt (i, j, t); }
-  virtual double d2Pij_dt2(size_t i, size_t j, double t) const { return getModel().d2Pij_dt2(i, j, t); }
+    virtual double Pij_t    (size_t i, size_t j, double t) const { return getModel().Pij_t(i, j, t); }
+    virtual double dPij_dt  (size_t i, size_t j, double t) const { return getModel().dPij_dt (i, j, t); }
+    virtual double d2Pij_dt2(size_t i, size_t j, double t) const { return getModel().d2Pij_dt2(i, j, t); }
 
-  virtual const Vdouble& getFrequencies() const { return getModel().getFrequencies(); }
+    virtual const Vdouble& getFrequencies() const { return getModel().getFrequencies(); }
 
-  const Matrix<double>& getGenerator() const { return getModel().getGenerator(); }
+    const Matrix<double>& getGenerator() const { return getModel().getGenerator(); }
 
-  const Matrix<double>& getExchangeabilityMatrix() const { return getModel().getExchangeabilityMatrix(); }
+    const Matrix<double>& getExchangeabilityMatrix() const { return getModel().getExchangeabilityMatrix(); }
 
-  double Sij(size_t i, size_t j) const { return getModel().Sij(i, j); }
+    double Sij(size_t i, size_t j) const { return getModel().Sij(i, j); }
 
-  const Matrix<double>& getPij_t(double t) const { return getModel().getPij_t(t); }
+    const Matrix<double>& getPij_t(double t) const { return getModel().getPij_t(t); }
 
-  const Matrix<double>& getdPij_dt(double t) const { return getModel().getdPij_dt(t); }
+    const Matrix<double>& getdPij_dt(double t) const { return getModel().getdPij_dt(t); }
 
-  const Matrix<double>& getd2Pij_dt2(double t) const { return getModel().getd2Pij_dt2(t); }
+    const Matrix<double>& getd2Pij_dt2(double t) const { return getModel().getd2Pij_dt2(t); }
 
-  void enableEigenDecomposition(bool yn) { getModel().enableEigenDecomposition(yn); }
+    void enableEigenDecomposition(bool yn) { getModel().enableEigenDecomposition(yn); }
 
-  bool enableEigenDecomposition() { return getModel().enableEigenDecomposition(); }
+    bool enableEigenDecomposition() { return getModel().enableEigenDecomposition(); }
 
-  bool isDiagonalizable() const { return getModel().isDiagonalizable(); }
+    bool isDiagonalizable() const { return getModel().isDiagonalizable(); }
 
-  bool isNonSingular() const { return getModel().isNonSingular(); }
+    bool isNonSingular() const { return getModel().isNonSingular(); }
 
-  const Vdouble& getEigenValues() const { return getModel().getEigenValues(); }
+    const Vdouble& getEigenValues() const { return getModel().getEigenValues(); }
 
-  const Vdouble& getIEigenValues() const { return getModel().getIEigenValues(); }
+    const Vdouble& getIEigenValues() const { return getModel().getIEigenValues(); }
 
-  const Matrix<double>& getRowLeftEigenVectors() const { return getModel().getRowLeftEigenVectors(); }
-  const Matrix<double>& getColumnRightEigenVectors() const { return getModel().getColumnRightEigenVectors(); }
+    const Matrix<double>& getRowLeftEigenVectors() const { return getModel().getRowLeftEigenVectors(); }
+    const Matrix<double>& getColumnRightEigenVectors() const { return getModel().getColumnRightEigenVectors(); }
 
-  double getRate() const { return getModel().getRate(); }
+    double getRate() const { return getModel().getRate(); }
 
-  void setRate(double rate) { return getModel().setRate(rate); }
+    void setRate(double rate) { return getModel().setRate(rate); }
 
-  void addRateParameter();
+    void addRateParameter();
 
-  void setFreqFromData(const SequenceContainer& data, double pseudoCount = 0);
+    void setFreqFromData(const SequenceContainer& data, double pseudoCount = 0);
 
-  void setFreq(std::map<int, double>& frequ);
+    void setFreq(std::map<int, double>& frequ);
 
-  const Alphabet* getAlphabet() const { return getModel().getAlphabet(); }
+    const Alphabet* getAlphabet() const { return getModel().getAlphabet(); }
 
-  size_t getNumberOfStates() const { return getModel().getNumberOfStates(); }
+    size_t getNumberOfStates() const { return getModel().getNumberOfStates(); }
 
-  double getInitValue(size_t i, int state) const throw (BadIntException) { return getModel().getInitValue(i, state); }
+    double getInitValue(size_t i, int state) const throw (BadIntException) { return getModel().getInitValue(i, state); }
 
-  const FrequenciesSet* getFrequenciesSet() const {return getModel().getFrequenciesSet(); }
+    const FrequenciesSet* getFrequenciesSet() const {return getModel().getFrequenciesSet(); }
 
-  /*
-   * @}
-   *
-   */
+    /*
+     * @}
+     *
+     */
 
-  /*
+    /*
      *@ brief Methods to supersede AbstractSubstitutionModel methods.
-   *
-   * @{
-   */
-
-  /**
-   * @brief Tells the model that a parameter value has changed.
-   *
-   * This updates the matrices consequently.
-   */
-  virtual void fireParameterChanged(const ParameterList& parameters)
-  {
-    AbstractParameterAliasable::fireParameterChanged(parameters);
-    if (parameters.size() > 1 || (parameters.size() == 1 && parameters[0].getName() != getNamespace() + "rate")) {
-      updateMatrices();
+     *
+     * @{
+     */
+
+    /**
+     * @brief Tells the model that a parameter value has changed.
+     *
+     * This updates the matrices consequently.
+     */
+    virtual void fireParameterChanged(const ParameterList& parameters)
+    {
+      AbstractParameterAliasable::fireParameterChanged(parameters);
+    
+      if (parameters.hasParameter(getNamespace()+"rate"))
+      {
+        getModel().setRate(parameters.getParameterValue(getNamespace()+"rate"));
+        if (parameters.size()!=1)
+          updateMatrices();
+      }
+      else
+        updateMatrices();      
     }
-  }
 
-protected:
-  virtual void updateMatrices();
-  virtual SubstitutionModel& getModel() = 0;
+    void setNamespace(const std::string& name);
+  
+  public:
+    bool isScalable() const 
+    {
+      return getModel().isScalable();
+    }
 
-public:
-  double getScale() const { return getModel().getScale(); }
+    void setScalable(bool scalable)
+    {
+      getModel().setScalable(scalable);
+    }
+
+    void normalize()
+    {
+      getModel().normalize();
+    }
+    
+    double getScale() const { return getModel().getScale(); }
 
-  void setScale(double scale) { getModel().setScale(scale); }
+    void setScale(double scale) { getModel().setScale(scale); }
 
-  /*
-   * @}
-   */
-};
+    /*
+     * @}
+     */
+  };
 } // end of namespace bpp.
 
 
diff --git a/src/Bpp/Phyl/Model/Codon/CodonRateSubstitutionModel.cpp b/src/Bpp/Phyl/Model/AbstractFromSubstitutionModelTransitionModel.cpp
similarity index 52%
copy from src/Bpp/Phyl/Model/Codon/CodonRateSubstitutionModel.cpp
copy to src/Bpp/Phyl/Model/AbstractFromSubstitutionModelTransitionModel.cpp
index 13dba94..6523a56 100644
--- a/src/Bpp/Phyl/Model/Codon/CodonRateSubstitutionModel.cpp
+++ b/src/Bpp/Phyl/Model/AbstractFromSubstitutionModelTransitionModel.cpp
@@ -1,11 +1,12 @@
 //
-// File: CodonSubstitutionModel.cpp
-// Created by:  Laurent Gueguen
-// Created on: Feb 2009
+// File: AbstractFromSubstitutionModelTransitionModel.cpp
+// Created by: Laurent Gueguen
+// Created on: samedi 24 octobre 2015, � 18h 50
 //
 
 /*
-   Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+   Copyright or � or Copr. Bio++ Development Team, (November 16, 2004)
+
    This software is a computer program whose purpose is to provide classes
    for phylogenetic data analysis.
 
@@ -36,47 +37,51 @@
    knowledge of the CeCILL license and that you accept its terms.
  */
 
-#include "CodonRateSubstitutionModel.h"
-
+#include "AbstractFromSubstitutionModelTransitionModel.h"
 
 using namespace bpp;
-
 using namespace std;
 
 /******************************************************************************/
 
-CodonRateSubstitutionModel::CodonRateSubstitutionModel(
-    const GeneticCode* gCode,
-    NucleotideSubstitutionModel* pmod) :
-  AbstractParameterAliasable("CodonRate."),
-  AbstractCodonSubstitutionModel(gCode, pmod, "CodonRate.", true)
+AbstractFromSubstitutionModelTransitionModel::AbstractFromSubstitutionModelTransitionModel(const SubstitutionModel& subModel) :
+  AbstractParameterAliasable(subModel.getName()),
+  subModel_(std::unique_ptr<SubstitutionModel>(subModel.clone())),
+  size_(subModel.getNumberOfStates()),
+  pij_t(size_, size_),
+  dpij_t(size_, size_),
+  d2pij_t(size_, size_)
 {
-  updateMatrices();
+  subModel_->setNamespace(getName());
+  addParameters_(subModel_->getParameters());
 }
 
-CodonRateSubstitutionModel::CodonRateSubstitutionModel(
-    const GeneticCode* gCode,
-    NucleotideSubstitutionModel* pmod1,
-    NucleotideSubstitutionModel* pmod2,
-    NucleotideSubstitutionModel* pmod3) :
-  AbstractParameterAliasable("CodonRate."),
-  AbstractCodonSubstitutionModel(gCode, pmod1, pmod2, pmod3, "CodonRate.", true)
-{
-  updateMatrices();
-}
 
-std::string CodonRateSubstitutionModel::getName() const
-{
-  return "CodonRate";
-}
+/******************************************************************************/
+
+AbstractFromSubstitutionModelTransitionModel::AbstractFromSubstitutionModelTransitionModel(const AbstractFromSubstitutionModelTransitionModel& fmsm) :
+  AbstractParameterAliasable(fmsm),
+  subModel_(fmsm.subModel_->clone()),
+  size_(fmsm.size_),
+  pij_t(fmsm.pij_t),
+  dpij_t(fmsm.dpij_t),
+  d2pij_t(fmsm.d2pij_t)
+{}
 
-void CodonRateSubstitutionModel::fireParameterChanged(const ParameterList& parameters)
-{
-  AbstractCodonSubstitutionModel::fireParameterChanged(parameters);
-}
 
-double CodonRateSubstitutionModel::getCodonsMulRate(size_t i, size_t j) const
+/******************************************************************************/
+
+AbstractFromSubstitutionModelTransitionModel& AbstractFromSubstitutionModelTransitionModel::operator=(const AbstractFromSubstitutionModelTransitionModel& fmsm)
 {
-  return AbstractCodonSubstitutionModel::getCodonsMulRate(i,j);
+  AbstractParameterAliasable::operator=(fmsm);
+
+  subModel_ = std::unique_ptr<SubstitutionModel>(fmsm.subModel_->clone());
+  size_ = fmsm.size_;
+  pij_t = fmsm.pij_t;
+  dpij_t = fmsm.dpij_t;
+  d2pij_t = fmsm.d2pij_t;
+  
+  return *this;
 }
 
+
diff --git a/src/Bpp/Phyl/Model/AbstractFromSubstitutionModelTransitionModel.h b/src/Bpp/Phyl/Model/AbstractFromSubstitutionModelTransitionModel.h
new file mode 100644
index 0000000..33dc2b8
--- /dev/null
+++ b/src/Bpp/Phyl/Model/AbstractFromSubstitutionModelTransitionModel.h
@@ -0,0 +1,201 @@
+//
+// File: AbstractFromModelTransitionModel.h
+// Created by: Laurent Gueguen
+// Created on: lundi 24 avril 2017, � 22h 55
+//
+
+/*
+   Copyright or � or Copr. Bio++ Development Team, (November 16, 2004)
+
+   This software is a computer program whose purpose is to provide classes
+   for phylogenetic data analysis.
+
+   This software is governed by the CeCILL  license under French law and
+   abiding by the rules of distribution of free software.  You can  use,
+   modify and/ or redistribute the software under the terms of the CeCILL
+   license as circulated by CEA, CNRS and INRIA at the following URL
+   "http://www.cecill.info".
+
+   As a counterpart to the access to the source code and  rights to copy,
+   modify and redistribute granted by the license, users are provided only
+   with a limited warranty  and the software's author,  the holder of the
+   economic rights,  and the successive licensors  have only  limited
+   liability.
+
+   In this respect, the user's attention is drawn to the risks associated
+   with loading,  using,  modifying and/or developing or reproducing the
+   software by the user in light of its specific status of free software,
+   that may mean  that it is complicated to manipulate,  and  that  also
+   therefore means  that it is reserved for developers  and  experienced
+   professionals having in-depth computer knowledge. Users are therefore
+   encouraged to load and test the software's suitability as regards their
+   requirements in conditions enabling the security of their systems and/or
+   data to be ensured and,  more generally, to use and operate it in the
+   same conditions as regards security.
+
+   The fact that you are presently reading this means that you have had
+   knowledge of the CeCILL license and that you accept its terms.
+ */
+
+#ifndef _ABSTRACT_FROM_SUBSTITUTION_MODEL_TRANSITION_MODEL_H_
+#define _ABSTRACT_FROM_SUBSTITUTION_MODEL_TRANSITION_MODEL_H_
+
+#include "SubstitutionModel.h"
+
+namespace bpp
+{
+/**
+ * @brief Virtual class of a Transition Model related to a given
+ * SubstitutionModel.
+ *
+ * It has the same parameters as the SubModel.
+ */
+
+  class AbstractFromSubstitutionModelTransitionModel :
+    public virtual TransitionModel,
+    public AbstractParameterAliasable
+  {
+  protected:
+    /*
+     * @brief The related model.
+     *
+     */
+    
+    std::unique_ptr<SubstitutionModel> subModel_;
+
+    /*
+     * The number of states
+     *
+     */
+    
+     size_t size_;
+
+    /**
+     * @brief These ones are for bookkeeping:
+     */
+    mutable RowMatrix<double> pij_t;
+    mutable RowMatrix<double> dpij_t;
+    mutable RowMatrix<double> d2pij_t;
+
+  public:
+    AbstractFromSubstitutionModelTransitionModel(const SubstitutionModel& subModel);
+
+    AbstractFromSubstitutionModelTransitionModel(const AbstractFromSubstitutionModelTransitionModel& fmsm);
+
+    AbstractFromSubstitutionModelTransitionModel& operator=(const AbstractFromSubstitutionModelTransitionModel& fmsm);
+    
+    virtual ~AbstractFromSubstitutionModelTransitionModel() {};
+    
+    virtual AbstractFromSubstitutionModelTransitionModel* clone() const = 0;
+    
+  public:
+    const SubstitutionModel& getModel() const
+    {
+      return *subModel_.get();
+    }
+
+  protected:
+    SubstitutionModel& getModel()
+    {
+      return *subModel_.get();
+    }
+    
+  public:
+    /*
+     *@ brief Methods to supersede SubstitutionModel methods.
+     *
+     * @{
+     */
+
+    const Alphabet* getAlphabet() const { return getModel().getAlphabet(); }
+
+    size_t getNumberOfStates() const { return getModel().getNumberOfStates(); }
+
+    const std::vector<int>& getAlphabetStates() const { return getModel().getAlphabetStates(); }
+
+    const StateMap& getStateMap() const { return getModel().getStateMap(); }
+
+    int getAlphabetStateAsInt(size_t i) const { return getModel().getAlphabetStateAsInt(i); }
+
+    std::string getAlphabetStateAsChar(size_t i) const { return getModel().getAlphabetStateAsChar(i); }
+
+    std::vector<size_t> getModelStates(int code) const { return getModel().getModelStates(code); }
+
+    std::vector<size_t> getModelStates(const std::string& code) const { return getModel().getModelStates(code); }
+
+    virtual double freq(size_t i) const = 0;
+
+    virtual double Pij_t (size_t i, size_t j, double t) const = 0;
+    
+    virtual double dPij_dt (size_t i, size_t j, double t) const = 0;
+    
+    virtual double d2Pij_dt2(size_t i, size_t j, double t) const = 0;
+
+    virtual const Vdouble& getFrequencies() const = 0;
+
+    virtual const Matrix<double>& getPij_t(double t) const = 0;
+
+    virtual const Matrix<double>& getdPij_dt(double t) const = 0;
+
+    virtual const Matrix<double>& getd2Pij_dt2(double t) const = 0;
+
+    double getRate() const { return getModel().getRate(); }
+
+    void setRate(double rate) { return getModel().setRate(rate); }
+
+    void addRateParameter()
+    {
+      getModel().addRateParameter();
+      addParameter_(new Parameter(getNamespace() + "rate", getModel().getRate(), &Parameter::R_PLUS_STAR));
+    }
+
+    void setFreqFromData(const SequenceContainer& data, double pseudoCount = 0){getModel().setFreqFromData(data, pseudoCount); }
+
+    void setFreq(std::map<int, double>& frequ) {getModel().setFreq(frequ); }
+
+    double getInitValue(size_t i, int state) const throw (BadIntException) { return getModel().getInitValue(i, state); }
+
+    virtual const FrequenciesSet* getFrequenciesSet() const = 0;
+
+    /*
+     * @}
+     *
+     */
+
+    /*
+     *@ brief Methods to supersede AbstractSubstitutionModel methods.
+     *
+     * @{
+     */
+
+    /**
+     * @brief Tells the model that a parameter value has changed.
+     *
+     * This updates the matrices consequently.
+     */
+    
+    virtual void fireParameterChanged(const ParameterList& parameters)
+    {
+      AbstractParameterAliasable::fireParameterChanged(parameters);
+      getModel().matchParametersValues(parameters);
+    }
+
+    virtual void setNamespace(const std::string& name)
+    {
+      AbstractParameterAliasable::setNamespace(name);
+      getModel().setNamespace(name);
+    }
+
+    /*
+     * @}
+     */
+
+    virtual std::string getName() const
+    {
+      return getModel().getName();
+    }
+    
+  };
+} // end of namespace bpp.
+
+#endif  // _ABSTRACT_FROM_SUBSTITUTION_MODEL_TRANSITION_MODEL_H_
diff --git a/src/Bpp/Phyl/Model/AbstractKroneckerWordSubstitutionModel.cpp b/src/Bpp/Phyl/Model/AbstractKroneckerWordSubstitutionModel.cpp
new file mode 100644
index 0000000..989174f
--- /dev/null
+++ b/src/Bpp/Phyl/Model/AbstractKroneckerWordSubstitutionModel.cpp
@@ -0,0 +1,253 @@
+//
+// File: AbstractKroneckerWordSubstitutionModel.cpp
+// Created by:  Laurent Gueguen
+// Created on: mardi 26 juillet 2016, à 10h 56
+//
+
+/*
+  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
+
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use,
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info".
+
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability.
+
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or
+  data to be ensured and,  more generally, to use and operate it in the
+  same conditions as regards security.
+
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
+*/
+
+#include "AbstractKroneckerWordSubstitutionModel.h"
+
+#include <Bpp/Numeric/Matrix/MatrixTools.h>
+#include <Bpp/Numeric/VectorTools.h>
+
+using namespace bpp;
+
+using namespace std;
+
+/******************************************************************************/
+
+AbstractKroneckerWordSubstitutionModel::AbstractKroneckerWordSubstitutionModel(
+  ModelList& modelList,
+  const std::string& prefix) :
+  AbstractParameterAliasable(prefix),
+  AbstractWordSubstitutionModel(modelList, prefix),
+  sChangingPos_(),
+  vGenerators_()
+{
+  enableEigenDecomposition(true);
+  initGenerators_();
+}
+
+AbstractKroneckerWordSubstitutionModel::AbstractKroneckerWordSubstitutionModel(
+  ModelList& modelList,
+  const std::vector<std::set<size_t> >& vPos,
+  const std::string& prefix) :
+  AbstractParameterAliasable(prefix),
+  AbstractWordSubstitutionModel(modelList, prefix),
+  sChangingPos_(vPos),
+  vGenerators_()
+{
+  if (!checkChangingPositions_())
+    throw Exception("AbstractKroneckerWordSubstitutionModel::AbstractKroneckerWordSubstitutionModel: Bad set of changing positions ");
+
+  enableEigenDecomposition(true);
+  initGenerators_();
+}
+
+AbstractKroneckerWordSubstitutionModel::AbstractKroneckerWordSubstitutionModel(
+  SubstitutionModel* pmodel,
+  unsigned int num,
+  const std::string& prefix) :
+  AbstractParameterAliasable(prefix),
+  AbstractWordSubstitutionModel(pmodel, num, prefix),
+  sChangingPos_(),
+  vGenerators_()
+{
+  enableEigenDecomposition(true);
+  initGenerators_();  
+}
+
+AbstractKroneckerWordSubstitutionModel::AbstractKroneckerWordSubstitutionModel(
+  SubstitutionModel* pmodel,
+  unsigned int num,
+  const std::vector<std::set<size_t> >& vPos,
+  const std::string& prefix) :
+  AbstractParameterAliasable(prefix),
+  AbstractWordSubstitutionModel(pmodel, num, prefix),
+  sChangingPos_(vPos),
+  vGenerators_()
+{
+  if (!checkChangingPositions_())
+    throw Exception("AbstractKroneckerWordSubstitutionModel::AbstractKroneckerWordSubstitutionModel: Bad set of changing positions ");
+
+  enableEigenDecomposition(true);
+  initGenerators_();
+}
+
+AbstractKroneckerWordSubstitutionModel::AbstractKroneckerWordSubstitutionModel(
+  const Alphabet* alph,
+  StateMap* stateMap,
+  const std::string& prefix) :
+  AbstractParameterAliasable(prefix),
+  AbstractWordSubstitutionModel(alph, stateMap, prefix),
+  sChangingPos_(),
+  vGenerators_()
+{
+  enableEigenDecomposition(true);
+}
+
+AbstractKroneckerWordSubstitutionModel::AbstractKroneckerWordSubstitutionModel(
+  const AbstractKroneckerWordSubstitutionModel& wrsm) :
+  AbstractParameterAliasable(wrsm),
+  AbstractWordSubstitutionModel(wrsm),
+  sChangingPos_(wrsm.sChangingPos_),
+  vGenerators_(wrsm.vGenerators_)
+{
+  initGenerators_();
+}
+
+
+AbstractKroneckerWordSubstitutionModel& AbstractKroneckerWordSubstitutionModel::operator=(
+  const AbstractKroneckerWordSubstitutionModel& model)
+{
+  AbstractParameterAliasable::operator=(model);
+  AbstractWordSubstitutionModel::operator=(model);
+  sChangingPos_ = model.sChangingPos_;
+  vGenerators_ = model.vGenerators_;
+    
+  return *this;
+}
+
+
+void AbstractKroneckerWordSubstitutionModel::setChangingPositions(const std::vector<std::set<size_t> >& vPos)
+{
+  sChangingPos_=vPos;
+
+  if (!checkChangingPositions_())
+    throw Exception("AbstractKroneckerWordSubstitutionModel::setChangingPositions: Bad set of changing positions ");
+}
+
+
+void AbstractKroneckerWordSubstitutionModel::initGenerators_()
+{
+  vGenerators_.clear();
+  
+  size_t nbmod = VSubMod_.size();
+
+  size_t size = 1;
+    
+  for (size_t k = 0; k < nbmod; k++)
+  {
+    size *= VSubMod_[k]->getNumberOfStates();
+    vGenerators_.push_back(RowMatrix<double>(size,size));
+  }
+}
+
+bool AbstractKroneckerWordSubstitutionModel::checkChangingPositions_()
+{
+  size_t nbmod = VSubMod_.size();
+  
+  for (auto i=sChangingPos_.begin(); i!=sChangingPos_.end(); i++)
+  {
+    if (*(--((*i).end()))>nbmod || *((*i).begin())==0)
+      return false;
+  }
+  
+  return true;
+}
+
+void AbstractKroneckerWordSubstitutionModel::fillBasicGenerator()
+{
+  size_t nbmod = VSubMod_.size();
+
+// Generator
+
+  if (sChangingPos_.size()==0)
+  {
+    vGenerators_[0]=VSubMod_[0]->getGenerator();
+
+    for (size_t k = 1; k < nbmod-1; k++)
+      MatrixTools::kroneckerMult(vGenerators_[k-1], VSubMod_[k]->getGenerator(), 1., 1., vGenerators_[k], false);
+
+    MatrixTools::kroneckerMult(vGenerators_[nbmod-2], VSubMod_[nbmod-1]->getGenerator(), 1., 1., generator_, false);
+
+  }
+  else
+  {
+    for (auto i=sChangingPos_.begin(); i!=sChangingPos_.end(); i++)
+    {
+      const set<size_t>& sPos=(*i);
+
+      size_t pos=0;
+
+      for (auto iPos=sPos.begin(); iPos!=sPos.end(); iPos++)
+      {
+        size_t posok=(*iPos)-1; // position of the next generator to multiply
+
+        if (pos==0)
+        {
+          size_t ss= 1;
+          while (pos<posok)
+          {
+            ss *= VSubMod_[pos]->getNumberOfStates();
+            pos++;
+          }
+          if (ss!=1)
+          {
+            MatrixTools::getId(ss, vGenerators_[posok-1]);          
+            MatrixTools::kroneckerMult(vGenerators_[posok-1], VSubMod_[posok]->getGenerator(), 1., 0., vGenerators_[posok], false);
+          }
+          else
+            vGenerators_[posok]=VSubMod_[0]->getGenerator();
+          
+          MatrixTools::fillDiag(vGenerators_[posok],0.);
+        }
+        else
+        {
+          while (pos<posok)
+          {
+            MatrixTools::kroneckerMult(vGenerators_[pos-1], VSubMod_[pos]->getNumberOfStates(), 1., vGenerators_[pos], false);
+            pos++;
+          }
+          MatrixTools::kroneckerMult(vGenerators_[posok-1], VSubMod_[posok]->getGenerator(), 0., 0., vGenerators_[posok], false);
+        }
+        
+        pos++;
+      }
+
+      while (pos<nbmod)
+      {
+        MatrixTools::kroneckerMult(vGenerators_[pos-1], VSubMod_[pos]->getNumberOfStates(), 1., vGenerators_[pos], false);
+        pos++;
+      }
+
+      if (i==sChangingPos_.begin())
+        generator_=vGenerators_[nbmod-1];
+      else
+        MatrixTools::add(generator_, vGenerators_[nbmod-1]);
+    }
+    
+  }
+}
+
diff --git a/src/Bpp/Phyl/Model/AbstractKroneckerWordSubstitutionModel.h b/src/Bpp/Phyl/Model/AbstractKroneckerWordSubstitutionModel.h
new file mode 100644
index 0000000..c100483
--- /dev/null
+++ b/src/Bpp/Phyl/Model/AbstractKroneckerWordSubstitutionModel.h
@@ -0,0 +1,218 @@
+//
+// File: AbstractKroneckerWordSubstitutionModel.h
+// Created by: Laurent Guéguen
+// Created on: lundi 25 juillet 2016, à 17h 00
+//
+
+/*
+  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
+
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use, 
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info". 
+
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability. 
+
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or 
+  data to be ensured and,  more generally, to use and operate it in the 
+  same conditions as regards security. 
+
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
+*/
+
+#ifndef _ABSTRACT_KRONECKER_WSM_H_
+#define _ABSTRACT_KRONECKER_WSM_H_
+
+#include "AbstractWordSubstitutionModel.h"
+#include <set>
+
+// From bpp-core:
+#include <Bpp/Numeric/Prob/Simplex.h>
+
+namespace bpp
+{
+  /**
+   * @brief Abstract Kronecker Word Model.
+   *
+   * Objects of this class are built from several substitution models.
+   * Each model corresponds to a position in the word. No model is
+   * directly accessible.
+   *
+   * A substitution rate between words is the product of the rates of
+   * changing letters of position generators.
+   *
+   * Either all substitutions are allowed, or any subset of them is
+   * allowed. For example, in case of 3 words model, if @f$Q at f$ is the
+   * generator of the position model, either all substitutions are
+   * allowed (ie generator is @f$ Q_1 \otimes Q_1 \otimes Q_1 @f$ with
+   * @f$Q_1 at f$ is @f$Q at f$ with diagonal of 1), or all and only three
+   * letters substitutions are allowed (ie generator is @f$ Q_0
+   * \otimes Q_0 \otimes Q_0 @f$ with @f$Q_0 at f$ is @f$Q at f$ with
+   * diagonal of 0), or all and only two letters substitutions are
+   * allowed (generator is @f$ I \otimes Q_0 \otimes Q_0 + Q_0 \otimes
+   * I \otimes Q_0 + Q_0 \otimes Q_0 \otimes I @f$), or all and only
+   * two neighbors letters substitutions are allowed (generator is @f$
+   * I \otimes Q_0 \otimes Q_0 + Q_0 \otimes Q_0 \otimes I @f$).
+   *
+   * Default construction is all substitutions, but a vector of
+   * vectors of simultaneously changing positions can be given.
+   *
+   */
+  
+  class AbstractKroneckerWordSubstitutionModel:
+    public AbstractWordSubstitutionModel
+  {
+  private:
+
+    /**
+     * @brief vector of sets of simultaneously changing positions.
+     *
+     * Shortcut : if empty, any number of any positions can change
+     * simultaneously
+     *
+     */
+
+    std::vector<std::set< size_t> > sChangingPos_;
+
+    /**
+     * @brief vector of generators for computation purposes
+     *
+     */
+
+    std::vector< RowMatrix<double> > vGenerators_;
+
+
+  protected:
+    
+    void initGenerators_();
+    
+    /**
+     * @brief checks that the vector of changing positions is valid
+     *
+     */
+    
+    bool checkChangingPositions_();
+
+    
+  private:
+
+    /**
+     * @brief First fill of the generator, from the position model
+     *
+     */
+
+    void fillBasicGenerator();
+
+  public:
+    /**
+     * @brief Build a new AbstractKroneckerWordSubstitutionModel
+     * object from a vector of pointers to SubstitutionModels,
+     * allowing for all substitutions.
+     *
+     * @param modelList the list of substitution models to use, in
+     *   the order of the positions in the words from left to right. All
+     *   the models must be different objects to avoid parameters
+     *   redundancy, otherwise only the first model is used. The used models
+     *   are owned by the instance.
+     * @param prefix the Namespace.
+     */
+
+    AbstractKroneckerWordSubstitutionModel(
+      ModelList& modelList,
+      const std::string& prefix);
+
+    /**
+     * @brief Build a new AbstractKroneckerWordSubstitutionModel
+     * object from a vector of pointers to SubstitutionModels,
+     * allowing for a given vector of simultaneous substitutions.
+     *
+     * @param modelList the list of substitution models to use, in
+     *   the order of the positions in the words from left to right. All
+     *   the models must be different objects to avoid parameters
+     *   redundancy, otherwise only the first model is used. The used models
+     *   are owned by the instance.
+     * @param vPos a vector of sets of simultaneously changing
+     *   positions.
+     * @param prefix the Namespace.
+     */
+ 
+    AbstractKroneckerWordSubstitutionModel(
+      ModelList& modelList,
+      const std::vector<std::set< size_t> >& vPos,
+      const std::string& prefix);
+
+    /**
+     * @brief Build a new AbstractWordSubstitutionModel object from a
+     * pointer to an SubstitutionModel and a number of desired models,
+     * allowing for all substitutions.
+     *
+     * @param pmodel A pointer to the substitution model to use in all
+     * the positions. It will be owned by the instance.
+     * @param num The number of models involved.
+     * @param prefix the Namespace.
+     */
+
+    AbstractKroneckerWordSubstitutionModel(
+      SubstitutionModel* pmodel,
+      unsigned int num,
+      const std::string& prefix);
+
+    /**
+     * @brief Build a new AbstractWordSubstitutionModel object from a
+     * pointer to an SubstitutionModel and a number of desired models,
+     * allowing for a given vector of simultaneous substitutions.
+     *
+     * @param pmodel A pointer to the substitution model to use in all
+     * the positions. It will be owned by the instance.
+     * @param num The number of models involved.
+     * @param vPos a vector of vectors of simultaneously changing
+     *   positions.
+     * @param prefix the Namespace.
+     */
+
+    AbstractKroneckerWordSubstitutionModel(
+      SubstitutionModel* pmodel,
+      unsigned int num,
+      const std::vector<std::set< size_t> >& vPos,
+      const std::string& prefix);
+    
+    
+    virtual ~AbstractKroneckerWordSubstitutionModel(){};
+    
+    
+
+    AbstractKroneckerWordSubstitutionModel(const AbstractKroneckerWordSubstitutionModel&);
+
+    AbstractKroneckerWordSubstitutionModel& operator=(const AbstractKroneckerWordSubstitutionModel&);
+
+  protected:
+    /**
+     * @brief Constructor for the derived classes only
+     */
+    AbstractKroneckerWordSubstitutionModel(const Alphabet* alph, StateMap* stateMap, const std::string& prefix);
+
+    void setChangingPositions(const std::vector<std::set<size_t> >& vPos);
+
+  };
+
+} //end of namespace bpp.
+
+#endif // _ABSTRACT_KRONECKER_WSM_H_
+
diff --git a/src/Bpp/Phyl/Model/AbstractSubstitutionModel.cpp b/src/Bpp/Phyl/Model/AbstractSubstitutionModel.cpp
index dcbf755..98cc9a0 100644
--- a/src/Bpp/Phyl/Model/AbstractSubstitutionModel.cpp
+++ b/src/Bpp/Phyl/Model/AbstractSubstitutionModel.cpp
@@ -58,6 +58,7 @@ AbstractSubstitutionModel::AbstractSubstitutionModel(const Alphabet* alpha, Stat
   alphabet_(alpha),
   stateMap_(stateMap),
   size_(alpha->getSize()),
+  isScalable_(true),
   rate_(1),
   generator_(size_, size_),
   freq_(size_),
@@ -202,6 +203,8 @@ const Matrix<double>& AbstractSubstitutionModel::getPij_t(double t) const
   return pijt_;
 }
 
+/******************************************************************************/
+
 const Matrix<double>& AbstractSubstitutionModel::getdPij_dt(double t) const
 {
   if (isNonSingular_)
@@ -271,6 +274,8 @@ const Matrix<double>& AbstractSubstitutionModel::getdPij_dt(double t) const
   return dpijt_;
 }
 
+/******************************************************************************/
+
 const Matrix<double>& AbstractSubstitutionModel::getd2Pij_dt2(double t) const
 {
   if (isNonSingular_)
@@ -353,9 +358,10 @@ double AbstractSubstitutionModel::getInitValue(size_t i, int state) const throw
   if (state < 0 || !alphabet_->isIntInAlphabet(state))
     throw BadIntException(state, "AbstractSubstitutionModel::getInitValue. Character " + alphabet_->intToChar(state) + " is not allowed in model.");
   vector<int> states = alphabet_->getAlias(state);
+
   for (size_t j = 0; j < states.size(); j++)
   {
-    if (getAlphabetStateAsInt(i) == states[j])
+     if (getAlphabetStateAsInt(i) == states[j])
       return 1.;
   }
   return 0.;
@@ -406,8 +412,23 @@ double AbstractSubstitutionModel::getScale() const
 
 /******************************************************************************/
 
-void AbstractSubstitutionModel::setScale(double scale) {
-  MatrixTools::scale(generator_, scale);
+void AbstractSubstitutionModel::setScale(double scale)
+{
+  if (isScalable_)
+  {
+    MatrixTools::scale(generator_, scale);
+    eigenValues_ *= scale;
+    iEigenValues_ *= scale;
+  }
+}
+
+
+/******************************************************************************/
+
+void AbstractSubstitutionModel::normalize() 
+{
+  if (isScalable_)
+    setScale(1/getScale());
 }
 
 /******************************************************************************/
@@ -423,11 +444,11 @@ void AbstractSubstitutionModel::setRate(double rate)
 {
   if (rate <= 0)
     throw Exception("Bad value for rate: " + TextTools::toString(rate));
-
+  
   if (hasParameter("rate"))
-    setParameterValue("rate", rate_);
-
-  rate_ = rate;
+    setParameterValue("rate", rate);
+  else
+    rate_ = rate;
 }
 
 void AbstractSubstitutionModel::addRateParameter()
@@ -442,6 +463,7 @@ void AbstractReversibleSubstitutionModel::updateMatrices()
   RowMatrix<double> Pi;
   MatrixTools::diag(freq_, Pi);
   MatrixTools::mult(exchangeability_, Pi, generator_); // Diagonal elements of the exchangability matrix will be ignored.
+
   // Compute diagonal elements of the generator:
   for (size_t i = 0; i < size_; i++)
   {
@@ -453,17 +475,17 @@ void AbstractReversibleSubstitutionModel::updateMatrices()
     }
     generator_(i, i) = -lambda;
   }
+  
   // Normalization:
-  double scale = getScale();
-  MatrixTools::scale(generator_, 1. / scale);
-
-  // Normalize exchangeability matrix too:
-  MatrixTools::scale(exchangeability_, 1. / scale);
+  normalize();
+  
   // Compute diagonal elements of the exchangeability matrix:
   for (size_t i = 0; i < size_; i++)
-  {
-    exchangeability_(i, i) = generator_(i, i) / freq_[i];
-  }
+    for (size_t j = 0; j < size_; j++)
+    {
+      exchangeability_(i, j) = generator_(i, j) / freq_[i];
+    }
+  
   AbstractSubstitutionModel::updateMatrices();
 }
 
diff --git a/src/Bpp/Phyl/Model/AbstractSubstitutionModel.h b/src/Bpp/Phyl/Model/AbstractSubstitutionModel.h
index 40e6d5b..f8f18c6 100755
--- a/src/Bpp/Phyl/Model/AbstractSubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/AbstractSubstitutionModel.h
@@ -88,7 +88,7 @@ protected:
   /**
    * @brief The map of model states with alphabet states.
    */
-  std::auto_ptr<StateMap> stateMap_;
+  std::unique_ptr<StateMap> stateMap_;
 
   /**
    * @brief The size of the generator, i.e. the number of states.
@@ -96,6 +96,13 @@ protected:
   size_t size_;
 
   /**
+   * @brief If the model is scalable (ie generator can be normalized
+   * automatically).
+   */
+  
+  bool isScalable_;
+
+  /**
    * @brief The rate of the model (default: 1). The generator (and all
    * its vectorial components) is independent of the rate, since it
    * should be normalized.
@@ -118,7 +125,6 @@ protected:
    * reversible, this matrix is symetric.
    *
    */
-  
   RowMatrix<double> exchangeability_;
 
   /**
@@ -146,7 +152,6 @@ protected:
   /**
    * @brief boolean value for diagonalizability in R of the generator_
    */
-  
   bool isDiagonalizable_;
 
   /**
@@ -184,6 +189,7 @@ public:
     alphabet_(model.alphabet_),
     stateMap_(model.stateMap_->clone()),
     size_(model.size_),
+    isScalable_(model.isScalable_),
     rate_(model.rate_),
     generator_(model.generator_),
     freq_(model.freq_),
@@ -208,6 +214,7 @@ public:
     alphabet_          = model.alphabet_;
     stateMap_.reset(model.stateMap_->clone());
     size_              = model.size_;
+    isScalable_        = model.isScalable_;
     rate_              = model.rate_;
     generator_         = model.generator_;
     freq_              = model.freq_;
@@ -229,9 +236,7 @@ public:
   
   virtual ~AbstractSubstitutionModel() {}
 
-#ifndef NO_VIRTUAL_COV
   virtual AbstractSubstitutionModel* clone() const = 0;
-#endif
 
 public:
   const Alphabet* getAlphabet() const { return alphabet_; }
@@ -298,10 +303,23 @@ public:
   virtual void fireParameterChanged(const ParameterList& parameters)
   {
     AbstractParameterAliasable::fireParameterChanged(parameters);
-    if ((parameters.size()!=1) || (parameters[0].getName()!=getNamespace()+"rate"))
-      updateMatrices();
+    
+    if (parameters.hasParameter(getNamespace()+"rate"))
+    {
+      rate_=parameters.getParameterValue(getNamespace()+"rate");
+      
+      if (parameters.size()!=1)
+        updateMatrices();
+    }
+    else
+      updateMatrices();      
   }
 
+  /**
+   * @brief add a "rate" parameter to the model, that handles the
+   * overall rate of the process.
+   *
+   */
   void addRateParameter();
 
 protected:
@@ -320,26 +338,61 @@ protected:
    * The optional rate parameter is not taken into account in this
    * method to prevent unnecessary computation.
    */
-  
   virtual void updateMatrices();
 
 public:
+
+  /**
+   * @brief sets if model is scalable, ie scale can be changed.
+   * Default : true, set to false to avoid normalization for example.
+   *
+   */
+  
+  void setScalable(bool scalable)
+  {
+    isScalable_=scalable;
+  }
+  
+  /**
+   * @brief returns  if model is scalable
+   *
+   */
+
+  virtual bool isScalable() const
+  {
+    return isScalable_;
+  }
+
+  /**
+   * @brief return scale
+   *
+   */
+  
   double getScale() const;
 
-  /*
+  /**
    * @brief Multiplies the current generator by the given scale.
    *
    * @param scale the scale by which the generator is multiplied.
    *
    */
-  
   void setScale(double scale);
 
+  /**
+   * @brief normalize the generator
+   *
+   */
+
+  virtual void normalize();
+  
+  /**
+   * @brief The rate of the substitution process.
+   *
+   */
   virtual double getRate() const;
 
   virtual void setRate(double rate);
 
-
   friend class AbstractBiblioSubstitutionModel;
 
 };
@@ -368,7 +421,6 @@ public:
  * characters in the alphabet. Consider using the
  * MarkovModulatedSubstitutionModel for more complexe cases.
  */
-  
 class AbstractReversibleSubstitutionModel :
   public AbstractSubstitutionModel,
   public virtual ReversibleSubstitutionModel
@@ -384,9 +436,7 @@ public:
 
   virtual ~AbstractReversibleSubstitutionModel() {}
 
-#ifndef NO_VIRTUAL_COV
   virtual AbstractReversibleSubstitutionModel* clone() const = 0;
-#endif
 
 protected:
 
diff --git a/src/Bpp/Phyl/Model/AbstractWordSubstitutionModel.cpp b/src/Bpp/Phyl/Model/AbstractWordSubstitutionModel.cpp
index 15b1dfd..4b96962 100644
--- a/src/Bpp/Phyl/Model/AbstractWordSubstitutionModel.cpp
+++ b/src/Bpp/Phyl/Model/AbstractWordSubstitutionModel.cpp
@@ -59,21 +59,22 @@ using namespace std;
 
 /******************************************************************************/
 
-//TODO: jdutheil on 24/09/14: we should define a class "vector of models", insuring they share the same alphabet and StateMap for instance.
-//This is the only way to avoid a segfault in case the user provides a vector of models of length 0.
 AbstractWordSubstitutionModel::AbstractWordSubstitutionModel(
-  const std::vector<SubstitutionModel*>& modelVector,
+  ModelList& modelList,
   const std::string& prefix) :
   AbstractParameterAliasable(prefix),
-  AbstractSubstitutionModel(AbstractWordSubstitutionModel::extractAlph(modelVector), modelVector[0]->getStateMap().clone(), prefix),
+  AbstractSubstitutionModel(
+      modelList.getWordAlphabet(),
+      new CanonicalStateMap(modelList.getWordAlphabet(), false),
+      prefix),
   new_alphabet_ (true),
   VSubMod_      (),
   VnestedPrefix_(),
-  Vrate_        (modelVector.size())
+  Vrate_        (modelList.size())
 {
   enableEigenDecomposition(false);
   size_t i, j;
-  size_t n = modelVector.size();
+  size_t n = modelList.size();
 
   // test whether two models are identical
 
@@ -82,7 +83,7 @@ AbstractWordSubstitutionModel::AbstractWordSubstitutionModel(
   j = 1;
   while (!flag && i < (n - 1))
   {
-    if (modelVector[i] == modelVector[j])
+    if (modelList.getModel(i) == modelList.getModel(j))
       flag = 1;
     else
     {
@@ -99,8 +100,8 @@ AbstractWordSubstitutionModel::AbstractWordSubstitutionModel(
   {
     for (i = 0; i < n; i++)
     {
-      VSubMod_.push_back(modelVector[i]);
-      VnestedPrefix_.push_back(modelVector[i]->getNamespace());
+      VSubMod_.push_back(modelList.getModel(i));
+      VnestedPrefix_.push_back(modelList.getModel(i)->getNamespace());
       VSubMod_[i]->setNamespace(prefix + TextTools::toString(i + 1) + "_" + VnestedPrefix_[i]);
       addParameters_(VSubMod_[i]->getParameters());
     }
@@ -110,8 +111,8 @@ AbstractWordSubstitutionModel::AbstractWordSubstitutionModel(
     string t = "";
     for (i = 0; i < n; i++)
     {
-      VSubMod_.push_back(modelVector[0]);
-      VnestedPrefix_.push_back(modelVector[0]->getNamespace());
+      VSubMod_.push_back(modelList.getModel(0));
+      VnestedPrefix_.push_back(modelList.getModel(0)->getNamespace());
       t += TextTools::toString(i + 1);
     }
     VSubMod_[0]->setNamespace(prefix + t + "_" + VnestedPrefix_[0]);
@@ -122,6 +123,7 @@ AbstractWordSubstitutionModel::AbstractWordSubstitutionModel(
   {
     Vrate_[i] = 1.0 / static_cast<double>(n);
   }
+
 }
 
 AbstractWordSubstitutionModel::AbstractWordSubstitutionModel(
@@ -133,7 +135,7 @@ AbstractWordSubstitutionModel::AbstractWordSubstitutionModel(
   new_alphabet_ (false),
   VSubMod_      (),
   VnestedPrefix_(),
-  Vrate_         (0)
+  Vrate_        (0)
 {
   enableEigenDecomposition(false);
 }
@@ -143,12 +145,14 @@ AbstractWordSubstitutionModel::AbstractWordSubstitutionModel(
   unsigned int num,
   const std::string& prefix) :
   AbstractParameterAliasable(prefix),
-  AbstractSubstitutionModel(new WordAlphabet(pmodel->getAlphabet(), num), pmodel->getStateMap().clone(), prefix),
+  AbstractSubstitutionModel(new WordAlphabet(pmodel->getAlphabet(), num), 0, prefix),
   new_alphabet_ (true),
   VSubMod_      (),
   VnestedPrefix_(),
-  Vrate_         (num)
+  Vrate_        (num,1.0/num)
 {
+  stateMap_=std::unique_ptr<StateMap>(new CanonicalStateMap(getAlphabet(), false));
+
   enableEigenDecomposition(false);
   size_t i;
 
@@ -157,7 +161,6 @@ AbstractWordSubstitutionModel::AbstractWordSubstitutionModel(
   {
     VSubMod_.push_back(pmodel);
     VnestedPrefix_.push_back(pmodel->getNamespace());
-    Vrate_[i] = 1.0 / num;
     t += TextTools::toString(i + 1);
   }
 
@@ -172,7 +175,7 @@ AbstractWordSubstitutionModel::AbstractWordSubstitutionModel(
   new_alphabet_ (wrsm.new_alphabet_),
   VSubMod_      (),
   VnestedPrefix_(wrsm.VnestedPrefix_),
-  Vrate_         (wrsm.Vrate_)
+  Vrate_        (wrsm.Vrate_)
 {
   size_t i;
   size_t num = wrsm.VSubMod_.size();
@@ -239,20 +242,6 @@ size_t AbstractWordSubstitutionModel::getNumberOfStates() const
   return getAlphabet()->getSize();
 }
 
-Alphabet* AbstractWordSubstitutionModel::extractAlph(const vector<SubstitutionModel*>& modelVector)
-{
-  size_t i;
-
-  vector<const Alphabet*> vAlph;
-
-  for (i = 0; i < modelVector.size(); i++)
-  {
-    vAlph.push_back(modelVector[i]->getAlphabet());
-  }
-
-  return new WordAlphabet(vAlph);
-}
-
 void AbstractWordSubstitutionModel::setNamespace(const std::string& prefix)
 {
   AbstractSubstitutionModel::setNamespace(prefix);
@@ -297,51 +286,27 @@ void AbstractWordSubstitutionModel::updateMatrices()
 
   // Generator
 
-  if (enableEigenDecomposition())
-  {
-    size_t i, j, n, l, k, m;
+  size_t i, j, n, l, k, m;
 
-    vector<size_t> vsize;
+  vector<size_t> vsize;
 
-    for (k = 0; k < nbmod; k++)
-    {
-      vsize.push_back(VSubMod_[k]->getNumberOfStates());
-    }
+  for (k = 0; k < nbmod; k++)
+  {
+    vsize.push_back(VSubMod_[k]->getNumberOfStates());
+  }
 
-    RowMatrix<double> gk, exch;
+  RowMatrix<double> gk, exch;
 
-    m = 1;
+  // First fill of the generator from simple position generators
+  
+  this->fillBasicGenerator();
 
-    for (k = nbmod; k > 0; k--)
-    {
-      gk = VSubMod_[k - 1]->getGenerator();
-      for (i = 0; i < vsize[k - 1]; i++)
-      {
-        for (j = 0; j < vsize[k - 1]; j++)
-        {
-          if (i != j)
-          {
-            n = 0;
-            while (n < salph)
-            { // loop on prefix
-              for (l = 0; l < m; l++)
-              { // loop on suffix
-                generator_(n + i * m + l, n + j * m + l) = gk(i, j) * Vrate_[k - 1];
-              }
-              n += m * vsize[k - 1];
-            }
-          }
-        }
-      }
-      m *= vsize[k - 1];
-    }
-  }
+  // modification of generator_
 
-  // modification of generator_ and freq_
+  this->completeMatrices();
 
-  completeMatrices();
+  // sets diagonal terms
 
-  size_t i, j;
   double x;
 
   for (i = 0; i < salph; i++)
@@ -359,7 +324,7 @@ void AbstractWordSubstitutionModel::updateMatrices()
   // enableEigenDecomposition
 
   // Eigen values:
-
+  
   if (enableEigenDecomposition())
   {
     for (i = 0; i < salph; i++)
@@ -382,8 +347,6 @@ void AbstractWordSubstitutionModel::updateMatrices()
     {
       size_t gi = 0, gj = 0;
 
-      RowMatrix<double> gk;
-
       gk.resize(salph - nbStop, salph - nbStop);
       for (i = 0; i < salph; i++)
       {
@@ -471,68 +434,66 @@ void AbstractWordSubstitutionModel::updateMatrices()
       // eigen vector elements are equal.
       //
 
-      if (isDiagonalizable_)
-      {
-        size_t nulleigen = 0;
-        double val;
+      size_t nulleigen = 0;
+      double val;
 
-        isNonSingular_ = false;
-        while (nulleigen < salph - nbStop)
+      isNonSingular_ = false;
+      while (nulleigen < salph - nbStop)
+      {
+        if ((abs(eigenValues_[nulleigen]) < NumConstants::SMALL()) && (abs(iEigenValues_[nulleigen]) < NumConstants::SMALL()))
         {
-          if ((abs(eigenValues_[nulleigen]) < NumConstants::SMALL()) && (abs(iEigenValues_[nulleigen]) < NumConstants::SMALL()))
-          {
-            i = 0;
-            while (vnull[i])
-              i++;
-            
-            val = rightEigenVectors_(i, nulleigen);
+          i = 0;
+          while (vnull[i])
             i++;
-            while (i < salph)
-            {
-              if (!vnull[i])
-              {
-                if (abs(rightEigenVectors_(i, nulleigen) - val) > NumConstants::SMALL())
-                  break;
-              }
-              i++;
-            }
-            
-            if (i < salph)
-              nulleigen++;
-            else
+          
+          val = rightEigenVectors_(i, nulleigen);
+          i++;
+          while (i < salph)
+          {
+            if (!vnull[i])
             {
-              isNonSingular_ = true;
-              break;
+              if (abs(rightEigenVectors_(i, nulleigen) - val) > NumConstants::SMALL())
+                break;
             }
+            i++;
           }
-          else
+          
+          if (i < salph)
             nulleigen++;
+          else
+          {
+            isNonSingular_ = true;
+            break;
+          }
         }
+        else
+          nulleigen++;
+      }
+      
+      if (isNonSingular_)
+      {
+        eigenValues_[nulleigen] = 0; // to avoid approximation errors on long long branches
+        iEigenValues_[nulleigen] = 0; // to avoid approximation errors on long long branches
         
-        if (isNonSingular_)
-        {
-          eigenValues_[nulleigen] = 0; // to avoid approximation errors on long long branches
-          iEigenValues_[nulleigen] = 0; // to avoid approximation errors on long long branches
-          
-          for (i = 0; i < salph; i++)
-            freq_[i] = leftEigenVectors_(nulleigen, i);
-          
-          x = 0;
-          for (i = 0; i < salph; i++)
+        for (i = 0; i < salph; i++)
+          freq_[i] = leftEigenVectors_(nulleigen, i);
+        
+        x = 0;
+        for (i = 0; i < salph; i++)
             x += freq_[i];
-          
-          for (i = 0; i < salph; i++)
+        
+        for (i = 0; i < salph; i++)
           freq_[i] /= x;
-        }
+      }
       
-        else
-        {
-          ApplicationTools::displayMessage("Unable to find eigenvector for eigenvalue 1. Taylor series used instead.");
-          isDiagonalizable_ = false;
-        }
+      else
+      {
+        ApplicationTools::displayMessage("Unable to find eigenvector for eigenvalue 1. Taylor series used instead.");
+        isDiagonalizable_ = false;
       }
     }
     
+    
     // if rightEigenVectors_ is singular
     catch (ZeroDivisionException& e)
     {
@@ -550,7 +511,7 @@ void AbstractWordSubstitutionModel::updateMatrices()
           min = generator_(i, i);
       }
 
-      MatrixTools::scale(generator_, -1 / min);
+      setScale(-1 / min);
 
       if (vPowGen_.size() == 0)
         vPowGen_.resize(30);
@@ -568,21 +529,40 @@ void AbstractWordSubstitutionModel::updateMatrices()
     }
 
     // normalization
+    normalize();
 
-    x = 0;
-    for (i = 0; i < salph; i++)
-      x += freq_[i] * generator_(i, i);
-
-    MatrixTools::scale(generator_, -1. / x);
-    for (i = 0; i < salph; i++)
+    
+    if (!isNonSingular_)
+      MatrixTools::Taylor(generator_, 30, vPowGen_);
+  }
+  else  // compute freq_ if no eigenDecomposition
+  {
+    for (j = 0; j < size_; j++)
+      freq_[j] = 1;
+  
+    m = 1;
+    for (k = nbmod; k > 0; k--)
     {
-      eigenValues_[i] /= -x;
-      iEigenValues_[i] /= -x;
+      SubstitutionModel* pSM = VSubMod_[k - 1];
+      for (j = 0; j < vsize[k - 1]; j++)
+      {
+        n = 0;
+        while (n < salph)
+        { // loop on prefix
+          for (l = 0; l < m; l++)
+          { // loop on suffix
+            freq_[n + j * m + l] *=  pSM->freq(j);
+          }
+          n += m * vsize[k - 1];
+        }
+      }
+      m *= vsize[k - 1];
     }
 
-    if (!isNonSingular_)
-      MatrixTools::Taylor(generator_, 30, vPowGen_);
+    // normalization
+    normalize();
   }
+  
 
   // compute the exchangeability_
 
@@ -592,6 +572,54 @@ void AbstractWordSubstitutionModel::updateMatrices()
 
 }
 
+
+
+void AbstractWordSubstitutionModel::fillBasicGenerator()
+{
+  size_t nbmod = VSubMod_.size();
+  size_t salph = getNumberOfStates();
+
+// Generator
+
+  RowMatrix<double> gk;
+  
+  vector<size_t> vsize;
+
+  for (size_t k = 0; k < nbmod; k++)
+  {
+    vsize.push_back(VSubMod_[k]->getNumberOfStates());
+  }
+  
+  size_t m = 1;
+  
+  for (size_t k = nbmod; k > 0; k--)
+  {
+    gk = VSubMod_[k - 1]->getGenerator();
+    for (size_t i = 0; i < vsize[k - 1]; i++)
+    {
+      const vector<double>& row_gi=gk.getRow(i);
+      
+      for (size_t j = 0; j < vsize[k - 1]; j++)
+      {
+        if (i != j)
+        {
+          size_t n = 0;
+          while (n < salph)
+          { // loop on prefix
+            for (size_t l = 0; l < m; l++)
+            { // loop on suffix
+              generator_(n + i * m + l, n + j * m + l) = row_gi[j] * Vrate_[k - 1];
+            }
+            n += m * vsize[k - 1];
+          }
+        }
+      }
+    }
+    m *= vsize[k - 1];
+  }
+}
+
+
 void AbstractWordSubstitutionModel::setFreq(std::map<int, double>& freqs)
 {
   map<int, double> tmpFreq;
diff --git a/src/Bpp/Phyl/Model/AbstractWordSubstitutionModel.h b/src/Bpp/Phyl/Model/AbstractWordSubstitutionModel.h
index 7df2f9d..0888caa 100644
--- a/src/Bpp/Phyl/Model/AbstractWordSubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/AbstractWordSubstitutionModel.h
@@ -42,11 +42,81 @@
 
 #include "AbstractSubstitutionModel.h"
 
+// From bpp-seq:
+#include <Bpp/Seq/Alphabet/WordAlphabet.h>
+
 // From the STL:
 #include <vector>
 
 namespace bpp
 {
+
+/**
+ * @brief A list of models, for building a WordSubstitutionModel
+ *
+ * Instance of ModelList contains a vector of pointers toward a substitution model which they do not own. Several methods are provided to build and check Alphabet and StateMaps.
+ *
+ * @author Julien Y. Dutheil.
+ */
+class ModelList
+{
+  protected:
+    std::vector<SubstitutionModel *> models_;
+    std::unique_ptr<WordAlphabet> wordAlphabet_;
+    WordAlphabet* pWordAlphabet_;
+
+  public:
+    /**
+     * @brief Create a ModelList from one template substitution model.
+     *
+     * @param models A vector of pointers toward substitution model objects.
+     */
+    ModelList(const std::vector<SubstitutionModel *>& models):
+      models_(models), wordAlphabet_(), pWordAlphabet_(0)
+    {
+      std::vector<const Alphabet *> alphabets(models.size());
+      for (size_t i = 0; i < models.size(); ++i) {
+        alphabets[i] = models[i]->getAlphabet();
+      }
+      wordAlphabet_.reset(new WordAlphabet(alphabets));
+      pWordAlphabet_ = wordAlphabet_.get();
+    }
+
+    ModelList(const ModelList& ml):
+      models_(ml.models_),
+      wordAlphabet_(ml.wordAlphabet_.get() ? ml.wordAlphabet_.get()->clone() : 0),
+      pWordAlphabet_(wordAlphabet_.get())
+    {}
+ 
+    ModelList& operator=(const ModelList& ml)
+    {
+      models_ = ml.models_;
+      wordAlphabet_.reset(ml.wordAlphabet_.get() ? ml.wordAlphabet_.get()->clone() : 0);
+      pWordAlphabet_ = wordAlphabet_.get();
+      return *this;
+    }
+
+  public:
+    size_t size() const { return models_.size(); }
+
+    const SubstitutionModel* getModel(size_t i) const {
+      return models_[i];
+    }
+
+    SubstitutionModel* getModel(size_t i) {
+      return models_[i];
+    }
+
+    const WordAlphabet* getWordAlphabet() {
+      if (wordAlphabet_.get()) //First call
+        return wordAlphabet_.release();
+      else //Other calls, this class does not own the pointer anymore.
+        return pWordAlphabet_; 
+    }    
+};
+
+
+
 /**
  * @brief Abstract Basal class for words of substitution models.
  * @author Laurent Guéguen
@@ -64,14 +134,19 @@ namespace bpp
  * @f{eqnarray*}
  * Q_{abc \rightarrow abd} &=& \rho_2 Q^{(2)}_{c \rightarrow d}\\
  * Q_{abc \rightarrow aed} &=& 0\\
- * Q_{abc \rightarrow abc} &=& \rho_0 Q^{(0)}_{a \rightarrow a} + \rho_1 Q^{(1)}_{b \rightarrow b} + \rho_2 Q^{(2)}_{c \rightarrow c})
  * @f}
  *
  * The parameters of this word model are the same as the ones of the
- * models used. Their names have a new suffix, "phi_" where i stands
- * for the position (i.e. the phase) in the word.
+ * models used. Their names have a new prefix :
+ *
+ * If there is one model per position, "i_" where i stands for the
+ * position in the word.
+ *
+ * If there is only one model, "123..._" where all positions are
+ * enumerated.
  *
  */
+  
 class AbstractWordSubstitutionModel :
     public AbstractSubstitutionModel
 {
@@ -88,9 +163,6 @@ protected:
   std::vector<double> Vrate_;
 
 protected:
-  static Alphabet* extractAlph(const std::vector<SubstitutionModel*>& modelVector);
-
-protected:
   void updateMatrices();
 
   /**
@@ -99,12 +171,19 @@ protected:
    */
   virtual void completeMatrices() = 0;
 
+  /**
+   * @brief First fill of the generator, from the position model
+   *
+   */
+  
+  virtual void fillBasicGenerator();
+  
 public:
   /**
    * @brief Build a new AbstractWordSubstitutionModel object from a
    * vector of pointers to SubstitutionModels.
    *
-   * @param modelVector the vector of substitution models to use, in
+   * @param modelList the list of substitution models to use, in
    *   the order of the positions in the words from left to right. All
    *   the models must be different objects to avoid parameters
    *   redundancy, otherwise only the first model is used. The used models
@@ -112,7 +191,7 @@ public:
    * @param prefix the Namespace.
    */
   AbstractWordSubstitutionModel(
-    const std::vector<SubstitutionModel*>& modelVector,
+    ModelList& modelList,
     const std::string& prefix);
 
   /**
diff --git a/src/Bpp/Phyl/Model/BinarySubstitutionModel.cpp b/src/Bpp/Phyl/Model/BinarySubstitutionModel.cpp
index d43c8f5..2eac0c1 100644
--- a/src/Bpp/Phyl/Model/BinarySubstitutionModel.cpp
+++ b/src/Bpp/Phyl/Model/BinarySubstitutionModel.cpp
@@ -117,7 +117,7 @@ void BinarySubstitutionModel::updateMatrices()
 
 double BinarySubstitutionModel::Pij_t(size_t i, size_t j, double d) const
 {
-  exp_ = exp(-lambda_ * d);
+  exp_ = exp(-lambda_ * rate_ * d);
 
   switch (i)
   {
@@ -143,7 +143,7 @@ double BinarySubstitutionModel::Pij_t(size_t i, size_t j, double d) const
 
 double BinarySubstitutionModel::dPij_dt(size_t i, size_t j, double d) const
 {
-  exp_ = exp(-lambda_ * d);
+  exp_ = rate_ * exp(-lambda_ * rate_ * d);
 
   switch (i)
   {
@@ -169,7 +169,7 @@ double BinarySubstitutionModel::dPij_dt(size_t i, size_t j, double d) const
 
 double BinarySubstitutionModel::d2Pij_dt2(size_t i, size_t j, double d) const
 {
-  exp_ = exp(-lambda_ * d);
+  exp_ = rate_ * rate_ * exp(-lambda_ * rate_ * d);
 
   switch (i)
   {
@@ -195,7 +195,7 @@ double BinarySubstitutionModel::d2Pij_dt2(size_t i, size_t j, double d) const
 
 const Matrix<double>& BinarySubstitutionModel::getPij_t(double d) const
 {
-  exp_ = exp(-lambda_ * d);
+  exp_ = exp(-lambda_ * rate_ * d);
 
   p_(0,0) = (1 + kappa_ * exp_) / (kappa_ + 1);
   p_(0,1) = kappa_ / (kappa_ + 1) * (1 - exp_);
@@ -208,7 +208,7 @@ const Matrix<double>& BinarySubstitutionModel::getPij_t(double d) const
 
 const Matrix<double>& BinarySubstitutionModel::getdPij_dt(double d) const
 {
-  exp_ = exp(-lambda_ * d);
+  exp_ = rate_ * exp(-lambda_ * rate_ * d);
 
   p_(0,0) = -(kappa_ + 1) / 2 * exp_;
   p_(0,1) = (kappa_ + 1) / 2 * exp_;
@@ -221,7 +221,7 @@ const Matrix<double>& BinarySubstitutionModel::getdPij_dt(double d) const
 
 const Matrix<double>& BinarySubstitutionModel::getd2Pij_dt2(double d) const
 {
-  exp_ = exp(-lambda_ * d);
+  exp_ = rate_ * rate_ * exp(-lambda_ * rate_ * d);
 
   p_(0,0) = lambda_ * (kappa_ + 1) / 2 * exp_;
   p_(0,1) = -lambda_ * (kappa_ + 1) / 2 * exp_;
diff --git a/src/Bpp/Phyl/Model/Codon/CodonRateSubstitutionModel.cpp b/src/Bpp/Phyl/Model/Codon/AbstractCodonCpGSubstitutionModel.cpp
similarity index 63%
copy from src/Bpp/Phyl/Model/Codon/CodonRateSubstitutionModel.cpp
copy to src/Bpp/Phyl/Model/Codon/AbstractCodonCpGSubstitutionModel.cpp
index 13dba94..2581093 100644
--- a/src/Bpp/Phyl/Model/Codon/CodonRateSubstitutionModel.cpp
+++ b/src/Bpp/Phyl/Model/Codon/AbstractCodonCpGSubstitutionModel.cpp
@@ -1,5 +1,5 @@
 //
-// File: CodonSubstitutionModel.cpp
+// File: AbstractCodonDistanceSubstitutionModel.cpp
 // Created by:  Laurent Gueguen
 // Created on: Feb 2009
 //
@@ -36,8 +36,8 @@
    knowledge of the CeCILL license and that you accept its terms.
  */
 
-#include "CodonRateSubstitutionModel.h"
-
+#include "AbstractCodonCpGSubstitutionModel.h"
+#include <Bpp/Numeric/NumConstants.h>
 
 using namespace bpp;
 
@@ -45,38 +45,25 @@ using namespace std;
 
 /******************************************************************************/
 
-CodonRateSubstitutionModel::CodonRateSubstitutionModel(
-    const GeneticCode* gCode,
-    NucleotideSubstitutionModel* pmod) :
-  AbstractParameterAliasable("CodonRate."),
-  AbstractCodonSubstitutionModel(gCode, pmod, "CodonRate.", true)
-{
-  updateMatrices();
-}
-
-CodonRateSubstitutionModel::CodonRateSubstitutionModel(
-    const GeneticCode* gCode,
-    NucleotideSubstitutionModel* pmod1,
-    NucleotideSubstitutionModel* pmod2,
-    NucleotideSubstitutionModel* pmod3) :
-  AbstractParameterAliasable("CodonRate."),
-  AbstractCodonSubstitutionModel(gCode, pmod1, pmod2, pmod3, "CodonRate.", true)
+AbstractCodonCpGSubstitutionModel::AbstractCodonCpGSubstitutionModel(
+  const std::string& prefix) :
+  CodonSubstitutionModel(),
+  AbstractParameterAliasable(prefix),
+  rho_(1)
 {
-  updateMatrices();
+  addParameter_(new Parameter(prefix + "rho", 1, new IntervalConstraint(NumConstants::SMALL(), 999, true, true), true));
 }
 
-std::string CodonRateSubstitutionModel::getName() const
+void AbstractCodonCpGSubstitutionModel::fireParameterChanged(const ParameterList& parameters)
 {
-  return "CodonRate";
+  rho_ = getParameterValue("rho");
 }
 
-void CodonRateSubstitutionModel::fireParameterChanged(const ParameterList& parameters)
+double AbstractCodonCpGSubstitutionModel::getCodonsMulRate(size_t i, size_t j) const
 {
-  AbstractCodonSubstitutionModel::fireParameterChanged(parameters);
-}
+  int ii=static_cast<int>(i);
+  int ij=static_cast<int>(j);
 
-double CodonRateSubstitutionModel::getCodonsMulRate(size_t i, size_t j) const
-{
-  return AbstractCodonSubstitutionModel::getCodonsMulRate(i,j);
+  return ((ii%16==7  && (ii-ij==2 || ij-ii==8)) || ((ii-1)/4==6 && (ii-ij==8 || (ij-ii==32))))?rho_:1;
 }
 
diff --git a/src/Bpp/Phyl/Model/Codon/AbstractCodonDistanceSubstitutionModel.h b/src/Bpp/Phyl/Model/Codon/AbstractCodonCpGSubstitutionModel.h
similarity index 52%
copy from src/Bpp/Phyl/Model/Codon/AbstractCodonDistanceSubstitutionModel.h
copy to src/Bpp/Phyl/Model/Codon/AbstractCodonCpGSubstitutionModel.h
index e5a9f87..6abdb70 100644
--- a/src/Bpp/Phyl/Model/Codon/AbstractCodonDistanceSubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/Codon/AbstractCodonCpGSubstitutionModel.h
@@ -37,92 +37,60 @@
    knowledge of the CeCILL license and that you accept its terms.
  */
 
-#ifndef _ABSTRACTCODONDISTANCESUBSTITUTIONMODEL_H_
-#define _ABSTRACTCODONDISTANCESUBSTITUTIONMODEL_H_
+#ifndef _ABSTRACTCODONCPGSUBSTITUTIONMODEL_H_
+#define _ABSTRACTCODONCPGSUBSTITUTIONMODEL_H_
 
 #include "CodonSubstitutionModel.h"
 #include <Bpp/Numeric/AbstractParameterAliasable.h>
 
 
-// From bpp-seq:
-#include <Bpp/Seq/GeneticCode/GeneticCode.h>
-#include <Bpp/Seq/AlphabetIndex/AlphabetIndex2.h>
-
 namespace bpp
 {
 /**
- * @brief Abstract class for modelling of non-synonymous abd
- *  synonymous substitution rates in codon models.
+ * @brief Abstract class for modelling of CpG -> CpA or TpG (symetric)
+ *  hypermutability substitution rate inside codons. Note that the
+ *  neihbouring effects between codons is note considered.
  *
  * @author Laurent Guéguen
  *
- * If a distance @f$d at f$ between amino-acids is defined, the
- *  non-synonymous rate is multiplied with, if the coded amino-acids
- *  are @f$x at f$ and @f$y at f$, @f$\beta*\exp(-\alpha.d(x,y))@f$ with
- *  non-negative parameter \c "alpha" and positive parameter \c
- *  "beta".
- *
- * If such a distance is not defined, the non-synonymous substitution
- *  rate is multiplied with @f$\beta at f$ with positive parameter \c
- *  "beta" (ie @f$d=0 at f$).
+ * Substitution rate from C to T (resp. from G to A) is multiplied by a factor @f$\rho at f$
+ *  if C is followed by a G (resp. if G is following a C).
  *
- * If paramSynRate is true, the synonymous substitution rate is
- *  multiplied with @f$\gamma at f$ (with optional positive parameter \c
- *  "gamma"), else it is multiplied with 1.
+ * Hypermutability parameter is named \c "rho".
  *
- * References:
- * - Goldman N. and Yang Z. (1994), _Molecular Biology And Evolution_ 11(5) 725--736. 
- * - Kosakovsky Pond, S. and Muse, S.V. (2005), _Molecular Biology And Evolution_,
- *   22(12), 2375--2385.
- * - Mayrose, I. and Doron-Faigenboim, A. and Bacharach, E. and Pupko T.
- *   (2007), Bioinformatics, 23, i319--i327.
  */
 
-class AbstractCodonDistanceSubstitutionModel :
+class AbstractCodonCpGSubstitutionModel :
   public virtual CodonSubstitutionModel,
   public virtual AbstractParameterAliasable
 {
 private:
-  const AlphabetIndex2* pdistance_;
-
-  double alpha_, beta_;
+  double rho_;
 
-  double gamma_;
 public:
   /**
-   * @brief Build a new AbstractCodonDistanceSubstitutionModel object from
+   * @brief Build a new AbstractCodonCpGSubstitutionModel object from
    *  a pointer to NucleotideSubstitutionModel.
    *
-   * @param pdist optional pointer to a distance between amino-acids
    * @param prefix the Namespace
-   * @param paramSynRate is true iff synonymous rate is parametrised
-   *       (default=false).
    */
-  AbstractCodonDistanceSubstitutionModel(
-    const AlphabetIndex2* pdist,
-    const std::string& prefix,
-    bool paramSynRate = false);
+  AbstractCodonCpGSubstitutionModel(
+    const std::string& prefix);
 
-  AbstractCodonDistanceSubstitutionModel(const AbstractCodonDistanceSubstitutionModel& model) :
+  AbstractCodonCpGSubstitutionModel(const AbstractCodonCpGSubstitutionModel& model) :
     AbstractParameterAliasable(model),
-    pdistance_(model.pdistance_),
-    alpha_(model.alpha_),
-    beta_(model.beta_),
-    gamma_(model.gamma_)
+    rho_(model.rho_)
   {}
 
-  AbstractCodonDistanceSubstitutionModel& operator=(
-    const AbstractCodonDistanceSubstitutionModel& model)
+  AbstractCodonCpGSubstitutionModel& operator=(
+    const AbstractCodonCpGSubstitutionModel& model)
   {
     AbstractParameterAliasable::operator=(model);
-    pdistance_ = model.pdistance_;
-    alpha_ = model.alpha_;
-    beta_ = model.beta_;
-    gamma_ = model.gamma_;
+    rho_ = model.rho_;
     return *this;
   }
 
-  virtual ~AbstractCodonDistanceSubstitutionModel() {}
+  virtual ~AbstractCodonCpGSubstitutionModel() {}
 
 public:
   void fireParameterChanged(const ParameterList& parameters);
diff --git a/src/Bpp/Phyl/Model/Codon/AbstractCodonDistanceSubstitutionModel.h b/src/Bpp/Phyl/Model/Codon/AbstractCodonDistanceSubstitutionModel.h
index e5a9f87..69a1420 100644
--- a/src/Bpp/Phyl/Model/Codon/AbstractCodonDistanceSubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/Codon/AbstractCodonDistanceSubstitutionModel.h
@@ -51,7 +51,7 @@
 namespace bpp
 {
 /**
- * @brief Abstract class for modelling of non-synonymous abd
+ * @brief Abstract class for modelling of non-synonymous and
  *  synonymous substitution rates in codon models.
  *
  * @author Laurent Guéguen
diff --git a/src/Bpp/Phyl/Model/Codon/AbstractCodonFrequenciesSubstitutionModel.h b/src/Bpp/Phyl/Model/Codon/AbstractCodonFrequenciesSubstitutionModel.h
index 23b6fba..e61beca 100644
--- a/src/Bpp/Phyl/Model/Codon/AbstractCodonFrequenciesSubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/Codon/AbstractCodonFrequenciesSubstitutionModel.h
@@ -39,7 +39,7 @@
 #ifndef _ABSTRACTCODONFREQUENCIESSUBSTITUTIONMODEL_H_
 #define _ABSTRACTCODONFREQUENCIESSUBSTITUTIONMODEL_H_
 
-#include "AbstractCodonSubstitutionModel.h"
+#include "CodonSubstitutionModel.h"
 #include "../FrequenciesSet/CodonFrequenciesSet.h"
 
 namespace bpp
diff --git a/src/Bpp/Phyl/Model/Codon/AbstractCodonPhaseFrequenciesSubstitutionModel.h b/src/Bpp/Phyl/Model/Codon/AbstractCodonPhaseFrequenciesSubstitutionModel.h
index 69e3cdc..ed7d008 100644
--- a/src/Bpp/Phyl/Model/Codon/AbstractCodonPhaseFrequenciesSubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/Codon/AbstractCodonPhaseFrequenciesSubstitutionModel.h
@@ -39,7 +39,7 @@
 #ifndef _ABSTRACTCODONPHASEFREQUENCIESSUBSTITUTIONMODEL_H_
 #define _ABSTRACTCODONPHASEFREQUENCIESSUBSTITUTIONMODEL_H_
 
-#include "AbstractCodonSubstitutionModel.h"
+#include "CodonSubstitutionModel.h"
 #include "../FrequenciesSet/CodonFrequenciesSet.h"
 
 namespace bpp
diff --git a/src/Bpp/Phyl/Model/Codon/AbstractCodonSubstitutionModel.cpp b/src/Bpp/Phyl/Model/Codon/AbstractCodonSubstitutionModel.cpp
index f6eb83f..1f03d30 100644
--- a/src/Bpp/Phyl/Model/Codon/AbstractCodonSubstitutionModel.cpp
+++ b/src/Bpp/Phyl/Model/Codon/AbstractCodonSubstitutionModel.cpp
@@ -1,5 +1,5 @@
 //
-// File: CodonSubstitutionModel.cpp
+// File: AbstractCodonSubstitutionModel.cpp
 // Created by:  Laurent Gueguen
 // Created on: Feb 2009
 //
diff --git a/src/Bpp/Phyl/Model/Codon/AbstractCodonSubstitutionModel.h b/src/Bpp/Phyl/Model/Codon/AbstractCodonSubstitutionModel.h
index 006fefe..382b677 100644
--- a/src/Bpp/Phyl/Model/Codon/AbstractCodonSubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/Codon/AbstractCodonSubstitutionModel.h
@@ -5,37 +5,37 @@
 //
 
 /*
-   Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
-
-   This software is a computer program whose purpose is to provide classes
-   for phylogenetic data analysis.
-
-   This software is governed by the CeCILL  license under French law and
-   abiding by the rules of distribution of free software.  You can  use,
-   modify and/ or redistribute the software under the terms of the CeCILL
-   license as circulated by CEA, CNRS and INRIA at the following URL
-   "http://www.cecill.info".
-
-   As a counterpart to the access to the source code and  rights to copy,
-   modify and redistribute granted by the license, users are provided only
-   with a limited warranty  and the software's author,  the holder of the
-   economic rights,  and the successive licensors  have only  limited
-   liability.
-
-   In this respect, the user's attention is drawn to the risks associated
-   with loading,  using,  modifying and/or developing or reproducing the
-   software by the user in light of its specific status of free software,
-   that may mean  that it is complicated to manipulate,  and  that  also
-   therefore means  that it is reserved for developers  and  experienced
-   professionals having in-depth computer knowledge. Users are therefore
-   encouraged to load and test the software's suitability as regards their
-   requirements in conditions enabling the security of their systems and/or
-   data to be ensured and,  more generally, to use and operate it in the
-   same conditions as regards security.
-
-   The fact that you are presently reading this means that you have had
-   knowledge of the CeCILL license and that you accept its terms.
- */
+  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
+
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use,
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info".
+
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability.
+
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or
+  data to be ensured and,  more generally, to use and operate it in the
+  same conditions as regards security.
+
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
+*/
 
 #ifndef _ABSTRACTCODONSUBSTITUTIONMODEL_H_
 #define _ABSTRACTCODONSUBSTITUTIONMODEL_H_
@@ -69,53 +69,51 @@ namespace bpp
  * used. Their names have a new prefix, "i_" where i stands for the
  * the phase (1,2 or 3) in the codon.
  */
-class AbstractCodonSubstitutionModel :
-  public virtual CodonSubstitutionModel,
-  public AbstractWordSubstitutionModel
-{
-private:
-  /**
-   * @brief boolean for the parametrization of the position relative
-   * rates. Default : false.
-   */
-  bool hasParametrizedRates_;
-  const GeneticCode* gCode_;
-
-public:
-  const GeneticCode* getGeneticCode() const { return gCode_; }
-  
-  /**
-   * @brief Build a new AbstractCodonSubstitutionModel object from
-   * a pointer to a NucleotideSubstitutionModel.
-   *
-   * @param gCode a pointer toward a genetic code. The codon alphabet from the genetic code will be used by the model class.
-   * @param pmod pointer to the NucleotideSubstitutionModel to use in
-   *        the three positions. It is owned by the instance.
-   * @param st string of the Namespace
-   * @param paramRates boolean concerning the presence of position
-   * relative rates (default: false)
-   */
-  AbstractCodonSubstitutionModel(
+  class AbstractCodonSubstitutionModel :
+    public virtual CodonSubstitutionModel,
+    public AbstractWordSubstitutionModel
+  {
+  private:
+    /**
+     * @brief boolean for the parametrization of the position relative
+     * rates. Default : false.
+     */
+    bool hasParametrizedRates_;
+    const GeneticCode* gCode_;
+
+  public:
+    /**
+     * @brief Build a new AbstractCodonSubstitutionModel object from
+     * a pointer to a NucleotideSubstitutionModel.
+     *
+     * @param gCode a pointer toward a genetic code. The codon alphabet from the genetic code will be used by the model class.
+     * @param pmod pointer to the NucleotideSubstitutionModel to use in
+     *        the three positions. It is owned by the instance.
+     * @param st string of the Namespace
+     * @param paramRates boolean concerning the presence of position
+     * relative rates (default: false)
+     */
+    AbstractCodonSubstitutionModel(
       const GeneticCode* gCode,
       NucleotideSubstitutionModel* pmod,
       const std::string& st,
       bool paramRates = false);
 
-  /**
-   * @brief Build a new AbstractCodonSubstitutionModel object
-   * from three pointers to NucleotideSubstitutionModels.
-   *
-   * @param gCode a pointer toward a genetic code. This model instance will own the underlying GeneticCode object and delete it when required.
-   *   The codon alphabet from the genetic code will be used by the model class.
-   * @param pmod1, pmod2, pmod3 are pointers to the
-   *   NucleotideSubstitutionModel to use in the three positions.
-   *   All the models must be different objects to avoid redundant
-   *   parameters.  They are owned by the instance.
-   * @param st string of the Namespace
-   * @param paramRates boolean concerning the presence of position
-   * relative rates (default: false)
-   */
-  AbstractCodonSubstitutionModel(
+    /**
+     * @brief Build a new AbstractCodonSubstitutionModel object
+     * from three pointers to NucleotideSubstitutionModels.
+     *
+     * @param gCode a pointer toward a genetic code. This model instance will own the underlying GeneticCode object and delete it when required.
+     *   The codon alphabet from the genetic code will be used by the model class.
+     * @param pmod1, pmod2, pmod3 are pointers to the
+     *   NucleotideSubstitutionModel to use in the three positions.
+     *   All the models must be different objects to avoid redundant
+     *   parameters.  They are owned by the instance.
+     * @param st string of the Namespace
+     * @param paramRates boolean concerning the presence of position
+     * relative rates (default: false)
+     */
+    AbstractCodonSubstitutionModel(
       const GeneticCode* gCode,
       NucleotideSubstitutionModel* pmod1,
       NucleotideSubstitutionModel* pmod2,
@@ -123,52 +121,49 @@ public:
       const std::string& st,
       bool paramRates = false);
 
-  virtual ~AbstractCodonSubstitutionModel() {}
-
-  AbstractCodonSubstitutionModel(const AbstractCodonSubstitutionModel& model) :
-    AbstractParameterAliasable(model),
-    AbstractWordSubstitutionModel(model),
-    hasParametrizedRates_(model.hasParametrizedRates_),
-    gCode_(model.gCode_)
-  {}
-
-  AbstractCodonSubstitutionModel& operator=(const AbstractCodonSubstitutionModel& model)
-  {
-    AbstractParameterAliasable::operator=(model);
-    AbstractSubstitutionModel::operator=(model);
-    AbstractWordSubstitutionModel::operator=(model);
-    hasParametrizedRates_ = model.hasParametrizedRates_;
-    gCode_ = model.gCode_;
-    return *this;
-  }
-
-#ifndef NO_VIRTUAL_COV
-  AbstractCodonSubstitutionModel*
-#else
-  Clonable*
-#endif
-  clone() const = 0;
-
-protected:
-  /**
-   * @brief Method inherited from AbstractWordSubstitutionModel
-   *
-   * This method sets the rates to/from stop codons to zero and
-   * performs the multiplication by the specific codon-codon rate.
-   */
-  void completeMatrices();
-
-public:
-  void updateMatrices();
-
-  /**
-   * @brief Method inherited from CodonSubstitutionModel
-   *
-   * Here this methods returns 1;
-   *
-   **/
-  virtual double getCodonsMulRate(size_t i, size_t j) const { return 1.; }
-};
+    virtual ~AbstractCodonSubstitutionModel() {}
+
+    AbstractCodonSubstitutionModel(const AbstractCodonSubstitutionModel& model) :
+      AbstractParameterAliasable(model),
+      AbstractWordSubstitutionModel(model),
+      hasParametrizedRates_(model.hasParametrizedRates_),
+      gCode_(model.gCode_)
+    {}
+
+    AbstractCodonSubstitutionModel& operator=(const AbstractCodonSubstitutionModel& model)
+    {
+      AbstractParameterAliasable::operator=(model);
+      AbstractSubstitutionModel::operator=(model);
+      AbstractWordSubstitutionModel::operator=(model);
+      hasParametrizedRates_ = model.hasParametrizedRates_;
+      gCode_ = model.gCode_;
+      return *this;
+    }
+
+    AbstractCodonSubstitutionModel* clone() const = 0;
+
+  protected:
+    /**
+     * @brief Method inherited from AbstractWordSubstitutionModel
+     *
+     * This method sets the rates to/from stop codons to zero and
+     * performs the multiplication by the specific codon-codon rate.
+     */
+    void completeMatrices();
+
+  public:
+    void updateMatrices();
+
+    const GeneticCode* getGeneticCode() const { return gCode_; }
+  
+    /**
+     * @brief Method inherited from CodonSubstitutionModel
+     *
+     * Here this methods returns 1;
+     *
+     **/
+    virtual double getCodonsMulRate(size_t i, size_t j) const { return 1.; }
+  };
 } // end of namespace bpp.
 
 #endif
diff --git a/src/Bpp/Phyl/Model/Codon/AbstractCodonSubstitutionModel.cpp b/src/Bpp/Phyl/Model/Codon/AbstractKroneckerCodonSubstitutionModel.cpp
similarity index 55%
copy from src/Bpp/Phyl/Model/Codon/AbstractCodonSubstitutionModel.cpp
copy to src/Bpp/Phyl/Model/Codon/AbstractKroneckerCodonSubstitutionModel.cpp
index f6eb83f..1d6255f 100644
--- a/src/Bpp/Phyl/Model/Codon/AbstractCodonSubstitutionModel.cpp
+++ b/src/Bpp/Phyl/Model/Codon/AbstractKroneckerCodonSubstitutionModel.cpp
@@ -1,7 +1,7 @@
 //
-// File: CodonSubstitutionModel.cpp
+// File: AbstractKroneckerCodonSubstitutionModel.cpp
 // Created by:  Laurent Gueguen
-// Created on: Feb 2009
+// Created on: mardi 26 juillet 2016, à 19h 00
 //
 
 /*
@@ -36,7 +36,7 @@
    knowledge of the CeCILL license and that you accept its terms.
  */
 
-#include "AbstractCodonSubstitutionModel.h"
+#include "AbstractKroneckerCodonSubstitutionModel.h"
 
 using namespace bpp;
 
@@ -44,14 +44,12 @@ using namespace std;
 
 /******************************************************************************/
 
-AbstractCodonSubstitutionModel::AbstractCodonSubstitutionModel(
+AbstractKroneckerCodonSubstitutionModel::AbstractKroneckerCodonSubstitutionModel(
   const GeneticCode* gCode,
   NucleotideSubstitutionModel* pmod,
-  const std::string& prefix,
-  bool paramRates) :
+  const std::string& prefix) :
   AbstractParameterAliasable(prefix),
-  AbstractWordSubstitutionModel(gCode->getSourceAlphabet(), new CanonicalStateMap(gCode->getSourceAlphabet(), false), prefix),
-  hasParametrizedRates_(paramRates),
+  AbstractKroneckerWordSubstitutionModel(gCode->getSourceAlphabet(), new CanonicalStateMap(gCode->getSourceAlphabet(), false), prefix),
   gCode_(gCode)
 {
   enableEigenDecomposition(true);
@@ -67,36 +65,45 @@ AbstractCodonSubstitutionModel::AbstractCodonSubstitutionModel(
   pmod->enableEigenDecomposition(0);
   addParameters_(pmod->getParameters());
 
-  Vrate_.resize(3);
-  for (i = 0; i < 3; i++)
-  {
-    Vrate_[i] = 1.0 / 3;
-  }
+  initGenerators_();
+}
 
+AbstractKroneckerCodonSubstitutionModel::AbstractKroneckerCodonSubstitutionModel(
+  const GeneticCode* gCode,
+  NucleotideSubstitutionModel* pmod,
+  const std::vector<std::set< size_t> >& vPos,
+  const std::string& prefix) :
+  AbstractParameterAliasable(prefix),
+  AbstractKroneckerWordSubstitutionModel(gCode->getSourceAlphabet(), new CanonicalStateMap(gCode->getSourceAlphabet(), false), prefix),
+  gCode_(gCode)
+{
+  enableEigenDecomposition(true);
 
-  if (hasParametrizedRates_)
+  size_t i;
+  for (i = 0; i < 3; i++)
   {
-    // relative rates
-    for (i = 0; i < 2; i++)
-    {
-      addParameter_(new Parameter(prefix + "relrate" + TextTools::toString(i + 1), 1.0 / static_cast<double>(3 - i), &Parameter::PROP_CONSTRAINT_EX));
-    }
+    VSubMod_.push_back(pmod);
+    VnestedPrefix_.push_back(pmod->getNamespace());
   }
+  pmod->setNamespace(prefix + "123_" + VnestedPrefix_[0]);
+  pmod->enableEigenDecomposition(0);
+  addParameters_(pmod->getParameters());
+
+  initGenerators_();
+  setChangingPositions(vPos);
 }
 
-AbstractCodonSubstitutionModel::AbstractCodonSubstitutionModel(
+AbstractKroneckerCodonSubstitutionModel::AbstractKroneckerCodonSubstitutionModel(
   const GeneticCode* gCode,
   NucleotideSubstitutionModel* pmod1,
   NucleotideSubstitutionModel* pmod2,
   NucleotideSubstitutionModel* pmod3,
-  const std::string& prefix,
-  bool paramRates) :
+  const std::string& prefix) :
   AbstractParameterAliasable(prefix),
-  AbstractWordSubstitutionModel(gCode->getSourceAlphabet(), new CanonicalStateMap(gCode->getSourceAlphabet(), false), prefix),
-  hasParametrizedRates_(paramRates),
+  AbstractKroneckerWordSubstitutionModel(gCode->getSourceAlphabet(), new CanonicalStateMap(gCode->getSourceAlphabet(), false), prefix),
   gCode_(gCode)
 {
-  enableEigenDecomposition(1);
+  enableEigenDecomposition(true);
 
   if ((pmod1 == pmod2) || (pmod2 == pmod3) || (pmod1 == pmod3))
   {
@@ -130,47 +137,61 @@ AbstractCodonSubstitutionModel::AbstractCodonSubstitutionModel(
     VSubMod_[2]->enableEigenDecomposition(0);
     addParameters_(pmod3->getParameters());
   }
+  initGenerators_();
+}
 
-  Vrate_.resize(3);
-  for (size_t i = 0; i < 3; ++i)
-  {
-    Vrate_[i] = 1.0 / 3;
-  }
+AbstractKroneckerCodonSubstitutionModel::AbstractKroneckerCodonSubstitutionModel(
+  const GeneticCode* gCode,
+  NucleotideSubstitutionModel* pmod1,
+  NucleotideSubstitutionModel* pmod2,
+  NucleotideSubstitutionModel* pmod3,
+  const std::vector<std::set< size_t> >& vPos,
+  const std::string& prefix) :
+  AbstractParameterAliasable(prefix),
+  AbstractKroneckerWordSubstitutionModel(gCode->getSourceAlphabet(), new CanonicalStateMap(gCode->getSourceAlphabet(), false), prefix),
+  gCode_(gCode)
+{
+  enableEigenDecomposition(true);
 
-  if (hasParametrizedRates_)
+  if ((pmod1 == pmod2) || (pmod2 == pmod3) || (pmod1 == pmod3))
   {
-    // relative rates
-    for (int i = 0; i < 2; ++i)
+    for (size_t i = 0; i < 3; ++i)
     {
-      addParameter_(new Parameter(prefix + "relrate" + TextTools::toString(i + 1), 1.0 / (3.0 - i), &Parameter::PROP_CONSTRAINT_EX));
+      VSubMod_.push_back(pmod1);
+      VnestedPrefix_.push_back(pmod1->getNamespace());
     }
-  }
-}
 
-void AbstractCodonSubstitutionModel::updateMatrices()
-{
-  if (hasParametrizedRates_)
+    pmod1->setNamespace(prefix + "123_" + VnestedPrefix_[0]);
+    pmod1->enableEigenDecomposition(0);
+    addParameters_(pmod1->getParameters());
+  }
+  else
   {
-    size_t i, nbmod = VSubMod_.size();
-    double x;
-    size_t k;
-    for (k = nbmod - 1; k > 0; k--)
-    {
-      x = 1.0;
-      for (i = 0; i < k; i++)
-      {
-        x *= 1 - getParameterValue("relrate" + TextTools::toString(i + 1));
-      }
-      if (k != nbmod - 1)
-        x *= getParameterValue("relrate" + TextTools::toString(k + 1));
-      Vrate_[k] = x;
-    }
+    VSubMod_.push_back(pmod1);
+    VnestedPrefix_.push_back(pmod1->getNamespace());
+    VSubMod_[0]->setNamespace(prefix + "1_" + VnestedPrefix_[0]);
+    VSubMod_[0]->enableEigenDecomposition(0);
+    addParameters_(pmod1->getParameters());
+
+    VSubMod_.push_back(pmod2);
+    VnestedPrefix_.push_back(pmod2->getNamespace());
+    VSubMod_[1]->setNamespace(prefix + "2_" + VnestedPrefix_[1]);
+    VSubMod_[1]->enableEigenDecomposition(0);
+    addParameters_(pmod2->getParameters());
+
+    VSubMod_.push_back(pmod3);
+    VnestedPrefix_.push_back(pmod3->getNamespace());
+    VSubMod_[2]->setNamespace(prefix + "3_" + VnestedPrefix_[2]);
+    VSubMod_[2]->enableEigenDecomposition(0);
+    addParameters_(pmod3->getParameters());
   }
 
-  AbstractWordSubstitutionModel::updateMatrices();
+  initGenerators_();
+  setChangingPositions(vPos);
 }
 
-void AbstractCodonSubstitutionModel::completeMatrices()
+
+void AbstractKroneckerCodonSubstitutionModel::completeMatrices()
 {
   size_t i, j;
   size_t salph = getNumberOfStates();
diff --git a/src/Bpp/Phyl/Model/Codon/AbstractKroneckerCodonSubstitutionModel.h b/src/Bpp/Phyl/Model/Codon/AbstractKroneckerCodonSubstitutionModel.h
new file mode 100644
index 0000000..f1fdc11
--- /dev/null
+++ b/src/Bpp/Phyl/Model/Codon/AbstractKroneckerCodonSubstitutionModel.h
@@ -0,0 +1,201 @@
+//
+// File: AbstractKroneckerCodonSubstitutionModel.h
+// Created by: Laurent Gueguen
+// Created on: mardi 26 juillet 2016, à 21h 15
+//
+
+/*
+  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
+
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use,
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info".
+
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability.
+
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or
+  data to be ensured and,  more generally, to use and operate it in the
+  same conditions as regards security.
+
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
+*/
+
+#ifndef _ABSTRACT_KRONECKER_CODON_SUBSTITUTIONMODEL_H_
+#define _ABSTRACT_KRONECKER_CODON_SUBSTITUTIONMODEL_H_
+
+#include "../AbstractKroneckerWordSubstitutionModel.h"
+#include "../Nucleotide/NucleotideSubstitutionModel.h"
+#include "CodonSubstitutionModel.h"
+
+// From bpp-seq:
+#include <Bpp/Seq/GeneticCode/GeneticCode.h>
+
+// From the STL:
+#include <memory>
+#include <set>
+
+namespace bpp
+{
+/**
+ * @brief Abstract class for substitution models on codons allowing
+ * multiple substitutions.
+ *
+ * Rates of multiple substitutions equal the product of single
+ * substitutions involved, before removing stop codons.
+ *
+ * @author Laurent Guéguen
+ *
+ * Objects of this class are built from either one (repeated three
+ * times) or three different substitution models of NucleicAlphabets.
+ * No model is directly accessible. </p>
+ *
+ * The parameters of this codon are the same as the ones of the models
+ * used. Their names have a new prefix, "i_" where i stands for the
+ * the phase (1,2 or 3) in the codon.
+ */
+
+  class AbstractKroneckerCodonSubstitutionModel :
+    public virtual CodonSubstitutionModel,
+    public AbstractKroneckerWordSubstitutionModel
+  {
+  private:
+    const GeneticCode* gCode_;
+
+  public:
+    /**
+     * @brief Build a new AbstractKroneckerCodonSubstitutionModel object from
+     * a pointer to a NucleotideSubstitutionModel.
+     *
+     * @param gCode a pointer toward a genetic code. The codon alphabet from the genetic code will be used by the model class.
+     * @param pmod pointer to the NucleotideSubstitutionModel to use in
+     *        the three positions. It is owned by the instance.
+     * @param st string of the Namespace
+     */
+    
+    AbstractKroneckerCodonSubstitutionModel(
+      const GeneticCode* gCode,
+      NucleotideSubstitutionModel* pmod,
+      const std::string& st);
+
+    /**
+     * @brief Build a new AbstractKroneckerCodonSubstitutionModel object from
+     * a pointer to a NucleotideSubstitutionModel.
+     *
+     * @param gCode a pointer toward a genetic code. The codon alphabet from the genetic code will be used by the model class.
+     * @param pmod pointer to the NucleotideSubstitutionModel to use in
+     *        the three positions. It is owned by the instance.
+     * @param vPos a vector of sets of simultaneously changing
+     *   positions.
+     * @param st string of the Namespace
+     */
+
+    AbstractKroneckerCodonSubstitutionModel(
+      const GeneticCode* gCode,
+      NucleotideSubstitutionModel* pmod,
+      const std::vector<std::set< size_t> >& vPos,
+      const std::string& st);
+
+    /**
+     * @brief Build a new AbstractKroneckerCodonSubstitutionModel object
+     * from three pointers to NucleotideSubstitutionModels.
+     *
+     * @param gCode a pointer toward a genetic code. This model instance will own the underlying GeneticCode object and delete it when required.
+     *   The codon alphabet from the genetic code will be used by the model class.
+     * @param pmod1, pmod2, pmod3 are pointers to the
+     *   NucleotideSubstitutionModel to use in the three positions.
+     *   All the models must be different objects to avoid redundant
+     *   parameters.  They are owned by the instance.
+     * @param st string of the Namespace
+     */
+    
+    AbstractKroneckerCodonSubstitutionModel(
+      const GeneticCode* gCode,
+      NucleotideSubstitutionModel* pmod1,
+      NucleotideSubstitutionModel* pmod2,
+      NucleotideSubstitutionModel* pmod3,
+      const std::string& st);
+
+    /**
+     * @brief Build a new AbstractKroneckerCodonSubstitutionModel object
+     * from three pointers to NucleotideSubstitutionModels.
+     *
+     * @param gCode a pointer toward a genetic code. This model instance will own the underlying GeneticCode object and delete it when required.
+     *   The codon alphabet from the genetic code will be used by the model class.
+     * @param pmod1, pmod2, pmod3 are pointers to the
+     *   NucleotideSubstitutionModel to use in the three positions.
+     *   All the models must be different objects to avoid redundant
+     *   parameters.  They are owned by the instance.
+     * @param vPos a vector of sets of simultaneously changing
+     *   positions.
+     * @param st string of the Namespace
+     */
+    
+    AbstractKroneckerCodonSubstitutionModel(
+      const GeneticCode* gCode,
+      NucleotideSubstitutionModel* pmod1,
+      NucleotideSubstitutionModel* pmod2,
+      NucleotideSubstitutionModel* pmod3,
+      const std::vector<std::set< size_t> >& vPos,
+      const std::string& st);
+
+    virtual ~AbstractKroneckerCodonSubstitutionModel() {}
+
+    AbstractKroneckerCodonSubstitutionModel(const AbstractKroneckerCodonSubstitutionModel& model) :
+      AbstractParameterAliasable(model),
+      AbstractKroneckerWordSubstitutionModel(model),
+      gCode_(model.gCode_)
+    {}
+
+    AbstractKroneckerCodonSubstitutionModel& operator=(const AbstractKroneckerCodonSubstitutionModel& model)
+    {
+      AbstractParameterAliasable::operator=(model);
+      AbstractKroneckerWordSubstitutionModel::operator=(model);
+      gCode_ = model.gCode_;
+      return *this;
+    }
+
+    AbstractKroneckerCodonSubstitutionModel* clone() const = 0;
+
+  protected:
+    /**
+     * @brief Method inherited from AbstractWordSubstitutionModel
+     *
+     * This method sets the rates to/from stop codons to zero and
+     * performs the multiplication by the specific codon-codon rate.
+     */
+    void completeMatrices();
+
+  public:
+
+    const GeneticCode* getGeneticCode() const { return gCode_; }
+
+    /**
+     * @brief Method inherited from CodonSubstitutionModel
+     *
+     * Here this methods returns 1;
+     *
+     **/
+
+    virtual double getCodonsMulRate(size_t i, size_t j) const { return 1.; }
+  };
+} // end of namespace bpp.
+
+#endif // _ABSTRACT_KRONECKER_CODON_SUBSTITUTIONMODEL_H_
+
diff --git a/src/Bpp/Phyl/Model/Codon/CodonDistanceCpGSubstitutionModel.cpp b/src/Bpp/Phyl/Model/Codon/CodonDistanceCpGSubstitutionModel.cpp
new file mode 100644
index 0000000..c0121dc
--- /dev/null
+++ b/src/Bpp/Phyl/Model/Codon/CodonDistanceCpGSubstitutionModel.cpp
@@ -0,0 +1,93 @@
+//
+// File: CodonDistanceSubstitutionModel.cpp
+// Created by:  Laurent Gueguen
+// Created on: Feb 2009
+//
+
+/*
+  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
+
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use,
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info".
+
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability.
+
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or
+  data to be ensured and,  more generally, to use and operate it in the
+  same conditions as regards security.
+
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
+*/
+
+#include "CodonDistanceCpGSubstitutionModel.h"
+
+using namespace bpp;
+
+using namespace std;
+
+/******************************************************************************/
+
+CodonDistanceCpGSubstitutionModel::CodonDistanceCpGSubstitutionModel(
+    const GeneticCode* gCode,
+    NucleotideSubstitutionModel* pmod,
+    const AlphabetIndex2* pdist) :
+  AbstractParameterAliasable("CodonDistCpG."),
+  AbstractCodonSubstitutionModel(gCode, pmod, "CodonDistCpG."),
+  AbstractCodonDistanceSubstitutionModel(pdist, "CodonDistCpG."),
+  AbstractCodonCpGSubstitutionModel("CodonDistCpG.")
+{
+  updateMatrices();
+}
+
+CodonDistanceCpGSubstitutionModel::CodonDistanceCpGSubstitutionModel(
+    const GeneticCode* gCode,
+    NucleotideSubstitutionModel* pmod1,
+    NucleotideSubstitutionModel* pmod2,
+    NucleotideSubstitutionModel* pmod3,
+    const AlphabetIndex2* pdist) :
+  AbstractParameterAliasable("CodonDistCpG."),
+  AbstractCodonSubstitutionModel(gCode, pmod1, pmod2, pmod3, "CodonDistCpG."),
+  AbstractCodonDistanceSubstitutionModel(pdist, "CodonDistCpG."),
+  AbstractCodonCpGSubstitutionModel("CodonDistCpG.")
+{
+  updateMatrices();
+}
+
+std::string CodonDistanceCpGSubstitutionModel::getName() const
+{
+  return "CodonDistCpG";
+}
+
+void CodonDistanceCpGSubstitutionModel::fireParameterChanged(const ParameterList& parameters)
+{
+  AbstractCodonDistanceSubstitutionModel::fireParameterChanged(parameters);
+  AbstractCodonCpGSubstitutionModel::fireParameterChanged(parameters);
+
+  // Beware: must be call at the end
+  AbstractCodonSubstitutionModel::fireParameterChanged(parameters);
+}
+
+double CodonDistanceCpGSubstitutionModel::getCodonsMulRate(size_t i, size_t j) const
+{
+  return AbstractCodonDistanceSubstitutionModel::getCodonsMulRate(i,j)
+    * AbstractCodonCpGSubstitutionModel::getCodonsMulRate(i,j)
+    * AbstractCodonSubstitutionModel::getCodonsMulRate(i,j);
+}
+
diff --git a/src/Bpp/Phyl/Model/Codon/CodonDistanceCpGSubstitutionModel.h b/src/Bpp/Phyl/Model/Codon/CodonDistanceCpGSubstitutionModel.h
new file mode 100644
index 0000000..d3ac593
--- /dev/null
+++ b/src/Bpp/Phyl/Model/Codon/CodonDistanceCpGSubstitutionModel.h
@@ -0,0 +1,133 @@
+//
+// File: CodonDistanceCpGSubstitutionModel.h
+// Created by: Laurent Gueguen
+// Created on: Tue Dec 24 11:03:53 2003
+//
+
+/*
+  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
+
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use,
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info".
+
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability.
+
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or
+  data to be ensured and,  more generally, to use and operate it in the
+  same conditions as regards security.
+
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
+*/
+
+#ifndef _CODONDISTANCECPGSUBSTITUTIONMODEL_H_
+#define _CODONDISTANCECPGSUBSTITUTIONMODEL_H_
+
+#include "AbstractCodonDistanceSubstitutionModel.h"
+#include "AbstractCodonCpGSubstitutionModel.h"
+#include "AbstractCodonSubstitutionModel.h"
+
+namespace bpp
+{
+  /**
+   * @brief Class for substitution models of codons with
+   * non-synonymous/synonymous ratios of substitution rates defined
+   * through a distance between amino-acids, with additional INSIDE
+   * codons CpG hypermutability rate multiplier (parameter \c "rho").
+   *
+   *
+   * @author Laurent Guéguen
+   *
+   * Objects of this class are built from three substitution models of
+   * NucleicAlphabets. No model is directly accessible. </p>
+   *
+   * Only substitutions with one letter changed are accepted. </p>
+   *
+   * If a distance @f$d at f$ between amino-acids is defined, the ratio between
+   * non-synonymous and synonymous substitutions rates is, if the codied
+   * amino-acids are @f$x at f$ and @f$y at f$, @f$\beta*\exp(-\alpha.d(x,y))@f$ with
+   * non-negative parameter \c "alpha" and positive parameter \c "beta".
+   *
+   * If such a distance is not defined, the ratio between non-synonymous
+   * and synonymous substitutions rates is @f$\beta at f$ with positive
+   * parameter \c "beta".
+   *
+   */
+
+  class CodonDistanceCpGSubstitutionModel :
+    public AbstractCodonSubstitutionModel,
+    public AbstractCodonDistanceSubstitutionModel,
+    public AbstractCodonCpGSubstitutionModel
+  {
+  public:
+    /**
+     * @brief Build a new CodonDistanceCpGSubstitutionModel object from
+     * a pointer to NucleotideSubstitutionModel.
+     *
+     * @param gCode pointer to a GeneticCode
+     * @param pmod  pointer to the NucleotideSubstitutionModel to use in the three positions.
+     * The instance will then own this substitution model.
+     * @param pdist optional pointer to a distance between amino-acids
+     */
+
+    CodonDistanceCpGSubstitutionModel(
+        const GeneticCode* gCode,
+        NucleotideSubstitutionModel* pmod,
+        const AlphabetIndex2* pdist);
+
+    /**
+     * @brief Build a new CodonDistanceCpGSubstitutionModel object
+     * from three pointers to NucleotideSubstitutionModels.
+     *
+     * @param gCode pointer to a GeneticCode
+     * @param pmod1, pmod2, pmod3 pointers to the
+     *   NucleotideSubstitutionModels to use in the three positions.
+     *   Either all the models are different objects to avoid parameters
+     *   redondancy, or only the first model is used in every position.
+     *   The used models are owned by the instance.
+     * @param pdist optional pointer to the AlphabetIndex2 amino-acids distance object.
+     */
+
+    CodonDistanceCpGSubstitutionModel(
+        const GeneticCode* gCode,
+        NucleotideSubstitutionModel* pmod1,
+        NucleotideSubstitutionModel* pmod2,
+        NucleotideSubstitutionModel* pmod3,
+        const AlphabetIndex2* pdist);
+
+    virtual ~CodonDistanceCpGSubstitutionModel() {}
+
+    CodonDistanceCpGSubstitutionModel* clone() const
+    {
+      return new CodonDistanceCpGSubstitutionModel(*this);
+    }
+
+  public:
+    void fireParameterChanged(const ParameterList& parameterlist);
+  
+    std::string getName() const;
+
+    double getCodonsMulRate(size_t i, size_t j) const;
+  };
+  
+} // end of namespace bpp.
+
+#endif //_CODONDISTANCECPGSUBSTITUTIONMODEL_H_
+
diff --git a/src/Bpp/Phyl/Model/Codon/CodonDistanceFrequenciesSubstitutionModel.h b/src/Bpp/Phyl/Model/Codon/CodonDistanceFrequenciesSubstitutionModel.h
index 2d2e999..534e08b 100644
--- a/src/Bpp/Phyl/Model/Codon/CodonDistanceFrequenciesSubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/Codon/CodonDistanceFrequenciesSubstitutionModel.h
@@ -74,14 +74,16 @@ namespace bpp
  *  rate is multiplied with @f$\beta at f$ with positive parameter \c
  *  "beta" (ie @f$d=0 at f$).
  *
+ * If such a distance is not defined, the ratio between non-synonymous
+ * and synonymous substitutions rates is @f$\beta at f$ with positive
+ * parameter \c "beta".
+ *
  * If paramSynRate is true, the synonymous substitution rate is
  *  multiplied with @f$\gamma at f$ (with optional positive parameter \c
  *  "gamma"), else it is multiplied with 1.
  *
- * If such a distance is not defined, the ratio between non-synonymous
- * and synonymous substitutions rates is @f$\beta at f$ with positive
- * parameter \c "beta".
  */
+  
 class CodonDistanceFrequenciesSubstitutionModel :
     public AbstractCodonSubstitutionModel,
     public AbstractCodonDistanceSubstitutionModel,
diff --git a/src/Bpp/Phyl/Model/Codon/CodonRateFrequenciesSubstitutionModel.h b/src/Bpp/Phyl/Model/Codon/CodonRateFrequenciesSubstitutionModel.h
index 9e0612e..0207314 100644
--- a/src/Bpp/Phyl/Model/Codon/CodonRateFrequenciesSubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/Codon/CodonRateFrequenciesSubstitutionModel.h
@@ -104,12 +104,7 @@ public:
 
   virtual ~CodonRateFrequenciesSubstitutionModel(){}
 
-#ifndef NO_VIRTUAL_COV
-  CodonRateFrequenciesSubstitutionModel*
-#else
-  Clonable*
-#endif
-  clone() const { return new CodonRateFrequenciesSubstitutionModel(*this); }
+  CodonRateFrequenciesSubstitutionModel* clone() const { return new CodonRateFrequenciesSubstitutionModel(*this); }
 
 public:
   void fireParameterChanged(const ParameterList& parameterlist);
diff --git a/src/Bpp/Phyl/Model/Codon/CodonRateSubstitutionModel.cpp b/src/Bpp/Phyl/Model/Codon/CodonRateSubstitutionModel.cpp
index 13dba94..894251b 100644
--- a/src/Bpp/Phyl/Model/Codon/CodonRateSubstitutionModel.cpp
+++ b/src/Bpp/Phyl/Model/Codon/CodonRateSubstitutionModel.cpp
@@ -70,13 +70,4 @@ std::string CodonRateSubstitutionModel::getName() const
   return "CodonRate";
 }
 
-void CodonRateSubstitutionModel::fireParameterChanged(const ParameterList& parameters)
-{
-  AbstractCodonSubstitutionModel::fireParameterChanged(parameters);
-}
-
-double CodonRateSubstitutionModel::getCodonsMulRate(size_t i, size_t j) const
-{
-  return AbstractCodonSubstitutionModel::getCodonsMulRate(i,j);
-}
 
diff --git a/src/Bpp/Phyl/Model/Codon/CodonRateSubstitutionModel.h b/src/Bpp/Phyl/Model/Codon/CodonRateSubstitutionModel.h
index 40d85a7..341d53e 100644
--- a/src/Bpp/Phyl/Model/Codon/CodonRateSubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/Codon/CodonRateSubstitutionModel.h
@@ -97,11 +97,8 @@ public:
   clone() const { return new CodonRateSubstitutionModel(*this); }
 
 public:
-  void fireParameterChanged(const ParameterList& parameterlist);
-  
   std::string getName() const;
 
-  double getCodonsMulRate(size_t i, size_t j) const;
 };
 
 } // end of namespace bpp.
diff --git a/src/Bpp/Phyl/Model/Codon/CodonSubstitutionModel.h b/src/Bpp/Phyl/Model/Codon/CodonSubstitutionModel.h
index b72deb4..d7a6648 100644
--- a/src/Bpp/Phyl/Model/Codon/CodonSubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/Codon/CodonSubstitutionModel.h
@@ -40,8 +40,6 @@
 #ifndef _CODONSUBSTITUTIONMODEL_H_
 #define _CODONSUBSTITUTIONMODEL_H_
 
-#include <Bpp/Numeric/ParameterAliasable.h>
-
 //From bpp-seq:
 #include <Bpp/Seq/GeneticCode/GeneticCode.h>
 
@@ -63,9 +61,7 @@ namespace bpp
     CodonSubstitutionModel() {}
     virtual ~CodonSubstitutionModel() {}
 
-#ifndef NO_VIRTUAL_COV
     virtual CodonSubstitutionModel* clone() const = 0;
-#endif
 
   public:
 
@@ -80,6 +76,22 @@ namespace bpp
     virtual double getCodonsMulRate(size_t, size_t) const = 0;
   };
   
+  
+  /**
+   * @brief Abstract class for reversible codon models
+   * @author Julien Dutheil
+   */
+  class CodonReversibleSubstitutionModel:
+    public virtual CodonSubstitutionModel,
+    public virtual ReversibleSubstitutionModel 
+  {
+  public:
+    CodonReversibleSubstitutionModel() {}
+    virtual ~CodonReversibleSubstitutionModel() {}
+
+    virtual CodonReversibleSubstitutionModel* clone() const = 0;
+  };
+
 } // end of namespace bpp.
 
 #endif
diff --git a/src/Bpp/Phyl/Model/Codon/GY94.h b/src/Bpp/Phyl/Model/Codon/GY94.h
index 78ba1c0..fabea3a 100644
--- a/src/Bpp/Phyl/Model/Codon/GY94.h
+++ b/src/Bpp/Phyl/Model/Codon/GY94.h
@@ -86,7 +86,7 @@ class GY94:
 private:
 
   GranthamAAChemicalDistance gacd_;
-  std::auto_ptr<CodonDistanceFrequenciesSubstitutionModel> pmodel_;
+  std::unique_ptr<CodonDistanceFrequenciesSubstitutionModel> pmodel_;
 
 public:
   GY94(const GeneticCode* gc, FrequenciesSet* codonFreqs);
diff --git a/src/Bpp/Phyl/Model/Codon/CodonRateSubstitutionModel.cpp b/src/Bpp/Phyl/Model/Codon/KCM.cpp
similarity index 52%
copy from src/Bpp/Phyl/Model/Codon/CodonRateSubstitutionModel.cpp
copy to src/Bpp/Phyl/Model/Codon/KCM.cpp
index 13dba94..dfea0c4 100644
--- a/src/Bpp/Phyl/Model/Codon/CodonRateSubstitutionModel.cpp
+++ b/src/Bpp/Phyl/Model/Codon/KCM.cpp
@@ -1,7 +1,7 @@
 //
-// File: CodonSubstitutionModel.cpp
+// File: KCM.cpp
 // Created by:  Laurent Gueguen
-// Created on: Feb 2009
+// Created on: vendredi 23 septembre 2016, à 11h 39
 //
 
 /*
@@ -36,8 +36,11 @@
    knowledge of the CeCILL license and that you accept its terms.
  */
 
-#include "CodonRateSubstitutionModel.h"
+#include "KCM.h"
+#include "../Nucleotide/GTR.h"
 
+#include "../FrequenciesSet/CodonFrequenciesSet.h"
+#include <Bpp/Numeric/NumConstants.h>
 
 using namespace bpp;
 
@@ -45,38 +48,55 @@ using namespace std;
 
 /******************************************************************************/
 
-CodonRateSubstitutionModel::CodonRateSubstitutionModel(
-    const GeneticCode* gCode,
-    NucleotideSubstitutionModel* pmod) :
-  AbstractParameterAliasable("CodonRate."),
-  AbstractCodonSubstitutionModel(gCode, pmod, "CodonRate.", true)
+KCM::KCM(const GeneticCode* gc, bool oneModel) :
+  AbstractBiblioSubstitutionModel("KCM"+string(oneModel?"7":"19")+"."),
+  pmodel_(),
+  oneModel_(oneModel)
 {
-  updateMatrices();
-}
+  const NucleicAlphabet* nalph=dynamic_cast<const CodonAlphabet*>(gc->getSourceAlphabet())->getNucleicAlphabet();
+  
+  if (oneModel)
+    pmodel_.reset(new KroneckerCodonDistanceSubstitutionModel(gc, new GTR(nalph)));
+  else
+    pmodel_.reset(new KroneckerCodonDistanceSubstitutionModel(gc, new GTR(nalph), new GTR(nalph), new GTR(nalph)));
+
+  string name="KCM"+string(oneModel?"7":"19")+".";
+
+  pmodel_->setNamespace(name);
+
+  addParameters_(pmodel_->getParameters());
+
+  getParameter_("beta").setName(name+"omega"),
+  // deleteParameter("KCM.beta")N
+
+  
+  // addParameter(new Parameter("KCM.omega", 1, new IntervalConstraint(NumConstants::MILLI(), 999, true, true), true));
+
+  lParPmodel_.addParameters(pmodel_->getParameters());
+
+  vector<std::string> v = lParPmodel_.getParameterNames();
+
+  for (size_t i = 0; i < v.size(); i++)
+    mapParNamesFromPmodel_[v[i]] = getParameterNameWithoutNamespace(v[i]);
+
+  mapParNamesFromPmodel_[name+"beta"] = "omega";
 
-CodonRateSubstitutionModel::CodonRateSubstitutionModel(
-    const GeneticCode* gCode,
-    NucleotideSubstitutionModel* pmod1,
-    NucleotideSubstitutionModel* pmod2,
-    NucleotideSubstitutionModel* pmod3) :
-  AbstractParameterAliasable("CodonRate."),
-  AbstractCodonSubstitutionModel(gCode, pmod1, pmod2, pmod3, "CodonRate.", true)
-{
   updateMatrices();
 }
 
-std::string CodonRateSubstitutionModel::getName() const
-{
-  return "CodonRate";
-}
 
-void CodonRateSubstitutionModel::fireParameterChanged(const ParameterList& parameters)
-{
-  AbstractCodonSubstitutionModel::fireParameterChanged(parameters);
-}
+KCM::KCM(const KCM& kcm) :
+  AbstractBiblioSubstitutionModel(kcm),
+  pmodel_(new KroneckerCodonDistanceSubstitutionModel(*kcm.pmodel_)),
+  oneModel_(kcm.oneModel_)
+{}
 
-double CodonRateSubstitutionModel::getCodonsMulRate(size_t i, size_t j) const
+KCM& KCM::operator=(const KCM& kcm)
 {
-  return AbstractCodonSubstitutionModel::getCodonsMulRate(i,j);
+  AbstractBiblioSubstitutionModel::operator=(kcm);
+
+  oneModel_=kcm.oneModel_;
+  pmodel_.reset(new KroneckerCodonDistanceSubstitutionModel(*kcm.pmodel_));
+  return *this;
 }
 
diff --git a/src/Bpp/Phyl/Model/Codon/KCM.h b/src/Bpp/Phyl/Model/Codon/KCM.h
new file mode 100644
index 0000000..0d2ac79
--- /dev/null
+++ b/src/Bpp/Phyl/Model/Codon/KCM.h
@@ -0,0 +1,119 @@
+//
+// File: KCM.h
+// Created by: Laurent Gueguen
+// Created on: mardi 26 juillet 2016, à 16h 46
+//
+
+/*
+  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
+
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use,
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info".
+
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability.
+
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or
+  data to be ensured and,  more generally, to use and operate it in the
+  same conditions as regards security.
+
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
+*/
+
+#ifndef _KCM_H_
+#define _KCM_H_
+
+#include "../AbstractBiblioSubstitutionModel.h"
+#include "KroneckerCodonDistanceSubstitutionModel.h"
+
+namespace bpp
+{
+/**
+ * @brief The general multiple substitution model for codons, from
+ * Zaheri & al, 2014.
+ *
+ * @author Laurent Guéguen
+ *
+ * This model is built from one or several nucleotide substitution
+ * models. It also allows distinct equilibrium frequencies between
+ * codons. A multiplicative factor accounts for the selective
+ * restraints at the amino acid level, depending on the synonymy of
+ * the amino acids.
+ *
+ *
+ * This model includes :
+ *
+ * - parameters of the nucleotide models, 
+ * - @f$\omega at f$ for the ratio of non-synonymous vs synonymous
+ * substitution rates,
+ * - parameters of the equilibrium frequencies 
+ 
+ * The codon frequencies @f$\pi_j at f$ are either observed or infered.
+ *
+ * Reference:
+ * -  Zaheri, M. and Linda, D. and Salamin, N. A Generalized
+ * Mechanistic Codon Model (2014).
+ *
+ */
+  
+  class KCM :
+    public AbstractBiblioSubstitutionModel,
+    public virtual CodonReversibleSubstitutionModel
+  {
+  private:
+    std::unique_ptr<KroneckerCodonDistanceSubstitutionModel> pmodel_;
+    bool oneModel_;
+    
+  public:
+    /**
+     * @brief constructor.
+     *
+     * If onemod, a unique GTR model is used, otherwise three
+     * different GTR models are used.
+     *
+     **/
+    
+    KCM(const GeneticCode* gc, bool oneModel);
+
+    KCM(const KCM& kcm);
+
+    KCM& operator=(const KCM&);
+
+    virtual ~KCM() {}
+
+    KCM* clone() const { return new KCM(*this); }
+
+  public:
+    std::string getName() const { return "KCM"+std::string(oneModel_?"7":"19")+".";}
+
+    const SubstitutionModel& getModel() const { return *pmodel_.get(); }
+
+    const GeneticCode* getGeneticCode() const { return pmodel_->getGeneticCode(); }
+  
+    double getCodonsMulRate(size_t i, size_t j) const { return pmodel_->getCodonsMulRate(i, j); }
+
+  private:
+    SubstitutionModel& getModel() { return *pmodel_.get(); }
+  };
+
+} // end of namespace bpp.
+
+#endif  // _KCM_H_
+
diff --git a/src/Bpp/Phyl/Model/Codon/KroneckerCodonDistanceFrequenciesSubstitutionModel.cpp b/src/Bpp/Phyl/Model/Codon/KroneckerCodonDistanceFrequenciesSubstitutionModel.cpp
new file mode 100644
index 0000000..8ed8e3e
--- /dev/null
+++ b/src/Bpp/Phyl/Model/Codon/KroneckerCodonDistanceFrequenciesSubstitutionModel.cpp
@@ -0,0 +1,137 @@
+//
+// File: KroneckerCodonDistanceFrequenciesSubstitutionModel.cpp
+// Created by:  Laurent Gueguen
+// Created on: Feb 2009
+//
+
+/*
+  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
+
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use,
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info".
+
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability.
+
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or
+  data to be ensured and,  more generally, to use and operate it in the
+  same conditions as regards security.
+
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
+*/
+
+#include "KroneckerCodonDistanceFrequenciesSubstitutionModel.h"
+
+using namespace bpp;
+
+using namespace std;
+
+/******************************************************************************/
+
+KroneckerCodonDistanceFrequenciesSubstitutionModel::KroneckerCodonDistanceFrequenciesSubstitutionModel(
+    const GeneticCode* gCode,
+    NucleotideSubstitutionModel* pmod,
+    FrequenciesSet* pfreq,
+    const AlphabetIndex2* pdist) :
+  AbstractParameterAliasable("KronCodonDistFreq."),
+  AbstractKroneckerCodonSubstitutionModel(gCode, pmod, "KronCodonDistFreq."),
+  AbstractCodonDistanceSubstitutionModel(pdist, "KronCodonDistFreq."),
+  AbstractCodonFrequenciesSubstitutionModel(pfreq, "KronCodonDistFreq.")
+{
+  updateMatrices();
+}
+
+KroneckerCodonDistanceFrequenciesSubstitutionModel::KroneckerCodonDistanceFrequenciesSubstitutionModel(
+  const GeneticCode* gCode,
+  NucleotideSubstitutionModel* pmod,
+  const std::vector<std::set< size_t> >& vPos,
+  FrequenciesSet* pfreq,
+  const AlphabetIndex2* pdist) :
+  AbstractParameterAliasable("KronCodonDistFreq."),
+  AbstractKroneckerCodonSubstitutionModel(gCode, pmod, vPos, "KronCodonDistFreq."),
+  AbstractCodonDistanceSubstitutionModel(pdist, "KronCodonDistFreq."),
+  AbstractCodonFrequenciesSubstitutionModel(pfreq, "KronCodonDistFreq.")
+{
+  updateMatrices();
+}
+
+KroneckerCodonDistanceFrequenciesSubstitutionModel::KroneckerCodonDistanceFrequenciesSubstitutionModel(
+    const GeneticCode* gCode,
+    NucleotideSubstitutionModel* pmod1,
+    NucleotideSubstitutionModel* pmod2,
+    NucleotideSubstitutionModel* pmod3,
+    FrequenciesSet* pfreq,
+    const AlphabetIndex2* pdist) :
+  AbstractParameterAliasable("KronCodonDistFreq."),
+  AbstractKroneckerCodonSubstitutionModel(gCode, pmod1, pmod2, pmod3, "KronCodonDistFreq."),
+  AbstractCodonDistanceSubstitutionModel(pdist, "KronCodonDistFreq."),
+  AbstractCodonFrequenciesSubstitutionModel(pfreq, "KronCodonDistFreq.")
+{
+  updateMatrices();
+}
+
+KroneckerCodonDistanceFrequenciesSubstitutionModel::KroneckerCodonDistanceFrequenciesSubstitutionModel(
+  const GeneticCode* gCode,
+  NucleotideSubstitutionModel* pmod1,
+  NucleotideSubstitutionModel* pmod2,
+  NucleotideSubstitutionModel* pmod3,
+  const std::vector<std::set< size_t> >& vPos,
+  FrequenciesSet* pfreq,
+  const AlphabetIndex2* pdist) :
+  AbstractParameterAliasable("KronCodonDistFreq."),
+  AbstractKroneckerCodonSubstitutionModel(gCode, pmod1, pmod2, pmod3, vPos, "KronCodonDistFreq."),
+  AbstractCodonDistanceSubstitutionModel(pdist, "KronCodonDistFreq."),
+  AbstractCodonFrequenciesSubstitutionModel(pfreq, "KronCodonDistFreq.")
+{
+  updateMatrices();
+}
+
+std::string KroneckerCodonDistanceFrequenciesSubstitutionModel::getName() const
+{
+  return "KronCodonDistFreq";
+}
+
+void KroneckerCodonDistanceFrequenciesSubstitutionModel::fireParameterChanged(const ParameterList& parameters)
+{
+  AbstractCodonDistanceSubstitutionModel::fireParameterChanged(parameters);
+  AbstractCodonFrequenciesSubstitutionModel::fireParameterChanged(parameters);
+
+  // Beware: must be called last
+  AbstractKroneckerCodonSubstitutionModel::fireParameterChanged(parameters);
+}
+
+double KroneckerCodonDistanceFrequenciesSubstitutionModel::getCodonsMulRate(size_t i, size_t j) const
+{
+  return AbstractCodonDistanceSubstitutionModel::getCodonsMulRate(i,j)
+    * AbstractKroneckerCodonSubstitutionModel::getCodonsMulRate(i,j)
+    * AbstractCodonFrequenciesSubstitutionModel::getCodonsMulRate(i,j);
+}
+
+void KroneckerCodonDistanceFrequenciesSubstitutionModel::setNamespace(const std::string& st)
+{
+  AbstractParameterAliasable::setNamespace(st);
+  AbstractKroneckerCodonSubstitutionModel::setNamespace(st);
+  AbstractCodonDistanceSubstitutionModel::setNamespace(st);
+  AbstractCodonFrequenciesSubstitutionModel::setNamespace(st);
+}
+
+void KroneckerCodonDistanceFrequenciesSubstitutionModel::setFreq(map<int,double>& frequencies)
+{
+  AbstractCodonFrequenciesSubstitutionModel::setFreq(frequencies);
+}
diff --git a/src/Bpp/Phyl/Model/Codon/CodonDistanceFrequenciesSubstitutionModel.h b/src/Bpp/Phyl/Model/Codon/KroneckerCodonDistanceFrequenciesSubstitutionModel.h
similarity index 54%
copy from src/Bpp/Phyl/Model/Codon/CodonDistanceFrequenciesSubstitutionModel.h
copy to src/Bpp/Phyl/Model/Codon/KroneckerCodonDistanceFrequenciesSubstitutionModel.h
index 2d2e999..9cd3667 100644
--- a/src/Bpp/Phyl/Model/Codon/CodonDistanceFrequenciesSubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/Codon/KroneckerCodonDistanceFrequenciesSubstitutionModel.h
@@ -1,7 +1,7 @@
 //
-// File: CodonDistanceFrequenciesSubstitutionModel.h
+// File: KroneckerCodonDistanceFrequenciesSubstitutionModel.h
 // Created by: Laurent Gueguen
-// Created on: lundi 19 septembre 2011, à 11h 47
+// Created on: mardi 26 juillet 2016, à 23h 43
 //
 
 /*
@@ -37,18 +37,24 @@
    knowledge of the CeCILL license and that you accept its terms.
  */
 
-#ifndef _CODONDISTANCEFREQUENCIESSUBSTITUTIONMODEL_H_
-#define _CODONDISTANCEFREQUENCIESSUBSTITUTIONMODEL_H_
+#ifndef _KRONECKER_CODONDISTANCEFREQUENCIESSUBSTITUTIONMODEL_H_
+#define _KRONECKER_CODONDISTANCEFREQUENCIESSUBSTITUTIONMODEL_H_
 
-#include "AbstractCodonSubstitutionModel.h"
+#include "AbstractKroneckerCodonSubstitutionModel.h"
 #include "AbstractCodonDistanceSubstitutionModel.h"
 #include "AbstractCodonFrequenciesSubstitutionModel.h"
 
 namespace bpp
 {
 /**
- * @brief Class for asynonymous substitution models on codons with
- * parameterized equilibrium frequencies and nucleotidic models.
+ * @brief Class for non-synonymous substitution models on codons with
+ * parameterized equilibrium frequencies and nucleotidic models,
+ * with allowed multiple substitutions.
+ *
+ * Rates of multiple substitutions equal the product of single
+ * substitutions involved, before mgmt of selection and removing stop
+ * codons.
+ *
  * @author Laurent Guéguen
  *
  * This class should be used with models which equilibrium
@@ -56,13 +62,12 @@ namespace bpp
  * Otherwise there may be problems of identifiability of the
  * parameters.
  *
- * See description in AbstractCodonDistanceSubstitutionModel and
- * AbstractCodonFrequenciesSubstitutionModel class.
- *
- * Only substitutions with one letter changed are accepted. </p>
+ * See description in AbstractKroneckerCodonDistanceSubstitutionModel
+ * and AbstractCodonFrequenciesSubstitutionModel class.
  *
- * The additional parameters to CodonFrequenciesSubstitutionModel are
- * the rates of nonsynonymous over synonymous substitutions.
+ * The additional parameters to
+ * AbstractCodonFrequenciesSubstitutionModel are the rates of
+ * nonsynonymous over synonymous substitutions.
  *
  * If a distance @f$d at f$ between amino-acids is defined, the
  *  non-synonymous rate is multiplied with, if the coded amino-acids
@@ -74,46 +79,67 @@ namespace bpp
  *  rate is multiplied with @f$\beta at f$ with positive parameter \c
  *  "beta" (ie @f$d=0 at f$).
  *
- * If paramSynRate is true, the synonymous substitution rate is
- *  multiplied with @f$\gamma at f$ (with optional positive parameter \c
- *  "gamma"), else it is multiplied with 1.
- *
  * If such a distance is not defined, the ratio between non-synonymous
  * and synonymous substitutions rates is @f$\beta at f$ with positive
  * parameter \c "beta".
  */
-class CodonDistanceFrequenciesSubstitutionModel :
-    public AbstractCodonSubstitutionModel,
+  
+class KroneckerCodonDistanceFrequenciesSubstitutionModel :
+    public AbstractKroneckerCodonSubstitutionModel,
     public AbstractCodonDistanceSubstitutionModel,
     public AbstractCodonFrequenciesSubstitutionModel
 {
 public:
   /**
-   * @brief Build a new CodonDistanceFrequenciesSubstitutionModel object
+   * @brief Build a new KroneckerCodonDistanceFrequenciesSubstitutionModel object
    * from three pointers to AbstractSubstitutionModels. NEW
    * AbstractSubstitutionModels are copied from the given ones.
    *
+   * Any number of any positions can change simultaneously
+   *
    * @param gCode pointer to a GeneticCode
    * @param pmod pointer to the NucleotideSubstitutionModel to use in
    *        the three positions. It is owned by the instance.
    * @param pfreq pointer to the FrequenciesSet* equilibrium frequencies
    * @param pdist optional pointer to the AlphabetIndex2 amino-acids
    *        distance object.
-   * @param paramSynRate is true iff synonymous rate is parametrised
-   *        (default=false).
    */
-  CodonDistanceFrequenciesSubstitutionModel(
+
+  KroneckerCodonDistanceFrequenciesSubstitutionModel(
       const GeneticCode* gCode,
       NucleotideSubstitutionModel* pmod,
       FrequenciesSet* pfreq,
-      const AlphabetIndex2* pdist = 0,
-      bool paramSynRate = false);
+      const AlphabetIndex2* pdist = 0);
+
+  /**
+   * @brief Build a new KroneckerCodonDistanceFrequenciesSubstitutionModel object
+   * from three pointers to AbstractSubstitutionModels. NEW
+   * AbstractSubstitutionModels are copied from the given ones.
+   *
+   * @param gCode pointer to a GeneticCode
+   * @param pmod pointer to the NucleotideSubstitutionModel to use in
+   *        the three positions. It is owned by the instance.
+   * @param vPos a vector of sets of simultaneously changing
+   *   positions.
+   * @param pfreq pointer to the FrequenciesSet* equilibrium frequencies
+   * @param pdist optional pointer to the AlphabetIndex2 amino-acids
+   *        distance object.
+   */
+
+  KroneckerCodonDistanceFrequenciesSubstitutionModel(
+    const GeneticCode* gCode,
+    NucleotideSubstitutionModel* pmod,
+    const std::vector<std::set< size_t> >& vPos,
+    FrequenciesSet* pfreq,
+    const AlphabetIndex2* pdist = 0);
 
   /**
-   * @brief Build a new CodonDistanceFrequenciesSubstitutionModel object
+   * @brief Build a new KroneckerCodonDistanceFrequenciesSubstitutionModel object
    * from three pointers to AbstractSubstitutionModels. NEW
    * AbstractSubstitutionModels are copied from the given ones.
    *
+   * Any number of any positions can change simultaneously
+   *
    * @param gCode pointer to a GeneticCode
    * @param pmod1, pmod2, pmod3 are pointers to the
    *   NucleotideSubstitutionModel to use in the three positions.
@@ -122,23 +148,47 @@ public:
    * @param pfreq pointer to the FrequenciesSet* equilibrium frequencies
    * @param pdist optional pointer to the AlphabetIndex2 amino-acids
    *   distance object.
-   * @param paramSynRate is true iff synonymous rate is parametrised
-   *   (default=false).
    */
-  CodonDistanceFrequenciesSubstitutionModel(
+
+  KroneckerCodonDistanceFrequenciesSubstitutionModel(
       const GeneticCode* gCode,
       NucleotideSubstitutionModel* pmod1,
       NucleotideSubstitutionModel* pmod2,
       NucleotideSubstitutionModel* pmod3,
       FrequenciesSet* pfreq,
-      const AlphabetIndex2* pdist = 0,
-      bool paramSynRate = false);
+      const AlphabetIndex2* pdist = 0);
+
+  /**
+   * @brief Build a new KroneckerCodonDistanceFrequenciesSubstitutionModel object
+   * from three pointers to AbstractSubstitutionModels. NEW
+   * AbstractSubstitutionModels are copied from the given ones.
+   *
+   * @param gCode pointer to a GeneticCode
+   * @param pmod1, pmod2, pmod3 are pointers to the
+   *   NucleotideSubstitutionModel to use in the three positions.
+   *   All the models must be different objects to avoid redundant
+   *   parameters.  They are owned by the instance.
+   * @param vPos a vector of sets of simultaneously changing
+   *   positions.
+   * @param pfreq pointer to the FrequenciesSet* equilibrium frequencies
+   * @param pdist optional pointer to the AlphabetIndex2 amino-acids
+   *   distance object.
+   */
+
+  KroneckerCodonDistanceFrequenciesSubstitutionModel(
+    const GeneticCode* gCode,
+    NucleotideSubstitutionModel* pmod1,
+    NucleotideSubstitutionModel* pmod2,
+    NucleotideSubstitutionModel* pmod3,
+    const std::vector<std::set< size_t> >& vPos,
+    FrequenciesSet* pfreq,
+    const AlphabetIndex2* pdist = 0);
 
-  virtual ~CodonDistanceFrequenciesSubstitutionModel() {}
+  virtual ~KroneckerCodonDistanceFrequenciesSubstitutionModel() {}
 
-  CodonDistanceFrequenciesSubstitutionModel* clone() const
+  KroneckerCodonDistanceFrequenciesSubstitutionModel* clone() const
   {
-    return new CodonDistanceFrequenciesSubstitutionModel(*this);
+    return new KroneckerCodonDistanceFrequenciesSubstitutionModel(*this);
   }
 
 public:
@@ -156,5 +206,5 @@ public:
 
 } // end of namespace bpp.
 
-#endif
+#endif // _KRONECKER_CODONDISTANCEFREQUENCIESSUBSTITUTIONMODEL_H_
 
diff --git a/src/Bpp/Phyl/Model/Codon/KroneckerCodonDistanceSubstitutionModel.cpp b/src/Bpp/Phyl/Model/Codon/KroneckerCodonDistanceSubstitutionModel.cpp
new file mode 100644
index 0000000..2840948
--- /dev/null
+++ b/src/Bpp/Phyl/Model/Codon/KroneckerCodonDistanceSubstitutionModel.cpp
@@ -0,0 +1,121 @@
+//
+// File: KroneckerCodonDistanceSubstitutionModel.cpp
+// Created by:  Laurent Gueguen
+// Created on: vendredi 23 septembre 2016, à 12h 18
+//
+
+/*
+  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
+
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use,
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info".
+
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability.
+
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or
+  data to be ensured and,  more generally, to use and operate it in the
+  same conditions as regards security.
+
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
+*/
+
+#include "KroneckerCodonDistanceSubstitutionModel.h"
+
+using namespace bpp;
+
+using namespace std;
+
+/******************************************************************************/
+
+KroneckerCodonDistanceSubstitutionModel::KroneckerCodonDistanceSubstitutionModel(
+    const GeneticCode* gCode,
+    NucleotideSubstitutionModel* pmod,
+    const AlphabetIndex2* pdist) :
+  AbstractParameterAliasable("KronCodonDist."),
+  AbstractKroneckerCodonSubstitutionModel(gCode, pmod, "KronCodonDist."),
+  AbstractCodonDistanceSubstitutionModel(pdist, "KronCodonDist.")
+{
+  updateMatrices();
+}
+
+KroneckerCodonDistanceSubstitutionModel::KroneckerCodonDistanceSubstitutionModel(
+    const GeneticCode* gCode,
+    NucleotideSubstitutionModel* pmod1,
+    NucleotideSubstitutionModel* pmod2,
+    NucleotideSubstitutionModel* pmod3,
+    const AlphabetIndex2* pdist) :
+  AbstractParameterAliasable("KronCodonDist."),
+  AbstractKroneckerCodonSubstitutionModel(gCode, pmod1, pmod2, pmod3, "KronCodonDist."),
+  AbstractCodonDistanceSubstitutionModel(pdist, "KronCodonDist.")
+{
+  updateMatrices();
+}
+
+KroneckerCodonDistanceSubstitutionModel::KroneckerCodonDistanceSubstitutionModel(
+  const GeneticCode* gCode,
+  NucleotideSubstitutionModel* pmod,
+  const std::vector<std::set< size_t> >& vPos,
+  const AlphabetIndex2* pdist) :
+  AbstractParameterAliasable("KronCodonDist."),
+  AbstractKroneckerCodonSubstitutionModel(gCode, pmod, vPos, "KronCodonDist."),
+  AbstractCodonDistanceSubstitutionModel(pdist, "KronCodonDist.")
+{
+  updateMatrices();
+}
+
+KroneckerCodonDistanceSubstitutionModel::KroneckerCodonDistanceSubstitutionModel(
+  const GeneticCode* gCode,
+  NucleotideSubstitutionModel* pmod1,
+  NucleotideSubstitutionModel* pmod2,
+  NucleotideSubstitutionModel* pmod3,
+  const std::vector<std::set< size_t> >& vPos,
+  const AlphabetIndex2* pdist) :
+  AbstractParameterAliasable("KronCodonDist."),
+  AbstractKroneckerCodonSubstitutionModel(gCode, pmod1, pmod2, pmod3, vPos, "KronCodonDist."),
+  AbstractCodonDistanceSubstitutionModel(pdist, "KronCodonDist.")
+{
+  updateMatrices();
+}
+std::string KroneckerCodonDistanceSubstitutionModel::getName() const
+{
+  return "KronCodonDist";
+}
+
+void KroneckerCodonDistanceSubstitutionModel::fireParameterChanged(const ParameterList& parameters)
+{
+  AbstractCodonDistanceSubstitutionModel::fireParameterChanged(parameters);
+
+  // Beware: must be call at the end
+  AbstractKroneckerCodonSubstitutionModel::fireParameterChanged(parameters);
+}
+
+double KroneckerCodonDistanceSubstitutionModel::getCodonsMulRate(size_t i, size_t j) const
+{
+  return AbstractCodonDistanceSubstitutionModel::getCodonsMulRate(i,j)
+    * AbstractKroneckerCodonSubstitutionModel::getCodonsMulRate(i,j);
+}
+
+void KroneckerCodonDistanceSubstitutionModel::setNamespace(const std::string& st)
+{
+  AbstractParameterAliasable::setNamespace(st);
+  AbstractKroneckerCodonSubstitutionModel::setNamespace(st);
+  AbstractCodonDistanceSubstitutionModel::setNamespace(st);
+}
+
diff --git a/src/Bpp/Phyl/Model/Codon/KroneckerCodonDistanceSubstitutionModel.h b/src/Bpp/Phyl/Model/Codon/KroneckerCodonDistanceSubstitutionModel.h
new file mode 100644
index 0000000..21c9051
--- /dev/null
+++ b/src/Bpp/Phyl/Model/Codon/KroneckerCodonDistanceSubstitutionModel.h
@@ -0,0 +1,190 @@
+//
+// File: KroneckerCodonDistanceSubstitutionModel.h
+// Created by: Laurent Gueguen
+// Created on: vendredi 23 septembre 2016, à 12h 18
+//
+
+/*
+  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
+
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use,
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info".
+
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability.
+
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or
+  data to be ensured and,  more generally, to use and operate it in the
+  same conditions as regards security.
+
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
+*/
+
+#ifndef _KRONECKER_CODONDISTANCE_SUBSTITUTIONMODEL_H_
+#define _KRONECKER_CODONDISTANCE_SUBSTITUTIONMODEL_H_
+
+#include "AbstractKroneckerCodonSubstitutionModel.h"
+#include "AbstractCodonDistanceSubstitutionModel.h"
+
+namespace bpp
+{
+/**
+ * @brief Class for non-synonymous substitution models on codons with
+ * parameterized nucleotidic models, with allowed multiple
+ * substitutions.
+ *
+ * Rates of multiple substitutions equal the product of single
+ * substitutions involved, before mgmt of selection and removing stop
+ * codons.
+ *
+ * @author Laurent Guéguen
+ *
+ * See description in AbstractKroneckerCodonDistanceSubstitutionModel
+ * and AbstractCodonDistanceSubstitutionModel class.
+ *
+ * If a distance @f$d at f$ between amino-acids is defined, the
+ *  non-synonymous rate is multiplied with, if the coded amino-acids
+ *  are @f$x at f$ and @f$y at f$, @f$\beta*\exp(-\alpha.d(x,y))@f$ with
+ *  non-negative parameter \c "alpha" and positive parameter \c
+ *  "beta".
+ *
+ * If such a distance is not defined, the non-synonymous substitution
+ *  rate is multiplied with @f$\beta at f$ with positive parameter \c
+ *  "beta" (ie @f$d=0 at f$).
+ *
+ * If such a distance is not defined, the ratio between non-synonymous
+ * and synonymous substitutions rates is @f$\beta at f$ with positive
+ * parameter \c "beta".
+ */
+  
+  
+  class KroneckerCodonDistanceSubstitutionModel :
+    public AbstractKroneckerCodonSubstitutionModel,
+    public AbstractCodonDistanceSubstitutionModel
+  {
+  public:
+    /**
+     * @brief Build a new KroneckerCodonDistanceSubstitutionModel object
+     * from three pointers to AbstractSubstitutionModels. NEW
+     * AbstractSubstitutionModels are copied from the given ones.
+     *
+     * Any number of any positions can change simultaneously
+     *
+     * @param gCode pointer to a GeneticCode
+     * @param pmod pointer to the NucleotideSubstitutionModel to use in
+     *        the three positions. It is owned by the instance.
+     * @param pdist optional pointer to the AlphabetIndex2 amino-acids
+     *        distance object.
+     */
+
+    KroneckerCodonDistanceSubstitutionModel(
+      const GeneticCode* gCode,
+      NucleotideSubstitutionModel* pmod,
+      const AlphabetIndex2* pdist = 0);
+
+    /**
+     * @brief Build a new KroneckerCodonDistanceSubstitutionModel object
+     * from three pointers to AbstractSubstitutionModels. NEW
+     * AbstractSubstitutionModels are copied from the given ones.
+     *
+     * @param gCode pointer to a GeneticCode
+     * @param pmod pointer to the NucleotideSubstitutionModel to use in
+     *        the three positions. It is owned by the instance.
+     * @param vPos a vector of sets of simultaneously changing
+     *        positions.
+     * @param pdist optional pointer to the AlphabetIndex2 amino-acids
+     *        distance object.
+     */
+
+    KroneckerCodonDistanceSubstitutionModel(
+      const GeneticCode* gCode,
+      NucleotideSubstitutionModel* pmod,
+      const std::vector<std::set< size_t> >& vPos,
+      const AlphabetIndex2* pdist = 0);
+
+    /**
+     * @brief Build a new KroneckerCodonDistanceSubstitutionModel object
+     * from three pointers to AbstractSubstitutionModels. NEW
+     * AbstractSubstitutionModels are copied from the given ones.
+     *
+     * Any number of any positions can change simultaneously
+     *
+     * @param gCode pointer to a GeneticCode
+     * @param pmod1, pmod2, pmod3 are pointers to the
+     *   NucleotideSubstitutionModel to use in the three positions.
+     *   All the models must be different objects to avoid redundant
+     *   parameters.  They are owned by the instance.
+     * @param pdist optional pointer to the AlphabetIndex2 amino-acids
+     *   distance object.
+     */
+
+    KroneckerCodonDistanceSubstitutionModel(
+      const GeneticCode* gCode,
+      NucleotideSubstitutionModel* pmod1,
+      NucleotideSubstitutionModel* pmod2,
+      NucleotideSubstitutionModel* pmod3,
+      const AlphabetIndex2* pdist = 0);
+
+    /**
+     * @brief Build a new KroneckerCodonDistanceSubstitutionModel object
+     * from three pointers to AbstractSubstitutionModels. NEW
+     * AbstractSubstitutionModels are copied from the given ones.
+     *
+     * @param gCode pointer to a GeneticCode
+     * @param pmod1, pmod2, pmod3 are pointers to the
+     *   NucleotideSubstitutionModel to use in the three positions.
+     *   All the models must be different objects to avoid redundant
+     *   parameters.  They are owned by the instance.
+     * @param vPos a vector of sets of simultaneously changing
+     *   positions.
+     * @param pdist optional pointer to the AlphabetIndex2 amino-acids
+     *   distance object.
+     */
+
+    KroneckerCodonDistanceSubstitutionModel(
+      const GeneticCode* gCode,
+      NucleotideSubstitutionModel* pmod1,
+      NucleotideSubstitutionModel* pmod2,
+      NucleotideSubstitutionModel* pmod3,
+      const std::vector<std::set< size_t> >& vPos,
+      const AlphabetIndex2* pdist = 0);
+
+    virtual ~KroneckerCodonDistanceSubstitutionModel() {}
+
+    KroneckerCodonDistanceSubstitutionModel* clone() const
+    {
+      return new KroneckerCodonDistanceSubstitutionModel(*this);
+    }
+
+  public:
+    void fireParameterChanged(const ParameterList& parameterlist);
+
+    std::string getName() const;
+
+    double getCodonsMulRate(size_t i, size_t j) const;
+
+    void setNamespace(const std::string&);
+
+  };
+
+} // end of namespace bpp.
+
+#endif // _KRONECKER_CODONDISTANCE_SUBSTITUTIONMODEL_H_
+
diff --git a/src/Bpp/Phyl/Model/Codon/MG94.h b/src/Bpp/Phyl/Model/Codon/MG94.h
index 82e30bc..ff0ed43 100644
--- a/src/Bpp/Phyl/Model/Codon/MG94.h
+++ b/src/Bpp/Phyl/Model/Codon/MG94.h
@@ -74,14 +74,12 @@ namespace bpp
  * Reference:
  * - Muse S.V. and Gaut B.S. (1994), Molecular_ Biology And Evolution_ 11(5) 715--724.
  */
-
-
 class MG94 :
     public AbstractBiblioSubstitutionModel,
-    virtual public ReversibleSubstitutionModel
+    virtual public CodonReversibleSubstitutionModel
 {
 private:
-  std::auto_ptr<CodonDistancePhaseFrequenciesSubstitutionModel> pmodel_;
+  std::unique_ptr<CodonDistancePhaseFrequenciesSubstitutionModel> pmodel_;
 
 public:
   MG94(const GeneticCode* gc, FrequenciesSet* codonFreqs);
@@ -92,18 +90,17 @@ public:
 
   ~MG94();
 
-#ifndef NO_VIRTUAL_COV
-  MG94*
-#else
-  Clonable*
-#endif
-  clone() const { return new MG94(*this); }
+  MG94* clone() const { return new MG94(*this); }
 
 public:
   std::string getName() const { return "MG94"; }
 
   const SubstitutionModel& getModel() const { return *pmodel_.get(); }
 
+  const GeneticCode* getGeneticCode() const { return pmodel_->getGeneticCode(); }
+  
+  double getCodonsMulRate(size_t i, size_t j) const { return pmodel_->getCodonsMulRate(i, j); }
+
 private:
   SubstitutionModel& getModel() { return *pmodel_.get(); }
 
diff --git a/src/Bpp/Phyl/Model/Codon/CodonDistanceFitnessPhaseFrequenciesSubstitutionModel.cpp b/src/Bpp/Phyl/Model/Codon/SENCA.cpp
similarity index 53%
rename from src/Bpp/Phyl/Model/Codon/CodonDistanceFitnessPhaseFrequenciesSubstitutionModel.cpp
rename to src/Bpp/Phyl/Model/Codon/SENCA.cpp
index 3e4170b..40dd52f 100644
--- a/src/Bpp/Phyl/Model/Codon/CodonDistanceFitnessPhaseFrequenciesSubstitutionModel.cpp
+++ b/src/Bpp/Phyl/Model/Codon/SENCA.cpp
@@ -1,5 +1,5 @@
 //
-// File: CodonDistanceFitnessPhaseFrequenciesSubstitutionModel.cpp
+// File: SENCA.cpp
 // Created by: Fanny Pouyet 
 // Created on: February 2012
 //
@@ -38,92 +38,86 @@
 */
 
 
-#include "CodonDistanceFitnessPhaseFrequenciesSubstitutionModel.h"
+#include "SENCA.h"
 using namespace bpp;
 using namespace std;
 
-CodonDistanceFitnessPhaseFrequenciesSubstitutionModel::CodonDistanceFitnessPhaseFrequenciesSubstitutionModel(
+SENCA::SENCA(
     const GeneticCode* gCode,
     NucleotideSubstitutionModel* pmod,
     FrequenciesSet* pfit,
-    FrequenciesSet* pfreq,
     const AlphabetIndex2* pdist) :
-  AbstractParameterAliasable("CodonDistFitPhasFreq."),
-  AbstractCodonSubstitutionModel(gCode, pmod, "CodonDistFitPhasFreq."),
-  AbstractCodonDistanceSubstitutionModel(pdist, "CodonDistFitPhasFreq."),
-  AbstractCodonPhaseFrequenciesSubstitutionModel(pfreq, "CodonDistFitPhasFreq."),
-  AbstractCodonFitnessSubstitutionModel(pfit, "CodonDistFitPhasFreq.")
+  AbstractParameterAliasable("SENCA."),
+  AbstractCodonSubstitutionModel(gCode, pmod, "SENCA."),
+  AbstractCodonDistanceSubstitutionModel(pdist, "SENCA."),
+  AbstractCodonFitnessSubstitutionModel(pfit, "SENCA.")
 {
   updateMatrices();
 }
 
-CodonDistanceFitnessPhaseFrequenciesSubstitutionModel::CodonDistanceFitnessPhaseFrequenciesSubstitutionModel(
+SENCA::SENCA(
     const GeneticCode* gCode,
     NucleotideSubstitutionModel* pmod1,
     NucleotideSubstitutionModel* pmod2,
     NucleotideSubstitutionModel* pmod3,
     FrequenciesSet* pfit,
-    FrequenciesSet* pfreq,
     const AlphabetIndex2* pdist) :
-  AbstractParameterAliasable("CodonDistFitPhasFreq."),
-  AbstractCodonSubstitutionModel(gCode, pmod1, pmod2, pmod3, "CodonDistFitPhasFreq."),
-  AbstractCodonDistanceSubstitutionModel(pdist, "CodonDistFitPhasFreq."),
-  AbstractCodonPhaseFrequenciesSubstitutionModel(pfreq, "CodonDistFitPhasFreq."),
-  AbstractCodonFitnessSubstitutionModel(pfit,"CodonDistFitPhasFreq.")
+  AbstractParameterAliasable("SENCA."),
+  AbstractCodonSubstitutionModel(gCode, pmod1, pmod2, pmod3, "SENCA."),
+  AbstractCodonDistanceSubstitutionModel(pdist, "SENCA."),
+  AbstractCodonFitnessSubstitutionModel(pfit,"SENCA.")
 {
   updateMatrices();
 }
 
-string CodonDistanceFitnessPhaseFrequenciesSubstitutionModel::getName() const
+string SENCA::getName() const
 {
-  return ("CodonDistFitPhasFreq");
+  return ("SENCA");
 }
 
-void CodonDistanceFitnessPhaseFrequenciesSubstitutionModel::fireParameterChanged(const ParameterList& parameters)
+void SENCA::fireParameterChanged(const ParameterList& parameters)
 {
   AbstractCodonDistanceSubstitutionModel::fireParameterChanged(parameters);
-  AbstractCodonPhaseFrequenciesSubstitutionModel::fireParameterChanged(parameters);
   AbstractCodonFitnessSubstitutionModel::fireParameterChanged(parameters);
 
   AbstractCodonSubstitutionModel::fireParameterChanged(parameters);
 }
 
-double CodonDistanceFitnessPhaseFrequenciesSubstitutionModel::getCodonsMulRate(size_t i, size_t j) const
+double SENCA::getCodonsMulRate(size_t i, size_t j) const
 {
   return AbstractCodonDistanceSubstitutionModel::getCodonsMulRate(i,j)
     * AbstractCodonSubstitutionModel::getCodonsMulRate(i,j)
-    * AbstractCodonPhaseFrequenciesSubstitutionModel::getCodonsMulRate(i,j)
     * AbstractCodonFitnessSubstitutionModel::getCodonsMulRate(i,j);
 }
 
-void CodonDistanceFitnessPhaseFrequenciesSubstitutionModel::setNamespace(const std::string& st)
+void SENCA::setNamespace(const std::string& st)
 {
   AbstractParameterAliasable::setNamespace(st);
   AbstractCodonSubstitutionModel::setNamespace(st);
   AbstractCodonDistanceSubstitutionModel::setNamespace(st);
-  AbstractCodonPhaseFrequenciesSubstitutionModel::setNamespace(st); 
   AbstractCodonFitnessSubstitutionModel::setNamespace(st);
 }
 
-void CodonDistanceFitnessPhaseFrequenciesSubstitutionModel::setFreq(map<int,double>& frequencies)
-{
-  AbstractCodonPhaseFrequenciesSubstitutionModel::setFreq(frequencies);
-  map<int, double> freq1 = AbstractCodonPhaseFrequenciesSubstitutionModel::getFrequenciesSet()->getAlphabetStatesFrequencies();
-
-  map<int, double> freq2;
-  double s=0;
-  map<int, double>::iterator it;
-
-  for (it=frequencies.begin();it!=frequencies.end();it++)
-  {
-    freq2[it->first]=(freq1[it->first] != 0 ? it->second/freq1[it->first] : 0);
-    s += freq2[it->first];
-  }
+void SENCA::setFreq(map<int,double>& frequencies)
+{ 
+   AbstractCodonSubstitutionModel::setFreq(frequencies);
+   const Vdouble& freq1 = AbstractCodonSubstitutionModel::getFrequencies();
+   const Alphabet* alphabet = getAlphabet();
+
+   map<int, double> freq2;
+   double s=0;
+   map<int, double>::iterator it;
+
+    for (it=frequencies.begin();it!=frequencies.end();it++)
+    {
+      freq2[it->first]=(freq1[alphabet->getStateIndex(it->first)-1] != 0 ? it->second/freq1[alphabet->getStateIndex(it->first)-1] : 0);
+      s += freq2[it->first];
+    }
   
-  for (it = freq2.begin(); it != freq2.end(); it++)
-    freq2[it->first] /= s;
+    for (it = freq2.begin(); it != freq2.end(); it++)
+      freq2[it->first] /= s;
 
-  AbstractCodonFitnessSubstitutionModel::setFreq(freq2);
+    AbstractCodonFitnessSubstitutionModel::setFreq(freq2);
 
   updateMatrices();
 }
diff --git a/src/Bpp/Phyl/Model/Codon/CodonDistanceFitnessPhaseFrequenciesSubstitutionModel.h b/src/Bpp/Phyl/Model/Codon/SENCA.h
similarity index 66%
rename from src/Bpp/Phyl/Model/Codon/CodonDistanceFitnessPhaseFrequenciesSubstitutionModel.h
rename to src/Bpp/Phyl/Model/Codon/SENCA.h
index 8aceb00..a4b0b07 100644
--- a/src/Bpp/Phyl/Model/Codon/CodonDistanceFitnessPhaseFrequenciesSubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/Codon/SENCA.h
@@ -1,5 +1,5 @@
 //
-// File: CodonDistanceFitnessPhaseFrequenciesSubstitutionModel.h
+// File: SENCA.h
 // Created by: Fanny Pouyet 
 // Created on: mars 2012
 //
@@ -37,52 +37,37 @@
   knowledge of the CeCILL license and that you accept its terms.
 */
  
-#ifndef _CODONDISTANCEFITNESSPHASEFREQUENCIESSUBSTITUTIONMODEL_H_
-#define _CODONDISTANCEFITNESSPHASEFREQUENCIESSUBSTITUTIONMODEL_H_
+#ifndef _SENCA_H_
+#define _SENCA_H_
  
 #include "AbstractCodonFitnessSubstitutionModel.h"
 #include "AbstractCodonSubstitutionModel.h"
 #include "AbstractCodonDistanceSubstitutionModel.h"
-#include "AbstractCodonPhaseFrequenciesSubstitutionModel.h"
 
 namespace bpp
 {
   /**
-   * @brief Class for asynonymous and synonymous substitution models
+   * @brief Class for non-synonymous and synonymous substitution models
    * on codons with parameterized equilibrium frequencies and
    * nucleotidic basic models.
    *
    * @author Fanny Pouyet, Laurent Guéguen
    *
-   * This class should be used with models which equilibrium
-   * distribution is fixed, ans does not depend on the parameters.
-   * Otherwise there may be problems of identifiability of the
-   * parameters.
-   *
    * See description in AbstractCodonDistanceSubstitutionModel
-   * class, AbstractCodonPhaseFrequenciesSubstitutionModel class,
-   * AbstractCodonFitnessSubstitutionModel class.
+   * class, AbstractCodonFitnessSubstitutionModel class.
    *
    * Only substitutions with one letter changed are accepted. </p>
    *
-   * The additional parameter to CodonPhaseFrequenciesSubstitutionModel
-   * is the ratio of nonsynonymous over synonymous substitutions.
-   *
-   * If a distance @f$d at f$ between amino-acids is defined, the ratio between
-   * non-synonymous and synonymous substitutions rates is, if the codied
-   * amino-acids are @f$x at f$ and @f$y at f$, @f$\beta*\exp(-\alpha.d(x,y))@f$ with
-   * non-negative parameter \c "alpha" and positive parameter \c "beta".
-   *
-   * If such a distance is not defined, the ratio between
-   * non-synonymous and synonymous substitutions rates is
-   * @f$\beta at f$ with positive parameter \c "beta".
+   * The ratio between non-synonymous and synonymous substitutions 
+   * rates is @f$\beta at f$ with positive parameter \c "beta".
    *
    * The fitness of a codon is a value between 0 and 1 defining the
    * relative advantage of a codon, compared to others. If a codon
    * @f$i at f$ has a fitness @f$\phi_i at f$ and another one (@f$j at f$)
    * has a fitness @f$\phi_j at f$, the substitution rate from codon
    * @f$i at f$ to codon @f$j at f$ is multiplied by
-   * \f[-\frac{\log(\frac{\phi_i}{\phi_j})}{1-\frac{\phi_i}{\phi_j}}\f]
+   * \f[-\frac{ \log(\frac{\phi_i}{\phi_j})}{1-\frac{\phi_i}{\phi_j}}\f]
+   *
    * The set of fitnesses is implemented through a Codon
    * FrequenciesSet object. The parameters are named \c
    * "fit_NameOfTheParameterInTheFrequenciesSet".
@@ -90,34 +75,32 @@ namespace bpp
    * Reference:
    * -  Yang Z. and Nielsen R. (2008), _Molecular Biology and Evolution_ 25(3):568--579.
    */
-  class CodonDistanceFitnessPhaseFrequenciesSubstitutionModel :
-    public virtual ReversibleSubstitutionModel,
+  
+  class SENCA :
+    public virtual SubstitutionModel,
     public AbstractCodonSubstitutionModel,
     public AbstractCodonDistanceSubstitutionModel,
-    public AbstractCodonPhaseFrequenciesSubstitutionModel,
     public AbstractCodonFitnessSubstitutionModel
   {
   public:
-    CodonDistanceFitnessPhaseFrequenciesSubstitutionModel(
+    SENCA(
         const GeneticCode* gCode,
         NucleotideSubstitutionModel* pmod,
         FrequenciesSet* pfit,
-        FrequenciesSet* pfreq,
         const AlphabetIndex2* pdist = 0);
-    CodonDistanceFitnessPhaseFrequenciesSubstitutionModel(
+    SENCA(
         const GeneticCode* gCode,
         NucleotideSubstitutionModel* pmod1,
         NucleotideSubstitutionModel* pmod2,
         NucleotideSubstitutionModel* pmod3,
         FrequenciesSet* pfit,
-        FrequenciesSet* pfreq,
         const AlphabetIndex2* pdist = 0);
 
-    virtual ~CodonDistanceFitnessPhaseFrequenciesSubstitutionModel() {}
+    virtual ~SENCA() {}
 
-    CodonDistanceFitnessPhaseFrequenciesSubstitutionModel* clone() const
+    SENCA* clone() const
     {
-      return new CodonDistanceFitnessPhaseFrequenciesSubstitutionModel(*this);
+      return new SENCA(*this);
     }
 
   public:
@@ -130,11 +113,11 @@ namespace bpp
     void setNamespace(const std::string&);
 
     /*
-     * @brief set the phasefrequencies and fitness of the model from
+     * @brief set the fitness of the model from
      * given frequencies, such that the equilibrium frequencies of the
      * model matches at best the given ones.
      * 
-     * Matching is done in two steps : first, phase frequencies are
+     * Matching is done in two steps : first, frequencies from nucleotide substitution model are
      * matched at best, then the resulting discrepancy (in terms of
      * ratios between the given one and the one computed by the pahse
      * frequencies) is given for matching to the fitness.
diff --git a/src/Bpp/Phyl/Model/Codon/TripletSubstitutionModel.h b/src/Bpp/Phyl/Model/Codon/TripletSubstitutionModel.h
index 1f0159c..60f50b9 100644
--- a/src/Bpp/Phyl/Model/Codon/TripletSubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/Codon/TripletSubstitutionModel.h
@@ -96,12 +96,7 @@ public:
 
   ~TripletSubstitutionModel() {};
   
-#ifndef NO_VIRTUAL_COV
-  TripletSubstitutionModel*
-#else
-  Clonable*
-#endif
-  clone() const { return new TripletSubstitutionModel(*this);}
+  TripletSubstitutionModel* clone() const { return new TripletSubstitutionModel(*this);}
   
 public:
   std::string getName() const;
diff --git a/src/Bpp/Phyl/Model/Codon/YN98.h b/src/Bpp/Phyl/Model/Codon/YN98.h
index 4fdc6fb..d712cb8 100644
--- a/src/Bpp/Phyl/Model/Codon/YN98.h
+++ b/src/Bpp/Phyl/Model/Codon/YN98.h
@@ -87,11 +87,10 @@ namespace bpp
  */
 class YN98 :
     public AbstractBiblioSubstitutionModel,
-    public virtual CodonSubstitutionModel,
-    public virtual ReversibleSubstitutionModel
+    public virtual CodonReversibleSubstitutionModel
 {
 private:
-  std::auto_ptr<CodonDistanceFrequenciesSubstitutionModel> pmodel_;
+  std::unique_ptr<CodonDistanceFrequenciesSubstitutionModel> pmodel_;
 
 public:
   YN98(const GeneticCode* gc, FrequenciesSet* codonFreqs);
diff --git a/src/Bpp/Phyl/Model/Codon/YNGKP_M1.cpp b/src/Bpp/Phyl/Model/Codon/YNGP_M1.cpp
similarity index 85%
rename from src/Bpp/Phyl/Model/Codon/YNGKP_M1.cpp
rename to src/Bpp/Phyl/Model/Codon/YNGP_M1.cpp
index 045bc8c..7d3d7a0 100644
--- a/src/Bpp/Phyl/Model/Codon/YNGKP_M1.cpp
+++ b/src/Bpp/Phyl/Model/Codon/YNGP_M1.cpp
@@ -1,5 +1,5 @@
 //
-// File: YNGKP_M1.cpp
+// File: YNGP_M1.cpp
 // Created by:  Laurent Gueguen
 // Created on: May 2010
 //
@@ -36,7 +36,7 @@
    knowledge of the CeCILL license and that you accept its terms.
  */
 
-#include "YNGKP_M1.h"
+#include "YNGP_M1.h"
 #include "YN98.h"
 
 #include <Bpp/Numeric/NumConstants.h>
@@ -48,9 +48,9 @@ using namespace std;
 
 /******************************************************************************/
 
-YNGKP_M1::YNGKP_M1(const GeneticCode* gc, FrequenciesSet* codonFreqs) :
-  AbstractBiblioMixedSubstitutionModel("YNGKP_M1."),
-  pmixmodel_(0),
+YNGP_M1::YNGP_M1(const GeneticCode* gc, FrequenciesSet* codonFreqs) :
+  AbstractBiblioMixedSubstitutionModel("YNGP_M1."),
+  pmixmodel_(),
   synfrom_(),
   synto_()
 {
@@ -66,8 +66,10 @@ YNGKP_M1::YNGKP_M1(const GeneticCode* gc, FrequenciesSet* codonFreqs) :
   mpdd["omega"] = psdd;
 
   YN98* yn98 = new YN98(gc, codonFreqs);
+
   pmixmodel_.reset(new MixtureOfASubstitutionModel(gc->getSourceAlphabet(), yn98, mpdd));
   delete psdd;
+
   vector<int> supportedChars = yn98->getAlphabetStates();
 
   // map the parameters
@@ -93,12 +95,12 @@ YNGKP_M1::YNGKP_M1(const GeneticCode* gc, FrequenciesSet* codonFreqs) :
     st = pmixmodel_->getParameterNameWithoutNamespace(it->first);
     if (st != "omega_Simple.V1")
     {
-      addParameter_(new Parameter("YNGKP_M1." + it->second, pmixmodel_->getParameterValue(st),
-                              pmixmodel_->getParameter(st).hasConstraint() ? pmixmodel_->getParameter(st).getConstraint()->clone() : 0, true));
+      addParameter_(new Parameter("YNGP_M1." + it->second, pmixmodel_->getParameterValue(st),
+                                  pmixmodel_->getParameter(st).hasConstraint() ? pmixmodel_->getParameter(st).getConstraint()->clone() : 0, true));
     }
   }
 
-  addParameter_(new Parameter("YNGKP_M1.omega", 0.5, new IntervalConstraint(NumConstants::MILLI(), 1, true, false, NumConstants::MILLI()), true));
+  addParameter_(new Parameter("YNGP_M1.omega", 0.5, new IntervalConstraint(NumConstants::MILLI(), 1, true, false, NumConstants::MILLI()), true));
 
   // look for synonymous codons
   for (synfrom_ = 1; synfrom_ < supportedChars.size(); ++synfrom_)
@@ -122,13 +124,13 @@ YNGKP_M1::YNGKP_M1(const GeneticCode* gc, FrequenciesSet* codonFreqs) :
   updateMatrices();
 }
 
-YNGKP_M1::YNGKP_M1(const YNGKP_M1& mod2) : AbstractBiblioMixedSubstitutionModel(mod2),
+YNGP_M1::YNGP_M1(const YNGP_M1& mod2) : AbstractBiblioMixedSubstitutionModel(mod2),
   pmixmodel_(new MixtureOfASubstitutionModel(*mod2.pmixmodel_)),
   synfrom_(mod2.synfrom_),
   synto_(mod2.synto_)
 {}
 
-YNGKP_M1& YNGKP_M1::operator=(const YNGKP_M1& mod2)
+YNGP_M1& YNGP_M1::operator=(const YNGP_M1& mod2)
 {
   AbstractBiblioSubstitutionModel::operator=(mod2);
 
@@ -139,9 +141,9 @@ YNGKP_M1& YNGKP_M1::operator=(const YNGKP_M1& mod2)
   return *this;
 }
 
-YNGKP_M1::~YNGKP_M1() {}
+YNGP_M1::~YNGP_M1() {}
 
-void YNGKP_M1::updateMatrices()
+void YNGP_M1::updateMatrices()
 {
   AbstractBiblioSubstitutionModel::updateMatrices();
 
diff --git a/src/Bpp/Phyl/Model/Codon/YNGKP_M1.h b/src/Bpp/Phyl/Model/Codon/YNGP_M1.h
similarity index 89%
rename from src/Bpp/Phyl/Model/Codon/YNGKP_M1.h
rename to src/Bpp/Phyl/Model/Codon/YNGP_M1.h
index df27549..a5bac47 100644
--- a/src/Bpp/Phyl/Model/Codon/YNGKP_M1.h
+++ b/src/Bpp/Phyl/Model/Codon/YNGP_M1.h
@@ -1,5 +1,5 @@
 //
-// File: YNGKP_M1.h
+// File: YNGP_M1.h
 // Created by: Laurent Gueguen
 // Created on: May 2010
 //
@@ -37,8 +37,8 @@ The fact that you are presently reading this means that you have had
 knowledge of the CeCILL license and that you accept its terms.
 */
 
-#ifndef _YNGKP_M1_H_
-#define _YNGKP_M1_H_
+#ifndef _YNGP_M1_H_
+#define _YNGP_M1_H_
 
 #include "../AbstractBiblioMixedSubstitutionModel.h"
 #include "../MixtureOfASubstitutionModel.h"
@@ -76,12 +76,12 @@ namespace bpp
  * Wong, W. S. W., Z. Yang, N. Goldman, and R. Nielsen. (2004)
  * Genetics 168:1041--1051.
  */
-class YNGKP_M1:
+class YNGP_M1:
     public AbstractBiblioMixedSubstitutionModel,
     virtual public ReversibleSubstitutionModel
 {
 private:
-  std::auto_ptr<MixtureOfASubstitutionModel> pmixmodel_;
+  std::unique_ptr<MixtureOfASubstitutionModel> pmixmodel_;
 
 
   /**
@@ -92,15 +92,15 @@ private:
   size_t synfrom_, synto_;
   
 public:
-  YNGKP_M1(const GeneticCode* gc, FrequenciesSet* codonFreqs);
+  YNGP_M1(const GeneticCode* gc, FrequenciesSet* codonFreqs);
 
-  virtual ~YNGKP_M1();
+  virtual ~YNGP_M1();
   
-  YNGKP_M1* clone() const { return new YNGKP_M1(*this); }
+  YNGP_M1* clone() const { return new YNGP_M1(*this); }
 
-  YNGKP_M1(const YNGKP_M1&);
+  YNGP_M1(const YNGP_M1&);
 
-  YNGKP_M1& operator=(const YNGKP_M1&);
+  YNGP_M1& operator=(const YNGP_M1&);
 
 protected:
   void updateMatrices();
@@ -110,7 +110,7 @@ public:
 
   const MixedSubstitutionModel& getMixedModel() const { return *pmixmodel_.get(); }
 
-  std::string getName() const { return "YNGKP_M1"; }
+  std::string getName() const { return "YNGP_M1"; }
 
 private:
   SubstitutionModel& getModel() { return *pmixmodel_.get(); }
@@ -122,5 +122,5 @@ private:
 
 } //end of namespace bpp.
 
-#endif	//_YNGKP_M1_H_
+#endif	//_YNGP_M1_H_
 
diff --git a/src/Bpp/Phyl/Model/Codon/YNGKP_M8.cpp b/src/Bpp/Phyl/Model/Codon/YNGP_M10.cpp
similarity index 69%
copy from src/Bpp/Phyl/Model/Codon/YNGKP_M8.cpp
copy to src/Bpp/Phyl/Model/Codon/YNGP_M10.cpp
index 869d7ab..e655bc7 100644
--- a/src/Bpp/Phyl/Model/Codon/YNGKP_M8.cpp
+++ b/src/Bpp/Phyl/Model/Codon/YNGP_M10.cpp
@@ -1,7 +1,7 @@
 //
-// File: YNGKP_M8.cpp
+// File: YNGP_M10.cpp
 // Created by:  Laurent Gueguen
-// Created on: May 2010
+// Created on: lundi 15 décembre 2014, à 15h 21
 //
 
 /*
@@ -36,12 +36,12 @@
    knowledge of the CeCILL license and that you accept its terms.
  */
 
-#include "YNGKP_M8.h"
+#include "YNGP_M10.h"
 #include "YN98.h"
 
 #include <Bpp/Numeric/Prob/MixtureOfDiscreteDistributions.h>
-#include <Bpp/Numeric/Prob/SimpleDiscreteDistribution.h>
 #include <Bpp/Numeric/Prob/BetaDiscreteDistribution.h>
+#include <Bpp/Numeric/Prob/GammaDiscreteDistribution.h>
 #include <Bpp/Text/TextTools.h>
 
 using namespace bpp;
@@ -50,26 +50,28 @@ using namespace std;
 
 /******************************************************************************/
 
-YNGKP_M8::YNGKP_M8(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned int nclass) :
-  AbstractBiblioMixedSubstitutionModel("YNGKP_M8."),
-  pmixmodel_(0),
+YNGP_M10::YNGP_M10(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned int nbBeta, unsigned int nbGamma) :
+  AbstractBiblioMixedSubstitutionModel("YNGP_M10."),
+  pmixmodel_(),
   synfrom_(),
-  synto_()
+  synto_(),
+  nBeta_(nbBeta),
+  nGamma_(nbGamma)
 {
-  if (nclass <= 0)
-    throw Exception("Bad number of classes for model YNGKP_M8: " + TextTools::toString(nclass));
+  if (nbBeta <= 0)
+    throw Exception("Bad number of classes for beta distribution of model YNGP_M10: " + TextTools::toString(nbBeta));
+  if (nbGamma <= 0)
+    throw Exception("Bad number of classes for gamma distribution of model YNGP_M10: " + TextTools::toString(nbGamma));
 
   // build the submodel
 
-  BetaDiscreteDistribution* pbdd = new BetaDiscreteDistribution(nclass, 2, 2);
-
-  vector<double> val; val.push_back(2);
-  vector<double> prob; prob.push_back(1);
-  SimpleDiscreteDistribution* psdd = new SimpleDiscreteDistribution(val, prob);
+  BetaDiscreteDistribution* pbdd = new BetaDiscreteDistribution(nbBeta, 2, 2);
+  GammaDiscreteDistribution* pgdd = new GammaDiscreteDistribution(nbGamma, 1, 1, 0.05, 0.05, false, 1);
 
   vector<DiscreteDistribution*> v_distr;
-  v_distr.push_back(pbdd); v_distr.push_back(psdd);
-  prob.clear(); prob.push_back(0.5); prob.push_back(0.5);
+  v_distr.push_back(pbdd); v_distr.push_back(pgdd);
+  vector<double> prob;
+  prob.push_back(0.5); prob.push_back(0.5);
 
   MixtureOfDiscreteDistributions* pmodd = new MixtureOfDiscreteDistributions(v_distr, prob);
 
@@ -77,8 +79,11 @@ YNGKP_M8::YNGKP_M8(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned i
   mpdd["omega"] = pmodd;
 
   YN98* yn98 = new YN98(gc, codonFreqs);
+
   pmixmodel_.reset(new MixtureOfASubstitutionModel(gc->getSourceAlphabet(), yn98, mpdd));
   delete pbdd;
+  delete pgdd;
+
   vector<int> supportedChars = yn98->getAlphabetStates();
 
   // mapping the parameters
@@ -93,14 +98,15 @@ YNGKP_M8::YNGKP_M8(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned i
 
   for (size_t i = 0; i < v.size(); i++)
   {
-    mapParNamesFromPmodel_[v[i]] = getParameterNameWithoutNamespace("YNGKP_M8." + v[i].substr(5));
+    mapParNamesFromPmodel_[v[i]] = v[i].substr(5);
   }
 
   mapParNamesFromPmodel_["YN98.kappa"] = "kappa";
   mapParNamesFromPmodel_["YN98.omega_Mixture.theta1"] = "p0";
   mapParNamesFromPmodel_["YN98.omega_Mixture.1_Beta.alpha"] = "p";
   mapParNamesFromPmodel_["YN98.omega_Mixture.1_Beta.beta"] = "q";
-  mapParNamesFromPmodel_["YN98.omega_Mixture.2_Simple.V1"] = "omegas";
+  mapParNamesFromPmodel_["YN98.omega_Mixture.2_Gamma.alpha"] = "alpha";
+  mapParNamesFromPmodel_["YN98.omega_Mixture.2_Gamma.beta"] = "beta";
 
   // specific parameters
 
@@ -108,13 +114,10 @@ YNGKP_M8::YNGKP_M8(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned i
   for (map<string, string>::iterator it = mapParNamesFromPmodel_.begin(); it != mapParNamesFromPmodel_.end(); it++)
   {
     st = pmixmodel_->getParameterNameWithoutNamespace(it->first);
-    if (it->second != "omegas")
-      addParameter_(new Parameter("YNGKP_M8." + it->second, pmixmodel_->getParameterValue(st),
-                              pmixmodel_->getParameter(st).hasConstraint() ? pmixmodel_->getParameter(st).getConstraint()->clone() : 0, true));
+    addParameter_(new Parameter("YNGP_M10." + it->second, pmixmodel_->getParameterValue(st),
+                                pmixmodel_->getParameter(st).hasConstraint() ? pmixmodel_->getParameter(st).getConstraint()->clone() : 0, true));
   }
 
-  addParameter_(new Parameter("YNGKP_M8.omegas", 2., new IntervalConstraint(1, 1, false), true));
-
   // look for synonymous codons
   for (synfrom_ = 1; synfrom_ < supportedChars.size(); synfrom_++)
   {
@@ -136,26 +139,32 @@ YNGKP_M8::YNGKP_M8(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned i
   updateMatrices();
 }
 
-YNGKP_M8::YNGKP_M8(const YNGKP_M8& mod2) : AbstractBiblioMixedSubstitutionModel(mod2),
-  pmixmodel_(new MixtureOfASubstitutionModel(*mod2.pmixmodel_)),
-  synfrom_(mod2.synfrom_),
-  synto_(mod2.synto_)
+YNGP_M10::YNGP_M10(const YNGP_M10& mod2) : AbstractBiblioMixedSubstitutionModel(mod2),
+                                           pmixmodel_(new MixtureOfASubstitutionModel(*mod2.pmixmodel_)),
+                                           synfrom_(mod2.synfrom_),
+                                           synto_(mod2.synto_),
+                                           nBeta_(mod2.nBeta_),
+                                           nGamma_(mod2.nGamma_)
+
 {}
 
-YNGKP_M8& YNGKP_M8::operator=(const YNGKP_M8& mod2)
+
+YNGP_M10& YNGP_M10::operator=(const YNGP_M10& mod2)
 {
   AbstractBiblioMixedSubstitutionModel::operator=(mod2);
 
   pmixmodel_.reset(new MixtureOfASubstitutionModel(*mod2.pmixmodel_));
   synfrom_ = mod2.synfrom_;
   synto_ = mod2.synto_;
-
+  nBeta_ = mod2.nBeta_;
+  nGamma_ = mod2.nGamma_;
+  
   return *this;
 }
 
-YNGKP_M8::~YNGKP_M8() {}
+YNGP_M10::~YNGP_M10() {}
 
-void YNGKP_M8::updateMatrices()
+void YNGP_M10::updateMatrices()
 {
   AbstractBiblioSubstitutionModel::updateMatrices();
 
diff --git a/src/Bpp/Phyl/Model/Codon/YNGKP_M8.h b/src/Bpp/Phyl/Model/Codon/YNGP_M10.h
similarity index 71%
copy from src/Bpp/Phyl/Model/Codon/YNGKP_M8.h
copy to src/Bpp/Phyl/Model/Codon/YNGP_M10.h
index d9caf9d..a8a605d 100644
--- a/src/Bpp/Phyl/Model/Codon/YNGKP_M8.h
+++ b/src/Bpp/Phyl/Model/Codon/YNGP_M10.h
@@ -1,5 +1,5 @@
 //
-// File: YNGKP_M8.h
+// File: YNGP_M10.h
 // Created by: Laurent Gueguen
 // Created on: May 2010
 //
@@ -37,8 +37,8 @@ The fact that you are presently reading this means that you have had
 knowledge of the CeCILL license and that you accept its terms.
 */
 
-#ifndef _YNGKP_M8_H_
-#define _YNGKP_M8_H_
+#ifndef _YNGP_M10_H_
+#define _YNGP_M10_H_
 
 #include "../AbstractBiblioMixedSubstitutionModel.h"
 #include "../MixtureOfASubstitutionModel.h"
@@ -50,19 +50,19 @@ namespace bpp
 {
 
 /**
- * @brief The Yang et al (2000) M8 substitution model for codons.
+ * @brief The Yang et al (2000) M10 substitution model for codons.
  * @author Laurent Guéguen
  *
  * This model is a mixture of models as described in YN98 class, the
- * mixture being defined on the selection parameter oomega to allow it
+ * mixture being defined on the selection parameter omega to allow it
  * to vary among sites, following a mixture of a Beta distribution and
- * of another value above 1.
+ * of a switched Gamma distribution.
  *
- * This model includes 5 parameters (@f$\kappa at f$, @f$ \alpha @f$ and
- * @f$\beta at f$) of the Beta distribution, @f$p0 at f$ the weight of the
- * Beta distribution and @f$\omega @f$ the selection parameter above 1
- * (with weight @f$ 1-p0 @f$). The codon frequencies @f$ \pi_j @f$ are
- * either observed or infered.
+ * This model includes 5 parameters (@f$\kappa at f$, @f$ p @f$ and
+ * @f$q at f$ of the @f$ Beta(p,q) @f$ distribution, @f$ \alpha @f$ and
+ * @f$\beta at f$ of the @f$ 1 + Gamma(\alpha,\beta) @f$
+ * distribution, at f$p0 at f$ the weight of the Beta distribution. The
+ * codon frequencies @f$ \pi_j @f$ are either observed or infered.
  *
  * References:
  *
@@ -70,35 +70,37 @@ namespace bpp
  * Genetics 155:431-449.
  * 
  */
-class YNGKP_M8:
+class YNGP_M10:
     public AbstractBiblioMixedSubstitutionModel,
     virtual public ReversibleSubstitutionModel
 {
 private:
-  std::auto_ptr<MixtureOfASubstitutionModel> pmixmodel_;
+  std::unique_ptr<MixtureOfASubstitutionModel> pmixmodel_;
 
   /**
    * @brief indexes of 2 codons between which the substitution is
    * synonymous, to set a basis to the homogeneization of the rates.
    */
   size_t synfrom_, synto_;
+
+  unsigned int nBeta_, nGamma_;
   
 public:
   /*
    *@brief Constructor that requires the number of classes of the
-   * BetaDiscreteDistribution.
+   * BetaDiscreteDistribution and the GammaDiscreteDistribution.
    *
    */
   
-  YNGKP_M8(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned int nbclass);
+  YNGP_M10(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned int nbBeta, unsigned int nbGamma);
 
-  ~YNGKP_M8();
+  ~YNGP_M10();
   
-  YNGKP_M8* clone() const { return new YNGKP_M8(*this); }
+  YNGP_M10* clone() const { return new YNGP_M10(*this); }
 
-  YNGKP_M8(const YNGKP_M8&);
+  YNGP_M10(const YNGP_M10&);
 
-  YNGKP_M8& operator=(const YNGKP_M8&);
+  YNGP_M10& operator=(const YNGP_M10&);
 
 protected:
   void updateMatrices();
@@ -108,8 +110,18 @@ public:
 
   const MixedSubstitutionModel& getMixedModel() const { return *pmixmodel_.get(); }
 
-  std::string getName() const { return "YNGKP_M8"; }
+  std::string getName() const { return "YNGP_M10"; }
 
+  unsigned int getNBeta() const 
+  {
+    return nBeta_;
+  }
+  
+  unsigned int getNGamma() const 
+  {
+    return nGamma_;
+  }
+  
 private:
   SubstitutionModel& getModel() { return *pmixmodel_.get(); }
 
@@ -120,5 +132,5 @@ private:
 
 } //end of namespace bpp.
 
-#endif	//_YNGKP_M8_H_
+#endif	//_YNGP_M10_H_
 
diff --git a/src/Bpp/Phyl/Model/Codon/YNGKP_M2.cpp b/src/Bpp/Phyl/Model/Codon/YNGP_M2.cpp
similarity index 85%
rename from src/Bpp/Phyl/Model/Codon/YNGKP_M2.cpp
rename to src/Bpp/Phyl/Model/Codon/YNGP_M2.cpp
index f1fea59..3bb1a21 100644
--- a/src/Bpp/Phyl/Model/Codon/YNGKP_M2.cpp
+++ b/src/Bpp/Phyl/Model/Codon/YNGP_M2.cpp
@@ -1,5 +1,5 @@
 //
-// File: YNGKP_M2.cpp
+// File: YNGP_M2.cpp
 // Created by:  Laurent Gueguen
 // Created on: May 2010
 //
@@ -36,7 +36,7 @@
    knowledge of the CeCILL license and that you accept its terms.
  */
 
-#include "YNGKP_M2.h"
+#include "YNGP_M2.h"
 #include "YN98.h"
 
 #include <Bpp/Numeric/NumConstants.h>
@@ -48,9 +48,9 @@ using namespace std;
 
 /******************************************************************************/
 
-YNGKP_M2::YNGKP_M2(const GeneticCode* gc, FrequenciesSet* codonFreqs) :
-  AbstractBiblioMixedSubstitutionModel("YNGKP_M2."),
-  pmixmodel_(0),
+YNGP_M2::YNGP_M2(const GeneticCode* gc, FrequenciesSet* codonFreqs) :
+  AbstractBiblioMixedSubstitutionModel("YNGP_M2."),
+  pmixmodel_(),
   synfrom_(),
   synto_()
 {
@@ -66,8 +66,10 @@ YNGKP_M2::YNGKP_M2(const GeneticCode* gc, FrequenciesSet* codonFreqs) :
   mpdd["omega"] = psdd;
 
   YN98* yn98 = new YN98(gc, codonFreqs);
+
   pmixmodel_.reset(new MixtureOfASubstitutionModel(gc->getSourceAlphabet(), yn98, mpdd));
   delete psdd;
+
   vector<int> supportedChars = yn98->getAlphabetStates();
 
   // mapping the parameters
@@ -82,7 +84,7 @@ YNGKP_M2::YNGKP_M2(const GeneticCode* gc, FrequenciesSet* codonFreqs) :
 
   for (size_t i = 0; i < v.size(); i++)
   {
-    mapParNamesFromPmodel_[v[i]] = getParameterNameWithoutNamespace("YNGKP_M2." + v[i].substr(5));
+    mapParNamesFromPmodel_[v[i]] = v[i].substr(5);
   }
 
   mapParNamesFromPmodel_["YN98.kappa"] = "kappa";
@@ -98,13 +100,13 @@ YNGKP_M2::YNGKP_M2(const GeneticCode* gc, FrequenciesSet* codonFreqs) :
   {
     st = pmixmodel_->getParameterNameWithoutNamespace(it->first);
     if (it->second.substr(0, 5) != "omega")
-      addParameter_(new Parameter("YNGKP_M2." + it->second, pmixmodel_->getParameterValue(st),
+      addParameter_(new Parameter("YNGP_M2." + it->second, pmixmodel_->getParameterValue(st),
                               pmixmodel_->getParameter(st).hasConstraint() ? pmixmodel_->getParameter(st).getConstraint()->clone() : 0, true));
   }
 
-  addParameter_(new Parameter("YNGKP_M2.omega0", 0.5, new IntervalConstraint(NumConstants::MILLI(), 1, true, false), true));
+  addParameter_(new Parameter("YNGP_M2.omega0", 0.5, new IntervalConstraint(NumConstants::MILLI(), 1, true, false), true));
 
-  addParameter_(new Parameter("YNGKP_M2.omega2", 2, new IntervalConstraint(1, 999, false, false, NumConstants::MILLI()), true));
+  addParameter_(new Parameter("YNGP_M2.omega2", 2, new IntervalConstraint(1, 999, false, false, NumConstants::MILLI()), true));
 
   // look for synonymous codons
   for (synfrom_ = 1; synfrom_ < supportedChars.size(); ++synfrom_)
@@ -128,13 +130,13 @@ YNGKP_M2::YNGKP_M2(const GeneticCode* gc, FrequenciesSet* codonFreqs) :
   updateMatrices();
 }
 
-YNGKP_M2::YNGKP_M2(const YNGKP_M2& mod2) : AbstractBiblioMixedSubstitutionModel(mod2),
+YNGP_M2::YNGP_M2(const YNGP_M2& mod2) : AbstractBiblioMixedSubstitutionModel(mod2),
   pmixmodel_(new MixtureOfASubstitutionModel(*mod2.pmixmodel_)),
   synfrom_(mod2.synfrom_),
   synto_(mod2.synto_)
 {}
 
-YNGKP_M2& YNGKP_M2::operator=(const YNGKP_M2& mod2)
+YNGP_M2& YNGP_M2::operator=(const YNGP_M2& mod2)
 {
   AbstractBiblioMixedSubstitutionModel::operator=(mod2);
 
@@ -145,9 +147,9 @@ YNGKP_M2& YNGKP_M2::operator=(const YNGKP_M2& mod2)
   return *this;
 }
 
-YNGKP_M2::~YNGKP_M2() {}
+YNGP_M2::~YNGP_M2() {}
 
-void YNGKP_M2::updateMatrices()
+void YNGP_M2::updateMatrices()
 {
   AbstractBiblioSubstitutionModel::updateMatrices();
 
diff --git a/src/Bpp/Phyl/Model/Codon/YNGKP_M2.h b/src/Bpp/Phyl/Model/Codon/YNGP_M2.h
similarity index 89%
rename from src/Bpp/Phyl/Model/Codon/YNGKP_M2.h
rename to src/Bpp/Phyl/Model/Codon/YNGP_M2.h
index 359e1f0..0eb253c 100644
--- a/src/Bpp/Phyl/Model/Codon/YNGKP_M2.h
+++ b/src/Bpp/Phyl/Model/Codon/YNGP_M2.h
@@ -1,5 +1,5 @@
 //
-// File: YNGKP_M2.h
+// File: YNGP_M2.h
 // Created by: Laurent Gueguen
 // Created on: May 2010
 //
@@ -37,8 +37,8 @@ The fact that you are presently reading this means that you have had
 knowledge of the CeCILL license and that you accept its terms.
 */
 
-#ifndef _YNGKP_M2_H_
-#define _YNGKP_M2_H_
+#ifndef _YNGP_M2_H_
+#define _YNGP_M2_H_
 
 #include "../AbstractBiblioMixedSubstitutionModel.h"
 #include "../MixtureOfASubstitutionModel.h"
@@ -72,12 +72,12 @@ namespace bpp
  * Wong, W. S. W., Z. Yang, N. Goldman, and R. Nielsen. (2004)
  * Genetics 168:1041--1051.
  */
-class YNGKP_M2:
+class YNGP_M2:
     public AbstractBiblioMixedSubstitutionModel,
     virtual public ReversibleSubstitutionModel
 {
 private:
-  std::auto_ptr<MixtureOfASubstitutionModel> pmixmodel_;
+  std::unique_ptr<MixtureOfASubstitutionModel> pmixmodel_;
 
   /**
    * @brief indexes of 2 codons between which the substitution is
@@ -86,15 +86,15 @@ private:
   size_t synfrom_, synto_;
   
 public:
-  YNGKP_M2(const GeneticCode* gc, FrequenciesSet* codonFreqs);
+  YNGP_M2(const GeneticCode* gc, FrequenciesSet* codonFreqs);
 
-  virtual ~YNGKP_M2();
+  virtual ~YNGP_M2();
   
-  YNGKP_M2* clone() const { return new YNGKP_M2(*this); }
+  YNGP_M2* clone() const { return new YNGP_M2(*this); }
 
-  YNGKP_M2(const YNGKP_M2&);
+  YNGP_M2(const YNGP_M2&);
 
-  YNGKP_M2& operator=(const YNGKP_M2&);
+  YNGP_M2& operator=(const YNGP_M2&);
 
 protected:
   void updateMatrices();
@@ -104,7 +104,7 @@ public:
 
   const MixedSubstitutionModel& getMixedModel() const { return *pmixmodel_.get(); }
 
-  std::string getName() const { return "YNGKP_M2"; }
+  std::string getName() const { return "YNGP_M2"; }
 
 private:
   SubstitutionModel& getModel() { return *pmixmodel_.get(); }
@@ -116,5 +116,5 @@ private:
 
 } //end of namespace bpp.
 
-#endif	//_YNGKP_M2_H_
+#endif	//_YNGP_M2_H_
 
diff --git a/src/Bpp/Phyl/Model/Codon/YNGKP_M3.cpp b/src/Bpp/Phyl/Model/Codon/YNGP_M3.cpp
similarity index 87%
rename from src/Bpp/Phyl/Model/Codon/YNGKP_M3.cpp
rename to src/Bpp/Phyl/Model/Codon/YNGP_M3.cpp
index 9d61027..1a23a95 100644
--- a/src/Bpp/Phyl/Model/Codon/YNGKP_M3.cpp
+++ b/src/Bpp/Phyl/Model/Codon/YNGP_M3.cpp
@@ -1,5 +1,5 @@
 //
-// File: YNGKP_M3.cpp
+// File: YNGP_M3.cpp
 // Created by:  Laurent Gueguen
 // Created on: May 2010
 //
@@ -36,7 +36,7 @@
    knowledge of the CeCILL license and that you accept its terms.
  */
 
-#include "YNGKP_M3.h"
+#include "YNGP_M3.h"
 #include "YN98.h"
 
 #include <Bpp/Numeric/NumConstants.h>
@@ -48,14 +48,14 @@ using namespace std;
 
 /******************************************************************************/
 
-YNGKP_M3::YNGKP_M3(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned int nbOmega) :
-  AbstractBiblioMixedSubstitutionModel("YNGKP_M3."),
-  pmixmodel_(0),
+YNGP_M3::YNGP_M3(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned int nbOmega) :
+  AbstractBiblioMixedSubstitutionModel("YNGP_M3."),
+  pmixmodel_(),
   synfrom_(),
   synto_()
 {
   if (nbOmega < 1)
-    throw Exception("At least one omega is necessary in the YNGKP_M3 model");
+    throw Exception("At least one omega is necessary in the YNGP_M3 model");
 
   // build the submodel
 
@@ -77,8 +77,10 @@ YNGKP_M3::YNGKP_M3(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned i
   mpdd["omega"] = psdd;
 
   YN98* yn98 = new YN98(gc, codonFreqs);
+
   pmixmodel_.reset(new MixtureOfASubstitutionModel(gc->getSourceAlphabet(), yn98, mpdd));
   delete psdd;
+
   vector<int> supportedChars = yn98->getAlphabetStates();
 
   // mapping the parameters
@@ -92,7 +94,7 @@ YNGKP_M3::YNGKP_M3(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned i
   vector<std::string> v = dynamic_cast<YN98*>(pmixmodel_->getNModel(0))->getFrequenciesSet()->getParameters().getParameterNames();
   for (size_t i = 0; i < v.size(); ++i)
   {
-    mapParNamesFromPmodel_[v[i]] = getParameterNameWithoutNamespace("YNGKP_M3." + v[i].substr(5));
+    mapParNamesFromPmodel_[v[i]] = v[i].substr(5);
   }
 
   mapParNamesFromPmodel_["YN98.kappa"] = "kappa";
@@ -116,13 +118,13 @@ YNGKP_M3::YNGKP_M3(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned i
   {
     st = pmixmodel_->getParameterNameWithoutNamespace(it->first);
     if (it->second.substr(0, 5) != "delta")
-      addParameter_(new Parameter("YNGKP_M3." + it->second, pmixmodel_->getParameterValue(st),
+      addParameter_(new Parameter("YNGP_M3." + it->second, pmixmodel_->getParameterValue(st),
                               pmixmodel_->getParameter(st).hasConstraint() ? pmixmodel_->getParameter(st).getConstraint()->clone() : 0, true));
   }
 
   for (size_t i = 1; i < nbOmega; ++i)
   {
-    addParameter_(new Parameter("YNGKP_M3.delta" + TextTools::toString(i), 0.5, new IntervalConstraint(NumConstants::MILLI(), 999, true, true, NumConstants::MILLI()), true));
+    addParameter_(new Parameter("YNGP_M3.delta" + TextTools::toString(i), 0.5, new IntervalConstraint(NumConstants::MILLI(), 999, true, true, NumConstants::MILLI()), true));
   }
 
   // look for synonymous codons
@@ -146,13 +148,13 @@ YNGKP_M3::YNGKP_M3(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned i
   updateMatrices();
 }
 
-YNGKP_M3::YNGKP_M3(const YNGKP_M3& mod2) : AbstractBiblioMixedSubstitutionModel(mod2),
+YNGP_M3::YNGP_M3(const YNGP_M3& mod2) : AbstractBiblioMixedSubstitutionModel(mod2),
   pmixmodel_(new MixtureOfASubstitutionModel(*mod2.pmixmodel_)),
   synfrom_(mod2.synfrom_),
   synto_(mod2.synto_)
 {}
 
-YNGKP_M3& YNGKP_M3::operator=(const YNGKP_M3& mod2)
+YNGP_M3& YNGP_M3::operator=(const YNGP_M3& mod2)
 {
   AbstractBiblioMixedSubstitutionModel::operator=(mod2);
 
@@ -163,9 +165,9 @@ YNGKP_M3& YNGKP_M3::operator=(const YNGKP_M3& mod2)
   return *this;
 }
 
-YNGKP_M3::~YNGKP_M3() {}
+YNGP_M3::~YNGP_M3() {}
 
-void YNGKP_M3::updateMatrices()
+void YNGP_M3::updateMatrices()
 {
   for (unsigned int i = 0; i < lParPmodel_.size(); i++)
   {
diff --git a/src/Bpp/Phyl/Model/Codon/YNGKP_M3.h b/src/Bpp/Phyl/Model/Codon/YNGP_M3.h
similarity index 88%
rename from src/Bpp/Phyl/Model/Codon/YNGKP_M3.h
rename to src/Bpp/Phyl/Model/Codon/YNGP_M3.h
index caacfba..9a5a658 100644
--- a/src/Bpp/Phyl/Model/Codon/YNGKP_M3.h
+++ b/src/Bpp/Phyl/Model/Codon/YNGP_M3.h
@@ -1,5 +1,5 @@
 //
-// File: YNGKP_M3.h
+// File: YNGP_M3.h
 // Created by: Laurent Gueguen
 // Created on: May 2010
 //
@@ -37,8 +37,8 @@ The fact that you are presently reading this means that you have had
 knowledge of the CeCILL license and that you accept its terms.
 */
 
-#ifndef _YNGKP_M3_H_
-#define _YNGKP_M3_H_
+#ifndef _YNGP_M3_H_
+#define _YNGP_M3_H_
 
 #include "../AbstractBiblioMixedSubstitutionModel.h"
 #include "../MixtureOfASubstitutionModel.h"
@@ -72,12 +72,12 @@ namespace bpp
  * Genetics 155:431-449.
  * 
  */
-class YNGKP_M3:
+class YNGP_M3:
     public AbstractBiblioMixedSubstitutionModel,
     virtual public ReversibleSubstitutionModel
 {
 private:
-  std::auto_ptr<MixtureOfASubstitutionModel> pmixmodel_;
+  std::unique_ptr<MixtureOfASubstitutionModel> pmixmodel_;
 
   /**
    * @brief indexes of 2 codons between which the substitution is
@@ -87,15 +87,15 @@ private:
   size_t synfrom_, synto_;
   
 public:
-  YNGKP_M3(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned int nclass = 3);
+  YNGP_M3(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned int nclass = 3);
 
-  ~YNGKP_M3();
+  ~YNGP_M3();
   
-  YNGKP_M3* clone() const { return new YNGKP_M3(*this); }
+  YNGP_M3* clone() const { return new YNGP_M3(*this); }
 
-  YNGKP_M3(const YNGKP_M3&);
+  YNGP_M3(const YNGP_M3&);
 
-  YNGKP_M3& operator=(const YNGKP_M3&);
+  YNGP_M3& operator=(const YNGP_M3&);
 
 protected:
   void updateMatrices();
@@ -105,7 +105,7 @@ public:
 
   const MixedSubstitutionModel& getMixedModel() const { return *pmixmodel_.get(); }
 
-  std::string getName() const { return "YNGKP_M3"; }
+  std::string getName() const { return "YNGP_M3"; }
 
 private:
   SubstitutionModel& getModel() { return *pmixmodel_.get(); }
@@ -118,5 +118,5 @@ private:
 
 } //end of namespace bpp.
 
-#endif	//_YNGKP_M3_H_
+#endif	//_YNGP_M3_H_
 
diff --git a/src/Bpp/Phyl/Model/Codon/YNGKP_M7.cpp b/src/Bpp/Phyl/Model/Codon/YNGP_M7.cpp
similarity index 86%
rename from src/Bpp/Phyl/Model/Codon/YNGKP_M7.cpp
rename to src/Bpp/Phyl/Model/Codon/YNGP_M7.cpp
index 7658f2b..2300410 100644
--- a/src/Bpp/Phyl/Model/Codon/YNGKP_M7.cpp
+++ b/src/Bpp/Phyl/Model/Codon/YNGP_M7.cpp
@@ -1,5 +1,5 @@
 //
-// File: YNGKP_M7.cpp
+// File: YNGP_M7.cpp
 // Created by:  Laurent Gueguen
 // Created on: May 2010
 //
@@ -36,7 +36,7 @@
    knowledge of the CeCILL license and that you accept its terms.
  */
 
-#include "YNGKP_M7.h"
+#include "YNGP_M7.h"
 #include "YN98.h"
 
 #include <Bpp/Numeric/NumConstants.h>
@@ -50,14 +50,14 @@ using namespace std;
 
 /******************************************************************************/
 
-YNGKP_M7::YNGKP_M7(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned int nclass) :
-  AbstractBiblioMixedSubstitutionModel("YNGKP_M7."),
-  pmixmodel_(0),
+YNGP_M7::YNGP_M7(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned int nclass) :
+  AbstractBiblioMixedSubstitutionModel("YNGP_M7."),
+  pmixmodel_(),
   synfrom_(),
   synto_()
 {
   if (nclass <= 0)
-    throw Exception("Bad number of classes for model YNGKP_M7: " + TextTools::toString(nclass));
+    throw Exception("Bad number of classes for model YNGP_M7: " + TextTools::toString(nclass));
 
   // build the submodel
 
@@ -67,8 +67,11 @@ YNGKP_M7::YNGKP_M7(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned i
   mpdd["omega"] = pbdd;
 
   YN98* yn98 = new YN98(gc, codonFreqs);
+
   pmixmodel_.reset(new MixtureOfASubstitutionModel(gc->getSourceAlphabet(), yn98, mpdd));
+
   delete pbdd;
+
   vector<int> supportedChars = yn98->getAlphabetStates();
 
   // mapping the parameters
@@ -83,7 +86,7 @@ YNGKP_M7::YNGKP_M7(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned i
 
   for (size_t i = 0; i < v.size(); i++)
   {
-    mapParNamesFromPmodel_[v[i]] = getParameterNameWithoutNamespace("YNGKP_M7." + v[i].substr(5));
+    mapParNamesFromPmodel_[v[i]] = v[i].substr(5);
   }
 
   mapParNamesFromPmodel_["YN98.kappa"] = "kappa";
@@ -96,7 +99,7 @@ YNGKP_M7::YNGKP_M7(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned i
   for (map<string, string>::iterator it = mapParNamesFromPmodel_.begin(); it != mapParNamesFromPmodel_.end(); it++)
   {
     st = pmixmodel_->getParameterNameWithoutNamespace(it->first);
-    addParameter_(new Parameter("YNGKP_M7." + it->second, pmixmodel_->getParameterValue(st),
+    addParameter_(new Parameter("YNGP_M7." + it->second, pmixmodel_->getParameterValue(st),
                             pmixmodel_->getParameter(st).hasConstraint() ? pmixmodel_->getParameter(st).getConstraint()->clone() : 0, true));
   }
 
@@ -122,13 +125,13 @@ YNGKP_M7::YNGKP_M7(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned i
   updateMatrices();
 }
 
-YNGKP_M7::YNGKP_M7(const YNGKP_M7& mod2) : AbstractBiblioMixedSubstitutionModel(mod2),
+YNGP_M7::YNGP_M7(const YNGP_M7& mod2) : AbstractBiblioMixedSubstitutionModel(mod2),
   pmixmodel_(new MixtureOfASubstitutionModel(*mod2.pmixmodel_)),
   synfrom_(mod2.synfrom_),
   synto_(mod2.synto_)
 {}
 
-YNGKP_M7& YNGKP_M7::operator=(const YNGKP_M7& mod2)
+YNGP_M7& YNGP_M7::operator=(const YNGP_M7& mod2)
 {
   AbstractBiblioMixedSubstitutionModel::operator=(mod2);
 
@@ -139,9 +142,9 @@ YNGKP_M7& YNGKP_M7::operator=(const YNGKP_M7& mod2)
   return *this;
 }
 
-YNGKP_M7::~YNGKP_M7() {}
+YNGP_M7::~YNGP_M7() {}
 
-void YNGKP_M7::updateMatrices()
+void YNGP_M7::updateMatrices()
 {
   AbstractBiblioSubstitutionModel::updateMatrices();
 
diff --git a/src/Bpp/Phyl/Model/Codon/YNGKP_M7.h b/src/Bpp/Phyl/Model/Codon/YNGP_M7.h
similarity index 88%
rename from src/Bpp/Phyl/Model/Codon/YNGKP_M7.h
rename to src/Bpp/Phyl/Model/Codon/YNGP_M7.h
index 715dd8f..8bb6bde 100644
--- a/src/Bpp/Phyl/Model/Codon/YNGKP_M7.h
+++ b/src/Bpp/Phyl/Model/Codon/YNGP_M7.h
@@ -1,5 +1,5 @@
 //
-// File: YNGKP_M7.h
+// File: YNGP_M7.h
 // Created by: Laurent Gueguen
 // Created on: May 2010
 //
@@ -37,8 +37,8 @@ The fact that you are presently reading this means that you have had
 knowledge of the CeCILL license and that you accept its terms.
 */
 
-#ifndef _YNGKP_M7_H_
-#define _YNGKP_M7_H_
+#ifndef _YNGP_M7_H_
+#define _YNGP_M7_H_
 
 #include "../AbstractBiblioMixedSubstitutionModel.h"
 #include "../MixtureOfASubstitutionModel.h"
@@ -67,12 +67,12 @@ namespace bpp
  * Genetics 155:431-449.
  * 
  */
-class YNGKP_M7:
+class YNGP_M7:
     public AbstractBiblioMixedSubstitutionModel,
     virtual public ReversibleSubstitutionModel
 {
 private:
-  std::auto_ptr<MixtureOfASubstitutionModel> pmixmodel_;
+  std::unique_ptr<MixtureOfASubstitutionModel> pmixmodel_;
 
   /**
    * @brief indexes of 2 codons between which the substitution is
@@ -88,15 +88,15 @@ public:
    *
    */
   
-  YNGKP_M7(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned int nclass);
+  YNGP_M7(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned int nclass);
 
-  ~YNGKP_M7();
+  ~YNGP_M7();
   
-  YNGKP_M7* clone() const { return new YNGKP_M7(*this); }
+  YNGP_M7* clone() const { return new YNGP_M7(*this); }
 
-  YNGKP_M7(const YNGKP_M7&);
+  YNGP_M7(const YNGP_M7&);
 
-  YNGKP_M7& operator=(const YNGKP_M7&);
+  YNGP_M7& operator=(const YNGP_M7&);
 
 protected:
   void updateMatrices();
@@ -106,7 +106,7 @@ public:
 
   const MixedSubstitutionModel& getMixedModel() const { return *pmixmodel_.get(); }
 
-  std::string getName() const { return "YNGKP_M7"; }
+  std::string getName() const { return "YNGP_M7"; }
 
 private:
   SubstitutionModel& getModel() { return *pmixmodel_.get(); }
@@ -119,5 +119,5 @@ private:
 
 } //end of namespace bpp.
 
-#endif	//_YNGKP_M7_H_
+#endif	//_YNGP_M7_H_
 
diff --git a/src/Bpp/Phyl/Model/Codon/YNGKP_M8.cpp b/src/Bpp/Phyl/Model/Codon/YNGP_M8.cpp
similarity index 86%
copy from src/Bpp/Phyl/Model/Codon/YNGKP_M8.cpp
copy to src/Bpp/Phyl/Model/Codon/YNGP_M8.cpp
index 869d7ab..d29589d 100644
--- a/src/Bpp/Phyl/Model/Codon/YNGKP_M8.cpp
+++ b/src/Bpp/Phyl/Model/Codon/YNGP_M8.cpp
@@ -1,5 +1,5 @@
 //
-// File: YNGKP_M8.cpp
+// File: YNGP_M8.cpp
 // Created by:  Laurent Gueguen
 // Created on: May 2010
 //
@@ -36,7 +36,7 @@
    knowledge of the CeCILL license and that you accept its terms.
  */
 
-#include "YNGKP_M8.h"
+#include "YNGP_M8.h"
 #include "YN98.h"
 
 #include <Bpp/Numeric/Prob/MixtureOfDiscreteDistributions.h>
@@ -50,14 +50,14 @@ using namespace std;
 
 /******************************************************************************/
 
-YNGKP_M8::YNGKP_M8(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned int nclass) :
-  AbstractBiblioMixedSubstitutionModel("YNGKP_M8."),
-  pmixmodel_(0),
+YNGP_M8::YNGP_M8(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned int nclass) :
+  AbstractBiblioMixedSubstitutionModel("YNGP_M8."),
+  pmixmodel_(),
   synfrom_(),
   synto_()
 {
   if (nclass <= 0)
-    throw Exception("Bad number of classes for model YNGKP_M8: " + TextTools::toString(nclass));
+    throw Exception("Bad number of classes for model YNGP_M8: " + TextTools::toString(nclass));
 
   // build the submodel
 
@@ -77,10 +77,12 @@ YNGKP_M8::YNGKP_M8(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned i
   mpdd["omega"] = pmodd;
 
   YN98* yn98 = new YN98(gc, codonFreqs);
+
   pmixmodel_.reset(new MixtureOfASubstitutionModel(gc->getSourceAlphabet(), yn98, mpdd));
   delete pbdd;
-  vector<int> supportedChars = yn98->getAlphabetStates();
 
+  vector<int> supportedChars = yn98->getAlphabetStates();
+  
   // mapping the parameters
 
   ParameterList pl = pmixmodel_->getParameters();
@@ -93,7 +95,7 @@ YNGKP_M8::YNGKP_M8(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned i
 
   for (size_t i = 0; i < v.size(); i++)
   {
-    mapParNamesFromPmodel_[v[i]] = getParameterNameWithoutNamespace("YNGKP_M8." + v[i].substr(5));
+    mapParNamesFromPmodel_[v[i]] = v[i].substr(5);
   }
 
   mapParNamesFromPmodel_["YN98.kappa"] = "kappa";
@@ -109,11 +111,11 @@ YNGKP_M8::YNGKP_M8(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned i
   {
     st = pmixmodel_->getParameterNameWithoutNamespace(it->first);
     if (it->second != "omegas")
-      addParameter_(new Parameter("YNGKP_M8." + it->second, pmixmodel_->getParameterValue(st),
+      addParameter_(new Parameter("YNGP_M8." + it->second, pmixmodel_->getParameterValue(st),
                               pmixmodel_->getParameter(st).hasConstraint() ? pmixmodel_->getParameter(st).getConstraint()->clone() : 0, true));
   }
 
-  addParameter_(new Parameter("YNGKP_M8.omegas", 2., new IntervalConstraint(1, 1, false), true));
+  addParameter_(new Parameter("YNGP_M8.omegas", 2., new IntervalConstraint(1, 1, false), true));
 
   // look for synonymous codons
   for (synfrom_ = 1; synfrom_ < supportedChars.size(); synfrom_++)
@@ -136,13 +138,13 @@ YNGKP_M8::YNGKP_M8(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned i
   updateMatrices();
 }
 
-YNGKP_M8::YNGKP_M8(const YNGKP_M8& mod2) : AbstractBiblioMixedSubstitutionModel(mod2),
+YNGP_M8::YNGP_M8(const YNGP_M8& mod2) : AbstractBiblioMixedSubstitutionModel(mod2),
   pmixmodel_(new MixtureOfASubstitutionModel(*mod2.pmixmodel_)),
   synfrom_(mod2.synfrom_),
   synto_(mod2.synto_)
 {}
 
-YNGKP_M8& YNGKP_M8::operator=(const YNGKP_M8& mod2)
+YNGP_M8& YNGP_M8::operator=(const YNGP_M8& mod2)
 {
   AbstractBiblioMixedSubstitutionModel::operator=(mod2);
 
@@ -153,9 +155,9 @@ YNGKP_M8& YNGKP_M8::operator=(const YNGKP_M8& mod2)
   return *this;
 }
 
-YNGKP_M8::~YNGKP_M8() {}
+YNGP_M8::~YNGP_M8() {}
 
-void YNGKP_M8::updateMatrices()
+void YNGP_M8::updateMatrices()
 {
   AbstractBiblioSubstitutionModel::updateMatrices();
 
diff --git a/src/Bpp/Phyl/Model/Codon/YNGKP_M8.h b/src/Bpp/Phyl/Model/Codon/YNGP_M8.h
similarity index 83%
copy from src/Bpp/Phyl/Model/Codon/YNGKP_M8.h
copy to src/Bpp/Phyl/Model/Codon/YNGP_M8.h
index d9caf9d..7383114 100644
--- a/src/Bpp/Phyl/Model/Codon/YNGKP_M8.h
+++ b/src/Bpp/Phyl/Model/Codon/YNGP_M8.h
@@ -1,5 +1,5 @@
 //
-// File: YNGKP_M8.h
+// File: YNGP_M8.h
 // Created by: Laurent Gueguen
 // Created on: May 2010
 //
@@ -37,8 +37,8 @@ The fact that you are presently reading this means that you have had
 knowledge of the CeCILL license and that you accept its terms.
 */
 
-#ifndef _YNGKP_M8_H_
-#define _YNGKP_M8_H_
+#ifndef _YNGP_M8_H_
+#define _YNGP_M8_H_
 
 #include "../AbstractBiblioMixedSubstitutionModel.h"
 #include "../MixtureOfASubstitutionModel.h"
@@ -58,10 +58,10 @@ namespace bpp
  * to vary among sites, following a mixture of a Beta distribution and
  * of another value above 1.
  *
- * This model includes 5 parameters (@f$\kappa at f$, @f$ \alpha @f$ and
- * @f$\beta at f$) of the Beta distribution, @f$p0 at f$ the weight of the
+ * This model includes 5 parameters (@f$\kappa at f$, @f$ p @f$ and
+ * @f$q at f$ of the @f$ Beta(p,q) @f$ distribution, @f$p0 at f$ the weight of the
  * Beta distribution and @f$\omega @f$ the selection parameter above 1
- * (with weight @f$ 1-p0 @f$). The codon frequencies @f$ \pi_j @f$ are
+ * (with weight @f$ 1-p0 @f$)). The codon frequencies @f$ \pi_j @f$ are
  * either observed or infered.
  *
  * References:
@@ -70,12 +70,12 @@ namespace bpp
  * Genetics 155:431-449.
  * 
  */
-class YNGKP_M8:
+class YNGP_M8:
     public AbstractBiblioMixedSubstitutionModel,
     virtual public ReversibleSubstitutionModel
 {
 private:
-  std::auto_ptr<MixtureOfASubstitutionModel> pmixmodel_;
+  std::unique_ptr<MixtureOfASubstitutionModel> pmixmodel_;
 
   /**
    * @brief indexes of 2 codons between which the substitution is
@@ -90,15 +90,15 @@ public:
    *
    */
   
-  YNGKP_M8(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned int nbclass);
+  YNGP_M8(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned int nbclass);
 
-  ~YNGKP_M8();
+  ~YNGP_M8();
   
-  YNGKP_M8* clone() const { return new YNGKP_M8(*this); }
+  YNGP_M8* clone() const { return new YNGP_M8(*this); }
 
-  YNGKP_M8(const YNGKP_M8&);
+  YNGP_M8(const YNGP_M8&);
 
-  YNGKP_M8& operator=(const YNGKP_M8&);
+  YNGP_M8& operator=(const YNGP_M8&);
 
 protected:
   void updateMatrices();
@@ -108,7 +108,7 @@ public:
 
   const MixedSubstitutionModel& getMixedModel() const { return *pmixmodel_.get(); }
 
-  std::string getName() const { return "YNGKP_M8"; }
+  std::string getName() const { return "YNGP_M8"; }
 
 private:
   SubstitutionModel& getModel() { return *pmixmodel_.get(); }
@@ -120,5 +120,5 @@ private:
 
 } //end of namespace bpp.
 
-#endif	//_YNGKP_M8_H_
+#endif	//_YNGP_M8_H_
 
diff --git a/src/Bpp/Phyl/Model/Codon/YNGKP_M8.cpp b/src/Bpp/Phyl/Model/Codon/YNGP_M9.cpp
similarity index 69%
rename from src/Bpp/Phyl/Model/Codon/YNGKP_M8.cpp
rename to src/Bpp/Phyl/Model/Codon/YNGP_M9.cpp
index 869d7ab..d52dee0 100644
--- a/src/Bpp/Phyl/Model/Codon/YNGKP_M8.cpp
+++ b/src/Bpp/Phyl/Model/Codon/YNGP_M9.cpp
@@ -1,7 +1,7 @@
 //
-// File: YNGKP_M8.cpp
+// File: YNGP_M9.cpp
 // Created by:  Laurent Gueguen
-// Created on: May 2010
+// Created on: lundi 15 décembre 2014, à 15h 21
 //
 
 /*
@@ -36,12 +36,12 @@
    knowledge of the CeCILL license and that you accept its terms.
  */
 
-#include "YNGKP_M8.h"
+#include "YNGP_M9.h"
 #include "YN98.h"
 
 #include <Bpp/Numeric/Prob/MixtureOfDiscreteDistributions.h>
-#include <Bpp/Numeric/Prob/SimpleDiscreteDistribution.h>
 #include <Bpp/Numeric/Prob/BetaDiscreteDistribution.h>
+#include <Bpp/Numeric/Prob/GammaDiscreteDistribution.h>
 #include <Bpp/Text/TextTools.h>
 
 using namespace bpp;
@@ -50,26 +50,28 @@ using namespace std;
 
 /******************************************************************************/
 
-YNGKP_M8::YNGKP_M8(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned int nclass) :
-  AbstractBiblioMixedSubstitutionModel("YNGKP_M8."),
-  pmixmodel_(0),
+YNGP_M9::YNGP_M9(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned int nbBeta, unsigned int nbGamma) :
+  AbstractBiblioMixedSubstitutionModel("YNGP_M9."),
+  pmixmodel_(),
   synfrom_(),
-  synto_()
+  synto_(),
+  nBeta_(nbBeta),
+  nGamma_(nbGamma)
 {
-  if (nclass <= 0)
-    throw Exception("Bad number of classes for model YNGKP_M8: " + TextTools::toString(nclass));
+  if (nbBeta <= 0)
+    throw Exception("Bad number of classes for beta distribution of model YNGP_M9: " + TextTools::toString(nbBeta));
+  if (nbGamma <= 0)
+    throw Exception("Bad number of classes for gamma distribution of model YNGP_M9: " + TextTools::toString(nbGamma));
 
   // build the submodel
 
-  BetaDiscreteDistribution* pbdd = new BetaDiscreteDistribution(nclass, 2, 2);
-
-  vector<double> val; val.push_back(2);
-  vector<double> prob; prob.push_back(1);
-  SimpleDiscreteDistribution* psdd = new SimpleDiscreteDistribution(val, prob);
+  BetaDiscreteDistribution* pbdd = new BetaDiscreteDistribution(nbBeta, 2, 2);
+  GammaDiscreteDistribution* pgdd = new GammaDiscreteDistribution(nbGamma, 1, 1);
 
   vector<DiscreteDistribution*> v_distr;
-  v_distr.push_back(pbdd); v_distr.push_back(psdd);
-  prob.clear(); prob.push_back(0.5); prob.push_back(0.5);
+  v_distr.push_back(pbdd); v_distr.push_back(pgdd);
+  vector<double> prob;
+  prob.push_back(0.5); prob.push_back(0.5);
 
   MixtureOfDiscreteDistributions* pmodd = new MixtureOfDiscreteDistributions(v_distr, prob);
 
@@ -79,6 +81,8 @@ YNGKP_M8::YNGKP_M8(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned i
   YN98* yn98 = new YN98(gc, codonFreqs);
   pmixmodel_.reset(new MixtureOfASubstitutionModel(gc->getSourceAlphabet(), yn98, mpdd));
   delete pbdd;
+  delete pgdd;
+
   vector<int> supportedChars = yn98->getAlphabetStates();
 
   // mapping the parameters
@@ -93,14 +97,15 @@ YNGKP_M8::YNGKP_M8(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned i
 
   for (size_t i = 0; i < v.size(); i++)
   {
-    mapParNamesFromPmodel_[v[i]] = getParameterNameWithoutNamespace("YNGKP_M8." + v[i].substr(5));
+    mapParNamesFromPmodel_[v[i]] = v[i].substr(5);
   }
 
   mapParNamesFromPmodel_["YN98.kappa"] = "kappa";
   mapParNamesFromPmodel_["YN98.omega_Mixture.theta1"] = "p0";
   mapParNamesFromPmodel_["YN98.omega_Mixture.1_Beta.alpha"] = "p";
   mapParNamesFromPmodel_["YN98.omega_Mixture.1_Beta.beta"] = "q";
-  mapParNamesFromPmodel_["YN98.omega_Mixture.2_Simple.V1"] = "omegas";
+  mapParNamesFromPmodel_["YN98.omega_Mixture.2_Gamma.alpha"] = "alpha";
+  mapParNamesFromPmodel_["YN98.omega_Mixture.2_Gamma.beta"] = "beta";
 
   // specific parameters
 
@@ -108,13 +113,10 @@ YNGKP_M8::YNGKP_M8(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned i
   for (map<string, string>::iterator it = mapParNamesFromPmodel_.begin(); it != mapParNamesFromPmodel_.end(); it++)
   {
     st = pmixmodel_->getParameterNameWithoutNamespace(it->first);
-    if (it->second != "omegas")
-      addParameter_(new Parameter("YNGKP_M8." + it->second, pmixmodel_->getParameterValue(st),
-                              pmixmodel_->getParameter(st).hasConstraint() ? pmixmodel_->getParameter(st).getConstraint()->clone() : 0, true));
+    addParameter_(new Parameter("YNGP_M9." + it->second, pmixmodel_->getParameterValue(st),
+                                pmixmodel_->getParameter(st).hasConstraint() ? pmixmodel_->getParameter(st).getConstraint()->clone() : 0, true));
   }
 
-  addParameter_(new Parameter("YNGKP_M8.omegas", 2., new IntervalConstraint(1, 1, false), true));
-
   // look for synonymous codons
   for (synfrom_ = 1; synfrom_ < supportedChars.size(); synfrom_++)
   {
@@ -136,26 +138,32 @@ YNGKP_M8::YNGKP_M8(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned i
   updateMatrices();
 }
 
-YNGKP_M8::YNGKP_M8(const YNGKP_M8& mod2) : AbstractBiblioMixedSubstitutionModel(mod2),
-  pmixmodel_(new MixtureOfASubstitutionModel(*mod2.pmixmodel_)),
-  synfrom_(mod2.synfrom_),
-  synto_(mod2.synto_)
+YNGP_M9::YNGP_M9(const YNGP_M9& mod2) : AbstractBiblioMixedSubstitutionModel(mod2),
+                                           pmixmodel_(new MixtureOfASubstitutionModel(*mod2.pmixmodel_)),
+                                           synfrom_(mod2.synfrom_),
+                                           synto_(mod2.synto_),
+                                           nBeta_(mod2.nBeta_),
+                                           nGamma_(mod2.nGamma_)
+
 {}
 
-YNGKP_M8& YNGKP_M8::operator=(const YNGKP_M8& mod2)
+
+YNGP_M9& YNGP_M9::operator=(const YNGP_M9& mod2)
 {
   AbstractBiblioMixedSubstitutionModel::operator=(mod2);
 
   pmixmodel_.reset(new MixtureOfASubstitutionModel(*mod2.pmixmodel_));
   synfrom_ = mod2.synfrom_;
   synto_ = mod2.synto_;
-
+  nBeta_ = mod2.nBeta_;
+  nGamma_ = mod2.nGamma_;
+  
   return *this;
 }
 
-YNGKP_M8::~YNGKP_M8() {}
+YNGP_M9::~YNGP_M9() {}
 
-void YNGKP_M8::updateMatrices()
+void YNGP_M9::updateMatrices()
 {
   AbstractBiblioSubstitutionModel::updateMatrices();
 
diff --git a/src/Bpp/Phyl/Model/Codon/YNGKP_M8.h b/src/Bpp/Phyl/Model/Codon/YNGP_M9.h
similarity index 74%
rename from src/Bpp/Phyl/Model/Codon/YNGKP_M8.h
rename to src/Bpp/Phyl/Model/Codon/YNGP_M9.h
index d9caf9d..851a50c 100644
--- a/src/Bpp/Phyl/Model/Codon/YNGKP_M8.h
+++ b/src/Bpp/Phyl/Model/Codon/YNGP_M9.h
@@ -1,5 +1,5 @@
 //
-// File: YNGKP_M8.h
+// File: YNGP_M9.h
 // Created by: Laurent Gueguen
 // Created on: May 2010
 //
@@ -37,8 +37,8 @@ The fact that you are presently reading this means that you have had
 knowledge of the CeCILL license and that you accept its terms.
 */
 
-#ifndef _YNGKP_M8_H_
-#define _YNGKP_M8_H_
+#ifndef _YNGP_M9_H_
+#define _YNGP_M9_H_
 
 #include "../AbstractBiblioMixedSubstitutionModel.h"
 #include "../MixtureOfASubstitutionModel.h"
@@ -50,19 +50,19 @@ namespace bpp
 {
 
 /**
- * @brief The Yang et al (2000) M8 substitution model for codons.
+ * @brief The Yang et al (2000) M9 substitution model for codons.
  * @author Laurent Guéguen
  *
  * This model is a mixture of models as described in YN98 class, the
  * mixture being defined on the selection parameter oomega to allow it
  * to vary among sites, following a mixture of a Beta distribution and
- * of another value above 1.
+ * of a Gamma distribution.
  *
- * This model includes 5 parameters (@f$\kappa at f$, @f$ \alpha @f$ and
- * @f$\beta at f$) of the Beta distribution, @f$p0 at f$ the weight of the
- * Beta distribution and @f$\omega @f$ the selection parameter above 1
- * (with weight @f$ 1-p0 @f$). The codon frequencies @f$ \pi_j @f$ are
- * either observed or infered.
+ * This model includes 5 parameters (@f$\kappa at f$, @f$ p @f$ and
+ * @f$q at f$ of the @f$ Beta(p,q) @f$ distribution, @f$ \alpha @f$ and
+ * @f$\beta at f$ of the @f$ Gamma(\alpha,\beta) @f$
+ * distribution, at f$p0 at f$ the weight of the Beta distribution. The
+ * codon frequencies @f$ \pi_j @f$ are either observed or infered.
  *
  * References:
  *
@@ -70,35 +70,37 @@ namespace bpp
  * Genetics 155:431-449.
  * 
  */
-class YNGKP_M8:
+class YNGP_M9:
     public AbstractBiblioMixedSubstitutionModel,
     virtual public ReversibleSubstitutionModel
 {
 private:
-  std::auto_ptr<MixtureOfASubstitutionModel> pmixmodel_;
+  std::unique_ptr<MixtureOfASubstitutionModel> pmixmodel_;
 
   /**
    * @brief indexes of 2 codons between which the substitution is
    * synonymous, to set a basis to the homogeneization of the rates.
    */
   size_t synfrom_, synto_;
+
+  unsigned int nBeta_, nGamma_;
   
 public:
   /*
    *@brief Constructor that requires the number of classes of the
-   * BetaDiscreteDistribution.
+   * BetaDiscreteDistribution and the GammaDiscreteDistribution.
    *
    */
   
-  YNGKP_M8(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned int nbclass);
+  YNGP_M9(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned int nbBeta, unsigned int nbGamma);
 
-  ~YNGKP_M8();
+  ~YNGP_M9();
   
-  YNGKP_M8* clone() const { return new YNGKP_M8(*this); }
+  YNGP_M9* clone() const { return new YNGP_M9(*this); }
 
-  YNGKP_M8(const YNGKP_M8&);
+  YNGP_M9(const YNGP_M9&);
 
-  YNGKP_M8& operator=(const YNGKP_M8&);
+  YNGP_M9& operator=(const YNGP_M9&);
 
 protected:
   void updateMatrices();
@@ -108,8 +110,18 @@ public:
 
   const MixedSubstitutionModel& getMixedModel() const { return *pmixmodel_.get(); }
 
-  std::string getName() const { return "YNGKP_M8"; }
+  std::string getName() const { return "YNGP_M9"; }
 
+  unsigned int getNBeta() const 
+  {
+    return nBeta_;
+  }
+  
+  unsigned int getNGamma() const 
+  {
+    return nGamma_;
+  }
+  
 private:
   SubstitutionModel& getModel() { return *pmixmodel_.get(); }
 
@@ -120,5 +132,5 @@ private:
 
 } //end of namespace bpp.
 
-#endif	//_YNGKP_M8_H_
+#endif	//_YNGP_M9_H_
 
diff --git a/src/Bpp/Phyl/Model/FrequenciesSet/CodonFrequenciesSet.cpp b/src/Bpp/Phyl/Model/FrequenciesSet/CodonFrequenciesSet.cpp
index 8729f81..01e4df3 100644
--- a/src/Bpp/Phyl/Model/FrequenciesSet/CodonFrequenciesSet.cpp
+++ b/src/Bpp/Phyl/Model/FrequenciesSet/CodonFrequenciesSet.cpp
@@ -150,6 +150,8 @@ void FullCodonFrequenciesSet::setFrequencies(const vector<double>& frequencies)
 
 void FullCodonFrequenciesSet::fireParameterChanged(const ParameterList& parameters)
 {
+  AbstractFrequenciesSet::fireParameterChanged(parameters);
+
   sFreq_.matchParametersValues(parameters);
   updateFreq_();
 }
@@ -248,6 +250,8 @@ FullPerAACodonFrequenciesSet& FullPerAACodonFrequenciesSet::operator=(const Full
 
 void FullPerAACodonFrequenciesSet::fireParameterChanged(const ParameterList& parameters)
 {
+  AbstractFrequenciesSet::fireParameterChanged(parameters);
+
   if (dynamic_cast<AbstractFrequenciesSet*>(ppfs_.get()))
     (dynamic_cast<AbstractFrequenciesSet*>(ppfs_.get()))->matchParametersValues(parameters);
   for (size_t i = 0; i < vS_.size(); i++)
@@ -266,7 +270,7 @@ void FullPerAACodonFrequenciesSet::updateFrequencies()
     std::vector<int> vc = pgc_->getSynonymous(aa);
     for (size_t j = 0; j < vc.size(); j++)
     {
-      //NB: only one alphabet state per model state here, as it is a CodonFreqSet.
+      // NB: only one alphabet state per model state here, as it is a CodonFreqSet.
       getFreq_(getStateMap().getModelStates(vc[j])[0]) =
         static_cast<double>(vc.size()) * ppfs_->getFrequencies()[i] * vS_[i].prob(j);
     }
@@ -281,7 +285,7 @@ void FullPerAACodonFrequenciesSet::setFrequencies(const vector<double>& frequenc
 
   double bigS = 0;
   Vdouble vaa;
-  
+
   const StateMap& aaStates = ppfs_->getStateMap();
   for (size_t i = 0; i < aaStates.getNumberOfModelStates(); ++i)
   {
@@ -289,14 +293,14 @@ void FullPerAACodonFrequenciesSet::setFrequencies(const vector<double>& frequenc
     std::vector<int> vc = pgc_->getSynonymous(aa);
     Vdouble vp;
     double s = 0;
-    
+
     for (size_t j = 0; j < vc.size(); j++)
     {
       size_t index = pgc_->getSourceAlphabet()->getStateIndex(vc[j]);
-      vp.push_back(frequencies[index-1]);
-      s += frequencies[index-1];
+      vp.push_back(frequencies[index - 1]);
+      s += frequencies[index - 1];
     }
-      
+
     vp /= s;
     vS_[i].setFrequencies(vp);
 
@@ -378,16 +382,16 @@ CodonFromIndependentFrequenciesSet::CodonFromIndependentFrequenciesSet(
   const GeneticCode* gCode,
   const std::vector<FrequenciesSet*>& freqvector,
   const string& name,
-  const string& mgmtStopFreq) :
+  const string& mgmtStopCodon) :
   WordFromIndependentFrequenciesSet(gCode->getSourceAlphabet(), freqvector, "", name),
   mStopNeigh_(),
-  mgmtStopFreq_(2),
+  mgmtStopCodon_(2),
   pgc_(gCode)
 {
-  if (mgmtStopFreq == "uniform")
-    mgmtStopFreq_ = 0;
-  else if (mgmtStopFreq == "linear")
-    mgmtStopFreq_ = 1;
+  if (mgmtStopCodon == "uniform")
+    mgmtStopCodon_ = 0;
+  else if (mgmtStopCodon == "linear")
+    mgmtStopCodon_ = 1;
 
   // fill the map of the stop codons
 
@@ -419,7 +423,7 @@ const CodonAlphabet* CodonFromIndependentFrequenciesSet::getAlphabet() const
 CodonFromIndependentFrequenciesSet::CodonFromIndependentFrequenciesSet(const CodonFromIndependentFrequenciesSet& iwfs) :
   WordFromIndependentFrequenciesSet(iwfs),
   mStopNeigh_(iwfs.mStopNeigh_),
-  mgmtStopFreq_(iwfs.mgmtStopFreq_),
+  mgmtStopCodon_(iwfs.mgmtStopCodon_),
   pgc_(iwfs.pgc_)
 {
   updateFrequencies();
@@ -429,7 +433,7 @@ CodonFromIndependentFrequenciesSet& CodonFromIndependentFrequenciesSet::operator
 {
   WordFromIndependentFrequenciesSet::operator=(iwfs);
   mStopNeigh_ = iwfs.mStopNeigh_;
-  mgmtStopFreq_ = iwfs.mgmtStopFreq_;
+  mgmtStopCodon_ = iwfs.mgmtStopCodon_;
   pgc_ = iwfs.pgc_;
   return *this;
 }
@@ -440,7 +444,7 @@ void CodonFromIndependentFrequenciesSet::updateFrequencies()
 
   size_t s = getAlphabet()->getSize();
 
-  if (mgmtStopFreq_ != 0)
+  if (mgmtStopCodon_ != 0)
   {
     // The frequencies of the stop codons are distributed to all
     // neighbour non-stop codons
@@ -458,12 +462,12 @@ void CodonFromIndependentFrequenciesSet::updateFrequencies()
       double sneifreq = 0;
       for (size_t vn = 0; vn < vneigh.size(); vn++)
       {
-        sneifreq += pow(getFreq_(static_cast<size_t>(vneigh[vn])), mgmtStopFreq_);
+        sneifreq += pow(getFreq_(static_cast<size_t>(vneigh[vn])), mgmtStopCodon_);
       }
       double x = getFreq_(static_cast<size_t>(stNb)) / sneifreq;
       for (size_t vn = 0; vn < vneigh.size(); vn++)
       {
-        f[vneigh[vn]] += pow(getFreq_(static_cast<size_t>(vneigh[vn])), mgmtStopFreq_) * x;
+        f[vneigh[vn]] += pow(getFreq_(static_cast<size_t>(vneigh[vn])), mgmtStopCodon_) * x;
       }
       getFreq_(static_cast<size_t>(stNb)) = 0;
       mStopNeigh_it++;
@@ -501,16 +505,16 @@ CodonFromUniqueFrequenciesSet::CodonFromUniqueFrequenciesSet(
   const GeneticCode* gCode,
   FrequenciesSet* pfreq,
   const string& name,
-  const string& mgmtStopFreq) :
+  const string& mgmtStopCodon) :
   WordFromUniqueFrequenciesSet(gCode->getSourceAlphabet(), pfreq, "", name),
   mStopNeigh_(),
-  mgmtStopFreq_(2),
+  mgmtStopCodon_(2),
   pgc_(gCode)
 {
-  if (mgmtStopFreq == "uniform")
-    mgmtStopFreq_ = 0;
-  else if (mgmtStopFreq == "linear")
-    mgmtStopFreq_ = 1;
+  if (mgmtStopCodon == "uniform")
+    mgmtStopCodon_ = 0;
+  else if (mgmtStopCodon == "linear")
+    mgmtStopCodon_ = 1;
 
   // fill the map of the stop codons
 
@@ -544,7 +548,7 @@ const CodonAlphabet* CodonFromUniqueFrequenciesSet::getAlphabet() const
 CodonFromUniqueFrequenciesSet::CodonFromUniqueFrequenciesSet(const CodonFromUniqueFrequenciesSet& iwfs) :
   WordFromUniqueFrequenciesSet(iwfs),
   mStopNeigh_(iwfs.mStopNeigh_),
-  mgmtStopFreq_(iwfs.mgmtStopFreq_),
+  mgmtStopCodon_(iwfs.mgmtStopCodon_),
   pgc_(iwfs.pgc_)
 {
   updateFrequencies();
@@ -554,7 +558,7 @@ CodonFromUniqueFrequenciesSet& CodonFromUniqueFrequenciesSet::operator=(const Co
 {
   WordFromUniqueFrequenciesSet::operator=(iwfs);
   mStopNeigh_ = iwfs.mStopNeigh_;
-  mgmtStopFreq_ = iwfs.mgmtStopFreq_;
+  mgmtStopCodon_ = iwfs.mgmtStopCodon_;
   pgc_ = iwfs.pgc_;
   return *this;
 }
@@ -565,39 +569,31 @@ void CodonFromUniqueFrequenciesSet::updateFrequencies()
 
   size_t s = getAlphabet()->getSize();
 
-  if (mgmtStopFreq_ != 0)
+  if (mgmtStopCodon_ != 0)
   {
     // The frequencies of the stop codons are distributed to all
     // neighbour non-stop codons
-    double f[64];
-    for (size_t i = 0; i < s; i++)
-    {
-      f[i] = 0;
-    }
-
-    std::map<int, Vint>::iterator mStopNeigh_it(mStopNeigh_.begin());
-    while (mStopNeigh_it != mStopNeigh_.end())
+    double f[64] = {0};
+    
+    for (auto mStopNeigh_it : mStopNeigh_)
     {
-      int stNb = mStopNeigh_it->first;
-      Vint vneigh = mStopNeigh_it->second;
+      int stNb = mStopNeigh_it.first;
+      Vint vneigh = mStopNeigh_it.second;
       double sneifreq = 0;
       for (size_t vn = 0; vn < vneigh.size(); vn++)
       {
-        sneifreq += pow(getFreq_(static_cast<size_t>(vneigh[vn])), mgmtStopFreq_);
+        sneifreq += pow(getFreq_(static_cast<size_t>(vneigh[vn])), mgmtStopCodon_);
       }
       double x = getFreq_(static_cast<size_t>(stNb)) / sneifreq;
       for (size_t vn = 0; vn < vneigh.size(); vn++)
       {
-        f[vneigh[vn]] += pow(getFreq_(static_cast<size_t>(vneigh[vn])), mgmtStopFreq_) * x;
+        f[vneigh[vn]] += pow(getFreq_(static_cast<size_t>(vneigh[vn])), mgmtStopCodon_) * x;
       }
       getFreq_(static_cast<size_t>(stNb)) = 0;
-      mStopNeigh_it++;
     }
 
     for (size_t i = 0; i < s; i++)
-    {
       getFreq_(i) += f[i];
-    }
   }
   else
   {
@@ -620,21 +616,21 @@ void CodonFromUniqueFrequenciesSet::updateFrequencies()
 
 /*********************************************************************/
 
-FrequenciesSet* CodonFrequenciesSet::getFrequenciesSetForCodons(short option, const GeneticCode* gCode, const string& mgmtStopFreq, unsigned short method)
+FrequenciesSet* CodonFrequenciesSet::getFrequenciesSetForCodons(short option, const GeneticCode* gCode, const string& mgmtStopCodon, unsigned short method)
 {
   FrequenciesSet* codonFreqs;
 
   if (option == F0)
     codonFreqs = new FixedCodonFrequenciesSet(gCode, "F0");
   else if (option == F1X4)
-    codonFreqs = new CodonFromUniqueFrequenciesSet(gCode, new FullNucleotideFrequenciesSet(gCode->getSourceAlphabet()->getNucleicAlphabet()), "F1X4", mgmtStopFreq);
+    codonFreqs = new CodonFromUniqueFrequenciesSet(gCode, new FullNucleotideFrequenciesSet(gCode->getSourceAlphabet()->getNucleicAlphabet()), "F1X4", mgmtStopCodon);
   else if (option == F3X4)
   {
     vector<FrequenciesSet*> v_AFS(3);
     v_AFS[0] = new FullNucleotideFrequenciesSet(gCode->getSourceAlphabet()->getNucleicAlphabet());
     v_AFS[1] = new FullNucleotideFrequenciesSet(gCode->getSourceAlphabet()->getNucleicAlphabet());
     v_AFS[2] = new FullNucleotideFrequenciesSet(gCode->getSourceAlphabet()->getNucleicAlphabet());
-    codonFreqs = new CodonFromIndependentFrequenciesSet(gCode, v_AFS, "F3X4", mgmtStopFreq);
+    codonFreqs = new CodonFromIndependentFrequenciesSet(gCode, v_AFS, "F3X4", mgmtStopCodon);
   }
   else if (option == F61)
     codonFreqs = new FullCodonFrequenciesSet(gCode, false, method, "F61");
diff --git a/src/Bpp/Phyl/Model/FrequenciesSet/CodonFrequenciesSet.h b/src/Bpp/Phyl/Model/FrequenciesSet/CodonFrequenciesSet.h
index 3de6ab2..9e8430b 100644
--- a/src/Bpp/Phyl/Model/FrequenciesSet/CodonFrequenciesSet.h
+++ b/src/Bpp/Phyl/Model/FrequenciesSet/CodonFrequenciesSet.h
@@ -57,11 +57,10 @@ class CodonFrequenciesSet :
   public virtual FrequenciesSet
 {
 public:
-#ifndef NO_VIRTUAL_COV
+  
   CodonFrequenciesSet* clone() const = 0;
 
   const CodonAlphabet* getAlphabet() const = 0;
-#endif
 
 public:
   /**
@@ -75,7 +74,7 @@ public:
    *
    * @param option A code describing the option, one of F61, F1X4 or F3X4.
    * @param gCode The genetic code to use. The underlying codon alphabet object will be passed to the FrequenciesSet instance.
-   * @param mgmtStopFreq the optional way the frequencies assigned
+   * @param mgmtStopCodon the optional way the frequencies assigned
    * to the stop codons are redistributed to the other codons, with
    * F1X4 and F3X4 options. The available values are:
    *  - uniform : each stop frequency is distributed evenly
@@ -90,7 +89,7 @@ public:
    *
    * @see Simplex
    */
-  static FrequenciesSet* getFrequenciesSetForCodons(short option, const GeneticCode* gCode, const std::string& mgmtStopFreq = "quadratic", unsigned short method = 1);
+  static FrequenciesSet* getFrequenciesSetForCodons(short option, const GeneticCode* gCode, const std::string& mgmtStopCodon = "quadratic", unsigned short method = 1);
 
   static const short F0;
   static const short F1X4;
@@ -131,12 +130,7 @@ public:
   FullCodonFrequenciesSet(const FullCodonFrequenciesSet& fcfs);
   FullCodonFrequenciesSet& operator=(const FullCodonFrequenciesSet& fcfs);
 
-#ifndef NO_VIRTUAL_COV
-  FullCodonFrequenciesSet*
-#else
-  Clonable*
-#endif
-  clone() const { return new FullCodonFrequenciesSet(*this); }
+  FullCodonFrequenciesSet* clone() const { return new FullCodonFrequenciesSet(*this); }
 
 public:
   const GeneticCode* getGeneticCode() const { return pgc_; }
@@ -148,12 +142,10 @@ public:
    */
   void setFrequencies(const std::vector<double>& frequencies);
 
-#ifndef NO_VIRTUAL_COV
   const CodonAlphabet* getAlphabet() const
   {
     return dynamic_cast<const CodonAlphabet*>(AbstractFrequenciesSet::getAlphabet());
   }
-#endif
 
   void setNamespace(const std::string& nameSpace);
 
@@ -202,22 +194,16 @@ public:
     return *this;
   }
 
-#ifndef NO_VIRTUAL_COV
-  FixedCodonFrequenciesSet*
-#else
-  Clonable*
-#endif
-  clone() const { return new FixedCodonFrequenciesSet(*this); }
+  FixedCodonFrequenciesSet* clone() const { return new FixedCodonFrequenciesSet(*this); }
 
 public:
   const GeneticCode* getGeneticCode() const { return pgc_; }
 
-#ifndef NO_VIRTUAL_COV
   const CodonAlphabet* getAlphabet() const
   {
     return dynamic_cast<const CodonAlphabet*>(AbstractFrequenciesSet::getAlphabet());
   }
-#endif
+  
   /**
    * @brief the given frequencies are normalized such thaat the sum of
    * the frequencies on the non-stop codons equals 1.
@@ -242,20 +228,17 @@ protected:
  * @see Simplex
  *
  */
-
 class FullPerAACodonFrequenciesSet :
   public virtual CodonFrequenciesSet,
   public AbstractFrequenciesSet
 {
 private:
   const GeneticCode* pgc_;
-  std::auto_ptr<ProteinFrequenciesSet> ppfs_;
+  std::unique_ptr<ProteinFrequenciesSet> ppfs_;
 
-  /*
-     *@ brief vector of the simplexes, one for each AA
-   *
+  /**
+   * @ brief vector of the simplexes, one for each AA
    */
-
   std::vector<Simplex> vS_;
 
   void updateFrequencies();
@@ -287,20 +270,14 @@ public:
 
   virtual ~FullPerAACodonFrequenciesSet() {}
 
-#ifndef NO_VIRTUAL_COV
-  FullPerAACodonFrequenciesSet*
-#else
-  Clonable*
-#endif
-  clone() const { return new FullPerAACodonFrequenciesSet(*this); }
+  FullPerAACodonFrequenciesSet* clone() const { return new FullPerAACodonFrequenciesSet(*this); }
 
 public:
-#ifndef NO_VIRTUAL_COV
+  
   const CodonAlphabet* getAlphabet() const
   {
     return dynamic_cast<const CodonAlphabet*>(AbstractFrequenciesSet::getAlphabet());
   }
-#endif
 
   const GeneticCode* getGeneticCode() const { return pgc_; }
 
@@ -343,7 +320,7 @@ private:
   // a map associating stop codons numbers with numbers of neighbour non-stop codons
   std::map<int, Vint> mStopNeigh_;
 
-  unsigned short mgmtStopFreq_;
+  unsigned short mgmtStopCodon_;
 
   const GeneticCode* pgc_;
 
@@ -355,7 +332,7 @@ public:
    * @param gCode a pointer to the genetic code to use.
    * @param freqvector a vector of pointers to the phase specific FrequenciesSets
    * @param name the optional name of the FrequenciesSet (default codon)
-   * @param mgmtStopFreq the optional way the frequencies assigned to the
+   * @param mgmtStopCodon the optional way the frequencies assigned to the
    * stop codons are redistributed to the other codons. The
    * available values are:
    *  - uniform : each stop frequency is distributed evenly
@@ -367,7 +344,7 @@ public:
    *     the square of each target codon frequency.
    *
    */
-  CodonFromIndependentFrequenciesSet(const GeneticCode* gCode, const std::vector<FrequenciesSet*>& freqvector, const std::string& name = "Codon", const std::string& mgmtStopFreq = "quadratic");
+  CodonFromIndependentFrequenciesSet(const GeneticCode* gCode, const std::vector<FrequenciesSet*>& freqvector, const std::string& name = "Codon", const std::string& mgmtStopCodon = "quadratic");
 
   CodonFromIndependentFrequenciesSet(const CodonFromIndependentFrequenciesSet& iwfs);
 
@@ -382,9 +359,26 @@ public:
   const GeneticCode* getGeneticCode() const { return pgc_; }
 
   /**
-   * @ brief Update the frequencies given the parameters.
+   * @brief Update the frequencies given the parameters.
    */
   void updateFrequencies();
+
+  /**
+   * @brief Retrieve the mgmt method for the stop codons.
+   */
+  std::string getMgmtStopCodon() const
+  {
+    switch (mgmtStopCodon_)
+    {
+    case 0:
+      return "uniform";
+    case 1:
+      return "linear";
+    case 2:
+      return "quadratic";
+    }
+    return "";
+  }
 };
 
 
@@ -404,7 +398,7 @@ private:
   // a map associating stop codons numbers with numbers of neighbour non-stop codons
   std::map<int, Vint> mStopNeigh_;
 
-  unsigned short mgmtStopFreq_;
+  unsigned short mgmtStopCodon_;
 
   const GeneticCode* pgc_;
 
@@ -416,7 +410,7 @@ public:
    * @param gCode a pointer to a genetic code.
    * @param pfreq a pointer to the nucleotidic FrequenciesSet
    * @param name the optional name of the FrequenciesSet (default codon)
-   * @param mgmtStopFreq the optional way the frequencies assigned to the
+   * @param mgmtStopCodon the optional way the frequencies assigned to the
    * stop codons are redistributed to the other codons. The
    * available values are:
    *  - uniform : each stop frequency is distributed evenly
@@ -431,7 +425,7 @@ public:
     const GeneticCode* gCode,
     FrequenciesSet* pfreq,
     const std::string& name = "Codon",
-    const std::string& mgmtStopFreq = "quadratic");
+    const std::string& mgmtStopCodon = "quadratic");
 
   CodonFromUniqueFrequenciesSet(const CodonFromUniqueFrequenciesSet& iwfs);
 
@@ -450,6 +444,23 @@ public:
    *
    */
   void updateFrequencies();
+
+  /**
+   * @brief Retrieve the mgmt method for the stop codons.
+   */
+  std::string getMgmtStopCodon() const
+  {
+    switch (mgmtStopCodon_)
+    {
+    case 0:
+      return "uniform";
+    case 1:
+      return "linear";
+    case 2:
+      return "quadratic";
+    }
+    return "";
+  }
 };
 } // end of namespace bpp.
 
diff --git a/src/Bpp/Phyl/Model/FrequenciesSet/FrequenciesSet.cpp b/src/Bpp/Phyl/Model/FrequenciesSet/FrequenciesSet.cpp
index 3584e5e..8424b5e 100644
--- a/src/Bpp/Phyl/Model/FrequenciesSet/FrequenciesSet.cpp
+++ b/src/Bpp/Phyl/Model/FrequenciesSet/FrequenciesSet.cpp
@@ -43,6 +43,11 @@
 #include <Bpp/Numeric/NumConstants.h>
 #include <Bpp/Numeric/Prob/Simplex.h>
 
+// From bpp-phyl
+#include "../SubstitutionModel.h"
+#include "../AbstractBiblioSubstitutionModel.h"
+
+
 using namespace bpp;
 
 #include <cmath>
@@ -114,7 +119,6 @@ FullFrequenciesSet::FullFrequenciesSet(StateMap* stateMap, const vector<double>&
 
 void FullFrequenciesSet::setFrequencies(const vector<double>& frequencies) 
 {
-  
   sFreq_.setFrequencies(frequencies);
   setParametersValues(sFreq_.getParameters()); 
 
@@ -129,6 +133,7 @@ void FullFrequenciesSet::setNamespace(const std::string& nameSpace)
 
 void FullFrequenciesSet::fireParameterChanged(const ParameterList& parameters)
 {
+  AbstractFrequenciesSet::fireParameterChanged(parameters);
   sFreq_.matchParametersValues(parameters);
   updateFreq_();
 }
@@ -184,3 +189,59 @@ MarkovModulatedFrequenciesSet::MarkovModulatedFrequenciesSet(FrequenciesSet* fre
   setFrequencies_(VectorTools::kroneckerMult(rateFreqs, freqSet_->getFrequencies()));
 }
 
+
+
+//////////////////////////////////
+/// From Model
+
+
+FromModelFrequenciesSet::FromModelFrequenciesSet(const FromModelFrequenciesSet& fmfs):
+  AbstractFrequenciesSet(fmfs),
+  model_(fmfs.model_->clone())
+{}
+
+FromModelFrequenciesSet& FromModelFrequenciesSet::operator=(const FromModelFrequenciesSet& fmfs) 
+{
+  AbstractFrequenciesSet::operator=(fmfs);
+  model_ = fmfs.model_->clone();
+  return *this;
+}
+
+FromModelFrequenciesSet::~FromModelFrequenciesSet()
+{
+  delete model_;
+}
+
+FromModelFrequenciesSet::FromModelFrequenciesSet(TransitionModel* model) :
+  AbstractFrequenciesSet(model->getStateMap().clone(), "FromModel."+(model?model->getNamespace():""), "FromModel"),
+  model_(model)
+{
+  model_->setNamespace(getNamespace());
+  addParameters_(model_->getParameters());
+  setFrequencies_(model_->getFrequencies());
+}
+
+
+void FromModelFrequenciesSet::setNamespace(const std::string& name)
+{
+  AbstractParameterAliasable::setNamespace(name);
+  model_->setNamespace(name);
+}
+
+
+void FromModelFrequenciesSet::setFrequencies(const std::vector<double>& frequencies)
+{
+  std::map<int, double> freq;
+  for (size_t i = 0; i < getNumberOfFrequencies(); ++i) {
+    freq[getStateMap().getAlphabetStateAsInt(i)] += frequencies[i];
+  }
+  model_->setFreq(freq);
+  matchParametersValues(model_->getParameters());
+}
+
+void FromModelFrequenciesSet::fireParameterChanged(const ParameterList& pl)
+{
+  AbstractFrequenciesSet::fireParameterChanged(pl);
+  model_->matchParametersValues(pl);
+  setFrequencies_(model_->getFrequencies());
+}
diff --git a/src/Bpp/Phyl/Model/FrequenciesSet/FrequenciesSet.h b/src/Bpp/Phyl/Model/FrequenciesSet/FrequenciesSet.h
index 6c27d54..b3a663b 100644
--- a/src/Bpp/Phyl/Model/FrequenciesSet/FrequenciesSet.h
+++ b/src/Bpp/Phyl/Model/FrequenciesSet/FrequenciesSet.h
@@ -6,37 +6,37 @@
 //
 
 /*
-   Copyright or (c) or Copr. Bio++ Development Team, (November 16, 2004)
-
-   This software is a computer program whose purpose is to provide classes
-   for phylogenetic data analysis.
-
-   This software is governed by the CeCILL  license under French law and
-   abiding by the rules of distribution of free software.  You can  use,
-   modify and/ or redistribute the software under the terms of the CeCILL
-   license as circulated by CEA, CNRS and INRIA at the following URL
-   "http://www.cecill.info".
-
-   As a counterpart to the access to the source code and  rights to copy,
-   modify and redistribute granted by the license, users are provided only
-   with a limited warranty  and the software's author,  the holder of the
-   economic rights,  and the successive licensors  have only  limited
-   liability.
-
-   In this respect, the user's attention is drawn to the risks associated
-   with loading,  using,  modifying and/or developing or reproducing the
-   software by the user in light of its specific status of free software,
-   that may mean  that it is complicated to manipulate,  and  that  also
-   therefore means  that it is reserved for developers  and  experienced
-   professionals having in-depth computer knowledge. Users are therefore
-   encouraged to load and test the software's suitability as regards their
-   requirements in conditions enabling the security of their systems and/or
-   data to be ensured and,  more generally, to use and operate it in the
-   same conditions as regards security.
-
-   The fact that you are presently reading this means that you have had
-   knowledge of the CeCILL license and that you accept its terms.
- */
+  Copyright or (c) or Copr. Bio++ Development Team, (November 16, 2004)
+
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
+
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use,
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info".
+
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability.
+
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or
+  data to be ensured and,  more generally, to use and operate it in the
+  same conditions as regards security.
+
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
+*/
 
 #ifndef _FREQUENCIESSET_H_
 #define _FREQUENCIESSET_H_
@@ -44,8 +44,8 @@
 #include "../StateMap.h"
 
 // From bpp-core:
-#include <Bpp/Numeric/Parametrizable.h>
-#include <Bpp/Numeric/AbstractParametrizable.h>
+#include <Bpp/Numeric/ParameterAliasable.h>
+#include <Bpp/Numeric/AbstractParameterAliasable.h>
 #include <Bpp/Numeric/VectorTools.h>
 #include <Bpp/Numeric/Prob/Simplex.h>
 
@@ -59,151 +59,153 @@ namespace bpp
  *
  * Frequencies are ordered according to alphabet states.
  */
-class FrequenciesSet :
-  public virtual Parametrizable
-{
-public:
-#ifndef NO_VIRTUAL_COV
-  FrequenciesSet* clone() const = 0;
-#endif
-
-public:
-  /**
-   * @return The alphabet associated to this set.
-   */
-  virtual const Alphabet* getAlphabet() const = 0;
-
-  /**
-   * @return The mapping of model states with alphabet states.
-   */
-  virtual const StateMap& getStateMap() const = 0;
-
-  /**
-   * @return The frequencies values of the set.
-   */
-  virtual const std::vector<double> getFrequencies() const = 0;
-
-  /**
-   * @return The frequencies of each alphabet states according to this model.
-   */
-  virtual const std::map<int, double> getAlphabetStatesFrequencies() const = 0;
-
-  /**
-   * @brief Set the parameters in order to match a given set of frequencies.
-   *
-   * @param frequencies The set of frequencies to match.
-   * @throw DimensionException If the number of frequencies does not match the size of the alphabet.
-   * @throw Exception If the frequencies do not sum to 1.
-   */
-  virtual void setFrequencies(const std::vector<double>& frequencies) = 0;
 
-  /**
-   * @brief Set the Frequencies from the one of the map which keys
-   *  match with a letter of the Alphabet.
-   *  The frequencies are normalized so that the matching values sum 1.
-   *
-   * @param frequencies The set of frequencies to match.
-   */
-  virtual void setFrequenciesFromAlphabetStatesFrequencies(const std::map<int, double>& frequencies) = 0;
-
-  virtual std::string getName() const = 0;
-
-  /**
-   * @return The number of frequencies in the set. This is equivalent to getStateMap().getNumberOfModelStates().
-   */
-  virtual size_t getNumberOfFrequencies() const = 0;
-
-public:
-  static IntervalConstraint FREQUENCE_CONSTRAINT_SMALL;
-  static IntervalConstraint FREQUENCE_CONSTRAINT_MILLI;
-};
+  class TransitionModel;
+  
+  class FrequenciesSet :
+    public virtual ParameterAliasable
+  {
+  public:
+    
+    FrequenciesSet* clone() const = 0;
+
+  public:
+    /**
+     * @return The alphabet associated to this set.
+     */
+    virtual const Alphabet* getAlphabet() const = 0;
+
+    /**
+     * @return The mapping of model states with alphabet states.
+     */
+    virtual const StateMap& getStateMap() const = 0;
+
+    /**
+     * @return The frequencies values of the set.
+     */
+    virtual const std::vector<double> getFrequencies() const = 0;
+
+    /**
+     * @return The frequencies of each alphabet states according to this model.
+     */
+    virtual const std::map<int, double> getAlphabetStatesFrequencies() const = 0;
+
+    /**
+     * @brief Set the parameters in order to match a given set of frequencies.
+     *
+     * @param frequencies The set of frequencies to match.
+     * @throw DimensionException If the number of frequencies does not match the size of the alphabet.
+     * @throw Exception If the frequencies do not sum to 1.
+     */
+    virtual void setFrequencies(const std::vector<double>& frequencies) = 0;
+
+    /**
+     * @brief Set the Frequencies from the one of the map which keys
+     *  match with a letter of the Alphabet.
+     *  The frequencies are normalized so that the matching values sum 1.
+     *
+     * @param frequencies The set of frequencies to match.
+     */
+    virtual void setFrequenciesFromAlphabetStatesFrequencies(const std::map<int, double>& frequencies) = 0;
+
+    virtual std::string getName() const = 0;
+
+    /**
+     * @return The number of frequencies in the set. This is equivalent to getStateMap().getNumberOfModelStates().
+     */
+    virtual size_t getNumberOfFrequencies() const = 0;
+
+  public:
+    static IntervalConstraint FREQUENCE_CONSTRAINT_SMALL;
+    static IntervalConstraint FREQUENCE_CONSTRAINT_MILLI;
+  };
 
 /**
  * @brief Basic implementation of the FrequenciesSet interface.
  */
 
-class AbstractFrequenciesSet :
-  public virtual FrequenciesSet,
-  public AbstractParametrizable
-{
-private:
-  const Alphabet* alphabet_;
-  std::auto_ptr<StateMap> stateMap_;
-  std::vector<double> freq_;
-  std::string name_;
-
-public:
-  AbstractFrequenciesSet(StateMap* stateMap, const std::string& prefix, const std::string& name) :
-    AbstractParametrizable(prefix),
-    alphabet_(stateMap->getAlphabet()),
-    stateMap_(stateMap),
-    freq_(stateMap->getNumberOfModelStates()),
-    name_(name)
-  {}
-
-#ifndef NO_VIRTUAL_COV
-  AbstractFrequenciesSet*
-#else
-  Clonable*
-#endif
-  clone() const = 0;
-
-  AbstractFrequenciesSet(const AbstractFrequenciesSet& af) :
-    AbstractParametrizable(af),
-    alphabet_(af.alphabet_),
-    stateMap_(af.stateMap_->clone()),
-    freq_(af.freq_),
-    name_(af.name_)
-  {}
-
-  AbstractFrequenciesSet& operator=(const AbstractFrequenciesSet& af)
+  class AbstractFrequenciesSet :
+    public virtual FrequenciesSet,
+    public AbstractParameterAliasable
   {
-    AbstractParametrizable::operator=(af);
-    alphabet_ = af.alphabet_;
-    stateMap_.reset(af.stateMap_->clone());
-    freq_ = af.freq_;
-    name_ = af.name_;
-    return *this;
-  }
-
-public:
-  const Alphabet* getAlphabet() const { return alphabet_; }
-
-  const StateMap& getStateMap() const { return *stateMap_; }
-
-  const std::vector<double> getFrequencies() const { return freq_; }
+  private:
+    const Alphabet* alphabet_;
+    std::unique_ptr<StateMap> stateMap_;
+    std::vector<double> freq_;
+    std::string name_;
+
+  public:
+    AbstractFrequenciesSet(StateMap* stateMap, const std::string& prefix, const std::string& name) :
+      AbstractParameterAliasable(prefix),
+      alphabet_(stateMap->getAlphabet()),
+      stateMap_(stateMap),
+      freq_(stateMap->getNumberOfModelStates()),
+      name_(name)
+    {}
+
+    AbstractFrequenciesSet* clone() const = 0;
+
+    AbstractFrequenciesSet(const AbstractFrequenciesSet& af) :
+      AbstractParameterAliasable(af),
+      alphabet_(af.alphabet_),
+      stateMap_(af.stateMap_->clone()),
+      freq_(af.freq_),
+      name_(af.name_)
+    {}
+
+    AbstractFrequenciesSet& operator=(const AbstractFrequenciesSet& af)
+    {
+      AbstractParameterAliasable::operator=(af);
+      alphabet_ = af.alphabet_;
+      stateMap_.reset(af.stateMap_->clone());
+      freq_ = af.freq_;
+      name_ = af.name_;
+      return *this;
+    }
+
+  public:
+    const Alphabet* getAlphabet() const { return alphabet_; }
+
+    const StateMap& getStateMap() const { return *stateMap_; }
+
+    const std::vector<double> getFrequencies() const { return freq_; }
   
-  const std::map<int, double> getAlphabetStatesFrequencies() const;
-
-  /**
-   * @brief Set the Frequencies from the one of the map which keys
-   *  match with a letter of the Alphabet.
-   *  The frequencies are normalized so that the matching values sum 1.
-   *
-   * In this implementation, all model states with the same alphabet state are given the same frequency.
-   * 
-   * @param frequencies The set of frequencies to match.
-   */
-  void setFrequenciesFromAlphabetStatesFrequencies(const std::map<int, double>& frequencies);
-
-  size_t getNumberOfFrequencies() const { return freq_.size(); }
-
-  std::string getName() const { return(name_); }
-
-  void normalize()
-  {
-    double x = 0;
-    for (size_t i = 0; i < freq_.size(); i++)
-      x += freq_[i];
-    freq_ /= x;
-  }
-   
-protected:
-  std::vector<double>& getFrequencies_() { return freq_; }
-  double& getFreq_(size_t i) { return freq_[i]; }
-  const double& getFreq_(size_t i) const { return freq_[i]; }
-  void setFrequencies_(const std::vector<double>& frequencies) { freq_ = frequencies; }
-};
+    const std::map<int, double> getAlphabetStatesFrequencies() const;
+
+    /**
+     * @brief Set the Frequencies from the one of the map which keys
+     *  match with a letter of the Alphabet.
+     *  The frequencies are normalized so that the matching values sum 1.
+     *
+     * In this implementation, all model states with the same alphabet state are given the same frequency.
+     * 
+     * @param frequencies The set of frequencies to match.
+     */
+    void setFrequenciesFromAlphabetStatesFrequencies(const std::map<int, double>& frequencies);
+
+    size_t getNumberOfFrequencies() const { return freq_.size(); }
+
+    std::string getName() const { return(name_); }
+
+    void normalize()
+    {
+      double x = 0;
+      for (size_t i = 0; i < freq_.size(); i++)
+        x += freq_[i];
+      freq_ /= x;
+    }
+
+    virtual void fireParameterChanged(const ParameterList& parameters)
+    {
+      AbstractParameterAliasable::fireParameterChanged(parameters);
+    }
+
+  protected:
+    std::vector<double>& getFrequencies_() { return freq_; }
+    double& getFreq_(size_t i) { return freq_[i]; }
+    const double& getFreq_(size_t i) const { return freq_[i]; }
+    void setFrequencies_(const std::vector<double>& frequencies) { freq_ = frequencies; }
+  };
 
 /**
  * @brief A generic FrequenciesSet allowing for the estimation of all frequencies.
@@ -217,38 +219,79 @@ protected:
  * @see Simplex
  */
 
-class FullFrequenciesSet :
-  public AbstractFrequenciesSet
-{
-private:
-  /**
-   * @brief Simplex to handle the probabilities and the parameters.
-   */
-  Simplex sFreq_;
+  class FullFrequenciesSet :
+    public AbstractFrequenciesSet
+  {
+  private:
+    /**
+     * @brief Simplex to handle the probabilities and the parameters.
+     */
+    Simplex sFreq_;
+  
+  public:
+    /**
+     * @brief Construction with uniform frequencies on the states of
+     * the alphabet.
+     */
+    FullFrequenciesSet(StateMap* stateMap, bool allowNullFreqs = false, unsigned short method = 1, const std::string& name = "Full.");
+    FullFrequenciesSet(StateMap* stateMap, const std::vector<double>& initFreqs, bool allowNullFreqs = false, unsigned short method = 1, const std::string& name = "Full.");
+
+    FullFrequenciesSet* clone() const { return new FullFrequenciesSet(*this); }
+
+  public:
+    void setFrequencies(const std::vector<double>& frequencies);
+
+    unsigned short getMethod() const { return sFreq_.getMethod();}
+
+    void setNamespace(const std::string& nameSpace);
   
-public:
+  protected:
+    void fireParameterChanged(const ParameterList& parameters);
+
+  private:
+    void updateFreq_();
+  };
+
   /**
-   * @brief Construction with uniform frequencies on the states of
-   * the alphabet.
+   * @brief FrequenciesSet to be used with a Markov-modulated substitution model.
+   *
+   * This implementation uses one parameter per character state frequency.
+   * The rate states are assumed to be fixed and are passed as an argument to the constructor, together with a 'regular'
+   * FrequenciesSet. The number of parameters hence do not depends on the number of rates used.
    */
-  FullFrequenciesSet(StateMap* stateMap, bool allowNullFreqs = false, unsigned short method = 1, const std::string& name = "Full.");
-  FullFrequenciesSet(StateMap* stateMap, const std::vector<double>& initFreqs, bool allowNullFreqs = false, unsigned short method = 1, const std::string& name = "Full.");
+  
+  class FromModelFrequenciesSet :
+    public AbstractFrequenciesSet
+  {
+  private:
+    TransitionModel* model_;
 
-  FullFrequenciesSet* clone() const { return new FullFrequenciesSet(*this); }
+  public:
+    FromModelFrequenciesSet(TransitionModel* model);
 
-public:
-  void setFrequencies(const std::vector<double>& frequencies);
+    FromModelFrequenciesSet(const FromModelFrequenciesSet& fmfs);
+    
+    FromModelFrequenciesSet& operator=(const FromModelFrequenciesSet& fmfs);
 
-  unsigned short getMethod() const { return sFreq_.getMethod();}
+    FromModelFrequenciesSet* clone() const { return new FromModelFrequenciesSet(*this); }
 
-  void setNamespace(const std::string& nameSpace);
-  
-protected:
-  void fireParameterChanged(const ParameterList& parameters);
+    ~FromModelFrequenciesSet();
+
+  public:
+
+    const TransitionModel* getModel() const
+    {
+      return model_;
+    }
+    
+    void setFrequencies(const std::vector<double>& frequencies);
+
+    void fireParameterChanged(const ParameterList& pl);
+
+    void setNamespace(const std::string& name);
+    
+  };
 
-private:
-  void updateFreq_();
-};
 
 /**
  * @brief FrequenciesSet to be used with a Markov-modulated substitution model.
@@ -257,50 +300,51 @@ private:
  * The rate states are assumed to be fixed and are passed as an argument to the constructor, together with a 'regular'
  * FrequenciesSet. The number of parameters hence do not depends on the number of rates used.
  */
-class MarkovModulatedFrequenciesSet :
-  public AbstractFrequenciesSet
-{
-private:
-  FrequenciesSet* freqSet_;
-  std::vector<double> rateFreqs_;
+  class MarkovModulatedFrequenciesSet :
+    public AbstractFrequenciesSet
+  {
+  private:
+    FrequenciesSet* freqSet_;
+    std::vector<double> rateFreqs_;
 
-public:
-  MarkovModulatedFrequenciesSet(FrequenciesSet* freqSet, const std::vector<double>& rateFreqs);
+  public:
+    MarkovModulatedFrequenciesSet(FrequenciesSet* freqSet, const std::vector<double>& rateFreqs);
 
-  MarkovModulatedFrequenciesSet(const MarkovModulatedFrequenciesSet& mmfs) :
-    AbstractFrequenciesSet(mmfs),
-    freqSet_(mmfs.freqSet_->clone()),
-    rateFreqs_(mmfs.rateFreqs_)
-  {}
+    MarkovModulatedFrequenciesSet(const MarkovModulatedFrequenciesSet& mmfs) :
+      AbstractFrequenciesSet(mmfs),
+      freqSet_(mmfs.freqSet_->clone()),
+      rateFreqs_(mmfs.rateFreqs_)
+    {}
 
-  MarkovModulatedFrequenciesSet& operator=(const MarkovModulatedFrequenciesSet& mmfs)
-  {
-    AbstractFrequenciesSet::operator=(mmfs);
-    freqSet_ = mmfs.freqSet_->clone();
-    rateFreqs_ = mmfs.rateFreqs_;
-    return *this;
-  }
+    MarkovModulatedFrequenciesSet& operator=(const MarkovModulatedFrequenciesSet& mmfs)
+    {
+      AbstractFrequenciesSet::operator=(mmfs);
+      freqSet_ = mmfs.freqSet_->clone();
+      rateFreqs_ = mmfs.rateFreqs_;
+      return *this;
+    }
 
-  MarkovModulatedFrequenciesSet* clone() const { return new MarkovModulatedFrequenciesSet(*this); }
+    MarkovModulatedFrequenciesSet* clone() const { return new MarkovModulatedFrequenciesSet(*this); }
 
-  virtual ~MarkovModulatedFrequenciesSet() { delete freqSet_; }
+    virtual ~MarkovModulatedFrequenciesSet() { delete freqSet_; }
 
-public:
-  void setFrequencies(const std::vector<double>& frequencies)
-  {
-    // Just forward this method to the sequence state frequencies set. This may change in the future...
-    freqSet_->setFrequencies(frequencies);
-  }
+  public:
+    void setFrequencies(const std::vector<double>& frequencies)
+    {
+      // Just forward this method to the sequence state frequencies set. This may change in the future...
+      freqSet_->setFrequencies(frequencies);
+    }
 
-  void fireParameterChanged(const ParameterList& pl)
-  {
-   freqSet_->matchParametersValues(pl);
-    setFrequencies_(VectorTools::kroneckerMult(rateFreqs_, freqSet_->getFrequencies()));
-  }
+    void fireParameterChanged(const ParameterList& pl)
+    {
+      AbstractFrequenciesSet::fireParameterChanged(pl);
+      freqSet_->matchParametersValues(pl);
+      setFrequencies_(VectorTools::kroneckerMult(rateFreqs_, freqSet_->getFrequencies()));
+    }
 
-  const FrequenciesSet& getStatesFrequenciesSet() const { return *freqSet_; }
+    const FrequenciesSet& getStatesFrequenciesSet() const { return *freqSet_; }
 
-};
+  };
 
 
 /**
@@ -308,37 +352,37 @@ public:
  *
  * This set contains no parameter.
  */
-class FixedFrequenciesSet :
-  public AbstractFrequenciesSet
-{
-public:
-
-  /**
-   * @brief Construction with user-defined frequencies on the states of the model.
-   *
-   * @param stateMap The model states for which frequencies should be built.
-   * @param initFreqs The frequencies to use. The size of the vector should match the number of model states.
-   * @param name The name of the set.
-   * @throw Exception In case the number of frequencies does not match the number of model states.
-   */
-  FixedFrequenciesSet(StateMap* stateMap, const std::vector<double>& initFreqs, const std::string& name = "Fixed") throw (Exception);
-
-  /**
-   * @brief Construction with uniform frequencies on the states of the model.
-   *
-   * @param stateMap The model states for which frequencies should be built.
-   * @param name The name of the set.
-   */
-  FixedFrequenciesSet(StateMap* stateMap, const std::string& name = "Fixed");
-
-  FixedFrequenciesSet* clone() const { return new FixedFrequenciesSet(*this); }
-
-public:
-  void setFrequencies(const std::vector<double>& frequencies);
-
-protected:
-  void fireParameterChanged(const ParameterList& parameters) {}
-};
+  class FixedFrequenciesSet :
+    public AbstractFrequenciesSet
+  {
+  public:
+
+    /**
+     * @brief Construction with user-defined frequencies on the states of the model.
+     *
+     * @param stateMap The model states for which frequencies should be built.
+     * @param initFreqs The frequencies to use. The size of the vector should match the number of model states.
+     * @param name The name of the set.
+     * @throw Exception In case the number of frequencies does not match the number of model states.
+     */
+    FixedFrequenciesSet(StateMap* stateMap, const std::vector<double>& initFreqs, const std::string& name = "Fixed") throw (Exception);
+
+    /**
+     * @brief Construction with uniform frequencies on the states of the model.
+     *
+     * @param stateMap The model states for which frequencies should be built.
+     * @param name The name of the set.
+     */
+    FixedFrequenciesSet(StateMap* stateMap, const std::string& name = "Fixed");
+
+    FixedFrequenciesSet* clone() const { return new FixedFrequenciesSet(*this); }
+
+  public:
+    void setFrequencies(const std::vector<double>& frequencies);
+
+  protected:
+    void fireParameterChanged(const ParameterList& parameters) {}
+  };
 
  
 } // end of namespace bpp.
diff --git a/src/Bpp/Phyl/Model/FrequenciesSet/MvaFrequenciesSet.cpp b/src/Bpp/Phyl/Model/FrequenciesSet/MvaFrequenciesSet.cpp
index 785ded9..83006a6 100644
--- a/src/Bpp/Phyl/Model/FrequenciesSet/MvaFrequenciesSet.cpp
+++ b/src/Bpp/Phyl/Model/FrequenciesSet/MvaFrequenciesSet.cpp
@@ -81,6 +81,7 @@ void MvaFrequenciesSet::defineParameters()
 
 void MvaFrequenciesSet::fireParameterChanged(const ParameterList& parameters)
 {
+  AbstractFrequenciesSet::fireParameterChanged(parameters);
   updateFrequencies();
 }
 
diff --git a/src/Bpp/Phyl/Model/FrequenciesSet/MvaFrequenciesSet.h b/src/Bpp/Phyl/Model/FrequenciesSet/MvaFrequenciesSet.h
index 5bc364a..9cd17d7 100644
--- a/src/Bpp/Phyl/Model/FrequenciesSet/MvaFrequenciesSet.h
+++ b/src/Bpp/Phyl/Model/FrequenciesSet/MvaFrequenciesSet.h
@@ -64,16 +64,10 @@ public:
    */
 	MvaFrequenciesSet(const ProteicAlphabet* alpha);
 	
-#ifndef NO_VIRTUAL_COV
-	MvaFrequenciesSet*
-#else
-	Clonable*
-#endif
-	clone() const { return new MvaFrequenciesSet(*this); }
+	MvaFrequenciesSet* clone() const { return new MvaFrequenciesSet(*this); }
 	
 	MvaFrequenciesSet& operator=(const MvaFrequenciesSet& mfs)
 	{
-		//			AbstractParametrizable::operator=(af);
 		AbstractFrequenciesSet::operator=(mfs);
 		tPpalAxes_ = mfs.tPpalAxes_;
 		rowCoords_ = mfs.rowCoords_;
diff --git a/src/Bpp/Phyl/Model/FrequenciesSet/NucleotideFrequenciesSet.cpp b/src/Bpp/Phyl/Model/FrequenciesSet/NucleotideFrequenciesSet.cpp
index 3b66fe3..33273c5 100644
--- a/src/Bpp/Phyl/Model/FrequenciesSet/NucleotideFrequenciesSet.cpp
+++ b/src/Bpp/Phyl/Model/FrequenciesSet/NucleotideFrequenciesSet.cpp
@@ -122,6 +122,7 @@ void FullNucleotideFrequenciesSet::setFrequencies(const vector<double>& frequenc
 
 void FullNucleotideFrequenciesSet::fireParameterChanged(const ParameterList& parameters)
 {
+  AbstractFrequenciesSet::fireParameterChanged(parameters);
   double theta  = getParameter_(0).getValue();
   double theta1 = getParameter_(1).getValue();
   double theta2 = getParameter_(2).getValue();
@@ -153,6 +154,7 @@ void GCFrequenciesSet::setFrequencies(const vector<double>& frequencies)
 
 void GCFrequenciesSet::fireParameterChanged(const ParameterList& parameters)
 {
+  AbstractFrequenciesSet::fireParameterChanged(parameters);
   double theta = getParameter_(0).getValue();
   getFreq_(0) = getFreq_(3) = (1. - theta) / 2.;
   getFreq_(1) = getFreq_(2) = theta / 2.;
diff --git a/src/Bpp/Phyl/Model/FrequenciesSet/NucleotideFrequenciesSet.h b/src/Bpp/Phyl/Model/FrequenciesSet/NucleotideFrequenciesSet.h
index 4285183..8029ffa 100644
--- a/src/Bpp/Phyl/Model/FrequenciesSet/NucleotideFrequenciesSet.h
+++ b/src/Bpp/Phyl/Model/FrequenciesSet/NucleotideFrequenciesSet.h
@@ -53,11 +53,11 @@ class NucleotideFrequenciesSet :
   public virtual FrequenciesSet
 {
 public:
-#ifndef NO_VIRTUAL_COV
+  
   NucleotideFrequenciesSet* clone() const = 0;
 
   const NucleicAlphabet* getAlphabet() const = 0;
-#endif
+
 };
 
 /**
@@ -83,20 +83,14 @@ public:
     getFreq_(1) = getFreq_(2) = theta / 2.;
   }
 
-#ifndef NO_VIRTUAL_COV
-  GCFrequenciesSet*
-#else
-  Clonable*
-#endif
-  clone() const { return new GCFrequenciesSet(*this); }
+  GCFrequenciesSet* clone() const { return new GCFrequenciesSet(*this); }
 
 public:
-#ifndef NO_VIRTUAL_COV
+  
   const NucleicAlphabet* getAlphabet() const
   {
     return dynamic_cast<const NucleicAlphabet*>(AbstractFrequenciesSet::getAlphabet());
   }
-#endif
 
   void setFrequencies(const std::vector<double>& frequencies);
 
@@ -134,20 +128,14 @@ public:
 
   FullNucleotideFrequenciesSet(const NucleicAlphabet* alphabet, double theta, double theta1, double theta2, bool allowNullFreqs = false, const std::string& name = "Full");
 
-#ifndef NO_VIRTUAL_COV
-  FullNucleotideFrequenciesSet*
-#else
-  Clonable*
-#endif
-  clone() const { return new FullNucleotideFrequenciesSet(*this); }
+  FullNucleotideFrequenciesSet* clone() const { return new FullNucleotideFrequenciesSet(*this); }
 
 public:
-#ifndef NO_VIRTUAL_COV
+  
   const NucleicAlphabet* getAlphabet() const
   {
     return dynamic_cast<const NucleicAlphabet*>(AbstractFrequenciesSet::getAlphabet());
   }
-#endif
 
   void setFrequencies(const std::vector<double>& frequencies);
 
@@ -176,19 +164,12 @@ public:
   FixedNucleotideFrequenciesSet(const NucleicAlphabet* alphabet, const std::string& name = "Fixed") :
     FixedFrequenciesSet(new CanonicalStateMap(alphabet, false), name) {}
 
-#ifndef NO_VIRTUAL_COV
-  FixedNucleotideFrequenciesSet*
-#else
-  NucleotideFrequenciesSet*
-#endif
-  clone() const { return new FixedNucleotideFrequenciesSet(*this); }
+  FixedNucleotideFrequenciesSet* clone() const { return new FixedNucleotideFrequenciesSet(*this); }
 
-#ifndef NO_VIRTUAL_COV
   const NucleicAlphabet* getAlphabet() const
   {
     return dynamic_cast<const NucleicAlphabet*>(AbstractFrequenciesSet::getAlphabet());
   }
-#endif
 };
 
 
diff --git a/src/Bpp/Phyl/Model/FrequenciesSet/ProteinFrequenciesSet.h b/src/Bpp/Phyl/Model/FrequenciesSet/ProteinFrequenciesSet.h
index 73423c7..a85b942 100644
--- a/src/Bpp/Phyl/Model/FrequenciesSet/ProteinFrequenciesSet.h
+++ b/src/Bpp/Phyl/Model/FrequenciesSet/ProteinFrequenciesSet.h
@@ -53,11 +53,10 @@ class ProteinFrequenciesSet :
   public virtual FrequenciesSet
 {
 public:
-#ifndef NO_VIRTUAL_COV
+  
   ProteinFrequenciesSet* clone() const = 0;
 
   const ProteicAlphabet* getAlphabet() const = 0;
-#endif
 };
 
 /**
@@ -81,20 +80,13 @@ public:
   FullProteinFrequenciesSet(const ProteicAlphabet* alphabet, const std::vector<double>& initFreqs, bool allowNullFreqs = false, unsigned short method = 1, const std::string& name = "Full") :
     FullFrequenciesSet(new CanonicalStateMap(alphabet, false), initFreqs, allowNullFreqs, method, name) {}
 
-#ifndef NO_VIRTUAL_COV
-  FullProteinFrequenciesSet*
-#else
-  Clonable*
-#endif
-  clone() const { return new FullProteinFrequenciesSet(*this); }
+  FullProteinFrequenciesSet* clone() const { return new FullProteinFrequenciesSet(*this); }
 
 public:
-#ifndef NO_VIRTUAL_COV
   const ProteicAlphabet* getAlphabet() const
   {
     return dynamic_cast<const ProteicAlphabet*>(AbstractFrequenciesSet::getAlphabet());
   }
-#endif
 };
 
 /**
@@ -117,19 +109,12 @@ public:
   FixedProteinFrequenciesSet(const ProteicAlphabet* alphabet, const std::string& name = "Fixed") :
     FixedFrequenciesSet(new CanonicalStateMap(alphabet, false), name) {}
 
-#ifndef NO_VIRTUAL_COV
-  FixedProteinFrequenciesSet*
-#else
-  FixedFrequenciesSet*
-#endif
-  clone() const { return new FixedProteinFrequenciesSet(*this); }
+  FixedProteinFrequenciesSet* clone() const { return new FixedProteinFrequenciesSet(*this); }
 
-#ifndef NO_VIRTUAL_COV
   const ProteicAlphabet* getAlphabet() const
   {
     return dynamic_cast<const ProteicAlphabet*>(AbstractFrequenciesSet::getAlphabet());
   }
-#endif
 };
 
 
diff --git a/src/Bpp/Phyl/Model/FrequenciesSet/WordFrequenciesSet.cpp b/src/Bpp/Phyl/Model/FrequenciesSet/WordFrequenciesSet.cpp
index 23aa12f..f227f76 100644
--- a/src/Bpp/Phyl/Model/FrequenciesSet/WordFrequenciesSet.cpp
+++ b/src/Bpp/Phyl/Model/FrequenciesSet/WordFrequenciesSet.cpp
@@ -142,6 +142,7 @@ WordFromIndependentFrequenciesSet& WordFromIndependentFrequenciesSet::operator=(
 
 void WordFromIndependentFrequenciesSet::fireParameterChanged(const ParameterList& pl)
 {
+  AbstractFrequenciesSet::fireParameterChanged(pl);
   size_t l = vFreq_.size();
 
   bool f = 0;
@@ -305,6 +306,7 @@ WordFromUniqueFrequenciesSet::~WordFromUniqueFrequenciesSet()
 
 void WordFromUniqueFrequenciesSet::fireParameterChanged(const ParameterList& pl)
 {
+  AbstractFrequenciesSet::fireParameterChanged(pl);
   if (pFreq_->matchParametersValues(pl))
     updateFrequencies();
 }
diff --git a/src/Bpp/Phyl/Model/FrequenciesSet/WordFrequenciesSet.h b/src/Bpp/Phyl/Model/FrequenciesSet/WordFrequenciesSet.h
index 5e59a95..de3db96 100644
--- a/src/Bpp/Phyl/Model/FrequenciesSet/WordFrequenciesSet.h
+++ b/src/Bpp/Phyl/Model/FrequenciesSet/WordFrequenciesSet.h
@@ -68,22 +68,18 @@ protected:
   virtual size_t getSizeFromVector(const std::vector<FrequenciesSet*>& freqVector) = 0;
   
 public:
-#ifndef NO_VIRTUAL_COV
   WordFrequenciesSet* clone() const = 0;
 
   const WordAlphabet* getAlphabet() const = 0;
-#endif
 
   /**
    *@ brief Returns the n-th FrequenciesSet&
-   **/
-
+   */
   virtual const FrequenciesSet& getFrequenciesSetForLetter(size_t i) const = 0;
 
   /**
    *@ brief Returns the length of the words
-   **/
-
+   */
   virtual size_t getLength() const = 0;
 };
 
@@ -98,12 +94,7 @@ protected:
 public:
   AbstractWordFrequenciesSet(StateMap* stateMap, const std::string& prefix = "", const std::string& name="");
 
-#ifndef NO_VIRTUAL_COV
-  AbstractWordFrequenciesSet*
-#else
-  Clonable*
-#endif
-  clone() const = 0;
+  AbstractWordFrequenciesSet* clone() const = 0;
 
   AbstractWordFrequenciesSet(const AbstractWordFrequenciesSet& af) :
     AbstractFrequenciesSet(af) {}
@@ -114,28 +105,25 @@ public:
     return *this;
   }
 
-#ifndef NO_VIRTUAL_COV
   const WordAlphabet* getAlphabet() const
   {
     return dynamic_cast<const WordAlphabet*>(AbstractFrequenciesSet::getAlphabet());
   }
-#endif
 
   virtual ~AbstractWordFrequenciesSet();
   
   /**
    *@ brief Return the length of the words
-   **/
-  
+   */
   size_t getLength() const;
 };
 
 
 /**
  * @brief the Frequencies in words are the product of Independent Frequencies in letters
+ *
  * @author Laurent Guéguen
  */
-
 class WordFromIndependentFrequenciesSet :
     public AbstractWordFrequenciesSet
 {
diff --git a/src/Bpp/Phyl/Model/FromMixtureSubstitutionModel.cpp b/src/Bpp/Phyl/Model/FromMixtureSubstitutionModel.cpp
new file mode 100644
index 0000000..959282d
--- /dev/null
+++ b/src/Bpp/Phyl/Model/FromMixtureSubstitutionModel.cpp
@@ -0,0 +1,93 @@
+//
+// File: FromMixtureSubstitutionModel.cpp
+// Created by: Laurent Gueguen
+// Created on: samedi 24 octobre 2015, � 18h 50
+//
+
+/*
+   Copyright or � or Copr. Bio++ Development Team, (November 16, 2004)
+
+   This software is a computer program whose purpose is to provide classes
+   for phylogenetic data analysis.
+
+   This software is governed by the CeCILL  license under French law and
+   abiding by the rules of distribution of free software.  You can  use,
+   modify and/ or redistribute the software under the terms of the CeCILL
+   license as circulated by CEA, CNRS and INRIA at the following URL
+   "http://www.cecill.info".
+
+   As a counterpart to the access to the source code and  rights to copy,
+   modify and redistribute granted by the license, users are provided only
+   with a limited warranty  and the software's author,  the holder of the
+   economic rights,  and the successive licensors  have only  limited
+   liability.
+
+   In this respect, the user's attention is drawn to the risks associated
+   with loading,  using,  modifying and/or developing or reproducing the
+   software by the user in light of its specific status of free software,
+   that may mean  that it is complicated to manipulate,  and  that  also
+   therefore means  that it is reserved for developers  and  experienced
+   professionals having in-depth computer knowledge. Users are therefore
+   encouraged to load and test the software's suitability as regards their
+   requirements in conditions enabling the security of their systems and/or
+   data to be ensured and,  more generally, to use and operate it in the
+   same conditions as regards security.
+
+   The fact that you are presently reading this means that you have had
+   knowledge of the CeCILL license and that you accept its terms.
+ */
+
+#include "FromMixtureSubstitutionModel.h"
+
+using namespace bpp;
+using namespace std;
+
+/******************************************************************************/
+
+FromMixtureSubstitutionModel::FromMixtureSubstitutionModel(const MixedSubstitutionModel& mixedModel, const std::string& subModelName, const std::string& mixtDesc) :
+  AbstractParameterAliasable(mixedModel.getName() + "_" + subModelName),
+  subModel_(),
+  mixtName_(mixtDesc)
+{
+  const SubstitutionModel* sm = mixedModel.getSubModelWithName(subModelName);
+
+  if (sm == 0)
+    throw ParameterNotFoundException("FromMixtureSubstitutionModel::FromMixtureSubstitutionModel : unknown model name", subModelName);
+
+  subModel_ = std::unique_ptr<SubstitutionModel>(sm->clone());
+  subModel_->setNamespace(mixtName_);
+
+  subModel_->setRate(1);
+  addParameters_(subModel_->getParameters());
+}
+
+
+/******************************************************************************/
+
+FromMixtureSubstitutionModel::FromMixtureSubstitutionModel(const FromMixtureSubstitutionModel& fmsm) :
+  AbstractParameterAliasable(fmsm),
+  subModel_(fmsm.subModel_->clone()),
+  mixtName_(fmsm.mixtName_)
+{}
+
+
+/******************************************************************************/
+
+FromMixtureSubstitutionModel& FromMixtureSubstitutionModel::operator=(const FromMixtureSubstitutionModel& fmsm)
+{
+  AbstractParameterAliasable::operator=(fmsm);
+
+  subModel_ = std::unique_ptr<SubstitutionModel>(fmsm.subModel_->clone());
+
+  mixtName_ = fmsm.mixtName_;
+
+  return *this;
+}
+
+
+std::string FromMixtureSubstitutionModel::getName() const
+{
+  size_t posp = mixtName_.find("(");
+
+  return mixtName_.substr(0, posp) + "_" + getModel().getName() + mixtName_.substr(posp);
+}
diff --git a/src/Bpp/Phyl/Model/AbstractBiblioSubstitutionModel.h b/src/Bpp/Phyl/Model/FromMixtureSubstitutionModel.h
similarity index 63%
copy from src/Bpp/Phyl/Model/AbstractBiblioSubstitutionModel.h
copy to src/Bpp/Phyl/Model/FromMixtureSubstitutionModel.h
index 64ca8fd..5631f07 100644
--- a/src/Bpp/Phyl/Model/AbstractBiblioSubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/FromMixtureSubstitutionModel.h
@@ -1,11 +1,11 @@
 //
-// File: AbstractBiblioSubstitutionModel.h
-// Created by: Laurent Guéguen
-// Created on: vendredi 8 juillet 2011, à 20h 17
+// File: FromMixtureSubstitutionModel.h
+// Created by: Laurent Gueguen
+// Created on: samedi 24 octobre 2015, � 18h 28
 //
 
 /*
-   Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+   Copyright or � or Copr. Bio++ Development Team, (November 16, 2004)
 
    This software is a computer program whose purpose is to provide classes
    for phylogenetic data analysis.
@@ -37,54 +37,66 @@
    knowledge of the CeCILL license and that you accept its terms.
  */
 
-#ifndef _ABSTRACTBIBLIOSUBSTITUTIONMODEL_H_
-#define _ABSTRACTBIBLIOSUBSTITUTIONMODEL_H_
+#ifndef _FROM_MIXTURE_SUBSTITUTIONMODEL_H_
+#define _FROM_MIXTURE_SUBSTITUTIONMODEL_H_
 
-#include "SubstitutionModel.h"
 #include "AbstractSubstitutionModel.h"
-
-#include <Bpp/Numeric/AbstractParameterAliasable.h>
+#include "MixtureOfSubstitutionModels.h"
 
 namespace bpp
 {
 /**
- * @brief Partial implementation of the SubstitutionModel interface
- *   for models that are set for matching the bibliography, and are
- *   only defined through a link to a "real" model.
+ * @brief Model taken from a SubModel of a
+ * MixtureOfSubstitutionModels.
  *
+ * It has the same parameters as the SubModel.
  */
-
-class AbstractBiblioSubstitutionModel :
+class FromMixtureSubstitutionModel :
   public virtual SubstitutionModel,
   public AbstractParameterAliasable
 {
-protected:
-  /**
-   * @brief Tools to make the link between the Parameters of the
-   * object and those of pmixmodel_.
+private:
+  /*
+   * @brief The subModel taken from the MixtureOfSubstitutionModels.
+   *
+   * This subModel is normalized, even if it is not in the mixture.
    *
    */
 
-  std::map<std::string, std::string> mapParNamesFromPmodel_;
+  std::unique_ptr<SubstitutionModel> subModel_;
+
+  /*
+   * @brief The name of the mixture model (for io purpose).
+   */
 
-  ParameterList lParPmodel_;
+  std::string mixtName_;
 
 public:
-  AbstractBiblioSubstitutionModel(const std::string& prefix);
+  FromMixtureSubstitutionModel(const MixedSubstitutionModel& mixedModel, const std::string& subModelName, const std::string& mixtDesc);
 
-  AbstractBiblioSubstitutionModel(const AbstractBiblioSubstitutionModel& model);
+  FromMixtureSubstitutionModel(const FromMixtureSubstitutionModel& fmsm);
 
-  AbstractBiblioSubstitutionModel& operator=(const AbstractBiblioSubstitutionModel& model);
+  FromMixtureSubstitutionModel& operator=(const FromMixtureSubstitutionModel& fmsm);
 
-  virtual ~AbstractBiblioSubstitutionModel() {}
+  ~FromMixtureSubstitutionModel() {}
 
-#ifndef NO_VIRTUAL_COV
-  virtual AbstractBiblioSubstitutionModel* clone() const = 0;
-#endif
+  FromMixtureSubstitutionModel* clone() const { return new FromMixtureSubstitutionModel(*this); }
 
 public:
-  virtual const SubstitutionModel& getModel() const = 0;
+  const SubstitutionModel& getModel() const
+  {
+    return *subModel_.get();
+  }
 
+protected:
+  void updateMatrices();
+
+  SubstitutionModel& getModel()
+  {
+    return *subModel_.get();
+  }
+
+public:
   /*
      *@ brief Methods to supersede SubstitutionModel methods.
    *
@@ -96,22 +108,22 @@ public:
   const StateMap& getStateMap() const { return getModel().getStateMap(); }
 
   int getAlphabetStateAsInt(size_t i) const { return getModel().getAlphabetStateAsInt(i); }
-  
+
   std::string getAlphabetStateAsChar(size_t i) const { return getModel().getAlphabetStateAsChar(i); }
 
   std::vector<size_t> getModelStates(int code) const { return getModel().getModelStates(code); }
-  
+
   std::vector<size_t> getModelStates(const std::string& code) const { return getModel().getModelStates(code); }
 
-  virtual double freq(size_t i) const { return getModel().freq(i); }
+  double freq(size_t i) const { return getModel().freq(i); }
 
-  virtual double Qij(size_t i, size_t j) const { return getModel().Qij(i, j); }
+  double Qij(size_t i, size_t j) const { return getModel().Qij(i, j); }
 
-  virtual double Pij_t    (size_t i, size_t j, double t) const { return getModel().Pij_t(i, j, t); }
-  virtual double dPij_dt  (size_t i, size_t j, double t) const { return getModel().dPij_dt (i, j, t); }
-  virtual double d2Pij_dt2(size_t i, size_t j, double t) const { return getModel().d2Pij_dt2(i, j, t); }
+  double Pij_t    (size_t i, size_t j, double t) const { return getModel().Pij_t(i, j, t); }
+  double dPij_dt  (size_t i, size_t j, double t) const { return getModel().dPij_dt (i, j, t); }
+  double d2Pij_dt2(size_t i, size_t j, double t) const { return getModel().d2Pij_dt2(i, j, t); }
 
-  virtual const Vdouble& getFrequencies() const { return getModel().getFrequencies(); }
+  const Vdouble& getFrequencies() const { return getModel().getFrequencies(); }
 
   const Matrix<double>& getGenerator() const { return getModel().getGenerator(); }
 
@@ -138,17 +150,22 @@ public:
   const Vdouble& getIEigenValues() const { return getModel().getIEigenValues(); }
 
   const Matrix<double>& getRowLeftEigenVectors() const { return getModel().getRowLeftEigenVectors(); }
+
   const Matrix<double>& getColumnRightEigenVectors() const { return getModel().getColumnRightEigenVectors(); }
 
   double getRate() const { return getModel().getRate(); }
 
   void setRate(double rate) { return getModel().setRate(rate); }
 
-  void addRateParameter();
+  void addRateParameter()
+  {
+    getModel().addRateParameter();
+    addParameter_(new Parameter(getNamespace() + "rate", getModel().getRate(), &Parameter::R_PLUS_STAR));
+  }
 
-  void setFreqFromData(const SequenceContainer& data, double pseudoCount = 0);
+  void setFreqFromData(const SequenceContainer& data, double pseudoCount = 0){getModel().setFreqFromData(data, pseudoCount); }
 
-  void setFreq(std::map<int, double>& frequ);
+  void setFreq(std::map<int, double>& frequ) {getModel().setFreq(frequ); }
 
   const Alphabet* getAlphabet() const { return getModel().getAlphabet(); }
 
@@ -174,19 +191,34 @@ public:
    *
    * This updates the matrices consequently.
    */
-  virtual void fireParameterChanged(const ParameterList& parameters)
+  void fireParameterChanged(const ParameterList& parameters)
   {
     AbstractParameterAliasable::fireParameterChanged(parameters);
-    if (parameters.size() > 1 || (parameters.size() == 1 && parameters[0].getName() != getNamespace() + "rate")) {
-      updateMatrices();
-    }
+    getModel().matchParametersValues(parameters);
   }
 
-protected:
-  virtual void updateMatrices();
-  virtual SubstitutionModel& getModel() = 0;
+  void setNamespace(const std::string& name)
+  {
+    AbstractParameterAliasable::setNamespace(name);
+    getModel().setNamespace(name);
+  }
 
 public:
+  bool isScalable() const 
+  {
+    return getModel().isScalable();
+  }
+
+  void setScalable(bool scalable)
+  {
+    getModel().setScalable(scalable);
+  }
+
+  void normalize()
+  {
+    getModel().normalize();
+  }
+    
   double getScale() const { return getModel().getScale(); }
 
   void setScale(double scale) { getModel().setScale(scale); }
@@ -194,9 +226,9 @@ public:
   /*
    * @}
    */
+
+  std::string getName() const;
 };
 } // end of namespace bpp.
 
-
-#endif  // _ABSTRACTBIBLIOSUBSTITUTIONMODEL_H_
-
+#endif  // _FROM_MIXTURE_SUBSTITUTIONMODEL_H_
diff --git a/src/Bpp/Phyl/Model/KroneckerWordSubstitutionModel.cpp b/src/Bpp/Phyl/Model/KroneckerWordSubstitutionModel.cpp
new file mode 100644
index 0000000..8f08ceb
--- /dev/null
+++ b/src/Bpp/Phyl/Model/KroneckerWordSubstitutionModel.cpp
@@ -0,0 +1,125 @@
+//
+// File: KroneckerWordSubstitutionModel.cpp
+// Created by: Laurent Gueguen
+// Created on: mercredi 27 juillet 2016, à 00h 12
+//
+
+/*
+   Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+   This software is a computer program whose purpose is to provide classes
+   for phylogenetic data analysis.
+
+   This software is governed by the CeCILL  license under French law and
+   abiding by the rules of distribution of free software.  You can  use,
+   modify and/ or redistribute the software under the terms of the CeCILL
+   license as circulated by CEA, CNRS and INRIA at the following URL
+   "http://www.cecill.info".
+
+   As a counterpart to the access to the source code and  rights to copy,
+   modify and redistribute granted by the license, users are provided only
+   with a limited warranty  and the software's author,  the holder of the
+   economic rights,  and the successive licensors  have only  limited
+   liability.
+
+   In this respect, the user's attention is drawn to the risks associated
+   with loading,  using,  modifying and/or developing or reproducing the
+   software by the user in light of its specific status of free software,
+   that may mean  that it is complicated to manipulate,  and  that  also
+   therefore means  that it is reserved for developers  and  experienced
+   professionals having in-depth computer knowledge. Users are therefore
+   encouraged to load and test the software's suitability as regards their
+   requirements in conditions enabling the security of their systems and/or
+   data to be ensured and,  more generally, to use and operate it in the
+   same conditions as regards security.
+
+   The fact that you are presently reading this means that you have had
+   knowledge of the CeCILL license and that you accept its terms.
+ */
+
+#include "KroneckerWordSubstitutionModel.h"
+
+#include <Bpp/Numeric/Matrix/MatrixTools.h>
+#include <Bpp/Numeric/VectorTools.h>
+#include <Bpp/Numeric/Matrix/EigenValue.h>
+
+// From SeqLib:
+#include <Bpp/Seq/Alphabet/WordAlphabet.h>
+#include <Bpp/Seq/Container/SequenceContainerTools.h>
+
+using namespace bpp;
+
+// From the STL:
+#include <cmath>
+
+using namespace std;
+
+/******************************************************************************/
+
+KroneckerWordSubstitutionModel::KroneckerWordSubstitutionModel(
+  ModelList& modelList,
+  const std::string& prefix) :
+  AbstractParameterAliasable((prefix == "") ? "Kron." : prefix),
+  AbstractKroneckerWordSubstitutionModel(
+    modelList,
+    (prefix == "") ? "Kron." : prefix)
+{
+  updateMatrices();
+}
+
+KroneckerWordSubstitutionModel::KroneckerWordSubstitutionModel(
+  const Alphabet* alph,
+  StateMap* stateMap,
+  const std::string& prefix) :
+  AbstractParameterAliasable((prefix == "") ? "Kron." : prefix),
+  AbstractKroneckerWordSubstitutionModel(alph, stateMap, (prefix == "") ? "Kron." : prefix)
+{
+  enableEigenDecomposition(true);
+}
+
+KroneckerWordSubstitutionModel::KroneckerWordSubstitutionModel(
+  SubstitutionModel* pmodel,
+  unsigned int num,
+  const std::string& prefix) :
+  AbstractParameterAliasable((prefix == "") ? "Kron." : prefix),
+  AbstractKroneckerWordSubstitutionModel(pmodel,
+                                num,
+                                (prefix == "") ? "Kron." : prefix)
+{
+  enableEigenDecomposition(true);
+  updateMatrices();
+}
+
+KroneckerWordSubstitutionModel::KroneckerWordSubstitutionModel(
+  ModelList& modelList,
+  const std::vector<std::set< size_t> >& vPos,
+  const std::string& prefix) :
+  AbstractParameterAliasable((prefix == "") ? "Kron." : prefix),
+  AbstractKroneckerWordSubstitutionModel(
+    modelList, vPos,
+    (prefix == "") ? "Kron." : prefix)
+{
+  enableEigenDecomposition(true);
+  updateMatrices();
+}
+
+KroneckerWordSubstitutionModel::KroneckerWordSubstitutionModel(
+  SubstitutionModel* pmodel,
+  unsigned int num,
+  const std::vector<std::set< size_t> >& vPos,
+  const std::string& prefix) :
+  AbstractParameterAliasable((prefix == "") ? "Kron." : prefix),
+  AbstractKroneckerWordSubstitutionModel(pmodel,
+                                         num, vPos,
+                                         (prefix == "") ? "Kron." : prefix)
+{
+  enableEigenDecomposition(true);
+  updateMatrices();
+}
+
+
+string KroneckerWordSubstitutionModel::getName() const
+{
+  return "Kron";
+}
+
+
diff --git a/src/Bpp/Phyl/Model/KroneckerWordSubstitutionModel.h b/src/Bpp/Phyl/Model/KroneckerWordSubstitutionModel.h
new file mode 100644
index 0000000..482bb5a
--- /dev/null
+++ b/src/Bpp/Phyl/Model/KroneckerWordSubstitutionModel.h
@@ -0,0 +1,148 @@
+//
+// File: KroneckerWordSubstitutionModel.h
+// Created by: Laurent Gueguen
+// Created on: mercredi 27 juillet 2016, à 00h 12
+//
+
+/*
+  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
+
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use,
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info".
+
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability.
+
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or
+  data to be ensured and,  more generally, to use and operate it in the
+  same conditions as regards security.
+
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
+*/
+
+#ifndef _KRONECKER_WORDSUBSTITUTIONMODEL_H_
+#define _KRONECKER_WORDSUBSTITUTIONMODEL_H_
+
+#include "AbstractKroneckerWordSubstitutionModel.h"
+
+//From bpp-core
+#include <Bpp/Numeric/Matrix/Matrix.h>
+#include <Bpp/BppVector.h>
+
+namespace bpp
+{
+/**
+ * @brief Basal class for words of  substitution models with multiple
+ * substitutions.
+ * @author Laurent Guéguen
+ *
+ * The equilibrium frequency of each word is due to the combination of
+ * the multiple substitutions.
+ *
+ */
+
+  class KroneckerWordSubstitutionModel :
+    public AbstractKroneckerWordSubstitutionModel
+  {
+  public:
+    /**
+     * @brief Build a new KroneckerWordSubstitutionModel object from a
+     * Vector of pointers to SubstitutionModels.
+     *
+     * @param modelList the list of substitution models to use, in
+     *   the order of the positions in the words from left to right. All
+     *   the models must be different objects to avoid parameters
+     *   redundancy, otherwise only the first model is used. The used models
+     *   are owned by the instance.
+     * @param prefix the Namespace.
+     */
+    KroneckerWordSubstitutionModel(ModelList& modelList, const std::string& prefix = "");
+
+    /**
+     * @brief Build a new KroneckerWordSubstitutionModel object from a
+     * Vector of pointers to SubstitutionModels.
+     *
+     * @param modelList the list of substitution models to use, in
+     *   the order of the positions in the words from left to right. All
+     *   the models must be different objects to avoid parameters
+     *   redundancy, otherwise only the first model is used. The used models
+     *   are owned by the instance.
+     * @param vPos a vector of sets of simultaneously changing
+     *   positions.
+     * @param prefix the Namespace.
+     */
+
+    KroneckerWordSubstitutionModel(ModelList& modelList,
+                                   const std::vector<std::set< size_t> >& vPos,
+                                   const std::string& prefix = "");
+
+    /**
+     * @brief Build a new KroneckerWordSubstitutionModel object from a
+     * pointer to an SubstitutionModel and a number of
+     * desired models.
+     *
+     * @param pmodel pointer to the substitution model to use in all the
+     *  positions. It is owned by the instance.
+     * @param num The number of models involved.
+     * @param prefix the Namespace.
+     */
+  
+    KroneckerWordSubstitutionModel(SubstitutionModel* pmodel, unsigned int num, const std::string& prefix = "");
+
+    /**
+     * @brief Build a new KroneckerWordSubstitutionModel object from a
+     * pointer to an SubstitutionModel and a number of
+     * desired models.
+     *
+     * @param pmodel pointer to the substitution model to use in all the
+     *  positions. It is owned by the instance.
+     * @param num The number of models involved.
+     * @param vPos a vector of sets of simultaneously changing
+     *   positions.
+     * @param prefix the Namespace.
+     */
+  
+    KroneckerWordSubstitutionModel(SubstitutionModel* pmodel, unsigned int num,
+                                   const std::vector<std::set< size_t> >& vPos,
+                                   const std::string& prefix = "");
+
+    virtual ~KroneckerWordSubstitutionModel() {}
+
+    KroneckerWordSubstitutionModel* clone() const { return new KroneckerWordSubstitutionModel(*this); }
+
+  protected:
+  
+    /**
+     * @brief Constructor for the derived classes only
+     */
+
+    KroneckerWordSubstitutionModel(const Alphabet* alph, StateMap* stateMap, const std::string& prefix = "");
+
+    void completeMatrices() {};
+    
+
+  public:
+    virtual std::string getName() const;
+
+  };
+} // end of namespace bpp.
+
+#endif  // _WORDSUBSTITUTIONMODEL
+
diff --git a/src/Bpp/Phyl/Model/MarkovModulatedSubstitutionModel.cpp b/src/Bpp/Phyl/Model/MarkovModulatedSubstitutionModel.cpp
index b4b32fa..e706148 100644
--- a/src/Bpp/Phyl/Model/MarkovModulatedSubstitutionModel.cpp
+++ b/src/Bpp/Phyl/Model/MarkovModulatedSubstitutionModel.cpp
@@ -129,13 +129,12 @@ void MarkovModulatedSubstitutionModel::updateMatrices()
   if (normalizeRateChanges_)
   {
     // Normalization:
-    Vdouble Tmp;
-    MatrixTools::diag(generator_, Tmp);
-    double scale = -VectorTools::scalar<double, double>(Tmp, freq_);
-    MatrixTools::scale(generator_, 1. / scale);
+    double scale = getScale();
+    setScale(1. / scale);
 
     // Normalize exchangeability matrix too:
-    MatrixTools::scale(exchangeability_, 1. / scale);
+    if (isScalable())
+      MatrixTools::scale(exchangeability_, 1. / scale);
   }
 
   // Compute eigen values and vectors:
diff --git a/src/Bpp/Phyl/Model/MarkovModulatedSubstitutionModel.h b/src/Bpp/Phyl/Model/MarkovModulatedSubstitutionModel.h
index 803e93d..9e33716 100644
--- a/src/Bpp/Phyl/Model/MarkovModulatedSubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/MarkovModulatedSubstitutionModel.h
@@ -177,12 +177,7 @@ namespace bpp
 
     virtual ~MarkovModulatedSubstitutionModel() { delete model_; }
 
-#ifndef NO_VIRTUAL_COV
-    MarkovModulatedSubstitutionModel*
-#else
-    Clonable*
-#endif
-    clone() const = 0;
+    MarkovModulatedSubstitutionModel* clone() const = 0;
 
   public:
 	  
@@ -237,7 +232,12 @@ namespace bpp
       updateMatrices();
     }
 
-
+    virtual void setFreq(std::map<int, double>& frequencies)
+    {
+      model_->setFreq(frequencies);
+      updateMatrices();
+    }
+    
     const ReversibleSubstitutionModel* getNestedModel() const { return model_; }
 
     /**
@@ -256,6 +256,22 @@ namespace bpp
 
     void setRate(double rate) { model_->setRate(rate); }
 
+    bool isScalable() const 
+    {
+      return model_->isScalable();
+    }
+
+    void setScalable(bool scalable)
+    {
+      model_->setScalable(scalable);
+    }
+
+    void normalize()
+    {
+      model_->normalize();
+      updateMatrices();
+    }
+    
     double getScale() const
     {
       std::vector<double> v;
diff --git a/src/Bpp/Phyl/Model/MixedSubstitutionModel.h b/src/Bpp/Phyl/Model/MixedSubstitutionModel.h
index 175df8c..d4df76e 100644
--- a/src/Bpp/Phyl/Model/MixedSubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/MixedSubstitutionModel.h
@@ -122,6 +122,15 @@ namespace bpp
 
     virtual void normalizeVRates() = 0;
 
+    /**
+     * @brief retrieve a pointer to the submodel with the given name.
+     *
+     * Return Null if not found.
+     *
+     */
+    
+    virtual const SubstitutionModel* getSubModelWithName(const std::string& name) const = 0;
+    
     /*
      *@brief Returns the vector of numbers of the submodels in the
      *mixture that match a description.
diff --git a/src/Bpp/Phyl/Model/MixedSubstitutionModelSet.cpp b/src/Bpp/Phyl/Model/MixedSubstitutionModelSet.cpp
index 9cb1de7..3af933a 100644
--- a/src/Bpp/Phyl/Model/MixedSubstitutionModelSet.cpp
+++ b/src/Bpp/Phyl/Model/MixedSubstitutionModelSet.cpp
@@ -116,7 +116,7 @@ bool MixedSubstitutionModelSet::complete()
   size_t nbm = getNumberOfModels();
   for (i = 0; i < nbm; i++)
   {
-    const MixedSubstitutionModel* pSM = dynamic_cast<const MixedSubstitutionModel*>(getModel(i));
+    const MixedSubstitutionModel* pSM = dynamic_cast<const MixedSubstitutionModel*>(getTransitionModel(i));
     if (pSM)
     {
       if (nhn.getNode(i).size() != pSM->getNumberOfModels())
@@ -130,7 +130,7 @@ bool MixedSubstitutionModelSet::complete()
   addEmptyHyperNode();
   for (i = 0; i < nbm; i++)
   {
-    const MixedSubstitutionModel* pSM = dynamic_cast<const MixedSubstitutionModel*>(getModel(i));
+    const MixedSubstitutionModel* pSM = dynamic_cast<const MixedSubstitutionModel*>(getTransitionModel(i));
     if (pSM)
     {
       const MixedSubstitutionModelSet::HyperNode::Node& nd = nhn.getNode(i);
@@ -203,7 +203,7 @@ void MixedSubstitutionModelSet::computeHyperNodesProbabilities()
   MixedSubstitutionModel* pfSM = 0;
   for (fmM = 0; fmM < nbm; fmM++)
   {
-    pfSM = dynamic_cast<MixedSubstitutionModel*>(getModel(fmM));
+    pfSM = dynamic_cast<MixedSubstitutionModel*>(getTransitionModel(fmM));
     if (pfSM != NULL)
       break;
   }
@@ -233,7 +233,7 @@ void MixedSubstitutionModelSet::computeHyperNodesProbabilities()
 
   for (size_t iM = fmM + 1; iM < nbm; iM++)
   {
-    pfSM = dynamic_cast<MixedSubstitutionModel*>(getModel(iM));
+    pfSM = dynamic_cast<MixedSubstitutionModel*>(getTransitionModel(iM));
     if (pfSM != NULL)
     {
       for (size_t nh = 0; nh < nbh; nh++)
@@ -280,7 +280,7 @@ double MixedSubstitutionModelSet::getHyperNodeProbability(const HyperNode& hn) c
   for (size_t fmM = 0; fmM < nbm; fmM++)
   {
     const MixedSubstitutionModelSet::HyperNode::Node& fnd = hn.getNode(fmM);
-    const MixedSubstitutionModel* pfSM = dynamic_cast<const MixedSubstitutionModel*>(getModel(fmM));
+    const MixedSubstitutionModel* pfSM = dynamic_cast<const MixedSubstitutionModel*>(getTransitionModel(fmM));
     if (pfSM != NULL)
     {
       double x = 0;
@@ -308,7 +308,7 @@ MixedSubstitutionModelSet::HyperNode::HyperNode(const MixedSubstitutionModelSet*
 {
   for (size_t i = 0; i < pMSMS->getNumberOfModels(); i++)
   {
-    const MixedSubstitutionModel* pSM = dynamic_cast<const MixedSubstitutionModel*>(pMSMS->getModel(i));
+    const MixedSubstitutionModel* pSM = dynamic_cast<const MixedSubstitutionModel*>(pMSMS->getTransitionModel(i));
     if (!pSM)
       vUnused_.push_back(static_cast<int>(i));
   }
@@ -397,7 +397,7 @@ bool MixedSubstitutionModelSet::HyperNode::intersects(const HyperNode& hn) const
 
 bool MixedSubstitutionModelSet::HyperNode::operator>=(const HyperNode& hn) const
 {
-  return hn >= *this;
+  return hn <= *this;
 }
 
 MixedSubstitutionModelSet::HyperNode& MixedSubstitutionModelSet::HyperNode::operator+=(const HyperNode& hn)
diff --git a/src/Bpp/Phyl/Model/MixedSubstitutionModelSet.h b/src/Bpp/Phyl/Model/MixedSubstitutionModelSet.h
index 1195327..4ec7694 100644
--- a/src/Bpp/Phyl/Model/MixedSubstitutionModelSet.h
+++ b/src/Bpp/Phyl/Model/MixedSubstitutionModelSet.h
@@ -295,12 +295,7 @@ public:
 
   MixedSubstitutionModelSet& operator=(const MixedSubstitutionModelSet& set);
 
-#ifndef NO_VIRTUAL_COV
-  MixedSubstitutionModelSet*
-#else
-  Clonable*
-#endif
-  clone() const { return new MixedSubstitutionModelSet(*this); }
+  MixedSubstitutionModelSet* clone() const { return new MixedSubstitutionModelSet(*this); }
 
   /**
    * @brief Resets the list of the HyperNodes
diff --git a/src/Bpp/Phyl/Model/MixtureOfASubstitutionModel.cpp b/src/Bpp/Phyl/Model/MixtureOfASubstitutionModel.cpp
index c3e9edd..ebdea62 100644
--- a/src/Bpp/Phyl/Model/MixtureOfASubstitutionModel.cpp
+++ b/src/Bpp/Phyl/Model/MixtureOfASubstitutionModel.cpp
@@ -102,7 +102,7 @@ MixtureOfASubstitutionModel::MixtureOfASubstitutionModel(
   for (i = 0; i < c; i++)
   {
     modelsContainer_.push_back(model->clone());
-    modelsContainer_[i]->addRateParameter();
+//    modelsContainer_[i]->addRateParameter();
     modelsContainer_[i]->setNamespace(model->getNamespace());
 
     vProbas_.push_back(1.0 / static_cast<double>(c));
@@ -276,6 +276,17 @@ void MixtureOfASubstitutionModel::setFreq(std::map<int, double>& m)
   matchParametersValues(modelsContainer_[0]->getParameters());
 }
 
+const SubstitutionModel* MixtureOfASubstitutionModel::getSubModelWithName(const std::string& name) const
+{
+  size_t nbmod=getNumberOfModels();
+  
+  for (size_t i=0; i<nbmod; i++)
+    if (getNModel(i)->getName()==name)
+      return getNModel(i);
+
+  return NULL;
+}
+
 Vint MixtureOfASubstitutionModel::getSubmodelNumbers(string& desc) const
 {
   vector<string> parnames = modelsContainer_[0]->getParameters().getParameterNames();
diff --git a/src/Bpp/Phyl/Model/MixtureOfASubstitutionModel.h b/src/Bpp/Phyl/Model/MixtureOfASubstitutionModel.h
index dc39832..358cc2d 100644
--- a/src/Bpp/Phyl/Model/MixtureOfASubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/MixtureOfASubstitutionModel.h
@@ -127,6 +127,15 @@ public:
 
   void updateMatrices();
 
+  /**
+   * @brief retrieve a pointer to the submodel with the given name.
+   *
+   * Return Null if not found.
+   *
+   */
+    
+  const SubstitutionModel* getSubModelWithName(const std::string& name) const;
+    
   /*
      *@brief Returns the vector of numbers of the submodels in the
      *mixture that match a description of the parameters numbers.
diff --git a/src/Bpp/Phyl/Model/MixtureOfSubstitutionModels.cpp b/src/Bpp/Phyl/Model/MixtureOfSubstitutionModels.cpp
index 639e077..4ebe65b 100644
--- a/src/Bpp/Phyl/Model/MixtureOfSubstitutionModels.cpp
+++ b/src/Bpp/Phyl/Model/MixtureOfSubstitutionModels.cpp
@@ -92,11 +92,6 @@ MixtureOfSubstitutionModels::MixtureOfSubstitutionModels(
     addParameters_(vpModel[i]->getParameters());
   }
 
-  for (i = 0; i < nbmod; i++)
-  {
-    vpModel[i]->addRateParameter();
-  }
-
   updateMatrices();
 }
 
@@ -178,11 +173,6 @@ MixtureOfSubstitutionModels::MixtureOfSubstitutionModels(
     addParameters_(vpModel[i]->getParameters());
   }
 
-  for (i = 0; i < nbmod; i++)
-  {
-    vpModel[i]->addRateParameter();
-  }
-
   updateMatrices();
 }
 
@@ -202,6 +192,16 @@ MixtureOfSubstitutionModels& MixtureOfSubstitutionModels::operator=(const Mixtur
 MixtureOfSubstitutionModels::~MixtureOfSubstitutionModels()
 {}
 
+const SubstitutionModel* MixtureOfSubstitutionModels::getSubModelWithName(const std::string& name) const
+{
+  size_t nbmod=getNumberOfModels();
+
+  for (size_t i=0; i<nbmod; i++)
+    if (getNModel(i)->getName()==name)
+      return getNModel(i);
+
+  return NULL;
+}
 
 void MixtureOfSubstitutionModels::updateMatrices()
 {
@@ -258,7 +258,7 @@ void MixtureOfSubstitutionModels::updateMatrices()
 
   for (i = 0; i < nbmod; i++)
   {
-    modelsContainer_[i]->setRate(vRates_[i]);
+    modelsContainer_[i]->setRate(rate_ * vRates_[i]);
     modelsContainer_[i]->matchParametersValues(getParameters());
   }
 
@@ -274,6 +274,7 @@ void MixtureOfSubstitutionModels::updateMatrices()
   }
 }
 
+
 void MixtureOfSubstitutionModels::setFreq(std::map<int, double>& m)
 {
   ParameterList pl;
diff --git a/src/Bpp/Phyl/Model/MixtureOfSubstitutionModels.h b/src/Bpp/Phyl/Model/MixtureOfSubstitutionModels.h
index 67b691a..e36114f 100644
--- a/src/Bpp/Phyl/Model/MixtureOfSubstitutionModels.h
+++ b/src/Bpp/Phyl/Model/MixtureOfSubstitutionModels.h
@@ -161,6 +161,15 @@ public:
 public:
   std::string getName() const { return "Mixture"; }
 
+  /**
+   * @brief retrieve a pointer to the submodel with the given name.
+   *
+   * Return Null if not found.
+   *
+   */
+  
+  const SubstitutionModel* getSubModelWithName(const std::string& name) const;
+  
   void updateMatrices();
 
   /**
diff --git a/src/Bpp/Phyl/Model/Nucleotide/F84.cpp b/src/Bpp/Phyl/Model/Nucleotide/F84.cpp
index a74cd58..89bc5fe 100644
--- a/src/Bpp/Phyl/Model/Nucleotide/F84.cpp
+++ b/src/Bpp/Phyl/Model/Nucleotide/F84.cpp
@@ -61,7 +61,7 @@ F84::F84(
     double piG,
     double piT) :
   AbstractParameterAliasable("F84."),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "F84."),
+  AbstractReversibleNucleotideSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "F84."),
   kappa_(kappa), piA_(piA), piC_(piC), piG_(piG), piT_(piT), piY_(), piR_(),
   r_(), k1_(), k2_(), theta_(piG + piC), theta1_(piA / (1. - theta_)), theta2_(piG / theta_),
   l_(), exp1_(), exp2_(), p_(size_, size_)
@@ -87,7 +87,8 @@ void F84::updateMatrices()
   piT_ = (1. - theta1_) * (1. - theta_);
   piR_ = piA_ + piG_;
   piY_ = piT_ + piC_;
-  r_ = 1. / (1 - piA_ * piA_ - piC_ * piC_ - piG_ * piG_ - piT_*piT_ + 2. * kappa_ * (piC_ * piT_ / piY_ + piA_ * piG_ / piR_));
+
+  r_ = isScalable()?1. / (1 - piA_ * piA_ - piC_ * piC_ - piG_ * piG_ - piT_*piT_ + 2. * kappa_ * (piC_ * piT_ / piY_ + piA_ * piG_ / piR_)):1;
   k1_ = 1;
   k2_ = kappa_ + 1;
   
@@ -118,7 +119,7 @@ void F84::updateMatrices()
   generator_(1, 3) = (1 + kappa_ / piY_) * piT_;
   
   // Normalization:
-  MatrixTools::scale(generator_, r_);
+  setScale(r_);
   
   // Exchangeability:
   exchangeability_(0,0) = generator_(0,0) / piA_;
diff --git a/src/Bpp/Phyl/Model/Nucleotide/F84.h b/src/Bpp/Phyl/Model/Nucleotide/F84.h
index 23611a9..032a981 100644
--- a/src/Bpp/Phyl/Model/Nucleotide/F84.h
+++ b/src/Bpp/Phyl/Model/Nucleotide/F84.h
@@ -41,11 +41,10 @@ knowledge of the CeCILL license and that you accept its terms.
 #define _F84_H_
 
 #include "NucleotideSubstitutionModel.h"
-#include "../AbstractSubstitutionModel.h"
 
 #include <Bpp/Numeric/Constraints.h>
 
-// From SeqLib:
+// From bpp-seq:
 #include <Bpp/Seq/Alphabet/NucleicAlphabet.h>
 
 namespace bpp
@@ -97,7 +96,7 @@ namespace bpp
  * 1 & \left(1 + \kappa/\pi_Y\right) & 1 & \frac{-\pi_G-\left(1 + \kappa/\pi_Y\right)\pi_C-\pi_A}{\pi_T} \\ 
  * \end{pmatrix}
  * \f]
- * with \f$P=2k\left({frac{piC.piT}{piT+piC}}+{\frac{piA.piG}{piG+piA}}\right)-piT^2-piG^2-piC^2-piA^2+1\f$.
+ * with \f$P=2\kappa \left({\frac{\pi_C \pi_T}{\pi_T+\pi_C}}+{\frac{\pi_A \pi_G}{\pi_G+\pi_A}}\right)-\pi_T^2-\pi_G^2-\pi_C^2-\pi_A^2+1\f$.
  *
  * The normalized generator is obtained by taking the dot product of \f$S\f$ and \f$\pi\f$:
  * \f[
@@ -176,8 +175,7 @@ namespace bpp
  * - Felsenstein (1984), Phylip version 2.6. 
  */
 class F84:
-  public virtual NucleotideSubstitutionModel,
-  public AbstractReversibleSubstitutionModel
+  public AbstractReversibleNucleotideSubstitutionModel
 {
   private:
     double kappa_, piA_, piC_, piG_, piT_, piY_, piR_, r_, k1_, k2_, theta_, theta1_, theta2_;
@@ -195,12 +193,7 @@ class F84:
   
     virtual ~F84() {}
 
-#ifndef NO_VIRTUAL_COV
-    F84*
-#else
-    Clonable*
-#endif
-    clone() const { return new F84(*this); }
+    F84* clone() const { return new F84(*this); }
 
   public:
 
diff --git a/src/Bpp/Phyl/Model/Nucleotide/GTR.cpp b/src/Bpp/Phyl/Model/Nucleotide/GTR.cpp
index f0b6ecf..15d67de 100755
--- a/src/Bpp/Phyl/Model/Nucleotide/GTR.cpp
+++ b/src/Bpp/Phyl/Model/Nucleotide/GTR.cpp
@@ -65,7 +65,7 @@ GTR::GTR(
     double piG,
     double piT) :
   AbstractParameterAliasable("GTR."),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "GTR."),
+  AbstractReversibleNucleotideSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "GTR."),
   a_(a), b_(b), c_(c), d_(d), e_(e), piA_(piA), piC_(piC), piG_(piG), piT_(piT), theta_(piG + piC), theta1_(piA / (1. - theta_)), theta2_(piG / theta_), p_()
 {
   addParameter_(new Parameter("GTR.a", a, &Parameter::R_PLUS_STAR));
@@ -73,12 +73,8 @@ GTR::GTR(
   addParameter_(new Parameter("GTR.c", c, &Parameter::R_PLUS_STAR));
   addParameter_(new Parameter("GTR.d", d, &Parameter::R_PLUS_STAR));
   addParameter_(new Parameter("GTR.e", e, &Parameter::R_PLUS_STAR));
-  //jdutheil on 07/02/11: is this still needed? If yes, we should also change it in all models in order to facilitate parameter aliasing...
-  //Parameter thetaP("GTR.theta", theta_ , new IncludingInterval(0.001, 0.999), true); //Avoid numerical errors close to the bounds.
   addParameter_(new Parameter("GTR.theta", theta_, &FrequenciesSet::FREQUENCE_CONSTRAINT_SMALL));
-  //Parameter theta1P("GTR.theta1", theta1_, new IncludingInterval(0.001, 0.999), true);
   addParameter_(new Parameter("GTR.theta1", theta1_, &FrequenciesSet::FREQUENCE_CONSTRAINT_SMALL));
-  //Parameter theta2P("GTR.theta2", theta2_, new IncludingInterval(0.001, 0.999), true);
   addParameter_(new Parameter("GTR.theta2", theta2_, &FrequenciesSet::FREQUENCE_CONSTRAINT_SMALL));
   updateMatrices();
 }
diff --git a/src/Bpp/Phyl/Model/Nucleotide/GTR.h b/src/Bpp/Phyl/Model/Nucleotide/GTR.h
index 02b0a70..384ec90 100755
--- a/src/Bpp/Phyl/Model/Nucleotide/GTR.h
+++ b/src/Bpp/Phyl/Model/Nucleotide/GTR.h
@@ -136,8 +136,7 @@ namespace bpp
  * - Rodriguez F (1990, Journal_ Of Theoretical Biology_ 142(4) 485-501.
  */
 class GTR:
-  public virtual NucleotideSubstitutionModel,
-  public AbstractReversibleSubstitutionModel
+  public AbstractReversibleNucleotideSubstitutionModel
 {
   protected:
     double a_, b_, c_, d_, e_, piA_, piC_, piG_, piT_, theta_, theta1_, theta2_, p_;
@@ -157,12 +156,7 @@ class GTR:
   
     virtual ~GTR() {}
 
-#ifndef NO_VIRTUAL_COV
-    GTR*
-#else
-    Clonable*
-#endif
-    clone() const { return new GTR(*this); }
+    GTR* clone() const { return new GTR(*this); }
 
   public:
     std::string getName() const { return "GTR"; }
diff --git a/src/Bpp/Phyl/Model/Nucleotide/HKY85.cpp b/src/Bpp/Phyl/Model/Nucleotide/HKY85.cpp
index 483b275..d4e4613 100755
--- a/src/Bpp/Phyl/Model/Nucleotide/HKY85.cpp
+++ b/src/Bpp/Phyl/Model/Nucleotide/HKY85.cpp
@@ -62,7 +62,7 @@ HKY85::HKY85(
   double piG,
   double piT):
   AbstractParameterAliasable("HKY85."),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "HKY85."),
+  AbstractReversibleNucleotideSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "HKY85."),
   kappa_(kappa), k1_(), k2_(), r_(),
   piA_(piA), piC_(piC), piG_(piG), piT_(piT), piY_(), piR_(),
   theta_(piG + piC), theta1_(piA / (1. - theta_)), theta2_(piG / theta_),
@@ -117,8 +117,9 @@ void HKY85::updateMatrices()
   generator_(1, 3) = kappa_ * piT_;
 	
   // Normalization:
-  r_ = 1. / (2. * (piA_ * piC_ + piC_ * piG_ + piA_ * piT_ + piG_ * piT_ + kappa_ * (piC_ * piT_ + piA_ * piG_)));
-  MatrixTools::scale(generator_, r_);
+  r_ = isScalable()?1. / (2. * (piA_ * piC_ + piC_ * piG_ + piA_ * piT_ + piG_ * piT_ + kappa_ * (piC_ * piT_ + piA_ * piG_))):1;
+
+  setScale(r_);
 	
   // Exchangeability:
   exchangeability_(0,0) = generator_(0,0) / piA_;
diff --git a/src/Bpp/Phyl/Model/Nucleotide/HKY85.h b/src/Bpp/Phyl/Model/Nucleotide/HKY85.h
index dee98b8..01271f5 100755
--- a/src/Bpp/Phyl/Model/Nucleotide/HKY85.h
+++ b/src/Bpp/Phyl/Model/Nucleotide/HKY85.h
@@ -177,39 +177,33 @@ namespace bpp
  * - Hasegawa M, Kishino H and Yano T (1985), Molecular_ Biology And Evolution_ 22(2) 160-74. 
  */
 class HKY85:
-  public virtual NucleotideSubstitutionModel,
-  public AbstractReversibleSubstitutionModel
+  public AbstractReversibleNucleotideSubstitutionModel
 {
-	private:
-		double kappa_, k1_, k2_, r_, piA_, piC_, piG_, piT_, piY_, piR_, theta_, theta1_, theta2_;
+  private:
+    double kappa_, k1_, k2_, r_, piA_, piC_, piG_, piT_, piY_, piR_, theta_, theta1_, theta2_;
     mutable double exp1_, exp21_, exp22_, l_;
     mutable RowMatrix<double> p_;
 
-	public:
-		HKY85(
-			const NucleicAlphabet * alpha,
-			double kappa = 1.,
-			double piA = 0.25,
-			double piC = 0.25,
-			double piG = 0.25,
-			double piT = 0.25);
-	
-		virtual ~HKY85() {}
-
-#ifndef NO_VIRTUAL_COV
-    HKY85*
-#else
-    Clonable*
-#endif
-    clone() const { return new HKY85(*this); }
+  public:
+    HKY85(
+      const NucleicAlphabet * alpha,
+      double kappa = 1.,
+      double piA = 0.25,
+      double piC = 0.25,
+      double piG = 0.25,
+      double piT = 0.25);
+  
+    virtual ~HKY85() {}
+
+    HKY85* clone() const { return new HKY85(*this); }
 
   public:
-		double Pij_t    (size_t i, size_t j, double d) const;
-		double dPij_dt  (size_t i, size_t j, double d) const;
-		double d2Pij_dt2(size_t i, size_t j, double d) const;
-		const Matrix<double> & getPij_t    (double d) const;
-		const Matrix<double> & getdPij_dt  (double d) const;
-		const Matrix<double> & getd2Pij_dt2(double d) const;
+    double Pij_t    (size_t i, size_t j, double d) const;
+    double dPij_dt  (size_t i, size_t j, double d) const;
+    double d2Pij_dt2(size_t i, size_t j, double d) const;
+    const Matrix<double> & getPij_t    (double d) const;
+    const Matrix<double> & getdPij_dt  (double d) const;
+    const Matrix<double> & getd2Pij_dt2(double d) const;
 
     std::string getName() const { return "HKY85"; }
 
@@ -217,11 +211,11 @@ class HKY85:
    * @brief This method is redefined to actualize the corresponding parameters piA, piT, piG and piC too.
    */
   void setFreq(std::map<int, double>& freqs);
-	
+  
   void updateMatrices();
 };
 
 } //end of namespace bpp.
 
-#endif	//_HKY85_H_
+#endif  //_HKY85_H_
 
diff --git a/src/Bpp/Phyl/Model/Nucleotide/JCnuc.cpp b/src/Bpp/Phyl/Model/Nucleotide/JCnuc.cpp
index 061cd16..ab361b1 100644
--- a/src/Bpp/Phyl/Model/Nucleotide/JCnuc.cpp
+++ b/src/Bpp/Phyl/Model/Nucleotide/JCnuc.cpp
@@ -49,7 +49,7 @@ using namespace std;
 
 JCnuc::JCnuc(const NucleicAlphabet* alpha) :
   AbstractParameterAliasable("JC69."),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "JC69."),
+  AbstractReversibleNucleotideSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "JC69."),
   exp_(),
   p_(size_, size_)
 {
diff --git a/src/Bpp/Phyl/Model/Nucleotide/JCnuc.h b/src/Bpp/Phyl/Model/Nucleotide/JCnuc.h
index 8cfd5a0..2268521 100644
--- a/src/Bpp/Phyl/Model/Nucleotide/JCnuc.h
+++ b/src/Bpp/Phyl/Model/Nucleotide/JCnuc.h
@@ -127,8 +127,7 @@ namespace bpp
  * - Jukes TH and Cantor CR (1969), Evolution_ of proteins molecules_, 121-123, in Mammalian_ protein metabolism_.
  */
 class JCnuc :
-  public virtual NucleotideSubstitutionModel,
-  public AbstractReversibleSubstitutionModel
+  public AbstractReversibleNucleotideSubstitutionModel
 {
 private:
   mutable double exp_;
@@ -139,12 +138,7 @@ public:
 
   virtual ~JCnuc() {}
 
-#ifndef NO_VIRTUAL_COV
-  JCnuc*
-#else
-  Clonable*
-#endif
-  clone() const { return new JCnuc(*this); }
+  JCnuc* clone() const { return new JCnuc(*this); }
 
 public:
   double Pij_t    (size_t i, size_t j, double d) const;
diff --git a/src/Bpp/Phyl/Model/Nucleotide/K80.cpp b/src/Bpp/Phyl/Model/Nucleotide/K80.cpp
index 8cd163a..9b20eba 100755
--- a/src/Bpp/Phyl/Model/Nucleotide/K80.cpp
+++ b/src/Bpp/Phyl/Model/Nucleotide/K80.cpp
@@ -52,7 +52,7 @@ using namespace std;
 
 K80::K80(const NucleicAlphabet* alpha, double kappa) :
 AbstractParameterAliasable("K80."),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "K80."),
+  AbstractReversibleNucleotideSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "K80."),
   kappa_(kappa), r_(), l_(), k_(), exp1_(), exp2_(), p_(size_, size_)
 {
   addParameter_(new Parameter("K80.kappa", kappa, &Parameter::R_PLUS_STAR));
@@ -65,7 +65,7 @@ void K80::updateMatrices()
 {
   kappa_ = getParameterValue("kappa");
   k_ = (kappa_ + 1.) / 2.;
-  r_ = 4. / (kappa_ + 2.);
+  r_ = isScalable()?4. / (kappa_ + 2.):4;
 	
   // Frequences:
   freq_[0] = freq_[1] = freq_[2] = freq_[3] = 1. / 4.;
@@ -91,7 +91,7 @@ void K80::updateMatrices()
   generator_(3, 1) = kappa_;
 
   // Normalization:
-  MatrixTools::scale(generator_, r_/4);
+  setScale(r_/4);
 
   // Exchangeability:
   exchangeability_ = generator_;
diff --git a/src/Bpp/Phyl/Model/Nucleotide/K80.h b/src/Bpp/Phyl/Model/Nucleotide/K80.h
index a3ce6f0..39ba712 100755
--- a/src/Bpp/Phyl/Model/Nucleotide/K80.h
+++ b/src/Bpp/Phyl/Model/Nucleotide/K80.h
@@ -148,8 +148,7 @@ namespace bpp
    * - Kimura M (1980), Journal_ Of Molecular Evolution_ 16(2) 111-20. 
    */
   class K80:
-    public virtual NucleotideSubstitutionModel,
-    public AbstractReversibleSubstitutionModel
+    public AbstractReversibleNucleotideSubstitutionModel
   {
   private:
     double kappa_, r_;
@@ -161,12 +160,7 @@ namespace bpp
 
     virtual ~K80() {}
 
-#ifndef NO_VIRTUAL_COV
-    K80*
-#else
-    Clonable*
-#endif
-    clone() const { return new K80(*this); }
+    K80* clone() const { return new K80(*this); }
 
   public:
     double Pij_t    (size_t i, size_t j, double d) const;
diff --git a/src/Bpp/Phyl/Model/Nucleotide/L95.cpp b/src/Bpp/Phyl/Model/Nucleotide/L95.cpp
index cd8e53f..6d6daca 100755
--- a/src/Bpp/Phyl/Model/Nucleotide/L95.cpp
+++ b/src/Bpp/Phyl/Model/Nucleotide/L95.cpp
@@ -57,7 +57,7 @@ L95::L95(
 	const NucleicAlphabet* alphabet,
 	double alpha, double beta, double gamma, double kappa, double theta):
     AbstractParameterAliasable("L95."),
-    AbstractSubstitutionModel(alphabet, new CanonicalStateMap(alphabet, false), "L95."), alpha_(alpha), beta_(beta), gamma_(gamma), kappa_(kappa), theta_(theta)
+    AbstractNucleotideSubstitutionModel(alphabet, new CanonicalStateMap(alphabet, false), "L95."), alpha_(alpha), beta_(beta), gamma_(gamma), kappa_(kappa), theta_(theta)
 {
 
   addParameter_(new Parameter("L95.alpha", alpha, &Parameter::PROP_CONSTRAINT_IN));
@@ -102,7 +102,8 @@ void L95::updateMatrices()
   generator_(3,2) = kappa_* beta_ * theta_;
   generator_(3,3) = -kappa_ * theta_ - gamma_;
 
-  MatrixTools::scale(generator_, 1. / (2*kappa_*theta_*(1-theta_)+gamma_+theta_-2*theta_*gamma_));
+  setScale(1. / (2*kappa_*theta_*(1-theta_)+gamma_+theta_-2*theta_*gamma_));
+
   AbstractSubstitutionModel::updateMatrices();
 }
 
diff --git a/src/Bpp/Phyl/Model/Nucleotide/L95.h b/src/Bpp/Phyl/Model/Nucleotide/L95.h
index 1a598e3..fb01de1 100755
--- a/src/Bpp/Phyl/Model/Nucleotide/L95.h
+++ b/src/Bpp/Phyl/Model/Nucleotide/L95.h
@@ -91,8 +91,7 @@ namespace bpp
  * - Lobry J R (1995), Journal_ Of Molecular Evolution_ 40 326-330.
  */
 class L95:
-  public virtual NucleotideSubstitutionModel,
-  public AbstractSubstitutionModel
+  public AbstractNucleotideSubstitutionModel
 {
 private:
   double alpha_, beta_, gamma_, kappa_, theta_;
@@ -108,12 +107,7 @@ public:
   
   virtual ~L95() {}
   
-#ifndef NO_VIRTUAL_COV
-  L95*
-#else
-  Clonable*
-#endif
-  clone() const { return new L95(*this); }
+  L95* clone() const { return new L95(*this); }
   
 public:
   std::string getName() const { return "L95"; }
diff --git a/src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h b/src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h
index 897ed67..462cf8a 100755
--- a/src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h
@@ -41,8 +41,9 @@
 #define _NUCLEICSUBSTITUTIONMODEL_H_
 
 #include "../SubstitutionModel.h"
+#include "../AbstractSubstitutionModel.h"
 
-// From SeqLib:
+// From bpp-seq:
 #include <Bpp/Seq/Alphabet/NucleicAlphabet.h>
 
 namespace bpp
@@ -57,18 +58,84 @@ namespace bpp
   public:
     virtual ~NucleotideSubstitutionModel() {}
 
-#ifndef NO_VIRTUAL_COV
-    NucleotideSubstitutionModel*
-#else
-    Clonable*
-#endif
-    clone() const = 0;
+    NucleotideSubstitutionModel* clone() const = 0;
 
   public:
-    virtual size_t getNumberOfStates() const { return 4; }
+    size_t getNumberOfStates() const { return 4; }
+    
+    const NucleicAlphabet* getAlphabet() const = 0;
 
   };
 
+
+  
+/**
+ * @brief Specialisation interface for rversible nucleotide substitution model.
+ */
+  class NucleotideReversibleSubstitutionModel :
+    public virtual NucleotideSubstitutionModel,
+    public virtual ReversibleSubstitutionModel
+  {
+  public:
+    virtual ~NucleotideReversibleSubstitutionModel() {}
+
+    NucleotideReversibleSubstitutionModel* clone() const = 0;
+    
+    //size_t getNumberOfStates() const { return NucleotideSubstitutionModel::getNumberOfStates(); }
+
+  };
+
+
+
+/**
+ * @brief Specialisation abstract class for nucleotide substitution model.
+ */
+  class AbstractNucleotideSubstitutionModel :
+    public AbstractSubstitutionModel,
+    public virtual NucleotideSubstitutionModel
+  {
+  public:
+    AbstractNucleotideSubstitutionModel(const NucleicAlphabet* alpha, StateMap* stateMap, const std::string& prefix):
+      AbstractParameterAliasable(prefix),
+      AbstractSubstitutionModel(alpha, stateMap, prefix) {}
+
+    virtual ~AbstractNucleotideSubstitutionModel() {}
+    
+    AbstractNucleotideSubstitutionModel* clone() const = 0;
+
+  public:
+    
+    const NucleicAlphabet* getAlphabet() const {
+      return dynamic_cast<const NucleicAlphabet*>(alphabet_);
+    }
+    
+  };
+
+/**
+ * @brief Specialisation abstract class for reversible nucleotide substitution model.
+ */
+  class AbstractReversibleNucleotideSubstitutionModel :
+    public AbstractReversibleSubstitutionModel,
+    public virtual NucleotideSubstitutionModel
+  {
+  public:
+    AbstractReversibleNucleotideSubstitutionModel(const NucleicAlphabet* alpha, StateMap* stateMap, const std::string& prefix):
+      AbstractParameterAliasable(prefix),
+      AbstractReversibleSubstitutionModel(alpha, stateMap, prefix) {}
+
+    virtual ~AbstractReversibleNucleotideSubstitutionModel() {}
+    
+    AbstractReversibleNucleotideSubstitutionModel* clone() const = 0;
+    
+  public:
+    const NucleicAlphabet* getAlphabet() const {
+      return dynamic_cast<const NucleicAlphabet*>(alphabet_);
+    }
+
+  };
+
+
+
 } //end of namespace bpp.
 
 #endif	//_NUCLEICSUBSTITUTIONMODEL_H_
diff --git a/src/Bpp/Phyl/Model/Nucleotide/RN95.cpp b/src/Bpp/Phyl/Model/Nucleotide/RN95.cpp
index c96b6bc..01b58cf 100644
--- a/src/Bpp/Phyl/Model/Nucleotide/RN95.cpp
+++ b/src/Bpp/Phyl/Model/Nucleotide/RN95.cpp
@@ -63,7 +63,7 @@ RN95::RN95(
   double lambda,
   double sigma) :
   AbstractParameterAliasable("RN95."),
-  AbstractSubstitutionModel(alphabet, new CanonicalStateMap(alphabet, false), "RN95."),
+  AbstractNucleotideSubstitutionModel(alphabet, new CanonicalStateMap(alphabet, false), "RN95."),
   alpha_(),
   beta_(),
   gamma_(),
@@ -171,16 +171,16 @@ void RN95::updateMatrices()
   generator_(3, 3) = -(delta_ + sigma_ + kappa_);
 
   // Normalization
-
+  
   double x = 0;
   for (size_t i = 0; i < 4; i++)
   {
     x += generator_(i, i) * freq_[i];
   }
 
-  r_ = -1 / x;
+  r_ = isScalable()?-1 / x:1;
 
-  MatrixTools::scale(generator_, r_);
+  setScale(r_);
   // variables for calculation purposes
 
   c1_ = 1;
diff --git a/src/Bpp/Phyl/Model/Nucleotide/RN95.h b/src/Bpp/Phyl/Model/Nucleotide/RN95.h
index 52601e3..bcdae61 100644
--- a/src/Bpp/Phyl/Model/Nucleotide/RN95.h
+++ b/src/Bpp/Phyl/Model/Nucleotide/RN95.h
@@ -128,8 +128,7 @@ namespace bpp
  */
 
 class RN95 :
-  public virtual NucleotideSubstitutionModel,
-  public AbstractSubstitutionModel
+  public AbstractNucleotideSubstitutionModel
 {
 private:
   double alpha_, beta_, gamma_, delta_, epsilon_, kappa_, lambda_, sigma_;
@@ -155,12 +154,7 @@ public:
 
   virtual ~RN95() {}
 
-#ifndef NO_VIRTUAL_COV
-  RN95*
-#else
-  Clonable*
-#endif
-  clone() const { return new RN95(*this); }
+  RN95* clone() const { return new RN95(*this); }
 
 public:
   double Pij_t    (size_t i, size_t j, double d) const;
diff --git a/src/Bpp/Phyl/Model/Nucleotide/RN95s.cpp b/src/Bpp/Phyl/Model/Nucleotide/RN95s.cpp
index 61ac2a5..a0339ba 100644
--- a/src/Bpp/Phyl/Model/Nucleotide/RN95s.cpp
+++ b/src/Bpp/Phyl/Model/Nucleotide/RN95s.cpp
@@ -58,7 +58,7 @@ RN95s::RN95s(const NucleicAlphabet* alphabet,
              double gamma,
              double delta) :
   AbstractParameterAliasable("RN95s."),
-  AbstractSubstitutionModel(alphabet, new CanonicalStateMap(alphabet, false), "RN95s."),
+  AbstractNucleotideSubstitutionModel(alphabet, new CanonicalStateMap(alphabet, false), "RN95s."),
   alpha_(),
   beta_(),
   gamma_(),
@@ -138,9 +138,9 @@ void RN95s::updateMatrices()
     x += generator_(i, i) * freq_[i];
   }
 
-  r_ = -1 / x;
-
-  MatrixTools::scale(generator_, r_);
+  r_ = isScalable()?-1 / x:1;
+  
+  setScale(r_);
 
   // variables for calculation purposes
 
diff --git a/src/Bpp/Phyl/Model/Nucleotide/RN95s.h b/src/Bpp/Phyl/Model/Nucleotide/RN95s.h
index 149ac36..8ee9cf2 100644
--- a/src/Bpp/Phyl/Model/Nucleotide/RN95s.h
+++ b/src/Bpp/Phyl/Model/Nucleotide/RN95s.h
@@ -108,8 +108,7 @@ namespace bpp
  */
 
 class RN95s :
-  public virtual NucleotideSubstitutionModel,
-  public AbstractSubstitutionModel
+  public AbstractNucleotideSubstitutionModel
 {
 private:
   double alpha_, beta_, gamma_, delta_;
@@ -130,12 +129,7 @@ public:
 
   virtual ~RN95s() {}
 
-#ifndef NO_VIRTUAL_COV
-  RN95s*
-#else
-  Clonable*
-#endif
-  clone() const { return new RN95s(*this); }
+  RN95s* clone() const { return new RN95s(*this); }
 
 public:
   double Pij_t    (size_t i, size_t j, double d) const;
diff --git a/src/Bpp/Phyl/Model/Nucleotide/SSR.cpp b/src/Bpp/Phyl/Model/Nucleotide/SSR.cpp
index ef57ad9..42011ee 100755
--- a/src/Bpp/Phyl/Model/Nucleotide/SSR.cpp
+++ b/src/Bpp/Phyl/Model/Nucleotide/SSR.cpp
@@ -59,7 +59,7 @@ SSR::SSR(
   double delta,
   double theta):
   AbstractParameterAliasable("SSR."),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "SSR."),
+  AbstractReversibleNucleotideSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "SSR."),
   beta_(beta), gamma_(gamma), delta_(delta), theta_(theta),
   piA_((1. - theta) / 2.), piC_(theta / 2.), piG_(theta / 2.), piT_((1. - theta) / 2.)
 {
diff --git a/src/Bpp/Phyl/Model/Nucleotide/SSR.h b/src/Bpp/Phyl/Model/Nucleotide/SSR.h
index 78cd14d..2f24b39 100755
--- a/src/Bpp/Phyl/Model/Nucleotide/SSR.h
+++ b/src/Bpp/Phyl/Model/Nucleotide/SSR.h
@@ -91,13 +91,12 @@ namespace bpp
  * \endcode
  * for instance.
  * 
- * Reference:
- * - Hobolth A, Christensen O Fm Mailund T, Schierup M H (2007), PLoS_ Genetics_ 3(2) e7.
- * - Yap VB, Speed TP (1995), Journal_ Of Molecular Evolution_ 58(1) 12-18
+ * References:
+ * - Hobolth A, Christensen O Fm Mailund T, Schierup M H (2007), PLoS Genetics 3(2) e7.
+ * - Yap VB, Speed TP (2004), Journal Of Molecular Evolution 58(1) 12-18
  */
   class SSR:
-    public virtual NucleotideSubstitutionModel,
-    public AbstractReversibleSubstitutionModel
+    public AbstractReversibleNucleotideSubstitutionModel
   {
   private:
     double beta_, gamma_, delta_, theta_, piA_, piC_, piG_, piT_;
@@ -111,15 +110,10 @@ namespace bpp
   
     virtual ~SSR() {}
   
-#ifndef NO_VIRTUAL_COV
-    SSR*
-#else
-    Clonable*
-#endif
-    clone() const { return new SSR(*this); }
+    SSR* clone() const { return new SSR(*this); }
   
   public:
-    std::string getName() const { return "Strand Symmetric Reversible"; }
+    std::string getName() const { return "SSR"; }
   
     void updateMatrices();
   
diff --git a/src/Bpp/Phyl/Model/Nucleotide/T92.cpp b/src/Bpp/Phyl/Model/Nucleotide/T92.cpp
index f3a8cd0..eea13bb 100644
--- a/src/Bpp/Phyl/Model/Nucleotide/T92.cpp
+++ b/src/Bpp/Phyl/Model/Nucleotide/T92.cpp
@@ -56,7 +56,7 @@ using namespace std;
 
 T92::T92(const NucleicAlphabet* alpha, double kappa, double theta) :
   AbstractParameterAliasable("T92."),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "T92."),
+  AbstractReversibleNucleotideSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "T92."),
   kappa_(kappa),
   theta_(theta),
   k_(),
@@ -87,7 +87,8 @@ void T92::updateMatrices()
   piG_ = theta_ / 2;
   piT_ = (1 - theta_) / 2;
   k_ = (kappa_ + 1.) / 2.;
-  r_ = 2. / (1. + 2. * theta_ * kappa_ - 2. * theta_ * theta_ * kappa_);
+  r_ = isScalable()?2. / (1. + 2. * theta_ * kappa_ - 2. * theta_ * theta_ * kappa_):1;
+  
 
   freq_[0] = piA_;
   freq_[1] = piC_;
@@ -114,7 +115,7 @@ void T92::updateMatrices()
   generator_(1, 3) = kappa_ * (1. - theta_) / 2;
 
   // Normalization:
-  MatrixTools::scale(generator_, r_);
+  setScale(r_);
 
   // Exchangeability:
   exchangeability_(0, 0) = generator_(0, 0) * 2. / (1. - theta_);
diff --git a/src/Bpp/Phyl/Model/Nucleotide/T92.h b/src/Bpp/Phyl/Model/Nucleotide/T92.h
index 191dc1d..6b4c679 100644
--- a/src/Bpp/Phyl/Model/Nucleotide/T92.h
+++ b/src/Bpp/Phyl/Model/Nucleotide/T92.h
@@ -157,8 +157,7 @@ namespace bpp
  * - Tamura K (1992), Molecular_ Biology And Evolution_ 9(5) 814-25.
  */
 class T92 :
-  public virtual NucleotideSubstitutionModel,
-  public AbstractReversibleSubstitutionModel
+  public AbstractReversibleNucleotideSubstitutionModel
 {
 private:
   double kappa_, theta_, k_, r_, piA_, piC_, piG_, piT_;
@@ -170,12 +169,7 @@ public:
 
   virtual ~T92() {}
 
-#ifndef NOVIRTUAL_COV_
-  T92*
-#else
-  Clonable*
-#endif
-  clone() const { return new T92(*this); }
+  T92* clone() const { return new T92(*this); }
 
 public:
   double Pij_t    (size_t i, size_t j, double d) const;
diff --git a/src/Bpp/Phyl/Model/Nucleotide/TN93.cpp b/src/Bpp/Phyl/Model/Nucleotide/TN93.cpp
index 7878d97..11753e6 100755
--- a/src/Bpp/Phyl/Model/Nucleotide/TN93.cpp
+++ b/src/Bpp/Phyl/Model/Nucleotide/TN93.cpp
@@ -56,160 +56,161 @@ using namespace bpp;
 /******************************************************************************/
 
 TN93::TN93(
-	const NucleicAlphabet* alpha,
-	double kappa1,
-	double kappa2,
-	double piA,
-	double piC,
-	double piG,
-	double piT):
+  const NucleicAlphabet* alpha,
+  double kappa1,
+  double kappa2,
+  double piA,
+  double piC,
+  double piG,
+  double piT):
   AbstractParameterAliasable("TN93."),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "TN93."),
+  AbstractReversibleNucleotideSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "TN93."),
   kappa1_(kappa1), kappa2_(kappa2), 
   piA_(piA), piC_(piC), piG_(piG), piT_(piT), piY_(), piR_(),
   r_(), k1_(), k2_(),
   theta_(piG + piC), theta1_(piA / (1. - theta_)), theta2_(piG / theta_),
   exp1_(), exp21_(), exp22_(), l_(), p_(size_, size_)
 {
-	addParameter_(new Parameter("TN93.kappa1", kappa1, &Parameter::R_PLUS_STAR));
-	addParameter_(new Parameter("TN93.kappa2", kappa2, &Parameter::R_PLUS_STAR));
-	addParameter_(new Parameter("TN93.theta" , theta_ , &FrequenciesSet::FREQUENCE_CONSTRAINT_SMALL));
-	addParameter_(new Parameter("TN93.theta1", theta1_, &FrequenciesSet::FREQUENCE_CONSTRAINT_SMALL));
-	addParameter_(new Parameter("TN93.theta2", theta2_, &FrequenciesSet::FREQUENCE_CONSTRAINT_SMALL));
+  addParameter_(new Parameter("TN93.kappa1", kappa1, &Parameter::R_PLUS_STAR));
+  addParameter_(new Parameter("TN93.kappa2", kappa2, &Parameter::R_PLUS_STAR));
+  addParameter_(new Parameter("TN93.theta" , theta_ , &FrequenciesSet::FREQUENCE_CONSTRAINT_SMALL));
+  addParameter_(new Parameter("TN93.theta1", theta1_, &FrequenciesSet::FREQUENCE_CONSTRAINT_SMALL));
+  addParameter_(new Parameter("TN93.theta2", theta2_, &FrequenciesSet::FREQUENCE_CONSTRAINT_SMALL));
   p_.resize(size_, size_);
-	updateMatrices();
+  updateMatrices();
 }
 
 /******************************************************************************/
 
 void TN93::updateMatrices()
 {
-	kappa1_ = getParameterValue("kappa1");
-	kappa2_ = getParameterValue("kappa2");
+  kappa1_ = getParameterValue("kappa1");
+  kappa2_ = getParameterValue("kappa2");
   theta_  = getParameterValue("theta" );
-	theta1_ = getParameterValue("theta1");
-	theta2_ = getParameterValue("theta2");
+  theta1_ = getParameterValue("theta1");
+  theta2_ = getParameterValue("theta2");
   piA_ = theta1_ * (1. - theta_);
   piC_ = (1. - theta2_) * theta_;
   piG_ = theta2_ * theta_;
   piT_ = (1. - theta1_) * (1. - theta_);
-	piR_ = piA_ + piG_;
-	piY_ = piT_ + piC_;
-	r_ = 1. / (2. * (piA_ * piC_ + piC_ * piG_ + piA_ * piT_ + piG_ * piT_ + kappa2_ * piC_ * piT_ + kappa1_ * piA_ * piG_));
-	k1_ = kappa2_ * piY_ + piR_;
-	k2_ = kappa1_ * piR_ + piY_;
+  piR_ = piA_ + piG_;
+  piY_ = piT_ + piC_;
+  r_ = isScalable()?1. / (2. * (piA_ * piC_ + piC_ * piG_ + piA_ * piT_ + piG_ * piT_ + kappa2_ * piC_ * piT_ + kappa1_ * piA_ * piG_)):1;
+  
+  k1_ = kappa2_ * piY_ + piR_;
+  k2_ = kappa1_ * piR_ + piY_;
 
   freq_[0] = piA_;
   freq_[1] = piC_;
   freq_[2] = piG_;
   freq_[3] = piT_;
-		
-	generator_(0, 0) = -(                       piC_ + kappa1_*piG_ +         piT_);
-	generator_(1, 1) = -(        piA_ +                        piG_ + kappa2_*piT_); 
-	generator_(2, 2) = -(kappa1_*piA_ +         piC_                +         piT_);
-	generator_(3, 3) = -(        piA_ + kappa2_*piC_ +         piG_               );
-
-	generator_(1, 0) = piA_;
-	generator_(3, 0) = piA_;
-	generator_(0, 1) = piC_;
-	generator_(2, 1) = piC_;
-	generator_(1, 2) = piG_;
-	generator_(3, 2) = piG_;
-	generator_(0, 3) = piT_;
-	generator_(2, 3) = piT_;
-	
-	generator_(2, 0) = kappa1_ * piA_;
-	generator_(3, 1) = kappa2_ * piC_;
-	generator_(0, 2) = kappa1_ * piG_;
-	generator_(1, 3) = kappa2_ * piT_;
-	
-	// Normalization:
-	MatrixTools::scale(generator_, r_);
-	
-	// Exchangeability:
-	exchangeability_(0,0) = generator_(0,0) / piA_;
-	exchangeability_(0,1) = generator_(0,1) / piC_; 
-	exchangeability_(0,2) = generator_(0,2) / piG_; 
-	exchangeability_(0,3) = generator_(0,3) / piT_;
-
-	exchangeability_(1,0) = generator_(1,0) / piA_; 
-	exchangeability_(1,1) = generator_(1,1) / piC_; 
-	exchangeability_(1,2) = generator_(1,2) / piG_; 
-	exchangeability_(1,3) = generator_(1,3) / piT_; 
-	
-	exchangeability_(2,0) = generator_(2,0) / piA_; 
-	exchangeability_(2,1) = generator_(2,1) / piC_; 
-	exchangeability_(2,2) = generator_(2,2) / piG_; 
-	exchangeability_(2,3) = generator_(2,3) / piT_; 
-	
-	exchangeability_(3,0) = generator_(3,0) / piA_;
-	exchangeability_(3,1) = generator_(3,1) / piC_; 
-	exchangeability_(3,2) = generator_(3,2) / piG_; 
-	exchangeability_(3,3) = generator_(3,3) / piT_;
-
-	// We are not sure that the values are computed in this order :p
-	// Eigen values:
-	//eigenValues_[0] = 0;
-	//eigenValues_[1] = -r * (kappa2 * piY + piR);
-	//eigenValues_[2] = -r * (kappa1 * piR + piY); 
-	//eigenValues_[3] = -r;
-	
-	// Eigen vectors and values:
-	EigenValue<double> ev(generator_);
-	rightEigenVectors_ = ev.getV();
-	MatrixTools::inv(rightEigenVectors_, leftEigenVectors_);
-	eigenValues_ = ev.getRealEigenValues();
+    
+  generator_(0, 0) = -(                       piC_ + kappa1_*piG_ +         piT_);
+  generator_(1, 1) = -(        piA_ +                        piG_ + kappa2_*piT_); 
+  generator_(2, 2) = -(kappa1_*piA_ +         piC_                +         piT_);
+  generator_(3, 3) = -(        piA_ + kappa2_*piC_ +         piG_               );
+
+  generator_(1, 0) = piA_;
+  generator_(3, 0) = piA_;
+  generator_(0, 1) = piC_;
+  generator_(2, 1) = piC_;
+  generator_(1, 2) = piG_;
+  generator_(3, 2) = piG_;
+  generator_(0, 3) = piT_;
+  generator_(2, 3) = piT_;
+  
+  generator_(2, 0) = kappa1_ * piA_;
+  generator_(3, 1) = kappa2_ * piC_;
+  generator_(0, 2) = kappa1_ * piG_;
+  generator_(1, 3) = kappa2_ * piT_;
+  
+  // Normalization:
+  setScale(r_);
+  
+  // Exchangeability:
+  exchangeability_(0,0) = generator_(0,0) / piA_;
+  exchangeability_(0,1) = generator_(0,1) / piC_; 
+  exchangeability_(0,2) = generator_(0,2) / piG_; 
+  exchangeability_(0,3) = generator_(0,3) / piT_;
+
+  exchangeability_(1,0) = generator_(1,0) / piA_; 
+  exchangeability_(1,1) = generator_(1,1) / piC_; 
+  exchangeability_(1,2) = generator_(1,2) / piG_; 
+  exchangeability_(1,3) = generator_(1,3) / piT_; 
+  
+  exchangeability_(2,0) = generator_(2,0) / piA_; 
+  exchangeability_(2,1) = generator_(2,1) / piC_; 
+  exchangeability_(2,2) = generator_(2,2) / piG_; 
+  exchangeability_(2,3) = generator_(2,3) / piT_; 
+  
+  exchangeability_(3,0) = generator_(3,0) / piA_;
+  exchangeability_(3,1) = generator_(3,1) / piC_; 
+  exchangeability_(3,2) = generator_(3,2) / piG_; 
+  exchangeability_(3,3) = generator_(3,3) / piT_;
+
+  // We are not sure that the values are computed in this order :p
+  // Eigen values:
+  //eigenValues_[0] = 0;
+  //eigenValues_[1] = -r * (kappa2 * piY + piR);
+  //eigenValues_[2] = -r * (kappa1 * piR + piY); 
+  //eigenValues_[3] = -r;
+  
+  // Eigen vectors and values:
+  EigenValue<double> ev(generator_);
+  rightEigenVectors_ = ev.getV();
+  MatrixTools::inv(rightEigenVectors_, leftEigenVectors_);
+  eigenValues_ = ev.getRealEigenValues();
 }
-	
+  
 /******************************************************************************/
 
 double TN93::Pij_t(size_t i, size_t j, double d) const
 {
   l_ = rate_ * r_ * d;
-	exp1_ = exp(-l_);
-	exp22_ = exp(-k2_ * l_);
-	exp21_ = exp(-k1_ * l_);
-	
-	switch(i)
+  exp1_ = exp(-l_);
+  exp22_ = exp(-k2_ * l_);
+  exp21_ = exp(-k1_ * l_);
+  
+  switch(i)
   {
-		//A
-		case 0 : {
-			switch(j) {
-				case 0 : return piA_ * (1. + (piY_/piR_) * exp1_) + (piG_/piR_) * exp22_; //A
-				case 1 : return piC_ * (1. -               exp1_);                        //C
-				case 2 : return piG_ * (1. + (piY_/piR_) * exp1_) - (piG_/piR_) * exp22_; //G
-				case 3 : return piT_ * (1. -               exp1_);                        //T, U
-			}
-		} 
-		//C
-		case 1 : {
-			switch(j) {
-				case 0 : return piA_ * (1. -               exp1_);                         //A
-				case 1 : return piC_ * (1. + (piR_/piY_) * exp1_) + (piT_/piY_) * exp21_; //C
-				case 2 : return piG_ * (1. -               exp1_);                        //G
-				case 3 : return piT_ * (1. + (piR_/piY_) * exp1_) - (piT_/piY_) * exp21_; //T, U
-			}
-		}
-		//G
-		case 2 : {
-			switch(j) {
-				case 0 : return piA_ * (1. + (piY_/piR_) * exp1_) - (piA_/piR_) * exp22_; //A
-				case 1 : return piC_ * (1. -               exp1_);                        //C
-				case 2 : return piG_ * (1. + (piY_/piR_) * exp1_) + (piA_/piR_) * exp22_; //G
-				case 3 : return piT_ * (1. -               exp1_);                        //T, U
-			}
-		}
-		//T, U
-		case 3 : {
-			switch(j) {
-				case 0 : return piA_ * (1. -               exp1_);                        //A
-				case 1 : return piC_ * (1. + (piR_/piY_) * exp1_) - (piC_/piY_) * exp21_; //C
-				case 2 : return piG_ * (1. -               exp1_);                        //G
-				case 3 : return piT_ * (1. + (piR_/piY_) * exp1_) + (piC_/piY_) * exp21_; //T, U
-			}
-		}
-	}
-	return 0;
+    //A
+    case 0 : {
+      switch(j) {
+        case 0 : return piA_ * (1. + (piY_/piR_) * exp1_) + (piG_/piR_) * exp22_; //A
+        case 1 : return piC_ * (1. -               exp1_);                        //C
+        case 2 : return piG_ * (1. + (piY_/piR_) * exp1_) - (piG_/piR_) * exp22_; //G
+        case 3 : return piT_ * (1. -               exp1_);                        //T, U
+      }
+    } 
+    //C
+    case 1 : {
+      switch(j) {
+        case 0 : return piA_ * (1. -               exp1_);                         //A
+        case 1 : return piC_ * (1. + (piR_/piY_) * exp1_) + (piT_/piY_) * exp21_; //C
+        case 2 : return piG_ * (1. -               exp1_);                        //G
+        case 3 : return piT_ * (1. + (piR_/piY_) * exp1_) - (piT_/piY_) * exp21_; //T, U
+      }
+    }
+    //G
+    case 2 : {
+      switch(j) {
+        case 0 : return piA_ * (1. + (piY_/piR_) * exp1_) - (piA_/piR_) * exp22_; //A
+        case 1 : return piC_ * (1. -               exp1_);                        //C
+        case 2 : return piG_ * (1. + (piY_/piR_) * exp1_) + (piA_/piR_) * exp22_; //G
+        case 3 : return piT_ * (1. -               exp1_);                        //T, U
+      }
+    }
+    //T, U
+    case 3 : {
+      switch(j) {
+        case 0 : return piA_ * (1. -               exp1_);                        //A
+        case 1 : return piC_ * (1. + (piR_/piY_) * exp1_) - (piC_/piY_) * exp21_; //C
+        case 2 : return piG_ * (1. -               exp1_);                        //G
+        case 3 : return piT_ * (1. + (piR_/piY_) * exp1_) + (piC_/piY_) * exp21_; //T, U
+      }
+    }
+  }
+  return 0;
 }
 
 /******************************************************************************/
@@ -217,50 +218,50 @@ double TN93::Pij_t(size_t i, size_t j, double d) const
 double TN93::dPij_dt(size_t i, size_t j, double d) const
 {
   l_ = rate_ * r_ * d;
-	exp1_ = exp(-l_);
-	exp22_ = exp(-k2_ * l_);
-	exp21_ = exp(-k1_ * l_);
-	
-	switch(i)
+  exp1_ = exp(-l_);
+  exp22_ = exp(-k2_ * l_);
+  exp21_ = exp(-k1_ * l_);
+  
+  switch(i)
   {
-		//A
-		case 0 : {
-			switch(j) {
-				case 0 : return rate_ * r_ * (piA_ * -(piY_/piR_) * exp1_ - (piG_/piR_) * k2_ * exp22_); //A
-				case 1 : return rate_ * r_ * (piC_ *                exp1_);                              //C
-				case 2 : return rate_ * r_ * (piG_ * -(piY_/piR_) * exp1_ + (piG_/piR_) * k2_ * exp22_); //G
-				case 3 : return rate_ * r_ * (piT_ *                exp1_);                              //T, U
-			}
-		} 
-		//C
-		case 1 : {
-			switch(j) {
-				case 0 : return rate_ * r_ * (piA_ *                exp1_);                              //A
-				case 1 : return rate_ * r_ * (piC_ * -(piR_/piY_) * exp1_ - (piT_/piY_) * k1_ * exp21_); //C
-				case 2 : return rate_ * r_ * (piG_ *                exp1_);                              //G
-				case 3 : return rate_ * r_ * (piT_ * -(piR_/piY_) * exp1_ + (piT_/piY_) * k1_ * exp21_); //T, U
-			}
-		}
-		//G
-		case 2 : {
-			switch(j) {
-				case 0 : return rate_ * r_ * (piA_ * -(piY_/piR_) * exp1_ + (piA_/piR_) * k2_ * exp22_); //A
-				case 1 : return rate_ * r_ * (piC_ *                exp1_);                              //C
-				case 2 : return rate_ * r_ * (piG_ * -(piY_/piR_) * exp1_ - (piA_/piR_) * k2_ * exp22_); //G
-				case 3 : return rate_ * r_ * (piT_ *                exp1_);                              //T, U
-			}
-		}
-		//T, U
-		case 3 : {
-			switch(j) {
-				case 0 : return rate_ * r_ * (piA_ *                exp1_);                              //A
-				case 1 : return rate_ * r_ * (piC_ * -(piR_/piY_) * exp1_ + (piC_/piY_) * k1_ * exp21_); //C
-				case 2 : return rate_ * r_ * (piG_ *                exp1_);                              //G
-				case 3 : return rate_ * r_ * (piT_ * -(piR_/piY_) * exp1_ - (piC_/piY_) * k1_ * exp21_); //T, U
-			}
-		}
-	}
-	return 0;
+    //A
+    case 0 : {
+      switch(j) {
+        case 0 : return rate_ * r_ * (piA_ * -(piY_/piR_) * exp1_ - (piG_/piR_) * k2_ * exp22_); //A
+        case 1 : return rate_ * r_ * (piC_ *                exp1_);                              //C
+        case 2 : return rate_ * r_ * (piG_ * -(piY_/piR_) * exp1_ + (piG_/piR_) * k2_ * exp22_); //G
+        case 3 : return rate_ * r_ * (piT_ *                exp1_);                              //T, U
+      }
+    } 
+    //C
+    case 1 : {
+      switch(j) {
+        case 0 : return rate_ * r_ * (piA_ *                exp1_);                              //A
+        case 1 : return rate_ * r_ * (piC_ * -(piR_/piY_) * exp1_ - (piT_/piY_) * k1_ * exp21_); //C
+        case 2 : return rate_ * r_ * (piG_ *                exp1_);                              //G
+        case 3 : return rate_ * r_ * (piT_ * -(piR_/piY_) * exp1_ + (piT_/piY_) * k1_ * exp21_); //T, U
+      }
+    }
+    //G
+    case 2 : {
+      switch(j) {
+        case 0 : return rate_ * r_ * (piA_ * -(piY_/piR_) * exp1_ + (piA_/piR_) * k2_ * exp22_); //A
+        case 1 : return rate_ * r_ * (piC_ *                exp1_);                              //C
+        case 2 : return rate_ * r_ * (piG_ * -(piY_/piR_) * exp1_ - (piA_/piR_) * k2_ * exp22_); //G
+        case 3 : return rate_ * r_ * (piT_ *                exp1_);                              //T, U
+      }
+    }
+    //T, U
+    case 3 : {
+      switch(j) {
+        case 0 : return rate_ * r_ * (piA_ *                exp1_);                              //A
+        case 1 : return rate_ * r_ * (piC_ * -(piR_/piY_) * exp1_ + (piC_/piY_) * k1_ * exp21_); //C
+        case 2 : return rate_ * r_ * (piG_ *                exp1_);                              //G
+        case 3 : return rate_ * r_ * (piT_ * -(piR_/piY_) * exp1_ - (piC_/piY_) * k1_ * exp21_); //T, U
+      }
+    }
+  }
+  return 0;
 }
 
 /******************************************************************************/
@@ -269,52 +270,52 @@ double TN93::d2Pij_dt2(size_t i, size_t j, double d) const
 {
   double r_2 = rate_ * rate_ * r_ * r_;
   l_ = rate_ * r_ * d;
-	double k1_2 = k1_ * k1_;
-	double k2_2 = k2_ * k2_;
-	exp1_ = exp(-l_);
-	exp22_ = exp(-k2_ * l_);
-	exp21_ = exp(-k1_ * l_);
+  double k1_2 = k1_ * k1_;
+  double k2_2 = k2_ * k2_;
+  exp1_ = exp(-l_);
+  exp22_ = exp(-k2_ * l_);
+  exp21_ = exp(-k1_ * l_);
 
-	switch(i)
+  switch(i)
   {
-		//A
-		case 0 : {
-			switch(j) {
-				case 0 : return r_2 * (piA_ * (piY_/piR_) * exp1_ + (piG_/piR_) * k2_2 * exp22_); //A
-				case 1 : return r_2 * (piC_ *             - exp1_);                               //C
-				case 2 : return r_2 * (piG_ * (piY_/piR_) * exp1_ - (piG_/piR_) * k2_2 * exp22_); //G
-				case 3 : return r_2 * (piT_ *             - exp1_);                               //T, U
-			}
-		}
-		//C
-		case 1 : {
-			switch(j) {
-				case 0 : return r_2 * (piA_ *             - exp1_);                               //A
-				case 1 : return r_2 * (piC_ * (piR_/piY_) * exp1_ + (piT_/piY_) * k1_2 * exp21_); //C
-				case 2 : return r_2 * (piG_ *             - exp1_);                               //G
-				case 3 : return r_2 * (piT_ * (piR_/piY_) * exp1_ - (piT_/piY_) * k1_2 * exp21_); //T, U
-			}
-		}
-		//G
-		case 2 : {
-			switch(j) {
-				case 0 : return r_2 * (piA_ * (piY_/piR_) * exp1_ - (piA_/piR_) * k2_2 * exp22_); //A
-				case 1 : return r_2 * (piC_ *             - exp1_);                               //C
-				case 2 : return r_2 * (piG_ * (piY_/piR_) * exp1_ + (piA_/piR_) * k2_2 * exp22_); //G
-				case 3 : return r_2 * (piT_ *             - exp1_);                               //T, U
-			}
-		}
-		//T, U
-		case 3 : {
-			switch(j) {
-				case 0 : return r_2 * (piA_ *             - exp1_);                               //A
-				case 1 : return r_2 * (piC_ * (piR_/piY_) * exp1_ - (piC_/piY_) * k1_2 * exp21_); //C
-				case 2 : return r_2 * (piG_ *             - exp1_);                               //G
-				case 3 : return r_2 * (piT_ * (piR_/piY_) * exp1_ + (piC_/piY_) * k1_2 * exp21_); //T, U
-			}
-		}
-	}
-	return 0;
+    //A
+    case 0 : {
+      switch(j) {
+        case 0 : return r_2 * (piA_ * (piY_/piR_) * exp1_ + (piG_/piR_) * k2_2 * exp22_); //A
+        case 1 : return r_2 * (piC_ *             - exp1_);                               //C
+        case 2 : return r_2 * (piG_ * (piY_/piR_) * exp1_ - (piG_/piR_) * k2_2 * exp22_); //G
+        case 3 : return r_2 * (piT_ *             - exp1_);                               //T, U
+      }
+    }
+    //C
+    case 1 : {
+      switch(j) {
+        case 0 : return r_2 * (piA_ *             - exp1_);                               //A
+        case 1 : return r_2 * (piC_ * (piR_/piY_) * exp1_ + (piT_/piY_) * k1_2 * exp21_); //C
+        case 2 : return r_2 * (piG_ *             - exp1_);                               //G
+        case 3 : return r_2 * (piT_ * (piR_/piY_) * exp1_ - (piT_/piY_) * k1_2 * exp21_); //T, U
+      }
+    }
+    //G
+    case 2 : {
+      switch(j) {
+        case 0 : return r_2 * (piA_ * (piY_/piR_) * exp1_ - (piA_/piR_) * k2_2 * exp22_); //A
+        case 1 : return r_2 * (piC_ *             - exp1_);                               //C
+        case 2 : return r_2 * (piG_ * (piY_/piR_) * exp1_ + (piA_/piR_) * k2_2 * exp22_); //G
+        case 3 : return r_2 * (piT_ *             - exp1_);                               //T, U
+      }
+    }
+    //T, U
+    case 3 : {
+      switch(j) {
+        case 0 : return r_2 * (piA_ *             - exp1_);                               //A
+        case 1 : return r_2 * (piC_ * (piR_/piY_) * exp1_ - (piC_/piY_) * k1_2 * exp21_); //C
+        case 2 : return r_2 * (piG_ *             - exp1_);                               //G
+        case 3 : return r_2 * (piT_ * (piR_/piY_) * exp1_ + (piC_/piY_) * k1_2 * exp21_); //T, U
+      }
+    }
+  }
+  return 0;
 }
 
 /******************************************************************************/
@@ -322,106 +323,106 @@ double TN93::d2Pij_dt2(size_t i, size_t j, double d) const
 const Matrix<double> & TN93::getPij_t(double d) const
 {
   l_ = rate_ * r_ * d;
-	exp1_ = exp(-l_);
-	exp22_ = exp(-k2_ * l_);
-	exp21_ = exp(-k1_ * l_);
-
-	//A
-	p_(0, 0) = piA_ * (1. + (piY_/piR_) * exp1_) + (piG_/piR_) * exp22_; //A
-	p_(0, 1) = piC_ * (1. -               exp1_);                        //C
-	p_(0, 2) = piG_ * (1. + (piY_/piR_) * exp1_) - (piG_/piR_) * exp22_; //G
-	p_(0, 3) = piT_ * (1. -               exp1_);                        //T, U
-
-	//C
-	p_(1, 0) = piA_ * (1. -               exp1_);                        //A
-	p_(1, 1) = piC_ * (1. + (piR_/piY_) * exp1_) + (piT_/piY_) * exp21_; //C
-	p_(1, 2) = piG_ * (1. -               exp1_);                        //G
-	p_(1, 3) = piT_ * (1. + (piR_/piY_) * exp1_) - (piT_/piY_) * exp21_; //T, U
-
-	//G
-	p_(2, 0) = piA_ * (1. + (piY_/piR_) * exp1_) - (piA_/piR_) * exp22_; //A
-	p_(2, 1) = piC_ * (1. -               exp1_);                        //C
-	p_(2, 2) = piG_ * (1. + (piY_/piR_) * exp1_) + (piA_/piR_) * exp22_; //G
-	p_(2, 3) = piT_ * (1. -               exp1_);                        //T, U
-
-	//T, U
-	p_(3, 0) = piA_ * (1. -               exp1_);                        //A
-	p_(3, 1) = piC_ * (1. + (piR_/piY_) * exp1_) - (piC_/piY_) * exp21_; //C
-	p_(3, 2) = piG_ * (1. -               exp1_);                        //G
-	p_(3, 3) = piT_ * (1. + (piR_/piY_) * exp1_) + (piC_/piY_) * exp21_; //T, U
-
-	return p_;
+  exp1_ = exp(-l_);
+  exp22_ = exp(-k2_ * l_);
+  exp21_ = exp(-k1_ * l_);
+
+  //A
+  p_(0, 0) = piA_ * (1. + (piY_/piR_) * exp1_) + (piG_/piR_) * exp22_; //A
+  p_(0, 1) = piC_ * (1. -               exp1_);                        //C
+  p_(0, 2) = piG_ * (1. + (piY_/piR_) * exp1_) - (piG_/piR_) * exp22_; //G
+  p_(0, 3) = piT_ * (1. -               exp1_);                        //T, U
+
+  //C
+  p_(1, 0) = piA_ * (1. -               exp1_);                        //A
+  p_(1, 1) = piC_ * (1. + (piR_/piY_) * exp1_) + (piT_/piY_) * exp21_; //C
+  p_(1, 2) = piG_ * (1. -               exp1_);                        //G
+  p_(1, 3) = piT_ * (1. + (piR_/piY_) * exp1_) - (piT_/piY_) * exp21_; //T, U
+
+  //G
+  p_(2, 0) = piA_ * (1. + (piY_/piR_) * exp1_) - (piA_/piR_) * exp22_; //A
+  p_(2, 1) = piC_ * (1. -               exp1_);                        //C
+  p_(2, 2) = piG_ * (1. + (piY_/piR_) * exp1_) + (piA_/piR_) * exp22_; //G
+  p_(2, 3) = piT_ * (1. -               exp1_);                        //T, U
+
+  //T, U
+  p_(3, 0) = piA_ * (1. -               exp1_);                        //A
+  p_(3, 1) = piC_ * (1. + (piR_/piY_) * exp1_) - (piC_/piY_) * exp21_; //C
+  p_(3, 2) = piG_ * (1. -               exp1_);                        //G
+  p_(3, 3) = piT_ * (1. + (piR_/piY_) * exp1_) + (piC_/piY_) * exp21_; //T, U
+
+  return p_;
 }
 
 const Matrix<double> & TN93::getdPij_dt(double d) const
 {
   l_ = rate_ * r_ * d;
-	exp1_ = exp(-l_);
-	exp22_ = exp(-k2_ * l_);
-	exp21_ = exp(-k1_ * l_);
-
-	//A
-	p_(0, 0) = rate_ * r_ * (piA_ * -(piY_/piR_) * exp1_ - (piG_/piR_) * k2_ * exp22_); //A
-	p_(0, 1) = rate_ * r_ * (piC_ *                exp1_);                              //C
-	p_(0, 2) = rate_ * r_ * (piG_ * -(piY_/piR_) * exp1_ + (piG_/piR_) * k2_ * exp22_); //G
-	p_(0, 3) = rate_ * r_ * (piT_ *                exp1_);                              //T, U
-
-	//C
-	p_(1, 0) = rate_ * r_ * (piA_ *                exp1_);                              //A
-	p_(1, 1) = rate_ * r_ * (piC_ * -(piR_/piY_) * exp1_ - (piT_/piY_) * k1_ * exp21_); //C
-	p_(1, 2) = rate_ * r_ * (piG_ *                exp1_);                              //G
-	p_(1, 3) = rate_ * r_ * (piT_ * -(piR_/piY_) * exp1_ + (piT_/piY_) * k1_ * exp21_); //T, U
-
-	//G
-	p_(2, 0) = rate_ * r_ * (piA_ * -(piY_/piR_) * exp1_ + (piA_/piR_) * k2_ * exp22_); //A
-	p_(2, 1) = rate_ * r_ * (piC_ *                exp1_);                              //C
-	p_(2, 2) = rate_ * r_ * (piG_ * -(piY_/piR_) * exp1_ - (piA_/piR_) * k2_ * exp22_); //G
-	p_(2, 3) = rate_ * r_ * (piT_ *                exp1_);                              //T, U
-
-	//T, U
-	p_(3, 0) = rate_ * r_ * (piA_ *                exp1_);                              //A
-	p_(3, 1) = rate_ * r_ * (piC_ * -(piR_/piY_) * exp1_ + (piC_/piY_) * k1_ * exp21_); //C
-	p_(3, 2) = rate_ * r_ * (piG_ *                exp1_);                              //G
-	p_(3, 3) = rate_ * r_ * (piT_ * -(piR_/piY_) * exp1_ - (piC_/piY_) * k1_ * exp21_); //T, U
-
-	return p_;
+  exp1_ = exp(-l_);
+  exp22_ = exp(-k2_ * l_);
+  exp21_ = exp(-k1_ * l_);
+
+  //A
+  p_(0, 0) = rate_ * r_ * (piA_ * -(piY_/piR_) * exp1_ - (piG_/piR_) * k2_ * exp22_); //A
+  p_(0, 1) = rate_ * r_ * (piC_ *                exp1_);                              //C
+  p_(0, 2) = rate_ * r_ * (piG_ * -(piY_/piR_) * exp1_ + (piG_/piR_) * k2_ * exp22_); //G
+  p_(0, 3) = rate_ * r_ * (piT_ *                exp1_);                              //T, U
+
+  //C
+  p_(1, 0) = rate_ * r_ * (piA_ *                exp1_);                              //A
+  p_(1, 1) = rate_ * r_ * (piC_ * -(piR_/piY_) * exp1_ - (piT_/piY_) * k1_ * exp21_); //C
+  p_(1, 2) = rate_ * r_ * (piG_ *                exp1_);                              //G
+  p_(1, 3) = rate_ * r_ * (piT_ * -(piR_/piY_) * exp1_ + (piT_/piY_) * k1_ * exp21_); //T, U
+
+  //G
+  p_(2, 0) = rate_ * r_ * (piA_ * -(piY_/piR_) * exp1_ + (piA_/piR_) * k2_ * exp22_); //A
+  p_(2, 1) = rate_ * r_ * (piC_ *                exp1_);                              //C
+  p_(2, 2) = rate_ * r_ * (piG_ * -(piY_/piR_) * exp1_ - (piA_/piR_) * k2_ * exp22_); //G
+  p_(2, 3) = rate_ * r_ * (piT_ *                exp1_);                              //T, U
+
+  //T, U
+  p_(3, 0) = rate_ * r_ * (piA_ *                exp1_);                              //A
+  p_(3, 1) = rate_ * r_ * (piC_ * -(piR_/piY_) * exp1_ + (piC_/piY_) * k1_ * exp21_); //C
+  p_(3, 2) = rate_ * r_ * (piG_ *                exp1_);                              //G
+  p_(3, 3) = rate_ * r_ * (piT_ * -(piR_/piY_) * exp1_ - (piC_/piY_) * k1_ * exp21_); //T, U
+
+  return p_;
 }
 
 const Matrix<double> & TN93::getd2Pij_dt2(double d) const
 {
   double r_2 = rate_ * rate_ * r_ * r_;
   l_ = rate_ * r_ * d;
-	double k1_2 = k1_ * k1_;
-	double k2_2 = k2_ * k2_;
-	exp1_ = exp(-l_);
-	exp22_ = exp(-k2_ * l_);
-	exp21_ = exp(-k1_ * l_);
-
-	//A
-	p_(0, 0) = r_2 * (piA_ * (piY_/piR_) * exp1_ + (piG_/piR_) * k2_2 * exp22_); //A
-	p_(0, 1) = r_2 * (piC_ *             - exp1_);                               //C
-	p_(0, 2) = r_2 * (piG_ * (piY_/piR_) * exp1_ - (piG_/piR_) * k2_2 * exp22_); //G
-	p_(0, 3) = r_2 * (piT_ *             - exp1_);                               //T, U
-
-	//C
-	p_(1, 0) = r_2 * (piA_ *             - exp1_);                               //A
-	p_(1, 1) = r_2 * (piC_ * (piR_/piY_) * exp1_ + (piT_/piY_) * k1_2 * exp21_); //C
-	p_(1, 2) = r_2 * (piG_ *             - exp1_);                               //G
-	p_(1, 3) = r_2 * (piT_ * (piR_/piY_) * exp1_ - (piT_/piY_) * k1_2 * exp21_); //T, U
-
-	//G
-	p_(2, 0) = r_2 * (piA_ * (piY_/piR_) * exp1_ - (piA_/piR_) * k2_2 * exp22_); //A
-	p_(2, 1) = r_2 * (piC_ *             - exp1_);                               //C
-	p_(2, 2) = r_2 * (piG_ * (piY_/piR_) * exp1_ + (piA_/piR_) * k2_2 * exp22_); //G
-	p_(2, 3) = r_2 * (piT_ *             - exp1_);                               //T, U
-
-	//T, U
-	p_(3, 0) = r_2 * (piA_ *             - exp1_);                               //A
-	p_(3, 1) = r_2 * (piC_ * (piR_/piY_) * exp1_ - (piC_/piY_) * k1_2 * exp21_); //C
-	p_(3, 2) = r_2 * (piG_ *             - exp1_);                               //G
-	p_(3, 3) = r_2 * (piT_ * (piR_/piY_) * exp1_ + (piC_/piY_) * k1_2 * exp21_); //T, U
-
-	return p_;
+  double k1_2 = k1_ * k1_;
+  double k2_2 = k2_ * k2_;
+  exp1_ = exp(-l_);
+  exp22_ = exp(-k2_ * l_);
+  exp21_ = exp(-k1_ * l_);
+
+  //A
+  p_(0, 0) = r_2 * (piA_ * (piY_/piR_) * exp1_ + (piG_/piR_) * k2_2 * exp22_); //A
+  p_(0, 1) = r_2 * (piC_ *             - exp1_);                               //C
+  p_(0, 2) = r_2 * (piG_ * (piY_/piR_) * exp1_ - (piG_/piR_) * k2_2 * exp22_); //G
+  p_(0, 3) = r_2 * (piT_ *             - exp1_);                               //T, U
+
+  //C
+  p_(1, 0) = r_2 * (piA_ *             - exp1_);                               //A
+  p_(1, 1) = r_2 * (piC_ * (piR_/piY_) * exp1_ + (piT_/piY_) * k1_2 * exp21_); //C
+  p_(1, 2) = r_2 * (piG_ *             - exp1_);                               //G
+  p_(1, 3) = r_2 * (piT_ * (piR_/piY_) * exp1_ - (piT_/piY_) * k1_2 * exp21_); //T, U
+
+  //G
+  p_(2, 0) = r_2 * (piA_ * (piY_/piR_) * exp1_ - (piA_/piR_) * k2_2 * exp22_); //A
+  p_(2, 1) = r_2 * (piC_ *             - exp1_);                               //C
+  p_(2, 2) = r_2 * (piG_ * (piY_/piR_) * exp1_ + (piA_/piR_) * k2_2 * exp22_); //G
+  p_(2, 3) = r_2 * (piT_ *             - exp1_);                               //T, U
+
+  //T, U
+  p_(3, 0) = r_2 * (piA_ *             - exp1_);                               //A
+  p_(3, 1) = r_2 * (piC_ * (piR_/piY_) * exp1_ - (piC_/piY_) * k1_2 * exp21_); //C
+  p_(3, 2) = r_2 * (piG_ *             - exp1_);                               //G
+  p_(3, 3) = r_2 * (piT_ * (piR_/piY_) * exp1_ + (piC_/piY_) * k1_2 * exp21_); //T, U
+
+  return p_;
 }
 
 /******************************************************************************/
diff --git a/src/Bpp/Phyl/Model/Nucleotide/TN93.h b/src/Bpp/Phyl/Model/Nucleotide/TN93.h
index f20ede1..ac9b6b3 100755
--- a/src/Bpp/Phyl/Model/Nucleotide/TN93.h
+++ b/src/Bpp/Phyl/Model/Nucleotide/TN93.h
@@ -128,44 +128,38 @@ namespace bpp
  * - Tamura N and Nei K (1993), Molecular_ Biology And Evolution_ 10(3) 512-26. 
  */
 class TN93 :
-  public virtual NucleotideSubstitutionModel,
-  public AbstractReversibleSubstitutionModel
+  public AbstractReversibleNucleotideSubstitutionModel
 {
-	private:
+  private:
     double kappa1_, kappa2_, piA_, piC_, piG_, piT_, piY_, piR_, r_, k1_, k2_, theta_, theta1_, theta2_;
     mutable double exp1_, exp21_, exp22_, l_;
     mutable RowMatrix<double> p_;
 
-	public:
-		TN93(
-			const NucleicAlphabet * alpha,
-			double kappa1 = 1.,
-			double kappa2 = 1.,
-			double piA = 0.25,
-			double piC = 0.25,
-			double piG = 0.25,
-			double piT = 0.25);
-	
-		virtual ~TN93() {}
-
-#ifndef NO_VIRTUAL_COV
-    TN93*
-#else
-    Clonable*
-#endif
-    clone() const { return new TN93(*this); }
+  public:
+    TN93(
+      const NucleicAlphabet * alpha,
+      double kappa1 = 1.,
+      double kappa2 = 1.,
+      double piA = 0.25,
+      double piC = 0.25,
+      double piG = 0.25,
+      double piT = 0.25);
+  
+    virtual ~TN93() {}
+
+    TN93* clone() const { return new TN93(*this); }
 
   public:
 
-		double Pij_t    (size_t i, size_t j, double d) const;
-		double dPij_dt  (size_t i, size_t j, double d) const;
-		double d2Pij_dt2(size_t i, size_t j, double d) const;
-		const Matrix<double>& getPij_t    (double d) const;
-		const Matrix<double>& getdPij_dt  (double d) const;
-		const Matrix<double>& getd2Pij_dt2(double d) const;
+    double Pij_t    (size_t i, size_t j, double d) const;
+    double dPij_dt  (size_t i, size_t j, double d) const;
+    double d2Pij_dt2(size_t i, size_t j, double d) const;
+    const Matrix<double>& getPij_t    (double d) const;
+    const Matrix<double>& getdPij_dt  (double d) const;
+    const Matrix<double>& getd2Pij_dt2(double d) const;
 
     std::string getName() const { return "TN93"; }
-	
+  
   /**
    * @brief This method is over-defined to actualize the corresponding parameters piA, piT, piG and piC too.
    */
@@ -177,5 +171,5 @@ class TN93 :
 
 } //end of namespace bpp.
 
-#endif	//_TN93_H_
+#endif  //_TN93_H_
 
diff --git a/src/Bpp/Phyl/Model/Nucleotide/YpR.cpp b/src/Bpp/Phyl/Model/Nucleotide/YpR.cpp
index cc3a961..21c1433 100644
--- a/src/Bpp/Phyl/Model/Nucleotide/YpR.cpp
+++ b/src/Bpp/Phyl/Model/Nucleotide/YpR.cpp
@@ -294,7 +294,7 @@ void YpR::updateMatrices(double CgT, double cGA,
         min = generator_(i, i);
     }
 
-    MatrixTools::scale(generator_, -1 / min);
+    setScale(-1 / min);
 
     MatrixTools::getId(36, tmpMat_);    // to compute the equilibrium frequency  (Q+Id)^256
 
@@ -331,16 +331,19 @@ void YpR::updateMatrices(double CgT, double cGA,
     }
   }
 
-  MatrixTools::scale(generator_, 1 / x);
+  setScale(1 / x);
 
-  if (!isNonSingular_)
-    MatrixTools::Taylor(generator_, 30, vPowGen_);
-
-  for (i = 0; i < 36; i++)
+  if (isScalable())
   {
-    eigenValues_[i] /= x;
-    iEigenValues_[i] /= x;
+    for (i = 0; i < 36; i++)
+    {
+      eigenValues_[i] /= x;
+      iEigenValues_[i] /= x;
+    }
   }
+  
+  if (!isNonSingular_)
+    MatrixTools::Taylor(generator_, 30, vPowGen_);
 
   // and the exchangeability_
   for (i = 0; i < size_; i++)
diff --git a/src/Bpp/Phyl/Model/Nucleotide/YpR.h b/src/Bpp/Phyl/Model/Nucleotide/YpR.h
index e575a1a..459666b 100644
--- a/src/Bpp/Phyl/Model/Nucleotide/YpR.h
+++ b/src/Bpp/Phyl/Model/Nucleotide/YpR.h
@@ -184,8 +184,8 @@ public:
   void fireParameterChanged(const ParameterList& parameters)
   {
     AbstractSubstitutionModel::fireParameterChanged(parameters);
-   pmodel_->matchParametersValues(parameters);
-   updateMatrices();
+    pmodel_->matchParametersValues(parameters);
+    updateMatrices();
   }
 };
 }
diff --git a/src/Bpp/Phyl/Model/Nucleotide/gBGC.cpp b/src/Bpp/Phyl/Model/Nucleotide/gBGC.cpp
index aae385e..68ea70d 100644
--- a/src/Bpp/Phyl/Model/Nucleotide/gBGC.cpp
+++ b/src/Bpp/Phyl/Model/Nucleotide/gBGC.cpp
@@ -5,36 +5,36 @@
 //
 
 /*
-  Copyright or � or Copr. Bio++ Development Team, (November 16, 2004)
-  This software is a computer program whose purpose is to provide
-  classes for phylogenetic data analysis.
-
-  This software is governed by the CeCILL license under French law and
-  abiding by the rules of distribution of free software. You can use,
-  modify and/ or redistribute the software under the terms of the CeCILL
-  license as circulated by CEA, CNRS and INRIA at the following URL
-  "http://www.cecill.info".
-
-  As a counterpart to the access to the source code and rights to copy,
-  modify and redistribute granted by the license, users are provided
-  only with a limited warranty and the software's author, the holder of
-  the economic rights, and the successive licensors have only limited
-  liability.
-
-  In this respect, the user's attention is drawn to the risks associated
-  with loading, using, modifying and/or developing or reproducing the
-  software by the user in light of its specific status of free software,
-  that may mean that it is complicated to manipulate, and that also
-  therefore means that it is reserved for developers and experienced
-  professionals having in-depth computer knowledge. Users are therefore
-  encouraged to load and test the software's suitability as regards
-  their requirements in conditions enabling the security of their
-  systems and/or data to be ensured and, more generally, to use and
-  operate it in the same conditions as regards security.
-
-  The fact that you are presently reading this means that you have had
-  knowledge of the CeCILL license and that you accept its terms.
-*/
+   Copyright or � or Copr. Bio++ Development Team, (November 16, 2004)
+   This software is a computer program whose purpose is to provide
+   classes for phylogenetic data analysis.
+
+   This software is governed by the CeCILL license under French law and
+   abiding by the rules of distribution of free software. You can use,
+   modify and/ or redistribute the software under the terms of the CeCILL
+   license as circulated by CEA, CNRS and INRIA at the following URL
+   "http://www.cecill.info".
+
+   As a counterpart to the access to the source code and rights to copy,
+   modify and redistribute granted by the license, users are provided
+   only with a limited warranty and the software's author, the holder of
+   the economic rights, and the successive licensors have only limited
+   liability.
+
+   In this respect, the user's attention is drawn to the risks associated
+   with loading, using, modifying and/or developing or reproducing the
+   software by the user in light of its specific status of free software,
+   that may mean that it is complicated to manipulate, and that also
+   therefore means that it is reserved for developers and experienced
+   professionals having in-depth computer knowledge. Users are therefore
+   encouraged to load and test the software's suitability as regards
+   their requirements in conditions enabling the security of their
+   systems and/or data to be ensured and, more generally, to use and
+   operate it in the same conditions as regards security.
+
+   The fact that you are presently reading this means that you have had
+   knowledge of the CeCILL license and that you accept its terms.
+ */
 
 #include "gBGC.h"
 
@@ -49,37 +49,36 @@ using namespace bpp;
 
 /******************************************************************************/
 
-gBGC::gBGC(const NucleicAlphabet* alph, NucleotideSubstitutionModel* const pm, double gamma) :
+gBGC::gBGC(const NucleicAlphabet* alph, NucleotideSubstitutionModel* const pm, double B) :
   AbstractParameterAliasable("gBGC."),
-  AbstractSubstitutionModel(alph, new CanonicalStateMap(alph, false), "gBGC."),
+  AbstractNucleotideSubstitutionModel(alph, new CanonicalStateMap(alph, false), "gBGC."),
   model_(pm),
   nestedPrefix_(pm->getNamespace()),
-  gamma_(gamma)
+  B_(B)
 {
-  model_->setNamespace("gBGC."+nestedPrefix_);
+  model_->setNamespace("gBGC." + nestedPrefix_);
   model_->enableEigenDecomposition(0);
   addParameters_(model_->getParameters());
-  addParameter_(new Parameter("gBGC.gamma", gamma_, new IntervalConstraint(-999, 10, true, true), true));
+  addParameter_(new Parameter("gBGC.B", B_, new IntervalConstraint(-999, 10, true, true), true));
 
   updateMatrices();
 }
 
 gBGC::gBGC(const gBGC& gbgc) :
   AbstractParameterAliasable(gbgc),
-  AbstractSubstitutionModel(gbgc),
+  AbstractNucleotideSubstitutionModel(gbgc),
   model_(gbgc.model_->clone()),
   nestedPrefix_(gbgc.nestedPrefix_),
-  gamma_(gbgc.gamma_)
-{
-}
+  B_(gbgc.B_)
+{}
 
 gBGC& gBGC::operator=(const gBGC& gbgc)
 {
   AbstractParameterAliasable::operator=(gbgc);
   AbstractSubstitutionModel::operator=(gbgc);
-  model_ = auto_ptr<NucleotideSubstitutionModel>(gbgc.model_.get());
+  model_ = unique_ptr<NucleotideSubstitutionModel>(gbgc.model_.get());
   nestedPrefix_ = gbgc.nestedPrefix_;
-  gamma_=gbgc.gamma_;
+  B_ = gbgc.B_;
   return *this;
 }
 
@@ -92,26 +91,37 @@ void gBGC::fireParameterChanged(const ParameterList& parameters)
 
 void gBGC::updateMatrices()
 {
-  gamma_=getParameterValue("gamma");
-  unsigned int i,j;
+  B_ = getParameterValue("B");
+  unsigned int i, j;
   // Generator:
-  double eg=exp(gamma_);
-  
-  for ( i = 0; i < 4; i++)
-    for ( j = 0; j < 4; j++)
-      generator_(i,j)=model_->Qij(i,j);
-
-  generator_(0,1) *= eg;
-  generator_(0,2) *= eg;
-  generator_(3,1) *= eg;
-  generator_(3,2) *= eg;
-  generator_(1,0) /= eg;
-  generator_(2,0) /= eg;
-  generator_(1,3) /= eg;
-  generator_(2,3) /= eg;
-
-  generator_(0,0) -= (generator_(0,1)+generator_(0,2))*(1-1/eg);
-  generator_(3,3) -= (generator_(3,1)+generator_(3,2))*(1-1/eg);
+
+  for (i = 0; i < 4; i++)
+  {
+    for (j = 0; j < 4; j++)
+    {
+      generator_(i, j) = model_->Qij(i, j);
+    }
+  }
+
+  if (B_ != 0)
+  {
+    double bp = B_ / (1 - exp(-B_));
+    double bm = B_ / (exp(B_) - 1);
+
+    generator_(0, 0) -= (generator_(0, 1) + generator_(0, 2)) * (bp - 1);
+    generator_(1, 1) -= (generator_(1, 0) + generator_(1, 3)) * (bm - 1);
+    generator_(2, 2) -= (generator_(2, 0) + generator_(2, 3)) * (bm - 1);
+    generator_(3, 3) -= (generator_(3, 1) + generator_(3, 2)) * (bp - 1);
+
+    generator_(0, 1) *= bp;
+    generator_(0, 2) *= bp;
+    generator_(3, 1) *= bp;
+    generator_(3, 2) *= bp;
+    generator_(1, 0) *= bm;
+    generator_(2, 0) *= bm;
+    generator_(1, 3) *= bm;
+    generator_(2, 3) *= bm;
+  }
 
   if (enableEigenDecomposition())
   {
@@ -120,14 +130,14 @@ void gBGC::updateMatrices()
     EigenValue<double> ev(generator_);
     eigenValues_ = ev.getRealEigenValues();
     iEigenValues_ = ev.getImagEigenValues();
-  
+
     rightEigenVectors_ = ev.getV();
     try
     {
       MatrixTools::inv(rightEigenVectors_, leftEigenVectors_);
       isNonSingular_ = true;
       isDiagonalizable_ = true;
-      
+
       for (i = 0; i < 4 && isDiagonalizable_; i++)
       {
         if (abs(iEigenValues_[i]) > NumConstants::TINY())
@@ -141,18 +151,20 @@ void gBGC::updateMatrices()
         size_t nulleigen = 0;
         double val;
         isNonSingular_ = false;
-        
-        while (nulleigen < 4){
-          if (abs(eigenValues_[nulleigen]) < 0.000001 && abs(iEigenValues_[nulleigen]) < 0.000001) {
+
+        while (nulleigen < 4)
+        {
+          if (abs(eigenValues_[nulleigen]) < 0.000001 && abs(iEigenValues_[nulleigen]) < 0.000001)
+          {
             val = rightEigenVectors_(0, nulleigen);
-            i=1;
+            i = 1;
             while (i < 4)
             {
               if (abs(rightEigenVectors_(i, nulleigen) - val) > NumConstants::SMALL())
                 break;
               i++;
             }
-            
+
             if (i < 4)
               nulleigen++;
             else
@@ -169,16 +181,22 @@ void gBGC::updateMatrices()
         {
           eigenValues_[nulleigen] = 0; // to avoid approximation errors on long long branches
           iEigenValues_[nulleigen] = 0; // to avoid approximation errors on long long branches
-          
+
           for (i = 0; i < 4; i++)
+          {
             freq_[i] = leftEigenVectors_(nulleigen, i);
-          
+          }
+
           val = 0;
           for (i = 0; i < 4; i++)
+          {
             val += freq_[i];
-          
+          }
+
           for (i = 0; i < 4; i++)
+          {
             freq_[i] /= val;
+          }
         }
         else
         {
@@ -203,7 +221,7 @@ void gBGC::updateMatrices()
           min = generator_(i, i);
       }
 
-      MatrixTools::scale(generator_, -1 / min);
+      setScale(-1 / min);
 
       if (vPowGen_.size() == 0)
         vPowGen_.resize(30);
@@ -213,29 +231,21 @@ void gBGC::updateMatrices()
       MatrixTools::pow(tmpMat_, 4, vPowGen_[0]);
 
       for (i = 0; i < 4; i++)
+      {
         freq_[i] = vPowGen_[0](0, i);
+      }
 
       MatrixTools::getId(4, vPowGen_[0]);
     }
 
     // mise a l'echelle
 
-    double x = 0;
-    for (i = 0; i < 4; i++)
-      x += freq_[i] * generator_(i,i);
-
-    MatrixTools::scale(generator_,-1 / x);
-    for (i = 0; i < 4; i++)
-    {
-      eigenValues_[i] /= -x;
-      iEigenValues_[i] /= -x;
-    }
+    normalize();
 
+    
     if (!isNonSingular_)
       MatrixTools::Taylor(generator_, 30, vPowGen_);
-
   }
-
 }
 
 void gBGC::setNamespace(const std::string& prefix)
@@ -248,6 +258,5 @@ void gBGC::setNamespace(const std::string& prefix)
 
 std::string gBGC::getName() const
 {
-  return "gBGC";
+  return model_->getName() + "+gBGC";
 }
-
diff --git a/src/Bpp/Phyl/Model/Nucleotide/gBGC.h b/src/Bpp/Phyl/Model/Nucleotide/gBGC.h
index e9ce717..5eca0ab 100644
--- a/src/Bpp/Phyl/Model/Nucleotide/gBGC.h
+++ b/src/Bpp/Phyl/Model/Nucleotide/gBGC.h
@@ -5,37 +5,37 @@
 //
 
 /*
-  Copyright or � or Copr. Bio++ Development Team, (November 16, 2004)
-
-  This software is a computer program whose purpose is to provide classes
-  for phylogenetic data analysis.
-
-  This software is governed by the CeCILL  license under French law and
-  abiding by the rules of distribution of free software.  You can  use,
-  modify and/ or redistribute the software under the terms of the CeCILL
-  license as circulated by CEA, CNRS and INRIA at the following URL
-  "http://www.cecill.info".
-
-  As a counterpart to the access to the source code and  rights to copy,
-  modify and redistribute granted by the license, users are provided only
-  with a limited warranty  and the software's author,  the holder of the
-  economic rights,  and the successive licensors  have only  limited
-  liability.
-
-  In this respect, the user's attention is drawn to the risks associated
-  with loading,  using,  modifying and/or developing or reproducing the
-  software by the user in light of its specific status of free software,
-  that may mean  that it is complicated to manipulate,  and  that  also
-  therefore means  that it is reserved for developers  and  experienced
-  professionals having in-depth computer knowledge. Users are therefore
-  encouraged to load and test the software's suitability as regards their
-  requirements in conditions enabling the security of their systems and/or
-  data to be ensured and,  more generally, to use and operate it in the
-  same conditions as regards security.
-
-  The fact that you are presently reading this means that you have had
-  knowledge of the CeCILL license and that you accept its terms.
-*/
+   Copyright or � or Copr. Bio++ Development Team, (November 16, 2004)
+
+   This software is a computer program whose purpose is to provide classes
+   for phylogenetic data analysis.
+
+   This software is governed by the CeCILL  license under French law and
+   abiding by the rules of distribution of free software.  You can  use,
+   modify and/ or redistribute the software under the terms of the CeCILL
+   license as circulated by CEA, CNRS and INRIA at the following URL
+   "http://www.cecill.info".
+
+   As a counterpart to the access to the source code and  rights to copy,
+   modify and redistribute granted by the license, users are provided only
+   with a limited warranty  and the software's author,  the holder of the
+   economic rights,  and the successive licensors  have only  limited
+   liability.
+
+   In this respect, the user's attention is drawn to the risks associated
+   with loading,  using,  modifying and/or developing or reproducing the
+   software by the user in light of its specific status of free software,
+   that may mean  that it is complicated to manipulate,  and  that  also
+   therefore means  that it is reserved for developers  and  experienced
+   professionals having in-depth computer knowledge. Users are therefore
+   encouraged to load and test the software's suitability as regards their
+   requirements in conditions enabling the security of their systems and/or
+   data to be ensured and,  more generally, to use and operate it in the
+   same conditions as regards security.
+
+   The fact that you are presently reading this means that you have had
+   knowledge of the CeCILL license and that you accept its terms.
+ */
 
 #ifndef _GBGC_H_
 #define _GBGC_H_
@@ -55,7 +55,7 @@ using namespace std;
 namespace bpp
 {
 /**
- * @brief gBGC  model.
+ * @brief gBGC model.
  * @author Laurent Gu�guen
  *
  * modelling of GC biased gene-conversion.
@@ -64,65 +64,59 @@ namespace bpp
  * given nucleotidic substitution model.
  *
  * In addition to the parameters of the basic nucleic model, the
- * biased gene conversion effect is parametrized by @f$ \gamma @f$
- * (denoted \c "gamma"), and the mutation rates from A<->T nucleotides
- * to C<->G nucleotides are multiplied by @f$ exp(\gamma)@f$.
+ * biased gene conversion effect is parametrized by @f$ B @f$, that
+ * corresponds to fixation, and stands for a dubious selection.
+ *
+ * With this term, the mutation rates from A and T to C and G are
+ * multiplied by @f$ \frac{B}{2} . \frac{1}{1-exp(-B)}@f$, and
+ * the mutation rates from C and G to A and T are multiplied by
+ * @f$ \frac{B}{2} . \frac{1}{exp(B)-1}@f$.
  *
  * @see AbstractSubstitutionModel
  *
+ * Reference:
+ * - Galtier & al (2009), Trends in Genetics, 25(1), doi:10.1016/j.tig.2008.10.011
  */
 
-  class gBGC :
-    public virtual NucleotideSubstitutionModel,
-    public AbstractSubstitutionModel
-  {
-  private:
-    std::auto_ptr<NucleotideSubstitutionModel>  model_;
-    std::string nestedPrefix_;
+class gBGC :
+  public AbstractNucleotideSubstitutionModel
+{
+private:
+  std::unique_ptr<NucleotideSubstitutionModel>  model_;
+  std::string nestedPrefix_;
+
+  /**
+   * @brief the value of the bias.
+   */
+  double B_;
 
-    /*
-     * @brief the value of the bias.
-     *
-     */
-  
-    double gamma_;
-  
-  public:
-    /*
-     * @brief Build a new gBGC substitution model.
-     *
-     */
+public:
+  /**
+   * @brief Build a new gBGC substitution model.
+   */
+  gBGC(const NucleicAlphabet*, NucleotideSubstitutionModel* const, double B = 0);
 
-    gBGC(const NucleicAlphabet*, NucleotideSubstitutionModel* const, double gamma=0);
+  gBGC(const gBGC&);
 
-    gBGC(const gBGC&);
+  gBGC& operator=(const gBGC& gbgc);
 
-    gBGC& operator=(const gBGC& gbgc);
+  gBGC* clone() const { return new gBGC(*this); }
 
-#ifndef NOVIRTUAL_COV_
-    gBGC*
-#else
-    Clonable*
-#endif
-    clone() const { return new gBGC(*this); }
+  virtual ~gBGC() {}
 
-    ~gBGC()  {}
+public:
+  std::string getName() const;
 
-  public:
-    std::string getName() const;
+  size_t getNumberOfStates() const { return model_->getNumberOfStates(); }
 
-    size_t getNumberOfStates() const { return model_->getNumberOfStates(); }
+  void fireParameterChanged(const ParameterList&);
 
-    void fireParameterChanged(const ParameterList&);
+  const SubstitutionModel* getNestedModel() const {return model_.get(); }
 
-    const SubstitutionModel* getNestedModel() const {return model_.get();}
-    
-    void updateMatrices();
+  void updateMatrices();
 
-    void setNamespace(const std::string&);
-  };
+  void setNamespace(const std::string&);
+};
 }
 
 #endif // _GBGC_H
-
-
diff --git a/src/Bpp/Phyl/Model/OneChangeTransitionModel.cpp b/src/Bpp/Phyl/Model/OneChangeTransitionModel.cpp
new file mode 100644
index 0000000..e774e62
--- /dev/null
+++ b/src/Bpp/Phyl/Model/OneChangeTransitionModel.cpp
@@ -0,0 +1,303 @@
+//
+// File: OneChangeTransitionModel.cpp
+// Created by: Laurent Gueguen
+// Created on: samedi 24 octobre 2015, � 18h 50
+//
+
+/*
+   Copyright or � or Copr. Bio++ Development Team, (November 16, 2004)
+
+   This software is a computer program whose purpose is to provide classes
+   for phylogenetic data analysis.
+
+   This software is governed by the CeCILL  license under French law and
+   abiding by the rules of distribution of free software.  You can  use,
+   modify and/ or redistribute the software under the terms of the CeCILL
+   license as circulated by CEA, CNRS and INRIA at the following URL
+   "http://www.cecill.info".
+
+   As a counterpart to the access to the source code and  rights to copy,
+   modify and redistribute granted by the license, users are provided only
+   with a limited warranty  and the software's author,  the holder of the
+   economic rights,  and the successive licensors  have only  limited
+   liability.
+
+   In this respect, the user's attention is drawn to the risks associated
+   with loading,  using,  modifying and/or developing or reproducing the
+   software by the user in light of its specific status of free software,
+   that may mean  that it is complicated to manipulate,  and  that  also
+   therefore means  that it is reserved for developers  and  experienced
+   professionals having in-depth computer knowledge. Users are therefore
+   encouraged to load and test the software's suitability as regards their
+   requirements in conditions enabling the security of their systems and/or
+   data to be ensured and,  more generally, to use and operate it in the
+   same conditions as regards security.
+
+   The fact that you are presently reading this means that you have had
+   knowledge of the CeCILL license and that you accept its terms.
+ */
+
+#include "OneChangeTransitionModel.h"
+#include <Bpp/Numeric/Matrix/MatrixTools.h>
+
+using namespace bpp;
+using namespace std;
+
+/******************************************************************************/
+
+double OneChangeTransitionModel::Pij_t    (size_t i, size_t j, double t) const
+{
+  double qii=getModel().Qij(i,i);
+  if (qii==0)
+  {
+    return (i==j?1:0);
+  }
+  else
+  {
+    if (t!=0)
+    {    
+      double v=exp(qii*t);
+      return (getModel().Pij_t(i,j,t)-(i==j?v:0))/(1-v);
+    }
+    else
+      return (i==j?0:-getModel().Qij(i,j)/qii);
+  }
+}
+
+double OneChangeTransitionModel::dPij_dt  (size_t i, size_t j, double t) const
+{
+  const RowMatrix<double>& Q=getModel().getGenerator();
+  double qii=Q(i,i);
+  
+  if (qii==0)
+    return 0;
+  
+  if (t!=0)
+  {
+    double v=exp(qii*t);
+    
+    return (getModel().dPij_dt(i,j,t)*(1-v)+(getModel().Pij_t(i,j,t)-(i==j?1:0))*qii*v)/((1-v)*(1-v));
+  }
+  else
+  {
+    double q2ij=0;
+    for (size_t k = 0; k < size_; ++k)
+      q2ij+=Q(i,k)*Q(k,j);
+    
+    return (-q2ij+qii*Q(i,j))/(2*qii);
+  }
+}
+
+double OneChangeTransitionModel::d2Pij_dt2(size_t i, size_t j, double t) const
+{
+  if (t!=0)
+  {
+    double qii=getModel().Qij(i,i);
+      
+    if (qii==0)
+    {
+      return 0;
+    }
+    else
+    {
+      double v=exp(qii*t);
+      double mv=1-v;
+      
+      return -((mv*getModel().d2Pij_dt2(i,j,t)+2*qii*v*getModel().dPij_dt(i,j,t))*mv+(getModel().Pij_t(i,j,t)-(i==j?1:0))*qii*qii*(v+v*v))/(mv*mv*mv);
+    }
+  }
+  else
+  {
+    const RowMatrix<double>& Q=getModel().getGenerator();
+    double qii=Q(i,i);
+    
+    if (qii==0)
+      return 0;
+    
+    double q2ik,q2ij=0,q3ij=0;
+    
+    for (size_t k = 0; k < size_; ++k)
+    {
+      q2ik=0;
+      for (size_t l = 0; l < size_; ++l)
+        q2ik+=Q(i,l)*Q(l,k);
+      if (k==j)
+        q2ij=q2ik;
+      
+      q3ij+=q2ik*Q(k,j);
+    }
+    
+    return -(2*q3ij-3*qii*q2ij+qii*qii*Q(i,j))/(12*qii);
+  }
+}
+
+const Matrix<double>& OneChangeTransitionModel::getPij_t(double t) const
+{
+  const RowMatrix<double>& origPij=getModel().getPij_t(t);
+  const RowMatrix<double>& Q=getModel().getGenerator();
+  
+  for (unsigned int i = 0; i < size_; ++i) {
+    vector<double>& pi_t=pij_t.getRow(i);
+    
+    double qii=Q(i,i);
+    if (qii==0)
+    {
+      for (unsigned int j = 0; j < size_; ++j)
+        pi_t[j]=(i==j?1:0);
+    }
+    else
+    {
+      if (t!=0)
+      {
+        const vector<double>& origPij_i=origPij.getRow(i);
+        
+        double v=exp(qii*t);
+        for (unsigned int j = 0; j < size_; ++j)
+          pi_t[j]=(origPij_i[j]-(i==j?v:0))/(1-v);
+      }
+      else
+      {
+        const vector<double>& Q_i=Q.getRow(i);
+        for (unsigned int j = 0; j < size_; ++j)
+          pi_t[j]=(i==j?0:-Q_i[j]/qii);
+      }
+      
+    }
+  }
+  
+  return pij_t;
+}
+
+
+const Matrix<double>& OneChangeTransitionModel::getdPij_dt(double t) const
+{
+  if (t!=0)
+  {
+    const RowMatrix<double>& origPij=getModel().getPij_t(t);
+    const RowMatrix<double>& origdPij=getModel().getdPij_dt(t);
+  
+    for (unsigned int i = 0; i < size_; ++i) {
+      vector<double>& dpi_t=dpij_t.getRow(i);
+      double qii=getModel().Qij(i,i);
+      
+      if (qii==0)
+      {
+        for (unsigned int j = 0; j < size_; ++j)
+          dpi_t[j]=0;
+      }
+      else
+      {
+        {    
+          double v=exp(qii*t);
+          double mv2=(1-v)*(1-v);
+          const vector<double>& origPij_i=origPij.getRow(i);
+          const vector<double>& origdPij_i=origdPij.getRow(i);
+          
+          for (unsigned int j = 0; j < size_; ++j)
+            dpi_t[j]=(origdPij_i[j]*(1-v)+(origPij_i[j]-(i==j?1:0))*qii*v)/mv2;
+        }
+      }
+    }
+  }
+  else
+  {
+    const RowMatrix<double>& Q=getModel().getGenerator();
+    RowMatrix<double> Q2;
+    MatrixTools::mult<double>(Q,Q,Q2);
+    
+    for (unsigned int i = 0; i < size_; ++i)
+    {
+      const vector<double>& Q_i=Q.getRow(i);
+      vector<double>& dpi_t=dpij_t.getRow(i);
+      double qii=Q_i[i];
+      
+      if (qii==0)
+      {
+        for (unsigned int j = 0; j < size_; ++j)
+          dpi_t[j]=0;
+      }
+      else
+      {
+        const vector<double>& Q2_i=Q2.getRow(i);
+        
+        for (unsigned int j = 0; j < size_; ++j)
+          dpi_t[j]=(-Q2_i[j]+qii*Q_i[j])/(2*qii);
+      }
+    }
+  }
+
+  return dpij_t;
+}
+
+
+const Matrix<double>& OneChangeTransitionModel::getd2Pij_dt2(double t) const
+{
+  if (t!=0)
+  {
+    const RowMatrix<double>& origPij=getModel().getPij_t(t);
+    const RowMatrix<double>& origdPij=getModel().getdPij_dt(t);
+    const RowMatrix<double>& origd2Pij=getModel().getd2Pij_dt2(t);
+  
+    for (unsigned int i = 0; i < size_; ++i) {
+      double qii=getModel().Qij(i,i);
+      vector<double>& d2pi_t=d2pij_t.getRow(i);
+      
+      if (qii==0)
+      {
+        for (unsigned int j = 0; j < size_; ++j)
+          d2pi_t[j]=0;
+      }
+      else
+      {
+        {    
+          double v=exp(qii*t);
+          double mv=1-v;
+          double q2=qii*qii;
+          
+          double mv3=mv*mv*mv;
+          double vpv2=v+v*v;
+          
+          const vector<double>& origPij_i=origPij.getRow(i);
+          const vector<double>& origdPij_i=origdPij.getRow(i);
+          const vector<double>& origd2Pij_i=origd2Pij.getRow(i);
+          
+          for (unsigned int j = 0; j < size_; ++j)
+            d2pi_t[j]=-((mv*origd2Pij_i[j]+2*qii*v*origdPij_i[j])*mv+(origPij_i[j]-(i==j?1:0))*q2*vpv2)/mv3;
+        }
+      }
+    }
+  }
+  else
+  {
+    const RowMatrix<double>& Q=getModel().getGenerator();
+    RowMatrix<double> Q2;
+    MatrixTools::mult<double>(Q,Q,Q2);
+    RowMatrix<double> Q3;
+    MatrixTools::mult<double>(Q,Q2,Q3);
+    
+    for (unsigned int i = 0; i < size_; ++i)
+    {
+      const vector<double>& Q_i=Q.getRow(i);
+      double qii=Q_i[i];
+      vector<double>& d2pi_t=d2pij_t.getRow(i);
+ 
+      if (qii==0)
+      {
+        for (unsigned int j = 0; j < size_; ++j)
+          d2pi_t[j]=0;
+      }
+      else
+      {
+        const vector<double>& Q2_i=Q2.getRow(i);
+        const vector<double>& Q3_i=Q3.getRow(i);
+        
+        for (unsigned int j = 0; j < size_; ++j)
+          d2pi_t[j]=-(2*Q3_i[j]-3*qii*Q2_i[j]+qii*qii*Q_i[j])/(12*qii);
+      }
+    }
+  }
+
+  return d2pij_t;
+}
+
+
diff --git a/src/Bpp/Phyl/Model/Nucleotide/gBGC.h b/src/Bpp/Phyl/Model/OneChangeTransitionModel.h
similarity index 50%
copy from src/Bpp/Phyl/Model/Nucleotide/gBGC.h
copy to src/Bpp/Phyl/Model/OneChangeTransitionModel.h
index e9ce717..e72a920 100644
--- a/src/Bpp/Phyl/Model/Nucleotide/gBGC.h
+++ b/src/Bpp/Phyl/Model/OneChangeTransitionModel.h
@@ -1,7 +1,7 @@
 //
-// File: gBGC.h
+// File: OneChangeTransitionModel.h
 // Created by: Laurent Gueguen
-// Created on: lundi 13 f�vrier 2012, � 09h 43
+// Created on: samedi 24 octobre 2015, � 18h 28
 //
 
 /*
@@ -37,92 +37,68 @@
   knowledge of the CeCILL license and that you accept its terms.
 */
 
-#ifndef _GBGC_H_
-#define _GBGC_H_
+#ifndef _ONE_CHANGE_TRANSITION_MODEL_H_
+#define _ONE_CHANGE_TRANSITION_MODEL_H_
 
-#include "NucleotideSubstitutionModel.h"
-#include "../AbstractSubstitutionModel.h"
-
-#include <Bpp/Numeric/Constraints.h>
-
-// From SeqLib:
-#include <Bpp/Seq/Alphabet/NucleicAlphabet.h>
-
-// From Utils:
-
-using namespace std;
+#include "AbstractFromSubstitutionModelTransitionModel.h"
 
 namespace bpp
 {
 /**
- * @brief gBGC  model.
- * @author Laurent Gu�guen
- *
- * modelling of GC biased gene-conversion.
- *
- * This model adds strand symetric GC biased gene conversion to a
- * given nucleotidic substitution model.
- *
- * In addition to the parameters of the basic nucleic model, the
- * biased gene conversion effect is parametrized by @f$ \gamma @f$
- * (denoted \c "gamma"), and the mutation rates from A<->T nucleotides
- * to C<->G nucleotides are multiplied by @f$ exp(\gamma)@f$.
- *
- * @see AbstractSubstitutionModel
+ * @brief From a model, compute transition probabilities given there
+ * is at least a change in the branch.
  *
+ * It has the same parameters as the SubModel.
  */
 
-  class gBGC :
-    public virtual NucleotideSubstitutionModel,
-    public AbstractSubstitutionModel
+  class OneChangeTransitionModel :
+    public AbstractFromSubstitutionModelTransitionModel
   {
-  private:
-    std::auto_ptr<NucleotideSubstitutionModel>  model_;
-    std::string nestedPrefix_;
-
-    /*
-     * @brief the value of the bias.
-     *
-     */
-  
-    double gamma_;
-  
   public:
-    /*
-     * @brief Build a new gBGC substitution model.
-     *
-     */
-
-    gBGC(const NucleicAlphabet*, NucleotideSubstitutionModel* const, double gamma=0);
-
-    gBGC(const gBGC&);
-
-    gBGC& operator=(const gBGC& gbgc);
+    OneChangeTransitionModel(const SubstitutionModel& originalModel) :
+      AbstractFromSubstitutionModelTransitionModel(originalModel)
+    {
+    }
+    
+    OneChangeTransitionModel(const OneChangeTransitionModel& fmsm) :
+      AbstractFromSubstitutionModelTransitionModel(fmsm)
+    {
+    }
+    
 
-#ifndef NOVIRTUAL_COV_
-    gBGC*
-#else
-    Clonable*
-#endif
-    clone() const { return new gBGC(*this); }
+    OneChangeTransitionModel& operator=(const OneChangeTransitionModel& fmsm)
+    {
+      AbstractFromSubstitutionModelTransitionModel::operator=(fmsm);
+      return *this;
+    }
+    
+    ~OneChangeTransitionModel() {}
 
-    ~gBGC()  {}
+    OneChangeTransitionModel* clone() const { return new OneChangeTransitionModel(*this); }
 
   public:
-    std::string getName() const;
+    double freq(size_t i) const { return getModel().freq(i); }
 
-    size_t getNumberOfStates() const { return model_->getNumberOfStates(); }
+    double Pij_t    (size_t i, size_t j, double t) const;
+    double dPij_dt  (size_t i, size_t j, double t) const;
+    double d2Pij_dt2(size_t i, size_t j, double t) const;
+    
+    const Vdouble& getFrequencies() const { return getModel().getFrequencies(); }
 
-    void fireParameterChanged(const ParameterList&);
+    const FrequenciesSet* getFrequenciesSet() const {return getModel().getFrequenciesSet(); }
 
-    const SubstitutionModel* getNestedModel() const {return model_.get();}
+    const Matrix<double>& getPij_t(double t) const;
     
-    void updateMatrices();
+    const Matrix<double>& getdPij_dt(double t) const;
 
-    void setNamespace(const std::string&);
-  };
-}
+    const Matrix<double>& getd2Pij_dt2(double t) const;
 
-#endif // _GBGC_H
+    /*
+     * @}
+     *
+     */
 
+  };
+} // end of namespace bpp.
 
+#endif  // _ONE_CHANGE_TRANSITION_MODEL_H_
diff --git a/src/Bpp/Phyl/Model/Protein/Coala.cpp b/src/Bpp/Phyl/Model/Protein/Coala.cpp
index 4c85536..a22d321 100644
--- a/src/Bpp/Phyl/Model/Protein/Coala.cpp
+++ b/src/Bpp/Phyl/Model/Protein/Coala.cpp
@@ -68,8 +68,7 @@ Coala::Coala(
   unsigned int nbAxes,
   bool param) :
   AbstractParameterAliasable("Coala."),
-  ProteinSubstitutionModel(),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "Coala."),
+  AbstractReversibleProteinSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "Coala."),
   CoalaCore(nbAxes, model.getName()),
   init_(true),
   nbrOfAxes_(nbAxes),
diff --git a/src/Bpp/Phyl/Model/Protein/Coala.h b/src/Bpp/Phyl/Model/Protein/Coala.h
index 06b722f..268b9ec 100644
--- a/src/Bpp/Phyl/Model/Protein/Coala.h
+++ b/src/Bpp/Phyl/Model/Protein/Coala.h
@@ -70,8 +70,7 @@ namespace bpp
  */
 
 class Coala :
-  public ProteinSubstitutionModel,
-  public AbstractReversibleSubstitutionModel,
+  public AbstractReversibleProteinSubstitutionModel,
   public CoalaCore
 {
 protected:
@@ -89,16 +88,11 @@ public:
 
   virtual ~Coala() {}
 
-#ifndef NO_VIRTUAL_COV
-  Coala*
-#else
-  Clonable*
-#endif
-  clone() const { return new Coala(*this); }
+  Coala* clone() const { return new Coala(*this); }
 
 public:
-  std::string getName() const {return "Coala"; }
-  std::string getExch() const {return exch_; }
+  std::string getName() const { return "Coala"; }
+  std::string getExch() const { return exch_; }
   void setFreqFromData(const SequenceContainer& data, double pseudoCount = 0);
   std::string getEmpiricalMatrixFile() const { return file_; }
 
diff --git a/src/Bpp/Phyl/Model/Protein/CoalaCore.cpp b/src/Bpp/Phyl/Model/Protein/CoalaCore.cpp
index 3c08904..84ad97f 100644
--- a/src/Bpp/Phyl/Model/Protein/CoalaCore.cpp
+++ b/src/Bpp/Phyl/Model/Protein/CoalaCore.cpp
@@ -5,7 +5,7 @@
 //
 
 /*
-   Copyright or � or Copr. CNRS, (November 16, 2004)
+   Copyright or (C) or Copr. Bio++ Development Team, (November 16, 2004)
 
    This software is a computer program whose purpose is to provide classes
    for phylogenetic data analysis.
@@ -40,7 +40,6 @@
 
 #include "CoalaCore.h"
 
-// #include <Bpp/Io/FileTools.h>
 #include <Bpp/Text/TextTools.h>
 #include <Bpp/Text/StringTokenizer.h>
 #include <Bpp/App/ApplicationTools.h>
diff --git a/src/Bpp/Phyl/Model/Protein/CoalaCore.h b/src/Bpp/Phyl/Model/Protein/CoalaCore.h
index 98c7308..1286822 100644
--- a/src/Bpp/Phyl/Model/Protein/CoalaCore.h
+++ b/src/Bpp/Phyl/Model/Protein/CoalaCore.h
@@ -5,7 +5,7 @@
 //
 
 /*
-   Copyright or � or Copr. Bio++ Development Team, (November 16, 2004)
+   Copyright or (C) or Copr. Bio++ Development Team, (November 16, 2004)
    PCA
    This software is a computer program whose purpose is to provide classes
    for phylogenetic data analysis.
@@ -41,11 +41,11 @@
 #ifndef _COALACORE_H_
 #define _COALACORE_H_
 
-// From Core:
+// From bpp-core:
 #include <Bpp/Numeric/Matrix/Matrix.h>
-
 #include <Bpp/Numeric/ParameterList.h>
-// From SeqLib:
+
+// From bpp-seq:
 #include <Bpp/Seq/Alphabet/ProteicAlphabet.h>
 #include <Bpp/Seq/Container/SequenceContainer.h>
 
diff --git a/src/Bpp/Phyl/Model/Protein/DSO78.cpp b/src/Bpp/Phyl/Model/Protein/DSO78.cpp
index 94678ab..ff86cb8 100755
--- a/src/Bpp/Phyl/Model/Protein/DSO78.cpp
+++ b/src/Bpp/Phyl/Model/Protein/DSO78.cpp
@@ -52,7 +52,7 @@ using namespace std;
 
 DSO78::DSO78(const ProteicAlphabet* alpha) :
   AbstractParameterAliasable("DSO78."),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "DSO78."),
+  AbstractReversibleProteinSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "DSO78."),
   freqSet_(0)
 {
   #include "__DSO78ExchangeabilityCode"
@@ -63,7 +63,7 @@ DSO78::DSO78(const ProteicAlphabet* alpha) :
 
 DSO78::DSO78(const ProteicAlphabet* alpha, ProteinFrequenciesSet* freqSet, bool initFreqs) :
   AbstractParameterAliasable("DSO78+F."),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "DSO78+F."),
+  AbstractReversibleProteinSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "DSO78+F."),
   freqSet_(freqSet)
 {
   #include "__DSO78ExchangeabilityCode"
@@ -86,7 +86,10 @@ void DSO78::setFreqFromData(const SequenceContainer& data, double pseudoCount)
   {
     t += (counts[i] + pseudoCount);
   }
-  for (size_t i = 0; i < size_; ++i) freq_[i] = (static_cast<double>(counts[static_cast<int>(i)]) + pseudoCount) / t;
+  for (size_t i = 0; i < size_; ++i) {
+    freq_[i] = (static_cast<double>(counts[static_cast<int>(i)]) + pseudoCount) / t;
+    //ApplicationTools::displayResult("-- Frequency for " + alphabet_->intToChar(static_cast<int>(i)), freq_[i]);
+  }
   freqSet_->setFrequencies(freq_);
   //Update parameters and re-compute generator and eigen values:
   matchParametersValues(freqSet_->getParameters());
diff --git a/src/Bpp/Phyl/Model/Protein/DSO78.h b/src/Bpp/Phyl/Model/Protein/DSO78.h
index 229a6b9..0c8692d 100755
--- a/src/Bpp/Phyl/Model/Protein/DSO78.h
+++ b/src/Bpp/Phyl/Model/Protein/DSO78.h
@@ -64,8 +64,7 @@ namespace bpp
    * - Kosiol C and Goldman N (2005), _Molecular Biology And Evolution_ 22(2) 193-9. 
    */
   class DSO78 :
-    public virtual ProteinSubstitutionModel,
-    public AbstractReversibleSubstitutionModel
+    public AbstractReversibleProteinSubstitutionModel
   {
   private:
     ProteinFrequenciesSet* freqSet_;
@@ -90,16 +89,14 @@ namespace bpp
 
     DSO78(const DSO78& model) :
       AbstractParameterAliasable(model),
-      //AbstractSubstitutionModel(model),
-      AbstractReversibleSubstitutionModel(model),
+      AbstractReversibleProteinSubstitutionModel(model),
       freqSet_(dynamic_cast<ProteinFrequenciesSet *>(model.freqSet_->clone()))
     {}
 
     DSO78& operator=(const DSO78& model)
     {
       AbstractParameterAliasable::operator=(model);
-      AbstractSubstitutionModel::operator=(model);
-      AbstractReversibleSubstitutionModel::operator=(model);
+      AbstractReversibleProteinSubstitutionModel::operator=(model);
       if (freqSet_) delete freqSet_;
       freqSet_ = dynamic_cast<ProteinFrequenciesSet *>(model.freqSet_->clone());
       return *this;
@@ -107,12 +104,7 @@ namespace bpp
 
     virtual ~DSO78() { delete freqSet_; }
 
-#ifndef NO_VIRTUAL_COV
-    DSO78*
-#else
-    Clonable*
-#endif
-    clone() const { return new DSO78(*this); }
+    DSO78* clone() const { return new DSO78(*this); }
     
   public:
     std::string getName() const 
diff --git a/src/Bpp/Phyl/Model/Protein/JCprot.cpp b/src/Bpp/Phyl/Model/Protein/JCprot.cpp
index 45ab877..919868e 100755
--- a/src/Bpp/Phyl/Model/Protein/JCprot.cpp
+++ b/src/Bpp/Phyl/Model/Protein/JCprot.cpp
@@ -53,7 +53,7 @@ using namespace std;
 
 JCprot::JCprot(const ProteicAlphabet* alpha) :
   AbstractParameterAliasable("JC69."),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "JC69."),
+  AbstractReversibleProteinSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "JC69."),
   exp_(), p_(size_, size_), freqSet_(0)
 {
   freqSet_ = new FixedProteinFrequenciesSet(alpha, freq_);
@@ -62,7 +62,7 @@ JCprot::JCprot(const ProteicAlphabet* alpha) :
 
 JCprot::JCprot(const ProteicAlphabet* alpha, ProteinFrequenciesSet* freqSet, bool initFreqs) :
   AbstractParameterAliasable("JC69+F."),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "JC69+F."),
+  AbstractReversibleProteinSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "JC69+F."),
   exp_(), p_(size_, size_), freqSet_(freqSet)
 {
   freqSet_->setNamespace("JC69+F."+freqSet_->getNamespace());
diff --git a/src/Bpp/Phyl/Model/Protein/JCprot.h b/src/Bpp/Phyl/Model/Protein/JCprot.h
index aeb45cf..0ab4b96 100755
--- a/src/Bpp/Phyl/Model/Protein/JCprot.h
+++ b/src/Bpp/Phyl/Model/Protein/JCprot.h
@@ -132,8 +132,7 @@ namespace bpp
    * - Jukes TH and Cantor CR (1969), Evolution_ of proteins molecules_, 121-123, in Mammalian_ protein metabolism_. 
    */
   class JCprot:
-    public virtual ProteinSubstitutionModel,
-    public AbstractReversibleSubstitutionModel
+    public AbstractReversibleProteinSubstitutionModel
   {
   private:
     mutable double exp_;
@@ -160,8 +159,7 @@ namespace bpp
 
     JCprot(const JCprot& model) :
       AbstractParameterAliasable(model),
-      //AbstractSubstitutionModel(model),
-      AbstractReversibleSubstitutionModel(model),
+      AbstractReversibleProteinSubstitutionModel(model),
       exp_(model.exp_),
       p_(model.p_),
       freqSet_(dynamic_cast<ProteinFrequenciesSet*>(model.freqSet_->clone()))
@@ -170,8 +168,7 @@ namespace bpp
     JCprot& operator=(const JCprot& model)
     {
       AbstractParameterAliasable::operator=(model);
-      AbstractSubstitutionModel::operator=(model);
-      AbstractReversibleSubstitutionModel::operator=(model);
+      AbstractReversibleProteinSubstitutionModel::operator=(model);
       exp_ = model.exp_;
       p_   = model.p_;
       if (freqSet_) delete freqSet_;
@@ -181,12 +178,7 @@ namespace bpp
 
     virtual ~JCprot() { delete freqSet_; }
 	
-#ifndef NO_VIRTUAL_COV
-    JCprot*
-#else
-    Clonable*
-#endif
-    clone() const { return new JCprot(*this); }
+    JCprot* clone() const { return new JCprot(*this); }
 
   public:
     double Pij_t    (size_t i, size_t j, double d) const;
diff --git a/src/Bpp/Phyl/Model/Protein/JTT92.cpp b/src/Bpp/Phyl/Model/Protein/JTT92.cpp
index a2ab2a5..5cce478 100755
--- a/src/Bpp/Phyl/Model/Protein/JTT92.cpp
+++ b/src/Bpp/Phyl/Model/Protein/JTT92.cpp
@@ -52,7 +52,7 @@ using namespace std;
 
 JTT92::JTT92(const ProteicAlphabet* alpha) :
   AbstractParameterAliasable("JTT92."),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "JTT92."),
+  AbstractReversibleProteinSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "JTT92."),
   freqSet_(0)
 {
   #include "__JTT92ExchangeabilityCode"
@@ -63,7 +63,7 @@ JTT92::JTT92(const ProteicAlphabet* alpha) :
 
 JTT92::JTT92(const ProteicAlphabet* alpha, ProteinFrequenciesSet* freqSet, bool initFreqs) :
   AbstractParameterAliasable("JTT92+F."),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "JTT92+F."),
+  AbstractReversibleProteinSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "JTT92+F."),
   freqSet_(freqSet)
 {
   #include "__JTT92ExchangeabilityCode"
diff --git a/src/Bpp/Phyl/Model/Protein/JTT92.h b/src/Bpp/Phyl/Model/Protein/JTT92.h
index a673f81..7cd97c3 100755
--- a/src/Bpp/Phyl/Model/Protein/JTT92.h
+++ b/src/Bpp/Phyl/Model/Protein/JTT92.h
@@ -64,19 +64,18 @@ namespace bpp
  * - Kosiol C and Goldman N (2005), _Molecular Biology And Evolution_ 22(2) 193-9. 
  */
 class JTT92 :
-  public virtual ProteinSubstitutionModel,
-  public AbstractReversibleSubstitutionModel
+  public AbstractReversibleProteinSubstitutionModel
 {
   private:
     ProteinFrequenciesSet* freqSet_;
 
-	public:
+  public:
     /**
      * @brief Build a simple JTT92 model, with original equilibrium frequencies.
      *
      * @param alpha A proteic alphabet.
      */
-		JTT92(const ProteicAlphabet* alpha);
+    JTT92(const ProteicAlphabet* alpha);
 
     /**
      * @brief Build a JTT92 model with special equilibrium frequencies.
@@ -86,38 +85,31 @@ class JTT92 :
      * @param initFreqs Tell if the frequency set should be initialized with the original JTT92 values.
      * Otherwise, the values of the set will be used.
      */
-		JTT92(const ProteicAlphabet* alpha, ProteinFrequenciesSet* freqSet, bool initFreqs=false);
+    JTT92(const ProteicAlphabet* alpha, ProteinFrequenciesSet* freqSet, bool initFreqs=false);
 
     JTT92(const JTT92& model) :
       AbstractParameterAliasable(model),
-      //AbstractSubstitutionModel(model),
-      AbstractReversibleSubstitutionModel(model),
+      AbstractReversibleProteinSubstitutionModel(model),
       freqSet_(dynamic_cast<ProteinFrequenciesSet *>(model.freqSet_->clone()))
     {}
 
     JTT92& operator=(const JTT92& model)
     {
       AbstractParameterAliasable::operator=(model);
-      AbstractSubstitutionModel::operator=(model);
-      AbstractReversibleSubstitutionModel::operator=(model);
+      AbstractReversibleProteinSubstitutionModel::operator=(model);
       if (freqSet_) delete freqSet_;
       freqSet_ = dynamic_cast<ProteinFrequenciesSet *>(model.freqSet_->clone());
       return *this;
     }
 
-		virtual ~JTT92() { delete freqSet_; }
+    virtual ~JTT92() { delete freqSet_; }
 
-#ifndef NO_VIRTUAL_COV
-    JTT92*
-#else
-    Clonable*
-#endif
-    clone() const { return new JTT92(*this); }
+    JTT92* clone() const { return new JTT92(*this); }
 
-	public:
+  public:
     std::string getName() const 
     { 
-      if (freqSet_->getNamespace().find("JTT92+F.")!=std::string::npos)
+      if (freqSet_->getNamespace().find("JTT92+F.") != std::string::npos)
         return "JTT92+F"; 
       else 
         return "JTT92"; 
@@ -146,5 +138,5 @@ class JTT92 :
 
 } //end of namespace bpp.
 
-#endif	//_JTT92_H_
+#endif  //_JTT92_H_
 
diff --git a/src/Bpp/Phyl/Model/Protein/LG08.cpp b/src/Bpp/Phyl/Model/Protein/LG08.cpp
index a27602c..2cb89a4 100644
--- a/src/Bpp/Phyl/Model/Protein/LG08.cpp
+++ b/src/Bpp/Phyl/Model/Protein/LG08.cpp
@@ -52,7 +52,7 @@ using namespace std;
 
 LG08::LG08(const ProteicAlphabet* alpha) :
   AbstractParameterAliasable("LG08."),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "LG08."),
+  AbstractReversibleProteinSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "LG08."),
   freqSet_(0)
 {
   #include "__LG08ExchangeabilityCode"
@@ -63,15 +63,19 @@ LG08::LG08(const ProteicAlphabet* alpha) :
 
 LG08::LG08(const ProteicAlphabet* alpha, ProteinFrequenciesSet* freqSet, bool initFreqs) :
   AbstractParameterAliasable("LG08+F."),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "LG08+F."),
+  AbstractReversibleProteinSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "LG08+F."),
   freqSet_(freqSet)
 {
   #include "__LG08ExchangeabilityCode"
   #include "__LG08FrequenciesCode"
   freqSet_->setNamespace("LG08+F."+freqSet_->getNamespace());
-  if (initFreqs) freqSet_->setFrequencies(freq_);
-  else freq_ = freqSet_->getFrequencies();
+  if (initFreqs)
+    freqSet_->setFrequencies(freq_);
+  else
+    freq_ = freqSet_->getFrequencies();
+
   addParameters_(freqSet_->getParameters());
+  
   updateMatrices();  
 }
 
diff --git a/src/Bpp/Phyl/Model/Protein/LG08.h b/src/Bpp/Phyl/Model/Protein/LG08.h
index bacad8b..b6ee317 100644
--- a/src/Bpp/Phyl/Model/Protein/LG08.h
+++ b/src/Bpp/Phyl/Model/Protein/LG08.h
@@ -62,8 +62,7 @@ namespace bpp
    * - Le, Si Q. and Gascuel, O. (2008), _Molecular Biology And Evolution_ 25, 1307--1320. 
    */
   class LG08 :
-    public virtual ProteinSubstitutionModel,
-    public AbstractReversibleSubstitutionModel
+    public AbstractReversibleProteinSubstitutionModel
   {
   private:
     ProteinFrequenciesSet* freqSet_;
@@ -88,16 +87,14 @@ namespace bpp
 
     LG08(const LG08& model) :
       AbstractParameterAliasable(model),
-      //AbstractSubstitutionModel(model),
-      AbstractReversibleSubstitutionModel(model),
+      AbstractReversibleProteinSubstitutionModel(model),
       freqSet_(dynamic_cast<ProteinFrequenciesSet*>(model.freqSet_->clone()))
     {}
 
     LG08& operator=(const LG08& model)
     {
       AbstractParameterAliasable::operator=(model);
-      AbstractSubstitutionModel::operator=(model);
-      AbstractReversibleSubstitutionModel::operator=(model);
+      AbstractReversibleProteinSubstitutionModel::operator=(model);
       if (freqSet_) delete freqSet_;
       freqSet_ = dynamic_cast<ProteinFrequenciesSet*>(model.freqSet_->clone());
       return *this;
@@ -105,12 +102,7 @@ namespace bpp
 
     virtual ~LG08() { delete freqSet_; }
 
-#ifndef NO_VIRTUAL_COV
-    LG08*
-#else
-    Clonable*
-#endif
-    clone() const { return new LG08(*this); }
+    LG08* clone() const { return new LG08(*this); }
 
   public:
     std::string getName() const 
diff --git a/src/Bpp/Phyl/Model/Protein/LG10_EX_EHO.cpp b/src/Bpp/Phyl/Model/Protein/LG10_EX_EHO.cpp
index bb3e2f4..ad4a626 100644
--- a/src/Bpp/Phyl/Model/Protein/LG10_EX_EHO.cpp
+++ b/src/Bpp/Phyl/Model/Protein/LG10_EX_EHO.cpp
@@ -49,7 +49,7 @@ using namespace std;
 
 LG10_EX_EHO::LG10_EX_EHO(const ProteicAlphabet* alpha) : 
   AbstractBiblioMixedSubstitutionModel("LG10_EX_EHO."),
-  pmixmodel_(0)
+  pmixmodel_()
 {
   // build the submodel
 	
@@ -107,7 +107,7 @@ LG10_EX_EHO::~LG10_EX_EHO()
 
 LG10_EX_EHO::EmbeddedModel::EmbeddedModel(const ProteicAlphabet* alpha, string name) :
   AbstractParameterAliasable(name),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), name), 
+  AbstractReversibleProteinSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), name), 
   proportion_(1), 
   name_(name)
 {
diff --git a/src/Bpp/Phyl/Model/Protein/LG10_EX_EHO.h b/src/Bpp/Phyl/Model/Protein/LG10_EX_EHO.h
index 5d9526b..ad88f1f 100644
--- a/src/Bpp/Phyl/Model/Protein/LG10_EX_EHO.h
+++ b/src/Bpp/Phyl/Model/Protein/LG10_EX_EHO.h
@@ -71,14 +71,12 @@ namespace bpp
  *
  * Le S.Q., Gascuel O. (2010) Syst. Biol. 59(3):277–287
  */
-
 class LG10_EX_EHO :
   public AbstractBiblioMixedSubstitutionModel
 {
 public:
   class EmbeddedModel :
-    public virtual ProteinSubstitutionModel,
-    public AbstractReversibleSubstitutionModel
+    public AbstractReversibleProteinSubstitutionModel
   {
 private:
     double proportion_;
@@ -86,14 +84,14 @@ private:
 
 public:
     EmbeddedModel(const ProteicAlphabet* alpha, string name);
-    ~EmbeddedModel(){}
+    virtual ~EmbeddedModel() {}
     EmbeddedModel* clone() const { return new EmbeddedModel(*this); }
     string getName() const { return name_;}
     double getProportion() const { return proportion_;}
   };
 
 private:
-  std::auto_ptr<MixtureOfSubstitutionModels> pmixmodel_;
+  std::unique_ptr<MixtureOfSubstitutionModels> pmixmodel_;
 
 public:
   /**
diff --git a/src/Bpp/Phyl/Model/Protein/LGL08_CAT.cpp b/src/Bpp/Phyl/Model/Protein/LGL08_CAT.cpp
index 04e125c..4b0dbe3 100644
--- a/src/Bpp/Phyl/Model/Protein/LGL08_CAT.cpp
+++ b/src/Bpp/Phyl/Model/Protein/LGL08_CAT.cpp
@@ -49,13 +49,13 @@ using namespace std;
 
 LGL08_CAT::LGL08_CAT(const ProteicAlphabet* alpha, unsigned int nbCat) :
   AbstractBiblioMixedSubstitutionModel("LGL08_CAT."),
-  pmixmodel_(0)
+  pmixmodel_()
 {
   // build the submodel
 
   vector<SubstitutionModel*> vpSM;
   for(unsigned int i = 1; i < nbCat + 1; i++)
-	vpSM.push_back(new LGL08_CAT::EmbeddedModel(alpha, "C" + TextTools::toString(i), nbCat));
+  vpSM.push_back(new LGL08_CAT::EmbeddedModel(alpha, "C" + TextTools::toString(i), nbCat));
 
   Vdouble vrate, vproba;
 
@@ -102,20 +102,20 @@ LGL08_CAT::~LGL08_CAT() {}
 
 LGL08_CAT::EmbeddedModel::EmbeddedModel(const ProteicAlphabet* alpha, string name, unsigned int nbCat) :
   AbstractParameterAliasable(name),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), name),
+  AbstractReversibleProteinSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), name),
   proportion_(1),
   name_(name)
 {
   //Exchangeabilities:
   for(unsigned int i = 0; i < 20; i++)
   {
-	for(unsigned int j = 0; j < 20; j++)
-	{
-	  if(i == j)
-		exchangeability_(i,i) = -19.;
-	  else
-		exchangeability_(i,j) = 1.;
-	}
+  for(unsigned int j = 0; j < 20; j++)
+  {
+    if(i == j)
+    exchangeability_(i,i) = -19.;
+    else
+    exchangeability_(i,j) = 1.;
+  }
   }
   
   //Equilibrium frequencies, rates and proportions:
@@ -127,30 +127,30 @@ LGL08_CAT::EmbeddedModel::EmbeddedModel(const ProteicAlphabet* alpha, string nam
   else if(nbCat == 20)
   {
 #include "__CATC20FrequenciesCode"
-#include "__CATC20RatesProps"	
+#include "__CATC20RatesProps"  
   }
   else if(nbCat == 30)
   {
 #include "__CATC30FrequenciesCode"
-#include "__CATC30RatesProps"	
+#include "__CATC30RatesProps"  
   }
   else if(nbCat == 40)
   {
 #include "__CATC40FrequenciesCode"
-#include "__CATC40RatesProps"	
+#include "__CATC40RatesProps"  
   }
   else if(nbCat == 50)
   {
 #include "__CATC50FrequenciesCode"
-#include "__CATC50RatesProps"	
+#include "__CATC50RatesProps"  
   }
   else if(nbCat == 60)
   {
 #include "__CATC60FrequenciesCode"
-#include "__CATC60RatesProps"	
+#include "__CATC60RatesProps"  
   }
   else
-	throw Exception("LGL08_CAT.cpp: incorrect number of profiles. This number has to be 10, 20, 30, 40, 50 or 60.");
+  throw Exception("LGL08_CAT.cpp: incorrect number of profiles. This number has to be 10, 20, 30, 40, 50 or 60.");
   
   updateMatrices();
 }
diff --git a/src/Bpp/Phyl/Model/Protein/LGL08_CAT.h b/src/Bpp/Phyl/Model/Protein/LGL08_CAT.h
index 97f916b..ff87244 100644
--- a/src/Bpp/Phyl/Model/Protein/LGL08_CAT.h
+++ b/src/Bpp/Phyl/Model/Protein/LGL08_CAT.h
@@ -76,8 +76,7 @@ class LGL08_CAT :
 {
 public:
   class EmbeddedModel :
-    public virtual ProteinSubstitutionModel,
-    public AbstractReversibleSubstitutionModel
+    public AbstractReversibleProteinSubstitutionModel
   {
 private:
     double proportion_;
@@ -85,14 +84,14 @@ private:
 
 public:
     EmbeddedModel(const ProteicAlphabet* alpha, string name, unsigned int nbCat = 10);
-    ~EmbeddedModel(){}
+    virtual ~EmbeddedModel(){}
     EmbeddedModel* clone() const { return new EmbeddedModel(*this); }
     string getName() const { return name_;}
     double getProportion() const { return proportion_;}
   };
 
 private:
-  std::auto_ptr<MixtureOfSubstitutionModels> pmixmodel_;
+  std::unique_ptr<MixtureOfSubstitutionModels> pmixmodel_;
 
 public:
   /**
diff --git a/src/Bpp/Phyl/Model/Protein/LLG08_EHO.cpp b/src/Bpp/Phyl/Model/Protein/LLG08_EHO.cpp
index ae4327c..5c537d2 100644
--- a/src/Bpp/Phyl/Model/Protein/LLG08_EHO.cpp
+++ b/src/Bpp/Phyl/Model/Protein/LLG08_EHO.cpp
@@ -49,7 +49,7 @@ using namespace std;
 
 LLG08_EHO::LLG08_EHO(const ProteicAlphabet* alpha) :
   AbstractBiblioMixedSubstitutionModel("LLG08_EHO."),
-  pmixmodel_(0)
+  pmixmodel_()
 {
   // build the submodel
 
@@ -102,7 +102,7 @@ LLG08_EHO::~LLG08_EHO() {}
 
 LLG08_EHO::EmbeddedModel::EmbeddedModel(const ProteicAlphabet* alpha, string name) :
   AbstractParameterAliasable(name),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), name),
+  AbstractReversibleProteinSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), name),
   proportion_(1),
   name_(name)
 {
diff --git a/src/Bpp/Phyl/Model/Protein/LLG08_EHO.h b/src/Bpp/Phyl/Model/Protein/LLG08_EHO.h
index 844def4..1daaa27 100644
--- a/src/Bpp/Phyl/Model/Protein/LLG08_EHO.h
+++ b/src/Bpp/Phyl/Model/Protein/LLG08_EHO.h
@@ -80,8 +80,7 @@ class LLG08_EHO :
 {
 public:
   class EmbeddedModel :
-    public virtual ProteinSubstitutionModel,
-    public AbstractReversibleSubstitutionModel
+    public AbstractReversibleProteinSubstitutionModel
   {
 private:
     double proportion_;
@@ -89,14 +88,14 @@ private:
 
 public:
     EmbeddedModel(const ProteicAlphabet* alpha, string name);
-    ~EmbeddedModel(){}
+    virtual ~EmbeddedModel(){}
     EmbeddedModel* clone() const { return new EmbeddedModel(*this); }
     string getName() const { return name_;}
     double getProportion() const { return proportion_;}
   };
 
 private:
-  auto_ptr<MixtureOfSubstitutionModels> pmixmodel_;
+  unique_ptr<MixtureOfSubstitutionModels> pmixmodel_;
 
 public:
   /**
diff --git a/src/Bpp/Phyl/Model/Protein/LLG08_EX2.cpp b/src/Bpp/Phyl/Model/Protein/LLG08_EX2.cpp
index 6820f93..4cc149e 100644
--- a/src/Bpp/Phyl/Model/Protein/LLG08_EX2.cpp
+++ b/src/Bpp/Phyl/Model/Protein/LLG08_EX2.cpp
@@ -49,7 +49,7 @@ using namespace std;
 
 LLG08_EX2::LLG08_EX2(const ProteicAlphabet* alpha) :
   AbstractBiblioMixedSubstitutionModel("LLG08_EX2."),
-  pmixmodel_(0)
+  pmixmodel_()
 {
   // build the submodel
 
@@ -102,7 +102,7 @@ LLG08_EX2::~LLG08_EX2() {}
 
 LLG08_EX2::EmbeddedModel::EmbeddedModel(const ProteicAlphabet* alpha, string name) :
   AbstractParameterAliasable(name),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), name),
+  AbstractReversibleProteinSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), name),
   proportion_(1),
   name_(name)
 {
diff --git a/src/Bpp/Phyl/Model/Protein/LLG08_EX2.h b/src/Bpp/Phyl/Model/Protein/LLG08_EX2.h
index ec50265..4c1165d 100644
--- a/src/Bpp/Phyl/Model/Protein/LLG08_EX2.h
+++ b/src/Bpp/Phyl/Model/Protein/LLG08_EX2.h
@@ -76,8 +76,7 @@ class LLG08_EX2 :
 {
 public:
   class EmbeddedModel :
-    public virtual ProteinSubstitutionModel,
-    public AbstractReversibleSubstitutionModel
+    public AbstractReversibleProteinSubstitutionModel
   {
 private:
     double proportion_;
@@ -85,14 +84,14 @@ private:
 
 public:
     EmbeddedModel(const ProteicAlphabet* alpha, string name);
-    ~EmbeddedModel(){}
+    virtual ~EmbeddedModel(){}
     EmbeddedModel* clone() const { return new EmbeddedModel(*this); }
     string getName() const { return name_;}
     double getProportion() const { return proportion_;}
   };
 
 private:
-  std::auto_ptr<MixtureOfSubstitutionModels> pmixmodel_;
+  std::unique_ptr<MixtureOfSubstitutionModels> pmixmodel_;
 
 public:
   /**
@@ -104,7 +103,7 @@ public:
 
   LLG08_EX2(const ProteicAlphabet* alpha);
 
-  ~LLG08_EX2();
+  virtual ~LLG08_EX2();
 
   LLG08_EX2* clone() const { return new LLG08_EX2(*this); }
 
diff --git a/src/Bpp/Phyl/Model/Protein/LLG08_EX3.cpp b/src/Bpp/Phyl/Model/Protein/LLG08_EX3.cpp
index 31c7e49..5ebcb1a 100644
--- a/src/Bpp/Phyl/Model/Protein/LLG08_EX3.cpp
+++ b/src/Bpp/Phyl/Model/Protein/LLG08_EX3.cpp
@@ -49,7 +49,7 @@ using namespace std;
 
 LLG08_EX3::LLG08_EX3(const ProteicAlphabet* alpha) :
   AbstractBiblioMixedSubstitutionModel("LLG08_EX3."),
-  pmixmodel_(0)
+  pmixmodel_()
 {
   // build the submodel
 
@@ -103,7 +103,7 @@ LLG08_EX3::~LLG08_EX3() {}
 
 LLG08_EX3::EmbeddedModel::EmbeddedModel(const ProteicAlphabet* alpha, string name) :
   AbstractParameterAliasable(name),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), name),
+  AbstractReversibleProteinSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), name),
   proportion_(1),
   name_(name)
 {
diff --git a/src/Bpp/Phyl/Model/Protein/LLG08_EX3.h b/src/Bpp/Phyl/Model/Protein/LLG08_EX3.h
index 8b50333..efbb5df 100644
--- a/src/Bpp/Phyl/Model/Protein/LLG08_EX3.h
+++ b/src/Bpp/Phyl/Model/Protein/LLG08_EX3.h
@@ -81,8 +81,7 @@ class LLG08_EX3 :
 {
 public:
   class EmbeddedModel :
-    public virtual ProteinSubstitutionModel,
-    public AbstractReversibleSubstitutionModel
+    public AbstractReversibleProteinSubstitutionModel
   {
 private:
     double proportion_;
@@ -97,7 +96,7 @@ public:
   };
 
 private:
-  std::auto_ptr<MixtureOfSubstitutionModels> pmixmodel_;
+  std::unique_ptr<MixtureOfSubstitutionModels> pmixmodel_;
 
 public:
   /**
diff --git a/src/Bpp/Phyl/Model/Protein/LLG08_UL2.cpp b/src/Bpp/Phyl/Model/Protein/LLG08_UL2.cpp
index 4b40dc6..cafe1f7 100644
--- a/src/Bpp/Phyl/Model/Protein/LLG08_UL2.cpp
+++ b/src/Bpp/Phyl/Model/Protein/LLG08_UL2.cpp
@@ -49,7 +49,7 @@ using namespace std;
 
 LLG08_UL2::LLG08_UL2(const ProteicAlphabet* alpha) :
   AbstractBiblioMixedSubstitutionModel("LLG08_UL2."),
-  pmixmodel_(0)
+  pmixmodel_()
 {
   // build the submodel
 
@@ -102,7 +102,7 @@ LLG08_UL2::~LLG08_UL2() {}
 
 LLG08_UL2::EmbeddedModel::EmbeddedModel(const ProteicAlphabet* alpha, string name) :
   AbstractParameterAliasable(name),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), name),
+  AbstractReversibleProteinSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), name),
   proportion_(1),
   name_(name)
 {
diff --git a/src/Bpp/Phyl/Model/Protein/LLG08_UL2.h b/src/Bpp/Phyl/Model/Protein/LLG08_UL2.h
index 58e6a9c..031fbb2 100644
--- a/src/Bpp/Phyl/Model/Protein/LLG08_UL2.h
+++ b/src/Bpp/Phyl/Model/Protein/LLG08_UL2.h
@@ -76,8 +76,7 @@ class LLG08_UL2 :
 {
 public:
   class EmbeddedModel :
-    public virtual ProteinSubstitutionModel,
-    public AbstractReversibleSubstitutionModel
+    public AbstractReversibleProteinSubstitutionModel
   {
 private:
     double proportion_;
@@ -85,14 +84,14 @@ private:
 
 public:
     EmbeddedModel(const ProteicAlphabet* alpha, string name);
-    ~EmbeddedModel(){}
+    virtual ~EmbeddedModel() {}
     EmbeddedModel* clone() const { return new EmbeddedModel(*this); }
     string getName() const { return name_;}
     double getProportion() const { return proportion_;}
   };
 
 private:
-  std::auto_ptr<MixtureOfSubstitutionModels> pmixmodel_;
+  std::unique_ptr<MixtureOfSubstitutionModels> pmixmodel_;
 
 public:
   /**
diff --git a/src/Bpp/Phyl/Model/Protein/LLG08_UL3.cpp b/src/Bpp/Phyl/Model/Protein/LLG08_UL3.cpp
index 2bb1fad..90acf9a 100644
--- a/src/Bpp/Phyl/Model/Protein/LLG08_UL3.cpp
+++ b/src/Bpp/Phyl/Model/Protein/LLG08_UL3.cpp
@@ -49,7 +49,7 @@ using namespace std;
 
 LLG08_UL3::LLG08_UL3(const ProteicAlphabet* alpha) :
   AbstractBiblioMixedSubstitutionModel("LLG08_UL3."),
-  pmixmodel_(0)
+  pmixmodel_()
 {
   // build the submodel
 
@@ -103,7 +103,7 @@ LLG08_UL3::~LLG08_UL3() {}
 
 LLG08_UL3::EmbeddedModel::EmbeddedModel(const ProteicAlphabet* alpha, string name) :
   AbstractParameterAliasable(name),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), name),
+  AbstractReversibleProteinSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), name),
   proportion_(1),
   name_(name)
 {
diff --git a/src/Bpp/Phyl/Model/Protein/LLG08_UL3.h b/src/Bpp/Phyl/Model/Protein/LLG08_UL3.h
index 1ccce18..a8e867b 100644
--- a/src/Bpp/Phyl/Model/Protein/LLG08_UL3.h
+++ b/src/Bpp/Phyl/Model/Protein/LLG08_UL3.h
@@ -80,8 +80,7 @@ class LLG08_UL3 :
 {
 public:
   class EmbeddedModel :
-    public virtual ProteinSubstitutionModel,
-    public AbstractReversibleSubstitutionModel
+    public AbstractReversibleProteinSubstitutionModel
   {
 private:
     double proportion_;
@@ -89,14 +88,14 @@ private:
 
 public:
     EmbeddedModel(const ProteicAlphabet* alpha, string name);
-    ~EmbeddedModel(){}
+    virtual ~EmbeddedModel(){}
     EmbeddedModel* clone() const { return new EmbeddedModel(*this); }
     string getName() const { return name_;}
     double getProportion() const { return proportion_;}
   };
 
 private:
-  std::auto_ptr<MixtureOfSubstitutionModels> pmixmodel_;
+  std::unique_ptr<MixtureOfSubstitutionModels> pmixmodel_;
 
 public:
   /**
diff --git a/src/Bpp/Phyl/Model/Protein/ProteinSubstitutionModel.h b/src/Bpp/Phyl/Model/Protein/ProteinSubstitutionModel.h
index ad4c40c..8ac5eb6 100755
--- a/src/Bpp/Phyl/Model/Protein/ProteinSubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/Protein/ProteinSubstitutionModel.h
@@ -41,8 +41,9 @@ knowledge of the CeCILL license and that you accept its terms.
 #define _PROTEINSUBSTITUTIONMODEL_H_
 
 #include "../SubstitutionModel.h"
+#include "../AbstractSubstitutionModel.h"
 
-// From SeqLib:
+// From bpp-seq:
 #include <Bpp/Seq/Alphabet/ProteicAlphabet.h>
 
 namespace bpp
@@ -54,22 +55,86 @@ namespace bpp
 class ProteinSubstitutionModel:
   public virtual SubstitutionModel
 {
-	public:
-		virtual ~ProteinSubstitutionModel() {}
-
-#ifndef NO_VIRTUAL_COV
-    ProteinSubstitutionModel*
-#else
-    Clonable*
-#endif
-    clone() const = 0;
-		
+  public:
+    virtual ~ProteinSubstitutionModel() {}
+
+    ProteinSubstitutionModel* clone() const = 0;
+    
   public:
     size_t getNumberOfStates() const { return 20; };
 
+    const ProteicAlphabet* getAlphabet() const = 0;
 };
 
+
+
+/**
+ * @brief Specialized interface for protein reversible substitution model.
+ */
+class ProteinReversibleSubstitutionModel:
+  public virtual ProteinSubstitutionModel,
+  public virtual ReversibleSubstitutionModel
+{
+  public:
+    virtual ~ProteinReversibleSubstitutionModel() {}
+
+    ProteinReversibleSubstitutionModel* clone() const = 0;
+    
+};
+
+
+/**
+ * @brief Specialisation abstract class for protein substitution model.
+ */
+  class AbstractProteinSubstitutionModel :
+    public AbstractSubstitutionModel,
+    public virtual ProteinSubstitutionModel
+  {
+  public:
+    AbstractProteinSubstitutionModel(const ProteicAlphabet* alpha, StateMap* stateMap, const std::string& prefix):
+      AbstractParameterAliasable(prefix),
+      AbstractSubstitutionModel(alpha, stateMap, prefix) {}
+
+    virtual ~AbstractProteinSubstitutionModel() {}
+    
+    AbstractProteinSubstitutionModel* clone() const = 0;
+
+  public:
+    
+    const ProteicAlphabet* getAlphabet() const {
+      return dynamic_cast<const ProteicAlphabet*>(alphabet_);
+    }
+    
+  };
+
+/**
+ * @brief Specialisation abstract class for reversible protein substitution model.
+ */
+  class AbstractReversibleProteinSubstitutionModel :
+    public AbstractReversibleSubstitutionModel,
+    public virtual ProteinSubstitutionModel
+  {
+  public:
+    AbstractReversibleProteinSubstitutionModel(const ProteicAlphabet* alpha, StateMap* stateMap, const std::string& prefix):
+      AbstractParameterAliasable(prefix),
+      AbstractReversibleSubstitutionModel(alpha, stateMap, prefix) {}
+
+    virtual ~AbstractReversibleProteinSubstitutionModel() {}
+    
+    AbstractReversibleProteinSubstitutionModel* clone() const = 0;
+    
+  public:
+    const ProteicAlphabet* getAlphabet() const {
+      return dynamic_cast<const ProteicAlphabet*>(alphabet_);
+    }
+
+  };
+
+
+
+
+
 } //end of namespace bpp.
 
-#endif	//_PROTEINSUBSTITUTIONMODEL_H_
+#endif  //_PROTEINSUBSTITUTIONMODEL_H_
 
diff --git a/src/Bpp/Phyl/Model/Protein/UserProteinSubstitutionModel.cpp b/src/Bpp/Phyl/Model/Protein/UserProteinSubstitutionModel.cpp
index 0a44552..9a8bd30 100755
--- a/src/Bpp/Phyl/Model/Protein/UserProteinSubstitutionModel.cpp
+++ b/src/Bpp/Phyl/Model/Protein/UserProteinSubstitutionModel.cpp
@@ -44,6 +44,7 @@ knowledge of the CeCILL license and that you accept its terms.
 #include <Bpp/Text/TextTools.h>
 #include <Bpp/Text/StringTokenizer.h>
 #include <Bpp/Numeric/VectorTools.h>
+#include <Bpp/Io/FileTools.h>
 
 //From SeqLib:
 #include <Bpp/Seq/Container/SequenceContainerTools.h>
@@ -62,7 +63,7 @@ using namespace std;
 UserProteinSubstitutionModel::UserProteinSubstitutionModel(
     const ProteicAlphabet* alpha, const std::string& path, const std::string& prefix) : 
   AbstractParameterAliasable(prefix),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), prefix),
+  AbstractReversibleProteinSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), prefix),
   path_(path),
   freqSet_(0)
 {
@@ -76,7 +77,7 @@ UserProteinSubstitutionModel::UserProteinSubstitutionModel(
     ProteinFrequenciesSet* freqSet, const std::string& prefix,
     bool initFreqs) : 
   AbstractParameterAliasable(prefix),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), prefix),
+  AbstractReversibleProteinSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), prefix),
   path_(path),
   freqSet_(freqSet)
 {
@@ -102,6 +103,9 @@ std::string UserProteinSubstitutionModel::getName() const
 
 void UserProteinSubstitutionModel::readFromFile()
 {
+  if (!FileTools::fileExists(path_.c_str()))
+    throw Exception("UserProteinSubstitutionModel::readFromFile. Frequencies file not found : " +  path_);
+  
   ifstream in(path_.c_str(), ios::in);
   //Read exchangeability matrix:
   for (unsigned int i = 1; i < 20; i++)
diff --git a/src/Bpp/Phyl/Model/Protein/UserProteinSubstitutionModel.h b/src/Bpp/Phyl/Model/Protein/UserProteinSubstitutionModel.h
index 5154d29..0410f18 100755
--- a/src/Bpp/Phyl/Model/Protein/UserProteinSubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/Protein/UserProteinSubstitutionModel.h
@@ -62,8 +62,7 @@ namespace bpp
    * so that \f$\sum_i Q_{i,i} \times \pi_i = -1\f$.
    */
   class UserProteinSubstitutionModel:
-    public virtual ProteinSubstitutionModel,
-    public AbstractReversibleSubstitutionModel
+    public AbstractReversibleProteinSubstitutionModel
   {
   private:
     std::string path_;
@@ -102,8 +101,7 @@ namespace bpp
 
     UserProteinSubstitutionModel(const UserProteinSubstitutionModel& model) :
       AbstractParameterAliasable(model),
-      //AbstractSubstitutionModel(model),
-      AbstractReversibleSubstitutionModel(model),
+      AbstractReversibleProteinSubstitutionModel(model),
       path_(model.path_),
       freqSet_(dynamic_cast<ProteinFrequenciesSet*>(model.freqSet_->clone()))
     {}
@@ -111,8 +109,7 @@ namespace bpp
     UserProteinSubstitutionModel& operator=(const UserProteinSubstitutionModel& model)
     {
       AbstractParameterAliasable::operator=(model);
-      AbstractSubstitutionModel::operator=(model);
-      AbstractReversibleSubstitutionModel::operator=(model);
+      AbstractReversibleProteinSubstitutionModel::operator=(model);
       path_ = model.path_;
       freqSet_ = dynamic_cast<ProteinFrequenciesSet*>(model.freqSet_->clone());
       return *this;
@@ -120,12 +117,7 @@ namespace bpp
  
     virtual ~UserProteinSubstitutionModel() { delete freqSet_; }
 
-#ifndef NO_VIRTUAL_COV
-    UserProteinSubstitutionModel*
-#else
-    Clonable*
-#endif
-    clone() const { return new UserProteinSubstitutionModel(*this); }
+    UserProteinSubstitutionModel* clone() const { return new UserProteinSubstitutionModel(*this); }
       
   public:
     std::string getName() const;
diff --git a/src/Bpp/Phyl/Model/Protein/WAG01.cpp b/src/Bpp/Phyl/Model/Protein/WAG01.cpp
index 5f80f51..5095909 100644
--- a/src/Bpp/Phyl/Model/Protein/WAG01.cpp
+++ b/src/Bpp/Phyl/Model/Protein/WAG01.cpp
@@ -49,7 +49,7 @@ using namespace std;
 
 WAG01::WAG01(const ProteicAlphabet* alpha) :
   AbstractParameterAliasable("WAG01."),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "WAG01."),
+  AbstractReversibleProteinSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "WAG01."),
   freqSet_(0)
 {
   #include "__WAG01ExchangeabilityCode"
@@ -60,7 +60,7 @@ WAG01::WAG01(const ProteicAlphabet* alpha) :
 
 WAG01::WAG01(const ProteicAlphabet* alpha, ProteinFrequenciesSet* freqSet, bool initFreqs) :
   AbstractParameterAliasable("WAG01+F."),
-  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "WAG01+F."),
+  AbstractReversibleProteinSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), "WAG01+F."),
   freqSet_(freqSet)
 {
   #include "__WAG01ExchangeabilityCode"
diff --git a/src/Bpp/Phyl/Model/Protein/WAG01.h b/src/Bpp/Phyl/Model/Protein/WAG01.h
index a1bbba0..aad704f 100644
--- a/src/Bpp/Phyl/Model/Protein/WAG01.h
+++ b/src/Bpp/Phyl/Model/Protein/WAG01.h
@@ -67,10 +67,8 @@ namespace bpp
    * maximum likelihood approach. Molecular Biology and Evolution 18:691-699.
    *
    */
-
   class WAG01 :
-    public virtual ProteinSubstitutionModel,
-    public AbstractReversibleSubstitutionModel
+    public AbstractReversibleProteinSubstitutionModel
   {
   private:
     ProteinFrequenciesSet* freqSet_;
@@ -95,16 +93,14 @@ namespace bpp
 
     WAG01(const WAG01& model) :
       AbstractParameterAliasable(model),
-      //AbstractSubstitutionModel(model),
-      AbstractReversibleSubstitutionModel(model),
+      AbstractReversibleProteinSubstitutionModel(model),
       freqSet_(dynamic_cast<ProteinFrequenciesSet *>(model.freqSet_->clone()))
     {}
 
     WAG01& operator=(const WAG01& model)
     {
       AbstractParameterAliasable::operator=(model);
-      AbstractSubstitutionModel::operator=(model);
-      AbstractReversibleSubstitutionModel::operator=(model);
+      AbstractReversibleProteinSubstitutionModel::operator=(model);
       if (freqSet_) delete freqSet_;
       freqSet_ = dynamic_cast<ProteinFrequenciesSet *>(model.freqSet_->clone());
       return *this;
@@ -112,12 +108,7 @@ namespace bpp
 
     virtual ~WAG01() { delete freqSet_; }
 
-#ifndef NO_VIRTUAL_COV
-    WAG01*
-#else
-    Clonable*
-#endif
-    clone() const { return new WAG01(*this); }
+    WAG01* clone() const { return new WAG01(*this); }
 
   public:
     std::string getName() const 
diff --git a/src/Bpp/Phyl/Model/RE08.cpp b/src/Bpp/Phyl/Model/RE08.cpp
index 8174b30..a9d9991 100755
--- a/src/Bpp/Phyl/Model/RE08.cpp
+++ b/src/Bpp/Phyl/Model/RE08.cpp
@@ -285,7 +285,7 @@ const Matrix<double>& RE08::getd2Pij_dt2(double d) const
     p_(size_ - 1, j) = - (lambda_ + mu_) * (lambda_ + mu_) * freq_[j] * exp(-(lambda_ + mu_) * d);
   }
   p_(size_ - 1, size_ - 1) = f * (lambda_ + mu_) * (lambda_ + mu_) * exp(-(lambda_ + mu_) * d);
-  for(size_t i = 0; i < size_ - 1; i++)
+  for (size_t i = 0; i < size_ - 1; i++)
   {  
     p_(i, size_ - 1) = - (lambda_ + mu_) * (lambda_ + mu_) * freq_[size_ - 1] * exp(-(lambda_ + mu_) * d);
   }
diff --git a/src/Bpp/Phyl/Model/RE08.h b/src/Bpp/Phyl/Model/RE08.h
index 395863b..5d4acbb 100755
--- a/src/Bpp/Phyl/Model/RE08.h
+++ b/src/Bpp/Phyl/Model/RE08.h
@@ -42,6 +42,9 @@
 
 #include "SubstitutionModel.h"
 #include "AbstractSubstitutionModel.h"
+#include "Nucleotide/NucleotideSubstitutionModel.h"
+#include "Protein/ProteinSubstitutionModel.h"
+#include "Codon/CodonSubstitutionModel.h"
 
 namespace bpp
 {
@@ -97,7 +100,7 @@ namespace bpp
     public AbstractReversibleSubstitutionModel
   {
   private:
-    std::auto_ptr<ReversibleSubstitutionModel> simpleModel_;
+    std::unique_ptr<ReversibleSubstitutionModel> simpleModel_;
     RowMatrix<double> simpleGenerator_;
     RowMatrix<double> simpleExchangeabilities_;
     mutable double exp_;
@@ -118,7 +121,7 @@ namespace bpp
      * @param lambda Insertion rate.
      * @param mu     Deletion rate.
      */
-    RE08(ReversibleSubstitutionModel* simpleModel, double lambda = 0, double mu = 0);
+    RE08(ReversibleSubstitutionModel* simpleModel, double lambda = 0.1, double mu = 0.1);
 
     RE08(const RE08& model):
       AbstractParameterAliasable(model),
@@ -191,13 +194,139 @@ namespace bpp
   
     void setNamespace(const std::string& prefix);
 
-    const SubstitutionModel* getNestedModel() const { return simpleModel_.get(); }
+    const ReversibleSubstitutionModel* getNestedModel() const { return simpleModel_.get(); }
 
   protected:
 
     void updateMatrices();
   };
 
+ 
+  
+  /**
+   * @brief This is a wrapper class of RE08 for nucleotide substitution models.
+   */
+  class RE08Nucleotide:
+    public RE08,
+    public virtual NucleotideSubstitutionModel
+  {
+  public:
+    /**
+     * @brief Build a new Rivas & Eddy model from a nucleotide
+     * substitution model.
+     * 
+     * The alphabet and number of states for the extended model will
+     * be derived from the simple one.
+     *
+     * @param nucleotideModel The simple model to use to build the
+     * extended one. THE RE08 class will own the simple one, meaning
+     * that it will be destroyed together with the RE08 instance, and
+     * cloned when cloning the RE08 instance. To prevent the original
+     * simple model to be destroyed, you should make a copy of it
+     * before creating the RE08 instance.
+     * @param lambda Insertion rate.
+     * @param mu     Deletion rate.
+     */
+    RE08Nucleotide(NucleotideReversibleSubstitutionModel* nucleotideModel, double lambda = 0.1, double mu = 0.1):
+      AbstractParameterAliasable("RE08."),
+      RE08(nucleotideModel, lambda, mu) {};
+
+    virtual ~RE08Nucleotide() {}
+
+    RE08Nucleotide* clone() const { return new RE08Nucleotide(*this); }
+
+  public:
+    const NucleicAlphabet* getAlphabet() const { return dynamic_cast<const NucleicAlphabet*>(alphabet_); }
+    const NucleotideReversibleSubstitutionModel* getNestedModel() const {
+      return dynamic_cast<const NucleotideReversibleSubstitutionModel*>(RE08::getNestedModel());
+    }
+    
+    size_t getNumberOfStates() const { return RE08::getNumberOfStates(); }
+
+  };
+ 
+  /**
+   * @brief This is a wrapper class of RE08 for protein substitution models.
+   */
+  class RE08Protein:
+    public RE08,
+    public virtual ProteinSubstitutionModel
+  {
+  public:
+    /**
+     * @brief Build a new Rivas & Eddy model from a protein substitution model.
+     * 
+     * The alphabet and number of states for the extended model will be derived from the simple one.
+     *
+     * @param proteinModel The simple model to use to build the extended one.
+     * THE RE08 class will own the simple one, meaning that it will be destroyed together with the RE08 instance, and cloned when cloning the RE08 instance.
+     * To prevent the original simple model to be destroyed, you should make a copy of it before creating the RE08 instance.
+     * @param lambda Insertion rate.
+     * @param mu     Deletion rate.
+     */
+    RE08Protein(ProteinReversibleSubstitutionModel* proteinModel, double lambda = 0.1, double mu = 0.1):
+      AbstractParameterAliasable("RE08."),
+      RE08(proteinModel, lambda, mu) {};
+
+    virtual ~RE08Protein() {}
+
+    RE08Protein* clone() const { return new RE08Protein(*this); }
+
+  public:
+    const ProteicAlphabet* getAlphabet() const { return dynamic_cast<const ProteicAlphabet*>(alphabet_); }
+    const ProteinReversibleSubstitutionModel* getNestedModel() const {
+      return dynamic_cast<const ProteinReversibleSubstitutionModel*>(RE08::getNestedModel());
+    }
+
+    size_t getNumberOfStates() const { return RE08::getNumberOfStates(); }
+  };
+
+
+
+  /**
+   * @brief This is a wrapper class of RE08 for codon substitution models.
+   */
+  class RE08Codon:
+    public RE08,
+    public virtual CodonSubstitutionModel
+  {
+  public:
+    /**
+     * @brief Build a new Rivas & Eddy model from a codon substitution model.
+     * 
+     * The alphabet and number of states for the extended model will be derived from the simple one.
+     *
+     * @param codonModel The simple model to use to build the extended one.
+     * THE RE08 class will own the simple one, meaning that it will be destroyed together with the RE08 instance, and cloned when cloning the RE08 instance.
+     * To prevent the original simple model to be destroyed, you should make a copy of it before creating the RE08 instance.
+     * @param lambda Insertion rate.
+     * @param mu     Deletion rate.
+     */
+    RE08Codon(CodonReversibleSubstitutionModel* codonModel, double lambda = 0.1, double mu = 0.1):
+      AbstractParameterAliasable("RE08."),
+      RE08(codonModel, lambda, mu) {};
+
+    virtual ~RE08Codon() {}
+
+    RE08Codon* clone() const { return new RE08Codon(*this); }
+
+  public:
+    const CodonReversibleSubstitutionModel* getNestedModel() const {
+      return dynamic_cast<const CodonReversibleSubstitutionModel*>(RE08::getNestedModel());
+    }
+
+    const GeneticCode* getGeneticCode () const {
+      return getNestedModel()->getGeneticCode();
+    }
+
+    double	getCodonsMulRate (size_t i, size_t j) const { 
+      return getNestedModel()->getCodonsMulRate(i, j);
+    }
+
+    size_t getNumberOfStates() const { return RE08::getNumberOfStates(); }
+  };
+
+
 } //end of namespace bpp.
 
 #endif	//_RE08_H_
diff --git a/src/Bpp/Phyl/Model/RateDistribution/ConstantRateDistribution.h b/src/Bpp/Phyl/Model/RateDistribution/ConstantRateDistribution.h
index 8143e78..93e8f47 100644
--- a/src/Bpp/Phyl/Model/RateDistribution/ConstantRateDistribution.h
+++ b/src/Bpp/Phyl/Model/RateDistribution/ConstantRateDistribution.h
@@ -53,7 +53,7 @@ class ConstantRateDistribution:
       AbstractParameterAliasable("Constant."),
       ConstantDistribution(1.)
     {
-      deleteParameter_(0);
+      resetParameters_();
     }
 
     ConstantRateDistribution* clone() const { return new ConstantRateDistribution(*this); }
diff --git a/src/Bpp/Phyl/Model/RateDistributionFactory.h b/src/Bpp/Phyl/Model/RateDistributionFactory.h
deleted file mode 100644
index 79a5fe5..0000000
--- a/src/Bpp/Phyl/Model/RateDistributionFactory.h
+++ /dev/null
@@ -1,110 +0,0 @@
-//
-// File: RateDistributionFactory.h
-// Created by: Julien Dutheil
-//             Vincent Ranwez
-// Created on: Fri apr 14 11:11 2006
-//
-
-/*
-Copyright or © or Copr. Bio++ Development Team, (November 16, 2004, 2005, 2006)
-
-This software is a computer program whose purpose is to provide classes
-for phylogenetic data analysis.
-
-This software is governed by the CeCILL  license under French law and
-abiding by the rules of distribution of free software.  You can  use, 
-modify and/ or redistribute the software under the terms of the CeCILL
-license as circulated by CEA, CNRS and INRIA at the following URL
-"http://www.cecill.info". 
-
-As a counterpart to the access to the source code and  rights to copy,
-modify and redistribute granted by the license, users are provided only
-with a limited warranty  and the software's author,  the holder of the
-economic rights,  and the successive licensors  have only  limited
-liability. 
-
-In this respect, the user's attention is drawn to the risks associated
-with loading,  using,  modifying and/or developing or reproducing the
-software by the user in light of its specific status of free software,
-that may mean  that it is complicated to manipulate,  and  that  also
-therefore means  that it is reserved for developers  and  experienced
-professionals having in-depth computer knowledge. Users are therefore
-encouraged to load and test the software's suitability as regards their
-requirements in conditions enabling the security of their systems and/or 
-data to be ensured and,  more generally, to use and operate it in the 
-same conditions as regards security. 
-
-The fact that you are presently reading this means that you have had
-knowledge of the CeCILL license and that you accept its terms.
-*/
-
-#ifndef _RATEDISTRIBUTIONFACTORY_H_
-#define _RATEDISTRIBUTIONFACTORY_H_
-
-#include <Bpp/Numeric/Prob/DiscreteDistribution.h>
-
-// From the STL:
-#include <string>
-
-namespace bpp
-{
-
-/**
- * @brief Utilitary class for creating rate distributions.
- *
- * @see SubstitutionModelFactory
- */
-class RateDistributionFactory
-{
-public:
-  static const std::string CONSTANT_DISTRIBUTION;
-  static const std::string GAMMA_DISTRIBUTION;
-  static const std::string GAUSSIAN_DISTRIBUTION;
-  static const std::string EXPONENTIAL_DISTRIBUTION;
-
-private:
-  unsigned int nbClasses_; // For discrete distributions. 
-  
-public:
-  /**
-   * @brief Creates a new factory object.
-   *
-   * Example:
-   * @code
-   * DiscreteDistribution* dist = RateDistributionFactory().createDiscreteDistribution(RateDistributionFactory::GAMMA_DISTRIBUTION);
-   * // or DiscreteDistribution* dist = RateDistributionFactory(10).createDiscreteDistribution(RateDistributionFactory::GAMMA_DISTRIBUTION);
-   * // or DiscreteDistribution* dist = RateDistributionFactory().createDiscreteDistribution(RateDistributionFactory::GAMMA_DISTRIBUTION, 10);
-   * // dist can be used in any object dealing with rate distributions.
-   * @endcode
-   */
-  RateDistributionFactory(unsigned int nbClasses = 4): nbClasses_(nbClasses) {}
-  virtual ~RateDistributionFactory() {}
-
-public:
-  /**
-   * @brief Get a new dynamically created DiscreteDistribution object.
-   *
-   * @param distName The name of the distribution to use.
-   * @param nbClasses The number of classes to use. This override the value passed to the constructor and is ignored for a constant distribution.
-   * @return A pointer toward a new discrete distribution, with default parameter values.
-   * @throw Exception If the dist name do not match any available distribution.
-   */
-  virtual DiscreteDistribution* createDiscreteDistribution(const std::string& distName, unsigned int nbClasses) throw (Exception);
-  /**
-   * @brief Get a new dynamically created DiscreteDistribution object.
-   *
-   * @param distName The name of the distribution to use.
-   * @return A pointer toward a new discrete distribution, with default parameter values.
-   * @throw Exception If the dist name do not match any available distribution.
-   */
-  virtual DiscreteDistribution* createDiscreteDistribution(const std::string& distName) throw (Exception)
-  {
-    return createDiscreteDistribution(distName, nbClasses_);
-  }
-
-};
-
-} //end of namespace bpp.
-
-#endif //_RATEDISTRIBUTIONFACTORY_H_
-
diff --git a/src/Bpp/Phyl/Model/StateMap.cpp b/src/Bpp/Phyl/Model/StateMap.cpp
index 68995d6..f3f53bd 100644
--- a/src/Bpp/Phyl/Model/StateMap.cpp
+++ b/src/Bpp/Phyl/Model/StateMap.cpp
@@ -40,6 +40,7 @@
 #include "StateMap.h"
 
 using namespace bpp;
+using namespace std;
 
 CanonicalStateMap::CanonicalStateMap(const Alphabet* alphabet, bool includeGaps):
   AbstractStateMap(alphabet)
@@ -62,7 +63,8 @@ CanonicalStateMap::CanonicalStateMap(const StateMap& sm, bool includeGaps):
 }
 
 MarkovModulatedStateMap::MarkovModulatedStateMap(const StateMap& unitMap, unsigned int nbClasses):
-  AbstractStateMap(unitMap.getAlphabet())
+  AbstractStateMap(unitMap.getAlphabet()),
+  nbClasses_(nbClasses)
 {
   for (unsigned int j = 0; j < nbClasses; ++j) {
     for (size_t i = 0; i < unitMap.getNumberOfModelStates(); ++i) {
diff --git a/src/Bpp/Phyl/Model/StateMap.h b/src/Bpp/Phyl/Model/StateMap.h
index 86a930d..1f5b3d1 100644
--- a/src/Bpp/Phyl/Model/StateMap.h
+++ b/src/Bpp/Phyl/Model/StateMap.h
@@ -5,37 +5,37 @@
 //
 
 /*
-   Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
-
-   This software is a computer program whose purpose is to provide classes
-   for phylogenetic data analysis.
-
-   This software is governed by the CeCILL  license under French law and
-   abiding by the rules of distribution of free software.  You can  use,
-   modify and/ or redistribute the software under the terms of the CeCILL
-   license as circulated by CEA, CNRS and INRIA at the following URL
-   "http://www.cecill.info".
-
-   As a counterpart to the access to the source code and  rights to copy,
-   modify and redistribute granted by the license, users are provided only
-   with a limited warranty  and the software's author,  the holder of the
-   economic rights,  and the successive licensors  have only  limited
-   liability.
-
-   In this respect, the user's attention is drawn to the risks associated
-   with loading,  using,  modifying and/or developing or reproducing the
-   software by the user in light of its specific status of free software,
-   that may mean  that it is complicated to manipulate,  and  that  also
-   therefore means  that it is reserved for developers  and  experienced
-   professionals having in-depth computer knowledge. Users are therefore
-   encouraged to load and test the software's suitability as regards their
-   requirements in conditions enabling the security of their systems and/or
-   data to be ensured and,  more generally, to use and operate it in the
-   same conditions as regards security.
-
-   The fact that you are presently reading this means that you have had
-   knowledge of the CeCILL license and that you accept its terms.
- */
+  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
+
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use,
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info".
+
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability.
+
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or
+  data to be ensured and,  more generally, to use and operate it in the
+  same conditions as regards security.
+
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
+*/
 
 #ifndef _STATEMAP_H_
 #define _STATEMAP_H_
@@ -58,51 +58,57 @@ namespace bpp
   class StateMap:
     public virtual Clonable
   {
-    public:
-      virtual ~StateMap() {}
-      virtual StateMap* clone() const = 0;
-
-    public:
-      /**
-       * @return The associated alphabet.
-       */
-      virtual const Alphabet* getAlphabet() const = 0;
-
-      /**
-       * @return The number of states supported by the model.
-       */
-      virtual size_t getNumberOfModelStates() const = 0;
-
-      /**
-       * @return A vector with the corresponding alphabet states for each model state.
-       * the size of the vector is the number of model states, not the number of supported alphabet states,
-       * as distinct model states can correspond to a single alphabet state.
-       */
-      virtual const std::vector<int>& getAlphabetStates() const = 0;
-
-      /**
-       * @param index The model state.
-       * @return The corresponding alphabet state as character code.
-       */
-      virtual std::string getAlphabetStateAsChar(size_t index) const = 0;
-
-      /**
-       * @param index The model state.
-       * @return The corresponding alphabet state as int code.
-       */
-      virtual int getAlphabetStateAsInt(size_t index) const = 0;
-
-      /**
-       * @param code The character code of the alphabet state to check.
-       * @return The corresponding model states, is any.
-       */
-      virtual std::vector<size_t> getModelStates(const std::string& code) const = 0;
-
-      /**
-       * @param code The int code of the alphabet state to check.
-       * @return The corresponding model states, is any.
-       */
-      virtual std::vector<size_t> getModelStates(int code) const = 0;
+  public:
+    virtual ~StateMap() {}
+    virtual StateMap* clone() const = 0;
+
+  public:
+    /**
+     * @return The associated alphabet.
+     */
+    virtual const Alphabet* getAlphabet() const = 0;
+
+    /**
+     * @return The number of states supported by the model.
+     */
+    virtual size_t getNumberOfModelStates() const = 0;
+
+    /**
+     * @return A string describing the model state.
+     * @param index The state index.
+     */
+    virtual std::string getStateDescription(size_t index) const = 0;
+
+    /**
+     * @return A vector with the corresponding alphabet states for each model state.
+     * the size of the vector is the number of model states, not the number of supported alphabet states,
+     * as distinct model states can correspond to a single alphabet state.
+     */
+    virtual const std::vector<int>& getAlphabetStates() const = 0;
+
+    /**
+     * @param index The model state.
+     * @return The corresponding alphabet state as character code.
+     */
+    virtual std::string getAlphabetStateAsChar(size_t index) const = 0;
+
+    /**
+     * @param index The model state.
+     * @return The corresponding alphabet state as int code.
+     */
+    virtual int getAlphabetStateAsInt(size_t index) const = 0;
+
+    /**
+     * @param code The character code of the alphabet state to check.
+     * @return The corresponding model states, is any.
+     */
+    virtual std::vector<size_t> getModelStates(const std::string& code) const = 0;
+
+    /**
+     * @param code The int code of the alphabet state to check.
+     * @return The corresponding model states, is any.
+     */
+    virtual std::vector<size_t> getModelStates(int code) const = 0;
       
   };
 
@@ -115,40 +121,40 @@ namespace bpp
   class AbstractStateMap:
     public virtual StateMap
   {
-    protected:
-      const Alphabet* alphabet_;
-      std::vector<int> states_;
-
-    public:
-      AbstractStateMap(const Alphabet* alphabet):
-        alphabet_(alphabet),
-        states_()
-      {}
-
-      AbstractStateMap(const AbstractStateMap& absm):
-        alphabet_(absm.alphabet_),
-        states_(absm.states_)
-      {}
-
-      AbstractStateMap& operator=(const AbstractStateMap& absm)
-      {
-        alphabet_ = absm.alphabet_;
-        states_ = absm.states_;
-        return *this;
-      }
-
-    public:
-      virtual const Alphabet* getAlphabet() const { return alphabet_; }
-      virtual size_t getNumberOfModelStates() const { return states_.size(); }
-      virtual const std::vector<int>& getAlphabetStates() const { return states_; }
-      virtual int getAlphabetStateAsInt(size_t index) const { return states_[index]; }
-      virtual std::string getAlphabetStateAsChar(size_t index) const { return alphabet_->intToChar(states_[index]); }
-      virtual std::vector<size_t> getModelStates(int code) const {
-        return VectorTools::whichAll(states_, code);
-      }
-      virtual std::vector<size_t> getModelStates(const std::string& code) const {
-        return VectorTools::whichAll(states_, alphabet_->charToInt(code));
-      }
+  protected:
+    const Alphabet* alphabet_;
+    std::vector<int> states_;
+
+  public:
+    AbstractStateMap(const Alphabet* alphabet):
+      alphabet_(alphabet),
+      states_()
+    {}
+
+    AbstractStateMap(const AbstractStateMap& absm):
+      alphabet_(absm.alphabet_),
+      states_(absm.states_)
+    {}
+
+    AbstractStateMap& operator=(const AbstractStateMap& absm)
+    {
+      alphabet_ = absm.alphabet_;
+      states_ = absm.states_;
+      return *this;
+    }
+
+  public:
+    virtual const Alphabet* getAlphabet() const { return alphabet_; }
+    virtual size_t getNumberOfModelStates() const { return states_.size(); }
+    virtual const std::vector<int>& getAlphabetStates() const { return states_; }
+    virtual int getAlphabetStateAsInt(size_t index) const { return states_[index]; }
+    virtual std::string getAlphabetStateAsChar(size_t index) const { return alphabet_->intToChar(states_[index]); }
+    virtual std::vector<size_t> getModelStates(int code) const {
+      return VectorTools::whichAll(states_, code);
+    }
+    virtual std::vector<size_t> getModelStates(const std::string& code) const {
+      return VectorTools::whichAll(states_, alphabet_->charToInt(code));
+    }
 
   };
 
@@ -161,17 +167,18 @@ namespace bpp
   class CanonicalStateMap:
     public AbstractStateMap
   {
-    public:
-      CanonicalStateMap(const Alphabet* alphabet, bool includeGaps);
-
-      /**
-       * @brief this contructors takes an existing StateMap and adds one model states for gaps.
-       * If the original StateMap alread had a state for gaps, a new one will be appended.
-       */
-      CanonicalStateMap(const StateMap& sm, bool includeGaps);
-
-      virtual CanonicalStateMap* clone() const { return new CanonicalStateMap(*this); }
-
+  public:
+    CanonicalStateMap(const Alphabet* alphabet, bool includeGaps);
+    
+    /**
+     * @brief this contructors takes an existing StateMap and adds one model states for gaps.
+     * If the original StateMap alread had a state for gaps, a new one will be appended.
+     */
+    CanonicalStateMap(const StateMap& sm, bool includeGaps);
+
+    virtual CanonicalStateMap* clone() const { return new CanonicalStateMap(*this); }
+
+    virtual std::string getStateDescription(size_t index) const { return getAlphabetStateAsChar(index); }
   };
 
 
@@ -185,10 +192,14 @@ namespace bpp
   class MarkovModulatedStateMap:
     public AbstractStateMap
   {
-    public:
-      MarkovModulatedStateMap(const StateMap& unitMap, unsigned int nbClasses);
-      virtual MarkovModulatedStateMap* clone() const { return new MarkovModulatedStateMap(*this); }
+  private:
+    unsigned int nbClasses_;
+
+  public:
+    MarkovModulatedStateMap(const StateMap& unitMap, unsigned int nbClasses);
+    virtual MarkovModulatedStateMap* clone() const { return new MarkovModulatedStateMap(*this); }
 
+    virtual std::string getStateDescription(size_t index) const { return getAlphabetStateAsChar(index) + TextTools::toString(index % nbClasses_); }
   };
 
 }// end of namespace bpp
diff --git a/src/Bpp/Phyl/Model/SubstitutionModel.h b/src/Bpp/Phyl/Model/SubstitutionModel.h
index 65d60f2..543350e 100755
--- a/src/Bpp/Phyl/Model/SubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/SubstitutionModel.h
@@ -5,37 +5,37 @@
 //
 
 /*
-   Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
-
-   This software is a computer program whose purpose is to provide classes
-   for phylogenetic data analysis.
-
-   This software is governed by the CeCILL  license under French law and
-   abiding by the rules of distribution of free software.  You can  use,
-   modify and/ or redistribute the software under the terms of the CeCILL
-   license as circulated by CEA, CNRS and INRIA at the following URL
-   "http://www.cecill.info".
-
-   As a counterpart to the access to the source code and  rights to copy,
-   modify and redistribute granted by the license, users are provided only
-   with a limited warranty  and the software's author,  the holder of the
-   economic rights,  and the successive licensors  have only  limited
-   liability.
-
-   In this respect, the user's attention is drawn to the risks associated
-   with loading,  using,  modifying and/or developing or reproducing the
-   software by the user in light of its specific status of free software,
-   that may mean  that it is complicated to manipulate,  and  that  also
-   therefore means  that it is reserved for developers  and  experienced
-   professionals having in-depth computer knowledge. Users are therefore
-   encouraged to load and test the software's suitability as regards their
-   requirements in conditions enabling the security of their systems and/or
-   data to be ensured and,  more generally, to use and operate it in the
-   same conditions as regards security.
-
-   The fact that you are presently reading this means that you have had
-   knowledge of the CeCILL license and that you accept its terms.
- */
+  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
+
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
+
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use,
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info".
+
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability.
+
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or
+  data to be ensured and,  more generally, to use and operate it in the
+  same conditions as regards security.
+
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
+*/
 
 #ifndef _SUBSTITUTIONMODEL_H_
 #define _SUBSTITUTIONMODEL_H_
@@ -62,43 +62,246 @@
 
 namespace bpp
 {
-class SubstitutionModel;
+  class SubstitutionModel;
 
 /**
  * @brief Exception that may be thrown by susbstitution models.
  *
  * @see SubstitutionModel
  */
-class SubstitutionModelException :
-  public Exception
-{
-protected:
-  const SubstitutionModel* model_;
+  class SubstitutionModelException :
+    public Exception
+  {
+  protected:
+    const SubstitutionModel* model_;
 
-public:
-  SubstitutionModelException(const std::string& text, const SubstitutionModel* sm = 0);
+  public:
+    SubstitutionModelException(const std::string& text, const SubstitutionModel* sm = 0);
 
-  SubstitutionModelException(const SubstitutionModelException& sme) :
-    Exception(sme), model_(sme.model_) {}
+    SubstitutionModelException(const SubstitutionModelException& sme) :
+      Exception(sme), model_(sme.model_) {}
 
-  SubstitutionModelException& operator=(const SubstitutionModelException& sme)
-  {
-    Exception::operator=(sme);
-    model_ = sme.model_;
-    return *this;
-  }
+    SubstitutionModelException& operator=(const SubstitutionModelException& sme)
+    {
+      Exception::operator=(sme);
+      model_ = sme.model_;
+      return *this;
+    }
 
-  ~SubstitutionModelException() throw ();
+    ~SubstitutionModelException() throw ();
 
-public:
-  /**
-   * @brief Get the model that throws the exception.
+  public:
+    /**
+     * @brief Get the model that throws the exception.
+     *
+     * @return The model that throws the exception.
+     */
+    virtual const SubstitutionModel* getSubstitutionModel() const { return model_; }
+  };
+
+
+  /*
+   *
+   * @brief Interface for all transition models.
+   *
+   * A transition model defines transition probability matrices, the size of
+   * which depends on the alphabet used (4 for nucleotides, 20 for proteins, etc.).
+   * Each SubstitutionModel object hence includes a pointer toward an alphabet,
+   * and provides a method to retrieve the alphabet used (getAlphabet() method).
+   *
+   * What we want from a transition model is to compute the
+   * probabilities of state j at time t geven state j at time 0
+   * (\f$P_{i,j}(t)\f$).
+   *
+   * First and second order derivatives of \f$P(t)\f$ with respect to \f$t\f$
+   * can also be retrieved.
+   * These methods may be useful for optimization processes.
    *
-   * @return The model that throws the exception.
    */
-  virtual const SubstitutionModel* getSubstitutionModel() const { return model_; }
-};
 
+  class TransitionModel :
+    public virtual ParameterAliasable
+  {
+  public:
+    TransitionModel() {}
+    virtual ~TransitionModel() {}
+
+    TransitionModel* clone() const = 0;
+
+  public:
+    /**
+     * @brief Get the name of the model.
+     *
+     * @return The name of this model.
+     */
+    virtual std::string getName() const = 0;
+
+    /**
+     * @return The alphabet states of each state of the model, as a vector of int codes.
+     *
+     * @see Alphabet
+     */
+    virtual const std::vector<int>& getAlphabetStates() const = 0;
+
+    /**
+     * @return The mapping of model states with alphabet states.
+     */
+    virtual const StateMap& getStateMap() const = 0;
+
+    /**
+     * @brief Get the state in the model corresponding to a particular state in the alphabet.
+     *
+     * @param code The alphabet state to check.
+     * @return A vector of indices of model states.
+     */
+    virtual std::vector<size_t> getModelStates(int code) const = 0;
+
+    /**
+     * @brief Get the state in the model corresponding to a particular state in the alphabet.
+     *
+     * @param code The alphabet state to check.
+     * @return A vector of indices of model states.
+     */
+    virtual std::vector<size_t> getModelStates(const std::string& code) const = 0;
+
+    /**
+     * @param index The model state.
+     * @return The corresponding alphabet state as character code.
+     */
+    virtual int getAlphabetStateAsInt(size_t index) const = 0;
+  
+    /**
+     * @param index The model state.
+     * @return The corresponding alphabet state as character code.
+     */
+    virtual std::string getAlphabetStateAsChar(size_t index) const = 0;
+
+    /**
+     * @return Equilibrium frequency associated to character i.
+     * @see getFrequencies(), getStates()
+     */
+    virtual double freq(size_t i) const = 0;
+
+    /**
+     * @return The probability of change from state i to state j during time t.
+     * @see getPij_t(), getStates()
+     */
+    virtual double Pij_t(size_t i, size_t j, double t) const = 0;
+
+    /**
+     * @return The first order derivative of the probability of change from state
+     * i to state j with respect to time t, at time t.
+     * @see getdPij_dt(), getStates()
+     */
+    virtual double dPij_dt(size_t i, size_t j, double t) const = 0;
+
+    /**
+     * @return The second order derivative of the probability of change from state
+     * i to state j with respect to time t, at time t.
+     * @see getd2Pij_dt2(), getStates()
+     */
+    virtual double d2Pij_dt2(size_t i, size_t j, double t) const = 0;
+
+    /**
+     * @return A vector of all equilibrium frequencies.
+     * @see freq()
+     */
+    virtual const Vdouble& getFrequencies() const = 0;
+
+    /**
+     * @return All probabilities of change from state i to state j during time t.
+     * @see Pij_t()
+     */
+    virtual const Matrix<double>& getPij_t(double t) const = 0;
+
+    /**
+     * @return Get all first order derivatives of the probability of change from state
+     * i to state j with respect to time t, at time t.
+     * @see dPij_dt()
+     */
+    virtual const Matrix<double>& getdPij_dt(double t) const = 0;
+
+    /**
+     * @return All second order derivatives of the probability of change from state
+     * i to state j with respect to time t, at time t.
+     * @see d2Pij_dt2()
+     */
+    virtual const Matrix<double>& getd2Pij_dt2(double t) const = 0;
+
+    /**
+     * @return Get the alphabet associated to this model.
+     */
+    virtual const Alphabet* getAlphabet() const = 0;
+
+    /**
+     * @brief Get the number of states.
+     *
+     * For most models, this equals the size of the alphabet.
+     * @see getAlphabetChars for the list of supported states.
+     *
+     * @return The number of different states in the model.
+     */
+    virtual size_t getNumberOfStates() const = 0;
+
+    /**
+     * This method is used to initialize likelihoods in reccursions.
+     * It typically sends 1 if i = state, 0 otherwise, where
+     * i is one of the possible states of the alphabet allowed in the model
+     * and state is the observed state in the considered sequence/site.
+     *
+     * @param i the index of the state in the model.
+     * @param state An observed state in the sequence/site.
+     * @return 1 or 0 depending if the two states are compatible.
+     * @throw IndexOutOfBoundsException if array position is out of range.
+     * @throw BadIntException if states are not allowed in the associated alphabet.
+     * @see getStates();
+     */
+    virtual double getInitValue(size_t i, int state) const throw (IndexOutOfBoundsException, BadIntException) = 0;
+
+    /**
+     * @brief Get the rate
+     */
+    virtual double getRate() const = 0;
+
+    /**
+     * @brief Set the rate of the model (must be positive).
+     * @param rate must be positive.
+     */
+    virtual void setRate(double rate) = 0;
+
+    virtual void addRateParameter() = 0;
+  
+    /**
+     * @brief Set equilibrium frequencies equal to the frequencies estimated
+     * from the data.
+     *
+     * @param data The sequences to use.
+     * @param pseudoCount A quantity @f$\psi at f$ to add to adjust the observed
+     *   values in order to prevent issues due to missing states on small data set.
+     * The corrected frequencies shall be computed as
+     * @f[
+     * \pi_i = \frac{n_i+\psi}{\sum_j (f_j+\psi)}
+     * @f]
+     */
+    virtual void setFreqFromData(const SequenceContainer& data, double pseudoCount = 0) = 0;
+
+    /**
+     * @brief Set equilibrium frequencies
+     *
+     * @param frequencies The map of the frequencies to use.
+     */
+
+    virtual void setFreq(std::map<int, double>& frequencies) = 0;
+
+    /**
+     * @brief If the model owns a FrequenciesSet, returns a pointer to
+     * it, otherwise return 0.
+     */
+    
+    virtual const FrequenciesSet* getFrequenciesSet() const {return NULL;}
+  };
+
+  
 /**
  * @brief Interface for all substitution models.
  *
@@ -196,288 +399,153 @@ public:
  *
  */
 
-class SubstitutionModel :
-  public virtual ParameterAliasable
-{
-public:
-  SubstitutionModel() {}
-  virtual ~SubstitutionModel() {}
-
-#ifndef NO_VIRTUAL_COV
-  SubstitutionModel* clone() const = 0;
-#endif
-
-public:
-  /**
-   * @brief Get the name of the model.
-   *
-   * @return The name of this model.
-   */
-  virtual std::string getName() const = 0;
-
-  /**
-   * @return The alphabet states of each state of the model, as a vector of int codes.
-   *
-   * @see Alphabet
-   */
-  virtual const std::vector<int>& getAlphabetStates() const = 0;
-
-  /**
-   * @return The mapping of model states with alphabet states.
-   */
-  virtual const StateMap& getStateMap() const = 0;
-
-  /**
-   * @brief Get the state in the model corresponding to a particular state in the alphabet.
-   *
-   * @param code The alphabet state to check.
-   * @return A vector of indices of model states.
-   */
-  virtual std::vector<size_t> getModelStates(int code) const = 0;
-
-  /**
-   * @brief Get the state in the model corresponding to a particular state in the alphabet.
-   *
-   * @param code The alphabet state to check.
-   * @return A vector of indices of model states.
-   */
-  virtual std::vector<size_t> getModelStates(const std::string& code) const = 0;
-
-  /**
-   * @param index The model state.
-   * @return The corresponding alphabet state as character code.
-   */
-  virtual int getAlphabetStateAsInt(size_t index) const = 0;
+  class SubstitutionModel :
+    public virtual TransitionModel
+  {
+  public:
+    SubstitutionModel() {}
+    virtual ~SubstitutionModel() {}
+
+    SubstitutionModel* clone() const = 0;
+
+  public:
+
+    /**
+     * @return The rate in the generator of change from state i to state j.
+     *
+     * @see getStates();
+     */
+    virtual double Qij(size_t i, size_t j) const = 0;
+
+    /**
+     * @return The normalized Markov generator matrix, i.e. all
+     * normalized rates of changes from state i to state j. The
+     * generator is normalized so that
+     * (i) \f$ \forall i; \sum_j Q_{i,j} = 0 \f$, meaning that
+     * $\f$ \forall i; Q_{i,i} = -\sum_{j \neq i}Q_{i,j}\f$, and
+     * (ii) \f$ \sum_i Q_{i,i} \times \pi_i = -1\f$.
+     * This means that, under normalization, the mean rate of replacement at
+     * equilibrium is 1 and that time \f$t\f$ are measured in units of
+     * expected number of changes per site. Additionnaly, the rate_ attibute provides
+     * the possibility to increase or decrease this mean rate.
+     *
+     * See Kosiol and Goldman (2005), Molecular Biology And Evolution 22(2) 193-9.
+     * @see Qij()
+     */
+    virtual const Matrix<double>& getGenerator() const = 0;
+
+    /**
+     * @return The matrix of exchangeability terms.
+     * It is recommended that exchangeability matrix be normalized so that the normalized
+     * generator be obtained directly by the dot product \f$S . \pi\f$.
+     */
+    virtual const Matrix<double>& getExchangeabilityMatrix() const = 0;
+
+    /**
+     * @return The exchangeability between state i and state j.
+     *
+     * By definition Sij(i,j) = Sij(j,i).
+     */
   
-  /**
-   * @param index The model state.
-   * @return The corresponding alphabet state as character code.
-   */
-  virtual std::string getAlphabetStateAsChar(size_t index) const = 0;
-
-  /**
-   * @return Equilibrium frequency associated to character i.
-   * @see getFrequencies(), getStates()
-   */
-  virtual double freq(size_t i) const = 0;
-
-  /**
-   * @return The rate in the generator of change from state i to state j.
-   *
-   * @see getStates();
-   */
-  virtual double Qij(size_t i, size_t j) const = 0;
-
-  /**
-   * @return The probability of change from state i to state j during time t.
-   * @see getPij_t(), getStates()
-   */
-  virtual double Pij_t(size_t i, size_t j, double t) const = 0;
-
-  /**
-   * @return The first order derivative of the probability of change from state
-   * i to state j with respect to time t, at time t.
-   * @see getdPij_dt(), getStates()
-   */
-  virtual double dPij_dt(size_t i, size_t j, double t) const = 0;
-
-  /**
-   * @return The second order derivative of the probability of change from state
-   * i to state j with respect to time t, at time t.
-   * @see getd2Pij_dt2(), getStates()
-   */
-  virtual double d2Pij_dt2(size_t i, size_t j, double t) const = 0;
-
-  /**
-   * @return A vector of all equilibrium frequencies.
-   * @see freq()
-   */
-  virtual const Vdouble& getFrequencies() const = 0;
-
-  /**
-   * @return The normalized Markov generator matrix, i.e. all
-   * normalized rates of changes from state i to state j. The
-   * generator is normalized so that
-   * (i) \f$ \forall i; \sum_j Q_{i,j} = 0 \f$, meaning that
-   * $\f$ \forall i; Q_{i,i} = -\sum_{j \neq i}Q_{i,j}\f$, and
-   * (ii) \f$ \sum_i Q_{i,i} \times \pi_i = -1\f$.
-   * This means that, under normalization, the mean rate of replacement at
-   * equilibrium is 1 and that time \f$t\f$ are measured in units of
-   * expected number of changes per site. Additionnaly, the rate_ attibute provides
-   * the possibility to increase or decrease this mean rate.
-   *
-   * See Kosiol and Goldman (2005), Molecular Biology And Evolution 22(2) 193-9.
-   * @see Qij()
-   */
-  virtual const Matrix<double>& getGenerator() const = 0;
-
-  /**
-   * @return The matrix of exchangeability terms.
-   * It is recommended that exchangeability matrix be normalized so that the normalized
-   * generator be obtained directly by the dot product \f$S . \pi\f$.
-   */
-  virtual const Matrix<double>& getExchangeabilityMatrix() const = 0;
-
-  /**
-   * @return The exchangeability between state i and state j.
-   *
-   * By definition Sij(i,j) = Sij(j,i).
-   */
+    virtual double Sij(size_t i, size_t j) const = 0;
+
+    /**
+     * @brief Set if eigenValues and Vectors must be computed
+     */
+    virtual void enableEigenDecomposition(bool yn) = 0;
+
+    /**
+     * @brief Tell if eigenValues and Vectors must be computed
+     */
+    virtual bool enableEigenDecomposition() = 0;
+
+    /**
+     * @return A vector with all real parts of the eigen values of the generator of this model;
+     */
+    virtual const Vdouble& getEigenValues() const = 0;
+
+    /**
+     * @return A vector with all imaginary parts of the eigen values of the generator of this model;
+     */
+    virtual const Vdouble& getIEigenValues() const = 0;
+
+    /**
+     * @return True if the model is diagonalizable in R.
+     */
+    virtual bool isDiagonalizable() const = 0;
   
-  virtual double Sij(size_t i, size_t j) const = 0;
-  /**
-   * @return All probabilities of change from state i to state j during time t.
-   * @see Pij_t()
-   */
-  virtual const Matrix<double>& getPij_t(double t) const = 0;
-
-  /**
-   * @return Get all first order derivatives of the probability of change from state
-   * i to state j with respect to time t, at time t.
-   * @see dPij_dt()
-   */
-  virtual const Matrix<double>& getdPij_dt(double t) const = 0;
-
-  /**
-   * @return All second order derivatives of the probability of change from state
-   * i to state j with respect to time t, at time t.
-   * @see d2Pij_dt2()
-   */
-  virtual const Matrix<double>& getd2Pij_dt2(double t) const = 0;
-
-  /**
-   * @brief Set if eigenValues and Vectors must be computed
-   */
-  virtual void enableEigenDecomposition(bool yn) = 0;
-
-  /**
-   * @brief Tell if eigenValues and Vectors must be computed
-   */
-  virtual bool enableEigenDecomposition() = 0;
-
-  /**
-   * @return A vector with all real parts of the eigen values of the generator of this model;
-   */
-  virtual const Vdouble& getEigenValues() const = 0;
-
-  /**
-   * @return A vector with all imaginary parts of the eigen values of the generator of this model;
-   */
-  virtual const Vdouble& getIEigenValues() const = 0;
-
-  /**
-   * @return True if the model is diagonalizable in R.
-   */
-  virtual bool isDiagonalizable() const = 0;
+    /**
+     * @return True is the model is non-singular.
+     */
+    virtual bool isNonSingular() const = 0;
+
+    /**
+     * @return A matrix with left eigen vectors.
+     * Each row in the matrix stands for an eigen vector.
+     */
+    virtual const Matrix<double>& getRowLeftEigenVectors() const = 0;
+
+    /**
+     * @return A matrix with right eigen vectors.
+     * Each column in the matrix stands for an eigen vector.
+     */
+    virtual const Matrix<double>& getColumnRightEigenVectors() const = 0;
+
+    /**
+     * @brief sets if model is scalable, ie scale can be changed.
+     * Default : true, set to false to avoid normalization for example.
+     *
+     */
   
-  /**
-   * @return True is the model is non-singular.
-   */
-  virtual bool isNonSingular() const = 0;
-
-  /**
-   * @return A matrix with left eigen vectors.
-   * Each row in the matrix stands for an eigen vector.
-   */
-  virtual const Matrix<double>& getRowLeftEigenVectors() const = 0;
-
-  /**
-   * @return A matrix with right eigen vectors.
-   * Each column in the matrix stands for an eigen vector.
-   */
-  virtual const Matrix<double>& getColumnRightEigenVectors() const = 0;
-
-  /**
-   * @return Get the alphabet associated to this model.
-   */
-  virtual const Alphabet* getAlphabet() const = 0;
-
-  /**
-   * @brief Get the number of states.
-   *
-   * For most models, this equals the size of the alphabet.
-   * @see getAlphabetChars for the list of supported states.
-   *
-   * @return The number of different states in the model.
-   */
-  virtual size_t getNumberOfStates() const = 0;
-
-  /**
-   * This method is used to initialize likelihoods in reccursions.
-   * It typically sends 1 if i = state, 0 otherwise, where
-   * i is one of the possible states of the alphabet allowed in the model
-   * and state is the observed state in the considered sequence/site.
-   *
-   * @param i the index of the state in the model.
-   * @param state An observed state in the sequence/site.
-   * @return 1 or 0 depending if the two states are compatible.
-   * @throw IndexOutOfBoundsException if array position is out of range.
-   * @throw BadIntException if states are not allowed in the associated alphabet.
-   * @see getStates();
-   */
-  virtual double getInitValue(size_t i, int state) const throw (IndexOutOfBoundsException, BadIntException) = 0;
-
-  /**
-   * @brief Get the scalar product of diagonal elements of the generator
-   * and the frequencies vector.
-   * If the generator is normalized, then scale=1. Otherwise each element
-   * must be multiplied by 1/scale.
-   *
-   * @return Minus the scalar product of diagonal elements and the frequencies vector.
-   */
-  virtual double getScale() const = 0;
-
-  /**
-   * 
-   * @brief Multiplies the current generator by the given scale.
-   *
-   * @param scale the scale by which the generator is multiplied.
-   *
-   */
-
-  virtual void setScale(double scale) = 0;
-
-  /**
-   * @brief Get the rate
-   */
-  virtual double getRate() const = 0;
-
-  /**
-   * @brief Set the rate of the model (must be positive).
-   * @param rate must be positive.
-   */
+    virtual void setScalable(bool scalable) = 0;
   
-  virtual void setRate(double rate) = 0;
+    /**
+     * @brief returns  if model is scalable
+     *
+     */
 
-  virtual void addRateParameter() = 0;
+    virtual bool isScalable() const = 0;
   
-  /**
-   * @brief Set equilibrium frequencies equal to the frequencies estimated
-   * from the data.
-   *
-   * @param data The sequences to use.
-   * @param pseudoCount A quantity @f$\psi at f$ to add to adjust the observed
-   *   values in order to prevent issues due to missing states on small data set.
-   * The corrected frequencies shall be computed as
-   * @f[
-   * \pi_i = \frac{n_i+\psi}{\sum_j (f_j+\psi)}
-   * @f]
-   */
-  virtual void setFreqFromData(const SequenceContainer& data, double pseudoCount = 0) = 0;
+    /**
+     * @brief Get the scalar product of diagonal elements of the generator
+     * and the frequencies vector.
+     * If the generator is normalized, then scale=1. Otherwise each element
+     * must be multiplied by 1/scale.
+     *
+     * @return Minus the scalar product of diagonal elements and the frequencies vector.
+     */
+    virtual double getScale() const = 0;
+  
+    /**
+     * 
+     * @brief Multiplies the current generator by the given scale.
+     *
+     * @param scale the scale by which the generator is multiplied.
+     *
+     */
+    virtual void setScale(double scale) = 0;
+
+    /**
+     * @brief Normalize the generator
+     *
+     */
+  
+    virtual void normalize() = 0;
+  
+    /**
+     * @brief Get the rate
+     */
+    virtual double getRate() const = 0;
 
-  /**
-   * @brief Set equilibrium frequencies
-   *
-   * @param frequencies The map of the frequencies to use.
-   */
-  virtual void setFreq(std::map<int, double>& frequencies) {}
+    /**
+     * @brief Set the rate of the model (must be positive).
+     * @param rate must be positive.
+     */
+    virtual void setRate(double rate) = 0;
 
-  /**
-   * @brief If the model owns a FrequenciesSet, returns a pointer to
-   * it, otherwise return 0.
-   */
-  virtual const FrequenciesSet* getFrequenciesSet() const {return NULL;}
-};
+    virtual void addRateParameter() = 0;
+
+  };
 
 
 /**
@@ -491,17 +559,15 @@ public:
  * or individually by the freq() method.
  * The \f$S\f$ matrix may be obtained by the getExchangeabilityMatrix().
  */
-class ReversibleSubstitutionModel :
-  public virtual SubstitutionModel
-{
-public:
-  ReversibleSubstitutionModel() {}
-  virtual ~ReversibleSubstitutionModel() {}
-
-#ifndef NO_VIRTUAL_COV
-  ReversibleSubstitutionModel* clone() const = 0;
-#endif
-};
+  class ReversibleSubstitutionModel :
+    public virtual SubstitutionModel
+  {
+  public:
+    ReversibleSubstitutionModel() {}
+    virtual ~ReversibleSubstitutionModel() {}
+
+    ReversibleSubstitutionModel* clone() const = 0;
+  };
 
 } //end of namespace bpp.
 
diff --git a/src/Bpp/Phyl/Model/SubstitutionModelFactory.cpp b/src/Bpp/Phyl/Model/SubstitutionModelFactory.cpp
deleted file mode 100644
index dcbc37d..0000000
--- a/src/Bpp/Phyl/Model/SubstitutionModelFactory.cpp
+++ /dev/null
@@ -1,188 +0,0 @@
-//
-// File: SubstitutionModelFactory.cpp
-// Created by: Julien Dutheil
-//             Vincent Ranwez
-// Created on: Fri apr 14 11:11 2006
-//
-
-/*
-Copyright or © or Copr. Bio++ Development Team, (November 16, 2004, 2005, 2006)
-
-This software is a computer program whose purpose is to provide classes
-for phylogenetic data analysis.
-
-This software is governed by the CeCILL  license under French law and
-abiding by the rules of distribution of free software.  You can  use, 
-modify and/ or redistribute the software under the terms of the CeCILL
-license as circulated by CEA, CNRS and INRIA at the following URL
-"http://www.cecill.info". 
-
-As a counterpart to the access to the source code and  rights to copy,
-modify and redistribute granted by the license, users are provided only
-with a limited warranty  and the software's author,  the holder of the
-economic rights,  and the successive licensors  have only  limited
-liability. 
-
-In this respect, the user's attention is drawn to the risks associated
-with loading,  using,  modifying and/or developing or reproducing the
-software by the user in light of its specific status of free software,
-that may mean  that it is complicated to manipulate,  and  that  also
-therefore means  that it is reserved for developers  and  experienced
-professionals having in-depth computer knowledge. Users are therefore
-encouraged to load and test the software's suitability as regards their
-requirements in conditions enabling the security of their systems and/or 
-data to be ensured and,  more generally, to use and operate it in the 
-same conditions as regards security. 
-
-The fact that you are presently reading this means that you have had
-knowledge of the CeCILL license and that you accept its terms.
-*/
-
-#include "SubstitutionModelFactory.h"
-#include "SubstitutionModelSetTools.h"
-#include "Protein/JCprot.h"
-#include "Nucleotide/K80.h"
-#include "Nucleotide/T92.h"
-#include "Nucleotide/L95.h"
-#include "Nucleotide/F84.h"
-#include "Nucleotide/TN93.h"
-#include "Nucleotide/HKY85.h"
-#include "Nucleotide/GTR.h"
-#include "Nucleotide/SSR.h"
-#include "Protein/JTT92.h"
-#include "Protein/DSO78.h"
-#include "Protein/WAG01.h"
-#include "Protein/LG08.h"
-
-// From bpp-seq:
-#include <Bpp/Seq/Alphabet/AlphabetTools.h>
-
-using namespace bpp;
-
-// From the STL:
-#include <algorithm>
-
-using namespace std;
-
-const string SubstitutionModelFactory::JUKES_CANTOR                = "JC69";
-const string SubstitutionModelFactory::KIMURA_2P                   = "K80";
-const string SubstitutionModelFactory::HASEGAWA_KISHINO_YANO       = "HKY85";
-const string SubstitutionModelFactory::TAMURA_NEI                  = "TN93";
-const string SubstitutionModelFactory::GENERAL_TIME_REVERSIBLE     = "HKY85";
-const string SubstitutionModelFactory::STRAND_SYMMETRIC_REVERSIBLE = "SSR";
-const string SubstitutionModelFactory::TAMURA                      = "T92";
-const string SubstitutionModelFactory::LOBRY                       = "L95";
-const string SubstitutionModelFactory::FELSENSTEIN                 = "F84";
-const string SubstitutionModelFactory::JOHN_TAYLOR_THORNTON        = "JTT92";
-const string SubstitutionModelFactory::DAYHOFF_SCHWARTZ_ORCUTT     = "DSO78";
-const string SubstitutionModelFactory::WHELAN_AND_GOLDMAN          = "WAG";
-const string SubstitutionModelFactory::LE_GASCUEL                  = "LG08";
-
-SubstitutionModel* SubstitutionModelFactory::createModel(const string& modelName) const throw (AlphabetException, Exception)
-{
-  if (modelName == JUKES_CANTOR)
-  {
-    if (AlphabetTools::isNucleicAlphabet(alphabet_))
-      return new JCnuc(dynamic_cast<const NucleicAlphabet *>(alphabet_));
-    else
-      return new JCprot(dynamic_cast<const ProteicAlphabet *>(alphabet_));
-  }
-  else if(modelName == KIMURA_2P)
-  {
-    try { 
-      return new K80(dynamic_cast<const NucleicAlphabet *>(alphabet_));
-    } catch(Exception & e) {
-      throw AlphabetException("SubstitutionModelFactory::createInstanceOf(). K80 model requires a nucleotide alphabet.", alphabet_);
-    }
-  }
-  else if(modelName == TAMURA)
-  {
-    try { 
-      return new T92(dynamic_cast<const NucleicAlphabet *>(alphabet_));
-    } catch(Exception & e) {
-      throw AlphabetException("SubstitutionModelFactory::createInstanceOf(). T92 model requires a nucleotide alphabet.", alphabet_);
-    }
-  }
-  else if(modelName == LOBRY)
-  {
-    try { 
-      return new L95(dynamic_cast<const NucleicAlphabet *>(alphabet_));
-    } catch(Exception & e) {
-      throw AlphabetException("SubstitutionModelFactory::createInstanceOf(). L95 model requires a nucleotide alphabet.", alphabet_);
-    }
-  }
-  else if(modelName == FELSENSTEIN)
-  {
-    try { 
-      return new F84(dynamic_cast<const NucleicAlphabet *>(alphabet_));
-    } catch(Exception & e) {
-      throw AlphabetException("SubstitutionModelFactory::createInstanceOf(). T92 model requires a nucleotide alphabet.", alphabet_);
-    }
-  }
-  else if(modelName == TAMURA_NEI)
-  {
-    try { 
-      return new TN93(dynamic_cast<const NucleicAlphabet *>(alphabet_));
-    } catch(Exception & e) {
-      throw AlphabetException("SubstitutionModelFactory::createInstanceOf(). TN93 model requires a nucleotide alphabet.", alphabet_);
-    }
-  }
-  else if(modelName == HASEGAWA_KISHINO_YANO)
-  {
-    try { 
-      return new HKY85(dynamic_cast<const NucleicAlphabet *>(alphabet_));
-    } catch(Exception & e) {
-      throw AlphabetException("SubstitutionModelFactory::createInstanceOf(). HKY85 model requires a nucleotide alphabet.", alphabet_);
-    }
-  }
-  else if(modelName == GENERAL_TIME_REVERSIBLE)
-  {
-    try { 
-      return new GTR(dynamic_cast<const NucleicAlphabet *>(alphabet_));
-    } catch(Exception & e) {
-      throw AlphabetException("SubstitutionModelFactory::createInstanceOf(). GTR model requires a nucleotide alphabet.", alphabet_);
-    }
-  }
-  else if(modelName == STRAND_SYMMETRIC_REVERSIBLE)
-  {
-    try { 
-      return new SSR(dynamic_cast<const NucleicAlphabet *>(alphabet_));
-    } catch(Exception & e) {
-      throw AlphabetException("SubstitutionModelFactory::createInstanceOf(). SSR model requires a nucleotide alphabet.", alphabet_);
-    }
-  }
-  else if(modelName == JOHN_TAYLOR_THORNTON)
-  {
-    try { 
-      return new JTT92(dynamic_cast<const ProteicAlphabet *>(alphabet_));
-    } catch(Exception & e) {
-      throw AlphabetException("SubstitutionModelFactory::createInstanceOf(). JTT92 model requires a protein alphabet.", alphabet_);
-    }
-  }
-  else if(modelName == DAYHOFF_SCHWARTZ_ORCUTT)
-  {
-    try { 
-      return new DSO78(dynamic_cast<const ProteicAlphabet *>(alphabet_));
-    } catch(Exception & e) {
-      throw AlphabetException("SubstitutionModelFactory::createInstanceOf(). DSO78 model requires a protein alphabet.", alphabet_);
-    }
-  }
-  else if(modelName == WHELAN_AND_GOLDMAN)
-  {
-    try { 
-      return new WAG01(dynamic_cast<const ProteicAlphabet *>(alphabet_));
-    } catch(Exception & e) {
-      throw AlphabetException("SubstitutionModelFactory::createInstanceOf(). WAG01 model requires a protein alphabet.", alphabet_);
-    }
-  }
-  else if(modelName == LE_GASCUEL)
-  {
-    try { 
-      return new LG08(dynamic_cast<const ProteicAlphabet *>(alphabet_));
-    } catch(Exception & e) {
-      throw AlphabetException("SubstitutionModelFactory::createInstanceOf(). LE08 model requires a protein alphabet.", alphabet_);
-    }
-  }
-  else throw Exception("SubstitutionModelFactory::createModel(). Unknown model: " + modelName);
-}
-
diff --git a/src/Bpp/Phyl/Model/SubstitutionModelFactory.h b/src/Bpp/Phyl/Model/SubstitutionModelFactory.h
deleted file mode 100644
index 630c3f2..0000000
--- a/src/Bpp/Phyl/Model/SubstitutionModelFactory.h
+++ /dev/null
@@ -1,131 +0,0 @@
-//
-// File: SubstitutionModelFactory.h
-// Created by: Julien Dutheil
-//             Vincent Ranwez
-// Created on: Fri apr 14 11:11 2006
-//
-
-/*
-Copyright or © or Copr. Bio++ Development Team, (November 16, 2004, 2005, 2006)
-
-This software is a computer program whose purpose is to provide classes
-for phylogenetic data analysis.
-
-This software is governed by the CeCILL  license under French law and
-abiding by the rules of distribution of free software.  You can  use, 
-modify and/ or redistribute the software under the terms of the CeCILL
-license as circulated by CEA, CNRS and INRIA at the following URL
-"http://www.cecill.info". 
-
-As a counterpart to the access to the source code and  rights to copy,
-modify and redistribute granted by the license, users are provided only
-with a limited warranty  and the software's author,  the holder of the
-economic rights,  and the successive licensors  have only  limited
-liability. 
-
-In this respect, the user's attention is drawn to the risks associated
-with loading,  using,  modifying and/or developing or reproducing the
-software by the user in light of its specific status of free software,
-that may mean  that it is complicated to manipulate,  and  that  also
-therefore means  that it is reserved for developers  and  experienced
-professionals having in-depth computer knowledge. Users are therefore
-encouraged to load and test the software's suitability as regards their
-requirements in conditions enabling the security of their systems and/or 
-data to be ensured and,  more generally, to use and operate it in the 
-same conditions as regards security. 
-
-The fact that you are presently reading this means that you have had
-knowledge of the CeCILL license and that you accept its terms.
-*/
-
-#ifndef _SUBSTITUTIOMODELFACTORY_H_
-#define _SUBSTITUTIOMODELFACTORY_H_
-
-#include "../Model/Nucleotide/JCnuc.h"
-#include "../Tree.h"
-
-// From SeqLib:
-#include <Bpp/Seq/Alphabet/Alphabet.h>
-#include <Bpp/Seq/Alphabet/AlphabetExceptions.h>
-#include <Bpp/Seq/GeneticCode/GeneticCode.h>
-
-// From the STL:
-#include <string>
-
-namespace bpp
-{
-
-/**
- * @brief Utilitary class for creating substitution models.
- */
-class SubstitutionModelFactory
-{
-  public:
-    static const std::string JUKES_CANTOR;
-    static const std::string KIMURA_2P;
-    static const std::string HASEGAWA_KISHINO_YANO;
-    static const std::string TAMURA_NEI;
-    static const std::string GENERAL_TIME_REVERSIBLE;
-    static const std::string STRAND_SYMMETRIC_REVERSIBLE;
-    static const std::string TAMURA;
-    static const std::string LOBRY;
-    static const std::string FELSENSTEIN;
-    static const std::string JOHN_TAYLOR_THORNTON;
-    static const std::string DAYHOFF_SCHWARTZ_ORCUTT;
-    static const std::string WHELAN_AND_GOLDMAN;
-    static const std::string LE_GASCUEL;
-  
-  private:
-    const Alphabet* alphabet_;
-    const GeneticCode* geneticCode_;
-  
-  public:
-    /**
-     * @brief Creates a new factory object with the given alphabet.
-     *
-     * This factory only provides ways to instanciate simple substitution models,
-     * for nucleotides and proteins.
-     *
-     * @param alphabet The alphabet for wich models must be instanciated.
-     * @param geneticCode Genetic code to use for codon model.
-     *
-     * Example:
-     * @code
-     * const Alphabet* alphabet = new DNA();
-     * SubstitutionModel* model = SubstitutionModelFactory(alphabet)
-     *     .createModel(SubstitutionModelFactory::TAMURA);
-     * // model can be used in any object dealing with a nucleotide substitution models.
-     * @endcode
-     */
-    SubstitutionModelFactory(const Alphabet* alphabet, const GeneticCode* geneticCode):
-      alphabet_(alphabet), geneticCode_(geneticCode) {}
-    
-    SubstitutionModelFactory(const SubstitutionModelFactory& smf) :
-      alphabet_(smf.alphabet_), geneticCode_(smf.geneticCode_) {}
-    
-    SubstitutionModelFactory& operator=(const SubstitutionModelFactory& smf)
-    {
-      alphabet_    = smf.alphabet_;
-      geneticCode_ = smf.geneticCode_;
-      return *this;
-    }
-    
-    virtual ~SubstitutionModelFactory() {}
-
-  public:
-    /**
-     * @brief Get a new dynamically created SubstitutionModel object.
-     *
-     * @param modelName The name of the model to use.
-     * @return A pointer toward a new substitution model, with default parameter values.
-     * @throw AlphabetException If the model is not compatible with the given alphabet.
-     * @throw Exception If the model name do not match any available model.
-     */
-    virtual SubstitutionModel* createModel(const std::string& modelName) const throw (AlphabetException, Exception);
-
-};
-
-} //end of namespace bpp.
-
-#endif //_SUBSTITUTIOMODELFACTORY_H_
-
diff --git a/src/Bpp/Phyl/Model/SubstitutionModelSet.cpp b/src/Bpp/Phyl/Model/SubstitutionModelSet.cpp
index 44d27b0..ee202dd 100644
--- a/src/Bpp/Phyl/Model/SubstitutionModelSet.cpp
+++ b/src/Bpp/Phyl/Model/SubstitutionModelSet.cpp
@@ -60,7 +60,7 @@ SubstitutionModelSet::SubstitutionModelSet(const SubstitutionModelSet& set) :
   // Duplicate all model objects:
   for (size_t i = 0; i < set.modelSet_.size(); i++)
     {
-      modelSet_[i] = dynamic_cast<SubstitutionModel*>(set.modelSet_[i]->clone());
+      modelSet_[i] = dynamic_cast<TransitionModel*>(set.modelSet_[i]->clone());
     }
 }
 
@@ -82,7 +82,7 @@ SubstitutionModelSet& SubstitutionModelSet::operator=(const SubstitutionModelSet
   modelSet_.resize(set.modelSet_.size());
   for (size_t i = 0; i < set.modelSet_.size(); i++)
     {
-      modelSet_[i] = dynamic_cast<SubstitutionModel*>(set.modelSet_[i]->clone());
+      modelSet_[i] = dynamic_cast<TransitionModel*>(set.modelSet_[i]->clone());
     }
   return *this;
 }
@@ -125,14 +125,17 @@ std::vector<int> SubstitutionModelSet::getNodesWithParameter(const std::string&
   for (size_t i = 0; i < nalias.size(); i++)
     {
       p=nalias[i].rfind("_");
-      vector<int> ni = getNodesWithModel(TextTools::to<size_t>(nalias[i].substr(p+1,string::npos))-1);
-      inode.insert(inode.end(),ni.begin(),ni.end());
+      size_t pos=TextTools::to<size_t>(nalias[i].substr(p+1,string::npos));
+      if (pos>0){
+        vector<int> ni = getNodesWithModel(pos-1);
+        inode.insert(inode.end(),ni.begin(),ni.end());
+      }
     }
   
   return inode;
 }
 
-void SubstitutionModelSet::addModel(SubstitutionModel* model, const std::vector<int>& nodesId)//, const vector<string>& newParams) throw (Exception)
+void SubstitutionModelSet::addModel(TransitionModel* model, const std::vector<int>& nodesId)//, const vector<string>& newParams) throw (Exception)
 {
   if (model->getAlphabet()->getAlphabetType() != alphabet_->getAlphabetType())
     throw Exception("SubstitutionModelSet::addModel. A Substitution Model cannot be added to a Model Set if it does not have the same alphabet.");
@@ -166,12 +169,11 @@ void SubstitutionModelSet::addModel(SubstitutionModel* model, const std::vector<
     }
 }
 
-void SubstitutionModelSet::replaceModel(size_t modelIndex, SubstitutionModel* model) throw (Exception)
+void SubstitutionModelSet::replaceModel(size_t modelIndex, TransitionModel* model) throw (Exception)
 {
   delete modelSet_[modelIndex];
   modelSet_[modelIndex]=model;
   
-  
   // Erase all parameter references to this model
 
   ParameterList pl=getNodeParameters();
@@ -179,9 +181,10 @@ void SubstitutionModelSet::replaceModel(size_t modelIndex, SubstitutionModel* mo
   for (size_t i = pl.size(); i>0; i--)
     {
       string pn=pl[i-1].getName();
-
+      
       size_t pu=pn.rfind("_");
       int nm=TextTools::toInt(pn.substr(pu+1,string::npos));
+
       if (nm==(int)modelIndex+1){
         vector<string> alpn=getAlias(pn);
         for (unsigned j=0; j<alpn.size(); j++)
@@ -192,7 +195,7 @@ void SubstitutionModelSet::replaceModel(size_t modelIndex, SubstitutionModel* mo
             {
               continue;
             }
-        deleteParameter_(i-1);
+        deleteParameter_(pn);
       }
     }
 
@@ -302,7 +305,7 @@ bool SubstitutionModelSet::hasMixedSubstitutionModel() const
 {
   for (size_t i = 0; i < getNumberOfModels(); i++)
     {
-      if (dynamic_cast<const MixedSubstitutionModel*>(getModel(i)) != NULL)
+      if ((dynamic_cast<const MixedSubstitutionModel*>(getTransitionModel(i)) != NULL) && (modelToNodes_[i].size()>1))
         return true;
     }
   return false;
diff --git a/src/Bpp/Phyl/Model/SubstitutionModelSet.h b/src/Bpp/Phyl/Model/SubstitutionModelSet.h
index 7863ac6..fbb6b3c 100644
--- a/src/Bpp/Phyl/Model/SubstitutionModelSet.h
+++ b/src/Bpp/Phyl/Model/SubstitutionModelSet.h
@@ -60,6 +60,7 @@
 #include <map>
 #include <algorithm>
 #include <memory>
+#include <typeinfo>
 
 namespace bpp
 {
@@ -115,13 +116,13 @@ protected:
   /**
    * @brief Contains all models used in this tree.
    */
-  std::vector<SubstitutionModel*> modelSet_;
+  std::vector<TransitionModel*> modelSet_;
 
 private:
   /**
    * @brief Root frequencies.
    */
-  std::auto_ptr<FrequenciesSet> rootFrequencies_;
+  std::unique_ptr<FrequenciesSet> rootFrequencies_;
 
   /**
    * @brief Contains for each node in a tree the index of the corresponding model in modelSet_
@@ -152,7 +153,7 @@ public:
     alphabet_(alpha),
     nbStates_(0),
     modelSet_(),
-    rootFrequencies_(0),
+    rootFrequencies_(),
     nodeToModel_(),
     modelToNodes_(),
     modelParameters_(),
@@ -172,7 +173,7 @@ public:
     alphabet_(alpha),
     nbStates_(0),
     modelSet_(),
-    rootFrequencies_(0),
+    rootFrequencies_(),
     nodeToModel_(),
     modelToNodes_(),
     modelParameters_(),
@@ -185,15 +186,18 @@ public:
    * @brief Resets all the information contained in this object.
    *
    */
-   
   void clear();
+
+  bool isStationary() const
+  {
+    return stationarity_;
+  }
   
   /**
    * @brief Sets a given FrequenciesSet for root frequencies.
    *
    * @param rootFreqs The FrequenciesSet for root frequencies.
    */
-
   void setRootFrequencies(FrequenciesSet* rootFreqs);
 
   SubstitutionModelSet(const SubstitutionModelSet& set);
@@ -202,15 +206,10 @@ public:
 
   virtual ~SubstitutionModelSet()
   {
-    for (size_t i = 0; i < modelSet_.size(); i++) { delete modelSet_[i]; }
+    for (auto model : modelSet_) { delete model; }
   }
 
-#ifndef NO_VIRTUAL_COV
-  SubstitutionModelSet*
-#else
-  Clonable*
-#endif
-  clone() const { return new SubstitutionModelSet(*this); }
+  SubstitutionModelSet* clone() const { return new SubstitutionModelSet(*this); }
 
 public:
   /**
@@ -248,18 +247,77 @@ public:
    * @param i Index of the model in the set.
    * @return A pointer toward the corresponding model.
    */
+  
   const SubstitutionModel* getModel(size_t i) const throw (IndexOutOfBoundsException)
   {
-    if (i > modelSet_.size()) throw IndexOutOfBoundsException("SubstitutionModelSet::getNumberOfModels().", 0, modelSet_.size() - 1, i);
-    return modelSet_[i];
+    std::cerr << "#warning : SubstitutionModelSet::getModel function is deprecated in Bio++ 2.3.0. Replace it with SubstitutionModelSet::getSubstitutionModel." << std::endl;
+
+    return getSubstitutionModel(i);
   }
 
   SubstitutionModel* getModel(size_t i) throw (IndexOutOfBoundsException)
   {
-    if (i > modelSet_.size()) throw IndexOutOfBoundsException("SubstitutionModelSet::getNumberOfModels().", 0, modelSet_.size() - 1, i);
+    std::cerr << "#warning : SubstitutionModelSet::getModel function is deprecated in Bio++ 2.3.0. Replace it with SubstitutionModelSet::getSubstitutionModel." << std::endl;
+
+    return getSubstitutionModel(i);
+  }
+
+  const TransitionModel* getTransitionModel(size_t i) const throw (IndexOutOfBoundsException)
+  {
+    if (i >= modelSet_.size()) throw IndexOutOfBoundsException("SubstitutionModelSet::getNumberOfModels().", 0, modelSet_.size() - 1, i);
     return modelSet_[i];
   }
 
+  TransitionModel* getTransitionModel(size_t i) throw (IndexOutOfBoundsException)
+  {
+    if (i >= modelSet_.size()) throw IndexOutOfBoundsException("SubstitutionModelSet::getNumberOfModels().", 0, modelSet_.size() - 1, i);
+    return modelSet_[i];
+  }
+
+  /*
+   * @brief Return a markovian substitution model (or null)
+   *
+   */
+  
+  const SubstitutionModel* getSubstitutionModel(size_t i) const throw (IndexOutOfBoundsException)
+  {
+    try
+    {
+      return dynamic_cast<const SubstitutionModel*>(getTransitionModel(i));
+    }
+    catch (std::bad_cast& bc)
+    {
+      throw Exception("SubstitutionModelSet::getSubstitutionModel : model is not a sustitution model " + getTransitionModel(i)->getName());
+    }
+  }
+  
+
+  SubstitutionModel* getSubstitutionModel(size_t i) throw (IndexOutOfBoundsException)
+  {
+    try
+    {
+      return dynamic_cast<SubstitutionModel*>(getTransitionModel(i));
+    }
+    catch (std::bad_cast& bc)
+    {
+      throw Exception("SubstitutionModelSet::getSubstitutionModel : model is not a sustitution model " + getTransitionModel(i)->getName());
+    }
+  }
+
+  /*
+   * @brief check if has only markovian substitution models
+   *
+   */
+ 
+  bool hasOnlySubstitutionModels() const
+  {
+    for (auto mod : modelSet_)
+      if (dynamic_cast<const SubstitutionModel*>(mod)==0)
+        return false;
+
+    return true;
+  }
+  
   /**
    * @brief Get the index in the set of the model associated to a particular node id.
    *
@@ -282,14 +340,14 @@ public:
    * @return A pointer toward the corresponding model.
    * @throw Exception If no model is found for this node.
    */
-  const SubstitutionModel* getModelForNode(int nodeId) const throw (Exception)
+  const TransitionModel* getModelForNode(int nodeId) const throw (Exception)
   {
    std::map<int, size_t>::const_iterator i = nodeToModel_.find(nodeId);
     if (i == nodeToModel_.end())
       throw Exception("SubstitutionModelSet::getModelForNode(). No model associated to node with id " + TextTools::toString(nodeId));
     return modelSet_[i->second];
   }
-  SubstitutionModel* getModelForNode(int nodeId) throw (Exception)
+  TransitionModel* getModelForNode(int nodeId) throw (Exception)
   {
    std::map<int, size_t>::iterator i = nodeToModel_.find(nodeId);
     if (i == nodeToModel_.end())
@@ -297,6 +355,16 @@ public:
     return modelSet_[i->second];
   }
 
+  const SubstitutionModel* getSubstitutionModelForNode(int nodeId) const throw (Exception)
+  {
+    return dynamic_cast<const SubstitutionModel*>(getModelForNode(nodeId));
+  }
+
+  SubstitutionModel* getSubstitutionModelForNode(int nodeId) throw (Exception)
+  {
+    return dynamic_cast<SubstitutionModel*>(getModelForNode(nodeId));
+  }
+
   /**
    * @brief Get a list of nodes id for which the given model is associated.
    *
@@ -334,7 +402,7 @@ public:
    * <li>etc.</li>
    * </ul>
    */
-  void addModel(SubstitutionModel* model, const std::vector<int>& nodesId);//, const std::vector<std::string>& newParams) throw (Exception);
+  void addModel(TransitionModel* model, const std::vector<int>& nodesId);//, const std::vector<std::string>& newParams) throw (Exception);
 
   /**
    * @brief Replace a model in the set, and all corresponding
@@ -346,7 +414,7 @@ public:
    * @throw Exception if a parameter becomes orphan because of the removal.
    */
 
-  void replaceModel(size_t modelIndex, SubstitutionModel* model) throw (Exception);
+  void replaceModel(size_t modelIndex, TransitionModel* model) throw (Exception);
 
   void listModelNames(std::ostream& out = std::cout) const;
 
@@ -415,19 +483,19 @@ public:
    * @see Alphabet
    */
   virtual const std::vector<int>& getAlphabetStates() const {
-    return getModel(0)->getAlphabetStates();
+    return getTransitionModel(0)->getAlphabetStates();
   }
 
   virtual const StateMap& getStateMap() const {
-    return getModel(0)->getStateMap();
+    return getTransitionModel(0)->getStateMap();
   }
 
   virtual std::vector<size_t> getModelStates(int code) const {
-    return getModel(0)->getModelStates(code);
+    return getTransitionModel(0)->getModelStates(code);
   }
 
   virtual std::vector<size_t> getModelStates(const std::string& code) const {
-    return getModel(0)->getModelStates(code);
+    return getTransitionModel(0)->getModelStates(code);
   }
 
   /**
@@ -435,7 +503,7 @@ public:
    * @return The corresponding alphabet state as character code.
    */
   virtual int getAlphabetStateAsInt(size_t index) const {
-    return getModel(0)->getAlphabetStateAsInt(index);
+    return getTransitionModel(0)->getAlphabetStateAsInt(index);
   }
   
   /**
@@ -443,7 +511,7 @@ public:
    * @return The corresponding alphabet state as character code.
    */
   virtual std::string getAlphabetStateAsChar(size_t index) const {
-    return getModel(0)->getAlphabetStateAsChar(index);
+    return getTransitionModel(0)->getAlphabetStateAsChar(index);
   }
 
   /**
diff --git a/src/Bpp/Phyl/Model/SubstitutionModelSetTools.cpp b/src/Bpp/Phyl/Model/SubstitutionModelSetTools.cpp
index 1da9ddd..7cc6f06 100644
--- a/src/Bpp/Phyl/Model/SubstitutionModelSetTools.cpp
+++ b/src/Bpp/Phyl/Model/SubstitutionModelSetTools.cpp
@@ -46,7 +46,7 @@ using namespace bpp;
 using namespace std;
 
 SubstitutionModelSet* SubstitutionModelSetTools::createHomogeneousModelSet(
-  SubstitutionModel* model,
+  TransitionModel* model,
   FrequenciesSet* rootFreqs,
   const Tree* tree
   ) throw (AlphabetException, Exception)
@@ -79,9 +79,10 @@ SubstitutionModelSet* SubstitutionModelSetTools::createHomogeneousModelSet(
 }
 
 SubstitutionModelSet* SubstitutionModelSetTools::createNonHomogeneousModelSet(
-  SubstitutionModel* model,
+  TransitionModel* model,
   FrequenciesSet* rootFreqs,
   const Tree* tree,
+  const std::map<std::string, std::string>& aliasFreqNames,
   const vector<string>& globalParameterNames
   ) throw (AlphabetException, Exception)
 {
@@ -90,51 +91,26 @@ SubstitutionModelSet* SubstitutionModelSetTools::createNonHomogeneousModelSet(
     throw AlphabetMismatchException("SubstitutionModelSetTools::createNonHomogeneousModelSet()", model->getAlphabet(), rootFreqs->getAlphabet());
   ParameterList globalParameters, branchParameters;
   globalParameters = model->getParameters();
-
-  vector<string> globalParameterNames2; // vector of the complete names of global parameters
-
+  
+  vector<string> modelParamNames=globalParameters.getParameterNames();
+  
+  vector<string> globalParameterNames2;
+  
   // First get correct parameter names
-  size_t i, j;
 
-  for (i = 0; i < globalParameterNames.size(); i++)
+  for (size_t i = 0; i < globalParameterNames.size(); i++)
   {
-    if (globalParameterNames[i].find("*") != string::npos)
-    {
-      for (j = 0; j < globalParameters.size(); j++)
-      {
-        StringTokenizer stj(globalParameterNames[i], "*", true, false);
-        size_t pos1, pos2;
-        string parn = globalParameters[j].getName();
-        bool flag(true);
-        string g = stj.nextToken();
-        pos1 = parn.find(g);
-        if (pos1 != 0)
-          flag = false;
-        pos1 += g.length();
-        while (flag && stj.hasMoreToken())
-        {
-          g = stj.nextToken();
-          pos2 = parn.find(g, pos1);
-          if (pos2 == string::npos)
-          {
-            flag = false;
-            break;
-          }
-          pos1 = pos2 + g.length();
-        }
-        if (flag &&
-            ((g.length() == 0) || (pos1 == parn.length()) || (parn.rfind(g) == parn.length() - g.length())))
-          globalParameterNames2.push_back(parn);
-      }
-    }
-    else if (!globalParameters.hasParameter(globalParameterNames[i]))
+    vector<string> complName=ApplicationTools::matchingParameters(globalParameterNames[i], modelParamNames);
+
+    if (complName.size()==0)
       throw Exception("SubstitutionModelSetTools::createNonHomogeneousModelSet. Parameter '" + globalParameterNames[i] + "' is not valid.");
     else
-      globalParameterNames2.push_back(globalParameterNames[i]);
+      for (size_t j=0; j<complName.size(); j++)
+        globalParameterNames2.push_back(complName[j]);
   }
 
   // remove non global parameters
-  for (i = globalParameters.size(); i > 0; i--)
+  for (size_t i = globalParameters.size(); i > 0; i--)
   {
     if (find(globalParameterNames2.begin(), globalParameterNames2.end(), globalParameters[i - 1].getName()) == globalParameterNames2.end())
     {
@@ -144,32 +120,17 @@ SubstitutionModelSet* SubstitutionModelSetTools::createNonHomogeneousModelSet(
     }
   }
 
-  bool mixed = (dynamic_cast<MixedSubstitutionModel*>(model) != NULL);
   SubstitutionModelSet*  modelSet;
-  if (mixed)
-  {
-    modelSet = new MixedSubstitutionModelSet(model->getAlphabet());
-    // Remove the "relproba" parameters from the branch parameters and put them in the global parameters, for the hypernodes
-    for (i = branchParameters.size(); i > 0; i--)
-    {
-      if (branchParameters[i - 1].getName().find("relproba") != string::npos)
-      {
-        globalParameters.addParameter(branchParameters[i - 1]);
-        branchParameters.deleteParameter(i - 1);
-      }
-    }
-  }
-  else
-    modelSet = new SubstitutionModelSet(model->getAlphabet());
+  modelSet = new SubstitutionModelSet(model->getAlphabet());
 
   if (rootFreqs)
     modelSet->setRootFrequencies(rootFreqs);
-
+  
   // We assign a copy of this model to all nodes in the tree (excepted root node), and link all parameters with it.
   vector<int> ids = tree->getNodesId();
   int rootId = tree->getRootId();
   size_t pos = 0;
-  for (i = 0; i < ids.size(); i++)
+  for (size_t i = 0; i < ids.size(); i++)
   {
     if (ids[i] == rootId)
     {
@@ -179,36 +140,27 @@ SubstitutionModelSet* SubstitutionModelSetTools::createNonHomogeneousModelSet(
   }
 
   ids.erase(ids.begin() + static_cast<ptrdiff_t>(pos));
-  for (i = 0; i < ids.size(); i++)
+  for (size_t i = 0; i < ids.size(); i++)
   {
-    modelSet->addModel(dynamic_cast<SubstitutionModel*>(model->clone()), vector<int>(1, ids[i]));
+    modelSet->addModel(dynamic_cast<TransitionModel*>(model->clone()), vector<int>(1, ids[i]));
   }
 
   // Now alias all global parameters on all nodes:
-  for (i=0; i < globalParameters.size(); i++)
+  for (size_t i=0; i < globalParameters.size(); i++)
     {
       string pname=globalParameters[i].getName();
 
       for (size_t nn = 1; nn < ids.size(); nn++)
         modelSet->aliasParameters(pname+"_1",pname+"_"+TextTools::toString(nn+1));
     }
-  
-  // Defines the hypernodes if mixed
-  if (mixed)
-  {
-    MixedSubstitutionModelSet* pMSMS = dynamic_cast<MixedSubstitutionModelSet*>(modelSet);
-    MixedSubstitutionModel* pMSM = dynamic_cast<MixedSubstitutionModel*>(model);
 
-    size_t nbm = pMSM->getNumberOfModels();
-    for (i = 0; i < nbm; i++)
-    {
-      pMSMS->addEmptyHyperNode();
-      for (j = 0; j < ids.size(); j++)
-      {
-        pMSMS->addToHyperNode(j, vector<int>(1, static_cast<int>(i)));
-      }
-    }
-    pMSMS->computeHyperNodesProbabilities();
+  // and alias on the root
+  std::map<std::string, std::string>::const_iterator it;
+
+  for (it = aliasFreqNames.begin(); it != aliasFreqNames.end(); it++)
+  {
+    if (globalParameters.hasParameter(it->second))
+      modelSet->aliasParameters(it->second + "_1",it->first);
   }
 
   delete model; // delete template model.
diff --git a/src/Bpp/Phyl/Model/SubstitutionModelSetTools.h b/src/Bpp/Phyl/Model/SubstitutionModelSetTools.h
index 8ffbe57..18e7710 100644
--- a/src/Bpp/Phyl/Model/SubstitutionModelSetTools.h
+++ b/src/Bpp/Phyl/Model/SubstitutionModelSetTools.h
@@ -68,7 +68,7 @@ class SubstitutionModelSetTools
      * @param tree      The tree to use for the construction of the set.
      */
     static SubstitutionModelSet* createHomogeneousModelSet(
-        SubstitutionModel* model,
+        TransitionModel* model,
         FrequenciesSet* rootFreqs,
         const Tree* tree
       ) throw (AlphabetException, Exception);
@@ -82,13 +82,15 @@ class SubstitutionModelSetTools
      * @param model                The model to use.
      * @param rootFreqs            A FrequenciesSet object to parametrize root frequencies.
      * @param tree                 The tree to use for the construction of the set.
+     * @param aliasFreqNames             Aliases for the frequencies names
      * @param globalParameterNames Common parameters for all branches.
      * All other parameters will be considered distinct for all branches.
      */
     static SubstitutionModelSet* createNonHomogeneousModelSet(
-        SubstitutionModel* model,
+        TransitionModel* model,
         FrequenciesSet* rootFreqs,
         const Tree* tree,
+        const std::map<std::string, std::string>& aliasFreqNames,
         const std::vector<std::string>& globalParameterNames
       ) throw (AlphabetException, Exception);
 
diff --git a/src/Bpp/Phyl/Model/TS98.h b/src/Bpp/Phyl/Model/TS98.h
index 667348a..2cf519a 100644
--- a/src/Bpp/Phyl/Model/TS98.h
+++ b/src/Bpp/Phyl/Model/TS98.h
@@ -97,12 +97,7 @@ namespace bpp
 
     virtual ~TS98() {}
 
-#ifndef NO_VIRTUAL_COV
-    TS98*
-#else
-    Clonable*
-#endif
-    clone() const { return new TS98(*this); }
+    TS98* clone() const { return new TS98(*this); }
 
   public:
     std::string getName() const { return "TS98"; }
diff --git a/src/Bpp/Phyl/Model/WordSubstitutionModel.cpp b/src/Bpp/Phyl/Model/WordSubstitutionModel.cpp
index 976f873..3e1c0e3 100644
--- a/src/Bpp/Phyl/Model/WordSubstitutionModel.cpp
+++ b/src/Bpp/Phyl/Model/WordSubstitutionModel.cpp
@@ -37,7 +37,6 @@
  */
 
 #include "WordSubstitutionModel.h"
-#include "FrequenciesSet/WordFrequenciesSet.h"
 
 #include <Bpp/Numeric/Matrix/MatrixTools.h>
 #include <Bpp/Numeric/VectorTools.h>
@@ -57,11 +56,12 @@ using namespace std;
 /******************************************************************************/
 
 WordSubstitutionModel::WordSubstitutionModel(
-  const std::vector<SubstitutionModel*>& modelVector,
+  ModelList& modelList,
   const std::string& prefix) :
   AbstractParameterAliasable((prefix == "") ? "Word." : prefix),
-  AbstractWordSubstitutionModel(modelVector,
-                                (prefix == "") ? "Word." : prefix)
+  AbstractWordSubstitutionModel(
+      modelList,
+      (prefix == "") ? "Word." : prefix)
 {
   size_t i, nbmod = VSubMod_.size();
 
@@ -174,6 +174,7 @@ const RowMatrix<double>& WordSubstitutionModel::getPij_t(double d) const
       pijt_(i, j) = x;
     }
   }
+  
   return pijt_;
 }
 
@@ -300,14 +301,7 @@ const RowMatrix<double>& WordSubstitutionModel::getd2Pij_dt2(double d) const
 
 string WordSubstitutionModel::getName() const
 {
-  size_t nbmod = VSubMod_.size();
-  string s = "WordSubstitutionModel model: " + VSubMod_[0]->getName();
-  for (size_t i = 1; i < nbmod - 1; i++)
-  {
-    s += " " + VSubMod_[i]->getName();
-  }
-
-  return s;
+  return "Word";
 }
 
 
diff --git a/src/Bpp/Phyl/Model/WordSubstitutionModel.h b/src/Bpp/Phyl/Model/WordSubstitutionModel.h
index 9227e27..5513520 100644
--- a/src/Bpp/Phyl/Model/WordSubstitutionModel.h
+++ b/src/Bpp/Phyl/Model/WordSubstitutionModel.h
@@ -41,13 +41,15 @@
 #define _WORDSUBSTITUTIONMODEL_H_
 
 #include "AbstractWordSubstitutionModel.h"
+
+//From bpp-core
 #include <Bpp/Numeric/Matrix/Matrix.h>
 #include <Bpp/BppVector.h>
 
 namespace bpp
 {
 /**
- * @brief Basal class for words of reversible substitution models.
+ * @brief Basal class for words of substitution models.
  * @author Laurent Guéguen
  *
  * Only substitutions with one letter changed are accepted. Hence the
@@ -79,14 +81,14 @@ public:
    * @brief Build a new WordSubstitutionModel object from a
    * Vector of pointers to SubstitutionModels.
    *
-   * @param modelVector the Vector of substitution models to use, in
+   * @param modelList the list of substitution models to use, in
    *   the order of the positions in the words from left to right. All
    *   the models must be different objects to avoid parameters
    *   redundancy, otherwise only the first model is used. The used models
    *   are owned by the instance.
    * @param prefix the Namespace.
    */
-  WordSubstitutionModel(const std::vector<SubstitutionModel*>& modelVector, const std::string& prefix = "");
+  WordSubstitutionModel(ModelList& modelList, const std::string& prefix = "");
 
   /**
    * @brief Build a new WordSubstitutionModel object from a
diff --git a/src/Bpp/Phyl/NNISearchable.h b/src/Bpp/Phyl/NNISearchable.h
index 1844154..9842c4b 100755
--- a/src/Bpp/Phyl/NNISearchable.h
+++ b/src/Bpp/Phyl/NNISearchable.h
@@ -101,9 +101,7 @@ class NNISearchable:
 		NNISearchable() {}
 		virtual ~NNISearchable() {}
 
-#ifndef NO_VIRTUAL_COV
     virtual NNISearchable* clone() const = 0;
-#endif
 
 	public:
 
diff --git a/src/Bpp/Phyl/OptimizationTools.cpp b/src/Bpp/Phyl/OptimizationTools.cpp
index 213a5ca..72592a0 100644
--- a/src/Bpp/Phyl/OptimizationTools.cpp
+++ b/src/Bpp/Phyl/OptimizationTools.cpp
@@ -166,7 +166,7 @@ throw (Exception)
   ParameterList pl = parameters;
 
   // Shall we reparametrize the function to remove constraints?
-  auto_ptr<DerivableSecondOrder> frep;
+  unique_ptr<DerivableSecondOrder> frep;
   if (reparametrization)
   {
     frep.reset(new ReparametrizationDerivableSecondOrderWrapper(f, parameters));
@@ -269,7 +269,7 @@ throw (Exception)
   DerivableSecondOrder* f = tl;
   ParameterList pl = parameters;
   // Shall we use a molecular clock constraint on branch lengths?
-  auto_ptr<GlobalClockTreeLikelihoodFunctionWrapper> fclock;
+  unique_ptr<GlobalClockTreeLikelihoodFunctionWrapper> fclock;
   if (useClock)
   {
     fclock.reset(new GlobalClockTreeLikelihoodFunctionWrapper(tl));
@@ -282,7 +282,7 @@ throw (Exception)
     pl.addParameters(fclock->getHeightParameters());
   }
   // Shall we reparametrize the function to remove constraints?
-  auto_ptr<DerivableSecondOrder> frep;
+  unique_ptr<DerivableSecondOrder> frep;
   if (reparametrization)
   {
     frep.reset(new ReparametrizationDerivableSecondOrderWrapper(f, pl));
@@ -292,9 +292,9 @@ throw (Exception)
     pl = f->getParameters().subList(pl.getParameterNames());
   }
 
-  auto_ptr<AbstractNumericalDerivative> fnum;
+  unique_ptr<AbstractNumericalDerivative> fnum;
   // Build optimizer:
-  auto_ptr<Optimizer> optimizer;
+  unique_ptr<Optimizer> optimizer;
   if (optMethodDeriv == OPTIMIZATION_GRADIENT)
   {
     fnum.reset(new TwoPointsNumericalDerivative(f));
@@ -665,7 +665,7 @@ DistanceMatrix* OptimizationTools::estimateDistanceMatrix(
   if (verbose > 0)
     ApplicationTools::displayTask("Estimating distance matrix", true);
   estimationMethod.computeMatrix();
-  auto_ptr<DistanceMatrix> matrix(estimationMethod.getMatrix());
+  unique_ptr<DistanceMatrix> matrix(estimationMethod.getMatrix());
   if (verbose > 0)
     ApplicationTools::displayTaskDone();
 
@@ -709,6 +709,18 @@ TreeTemplate<Node>* OptimizationTools::buildDistanceTree(
       ApplicationTools::displayTaskDone();
 
     // Compute tree:
+    if (matrix->size() == 2) {
+      //Special case, there is only one possible tree:
+      Node* n1 = new Node(0);
+      Node* n2 = new Node(1, matrix->getName(0));
+      n2->setDistanceToFather((*matrix)(0,0) / 2.);
+      Node* n3 = new Node(2, matrix->getName(1));
+      n3->setDistanceToFather((*matrix)(0,0) / 2.);
+      n1->addSon(n2);
+      n1->addSon(n3);
+      tree = new TreeTemplate<Node>(n1);
+      break;
+    }
     if (verbose > 0)
       ApplicationTools::displayTask("Building tree");
     reconstructionMethod.setDistanceMatrix(*matrix);
@@ -729,8 +741,8 @@ TreeTemplate<Node>* OptimizationTools::buildDistanceTree(
       break;  // Ends here.
 
     // Now, re-estimate parameters:
-    auto_ptr<SubstitutionModel> model(estimationMethod.getSubstitutionModel().clone());
-    auto_ptr<DiscreteDistribution> rdist(estimationMethod.getRateDistribution().clone());
+    unique_ptr<TransitionModel> model(estimationMethod.getSubstitutionModel().clone());
+    unique_ptr<DiscreteDistribution> rdist(estimationMethod.getRateDistribution().clone());
     DRHomogeneousTreeLikelihood tl(*tree,
         *estimationMethod.getData(),
         model.get(),
diff --git a/src/Bpp/Phyl/OptimizationTools.h b/src/Bpp/Phyl/OptimizationTools.h
index 36b3268..38bec80 100644
--- a/src/Bpp/Phyl/OptimizationTools.h
+++ b/src/Bpp/Phyl/OptimizationTools.h
@@ -517,12 +517,7 @@ public:
 
     virtual ~ScaleFunction();
 
-#ifndef NO_VIRTUAL_COV
-    ScaleFunction*
-#else
-    Clonable*
-#endif
-    clone() const { return new ScaleFunction(*this); }
+    ScaleFunction* clone() const { return new ScaleFunction(*this); }
 
 public:
     void setParameters(const ParameterList& lambda) throw (ParameterNotFoundException, ConstraintException);
diff --git a/src/Bpp/Phyl/Parsimony/DRTreeParsimonyScore.h b/src/Bpp/Phyl/Parsimony/DRTreeParsimonyScore.h
index 690b44a..775a3ed 100755
--- a/src/Bpp/Phyl/Parsimony/DRTreeParsimonyScore.h
+++ b/src/Bpp/Phyl/Parsimony/DRTreeParsimonyScore.h
@@ -81,12 +81,7 @@ public:
 
   virtual ~DRTreeParsimonyScore();
 
-#ifndef NO_VIRTUAL_COV
-  DRTreeParsimonyScore*
-#else
-  Clonable*
-#endif
-  clone() const { return new DRTreeParsimonyScore(*this); }
+  DRTreeParsimonyScore* clone() const { return new DRTreeParsimonyScore(*this); }
 
 private:
   void init_(const SiteContainer& data, bool verbose);
diff --git a/src/Bpp/Phyl/Parsimony/TreeParsimonyData.h b/src/Bpp/Phyl/Parsimony/TreeParsimonyData.h
index 71b7c66..9056761 100644
--- a/src/Bpp/Phyl/Parsimony/TreeParsimonyData.h
+++ b/src/Bpp/Phyl/Parsimony/TreeParsimonyData.h
@@ -62,9 +62,7 @@ public:
   TreeParsimonyNodeData() {}
   virtual ~TreeParsimonyNodeData() {}
 
-#ifndef NO_VIRTUAL_COV
   TreeParsimonyNodeData* clone() const = 0;
-#endif
 
 public:
   /**
@@ -98,9 +96,7 @@ public:
   TreeParsimonyData() {}
   virtual ~TreeParsimonyData() {}
 
-#ifndef NO_VIRTUAL_COV
   TreeParsimonyData* clone() const = 0;
-#endif
 
 public:
   virtual const TreeTemplate<Node>* getTree() const = 0;
diff --git a/src/Bpp/Phyl/Parsimony/TreeParsimonyScore.h b/src/Bpp/Phyl/Parsimony/TreeParsimonyScore.h
index 6e60ade..a59b779 100755
--- a/src/Bpp/Phyl/Parsimony/TreeParsimonyScore.h
+++ b/src/Bpp/Phyl/Parsimony/TreeParsimonyScore.h
@@ -59,11 +59,7 @@ public:
   TreeParsimonyScore() {}
   virtual ~TreeParsimonyScore() {}
 
-#if defined(NO_VIRTUAL_COV)
-  Clonable* clone() const = 0;
-#else
   TreeParsimonyScore* clone() const = 0;
-#endif
 
 public:
   /**
diff --git a/src/Bpp/Phyl/PhyloStatistics.h b/src/Bpp/Phyl/PhyloStatistics.h
index 4acc217..78cc8c2 100644
--- a/src/Bpp/Phyl/PhyloStatistics.h
+++ b/src/Bpp/Phyl/PhyloStatistics.h
@@ -76,12 +76,7 @@ namespace bpp
       {}
       virtual ~PhyloStatistics() {}
 
-#ifndef NO_VIRTUAL_COV
-      Clonable*
-#else
-      PhyloStatistics*
-#endif
-      clone() const { return new PhyloStatistics(*this); }
+      PhyloStatistics* clone() const { return new PhyloStatistics(*this); }
 
       /**
        * @brief Compute statistics for a given input tree.
diff --git a/src/Bpp/Phyl/Simulation/DetailedSiteSimulator.h b/src/Bpp/Phyl/Simulation/DetailedSiteSimulator.h
index 58cf4ab..9505357 100644
--- a/src/Bpp/Phyl/Simulation/DetailedSiteSimulator.h
+++ b/src/Bpp/Phyl/Simulation/DetailedSiteSimulator.h
@@ -170,7 +170,7 @@ class SiteSimulationResult
     /**
      * @return The site corresponding to this simulation.
      */
-    virtual Site* getSite(const SubstitutionModel& model) const {
+    virtual Site* getSite(const TransitionModel& model) const {
       std::vector<size_t> mstates = getFinalStates();
       std::vector<int> astates(mstates.size());
       for (size_t i = 0; i < mstates.size(); ++i) {
diff --git a/src/Bpp/Phyl/Simulation/HomogeneousSequenceSimulator.h b/src/Bpp/Phyl/Simulation/HomogeneousSequenceSimulator.h
index 52fa405..746044f 100644
--- a/src/Bpp/Phyl/Simulation/HomogeneousSequenceSimulator.h
+++ b/src/Bpp/Phyl/Simulation/HomogeneousSequenceSimulator.h
@@ -5,36 +5,36 @@
 //
 
 /*
-Copyright or © or Copr. CNRS, (November 16, 2004)
+  Copyright or © or Copr. CNRS, (November 16, 2004)
 
-This software is a computer program whose purpose is to provide classes
-for phylogenetic data analysis.
+  This software is a computer program whose purpose is to provide classes
+  for phylogenetic data analysis.
 
-This software is governed by the CeCILL  license under French law and
-abiding by the rules of distribution of free software.  You can  use, 
-modify and/ or redistribute the software under the terms of the CeCILL
-license as circulated by CEA, CNRS and INRIA at the following URL
-"http://www.cecill.info". 
+  This software is governed by the CeCILL  license under French law and
+  abiding by the rules of distribution of free software.  You can  use, 
+  modify and/ or redistribute the software under the terms of the CeCILL
+  license as circulated by CEA, CNRS and INRIA at the following URL
+  "http://www.cecill.info". 
 
-As a counterpart to the access to the source code and  rights to copy,
-modify and redistribute granted by the license, users are provided only
-with a limited warranty  and the software's author,  the holder of the
-economic rights,  and the successive licensors  have only  limited
-liability. 
+  As a counterpart to the access to the source code and  rights to copy,
+  modify and redistribute granted by the license, users are provided only
+  with a limited warranty  and the software's author,  the holder of the
+  economic rights,  and the successive licensors  have only  limited
+  liability. 
 
-In this respect, the user's attention is drawn to the risks associated
-with loading,  using,  modifying and/or developing or reproducing the
-software by the user in light of its specific status of free software,
-that may mean  that it is complicated to manipulate,  and  that  also
-therefore means  that it is reserved for developers  and  experienced
-professionals having in-depth computer knowledge. Users are therefore
-encouraged to load and test the software's suitability as regards their
-requirements in conditions enabling the security of their systems and/or 
-data to be ensured and,  more generally, to use and operate it in the 
-same conditions as regards security. 
+  In this respect, the user's attention is drawn to the risks associated
+  with loading,  using,  modifying and/or developing or reproducing the
+  software by the user in light of its specific status of free software,
+  that may mean  that it is complicated to manipulate,  and  that  also
+  therefore means  that it is reserved for developers  and  experienced
+  professionals having in-depth computer knowledge. Users are therefore
+  encouraged to load and test the software's suitability as regards their
+  requirements in conditions enabling the security of their systems and/or 
+  data to be ensured and,  more generally, to use and operate it in the 
+  same conditions as regards security. 
 
-The fact that you are presently reading this means that you have had
-knowledge of the CeCILL license and that you accept its terms.
+  The fact that you are presently reading this means that you have had
+  knowledge of the CeCILL license and that you accept its terms.
 */
 
 #ifndef _HOMOGENEOUSSEQUENCESIMULATOR_H_
@@ -50,26 +50,26 @@ namespace bpp
  *
  * This is an alias class, for clarity and backward compatibility.
  */
-class HomogeneousSequenceSimulator:
-  public NonHomogeneousSequenceSimulator
-{
-	public:
+  class HomogeneousSequenceSimulator:
+    public NonHomogeneousSequenceSimulator
+  {
+  public:
 		
-		HomogeneousSequenceSimulator(
-			const SubstitutionModel* model,
-			const DiscreteDistribution* rate,
-			const Tree* tree
-		) : NonHomogeneousSequenceSimulator(model, rate, tree) {}
+    HomogeneousSequenceSimulator(
+      const TransitionModel* model,
+      const DiscreteDistribution* rate,
+      const Tree* tree
+      ) : NonHomogeneousSequenceSimulator(model, rate, tree) {}
 			
-		virtual ~HomogeneousSequenceSimulator() {}
+    virtual ~HomogeneousSequenceSimulator() {}
 
-	public:
-    const SubstitutionModel* getSubstitutionModel() const
+  public:
+    const TransitionModel* getModel() const
     {
-      return getSubstitutionModelSet()->getModel(0);
+      return getSubstitutionModelSet()->getTransitionModel(0);
     }
 	
-};
+  };
 
 } //end of namespace bpp.
 
diff --git a/src/Bpp/Phyl/Simulation/NonHomogeneousSequenceSimulator.cpp b/src/Bpp/Phyl/Simulation/NonHomogeneousSequenceSimulator.cpp
index 249d29c..4deed21 100644
--- a/src/Bpp/Phyl/Simulation/NonHomogeneousSequenceSimulator.cpp
+++ b/src/Bpp/Phyl/Simulation/NonHomogeneousSequenceSimulator.cpp
@@ -70,7 +70,8 @@ NonHomogeneousSequenceSimulator::NonHomogeneousSequenceSimulator(
   nbNodes_(),
   nbClasses_(rate_->getNumberOfCategories()),
   nbStates_(modelSet_->getNumberOfStates()),
-  continuousRates_(false)
+  continuousRates_(false),
+  outputInternalSequences_(false)
 {
   if (!modelSet->isFullySetUpFor(*tree))
     throw Exception("NonHomogeneousSequenceSimulator(constructor). Model set is not fully specified.");
@@ -80,7 +81,7 @@ NonHomogeneousSequenceSimulator::NonHomogeneousSequenceSimulator(
 /******************************************************************************/
 
 NonHomogeneousSequenceSimulator::NonHomogeneousSequenceSimulator(
-  const SubstitutionModel* model,
+  const TransitionModel* model,
   const DiscreteDistribution* rate,
   const Tree* tree) :
   modelSet_(0),
@@ -95,11 +96,12 @@ NonHomogeneousSequenceSimulator::NonHomogeneousSequenceSimulator(
   nbNodes_(),
   nbClasses_(rate_->getNumberOfCategories()),
   nbStates_(model->getNumberOfStates()),
-  continuousRates_(false)
+  continuousRates_(false),
+  outputInternalSequences_(false)
 {
   FixedFrequenciesSet* fSet = new FixedFrequenciesSet(model->getStateMap().clone(), model->getFrequencies());
   fSet->setNamespace("anc.");
-  modelSet_ = SubstitutionModelSetTools::createHomogeneousModelSet(dynamic_cast<SubstitutionModel*>(model->clone()), fSet, templateTree_);
+  modelSet_ = SubstitutionModelSetTools::createHomogeneousModelSet(model->clone(), fSet, templateTree_);
   init();
 }
 
@@ -107,13 +109,28 @@ NonHomogeneousSequenceSimulator::NonHomogeneousSequenceSimulator(
 
 void NonHomogeneousSequenceSimulator::init()
 {
-  seqNames_.resize(leaves_.size());
-  for (size_t i = 0; i < seqNames_.size(); i++)
-  {
-    seqNames_[i] = leaves_[i]->getName();
+  vector<SNode*> nodes = tree_.getNodes();
+
+  if (outputInternalSequences_) {
+    seqNames_.resize(nodes.size());
+    for (size_t i = 0; i < seqNames_.size(); i++)
+    {
+      if (nodes[i]->isLeaf()) {
+        seqNames_[i] = nodes[i]->getName();
+      }
+    else {
+      seqNames_[i] = TextTools::toString( nodes[i]->getId() );
+      }
+    }
+  }
+  else {
+    seqNames_.resize(leaves_.size());
+    for (size_t i = 0; i < seqNames_.size(); i++)
+    {
+      seqNames_[i] = leaves_[i]->getName();
+    }
   }
   // Initialize cumulative pxy:
-  vector<SNode*> nodes = tree_.getNodes();
   nodes.pop_back(); // remove root
   nbNodes_ = nodes.size();
 
@@ -196,10 +213,29 @@ Site* NonHomogeneousSequenceSimulator::simulateSite(size_t ancestralStateIndex,
     evolveInternal(root->getSon(i), rateClass);
   }
   // Now create a Site object:
-  Vint site(leaves_.size());
-  for (size_t i = 0; i < leaves_.size(); ++i)
-  {
-    site[i] = leaves_[i]->getInfos().model->getAlphabetStateAsInt(leaves_[i]->getInfos().state);
+  size_t n = nbNodes_ + 1 ;
+  if (! outputInternalSequences_) {
+    n = leaves_.size() ;
+  }
+  Vint site(n);
+
+  if (outputInternalSequences_) {
+  vector<SNode*> nodes = tree_.getNodes();
+  for (size_t i = 0; i < n; i++)
+    {
+      if (i == n - 1) { // We take the model of node i-1 because the root has no model
+        site[i] = nodes[i-1]->getInfos().model->getAlphabetStateAsInt(nodes[i]->getInfos().state);
+      }
+      else {
+        site[i] = nodes[i]->getInfos().model->getAlphabetStateAsInt(nodes[i]->getInfos().state);
+      }
+    }
+  }
+  else {
+    for (size_t i = 0; i < leaves_.size(); ++i)
+    {
+      site[i] = leaves_[i]->getInfos().model->getAlphabetStateAsInt(leaves_[i]->getInfos().state);
+    }
   }
   return new Site(site, alphabet_);
 }
@@ -216,10 +252,29 @@ Site* NonHomogeneousSequenceSimulator::simulateSite(size_t ancestralStateIndex,
     evolveInternal(root->getSon(i), rate);
   }
   // Now create a Site object:
-  Vint site(leaves_.size());
-  for (size_t i = 0; i < leaves_.size(); i++)
-  {
-    site[i] = leaves_[i]->getInfos().model->getAlphabetStateAsInt(leaves_[i]->getInfos().state);
+  size_t n = nbNodes_ + 1 ;
+  if (! outputInternalSequences_) {
+    n = leaves_.size() ;
+  }
+  Vint site(n);
+
+  if (outputInternalSequences_) {
+  vector<SNode*> nodes = tree_.getNodes();
+  for (size_t i = 0; i < n; i++)
+    {
+      if (i == n - 1) { // We take the model of node i-1 because the root has no model
+        site[i] = nodes[i-1]->getInfos().model->getAlphabetStateAsInt(nodes[i]->getInfos().state);
+      }
+      else {
+        site[i] = nodes[i]->getInfos().model->getAlphabetStateAsInt(nodes[i]->getInfos().state);
+      }
+    }
+  }
+  else {
+    for (size_t i = 0; i < leaves_.size(); i++)
+    {
+      site[i] = leaves_[i]->getInfos().model->getAlphabetStateAsInt(leaves_[i]->getInfos().state);
+    }
   }
   return new Site(site, alphabet_);
 }
@@ -393,7 +448,7 @@ size_t NonHomogeneousSequenceSimulator::evolve(const SNode* node, size_t initial
   double cumpxy = 0;
   double rand = RandomTools::giveRandomNumberBetweenZeroAndEntry(1.);
   double l = rate * node->getDistanceToFather();
-  const SubstitutionModel* model = node->getInfos().model;
+  const TransitionModel* model = node->getInfos().model;
   for (size_t y = 0; y < nbStates_; y++)
   {
     cumpxy += model->Pij_t(initialStateIndex, y, l);
@@ -493,19 +548,44 @@ SiteContainer* NonHomogeneousSequenceSimulator::multipleEvolve(
   }
   // Now create a SiteContainer object:
   AlignedSequenceContainer* sites = new AlignedSequenceContainer(alphabet_);
-  size_t n = leaves_.size();
   size_t nbSites = initialStateIndices.size();
-  const SubstitutionModel* model = 0;
-  for (size_t i = 0; i < n; i++)
-  {
-    vector<int> content(nbSites);
-    vector<size_t>& states = leaves_[i]->getInfos().states;
-    model = leaves_[i]->getInfos().model;
-    for (size_t j = 0; j < nbSites; j++)
+  const TransitionModel* model = 0;
+  if (outputInternalSequences_) {
+    vector<SNode*> nodes = tree_.getNodes();
+    size_t n = nbNodes_ + 1 ;
+    for (size_t i = 0; i < n; i++)
+    {
+      vector<int> content(nbSites);
+      vector<size_t>& states = nodes[i]->getInfos().states;
+      if (i == n - 1) { // If at the root, there is no model, so we take the model of node n-1.
+        model = nodes[i-1]->getInfos().model;
+      }
+      else {
+        model = nodes[i]->getInfos().model;
+      }
+      for (size_t j = 0; j < nbSites; j++)
+      {
+        content[j] = model->getAlphabetStateAsInt(states[j]);
+      }
+      if (nodes[i]->isLeaf())
+        sites->addSequence(BasicSequence(nodes[i]->getName(), content, alphabet_), false);
+      else
+        sites->addSequence(BasicSequence(TextTools::toString(nodes[i]->getId()), content, alphabet_), false);
+    }
+  }
+    else {
+    size_t n = leaves_.size();
+    for (size_t i = 0; i < n; i++)
     {
-      content[j] = model->getAlphabetStateAsInt(states[j]);
+      vector<int> content(nbSites);
+      vector<size_t>& states = leaves_[i]->getInfos().states;
+      model = leaves_[i]->getInfos().model;
+      for (size_t j = 0; j < nbSites; j++)
+      {
+        content[j] = model->getAlphabetStateAsInt(states[j]);
+      }
+      sites->addSequence(BasicSequence(leaves_[i]->getName(), content, alphabet_), false);
     }
-    sites->addSequence(BasicSequence(leaves_[i]->getName(), content, alphabet_), false);
   }
   return sites;
 }
@@ -532,7 +612,12 @@ void NonHomogeneousSequenceSimulator::dEvolveInternal(SNode* node, double rate,
     cerr << "DEBUG: NonHomogeneousSequenceSimulator::evolveInternal. Forbidden call of method on root node." << endl;
     return;
   }
-  SimpleMutationProcess process(node->getInfos().model);
+  const TransitionModel* tm=node->getInfos().model;
+  if (dynamic_cast<const SubstitutionModel*>(tm)==0)
+    throw Exception("NonHomogeneousSequenceSimulator::dEvolveInternal : detailed simulation not possible for non-markovian model");
+  
+  SimpleMutationProcess process(dynamic_cast<const SubstitutionModel*>(tm));
+  
   MutationPath mp = process.detailedEvolve(node->getFather()->getInfos().state, node->getDistanceToFather() * rate);
   node->getInfos().state = mp.getFinalState();
 
@@ -548,3 +633,28 @@ void NonHomogeneousSequenceSimulator::dEvolveInternal(SNode* node, double rate,
 
 /******************************************************************************/
 
+void NonHomogeneousSequenceSimulator::outputInternalSequences(bool yn) {
+  outputInternalSequences_ = yn;
+  if (outputInternalSequences_) {
+    vector<SNode*> nodes = tree_.getNodes();
+    seqNames_.resize(nodes.size());
+    for (size_t i = 0; i < seqNames_.size(); i++)
+    {
+      if (nodes[i]->isLeaf()) {
+        seqNames_[i] = nodes[i]->getName();
+      }
+    else {
+      seqNames_[i] = TextTools::toString( nodes[i]->getId() );
+      }
+    }
+  }
+  else {
+    seqNames_.resize(leaves_.size());
+    for (size_t i = 0; i < seqNames_.size(); i++)
+    {
+      seqNames_[i] = leaves_[i]->getName();
+    }
+  }
+}
+
+/******************************************************************************/
diff --git a/src/Bpp/Phyl/Simulation/NonHomogeneousSequenceSimulator.h b/src/Bpp/Phyl/Simulation/NonHomogeneousSequenceSimulator.h
index 7b7edcf..dcb0eee 100644
--- a/src/Bpp/Phyl/Simulation/NonHomogeneousSequenceSimulator.h
+++ b/src/Bpp/Phyl/Simulation/NonHomogeneousSequenceSimulator.h
@@ -12,16 +12,16 @@ This software is a computer program whose purpose is to provide classes
 for phylogenetic data analysis.
 
 This software is governed by the CeCILL  license under French law and
-abiding by the rules of distribution of free software.  You can  use, 
+abiding by the rules of distribution of free software.  You can  use,
 modify and/ or redistribute the software under the terms of the CeCILL
 license as circulated by CEA, CNRS and INRIA at the following URL
-"http://www.cecill.info". 
+"http://www.cecill.info".
 
 As a counterpart to the access to the source code and  rights to copy,
 modify and redistribute granted by the license, users are provided only
 with a limited warranty  and the software's author,  the holder of the
 economic rights,  and the successive licensors  have only  limited
-liability. 
+liability.
 
 In this respect, the user's attention is drawn to the risks associated
 with loading,  using,  modifying and/or developing or reproducing the
@@ -30,9 +30,9 @@ that may mean  that it is complicated to manipulate,  and  that  also
 therefore means  that it is reserved for developers  and  experienced
 professionals having in-depth computer knowledge. Users are therefore
 encouraged to load and test the software's suitability as regards their
-requirements in conditions enabling the security of their systems and/or 
-data to be ensured and,  more generally, to use and operate it in the 
-same conditions as regards security. 
+requirements in conditions enabling the security of their systems and/or
+data to be ensured and,  more generally, to use and operate it in the
+same conditions as regards security.
 
 The fact that you are presently reading this means that you have had
 knowledge of the CeCILL license and that you accept its terms.
@@ -70,7 +70,7 @@ class SimData
     size_t state;
     std::vector<size_t> states;
     VVVdouble cumpxy;
-    const SubstitutionModel* model;
+    const TransitionModel* model;
 
   public:
     SimData(): state(), states(), cumpxy(), model(0) {}
@@ -104,13 +104,13 @@ class NonHomogeneousSequenceSimulator:
     const Tree                * templateTree_;
     mutable TreeTemplate<SNode> tree_;
     bool ownModelSet_;
-  
+
     /**
      * @brief This stores once for all all leaves in a given order.
      * This order will be used during site creation.
      */
     std::vector<SNode*> leaves_;
-  
+
     std::vector<std::string> seqNames_;
 
     size_t nbNodes_;
@@ -118,14 +118,17 @@ class NonHomogeneousSequenceSimulator:
     size_t nbStates_;
 
     bool continuousRates_;
-  
+
+    // Should we ouptut internal sequences as well?
+    bool outputInternalSequences_;
+
     /**
      * @name Stores intermediate results.
      *
      * @{
      */
 
-  public:    
+  public:
     NonHomogeneousSequenceSimulator(
       const SubstitutionModelSet* modelSet,
       const DiscreteDistribution* rate,
@@ -133,11 +136,11 @@ class NonHomogeneousSequenceSimulator:
     ) throw (Exception);
 
     NonHomogeneousSequenceSimulator(
-      const SubstitutionModel* model,
+      const TransitionModel* model,
       const DiscreteDistribution* rate,
       const Tree* tree
     );
-      
+
     virtual ~NonHomogeneousSequenceSimulator()
     {
       if (ownModelSet_ && modelSet_) delete modelSet_;
@@ -156,7 +159,8 @@ class NonHomogeneousSequenceSimulator:
       nbNodes_        (nhss.nbNodes_),
       nbClasses_      (nhss.nbClasses_),
       nbStates_       (nhss.nbStates_),
-      continuousRates_(nhss.continuousRates_)
+      continuousRates_(nhss.continuousRates_),
+      outputInternalSequences_(nhss.outputInternalSequences_)
     {}
 
     NonHomogeneousSequenceSimulator& operator=(const NonHomogeneousSequenceSimulator& nhss)
@@ -174,15 +178,11 @@ class NonHomogeneousSequenceSimulator:
       nbClasses_       = nhss.nbClasses_;
       nbStates_        = nhss.nbStates_;
       continuousRates_ = nhss.continuousRates_;
+      outputInternalSequences_ = nhss.outputInternalSequences_;
       return *this;
     }
 
-#ifndef NO_VIRTUAL_COV
-    NonHomogeneousSequenceSimulator*
-#else
-    Clonable*
-#endif
-    clone() const { return new NonHomogeneousSequenceSimulator(*this); }
+    NonHomogeneousSequenceSimulator* clone() const { return new NonHomogeneousSequenceSimulator(*this); }
 
   private:
     /**
@@ -193,7 +193,7 @@ class NonHomogeneousSequenceSimulator:
     void init();
 
   public:
-  
+
     /**
      * @name The SiteSimulator interface
      *
@@ -204,23 +204,23 @@ class NonHomogeneousSequenceSimulator:
     Site* simulateSite(size_t ancestralStateIndex) const;
 
     Site* simulateSite(size_t ancestralStateIndex, double rate) const;
-    
+
     Site* simulateSite(double rate) const;
 
     std::vector<std::string> getSequencesNames() const { return seqNames_; }
     /** @} */
-    
+
     /**
      * @name The DetailedSiteSimulator interface.
      *
      * @{
      */
     RASiteSimulationResult* dSimulateSite() const;
-    
+
     RASiteSimulationResult* dSimulateSite(size_t ancestralStateIndex) const;
-    
+
     RASiteSimulationResult* dSimulateSite(size_t ancestralStateIndex, double rate) const;
-    
+
     RASiteSimulationResult* dSimulateSite(double rate) const;
     /** @} */
 
@@ -231,7 +231,7 @@ class NonHomogeneousSequenceSimulator:
      */
     SiteContainer* simulate(size_t numberOfSites) const;
     /** @} */
-    
+
     /**
      * @name SiteSimulator and SequenceSimulator interface
      *
@@ -248,14 +248,14 @@ class NonHomogeneousSequenceSimulator:
     virtual Site* simulateSite(size_t ancestralStateIndex, size_t rateClass) const;
     virtual RASiteSimulationResult* dSimulateSite(size_t ancestralStateIndex, size_t rateClass) const;
     /** @} */
-  
+
     /**
      * @brief Get the substitution model associated to this instance.
      *
      * @return The substitution model associated to this instance.
      */
     const SubstitutionModelSet* getSubstitutionModelSet() const { return modelSet_; }
-    
+
     /**
      * @brief Get the rate distribution associated to this instance.
      *
@@ -278,9 +278,18 @@ class NonHomogeneousSequenceSimulator:
      * @param yn Tell if we should use continuous rates.
      */
     void enableContinuousRates(bool yn) { continuousRates_ = yn; }
-  
+
+    /**
+     * @brief Sets whether we will output the internal sequences or not.
+     *
+     *
+     * @param yn Tell if we should output internal sequences.
+     */
+    void outputInternalSequences(bool yn) ;
+
+
   protected:
-    
+
     /**
      * @brief Evolve from an initial state along a branch, knowing the evolutionary rate class.
      *
@@ -288,7 +297,7 @@ class NonHomogeneousSequenceSimulator:
      * This method is used for the implementation of the SiteSimulator interface.
      */
     size_t evolve(const SNode* node, size_t initialStateIndex, size_t rateClass) const;
-    
+
     /**
      * @brief Evolve from an initial state along a branch, knowing the evolutionary rate.
      *
@@ -296,7 +305,7 @@ class NonHomogeneousSequenceSimulator:
      * This method is used for the implementation of the SiteSimulator interface.
      */
     size_t evolve(const SNode* node, size_t initialStateIndex, double rate) const;
-    
+
     /**
      * @brief The same as the evolve(initialState, rateClass) function, but for several sites at a time.
      *
@@ -307,12 +316,13 @@ class NonHomogeneousSequenceSimulator:
         const std::vector<size_t>& initialStateIndices,
         const std::vector<size_t>& rateClasses,
         std::vector<size_t>& finalStates) const;
+
     SiteContainer* multipleEvolve(
         const std::vector<size_t>& initialStates,
         const std::vector<size_t>& rateClasses) const;
-    
+
     void dEvolve(size_t initialState, double rate, RASiteSimulationResult& rassr) const;
-    
+
     /**
      * @name The 'Internal' methods.
      *
@@ -343,4 +353,3 @@ class NonHomogeneousSequenceSimulator:
 } //end of namespace bpp.
 
 #endif //_NONHOMOGENEOUSSEQUENCESIMULATOR_H_
-
diff --git a/src/Bpp/Phyl/Simulation/SequenceSimulator.h b/src/Bpp/Phyl/Simulation/SequenceSimulator.h
index ef0fa94..ef7916d 100755
--- a/src/Bpp/Phyl/Simulation/SequenceSimulator.h
+++ b/src/Bpp/Phyl/Simulation/SequenceSimulator.h
@@ -60,9 +60,7 @@ class SequenceSimulator:
     SequenceSimulator() {}
     virtual ~SequenceSimulator() {}
 
-#ifndef NO_VIRTUAL_COV
     SequenceSimulator* clone() const = 0;
-#endif
   
   public:
     virtual SiteContainer* simulate(size_t numberOfSites) const = 0;
diff --git a/src/Bpp/Phyl/SitePatterns.h b/src/Bpp/Phyl/SitePatterns.h
index f177a6e..7f04337 100755
--- a/src/Bpp/Phyl/SitePatterns.h
+++ b/src/Bpp/Phyl/SitePatterns.h
@@ -157,12 +157,7 @@ class SitePatterns :
       return *this;
     }
 
-#ifdef NO_VIRTUAL_COV
-    Clonable*
-#else
-    SitePatterns *
-#endif
-    clone() const { return new SitePatterns(*this); }
+    SitePatterns * clone() const { return new SitePatterns(*this); }
 
   public:
     /**
diff --git a/src/Bpp/Phyl/TopologySearch.h b/src/Bpp/Phyl/TopologySearch.h
index c95f628..6268824 100755
--- a/src/Bpp/Phyl/TopologySearch.h
+++ b/src/Bpp/Phyl/TopologySearch.h
@@ -86,9 +86,7 @@ class TopologyListener :
     TopologyListener() {}
     virtual ~TopologyListener() {}
 
-#ifndef NO_VIRTUAL_COV
     TopologyListener* clone() const = 0;
-#endif
 
   public:
 		/**
diff --git a/src/Bpp/Phyl/Tree.h b/src/Bpp/Phyl/Tree.h
index a37e3d7..cd8e1cd 100755
--- a/src/Bpp/Phyl/Tree.h
+++ b/src/Bpp/Phyl/Tree.h
@@ -56,7 +56,7 @@
  * @section tree Tree data storage and manipulation
  *
  * @par
- * The Bio++ Phylogenetics Library (PhylLib) provides classes and methods for phylogenetics and molecular evolution.
+ * The Bio++ Phylogenetics Library (bpp-phyl) provides classes and methods for phylogenetics and molecular evolution.
  * The bpp::Tree interface provides general methods to store and manipulate phylogenetic trees.
  * Several utilitary methods can also be found in the bpp::TreeTools static class.
  * The only implementation for now of the bpp::Tree interface is the bpp::TreeTemplate class.
diff --git a/src/Bpp/Phyl/TreeTemplate.h b/src/Bpp/Phyl/TreeTemplate.h
index 60ca3d7..a1d3af5 100644
--- a/src/Bpp/Phyl/TreeTemplate.h
+++ b/src/Bpp/Phyl/TreeTemplate.h
@@ -165,6 +165,8 @@ public:
 
   size_t getNumberOfNodes() const { return TreeTemplateTools::getNumberOfNodes(*root_); }
 
+  size_t getNumberOfBranches() const { return getNumberOfNodes() -1;}
+
   int getLeafId(const std::string& name) const throw (NodeNotFoundException) { return TreeTemplateTools::getLeafId(*root_, name); }
 
   std::vector<int> getLeavesId() const { return TreeTemplateTools::getLeavesId(*root_); }
@@ -398,7 +400,7 @@ public:
    *
    * @{
    */
-  virtual void setRootNode(N* root) { root_ = root; }
+  virtual void setRootNode(N* root) { root_ = root; root_->removeFather(); }
 
   virtual N* getRootNode() { return root_; }
 
@@ -473,19 +475,13 @@ public:
     if (root_ == newRoot) return;
     if (isRooted()) unroot();
     std::vector<Node*> path = TreeTemplateTools::getPathBetweenAnyTwoNodes(*root_, *newRoot);
-
     for (size_t i = 0; i < path.size() - 1; i++)
     {
-      // pathMatrix[i] -> _father = pathMatrix[i + 1];
-      // pathMatrix[i] -> setDistanceToFather(pathMatrix[i + 1] -> getDistanceToFather());
-      // typename vector<Node *>::iterator vec_iter;
-      // vec_iter = remove(pathMatrix[i] -> _sons.begin(), pathMatrix[i] -> _sons.end(), pathMatrix[i + 1]);
-      // pathMatrix[i] -> _sons.erase(vec_iter, pathMatrix[i] -> _sons.end()); // pg 1170, primer.
-      // pathMatrix[i+1] -> _sons.push_back(pathMatrix[i + 1] -> getFather());
-      // pathMatrix[i+1] -> _father = 0;
-      path[i]->removeSon(path[i + 1]);
-      if (path[i + 1]->hasDistanceToFather()) path[i]->setDistanceToFather(path[i + 1]->getDistanceToFather());
+      if (path[i + 1]->hasDistanceToFather())  { 
+	      path[i]->setDistanceToFather(path[i + 1]->getDistanceToFather());
+	    }
       else path[i]->deleteDistanceToFather();
+      path[i]->removeSon(path[i + 1]);
       path[i + 1]->addSon(path[i]);
 
       std::vector<std::string> names = path[i + 1]->getBranchPropertyNames();
@@ -495,6 +491,7 @@ public:
       }
       path[i + 1]->deleteBranchProperties();
     }
+
     newRoot->deleteDistanceToFather();
     newRoot->deleteBranchProperties();
     root_ = newRoot;
diff --git a/src/Bpp/Phyl/TreeTemplateTools.cpp b/src/Bpp/Phyl/TreeTemplateTools.cpp
index f0633fc..dae33e0 100644
--- a/src/Bpp/Phyl/TreeTemplateTools.cpp
+++ b/src/Bpp/Phyl/TreeTemplateTools.cpp
@@ -251,7 +251,7 @@ TreeTemplateTools::Element TreeTemplateTools::getElement(const string& elt) thro
 /******************************************************************************/
 
 
-Node* TreeTemplateTools::parenthesisToNode(const string& description, bool bootstrap, const string& propertyName, bool withId)
+Node* TreeTemplateTools::parenthesisToNode(const string& description, unsigned int& nodeCounter, bool bootstrap, const string& propertyName, bool withId, bool verbose)
 {
   // cout << "NODE: " << description << endl;
   Element elt = getElement(description);
@@ -320,28 +320,36 @@ Node* TreeTemplateTools::parenthesisToNode(const string& description, bool boots
     for (size_t i = 0; i < elements.size(); i++)
     {
       // cout << "NODE: SUBNODE: " << i << ", " << elements[i] << endl;
-      Node* son = parenthesisToNode(elements[i], bootstrap, propertyName, withId);
+      Node* son = parenthesisToNode(elements[i], nodeCounter, bootstrap, propertyName, withId, verbose);
       node->addSon(son);
     }
   }
+  nodeCounter++;
+  if (verbose)
+    ApplicationTools::displayUnlimitedGauge(nodeCounter);
   return node;
 }
 
 /******************************************************************************/
 
-TreeTemplate<Node>* TreeTemplateTools::parenthesisToTree(const string& description, bool bootstrap, const string& propertyName, bool withId) throw (Exception)
+TreeTemplate<Node>* TreeTemplateTools::parenthesisToTree(const string& description, bool bootstrap, const string& propertyName, bool withId, bool verbose) throw (Exception)
 {
   string::size_type semi = description.rfind(';');
   if (semi == string::npos)
     throw Exception("TreeTemplateTools::parenthesisToTree(). Bad format: no semi-colon found.");
   string content = description.substr(0, semi);
-  Node* node = parenthesisToNode(content, bootstrap, propertyName, withId);
+  unsigned int nodeCounter = 0;
+  Node* node = parenthesisToNode(content, nodeCounter, bootstrap, propertyName, withId, verbose);
   TreeTemplate<Node>* tree = new TreeTemplate<Node>();
   tree->setRootNode(node);
   if (!withId)
   {
     tree->resetNodesId();
   }
+  if (verbose) {
+    (*ApplicationTools::message) << " nodes loaded.";
+    ApplicationTools::message->endLine();
+  }
   return tree;
 }
 
@@ -618,7 +626,7 @@ TreeTemplate<Node>* TreeTemplateTools::getRandomTree(vector<string>& leavesNames
 
 /******************************************************************************/
 
-vector<Node*> TreeTemplateTools::getPathBetweenAnyTwoNodes(Node& node1, Node& node2, bool includeAncestor)
+vector<Node*> TreeTemplateTools::getPathBetweenAnyTwoNodes(Node& node1, Node& node2, bool includeAncestor, bool includeAncestorAtEndOfPath)
 {
   vector<Node*> path;
   vector<Node*> pathMatrix1;
@@ -652,11 +660,11 @@ vector<Node*> TreeTemplateTools::getPathBetweenAnyTwoNodes(Node& node1, Node& no
   } else if (pos1 == 0) {
     //Node 1 is the root node
     //Note: we need to use push_back here as the insert method does not work with reverse iterators.
-    for (size_t i = pathMatrix2.size(); i > 0; --i)
+    for (size_t i = (includeAncestorAtEndOfPath ? pathMatrix2.size(): pathMatrix2.size() - 1); i > 0; --i)
       path.push_back(pathMatrix2[i-1]);
   } else if (pos2 == 0) {
     //Node 2 is the root node
-    path.insert(path.end(), pathMatrix1.begin(), pathMatrix1.end());
+    path.insert(path.end(), pathMatrix1.begin(), (includeAncestorAtEndOfPath ? pathMatrix1.end() : --pathMatrix1.end()));
   } else {
     Node* commonAnc = 0;
     while (pathMatrix1[pos1] == pathMatrix2[pos2] && pos1 > 0 && pos2 > 0)
@@ -668,8 +676,8 @@ vector<Node*> TreeTemplateTools::getPathBetweenAnyTwoNodes(Node& node1, Node& no
     path.insert(path.end(), pathMatrix1.begin(), pathMatrix1.begin() + static_cast<ptrdiff_t>(pos1 + 1));
     if (includeAncestor && commonAnc)
       path.push_back(commonAnc); // pushing once the Node that was common to both.
-                                 // note: if node1 or node2 is the common ancestor, then commonAnc is null
-                                 // and will be added as node1 or node2, respectively, even if includeAncestor is false.
+    // If node1 or node2 is the common ancestor, then commonAnc is null
+    // and was added as node1 or node2, respectively, if includeAncestorAtEndOfPath was set to true.
     //Note: we need to use push_back here as the insert method does not work with reverse iterators.
     for (size_t i = pos2 + 1; i > 0; --i)
       path.push_back(pathMatrix2[i-1]);
@@ -679,7 +687,7 @@ vector<Node*> TreeTemplateTools::getPathBetweenAnyTwoNodes(Node& node1, Node& no
 
 /******************************************************************************/
 
-vector<const Node*> TreeTemplateTools::getPathBetweenAnyTwoNodes(const Node& node1, const Node& node2, bool includeAncestor)
+vector<const Node*> TreeTemplateTools::getPathBetweenAnyTwoNodes(const Node& node1, const Node& node2, bool includeAncestor, bool includeAncestorAtEndOfPath)
 {
   vector<const Node*> path;
   vector<const Node*> pathMatrix1;
@@ -713,11 +721,11 @@ vector<const Node*> TreeTemplateTools::getPathBetweenAnyTwoNodes(const Node& nod
   } else if (pos1 == 0) {
     //Node 1 is the root node
     //Note: we need to use push_back here as the insert method does not work with reverse iterators.
-    for (size_t i = pathMatrix2.size(); i > 0; --i)
+    for (size_t i = (includeAncestorAtEndOfPath ? pathMatrix2.size(): pathMatrix2.size() - 1); i > 0; --i)
       path.push_back(pathMatrix2[i-1]);
   } else if (pos2 == 0) {
     //Node 2 is the root node
-    path.insert(path.end(), pathMatrix1.begin(), pathMatrix1.end());
+    path.insert(path.end(), pathMatrix1.begin(), (includeAncestorAtEndOfPath ? pathMatrix1.end() : --pathMatrix1.end()));
   } else {
     const Node* commonAnc = 0;
     while (pathMatrix1[pos1] == pathMatrix2[pos2] && pos1 > 0 && pos2 > 0)
@@ -727,10 +735,11 @@ vector<const Node*> TreeTemplateTools::getPathBetweenAnyTwoNodes(const Node& nod
     }
 
     path.insert(path.end(), pathMatrix1.begin(), pathMatrix1.begin() + static_cast<ptrdiff_t>(pos1 + 1));
-    if (includeAncestor && commonAnc)
-      path.push_back(commonAnc); // pushing once the Node that was common to both.
-                                 // note: if node1 or node2 is the common ancestor, then commonAnc is null
-                                 // and will be added as node1 or node2, respectively, even if includeAncestor is false.
+    if (commonAnc &&includeAncestor)
+        path.push_back(commonAnc); // pushing once the Node that was common to both.
+    // If node1 or node2 is the common ancestor, then commonAnc is null
+    // and was added as node1 or node2, respectively, if includeAncestorAtEndOfPath was set to true.
+    
     //Note: we need to use push_back here as the insert method does not work with reverse iterators.
     for (size_t i = pos2 + 1; i > 0; --i)
       path.push_back(pathMatrix2[i-1]);
@@ -742,7 +751,7 @@ vector<const Node*> TreeTemplateTools::getPathBetweenAnyTwoNodes(const Node& nod
 
 double TreeTemplateTools::getDistanceBetweenAnyTwoNodes(const Node& node1, const Node& node2)
 {
-  vector<const Node*> path = getPathBetweenAnyTwoNodes(node1, node2, false);
+  vector<const Node*> path = getPathBetweenAnyTwoNodes(node1, node2, false, false);
   double d = 0;
   for (size_t i = 0; i < path.size(); ++i)
   {
diff --git a/src/Bpp/Phyl/TreeTemplateTools.h b/src/Bpp/Phyl/TreeTemplateTools.h
index 4bb8844..5a357e0 100644
--- a/src/Bpp/Phyl/TreeTemplateTools.h
+++ b/src/Bpp/Phyl/TreeTemplateTools.h
@@ -739,9 +739,9 @@ public:
    */
   static bool haveSameOrderedTopology(const Node& n1, const Node& n2);
 
-  static std::vector<Node*> getPathBetweenAnyTwoNodes(Node& node1, Node& node2, bool includeAncestor = true);
+  static std::vector<Node*> getPathBetweenAnyTwoNodes(Node& node1, Node& node2, bool includeAncestor = true, bool includeAncestorAtEndOfPath = true);
 
-  static std::vector<const Node*> getPathBetweenAnyTwoNodes(const Node& node1, const Node& node2, bool includeAncestor = true);
+  static std::vector<const Node*> getPathBetweenAnyTwoNodes(const Node& node1, const Node& node2, bool includeAncestor = true, bool includeAncestorAtEndOfPath = true);
 
   /**
    * @brief Recursively clone a subtree structure.
@@ -956,13 +956,15 @@ public:
    * a subtree.
    *
    * @param description the string to parse;
+   * @param nodeCounter [Output] Count all created nodes.
    * @param bootstrap Tell is real bootstrap values are expected. If so, a property with name TreeTools::BOOTSTRAP will be created and stored at the corresponding node.
    * The property value will be of type Number<double>. Otherwise, an object of type String will be created and stored with the property name propertyName.
    * @param propertyName The name of the property to store. Only used if bootstrap = false.
    * @param withId Tells if node ids have been stored in the tree. If set at "true", no bootstrap or property values can be read. Node ids are positioned as bootstrap values for internal nodes, and are concatenated to leaf names after a "_" sign.
+   * @param verbose Tell if some information should be displayed, like progress bars for large trees.
    * @return A pointer toward a dynamically created subtree.
    */
-  static Node* parenthesisToNode(const std::string& description, bool bootstrap = true, const std::string& propertyName = TreeTools::BOOTSTRAP, bool withId = false);
+  static Node* parenthesisToNode(const std::string& description, unsigned int& nodeCounter, bool bootstrap = true, const std::string& propertyName = TreeTools::BOOTSTRAP, bool withId = false, bool verbose = true);
 
   /**
    * @brief Parse a string in the parenthesis format and convert it to
@@ -973,10 +975,11 @@ public:
    * The property value will be of type Number<double>. Otherwise, an object of type String will be created and stored with the property name propertyName.
    * @param propertyName The name of the property to store. Only used if bootstrap = false.
    * @param withId Tells if node ids have been stored in the tree. If set at "true", no bootstrap or property values can be read. Node ids are positioned as bootstrap values for internal nodes, and are concatenated to leaf names after a "_" sign.
+   * @param verbose Tell if some information should be displayed, like progress bars for large trees.
    * @return A pointer toward a dynamically created tree.
    * @throw Exception in case of bad format.
    */
-  static TreeTemplate<Node>* parenthesisToTree(const std::string& description, bool bootstrap = true, const std::string& propertyName = TreeTools::BOOTSTRAP, bool withId = false) throw (Exception);
+  static TreeTemplate<Node>* parenthesisToTree(const std::string& description, bool bootstrap = true, const std::string& propertyName = TreeTools::BOOTSTRAP, bool withId = false, bool verbose = true) throw (Exception);
 
   /**
    * @brief Get the parenthesis description of a subtree.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c0c57df..4f39a0d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,36 +1,44 @@
 # CMake script for Bio++ PhylLib
-# Author: Sylvain Gaillard and Julien Dutheil
+# Authors:
+#   Sylvain Gaillard
+#   Julien Dutheil
+#   Francois Gindraud (2017)
 # Created: 20/08/2009
 
 # File list
-SET(CPP_FILES
+set (CPP_FILES
   Bpp/Phyl/App/PhylogeneticsApplicationTools.cpp
   Bpp/Phyl/BipartitionList.cpp
   Bpp/Phyl/BipartitionTools.cpp
   Bpp/Phyl/Distance/AbstractAgglomerativeDistanceMethod.cpp
   Bpp/Phyl/Distance/BioNJ.cpp
   Bpp/Phyl/Distance/DistanceEstimation.cpp
+  Bpp/Phyl/Distance/HierarchicalClustering.cpp
   Bpp/Phyl/Distance/NeighborJoining.cpp
   Bpp/Phyl/Distance/PGMA.cpp
-  Bpp/Phyl/Distance/HierarchicalClustering.cpp
   Bpp/Phyl/Graphics/AbstractDendrogramPlot.cpp
   Bpp/Phyl/Graphics/AbstractTreeDrawing.cpp
   Bpp/Phyl/Graphics/CladogramPlot.cpp
   Bpp/Phyl/Graphics/PhylogramPlot.cpp
   Bpp/Phyl/Graphics/TreeDrawingDisplayControler.cpp
   Bpp/Phyl/Graphics/TreeDrawingListener.cpp
+  Bpp/Phyl/Io/BppOFrequenciesSetFormat.cpp
+  Bpp/Phyl/Io/BppOMultiTreeReaderFormat.cpp
+  Bpp/Phyl/Io/BppOMultiTreeWriterFormat.cpp
+  Bpp/Phyl/Io/BppORateDistributionFormat.cpp
+  Bpp/Phyl/Io/BppOSubstitutionModelFormat.cpp
+  Bpp/Phyl/Io/BppOTransitionModelFormat.cpp
+  Bpp/Phyl/Io/BppOTreeReaderFormat.cpp
+  Bpp/Phyl/Io/BppOTreeWriterFormat.cpp
   Bpp/Phyl/Io/IoDistanceMatrixFactory.cpp
+  Bpp/Phyl/Io/IoFrequenciesSetFactory.cpp
+  Bpp/Phyl/Io/IoPairedSiteLikelihoods.cpp
+  Bpp/Phyl/Io/IoSubstitutionModelFactory.cpp
   Bpp/Phyl/Io/IoTreeFactory.cpp
   Bpp/Phyl/Io/Newick.cpp
   Bpp/Phyl/Io/NexusIoTree.cpp
   Bpp/Phyl/Io/Nhx.cpp
   Bpp/Phyl/Io/PhylipDistanceMatrixFormat.cpp
-  Bpp/Phyl/Io/IoPairedSiteLikelihoods.cpp
-  Bpp/Phyl/Io/IoSubstitutionModelFactory.cpp
-  Bpp/Phyl/Io/BppOSubstitutionModelFormat.cpp
-  Bpp/Phyl/Io/IoFrequenciesSetFactory.cpp
-  Bpp/Phyl/Io/BppOFrequenciesSetFormat.cpp
-  Bpp/Phyl/Io/BppORateDistributionFormat.cpp
   Bpp/Phyl/Likelihood/AbstractDiscreteRatesAcrossSitesTreeLikelihood.cpp
   Bpp/Phyl/Likelihood/AbstractHomogeneousTreeLikelihood.cpp
   Bpp/Phyl/Likelihood/AbstractNonHomogeneousTreeLikelihood.cpp
@@ -41,8 +49,10 @@ SET(CPP_FILES
   Bpp/Phyl/Likelihood/DRHomogeneousTreeLikelihood.cpp
   Bpp/Phyl/Likelihood/DRNonHomogeneousTreeLikelihood.cpp
   Bpp/Phyl/Likelihood/DRTreeLikelihoodTools.cpp
+  Bpp/Phyl/Likelihood/GlobalClockTreeLikelihoodFunctionWrapper.cpp
   Bpp/Phyl/Likelihood/MarginalAncestralStateReconstruction.cpp
   Bpp/Phyl/Likelihood/NNIHomogeneousTreeLikelihood.cpp
+  Bpp/Phyl/Likelihood/PairedSiteLikelihoods.cpp
   Bpp/Phyl/Likelihood/PseudoNewtonOptimizer.cpp
   Bpp/Phyl/Likelihood/RASTools.cpp
   Bpp/Phyl/Likelihood/RHomogeneousClockTreeLikelihood.cpp
@@ -51,41 +61,69 @@ SET(CPP_FILES
   Bpp/Phyl/Likelihood/RNonHomogeneousMixedTreeLikelihood.cpp
   Bpp/Phyl/Likelihood/RNonHomogeneousTreeLikelihood.cpp
   Bpp/Phyl/Likelihood/TreeLikelihoodTools.cpp
-  Bpp/Phyl/Likelihood/PairedSiteLikelihoods.cpp
-  Bpp/Phyl/Likelihood/GlobalClockTreeLikelihoodFunctionWrapper.cpp
-  Bpp/Phyl/Mapping/SubstitutionRegister.cpp
+  Bpp/Phyl/Mapping/DecompositionReward.cpp
+  Bpp/Phyl/Mapping/DecompositionSubstitutionCount.cpp
   Bpp/Phyl/Mapping/LaplaceSubstitutionCount.cpp
+  Bpp/Phyl/Mapping/NaiveSubstitutionCount.cpp
   Bpp/Phyl/Mapping/OneJumpSubstitutionCount.cpp
+  Bpp/Phyl/Mapping/ProbabilisticRewardMapping.cpp
   Bpp/Phyl/Mapping/ProbabilisticSubstitutionMapping.cpp
-  Bpp/Phyl/Mapping/NaiveSubstitutionCount.cpp
-  Bpp/Phyl/Mapping/DecompositionSubstitutionCount.cpp
+  Bpp/Phyl/Mapping/RewardMappingTools.cpp
+  Bpp/Phyl/Mapping/SubstitutionMappingTools.cpp
+  Bpp/Phyl/Mapping/SubstitutionRegister.cpp
   Bpp/Phyl/Mapping/UniformizationSubstitutionCount.cpp
   Bpp/Phyl/Mapping/WeightedSubstitutionCount.cpp
-  Bpp/Phyl/Mapping/SubstitutionMappingTools.cpp
-  Bpp/Phyl/Mapping/DecompositionReward.cpp
-  Bpp/Phyl/Mapping/ProbabilisticRewardMapping.cpp
-  Bpp/Phyl/Mapping/RewardMappingTools.cpp
-  Bpp/Phyl/Model/StateMap.cpp
-  Bpp/Phyl/Model/BinarySubstitutionModel.cpp
-  Bpp/Phyl/Model/AbstractSubstitutionModel.cpp
-  Bpp/Phyl/Model/AbstractBiblioSubstitutionModel.cpp
   Bpp/Phyl/Model/AbstractBiblioMixedSubstitutionModel.cpp
-  Bpp/Phyl/Model/MarkovModulatedSubstitutionModel.cpp
+  Bpp/Phyl/Model/AbstractBiblioSubstitutionModel.cpp
+  Bpp/Phyl/Model/AbstractFromSubstitutionModelTransitionModel.cpp
+  Bpp/Phyl/Model/AbstractKroneckerWordSubstitutionModel.cpp
   Bpp/Phyl/Model/AbstractMixedSubstitutionModel.cpp
+  Bpp/Phyl/Model/AbstractSubstitutionModel.cpp
+  Bpp/Phyl/Model/AbstractWordSubstitutionModel.cpp
+  Bpp/Phyl/Model/BinarySubstitutionModel.cpp
+  Bpp/Phyl/Model/Codon/AbstractCodonCpGSubstitutionModel.cpp
+  Bpp/Phyl/Model/Codon/AbstractCodonDistanceSubstitutionModel.cpp
+  Bpp/Phyl/Model/Codon/AbstractCodonFitnessSubstitutionModel.cpp
+  Bpp/Phyl/Model/Codon/AbstractCodonFrequenciesSubstitutionModel.cpp
+  Bpp/Phyl/Model/Codon/AbstractCodonPhaseFrequenciesSubstitutionModel.cpp
+  Bpp/Phyl/Model/Codon/AbstractCodonSubstitutionModel.cpp
+  Bpp/Phyl/Model/Codon/AbstractKroneckerCodonSubstitutionModel.cpp
+  Bpp/Phyl/Model/Codon/CodonDistanceCpGSubstitutionModel.cpp
+  Bpp/Phyl/Model/Codon/CodonDistanceFrequenciesSubstitutionModel.cpp
+  Bpp/Phyl/Model/Codon/CodonDistancePhaseFrequenciesSubstitutionModel.cpp
+  Bpp/Phyl/Model/Codon/CodonDistanceSubstitutionModel.cpp
+  Bpp/Phyl/Model/Codon/CodonRateFrequenciesSubstitutionModel.cpp
+  Bpp/Phyl/Model/Codon/CodonRateSubstitutionModel.cpp
+  Bpp/Phyl/Model/Codon/GY94.cpp
+  Bpp/Phyl/Model/Codon/KCM.cpp
+  Bpp/Phyl/Model/Codon/KroneckerCodonDistanceFrequenciesSubstitutionModel.cpp 
+  Bpp/Phyl/Model/Codon/KroneckerCodonDistanceSubstitutionModel.cpp
+  Bpp/Phyl/Model/Codon/MG94.cpp
+  Bpp/Phyl/Model/Codon/SENCA.cpp
+  Bpp/Phyl/Model/Codon/TripletSubstitutionModel.cpp
+  Bpp/Phyl/Model/Codon/YN98.cpp
+  Bpp/Phyl/Model/Codon/YNGP_M1.cpp
+  Bpp/Phyl/Model/Codon/YNGP_M10.cpp
+  Bpp/Phyl/Model/Codon/YNGP_M2.cpp
+  Bpp/Phyl/Model/Codon/YNGP_M3.cpp
+  Bpp/Phyl/Model/Codon/YNGP_M7.cpp
+  Bpp/Phyl/Model/Codon/YNGP_M8.cpp
+  Bpp/Phyl/Model/Codon/YNGP_M9.cpp
+  Bpp/Phyl/Model/FrequenciesSet/CodonFrequenciesSet.cpp
+  Bpp/Phyl/Model/FrequenciesSet/FrequenciesSet.cpp
+  Bpp/Phyl/Model/FrequenciesSet/MvaFrequenciesSet.cpp
+  Bpp/Phyl/Model/FrequenciesSet/NucleotideFrequenciesSet.cpp
+  Bpp/Phyl/Model/FrequenciesSet/WordFrequenciesSet.cpp
+  Bpp/Phyl/Model/FromMixtureSubstitutionModel.cpp
+  Bpp/Phyl/Model/KroneckerWordSubstitutionModel.cpp
+  Bpp/Phyl/Model/MarkovModulatedSubstitutionModel.cpp
+  Bpp/Phyl/Model/MixedSubstitutionModelSet.cpp
   Bpp/Phyl/Model/MixtureOfASubstitutionModel.cpp
   Bpp/Phyl/Model/MixtureOfSubstitutionModels.cpp
-  Bpp/Phyl/Model/RateDistributionFactory.cpp
-  Bpp/Phyl/Model/RE08.cpp
-  Bpp/Phyl/Model/SubstitutionModelFactory.cpp
-  Bpp/Phyl/Model/SubstitutionModelSet.cpp
-  Bpp/Phyl/Model/MixedSubstitutionModelSet.cpp
-  Bpp/Phyl/Model/SubstitutionModelSetTools.cpp
-  Bpp/Phyl/Model/AbstractWordSubstitutionModel.cpp
-  Bpp/Phyl/Model/WordSubstitutionModel.cpp
   Bpp/Phyl/Model/Nucleotide/F84.cpp
+  Bpp/Phyl/Model/Nucleotide/GTR.cpp
   Bpp/Phyl/Model/Nucleotide/HKY85.cpp
   Bpp/Phyl/Model/Nucleotide/JCnuc.cpp
-  Bpp/Phyl/Model/Nucleotide/GTR.cpp
   Bpp/Phyl/Model/Nucleotide/K80.cpp
   Bpp/Phyl/Model/Nucleotide/L95.cpp
   Bpp/Phyl/Model/Nucleotide/RN95.cpp
@@ -93,48 +131,29 @@ SET(CPP_FILES
   Bpp/Phyl/Model/Nucleotide/SSR.cpp
   Bpp/Phyl/Model/Nucleotide/T92.cpp
   Bpp/Phyl/Model/Nucleotide/TN93.cpp
-  Bpp/Phyl/Model/Nucleotide/gBGC.cpp
   Bpp/Phyl/Model/Nucleotide/YpR.cpp
+  Bpp/Phyl/Model/Nucleotide/gBGC.cpp
+  Bpp/Phyl/Model/OneChangeTransitionModel.cpp
+  Bpp/Phyl/Model/Protein/Coala.cpp
+  Bpp/Phyl/Model/Protein/CoalaCore.cpp
   Bpp/Phyl/Model/Protein/DSO78.cpp
-  Bpp/Phyl/Model/Protein/UserProteinSubstitutionModel.cpp
   Bpp/Phyl/Model/Protein/JCprot.cpp
   Bpp/Phyl/Model/Protein/JTT92.cpp
   Bpp/Phyl/Model/Protein/LG08.cpp
-  Bpp/Phyl/Model/Protein/WAG01.cpp
+  Bpp/Phyl/Model/Protein/LG10_EX_EHO.cpp
+  Bpp/Phyl/Model/Protein/LGL08_CAT.cpp
   Bpp/Phyl/Model/Protein/LLG08_EHO.cpp
   Bpp/Phyl/Model/Protein/LLG08_EX2.cpp
   Bpp/Phyl/Model/Protein/LLG08_EX3.cpp
   Bpp/Phyl/Model/Protein/LLG08_UL2.cpp
   Bpp/Phyl/Model/Protein/LLG08_UL3.cpp
-  Bpp/Phyl/Model/Protein/LG10_EX_EHO.cpp
-  Bpp/Phyl/Model/Protein/LGL08_CAT.cpp
-  Bpp/Phyl/Model/Protein/Coala.cpp
-  Bpp/Phyl/Model/Protein/CoalaCore.cpp
-  Bpp/Phyl/Model/Codon/GY94.cpp
-  Bpp/Phyl/Model/Codon/MG94.cpp
-  Bpp/Phyl/Model/Codon/TripletSubstitutionModel.cpp
-  Bpp/Phyl/Model/Codon/AbstractCodonSubstitutionModel.cpp
-  Bpp/Phyl/Model/Codon/AbstractCodonFrequenciesSubstitutionModel.cpp
-  Bpp/Phyl/Model/Codon/AbstractCodonPhaseFrequenciesSubstitutionModel.cpp
-  Bpp/Phyl/Model/Codon/AbstractCodonDistanceSubstitutionModel.cpp
-  Bpp/Phyl/Model/Codon/AbstractCodonFitnessSubstitutionModel.cpp
-  Bpp/Phyl/Model/Codon/CodonDistanceSubstitutionModel.cpp
-  Bpp/Phyl/Model/Codon/CodonDistanceFrequenciesSubstitutionModel.cpp
-  Bpp/Phyl/Model/Codon/CodonDistancePhaseFrequenciesSubstitutionModel.cpp
-  Bpp/Phyl/Model/Codon/CodonDistanceFitnessPhaseFrequenciesSubstitutionModel.cpp
-  Bpp/Phyl/Model/Codon/CodonRateSubstitutionModel.cpp
-  Bpp/Phyl/Model/Codon/CodonRateFrequenciesSubstitutionModel.cpp
-  Bpp/Phyl/Model/Codon/YN98.cpp
-  Bpp/Phyl/Model/Codon/YNGKP_M1.cpp
-  Bpp/Phyl/Model/Codon/YNGKP_M2.cpp
-  Bpp/Phyl/Model/Codon/YNGKP_M3.cpp
-  Bpp/Phyl/Model/Codon/YNGKP_M7.cpp
-  Bpp/Phyl/Model/Codon/YNGKP_M8.cpp
-  Bpp/Phyl/Model/FrequenciesSet/FrequenciesSet.cpp
-  Bpp/Phyl/Model/FrequenciesSet/NucleotideFrequenciesSet.cpp
-  Bpp/Phyl/Model/FrequenciesSet/MvaFrequenciesSet.cpp
-  Bpp/Phyl/Model/FrequenciesSet/WordFrequenciesSet.cpp
-  Bpp/Phyl/Model/FrequenciesSet/CodonFrequenciesSet.cpp
+  Bpp/Phyl/Model/Protein/UserProteinSubstitutionModel.cpp
+  Bpp/Phyl/Model/Protein/WAG01.cpp
+  Bpp/Phyl/Model/RE08.cpp
+  Bpp/Phyl/Model/StateMap.cpp
+  Bpp/Phyl/Model/SubstitutionModelSet.cpp
+  Bpp/Phyl/Model/SubstitutionModelSetTools.cpp
+  Bpp/Phyl/Model/WordSubstitutionModel.cpp
   Bpp/Phyl/NNITopologySearch.cpp
   Bpp/Phyl/Node.cpp
   Bpp/Phyl/OptimizationTools.cpp
@@ -151,228 +170,42 @@ SET(CPP_FILES
   Bpp/Phyl/TreeTemplateTools.cpp
   Bpp/Phyl/TreeTools.cpp  
   )
-SET(H_FILES
-  Bpp/Phyl/AncestralStateReconstruction.h
-  Bpp/Phyl/App/PhylogeneticsApplicationTools.h
-  Bpp/Phyl/BipartitionList.h
-  Bpp/Phyl/BipartitionTools.h
-  Bpp/Phyl/Distance/AbstractAgglomerativeDistanceMethod.h
-  Bpp/Phyl/Distance/DistanceMethod.h
-  Bpp/Phyl/Distance/BioNJ.h
-  Bpp/Phyl/Distance/DistanceEstimation.h
-  Bpp/Phyl/Distance/NeighborJoining.h
-  Bpp/Phyl/Distance/PGMA.h
-  Bpp/Phyl/Distance/HierarchicalClustering.h
-  Bpp/Phyl/Graphics/AbstractDendrogramPlot.h
-  Bpp/Phyl/Graphics/AbstractTreeDrawing.h
-  Bpp/Phyl/Graphics/CladogramPlot.h
-  Bpp/Phyl/Graphics/PhylogramPlot.h
-  Bpp/Phyl/Graphics/TreeDrawingDisplayControler.h
-  Bpp/Phyl/Graphics/TreeDrawing.h
-  Bpp/Phyl/Graphics/TreeDrawingListener.h
-  Bpp/Phyl/Io/IoDistanceMatrixFactory.h
-  Bpp/Phyl/Io/IoDistanceMatrix.h
-  Bpp/Phyl/Io/IoTreeFactory.h
-  Bpp/Phyl/Io/IoTree.h
-  Bpp/Phyl/Io/Newick.h
-  Bpp/Phyl/Io/Nhx.h
-  Bpp/Phyl/Io/NexusIoTree.h
-  Bpp/Phyl/Io/PhylipDistanceMatrixFormat.h
-  Bpp/Phyl/Io/IoPairedSiteLikelihoods.h
-  Bpp/Phyl/Io/IoSubstitutionModel.h
-  Bpp/Phyl/Io/IoSubstitutionModelFactory.h
-  Bpp/Phyl/Io/BppOSubstitutionModelFormat.h
-  Bpp/Phyl/Io/IoFrequenciesSet.h
-  Bpp/Phyl/Io/IoFrequenciesSetFactory.h
-  Bpp/Phyl/Io/BppOFrequenciesSetFormat.h
-  Bpp/Phyl/Io/BppORateDistributionFormat.h
-  Bpp/Phyl/Likelihood/AbstractDiscreteRatesAcrossSitesTreeLikelihood.h
-  Bpp/Phyl/Likelihood/AbstractHomogeneousTreeLikelihood.h
-  Bpp/Phyl/Likelihood/AbstractNonHomogeneousTreeLikelihood.h
-  Bpp/Phyl/Likelihood/AbstractTreeLikelihoodData.h
-  Bpp/Phyl/Likelihood/AbstractTreeLikelihood.h
-  Bpp/Phyl/Likelihood/ClockTreeLikelihood.h
-  Bpp/Phyl/Likelihood/DiscreteRatesAcrossSitesTreeLikelihood.h
-  Bpp/Phyl/Likelihood/DRASDRTreeLikelihoodData.h
-  Bpp/Phyl/Likelihood/DRASRTreeLikelihoodData.h
-  Bpp/Phyl/Likelihood/DRHomogeneousMixedTreeLikelihood.h
-  Bpp/Phyl/Likelihood/DRHomogeneousTreeLikelihood.h
-  Bpp/Phyl/Likelihood/DRNonHomogeneousTreeLikelihood.h
-  Bpp/Phyl/Likelihood/DRTreeLikelihood.h
-  Bpp/Phyl/Likelihood/DRTreeLikelihoodTools.h
-  Bpp/Phyl/Likelihood/HomogeneousTreeLikelihood.h
-  Bpp/Phyl/Likelihood/MarginalAncestralStateReconstruction.h
-  Bpp/Phyl/Likelihood/NNIHomogeneousTreeLikelihood.h
-  Bpp/Phyl/Likelihood/NonHomogeneousTreeLikelihood.h
-  Bpp/Phyl/Likelihood/PseudoNewtonOptimizer.h
-  Bpp/Phyl/Likelihood/RASTools.h
-  Bpp/Phyl/Likelihood/RHomogeneousClockTreeLikelihood.h
-  Bpp/Phyl/Likelihood/RHomogeneousMixedTreeLikelihood.h
-  Bpp/Phyl/Likelihood/RHomogeneousTreeLikelihood.h
-  Bpp/Phyl/Likelihood/RNonHomogeneousMixedTreeLikelihood.h
-  Bpp/Phyl/Likelihood/RNonHomogeneousTreeLikelihood.h
-  Bpp/Phyl/Likelihood/SitePartitionTreeLikelihood.h
-  Bpp/Phyl/Likelihood/TreeLikelihoodData.h
-  Bpp/Phyl/Likelihood/TreeLikelihood.h
-  Bpp/Phyl/Likelihood/TreeLikelihoodTools.h
-  Bpp/Phyl/Likelihood/PairedSiteLikelihoods.h
-  Bpp/Phyl/Likelihood/GlobalClockTreeLikelihoodFunctionWrapper.h
-  Bpp/Phyl/Mapping/LaplaceSubstitutionCount.h
-  Bpp/Phyl/Mapping/WeightedSubstitutionCount.h
-  Bpp/Phyl/Mapping/OneJumpSubstitutionCount.h
-  Bpp/Phyl/Mapping/ProbabilisticSubstitutionMapping.h
-  Bpp/Phyl/Mapping/NaiveSubstitutionCount.h
-  Bpp/Phyl/Mapping/DecompositionSubstitutionCount.h
-  Bpp/Phyl/Mapping/UniformizationSubstitutionCount.h
-  Bpp/Phyl/Mapping/SubstitutionRegister.h
-  Bpp/Phyl/Mapping/SubstitutionCount.h
-  Bpp/Phyl/Mapping/Mapping.h
-  Bpp/Phyl/Mapping/SubstitutionMapping.h
-  Bpp/Phyl/Mapping/SubstitutionMappingTools.h
-  Bpp/Phyl/Mapping/Reward.h
-  Bpp/Phyl/Mapping/DecompositionReward.h
-  Bpp/Phyl/Mapping/RewardMapping.h
-  Bpp/Phyl/Mapping/RewardMappingTools.h
-  Bpp/Phyl/Mapping/ProbabilisticRewardMapping.h
-  Bpp/Phyl/Model/StateMap.h
-  Bpp/Phyl/Model/AbstractSubstitutionModel.h
-  Bpp/Phyl/Model/BinarySubstitutionModel.h
-  Bpp/Phyl/Model/G2001.h
-  Bpp/Phyl/Model/AbstractBiblioSubstitutionModel.h
-  Bpp/Phyl/Model/AbstractBiblioMixedSubstitutionModel.h
-  Bpp/Phyl/Model/MarkovModulatedSubstitutionModel.h
-  Bpp/Phyl/Model/MixedSubstitutionModel.h
-  Bpp/Phyl/Model/AbstractMixedSubstitutionModel.h
-  Bpp/Phyl/Model/MixtureOfASubstitutionModel.h
-  Bpp/Phyl/Model/MixtureOfSubstitutionModels.h
-  Bpp/Phyl/Model/RateDistributionFactory.h
-  Bpp/Phyl/Model/RE08.h
-  Bpp/Phyl/Model/SubstitutionModelFactory.h
-  Bpp/Phyl/Model/SubstitutionModel.h
-  Bpp/Phyl/Model/SubstitutionModelSet.h
-  Bpp/Phyl/Model/MixedSubstitutionModelSet.h
-  Bpp/Phyl/Model/SubstitutionModelSetTools.h
-  Bpp/Phyl/Model/TS98.h
-  Bpp/Phyl/Model/AbstractWordSubstitutionModel.h
-  Bpp/Phyl/Model/WordSubstitutionModel.h
-  Bpp/Phyl/Model/Nucleotide/NucleotideSubstitutionModel.h
-  Bpp/Phyl/Model/Nucleotide/F84.h
-  Bpp/Phyl/Model/Nucleotide/HKY85.h
-  Bpp/Phyl/Model/Nucleotide/JCnuc.h
-  Bpp/Phyl/Model/Nucleotide/GTR.h
-  Bpp/Phyl/Model/Nucleotide/K80.h
-  Bpp/Phyl/Model/Nucleotide/L95.h
-  Bpp/Phyl/Model/Nucleotide/RN95.h
-  Bpp/Phyl/Model/Nucleotide/RN95s.h
-  Bpp/Phyl/Model/Nucleotide/SSR.h
-  Bpp/Phyl/Model/Nucleotide/T92.h
-  Bpp/Phyl/Model/Nucleotide/TN93.h
-  Bpp/Phyl/Model/Nucleotide/gBGC.h
-  Bpp/Phyl/Model/Nucleotide/YpR.h
-  Bpp/Phyl/Model/Protein/ProteinSubstitutionModel.h
-  Bpp/Phyl/Model/Protein/DSO78.h
-  Bpp/Phyl/Model/Protein/UserProteinSubstitutionModel.h
-  Bpp/Phyl/Model/Protein/JCprot.h
-  Bpp/Phyl/Model/Protein/JTT92.h
-  Bpp/Phyl/Model/Protein/LG08.h
-  Bpp/Phyl/Model/Protein/WAG01.h
-  Bpp/Phyl/Model/Protein/LLG08_EHO.h
-  Bpp/Phyl/Model/Protein/LLG08_EX2.h
-  Bpp/Phyl/Model/Protein/LLG08_EX3.h
-  Bpp/Phyl/Model/Protein/LLG08_UL2.h
-  Bpp/Phyl/Model/Protein/LLG08_UL3.h
-  Bpp/Phyl/Model/Protein/LG10_EX_EHO.h
-  Bpp/Phyl/Model/Protein/LGL08_CAT.h
-  Bpp/Phyl/Model/Protein/Coala.h
-  Bpp/Phyl/Model/Protein/CoalaCore.h
-  Bpp/Phyl/Model/Codon/GY94.h
-  Bpp/Phyl/Model/Codon/MG94.h
-  Bpp/Phyl/Model/Codon/CodonSubstitutionModel.h
-  Bpp/Phyl/Model/Codon/TripletSubstitutionModel.h
-  Bpp/Phyl/Model/Codon/AbstractCodonSubstitutionModel.h
-  Bpp/Phyl/Model/Codon/AbstractCodonFrequenciesSubstitutionModel.h
-  Bpp/Phyl/Model/Codon/AbstractCodonPhaseFrequenciesSubstitutionModel.h
-  Bpp/Phyl/Model/Codon/AbstractCodonDistanceSubstitutionModel.h
-  Bpp/Phyl/Model/Codon/AbstractCodonFitnessSubstitutionModel.h
-  Bpp/Phyl/Model/Codon/CodonDistanceSubstitutionModel.h
-  Bpp/Phyl/Model/Codon/CodonDistanceFrequenciesSubstitutionModel.h
-  Bpp/Phyl/Model/Codon/CodonDistancePhaseFrequenciesSubstitutionModel.h
-  Bpp/Phyl/Model/Codon/CodonDistanceFitnessPhaseFrequenciesSubstitutionModel.h
-  Bpp/Phyl/Model/Codon/CodonRateSubstitutionModel.h
-  Bpp/Phyl/Model/Codon/CodonRateFrequenciesSubstitutionModel.h
-  Bpp/Phyl/Model/Codon/YN98.h
-  Bpp/Phyl/Model/Codon/YNGKP_M1.h
-  Bpp/Phyl/Model/Codon/YNGKP_M2.h
-  Bpp/Phyl/Model/Codon/YNGKP_M3.h
-  Bpp/Phyl/Model/Codon/YNGKP_M7.h
-  Bpp/Phyl/Model/Codon/YNGKP_M8.h
-  Bpp/Phyl/Model/FrequenciesSet/FrequenciesSet.h
-  Bpp/Phyl/Model/FrequenciesSet/NucleotideFrequenciesSet.h
-  Bpp/Phyl/Model/FrequenciesSet/WordFrequenciesSet.h
-  Bpp/Phyl/Model/FrequenciesSet/CodonFrequenciesSet.h
-  Bpp/Phyl/Model/FrequenciesSet/FrequenciesSet.h
-  Bpp/Phyl/Model/FrequenciesSet/NucleotideFrequenciesSet.h
-  Bpp/Phyl/Model/FrequenciesSet/ProteinFrequenciesSet.h
-  Bpp/Phyl/Model/FrequenciesSet/MvaFrequenciesSet.h
-  Bpp/Phyl/Model/FrequenciesSet/WordFrequenciesSet.h
-  Bpp/Phyl/Model/FrequenciesSet/CodonFrequenciesSet.h
-  Bpp/Phyl/Model/RateDistribution/ConstantRateDistribution.h
-  Bpp/Phyl/Model/RateDistribution/GammaDiscreteRateDistribution.h
-  Bpp/Phyl/Model/RateDistribution/GaussianDiscreteRateDistribution.h
-  Bpp/Phyl/Model/RateDistribution/ExponentialDiscreteRateDistribution.h
-  Bpp/Phyl/NNISearchable.h
-  Bpp/Phyl/NNITopologySearch.h
-  Bpp/Phyl/Node.h
-  Bpp/Phyl/NodeTemplate.h
-  Bpp/Phyl/OptimizationTools.h
-  Bpp/Phyl/Parsimony/AbstractTreeParsimonyData.h
-  Bpp/Phyl/Parsimony/AbstractTreeParsimonyScore.h
-  Bpp/Phyl/Parsimony/DRTreeParsimonyData.h
-  Bpp/Phyl/Parsimony/DRTreeParsimonyScore.h
-  Bpp/Phyl/Parsimony/TreeParsimonyData.h
-  Bpp/Phyl/Parsimony/TreeParsimonyScore.h
-  Bpp/Phyl/PatternTools.h
-  Bpp/Phyl/PhyloStatistics.h
-  Bpp/Phyl/Simulation/DetailedSiteSimulator.h
-  Bpp/Phyl/Simulation/HomogeneousSequenceSimulator.h
-  Bpp/Phyl/Simulation/MutationProcess.h
-  Bpp/Phyl/Simulation/NonHomogeneousSequenceSimulator.h
-  Bpp/Phyl/Simulation/SequenceSimulationTools.h
-  Bpp/Phyl/Simulation/SequenceSimulator.h
-  Bpp/Phyl/Simulation/SiteSimulator.h
-  Bpp/Phyl/SitePatterns.h
-  Bpp/Phyl/TopologySearch.h
-  Bpp/Phyl/TreeExceptions.h
-  Bpp/Phyl/Tree.h
-  Bpp/Phyl/TreeTemplate.h
-  Bpp/Phyl/TreeTemplateTools.h
-  Bpp/Phyl/TreeTools.h
-  )
 
 # Build the static lib
-ADD_LIBRARY(bppphyl-static STATIC ${CPP_FILES})
-SET_TARGET_PROPERTIES(bppphyl-static
-  PROPERTIES OUTPUT_NAME bpp-phyl
-  CLEAN_DIRECT_OUTPUT 1
+add_library (${PROJECT_NAME}-static STATIC ${CPP_FILES})
+target_include_directories (${PROJECT_NAME}-static PUBLIC
+  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+  $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>
   )
-TARGET_LINK_LIBRARIES(bppphyl-static ${LIBS})
+set_target_properties (${PROJECT_NAME}-static PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
+target_link_libraries (${PROJECT_NAME}-static ${BPP_LIBS_STATIC})
 
 # Build the shared lib
-ADD_LIBRARY(bppphyl-shared SHARED ${CPP_FILES})
-SET_TARGET_PROPERTIES(bppphyl-shared
-  PROPERTIES OUTPUT_NAME bpp-phyl
-  CLEAN_DIRECT_OUTPUT 1
-  VERSION ${BPPPHYL_VERSION}
-  SOVERSION ${BPPPHYL_VERSION_MAJOR}
+add_library (${PROJECT_NAME}-shared SHARED ${CPP_FILES})
+target_include_directories (${PROJECT_NAME}-shared PUBLIC
+  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+  $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>
   )
-TARGET_LINK_LIBRARIES(bppphyl-shared ${LIBS})
-
-# Install libs
-INSTALL(TARGETS bppphyl-static bppphyl-shared DESTINATION lib${LIB_SUFFIX})
-
-# Install headers
-INSTALL(DIRECTORY Bpp/ DESTINATION include/Bpp FILES_MATCHING PATTERN "*.h")
-
-# Generate generic include files (.all)
-INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_SOURCE_DIR}/genIncludes.sh ${CMAKE_PREFIX_PATH}/include/Bpp)")
+set_target_properties (${PROJECT_NAME}-shared
+  PROPERTIES OUTPUT_NAME ${PROJECT_NAME}
+  MACOSX_RPATH 1
+  VERSION ${${PROJECT_NAME}_VERSION}
+  SOVERSION ${${PROJECT_NAME}_VERSION_MAJOR}
+  )
+target_link_libraries (${PROJECT_NAME}-shared ${BPP_LIBS_SHARED})
 
+# Install libs and headers
+install (
+  TARGETS ${PROJECT_NAME}-static ${PROJECT_NAME}-shared
+  EXPORT ${PROJECT_NAME}-targets
+  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+  RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
+  )
+install (
+  DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bpp
+  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+  FILES_MATCHING PATTERN "*.h"
+  )
+# Install cmake file representing targets
+install (EXPORT ${PROJECT_NAME}-targets DESTINATION ${cmake-package-location})
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 8d53244..206cef3 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,86 +1,24 @@
 # CMake script for bpp-phyl unit tests
-# Author: Julien Dutheil
+# Authors:
+#   Julien Dutheil
+#   Francois Gindraud (2017)
 # Created: 12/11/2010
 
-MACRO(TEST_FIND_LIBRARY OUTPUT_LIBS lib_name include_to_find)
-  #start:
-  FIND_PATH(${lib_name}_INCLUDE_DIR ${include_to_find})
-
-  SET(${lib_name}_NAMES ${lib_name} ${lib_name}.lib ${lib_name}.dll)
-  FIND_LIBRARY(${lib_name}_LIBRARY NAMES ${${lib_name}_NAMES})
-  IF(${lib_name}_LIBRARY)
-    MESSAGE("-- Library ${lib_name} found here:")
-    MESSAGE("   includes: ${${lib_name}_INCLUDE_DIR}")
-    MESSAGE("   dynamic libraries: ${${lib_name}_LIBRARY}")
-    MESSAGE(WARNING "Library ${lib_name} is already installed in the system tree. Test will be built against it. This may lead to unexpected results. You may want to do 'make install' before 'make test', or remove the installed version.")
-  ELSE()
-    SET(${lib_name}_LIBRARY "-L../src -lbpp-phyl")
-    SET(${lib_name}_INCLUDE_DIR "../src/")
-  ENDIF()
-  INCLUDE_DIRECTORIES(${${lib_name}_INCLUDE_DIR})
-  SET(${OUTPUT_LIBS} ${${OUTPUT_LIBS}} ${${lib_name}_LIBRARY})
-ENDMACRO(TEST_FIND_LIBRARY)
-
-#Find the bpp-phyl library library:
-TEST_FIND_LIBRARY(LIBS bpp-phyl Bpp/Phyl/Tree.h)
-
-ADD_EXECUTABLE(test_tree test_tree.cpp)
-TARGET_LINK_LIBRARIES(test_tree ${LIBS})
-ADD_TEST(test_tree "test_tree")
-
-ADD_EXECUTABLE(test_models test_models.cpp)
-TARGET_LINK_LIBRARIES(test_models ${LIBS})
-ADD_TEST(test_models "test_models")
-
-ADD_EXECUTABLE(test_detailed_simulations test_detailed_simulations.cpp)
-TARGET_LINK_LIBRARIES(test_detailed_simulations ${LIBS})
-ADD_TEST(test_detailed_simulations "test_detailed_simulations")
-
-ADD_EXECUTABLE(test_simulations test_simulations.cpp)
-TARGET_LINK_LIBRARIES(test_simulations ${LIBS})
-ADD_TEST(test_simulations "test_simulations")
-
-ADD_EXECUTABLE(test_parsimony test_parsimony.cpp)
-TARGET_LINK_LIBRARIES(test_parsimony ${LIBS})
-ADD_TEST(test_parsimony "test_parsimony")
-
-ADD_EXECUTABLE(test_likelihood test_likelihood.cpp)
-TARGET_LINK_LIBRARIES(test_likelihood ${LIBS})
-ADD_TEST(test_likelihood "test_likelihood")
-
-ADD_EXECUTABLE(test_likelihood_nh test_likelihood_nh.cpp)
-TARGET_LINK_LIBRARIES(test_likelihood_nh ${LIBS})
-ADD_TEST(test_likelihood_nh "test_likelihood_nh")
-
-ADD_EXECUTABLE(test_likelihood_clock test_likelihood_clock.cpp)
-TARGET_LINK_LIBRARIES(test_likelihood_clock ${LIBS})
-ADD_TEST(test_likelihood_clock "test_likelihood_clock")
-
-ADD_EXECUTABLE(test_mapping test_mapping.cpp)
-TARGET_LINK_LIBRARIES(test_mapping ${LIBS})
-ADD_TEST(test_mapping "test_mapping")
-
-ADD_EXECUTABLE(test_mapping_codon test_mapping_codon.cpp)
-TARGET_LINK_LIBRARIES(test_mapping_codon ${LIBS})
-ADD_TEST(test_mapping_codon "test_mapping_codon")
-
-ADD_EXECUTABLE(test_nhx test_nhx.cpp)
-TARGET_LINK_LIBRARIES(test_nhx ${LIBS})
-ADD_TEST(test_nhx "test_nhx")
-
-ADD_EXECUTABLE(test_bowker test_bowker.cpp)
-TARGET_LINK_LIBRARIES(test_bowker ${LIBS})
-ADD_TEST(test_bowker "test_bowker")
-
-IF(UNIX)
-  SET_PROPERTY(TEST test_detailed_simulations test_simulations test_parsimony test_models test_likelihood test_likelihood_nh test_likelihood_clock test_tree test_mapping test_mapping_codon test_nhx test_bowker PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:../src")
-ENDIF()
-
-IF(APPLE)
-  SET_PROPERTY(TEST test_detailed_simulations test_simulations test_parsimony test_models test_likelihood test_likelihood_nh test_likelihood_clock test_tree test_mapping test_mapping_codon test_nhx test_bowker PROPERTY ENVIRONMENT "DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH}:../src")
-ENDIF()
-
-IF(WIN32)
-  SET(ENV{PATH} "$ENV{PATH};..\\src")
-ENDIF()
-
+# Add all tests.
+# Any .cpp file in test/ is considered to be a test.
+# It will be compiled as a standalone program (must contain a main()).
+# A test is considered to succeed if it returns EXIT_SUCCESS (usually 0).
+# Tests are linked to the the shared library target.
+
+file (GLOB test_cpp_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
+foreach (test_cpp_file ${test_cpp_files})
+  # Add each test (named as the filename without extension)
+  get_filename_component (test_name ${test_cpp_file} NAME_WE)
+  add_executable (${test_name} ${test_cpp_file})
+  target_link_libraries (${test_name} ${PROJECT_NAME}-shared)
+  add_test (
+    NAME ${test_name}
+    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+    COMMAND ${test_name}
+    )
+endforeach (test_cpp_file)
diff --git a/test/test_bowker.cpp b/test/test_bowker.cpp
index 51acaef..1d79c47 100644
--- a/test/test_bowker.cpp
+++ b/test/test_bowker.cpp
@@ -52,21 +52,21 @@ using namespace bpp;
 using namespace std;
 
 double testBowker(const NonHomogeneousSequenceSimulator& sim, size_t seqlen) {
-  auto_ptr<SiteContainer> sites(sim.simulate(seqlen));
-  auto_ptr<BowkerTest> bTest(SequenceTools::bowkerTest(sites->getSequence(0), sites->getSequence(1)));
+  unique_ptr<SiteContainer> sites(sim.simulate(seqlen));
+  unique_ptr<BowkerTest> bTest(SequenceTools::bowkerTest(sites->getSequence(0), sites->getSequence(1)));
   return bTest->getPValue();
 }
 
 int main() {
-  auto_ptr< TreeTemplate<Node> > tree(TreeTemplateTools::parenthesisToTree("(A:0.02, B:0.02);"));
+  unique_ptr< TreeTemplate<Node> > tree(TreeTemplateTools::parenthesisToTree("(A:0.02, B:0.02);"));
 
   //First test homogeneous model:
   cout << "..:: Testing with homogeneous model ::.." << endl;
-  auto_ptr<NucleicAlphabet> alphabet(new DNA());
+  unique_ptr<NucleicAlphabet> alphabet(new DNA());
   SubstitutionModel* model = new T92(alphabet.get(), 3., 0.65);
   FrequenciesSet* rootFreqs = new GCFrequenciesSet(alphabet.get(), 0.65);
-  auto_ptr<DiscreteDistribution> rdist(new ConstantRateDistribution());
-  auto_ptr<SubstitutionModelSet> modelSetH(SubstitutionModelSetTools::createHomogeneousModelSet(model, rootFreqs, tree.get()));
+  unique_ptr<DiscreteDistribution> rdist(new ConstantRateDistribution());
+  unique_ptr<SubstitutionModelSet> modelSetH(SubstitutionModelSetTools::createHomogeneousModelSet(model, rootFreqs, tree.get()));
   NonHomogeneousSequenceSimulator simulatorH(modelSetH.get(), rdist.get(), tree.get());
 
   unsigned int nsim = 10000;
@@ -90,7 +90,7 @@ int main() {
   cout << "..:: Testing with homogeneous, non-stationary model ::.." << endl;
   model = new T92(alphabet.get(), 3., 0.65);
   rootFreqs = new GCFrequenciesSet(alphabet.get(), 0.4);
-  auto_ptr<SubstitutionModelSet> modelSetHNS(SubstitutionModelSetTools::createHomogeneousModelSet(model, rootFreqs, tree.get()));
+  unique_ptr<SubstitutionModelSet> modelSetHNS(SubstitutionModelSetTools::createHomogeneousModelSet(model, rootFreqs, tree.get()));
   NonHomogeneousSequenceSimulator simulatorHNS(modelSetHNS.get(), rdist.get(), tree.get());
 
   count05 = 0;
@@ -113,7 +113,9 @@ int main() {
   rootFreqs = new GCFrequenciesSet(alphabet.get(), 0.65);
   std::vector<std::string> globalParameterNames;
   globalParameterNames.push_back("T92.kappa");
-  auto_ptr<SubstitutionModelSet> modelSetNHGC(SubstitutionModelSetTools::createNonHomogeneousModelSet(model, rootFreqs, tree.get(), globalParameterNames));
+  map<string, string> alias;
+  
+  unique_ptr<SubstitutionModelSet> modelSetNHGC(SubstitutionModelSetTools::createNonHomogeneousModelSet(model, rootFreqs, tree.get(), alias, globalParameterNames));
   modelSetNHGC->setParameterValue("T92.theta_1", 0.3);
   modelSetNHGC->setParameterValue("T92.theta_2", 0.8);
   NonHomogeneousSequenceSimulator simulatorNHGC(modelSetNHGC.get(), rdist.get(), tree.get());
@@ -138,7 +140,7 @@ int main() {
   rootFreqs = new GCFrequenciesSet(alphabet.get(), 0.5);
   globalParameterNames.clear();
   globalParameterNames.push_back("T92.theta");
-  auto_ptr<SubstitutionModelSet> modelSetNHTsTv(SubstitutionModelSetTools::createNonHomogeneousModelSet(model, rootFreqs, tree.get(), globalParameterNames));
+  unique_ptr<SubstitutionModelSet> modelSetNHTsTv(SubstitutionModelSetTools::createNonHomogeneousModelSet(model, rootFreqs, tree.get(), alias, globalParameterNames));
   modelSetNHTsTv->setParameterValue("T92.kappa_1", 2);
   modelSetNHTsTv->setParameterValue("T92.kappa_2", 7);
   NonHomogeneousSequenceSimulator simulatorNHTsTv(modelSetNHTsTv.get(), rdist.get(), tree.get());
diff --git a/test/test_likelihood.cpp b/test/test_likelihood.cpp
index c797bb6..479a707 100644
--- a/test/test_likelihood.cpp
+++ b/test/test_likelihood.cpp
@@ -88,7 +88,7 @@ void fitModelHDR(SubstitutionModel* model, DiscreteDistribution* rdist, const Tr
 }
 
 int main() {
-  auto_ptr<TreeTemplate<Node> > tree(TreeTemplateTools::parenthesisToTree("((A:0.01, B:0.02):0.03,C:0.01,D:0.1);"));
+  unique_ptr<TreeTemplate<Node> > tree(TreeTemplateTools::parenthesisToTree("((A:0.01, B:0.02):0.03,C:0.01,D:0.1);"));
   vector<string> seqNames= tree->getLeavesNames();
   vector<int> ids = tree->getNodesId();
   //-------------
@@ -101,8 +101,8 @@ int main() {
   sites.addSequence(BasicSequence("C", "CTCTGGATGTGCACGTG", alphabet));
   sites.addSequence(BasicSequence("D", "AAATGGCGGTGCGCCTA", alphabet));
 
-  auto_ptr<SubstitutionModel> model(new T92(alphabet, 3.));
-  auto_ptr<DiscreteDistribution> rdist(new GammaDiscreteRateDistribution(4, 1.0));
+  unique_ptr<SubstitutionModel> model(new T92(alphabet, 3.));
+  unique_ptr<DiscreteDistribution> rdist(new GammaDiscreteRateDistribution(4, 1.0));
   try {
     cout << "Testing Single Tree Traversal likelihood class..." << endl;
     fitModelHSR(model.get(), rdist.get(), *tree, sites, 85.030942031997312824, 65.72293577214308868406);
diff --git a/test/test_likelihood_clock.cpp b/test/test_likelihood_clock.cpp
index e89c4f0..fa70e89 100644
--- a/test/test_likelihood_clock.cpp
+++ b/test/test_likelihood_clock.cpp
@@ -62,8 +62,8 @@ void fitModelH(SubstitutionModel* model, DiscreteDistribution* rdist, const Tree
   ApplicationTools::displayResult("* initial likelihood", tl.getValue());
   if (abs(tl.getValue() - initialValue) > 0.0001)
     throw Exception("Incorrect initial value.");
-  auto_ptr<OutputStream> messenger(new StlOutputStream(new ofstream("messages.txt", ios::out)));
-  auto_ptr<OutputStream> profiler(new StlOutputStream(new ofstream("profile.txt", ios::out)));
+  unique_ptr<OutputStream> messenger(new StlOutputStream(new ofstream("messages.txt", ios::out)));
+  unique_ptr<OutputStream> profiler(new StlOutputStream(new ofstream("profile.txt", ios::out)));
   profiler->setPrecision(20);
   OptimizationTools::optimizeNumericalParameters2(&tl, tl.getParameters(), 0, 0.000001, 10000, messenger.get(), profiler.get(), false, true, 2, OptimizationTools::OPTIMIZATION_NEWTON);
   cout << setprecision(20) << tl.getValue() << endl;
@@ -84,8 +84,8 @@ void fitModelHClock(SubstitutionModel* model, DiscreteDistribution* rdist, const
   ApplicationTools::displayResult("* initial likelihood", tl.getValue());
   if (abs(tl.getValue() - initialValue) > 0.001)
     throw Exception("Incorrect initial value.");
-  auto_ptr<OutputStream> messenger(new StlOutputStream(new ofstream("messages.txt", ios::out)));
-  auto_ptr<OutputStream> profiler(new StlOutputStream(new ofstream("profile.txt", ios::out)));
+  unique_ptr<OutputStream> messenger(new StlOutputStream(new ofstream("messages.txt", ios::out)));
+  unique_ptr<OutputStream> profiler(new StlOutputStream(new ofstream("profile.txt", ios::out)));
   profiler->setPrecision(20);
   OptimizationTools::optimizeNumericalParametersWithGlobalClock2(&tl, tl.getParameters(), 0, 0.000001, 10000, messenger.get(), profiler.get());
   cout << setprecision(20) << tl.getValue() << endl;
diff --git a/test/test_likelihood_nh.cpp b/test/test_likelihood_nh.cpp
index c1f0e45..b4cd485 100644
--- a/test/test_likelihood_nh.cpp
+++ b/test/test_likelihood_nh.cpp
@@ -81,7 +81,9 @@ int main() {
   SubstitutionModel* model = new T92(alphabet, 3.);
   std::vector<std::string> globalParameterNames;
   globalParameterNames.push_back("T92.kappa");
-  SubstitutionModelSet* modelSet = SubstitutionModelSetTools::createNonHomogeneousModelSet(model, rootFreqs, tree, globalParameterNames);
+  map<string, string> alias;
+
+  SubstitutionModelSet* modelSet = SubstitutionModelSetTools::createNonHomogeneousModelSet(model, rootFreqs, tree, alias, globalParameterNames);
   //DiscreteDistribution* rdist = new ConstantDistribution(1.0, true);
   //Very difficult to optimize on small datasets:
   DiscreteDistribution* rdist = new GammaDiscreteRateDistribution(4, 1.0);
@@ -107,10 +109,10 @@ int main() {
     OutputStream* messenger = new StlOutputStream(new ofstream("messages.txt", ios::out));
 
     //Simulate data:
-    auto_ptr<SiteContainer> sites(simulator.simulate(nsites));
+    unique_ptr<SiteContainer> sites(simulator.simulate(nsites));
     //Now fit model:
-    auto_ptr<SubstitutionModelSet> modelSet2(modelSet->clone());
-    auto_ptr<SubstitutionModelSet> modelSet3(modelSet->clone());
+    unique_ptr<SubstitutionModelSet> modelSet2(modelSet->clone());
+    unique_ptr<SubstitutionModelSet> modelSet3(modelSet->clone());
     RNonHomogeneousTreeLikelihood tl(*tree, *sites.get(), modelSet2.get(), rdist, true, true, false);
     tl.initialize();
     RNonHomogeneousTreeLikelihood tl2(*tree, *sites.get(), modelSet3.get(), rdist, true, true, true);
diff --git a/test/test_mapping.cpp b/test/test_mapping.cpp
index 8fd3c61..cb649d9 100644
--- a/test/test_mapping.cpp
+++ b/test/test_mapping.cpp
@@ -45,6 +45,7 @@ knowledge of the CeCILL license and that you accept its terms.
 #include <Bpp/Seq/Io/Fasta.h>
 #include <Bpp/Phyl/TreeTemplate.h>
 #include <Bpp/Phyl/Model/Nucleotide/GTR.h>
+#include <Bpp/Phyl/Model/Protein/JTT92.h>
 #include <Bpp/Phyl/Simulation/HomogeneousSequenceSimulator.h>
 #include <Bpp/Phyl/Likelihood/DRHomogeneousTreeLikelihood.h>
 #include <Bpp/Phyl/Mapping/SubstitutionRegister.h>
@@ -52,9 +53,11 @@ knowledge of the CeCILL license and that you accept its terms.
 #include <Bpp/Phyl/Mapping/LaplaceSubstitutionCount.h>
 #include <Bpp/Phyl/Mapping/DecompositionSubstitutionCount.h>
 #include <Bpp/Phyl/Mapping/UniformizationSubstitutionCount.h>
+#include <Bpp/Phyl/Mapping/DecompositionReward.h>
 #include <Bpp/Phyl/Mapping/NaiveSubstitutionCount.h>
 #include <Bpp/Phyl/Mapping/ProbabilisticSubstitutionMapping.h>
 #include <Bpp/Phyl/Mapping/SubstitutionMappingTools.h>
+#include <Bpp/Seq/AlphabetIndex/GranthamAAVolumeIndex.h>
 #include <iostream>
 
 using namespace bpp;
@@ -76,14 +79,25 @@ int main() {
   TotalSubstitutionRegister* totReg = new TotalSubstitutionRegister(model);
   ComprehensiveSubstitutionRegister* detReg = new ComprehensiveSubstitutionRegister(model);
 
+
+  cout << "test mem" << endl;
+  ProteicAlphabet* alphabet2 = new ProteicAlphabet();
+  ReversibleSubstitutionModel* model2 = new JTT92(alphabet2);
+  AlphabetIndex1* ind = new GranthamAAVolumeIndex();
+  for (size_t i = 0; i < 1000000; i++) {
+    cout << i << endl;
+    unique_ptr<DecompositionReward> d(new DecompositionReward(model2, ind));
+  }
+  cout << "done" << endl;
+
   unsigned int n = 20000;
   vector< vector<double> > realMap(n);
   vector< vector< vector<double> > > realMapTotal(n);
   vector< vector< vector<double> > > realMapDetailed(n);
   VectorSiteContainer sites(tree->getLeavesNames(), alphabet);
   for (unsigned int i = 0; i < n; ++i) {
-    ApplicationTools::displayGauge(i, n-1, '=');
-    auto_ptr<RASiteSimulationResult> result(simulator.dSimulateSite());
+    ApplicationTools::displayGauge(i, n - 1, '=');
+    unique_ptr<RASiteSimulationResult> result(simulator.dSimulateSite());
     realMap[i].resize(ids.size());
     realMapTotal[i].resize(ids.size());
     realMapDetailed[i].resize(ids.size());
@@ -102,7 +116,7 @@ int main() {
         return 1;
       }
     }
-    auto_ptr<Site> site(result->getSite(*model));
+    unique_ptr<Site> site(result->getSite(*model));
     site->setPosition(static_cast<int>(i));
     sites.addSite(*site, false);
   }
diff --git a/test/test_mapping_codon.cpp b/test/test_mapping_codon.cpp
index 3e98269..d79e5a0 100644
--- a/test/test_mapping_codon.cpp
+++ b/test/test_mapping_codon.cpp
@@ -109,7 +109,7 @@ int main() {
       //  return 1;
       //}
     }
-    auto_ptr<Site> site(result->getSite(*model));
+    unique_ptr<Site> site(result->getSite(*model));
     site->setPosition(static_cast<int>(i));
     sites.addSite(*site, false);
     delete result;
diff --git a/test/test_parsimony.cpp b/test/test_parsimony.cpp
index b9f988f..32eae43 100644
--- a/test/test_parsimony.cpp
+++ b/test/test_parsimony.cpp
@@ -50,9 +50,9 @@ using namespace std;
 int main() {
   try {
     Newick treeReader;
-    auto_ptr<Tree> tree(treeReader.read("example1.mp.dnd"));
+    unique_ptr<Tree> tree(treeReader.read("example1.mp.dnd"));
     Phylip alnReader(false, false);
-    auto_ptr<SiteContainer> sites(alnReader.readAlignment("example1.ph", &AlphabetTools::DNA_ALPHABET));
+    unique_ptr<SiteContainer> sites(alnReader.readAlignment("example1.ph", &AlphabetTools::DNA_ALPHABET));
 
     DRTreeParsimonyScore pars(*tree, *sites, true, true);
   
diff --git a/test/test_simulations.cpp b/test/test_simulations.cpp
index dc7a08f..fa97a9c 100644
--- a/test/test_simulations.cpp
+++ b/test/test_simulations.cpp
@@ -64,7 +64,9 @@ int main() {
   FrequenciesSet* rootFreqs = new GCFrequenciesSet(alphabet);
   std::vector<std::string> globalParameterNames;
   globalParameterNames.push_back("T92.kappa");
-  SubstitutionModelSet* modelSet = SubstitutionModelSetTools::createNonHomogeneousModelSet(model, rootFreqs, tree, globalParameterNames);
+  map<string, string> alias;
+
+  SubstitutionModelSet* modelSet = SubstitutionModelSetTools::createNonHomogeneousModelSet(model, rootFreqs, tree, alias, globalParameterNames);
   DiscreteDistribution* rdist = new ConstantRateDistribution();
   vector<double> thetas;
   for (unsigned int i = 0; i < modelSet->getNumberOfModels(); ++i) {
@@ -86,7 +88,7 @@ int main() {
   //Generate data set:
   VectorSiteContainer sites(seqNames, alphabet);
   for (unsigned int i = 0; i < n; ++i) {
-    auto_ptr<Site> site(simulator.simulateSite());
+    unique_ptr<Site> site(simulator.simulateSite());
     site->setPosition(static_cast<int>(i));
     sites.addSite(*site, false);
   }
@@ -117,7 +119,7 @@ int main() {
   VectorSiteContainer sites2(seqNames, alphabet);
   for (unsigned int i = 0; i < n; ++i) {
     RASiteSimulationResult* result = simulator.dSimulateSite();
-    auto_ptr<Site> site(result->getSite(*simulator.getSubstitutionModelSet()->getModel(0)));
+    unique_ptr<Site> site(result->getSite(*simulator.getSubstitutionModelSet()->getModel(0)));
     site->setPosition(static_cast<int>(i));
     sites2.addSite(*site, false);
     delete result;
diff --git a/test/test_tree.cpp b/test/test_tree.cpp
index 79c661d..4861d61 100644
--- a/test/test_tree.cpp
+++ b/test/test_tree.cpp
@@ -67,7 +67,7 @@ int main() {
   
     //Convert tree to string and read it again:
     string newick = TreeTemplateTools::treeToParenthesis(*tree);
-    TreeTemplate<Node>* tree3 = TreeTemplateTools::parenthesisToTree(newick);
+    TreeTemplate<Node>* tree3 = TreeTemplateTools::parenthesisToTree(newick, true, TreeTools::BOOTSTRAP, false, false);
     if (!tree->hasSameTopologyAs(*tree3))
       return 1; //Error!!!
     //cout << "Third test passed." << endl;
@@ -98,30 +98,42 @@ int main() {
   cout << TreeTemplateTools::treeToParenthesis(*tree7) << endl;
   delete tree7;
 
-  istringstream iss8("((A,B)aa,C)2;");
-  tReader.enableExtendedBootstrapProperty("ESS");
+  istringstream iss8("((A:1,B:2)80:3,C:4)2:5;");
   TreeTemplate<Node>* tree8 = tReader.read(iss8);
   cout << TreeTemplateTools::treeToParenthesis(*tree8) << endl;
   vector<int> ids = tree8->getNodesId();
   for (size_t i = 0; i < ids.size(); ++i) {
     cout << "Node " << ids[i] << ":" << endl;
-    vector<string> nodePpt = tree8->getNode(ids[i])->getNodePropertyNames();
-    for (size_t j = 0; j < nodePpt.size(); ++j)
-      if (tree8->getNode(ids[i])->hasNodeProperty(nodePpt[j]))
-        cout << "N: " << nodePpt[j] << "=" << dynamic_cast<BppString*>(tree8->getNode(ids[i])->getNodeProperty(nodePpt[j]))->toSTL() << endl;
+    if (tree8->getNode(ids[i])->hasBranchProperty(TreeTools::BOOTSTRAP))
+      cout << "N: BOOTSTRAP=" << dynamic_cast<Number<double>*>(tree8->getNode(ids[i])->getBranchProperty(TreeTools::BOOTSTRAP))->getValue() << endl;
     vector<string> branchPpt = tree8->getNode(ids[i])->getBranchPropertyNames();
-    for (size_t j = 0; j < branchPpt.size(); ++j)
-      if (tree8->getNode(ids[i])->hasBranchProperty(branchPpt[j]))
-        cout << "B: " << branchPpt[j] << "=" << dynamic_cast<BppString*>(tree8->getNode(ids[i])->getBranchProperty(branchPpt[j]))->toSTL() << endl;
   }
   delete tree8;
 
+  istringstream iss9("((A,B)aa,C)2;");
+  tReader.enableExtendedBootstrapProperty("ESS");
+  TreeTemplate<Node>* tree9 = tReader.read(iss9);
+  cout << TreeTemplateTools::treeToParenthesis(*tree9) << endl;
+  ids = tree9->getNodesId();
+  for (size_t i = 0; i < ids.size(); ++i) {
+    cout << "Node " << ids[i] << ":" << endl;
+    vector<string> nodePpt = tree9->getNode(ids[i])->getNodePropertyNames();
+    for (size_t j = 0; j < nodePpt.size(); ++j)
+      if (tree9->getNode(ids[i])->hasNodeProperty(nodePpt[j]))
+        cout << "N: " << nodePpt[j] << "=" << dynamic_cast<BppString*>(tree9->getNode(ids[i])->getNodeProperty(nodePpt[j]))->toSTL() << endl;
+    vector<string> branchPpt = tree9->getNode(ids[i])->getBranchPropertyNames();
+    for (size_t j = 0; j < branchPpt.size(); ++j)
+      if (tree9->getNode(ids[i])->hasBranchProperty(branchPpt[j]))
+        cout << "B: " << branchPpt[j] << "=" << dynamic_cast<BppString*>(tree9->getNode(ids[i])->getBranchProperty(branchPpt[j]))->toSTL() << endl;
+  }
+  delete tree9;
+
   //Test file parsing:
-  TreeTemplate<Node>* tree9 = TreeTemplateTools::getRandomTree(leaves, true);
+  TreeTemplate<Node>* tree10 = TreeTemplateTools::getRandomTree(leaves, true);
   Newick tWriter;
-  tWriter.write(*tree9, "tmp_tree.dnd");
+  tWriter.write(*tree10, "tmp_tree.dnd");
   Tree* test = tReader.read("tmp_tree.dnd");
-  if (!TreeTools::haveSameTopology(*tree9, *test))
+  if (!TreeTools::haveSameTopology(*tree10, *test))
     return 1;
   cout << "Newick I/O ok." << endl;
 
@@ -154,11 +166,11 @@ int main() {
   try {
     Tree* tmp = tReader.read("test/");
     cerr << "Arg, reading on directory should fail!" << endl;
-    if (tmp != NULL) {
+    if (tmp) {
       cerr << "Output of read on directory is not NULL!" << endl;
     }
     return 1;
-  } catch(Exception& ex) {
+  } catch (Exception& ex) {
     cout << "Ok, reading on directory throws exception!" << endl;
   }
 
@@ -237,32 +249,6 @@ int main() {
   }
   cout << TreeTemplateTools::treeToParenthesis(*weird6) << endl;
   delete weird6;
-
-  // Test TreeTools functions:
-  
-  //getPathBetweenAnyTwoNodes()...
-  TreeTemplate <Node>* tree = TreeTemplateTools::parenthesisToTree ("(A:0.1, (B :0.2, C:0.4):0.1);" );
-  vector <int> Leaves_select = tree->getLeavesId();
-
-  Node* node1 = tree->getNode(Leaves_select[0]);
-  Node* node2 = tree->getNode(Leaves_select[1]);
-  Node* node3 = tree->getNode(Leaves_select[2]);
-
-  vector<Node*> vecNode = TreeTemplateTools::getPathBetweenAnyTwoNodes(*node1, *node2, true);
-  cout << "Id node1 " << node1->getId() << endl;
-  cout << "Id node2 " << node2->getId() << endl;
-  cout << "Ids of path:" << endl;
-  for (size_t i = 0; i < vecNode.size(); i++){
-    cout << vecNode[i]->getId() << endl;
-  }
-
-  vecNode = TreeTemplateTools::getPathBetweenAnyTwoNodes(*node1, *node3, true);
-  cout << "Id node1 " << node1->getId() << endl;
-  cout << "Id node3 " << node3->getId() << endl;
-  cout << "Ids of path: " << endl;
-  for (size_t i = 0; i < vecNode.size(); i++){
-    cout << vecNode[i]->getId() << endl;
-  }
-  
+ 
   return 0;
 }
diff --git a/test/test_parsimony.cpp b/test/test_tree_getpath.cpp
similarity index 54%
copy from test/test_parsimony.cpp
copy to test/test_tree_getpath.cpp
index b9f988f..0c913c6 100644
--- a/test/test_parsimony.cpp
+++ b/test/test_tree_getpath.cpp
@@ -1,7 +1,7 @@
 //
-// File: test_parsimony.cpp
+// File: test_tree_getpath.cpp
 // Created by: Julien Dutheil
-// Created on: Wed 03/10 16:47 2012
+// Created on: Mon Oct 20 09:56 2014
 //
 
 /*
@@ -37,33 +37,46 @@ The fact that you are presently reading this means that you have had
 knowledge of the CeCILL license and that you accept its terms.
 */
 
-#include <Bpp/Seq/Alphabet/AlphabetTools.h>
-#include <Bpp/Seq/Io/Phylip.h>
-#include <Bpp/Phyl/Tree.h>
-#include <Bpp/Phyl/Io/Newick.h>
-#include <Bpp/Phyl/Parsimony/DRTreeParsimonyScore.h>
+#include <Bpp/Phyl/TreeTemplate.h>
+#include <Bpp/Phyl/TreeTemplateTools.h>
+#include <string>
+#include <vector>
 #include <iostream>
 
 using namespace bpp;
 using namespace std;
 
 int main() {
-  try {
-    Newick treeReader;
-    auto_ptr<Tree> tree(treeReader.read("example1.mp.dnd"));
-    Phylip alnReader(false, false);
-    auto_ptr<SiteContainer> sites(alnReader.readAlignment("example1.ph", &AlphabetTools::DNA_ALPHABET));
+  TreeTemplate<Node>* tree = TreeTemplateTools::parenthesisToTree ("(A:0.1, (B :0.2, C:0.4):0.1);" );
+  vector <int> Leaves_select = tree->getLeavesId();
 
-    DRTreeParsimonyScore pars(*tree, *sites, true, true);
-  
-    cout << "Parsimony score: " << pars.getScore() << endl;
+  Node* node1 = tree->getNode(Leaves_select[0]);
+  Node* node2 = tree->getNode(Leaves_select[1]);
+  Node* node3 = tree->getNode(Leaves_select[2]);
 
-    if (pars.getScore() != 9) return 1;
-    
-  } catch (Exception& ex) {
-    cerr << ex.what() << endl;
-    return 1;
-  }  
+  vector<Node*> vecNode = TreeTemplateTools::getPathBetweenAnyTwoNodes(*node1, *node2, true);
+  cout << "Id node1 " << node1->getId() << endl;
+  cout << "Id node2 " << node2->getId() << endl;
+  cout << "Ids of path:" << endl;
+  for (size_t i = 0; i < vecNode.size(); i++){
+    cout << vecNode[i]->getId() << endl;
+  }
+  if (vecNode[0]->getId() != 0) return -1;
+  if (vecNode[1]->getId() != 4) return -1;
+  if (vecNode[2]->getId() != 3) return -1;
+  if (vecNode[3]->getId() != 1) return -1;
 
+  vecNode = TreeTemplateTools::getPathBetweenAnyTwoNodes(*node1, *node3, true);
+  cout << "Id node1 " << node1->getId() << endl;
+  cout << "Id node3 " << node3->getId() << endl;
+  cout << "Ids of path: " << endl;
+  for (size_t i = 0; i < vecNode.size(); i++){
+    cout << vecNode[i]->getId() << endl;
+  }
+  if (vecNode[0]->getId() != 0) return -1;
+  if (vecNode[1]->getId() != 4) return -1;
+  if (vecNode[2]->getId() != 3) return -1;
+  if (vecNode[3]->getId() != 2) return -1;
+ 
   return 0;
 }
diff --git a/src/Bpp/Phyl/Model/RateDistributionFactory.cpp b/test/test_tree_rootat.cpp
similarity index 52%
rename from src/Bpp/Phyl/Model/RateDistributionFactory.cpp
rename to test/test_tree_rootat.cpp
index 5c5767c..d8fe959 100644
--- a/src/Bpp/Phyl/Model/RateDistributionFactory.cpp
+++ b/test/test_tree_rootat.cpp
@@ -1,15 +1,14 @@
 //
-// File: RateDistributionFactory.cpp
+// File: test_tree_rootat.cpp
 // Created by: Julien Dutheil
-//             Vincent Ranwez
-// Created on: Fri apr 14 11:11 2006
+// Created on: Sat Oct 18 22:32 2014
 //
 
 /*
-Copyright or © or Copr. Bio++ Development Team, (November 16, 2004, 2005, 2006)
+Copyright or © or Copr. Bio++ Development Team, (November 17, 2004)
 
 This software is a computer program whose purpose is to provide classes
-for phylogenetic data analysis.
+for numerical calculus. This file is part of the Bio++ project.
 
 This software is governed by the CeCILL  license under French law and
 abiding by the rules of distribution of free software.  You can  use, 
@@ -38,27 +37,41 @@ The fact that you are presently reading this means that you have had
 knowledge of the CeCILL license and that you accept its terms.
 */
 
-#include "RateDistributionFactory.h"
-
-#include "RateDistribution/ConstantRateDistribution.h"
-#include "RateDistribution/GammaDiscreteRateDistribution.h"
-#include "RateDistribution/GaussianDiscreteRateDistribution.h"
-#include "RateDistribution/ExponentialDiscreteRateDistribution.h"
+#include <Bpp/Phyl/TreeTemplate.h>
+#include <Bpp/Phyl/TreeTemplateTools.h>
+#include <string>
+#include <vector>
+#include <iostream>
 
 using namespace bpp;
 using namespace std;
 
-const string RateDistributionFactory::CONSTANT_DISTRIBUTION = "Constant";
-const string RateDistributionFactory::GAMMA_DISTRIBUTION = "Gamma";
-const string RateDistributionFactory::GAUSSIAN_DISTRIBUTION = "Gaussian";
-const string RateDistributionFactory::EXPONENTIAL_DISTRIBUTION = "Exponential";
+int main() {
+  //Get some leaf names:
+  vector<string> leaves(100);
+  for (size_t i = 0; i < leaves.size(); ++i)
+    leaves[i] = "leaf" + TextTools::toString(i);
+  
+  //Testing rerooting:
+  //Get a random topology:
+  unique_ptr< TreeTemplate<Node> > tr(TreeTemplateTools::getRandomTree(leaves, true));
+  //Set random branch lengths:
+  vector<Node*> nodes = tr->getNodes();
+  for (size_t i = 0; i < nodes.size(); ++i) {
+    if (nodes[i]->hasFather())
+      nodes[i]->setDistanceToFather(RandomTools::giveRandomNumberBetweenZeroAndEntry(1.));
+  }
+  double totalLen = TreeTools::getTotalLength(*tr.get(), tr->getRootId(), false);
+  ApplicationTools::displayResult("Total length", totalLen);
+  for (unsigned int i = 0; i < 100; ++i) {
+    size_t pos = RandomTools::giveIntRandomNumberBetweenZeroAndEntry<size_t>(100);
+    tr->rootAt(nodes[pos]);
+    double l = TreeTools::getTotalLength(*tr.get(), tr->getRootId(), false);
+    if ((l - totalLen) / totalLen > 0.00000001) {
+      cerr << "Error, rerooting gave incorrect branch lengths :(: " << l << " vs. " << totalLen << endl;
+      return 1;
+    }
+  }
 
-DiscreteDistribution* RateDistributionFactory::createDiscreteDistribution(const string& distName, unsigned int nbClasses) throw (Exception)
-{
-       if (distName == GAMMA_DISTRIBUTION) return new GammaDiscreteRateDistribution(nbClasses);
-  else if (distName == GAUSSIAN_DISTRIBUTION) return new GaussianDiscreteRateDistribution(nbClasses, 1.);
-  else if (distName == EXPONENTIAL_DISTRIBUTION) return new ExponentialDiscreteRateDistribution(nbClasses);
-  else if (distName == CONSTANT_DISTRIBUTION) return new ConstantRateDistribution();
-  else throw Exception("RateDistributionFactory::createDistribution(). Unknown rate distribution: " + distName);
+  return 0;
 }
-

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



More information about the debian-med-commit mailing list