[med-svn] [freebayes] 02/03: Imported Upstream version 0.9.14+dfsg

Andreas Tille tille at debian.org
Wed May 28 17:27:40 UTC 2014


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

tille pushed a commit to branch master
in repository freebayes.

commit 28bfd02d231be04695c8a6808627ef3b4aac65e4
Author: Andreas Tille <tille at debian.org>
Date:   Wed May 28 19:27:21 2014 +0200

    Imported Upstream version 0.9.14+dfsg
---
 .gitmodules                                        |     6 +-
 Makefile                                           |     8 +-
 README.md                                          |     2 +-
 bamtools/CMakeLists.txt                            |    65 -
 bamtools/LICENSE                                   |    22 -
 bamtools/README                                    |    60 -
 bamtools/docs/Doxyfile                             |  1605 --
 bamtools/src/CMakeLists.txt                        |    16 -
 bamtools/src/ExportHeader.cmake                    |    27 -
 bamtools/src/api/BamAlgorithms.h                   |    21 -
 bamtools/src/api/BamAlignment.cpp                  |  1083 -
 bamtools/src/api/BamAlignment.h                    |   638 -
 bamtools/src/api/BamAux.h                          |   468 -
 bamtools/src/api/BamConstants.h                    |   282 -
 bamtools/src/api/BamIndex.h                        |    90 -
 bamtools/src/api/BamMultiReader.cpp                |   421 -
 bamtools/src/api/BamMultiReader.h                  |   127 -
 bamtools/src/api/BamReader.cpp                     |   383 -
 bamtools/src/api/BamReader.h                       |   119 -
 bamtools/src/api/BamWriter.cpp                     |   152 -
 bamtools/src/api/BamWriter.h                       |    69 -
 bamtools/src/api/CMakeLists.txt                    |    83 -
 bamtools/src/api/IBamIODevice.h                    |    98 -
 bamtools/src/api/SamConstants.h                    |    97 -
 bamtools/src/api/SamHeader.cpp                     |   236 -
 bamtools/src/api/SamHeader.h                       |    74 -
 bamtools/src/api/SamProgram.cpp                    |   139 -
 bamtools/src/api/SamProgram.h                      |    61 -
 bamtools/src/api/SamProgramChain.cpp               |   354 -
 bamtools/src/api/SamProgramChain.h                 |    85 -
 bamtools/src/api/SamReadGroup.cpp                  |   221 -
 bamtools/src/api/SamReadGroup.h                    |    68 -
 bamtools/src/api/SamReadGroupDictionary.cpp        |   297 -
 bamtools/src/api/SamReadGroupDictionary.h          |    85 -
 bamtools/src/api/SamSequence.cpp                   |   161 -
 bamtools/src/api/SamSequence.h                     |    60 -
 bamtools/src/api/SamSequenceDictionary.cpp         |   301 -
 bamtools/src/api/SamSequenceDictionary.h           |    86 -
 bamtools/src/api/algorithms/Sort.h                 |   335 -
 bamtools/src/api/api_global.h                      |    21 -
 bamtools/src/api/internal/CMakeLists.txt           |    25 -
 bamtools/src/api/internal/bam/BamHeader_p.cpp      |   125 -
 bamtools/src/api/internal/bam/BamHeader_p.h        |    71 -
 bamtools/src/api/internal/bam/BamMultiMerger_p.h   |   266 -
 bamtools/src/api/internal/bam/BamMultiReader_p.cpp |   872 -
 bamtools/src/api/internal/bam/BamMultiReader_p.h   |   105 -
 .../internal/bam/BamRandomAccessController_p.cpp   |   289 -
 .../api/internal/bam/BamRandomAccessController_p.h |    94 -
 bamtools/src/api/internal/bam/BamReader_p.cpp      |   470 -
 bamtools/src/api/internal/bam/BamReader_p.h        |   119 -
 bamtools/src/api/internal/bam/BamWriter_p.cpp      |   475 -
 bamtools/src/api/internal/bam/BamWriter_p.h        |    73 -
 bamtools/src/api/internal/bam/CMakeLists.txt       |    19 -
 .../src/api/internal/index/BamIndexFactory_p.cpp   |   107 -
 .../src/api/internal/index/BamIndexFactory_p.h     |    49 -
 .../src/api/internal/index/BamStandardIndex_p.cpp  |   965 -
 .../src/api/internal/index/BamStandardIndex_p.h    |   237 -
 .../src/api/internal/index/BamToolsIndex_p.cpp     |   642 -
 bamtools/src/api/internal/index/BamToolsIndex_p.h  |   186 -
 bamtools/src/api/internal/index/CMakeLists.txt     |    17 -
 .../src/api/internal/io/BamDeviceFactory_p.cpp     |    37 -
 bamtools/src/api/internal/io/BamDeviceFactory_p.h  |    37 -
 bamtools/src/api/internal/io/BamFile_p.cpp         |    69 -
 bamtools/src/api/internal/io/BamFile_p.h           |    51 -
 bamtools/src/api/internal/io/BamFtp_p.cpp          |   490 -
 bamtools/src/api/internal/io/BamFtp_p.h            |    91 -
 bamtools/src/api/internal/io/BamHttp_p.cpp         |   544 -
 bamtools/src/api/internal/io/BamHttp_p.h           |    91 -
 bamtools/src/api/internal/io/BamPipe_p.cpp         |    69 -
 bamtools/src/api/internal/io/BamPipe_p.h           |    46 -
 bamtools/src/api/internal/io/BgzfStream_p.cpp      |   469 -
 bamtools/src/api/internal/io/BgzfStream_p.h        |    93 -
 bamtools/src/api/internal/io/ByteArray_p.cpp       |   111 -
 bamtools/src/api/internal/io/ByteArray_p.h         |    69 -
 bamtools/src/api/internal/io/CMakeLists.txt        |    48 -
 bamtools/src/api/internal/io/HostAddress_p.cpp     |   396 -
 bamtools/src/api/internal/io/HostAddress_p.h       |   100 -
 bamtools/src/api/internal/io/HostInfo_p.cpp        |   224 -
 bamtools/src/api/internal/io/HostInfo_p.h          |    76 -
 bamtools/src/api/internal/io/HttpHeader_p.cpp      |   395 -
 bamtools/src/api/internal/io/HttpHeader_p.h        |   132 -
 bamtools/src/api/internal/io/ILocalIODevice_p.cpp  |    56 -
 bamtools/src/api/internal/io/ILocalIODevice_p.h    |    50 -
 bamtools/src/api/internal/io/NetUnix_p.h           |    39 -
 bamtools/src/api/internal/io/NetWin_p.h            |    60 -
 bamtools/src/api/internal/io/RollingBuffer_p.cpp   |   314 -
 bamtools/src/api/internal/io/RollingBuffer_p.h     |    87 -
 bamtools/src/api/internal/io/TcpSocketEngine_p.cpp |   196 -
 bamtools/src/api/internal/io/TcpSocketEngine_p.h   |   103 -
 .../src/api/internal/io/TcpSocketEngine_unix_p.cpp |   216 -
 .../src/api/internal/io/TcpSocketEngine_win_p.cpp  |   241 -
 bamtools/src/api/internal/io/TcpSocket_p.cpp       |   430 -
 bamtools/src/api/internal/io/TcpSocket_p.h         |   128 -
 bamtools/src/api/internal/sam/CMakeLists.txt       |    17 -
 .../src/api/internal/sam/SamFormatParser_p.cpp     |   202 -
 bamtools/src/api/internal/sam/SamFormatParser_p.h  |    61 -
 .../src/api/internal/sam/SamFormatPrinter_p.cpp    |   219 -
 bamtools/src/api/internal/sam/SamFormatPrinter_p.h |    59 -
 .../src/api/internal/sam/SamHeaderValidator_p.cpp  |   524 -
 .../src/api/internal/sam/SamHeaderValidator_p.h    |   105 -
 bamtools/src/api/internal/sam/SamHeaderVersion_p.h |   134 -
 bamtools/src/api/internal/utils/BamException_p.cpp |    15 -
 bamtools/src/api/internal/utils/BamException_p.h   |    51 -
 bamtools/src/api/internal/utils/CMakeLists.txt     |    15 -
 bamtools/src/shared/bamtools_global.h              |    97 -
 bamtools/src/third_party/CMakeLists.txt            |     9 -
 bamtools/src/third_party/gtest-1.6.0/CHANGES       |   130 -
 .../src/third_party/gtest-1.6.0/CMakeLists.txt     |   240 -
 bamtools/src/third_party/gtest-1.6.0/CONTRIBUTORS  |    37 -
 bamtools/src/third_party/gtest-1.6.0/COPYING       |    28 -
 bamtools/src/third_party/gtest-1.6.0/README        |   424 -
 .../gtest-1.6.0/cmake/internal_utils.cmake         |   216 -
 .../gtest-1.6.0/fused-src/gtest/gtest-all.cc       |  9118 ---------
 .../gtest-1.6.0/fused-src/gtest/gtest.h            | 19537 -------------------
 .../gtest-1.6.0/fused-src/gtest/gtest_main.cc      |    39 -
 .../src/third_party/gtest-1.6.0/src/gtest-all.cc   |    48 -
 .../gtest-1.6.0/src/gtest-death-test.cc            |  1234 --
 .../third_party/gtest-1.6.0/src/gtest-filepath.cc  |   380 -
 .../gtest-1.6.0/src/gtest-internal-inl.h           |  1038 -
 .../src/third_party/gtest-1.6.0/src/gtest-port.cc  |   746 -
 .../third_party/gtest-1.6.0/src/gtest-printers.cc  |   356 -
 .../third_party/gtest-1.6.0/src/gtest-test-part.cc |   110 -
 .../gtest-1.6.0/src/gtest-typed-test.cc            |   110 -
 bamtools/src/third_party/gtest-1.6.0/src/gtest.cc  |  4898 -----
 .../src/third_party/gtest-1.6.0/src/gtest_main.cc  |    39 -
 bamtools/src/third_party/jsoncpp/CMakeLists.txt    |    23 -
 bamtools/src/third_party/jsoncpp/LICENSE           |    55 -
 bamtools/src/third_party/jsoncpp/json.h            |    15 -
 .../src/third_party/jsoncpp/json_batchallocator.h  |   130 -
 bamtools/src/third_party/jsoncpp/json_config.h     |    42 -
 bamtools/src/third_party/jsoncpp/json_features.h   |    47 -
 bamtools/src/third_party/jsoncpp/json_forwards.h   |    42 -
 .../src/third_party/jsoncpp/json_internalarray.inl |   453 -
 .../src/third_party/jsoncpp/json_internalmap.inl   |   612 -
 bamtools/src/third_party/jsoncpp/json_reader.cpp   |   870 -
 bamtools/src/third_party/jsoncpp/json_reader.h     |   201 -
 bamtools/src/third_party/jsoncpp/json_tool.h       |    93 -
 bamtools/src/third_party/jsoncpp/json_value.cpp    |  1701 --
 bamtools/src/third_party/jsoncpp/json_value.h      |  1059 -
 .../src/third_party/jsoncpp/json_valueiterator.inl |   297 -
 bamtools/src/third_party/jsoncpp/json_writer.cpp   |   819 -
 bamtools/src/third_party/jsoncpp/json_writer.h     |   179 -
 bamtools/src/toolkit/CMakeLists.txt                |    44 -
 bamtools/src/toolkit/bamtools.cpp                  |   163 -
 bamtools/src/toolkit/bamtools_convert.cpp          |   919 -
 bamtools/src/toolkit/bamtools_convert.h            |    37 -
 bamtools/src/toolkit/bamtools_count.cpp            |   210 -
 bamtools/src/toolkit/bamtools_count.h              |    37 -
 bamtools/src/toolkit/bamtools_coverage.cpp         |   197 -
 bamtools/src/toolkit/bamtools_coverage.h           |    37 -
 bamtools/src/toolkit/bamtools_filter.cpp           |   955 -
 bamtools/src/toolkit/bamtools_filter.h             |    37 -
 bamtools/src/toolkit/bamtools_header.cpp           |   141 -
 bamtools/src/toolkit/bamtools_header.h             |    38 -
 bamtools/src/toolkit/bamtools_index.cpp            |   126 -
 bamtools/src/toolkit/bamtools_index.h              |    37 -
 bamtools/src/toolkit/bamtools_merge.cpp            |   241 -
 bamtools/src/toolkit/bamtools_merge.h              |    37 -
 bamtools/src/toolkit/bamtools_random.cpp           |   285 -
 bamtools/src/toolkit/bamtools_random.h             |    37 -
 bamtools/src/toolkit/bamtools_resolve.cpp          |  1414 --
 bamtools/src/toolkit/bamtools_resolve.h            |    42 -
 bamtools/src/toolkit/bamtools_revert.cpp           |   194 -
 bamtools/src/toolkit/bamtools_revert.h             |    37 -
 bamtools/src/toolkit/bamtools_sort.cpp             |   375 -
 bamtools/src/toolkit/bamtools_sort.h               |    37 -
 bamtools/src/toolkit/bamtools_split.cpp            |   600 -
 bamtools/src/toolkit/bamtools_split.h              |    38 -
 bamtools/src/toolkit/bamtools_stats.cpp            |   307 -
 bamtools/src/toolkit/bamtools_stats.h              |    37 -
 bamtools/src/toolkit/bamtools_tool.h               |    35 -
 bamtools/src/toolkit/bamtools_version.h.in         |    20 -
 bamtools/src/utils/CMakeLists.txt                  |    30 -
 bamtools/src/utils/bamtools_fasta.cpp              |   623 -
 bamtools/src/utils/bamtools_fasta.h                |    47 -
 bamtools/src/utils/bamtools_filter_engine.h        |   552 -
 bamtools/src/utils/bamtools_filter_properties.h    |   195 -
 bamtools/src/utils/bamtools_filter_ruleparser.h    |   319 -
 bamtools/src/utils/bamtools_options.cpp            |   287 -
 bamtools/src/utils/bamtools_options.h              |   213 -
 bamtools/src/utils/bamtools_pileup_engine.cpp      |   346 -
 bamtools/src/utils/bamtools_pileup_engine.h        |    95 -
 bamtools/src/utils/bamtools_utilities.cpp          |   333 -
 bamtools/src/utils/bamtools_utilities.h            |    65 -
 bamtools/src/utils/bamtools_variant.h              |   128 -
 bamtools/src/utils/utils_global.h                  |    21 -
 intervaltree/.gitignore                            |     1 -
 intervaltree/IntervalTree.h                        |   215 -
 intervaltree/LICENSE                               |    19 -
 intervaltree/Makefile                              |     7 -
 intervaltree/README                                |    41 -
 intervaltree/interval_tree_test.cpp                |    81 -
 src/Allele.cpp                                     |     3 +-
 src/AlleleParser.cpp                               |     3 +
 src/Ewens.cpp                                      |     4 +-
 src/version_git.h                                  |     2 +-
 src/version_release.txt                            |     6 +-
 vcflib/.gitignore                                  |   107 -
 vcflib/.gitmodules                                 |    21 -
 vcflib/LICENSE                                     |    19 -
 vcflib/Makefile                                    |   154 -
 vcflib/README.md                                   |   639 -
 vcflib/bin/plot_roc.r                              |   153 -
 vcflib/bin/vcf2sqlite.py                           |   130 -
 vcflib/bin/vcf_strip_extra_headers                 |    18 -
 vcflib/bin/vcfbiallelic                            |    20 -
 vcflib/bin/vcfclearid                              |    12 -
 vcflib/bin/vcfclearinfo                            |    12 -
 vcflib/bin/vcfcomplex                              |    26 -
 vcflib/bin/vcfgtcompare.sh                         |    16 -
 vcflib/bin/vcfindelproximity                       |    82 -
 vcflib/bin/vcfindels                               |    26 -
 vcflib/bin/vcfmultiallelic                         |    20 -
 vcflib/bin/vcfmultiway                             |    20 -
 vcflib/bin/vcfmultiwayscripts                      |    30 -
 vcflib/bin/vcfnobiallelicsnps                      |    25 -
 vcflib/bin/vcfnoindels                             |    25 -
 vcflib/bin/vcfnosnps                               |    25 -
 vcflib/bin/vcfnulldotslashdot                      |    22 -
 vcflib/bin/vcfplotaltdiscrepancy.r                 |   511 -
 vcflib/bin/vcfplotaltdiscrepancy.sh                |    12 -
 vcflib/bin/vcfplotsitediscrepancy.r                |    99 -
 vcflib/bin/vcfplottstv.sh                          |    13 -
 vcflib/bin/vcfprintaltdiscrepancy.r                |    37 -
 vcflib/bin/vcfprintaltdiscrepancy.sh               |    18 -
 vcflib/bin/vcfqualfilter                           |    32 -
 vcflib/bin/vcfregionreduce                         |    29 -
 vcflib/bin/vcfregionreduce_and_cut                 |    32 -
 vcflib/bin/vcfregionreduce_pipe                    |    29 -
 vcflib/bin/vcfregionreduce_uncompressed            |    29 -
 vcflib/bin/vcfsnps                                 |    26 -
 vcflib/bin/vcfsort                                 |     3 -
 vcflib/bin/vcfvarstats                             |   225 -
 vcflib/fastahack/.gitignore                        |     2 -
 vcflib/fastahack/Fasta.cpp                         |   317 -
 vcflib/fastahack/Fasta.h                           |    82 -
 vcflib/fastahack/FastaHack.cpp                     |   179 -
 vcflib/fastahack/LargeFileSupport.h                |    16 -
 vcflib/fastahack/Makefile                          |    19 -
 vcflib/fastahack/README                            |    63 -
 vcflib/fastahack/Region.h                          |    51 -
 vcflib/fastahack/disorder.c                        |   192 -
 vcflib/fastahack/disorder.h                        |    62 -
 vcflib/fastahack/libdisorder.LICENSE               |   339 -
 vcflib/fastahack/split.cpp                         |    33 -
 vcflib/fastahack/split.h                           |    20 -
 vcflib/fastahack/tests/correct.fasta               |    30 -
 vcflib/fastahack/tests/embedded_newline.fasta      |    35 -
 vcflib/fastahack/tests/mismatched_lines.fasta      |    30 -
 vcflib/fastahack/tests/trailing_newlines.fasta     |    34 -
 vcflib/filevercmp/Makefile                         |    13 -
 vcflib/filevercmp/README.md                        |    39 -
 vcflib/filevercmp/filevercmp.c                     |   180 -
 vcflib/filevercmp/filevercmp.h                     |    42 -
 vcflib/filevercmp/main.c                           |    15 -
 vcflib/fsom/Makefile                               |     5 -
 vcflib/fsom/README                                 |     0
 vcflib/fsom/convert.h                              |    22 -
 vcflib/fsom/example.c                              |   121 -
 vcflib/fsom/fsom.c                                 |   988 -
 vcflib/fsom/fsom.h                                 |    87 -
 vcflib/fsom/main.cpp                               |   272 -
 vcflib/fsom/split.cpp                              |    33 -
 vcflib/fsom/split.h                                |    20 -
 vcflib/intervaltree/.gitignore                     |     1 -
 vcflib/intervaltree/IntervalTree.h                 |   214 -
 vcflib/intervaltree/Makefile                       |     7 -
 vcflib/intervaltree/interval_tree_test.cpp         |    81 -
 vcflib/multichoose/.gitignore                      |     5 -
 vcflib/multichoose/Makefile                        |    17 -
 vcflib/multichoose/README                          |    40 -
 vcflib/multichoose/multichoose.c                   |    53 -
 vcflib/multichoose/multichoose.cpp                 |    66 -
 vcflib/multichoose/multichoose.h                   |    79 -
 vcflib/multichoose/multichoose.py                  |    55 -
 vcflib/multichoose/multipermute.cpp                |    66 -
 vcflib/multichoose/multipermute.h                  |   132 -
 vcflib/multichoose/multipermute.py                 |    98 -
 vcflib/samples/sample.vcf                          |    31 -
 vcflib/smithwaterman/.gitignore                    |     3 -
 vcflib/smithwaterman/BandedSmithWaterman.cpp       |   670 -
 vcflib/smithwaterman/BandedSmithWaterman.h         |   111 -
 vcflib/smithwaterman/IndelAllele.cpp               |    62 -
 vcflib/smithwaterman/IndelAllele.h                 |    37 -
 vcflib/smithwaterman/LeftAlign.cpp                 |   853 -
 vcflib/smithwaterman/LeftAlign.h                   |    32 -
 vcflib/smithwaterman/Makefile                      |    34 -
 vcflib/smithwaterman/Mosaik.h                      |    73 -
 vcflib/smithwaterman/Repeats.cpp                   |    69 -
 vcflib/smithwaterman/Repeats.h                     |     8 -
 vcflib/smithwaterman/SWMain.cpp                    |   126 -
 vcflib/smithwaterman/SmithWatermanGotoh.cpp        |   741 -
 vcflib/smithwaterman/SmithWatermanGotoh.h          |   101 -
 vcflib/smithwaterman/convert.h                     |    22 -
 vcflib/smithwaterman/disorder.c                    |   192 -
 vcflib/smithwaterman/disorder.h                    |    62 -
 vcflib/smithwaterman/examples.txt                  |    76 -
 vcflib/smithwaterman/libdisorder.LICENSE           |   339 -
 vcflib/smithwaterman/smithwaterman.cpp             |   246 -
 vcflib/src/BedReader.h                             |   176 -
 vcflib/src/Variant.cpp                             |  2199 ---
 vcflib/src/Variant.h                               |   495 -
 vcflib/src/convert.h                               |    22 -
 vcflib/src/join.h                                  |    36 -
 vcflib/src/mt19937ar.h                             |   192 -
 vcflib/src/split.cpp                               |    23 -
 vcflib/src/split.h                                 |    53 -
 vcflib/src/ssw.c                                   |   834 -
 vcflib/src/ssw.h                                   |   129 -
 vcflib/src/ssw_cpp.cpp                             |   399 -
 vcflib/src/ssw_cpp.h                               |   216 -
 vcflib/src/vcf2fasta.cpp                           |   264 -
 vcflib/src/vcf2tsv.cpp                             |   241 -
 vcflib/src/vcfaddinfo.cpp                          |   111 -
 vcflib/src/vcfafpath.cpp                           |    52 -
 vcflib/src/vcfallelicprimitives.cpp                |   341 -
 vcflib/src/vcfaltcount.cpp                         |    50 -
 vcflib/src/vcfannotate.cpp                         |   126 -
 vcflib/src/vcfannotategenotypes.cpp                |   215 -
 vcflib/src/vcfbreakmulti.cpp                       |   114 -
 vcflib/src/vcfcat.cpp                              |    34 -
 vcflib/src/vcfcheck.cpp                            |   139 -
 vcflib/src/vcfclassify.cpp                         |   162 -
 vcflib/src/vcfcleancomplex.cpp                     |    71 -
 vcflib/src/vcfcombine.cpp                          |   179 -
 vcflib/src/vcfcommonsamples.cpp                    |    85 -
 vcflib/src/vcfcountalleles.cpp                     |    33 -
 vcflib/src/vcfcreatemulti.cpp                      |   195 -
 vcflib/src/vcfdistance.cpp                         |    85 -
 vcflib/src/vcfecho.cpp                             |    31 -
 vcflib/src/vcfentropy.cpp                          |   142 -
 vcflib/src/vcfevenregions.cpp                      |   202 -
 vcflib/src/vcffilter.cpp                           |   389 -
 vcflib/src/vcffixup.cpp                            |   115 -
 vcflib/src/vcfflatten.cpp                          |   178 -
 vcflib/src/vcfgeno2alleles.cpp                     |    54 -
 vcflib/src/vcfgeno2haplo.cpp                       |   391 -
 vcflib/src/vcfgenosamplenames.cpp                  |    39 -
 vcflib/src/vcfgenosummarize.cpp                    |   107 -
 vcflib/src/vcfgenotypecompare.cpp                  |   327 -
 vcflib/src/vcfgenotypes.cpp                        |    62 -
 vcflib/src/vcfglxgt.cpp                            |   171 -
 vcflib/src/vcfhetcount.cpp                         |    67 -
 vcflib/src/vcfhethomratio.cpp                      |    66 -
 vcflib/src/vcfintersect.cpp                        |   569 -
 vcflib/src/vcfkeepgeno.cpp                         |    62 -
 vcflib/src/vcfkeepinfo.cpp                         |    62 -
 vcflib/src/vcfkeepsamples.cpp                      |    54 -
 vcflib/src/vcfleftalign.cpp                        |   779 -
 vcflib/src/vcflength.cpp                           |    39 -
 vcflib/src/vcfnumalt.cpp                           |    55 -
 vcflib/src/vcfoverlay.cpp                          |   115 -
 vcflib/src/vcfparsealts.cpp                        |    42 -
 vcflib/src/vcfprimers.cpp                          |   140 -
 vcflib/src/vcfrandom.cpp                           |    70 -
 vcflib/src/vcfrandomsample.cpp                     |   174 -
 vcflib/src/vcfremap.cpp                            |   350 -
 vcflib/src/vcfremoveaberrantgenotypes.cpp          |    75 -
 vcflib/src/vcfremovesamples.cpp                    |    76 -
 vcflib/src/vcfroc.cpp                              |   469 -
 vcflib/src/vcfsamplediff.cpp                       |   200 -
 vcflib/src/vcfsamplenames.cpp                      |    29 -
 vcflib/src/vcfsamplestats.cpp                      |   193 -
 vcflib/src/vcfsitesummarize.cpp                    |    94 -
 vcflib/src/vcfsom.cpp                              |   626 -
 vcflib/src/vcfstats.cpp                            |   570 -
 vcflib/src/vcfstreamsort.cpp                       |   143 -
 vcflib/src/vcfuniq.cpp                             |    49 -
 vcflib/src/vcfuniqalleles.cpp                      |    54 -
 vcflib/tabixpp/ChangeLog                           |   593 -
 vcflib/tabixpp/Makefile                            |    71 -
 vcflib/tabixpp/NEWS                                |   126 -
 vcflib/tabixpp/README                              |     6 -
 vcflib/tabixpp/TabixReader.java                    |   395 -
 vcflib/tabixpp/bam_endian.h                        |    42 -
 vcflib/tabixpp/bedidx.c                            |   156 -
 vcflib/tabixpp/bgzf.c                              |   714 -
 vcflib/tabixpp/bgzf.h                              |   157 -
 vcflib/tabixpp/bgzip.c                             |   206 -
 vcflib/tabixpp/example.gtf.gz                      |   Bin 3778 -> 0 bytes
 vcflib/tabixpp/example.gtf.gz.tbi                  |   Bin 259 -> 0 bytes
 vcflib/tabixpp/index.c                             |   998 -
 vcflib/tabixpp/khash.h                             |   486 -
 vcflib/tabixpp/knetfile.c                          |   632 -
 vcflib/tabixpp/knetfile.h                          |    75 -
 vcflib/tabixpp/kseq.h                              |   227 -
 vcflib/tabixpp/ksort.h                             |   271 -
 vcflib/tabixpp/kstring.c                           |   165 -
 vcflib/tabixpp/kstring.h                           |    68 -
 vcflib/tabixpp/main.c                              |   290 -
 vcflib/tabixpp/main.cpp                            |    47 -
 vcflib/tabixpp/perl/MANIFEST                       |     8 -
 vcflib/tabixpp/perl/Makefile.PL                    |     8 -
 vcflib/tabixpp/perl/Tabix.pm                       |    76 -
 vcflib/tabixpp/perl/Tabix.xs                       |    71 -
 vcflib/tabixpp/perl/TabixIterator.pm               |    41 -
 vcflib/tabixpp/perl/t/01local.t                    |    28 -
 vcflib/tabixpp/perl/t/02remote.t                   |    28 -
 vcflib/tabixpp/perl/typemap                        |     3 -
 vcflib/tabixpp/python/setup.py                     |    55 -
 vcflib/tabixpp/python/tabixmodule.c                |   408 -
 vcflib/tabixpp/python/test.py                      |    91 -
 vcflib/tabixpp/tabix.1                             |   132 -
 vcflib/tabixpp/tabix.cpp                           |    89 -
 vcflib/tabixpp/tabix.h                             |   145 -
 vcflib/tabixpp/tabix.hpp                           |    31 -
 vcflib/tabixpp/tabix.py                            |    87 -
 vcflib/tabixpp/tabix.tex                           |   121 -
 408 files changed, 22 insertions(+), 109180 deletions(-)

diff --git a/.gitmodules b/.gitmodules
index 8b1bc04..7be5e68 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,9 +1,9 @@
 [submodule "vcflib"]
 	path = vcflib
-	url = git://github.com/ekg/vcflib.git
+	url = https://github.com/ekg/vcflib.git
 [submodule "bamtools"]
 	path = bamtools
-	url = git://github.com/pezmaster31/bamtools.git
+	url = https://github.com/pezmaster31/bamtools.git
 [submodule "intervaltree"]
 	path = intervaltree
-	url = git://github.com/ekg/intervaltree.git
+	url = https://github.com/ekg/intervaltree.git
diff --git a/Makefile b/Makefile
index c6d18b9..abcef20 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,12 @@
-all:
+all: vcflib/Makefile
 	cd src && $(MAKE)
 
+vcflib/Makefile:
+	@echo "To build freebayes you must use git to also download its submodules."
+	@echo "Do so by downloading freebayes again using this command (note --recursive flag):"
+	@echo "    git clone --recursive git://github.com/ekg/freebayes.git"
+	@error
+
 debug:
 	cd src && $(MAKE) debug
 
diff --git a/README.md b/README.md
index 3208718..f2feb0b 100644
--- a/README.md
+++ b/README.md
@@ -23,7 +23,7 @@ alignments.  This method avoids one of the core problems with alignment-based
 variant detection--- that identical sequences may have multiple possible 
 alignments:
 
-<img src="http://hypervolu.me/~erik/freebayes/figures/haplotype_calling.png" 
+<img src="http://hypervolu.me/freebayes/figures/haplotype_calling.png" 
 width=500/>
 
 *FreeBayes* uses short-read alignments 
diff --git a/bamtools/CMakeLists.txt b/bamtools/CMakeLists.txt
deleted file mode 100644
index 9b97fa0..0000000
--- a/bamtools/CMakeLists.txt
+++ /dev/null
@@ -1,65 +0,0 @@
-# ==========================
-# BamTools CMakeLists.txt
-# (c) 2010 Derek Barnett
-#
-# top-level
-# ==========================
-
-# set project name
-project( BamTools )
-
-# Cmake requirements
-cmake_minimum_required( VERSION 2.6.4 )
-
-# Force the build directory to be different from source directory
-macro( ENSURE_OUT_OF_SOURCE_BUILD MSG )
-    string( COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" insource )
-    get_filename_component( PARENTDIR ${CMAKE_SOURCE_DIR} PATH )
-    string( COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${PARENTDIR}" insourcesubdir )
-    IF( insource OR insourcesubdir )
-        message( FATAL_ERROR "${MSG}" )
-    ENDIF( insource OR insourcesubdir )
-endmacro( ENSURE_OUT_OF_SOURCE_BUILD )
-
-ensure_out_of_source_build( "
-  ${PROJECT_NAME} requires an out of source build.
-  $ mkdir build 
-  $ cd build
-  $ cmake ..
-  $ make 
-(or the Windows equivalent)\n" )
-
-# set BamTools version information
-set( BamTools_VERSION_MAJOR 2 )
-set( BamTools_VERSION_MINOR 3 )
-set( BamTools_VERSION_BUILD 0 )
-
-# set our library and executable destination dirs
-set( EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin" )
-set( LIBRARY_OUTPUT_PATH    "${CMAKE_SOURCE_DIR}/lib" )
-
-# define compiler flags for all code
-set( CMAKE_BUILD_TYPE Release )
-add_definitions( -Wall -D_FILE_OFFSET_BITS=64 )
-
-# -----------------------------------------------
-# handle platform-/environment-specific defines
-
-# If planning to run in Node.js environment, run:
-# cmake -DEnableNodeJS=true
-if( EnableNodeJS )
-    add_definitions( -DSYSTEM_NODEJS=1 )
-endif()
-
-# If running on SunOS
-if( "${CMAKE_SYSTEM_NAME}" MATCHES "SunOS" )
-    add_definitions( -DSUN_OS )
-endif()
-
-# -------------------------------------------
-
-# add our includes root path
-include_directories( src )
-
-# list subdirectories to build in
-add_subdirectory( src )
diff --git a/bamtools/LICENSE b/bamtools/LICENSE
deleted file mode 100644
index eaee1fd..0000000
--- a/bamtools/LICENSE
+++ /dev/null
@@ -1,22 +0,0 @@
-The MIT License
-
-Copyright (c) 2009-2010 Derek Barnett, Erik Garrison, Gabor Marth, Michael Stromberg
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-
diff --git a/bamtools/README b/bamtools/README
deleted file mode 100644
index 498f4be..0000000
--- a/bamtools/README
+++ /dev/null
@@ -1,60 +0,0 @@
---------------------------------------------------------------------------------
-README : BAMTOOLS
---------------------------------------------------------------------------------
-
-BamTools provides both a programmer's API and an end-user's toolkit for handling
-BAM files.
-
-I.   Learn More
-
-II.  License
-
-III. Acknowledgements
-
-IV.  Contact
-
---------------------------------------------------------------------------------
-I. Learn More:
---------------------------------------------------------------------------------
-
-Installation steps, tutorial, API documentation, etc. are all now available 
-through the BamTools project wiki:
-
-https://github.com/pezmaster31/bamtools/wiki
-
-Join the mailing list(s) to stay informed of updates or get involved with 
-contributing:
-
-https://github.com/pezmaster31/bamtools/wiki/Mailing-lists
-
---------------------------------------------------------------------------------
-II. License :
---------------------------------------------------------------------------------
-
-Both the BamTools API and toolkit are released under the MIT License.
-Copyright (c) 2009-2010 Derek Barnett, Erik Garrison, Gabor Marth,
-    Michael Stromberg
-
-See included file LICENSE for details.
-
---------------------------------------------------------------------------------
-III. Acknowledgements :
---------------------------------------------------------------------------------
-
- * Aaron Quinlan for several key feature ideas and bug fix contributions
- * Baptiste Lepilleur for the public-domain JSON parser (JsonCPP)
- * Heng Li, author of SAMtools - the original C-language BAM API/toolkit.
-
---------------------------------------------------------------------------------
-IV. Contact :
---------------------------------------------------------------------------------
-
-Feel free to contact me with any questions, comments, suggestions, bug reports,
-    etc.
-
-Derek Barnett
-Marth Lab
-Biology Dept., Boston College
-
-Email: derekwbarnett at gmail.com
-Project Website: http://github.com/pezmaster31/bamtools
diff --git a/bamtools/docs/Doxyfile b/bamtools/docs/Doxyfile
deleted file mode 100644
index 410ea27..0000000
--- a/bamtools/docs/Doxyfile
+++ /dev/null
@@ -1,1605 +0,0 @@
-# Doxyfile 1.6.3
-
-# This file describes the settings to be used by the documentation system
-# doxygen (www.doxygen.org) for a project
-#
-# All text after a 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 (" ")
-
-#---------------------------------------------------------------------------
-# 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.
-
-DOXYFILE_ENCODING      = UTF-8
-
-# The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
-# by quotes) that should identify the project.
-
-PROJECT_NAME           = BamTools
-
-# 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.3.0
-
-# 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.
-
-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.
-
-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, Lithuanian, Norwegian, Macedonian, Persian, 
-# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, 
-# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
-
-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.
-
-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 
-# brief descriptions will be completely suppressed.
-
-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"
-
-ABBREVIATE_BRIEF       = "The $name class" \
-                         "The $name widget" \
-                         "The $name file" \
-                         is \
-                         provides \
-                         specifies \
-                         contains \
-                         represents \
-                         a \
-                         an \
-                         the
-
-# 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.
-
-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 
-# operators of the base classes will not be shown.
-
-INLINE_INHERITED_MEMB  = NO
-
-# 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.
-
-FULL_PATH_NAMES        = NO
-
-# 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.
-
-STRIP_FROM_PATH        = 
-
-# 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.
-
-STRIP_FROM_INC_PATH    = 
-
-# 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.
-
-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.)
-
-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.)
-
-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.
-
-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.
-
-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.
-
-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.
-
-TAB_SIZE               = 1
-
-# 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.
-
-ALIASES                = samSpecURL=http://samtools.sourceforge.net/SAM1.pdf
-
-# 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.
-
-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.
-
-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.
-
-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.
-
-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, C#, 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.
-
-EXTENSION_MAPPING      = 
-
-# 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 make the inheritance and collaboration 
-# diagrams that involve STL classes more complete and accurate.
-
-BUILTIN_STL_SUPPORT    = NO
-
-# If you use Microsoft's C++/CLI language, you should set this option to YES to 
-# enable parsing support.
-
-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.
-
-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 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.
-
-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 
-# all members of a group must be documented explicitly.
-
-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.
-
-SUBGROUPING            = YES
-
-# 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 
-# types are typedef'ed and only the typedef is referenced, never the tag name.
-
-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 penality. 
-# 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 rougly 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
-
-#---------------------------------------------------------------------------
-# 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
-
-EXTRACT_ALL            = YES
-
-# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
-# will be included in the documentation.
-
-EXTRACT_PRIVATE        = NO
-
-# If the EXTRACT_STATIC tag is set to YES all static members of a file 
-# will be included in the documentation.
-
-EXTRACT_STATIC         = NO
-
-# 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.
-
-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.
-
-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 namespace are hidden.
-
-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.
-
-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.
-
-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.
-
-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.
-
-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.
-
-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 
-# and Mac users are advised to set this option to NO.
-
-CASE_SENSE_NAMES       = NO
-
-# 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.
-
-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.
-
-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.
-
-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.
-
-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.
-
-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.
-
-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.
-
-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.
-
-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.
-
-SORT_BY_SCOPE_NAME     = 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.
-
-GENERATE_TODOLIST      = YES
-
-# 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.
-
-GENERATE_TESTLIST      = YES
-
-# 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.
-
-GENERATE_BUGLIST       = YES
-
-# 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.
-
-GENERATE_DEPRECATEDLIST= YES
-
-# The ENABLED_SECTIONS tag can be used to enable conditional 
-# documentation sections, marked by \if sectionname ... \endif.
-
-ENABLED_SECTIONS       = 
-
-# The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
-# the initial value of a variable or define 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 defines in the 
-# documentation can be controlled using \showinitializer or \hideinitializer 
-# command in the documentation regardless of this setting.
-
-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 
-# list will mention the files that were used to generate the documentation.
-
-SHOW_USED_FILES        = YES
-
-# If the sources in your project are distributed over multiple directories 
-# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy 
-# in the documentation. The default is NO.
-
-SHOW_DIRECTORIES       = 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.
-
-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.
-
-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.
-
-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. The 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.
-
-LAYOUT_FILE            = 
-
-#---------------------------------------------------------------------------
-# 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.
-
-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.
-
-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.
-
-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.
-
-WARN_IF_DOC_ERROR      = YES
-
-# This WARN_NO_PARAMDOC option can be abled 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.
-
-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)
-
-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.
-
-WARN_LOGFILE           = 
-
-#---------------------------------------------------------------------------
-# 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.
-
-INPUT                  = /home/derek/development/bamtools/src/api
-
-# 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.
-
-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++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx 
-# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
-
-FILE_PATTERNS          = *.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 \
-                         *.vhd \
-                         *.vhdl
-
-# 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.
-
-RECURSIVE              = YES
-
-# The EXCLUDE tag can be used to specify files and/or directories that should 
-# 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.
-
-EXCLUDE                = /home/derek/development/bamtools/src/api/internal
-
-# The EXCLUDE_SYMLINKS tag can be used select whether or not files or 
-# directories that are symbolic links (a Unix filesystem feature) are excluded 
-# from the input.
-
-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/*
-
-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, 
-# AClass::ANamespace, ANamespace::*Test
-
-EXCLUDE_SYMBOLS        = BamTools::Internal \
-                         BamTools::BamAlignment::BamAlignmentSupportData \
-                         BamTools::RaiiBuffer \
-                         UsesCharData \
-                         sort_helper \
-                         AlignmentSortBase
-
-# 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.
-
-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.
-
-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).
-
-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.
-
-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, INPUT_FILTER 
-# is applied to all files.
-
-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).
-
-FILTER_SOURCE_FILES    = NO
-
-#---------------------------------------------------------------------------
-# 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.
-
-SOURCE_BROWSER         = NO
-
-# Setting the INLINE_SOURCES tag to YES will include the body 
-# of functions and classes directly in the documentation.
-
-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 and C++ comments will always remain visible.
-
-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.
-
-REFERENCED_BY_RELATION = NO
-
-# 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.
-
-REFERENCES_RELATION    = NO
-
-# 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.
-
-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.
-
-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.
-
-VERBATIM_HEADERS       = YES
-
-#---------------------------------------------------------------------------
-# 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.
-
-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])
-
-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.
-
-IGNORE_PREFIX          = 
-
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
-# generate HTML output.
-
-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.
-
-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.
-
-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.
-
-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.
-
-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 the tag is left blank doxygen 
-# will generate a default style sheet. Note that doxygen will try to copy 
-# the style sheet file to the HTML output directory, so don't put your own 
-# stylesheet in the HTML output directory as well, or it will be erased!
-
-HTML_STYLESHEET        = 
-
-# 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.
-
-HTML_TIMESTAMP         = YES
-
-# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 
-# files or namespaces will be aligned in HTML using tables. If set to 
-# NO a bullet list will be used.
-
-HTML_ALIGN_MEMBERS     = 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 
-# page has loaded. For this to work a browser that supports 
-# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox 
-# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
-
-HTML_DYNAMIC_SECTIONS  = YES
-
-# 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 for more information.
-
-GENERATE_DOCSET        = NO
-
-# 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.
-
-DOCSET_FEEDNAME        = "Doxygen generated docs"
-
-# 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.
-
-DOCSET_BUNDLE_ID       = org.doxygen.Project
-
-# 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.
-
-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 
-# written to the html output directory.
-
-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.
-
-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).
-
-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.
-
-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.
-
-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.
-
-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.
-
-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.
-
-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
-
-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
-
-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
-
-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>.
-
-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>.
-
-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.
-
-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.
-
-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.
-
-ECLIPSE_DOC_ID         = org.doxygen.Project
-
-# The DISABLE_INDEX tag can be used to turn on/off the condensed index at 
-# top of each HTML page. The value NO (the default) enables the index and 
-# the value YES disables it.
-
-DISABLE_INDEX          = NO
-
-# This tag can be used to set the number of enum values (range [1..20]) 
-# that doxygen will group on one line in the generated HTML documentation.
-
-ENUM_VALUES_PER_LINE   = 4
-
-# 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.
-
-GENERATE_TREEVIEW      = NO
-
-# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, 
-# and Class Hierarchy pages using a tree view instead of an ordered list.
-
-USE_INLINE_TREES       = NO
-
-# 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.
-
-TREEVIEW_WIDTH         = 250
-
-# 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.
-
-FORMULA_FONTSIZE       = 10
-
-# 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.
-
-SEARCHENGINE           = YES
-
-# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
-# implemented using a PHP enabled web server instead of at the web client
-# using Javascript. Doxygen will generate the search PHP script and index 
-# file to put on the web server. The advantage of the server
-# based approach is that it scales better to large projects and allows
-# full text search. The disadvances is that it is more difficult to setup 
-# and does not have live searching capabilities.
-
-SERVER_BASED_SEARCH    = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
-# generate Latex output.
-
-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.
-
-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.
-
-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.
-
-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.
-
-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, a4wide, letter, legal and 
-# executive. If left blank a4wide will be used.
-
-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.
-
-EXTRA_PACKAGES         = 
-
-# 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!
-
-LATEX_HEADER           = 
-
-# 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.
-
-PDF_HYPERLINKS         = YES
-
-# 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 
-# higher quality PDF documentation.
-
-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.
-
-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.
-
-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.
-
-LATEX_SOURCE_CODE      = NO
-
-#---------------------------------------------------------------------------
-# 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.
-
-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.
-
-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.
-
-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.
-
-RTF_HYPERLINKS         = NO
-
-# 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.
-
-RTF_STYLESHEET_FILE    = 
-
-# Set optional variables used in the generation of an rtf document. 
-# Syntax is similar to doxygen's config file.
-
-RTF_EXTENSIONS_FILE    = 
-
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
-# generate man pages
-
-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.
-
-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)
-
-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.
-
-MAN_LINKS              = NO
-
-#---------------------------------------------------------------------------
-# 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.
-
-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.
-
-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.
-
-XML_PROGRAMLISTING     = YES
-
-#---------------------------------------------------------------------------
-# 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.
-
-GENERATE_AUTOGEN_DEF   = NO
-
-#---------------------------------------------------------------------------
-# 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.
-
-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.
-
-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.
-
-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.
-
-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.
-
-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.
-
-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.
-
-EXPAND_ONLY_PREDEF     = NO
-
-# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
-# in the INCLUDE_PATH (see below) will be search if a #include is found.
-
-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.
-
-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.
-
-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.
-
-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.
-
-EXPAND_AS_DEFINED      = 
-
-# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
-# doxygen's preprocessor will remove all 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.
-
-SKIP_FUNCTION_MACROS   = YES
-
-#---------------------------------------------------------------------------
-# Configuration::additions related to external references
-#---------------------------------------------------------------------------
-
-# The TAGFILES option can be used to specify one or more tagfiles. 
-# Optionally an initial location of the external documentation 
-# can be added for each tagfile. 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. If a location is present for each tag, the installdox tool 
-# does not have to be run to correct the links. 
-# 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.
-
-TAGFILES               = 
-
-# When a file name is specified after GENERATE_TAGFILE, doxygen will create 
-# a tag file that is based on the input files it reads.
-
-GENERATE_TAGFILE       = 
-
-# 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.
-
-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.
-
-EXTERNAL_GROUPS        = NO
-
-# The PERL_PATH should be the absolute path and name of the perl script 
-# interpreter (i.e. the result of `which perl').
-
-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 is superseded by the HAVE_DOT option below. This is only a 
-# fallback. It is recommended to install and use dot, since it yields more 
-# powerful graphs.
-
-CLASS_DIAGRAMS         = NO
-
-# 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.
-
-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)
-
-HAVE_DOT               = NO
-
-# By default doxygen will write a font called FreeSans.ttf to the output 
-# directory and reference it in all dot files that doxygen generates. This 
-# font does not include all possible unicode characters however, so when you need 
-# these (or just want a differently looking font) you can specify the font name 
-# using DOT_FONTNAME. You need 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.
-
-DOT_FONTNAME           = FreeSans
-
-# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. 
-# The default size is 10pt.
-
-DOT_FONTSIZE           = 10
-
-# By default doxygen will tell dot to use the output directory to look for the 
-# FreeSans.ttf font (which doxygen will put there itself). If you specify a 
-# different font using DOT_FONTNAME you can set the path where dot 
-# can find it using this tag.
-
-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 
-# the CLASS_DIAGRAMS tag to NO.
-
-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.
-
-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
-
-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 
-# Language.
-
-UML_LOOK               = NO
-
-# If set to YES, the inheritance and collaboration graphs will show the 
-# relations between templates and their instances.
-
-TEMPLATE_RELATIONS     = NO
-
-# 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.
-
-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.
-
-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.
-
-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.
-
-CALLER_GRAPH           = NO
-
-# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
-# will graphical hierarchy of all classes instead of a textual one.
-
-GRAPHICAL_HIERARCHY    = YES
-
-# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES 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.
-
-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 png, jpg, or gif 
-# If left blank png will be used.
-
-DOT_IMAGE_FORMAT       = png
-
-# The tag DOT_PATH 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.
-
-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).
-
-DOTFILE_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.
-
-DOT_GRAPH_MAX_NODES    = 50
-
-# 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.
-
-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).
-
-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.
-
-DOT_MULTI_TARGETS      = NO
-
-# 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.
-
-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.
-
-DOT_CLEANUP            = YES
diff --git a/bamtools/src/CMakeLists.txt b/bamtools/src/CMakeLists.txt
deleted file mode 100644
index e359695..0000000
--- a/bamtools/src/CMakeLists.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-# ==========================
-# BamTools CMakeLists.txt
-# (c) 2010 Derek Barnett
-#
-# src/
-# ==========================
-
-add_subdirectory( api )
-add_subdirectory( third_party )
-add_subdirectory( toolkit )
-add_subdirectory( utils )
-
-# export shared headers
-include( ExportHeader.cmake )
-set( SharedIncludeDir "shared" )
-ExportHeader( SharedHeaders shared/bamtools_global.h ${SharedIncludeDir} )
diff --git a/bamtools/src/ExportHeader.cmake b/bamtools/src/ExportHeader.cmake
deleted file mode 100644
index ec62573..0000000
--- a/bamtools/src/ExportHeader.cmake
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# ExportHeader
-#
-
-function( ExportHeader MODULE FILE DEST )
-
-    # if haven't defined our custom 'build target'
-    # not exactly a build target, but lets this command get
-    # checked any time build step happens
-    if( NOT TARGET ${MODULE} )
-        add_custom_target( ${MODULE} ALL COMMENT "Exporting ${MODULE}" )
-    endif( NOT TARGET ${MODULE} )
-
-    # get the filename (without path)
-    get_filename_component( FILENAME "${FILE}" NAME )
-
-    # copy header to destination
-    add_custom_command( TARGET ${MODULE} COMMAND
-        ${CMAKE_COMMAND} -E copy_if_different
-        "${CMAKE_CURRENT_SOURCE_DIR}/${FILE}"
-        "${CMAKE_SOURCE_DIR}/include/${DEST}/${FILENAME}" )
-
-    # make sure files are properly 'installed'
-    install( FILES "${FILE}" DESTINATION "include/bamtools/${DEST}" )
-
-endfunction( ExportHeader )
-
diff --git a/bamtools/src/api/BamAlgorithms.h b/bamtools/src/api/BamAlgorithms.h
deleted file mode 100644
index 6109412..0000000
--- a/bamtools/src/api/BamAlgorithms.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// ***************************************************************************
-// BamAlgorithms.h (c) 2009 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// All rights reserved.
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides generic algorithms that are intended to work with BamTools data
-// structures. Where possible, these are intended to be STL-compatible.
-// ***************************************************************************
-
-#ifndef BAMALGORITHMS_H
-#define BAMALGORITHMS_H
-
-#include "api/algorithms/Sort.h"
-
-/*! \namespace BamTools::Algorithms
-    \brief Provides convenient classes & methods for working with BAM data
-*/
-
-#endif // BAM_ALGORITHMS_H
diff --git a/bamtools/src/api/BamAlignment.cpp b/bamtools/src/api/BamAlignment.cpp
deleted file mode 100644
index 620ba2e..0000000
--- a/bamtools/src/api/BamAlignment.cpp
+++ /dev/null
@@ -1,1083 +0,0 @@
-// ***************************************************************************
-// BamAlignment.cpp (c) 2009 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 4 December 2012 (DB)
-// ---------------------------------------------------------------------------
-// Provides the BamAlignment data structure
-// ***************************************************************************
-
-#include "api/BamAlignment.h"
-#include "api/BamConstants.h"
-using namespace BamTools;
-using namespace std;
-
-/*! \class BamTools::BamAlignment
-    \brief The main BAM alignment data structure.
-
-    Provides methods to query/modify BAM alignment data fields.
-*/
-/*! \var BamAlignment::Name
-    \brief read name
-*/
-/*! \var BamAlignment::Length
-    \brief length of query sequence
-*/
-/*! \var BamAlignment::QueryBases
-    \brief 'original' sequence (as reported from sequencing machine)
-
-    \note Setting this field to "*" indicates that the sequence is not to be stored on output.
-    In this case, the contents of the Qualities field should be invalidated as well (cleared or marked as "*").
-*/
-/*! \var BamAlignment::AlignedBases
-    \brief 'aligned' sequence (includes any indels, padding, clipping)
-
-    This field will be completely empty after reading from BamReader/BamMultiReader when
-    QueryBases is empty.
-*/
-/*! \var BamAlignment::Qualities
-    \brief FASTQ qualities (ASCII characters, not numeric values)
-
-    \note Setting this field to "*" indicates to BamWriter that the quality scores are not to be stored,
-    but instead will be output as a sequence of '0xFF'. Otherwise, QueryBases must not be a "*" and
-    the length of this field should equal the length of QueryBases.
-*/
-/*! \var BamAlignment::TagData
-    \brief tag data (use the provided methods to query/modify)
-*/
-/*! \var BamAlignment::RefID
-    \brief ID number for reference sequence
-*/
-/*! \var BamAlignment::Position
-    \brief position (0-based) where alignment starts
-*/
-/*! \var BamAlignment::Bin
-    \brief BAM (standard) index bin number for this alignment
-*/
-/*! \var BamAlignment::MapQuality
-    \brief mapping quality score
-*/
-/*! \var BamAlignment::AlignmentFlag
-    \brief alignment bit-flag (use the provided methods to query/modify)
-*/
-/*! \var BamAlignment::CigarData
-    \brief CIGAR operations for this alignment
-*/
-/*! \var BamAlignment::MateRefID
-    \brief ID number for reference sequence where alignment's mate was aligned
-*/
-/*! \var BamAlignment::MatePosition
-    \brief position (0-based) where alignment's mate starts
-*/
-/*! \var BamAlignment::InsertSize
-    \brief mate-pair insert size
-*/
-/*! \var BamAlignment::Filename
-    \brief name of BAM file which this alignment comes from
-*/
-
-/*! \fn BamAlignment::BamAlignment(void)
-    \brief constructor
-*/
-BamAlignment::BamAlignment(void)
-    : Length(0)
-    , RefID(-1)
-    , Position(-1)
-    , Bin(0)
-    , MapQuality(0)
-    , AlignmentFlag(0)
-    , MateRefID(-1)
-    , MatePosition(-1)
-    , InsertSize(0)
-{ }
-
-/*! \fn BamAlignment::BamAlignment(const BamAlignment& other)
-    \brief copy constructor
-*/
-BamAlignment::BamAlignment(const BamAlignment& other)
-    : Name(other.Name)
-    , Length(other.Length)
-    , QueryBases(other.QueryBases)
-    , AlignedBases(other.AlignedBases)
-    , Qualities(other.Qualities)
-    , TagData(other.TagData)
-    , RefID(other.RefID)
-    , Position(other.Position)
-    , Bin(other.Bin)
-    , MapQuality(other.MapQuality)
-    , AlignmentFlag(other.AlignmentFlag)
-    , CigarData(other.CigarData)
-    , MateRefID(other.MateRefID)
-    , MatePosition(other.MatePosition)
-    , InsertSize(other.InsertSize)
-    , Filename(other.Filename)
-    , SupportData(other.SupportData)
-{ }
-
-/*! \fn BamAlignment::~BamAlignment(void)
-    \brief destructor
-*/
-BamAlignment::~BamAlignment(void) { }
-
-/*! \fn bool BamAlignment::BuildCharData(void)
-    \brief Populates alignment string fields (read name, bases, qualities, tag data).
-
-    An alignment retrieved using BamReader::GetNextAlignmentCore() lacks this data.
-    Using that method makes parsing much quicker when only positional data is required.
-
-    However, if you later want to access the character data fields from such an alignment,
-    use this method to populate those fields. Provides ability to do 'lazy evaluation' of
-    alignment parsing.
-
-    \return \c true if character data populated successfully (or was already available to begin with)
-*/
-bool BamAlignment::BuildCharData(void) {
-
-    // skip if char data already parsed
-    if ( !SupportData.HasCoreOnly )
-        return true;
-
-    // check system endianness
-    bool IsBigEndian = BamTools::SystemIsBigEndian();
-
-    // calculate character lengths/offsets
-    const unsigned int dataLength     = SupportData.BlockLength - Constants::BAM_CORE_SIZE;
-    const unsigned int seqDataOffset  = SupportData.QueryNameLength + (SupportData.NumCigarOperations*4);
-    const unsigned int qualDataOffset = seqDataOffset + (SupportData.QuerySequenceLength+1)/2;
-    const unsigned int tagDataOffset  = qualDataOffset + SupportData.QuerySequenceLength;
-    const unsigned int tagDataLength  = dataLength - tagDataOffset;
-
-    // check offsets to see what char data exists
-    const bool hasSeqData  = ( seqDataOffset  < qualDataOffset );
-    const bool hasQualData = ( qualDataOffset < tagDataOffset );
-    const bool hasTagData  = ( tagDataOffset  < dataLength );
-
-    // store alignment name (relies on null char in name as terminator)
-    Name.assign(SupportData.AllCharData.data());
-
-    // save query sequence
-    QueryBases.clear();
-    if ( hasSeqData ) {
-        const char* seqData = SupportData.AllCharData.data() + seqDataOffset;
-        QueryBases.reserve(SupportData.QuerySequenceLength);
-        for ( size_t i = 0; i < SupportData.QuerySequenceLength; ++i ) {
-            const char singleBase = Constants::BAM_DNA_LOOKUP[ ( (seqData[(i/2)] >> (4*(1-(i%2)))) & 0xf ) ];
-            QueryBases.append(1, singleBase);
-        }
-    }
-
-    // save qualities
-
-    Qualities.clear();
-    if ( hasQualData ) {
-        const char* qualData = SupportData.AllCharData.data() + qualDataOffset;
-
-        // if marked as unstored (sequence of 0xFF) - don't do conversion, just fill with 0xFFs
-        if ( qualData[0] == (char)0xFF )
-            Qualities.resize(SupportData.QuerySequenceLength, (char)0xFF);
-
-        // otherwise convert from numeric QV to 'FASTQ-style' ASCII character
-        else {
-            Qualities.reserve(SupportData.QuerySequenceLength);
-            for ( size_t i = 0; i < SupportData.QuerySequenceLength; ++i )
-                Qualities.append(1, qualData[i]+33);
-        }
-    }
-
-    // clear previous AlignedBases
-    AlignedBases.clear();
-
-    // if QueryBases has data, build AlignedBases using CIGAR data
-    // otherwise, AlignedBases will remain empty (this case IS allowed)
-    if ( !QueryBases.empty() && QueryBases != "*" ) {
-
-        // resize AlignedBases
-        AlignedBases.reserve(SupportData.QuerySequenceLength);
-
-        // iterate over CigarOps
-        int k = 0;
-        vector<CigarOp>::const_iterator cigarIter = CigarData.begin();
-        vector<CigarOp>::const_iterator cigarEnd  = CigarData.end();
-        for ( ; cigarIter != cigarEnd; ++cigarIter ) {
-            const CigarOp& op = (*cigarIter);
-
-            switch ( op.Type ) {
-
-                // for 'M', 'I', '=', 'X' - write bases
-                case (Constants::BAM_CIGAR_MATCH_CHAR)    :
-                case (Constants::BAM_CIGAR_INS_CHAR)      :
-                case (Constants::BAM_CIGAR_SEQMATCH_CHAR) :
-                case (Constants::BAM_CIGAR_MISMATCH_CHAR) :
-                    AlignedBases.append(QueryBases.substr(k, op.Length));
-                    // fall through
-
-                // for 'S' - soft clip, do not write bases
-                // but increment placeholder 'k'
-                case (Constants::BAM_CIGAR_SOFTCLIP_CHAR) :
-                    k += op.Length;
-                    break;
-
-                // for 'D' - write gap character
-                case (Constants::BAM_CIGAR_DEL_CHAR) :
-                    AlignedBases.append(op.Length, Constants::BAM_DNA_DEL);
-                    break;
-
-                // for 'P' - write padding character
-                case (Constants::BAM_CIGAR_PAD_CHAR) :
-                    AlignedBases.append( op.Length, Constants::BAM_DNA_PAD );
-                    break;
-
-                // for 'N' - write N's, skip bases in original query sequence
-                case (Constants::BAM_CIGAR_REFSKIP_CHAR) :
-                    AlignedBases.append( op.Length, Constants::BAM_DNA_N );
-                    break;
-
-                // for 'H' - hard clip, do nothing to AlignedBases, move to next op
-                case (Constants::BAM_CIGAR_HARDCLIP_CHAR) :
-                    break;
-
-                // invalid CIGAR op-code
-                default:
-                    const string message = string("invalid CIGAR operation type: ") + op.Type;
-                    SetErrorString("BamAlignment::BuildCharData", message);
-                    return false;
-            }
-        }
-    }
-
-    // save tag data
-    TagData.clear();
-    if ( hasTagData ) {
-
-        char* tagData = (((char*)SupportData.AllCharData.data()) + tagDataOffset);
-
-        if ( IsBigEndian ) {
-            size_t i = 0;
-            while ( i < tagDataLength ) {
-
-                i += Constants::BAM_TAG_TAGSIZE;  // skip tag chars (e.g. "RG", "NM", etc.)
-                const char type = tagData[i];     // get tag type at position i
-                ++i;                              // move i past tag type
-
-                switch (type) {
-
-                    case(Constants::BAM_TAG_TYPE_ASCII) :
-                    case(Constants::BAM_TAG_TYPE_INT8)  :
-                    case(Constants::BAM_TAG_TYPE_UINT8) :
-                        // no endian swapping necessary for single-byte data
-                        ++i;
-                        break;
-
-                    case(Constants::BAM_TAG_TYPE_INT16)  :
-                    case(Constants::BAM_TAG_TYPE_UINT16) :
-                        BamTools::SwapEndian_16p(&tagData[i]);
-                        i += sizeof(uint16_t);
-                        break;
-
-                    case(Constants::BAM_TAG_TYPE_FLOAT)  :
-                    case(Constants::BAM_TAG_TYPE_INT32)  :
-                    case(Constants::BAM_TAG_TYPE_UINT32) :
-                        BamTools::SwapEndian_32p(&tagData[i]);
-                        i += sizeof(uint32_t);
-                        break;
-
-                    case(Constants::BAM_TAG_TYPE_HEX) :
-                    case(Constants::BAM_TAG_TYPE_STRING) :
-                        // no endian swapping necessary for hex-string/string data
-                        while ( tagData[i] )
-                            ++i;
-                        // increment one more for null terminator
-                        ++i;
-                        break;
-
-                    case(Constants::BAM_TAG_TYPE_ARRAY) :
-
-                    {
-                        // read array type
-                        const char arrayType = tagData[i];
-                        ++i;
-
-                        // swap endian-ness of number of elements in place, then retrieve for loop
-                        BamTools::SwapEndian_32p(&tagData[i]);
-                        uint32_t numElements;
-                        memcpy(&numElements, &tagData[i], sizeof(uint32_t));
-                        i += sizeof(uint32_t);
-
-                        // swap endian-ness of array elements
-                        for ( size_t j = 0; j < numElements; ++j ) {
-                            switch (arrayType) {
-                                case (Constants::BAM_TAG_TYPE_INT8)  :
-                                case (Constants::BAM_TAG_TYPE_UINT8) :
-                                    // no endian-swapping necessary
-                                    ++i;
-                                    break;
-                                case (Constants::BAM_TAG_TYPE_INT16)  :
-                                case (Constants::BAM_TAG_TYPE_UINT16) :
-                                    BamTools::SwapEndian_16p(&tagData[i]);
-                                    i += sizeof(uint16_t);
-                                    break;
-                                case (Constants::BAM_TAG_TYPE_FLOAT)  :
-                                case (Constants::BAM_TAG_TYPE_INT32)  :
-                                case (Constants::BAM_TAG_TYPE_UINT32) :
-                                    BamTools::SwapEndian_32p(&tagData[i]);
-                                    i += sizeof(uint32_t);
-                                    break;
-                                default:
-                                    const string message = string("invalid binary array type: ") + arrayType;
-                                    SetErrorString("BamAlignment::BuildCharData", message);
-                                    return false;
-                            }
-                        }
-
-                        break;
-                    }
-
-                    // invalid tag type-code
-                    default :
-                        const string message = string("invalid tag type: ") + type;
-                        SetErrorString("BamAlignment::BuildCharData", message);
-                        return false;
-                }
-            }
-        }
-
-        // store tagData in alignment
-        TagData.resize(tagDataLength);
-        memcpy((char*)(TagData.data()), tagData, tagDataLength);
-    }
-
-    // clear core-only flag & return success
-    SupportData.HasCoreOnly = false;
-    return true;
-}
-
-/*! \fn bool BamAlignment::FindTag(const std::string& tag, char*& pTagData, const unsigned int& tagDataLength, unsigned int& numBytesParsed) const
-    \internal
-
-    Searches for requested tag in BAM tag data.
-
-    \param[in]     tag            requested 2-character tag name
-    \param[in,out] pTagData       pointer to current position in BamAlignment::TagData
-    \param[in]     tagDataLength  length of BamAlignment::TagData
-    \param[in,out] numBytesParsed number of bytes parsed so far
-
-    \return \c true if found
-
-    \post If \a tag is found, \a pTagData will point to the byte where the tag data begins.
-          \a numBytesParsed will correspond to the position in the full TagData string.
-
-*/
-bool BamAlignment::FindTag(const std::string& tag,
-                           char*& pTagData,
-                           const unsigned int& tagDataLength,
-                           unsigned int& numBytesParsed) const
-{
-
-    while ( numBytesParsed < tagDataLength ) {
-
-        const char* pTagType        = pTagData;
-        const char* pTagStorageType = pTagData + 2;
-        pTagData       += 3;
-        numBytesParsed += 3;
-
-        // check the current tag, return true on match
-        if ( strncmp(pTagType, tag.c_str(), 2) == 0 )
-            return true;
-
-        // get the storage class and find the next tag
-        if ( *pTagStorageType == '\0' ) return false;
-        if ( !SkipToNextTag(*pTagStorageType, pTagData, numBytesParsed) ) return false;
-        if ( *pTagData == '\0' ) return false;
-    }
-
-    // checked all tags, none match
-    return false;
-}
-
-/*! \fn bool BamAlignment::GetArrayTagType(const std::string& tag, char& type) const
-    \brief Retrieves the BAM tag type-code for the array elements associated with requested tag name.
-
-    \param[in]  tag  2-character tag name
-    \param[out] type retrieved (1-character) type-code
-
-    \return \c true if found. False if not found, or if tag is not an array type.
-    \sa \samSpecURL for more details on reserved tag names, supported tag types, etc.
-*/
-bool BamAlignment::GetArrayTagType(const std::string& tag, char& type) const {
-
-    // skip if alignment is core-only
-    if ( SupportData.HasCoreOnly ) {
-        // TODO: set error string?
-        return false;
-    }
-
-    // skip if no tags present
-    if ( TagData.empty() ) {
-        // TODO: set error string?
-        return false;
-    }
-
-    // localize the tag data
-    char* pTagData = (char*)TagData.data();
-    const unsigned int tagDataLength = TagData.size();
-    unsigned int numBytesParsed = 0;
-
-    // if tag not found, return failure
-    if ( !FindTag(tag, pTagData, tagDataLength, numBytesParsed) ){
-        // TODO: set error string?
-        return false;
-    }
-
-    // check that tag type code is array
-    type = *(pTagData - 1);
-    if ( type != Constants::BAM_TAG_TYPE_ARRAY ) {
-        // TODO: set error string
-        return false;
-    }
-
-    // fetch element type
-    const char elementType = *pTagData;
-    switch ( elementType ) {
-
-        // allowable types
-        case (Constants::BAM_TAG_TYPE_INT8)   :
-        case (Constants::BAM_TAG_TYPE_UINT8)  :
-        case (Constants::BAM_TAG_TYPE_INT16)  :
-        case (Constants::BAM_TAG_TYPE_UINT16) :
-        case (Constants::BAM_TAG_TYPE_INT32)  :
-        case (Constants::BAM_TAG_TYPE_UINT32) :
-        case (Constants::BAM_TAG_TYPE_FLOAT)  :
-            type = elementType;
-            break;
-
-        default:
-            //TODO: set error string
-            return false;
-    }
-
-    // if we get here, return success
-    return true;
-}
-
-
-/*! \fn int BamAlignment::GetEndPosition(bool usePadded = false, bool closedInterval = false) const
-    \brief Calculates alignment end position, based on its starting position and CIGAR data.
-
-    \warning The position returned now represents a zero-based, HALF-OPEN interval.
-    In previous versions of BamTools (0.x & 1.x) all intervals were treated
-    as zero-based, CLOSED.
-
-    \param[in] usePadded      Allow inserted bases to affect the reported position. Default is
-                              false, so that reported position stays synced with reference
-                              coordinates.
-    \param[in] closedInterval Setting this to true will return a 0-based end coordinate. Default is
-                              false, so that his value represents a standard, half-open interval.
-
-    \return alignment end position
-*/
-int BamAlignment::GetEndPosition(bool usePadded, bool closedInterval) const {
-
-    // initialize alignment end to starting position
-    int alignEnd = Position;
-
-    // iterate over cigar operations
-    vector<CigarOp>::const_iterator cigarIter = CigarData.begin();
-    vector<CigarOp>::const_iterator cigarEnd  = CigarData.end();
-    for ( ; cigarIter != cigarEnd; ++cigarIter) {
-        const CigarOp& op = (*cigarIter);
-
-        switch ( op.Type ) {
-
-            // increase end position on CIGAR chars [DMXN=]
-            case Constants::BAM_CIGAR_DEL_CHAR      :
-            case Constants::BAM_CIGAR_MATCH_CHAR    :
-            case Constants::BAM_CIGAR_MISMATCH_CHAR :
-            case Constants::BAM_CIGAR_REFSKIP_CHAR  :
-            case Constants::BAM_CIGAR_SEQMATCH_CHAR :
-                alignEnd += op.Length;
-                break;
-
-            // increase end position on insertion, only if @usePadded is true
-            case Constants::BAM_CIGAR_INS_CHAR :
-                if ( usePadded )
-                    alignEnd += op.Length;
-                break;
-
-            // all other CIGAR chars do not affect end position
-            default :
-                break;
-        }
-    }
-
-    // adjust for closedInterval, if requested
-    if ( closedInterval )
-        alignEnd -= 1;
-
-    // return result
-    return alignEnd;
-}
-
-/*! \fn std::string BamAlignment::GetErrorString(void) const
-    \brief Returns a human-readable description of the last error that occurred
-
-    This method allows elimination of STDERR pollution. Developers of client code
-    may choose how the messages are displayed to the user, if at all.
-
-    \return error description
-*/
-std::string BamAlignment::GetErrorString(void) const {
-    return ErrorString;
-}
-
-/*! \fn bool BamAlignment::GetSoftClips(std::vector<int>& clipSizes, std::vector<int>& readPositions, std::vector<int>& genomePositions, bool usePadded = false) const
-    \brief Identifies if an alignment has a soft clip. If so, identifies the
-           sizes of the soft clips, as well as their positions in the read and reference.
-
-    \param[out] clipSizes       vector of the sizes of each soft clip in the alignment
-    \param[out] readPositions   vector of the 0-based read locations of each soft clip in the alignment.
-                                These positions are basically indexes within the read, not genomic positions.
-    \param[out] genomePositions vector of the 0-based genome locations of each soft clip in the alignment
-    \param[in]  usePadded       inserted bases affect reported position. Default is false, so that
-                                reported position stays 'sync-ed' with reference coordinates.
-
-    \return \c true if any soft clips were found in the alignment
-*/
-bool BamAlignment::GetSoftClips(vector<int>& clipSizes,
-                                vector<int>& readPositions,
-                                vector<int>& genomePositions,
-                                bool usePadded) const
-{
-    // initialize positions & flags
-    int refPosition  = Position;
-    int readPosition = 0;
-    bool softClipFound = false;
-    bool firstCigarOp  = true;
-
-    // iterate over cigar operations
-    vector<CigarOp>::const_iterator cigarIter = CigarData.begin();
-    vector<CigarOp>::const_iterator cigarEnd  = CigarData.end();
-    for ( ; cigarIter != cigarEnd; ++cigarIter) {
-        const CigarOp& op = (*cigarIter);
-
-        switch ( op.Type ) {
-
-            // increase both read & genome positions on CIGAR chars [DMXN=]
-            case Constants::BAM_CIGAR_DEL_CHAR      :
-            case Constants::BAM_CIGAR_MATCH_CHAR    :
-            case Constants::BAM_CIGAR_MISMATCH_CHAR :
-            case Constants::BAM_CIGAR_REFSKIP_CHAR  :
-            case Constants::BAM_CIGAR_SEQMATCH_CHAR :
-                refPosition  += op.Length;
-                readPosition += op.Length;
-                break;
-
-            // increase read position on insertion, genome position only if @usePadded is true
-            case Constants::BAM_CIGAR_INS_CHAR :
-                readPosition += op.Length;
-                if ( usePadded )
-                    refPosition += op.Length;
-                break;
-
-            case Constants::BAM_CIGAR_SOFTCLIP_CHAR :
-
-                softClipFound = true;
-
-                //////////////////////////////////////////////////////////////////////////////
-                // if we are dealing with the *first* CIGAR operation
-                // for this alignment, we increment the read position so that
-                // the read and genome position of the clip are referring to the same base.
-                // For example, in the alignment below, the ref position would be 4, yet
-                //              the read position would be 0. Thus, to "sync" the two,
-                //              we need to increment the read position by the length of the
-                //              soft clip.
-                // Read:  ATCGTTTCGTCCCTGC
-                // Ref:   GGGATTTCGTCCCTGC
-                // Cigar: SSSSMMMMMMMMMMMM
-                //
-                // NOTE: This only needs to be done if the soft clip is the _first_ CIGAR op.
-                //////////////////////////////////////////////////////////////////////////////
-                if ( firstCigarOp )
-                    readPosition += op.Length;
-
-                // track the soft clip's size, read position, and genome position
-                clipSizes.push_back(op.Length);
-                readPositions.push_back(readPosition);
-                genomePositions.push_back(refPosition);
-
-            // any other CIGAR operations have no effect
-            default :
-                break;
-        }
-
-        // clear our "first pass" flag
-        firstCigarOp = false;
-    }
-
-    // return whether any soft clips found
-    return softClipFound;
-}
-
-/*! \fn std::vector<std::string> BamAlignment::GetTagNames(void) const
-    \brief Retrieves the BAM tag names.
-
-    When paired with GetTagType() and GetTag(), this method allows you
-    to iterate over an alignment's tag data without knowing the names (or types)
-    beforehand.
-
-    \return \c vector containing all tag names found (empty if none available)
-    \sa \samSpecURL for more details on reserved tag names, supported tag types, etc.
-*/
-std::vector<std::string> BamAlignment::GetTagNames(void) const {
-
-    std::vector<std::string> result;
-    if ( SupportData.HasCoreOnly || TagData.empty() )
-        return result;
-
-    char* pTagData = (char*)TagData.data();
-    const unsigned int tagDataLength = TagData.size();
-    unsigned int numBytesParsed = 0;
-    while ( numBytesParsed < tagDataLength ) {
-
-        // get current tag name & type
-        const char* pTagName = pTagData;
-        const char* pTagType = pTagData + 2;
-        pTagData       += 3;
-        numBytesParsed +=3;
-
-        // store tag name
-        result.push_back( std::string(pTagName, 2)  );
-
-        // find the next tag
-        if ( *pTagType == '\0' ) break;
-        if ( !SkipToNextTag(*pTagType, pTagData, numBytesParsed) ) break;
-        if ( *pTagData == '\0' ) break;
-    }
-
-    return result;
-}
-
-/*! \fn bool BamAlignment::GetTagType(const std::string& tag, char& type) const
-    \brief Retrieves the BAM tag type-code associated with requested tag name.
-
-    \param[in]  tag  2-character tag name
-    \param[out] type retrieved (1-character) type-code
-
-    \return \c true if found
-    \sa \samSpecURL for more details on reserved tag names, supported tag types, etc.
-*/
-bool BamAlignment::GetTagType(const std::string& tag, char& type) const {
-  
-    // skip if alignment is core-only
-    if ( SupportData.HasCoreOnly ) {
-        // TODO: set error string?
-        return false;
-    }
-
-    // skip if no tags present
-    if ( TagData.empty() ) {
-        // TODO: set error string?
-        return false;
-    }
-
-    // localize the tag data
-    char* pTagData = (char*)TagData.data();
-    const unsigned int tagDataLength = TagData.size();
-    unsigned int numBytesParsed = 0;
-    
-    // if tag not found, return failure
-    if ( !FindTag(tag, pTagData, tagDataLength, numBytesParsed) ){
-        // TODO: set error string?
-        return false;
-    }
-
-    // otherwise, retrieve & validate tag type code
-    type = *(pTagData - 1);
-    switch ( type ) {
-        case (Constants::BAM_TAG_TYPE_ASCII)  :
-        case (Constants::BAM_TAG_TYPE_INT8)   :
-        case (Constants::BAM_TAG_TYPE_UINT8)  :
-        case (Constants::BAM_TAG_TYPE_INT16)  :
-        case (Constants::BAM_TAG_TYPE_UINT16) :
-        case (Constants::BAM_TAG_TYPE_INT32)  :
-        case (Constants::BAM_TAG_TYPE_UINT32) :
-        case (Constants::BAM_TAG_TYPE_FLOAT)  :
-        case (Constants::BAM_TAG_TYPE_STRING) :
-        case (Constants::BAM_TAG_TYPE_HEX)    :
-        case (Constants::BAM_TAG_TYPE_ARRAY)  :
-            return true;
-
-        // unknown tag type
-        default:
-            const string message = string("invalid tag type: ") + type;
-            SetErrorString("BamAlignment::GetTagType", message);
-            return false;
-    }
-}
-
-/*! \fn bool BamAlignment::HasTag(const std::string& tag) const
-    \brief Returns true if alignment has a record for requested tag.
-
-    \param[in] tag 2-character tag name
-    \return \c true if alignment has a record for tag
-*/
-bool BamAlignment::HasTag(const std::string& tag) const {
-
-    // return false if no tag data present
-    if ( SupportData.HasCoreOnly || TagData.empty() )
-        return false;
-
-    // localize the tag data for lookup
-    char* pTagData = (char*)TagData.data();
-    const unsigned int tagDataLength = TagData.size();
-    unsigned int numBytesParsed = 0;
-
-    // if result of tag lookup
-    return FindTag(tag, pTagData, tagDataLength, numBytesParsed);
-}
-
-/*! \fn bool BamAlignment::IsDuplicate(void) const
-    \return \c true if this read is a PCR duplicate
-*/
-bool BamAlignment::IsDuplicate(void) const {
-    return ( (AlignmentFlag & Constants::BAM_ALIGNMENT_DUPLICATE) != 0 );
-}
-
-/*! \fn bool BamAlignment::IsFailedQC(void) const
-    \return \c true if this read failed quality control
-*/
-bool BamAlignment::IsFailedQC(void) const {
-    return ( (AlignmentFlag & Constants::BAM_ALIGNMENT_QC_FAILED) != 0 );
-}
-
-/*! \fn bool BamAlignment::IsFirstMate(void) const
-    \return \c true if alignment is first mate on paired-end read
-*/
-bool BamAlignment::IsFirstMate(void) const {
-    return ( (AlignmentFlag & Constants::BAM_ALIGNMENT_READ_1) != 0 );
-}
-
-/*! \fn bool BamAlignment::IsMapped(void) const
-    \return \c true if alignment is mapped
-*/
-bool BamAlignment::IsMapped(void) const {
-    return ( (AlignmentFlag & Constants::BAM_ALIGNMENT_UNMAPPED) == 0 );
-}
-
-/*! \fn bool BamAlignment::IsMateMapped(void) const
-    \return \c true if alignment's mate is mapped
-*/
-bool BamAlignment::IsMateMapped(void) const {
-    return ( (AlignmentFlag & Constants::BAM_ALIGNMENT_MATE_UNMAPPED) == 0 );
-}
-
-/*! \fn bool BamAlignment::IsMateReverseStrand(void) const
-    \return \c true if alignment's mate mapped to reverse strand
-*/
-bool BamAlignment::IsMateReverseStrand(void) const {
-    return ( (AlignmentFlag & Constants::BAM_ALIGNMENT_MATE_REVERSE_STRAND) != 0 );
-}
-
-/*! \fn bool BamAlignment::IsPaired(void) const
-    \return \c true if alignment part of paired-end read
-*/
-bool BamAlignment::IsPaired(void) const {
-    return ( (AlignmentFlag & Constants::BAM_ALIGNMENT_PAIRED) != 0 );
-}
-
-/*! \fn bool BamAlignment::IsPrimaryAlignment(void) const
-    \return \c true if reported position is primary alignment
-*/
-bool BamAlignment::IsPrimaryAlignment(void) const  {
-    return ( (AlignmentFlag & Constants::BAM_ALIGNMENT_SECONDARY) == 0 );
-}
-
-/*! \fn bool BamAlignment::IsProperPair(void) const
-    \return \c true if alignment is part of read that satisfied paired-end resolution
-*/
-bool BamAlignment::IsProperPair(void) const {
-    return ( (AlignmentFlag & Constants::BAM_ALIGNMENT_PROPER_PAIR) != 0 );
-}
-
-/*! \fn bool BamAlignment::IsReverseStrand(void) const
-    \return \c true if alignment mapped to reverse strand
-*/
-bool BamAlignment::IsReverseStrand(void) const {
-    return ( (AlignmentFlag & Constants::BAM_ALIGNMENT_REVERSE_STRAND) != 0 );
-}
-
-/*! \fn bool BamAlignment::IsSecondMate(void) const
-    \return \c true if alignment is second mate on read
-*/
-bool BamAlignment::IsSecondMate(void) const {
-    return ( (AlignmentFlag & Constants::BAM_ALIGNMENT_READ_2) != 0 );
-}
-
-/*! \fn bool BamAlignment::IsValidSize(const std::string& tag, const std::string& type) const
-    \internal
-
-    Checks that tag name & type strings are expected sizes.
-
-    \param tag[in]  BAM tag name
-    \param type[in] BAM tag type-code
-    \return \c true if both input strings are valid sizes
-*/
-bool BamAlignment::IsValidSize(const std::string& tag, const std::string& type) const {
-    return (tag.size()  == Constants::BAM_TAG_TAGSIZE) &&
-           (type.size() == Constants::BAM_TAG_TYPESIZE);
-}
-
-/*! \fn void BamAlignment::RemoveTag(const std::string& tag)
-    \brief Removes field from BAM tags.
-
-    \param[in] tag 2-character name of field to remove
-*/
-void BamAlignment::RemoveTag(const std::string& tag) {
-  
-    // if char data not populated, do that first
-    if ( SupportData.HasCoreOnly )
-        BuildCharData();
-
-    // skip if no tags available
-    if ( TagData.empty() )
-        return;
-  
-    // localize the tag data
-    char* pOriginalTagData = (char*)TagData.data();
-    char* pTagData = pOriginalTagData;
-    const unsigned int originalTagDataLength = TagData.size();
-    unsigned int newTagDataLength = 0;
-    unsigned int numBytesParsed = 0;
-
-    // skip if tag not found
-    if  ( !FindTag(tag, pTagData, originalTagDataLength, numBytesParsed) )
-        return;
-
-    // otherwise, remove it
-    RaiiBuffer newTagData(originalTagDataLength);
-
-    // copy original tag data up til desired tag
-    pTagData       -= 3;
-    numBytesParsed -= 3;
-    const unsigned int beginningTagDataLength = numBytesParsed;
-    newTagDataLength += beginningTagDataLength;
-    memcpy(newTagData.Buffer, pOriginalTagData, numBytesParsed);
-
-    // attemp to skip to next tag
-    const char* pTagStorageType = pTagData + 2;
-    pTagData       += 3;
-    numBytesParsed += 3;
-    if ( SkipToNextTag(*pTagStorageType, pTagData, numBytesParsed) ) {
-
-        // squeeze remaining tag data
-        const unsigned int skippedDataLength = (numBytesParsed - beginningTagDataLength);
-        const unsigned int endTagDataLength = originalTagDataLength - beginningTagDataLength - skippedDataLength;
-        memcpy(newTagData.Buffer + beginningTagDataLength, pTagData, endTagDataLength );
-
-        // save modified tag data in alignment
-        TagData.assign(newTagData.Buffer, beginningTagDataLength + endTagDataLength);
-    }
-}
-
-/*! \fn void BamAlignment::SetErrorString(const std::string& where, const std::string& what) const
-    \internal
-
-    Sets a formatted error string for this alignment.
-
-    \param[in] where class/method where error occurred
-    \param[in] what  description of error
-*/
-void BamAlignment::SetErrorString(const std::string& where, const std::string& what) const {
-    static const string SEPARATOR = ": ";
-    ErrorString = where + SEPARATOR + what;
-}
-
-/*! \fn void BamAlignment::SetIsDuplicate(bool ok)
-    \brief Sets value of "PCR duplicate" flag to \a ok.
-*/
-void BamAlignment::SetIsDuplicate(bool ok) {
-    if (ok) AlignmentFlag |=  Constants::BAM_ALIGNMENT_DUPLICATE;
-    else    AlignmentFlag &= ~Constants::BAM_ALIGNMENT_DUPLICATE;
-}
-
-/*! \fn void BamAlignment::SetIsFailedQC(bool ok)
-    \brief Sets "failed quality control" flag to \a ok.
-*/
-void BamAlignment::SetIsFailedQC(bool ok) {
-    if (ok) AlignmentFlag |=  Constants::BAM_ALIGNMENT_QC_FAILED;
-    else    AlignmentFlag &= ~Constants::BAM_ALIGNMENT_QC_FAILED;
-}
-
-/*! \fn void BamAlignment::SetIsFirstMate(bool ok)
-    \brief Sets "alignment is first mate" flag to \a ok.
-*/
-void BamAlignment::SetIsFirstMate(bool ok) {
-    if (ok) AlignmentFlag |=  Constants::BAM_ALIGNMENT_READ_1;
-    else    AlignmentFlag &= ~Constants::BAM_ALIGNMENT_READ_1;
-}
-
-/*! \fn void BamAlignment::SetIsMapped(bool ok)
-    \brief Sets "alignment is mapped" flag to \a ok.
-*/
-void BamAlignment::SetIsMapped(bool ok) {
-    if (ok) AlignmentFlag &= ~Constants::BAM_ALIGNMENT_UNMAPPED;
-    else    AlignmentFlag |=  Constants::BAM_ALIGNMENT_UNMAPPED;
-}
-
-/*! \fn void BamAlignment::SetIsMateMapped(bool ok)
-    \brief Sets "alignment's mate is mapped" flag to \a ok.
-*/
-void BamAlignment::SetIsMateMapped(bool ok) {
-    if (ok) AlignmentFlag &= ~Constants::BAM_ALIGNMENT_MATE_UNMAPPED;
-    else    AlignmentFlag |=  Constants::BAM_ALIGNMENT_MATE_UNMAPPED;
-}
-
-/*! \fn void BamAlignment::SetIsMateReverseStrand(bool ok)
-    \brief Sets "alignment's mate mapped to reverse strand" flag to \a ok.
-*/
-void BamAlignment::SetIsMateReverseStrand(bool ok) {
-    if (ok) AlignmentFlag |=  Constants::BAM_ALIGNMENT_MATE_REVERSE_STRAND;
-    else    AlignmentFlag &= ~Constants::BAM_ALIGNMENT_MATE_REVERSE_STRAND;
-}
-
-/*! \fn void BamAlignment::SetIsPaired(bool ok)
-    \brief Sets "alignment part of paired-end read" flag to \a ok.
-*/
-void BamAlignment::SetIsPaired(bool ok) {
-    if (ok) AlignmentFlag |=  Constants::BAM_ALIGNMENT_PAIRED;
-    else    AlignmentFlag &= ~Constants::BAM_ALIGNMENT_PAIRED;
-}
-
-/*! \fn void BamAlignment::SetIsPrimaryAlignment(bool ok)
-    \brief Sets "position is primary alignment" flag to \a ok.
-*/
-void BamAlignment::SetIsPrimaryAlignment(bool ok) {
-    if (ok) AlignmentFlag &= ~Constants::BAM_ALIGNMENT_SECONDARY;
-    else    AlignmentFlag |=  Constants::BAM_ALIGNMENT_SECONDARY;
-}
-
-/*! \fn void BamAlignment::SetIsProperPair(bool ok)
-    \brief Sets "alignment is part of read that satisfied paired-end resolution" flag to \a ok.
-*/
-void BamAlignment::SetIsProperPair(bool ok) {
-    if (ok) AlignmentFlag |=  Constants::BAM_ALIGNMENT_PROPER_PAIR;
-    else    AlignmentFlag &= ~Constants::BAM_ALIGNMENT_PROPER_PAIR;
-}
-
-/*! \fn void BamAlignment::SetIsReverseStrand(bool ok)
-    \brief Sets "alignment mapped to reverse strand" flag to \a ok.
-*/
-void BamAlignment::SetIsReverseStrand(bool ok) {
-    if (ok) AlignmentFlag |=  Constants::BAM_ALIGNMENT_REVERSE_STRAND;
-    else    AlignmentFlag &= ~Constants::BAM_ALIGNMENT_REVERSE_STRAND;
-}
-
-/*! \fn void BamAlignment::SetIsSecondMate(bool ok)
-    \brief Sets "alignment is second mate on read" flag to \a ok.
-*/
-void BamAlignment::SetIsSecondMate(bool ok) {
-    if (ok) AlignmentFlag |=  Constants::BAM_ALIGNMENT_READ_2;
-    else    AlignmentFlag &= ~Constants::BAM_ALIGNMENT_READ_2;
-}
-
-/*! \fn bool BamAlignment::SkipToNextTag(const char storageType, char*& pTagData, unsigned int& numBytesParsed) const
-    \internal
-
-    Moves to next available tag in tag data string
-
-    \param[in]     storageType    BAM tag type-code that determines how far to move cursor
-    \param[in,out] pTagData       pointer to current position (cursor) in tag string
-    \param[in,out] numBytesParsed report of how many bytes were parsed (cumulatively)
-
-    \return \c if storageType was a recognized BAM tag type
-
-    \post \a pTagData       will point to the byte where the next tag data begins.
-          \a numBytesParsed will correspond to the cursor's position in the full TagData string.
-*/
-bool BamAlignment::SkipToNextTag(const char storageType,
-                                 char*& pTagData,
-                                 unsigned int& numBytesParsed) const
-{
-    switch (storageType) {
-
-        case (Constants::BAM_TAG_TYPE_ASCII) :
-        case (Constants::BAM_TAG_TYPE_INT8)  :
-        case (Constants::BAM_TAG_TYPE_UINT8) :
-            ++numBytesParsed;
-            ++pTagData;
-            break;
-
-        case (Constants::BAM_TAG_TYPE_INT16)  :
-        case (Constants::BAM_TAG_TYPE_UINT16) :
-            numBytesParsed += sizeof(uint16_t);
-            pTagData       += sizeof(uint16_t);
-            break;
-
-        case (Constants::BAM_TAG_TYPE_FLOAT)  :
-        case (Constants::BAM_TAG_TYPE_INT32)  :
-        case (Constants::BAM_TAG_TYPE_UINT32) :
-            numBytesParsed += sizeof(uint32_t);
-            pTagData       += sizeof(uint32_t);
-            break;
-
-        case (Constants::BAM_TAG_TYPE_STRING) :
-        case (Constants::BAM_TAG_TYPE_HEX)    :
-            while( *pTagData ) {
-                ++numBytesParsed;
-                ++pTagData;
-            }
-            // increment for null-terminator
-            ++numBytesParsed;
-            ++pTagData;
-            break;
-
-        case (Constants::BAM_TAG_TYPE_ARRAY) :
-
-        {
-            // read array type
-            const char arrayType = *pTagData;
-            ++numBytesParsed;
-            ++pTagData;
-
-            // read number of elements
-            int32_t numElements;
-            memcpy(&numElements, pTagData, sizeof(uint32_t)); // already endian-swapped, if needed
-            numBytesParsed += sizeof(uint32_t);
-            pTagData       += sizeof(uint32_t);
-
-            // calculate number of bytes to skip
-            int bytesToSkip = 0;
-            switch (arrayType) {
-                case (Constants::BAM_TAG_TYPE_INT8)  :
-                case (Constants::BAM_TAG_TYPE_UINT8) :
-                    bytesToSkip = numElements;
-                    break;
-                case (Constants::BAM_TAG_TYPE_INT16)  :
-                case (Constants::BAM_TAG_TYPE_UINT16) :
-                    bytesToSkip = numElements*sizeof(uint16_t);
-                    break;
-                case (Constants::BAM_TAG_TYPE_FLOAT)  :
-                case (Constants::BAM_TAG_TYPE_INT32)  :
-                case (Constants::BAM_TAG_TYPE_UINT32) :
-                    bytesToSkip = numElements*sizeof(uint32_t);
-                    break;
-                default:
-                    const string message = string("invalid binary array type: ") + arrayType;
-                    SetErrorString("BamAlignment::SkipToNextTag", message);
-                    return false;
-            }
-
-            // skip binary array contents
-            numBytesParsed += bytesToSkip;
-            pTagData       += bytesToSkip;
-            break;
-        }
-
-        default:
-            const string message = string("invalid tag type: ") + storageType;
-            SetErrorString("BamAlignment::SkipToNextTag", message);
-            return false;
-    }
-
-    // if we get here, tag skipped OK - return success
-    return true;
-}
diff --git a/bamtools/src/api/BamAlignment.h b/bamtools/src/api/BamAlignment.h
deleted file mode 100644
index 0f4fe73..0000000
--- a/bamtools/src/api/BamAlignment.h
+++ /dev/null
@@ -1,638 +0,0 @@
-// ***************************************************************************
-// BamAlignment.h (c) 2009 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 25 July 2013 (DB)
-// ---------------------------------------------------------------------------
-// Provides the BamAlignment data structure
-// ***************************************************************************
-
-#ifndef BAMALIGNMENT_H
-#define BAMALIGNMENT_H
-
-#include "api/api_global.h"
-#include "api/BamAux.h"
-#include "api/BamConstants.h"
-#include <cstdlib>
-#include <cstring>
-#include <string>
-#include <vector>
-
-namespace BamTools {
-
-//! \cond
-// forward declaration of BamAlignment's "friends"
-namespace Internal {
-    class BamReaderPrivate;
-    class BamWriterPrivate;
-} // namespace Internal
-//! \endcond
-
-// BamAlignment data structure
-struct API_EXPORT BamAlignment {
-
-    // constructors & destructor
-    public:
-        BamAlignment(void);
-        BamAlignment(const BamAlignment& other);
-        ~BamAlignment(void);
-
-    // queries against alignment flags
-    public:        
-        bool IsDuplicate(void) const;         // returns true if this read is a PCR duplicate
-        bool IsFailedQC(void) const;          // returns true if this read failed quality control
-        bool IsFirstMate(void) const;         // returns true if alignment is first mate on read
-        bool IsMapped(void) const;            // returns true if alignment is mapped
-        bool IsMateMapped(void) const;        // returns true if alignment's mate is mapped
-        bool IsMateReverseStrand(void) const; // returns true if alignment's mate mapped to reverse strand
-        bool IsPaired(void) const;            // returns true if alignment part of paired-end read
-        bool IsPrimaryAlignment(void) const;  // returns true if reported position is primary alignment
-        bool IsProperPair(void) const;        // returns true if alignment is part of read that satisfied paired-end resolution
-        bool IsReverseStrand(void) const;     // returns true if alignment mapped to reverse strand
-        bool IsSecondMate(void) const;        // returns true if alignment is second mate on read
-
-    // manipulate alignment flags
-    public:        
-        void SetIsDuplicate(bool ok);         // sets value of "PCR duplicate" flag
-        void SetIsFailedQC(bool ok);          // sets value of "failed quality control" flag
-        void SetIsFirstMate(bool ok);         // sets value of "alignment is first mate" flag
-        void SetIsMapped(bool ok);            // sets value of "alignment is mapped" flag
-        void SetIsMateMapped(bool ok);        // sets value of "alignment's mate is mapped" flag
-        void SetIsMateReverseStrand(bool ok); // sets value of "alignment's mate mapped to reverse strand" flag
-        void SetIsPaired(bool ok);            // sets value of "alignment part of paired-end read" flag
-        void SetIsPrimaryAlignment(bool ok);  // sets value of "position is primary alignment" flag
-        void SetIsProperPair(bool ok);        // sets value of "alignment is part of read that satisfied paired-end resolution" flag
-        void SetIsReverseStrand(bool ok);     // sets value of "alignment mapped to reverse strand" flag
-        void SetIsSecondMate(bool ok);        // sets value of "alignment is second mate on read" flag
-
-    // tag data access methods
-    public:
-
-        // add a new tag
-        template<typename T> bool AddTag(const std::string& tag, const std::string& type, const T& value);
-        template<typename T> bool AddTag(const std::string& tag, const std::vector<T>& values);
-
-        // edit (or append) tag
-        template<typename T> bool EditTag(const std::string& tag, const std::string& type, const T& value);
-        template<typename T> bool EditTag(const std::string& tag, const std::vector<T>& values);
-
-        // retrieves tag data
-        template<typename T> bool GetTag(const std::string& tag, T& destination) const;
-        template<typename T> bool GetTag(const std::string& tag, std::vector<T>& destination) const;
-
-        // retrieves all current tag names
-        std::vector<std::string> GetTagNames(void) const;
-
-        // retrieves the SAM/BAM type-code for requested tag name
-        bool GetTagType(const std::string& tag, char& type) const;
-
-        // retrieves the SAM/BAM type-code for the data elements in an array tag
-        bool GetArrayTagType(const std::string& tag, char& type) const;
-
-        // returns true if alignment has a record for this tag name
-        bool HasTag(const std::string& tag) const;
-
-        // removes a tag
-        void RemoveTag(const std::string& tag);
-
-    // additional methods
-    public:
-        // populates alignment string fields
-        bool BuildCharData(void);
-
-        // calculates alignment end position
-        int GetEndPosition(bool usePadded = false, bool closedInterval = false) const;
-
-        // returns a description of the last error that occurred
-        std::string GetErrorString(void) const;
-
-        // retrieves the size, read locations and reference locations of soft-clip operations
-        bool GetSoftClips(std::vector<int>& clipSizes,
-                          std::vector<int>& readPositions,
-                          std::vector<int>& genomePositions,
-                          bool usePadded = false) const;
-
-    // public data fields
-    public:
-        std::string Name;               // read name
-        int32_t     Length;             // length of query sequence
-        std::string QueryBases;         // 'original' sequence (contained in BAM file)
-        std::string AlignedBases;       // 'aligned' sequence (QueryBases plus deletion, padding, clipping chars)
-        std::string Qualities;          // FASTQ qualities (ASCII characters, not numeric values)
-        std::string TagData;            // tag data (use provided methods to query/modify)
-        int32_t     RefID;              // ID number for reference sequence
-        int32_t     Position;           // position (0-based) where alignment starts
-        uint16_t    Bin;                // BAM (standard) index bin number for this alignment
-        uint16_t    MapQuality;         // mapping quality score
-        uint32_t    AlignmentFlag;      // alignment bit-flag (use provided methods to query/modify)
-        std::vector<CigarOp> CigarData; // CIGAR operations for this alignment
-        int32_t     MateRefID;          // ID number for reference sequence where alignment's mate was aligned
-        int32_t     MatePosition;       // position (0-based) where alignment's mate starts
-        int32_t     InsertSize;         // mate-pair insert size
-        std::string Filename;           // name of BAM file which this alignment comes from
-
-    //! \internal
-    // internal utility methods
-    private:
-        bool FindTag(const std::string& tag,
-                     char*& pTagData,
-                     const unsigned int& tagDataLength,
-                     unsigned int& numBytesParsed) const;
-        bool IsValidSize(const std::string& tag, const std::string& type) const;
-        void SetErrorString(const std::string& where, const std::string& what) const;
-        bool SkipToNextTag(const char storageType,
-                           char*& pTagData,
-                           unsigned int& numBytesParsed) const;
-
-    // internal data
-    private:
-
-        struct BamAlignmentSupportData {
-      
-            // data members
-            std::string AllCharData;
-            uint32_t    BlockLength;
-            uint32_t    NumCigarOperations;
-            uint32_t    QueryNameLength;
-            uint32_t    QuerySequenceLength;
-            bool        HasCoreOnly;
-            
-            // constructor
-            BamAlignmentSupportData(void)
-                : BlockLength(0)
-                , NumCigarOperations(0)
-                , QueryNameLength(0)
-                , QuerySequenceLength(0)
-                , HasCoreOnly(false)
-            { }
-        };
-        BamAlignmentSupportData SupportData;
-        friend class Internal::BamReaderPrivate;
-        friend class Internal::BamWriterPrivate;
-
-        mutable std::string ErrorString; // mutable to allow updates even in logically const methods
-    //! \endinternal
-};
-
-// ---------------------------------------------------------
-// BamAlignment tag access methods
-
-/*! \fn bool AddTag(const std::string& tag, const std::string& type, const T& value)
-    \brief Adds a field to the BAM tags.
-
-    Does NOT modify an existing tag - use \link BamAlignment::EditTag() \endlink instead.
-
-    \param[in] tag   2-character tag name
-    \param[in] type  1-character tag type
-    \param[in] value data to store
-    \return \c true if the \b new tag was added successfully
-    \sa \samSpecURL for more details on reserved tag names, supported tag types, etc.
-*/
-template<typename T>
-inline bool BamAlignment::AddTag(const std::string& tag, const std::string& type, const T& value) {
-
-    // if char data not populated, do that first
-    if ( SupportData.HasCoreOnly )
-        BuildCharData();
-
-    // check tag/type size
-    if ( !IsValidSize(tag, type) ) {
-        // TODO: set error string?
-        return false;
-    }
-
-    // check that storage type code is OK for T
-    if ( !TagTypeHelper<T>::CanConvertTo(type.at(0)) ) {
-        // TODO: set error string?
-        return false;
-    }
-
-    // localize the tag data
-    char* pTagData = (char*)TagData.data();
-    const unsigned int tagDataLength = TagData.size();
-    unsigned int numBytesParsed = 0;
-
-    // if tag already exists, return false
-    // use EditTag explicitly instead
-    if ( FindTag(tag, pTagData, tagDataLength, numBytesParsed) ) {
-        // TODO: set error string?
-        return false;
-    }
-
-    // otherwise, convert value to string
-    union { T value; char valueBuffer[sizeof(T)]; } un;
-    un.value = value;
-
-    // copy original tag data to temp buffer
-    const std::string newTag = tag + type;
-    const size_t newTagDataLength = tagDataLength + newTag.size() + sizeof(T); // leave room for new T
-    RaiiBuffer originalTagData(newTagDataLength);
-    memcpy(originalTagData.Buffer, TagData.c_str(), tagDataLength + 1);    // '+1' for TagData null-term
-
-    // append newTag
-    strcat(originalTagData.Buffer + tagDataLength, newTag.data());
-    memcpy(originalTagData.Buffer + tagDataLength + newTag.size(), un.valueBuffer, sizeof(T));
-
-    // store temp buffer back in TagData
-    const char* newTagData = (const char*)originalTagData.Buffer;
-    TagData.assign(newTagData, newTagDataLength);
-    return true;
-}
-
-template<>
-inline bool BamAlignment::AddTag<std::string>(const std::string& tag,
-                                              const std::string& type,
-                                              const std::string& value)
-{
-    // if char data not populated, do that first
-    if ( SupportData.HasCoreOnly )
-        BuildCharData();
-
-    // check tag/type size
-    if ( !IsValidSize(tag, type) ) {
-        // TODO: set error string?
-        return false;
-    }
-
-    // check that storage type code is OK for string
-    if ( !TagTypeHelper<std::string>::CanConvertTo(type.at(0)) ) {
-        // TODO: set error string?
-        return false;
-    }
-
-    // localize the tag data
-    char* pTagData = (char*)TagData.data();
-    const unsigned int tagDataLength = TagData.size();
-    unsigned int numBytesParsed = 0;
-
-    // if tag already exists, return false
-    // use EditTag explicitly instead
-    if ( FindTag(tag, pTagData, tagDataLength, numBytesParsed) ) {
-        // TODO: set error string?
-        return false;
-    }
-
-    // otherwise, copy tag data to temp buffer
-    const std::string newTag = tag + type + value;
-    const size_t newTagDataLength = tagDataLength + newTag.size() + 1; // leave room for null-term
-    RaiiBuffer originalTagData(newTagDataLength);
-    memcpy(originalTagData.Buffer, TagData.c_str(), tagDataLength + 1);    // '+1' for TagData null-term
-
-    // append newTag (removes original null-term, then appends newTag + null-term)
-    strcat(originalTagData.Buffer + tagDataLength, newTag.data());
-
-    // store temp buffer back in TagData
-    const char* newTagData = (const char*)originalTagData.Buffer;
-    TagData.assign(newTagData, newTagDataLength);
-    return true;
-}
-
-/*! \fn template<typename T> bool AddTag(const std::string& tag, const std::vector<T>& values)
-    \brief Adds a numeric array field to the BAM tags.
-
-    Does NOT modify an existing tag - use \link BamAlignment::EditTag() \endlink instead.
-
-    \param[in] tag    2-character tag name
-    \param[in] values vector of data values to store
-    \return \c true if the \b new tag was added successfully
-    \sa \samSpecURL for more details on reserved tag names, supported tag types, etc.
-*/
-template<typename T>
-inline bool BamAlignment::AddTag(const std::string& tag, const std::vector<T>& values) {
-
-    // if char data not populated, do that first
-    if ( SupportData.HasCoreOnly )
-        BuildCharData();
-
-    // check for valid tag name length
-    if ( tag.size() != Constants::BAM_TAG_TAGSIZE )
-        return false;
-
-    // localize the tag data
-    char* pTagData = (char*)TagData.data();
-    const unsigned int tagDataLength = TagData.size();
-    unsigned int numBytesParsed = 0;
-
-    // if tag already exists, return false
-    // use EditTag explicitly instead
-    if ( FindTag(tag, pTagData, tagDataLength, numBytesParsed) ) {
-        // TODO: set error string?
-        return false;
-    }
-
-    // build new tag's base information
-    char newTagBase[Constants::BAM_TAG_ARRAYBASE_SIZE];
-    memcpy( newTagBase, tag.c_str(), Constants::BAM_TAG_TAGSIZE );
-    newTagBase[2] = Constants::BAM_TAG_TYPE_ARRAY;
-    newTagBase[3] = TagTypeHelper<T>::TypeCode();
-
-    // add number of array elements to newTagBase
-    const int32_t numElements  = values.size();
-    memcpy(newTagBase + 4, &numElements, sizeof(int32_t));
-
-    // copy current TagData string to temp buffer, leaving room for new tag's contents
-    const size_t newTagDataLength = tagDataLength +
-                                    Constants::BAM_TAG_ARRAYBASE_SIZE +
-                                    numElements*sizeof(T);
-    RaiiBuffer originalTagData(newTagDataLength);
-    memcpy(originalTagData.Buffer, TagData.c_str(), tagDataLength+1); // '+1' for TagData's null-term
-
-    // write newTagBase (removes old null term)
-    strcat(originalTagData.Buffer + tagDataLength, (const char*)newTagBase);
-
-    // add vector elements to tag
-    int elementsBeginOffset = tagDataLength + Constants::BAM_TAG_ARRAYBASE_SIZE;
-    for ( int i = 0 ; i < numElements; ++i ) {
-        const T& value = values.at(i);
-        memcpy(originalTagData.Buffer + elementsBeginOffset + i*sizeof(T), &value, sizeof(T));
-    }
-
-    // store temp buffer back in TagData
-    const char* newTagData = (const char*)originalTagData.Buffer;
-    TagData.assign(newTagData, newTagDataLength);
-    return true;
-}
-
-/*! \fn template<typename T> bool EditTag(const std::string& tag, const std::string& type, const T& value)
-    \brief Edits a BAM tag field.
-
-    If \a tag does not exist, a new entry is created.
-
-    \param tag[in]   2-character tag name
-    \param type[in]  1-character tag type (must be "Z" or "H")
-    \param value[in] new data value
-
-    \return \c true if the tag was modified/created successfully
-
-    \sa BamAlignment::RemoveTag()
-    \sa \samSpecURL for more details on reserved tag names, supported tag types, etc.
-*/
-template<typename T>
-inline bool BamAlignment::EditTag(const std::string& tag, const std::string& type, const T& value) {
-
-    // if char data not populated, do that first
-    if ( SupportData.HasCoreOnly )
-        BuildCharData();
-
-    // remove existing tag if present, then append tag with new value
-    if ( HasTag(tag) )
-        RemoveTag(tag);
-    return AddTag(tag, type, value);
-}
-
-/*! \fn template<typename T> bool EditTag(const std::string& tag, const std::vector<T>& values)
-    \brief Edits a BAM tag field containing a numeric array.
-
-    If \a tag does not exist, a new entry is created.
-
-    \param tag[in]   2-character tag name
-    \param value[in] vector of data values
-
-    \return \c true if the tag was modified/created successfully
-    \sa \samSpecURL for more details on reserved tag names, supported tag types, etc.
-*/
-template<typename T>
-inline bool BamAlignment::EditTag(const std::string& tag, const std::vector<T>& values) {
-
-    // if char data not populated, do that first
-    if ( SupportData.HasCoreOnly )
-        BuildCharData();
-
-    // remove existing tag if present, then append tag with new values
-    if ( HasTag(tag) )
-        RemoveTag(tag);
-    return AddTag(tag, values);
-}
-
-
-/*! \fn template<typename T> bool GetTag(const std::string& tag, T& destination) const
-    \brief Retrieves the value associated with a BAM tag.
-
-    \param tag[in]          2-character tag name
-    \param destination[out] retrieved value
-    \return \c true if found
-*/
-template<typename T>
-inline bool BamAlignment::GetTag(const std::string& tag, T& destination) const {
-
-    // skip if alignment is core-only
-    if ( SupportData.HasCoreOnly ) {
-        // TODO: set error string?
-        return false;
-    }
-
-    // skip if no tags present
-    if ( TagData.empty() ) {
-        // TODO: set error string?
-        return false;
-    }
-
-    // localize the tag data
-    char* pTagData = (char*)TagData.data();
-    const unsigned int tagDataLength = TagData.size();
-    unsigned int numBytesParsed = 0;
-
-    // return failure if tag not found
-    if ( !FindTag(tag, pTagData, tagDataLength, numBytesParsed) ) {
-        // TODO: set error string?
-        return false;
-    }
-
-    // fetch data type
-    const char type = *(pTagData - 1);
-    if ( !TagTypeHelper<T>::CanConvertFrom(type) ) {
-        // TODO: set error string ?
-        return false;
-    }
-
-    // determine data length
-    int destinationLength = 0;
-    switch ( type ) {
-
-        // 1 byte data
-        case (Constants::BAM_TAG_TYPE_ASCII) :
-        case (Constants::BAM_TAG_TYPE_INT8)  :
-        case (Constants::BAM_TAG_TYPE_UINT8) :
-            destinationLength = 1;
-            break;
-
-        // 2 byte data
-        case (Constants::BAM_TAG_TYPE_INT16)  :
-        case (Constants::BAM_TAG_TYPE_UINT16) :
-            destinationLength = 2;
-            break;
-
-        // 4 byte data
-        case (Constants::BAM_TAG_TYPE_INT32)  :
-        case (Constants::BAM_TAG_TYPE_UINT32) :
-        case (Constants::BAM_TAG_TYPE_FLOAT)  :
-            destinationLength = 4;
-            break;
-
-        // var-length types not supported for numeric destination
-        case (Constants::BAM_TAG_TYPE_STRING) :
-        case (Constants::BAM_TAG_TYPE_HEX)    :
-        case (Constants::BAM_TAG_TYPE_ARRAY)  :
-            SetErrorString("BamAlignment::GetTag",
-                           "cannot store variable length tag data into a numeric destination");
-            return false;
-
-        // unrecognized tag type
-        default:
-            const std::string message = std::string("invalid tag type: ") + type;
-            SetErrorString("BamAlignment::GetTag", message);
-            return false;
-    }
-
-    // store data in destination
-    destination = 0;
-    memcpy(&destination, pTagData, destinationLength);
-
-    // return success
-    return true;
-}
-
-template<>
-inline bool BamAlignment::GetTag<std::string>(const std::string& tag,
-                                              std::string& destination) const
-{
-    // skip if alignment is core-only
-    if ( SupportData.HasCoreOnly ) {
-        // TODO: set error string?
-        return false;
-    }
-
-    // skip if no tags present
-    if ( TagData.empty() ) {
-        // TODO: set error string?
-        return false;
-    }
-
-    // localize the tag data
-    char* pTagData = (char*)TagData.data();
-    const unsigned int tagDataLength = TagData.size();
-    unsigned int numBytesParsed = 0;
-
-    // return failure if tag not found
-    if ( !FindTag(tag, pTagData, tagDataLength, numBytesParsed) ) {
-        // TODO: set error string?
-        return false;
-    }
-
-    // otherwise copy data into destination
-    const unsigned int dataLength = strlen(pTagData);
-    destination.clear();
-    destination.resize(dataLength);
-    memcpy( (char*)destination.data(), pTagData, dataLength );
-
-    // return success
-    return true;
-}
-
-/*! \fn template<typename T> bool GetTag(const std::string& tag, std::vector<T>& destination) const
-    \brief Retrieves the numeric array associated with a BAM tag.
-
-    \param tag[in]          2-character tag name
-    \param destination[out] retrieved values
-    \return \c true if found
-*/
-template<typename T>
-inline bool BamAlignment::GetTag(const std::string& tag, std::vector<T>& destination) const {
-
-    // skip if alignment is core-only
-    if ( SupportData.HasCoreOnly ) {
-        // TODO: set error string?
-        return false;
-    }
-
-    // skip if no tags present
-    if ( TagData.empty() ) {
-        // TODO: set error string?
-        return false;
-    }
-
-    // localize the tag data
-    char* pTagData = (char*)TagData.data();
-    const unsigned int tagDataLength = TagData.size();
-    unsigned int numBytesParsed = 0;
-
-    // return false if tag not found
-    if ( !FindTag(tag, pTagData, tagDataLength, numBytesParsed) ) {
-        // TODO: set error string?
-        return false;
-    }
-
-    // check that tag is array type
-    const char tagType = *(pTagData - 1);
-    if ( tagType != Constants::BAM_TAG_TYPE_ARRAY ) {
-        SetErrorString("BamAlignment::GetTag", "cannot store a non-array tag in array destination");
-        return false;
-    }
-
-    // fetch element type
-    const char elementType = *pTagData;
-    if ( !TagTypeHelper<T>::CanConvertFrom(elementType) ) {
-        // TODO: set error string ?
-        return false;
-    }
-    ++pTagData;
-
-    // calculate length of each element in tag's array
-    int elementLength = 0;
-    switch ( elementType ) {
-        case (Constants::BAM_TAG_TYPE_ASCII) :
-        case (Constants::BAM_TAG_TYPE_INT8)  :
-        case (Constants::BAM_TAG_TYPE_UINT8) :
-            elementLength = sizeof(uint8_t);
-            break;
-
-        case (Constants::BAM_TAG_TYPE_INT16)  :
-        case (Constants::BAM_TAG_TYPE_UINT16) :
-            elementLength = sizeof(uint16_t);
-            break;
-
-        case (Constants::BAM_TAG_TYPE_INT32)  :
-        case (Constants::BAM_TAG_TYPE_UINT32) :
-        case (Constants::BAM_TAG_TYPE_FLOAT)  :
-            elementLength = sizeof(uint32_t);
-            break;
-
-        // var-length types not supported for numeric destination
-        case (Constants::BAM_TAG_TYPE_STRING) :
-        case (Constants::BAM_TAG_TYPE_HEX)    :
-        case (Constants::BAM_TAG_TYPE_ARRAY)  :
-            SetErrorString("BamAlignment::GetTag",
-                           "invalid array data, variable-length elements are not allowed");
-            return false;
-
-        // unknown tag type
-        default:
-            const std::string message = std::string("invalid array element type: ") + elementType;
-            SetErrorString("BamAlignment::GetTag", message);
-            return false;
-    }
-
-    // get number of elements
-    int32_t numElements;
-    memcpy(&numElements, pTagData, sizeof(int32_t));
-    pTagData += 4;
-    destination.clear();
-    destination.reserve(numElements);
-
-    // read in elements
-    T value;
-    for ( int i = 0 ; i < numElements; ++i ) {
-        memcpy(&value, pTagData, sizeof(T));
-        pTagData += sizeof(T);
-        destination.push_back(value);
-    }
-
-    // return success
-    return true;
-}
-
-typedef std::vector<BamAlignment> BamAlignmentVector;
-
-} // namespace BamTools
-
-#endif // BAMALIGNMENT_H
diff --git a/bamtools/src/api/BamAux.h b/bamtools/src/api/BamAux.h
deleted file mode 100644
index 0dd3e99..0000000
--- a/bamtools/src/api/BamAux.h
+++ /dev/null
@@ -1,468 +0,0 @@
-// ***************************************************************************
-// BamAux.h (c) 2009 Derek Barnett, Michael Str�mberg
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 25 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides data structures & utility methods that are used throughout the API.
-// ***************************************************************************
-
-#ifndef BAMAUX_H
-#define BAMAUX_H
-
-#include "api/api_global.h"
-#include <cstring>
-#include <fstream> 
-#include <iostream>
-#include <string>
-#include <vector>
-
-/*! \file BamAux.h
-
-    Provides data structures & utility methods that are used throughout the API.
-*/
-
-/*! \namespace BamTools
-    \brief Contains all BamTools classes & methods.
-
-    The BamTools API contained in this namespace contains classes and methods
-    for reading, writing, and manipulating BAM alignment files.
-*/
-namespace BamTools {
-
-// ----------------------------------------------------------------
-// CigarOp
-
-/*! \struct BamTools::CigarOp
-    \brief Represents a CIGAR alignment operation.
-
-    \sa \samSpecURL for more details on using CIGAR operations.
-*/
-struct API_EXPORT CigarOp {
-  
-    char     Type;   //!< CIGAR operation type (MIDNSHPX=)
-    uint32_t Length; //!< CIGAR operation length (number of bases)
-    
-    //! constructor
-    CigarOp(const char type = '\0', 
-            const uint32_t& length = 0)
-        : Type(type)
-        , Length(length) 
-    { }
-};
-
-// ----------------------------------------------------------------
-// RefData
-
-/*! \struct BamTools::RefData
-    \brief Represents a reference sequence entry
-*/
-struct API_EXPORT RefData {
-   
-    std::string RefName;    //!< name of reference sequence
-    int32_t     RefLength;  //!< length of reference sequence
-    
-    //! constructor
-    RefData(const std::string& name = "",
-            const int32_t& length = 0)
-        : RefName(name)
-        , RefLength(length)
-    { }
-};
-
-//! convenience typedef for vector of RefData entries
-typedef std::vector<RefData> RefVector;
-
-// ----------------------------------------------------------------
-// BamRegion
-
-/*! \struct BamTools::BamRegion
-    \brief Represents a sequential genomic region
-
-    Allowed to span multiple (sequential) references.
-
-    \warning BamRegion now represents a zero-based, HALF-OPEN interval.
-    In previous versions of BamTools (0.x & 1.x) all intervals were treated
-    as zero-based, CLOSED.
-*/
-struct API_EXPORT BamRegion {
-  
-    int LeftRefID;      //!< reference ID for region's left boundary
-    int LeftPosition;   //!< position for region's left boundary
-    int RightRefID;     //!< reference ID for region's right boundary
-    int RightPosition;  //!< position for region's right boundary
-    
-    //! constructor
-    BamRegion(const int& leftID   = -1, 
-              const int& leftPos  = -1,
-              const int& rightID  = -1,
-              const int& rightPos = -1)
-        : LeftRefID(leftID)
-        , LeftPosition(leftPos)
-        , RightRefID(rightID)
-        , RightPosition(rightPos)
-    { }
-    
-    //! copy constructor
-    BamRegion(const BamRegion& other)
-        : LeftRefID(other.LeftRefID)
-        , LeftPosition(other.LeftPosition)
-        , RightRefID(other.RightRefID)
-        , RightPosition(other.RightPosition)
-    { }
-    
-    //! Clears region boundaries
-    void clear(void) {
-        LeftRefID  = -1; LeftPosition  = -1;
-        RightRefID = -1; RightPosition = -1;
-    }
-
-    //! Returns true if region has a left boundary
-    bool isLeftBoundSpecified(void) const {
-        return ( LeftRefID >= 0 && LeftPosition >= 0 );
-    }
-
-    //! Returns true if region boundaries are not defined
-    bool isNull(void) const {
-        return ( !isLeftBoundSpecified() && !isRightBoundSpecified() );
-    }
-
-    //! Returns true if region has a right boundary
-    bool isRightBoundSpecified(void) const {
-        return ( RightRefID >= 0 && RightPosition >= 1 );
-    }
-};
-
-// ----------------------------------------------------------------
-// General utility methods
-
-/*! \fn bool FileExists(const std::string& filename)
-    \brief returns true if the file exists
-*/
-API_EXPORT inline bool FileExists(const std::string& filename) {
-    std::ifstream f(filename.c_str(), std::ifstream::in);
-    return !f.fail();
-}
-
-/*! \fn void SwapEndian_16(int16_t& x)
-    \brief swaps endianness of signed 16-bit integer, in place
-*/
-API_EXPORT inline void SwapEndian_16(int16_t& x) {
-    x = ((x >> 8) | (x << 8));
-}
-
-/*! \fn void SwapEndian_16(uint16_t& x)
-    \brief swaps endianness of unsigned 16-bit integer, in place
-*/
-API_EXPORT inline void SwapEndian_16(uint16_t& x) {
-    x = ((x >> 8) | (x << 8));
-}
-
-/*! \fn void SwapEndian_32(int32_t& x)
-    \brief swaps endianness of signed 32-bit integer, in place
-*/
-API_EXPORT inline void SwapEndian_32(int32_t& x) {
-    x = ( (x >> 24) | 
-         ((x << 8) & 0x00FF0000) | 
-         ((x >> 8) & 0x0000FF00) | 
-          (x << 24)
-        );
-}
-
-/*! \fn void SwapEndian_32(uint32_t& x)
-    \brief swaps endianness of unsigned 32-bit integer, in place
-*/
-API_EXPORT inline void SwapEndian_32(uint32_t& x) {
-    x = ( (x >> 24) | 
-         ((x << 8) & 0x00FF0000) | 
-         ((x >> 8) & 0x0000FF00) | 
-          (x << 24)
-        );
-}
-
-/*! \fn void SwapEndian_64(int64_t& x)
-    \brief swaps endianness of signed 64-bit integer, in place
-*/
-API_EXPORT inline void SwapEndian_64(int64_t& x) {
-    x = ( (x >> 56) | 
-         ((x << 40) & 0x00FF000000000000ll) |
-         ((x << 24) & 0x0000FF0000000000ll) |
-         ((x << 8)  & 0x000000FF00000000ll) |
-         ((x >> 8)  & 0x00000000FF000000ll) |
-         ((x >> 24) & 0x0000000000FF0000ll) |
-         ((x >> 40) & 0x000000000000FF00ll) |
-          (x << 56)
-        );
-}
-
-/*! \fn void SwapEndian_64(uint64_t& x)
-    \brief swaps endianness of unsigned 64-bit integer, in place
-*/
-API_EXPORT inline void SwapEndian_64(uint64_t& x) {
-    x = ( (x >> 56) | 
-         ((x << 40) & 0x00FF000000000000ll) |
-         ((x << 24) & 0x0000FF0000000000ll) |
-         ((x << 8)  & 0x000000FF00000000ll) |
-         ((x >> 8)  & 0x00000000FF000000ll) |
-         ((x >> 24) & 0x0000000000FF0000ll) |
-         ((x >> 40) & 0x000000000000FF00ll) |
-          (x << 56)
-        );
-}
-
-/*! \fn void SwapEndian_16p(char* data)
-    \brief swaps endianness of the next 2 bytes in a buffer, in place
-*/
-API_EXPORT inline void SwapEndian_16p(char* data) {
-    uint16_t& value = (uint16_t&)*data; 
-    SwapEndian_16(value);
-}
-
-/*! \fn void SwapEndian_32p(char* data)
-    \brief swaps endianness of the next 4 bytes in a buffer, in place
-*/
-API_EXPORT inline void SwapEndian_32p(char* data) {
-    uint32_t& value = (uint32_t&)*data; 
-    SwapEndian_32(value);
-}
-
-/*! \fn void SwapEndian_64p(char* data)
-    \brief swaps endianness of the next 8 bytes in a buffer, in place
-*/
-API_EXPORT inline void SwapEndian_64p(char* data) {
-    uint64_t& value = (uint64_t&)*data; 
-    SwapEndian_64(value);
-}
-
-/*! \fn bool SystemIsBigEndian(void)
-    \brief checks host architecture's byte order
-    \return \c true if system uses big-endian ordering
-*/
-API_EXPORT inline bool SystemIsBigEndian(void) {
-   const uint16_t one = 0x0001;
-   return ((*(char*) &one) == 0 );
-}
-
-/*! \fn void PackUnsignedInt(char* buffer, unsigned int value)
-    \brief stores unsigned integer value in a byte buffer
-
-    \param[out] buffer destination buffer
-    \param[in]  value  value to 'pack' in buffer
-*/
-API_EXPORT inline void PackUnsignedInt(char* buffer, unsigned int value) {
-    buffer[0] = (char)value;
-    buffer[1] = (char)(value >> 8);
-    buffer[2] = (char)(value >> 16);
-    buffer[3] = (char)(value >> 24);
-}
-
-/*! \fn void PackUnsignedShort(char* buffer, unsigned short value)
-    \brief stores unsigned short integer value in a byte buffer
-
-    \param[out] buffer destination buffer
-    \param[in]  value  value to 'pack' in buffer
-*/
-API_EXPORT inline void PackUnsignedShort(char* buffer, unsigned short value) {
-    buffer[0] = (char)value;
-    buffer[1] = (char)(value >> 8);
-}
-
-/*! \fn double UnpackDouble(const char* buffer)
-    \brief reads a double value from byte buffer
-
-    \param[in] buffer source byte buffer
-    \return the (double) value read from the buffer
-*/
-API_EXPORT inline double UnpackDouble(const char* buffer) {
-    union { double value; unsigned char valueBuffer[sizeof(double)]; } un;
-    un.value = 0;
-    un.valueBuffer[0] = buffer[0];
-    un.valueBuffer[1] = buffer[1];
-    un.valueBuffer[2] = buffer[2];
-    un.valueBuffer[3] = buffer[3];
-    un.valueBuffer[4] = buffer[4];
-    un.valueBuffer[5] = buffer[5];
-    un.valueBuffer[6] = buffer[6];
-    un.valueBuffer[7] = buffer[7];
-    return un.value;
-}
-
-/*! \fn double UnpackDouble(char* buffer)
-    \brief reads a double value from byte buffer
-
-    This is an overloaded function.
-
-    \param[in] buffer source byte buffer
-    \return the (double) value read from the buffer
-*/
-API_EXPORT inline double UnpackDouble(char* buffer) {
-    return UnpackDouble( (const char*)buffer );
-}
-
-/*! \fn double UnpackFloat(const char* buffer)
-    \brief reads a float value from byte buffer
-
-    \param[in] buffer source byte buffer
-    \return the (float) value read from the buffer
-*/
-API_EXPORT inline float UnpackFloat(const char* buffer) {
-    union { float value; unsigned char valueBuffer[sizeof(float)]; } un;
-    un.value = 0;
-    un.valueBuffer[0] = buffer[0];
-    un.valueBuffer[1] = buffer[1];
-    un.valueBuffer[2] = buffer[2];
-    un.valueBuffer[3] = buffer[3];
-    return un.value;
-}
-
-/*! \fn double UnpackFloat(char* buffer)
-    \brief reads a float value from byte buffer
-
-    This is an overloaded function.
-
-    \param[in] buffer source byte buffer
-    \return the (float) value read from the buffer
-*/
-API_EXPORT inline float UnpackFloat(char* buffer) {
-    return UnpackFloat( (const char*)buffer );
-}
-
-/*! \fn signed int UnpackSignedInt(const char* buffer)
-    \brief reads a signed integer value from byte buffer
-
-    \param[in] buffer source byte buffer
-    \return the (signed int) value read from the buffer
-*/
-API_EXPORT inline signed int UnpackSignedInt(const char* buffer) {
-    union { signed int value; unsigned char valueBuffer[sizeof(signed int)]; } un;
-    un.value = 0;
-    un.valueBuffer[0] = buffer[0];
-    un.valueBuffer[1] = buffer[1];
-    un.valueBuffer[2] = buffer[2];
-    un.valueBuffer[3] = buffer[3];
-    return un.value;
-}
-
-/*! \fn signed int UnpackSignedInt(char* buffer)
-    \brief reads a signed integer value from byte buffer
-
-    This is an overloaded function.
-
-    \param[in] buffer source byte buffer
-    \return the (signed int) value read from the buffer
-*/
-API_EXPORT inline signed int UnpackSignedInt(char* buffer) {
-    return UnpackSignedInt( (const char*) buffer );
-}
-
-/*! \fn signed short UnpackSignedShort(const char* buffer)
-    \brief reads a signed short integer value from byte buffer
-
-    \param[in] buffer source byte buffer
-    \return the (signed short) value read from the buffer
-*/
-API_EXPORT inline signed short UnpackSignedShort(const char* buffer) {
-    union { signed short value; unsigned char valueBuffer[sizeof(signed short)]; } un;
-    un.value = 0;
-    un.valueBuffer[0] = buffer[0];
-    un.valueBuffer[1] = buffer[1];
-    return un.value;
-}
-
-/*! \fn signed short UnpackSignedShort(char* buffer)
-    \brief reads a signed short integer value from byte buffer
-
-    This is an overloaded function.
-
-    \param[in] buffer source byte buffer
-    \return the (signed short) value read from the buffer
-*/
-API_EXPORT inline signed short UnpackSignedShort(char* buffer) {
-    return UnpackSignedShort( (const char*)buffer );
-}
-
-/*! \fn unsigned int UnpackUnsignedInt(const char* buffer)
-    \brief reads an unsigned integer value from byte buffer
-
-    \param[in] buffer source byte buffer
-    \return the (unsigned int) value read from the buffer
-*/
-API_EXPORT inline unsigned int UnpackUnsignedInt(const char* buffer) {
-    union { unsigned int value; unsigned char valueBuffer[sizeof(unsigned int)]; } un;
-    un.value = 0;
-    un.valueBuffer[0] = buffer[0];
-    un.valueBuffer[1] = buffer[1];
-    un.valueBuffer[2] = buffer[2];
-    un.valueBuffer[3] = buffer[3];
-    return un.value;
-}
-
-/*! \fn unsigned int UnpackUnsignedInt(char* buffer)
-    \brief reads an unsigned integer value from byte buffer
-
-    This is an overloaded function.
-
-    \param[in] buffer source byte buffer
-    \return the (unsigned int) value read from the buffer
-*/
-API_EXPORT inline unsigned int UnpackUnsignedInt(char* buffer) {
-    return UnpackUnsignedInt( (const char*)buffer );
-}
-
-/*! \fn unsigned short UnpackUnsignedShort(const char* buffer)
-    \brief reads an unsigned short integer value from byte buffer
-
-    \param[in] buffer source byte buffer
-    \return the (unsigned short) value read from the buffer
-*/
-API_EXPORT inline unsigned short UnpackUnsignedShort(const char* buffer) {
-    union { unsigned short value; unsigned char valueBuffer[sizeof(unsigned short)]; } un;
-    un.value = 0;
-    un.valueBuffer[0] = buffer[0];
-    un.valueBuffer[1] = buffer[1];
-    return un.value;
-}
-
-/*! \fn unsigned short UnpackUnsignedShort(char* buffer)
-    \brief reads an unsigned short integer value from byte buffer
-
-    This is an overloaded function.
-
-    \param[in] buffer source byte buffer
-    \return the (unsigned short) value read from the buffer
-*/
-API_EXPORT inline unsigned short UnpackUnsignedShort(char* buffer) {
-    return UnpackUnsignedShort( (const char*)buffer );
-}
-
-// ----------------------------------------------------------------
-// 'internal' helper structs
-
-/*! \struct RaiiBuffer
-    \internal
-*/
-struct RaiiBuffer {
-
-    // data members
-    char* Buffer;
-    const size_t NumBytes;
-
-    // ctor & dtor
-    RaiiBuffer(const size_t n)
-        : Buffer( new char[n]() )
-        , NumBytes(n)
-    { }
-
-    ~RaiiBuffer(void) {
-        delete[] Buffer;
-    }
-
-    // add'l methods
-    void Clear(void) {
-        memset(Buffer, 0, NumBytes);
-    }
-};
-
-} // namespace BamTools
-
-#endif // BAMAUX_H
diff --git a/bamtools/src/api/BamConstants.h b/bamtools/src/api/BamConstants.h
deleted file mode 100644
index 47f73a9..0000000
--- a/bamtools/src/api/BamConstants.h
+++ /dev/null
@@ -1,282 +0,0 @@
-// ***************************************************************************
-// BamConstants.h (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 16 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides basic constants for handling BAM files.
-// ***************************************************************************
-
-#ifndef BAM_CONSTANTS_H
-#define BAM_CONSTANTS_H
-
-#include "api/api_global.h"
-#include <cassert>
-#include <string>
-
-/*! \namespace BamTools::Constants
-    \brief Provides basic constants for handling BAM files.
-*/
-
-namespace BamTools {
-namespace Constants {
-
-const uint8_t BAM_SIZEOF_INT = 4;
-
-// header magic number
-const char* const BAM_HEADER_MAGIC = "BAM\1";
-const uint8_t BAM_HEADER_MAGIC_LENGTH = 4;
-
-// BAM alignment core size
-const uint8_t BAM_CORE_SIZE        = 32;
-const uint8_t BAM_CORE_BUFFER_SIZE = 8;
-
-// BAM alignment flags
-const int BAM_ALIGNMENT_PAIRED              = 0x0001;
-const int BAM_ALIGNMENT_PROPER_PAIR         = 0x0002;
-const int BAM_ALIGNMENT_UNMAPPED            = 0x0004;
-const int BAM_ALIGNMENT_MATE_UNMAPPED       = 0x0008;
-const int BAM_ALIGNMENT_REVERSE_STRAND      = 0x0010;
-const int BAM_ALIGNMENT_MATE_REVERSE_STRAND = 0x0020;
-const int BAM_ALIGNMENT_READ_1              = 0x0040;
-const int BAM_ALIGNMENT_READ_2              = 0x0080;
-const int BAM_ALIGNMENT_SECONDARY           = 0x0100;
-const int BAM_ALIGNMENT_QC_FAILED           = 0x0200;
-const int BAM_ALIGNMENT_DUPLICATE           = 0x0400;
-
-// CIGAR constants
-const char* const BAM_CIGAR_LOOKUP = "MIDNSHP=X";
-const uint8_t BAM_CIGAR_MATCH    = 0;
-const uint8_t BAM_CIGAR_INS      = 1;
-const uint8_t BAM_CIGAR_DEL      = 2;
-const uint8_t BAM_CIGAR_REFSKIP  = 3;
-const uint8_t BAM_CIGAR_SOFTCLIP = 4;
-const uint8_t BAM_CIGAR_HARDCLIP = 5;
-const uint8_t BAM_CIGAR_PAD      = 6;
-const uint8_t BAM_CIGAR_SEQMATCH = 7;
-const uint8_t BAM_CIGAR_MISMATCH = 8;
-
-const char BAM_CIGAR_MATCH_CHAR    = 'M';
-const char BAM_CIGAR_INS_CHAR      = 'I';
-const char BAM_CIGAR_DEL_CHAR      = 'D';
-const char BAM_CIGAR_REFSKIP_CHAR  = 'N';
-const char BAM_CIGAR_SOFTCLIP_CHAR = 'S';
-const char BAM_CIGAR_HARDCLIP_CHAR = 'H';
-const char BAM_CIGAR_PAD_CHAR      = 'P';
-const char BAM_CIGAR_SEQMATCH_CHAR = '=';
-const char BAM_CIGAR_MISMATCH_CHAR = 'X';
-
-const int BAM_CIGAR_SHIFT = 4;
-const int BAM_CIGAR_MASK  = ((1 << BAM_CIGAR_SHIFT) - 1);
-
-// BAM tag types & sizes
-const char BAM_TAG_TYPE_ASCII  = 'A';
-const char BAM_TAG_TYPE_INT8   = 'c';
-const char BAM_TAG_TYPE_UINT8  = 'C';
-const char BAM_TAG_TYPE_INT16  = 's';
-const char BAM_TAG_TYPE_UINT16 = 'S';
-const char BAM_TAG_TYPE_INT32  = 'i';
-const char BAM_TAG_TYPE_UINT32 = 'I';
-const char BAM_TAG_TYPE_FLOAT  = 'f';
-const char BAM_TAG_TYPE_STRING = 'Z';
-const char BAM_TAG_TYPE_HEX    = 'H';
-const char BAM_TAG_TYPE_ARRAY  = 'B';
-
-const uint8_t BAM_TAG_TAGSIZE        = 2;
-const uint8_t BAM_TAG_TYPESIZE       = 1;
-const uint8_t BAM_TAG_ARRAYBASE_SIZE = 8;
-
-// DNA bases
-const char* const BAM_DNA_LOOKUP = "=ACMGRSVTWYHKDBN";
-const uint8_t BAM_BASECODE_EQUAL = 0;
-const uint8_t BAM_BASECODE_A     = 1;
-const uint8_t BAM_BASECODE_C     = 2;
-const uint8_t BAM_BASECODE_M     = 3;
-const uint8_t BAM_BASECODE_G     = 4;
-const uint8_t BAM_BASECODE_R     = 5;
-const uint8_t BAM_BASECODE_S     = 6;
-const uint8_t BAM_BASECODE_V     = 7;
-const uint8_t BAM_BASECODE_T     = 8;
-const uint8_t BAM_BASECODE_W     = 9;
-const uint8_t BAM_BASECODE_Y     = 10;
-const uint8_t BAM_BASECODE_H     = 11;
-const uint8_t BAM_BASECODE_K     = 12;
-const uint8_t BAM_BASECODE_D     = 13;
-const uint8_t BAM_BASECODE_B     = 14;
-const uint8_t BAM_BASECODE_N     = 15;
-
-const char BAM_DNA_EQUAL = '=';
-const char BAM_DNA_A     = 'A';
-const char BAM_DNA_C     = 'C';
-const char BAM_DNA_M     = 'M';
-const char BAM_DNA_G     = 'G';
-const char BAM_DNA_R     = 'R';
-const char BAM_DNA_S     = 'S';
-const char BAM_DNA_V     = 'V';
-const char BAM_DNA_T     = 'T';
-const char BAM_DNA_W     = 'W';
-const char BAM_DNA_Y     = 'Y';
-const char BAM_DNA_H     = 'H';
-const char BAM_DNA_K     = 'K';
-const char BAM_DNA_D     = 'D';
-const char BAM_DNA_B     = 'B';
-const char BAM_DNA_N     = 'N';
-const char BAM_DNA_DEL   = '-';
-const char BAM_DNA_PAD   = '*';
-
-// zlib & BGZF constants
-const char GZIP_ID1   = 31;
-const char GZIP_ID2   = 139;
-const char CM_DEFLATE = 8;
-const char FLG_FEXTRA = 4;
-const char OS_UNKNOWN = 255;
-const char BGZF_XLEN  = 6;
-const char BGZF_ID1   = 66;
-const char BGZF_ID2   = 67;
-const char BGZF_LEN   = 2;
-
-const int8_t   GZIP_WINDOW_BITS          = -15;
-const int8_t   Z_DEFAULT_MEM_LEVEL       = 8;
-const uint8_t  BGZF_BLOCK_HEADER_LENGTH  = 18;
-const uint8_t  BGZF_BLOCK_FOOTER_LENGTH  = 8;
-const uint32_t BGZF_MAX_BLOCK_SIZE       = 65536;
-const uint32_t BGZF_DEFAULT_BLOCK_SIZE   = 65536;
-
-} // namespace Constants
-
-//! \cond
-// -------------------------
-// tag-type helper structs
-// -------------------------
-
-// fail on any types not specified below
-template<typename T>
-struct TagTypeHelper {
-    static bool CanConvertFrom(const char) { assert(false); return false; }
-    static bool CanConvertTo(const char) { assert(false); return false; }
-    static char TypeCode(void) { assert(false); return 0; }
-};
-
-template<>
-struct TagTypeHelper<uint8_t> {
-    static bool CanConvertFrom(const char c) {
-        return ( c == Constants::BAM_TAG_TYPE_ASCII ||
-                 c == Constants::BAM_TAG_TYPE_UINT8 );
-    }
-    static bool CanConvertTo(const char c) {
-        return ( c == Constants::BAM_TAG_TYPE_ASCII  ||
-                 c == Constants::BAM_TAG_TYPE_UINT8  ||
-                 c == Constants::BAM_TAG_TYPE_UINT16 ||
-                 c == Constants::BAM_TAG_TYPE_UINT32 );
-    }
-
-    static char TypeCode(void) { return Constants::BAM_TAG_TYPE_UINT8; }
-};
-
-template<>
-struct TagTypeHelper<int8_t> {
-    static bool CanConvertFrom(const char c) {
-        return ( c == Constants::BAM_TAG_TYPE_ASCII ||
-                 c == Constants::BAM_TAG_TYPE_INT8 );
-    }
-    static bool CanConvertTo(const char c) {
-        return ( c == Constants::BAM_TAG_TYPE_ASCII ||
-                 c == Constants::BAM_TAG_TYPE_INT8  ||
-                 c == Constants::BAM_TAG_TYPE_INT16 ||
-                 c == Constants::BAM_TAG_TYPE_INT32 );
-    }
-    static char TypeCode(void) { return Constants::BAM_TAG_TYPE_INT8; }
-};
-
-template<>
-struct TagTypeHelper<uint16_t> {
-    static bool CanConvertFrom(const char c) {
-        return ( c == Constants::BAM_TAG_TYPE_ASCII ||
-                 c == Constants::BAM_TAG_TYPE_UINT8 ||
-                 c == Constants::BAM_TAG_TYPE_UINT16 );
-    }
-    static bool CanConvertTo(const char c) {
-        return ( c == Constants::BAM_TAG_TYPE_UINT16 ||
-                 c == Constants::BAM_TAG_TYPE_UINT32);
-    }
-    static char TypeCode(void) { return Constants::BAM_TAG_TYPE_UINT16; }
-};
-
-template<>
-struct TagTypeHelper<int16_t> {
-    static bool CanConvertFrom(const char c) {
-        return ( c == Constants::BAM_TAG_TYPE_ASCII ||
-                 c == Constants::BAM_TAG_TYPE_INT8 ||
-                 c == Constants::BAM_TAG_TYPE_INT16 );
-    }
-    static bool CanConvertTo(const char c) {
-        return ( c == Constants::BAM_TAG_TYPE_INT16 ||
-                 c == Constants::BAM_TAG_TYPE_INT32);
-    }
-    static char TypeCode(void) { return Constants::BAM_TAG_TYPE_INT16; }
-};
-
-template<>
-struct TagTypeHelper<uint32_t> {
-    static bool CanConvertFrom(const char c) {
-        return ( c == Constants::BAM_TAG_TYPE_ASCII  ||
-                 c == Constants::BAM_TAG_TYPE_UINT8  ||
-                 c == Constants::BAM_TAG_TYPE_UINT16 ||
-                 c == Constants::BAM_TAG_TYPE_UINT32 );
-    }
-    static bool CanConvertTo(const char c) {
-        return ( c == Constants::BAM_TAG_TYPE_UINT32 );
-    }
-    static char TypeCode(void) { return Constants::BAM_TAG_TYPE_UINT32; }
-};
-
-template<>
-struct TagTypeHelper<int32_t> {
-    static bool CanConvertFrom(const char c) {
-        return ( c == Constants::BAM_TAG_TYPE_ASCII  ||
-                 c == Constants::BAM_TAG_TYPE_INT8  ||
-                 c == Constants::BAM_TAG_TYPE_INT16 ||
-                 c == Constants::BAM_TAG_TYPE_INT32 );
-    }
-    static bool CanConvertTo(const char c) {
-        return ( c == Constants::BAM_TAG_TYPE_INT32 );
-    }
-    static char TypeCode(void) { return Constants::BAM_TAG_TYPE_INT32; }
-};
-
-template<>
-struct TagTypeHelper<float> {
-    static bool CanConvertFrom(const char c) {
-        return ( c == Constants::BAM_TAG_TYPE_ASCII  ||
-                 c == Constants::BAM_TAG_TYPE_UINT8  ||
-                 c == Constants::BAM_TAG_TYPE_INT8   ||
-                 c == Constants::BAM_TAG_TYPE_UINT16 ||
-                 c == Constants::BAM_TAG_TYPE_INT16  ||
-                 c == Constants::BAM_TAG_TYPE_UINT32 ||
-                 c == Constants::BAM_TAG_TYPE_INT32  ||
-                 c == Constants::BAM_TAG_TYPE_FLOAT);
-    }
-    static bool CanConvertTo(const char c) {
-        return ( c == Constants::BAM_TAG_TYPE_FLOAT );
-    }
-    static char TypeCode(void) { return Constants::BAM_TAG_TYPE_FLOAT; }
-};
-
-template<>
-struct TagTypeHelper<std::string> {
-    static bool CanConvertFrom(const char c) {
-        return ( c == Constants::BAM_TAG_TYPE_HEX ||
-                 c == Constants::BAM_TAG_TYPE_STRING );
-    }
-    static bool CanConvertTo(const char c) {
-        return ( c == Constants::BAM_TAG_TYPE_HEX ||
-                 c == Constants::BAM_TAG_TYPE_STRING );
-    }
-    static char TypeCode(void) { return Constants::BAM_TAG_TYPE_STRING; }
-};
-
-//! \endcond
-
-} // namespace BamTools
-
-#endif // BAM_CONSTANTS_H
diff --git a/bamtools/src/api/BamIndex.h b/bamtools/src/api/BamIndex.h
deleted file mode 100644
index fd41f69..0000000
--- a/bamtools/src/api/BamIndex.h
+++ /dev/null
@@ -1,90 +0,0 @@
-// ***************************************************************************
-// BamIndex.h (c) 2009 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides basic BAM index interface
-// ***************************************************************************
-
-#ifndef BAM_INDEX_H
-#define BAM_INDEX_H
-
-#include "api/api_global.h"
-#include "api/BamAux.h"
-#include <string>
-
-namespace BamTools {
-
-namespace Internal {
-    class BamReaderPrivate;
-} // namespace Internal
-
-/*! \class BamTools::BamIndex
-    \brief Provides methods for generating & loading BAM index files.
-
-    This class straddles the line between public API and internal
-    implementation detail. Most client code should never have to use this
-    class directly.
-
-    It is exposed to the public API to allow advanced users to implement
-    their own custom indexing schemes.
-*/
-
-class API_EXPORT BamIndex {
-
-    // enums
-    public:
-
-        // list of supported BamIndex types
-        enum IndexType { BAMTOOLS = 0
-                       , STANDARD
-                       };
-  
-    // ctor & dtor
-    public:
-        BamIndex(Internal::BamReaderPrivate* reader) : m_reader(reader) { }
-        virtual ~BamIndex(void) { }
-        
-    // index interface
-    public:
-        // builds index from associated BAM file & writes out to index file
-        virtual bool Create(void) =0;
-
-        // returns a human-readable description of the last error encountered
-        std::string GetErrorString(void) { return m_errorString; }
-
-        // returns whether reference has alignments or no
-        virtual bool HasAlignments(const int& referenceID) const =0;
-
-        // attempts to use index data to jump to @region, returns success/fail
-        // a "successful" jump indicates no error, but not whether this region has data
-        //   * thus, the method sets a flag to indicate whether there are alignments
-        //     available after the jump position
-        virtual bool Jump(const BamTools::BamRegion& region, bool* hasAlignmentsInRegion) =0;
-
-        // loads existing data from file into memory
-        virtual bool Load(const std::string& filename) =0;
-
-        // returns the 'type' enum for derived index format
-        virtual BamIndex::IndexType Type(void) const =0;
-
-    //! \cond
-
-    // internal methods
-    protected:
-        void SetErrorString(const std::string& where, const std::string& what) const {
-            m_errorString = where + ": " + what;
-        }
-
-    // data members
-    protected:
-        Internal::BamReaderPrivate* m_reader; // copy, not owned
-        mutable std::string m_errorString;
-
-    //! \endcond
-};
-
-} // namespace BamTools
-
-#endif // BAM_INDEX_H
diff --git a/bamtools/src/api/BamMultiReader.cpp b/bamtools/src/api/BamMultiReader.cpp
deleted file mode 100644
index 5c2a065..0000000
--- a/bamtools/src/api/BamMultiReader.cpp
+++ /dev/null
@@ -1,421 +0,0 @@
-// ***************************************************************************
-// BamMultiReader.cpp (c) 2010 Erik Garrison, Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 14 January 2013 (DB)
-// ---------------------------------------------------------------------------
-// Convenience class for reading multiple BAM files.
-//
-// This functionality allows applications to work on very large sets of files
-// without requiring intermediate merge, sort, and index steps for each file
-// subset. It also improves the performance of our merge system as it
-// precludes the need to sort merged files.
-// ***************************************************************************
-
-#include "api/BamMultiReader.h"
-#include "api/internal/bam/BamMultiReader_p.h"
-using namespace BamTools;
-
-#include <string>
-#include <vector>
-using namespace std;
-
-/*! \class BamTools::BamMultiReader
-    \brief Convenience class for reading multiple BAM files.
-*/
-/*! \enum BamMultiReader::MergeOrder
-    \brief Used to describe the merge strategy of the BamMultiReader.
-
-    The merge strategy determines which alignment is 'next' from across
-    all opened BAM files.
-*/
-/*! \var BamMultiReader::MergeOrder BamMultiReader::RoundRobinMerge
-    \brief Merge strategy when BAM files are unsorted, or their sorted status is either unknown or ignored
-*/
-/*! \var BamMultiReader::MergeOrder BamMultiReader::MergeByCoordinate
-    \brief Merge strategy when BAM files are sorted by position ('coordinate')
-*/
-/*! \var BamMultiReader::MergeOrder BamMultiReader::MergeByName
-    \brief Merge strategy when BAM files are sorted by read name ('queryname')
-*/
-
-/*! \fn BamMultiReader::BamMultiReader(void)
-    \brief constructor
-*/
-BamMultiReader::BamMultiReader(void)
-    : d(new Internal::BamMultiReaderPrivate)
-{ }
-
-/*! \fn BamMultiReader::~BamMultiReader(void)
-    \brief destructor
-*/
-BamMultiReader::~BamMultiReader(void) {
-    delete d;
-    d = 0;
-}
-
-/*! \fn void BamMultiReader::Close(void)
-    \brief Closes all open BAM files.
-
-    Also clears out all header and reference data.
-
-    \sa CloseFile(), IsOpen(), Open(), BamReader::Close()
-*/
-bool BamMultiReader::Close(void) {
-    return d->Close();
-}
-
-/*! \fn void BamMultiReader::CloseFile(const std::string& filename)
-    \brief Closes requested BAM file.
-
-    Leaves any other file(s) open, along with header and reference data.
-
-    \param[in] filename name of specific BAM file to close
-
-    \sa Close(), IsOpen(), Open(), BamReader::Close()
-*/
-bool BamMultiReader::CloseFile(const std::string& filename) {
-    return d->CloseFile(filename);
-}
-
-/*! \fn bool BamMultiReader::CreateIndexes(const BamIndex::IndexType& type)
-    \brief Creates index files for the current BAM files.
-
-    \param[in] type file format to create, see BamIndex::IndexType for available formats
-    \return \c true if index files created OK
-    \sa LocateIndexes(), OpenIndexes(), BamReader::CreateIndex()
-*/
-bool BamMultiReader::CreateIndexes(const BamIndex::IndexType& type) {
-    return d->CreateIndexes(type);
-}
-
-/*! \fn const std::vector<std::string> BamMultiReader::Filenames(void) const
-    \brief Returns list of filenames for all open BAM files.
-
-    Retrieved filenames will contain whatever was passed via Open().
-    If you need full directory paths here, be sure to include them
-    when you open the BAM files.
-
-    \returns names of open BAM files. If no files are open, returns an empty vector.
-    \sa IsOpen(), BamReader::GetFilename()
-*/
-const std::vector<std::string> BamMultiReader::Filenames(void) const {
-    return d->Filenames();
-}
-
-/*! \fn std::string BamMultiReader::GetErrorString(void) const
-    \brief Returns a human-readable description of the last error that occurred
-
-    This method allows elimination of STDERR pollution. Developers of client code
-    may choose how the messages are displayed to the user, if at all.
-
-    \return error description
-*/
-std::string BamMultiReader::GetErrorString(void) const {
-    return d->GetErrorString();
-}
-
-/*! \fn SamHeader BamMultiReader::GetHeader(void) const
-    \brief Returns unified SAM-format header for all files
-
-    \note Modifying the retrieved text does NOT affect the current
-    BAM files. These files have been opened in a read-only mode. However,
-    your modified header text can be used in conjunction with BamWriter
-    to generate a new BAM file with the appropriate header information.
-
-    \returns header data wrapped in SamHeader object
-    \sa GetHeaderText(), BamReader::GetHeader()
-*/
-SamHeader BamMultiReader::GetHeader(void) const {
-    return d->GetHeader();
-}
-
-/*! \fn std::string BamMultiReader::GetHeaderText(void) const
-    \brief Returns unified SAM-format header text for all files
-
-    \note Modifying the retrieved text does NOT affect the current
-    BAM files. These files have been opened in a read-only mode. However,
-    your modified header text can be used in conjunction with BamWriter
-    to generate a new BAM file with the appropriate header information.
-
-    \returns SAM-formatted header text
-    \sa GetHeader(), BamReader::GetHeaderText()
-*/
-std::string BamMultiReader::GetHeaderText(void) const {
-    return d->GetHeaderText();
-}
-
-/*! \fn BamMultiReader::MergeOrder BamMultiReader::GetMergeOrder(void) const
-    \brief Returns curent merge order strategy.
-
-    \returns current merge order enum value
-    \sa BamMultiReader::MergeOrder, SetExplicitMergeOrder()
-*/
-BamMultiReader::MergeOrder BamMultiReader::GetMergeOrder(void) const {
-    return d->GetMergeOrder();
-}
-
-/*! \fn bool BamMultiReader::GetNextAlignment(BamAlignment& alignment)
-    \brief Retrieves next available alignment.
-
-    Equivalent to BamReader::GetNextAlignment() with respect to what is a valid
-    overlapping alignment and what data gets populated.
-
-    This method takes care of determining which alignment actually is 'next'
-    across multiple files, depending on their sort order.
-
-    \param[out] alignment destination for alignment record data
-    \returns \c true if a valid alignment was found
-    \sa GetNextAlignmentCore(), SetExplicitMergeOrder(), SetRegion(), BamReader::GetNextAlignment()
-*/
-bool BamMultiReader::GetNextAlignment(BamAlignment& nextAlignment) {
-    return d->GetNextAlignment(nextAlignment);
-}
-
-/*! \fn bool BamMultiReader::GetNextAlignmentCore(BamAlignment& alignment)
-    \brief Retrieves next available alignment.
-
-    Equivalent to BamReader::GetNextAlignmentCore() with respect to what is a valid
-    overlapping alignment and what data gets populated.
-
-    This method takes care of determining which alignment actually is 'next'
-    across multiple files, depending on their sort order.
-
-    \param[out] alignment destination for alignment record data
-    \returns \c true if a valid alignment was found
-    \sa GetNextAlignment(), SetExplicitMergeOrder(), SetRegion(), BamReader::GetNextAlignmentCore()
-*/
-bool BamMultiReader::GetNextAlignmentCore(BamAlignment& nextAlignment) {
-    return d->GetNextAlignmentCore(nextAlignment);
-}
-
-/*! \fn int BamMultiReader::GetReferenceCount(void) const
-    \brief Returns number of reference sequences.
-    \sa BamReader::GetReferenceCount()
-*/
-int BamMultiReader::GetReferenceCount(void) const {
-    return d->GetReferenceCount();
-}
-
-/*! \fn const RefVector& BamMultiReader::GetReferenceData(void) const
-    \brief Returns all reference sequence entries.
-    \sa RefData, BamReader::GetReferenceData()
-*/
-const BamTools::RefVector BamMultiReader::GetReferenceData(void) const {
-    return d->GetReferenceData();
-}
-
-/*! \fn int BamMultiReader::GetReferenceID(const std::string& refName) const
-    \brief Returns the ID of the reference with this name.
-
-    If \a refName is not found, returns -1.
-
-    \param[in] refName name of reference to look up
-    \sa BamReader::GetReferenceID()
-*/
-int BamMultiReader::GetReferenceID(const std::string& refName) const {
-    return d->GetReferenceID(refName);
-}
-
-/*! \fn bool BamMultiReader::HasIndexes(void) const
-    \brief Returns \c true if all BAM files have index data available.
-    \sa BamReader::HasIndex()
-*/
-bool BamMultiReader::HasIndexes(void) const {
-    return d->HasIndexes();
-}
-
-/*! \fn bool BamMultiReader::HasOpenReaders(void) const
-    \brief Returns \c true if there are any open BAM files.
-*/
-bool BamMultiReader::HasOpenReaders(void) const {
-    return d->HasOpenReaders();
-}
-
-/*! \fn bool BamMultiReader::Jump(int refID, int position)
-    \brief Performs a random-access jump within current BAM files.
-
-    This is a convenience method, equivalent to calling SetRegion()
-    with only a left boundary specified.
-
-    \param[in] refID    ID of reference to jump to
-    \param[in] position (0-based) left boundary
-
-    \returns \c true if jump was successful
-    \sa HasIndex(), BamReader::Jump()
-*/
-
-bool BamMultiReader::Jump(int refID, int position) {
-    return d->Jump(refID, position);
-}
-
-/*! \fn bool BamMultiReader::LocateIndexes(const BamIndex::IndexType& preferredType)
-    \brief Looks for index files that match current BAM files.
-
-    Use this function when you need index files, and perhaps have a
-    preferred index format, but do not depend heavily on which indexes
-    actually get loaded at runtime.
-
-    For each BAM file, this function will defer to your \a preferredType
-    whenever possible. However, if an index file of \a preferredType can
-    not be found, then it will look for any other index file that matches
-    that BAM file.
-
-    An example case would look this:
-    \code
-        BamMultiReader reader;
-
-        // do setup...
-
-        // ensure that all files have an index
-        if ( !reader.LocateIndexes() )      // opens any existing index files that match our BAM files
-            reader.CreateIndexes();         // creates index files for any BAM files that still lack one
-
-        // do interesting stuff using random-access...
-
-    \endcode
-
-    If you want precise control over which index files are loaded, use OpenIndexes()
-    with the desired index filenames. If that function returns false, you can use
-    CreateIndexes() to then build index files of the exact requested format.
-
-    \param[in] preferredType desired index file format, see BamIndex::IndexType for available formats
-    \returns \c true if index files could be found for \b ALL open BAM files
-    \sa BamReader::LocateIndex()
-*/
-bool BamMultiReader::LocateIndexes(const BamIndex::IndexType& preferredType) {
-    return d->LocateIndexes(preferredType);
-}
-
-/*! \fn bool BamMultiReader::Open(const std::vector<std::string>& filenames)
-    \brief Opens BAM files.
-
-    \note Opening BAM files will invalidate any current region set on the multireader.
-    All file pointers will be returned to the beginning of the alignment data. Follow
-    this with Jump() or SetRegion() to establish a region of interest.
-
-    \param[in] filenames list of BAM filenames to open
-    \returns \c true if BAM files were opened successfully
-    \sa Close(), HasOpenReaders(), OpenFile(), OpenIndexes(), BamReader::Open()
-*/
-bool BamMultiReader::Open(const std::vector<std::string>& filenames) {
-    return d->Open(filenames);
-}
-
-/*! \fn bool BamMultiReader::OpenFile(const std::string& filename)
-    \brief Opens a single BAM file.
-
-    Adds another BAM file to multireader "on-the-fly".
-
-    \note Opening a BAM file will invalidate any current region set on the multireader.
-    All file pointers will be returned to the beginning of the alignment data. Follow
-    this with Jump() or SetRegion() to establish a region of interest.
-
-    \param[in] filename BAM filename to open
-    \returns \c true if BAM file was opened successfully
-    \sa Close(), HasOpenReaders(), Open(), OpenIndexes(), BamReader::Open()
-*/
-bool BamMultiReader::OpenFile(const std::string& filename) {
-    return d->OpenFile(filename);
-}
-
-/*! \fn bool BamMultiReader::OpenIndexes(const std::vector<std::string>& indexFilenames)
-    \brief Opens index files for current BAM files.
-
-    \note Currently assumes that index filenames match the order (and number) of
-    BAM files passed to Open().
-
-    \param[in] indexFilenames list of BAM index file names
-    \returns \c true if BAM index file was opened & data loaded successfully
-    \sa LocateIndex(), Open(), SetIndex(), BamReader::OpenIndex()
-*/
-bool BamMultiReader::OpenIndexes(const std::vector<std::string>& indexFilenames) {
-    return d->OpenIndexes(indexFilenames);
-}
-
-/*! \fn bool BamMultiReader::Rewind(void)
-    \brief Returns the internal file pointers to the beginning of alignment records.
-
-    Useful for performing multiple sequential passes through BAM files.
-    Calling this function clears any prior region that may have been set.
-
-    \returns \c true if rewind operation was successful
-    \sa Jump(), SetRegion(), BamReader::Rewind()
-*/
-bool BamMultiReader::Rewind(void) {
-    return d->Rewind();
-}
-
-/*! \fn void BamMultiReader::SetExplicitMergeOrder(BamMultiReader::MergeOrder order)
-    \brief Sets an explicit merge order, regardless of the BAM files' SO header tag.
-
-    The default behavior of the BamMultiReader is to check the SO tag in the BAM files'
-    SAM header text to determine the merge strategy". The merge strategy is used to
-    determine from which BAM file the next alignment should come when either
-    GetNextAlignment() or GetNextAlignmentCore() are called. If files share a
-    'coordinate' or 'queryname' value for this tag, then the merge strategy is
-    selected accordingly. If any of them do not match, or if any fileis marked as
-    'unsorted', then the merge strategy is simply a round-robin.
-
-    This method allows client code to explicitly override the lookup behavior. This
-    method can be useful when you know, for example, that your BAM files are sorted
-    by coordinate but upstream processes did not set the header tag properly.
-
-    \note This method should \bold not be called while reading alignments via
-    GetNextAlignment() or GetNextAlignmentCore(). For proper results, you should
-    call this method before (or immediately after) opening files, rewinding,
-    jumping, etc. but \bold not once alignment fetching has started. There is
-    nothing in the API to prevent you from doing so, but the results may be
-    unexpected.
-
-    \returns \c true if merge order could be successfully applied
-    \sa BamMultiReader::MergeOrder, GetMergeOrder(), GetNextAlignment(), GetNextAlignmentCore()
-*/
-bool BamMultiReader::SetExplicitMergeOrder(BamMultiReader::MergeOrder order) {
-    return d->SetExplicitMergeOrder(order);
-}
-
-/*! \fn bool BamMultiReader::SetRegion(const BamRegion& region)
-    \brief Sets a target region of interest
-
-    Equivalent to calling BamReader::SetRegion() on all open BAM files.
-
-    \warning BamRegion now represents a zero-based, HALF-OPEN interval.
-    In previous versions of BamTools (0.x & 1.x) all intervals were treated
-    as zero-based, CLOSED.
-
-    \param[in] region desired region-of-interest to activate
-    \returns \c true if ALL readers set the region successfully
-    \sa HasIndexes(), Jump(), BamReader::SetRegion()
-*/
-bool BamMultiReader::SetRegion(const BamRegion& region) {
-    return d->SetRegion(region);
-}
-
-/*! \fn bool BamMultiReader::SetRegion(const int& leftRefID,
-                                       const int& leftPosition,
-                                       const int& rightRefID,
-                                       const int& rightPosition)
-    \brief Sets a target region of interest
-
-    This is an overloaded function. Equivalent to calling BamReader::SetRegion() on all open BAM files.
-
-    \warning This function now expects a zero-based, HALF-OPEN interval.
-    In previous versions of BamTools (0.x & 1.x) all intervals were treated
-    as zero-based, CLOSED.
-
-    \param[in] leftRefID     referenceID of region's left boundary
-    \param[in] leftPosition  position of region's left boundary
-    \param[in] rightRefID    reference ID of region's right boundary
-    \param[in] rightPosition position of region's right boundary
-
-    \returns \c true if ALL readers set the region successfully
-    \sa HasIndexes(), Jump(), BamReader::SetRegion()
-*/
-bool BamMultiReader::SetRegion(const int& leftRefID,
-                               const int& leftPosition,
-                               const int& rightRefID,
-                               const int& rightPosition)
-{
-    return d->SetRegion( BamRegion(leftRefID, leftPosition, rightRefID, rightPosition) );
-}
diff --git a/bamtools/src/api/BamMultiReader.h b/bamtools/src/api/BamMultiReader.h
deleted file mode 100644
index 4f8c133..0000000
--- a/bamtools/src/api/BamMultiReader.h
+++ /dev/null
@@ -1,127 +0,0 @@
-// ***************************************************************************
-// BamMultiReader.h (c) 2010 Erik Garrison, Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 14 January 2013 (DB)
-// ---------------------------------------------------------------------------
-// Convenience class for reading multiple BAM files.
-// ***************************************************************************
-
-#ifndef BAMMULTIREADER_H
-#define BAMMULTIREADER_H
-
-#include "api/api_global.h"
-#include "api/BamReader.h"
-#include <map>
-#include <sstream>
-#include <string>
-#include <utility>
-
-namespace BamTools {
-
-namespace Internal {
-    class BamMultiReaderPrivate;
-} // namespace Internal
-
-class API_EXPORT BamMultiReader {
-
-    // enums
-    public:
-        // possible merge order strategies
-        enum MergeOrder { RoundRobinMerge = 0
-                        , MergeByCoordinate
-                        , MergeByName
-                        };
-
-    // constructor / destructor
-    public:
-        BamMultiReader(void);
-        ~BamMultiReader(void);
-
-    // public interface
-    public:
-
-        // ----------------------
-        // BAM file operations
-        // ----------------------
-
-        // closes all open BAM files
-        bool Close(void);
-        // close only the requested BAM file
-        bool CloseFile(const std::string& filename);
-        // returns list of filenames for all open BAM files
-        const std::vector<std::string> Filenames(void) const;
-        // returns curent merge order strategy
-        BamMultiReader::MergeOrder GetMergeOrder(void) const;
-        // returns true if multireader has any open BAM files
-        bool HasOpenReaders(void) const;
-        // performs random-access jump within current BAM files
-        bool Jump(int refID, int position = 0);
-        // opens BAM files
-        bool Open(const std::vector<std::string>& filenames);
-        // opens a single BAM file, adding to any other current BAM files
-        bool OpenFile(const std::string& filename);
-        // returns file pointers to beginning of alignments
-        bool Rewind(void);
-        // sets an explicit merge order, regardless of the BAM files' SO header tag
-        bool SetExplicitMergeOrder(BamMultiReader::MergeOrder order);
-        // sets the target region of interest
-        bool SetRegion(const BamRegion& region);
-        // sets the target region of interest
-        bool SetRegion(const int& leftRefID,
-                       const int& leftPosition,
-                       const int& rightRefID,
-                       const int& rightPosition);
-
-        // ----------------------
-        // access alignment data
-        // ----------------------
-
-        // retrieves next available alignment
-        bool GetNextAlignment(BamAlignment& alignment);
-        // retrieves next available alignment (without populating the alignment's string data fields)
-        bool GetNextAlignmentCore(BamAlignment& alignment);
-
-        // ----------------------
-        // access auxiliary data
-        // ----------------------
-
-        // returns unified SAM header for all files
-        SamHeader GetHeader(void) const;
-        // returns unified SAM header text for all files
-        std::string GetHeaderText(void) const;
-        // returns number of reference sequences
-        int GetReferenceCount(void) const;
-        // returns all reference sequence entries.
-        const BamTools::RefVector GetReferenceData(void) const;
-        // returns the ID of the reference with this name.
-        int GetReferenceID(const std::string& refName) const;
-
-        // ----------------------
-        // BAM index operations
-        // ----------------------
-
-        // creates index files for current BAM files
-        bool CreateIndexes(const BamIndex::IndexType& type = BamIndex::STANDARD);
-        // returns true if all BAM files have index data available
-        bool HasIndexes(void) const;
-        // looks for index files that match current BAM files
-        bool LocateIndexes(const BamIndex::IndexType& preferredType = BamIndex::STANDARD);
-        // opens index files for current BAM files.
-        bool OpenIndexes(const std::vector<std::string>& indexFilenames);
-
-        // ----------------------
-        // error handling
-        // ----------------------
-
-        // returns a human-readable description of the last error that occurred
-        std::string GetErrorString(void) const;
-
-    // private implementation
-    private:
-        Internal::BamMultiReaderPrivate* d;
-};
-
-} // namespace BamTools
-
-#endif // BAMMULTIREADER_H
diff --git a/bamtools/src/api/BamReader.cpp b/bamtools/src/api/BamReader.cpp
deleted file mode 100644
index 0728d96..0000000
--- a/bamtools/src/api/BamReader.cpp
+++ /dev/null
@@ -1,383 +0,0 @@
-// ***************************************************************************
-// BamReader.cpp (c) 2009 Derek Barnett, Michael Str�mberg
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 18 November 2012 (DB)
-// ---------------------------------------------------------------------------
-// Provides read access to BAM files.
-// ***************************************************************************
-
-#include "api/BamReader.h"
-#include "api/internal/bam/BamReader_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#include <algorithm>
-#include <iostream>
-#include <iterator>
-#include <string>
-#include <vector>
-using namespace std;
-
-/*! \class BamTools::BamReader
-    \brief Provides read access to BAM files.
-*/
-
-/*! \fn BamReader::BamReader(void)
-    \brief constructor
-*/
-BamReader::BamReader(void)
-    : d(new BamReaderPrivate(this))
-{ }
-
-/*! \fn BamReader::~BamReader(void)
-    \brief destructor
-*/
-BamReader::~BamReader(void) {
-    delete d;
-    d = 0;
-}
-
-/*! \fn bool BamReader::Close(void)
-    \brief Closes the current BAM file.
-
-    Also clears out all header and reference data.
-
-    \return \c true if file closed OK
-    \sa IsOpen(), Open()
-*/
-bool BamReader::Close(void) {
-    return d->Close();
-}
-
-/*! \fn bool BamReader::CreateIndex(const BamIndex::IndexType& type)
-    \brief Creates an index file for current BAM file.
-
-    \param[in] type file format to create, see BamIndex::IndexType for available formats
-    \return \c true if index created OK
-    \sa LocateIndex(), OpenIndex()
-*/
-bool BamReader::CreateIndex(const BamIndex::IndexType& type) {
-    return d->CreateIndex(type);
-}
-
-/*! \fn const SamHeader& BamReader::GetConstSamHeader(void) const
-    \brief Returns const reference to SAM header data.
-
-    Allows for read-only queries of SAM header data.
-
-    If you do not need to modify the SAM header, use this method to avoid the
-    potentially expensive copy used by GetHeader().
-
-    \note
-    \returns const reference to header data object
-    \sa GetHeader(), GetHeaderText()
-*/
-const SamHeader& BamReader::GetConstSamHeader(void) const {
-    return d->GetConstSamHeader();
-}
-
-/*! \fn std::string BamReader::GetErrorString(void) const
-    \brief Returns a human-readable description of the last error that occurred
-
-    This method allows elimination of STDERR pollution. Developers of client code
-    may choose how the messages are displayed to the user, if at all.
-
-    \return error description
-*/
-string BamReader::GetErrorString(void) const {
-    return d->GetErrorString();
-}
-
-/*! \fn const std::string BamReader::GetFilename(void) const
-    \brief Returns name of current BAM file.
-
-    Retrieved filename will contain whatever was passed via Open().
-    If you need full directory paths here, be sure to include them
-    when you open the BAM file.
-
-    \returns name of open BAM file. If no file is open, returns an empty string.
-    \sa IsOpen()
-*/
-const std::string BamReader::GetFilename(void) const {
-    return d->Filename();
-}
-
-/*! \fn SamHeader BamReader::GetHeader(void) const
-    \brief Returns SAM header data.
-
-    Header data is wrapped in a SamHeader object that can be conveniently queried and/or modified.
-    If you only need read access, consider using GetConstSamHeader() instead.
-
-    \note Modifying the retrieved SamHeader object does NOT affect the
-    current BAM file. This file has been opened in a read-only mode.
-    However, your modified SamHeader object can be used in conjunction with
-    BamWriter to generate a new BAM file with the appropriate header information.
-
-    \returns header data object
-    \sa GetConstSamHeader(), GetHeaderText()
-*/
-SamHeader BamReader::GetHeader(void) const {
-    return d->GetSamHeader();
-}
-
-/*! \fn std::string BamReader::GetHeaderText(void) const
-    \brief Returns SAM header data, as SAM-formatted text.
-
-    \note Modifying the retrieved text does NOT affect the current
-    BAM file. This file has been opened in a read-only mode. However,
-    your modified header text can be used in conjunction with BamWriter
-    to generate a new BAM file with the appropriate header information.
-
-    \returns SAM-formatted header text
-    \sa GetHeader()
-*/
-std::string BamReader::GetHeaderText(void) const {
-    return d->GetHeaderText();
-}
-
-/*! \fn bool BamReader::GetNextAlignment(BamAlignment& alignment)
-    \brief Retrieves next available alignment.
-
-    Attempts to read the next alignment record from BAM file, and checks to see
-    if it overlaps the current region. If no region is currently set, then the
-    next alignment available is always considered valid.
-
-    If a region has been set, via Jump() or SetRegion(), an alignment is only
-    considered valid if it overlaps the region. If the actual 'next' alignment record
-    in the BAM file does not overlap this region, then this function will read sequentially
-    through the file until the next alignment that overlaps this region is found.
-    Once the region has been exhausted (i.e. the next alignment loaded is beyond the region),
-    the function aborts and returns \c false. In this case, there is no point to continue
-    reading, assuming properly sorted alignments.
-
-    This function fully populates all of the alignment's available data fields,
-    including the string data fields (read name, bases, qualities, tags, filename).
-    If only positional data (refID, position, CIGAR ops, alignment flags, etc.)
-    are required, consider using GetNextAlignmentCore() for a significant
-    performance boost.
-
-    \param[out] alignment destination for alignment record data
-    \returns \c true if a valid alignment was found
-*/
-bool BamReader::GetNextAlignment(BamAlignment& alignment) {
-    return d->GetNextAlignment(alignment);
-}
-
-/*! \fn bool BamReader::GetNextAlignmentCore(BamAlignment& alignment)
-    \brief Retrieves next available alignment, without populating the alignment's string data fields.
-
-    Equivalent to GetNextAlignment() with respect to what is a valid overlapping alignment.
-
-    However, this method does NOT populate the alignment's string data fields
-    (read name, bases, qualities, tags, filename). This provides a boost in speed
-    when these fields are not required for every alignment. These fields can be
-    populated 'lazily' (as needed) by calling BamAlignment::BuildCharData() later.
-
-    \param[out] alignment destination for alignment record data
-    \returns \c true if a valid alignment was found
-    \sa SetRegion()
-*/
-bool BamReader::GetNextAlignmentCore(BamAlignment& alignment) {
-    return d->GetNextAlignmentCore(alignment);
-}
-
-/*! \fn int BamReader::GetReferenceCount(void) const
-    \brief Returns number of reference sequences.
-*/
-int BamReader::GetReferenceCount(void) const {
-    return d->GetReferenceCount();
-}
-
-/*! \fn const RefVector& BamReader::GetReferenceData(void) const
-    \brief Returns all reference sequence entries.
-    \sa RefData
-*/
-const RefVector& BamReader::GetReferenceData(void) const {
-    return d->GetReferenceData();
-}
-
-/*! \fn int BamReader::GetReferenceID(const std::string& refName) const
-    \brief Returns the ID of the reference with this name.
-
-    If \a refName is not found, returns -1.
-
-    \param[in] refName name of reference to look up
-*/
-int BamReader::GetReferenceID(const std::string& refName) const {
-    return d->GetReferenceID(refName);
-}
-
-/*! \fn bool BamReader::HasIndex(void) const
-    \brief Returns \c true if index data is available.
-*/
-bool BamReader::HasIndex(void) const {
-    return d->HasIndex();
-}
-
-/*! \fn bool BamReader::IsOpen(void) const
-    \brief Returns \c true if a BAM file is open for reading.
-*/
-bool BamReader::IsOpen(void) const {
-    return d->IsOpen();
-}
-
-/*! \fn bool BamReader::Jump(int refID, int position)
-    \brief Performs a random-access jump within BAM file.
-
-    This is a convenience method, equivalent to calling SetRegion()
-    with only a left boundary specified.
-
-    \param[in] refID    left-bound reference ID
-    \param[in] position left-bound position
-
-    \returns \c true if jump was successful
-    \sa HasIndex()
-*/
-bool BamReader::Jump(int refID, int position) {
-    return d->SetRegion( BamRegion(refID, position) );
-}
-
-/*! \fn bool BamReader::LocateIndex(const BamIndex::IndexType& preferredType)
-    \brief Looks in BAM file's directory for a matching index file.
-
-    Use this function when you need an index file, and perhaps have a
-    preferred index format, but do not depend heavily on which format
-    actually gets loaded at runtime.
-
-    This function will defer to your \a preferredType whenever possible.
-    However, if an index file of \a preferredType can not be found, then
-    it will look for any other index file that corresponds to this BAM file.
-
-    If you want precise control over which index file is loaded, use OpenIndex()
-    with the desired index filename. If that function returns false, you can use
-    CreateIndex() to then build an index of the exact requested format.
-
-    \param[in] preferredType desired index file format, see BamIndex::IndexType for available formats
-
-    \returns \c true if (any) index file could be found
-*/
-bool BamReader::LocateIndex(const BamIndex::IndexType& preferredType) {
-    return d->LocateIndex(preferredType);
-}
-
-/*! \fn bool BamReader::Open(const std::string& filename)
-    \brief Opens a BAM file.
-
-    If BamReader is already opened on another file, this function closes
-    that file, then attempts to open requested \a filename.
-
-    \param[in] filename name of BAM file to open
-
-    \returns \c true if BAM file was opened successfully
-    \sa Close(), IsOpen(), OpenIndex()
-*/
-bool BamReader::Open(const std::string& filename) {
-    return d->Open(filename);
-}
-
-/*! \fn bool BamReader::OpenIndex(const std::string& indexFilename)
-    \brief Opens a BAM index file.
-
-    \param[in] indexFilename name of BAM index file to open
-
-    \returns \c true if BAM index file was opened & data loaded successfully
-    \sa LocateIndex(), Open(), SetIndex()
-*/
-bool BamReader::OpenIndex(const std::string& indexFilename) {
-    return d->OpenIndex(indexFilename);
-}
-
-/*! \fn bool BamReader::Rewind(void)
-    \brief Returns the internal file pointer to the first alignment record.
-
-    Useful for performing multiple sequential passes through a BAM file.
-    Calling this function clears any prior region that may have been set.
-
-    \note This function sets the file pointer to first alignment record
-    in the BAM file, NOT the beginning of the file.
-
-    \returns \c true if rewind operation was successful
-    \sa Jump(), SetRegion()
-*/
-bool BamReader::Rewind(void) {
-    return d->Rewind();
-}
-
-/*! \fn void BamReader::SetIndex(BamIndex* index)
-    \brief Sets a custom BamIndex on this reader.
-
-    Only necessary for custom BamIndex subclasses. Most clients should
-    never have to use this function.
-
-    Example:
-    \code
-        BamReader reader;
-        reader.SetIndex(new MyCustomBamIndex);
-    \endcode
-
-    \note BamReader takes ownership of \a index - i.e. the BamReader will
-    take care of deleting it when the reader is destructed, when the current
-    BAM file is closed, or when a new index is requested.
-
-    \param[in] index custom BamIndex subclass created by client
-    \sa CreateIndex(), LocateIndex(), OpenIndex()
-*/
-void BamReader::SetIndex(BamIndex* index) {
-    d->SetIndex(index);
-}
-
-/*! \fn bool BamReader::SetRegion(const BamRegion& region)
-    \brief Sets a target region of interest
-
-    Requires that index data be available. Attempts a random-access
-    jump in the BAM file, near \a region left boundary position.
-
-    Subsequent calls to GetNextAlignment() or GetNextAlignmentCore()
-    will only return \c true when alignments can be found that overlap
-    this \a region.
-
-    A \a region with no right boundary is considered open-ended, meaning
-    that all alignments that lie downstream of the left boundary are
-    considered valid, continuing to the end of the BAM file.
-
-    \warning BamRegion now represents a zero-based, HALF-OPEN interval.
-    In previous versions of BamTools (0.x & 1.x) all intervals were treated
-    as zero-based, CLOSED.
-
-    \param[in] region desired region-of-interest to activate
-
-    \returns \c true if reader was able to jump successfully to the region's left boundary
-    \sa HasIndex(), Jump()
-*/
-bool BamReader::SetRegion(const BamRegion& region) {
-    return d->SetRegion(region);
-}
-
-/*! \fn bool BamReader::SetRegion(const int& leftRefID,
-                                  const int& leftPosition,
-                                  const int& rightRefID,
-                                  const int& rightPosition)
-    \brief Sets a target region of interest.
-
-    This is an overloaded function.
-
-    \warning This function expects a zero-based, HALF-OPEN interval.
-    In previous versions of BamTools (0.x & 1.x) all intervals were treated
-    as zero-based, CLOSED.
-
-    \param[in] leftRefID     referenceID of region's left boundary
-    \param[in] leftPosition  position of region's left boundary
-    \param[in] rightRefID    reference ID of region's right boundary
-    \param[in] rightPosition position of region's right boundary
-
-    \returns \c true if reader was able to jump successfully to the region's left boundary
-    \sa HasIndex(), Jump()
-*/
-bool BamReader::SetRegion(const int& leftRefID,
-                          const int& leftBound,
-                          const int& rightRefID,
-                          const int& rightBound)
-{
-    return d->SetRegion( BamRegion(leftRefID, leftBound, rightRefID, rightBound) );
-}
diff --git a/bamtools/src/api/BamReader.h b/bamtools/src/api/BamReader.h
deleted file mode 100644
index 15b4135..0000000
--- a/bamtools/src/api/BamReader.h
+++ /dev/null
@@ -1,119 +0,0 @@
-// ***************************************************************************
-// BamReader.h (c) 2009 Derek Barnett, Michael Str�mberg
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 18 November 2012 (DB)
-// ---------------------------------------------------------------------------
-// Provides read access to BAM files.
-// ***************************************************************************
-
-#ifndef BAMREADER_H
-#define BAMREADER_H
-
-#include "api/api_global.h"
-#include "api/BamAlignment.h"
-#include "api/BamIndex.h"
-#include "api/SamHeader.h"
-#include <string>
-
-namespace BamTools {
-  
-namespace Internal {
-    class BamReaderPrivate;
-} // namespace Internal
-
-class API_EXPORT BamReader {
-
-    // constructor / destructor
-    public:
-        BamReader(void);
-        ~BamReader(void);
-
-    // public interface
-    public:
-
-        // ----------------------
-        // BAM file operations
-        // ----------------------
-
-        // closes the current BAM file
-        bool Close(void);
-        // returns filename of current BAM file
-        const std::string GetFilename(void) const;
-        // returns true if a BAM file is open for reading
-        bool IsOpen(void) const;
-        // performs random-access jump within BAM file
-        bool Jump(int refID, int position = 0);
-        // opens a BAM file
-        bool Open(const std::string& filename);
-        // returns internal file pointer to beginning of alignment data
-        bool Rewind(void);
-        // sets the target region of interest
-        bool SetRegion(const BamRegion& region);
-        // sets the target region of interest
-        bool SetRegion(const int& leftRefID,
-                       const int& leftPosition,
-                       const int& rightRefID,
-                       const int& rightPosition);
-
-        // ----------------------
-        // access alignment data
-        // ----------------------
-
-        // retrieves next available alignment
-        bool GetNextAlignment(BamAlignment& alignment);
-        // retrieves next available alignmnet (without populating the alignment's string data fields)
-        bool GetNextAlignmentCore(BamAlignment& alignment);
-
-        // ----------------------
-        // access header data
-        // ----------------------
-
-        // returns a read-only reference to SAM header data
-        const SamHeader& GetConstSamHeader(void) const;
-        // returns an editable copy of SAM header data
-        SamHeader GetHeader(void) const;
-        // returns SAM header data, as SAM-formatted text
-        std::string GetHeaderText(void) const;
-
-        // ----------------------
-        // access reference data
-        // ----------------------
-
-        // returns the number of reference sequences
-        int GetReferenceCount(void) const;
-        // returns all reference sequence entries
-        const RefVector& GetReferenceData(void) const;
-        // returns the ID of the reference with this name
-        int GetReferenceID(const std::string& refName) const;
-
-        // ----------------------
-        // BAM index operations
-        // ----------------------
-
-        // creates an index file for current BAM file, using the requested index type
-        bool CreateIndex(const BamIndex::IndexType& type = BamIndex::STANDARD);
-        // returns true if index data is available
-        bool HasIndex(void) const;
-        // looks in BAM file's directory for a matching index file
-        bool LocateIndex(const BamIndex::IndexType& preferredType = BamIndex::STANDARD);
-        // opens a BAM index file
-        bool OpenIndex(const std::string& indexFilename);
-        // sets a custom BamIndex on this reader
-        void SetIndex(BamIndex* index);
-
-        // ----------------------
-        // error handling
-        // ----------------------
-
-        // returns a human-readable description of the last error that occurred
-        std::string GetErrorString(void) const;
-        
-    // private implementation
-    private:
-        Internal::BamReaderPrivate* d;
-};
-
-} // namespace BamTools
-
-#endif // BAMREADER_H
diff --git a/bamtools/src/api/BamWriter.cpp b/bamtools/src/api/BamWriter.cpp
deleted file mode 100644
index cbbfdae..0000000
--- a/bamtools/src/api/BamWriter.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-// ***************************************************************************
-// BamWriter.cpp (c) 2009 Michael Str�mberg, Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 25 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides the basic functionality for producing BAM files
-// ***************************************************************************
-
-#include "api/BamAlignment.h"
-#include "api/BamWriter.h"
-#include "api/SamHeader.h"
-#include "api/internal/bam/BamWriter_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-using namespace std;
-
-/*! \class BamTools::BamWriter
-    \brief Provides write access for generating BAM files.
-*/
-/*! \enum BamTools::BamWriter::CompressionMode
-    \brief This enum describes the compression behaviors for output BAM files.
-*/
-/*! \var BamWriter::CompressionMode BamWriter::Compressed
-    \brief Use normal BAM compression
-*/
-/*! \var BamWriter::CompressionMode BamWriter::Uncompressed
-    \brief Disable BAM compression
-
-    Useful in situations where the BAM data is streamed (e.g. piping).
-    It would be wasteful to compress, and then immediately decompress
-    the data.
-*/
-
-/*! \fn BamWriter::BamWriter(void)
-    \brief constructor
-*/
-BamWriter::BamWriter(void)
-    : d(new BamWriterPrivate)
-{ }
-
-/*! \fn BamWriter::~BamWriter(void)
-    \brief destructor
-*/
-BamWriter::~BamWriter(void) {
-    delete d;
-    d = 0;
-}
-
-/*! \fn BamWriter::Close(void)
-    \brief Closes the current BAM file.
-    \sa Open()
-*/
-void BamWriter::Close(void) {
-    d->Close();
-}
-
-/*! \fn std::string BamWriter::GetErrorString(void) const
-    \brief Returns a human-readable description of the last error that occurred
-
-    This method allows elimination of STDERR pollution. Developers of client code
-    may choose how the messages are displayed to the user, if at all.
-
-    \return error description
-*/
-std::string BamWriter::GetErrorString(void) const {
-    return d->GetErrorString();
-}
-
-/*! \fn bool BamWriter::IsOpen(void) const
-    \brief Returns \c true if BAM file is open for writing.
-    \sa Open()
-*/
-bool BamWriter::IsOpen(void) const {
-    return d->IsOpen();
-}
-
-/*! \fn bool BamWriter::Open(const std::string& filename,
-                             const std::string& samHeaderText,
-                             const RefVector& referenceSequences)
-    \brief Opens a BAM file for writing.
-
-    Will overwrite the BAM file if it already exists.
-
-    \param[in] filename           name of output BAM file
-    \param[in] samHeaderText      header data, as SAM-formatted string
-    \param[in] referenceSequences list of reference entries
-
-    \return \c true if opened successfully
-    \sa Close(), IsOpen(), BamReader::GetHeaderText(), BamReader::GetReferenceData()
-*/
-bool BamWriter::Open(const std::string& filename,
-                     const std::string& samHeaderText,
-                     const RefVector& referenceSequences)
-{
-    return d->Open(filename, samHeaderText, referenceSequences);
-}
-
-/*! \fn bool BamWriter::Open(const std::string& filename,
-                             const SamHeader& samHeader,
-                             const RefVector& referenceSequences)
-    \brief Opens a BAM file for writing.
-
-    This is an overloaded function.
-
-    Will overwrite the BAM file if it already exists.
-
-    \param[in] filename           name of output BAM file
-    \param[in] samHeader          header data, wrapped in SamHeader object
-    \param[in] referenceSequences list of reference entries
-
-    \return \c true if opened successfully
-    \sa Close(), IsOpen(), BamReader::GetHeader(), BamReader::GetReferenceData()
-*/
-bool BamWriter::Open(const std::string& filename,
-                     const SamHeader& samHeader,
-                     const RefVector& referenceSequences)
-{
-    return d->Open(filename, samHeader.ToString(), referenceSequences);
-}
-
-/*! \fn void BamWriter::SaveAlignment(const BamAlignment& alignment)
-    \brief Saves an alignment to the BAM file.
-
-    \param[in] alignment BamAlignment record to save
-    \sa BamReader::GetNextAlignment(), BamReader::GetNextAlignmentCore()
-*/
-bool BamWriter::SaveAlignment(const BamAlignment& alignment) {
-    return d->SaveAlignment(alignment);
-}
-
-/*! \fn void BamWriter::SetCompressionMode(const BamWriter::CompressionMode& compressionMode)
-    \brief Sets the output compression mode.
-
-    Default mode is BamWriter::Compressed.
-
-    \note Changing the compression mode is disabled on open files (i.e. the request will
-    be ignored). Be sure to call this function before opening the BAM file.
-
-    \code
-        BamWriter writer;
-        writer.SetCompressionMode(BamWriter::Uncompressed);
-        writer.Open( ... );
-        // ...
-    \endcode
-
-    \param[in] compressionMode desired output compression behavior
-    \sa IsOpen(), Open()
-*/
-void BamWriter::SetCompressionMode(const BamWriter::CompressionMode& compressionMode) {
-    d->SetWriteCompressed( compressionMode == BamWriter::Compressed );
-}
diff --git a/bamtools/src/api/BamWriter.h b/bamtools/src/api/BamWriter.h
deleted file mode 100644
index 68257ee..0000000
--- a/bamtools/src/api/BamWriter.h
+++ /dev/null
@@ -1,69 +0,0 @@
-// ***************************************************************************
-// BamWriter.h (c) 2009 Michael Str�mberg, Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides the basic functionality for producing BAM files
-// ***************************************************************************
-
-#ifndef BAMWRITER_H
-#define BAMWRITER_H
-
-#include "api/api_global.h"
-#include "api/BamAux.h"
-#include <string>
-
-namespace BamTools {
-
-class BamAlignment;
-class SamHeader;
-
-//! \cond
-namespace Internal {
-    class BamWriterPrivate;
-} // namespace Internal
-//! \endcond
-
-class API_EXPORT BamWriter {
-
-    // enums
-    public:
-        enum CompressionMode { Compressed = 0
-                             , Uncompressed
-                             };
-
-    // ctor & dtor
-    public:
-        BamWriter(void);
-        ~BamWriter(void);
-
-    // public interface
-    public:
-        //  closes the current BAM file
-        void Close(void);
-        // returns a human-readable description of the last error that occurred
-        std::string GetErrorString(void) const;
-        // returns true if BAM file is open for writing
-        bool IsOpen(void) const;
-        // opens a BAM file for writing
-        bool Open(const std::string& filename, 
-                  const std::string& samHeaderText,
-                  const RefVector& referenceSequences);
-        // opens a BAM file for writing
-        bool Open(const std::string& filename,
-                  const SamHeader& samHeader,
-                  const RefVector& referenceSequences);
-        // saves the alignment to the alignment archive
-        bool SaveAlignment(const BamAlignment& alignment);
-        // sets the output compression mode
-        void SetCompressionMode(const BamWriter::CompressionMode& compressionMode);
-
-    // private implementation
-    private:
-        Internal::BamWriterPrivate* d;
-};
-
-} // namespace BamTools
-
-#endif // BAMWRITER_H
diff --git a/bamtools/src/api/CMakeLists.txt b/bamtools/src/api/CMakeLists.txt
deleted file mode 100644
index 7e3d3ca..0000000
--- a/bamtools/src/api/CMakeLists.txt
+++ /dev/null
@@ -1,83 +0,0 @@
-# ==========================
-# BamTools CMakeLists.txt
-# (c) 2010 Derek Barnett
-#
-# src/api/
-# ==========================
-
-# list include paths
-include_directories( ${BamTools_SOURCE_DIR}/src )
-
-# add compiler definitions 
-add_definitions( -DBAMTOOLS_API_LIBRARY ) # (for proper exporting of library symbols)
-add_definitions( -fPIC ) # (attempt to force PIC compiling on CentOS, not being set on shared libs by CMake)
-
-# fetch all internal source files
-add_subdirectory( internal )
-
-# make list of all API source files
-set( BamToolsAPISources
-        BamAlignment.cpp
-        BamMultiReader.cpp
-        BamReader.cpp
-        BamWriter.cpp
-        SamHeader.cpp
-        SamProgram.cpp
-        SamProgramChain.cpp
-        SamReadGroup.cpp
-        SamReadGroupDictionary.cpp
-        SamSequence.cpp
-        SamSequenceDictionary.cpp
-        ${InternalSources}
-)
-
-# create main BamTools API shared library
-add_library( BamTools SHARED ${BamToolsAPISources} )
-set_target_properties( BamTools PROPERTIES
-                       SOVERSION "2.3.0"
-                       OUTPUT_NAME "bamtools" )
-
-# create main BamTools API static library
-add_library( BamTools-static STATIC ${BamToolsAPISources} )
-set_target_properties( BamTools-static PROPERTIES 
-                       OUTPUT_NAME "bamtools" 
-                       PREFIX "lib" )
-
-# link libraries automatically with zlib (and Winsock2, if applicable)
-if( WIN32 )
-    set( APILibs z ws2_32 )
-else()
-    set( APILibs z )
-endif()
-
-target_link_libraries( BamTools        ${APILibs} )
-target_link_libraries( BamTools-static ${APILibs} )
-
-# set library install destinations
-install( TARGETS BamTools        LIBRARY DESTINATION "lib/bamtools" RUNTIME DESTINATION "bin")
-install( TARGETS BamTools-static ARCHIVE DESTINATION "lib/bamtools")
-
-# export API headers
-include(../ExportHeader.cmake)
-set(ApiIncludeDir "api")
-ExportHeader(APIHeaders api_global.h             ${ApiIncludeDir})
-ExportHeader(APIHeaders BamAlgorithms.h          ${ApiIncludeDir})
-ExportHeader(APIHeaders BamAlignment.h           ${ApiIncludeDir})
-ExportHeader(APIHeaders BamAux.h                 ${ApiIncludeDir})
-ExportHeader(APIHeaders BamConstants.h           ${ApiIncludeDir})
-ExportHeader(APIHeaders BamIndex.h               ${ApiIncludeDir})
-ExportHeader(APIHeaders BamMultiReader.h         ${ApiIncludeDir})
-ExportHeader(APIHeaders BamReader.h              ${ApiIncludeDir})
-ExportHeader(APIHeaders BamWriter.h              ${ApiIncludeDir})
-ExportHeader(APIHeaders IBamIODevice.h           ${ApiIncludeDir})
-ExportHeader(APIHeaders SamConstants.h           ${ApiIncludeDir})
-ExportHeader(APIHeaders SamHeader.h              ${ApiIncludeDir})
-ExportHeader(APIHeaders SamProgram.h             ${ApiIncludeDir})
-ExportHeader(APIHeaders SamProgramChain.h        ${ApiIncludeDir})
-ExportHeader(APIHeaders SamReadGroup.h           ${ApiIncludeDir})
-ExportHeader(APIHeaders SamReadGroupDictionary.h ${ApiIncludeDir})
-ExportHeader(APIHeaders SamSequence.h            ${ApiIncludeDir})
-ExportHeader(APIHeaders SamSequenceDictionary.h  ${ApiIncludeDir})
-
-set( AlgorithmsIncludeDir "api/algorithms" )
-ExportHeader( AlgorithmsHeaders algorithms/Sort.h ${AlgorithmsIncludeDir} )
diff --git a/bamtools/src/api/IBamIODevice.h b/bamtools/src/api/IBamIODevice.h
deleted file mode 100644
index cf64129..0000000
--- a/bamtools/src/api/IBamIODevice.h
+++ /dev/null
@@ -1,98 +0,0 @@
-// ***************************************************************************
-// IBamIODevice.h (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 November 2011 (DB)
-// ---------------------------------------------------------------------------
-// Base class for all BAM I/O devices (e.g. local file, pipe, HTTP, FTP, etc.)
-//
-// Derived classes should provide protocol-specific implementations for
-// reading/writing plain bytes, as well as other I/O-related behaviors.
-//
-// Since IBamIODevices may be defined in client code, the internal
-// BamExceptions are NOT allowed to be thrown from devices, including the
-// built-in ones. This keeps a consistent interface at the BgzfStream for
-// handling any device type. Use the error string for relaying error messages.
-// ***************************************************************************
-
-#ifndef IBAMIODEVICE_H
-#define IBAMIODEVICE_H
-
-#include "api/api_global.h"
-#include <cstdio>
-#include <string>
-
-namespace BamTools {
-
-class API_EXPORT IBamIODevice {
-
-    // enums
-    public: enum OpenMode { NotOpen   = 0x0000
-                          , ReadOnly  = 0x0001
-                          , WriteOnly = 0x0002
-                          , ReadWrite = ReadOnly | WriteOnly
-                          };
-
-    // ctor & dtor
-    public:
-        virtual ~IBamIODevice(void) { }
-
-    // IBamIODevice interface
-    public:
-
-        // TODO: add seek(pos, *from*)
-
-        // pure virtuals
-        virtual void Close(void) =0;
-        virtual bool IsRandomAccess(void) const =0;
-        virtual bool Open(const OpenMode mode) =0;
-        virtual int64_t Read(char* data, const unsigned int numBytes) =0;
-        virtual bool Seek(const int64_t& position, const int origin = SEEK_SET) =0;
-        virtual int64_t Tell(void) const =0;
-        virtual int64_t Write(const char* data, const unsigned int numBytes) =0;
-
-        // default implementation provided
-        virtual std::string GetErrorString(void);
-        virtual bool IsOpen(void) const;
-        virtual OpenMode Mode(void) const;
-
-    // internal methods
-    protected:
-        IBamIODevice(void); // hidden ctor
-        void SetErrorString(const std::string& where, const std::string& what);
-
-    // data members
-    protected:
-        OpenMode    m_mode;
-        std::string m_errorString;
-};
-
-inline
-IBamIODevice::IBamIODevice(void)
-    : m_mode(IBamIODevice::NotOpen)
-{ }
-
-inline
-std::string IBamIODevice::GetErrorString(void) {
-    return m_errorString;
-}
-
-inline
-bool IBamIODevice::IsOpen(void) const {
-    return ( m_mode != IBamIODevice::NotOpen );
-}
-
-inline
-IBamIODevice::OpenMode IBamIODevice::Mode(void) const {
-    return m_mode;
-}
-
-inline
-void IBamIODevice::SetErrorString(const std::string& where, const std::string& what) {
-    static const std::string SEPARATOR = ": ";
-    m_errorString = where + SEPARATOR + what;
-}
-
-} // namespace BamTools
-
-#endif // IBAMIODEVICE_H
diff --git a/bamtools/src/api/SamConstants.h b/bamtools/src/api/SamConstants.h
deleted file mode 100644
index 4bb7ee9..0000000
--- a/bamtools/src/api/SamConstants.h
+++ /dev/null
@@ -1,97 +0,0 @@
-// ***************************************************************************
-// SamConstants.h (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 27 March 2012 (DB)
-// ---------------------------------------------------------------------------
-// Provides constants for SAM header
-// ***************************************************************************
-
-#ifndef SAM_CONSTANTS_H
-#define SAM_CONSTANTS_H
-
-#include "api/api_global.h"
-#include <string>
-
-namespace BamTools {
-namespace Constants {
-
-// basic char constants used in SAM format
-const char SAM_COLON  = ':';
-const char SAM_EQUAL  = '=';
-const char SAM_PERIOD = '.';
-const char SAM_STAR   = '*';
-const char SAM_TAB    = '\t';
-const std::string SAM_DIGITS = "0123456789";
-
-const std::string SAM_CURRENT_VERSION = "1.4";
-
-// HD entries
-const std::string SAM_HD_BEGIN_TOKEN    = "@HD";
-const std::string SAM_HD_VERSION_TAG    = "VN";
-const std::string SAM_HD_SORTORDER_TAG  = "SO";
-const std::string SAM_HD_GROUPORDER_TAG = "GO";
-
-// SQ entries
-const std::string SAM_SQ_BEGIN_TOKEN    = "@SQ";
-const std::string SAM_SQ_ASSEMBLYID_TAG = "AS";
-const std::string SAM_SQ_CHECKSUM_TAG   = "M5";
-const std::string SAM_SQ_LENGTH_TAG     = "LN";
-const std::string SAM_SQ_NAME_TAG       = "SN";
-const std::string SAM_SQ_SPECIES_TAG    = "SP";
-const std::string SAM_SQ_URI_TAG        = "UR";
-
-// RG entries
-const std::string SAM_RG_BEGIN_TOKEN             = "@RG";
-const std::string SAM_RG_DESCRIPTION_TAG         = "DS";
-const std::string SAM_RG_FLOWORDER_TAG           = "FO";
-const std::string SAM_RG_ID_TAG                  = "ID";
-const std::string SAM_RG_KEYSEQUENCE_TAG         = "KS";
-const std::string SAM_RG_LIBRARY_TAG             = "LB";
-const std::string SAM_RG_PLATFORMUNIT_TAG        = "PU";
-const std::string SAM_RG_PREDICTEDINSERTSIZE_TAG = "PI";
-const std::string SAM_RG_PRODUCTIONDATE_TAG      = "DT";
-const std::string SAM_RG_PROGRAM_TAG             = "PG";
-const std::string SAM_RG_SAMPLE_TAG              = "SM";
-const std::string SAM_RG_SEQCENTER_TAG           = "CN";
-const std::string SAM_RG_SEQTECHNOLOGY_TAG       = "PL";
-
-// PG entries
-const std::string SAM_PG_BEGIN_TOKEN         = "@PG";
-const std::string SAM_PG_COMMANDLINE_TAG     = "CL";
-const std::string SAM_PG_ID_TAG              = "ID";
-const std::string SAM_PG_NAME_TAG            = "PN";
-const std::string SAM_PG_PREVIOUSPROGRAM_TAG = "PP";
-const std::string SAM_PG_VERSION_TAG         = "VN";
-
-// CO entries
-const std::string SAM_CO_BEGIN_TOKEN = "@CO";
-
-// HD:SO values
-const std::string SAM_HD_SORTORDER_COORDINATE = "coordinate";
-const std::string SAM_HD_SORTORDER_QUERYNAME  = "queryname";
-const std::string SAM_HD_SORTORDER_UNKNOWN    = "unknown";
-const std::string SAM_HD_SORTORDER_UNSORTED   = "unsorted";
-
-// HD:GO values
-const std::string SAM_HD_GROUPORDER_NONE      = "none";
-const std::string SAM_HD_GROUPORDER_QUERY     = "query";
-const std::string SAM_HD_GROUPORDER_REFERENCE = "reference";
-
-// SQ:LN values
-const unsigned int SAM_SQ_LENGTH_MIN = 1;
-const unsigned int SAM_SQ_LENGTH_MAX = 536870911; // 2^29 - 1
-
-// RG:PL values
-const std::string SAM_RG_SEQTECHNOLOGY_CAPILLARY  = "CAPILLARY";
-const std::string SAM_RG_SEQTECHNOLOGY_HELICOS    = "HELICOS";
-const std::string SAM_RG_SEQTECHNOLOGY_ILLUMINA   = "ILLUMINA";
-const std::string SAM_RG_SEQTECHNOLOGY_IONTORRENT = "IONTORRENT";
-const std::string SAM_RG_SEQTECHNOLOGY_LS454      = "LS454";
-const std::string SAM_RG_SEQTECHNOLOGY_PACBIO     = "PACBIO";
-const std::string SAM_RG_SEQTECHNOLOGY_SOLID      = "SOLID";
-
-} // namespace Constants
-} // namespace BamTools
-
-#endif // SAM_CONSTANTS_H
diff --git a/bamtools/src/api/SamHeader.cpp b/bamtools/src/api/SamHeader.cpp
deleted file mode 100644
index 9221944..0000000
--- a/bamtools/src/api/SamHeader.cpp
+++ /dev/null
@@ -1,236 +0,0 @@
-// ***************************************************************************
-// SamHeader.cpp (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 25 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides direct read/write access to the SAM header data fields.
-// ***************************************************************************
-
-#include "api/SamConstants.h"
-#include "api/SamHeader.h"
-#include "api/internal/utils/BamException_p.h"
-#include "api/internal/sam/SamFormatParser_p.h"
-#include "api/internal/sam/SamFormatPrinter_p.h"
-#include "api/internal/sam/SamHeaderValidator_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-using namespace std;
-
-/*! \struct BamTools::SamHeader
-    \brief Represents the SAM-formatted text header that is part of the BAM file header.
-
-    Provides direct read/write access to the SAM header data fields.
-
-    \sa \samSpecURL
-*/
-/*! \var SamHeader::Version
-    \brief corresponds to \@HD VN:\<Version\>
-
-    Required for valid SAM header, if \@HD record is present.
-*/
-/*! \var SamHeader::SortOrder
-    \brief corresponds to \@HD SO:\<SortOrder\>
-*/
-/*! \var SamHeader::GroupOrder
-    \brief corresponds to \@HD GO:\<GroupOrder\>
-*/
-/*! \var SamHeader::Sequences
-    \brief corresponds to \@SQ entries
-    \sa SamSequence, SamSequenceDictionary
-*/
-/*! \var SamHeader::ReadGroups
-    \brief corresponds to \@RG entries
-    \sa SamReadGroup, SamReadGroupDictionary
-*/
-/*! \var SamHeader::Programs
-    \brief corresponds to \@PG entries
-    \sa SamProgram, SamProgramChain
-*/
-/*! \var SamHeader::Comments
-    \brief corresponds to \@CO entries
-*/
-
-/*! \fn SamHeader::SamHeader(const std::string& headerText = "")
-    \brief constructor
-*/
-SamHeader::SamHeader(const std::string& headerText)
-    : Version("")
-    , SortOrder(Constants::SAM_HD_SORTORDER_UNKNOWN)
-    , GroupOrder("")
-{
-    SetHeaderText(headerText);
-}
-
-/*! \fn SamHeader::SamHeader(const SamHeader& other)
-    \brief copy constructor
-*/
-SamHeader::SamHeader(const SamHeader& other)
-    : Version(other.Version)
-    , SortOrder(other.SortOrder)
-    , GroupOrder(other.GroupOrder)
-    , Sequences(other.Sequences)
-    , ReadGroups(other.ReadGroups)
-    , Programs(other.Programs)
-    , Comments(other.Comments)
-    , m_errorString(other.GetErrorString())
-{ }
-
-/*! \fn SamHeader::~SamHeader(void)
-    \brief destructor
-*/
-SamHeader::~SamHeader(void) { }
-
-/*! \fn void SamHeader::Clear(void)
-    \brief Clears all header contents.
-*/
-void SamHeader::Clear(void) {
-
-    // clear SAM header components
-    Version.clear();
-    SortOrder.clear();
-    GroupOrder.clear();
-    Sequences.Clear();
-    ReadGroups.Clear();
-    Programs.Clear();
-    Comments.clear();
-
-    // clear error string
-    m_errorString.clear();
-}
-
-/*! \fn std::string SamHeader::GetErrorString(void) const
-    \brief Returns a human-readable description of the last error that occurred
-
-    This method allows elimination of STDERR pollution. Developers of client code
-    may choose how the messages are displayed to the user, if at all.
-
-    \return error description
-*/
-std::string SamHeader::GetErrorString(void) const {
-    return m_errorString;
-}
-
-/*! \fn bool SamHeader::HasError(void) const
-    \brief Returns \c true if header encountered an error
-*/
-bool SamHeader::HasError(void) const {
-    return (!m_errorString.empty());
-}
-
-/*! \fn bool SamHeader::HasVersion(void) const
-    \brief Returns \c true if header contains \@HD ID:\<Version\>
-*/
-bool SamHeader::HasVersion(void) const {
-    return (!Version.empty());
-}
-
-/*! \fn bool SamHeader::HasSortOrder(void) const
-    \brief Returns \c true if header contains \@HD SO:\<SortOrder\>
-*/
-bool SamHeader::HasSortOrder(void) const {
-    return (!SortOrder.empty());
-}
-
-/*! \fn bool SamHeader::HasGroupOrder(void) const
-    \brief Returns \c true if header contains \@HD GO:\<GroupOrder\>
-*/
-bool SamHeader::HasGroupOrder(void) const {
-    return (!GroupOrder.empty());
-}
-
-/*! \fn bool SamHeader::HasSequences(void) const
-    \brief Returns \c true if header contains any \@SQ entries
-*/
-bool SamHeader::HasSequences(void) const {
-    return (!Sequences.IsEmpty());
-}
-
-/*! \fn bool SamHeader::HasReadGroups(void) const
-    \brief Returns \c true if header contains any \@RG entries
-*/
-bool SamHeader::HasReadGroups(void) const {
-    return (!ReadGroups.IsEmpty());
-}
-
-/*! \fn bool SamHeader::HasPrograms(void) const
-    \brief Returns \c true if header contains any \@PG entries
-*/
-bool SamHeader::HasPrograms(void) const {
-    return (!Programs.IsEmpty());
-}
-
-/*! \fn bool SamHeader::HasComments(void) const
-    \brief Returns \c true if header contains any \@CO entries
-*/
-bool SamHeader::HasComments(void) const {
-    return (!Comments.empty());
-}
-
-/*! \fn bool SamHeader::IsValid(bool verbose = false) const
-    \brief Checks header contents for required data and proper formatting.
-
-    \param[in] verbose If set to true, validation errors & warnings will be printed to stderr.
-                       Otherwise, messages are available through SamHeader::GetErrorString().
-    \return \c true if SAM header is well-formed
-*/
-bool SamHeader::IsValid(bool verbose) const {
-
-    SamHeaderValidator validator(*this);
-
-    // if SAM header is valid, return success
-    if ( validator.Validate() )
-        return true;
-
-    // otherwiser
-    else {
-
-        // print messages to stderr
-        if ( verbose )
-            validator.PrintMessages(std::cerr);
-
-        // or catch in local error string
-        else {
-            stringstream errorStream("");
-            validator.PrintMessages(errorStream);
-            m_errorString = errorStream.str();
-        }
-        return false;
-    }
-}
-
-/*! \fn void SamHeader::SetHeaderText(const std::string& headerText)
-    \brief Replaces header contents with \a headerText.
-
-    \param[in] headerText SAM formatted-text that will be parsed into data fields
-*/
-void SamHeader::SetHeaderText(const std::string& headerText) {
-
-    // clear prior data
-    Clear();
-
-    try {
-        SamFormatParser parser(*this);
-        parser.Parse(headerText);
-    } catch ( BamException& e ) {
-
-        // clear anything parsed so far
-        // no telling what's valid and what's partially parsed
-        Clear();
-
-        // set error string
-        m_errorString = e.what();
-    }
-}
-
-/*! \fn std::string SamHeader::ToString(void) const
-    \brief Converts data fields to SAM-formatted text.
-
-    Applies any local modifications made since creating this object or calling SetHeaderText().
-
-    \return SAM-formatted header text
-*/
-string SamHeader::ToString(void) const {
-    SamFormatPrinter printer(*this);
-    return printer.ToString();
-}
diff --git a/bamtools/src/api/SamHeader.h b/bamtools/src/api/SamHeader.h
deleted file mode 100644
index 5004994..0000000
--- a/bamtools/src/api/SamHeader.h
+++ /dev/null
@@ -1,74 +0,0 @@
-// ***************************************************************************
-// SamHeader.h (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides direct read/write access to the SAM header data fields.
-// ***************************************************************************
-
-#ifndef SAM_HEADER_H
-#define SAM_HEADER_H
-
-#include "api/api_global.h"
-#include "api/SamProgramChain.h"
-#include "api/SamReadGroupDictionary.h"
-#include "api/SamSequenceDictionary.h"
-#include <string>
-#include <vector>
-
-namespace BamTools {
-
-struct API_EXPORT SamHeader {
-
-    // ctor & dtor
-    SamHeader(const std::string& headerText = "");
-    SamHeader(const SamHeader& other);
-    ~SamHeader(void);
-
-    // query/modify entire SamHeader
-    void Clear(void);                                   // clears all header contents
-    std::string GetErrorString(void) const;
-    bool HasError(void) const;
-    bool IsValid(bool verbose = false) const;           // returns true if SAM header is well-formed
-    void SetHeaderText(const std::string& headerText);  // replaces data fields with contents of SAM-formatted text
-    std::string ToString(void) const;                   // returns the printable, SAM-formatted header text
-
-    // convenience query methods
-    bool HasVersion(void) const;     // returns true if header contains format version entry
-    bool HasSortOrder(void) const;   // returns true if header contains sort order entry
-    bool HasGroupOrder(void) const;  // returns true if header contains group order entry
-    bool HasSequences(void) const;   // returns true if header contains any sequence entries
-    bool HasReadGroups(void) const;  // returns true if header contains any read group entries
-    bool HasPrograms(void) const;    // returns true if header contains any program record entries
-    bool HasComments(void) const;    // returns true if header contains comments
-
-    // --------------
-    // data members
-    // --------------
-
-    // header metadata (@HD line)
-    std::string Version;             // VN:<Version>  *Required, if @HD record is present*
-    std::string SortOrder;           // SO:<SortOrder>
-    std::string GroupOrder;          // GO:<GroupOrder>
-
-    // header sequences (@SQ entries)
-    SamSequenceDictionary Sequences;
-
-    // header read groups (@RG entries)
-    SamReadGroupDictionary ReadGroups;
-
-    // header program data (@PG entries)
-    SamProgramChain Programs;
-
-    // header comments (@CO entries)
-    std::vector<std::string> Comments;
-
-    // internal data
-    private:
-        mutable std::string m_errorString;
-};
-
-} // namespace BamTools
-
-#endif // SAM_HEADER_H
diff --git a/bamtools/src/api/SamProgram.cpp b/bamtools/src/api/SamProgram.cpp
deleted file mode 100644
index 1720678..0000000
--- a/bamtools/src/api/SamProgram.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-// ***************************************************************************
-// SamProgram.cpp (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides direct read/write access to the SAM header program records.
-// ***************************************************************************
-
-#include "api/SamProgram.h"
-using namespace BamTools;
-using namespace std;
-
-/*! \struct BamTools::SamProgram
-    \brief Represents a SAM program record.
-
-    Provides direct read/write access to the SAM header program records.
-
-    \sa \samSpecURL
-*/
-/*! \var SamProgram::CommandLine
-    \brief corresponds to \@PG CL:\<CommandLine\>
-*/
-/*! \var SamProgram::ID
-    \brief corresponds to \@PG ID:\<ID\>
-
-    Required for valid SAM header.
-*/
-/*! \var SamProgram::Name
-    \brief corresponds to \@PG PN:\<Name\>
-*/
-/*! \var SamProgram::PreviousProgramID
-    \brief corresponds to \@PG PP:\<PreviousProgramID\>
-*/
-/*! \var SamProgram::Version
-    \brief corresponds to \@PG VN:\<Version\>
-*/
-/*! \var SamProgram::NextProgramID
-    \internal
-    Holds ID of the "next" program record in a SamProgramChain
-*/
-
-/*! \fn SamProgram::SamProgram(void)
-    \brief default constructor
-*/
-SamProgram::SamProgram(void)
-    : CommandLine("")
-    , ID("")
-    , Name("")
-    , PreviousProgramID("")
-    , Version("")
-    , NextProgramID("")
-{ }
-
-/*! \fn SamProgram::SamProgram(const std::string& id)
-    \brief constructs program record with \a id
-
-    \param id desired program record ID
-*/
-SamProgram::SamProgram(const std::string& id)
-    : CommandLine("")
-    , ID(id)
-    , Name("")
-    , PreviousProgramID("")
-    , Version("")
-    , NextProgramID("")
-{ }
-
-/*! \fn SamProgram::SamProgram(const SamProgram& other)
-    \brief copy constructor
-*/
-SamProgram::SamProgram(const SamProgram& other)
-    : CommandLine(other.CommandLine)
-    , ID(other.ID)
-    , Name(other.Name)
-    , PreviousProgramID(other.PreviousProgramID)
-    , Version(other.Version)
-    , NextProgramID(other.NextProgramID)
-{ }
-
-/*! \fn SamProgram::~SamProgram(void)
-    \brief destructor
-*/
-SamProgram::~SamProgram(void) { }
-
-/*! \fn void SamProgram::Clear(void)
-    \brief Clears all data fields.
-*/
-void SamProgram::Clear(void) {
-    CommandLine.clear();
-    ID.clear();
-    Name.clear();
-    PreviousProgramID.clear();
-    Version.clear();
-    NextProgramID.clear();
-}
-
-/*! \fn bool SamProgram::HasCommandLine(void) const
-    \brief Returns \c true if program record contains \@PG: CL:\<CommandLine\>
-*/
-bool SamProgram::HasCommandLine(void) const {
-    return (!CommandLine.empty());
-}
-
-/*! \fn bool SamProgram::HasID(void) const
-    \brief Returns \c true if program record contains \@PG: ID:\<ID\>
-*/
-bool SamProgram::HasID(void) const {
-    return (!ID.empty());
-}
-
-/*! \fn bool SamProgram::HasName(void) const
-    \brief Returns \c true if program record contains \@PG: PN:\<Name\>
-*/
-bool SamProgram::HasName(void) const {
-    return (!Name.empty());
-}
-
-/*! \fn bool SamProgram::HasNextProgramID(void) const
-    \internal
-    \return true if program has a "next" record in a SamProgramChain
-*/
-bool SamProgram::HasNextProgramID(void) const {
-    return (!NextProgramID.empty());
-}
-
-/*! \fn bool SamProgram::HasPreviousProgramID(void) const
-    \brief Returns \c true if program record contains \@PG: PP:\<PreviousProgramID\>
-*/
-bool SamProgram::HasPreviousProgramID(void) const {
-    return (!PreviousProgramID.empty());
-}
-
-/*! \fn bool SamProgram::HasVersion(void) const
-    \brief Returns \c true if program record contains \@PG: VN:\<Version\>
-*/
-bool SamProgram::HasVersion(void) const {
-    return (!Version.empty());
-}
diff --git a/bamtools/src/api/SamProgram.h b/bamtools/src/api/SamProgram.h
deleted file mode 100644
index 54da872..0000000
--- a/bamtools/src/api/SamProgram.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// ***************************************************************************
-// SamProgram.h (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides direct read/write access to the SAM header program records.
-// ***************************************************************************
-
-#ifndef SAM_PROGRAM_H
-#define SAM_PROGRAM_H
-
-#include "api/api_global.h"
-#include <string>
-
-namespace BamTools {
-
-class SamProgramChain;
-
-struct API_EXPORT SamProgram {
-
-    // ctor & dtor
-    SamProgram(void);
-    SamProgram(const std::string& id);
-    SamProgram(const SamProgram& other);
-    ~SamProgram(void);
-
-    // query/modify entire program record
-    void Clear(void);                      // clears all data fields
-
-    // convenience query methods
-    bool HasCommandLine(void) const;       // returns true if program record has a command line entry
-    bool HasID(void) const;                // returns true if program record has an ID
-    bool HasName(void) const;              // returns true if program record has a name
-    bool HasPreviousProgramID(void) const; // returns true if program record has a 'previous program ID'
-    bool HasVersion(void) const;           // returns true if program record has a version
-
-    // data members
-    std::string CommandLine;               // CL:<CommandLine>
-    std::string ID;                        // ID:<ID>          *Required for valid SAM header*
-    std::string Name;                      // PN:<Name>
-    std::string PreviousProgramID;         // PP:<PreviousProgramID>
-    std::string Version;                   // VN:<Version>
-
-    // internal (non-standard) methods & fields
-    private:
-        bool HasNextProgramID(void) const;
-        std::string NextProgramID;
-        friend class BamTools::SamProgramChain;
-};
-
-/*! \fn bool operator==(const SamProgram& lhs, const SamProgram& rhs)
-    \brief tests equality by comparing program IDs
-*/
-API_EXPORT inline bool operator==(const SamProgram& lhs, const SamProgram& rhs) {
-    return lhs.ID == rhs.ID;
-}
-
-} // namespace BamTools
-
-#endif // SAM_PROGRAM_H
diff --git a/bamtools/src/api/SamProgramChain.cpp b/bamtools/src/api/SamProgramChain.cpp
deleted file mode 100644
index 88c2185..0000000
--- a/bamtools/src/api/SamProgramChain.cpp
+++ /dev/null
@@ -1,354 +0,0 @@
-// ***************************************************************************
-// SamProgramChain.cpp (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides methods for operating on a SamProgram record "chain"
-// ***************************************************************************
-
-#include "api/SamProgramChain.h"
-using namespace BamTools;
-
-#include <algorithm>
-#include <iostream>
-#include <cstdlib>
-using namespace std;
-
-/*! \class BamTools::SamProgramChain
-    \brief Sorted container "chain" of SamProgram records.
-
-    Provides methods for operating on a collection of SamProgram records.
-
-    \note Underlying container is *NOT* ordered by linkage, but by order of
-    appearance in SamHeader and subsequent Add() calls. Using the current
-    iterators will not allow you to step through the header's program history.
-    Instead use First()/Last() to access oldest/newest records, respectively.
-*/
-
-/*! \fn SamProgramChain::SamProgramChain(void)
-    \brief constructor
-*/
-SamProgramChain::SamProgramChain(void) { }
-
-/*! \fn SamProgramChain::SamProgramChain(const SamProgramChain& other)
-    \brief copy constructor
-*/
-SamProgramChain::SamProgramChain(const SamProgramChain& other)
-    : m_data(other.m_data)
-{ }
-
-/*! \fn SamProgramChain::~SamProgramChain(void)
-    \brief destructor
-*/
-SamProgramChain::~SamProgramChain(void) { }
-
-/*! \fn void SamProgramChain::Add(SamProgram& program)
-    \brief Appends a program to program chain.
-
-    Duplicate entries are silently discarded.
-
-    \note Underlying container is *NOT* ordered by linkage, but by order of
-    appearance in SamHeader and subsequent Add() calls. Using the current
-    iterators will not allow you to step through the header's program history.
-    Instead use First()/Last() to access oldest/newest records, respectively.
-
-    \param[in] program entry to be appended
-*/
-void SamProgramChain::Add(SamProgram& program) {
-
-    // ignore duplicated records
-    if ( Contains(program) )
-        return;
-
-    // if other programs already in chain, try to find the "next" record
-    // tries to match another record's PPID with @program's ID
-    if ( !IsEmpty() )
-        program.NextProgramID = NextIdFor(program.ID);
-
-    // store program record
-    m_data.push_back(program);
-}
-
-/*! \fn void SamProgramChain::Add(std::vector<SamProgram>& programs)
-    \brief Appends a batch of programs to the end of the chain.
-
-    This is an overloaded function.
-
-    \param[in] programs batch of program records to append
-    \sa Add()
-*/
-void SamProgramChain::Add(std::vector<SamProgram>& programs) {
-    vector<SamProgram>::iterator pgIter = programs.begin();
-    vector<SamProgram>::iterator pgEnd  = programs.end();
-    for ( ; pgIter != pgEnd; ++pgIter )
-        Add(*pgIter);
-}
-
-/*! \fn SamProgramIterator SamProgramChain::Begin(void)
-    \return an STL iterator pointing to the first (oldest) program record
-    \sa ConstBegin(), End(), First()
-*/
-SamProgramIterator SamProgramChain::Begin(void) {
-    return m_data.begin();
-}
-
-/*! \fn SamProgramConstIterator SamProgramChain::Begin(void) const
-    \return an STL const_iterator pointing to the first (oldest) program record
-
-    This is an overloaded function.
-
-    \sa ConstBegin(), End(), First()
-*/
-SamProgramConstIterator SamProgramChain::Begin(void) const {
-    return m_data.begin();
-}
-
-/*! \fn void SamProgramChain::Clear(void)
-    \brief Clears all program records.
-*/
-void SamProgramChain::Clear(void) {
-    m_data.clear();
-}
-
-/*! \fn SamProgramConstIterator SamProgramChain::ConstBegin(void) const
-    \return an STL const_iterator pointing to the first (oldest) program record
-    \sa Begin(), ConstEnd(), First()
-*/
-SamProgramConstIterator SamProgramChain::ConstBegin(void) const {
-    return m_data.begin();
-}
-
-/*! \fn SamProgramConstIterator SamProgramChain::ConstEnd(void) const
-    \return an STL const_iterator pointing to the imaginary entry after the last (newest) program record
-    \sa ConstBegin(), End(), Last()
-*/
-SamProgramConstIterator SamProgramChain::ConstEnd(void) const {
-    return m_data.end();
-}
-
-/*! \fn bool SamProgramChain::Contains(const SamProgram& program) const
-    \brief Returns true if chains has this program record (matching on ID).
-
-    This is an overloaded function.
-
-    \param[in] program SamProgram to search for
-    \return \c true if chain contains program (matching on ID)
-*/
-bool SamProgramChain::Contains(const SamProgram& program) const {
-    return Contains(program.ID);
-}
-
-/*! \fn bool SamProgramChain::Contains(const std::string& programId) const
-    \brief Returns true if chains has a program record with this ID
-
-    \param[in] programId search for program matching this ID
-    \return \c true if chain contains a program record with this ID
-*/
-bool SamProgramChain::Contains(const std::string& programId) const {
-    return ( IndexOf(programId) != (int)m_data.size() );
-}
-
-/*! \fn SamProgramIterator SamProgramChain::End(void)
-    \return an STL iterator pointing to the imaginary entry after the last (newest) program record
-    \sa Begin(), ConstEnd(), Last()
-*/
-SamProgramIterator SamProgramChain::End(void) {
-    return m_data.end();
-}
-
-/*! \fn SamProgramConstIterator SamProgramChain::End(void) const
-    \return an STL const_iterator pointing to the imaginary entry after the last (newest) program record
-
-    This is an overloaded function.
-
-    \sa Begin(), ConstEnd(), Last()
-*/
-SamProgramConstIterator SamProgramChain::End(void) const {
-    return m_data.end();
-}
-
-/*! \fn SamProgram& SamProgramChain::First(void)
-    \brief Fetches first (oldest) record in the chain.
-
-    \warning This function will fail if the chain is empty. If this is possible,
-    check the result of IsEmpty() before calling this function.
-
-    \return a modifiable reference to the first (oldest) program entry
-    \sa Begin(), Last()
-*/
-SamProgram& SamProgramChain::First(void) {
-
-    // find first record in container that has no PreviousProgramID entry
-    SamProgramIterator iter = Begin();
-    SamProgramIterator end  = End();
-    for ( ; iter != end; ++iter ) {
-        SamProgram& current = (*iter);
-        if ( !current.HasPreviousProgramID() )
-            return current;
-    }
-
-    // otherwise error
-    cerr << "SamProgramChain::First: could not find any record without a PP tag" << endl;
-    exit(1);
-}
-
-/*! \fn const SamProgram& SamProgramChain::First(void) const
-    \brief Fetches first (oldest) record in the chain.
-
-    This is an overloaded function.
-
-    \warning This function will fail if the chain is empty. If this is possible,
-    check the result of IsEmpty() before calling this function.
-
-    \return a read-only reference to the first (oldest) program entry
-    \sa Begin(), ConstBegin(), Last()
-*/
-const SamProgram& SamProgramChain::First(void) const {
-
-    // find first record in container that has no PreviousProgramID entry
-    SamProgramConstIterator iter = ConstBegin();
-    SamProgramConstIterator end  = ConstEnd();
-    for ( ; iter != end; ++iter ) {
-        const SamProgram& current = (*iter);
-        if ( !current.HasPreviousProgramID() )
-            return current;
-    }
-
-    // otherwise error
-    cerr << "SamProgramChain::First: could not find any record without a PP tag" << endl;
-    exit(1);
-}
-
-/*! \fn int SamProgramChain::IndexOf(const std::string& programId) const
-    \internal
-    \return index of program record if found.
-    Otherwise, returns vector::size() (invalid index).
-*/
-int SamProgramChain::IndexOf(const std::string& programId) const {
-    SamProgramConstIterator begin = ConstBegin();
-    SamProgramConstIterator iter  = begin;
-    SamProgramConstIterator end   = ConstEnd();
-    for ( ; iter != end; ++iter ) {
-        const SamProgram& current = (*iter);
-        if ( current.ID == programId )
-            break;
-    }
-    return distance( begin, iter );
-}
-
-/*! \fn bool SamProgramChain::IsEmpty(void) const
-    \brief Returns \c true if chain contains no records
-    \sa Size()
-*/
-bool SamProgramChain::IsEmpty(void) const {
-    return m_data.empty();
-}
-
-/*! \fn SamProgram& SamProgramChain::Last(void)
-    \brief Fetches last (newest) record in the chain.
-
-    \warning This function will fail if the chain is empty. If this is possible,
-    check the result of IsEmpty() before calling this function.
-
-    \return a modifiable reference to the last (newest) program entry
-    \sa End(), First()
-*/
-SamProgram& SamProgramChain::Last(void) {
-    // find first record in container that has no NextProgramID entry
-    SamProgramIterator iter = Begin();
-    SamProgramIterator end  = End();
-    for ( ; iter != end; ++iter ) {
-        SamProgram& current = (*iter);
-        if ( !current.HasNextProgramID() )
-            return current;
-    }
-
-    // otherwise error
-    cerr << "SamProgramChain::Last: could not determine last record" << endl;
-    exit(1);
-}
-
-/*! \fn const SamProgram& SamProgramChain::Last(void) const
-    \brief Fetches last (newest) record in the chain.
-
-    This is an overloaded function.
-
-    \warning This function will fail if the chain is empty. If this is possible,
-    check the result of IsEmpty() before calling this function.
-
-    \return a read-only reference to the last (newest) program entry
-    \sa End(), ConstEnd(), First()
-*/
-const SamProgram& SamProgramChain::Last(void) const {
-    // find first record in container that has no NextProgramID entry
-    SamProgramConstIterator iter = ConstBegin();
-    SamProgramConstIterator end  = ConstEnd();
-    for ( ; iter != end; ++iter ) {
-        const SamProgram& current = (*iter);
-        if ( !current.HasNextProgramID() )
-            return current;
-    }
-
-    // otherwise error
-    cerr << "SamProgramChain::Last: could not determine last record" << endl;
-    exit(1);
-}
-
-/*! \fn const std::string SamProgramChain::NextIdFor(const std::string& programId) const
-    \internal
-
-    \return ID of program record, whose PreviousProgramID matches \a programId.
-    Otherwise, returns empty string if none found.
-*/
-const std::string SamProgramChain::NextIdFor(const std::string& programId) const {
-
-    // find first record in container whose PreviousProgramID matches @programId
-    SamProgramConstIterator iter = ConstBegin();
-    SamProgramConstIterator end  = ConstEnd();
-    for ( ; iter != end; ++iter ) {
-        const SamProgram& current = (*iter);
-        if ( !current.HasPreviousProgramID() &&
-              current.PreviousProgramID == programId
-           )
-        {
-            return current.ID;
-        }
-    }
-
-    // none found
-    return string();
-}
-
-/*! \fn int SamProgramChain::Size(void) const
-    \brief Returns number of program records in the chain.
-    \sa IsEmpty()
-*/
-int SamProgramChain::Size(void) const {
-    return m_data.size();
-}
-
-/*! \fn SamProgram& SamProgramChain::operator[](const std::string& programId)
-    \brief Retrieves the modifiable SamProgram record that matches \a programId.
-
-    \warning If the chain contains no read group matching this ID, this function will
-    print an error and terminate. Check the return value of Contains() if this may be
-    possible.
-
-    \param[in] programId ID of program record to retrieve
-    \return a modifiable reference to the SamProgram associated with the ID
-*/
-SamProgram& SamProgramChain::operator[](const std::string& programId) {
-
-    // look up program record matching this ID
-    int index = IndexOf(programId);
-
-    // if record not found
-    if ( index == (int)m_data.size() ) {
-        cerr << "SamProgramChain::operator[] - unknown programId: " << programId << endl;
-        exit(1);
-    }
-
-    // otherwise return program record at index
-    return m_data.at(index);
-}
diff --git a/bamtools/src/api/SamProgramChain.h b/bamtools/src/api/SamProgramChain.h
deleted file mode 100644
index a2bd532..0000000
--- a/bamtools/src/api/SamProgramChain.h
+++ /dev/null
@@ -1,85 +0,0 @@
-// ***************************************************************************
-// SamProgramChain.h (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides methods for operating on a SamProgram record "chain"
-// ***************************************************************************
-
-#ifndef SAM_PROGRAMCHAIN_H
-#define SAM_PROGRAMCHAIN_H
-
-#include "api/api_global.h"
-#include "api/SamProgram.h"
-#include <string>
-#include <vector>
-
-namespace BamTools {
-
-// chain is *NOT* sorted in any order
-// use First()/Last() to retrieve oldest/newest programs, respectively
-typedef std::vector<SamProgram>             SamProgramContainer;
-typedef SamProgramContainer::iterator       SamProgramIterator;
-typedef SamProgramContainer::const_iterator SamProgramConstIterator;
-
-class API_EXPORT SamProgramChain {
-
-    // ctor & dtor
-    public:
-        SamProgramChain(void);
-        SamProgramChain(const SamProgramChain& other);
-        ~SamProgramChain(void);
-
-    // query/modify program data
-    public:
-        // appends a program record to the chain
-        void Add(SamProgram& program);
-        void Add(std::vector<SamProgram>& programs);
-
-        // clears all read group entries
-        void Clear(void);
-
-        // returns true if chain contains this program record (matches on ID)
-        bool Contains(const SamProgram& program) const;
-        bool Contains(const std::string& programId) const;
-
-        // returns the first (oldest) program in the chain
-        SamProgram& First(void);
-        const SamProgram& First(void) const;
-
-        // returns true if chain is empty
-        bool IsEmpty(void) const;
-
-        // returns last (most recent) program in the chain
-        SamProgram& Last(void);
-        const SamProgram& Last(void) const;
-
-        // returns number of program records in the chain
-        int Size(void) const;
-
-        // retrieves a modifiable reference to the SamProgram object associated with this ID
-        SamProgram& operator[](const std::string& programId);
-
-    // retrieve STL-compatible iterators
-    public:
-        SamProgramIterator      Begin(void);              // returns iterator to begin()
-        SamProgramConstIterator Begin(void) const;        // returns const_iterator to begin()
-        SamProgramConstIterator ConstBegin(void) const;   // returns const_iterator to begin()
-        SamProgramIterator      End(void);                // returns iterator to end()
-        SamProgramConstIterator End(void) const;          // returns const_iterator to end()
-        SamProgramConstIterator ConstEnd(void) const;     // returns const_iterator to end()
-
-    // internal methods
-    private:
-        int IndexOf(const std::string& programId) const;
-        const std::string NextIdFor(const std::string& programId) const;
-
-    // data members
-    private:
-        SamProgramContainer m_data;
-};
-
-} // namespace BamTools
-
-#endif // SAM_PROGRAMCHAIN_H
diff --git a/bamtools/src/api/SamReadGroup.cpp b/bamtools/src/api/SamReadGroup.cpp
deleted file mode 100644
index ce022ab..0000000
--- a/bamtools/src/api/SamReadGroup.cpp
+++ /dev/null
@@ -1,221 +0,0 @@
-// ***************************************************************************
-// SamReadGroup.cpp (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides direct read/write access to the SAM read group data fields.
-// ***************************************************************************
-
-#include "api/SamReadGroup.h"
-using namespace BamTools;
-using namespace std;
-
-/*! \struct BamTools::SamReadGroup
-    \brief Represents a SAM read group entry.
-
-    Provides direct read/write access to the SAM read group data fields.
-
-    \sa \samSpecURL
-*/
-/*! \var SamReadGroup::Description
-    \brief corresponds to \@RG DS:\<Description\>
-*/
-/*! \var SamReadGroup::FlowOrder
-    \brief corresponds to \@RG FO:\<FlowOrder\>
-*/
-/*! \var SamReadGroup::ID
-    \brief corresponds to \@RG ID:\<ID\>
-
-    Required for valid SAM header.
-*/
-/*! \var SamReadGroup::KeySequence
-    \brief corresponds to \@RG KS:\<KeySequence\>
-*/
-/*! \var SamReadGroup::Library
-    \brief corresponds to \@RG LB:\<Library\>
-*/
-/*! \var SamReadGroup::PlatformUnit
-    \brief corresponds to \@RG PU:\<PlatformUnit\>
-*/
-/*! \var SamReadGroup::PredictedInsertSize
-    \brief corresponds to \@RG PI:\<PredictedInsertSize\>
-*/
-/*! \var SamReadGroup::ProductionDate
-    \brief corresponds to \@RG DT:\<ProductionDate\>
-*/
-/*! \var SamReadGroup::Program
-    \brief corresponds to \@RG PG:\<Program\>
-*/
-/*! \var SamReadGroup::Sample
-    \brief corresponds to \@RG SM:\<Sample\>
-*/
-/*! \var SamReadGroup::SequencingCenter
-    \brief corresponds to \@RG CN:\<SequencingCenter\>
-*/
-/*! \var SamReadGroup::SequencingTechnology
-    \brief corresponds to \@RG PL:\<SequencingTechnology\>
-*/
-
-/*! \fn SamReadGroup::SamReadGroup(void)
-    \brief default constructor
-*/
-SamReadGroup::SamReadGroup(void)
-    : Description("")
-    , FlowOrder("")
-    , ID("")
-    , KeySequence("")
-    , Library("")
-    , PlatformUnit("")
-    , PredictedInsertSize("")
-    , ProductionDate("")
-    , Program("")
-    , Sample("")
-    , SequencingCenter("")
-    , SequencingTechnology("")
-{ }
-
-/*! \fn SamReadGroup::SamReadGroup(const std::string& id)
-    \brief constructs read group with \a id
-
-    \param id desired read group ID
-*/
-SamReadGroup::SamReadGroup(const std::string& id)
-    : Description("")
-    , FlowOrder("")
-    , ID(id)
-    , KeySequence("")
-    , Library("")
-    , PlatformUnit("")
-    , PredictedInsertSize("")
-    , ProductionDate("")
-    , Program("")
-    , Sample("")
-    , SequencingCenter("")
-    , SequencingTechnology("")
-{ }
-
-/*! \fn SamReadGroup::SamReadGroup(const SamReadGroup& other)
-    \brief copy constructor
-*/
-SamReadGroup::SamReadGroup(const SamReadGroup& other)
-    : Description(other.Description)
-    , FlowOrder(other.FlowOrder)
-    , ID(other.ID)
-    , KeySequence(other.KeySequence)
-    , Library(other.Library)
-    , PlatformUnit(other.PlatformUnit)
-    , PredictedInsertSize(other.PredictedInsertSize)
-    , ProductionDate(other.ProductionDate)
-    , Program(other.Program)
-    , Sample(other.Sample)
-    , SequencingCenter(other.SequencingCenter)
-    , SequencingTechnology(other.SequencingTechnology)
-{ }
-
-/*! \fn SamReadGroup::~SamReadGroup(void)
-    \brief destructor
-*/
-SamReadGroup::~SamReadGroup(void) { }
-
-/*! \fn void SamReadGroup::Clear(void)
-    \brief Clears all data fields.
-*/
-void SamReadGroup::Clear(void) {
-    Description.clear();
-    FlowOrder.clear();
-    ID.clear();
-    KeySequence.clear();
-    Library.clear();
-    PlatformUnit.clear();
-    PredictedInsertSize.clear();
-    ProductionDate.clear();
-    Program.clear();
-    Sample.clear();
-    SequencingCenter.clear();
-    SequencingTechnology.clear();
-}
-
-/*! \fn bool SamReadGroup::HasDescription(void) const
-    \brief Returns \c true if read group contains \@RG DS:\<Description\>
-*/
-bool SamReadGroup::HasDescription(void) const {
-    return (!Description.empty());
-}
-
-/*! \fn bool SamReadGroup::HasFlowOrder(void) const
-    \brief Returns \c true if read group contains \@RG FO:\<FlowOrder\>
-*/
-bool SamReadGroup::HasFlowOrder(void) const {
-    return (!FlowOrder.empty());
-}
-
-/*! \fn bool SamReadGroup::HasID(void) const
-    \brief Returns \c true if read group contains \@RG: ID:\<ID\>
-*/
-bool SamReadGroup::HasID(void) const {
-    return (!ID.empty());
-}
-
-/*! \fn bool SamReadGroup::HasKeySequence(void) const
-    \brief Returns \c true if read group contains \@RG KS:\<KeySequence\>
-*/
-bool SamReadGroup::HasKeySequence(void) const {
-    return (!KeySequence.empty());
-}
-
-/*! \fn bool SamReadGroup::HasLibrary(void) const
-    \brief Returns \c true if read group contains \@RG LB:\<Library\>
-*/
-bool SamReadGroup::HasLibrary(void) const {
-    return (!Library.empty());
-}
-
-/*! \fn bool SamReadGroup::HasPlatformUnit(void) const
-    \brief Returns \c true if read group contains \@RG PU:\<PlatformUnit\>
-*/
-bool SamReadGroup::HasPlatformUnit(void) const {
-    return (!PlatformUnit.empty());
-}
-
-/*! \fn bool SamReadGroup::HasPredictedInsertSize(void) const
-    \brief Returns \c true if read group contains \@RG PI:\<PredictedInsertSize\>
-*/
-bool SamReadGroup::HasPredictedInsertSize(void) const {
-    return (!PredictedInsertSize.empty());
-}
-
-/*! \fn bool SamReadGroup::HasProductionDate(void) const
-    \brief Returns \c true if read group contains \@RG DT:\<ProductionDate\>
-*/
-bool SamReadGroup::HasProductionDate(void) const {
-    return (!ProductionDate.empty());
-}
-
-/*! \fn bool SamReadGroup::HasProgram(void) const
-    \brief Returns \c true if read group contains \@RG PG:\<Program\>
-*/
-bool SamReadGroup::HasProgram(void) const {
-    return (!Program.empty());
-}
-
-/*! \fn bool SamReadGroup::HasSample(void) const
-    \brief Returns \c true if read group contains \@RG SM:\<Sample\>
-*/
-bool SamReadGroup::HasSample(void) const {
-    return (!Sample.empty());
-}
-
-/*! \fn bool SamReadGroup::HasSequencingCenter(void) const
-    \brief Returns \c true if read group contains \@RG CN:\<SequencingCenter\>
-*/
-bool SamReadGroup::HasSequencingCenter(void) const {
-    return (!SequencingCenter.empty());
-}
-
-/*! \fn bool SamReadGroup::HasSequencingTechnology(void) const
-    \brief Returns \c true if read group contains \@RG PL:\<SequencingTechnology\>
-*/
-bool SamReadGroup::HasSequencingTechnology(void) const {
-    return (!SequencingTechnology.empty());
-}
diff --git a/bamtools/src/api/SamReadGroup.h b/bamtools/src/api/SamReadGroup.h
deleted file mode 100644
index 093ce2d..0000000
--- a/bamtools/src/api/SamReadGroup.h
+++ /dev/null
@@ -1,68 +0,0 @@
-// ***************************************************************************
-// SamReadGroup.h (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides direct read/write access to the SAM read group data fields.
-// ***************************************************************************
-
-#ifndef SAM_READGROUP_H
-#define SAM_READGROUP_H
-
-#include "api/api_global.h"
-#include <string>
-
-namespace BamTools {
-
-struct API_EXPORT SamReadGroup {
-
-    // ctor & dtor
-    SamReadGroup(void);
-    SamReadGroup(const std::string& id);
-    SamReadGroup(const SamReadGroup& other);
-    ~SamReadGroup(void);
-
-    // query/modify entire read group
-    void Clear(void);                          // clears all data fields
-
-    // convenience query methods
-    bool HasDescription(void) const;           // returns true if read group has a description
-    bool HasFlowOrder(void) const;             // returns true if read group has a flow order entry
-    bool HasID(void) const;                    // returns true if read group has a group ID
-    bool HasKeySequence(void) const;           // returns true if read group has a key sequence
-    bool HasLibrary(void) const;               // returns true if read group has a library name
-    bool HasPlatformUnit(void) const;          // returns true if read group has a platform unit ID
-    bool HasPredictedInsertSize(void) const;   // returns true if read group has a predicted insert size
-    bool HasProductionDate(void) const;        // returns true if read group has a production date
-    bool HasProgram(void) const;               // returns true if read group has a program entry
-    bool HasSample(void) const;                // returns true if read group has a sample name
-    bool HasSequencingCenter(void) const;      // returns true if read group has a sequencing center ID
-    bool HasSequencingTechnology(void) const;  // returns true if read group has a sequencing technology ID
-
-
-    // data fields
-    std::string Description;                   // DS:<Description>
-    std::string FlowOrder;                     // FO:<FlowOrder>
-    std::string ID;                            // ID:<ID>              *Required for valid SAM header*
-    std::string KeySequence;                   // KS:<KeySequence>
-    std::string Library;                       // LB:<Library>
-    std::string PlatformUnit;                  // PU:<PlatformUnit>
-    std::string PredictedInsertSize;           // PI:<PredictedInsertSize>
-    std::string ProductionDate;                // DT:<ProductionDate>
-    std::string Program;                       // PG:<Program>
-    std::string Sample;                        // SM:<Sample>
-    std::string SequencingCenter;              // CN:<SequencingCenter>
-    std::string SequencingTechnology;          // PL:<SequencingTechnology>
-};
-
-/*! \fn bool operator==(const SamReadGroup& lhs, const SamReadGroup& rhs)
-    \brief tests equality by comparing read group IDs
-*/
-API_EXPORT inline bool operator==(const SamReadGroup& lhs, const SamReadGroup& rhs) {
-    return lhs.ID == rhs.ID;
-}
-
-} // namespace BamTools
-
-#endif // SAM_READGROUP_H
diff --git a/bamtools/src/api/SamReadGroupDictionary.cpp b/bamtools/src/api/SamReadGroupDictionary.cpp
deleted file mode 100644
index 007221a..0000000
--- a/bamtools/src/api/SamReadGroupDictionary.cpp
+++ /dev/null
@@ -1,297 +0,0 @@
-// ***************************************************************************
-// SamReadGroupDictionary.cpp (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 16 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides methods for operating on a collection of SamReadGroup entries.
-// ***************************************************************************
-
-#include "api/SamReadGroupDictionary.h"
-using namespace BamTools;
-
-#include <iostream>
-using namespace std;
-
-/*! \class BamTools::SamReadGroupDictionary
-    \brief Container of SamReadGroup entries.
-
-    Provides methods for operating on a collection of SamReadGroup entries.
-*/
-
-/*! \fn SamReadGroupDictionary::SamReadGroupDictionary(void)
-    \brief constructor
-*/
-SamReadGroupDictionary::SamReadGroupDictionary(void) { }
-
-/*! \fn SamReadGroupDictionary::SamReadGroupDictionary(const SamReadGroupDictionary& other)
-    \brief copy constructor
-*/
-SamReadGroupDictionary::SamReadGroupDictionary(const SamReadGroupDictionary& other)
-    : m_data(other.m_data)
-    , m_lookupData(other.m_lookupData)
-{ }
-
-/*! \fn SamReadGroupDictionary::~SamReadGroupDictionary(void)
-    \brief destructor
-*/
-SamReadGroupDictionary::~SamReadGroupDictionary(void) { }
-
-/*! \fn void SamReadGroupDictionary::Add(const SamReadGroup& readGroup)
-    \brief Appends a read group to the dictionary.
-
-    Duplicate entries are silently discarded.
-
-    \param[in] readGroup entry to be added
-*/
-void SamReadGroupDictionary::Add(const SamReadGroup& readGroup) {
-    if ( IsEmpty() || !Contains(readGroup) ) {
-        m_data.push_back(readGroup);
-        m_lookupData[readGroup.ID] = m_data.size() - 1;
-    }
-}
-
-/*! \fn void SamReadGroupDictionary::Add(const std::string& readGroupId)
-    \brief Appends a read group to the dictionary.
-
-    This is an overloaded function.
-
-    \param[in] readGroupId ID of read group to be added
-    \sa Add()
-*/
-void SamReadGroupDictionary::Add(const std::string& readGroupId) {
-    Add( SamReadGroup(readGroupId) );
-}
-
-/*! \fn void SamReadGroupDictionary::Add(const SamReadGroupDictionary& readGroups)
-    \brief Appends another read group dictionary to this one.
-
-    This is an overloaded function.
-
-    \param[in] readGroups entries to be added
-    \sa Add()
-*/
-void SamReadGroupDictionary::Add(const SamReadGroupDictionary& readGroups) {
-    SamReadGroupConstIterator rgIter = readGroups.ConstBegin();
-    SamReadGroupConstIterator rgEnd  = readGroups.ConstEnd();
-    for ( ; rgIter != rgEnd; ++rgIter )
-        Add(*rgIter);
-}
-
-/*! \fn void SamReadGroupDictionary::Add(const std::vector<SamReadGroup>& readGroups)
-    \brief Appends multiple read groups to the dictionary.
-
-    This is an overloaded function.
-
-    \param[in] readGroups entries to be added
-    \sa Add()
-*/
-void SamReadGroupDictionary::Add(const std::vector<SamReadGroup>& readGroups) {
-    vector<SamReadGroup>::const_iterator rgIter = readGroups.begin();
-    vector<SamReadGroup>::const_iterator rgEnd  = readGroups.end();
-    for ( ; rgIter!= rgEnd; ++rgIter )
-        Add(*rgIter);
-}
-
-/*! \fn void SamReadGroupDictionary::Add(const std::vector<std::string>& readGroupIds)
-    \brief Appends multiple read groups to the dictionary.
-
-    This is an overloaded function.
-
-    \param[in] readGroupIds IDs of read groups to be added
-    \sa Add()
-*/
-void SamReadGroupDictionary::Add(const std::vector<std::string>& readGroupIds) {
-    vector<string>::const_iterator rgIter = readGroupIds.begin();
-    vector<string>::const_iterator rgEnd  = readGroupIds.end();
-    for ( ; rgIter!= rgEnd; ++rgIter )
-        Add(*rgIter);
-}
-
-/*! \fn SamReadGroupIterator SamReadGroupDictionary::Begin(void)
-    \return an STL iterator pointing to the first read group
-    \sa ConstBegin(), End()
-*/
-SamReadGroupIterator SamReadGroupDictionary::Begin(void) {
-    return m_data.begin();
-}
-
-/*! \fn SamReadGroupConstIterator SamReadGroupDictionary::Begin(void) const
-    \return an STL const_iterator pointing to the first read group
-
-    This is an overloaded function.
-
-    \sa ConstBegin(), End()
-*/
-SamReadGroupConstIterator SamReadGroupDictionary::Begin(void) const {
-    return m_data.begin();
-}
-
-/*! \fn void SamReadGroupDictionary::Clear(void)
-    \brief Clears all read group entries.
-*/
-void SamReadGroupDictionary::Clear(void) {
-    m_data.clear();
-    m_lookupData.clear();
-}
-
-/*! \fn SamReadGroupConstIterator SamReadGroupDictionary::ConstBegin(void) const
-    \return an STL const_iterator pointing to the first read group
-    \sa Begin(), ConstEnd()
-*/
-SamReadGroupConstIterator SamReadGroupDictionary::ConstBegin(void) const {
-    return m_data.begin();
-}
-
-/*! \fn SamReadGroupConstIterator SamReadGroupDictionary::ConstEnd(void) const
-    \return an STL const_iterator pointing to the imaginary entry after the last read group
-    \sa ConstBegin(), End()
-*/
-SamReadGroupConstIterator SamReadGroupDictionary::ConstEnd(void) const {
-    return m_data.end();
-}
-
-/*! \fn bool SamReadGroupDictionary::Contains(const std::string& readGroupId) const
-    \brief Returns true if dictionary contains read group.
-
-    \param[in] readGroupId search for read group matching this ID
-    \return \c true if dictionary contains a read group with this ID
-*/
-bool SamReadGroupDictionary::Contains(const std::string& readGroupId) const {
-    return ( m_lookupData.find(readGroupId) != m_lookupData.end() );
-}
-
-/*! \fn bool SamReadGroupDictionary::Contains(const SamReadGroup& readGroup) const
-    \brief Returns true if dictionary contains read group (matching on ID).
-
-    This is an overloaded function.
-
-    \param[in] readGroup search for this read group
-    \return \c true if dictionary contains read group (matching on ID).
-*/
-bool SamReadGroupDictionary::Contains(const SamReadGroup& readGroup) const {
-    return Contains(readGroup.ID);
-}
-
-/*! \fn SamReadGroupIterator SamReadGroupDictionary::End(void)
-    \return an STL iterator pointing to the imaginary entry after the last read group
-    \sa Begin(), ConstEnd()
-*/
-SamReadGroupIterator SamReadGroupDictionary::End(void) {
-    return m_data.end();
-}
-
-/*! \fn SamReadGroupConstIterator SamReadGroupDictionary::End(void) const
-    \return an STL const_iterator pointing to the imaginary entry after the last read group
-
-    This is an overloaded function.
-
-    \sa Begin(), ConstEnd()
-*/
-SamReadGroupConstIterator SamReadGroupDictionary::End(void) const {
-    return m_data.end();
-}
-
-/*! \fn bool SamReadGroupDictionary::IsEmpty(void) const
-    \brief Returns \c true if dictionary contains no read groups
-    \sa Size()
-*/
-bool SamReadGroupDictionary::IsEmpty(void) const {
-    return m_data.empty();
-}
-
-/*! \fn void SamReadGroupDictionary::Remove(const SamReadGroup& readGroup)
-    \brief Removes read group from dictionary, if found (matching on ID).
-
-    This is an overloaded function.
-
-    \param[in] readGroup read group to remove (matches on ID)
-*/
-void SamReadGroupDictionary::Remove(const SamReadGroup& readGroup) {
-    Remove(readGroup.ID);
-}
-
-/*! \fn void SamReadGroupDictionary::Remove(const std::string& readGroupId)
-    \brief Removes read group from dictionary, if found.
-
-    \param[in] readGroupId ID of read group to remove
-    \sa Remove()
-*/
-void SamReadGroupDictionary::Remove(const std::string& readGroupId) {
-
-    // skip if empty dictionary or if ID unknown
-    if ( IsEmpty() || !Contains(readGroupId) )
-        return;
-
-    // update 'lookup index' for every entry after @readGroupId
-    const size_t indexToRemove = m_lookupData[readGroupId];
-    const size_t numEntries = m_data.size();
-    for ( size_t i = indexToRemove+1; i < numEntries; ++i ) {
-        const SamReadGroup& rg = m_data.at(i);
-        --m_lookupData[rg.ID];
-    }
-
-    // erase entry from containers
-    m_data.erase( Begin() + indexToRemove );
-    m_lookupData.erase(readGroupId);
-}
-
-/*! \fn void SamReadGroupDictionary::Remove(const std::vector<SamReadGroup>& readGroups)
-    \brief Removes multiple read groups from dictionary (matching on ID).
-
-    This is an overloaded function.
-
-    \param[in] readGroups read groups to remove
-    \sa Remove()
-*/
-void SamReadGroupDictionary::Remove(const std::vector<SamReadGroup>& readGroups) {
-    vector<SamReadGroup>::const_iterator rgIter = readGroups.begin();
-    vector<SamReadGroup>::const_iterator rgEnd  = readGroups.end();
-    for ( ; rgIter!= rgEnd; ++rgIter )
-        Remove(*rgIter);
-}
-
-/*! \fn void SamReadGroupDictionary::Remove(const std::vector<std::string>& readGroupIds)
-    \brief Removes multiple read groups from dictionary.
-
-    This is an overloaded function.
-
-    \param[in] readGroupIds IDs of the read groups to remove
-    \sa Remove()
-*/
-void SamReadGroupDictionary::Remove(const std::vector<std::string>& readGroupIds) {
-    vector<string>::const_iterator rgIter = readGroupIds.begin();
-    vector<string>::const_iterator rgEnd  = readGroupIds.end();
-    for ( ; rgIter!= rgEnd; ++rgIter )
-        Remove(*rgIter);
-}
-
-/*! \fn int SamReadGroupDictionary::Size(void) const
-    \brief Returns number of read groups in dictionary.
-    \sa IsEmpty()
-*/
-int SamReadGroupDictionary::Size(void) const {
-    return m_data.size();
-}
-
-/*! \fn SamReadGroup& SamReadGroupDictionary::operator[](const std::string& readGroupId)
-    \brief Retrieves the modifiable SamReadGroup that matches \a readGroupId.
-
-    \note If the dictionary contains no read group matching this ID, this function inserts
-    a new one with this ID, and returns a reference to it. If you want to avoid this insertion
-    behavior, check the result of Contains() before using this operator.
-
-    \param[in] readGroupId ID of read group to retrieve
-    \return a modifiable reference to the SamReadGroup associated with the ID
-*/
-SamReadGroup& SamReadGroupDictionary::operator[](const std::string& readGroupId) {
-
-    if ( !Contains(readGroupId) ) {
-        SamReadGroup rg(readGroupId);
-        m_data.push_back(rg);
-        m_lookupData[readGroupId] = m_data.size() - 1;
-    }
-
-    const size_t index = m_lookupData[readGroupId];
-    return m_data.at(index);
-}
diff --git a/bamtools/src/api/SamReadGroupDictionary.h b/bamtools/src/api/SamReadGroupDictionary.h
deleted file mode 100644
index a4aeda9..0000000
--- a/bamtools/src/api/SamReadGroupDictionary.h
+++ /dev/null
@@ -1,85 +0,0 @@
-// ***************************************************************************
-// SamReadGroupDictionary.h (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 16 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides methods for operating on a collection of SamReadGroup entries.
-// ***************************************************************************
-
-#ifndef SAM_READGROUP_DICTIONARY_H
-#define SAM_READGROUP_DICTIONARY_H
-
-#include "api/api_global.h"
-#include "api/SamReadGroup.h"
-#include <map>
-#include <string>
-#include <vector>
-
-namespace BamTools {
-
-typedef std::vector<SamReadGroup>             SamReadGroupContainer;
-typedef SamReadGroupContainer::iterator       SamReadGroupIterator;
-typedef SamReadGroupContainer::const_iterator SamReadGroupConstIterator;
-
-class API_EXPORT SamReadGroupDictionary {
-
-    // ctor & dtor
-    public:
-        SamReadGroupDictionary(void);
-        SamReadGroupDictionary(const SamReadGroupDictionary& other);
-        ~SamReadGroupDictionary(void);
-
-    // query/modify read group data
-    public:
-        // adds a read group
-        void Add(const SamReadGroup& readGroup);
-        void Add(const std::string& readGroupId);
-
-        // adds multiple read groups
-        void Add(const SamReadGroupDictionary& readGroups);
-        void Add(const std::vector<SamReadGroup>& readGroups);
-        void Add(const std::vector<std::string>& readGroupIds);
-
-        // clears all read group entries
-        void Clear(void);
-
-        // returns true if dictionary contains this read group
-        bool Contains(const SamReadGroup& readGroup) const;
-        bool Contains(const std::string& readGroupId) const;
-
-        // returns true if dictionary is empty
-        bool IsEmpty(void) const;
-
-        // removes read group, if found
-        void Remove(const SamReadGroup& readGroup);
-        void Remove(const std::string& readGroupId);
-
-        // removes multiple read groups
-        void Remove(const std::vector<SamReadGroup>& readGroups);
-        void Remove(const std::vector<std::string>& readGroupIds);
-
-        // returns number of read groups in dictionary
-        int Size(void) const;
-
-        // retrieves a modifiable reference to the SamReadGroup object associated with this ID
-        SamReadGroup& operator[](const std::string& readGroupId);
-
-    // retrieve STL-compatible iterators
-    public:
-        SamReadGroupIterator      Begin(void);              // returns iterator to begin()
-        SamReadGroupConstIterator Begin(void) const;        // returns const_iterator to begin()
-        SamReadGroupConstIterator ConstBegin(void) const;   // returns const_iterator to begin()
-        SamReadGroupIterator      End(void);                // returns iterator to end()
-        SamReadGroupConstIterator End(void) const;          // returns const_iterator to end()
-        SamReadGroupConstIterator ConstEnd(void) const;     // returns const_iterator to end()
-
-    // data members
-    private:
-        SamReadGroupContainer m_data;
-        std::map<std::string, size_t> m_lookupData;
-};
-
-} // namespace BamTools
-
-#endif // SAM_READGROUP_DICTIONARY_H
diff --git a/bamtools/src/api/SamSequence.cpp b/bamtools/src/api/SamSequence.cpp
deleted file mode 100644
index dea176b..0000000
--- a/bamtools/src/api/SamSequence.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-// ***************************************************************************
-// SamSequence.cpp (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides direct read/write access to the SAM sequence data fields.
-// ***************************************************************************
-
-#include "api/SamSequence.h"
-#include <sstream>
-using namespace BamTools;
-using namespace std;
-
-/*! \struct BamTools::SamSequence
-    \brief Represents a SAM sequence entry.
-
-    Provides direct read/write access to the SAM sequence data fields.
-
-    \sa \samSpecURL
-*/
-/*! \var SamSequence::AssemblyID
-    \brief corresponds to \@SQ AS:\<AssemblyID\>
-*/
-/*! \var SamSequence::Checksum
-    \brief corresponds to \@SQ M5:\<Checksum\>
-*/
-/*! \var SamSequence::Length
-    \brief corresponds to \@SQ LN:\<Length\>
-
-    Required for valid SAM header.
-*/
-/*! \var SamSequence::Name
-    \brief corresponds to \@SQ SN:\<Name\>
-
-    Required for valid SAM header.
-*/
-/*! \var SamSequence::Species
-    \brief corresponds to \@SQ SP:\<Species\>
-*/
-/*! \var SamSequence::URI
-    \brief corresponds to \@SQ UR:\<URI\>
-*/
-
-/*! \fn SamSequence::SamSequence(void)
-    \brief default constructor
-*/
-SamSequence::SamSequence(void)
-    : AssemblyID("")
-    , Checksum("")
-    , Length("")
-    , Name("")
-    , Species("")
-    , URI("")
-{ }
-
-/*! \fn SamSequence::SamSequence(const std::string& name, const int& length)
-    \brief constructs sequence with \a name and \a length
-
-    \param name   desired sequence name
-    \param length desired sequence length (numeric value)
-*/
-SamSequence::SamSequence(const std::string& name,
-                         const int& length)
-    : AssemblyID("")
-    , Checksum("")
-    , Name(name)
-    , Species("")
-    , URI("")
-{
-    stringstream s("");
-    s << length;
-    Length = s.str();
-}
-
-/*! \fn SamSequence::SamSequence(const std::string& name, const std::string& length)
-    \brief constructs sequence with \a name and \a length
-
-    \param name   desired sequence name
-    \param length desired sequence length (string value)
-*/
-SamSequence::SamSequence(const std::string& name,
-                         const std::string& length)
-    : AssemblyID("")
-    , Checksum("")
-    , Length(length)
-    , Name(name)
-    , Species("")
-    , URI("")
-{ }
-
-/*! \fn SamSequence::SamSequence(const SamSequence& other)
-    \brief copy constructor
-*/
-SamSequence::SamSequence(const SamSequence& other)
-    : AssemblyID(other.AssemblyID)
-    , Checksum(other.Checksum)
-    , Length(other.Length)
-    , Name(other.Name)
-    , Species(other.Species)
-    , URI(other.URI)
-{ }
-
-/*! \fn SamSequence::~SamSequence(void)
-    \brief destructor
-*/
-SamSequence::~SamSequence(void) { }
-
-/*! \fn void SamSequence::Clear(void)
-    \brief Clears all data fields.
-*/
-void SamSequence::Clear(void) {
-    AssemblyID.clear();
-    Checksum.clear();
-    Length.clear();
-    Name.clear();
-    Species.clear();
-    URI.clear();
-}
-
-/*! \fn bool SamSequence::HasAssemblyID(void) const
-    \brief Returns \c true if sequence contains \@SQ AS:\<AssemblyID\>
-*/
-bool SamSequence::HasAssemblyID(void) const {
-    return (!AssemblyID.empty());
-}
-
-/*! \fn bool SamSequence::HasChecksum(void) const
-    \brief Returns \c true if sequence contains \@SQ M5:\<Checksum\>
-*/
-bool SamSequence::HasChecksum(void) const {
-    return (!Checksum.empty());
-}
-
-/*! \fn bool SamSequence::HasLength(void) const
-    \brief Returns \c true if sequence contains \@SQ LN:\<Length\>
-*/
-bool SamSequence::HasLength(void) const {
-    return (!Length.empty());
-}
-
-/*! \fn bool SamSequence::HasName(void) const
-    \brief Returns \c true if sequence contains \@SQ SN:\<Name\>
-*/
-bool SamSequence::HasName(void) const {
-    return (!Name.empty());
-}
-
-/*! \fn bool SamSequence::HasSpecies(void) const
-    \brief Returns \c true if sequence contains \@SQ SP:\<Species\>
-*/
-bool SamSequence::HasSpecies(void) const {
-    return (!Species.empty());
-}
-
-/*! \fn bool SamSequence::HasURI(void) const
-    \brief Returns \c true if sequence contains \@SQ UR:\<URI\>
-*/
-bool SamSequence::HasURI(void) const {
-    return (!URI.empty());
-}
diff --git a/bamtools/src/api/SamSequence.h b/bamtools/src/api/SamSequence.h
deleted file mode 100644
index c1a8792..0000000
--- a/bamtools/src/api/SamSequence.h
+++ /dev/null
@@ -1,60 +0,0 @@
-// ***************************************************************************
-// SamSequence.h (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides direct read/write access to the SAM sequence data fields.
-// ***************************************************************************
-
-#ifndef SAM_SEQUENCE_H
-#define SAM_SEQUENCE_H
-
-#include "api/api_global.h"
-#include <string>
-
-namespace BamTools {
-
-struct API_EXPORT SamSequence {
-
-    // ctor & dtor
-    SamSequence(void);
-    SamSequence(const std::string& name, const int& length);
-    SamSequence(const std::string& name, const std::string& length);
-    SamSequence(const SamSequence& other);
-    ~SamSequence(void);
-
-    // query/modify entire sequence
-    void Clear(void);                // clears all contents
-
-    // convenience query methods
-    bool HasAssemblyID(void) const;  // returns true if sequence has an assembly ID
-    bool HasChecksum(void) const;    // returns true if sequence has an MD5 checksum
-    bool HasLength(void) const;      // returns true if sequence has a length
-    bool HasName(void) const;        // returns true if sequence has a name
-    bool HasSpecies(void) const;     // returns true if sequence has a species ID
-    bool HasURI(void) const;         // returns true if sequence has a URI
-
-    // data members
-    std::string AssemblyID;          // AS:<AssemblyID>
-    std::string Checksum;            // M5:<Checksum>
-    std::string Length;              // LN:<Length>      *Required for valid SAM header*
-    std::string Name;                // SN:<Name>        *Required for valid SAM header*
-    std::string Species;             // SP:<Species>
-    std::string URI;                 // UR:<URI>
-};
-
-/*! \fn bool operator==(const SamSequence& lhs, const SamSequence& rhs)
-    \brief tests equality by comparing sequence names, lengths, & checksums (if available)
-*/
-API_EXPORT inline bool operator==(const SamSequence& lhs, const SamSequence& rhs) {
-    if ( lhs.Name   != rhs.Name   ) return false;
-    if ( lhs.Length != rhs.Length ) return false;
-    if ( lhs.HasChecksum() && rhs.HasChecksum() )
-        return (lhs.Checksum == rhs.Checksum);
-    else return true;
-}
-
-} // namespace BamTools
-
-#endif // SAM_SEQUENCE_H
diff --git a/bamtools/src/api/SamSequenceDictionary.cpp b/bamtools/src/api/SamSequenceDictionary.cpp
deleted file mode 100644
index 5d2ab64..0000000
--- a/bamtools/src/api/SamSequenceDictionary.cpp
+++ /dev/null
@@ -1,301 +0,0 @@
-// ***************************************************************************
-// SamSequenceDictionary.cpp (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 16 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides methods for operating on a collection of SamSequence entries.
-// *************************************************************************
-
-#include "api/SamSequenceDictionary.h"
-using namespace BamTools;
-
-#include <iostream>
-using namespace std;
-
-/*! \class BamTools::SamSequenceDictionary
-    \brief Container of SamSequence entries.
-
-    Provides methods for operating on a collection of SamSequence entries.
-*/
-
-/*! \fn SamSequenceDictionary::SamSequenceDictionary(void)
-    \brief constructor
-*/
-SamSequenceDictionary::SamSequenceDictionary(void) { }
-
-/*! \fn SamSequenceDictionary::SamSequenceDictionary(const SamSequenceDictionary& other)
-    \brief copy constructor
-*/
-SamSequenceDictionary::SamSequenceDictionary(const SamSequenceDictionary& other)
-    : m_data(other.m_data)
-    , m_lookupData(other.m_lookupData)
-{ }
-
-/*! \fn SamSequenceDictionary::~SamSequenceDictionary(void)
-    \brief destructor
-*/
-SamSequenceDictionary::~SamSequenceDictionary(void) { }
-
-/*! \fn void SamSequenceDictionary::Add(const SamSequence& sequence)
-    \brief Appends a sequence to the dictionary.
-
-    Duplicate entries are silently discarded.
-
-    \param[in] sequence entry to be added
-*/
-void SamSequenceDictionary::Add(const SamSequence& sequence) {
-    if ( IsEmpty() || !Contains(sequence) ) {
-        m_data.push_back(sequence);
-        m_lookupData[sequence.Name] = m_data.size() - 1;
-    }
-}
-
-/*! \fn void SamSequenceDictionary::Add(const std::string& name, const int& length)
-    \brief Appends a sequence to the dictionary.
-
-    This is an overloaded function.
-
-    \param[in] name name of sequence entry to be added
-    \param[in] length length of sequence entry to be added
-    \sa Add()
-*/
-void SamSequenceDictionary::Add(const std::string& name, const int& length) {
-    Add( SamSequence(name, length) );
-}
-
-/*! \fn void SamSequenceDictionary::Add(const SamSequenceDictionary& sequences)
-    \brief Appends another sequence dictionary to this one
-
-    This is an overloaded function.
-
-    \param[in] sequences sequence dictionary to be appended
-    \sa Add()
-*/
-void SamSequenceDictionary::Add(const SamSequenceDictionary& sequences) {
-    SamSequenceConstIterator seqIter = sequences.ConstBegin();
-    SamSequenceConstIterator seqEnd  = sequences.ConstEnd();
-    for ( ; seqIter != seqEnd; ++seqIter )
-        Add(*seqIter);
-}
-
-/*! \fn void SamSequenceDictionary::Add(const std::vector<SamSequence>& sequences)
-    \brief Appends multiple sequences to the dictionary.
-
-    This is an overloaded function.
-
-    \param[in] sequences entries to be added
-    \sa Add()
-*/
-void SamSequenceDictionary::Add(const std::vector<SamSequence>& sequences) {
-    vector<SamSequence>::const_iterator seqIter = sequences.begin();
-    vector<SamSequence>::const_iterator seqEnd  = sequences.end();
-    for ( ; seqIter!= seqEnd; ++seqIter )
-        Add(*seqIter);
-}
-
-/*! \fn void SamSequenceDictionary::Add(const std::map<std::string, int>& sequenceMap)
-    \brief Appends multiple sequences to the dictionary.
-
-    This is an overloaded function.
-
-    \param[in] sequenceMap map of sequence entries (name => length) to be added
-    \sa Add()
-*/
-void SamSequenceDictionary::Add(const std::map<std::string, int>& sequenceMap) {
-    map<string, int>::const_iterator seqIter = sequenceMap.begin();
-    map<string, int>::const_iterator seqEnd  = sequenceMap.end();
-    for ( ; seqIter != seqEnd; ++seqIter ) {
-        const string& name = (*seqIter).first;
-        const int& length = (*seqIter).second;
-        Add( SamSequence(name, length) );
-    }
-}
-
-/*! \fn SamSequenceIterator SamSequenceDictionary::Begin(void)
-    \return an STL iterator pointing to the first sequence
-    \sa ConstBegin(), End()
-*/
-SamSequenceIterator SamSequenceDictionary::Begin(void) {
-    return m_data.begin();
-}
-
-/*! \fn SamSequenceConstIterator SamSequenceDictionary::Begin(void) const
-    \return an STL const_iterator pointing to the first sequence
-
-    This is an overloaded function.
-
-    \sa ConstBegin(), End()
-*/
-SamSequenceConstIterator SamSequenceDictionary::Begin(void) const {
-    return m_data.begin();
-}
-
-/*! \fn void SamSequenceDictionary::Clear(void)
-    \brief Clears all sequence entries.
-*/
-void SamSequenceDictionary::Clear(void) {
-    m_data.clear();
-    m_lookupData.clear();
-}
-
-/*! \fn SamSequenceConstIterator SamSequenceDictionary::ConstBegin(void) const
-    \return an STL const_iterator pointing to the first sequence
-    \sa Begin(), ConstEnd()
-*/
-SamSequenceConstIterator SamSequenceDictionary::ConstBegin(void) const {
-    return m_data.begin();
-}
-
-/*! \fn SamSequenceConstIterator SamSequenceDictionary::ConstEnd(void) const
-    \return an STL const_iterator pointing to the imaginary entry after the last sequence
-    \sa End(), ConstBegin()
-*/
-SamSequenceConstIterator SamSequenceDictionary::ConstEnd(void) const {
-    return m_data.end();
-}
-
-/*! \fn bool SamSequenceDictionary::Contains(const std::string& sequenceName) const
-    \brief Returns true if dictionary contains sequence.
-
-    \param[in] sequenceName search for sequence matching this name
-    \return \c true if dictionary contains a sequence with this name
-*/
-bool SamSequenceDictionary::Contains(const std::string& sequenceName) const {
-    return ( m_lookupData.find(sequenceName) != m_lookupData.end() );
-}
-
-/*! \fn bool SamSequenceDictionary::Contains(const SamSequence& sequence) const
-    \brief Returns true if dictionary contains sequence (matches on name).
-
-    This is an overloaded function.
-
-    \param[in] sequence search for this sequence
-    \return \c true if dictionary contains sequence (matching on name)
-*/
-bool SamSequenceDictionary::Contains(const SamSequence& sequence) const {
-    return Contains(sequence.Name);
-}
-
-/*! \fn SamSequenceIterator SamSequenceDictionary::End(void)
-    \return an STL iterator pointing to the imaginary entry after the last sequence
-    \sa Begin(), ConstEnd()
-*/
-SamSequenceIterator SamSequenceDictionary::End(void) {
-    return m_data.end();
-}
-
-/*! \fn SamSequenceConstIterator SamSequenceDictionary::End(void) const
-    \return an STL const_iterator pointing to the imaginary entry after the last sequence
-
-    This is an overloaded function.
-
-    \sa Begin(), ConstEnd()
-*/
-SamSequenceConstIterator SamSequenceDictionary::End(void) const {
-    return m_data.end();
-}
-
-/*! \fn bool SamSequenceDictionary::IsEmpty(void) const
-    \brief Returns \c true if dictionary contains no sequences
-    \sa Size()
-*/
-bool SamSequenceDictionary::IsEmpty(void) const {
-    return m_data.empty();
-}
-
-/*! \fn void SamSequenceDictionary::Remove(const SamSequence& sequence)
-    \brief Removes sequence from dictionary, if found (matches on name).
-
-    This is an overloaded function.
-
-    \param[in] sequence SamSequence to remove (matching on name)
-*/
-void SamSequenceDictionary::Remove(const SamSequence& sequence) {
-    Remove(sequence.Name);
-}
-
-/*! \fn void SamSequenceDictionary::Remove(const std::string& sequenceName)
-    \brief Removes sequence from dictionary, if found.
-
-    \param[in] sequenceName name of sequence to remove
-    \sa Remove()
-*/
-void SamSequenceDictionary::Remove(const std::string& sequenceName) {
-
-    // skip if empty dictionary or if name unknown
-    if ( IsEmpty() || !Contains(sequenceName) )
-        return;
-
-    // update 'lookup index' for every entry after @sequenceName
-    const size_t indexToRemove = m_lookupData[sequenceName];
-    const size_t numEntries = m_data.size();
-    for ( size_t i = indexToRemove+1; i < numEntries; ++i ) {
-        const SamSequence& sq = m_data.at(i);
-        --m_lookupData[sq.Name];
-    }
-
-    // erase entry from containers
-    m_data.erase( Begin() + indexToRemove );
-    m_lookupData.erase(sequenceName);
-}
-
-/*! \fn void SamSequenceDictionary::Remove(const std::vector<SamSequence>& sequences)
-    \brief Removes multiple sequences from dictionary.
-
-    This is an overloaded function.
-
-    \param[in] sequences sequences to remove
-    \sa Remove()
-*/
-void SamSequenceDictionary::Remove(const std::vector<SamSequence>& sequences) {
-    vector<SamSequence>::const_iterator rgIter = sequences.begin();
-    vector<SamSequence>::const_iterator rgEnd  = sequences.end();
-    for ( ; rgIter!= rgEnd; ++rgIter )
-        Remove(*rgIter);
-}
-
-/*! \fn void SamSequenceDictionary::Remove(const std::vector<std::string>& sequenceNames)
-    \brief Removes multiple sequences from dictionary.
-
-    This is an overloaded function.
-
-    \param[in] sequenceNames names of the sequences to remove
-    \sa Remove()
-*/
-void SamSequenceDictionary::Remove(const std::vector<std::string>& sequenceNames) {
-    vector<string>::const_iterator rgIter = sequenceNames.begin();
-    vector<string>::const_iterator rgEnd  = sequenceNames.end();
-    for ( ; rgIter!= rgEnd; ++rgIter )
-        Remove(*rgIter);
-}
-
-/*! \fn int SamSequenceDictionary::Size(void) const
-    \brief Returns number of sequences in dictionary.
-    \sa IsEmpty()
-*/
-int SamSequenceDictionary::Size(void) const {
-    return m_data.size();
-}
-
-/*! \fn SamSequence& SamSequenceDictionary::operator[](const std::string& sequenceName)
-    \brief Retrieves the modifiable SamSequence that matches \a sequenceName.
-
-    \note If the dictionary contains no sequence matching this name, this function inserts
-    a new one with this name (length:0), and returns a reference to it. If you want to avoid
-    this insertion behavior, check the result of Contains() before using this operator.
-
-    \param[in] sequenceName name of sequence to retrieve
-    \return a modifiable reference to the SamSequence associated with the name
-*/
-SamSequence& SamSequenceDictionary::operator[](const std::string& sequenceName) {
-
-    if ( !Contains(sequenceName) ) {
-        SamSequence seq(sequenceName, 0);
-        m_data.push_back(seq);
-        m_lookupData[sequenceName] = m_data.size() - 1;
-    }
-
-    const size_t index = m_lookupData[sequenceName];
-    return m_data.at(index);
-}
diff --git a/bamtools/src/api/SamSequenceDictionary.h b/bamtools/src/api/SamSequenceDictionary.h
deleted file mode 100644
index d267dbd..0000000
--- a/bamtools/src/api/SamSequenceDictionary.h
+++ /dev/null
@@ -1,86 +0,0 @@
-// ***************************************************************************
-// SamSequenceDictionary.h (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 16 October 2011
-// ---------------------------------------------------------------------------
-// Provides methods for operating on a collection of SamSequence entries.
-// ***************************************************************************
-
-#ifndef SAM_SEQUENCE_DICTIONARY_H
-#define SAM_SEQUENCE_DICTIONARY_H
-
-#include "api/api_global.h"
-#include "api/SamSequence.h"
-#include <map>
-#include <string>
-#include <vector>
-
-namespace BamTools {
-
-typedef std::vector<SamSequence>             SamSequenceContainer;
-typedef SamSequenceContainer::iterator       SamSequenceIterator;
-typedef SamSequenceContainer::const_iterator SamSequenceConstIterator;
-
-class API_EXPORT SamSequenceDictionary {
-
-    // ctor & dtor
-    public:
-        SamSequenceDictionary(void);
-        SamSequenceDictionary(const SamSequenceDictionary& other);
-        ~SamSequenceDictionary(void);
-
-    // query/modify sequence data
-    public:
-        // adds a sequence
-        void Add(const SamSequence& sequence);
-        void Add(const std::string& name, const int& length);
-
-        // adds multiple sequences
-        void Add(const SamSequenceDictionary& sequences);
-        void Add(const std::vector<SamSequence>& sequences);
-        void Add(const std::map<std::string, int>& sequenceMap);
-
-        // clears all sequence entries
-        void Clear(void);
-
-        // returns true if dictionary contains this sequence
-        bool Contains(const SamSequence& sequence) const;
-        bool Contains(const std::string& sequenceName) const;
-
-        // returns true if dictionary is empty
-        bool IsEmpty(void) const;
-
-        // removes sequence, if found
-        void Remove(const SamSequence& sequence);
-        void Remove(const std::string& sequenceName);
-
-        // removes multiple sequences
-        void Remove(const std::vector<SamSequence>& sequences);
-        void Remove(const std::vector<std::string>& sequenceNames);
-
-        // returns number of sequences in dictionary
-        int Size(void) const;
-
-        // retrieves a modifiable reference to the SamSequence object associated with this name
-        SamSequence& operator[](const std::string& sequenceName);
-
-    // retrieve STL-compatible iterators
-    public:
-        SamSequenceIterator      Begin(void);               // returns iterator to begin()
-        SamSequenceConstIterator Begin(void) const;         // returns const_iterator to begin()
-        SamSequenceConstIterator ConstBegin(void) const;    // returns const_iterator to begin()
-        SamSequenceIterator      End(void);                 // returns iterator to end()
-        SamSequenceConstIterator End(void) const;           // returns const_iterator to end()
-        SamSequenceConstIterator ConstEnd(void) const;      // returns const_iterator to end()
-
-    // data members
-    private:
-        SamSequenceContainer m_data;
-        std::map<std::string, size_t> m_lookupData;
-};
-
-} // namespace BamTools
-
-#endif // SAM_SEQUENCE_DICTIONARY_H
-
diff --git a/bamtools/src/api/algorithms/Sort.h b/bamtools/src/api/algorithms/Sort.h
deleted file mode 100644
index 32902e1..0000000
--- a/bamtools/src/api/algorithms/Sort.h
+++ /dev/null
@@ -1,335 +0,0 @@
-// ***************************************************************************
-// Sort.h (c) 2009 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// All rights reserved.
-// ---------------------------------------------------------------------------
-// Last modified: 4 April 2012 (DB)
-// ---------------------------------------------------------------------------
-// Provides sorting functionality.
-// ***************************************************************************
-
-#ifndef ALGORITHMS_SORT_H
-#define ALGORITHMS_SORT_H
-
-#include "api/api_global.h"
-#include "api/BamAlignment.h"
-#include "api/BamReader.h"
-#include "api/BamMultiReader.h"
-#include <cassert>
-#include <algorithm>
-#include <functional>
-#include <string>
-#include <vector>
-
-namespace BamTools {
-namespace Algorithms {
-
-/*! \struct BamTools::Algorithms::Sort
-    \brief Provides classes & methods related to sorting BamAlignments
-*/
-struct API_EXPORT Sort {
-
-    //! Provides explicit values for specifying desired sort ordering
-    enum Order { AscendingOrder = 0
-               , DescendingOrder
-               };
-
-    /*! \fn template<typename ElemType> static inline bool sort_helper(const Sort::Order& order, const ElemType& lhs, const ElemType& rhs)
-        \internal
-
-        Determines necessary STL function object depending on requested Sort::Order
-    */
-    template<typename ElemType>
-    static inline bool sort_helper(const Sort::Order& order, const ElemType& lhs, const ElemType& rhs) {
-        switch ( order ) {
-            case ( Sort::AscendingOrder  ) : { std::less<ElemType> comp;    return comp(lhs, rhs); }
-            case ( Sort::DescendingOrder ) : { std::greater<ElemType> comp; return comp(lhs, rhs); }
-            default : BT_ASSERT_UNREACHABLE;
-        }
-        return false; // <-- unreachable
-    }
-
-    //! Base class for our sorting function objects
-    typedef std::binary_function<BamAlignment, BamAlignment, bool> AlignmentSortBase;
-
-    /*! \struct BamTools::Algorithms::Sort::ByName
-        \brief Function object for comparing alignments by name
-
-        Default sort order is Sort::AscendingOrder.
-
-        \code
-            std::vector<BamAlignment> a;
-
-            // sort by name, in ascending order (the following two lines are equivalent):
-            std::sort( a.begin(), a.end(), Sort::ByName() );
-            std::sort( a.begin(), a.end(), Sort::ByName(Sort::AscendingOrder) );
-
-            // OR sort in descending order
-            std::sort( a.begin(), a.end(), Sort::ByName(Sort::DescendingOrder) );
-        \endcode
-    */
-    struct ByName : public AlignmentSortBase {
-
-        // ctor
-        ByName(const Sort::Order& order = Sort::AscendingOrder)
-            : m_order(order)
-        { }
-
-        // comparison function
-        bool operator()(const BamTools::BamAlignment& lhs, const BamTools::BamAlignment& rhs) {
-            return sort_helper(m_order, lhs.Name, rhs.Name);
-        }
-
-        // used by BamMultiReader internals
-        static inline bool UsesCharData(void) { return true; }
-
-        // data members
-        private:
-            const Sort::Order m_order;
-    };
-
-    /*! \struct BamTools::Algorithms::Sort::ByPosition
-        \brief Function object for comparing alignments by position
-
-        Default sort order is Sort::AscendingOrder.
-
-        \code
-            std::vector<BamAlignment> a;
-
-            // sort by position, in ascending order (the following two lines are equivalent):
-            std::sort( a.begin(), a.end(), Sort::ByPosition() );
-            std::sort( a.begin(), a.end(), Sort::ByPosition(Sort::AscendingOrder) );
-
-            // OR sort in descending order
-            std::sort( a.begin(), a.end(), Sort::ByPosition(Sort::DescendingOrder) );
-        \endcode
-    */
-    struct ByPosition : public AlignmentSortBase {
-
-        // ctor
-        ByPosition(const Sort::Order& order = Sort::AscendingOrder)
-            : m_order(order)
-        { }
-
-        // comparison function
-        bool operator()(const BamTools::BamAlignment& lhs, const BamTools::BamAlignment& rhs) {
-
-            // force unmapped aligmnents to end
-            if ( lhs.RefID == -1 ) return false;
-            if ( rhs.RefID == -1 ) return true;
-
-            // if on same reference, sort on position
-            if ( lhs.RefID == rhs.RefID )
-                return sort_helper(m_order, lhs.Position, rhs.Position);
-
-            // otherwise sort on reference ID
-            return sort_helper(m_order, lhs.RefID, rhs.RefID);
-        }
-
-        // used by BamMultiReader internals
-        static inline bool UsesCharData(void) { return false; }
-
-        // data members
-        private:
-            const Sort::Order m_order;
-    };
-
-    /*! \struct BamTools::Algorithms::Sort::ByTag
-        \brief Function object for comparing alignments by tag value
-
-        Default sort order is Sort::AscendingOrder.
-
-        \code
-            std::vector<BamAlignment> a;
-
-            // sort by edit distance, in ascending order (the following two lines are equivalent):
-            std::sort( a.begin(), a.end(), Sort::ByTag<int>("NM") );
-            std::sort( a.begin(), a.end(), Sort::ByTag<int>("NM", Sort::AscendingOrder) );
-
-            // OR sort in descending order
-            std::sort( a.begin(), a.end(), Sort::ByTag<int>("NM", Sort::DescendingOrder) );
-        \endcode
-    */
-    template<typename T>
-    struct ByTag : public AlignmentSortBase {
-
-        // ctor
-        ByTag(const std::string& tag,
-              const Sort::Order& order = Sort::AscendingOrder)
-            : m_tag(tag)
-            , m_order(order)
-        { }
-
-        // comparison function
-        bool operator()(const BamTools::BamAlignment& lhs, const BamTools::BamAlignment& rhs) {
-
-            // force alignments without tag to end
-            T lhsTagValue;
-            T rhsTagValue;
-            if ( !lhs.GetTag(m_tag, lhsTagValue) ) return false;
-            if ( !rhs.GetTag(m_tag, rhsTagValue) ) return true;
-
-            // otherwise compare on tag values
-            return sort_helper(m_order, lhsTagValue, rhsTagValue);
-        }
-
-        // used by BamMultiReader internals
-        static inline bool UsesCharData(void) { return true; }
-
-        // data members
-        private:
-            const std::string m_tag;
-            const Sort::Order m_order;
-    };
-
-    /*! \struct BamTools::Algorithms::Sort::Unsorted
-        \brief Placeholder function object
-
-        This function object exists purely to allow for dropping a "do not care" ordering
-        into methods, containers, etc that are designed to work with the other sorting objects.
-
-        \code
-            std::set<BamAlignment, Sort::ByName>;   // STL set, ordered on alignment name
-            std::set<BamAlignment, Sort::Unsorted>; // STL set, unsorted (but probably insertion order)
-        \endcode
-    */
-    struct Unsorted : public AlignmentSortBase {
-
-        // comparison function
-        inline bool operator()(const BamTools::BamAlignment&, const BamTools::BamAlignment&) {
-            return false;   // returning false tends to retain insertion order
-        }
-
-        // used by BamMultiReader internals
-        static inline bool UsesCharData(void) { return false; }
-    };
-
-    /*! Sorts a std::vector of alignments (in-place), using the provided compare function.
-
-        \code
-            std::vector<BamAlignemnt> a;
-            // populate data
-
-            // sort our alignment list by edit distance
-            Sort::SortAlignments(a, Sort::ByTag<int>("NM"));
-        \endcode
-
-        \param[in,out] data vector of alignments to be sorted
-        \param[in]     comp comparison function object
-    */
-    template<typename Compare>
-    static inline void SortAlignments(std::vector<BamAlignment>& data,
-                                      const Compare& comp = Compare())
-    {
-        std::sort(data.begin(), data.end(), comp);
-    }
-
-    /*! Returns a sorted copy of the input alignments, using the provided compare function.
-
-        \code
-            std::vector<BamAlignemnt> a;
-            // populate data
-
-            // get a copy of our original data, sorted by edit distance (descending order)
-            std::vector<BamAligment> sortedData;
-            sortedData = Sort::SortAlignments(a, Sort::ByTag<int>("NM", Sort::DescendingOrder));
-        \endcode
-
-        \param[in] input vector of alignments to be sorted
-        \param[in] comp  comparison function object
-        \return sorted copy of the input data
-    */
-    template<typename Compare>
-    static inline std::vector<BamAlignment> SortAlignments(const std::vector<BamAlignment>& input,
-                                                           const Compare& comp = Compare())
-    {
-        std::vector<BamAlignment> output(input);
-        SortAlignments(output, comp);
-        return output;
-    }
-
-    /*! Reads a region of alignments from a position-sorted BAM file,
-        then sorts by the provided compare function
-
-        \code
-            BamReader reader;
-            // open BAM file & index file
-
-            BamRegion region;
-            // define a region of interest (i.e. a exon or some other feature)
-
-            // get all alignments covering that region, sorted by read group name
-            std::vector<BamAlignments> a;
-            a = Sort::GetSortedRegion(reader, region, Sort::ByTag<std::string>("RG"));
-        \endcode
-
-        \param[in] reader BamReader opened on desired BAM file
-        \param[in] region desired region-of-interest
-        \param[in] comp   comparison function object
-        \return sorted vector of the region's alignments
-    */
-    template<typename Compare>
-    static std::vector<BamAlignment> GetSortedRegion(BamReader& reader,
-                                                     const BamRegion& region,
-                                                     const Compare& comp = Compare())
-    {
-        // return empty container if unable to find region
-        if ( !reader.IsOpen() )          return std::vector<BamAlignment>();
-        if ( !reader.SetRegion(region) ) return std::vector<BamAlignment>();
-
-        // iterate through region, grabbing alignments
-        BamAlignment al;
-        std::vector<BamAlignment> results;
-        while ( reader.GetNextAlignmentCore(al) )
-            results.push_back(al);
-
-        // sort & return alignments
-        SortAlignments(results, comp);
-        return results;
-    }
-
-    /*! Reads a region of alignments from position-sorted BAM files,
-        then sorts by the provided compare function
-
-        \code
-            BamMultiReader reader;
-            // open BAM files & index files
-
-            BamRegion region;
-            // define a region of interest (i.e. a exon or some other feature)
-
-            // get all alignments covering that region, sorted by read group name
-            std::vector<BamAlignments> a;
-            a = Sort::GetSortedRegion(reader, region, Sort::ByTag<std::string>("RG"));
-        \endcode
-
-        \param[in] reader BamMultiReader opened on desired BAM files
-        \param[in] region desired region-of-interest
-        \param[in] comp   comparison function object
-        \return sorted vector of the region's alignments
-    */
-    template<typename Compare>
-    static std::vector<BamAlignment> GetSortedRegion(BamMultiReader& reader,
-                                                     const BamRegion& region,
-                                                     const Compare& comp = Compare())
-    {
-        // return empty container if unable to find region
-        if ( !reader.HasOpenReaders() )  return std::vector<BamAlignment>();
-        if ( !reader.SetRegion(region) ) return std::vector<BamAlignment>();
-
-        // iterate through region, grabbing alignments
-        BamAlignment al;
-        std::vector<BamAlignment> results;
-        while ( reader.GetNextAlignmentCore(al) )
-            results.push_back(al);
-
-        // sort & return alignments
-        SortAlignments(results, comp);
-        return results;
-    }
-};
-
-} // namespace Algorithms
-} // namespace BamTools
-
-#endif // ALGORITHMS_SORT_H
diff --git a/bamtools/src/api/api_global.h b/bamtools/src/api/api_global.h
deleted file mode 100644
index f1c2353..0000000
--- a/bamtools/src/api/api_global.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// ***************************************************************************
-// api_global.h (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 19 November 2010 (DB)
-// ---------------------------------------------------------------------------
-// Provides macros for exporting & importing BamTools API library symbols
-// ***************************************************************************
-
-#ifndef API_GLOBAL_H
-#define API_GLOBAL_H
-
-#include "shared/bamtools_global.h"
-
-#ifdef BAMTOOLS_API_LIBRARY
-#  define API_EXPORT BAMTOOLS_LIBRARY_EXPORT
-#else
-#  define API_EXPORT BAMTOOLS_LIBRARY_IMPORT
-#endif
-
-#endif // API_GLOBAL_H
diff --git a/bamtools/src/api/internal/CMakeLists.txt b/bamtools/src/api/internal/CMakeLists.txt
deleted file mode 100644
index a96cd6f..0000000
--- a/bamtools/src/api/internal/CMakeLists.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-# ==========================
-# BamTools CMakeLists.txt
-# (c) 2011 Derek Barnett
-#
-# src/api/internal
-# ==========================
-
-set( InternalDir "internal" )
-
-add_subdirectory( bam )
-add_subdirectory( index )
-add_subdirectory( io )
-add_subdirectory( sam )
-add_subdirectory( utils )
-
-set( InternalSources
-         ${InternalBamSources}
-         ${InternalIndexSources}
-         ${InternalIOSources}
-         ${InternalSamSources}
-         ${InternalUtilsSources}
-
-         PARENT_SCOPE # <-- leave this last
-   )
-
diff --git a/bamtools/src/api/internal/bam/BamHeader_p.cpp b/bamtools/src/api/internal/bam/BamHeader_p.cpp
deleted file mode 100644
index aa3cdf7..0000000
--- a/bamtools/src/api/internal/bam/BamHeader_p.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-// ***************************************************************************
-// BamHeader_p.cpp (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 18 November 2012 (DB)
-// ---------------------------------------------------------------------------
-// Provides the basic functionality for handling BAM headers.
-// ***************************************************************************
-
-#include "api/BamAux.h"
-#include "api/BamConstants.h"
-#include "api/internal/bam/BamHeader_p.h"
-#include "api/internal/io/BgzfStream_p.h"
-#include "api/internal/utils/BamException_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#include <cstdlib>
-#include <cstring>
-using namespace std;
-
-// ------------------------
-// static utility methods
-// ------------------------
-
-static inline
-bool isValidMagicNumber(const char* buffer) {
-    return ( strncmp(buffer, Constants::BAM_HEADER_MAGIC,
-                     Constants::BAM_HEADER_MAGIC_LENGTH) == 0 );
-}
-
-// --------------------------
-// BamHeader implementation
-// --------------------------
-
-// ctor
-BamHeader::BamHeader(void) { }
-
-// dtor
-BamHeader::~BamHeader(void) { }
-
-// reads magic number from BGZF stream, returns true if valid
-void BamHeader::CheckMagicNumber(BgzfStream* stream) {
-
-    // try to read magic number
-    char buffer[Constants::BAM_HEADER_MAGIC_LENGTH];
-    const size_t numBytesRead = stream->Read(buffer, Constants::BAM_HEADER_MAGIC_LENGTH);
-    if ( numBytesRead != (int)Constants::BAM_HEADER_MAGIC_LENGTH )
-        throw BamException("BamHeader::CheckMagicNumber", "could not read magic number");
-
-    // validate magic number
-    if ( !isValidMagicNumber(buffer) )
-        throw BamException("BamHeader::CheckMagicNumber", "invalid magic number");
-}
-
-// clear SamHeader data
-void BamHeader::Clear(void) {
-    m_header.Clear();
-}
-
-// return true if SamHeader data is valid
-bool BamHeader::IsValid(void) const {
-    return m_header.IsValid();
-}
-
-// load BAM header ('magic number' and SAM header text) from BGZF stream
-void BamHeader::Load(BgzfStream* stream) {
-
-    // read & check magic number
-    CheckMagicNumber(stream);
-
-    // read header (length, then actual text)
-    uint32_t length(0);
-    ReadHeaderLength(stream, length);
-    ReadHeaderText(stream, length);
-}
-
-// reads SAM header text length from BGZF stream, stores it in @length
-void BamHeader::ReadHeaderLength(BgzfStream* stream, uint32_t& length) {
-
-    // read BAM header text length
-    char buffer[sizeof(uint32_t)];
-    const size_t numBytesRead = stream->Read(buffer, sizeof(uint32_t));
-    if ( numBytesRead != sizeof(uint32_t) )
-        throw BamException("BamHeader::ReadHeaderLength", "could not read header length");
-
-    // convert char buffer to length
-    length = BamTools::UnpackUnsignedInt(buffer);
-    if ( BamTools::SystemIsBigEndian() )
-        BamTools::SwapEndian_32(length);
-}
-
-// reads SAM header text from BGZF stream, stores in SamHeader object
-void BamHeader::ReadHeaderText(BgzfStream* stream, const uint32_t& length) {
-
-    // read header text
-    char* headerText = (char*)calloc(length + 1, 1);
-    const size_t bytesRead = stream->Read(headerText, length);
-
-    // if error reading, clean up buffer & throw
-    if ( bytesRead != length ) {
-        free(headerText);
-        throw BamException("BamHeader::ReadHeaderText", "could not read header text");
-    }
-
-    // otherwise, text was read OK
-    // store & cleanup
-    m_header.SetHeaderText( (string)((const char*)headerText) );
-    free(headerText);
-}
-
-// returns const-reference to SamHeader data object
-const SamHeader& BamHeader::ToConstSamHeader(void) const {
-    return m_header;
-}
-
-// returns *copy* of SamHeader data object
-SamHeader BamHeader::ToSamHeader(void) const {
-    return m_header;
-}
-
-// returns SAM-formatted string of header data
-string BamHeader::ToString(void) const {
-    return m_header.ToString();
-}
diff --git a/bamtools/src/api/internal/bam/BamHeader_p.h b/bamtools/src/api/internal/bam/BamHeader_p.h
deleted file mode 100644
index 22851d8..0000000
--- a/bamtools/src/api/internal/bam/BamHeader_p.h
+++ /dev/null
@@ -1,71 +0,0 @@
-// ***************************************************************************
-// BamHeader_p.h (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 18 November 2012 (DB)
-// ---------------------------------------------------------------------------
-// Provides the basic functionality for handling BAM headers.
-// ***************************************************************************
-
-#ifndef BAMHEADER_P_H
-#define BAMHEADER_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#include "api/SamHeader.h"
-#include <string>
-
-namespace BamTools {
-namespace Internal {
-
-class BgzfStream;
-
-class BamHeader {
-
-    // ctor & dtor
-    public:
-        BamHeader(void);
-        ~BamHeader(void);
-
-    // BamHeader interface
-    public:
-        // clear SamHeader data
-        void Clear(void);
-        // return true if SamHeader data is valid
-        bool IsValid(void) const;
-        // load BAM header ('magic number' and SAM header text) from BGZF stream
-        // returns true if all OK
-        void Load(BgzfStream* stream);
-        // returns (read-only) reference to SamHeader data object
-        const SamHeader& ToConstSamHeader(void) const;
-        // returns (editable) copy of SamHeader data object
-        SamHeader ToSamHeader(void) const;
-        // returns SAM-formatted string of header data
-        std::string ToString(void) const;
-
-    // internal methods
-    private:
-        // reads magic number from BGZF stream
-        void CheckMagicNumber(BgzfStream* stream);
-        // reads SAM header length from BGZF stream, stores it in @length
-        void ReadHeaderLength(BgzfStream* stream, uint32_t& length);
-        // reads SAM header text from BGZF stream, stores in SamHeader object
-        void ReadHeaderText(BgzfStream* stream, const uint32_t& length);
-
-    // data members
-    private:
-        SamHeader m_header;
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // BAMHEADER_P_H
diff --git a/bamtools/src/api/internal/bam/BamMultiMerger_p.h b/bamtools/src/api/internal/bam/BamMultiMerger_p.h
deleted file mode 100644
index 3000097..0000000
--- a/bamtools/src/api/internal/bam/BamMultiMerger_p.h
+++ /dev/null
@@ -1,266 +0,0 @@
-// ***************************************************************************
-// BamMultiMerger_p.h (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides merging functionality for BamMultiReader.  At this point, supports
-// sorting results by (refId, position) or by read name.
-// ***************************************************************************
-
-#ifndef BAMMULTIMERGER_P_H
-#define BAMMULTIMERGER_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#include "api/BamAlignment.h"
-#include "api/BamReader.h"
-#include "api/algorithms/Sort.h"
-#include <deque>
-#include <functional>
-#include <set>
-#include <string>
-
-namespace BamTools {
-namespace Internal {
-
-struct MergeItem {
-
-    // data members
-    BamReader*    Reader;
-    BamAlignment* Alignment;
-
-    // ctors & dtor
-    MergeItem(BamReader* reader = 0,
-              BamAlignment* alignment = 0)
-        : Reader(reader)
-        , Alignment(alignment)
-    { }
-
-    MergeItem(const MergeItem& other)
-        : Reader(other.Reader)
-        , Alignment(other.Alignment)
-    { }
-
-    ~MergeItem(void) { }
-};
-
-template<typename Compare>
-struct MergeItemSorter : public std::binary_function<MergeItem, MergeItem, bool> {
-
-    public:
-        MergeItemSorter(const Compare& comp = Compare())
-            : m_comp(comp)
-        { }
-
-        bool operator()(const MergeItem& lhs, const MergeItem& rhs) {
-            const BamAlignment& l = *lhs.Alignment;
-            const BamAlignment& r = *rhs.Alignment;
-            return m_comp(l,r);
-        }
-
-    private:
-        Compare m_comp;
-};
-
-// pure ABC so we can just work polymorphically with any specific merger implementation
-class IMultiMerger {
-
-    public:
-        IMultiMerger(void) { }
-        virtual ~IMultiMerger(void) { }
-    public:
-        virtual void Add(MergeItem item) =0;
-        virtual void Clear(void) =0;
-        virtual const MergeItem& First(void) const =0;
-        virtual bool IsEmpty(void) const =0;
-        virtual void Remove(BamReader* reader) =0;
-        virtual int Size(void) const =0;
-        virtual MergeItem TakeFirst(void) =0;
-};
-
-// general merger
-template<typename Compare>
-class MultiMerger : public IMultiMerger {
-
-    public:
-        typedef Compare                      CompareType;
-        typedef MergeItemSorter<CompareType> MergeType;
-
-    public:
-        explicit MultiMerger(const Compare& comp = Compare())
-            : IMultiMerger()
-            , m_data( MergeType(comp) )
-        { }
-        ~MultiMerger(void) { }
-
-    public:
-        void Add(MergeItem item);
-        void Clear(void);
-        const MergeItem& First(void) const;
-        bool IsEmpty(void) const;
-        void Remove(BamReader* reader);
-        int Size(void) const;
-        MergeItem TakeFirst(void);
-
-    private:
-        typedef MergeItem                              ValueType;
-        typedef std::multiset<ValueType, MergeType>    ContainerType;
-        typedef typename ContainerType::iterator       DataIterator;
-        typedef typename ContainerType::const_iterator DataConstIterator;
-        ContainerType m_data;
-};
-
-template <typename Compare>
-inline void MultiMerger<Compare>::Add(MergeItem item) {
-
-    // N.B. - any future custom Compare types must define this method
-    //        see algorithms/Sort.h
-
-    if ( CompareType::UsesCharData() )
-        item.Alignment->BuildCharData();
-    m_data.insert(item);
-}
-
-template <typename Compare>
-inline void MultiMerger<Compare>::Clear(void) {
-    m_data.clear();
-}
-
-template <typename Compare>
-inline const MergeItem& MultiMerger<Compare>::First(void) const {
-    const ValueType& entry = (*m_data.begin());
-    return entry;
-}
-
-template <typename Compare>
-inline bool MultiMerger<Compare>::IsEmpty(void) const {
-    return m_data.empty();
-}
-template <typename Compare>
-inline void MultiMerger<Compare>::Remove(BamReader* reader) {
-
-    if ( reader == 0 ) return;
-    const std::string& filenameToRemove = reader->GetFilename();
-
-    // iterate over readers in cache
-    DataIterator dataIter = m_data.begin();
-    DataIterator dataEnd  = m_data.end();
-    for ( ; dataIter != dataEnd; ++dataIter ) {
-        const MergeItem& item = (*dataIter);
-        const BamReader* itemReader = item.Reader;
-        if ( itemReader == 0 ) continue;
-
-        // remove iterator on match
-        if ( itemReader->GetFilename() == filenameToRemove ) {
-            m_data.erase(dataIter);
-            return;
-        }
-    }
-}
-template <typename Compare>
-inline int MultiMerger<Compare>::Size(void) const {
-    return m_data.size();
-}
-
-template <typename Compare>
-inline MergeItem MultiMerger<Compare>::TakeFirst(void) {
-    DataIterator firstIter = m_data.begin();
-    MergeItem    firstItem = (*firstIter);
-    m_data.erase(firstIter);
-    return firstItem;
-}
-
-// unsorted "merger"
-template<>
-class MultiMerger<Algorithms::Sort::Unsorted> : public IMultiMerger {
-
-    public:
-        explicit MultiMerger(const Algorithms::Sort::Unsorted& comp = Algorithms::Sort::Unsorted())
-            : IMultiMerger()
-        { }
-        ~MultiMerger(void) { }
-
-    public:
-        void Add(MergeItem item);
-        void Clear(void);
-        const MergeItem& First(void) const;
-        bool IsEmpty(void) const;
-        void Remove(BamReader* reader);
-        int Size(void) const;
-        MergeItem TakeFirst(void);
-
-    private:
-        typedef MergeItem                     ValueType;
-        typedef std::deque<ValueType>         ContainerType;
-        typedef ContainerType::iterator       DataIterator;
-        typedef ContainerType::const_iterator DataConstIterator;
-        ContainerType m_data;
-};
-
-inline
-void MultiMerger<Algorithms::Sort::Unsorted>::Add(MergeItem item) {
-    m_data.push_back(item);
-}
-
-inline
-void MultiMerger<Algorithms::Sort::Unsorted>::Clear(void) {
-    m_data.clear();
-}
-
-inline
-const MergeItem& MultiMerger<Algorithms::Sort::Unsorted>::First(void) const {
-    return m_data.front();
-}
-
-inline
-bool MultiMerger<Algorithms::Sort::Unsorted>::IsEmpty(void) const {
-    return m_data.empty();
-}
-
-inline
-void MultiMerger<Algorithms::Sort::Unsorted>::Remove(BamReader* reader) {
-
-    if ( reader == 0 ) return;
-    const std::string filenameToRemove = reader->GetFilename();
-
-    // iterate over readers in cache
-    DataIterator dataIter = m_data.begin();
-    DataIterator dataEnd  = m_data.end();
-    for ( ; dataIter != dataEnd; ++dataIter ) {
-        const MergeItem& item = (*dataIter);
-        const BamReader* itemReader = item.Reader;
-        if ( itemReader == 0 ) continue;
-
-        // remove iterator on match
-        if ( itemReader->GetFilename() == filenameToRemove ) {
-            m_data.erase(dataIter);
-            return;
-        }
-    }
-}
-
-inline
-int MultiMerger<Algorithms::Sort::Unsorted>::Size(void) const {
-    return m_data.size();
-}
-
-inline
-MergeItem MultiMerger<Algorithms::Sort::Unsorted>::TakeFirst(void) {
-    MergeItem firstItem = m_data.front();
-    m_data.pop_front();
-    return firstItem;
-}
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // BAMMULTIMERGER_P_H
diff --git a/bamtools/src/api/internal/bam/BamMultiReader_p.cpp b/bamtools/src/api/internal/bam/BamMultiReader_p.cpp
deleted file mode 100644
index 310d837..0000000
--- a/bamtools/src/api/internal/bam/BamMultiReader_p.cpp
+++ /dev/null
@@ -1,872 +0,0 @@
-// ***************************************************************************
-// BamMultiReader_p.cpp (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 24 July 2013 (DB)
-// ---------------------------------------------------------------------------
-// Functionality for simultaneously reading multiple BAM files
-// *************************************************************************
-
-#include "api/BamAlignment.h"
-#include "api/BamMultiReader.h"
-#include "api/SamConstants.h"
-#include "api/algorithms/Sort.h"
-#include "api/internal/bam/BamMultiReader_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#include <algorithm>
-#include <fstream>
-#include <iostream>
-#include <iterator>
-#include <sstream>
-using namespace std;
-
-// ctor
-BamMultiReaderPrivate::BamMultiReaderPrivate(void)
-    : m_alignmentCache(0)
-    , m_hasUserMergeOrder(false)
-    , m_mergeOrder(BamMultiReader::RoundRobinMerge)
-{ }
-
-// dtor
-BamMultiReaderPrivate::~BamMultiReaderPrivate(void) {
-    Close();
-}
-
-// close all BAM files
-bool BamMultiReaderPrivate::Close(void) {
-
-    m_errorString.clear();
-
-    if ( CloseFiles(Filenames()) )
-        return true;
-    else {
-        const string currentError = m_errorString;
-        const string message = string("error encountered while closing all files: \n\t") + currentError;
-        SetErrorString("BamMultiReader::Close", message);
-        return false;
-    }
-}
-
-// close requested BAM file
-bool BamMultiReaderPrivate::CloseFile(const string& filename) {
-
-    m_errorString.clear();
-
-    vector<string> filenames(1, filename);
-    if ( CloseFiles(filenames) )
-        return true;
-    else {
-        const string currentError = m_errorString;
-        const string message = string("error while closing file: ") + filename + "\n" + currentError;
-        SetErrorString("BamMultiReader::CloseFile", message);
-        return false;
-    }
-}
-
-// close requested BAM files
-bool BamMultiReaderPrivate::CloseFiles(const vector<string>& filenames) {
-
-    bool errorsEncountered = false;
-    m_errorString.clear();
-
-    // iterate over filenames
-    vector<string>::const_iterator filesIter = filenames.begin();
-    vector<string>::const_iterator filesEnd  = filenames.end();
-    for ( ; filesIter != filesEnd; ++filesIter ) {
-        const string& filename = (*filesIter);
-        if ( filename.empty() ) continue;
-
-        // iterate over readers
-        vector<MergeItem>::iterator readerIter = m_readers.begin();
-        vector<MergeItem>::iterator readerEnd  = m_readers.end();
-        for ( ; readerIter != readerEnd; ++readerIter ) {
-            MergeItem& item = (*readerIter);
-            BamReader* reader = item.Reader;
-            if ( reader == 0 ) continue;
-
-            // if reader matches requested filename
-            if ( reader->GetFilename() == filename ) {
-
-                // remove reader's entry from alignment cache
-                m_alignmentCache->Remove(reader);
-
-                // clean up reader & its alignment
-                if ( !reader->Close() ) {
-                    m_errorString.append(1, '\t');
-                    m_errorString.append(reader->GetErrorString());
-                    m_errorString.append(1, '\n');
-                    errorsEncountered = true;
-                }
-                delete reader;
-                reader = 0;
-
-                // delete reader's alignment entry
-                BamAlignment* alignment = item.Alignment;
-                delete alignment;
-                alignment = 0;
-
-                // remove reader from reader list
-                m_readers.erase(readerIter);
-
-                // on match, just go on to next filename
-                // (no need to keep looking and item iterator is invalid now anyway)
-                break;
-            }
-        }
-    }
-
-    // make sure we clean up properly if all readers were closed
-    if ( m_readers.empty() ) {
-
-        // clean up merger
-        if ( m_alignmentCache ) {
-            m_alignmentCache->Clear();
-            delete m_alignmentCache;
-            m_alignmentCache = 0;
-        }
-
-        // reset merge flags
-        m_hasUserMergeOrder = false;
-        m_mergeOrder = BamMultiReader::RoundRobinMerge;
-    }
-
-    // return whether all readers closed OK
-    return !errorsEncountered;
-}
-
-// creates index files for BAM files that don't have them
-bool BamMultiReaderPrivate::CreateIndexes(const BamIndex::IndexType& type) {
-
-    bool errorsEncountered = false;
-    m_errorString.clear();
-
-    // iterate over readers
-    vector<MergeItem>::iterator itemIter = m_readers.begin();
-    vector<MergeItem>::iterator itemEnd  = m_readers.end();
-    for ( ; itemIter != itemEnd; ++itemIter ) {
-        MergeItem& item = (*itemIter);
-        BamReader* reader = item.Reader;
-        if ( reader == 0 ) continue;
-
-        // if reader doesn't have an index, create one
-        if ( !reader->HasIndex() ) {
-            if ( !reader->CreateIndex(type) ) {
-                m_errorString.append(1, '\t');
-                m_errorString.append(reader->GetErrorString());
-                m_errorString.append(1, '\n');
-                errorsEncountered = true;
-            }
-        }
-    }
-
-    // check for errors encountered before returning success/fail
-    if ( errorsEncountered ) {
-        const string currentError = m_errorString;
-        const string message = string("error while creating index files: ") + "\n" + currentError;
-        SetErrorString("BamMultiReader::CreateIndexes", message);
-        return false;
-    } else
-        return true;
-}
-
-IMultiMerger* BamMultiReaderPrivate::CreateAlignmentCache(void) {
-
-    // if no merge order set explicitly, use SAM header to lookup proper order
-    if ( !m_hasUserMergeOrder ) {
-
-        // fetch SamHeader from BAM files
-        SamHeader header = GetHeader();
-
-        // if BAM files are sorted by position
-        if ( header.SortOrder == Constants::SAM_HD_SORTORDER_COORDINATE )
-            m_mergeOrder = BamMultiReader::MergeByCoordinate;
-
-        // if BAM files are sorted by read name
-        else if ( header.SortOrder == Constants::SAM_HD_SORTORDER_QUERYNAME )
-            m_mergeOrder = BamMultiReader::MergeByName;
-
-        // otherwise, sorting is either "unknown" or marked as "unsorted"
-        else
-            m_mergeOrder = BamMultiReader::RoundRobinMerge;
-    }
-
-    // use current merge order to create proper 'multi-merger'
-    switch ( m_mergeOrder ) {
-
-        // merge BAM files by position
-        case BamMultiReader::MergeByCoordinate :
-            return new MultiMerger<Algorithms::Sort::ByPosition>();
-
-        // merge BAM files by read name
-        case BamMultiReader::MergeByName :
-            return new MultiMerger<Algorithms::Sort::ByName>();
-
-        // sorting is "unknown", "unsorted" or "ignored"... so use unsorted merger
-        case BamMultiReader::RoundRobinMerge :
-            return new MultiMerger<Algorithms::Sort::Unsorted>();
-
-        // unknown merge order, can't create merger
-        default:
-            return 0;
-    }
-}
-
-const vector<string> BamMultiReaderPrivate::Filenames(void) const {
-
-    // init filename container
-    vector<string> filenames;
-    filenames.reserve( m_readers.size() );
-
-    // iterate over readers
-    vector<MergeItem>::const_iterator itemIter = m_readers.begin();
-    vector<MergeItem>::const_iterator itemEnd  = m_readers.end();
-    for ( ; itemIter != itemEnd; ++itemIter ) {
-        const MergeItem& item = (*itemIter);
-        const BamReader* reader = item.Reader;
-        if ( reader == 0 ) continue;
-
-        // store filename if not empty
-        const string& filename = reader->GetFilename();
-        if ( !filename.empty() )
-            filenames.push_back(filename);
-    }
-
-    // return result
-    return filenames;
-}
-
-string BamMultiReaderPrivate::GetErrorString(void) const {
-    return m_errorString;
-}
-
-SamHeader BamMultiReaderPrivate::GetHeader(void) const {
-    const string& text = GetHeaderText();
-    return SamHeader(text);
-}
-
-// makes a virtual, unified header for all the bam files in the multireader
-string BamMultiReaderPrivate::GetHeaderText(void) const {
-
-    // N.B. - right now, simply copies all header data from first BAM,
-    //        and then appends RG's from other BAM files
-    // TODO: make this more intelligent wrt other header lines/fields
-
-    // if no readers open
-    const size_t numReaders = m_readers.size();
-    if ( numReaders == 0 ) return string();
-
-    // retrieve first reader's header
-    const MergeItem& firstItem = m_readers.front();
-    const BamReader* reader = firstItem.Reader;
-    if ( reader == 0 ) return string();
-    SamHeader mergedHeader = reader->GetHeader();
-
-    // iterate over any remaining readers (skipping the first)
-    for ( size_t i = 1; i < numReaders; ++i ) {
-        const MergeItem& item = m_readers.at(i);
-        const BamReader* reader = item.Reader;
-        if ( reader == 0 ) continue;
-
-        // retrieve current reader's header
-        const SamHeader currentHeader = reader->GetHeader();
-
-        // append current reader's RG entries to merged header
-        // N.B. - SamReadGroupDictionary handles duplicate-checking
-        mergedHeader.ReadGroups.Add(currentHeader.ReadGroups);
-
-        // TODO: merge anything else??
-    }
-
-    // return stringified header
-    return mergedHeader.ToString();
-}
-
-BamMultiReader::MergeOrder BamMultiReaderPrivate::GetMergeOrder(void) const {
-    return m_mergeOrder;
-}
-
-// get next alignment among all files
-bool BamMultiReaderPrivate::GetNextAlignment(BamAlignment& al) {
-    return PopNextCachedAlignment(al, true);
-}
-
-// get next alignment among all files without parsing character data from alignments
-bool BamMultiReaderPrivate::GetNextAlignmentCore(BamAlignment& al) {
-    return PopNextCachedAlignment(al, false);
-}
-
-// ---------------------------------------------------------------------------------------
-//
-// NB: The following GetReferenceX() functions assume that we have identical
-// references for all BAM files.  We enforce this by invoking the
-// ValidateReaders() method to verify that our reference data is the same
-// across all files on Open - so we will not encounter a situation in which
-// there is a mismatch and we are still live.
-//
-// ---------------------------------------------------------------------------------------
-
-// returns the number of reference sequences
-int BamMultiReaderPrivate::GetReferenceCount(void) const {
-
-    // handle empty multireader
-    if ( m_readers.empty() ) return 0;
-
-    // return reference count from first reader
-    const MergeItem& item = m_readers.front();
-    const BamReader* reader = item.Reader;
-    if ( reader == 0 ) return 0;
-    else
-        return reader->GetReferenceCount();
-}
-
-// returns vector of reference objects
-const RefVector BamMultiReaderPrivate::GetReferenceData(void) const {
-
-    // handle empty multireader
-    if ( m_readers.empty() ) return RefVector();
-
-    // return reference data from first BamReader
-    const MergeItem& item = m_readers.front();
-    const BamReader* reader = item.Reader;
-    if ( reader == 0 ) return RefVector();
-    else
-        return reader->GetReferenceData();
-}
-
-// returns refID from reference name
-int BamMultiReaderPrivate::GetReferenceID(const string& refName) const {
-
-    // handle empty multireader
-    if ( m_readers.empty() ) return -1;
-
-    // return reference ID from first BamReader
-    const MergeItem& item = m_readers.front();
-    const BamReader* reader = item.Reader;
-    if ( reader == 0 ) return -1;
-    else
-        return reader->GetReferenceID(refName);
-}
-// ---------------------------------------------------------------------------------------
-
-// returns true if all readers have index data available
-// this is useful to indicate whether Jump() or SetRegion() are possible
-bool BamMultiReaderPrivate::HasIndexes(void) const {
-
-    // handle empty multireader
-    if ( m_readers.empty() )
-        return false;
-
-    bool result = true;
-
-    // iterate over readers
-    vector<MergeItem>::const_iterator readerIter = m_readers.begin();
-    vector<MergeItem>::const_iterator readerEnd  = m_readers.end();
-    for ( ; readerIter != readerEnd; ++readerIter ) {
-        const MergeItem& item = (*readerIter);
-        const BamReader* reader = item.Reader;
-        if ( reader  == 0 ) continue;
-
-        // see if current reader has index data
-        result &= reader->HasIndex();
-    }
-
-    return result;
-}
-
-// returns true if multireader has open readers
-bool BamMultiReaderPrivate::HasOpenReaders(void) {
-
-    // iterate over readers
-    vector<MergeItem>::const_iterator readerIter = m_readers.begin();
-    vector<MergeItem>::const_iterator readerEnd  = m_readers.end();
-    for ( ; readerIter != readerEnd; ++readerIter ) {
-        const MergeItem& item = (*readerIter);
-        const BamReader* reader = item.Reader;
-        if ( reader == 0 ) continue;
-
-        // return true whenever an open reader is found
-        if ( reader->IsOpen() ) return true;
-    }
-
-    // no readers open
-    return false;
-}
-
-// performs random-access jump using (refID, position) as a left-bound
-bool BamMultiReaderPrivate::Jump(int refID, int position) {
-
-    // NB: While it may make sense to track readers in which we can
-    // successfully Jump, in practice a failure of Jump means "no
-    // alignments here."  It makes sense to simply accept the failure,
-    // UpdateAlignments(), and continue.
-
-    // iterate over readers
-    vector<MergeItem>::iterator readerIter = m_readers.begin();
-    vector<MergeItem>::iterator readerEnd  = m_readers.end();
-    for ( ; readerIter != readerEnd; ++readerIter ) {
-        MergeItem& item = (*readerIter);
-        BamReader* reader = item.Reader;
-        if ( reader == 0 ) continue;
-
-        // jump in each BamReader to position of interest
-        reader->Jump(refID, position);
-    }
-
-    // returns status of cache update
-    return UpdateAlignmentCache();
-}
-
-// locate (& load) index files for BAM readers that don't already have one loaded
-bool BamMultiReaderPrivate::LocateIndexes(const BamIndex::IndexType& preferredType) {
-
-    bool errorsEncountered = false;
-    m_errorString.clear();
-
-    // iterate over readers
-    vector<MergeItem>::iterator readerIter = m_readers.begin();
-    vector<MergeItem>::iterator readerEnd  = m_readers.end();
-    for ( ; readerIter != readerEnd; ++readerIter ) {
-        MergeItem& item = (*readerIter);
-        BamReader* reader = item.Reader;
-        if ( reader == 0 ) continue;
-
-        // if reader has no index, try to locate one
-        if ( !reader->HasIndex() ) {
-            if ( !reader->LocateIndex(preferredType) ) {
-                m_errorString.append(1, '\t');
-                m_errorString.append(reader->GetErrorString());
-                m_errorString.append(1, '\n');
-                errorsEncountered = true;
-            }
-        }
-    }
-
-    // check for errors encountered before returning success/fail
-    if ( errorsEncountered ) {
-        const string currentError = m_errorString;
-        const string message = string("error while locating index files: ") + "\n" + currentError;
-        SetErrorString("BamMultiReader::LocatingIndexes", message);
-        return false;
-    } else
-        return true;
-}
-
-// opens BAM files
-bool BamMultiReaderPrivate::Open(const vector<string>& filenames) {
-
-    m_errorString.clear();
-
-    // put all current readers back at beginning (refreshes alignment cache)
-    if ( !Rewind() ) {
-        const string currentError = m_errorString;
-        const string message = string("unable to rewind existing readers: \n\t") + currentError;
-        SetErrorString("BamMultiReader::Open", message);
-        return false;
-    }
-
-    // iterate over filenames
-    bool errorsEncountered = false;
-    vector<string>::const_iterator filenameIter = filenames.begin();
-    vector<string>::const_iterator filenameEnd  = filenames.end();
-    for ( ; filenameIter != filenameEnd; ++filenameIter ) {
-        const string& filename = (*filenameIter);
-        if ( filename.empty() ) continue;
-
-        // attempt to open BamReader
-        BamReader* reader = new BamReader;
-        const bool readerOpened = reader->Open(filename);
-
-        // if opened OK, store it
-        if ( readerOpened )
-            m_readers.push_back( MergeItem(reader, new BamAlignment) );
-
-        // otherwise store error & clean up invalid reader
-        else {
-            m_errorString.append(1, '\t');
-            m_errorString += string("unable to open file: ") + filename;
-            m_errorString.append(1, '\n');
-            errorsEncountered = true;
-
-            delete reader;
-            reader = 0;
-        }
-    }
-
-    // check for errors while opening
-    if ( errorsEncountered ) {
-        const string currentError = m_errorString;
-        const string message = string("unable to open all files: \t\n") + currentError;
-        SetErrorString("BamMultiReader::Open", message);
-        return false;
-    }
-
-    // check for BAM file consistency
-    if ( !ValidateReaders() ) {
-        const string currentError = m_errorString;
-        const string message = string("unable to open inconsistent files: \t\n") + currentError;
-        SetErrorString("BamMultiReader::Open", message);
-        return false;
-    }
-
-    // update alignment cache
-    return UpdateAlignmentCache();
-}
-
-bool BamMultiReaderPrivate::OpenFile(const std::string& filename) {
-    vector<string> filenames(1, filename);
-    if ( Open(filenames) )
-        return true;
-    else {
-        const string currentError = m_errorString;
-        const string message = string("could not open file: ") + filename + "\n\t" + currentError;
-        SetErrorString("BamMultiReader::OpenFile", message);
-        return false;
-    }
-}
-
-bool BamMultiReaderPrivate::OpenIndexes(const vector<string>& indexFilenames) {
-
-    // TODO: This needs to be cleaner - should not assume same order.
-    //       And either way, shouldn't start at first reader.  Should start at
-    //       first reader without an index?
-
-    // make sure same number of index filenames as readers
-    if ( m_readers.size() != indexFilenames.size() ) {
-        const string message("size of index file list does not match current BAM file count");
-        SetErrorString("BamMultiReader::OpenIndexes", message);
-        return false;
-    }
-
-    bool errorsEncountered = false;
-    m_errorString.clear();
-
-    // iterate over BamReaders
-    vector<string>::const_iterator indexFilenameIter = indexFilenames.begin();
-    vector<string>::const_iterator indexFilenameEnd  = indexFilenames.end();
-    vector<MergeItem>::iterator readerIter = m_readers.begin();
-    vector<MergeItem>::iterator readerEnd  = m_readers.end();
-    for ( ; readerIter != readerEnd; ++readerIter ) {
-        MergeItem& item = (*readerIter);
-        BamReader* reader = item.Reader;
-
-        // open index filename on reader
-        if ( reader ) {
-            const string& indexFilename = (*indexFilenameIter);
-            if ( !reader->OpenIndex(indexFilename) ) {
-                m_errorString.append(1, '\t');
-                m_errorString += reader->GetErrorString();
-                m_errorString.append(1, '\n');
-                errorsEncountered = true;
-            }
-        }
-
-        // increment filename iterator, skip if no more index files to open
-        if ( ++indexFilenameIter == indexFilenameEnd )
-            break;
-    }
-
-    // return success/fail
-    if ( errorsEncountered ) {
-        const string currentError = m_errorString;
-        const string message = string("could not open all index files: \n\t") + currentError;
-        SetErrorString("BamMultiReader::OpenIndexes", message);
-        return false;
-    } else
-        return true;
-}
-
-bool BamMultiReaderPrivate::PopNextCachedAlignment(BamAlignment& al, const bool needCharData) {
-
-    // skip if no alignments available
-    if ( m_alignmentCache == 0 || m_alignmentCache->IsEmpty() )
-        return false;
-
-    // pop next merge item entry from cache
-    MergeItem item = m_alignmentCache->TakeFirst();
-    BamReader* reader = item.Reader;
-    BamAlignment* alignment = item.Alignment;
-    if ( reader == 0 || alignment == 0 )
-        return false;
-
-    // set char data if requested
-    if ( needCharData ) {
-        alignment->BuildCharData();
-        alignment->Filename = reader->GetFilename();
-    }
-
-    // store cached alignment into destination parameter (by copy)
-    al = *alignment;
-
-    // load next alignment from reader & store in cache
-    SaveNextAlignment(reader, alignment);
-    return true;
-}
-
-// returns BAM file pointers to beginning of alignment data & resets alignment cache
-bool BamMultiReaderPrivate::Rewind(void) {
-
-    // skip if no readers open
-    if ( m_readers.empty() )
-        return true;
-
-    // attempt to rewind files
-    if ( !RewindReaders() ) {
-        const string currentError = m_errorString;
-        const string message = string("could not rewind readers: \n\t") + currentError;
-        SetErrorString("BamMultiReader::Rewind", message);
-        return false;
-    }
-
-    // return status of cache update
-    return UpdateAlignmentCache();
-}
-
-// returns BAM file pointers to beginning of alignment data
-bool BamMultiReaderPrivate::RewindReaders(void) {
-
-    m_errorString.clear();
-    bool errorsEncountered = false;
-
-    // iterate over readers
-    vector<MergeItem>::iterator readerIter = m_readers.begin();
-    vector<MergeItem>::iterator readerEnd  = m_readers.end();
-    for ( ; readerIter != readerEnd; ++readerIter ) {
-        MergeItem& item = (*readerIter);
-        BamReader* reader = item.Reader;
-        if ( reader == 0 ) continue;
-
-        // attempt rewind on BamReader
-        if ( !reader->Rewind() ) {
-            m_errorString.append(1, '\t');
-            m_errorString.append( reader->GetErrorString() );
-            m_errorString.append(1, '\n');
-            errorsEncountered = true;
-        }
-    }
-
-    return !errorsEncountered;
-}
-
-void BamMultiReaderPrivate::SaveNextAlignment(BamReader* reader, BamAlignment* alignment) {
-
-    // if can read alignment from reader, store in cache
-    //
-    // N.B. - lazy building of alignment's char data - populated only:
-    //        automatically by alignment cache to maintain its sorting OR
-    //        on demand from client call to future call to GetNextAlignment()
-
-    if ( reader->GetNextAlignmentCore(*alignment) )
-        m_alignmentCache->Add( MergeItem(reader, alignment) );
-}
-
-bool BamMultiReaderPrivate::SetExplicitMergeOrder(BamMultiReader::MergeOrder order) {
-
-    // set new merge flags
-    m_hasUserMergeOrder = true;
-    m_mergeOrder = order;
-
-    // remove any existing merger (storing any existing data sitting in the cache)
-    vector<MergeItem> currentCacheData;
-    if ( m_alignmentCache ) {        
-        while ( !m_alignmentCache->IsEmpty() )
-            currentCacheData.push_back( m_alignmentCache->TakeFirst() );
-        delete m_alignmentCache;
-        m_alignmentCache = 0;
-    }
-
-    // create new cache using the new merge flags
-    m_alignmentCache = CreateAlignmentCache();
-    if ( m_alignmentCache == 0 ) {
-        SetErrorString("BamMultiReader::SetExplicitMergeOrder", "requested order is unrecognized");
-        return false;
-    }
-
-    // push current data onto new cache
-    vector<MergeItem>::const_iterator readerIter = currentCacheData.begin();
-    vector<MergeItem>::const_iterator readerEnd  = currentCacheData.end();
-    for ( ; readerIter != readerEnd; ++readerIter ) {
-        const MergeItem& item = (*readerIter);
-        m_alignmentCache->Add(item);
-    }
-
-    // return success
-    return true;
-}
-
-void BamMultiReaderPrivate::SetErrorString(const string& where, const string& what) const {
-    static const string SEPARATOR = ": ";
-    m_errorString = where + SEPARATOR + what;
-}
-
-bool BamMultiReaderPrivate::SetRegion(const BamRegion& region) {
-
-    // NB: While it may make sense to track readers in which we can
-    // successfully SetRegion, In practice a failure of SetRegion means "no
-    // alignments here."  It makes sense to simply accept the failure,
-    // UpdateAlignments(), and continue.
-
-    // iterate over alignments
-    vector<MergeItem>::iterator readerIter = m_readers.begin();
-    vector<MergeItem>::iterator readerEnd  = m_readers.end();
-    for ( ; readerIter != readerEnd; ++readerIter ) {
-        MergeItem& item = (*readerIter);
-        BamReader* reader = item.Reader;
-        if ( reader == 0 ) continue;
-
-        // set region of interest
-        reader->SetRegion(region);
-    }
-
-    // return status of cache update
-    return UpdateAlignmentCache();
-}
-
-// updates our alignment cache
-bool BamMultiReaderPrivate::UpdateAlignmentCache(void) {
-
-    // create alignment cache if not created yet
-    if ( m_alignmentCache == 0 ) {
-        m_alignmentCache = CreateAlignmentCache();
-        if ( m_alignmentCache == 0 ) {
-            SetErrorString("BamMultiReader::UpdateAlignmentCache", "unable to create new alignment cache");
-            return false;
-        }
-    }
-
-    // clear any prior cache data
-    m_alignmentCache->Clear();
-
-    // iterate over readers
-    vector<MergeItem>::iterator readerIter = m_readers.begin();
-    vector<MergeItem>::iterator readerEnd  = m_readers.end();
-    for ( ; readerIter != readerEnd; ++readerIter ) {
-        MergeItem& item = (*readerIter);
-        BamReader* reader = item.Reader;
-        BamAlignment* alignment = item.Alignment;
-        if ( reader == 0 || alignment == 0 ) continue;
-
-        // save next alignment from each reader in cache
-        SaveNextAlignment(reader, alignment);
-    }
-
-    // if we get here, ok
-    return true;
-}
-
-// ValidateReaders checks that all the readers point to BAM files representing
-// alignments against the same set of reference sequences, and that the
-// sequences are identically ordered.  If these checks fail the operation of
-// the multireader is undefined, so we force program exit.
-bool BamMultiReaderPrivate::ValidateReaders(void) const {
-
-    m_errorString.clear();
-
-    // skip if 0 or 1 readers opened
-    if ( m_readers.empty() || (m_readers.size() == 1) )
-        return true;
-
-    // retrieve first reader
-    const MergeItem& firstItem = m_readers.front();
-    const BamReader* firstReader = firstItem.Reader;
-    if ( firstReader == 0 ) return false;
-
-    // retrieve first reader's header data
-    const SamHeader& firstReaderHeader = firstReader->GetHeader();
-    const string& firstReaderSortOrder = firstReaderHeader.SortOrder;
-
-    // retrieve first reader's reference data
-    const RefVector& firstReaderRefData = firstReader->GetReferenceData();
-    const int firstReaderRefCount = firstReader->GetReferenceCount();
-    const int firstReaderRefSize = firstReaderRefData.size();
-
-    // iterate over all readers
-    vector<MergeItem>::const_iterator readerIter = m_readers.begin();
-    vector<MergeItem>::const_iterator readerEnd  = m_readers.end();
-    for ( ; readerIter != readerEnd; ++readerIter ) {
-        const MergeItem& item = (*readerIter);
-        BamReader* reader = item.Reader;
-        if ( reader == 0 ) continue;
-
-        // get current reader's header data
-        const SamHeader& currentReaderHeader = reader->GetHeader();
-        const string& currentReaderSortOrder = currentReaderHeader.SortOrder;
-
-        // check compatible sort order
-        if ( currentReaderSortOrder != firstReaderSortOrder ) {
-            const string message = string("mismatched sort order in ") + reader->GetFilename() +
-                                   ", expected " + firstReaderSortOrder +
-                                   ", but found " + currentReaderSortOrder;
-            SetErrorString("BamMultiReader::ValidateReaders", message);
-            return false;
-        }
-
-        // get current reader's reference data
-        const RefVector currentReaderRefData = reader->GetReferenceData();
-        const int currentReaderRefCount = reader->GetReferenceCount();
-        const int currentReaderRefSize  = currentReaderRefData.size();
-
-        // init reference data iterators
-        RefVector::const_iterator firstRefIter   = firstReaderRefData.begin();
-        RefVector::const_iterator firstRefEnd    = firstReaderRefData.end();
-        RefVector::const_iterator currentRefIter = currentReaderRefData.begin();
-
-        // compare reference counts from BamReader ( & container size, in case of BR error)
-        if ( (currentReaderRefCount != firstReaderRefCount) ||
-             (firstReaderRefSize    != currentReaderRefSize) )
-        {
-            stringstream s("");
-            s << "mismatched reference count in " << reader->GetFilename()
-              << ", expected " << firstReaderRefCount
-              << ", but found " << currentReaderRefCount;
-            SetErrorString("BamMultiReader::ValidateReaders", s.str());
-            return false;
-        }
-
-        // this will be ok; we just checked above that we have identically-sized sets of references
-        // here we simply check if they are all, in fact, equal in content
-        while ( firstRefIter != firstRefEnd ) {
-            const RefData& firstRef   = (*firstRefIter);
-            const RefData& currentRef = (*currentRefIter);
-
-            // compare reference name & length
-            if ( (firstRef.RefName   != currentRef.RefName) ||
-                 (firstRef.RefLength != currentRef.RefLength) )
-            {
-                stringstream s("");
-                s << "mismatched references found in" << reader->GetFilename()
-                  << "expected: " << endl;
-
-                // print first reader's reference data
-                RefVector::const_iterator refIter = firstReaderRefData.begin();
-                RefVector::const_iterator refEnd  = firstReaderRefData.end();
-                for ( ; refIter != refEnd; ++refIter ) {
-                    const RefData& entry = (*refIter);
-                    stringstream s("");
-                    s << entry.RefName << " " << endl;
-                }
-
-                s << "but found: " << endl;
-
-                // print current reader's reference data
-                refIter = currentReaderRefData.begin();
-                refEnd  = currentReaderRefData.end();
-                for ( ; refIter != refEnd; ++refIter ) {
-                    const RefData& entry = (*refIter);
-                    s << entry.RefName << " " << entry.RefLength << endl;
-                }
-
-                SetErrorString("BamMultiReader::ValidateReaders", s.str());
-                return false;
-            }
-
-            // update iterators
-            ++firstRefIter;
-            ++currentRefIter;
-        }
-    }
-
-    // if we get here, everything checks out
-    return true;
-}
diff --git a/bamtools/src/api/internal/bam/BamMultiReader_p.h b/bamtools/src/api/internal/bam/BamMultiReader_p.h
deleted file mode 100644
index 3a7a0b2..0000000
--- a/bamtools/src/api/internal/bam/BamMultiReader_p.h
+++ /dev/null
@@ -1,105 +0,0 @@
-// ***************************************************************************
-// BamMultiReader_p.h (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 14 January 2013 (DB)
-// ---------------------------------------------------------------------------
-// Functionality for simultaneously reading multiple BAM files
-// *************************************************************************
-
-#ifndef BAMMULTIREADER_P_H
-#define BAMMULTIREADER_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#include "api/SamHeader.h"
-#include "api/BamMultiReader.h"
-#include "api/internal/bam/BamMultiMerger_p.h"
-#include <string>
-#include <vector>
-
-namespace BamTools {
-namespace Internal {
-
-class BamMultiReaderPrivate {
-
-    // typedefs
-    public:
-        typedef std::pair<BamReader*, BamAlignment*> ReaderAlignment;
-
-    // constructor / destructor
-    public:
-        BamMultiReaderPrivate(void);
-        ~BamMultiReaderPrivate(void);
-
-    // public interface
-    public:
-
-        // file operations
-        bool Close(void);
-        bool CloseFile(const std::string& filename);
-        const std::vector<std::string> Filenames(void) const;
-        bool Jump(int refID, int position = 0);
-        bool Open(const std::vector<std::string>& filenames);
-        bool OpenFile(const std::string& filename);
-        bool Rewind(void);
-        bool SetRegion(const BamRegion& region);
-
-        // access alignment data
-        BamMultiReader::MergeOrder GetMergeOrder(void) const;
-        bool GetNextAlignment(BamAlignment& al);
-        bool GetNextAlignmentCore(BamAlignment& al);
-        bool HasOpenReaders(void);
-        bool SetExplicitMergeOrder(BamMultiReader::MergeOrder order);
-
-        // access auxiliary data
-        SamHeader GetHeader(void) const;
-        std::string GetHeaderText(void) const;
-        int GetReferenceCount(void) const;
-        const BamTools::RefVector GetReferenceData(void) const;
-        int GetReferenceID(const std::string& refName) const;
-
-        // BAM index operations
-        bool CreateIndexes(const BamIndex::IndexType& type = BamIndex::STANDARD);
-        bool HasIndexes(void) const;
-        bool LocateIndexes(const BamIndex::IndexType& preferredType = BamIndex::STANDARD);
-        bool OpenIndexes(const std::vector<std::string>& indexFilenames);
-
-        // error handling
-        std::string GetErrorString(void) const;
-
-    // 'internal' methods
-    public:
-
-        bool CloseFiles(const std::vector<std::string>& filenames);
-        IMultiMerger* CreateAlignmentCache(void);
-        bool PopNextCachedAlignment(BamAlignment& al, const bool needCharData);
-        bool RewindReaders(void);
-        void SaveNextAlignment(BamReader* reader, BamAlignment* alignment);
-        void SetErrorString(const std::string& where, const std::string& what) const; //
-        bool UpdateAlignmentCache(void);
-        bool ValidateReaders(void) const;
-
-    // data members
-    public:
-        std::vector<MergeItem> m_readers;
-        IMultiMerger* m_alignmentCache;
-
-        bool m_hasUserMergeOrder;
-        BamMultiReader::MergeOrder m_mergeOrder;
-
-        mutable std::string m_errorString;
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // BAMMULTIREADER_P_H
diff --git a/bamtools/src/api/internal/bam/BamRandomAccessController_p.cpp b/bamtools/src/api/internal/bam/BamRandomAccessController_p.cpp
deleted file mode 100644
index 848fafd..0000000
--- a/bamtools/src/api/internal/bam/BamRandomAccessController_p.cpp
+++ /dev/null
@@ -1,289 +0,0 @@
-// ***************************************************************************
-// BamRandomAccessController_p.cpp (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 25 October 2011(DB)
-// ---------------------------------------------------------------------------
-// Manages random access operations in a BAM file
-// **************************************************************************
-
-#include "api/BamIndex.h"
-#include "api/internal/bam/BamRandomAccessController_p.h"
-#include "api/internal/bam/BamReader_p.h"
-#include "api/internal/index/BamIndexFactory_p.h"
-#include "api/internal/utils/BamException_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#include <cassert>
-#include <sstream>
-using namespace std;
-
-BamRandomAccessController::BamRandomAccessController(void)
-    : m_index(0)
-    , m_hasAlignmentsInRegion(true)
-{ }
-
-BamRandomAccessController::~BamRandomAccessController(void) {
-    Close();
-}
-
-void BamRandomAccessController::AdjustRegion(const int& referenceCount) {
-
-    // skip if no index available
-    if ( m_index == 0 )
-        return;
-
-    // see if any references in region have alignments
-    m_hasAlignmentsInRegion = false;
-    int currentId = m_region.LeftRefID;
-    const int rightBoundRefId = ( m_region.isRightBoundSpecified() ? m_region.RightRefID : referenceCount - 1 );
-    while ( currentId <= rightBoundRefId ) {
-        m_hasAlignmentsInRegion = m_index->HasAlignments(currentId);
-        if ( m_hasAlignmentsInRegion ) break;
-        ++currentId;
-    }
-
-    // if no data found on any reference in region
-    if ( !m_hasAlignmentsInRegion )
-        return;
-
-    // if left bound of desired region had no data, use first reference that had data
-    // otherwise, leave requested region as-is
-    if ( currentId != m_region.LeftRefID ) {
-        m_region.LeftRefID = currentId;
-        m_region.LeftPosition = 0;
-    }
-}
-
-// returns alignments' "RegionState": { Before|Overlaps|After } current region
-BamRandomAccessController::RegionState
-BamRandomAccessController::AlignmentState(const BamAlignment& alignment) const {
-
-    // if region has no left bound at all
-    if ( !m_region.isLeftBoundSpecified() )
-        return OverlapsRegion;
-
-    // handle unmapped reads - return AFTER region to halt processing
-    if ( alignment.RefID == -1 )
-        return AfterRegion;
-
-    // if alignment is on any reference before left bound reference
-    if ( alignment.RefID < m_region.LeftRefID )
-        return BeforeRegion;
-
-    // if alignment is on left bound reference
-    else if ( alignment.RefID == m_region.LeftRefID ) {
-
-        // if alignment starts at or after left bound position
-        if ( alignment.Position >= m_region.LeftPosition) {
-
-            if ( m_region.isRightBoundSpecified() &&             // right bound is specified AND
-                 m_region.LeftRefID == m_region.RightRefID &&    // left & right bounds on same reference AND
-                 alignment.Position >= m_region.RightPosition )  // alignment starts on or after right bound position
-                return AfterRegion;
-
-            // otherwise, alignment overlaps region
-            else return OverlapsRegion;
-        }
-
-        // alignment starts before left bound position
-        else {
-
-            // if alignment overlaps left bound position
-            if ( alignment.GetEndPosition() > m_region.LeftPosition )
-                return OverlapsRegion;
-            else
-                return BeforeRegion;
-        }
-    }
-
-    // otherwise alignment is on a reference after left bound reference
-    else {
-
-        // if region has a right bound
-        if ( m_region.isRightBoundSpecified() ) {
-
-            // alignment is on any reference between boundaries
-            if ( alignment.RefID < m_region.RightRefID )
-                return OverlapsRegion;
-
-            // alignment is on any reference after right boundary
-            else if ( alignment.RefID > m_region.RightRefID )
-                return AfterRegion;
-
-            // alignment is on right bound reference
-            else {
-
-                // if alignment starts before right bound position
-                if ( alignment.Position < m_region.RightPosition )
-                    return OverlapsRegion;
-                else
-                    return AfterRegion;
-            }
-        }
-
-        // otherwise, alignment starts after left bound and there is no right bound given
-        else return OverlapsRegion;
-    }
-}
-
-void BamRandomAccessController::Close(void) {
-    ClearIndex();
-    ClearRegion();
-}
-
-void BamRandomAccessController::ClearIndex(void) {
-    if ( m_index ) {
-        delete m_index;
-        m_index = 0;
-    }
-}
-
-void BamRandomAccessController::ClearRegion(void) {
-    m_region.clear();
-    m_hasAlignmentsInRegion = true;
-}
-
-bool BamRandomAccessController::CreateIndex(BamReaderPrivate* reader,
-                                            const BamIndex::IndexType& type)
-{
-    // skip if reader is invalid
-    assert(reader);
-    if ( !reader->IsOpen() ) {
-        SetErrorString("BamRandomAccessController::CreateIndex",
-                       "cannot create index for unopened reader");
-        return false;
-    }
-
-    // create new index of requested type
-    BamIndex* newIndex = BamIndexFactory::CreateIndexOfType(type, reader);
-    if ( newIndex == 0 ) {
-        stringstream s("");
-        s << "could not create index of type: " << type;
-        SetErrorString("BamRandomAccessController::CreateIndex", s.str());
-        return false;
-    }
-
-    // attempt to build index from current BamReader file
-    if ( !newIndex->Create() ) {
-        const string indexError = newIndex->GetErrorString();
-        const string message = "could not create index: \n\t" + indexError;
-        SetErrorString("BamRandomAccessController::CreateIndex", message);
-        return false;
-    }
-
-    // save new index & return success
-    SetIndex(newIndex);
-    return true;
-}
-
-string BamRandomAccessController::GetErrorString(void) const {
-    return m_errorString;
-}
-
-bool BamRandomAccessController::HasIndex(void) const {
-    return ( m_index != 0 );
-}
-
-bool BamRandomAccessController::HasRegion(void) const  {
-    return ( !m_region.isNull() );
-}
-
-bool BamRandomAccessController::IndexHasAlignmentsForReference(const int& refId) {
-    return m_index->HasAlignments(refId);
-}
-
-bool BamRandomAccessController::LocateIndex(BamReaderPrivate* reader,
-                                            const BamIndex::IndexType& preferredType)
-{
-    // look up index filename, deferring to preferredType if possible
-    assert(reader);
-    const string& indexFilename = BamIndexFactory::FindIndexFilename(reader->Filename(), preferredType);
-
-    // if no index file found (of any type)
-    if ( indexFilename.empty() ) {
-        const string message = string("could not find index file for:") + reader->Filename();
-        SetErrorString("BamRandomAccessController::LocateIndex", message);
-        return false;
-    }
-
-    // otherwise open & use index file that was found
-    return OpenIndex(indexFilename, reader);
-}
-
-bool BamRandomAccessController::OpenIndex(const string& indexFilename, BamReaderPrivate* reader) {
-
-    // attempt create new index of type based on filename
-    BamIndex* index = BamIndexFactory::CreateIndexFromFilename(indexFilename, reader);
-    if ( index == 0 ) {
-        const string message = string("could not open index file: ") + indexFilename;
-        SetErrorString("BamRandomAccessController::OpenIndex", message);
-        return false;
-    }
-
-    // attempt to load data from index file
-    if ( !index->Load(indexFilename) ) {
-        const string indexError = index->GetErrorString();
-        const string message = string("could not load index data from file: ") + indexFilename +
-                               "\n\t" + indexError;
-        SetErrorString("BamRandomAccessController::OpenIndex", message);
-        return false;
-    }
-
-    // save new index & return success
-    SetIndex(index);
-    return true;
-}
-
-bool BamRandomAccessController::RegionHasAlignments(void) const {
-    return m_hasAlignmentsInRegion;
-}
-
-void BamRandomAccessController::SetErrorString(const string& where, const string& what) {
-    m_errorString = where + ": " + what;
-}
-
-void BamRandomAccessController::SetIndex(BamIndex* index) {
-    if ( m_index )
-        ClearIndex();
-    m_index = index;
-}
-
-bool BamRandomAccessController::SetRegion(const BamRegion& region, const int& referenceCount) {
-
-    // store region
-    m_region = region;
-
-    // cannot jump when no index is available
-    if ( !HasIndex() ) {
-        SetErrorString("BamRandomAccessController", "cannot jump if no index data available");
-        return false;
-    }
-
-    // adjust region as necessary to reflect where data actually begins
-    AdjustRegion(referenceCount);
-
-    // if no data present, return true
-    //   * Not an error, but future attempts to access alignments in this region will not return data
-    //     Returning true is useful in a BamMultiReader setting where some BAM files may
-    //     lack alignments in regions where other files still have data available.
-    if ( !m_hasAlignmentsInRegion )
-        return true;
-
-    // return success/failure of jump to specified region,
-    //
-    //  * Index::Jump() is allowed to modify the m_hasAlignmentsInRegion flag
-    //    This covers 'corner case' where a region is requested that lies beyond the last
-    //    alignment on a reference. If this occurs, any subsequent calls to GetNextAlignment[Core]
-    //    will not return data. BamMultiReader will still be able to successfully pull alignments
-    //    from a region from other files even if this one has no data.
-    if ( !m_index->Jump(m_region, &m_hasAlignmentsInRegion) ) {
-        const string indexError = m_index->GetErrorString();
-        const string message = string("could not set region\n\t") + indexError;
-        SetErrorString("BamRandomAccessController::OpenIndex", message);
-        return false;
-    }
-    else
-        return true;
-}
diff --git a/bamtools/src/api/internal/bam/BamRandomAccessController_p.h b/bamtools/src/api/internal/bam/BamRandomAccessController_p.h
deleted file mode 100644
index 9262a61..0000000
--- a/bamtools/src/api/internal/bam/BamRandomAccessController_p.h
+++ /dev/null
@@ -1,94 +0,0 @@
-// ***************************************************************************
-// BamRandomAccessController_p.h (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011(DB)
-// ---------------------------------------------------------------------------
-// Manages random access operations in a BAM file
-// ***************************************************************************
-
-#ifndef BAMRACONTROLLER_P_H
-#define BAMRACONTROLLER_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#include "api/BamAux.h"
-#include "api/BamIndex.h"
-
-namespace BamTools {
-
-class BamAlignment;
-
-namespace Internal {
-
-class BamReaderPrivate;
-
-class BamRandomAccessController {
-
-    // enums
-    public: enum RegionState { BeforeRegion = 0
-                             , OverlapsRegion
-                             , AfterRegion
-                             };
-
-    // ctor & dtor
-    public:
-        BamRandomAccessController(void);
-        ~BamRandomAccessController(void);
-
-    // BamRandomAccessController interface
-    public:
-
-        // index methods
-        void ClearIndex(void);
-        bool CreateIndex(BamReaderPrivate* reader, const BamIndex::IndexType& type);
-        bool HasIndex(void) const;
-        bool IndexHasAlignmentsForReference(const int& refId);
-        bool LocateIndex(BamReaderPrivate* reader, const BamIndex::IndexType& preferredType);
-        bool OpenIndex(const std::string& indexFilename, BamReaderPrivate* reader);
-        void SetIndex(BamIndex* index);
-
-        // region methods
-        void ClearRegion(void);
-        bool HasRegion(void) const;
-        RegionState AlignmentState(const BamAlignment& alignment) const;
-        bool RegionHasAlignments(void) const;
-        bool SetRegion(const BamRegion& region, const int& referenceCount);
-
-        // general methods
-        void Close(void);
-        std::string GetErrorString(void) const;
-
-    // internal methods
-    private:
-        // adjusts requested region if necessary (depending on where data actually begins)
-        void AdjustRegion(const int& referenceCount);
-        // error-string handling
-        void SetErrorString(const std::string& where, const std::string& what);
-
-    // data members
-    private:
-
-        // index data
-        BamIndex* m_index;  // owns the index, not a copy - responsible for deleting
-
-        // region data
-        BamRegion m_region;
-        bool m_hasAlignmentsInRegion;
-
-        // general data
-        std::string m_errorString;
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // BAMRACONTROLLER_P_H
diff --git a/bamtools/src/api/internal/bam/BamReader_p.cpp b/bamtools/src/api/internal/bam/BamReader_p.cpp
deleted file mode 100644
index 737d598..0000000
--- a/bamtools/src/api/internal/bam/BamReader_p.cpp
+++ /dev/null
@@ -1,470 +0,0 @@
-// ***************************************************************************
-// BamReader_p.cpp (c) 2009 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 18 November 2012 (DB)
-// ---------------------------------------------------------------------------
-// Provides the basic functionality for reading BAM files
-// ***************************************************************************
-
-#include "api/BamConstants.h"
-#include "api/BamReader.h"
-#include "api/IBamIODevice.h"
-#include "api/internal/bam/BamHeader_p.h"
-#include "api/internal/bam/BamRandomAccessController_p.h"
-#include "api/internal/bam/BamReader_p.h"
-#include "api/internal/index/BamStandardIndex_p.h"
-#include "api/internal/index/BamToolsIndex_p.h"
-#include "api/internal/io/BamDeviceFactory_p.h"
-#include "api/internal/utils/BamException_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#include <algorithm>
-#include <cassert>
-#include <iostream>
-#include <iterator>
-#include <vector>
-using namespace std;
-
-// constructor
-BamReaderPrivate::BamReaderPrivate(BamReader* parent)
-    : m_alignmentsBeginOffset(0)
-    , m_parent(parent)
-{
-    m_isBigEndian = BamTools::SystemIsBigEndian();
-}
-
-// destructor
-BamReaderPrivate::~BamReaderPrivate(void) {
-    Close();
-}
-
-// closes the BAM file
-bool BamReaderPrivate::Close(void) {
-
-    // clear BAM metadata
-    m_references.clear();
-    m_header.Clear();
-
-    // clear filename
-    m_filename.clear();
-
-    // close random access controller
-    m_randomAccessController.Close();
-
-    // if stream is open, attempt close
-    if ( IsOpen() ) {
-        try {
-            m_stream.Close();
-        } catch ( BamException& e ) {
-            const string streamError = e.what();
-            const string message = string("encountered error closing BAM file: \n\t") + streamError;
-            SetErrorString("BamReader::Close", message);
-            return false;
-        }
-    }
-
-    // return success
-    return true;
-}
-
-// creates an index file of requested type on current BAM file
-bool BamReaderPrivate::CreateIndex(const BamIndex::IndexType& type) {
-
-    // skip if BAM file not open
-    if ( !IsOpen() ) {
-        SetErrorString("BamReader::CreateIndex", "cannot create index on unopened BAM file");
-        return false;
-    }
-
-    // attempt to create index
-    if ( m_randomAccessController.CreateIndex(this, type) )
-        return true;
-    else {
-        const string bracError = m_randomAccessController.GetErrorString();
-        const string message = string("could not create index: \n\t") + bracError;
-        SetErrorString("BamReader::CreateIndex", message);
-        return false;
-    }
-}
-
-// return path & filename of current BAM file
-const string BamReaderPrivate::Filename(void) const {
-    return m_filename;
-}
-
-const SamHeader& BamReaderPrivate::GetConstSamHeader(void) const {
-    return m_header.ToConstSamHeader();
-}
-
-string BamReaderPrivate::GetErrorString(void) const {
-    return m_errorString;
-}
-
-// return header data as std::string
-string BamReaderPrivate::GetHeaderText(void) const {
-    return m_header.ToString();
-}
-
-// return header data as SamHeader object
-SamHeader BamReaderPrivate::GetSamHeader(void) const {
-    return m_header.ToSamHeader();
-}
-
-// get next alignment (with character data fully parsed)
-bool BamReaderPrivate::GetNextAlignment(BamAlignment& alignment) {
-
-    // if valid alignment found
-    if ( GetNextAlignmentCore(alignment) ) {
-
-        // store alignment's "source" filename
-        alignment.Filename = m_filename;
-
-        // return success/failure of parsing char data
-        if ( alignment.BuildCharData() )
-            return true;
-        else {
-            const string alError = alignment.GetErrorString();
-            const string message = string("could not populate alignment data: \n\t") + alError;
-            SetErrorString("BamReader::GetNextAlignment", message);
-            return false;
-        }
-    }
-
-    // no valid alignment found
-    return false;
-}
-
-// retrieves next available alignment core data (returns success/fail)
-// ** DOES NOT populate any character data fields (read name, bases, qualities, tag data, filename)
-//    these can be accessed, if necessary, from the supportData
-// useful for operations requiring ONLY positional or other alignment-related information
-bool BamReaderPrivate::GetNextAlignmentCore(BamAlignment& alignment) {
-
-    // skip if stream not opened
-    if ( !m_stream.IsOpen() )
-        return false;
-
-    try {
-
-        // skip if region is set but has no alignments
-        if ( m_randomAccessController.HasRegion() &&
-             !m_randomAccessController.RegionHasAlignments() )
-        {
-            return false;
-        }
-
-        // if can't read next alignment
-        if ( !LoadNextAlignment(alignment) )
-            return false;
-
-        // check alignment's region-overlap state
-        BamRandomAccessController::RegionState state = m_randomAccessController.AlignmentState(alignment);
-
-        // if alignment starts after region, no need to keep reading
-        if ( state == BamRandomAccessController::AfterRegion )
-            return false;
-
-        // read until overlap is found
-        while ( state != BamRandomAccessController::OverlapsRegion ) {
-
-            // if can't read next alignment
-            if ( !LoadNextAlignment(alignment) )
-                return false;
-
-            // check alignment's region-overlap state
-            state = m_randomAccessController.AlignmentState(alignment);
-
-            // if alignment starts after region, no need to keep reading
-            if ( state == BamRandomAccessController::AfterRegion )
-                return false;
-        }
-
-        // if we get here, we found the next 'valid' alignment
-        // (e.g. overlaps current region if one was set, simply the next alignment if not)
-        alignment.SupportData.HasCoreOnly = true;
-        return true;
-
-    } catch ( BamException& e ) {
-        const string streamError = e.what();
-        const string message = string("encountered error reading BAM alignment: \n\t") + streamError;
-        SetErrorString("BamReader::GetNextAlignmentCore", message);
-        return false;
-    }
-}
-
-int BamReaderPrivate::GetReferenceCount(void) const {
-    return m_references.size();
-}
-
-const RefVector& BamReaderPrivate::GetReferenceData(void) const {
-    return m_references;
-}
-
-// returns RefID for given RefName (returns References.size() if not found)
-int BamReaderPrivate::GetReferenceID(const string& refName) const {
-
-    // retrieve names from reference data
-    vector<string> refNames;
-    RefVector::const_iterator refIter = m_references.begin();
-    RefVector::const_iterator refEnd  = m_references.end();
-    for ( ; refIter != refEnd; ++refIter)
-        refNames.push_back( (*refIter).RefName );
-
-    // return 'index-of' refName (or -1 if not found)
-    int index = distance(refNames.begin(), find(refNames.begin(), refNames.end(), refName));
-    if ( index == (int)m_references.size() ) return -1;
-    else return index;
-}
-
-bool BamReaderPrivate::HasIndex(void) const {
-    return m_randomAccessController.HasIndex();
-}
-
-bool BamReaderPrivate::IsOpen(void) const {
-    return m_stream.IsOpen();
-}
-
-// load BAM header data
-void BamReaderPrivate::LoadHeaderData(void) {
-    m_header.Load(&m_stream);
-}
-
-// populates BamAlignment with alignment data under file pointer, returns success/fail
-bool BamReaderPrivate::LoadNextAlignment(BamAlignment& alignment) {
-
-    // read in the 'block length' value, make sure it's not zero
-    char buffer[sizeof(uint32_t)];
-    fill_n(buffer, sizeof(uint32_t), 0);
-    m_stream.Read(buffer, sizeof(uint32_t));
-    alignment.SupportData.BlockLength = BamTools::UnpackUnsignedInt(buffer);
-    if ( m_isBigEndian ) BamTools::SwapEndian_32(alignment.SupportData.BlockLength);
-    if ( alignment.SupportData.BlockLength == 0 )
-        return false;
-
-    // read in core alignment data, make sure the right size of data was read
-    char x[Constants::BAM_CORE_SIZE];
-    if ( m_stream.Read(x, Constants::BAM_CORE_SIZE) != Constants::BAM_CORE_SIZE )
-        return false;
-
-    // swap core endian-ness if necessary
-    if ( m_isBigEndian ) {
-        for ( unsigned int i = 0; i < Constants::BAM_CORE_SIZE; i+=sizeof(uint32_t) )
-            BamTools::SwapEndian_32p(&x[i]);
-    }
-
-    // set BamAlignment 'core' and 'support' data
-    alignment.RefID    = BamTools::UnpackSignedInt(&x[0]);
-    alignment.Position = BamTools::UnpackSignedInt(&x[4]);
-
-    unsigned int tempValue = BamTools::UnpackUnsignedInt(&x[8]);
-    alignment.Bin        = tempValue >> 16;
-    alignment.MapQuality = tempValue >> 8 & 0xff;
-    alignment.SupportData.QueryNameLength = tempValue & 0xff;
-
-    tempValue = BamTools::UnpackUnsignedInt(&x[12]);
-    alignment.AlignmentFlag = tempValue >> 16;
-    alignment.SupportData.NumCigarOperations = tempValue & 0xffff;
-
-    alignment.SupportData.QuerySequenceLength = BamTools::UnpackUnsignedInt(&x[16]);
-    alignment.MateRefID    = BamTools::UnpackSignedInt(&x[20]);
-    alignment.MatePosition = BamTools::UnpackSignedInt(&x[24]);
-    alignment.InsertSize   = BamTools::UnpackSignedInt(&x[28]);
-
-    // set BamAlignment length
-    alignment.Length = alignment.SupportData.QuerySequenceLength;
-
-    // read in character data - make sure proper data size was read
-    bool readCharDataOK = false;
-    const unsigned int dataLength = alignment.SupportData.BlockLength - Constants::BAM_CORE_SIZE;
-    RaiiBuffer allCharData(dataLength);
-
-    if ( m_stream.Read(allCharData.Buffer, dataLength) == dataLength ) {
-
-        // store 'allCharData' in supportData structure
-        alignment.SupportData.AllCharData.assign((const char*)allCharData.Buffer, dataLength);
-
-        // set success flag
-        readCharDataOK = true;
-
-        // save CIGAR ops
-        // need to calculate this here so that  BamAlignment::GetEndPosition() performs correctly,
-        // even when GetNextAlignmentCore() is called
-        const unsigned int cigarDataOffset = alignment.SupportData.QueryNameLength;
-        uint32_t* cigarData = (uint32_t*)(allCharData.Buffer + cigarDataOffset);
-        CigarOp op;
-        alignment.CigarData.clear();
-        alignment.CigarData.reserve(alignment.SupportData.NumCigarOperations);
-        for ( unsigned int i = 0; i < alignment.SupportData.NumCigarOperations; ++i ) {
-
-            // swap endian-ness if necessary
-            if ( m_isBigEndian ) BamTools::SwapEndian_32(cigarData[i]);
-
-            // build CigarOp structure
-            op.Length = (cigarData[i] >> Constants::BAM_CIGAR_SHIFT);
-            op.Type   = Constants::BAM_CIGAR_LOOKUP[ (cigarData[i] & Constants::BAM_CIGAR_MASK) ];
-
-            // save CigarOp
-            alignment.CigarData.push_back(op);
-        }
-    }
-
-    // return success/failure
-    return readCharDataOK;
-}
-
-// loads reference data from BAM file
-bool BamReaderPrivate::LoadReferenceData(void) {
-
-    // get number of reference sequences
-    char buffer[sizeof(uint32_t)];
-    m_stream.Read(buffer, sizeof(uint32_t));
-    uint32_t numberRefSeqs = BamTools::UnpackUnsignedInt(buffer);
-    if ( m_isBigEndian ) BamTools::SwapEndian_32(numberRefSeqs);
-    m_references.reserve((int)numberRefSeqs);
-
-    // iterate over all references in header
-    for ( unsigned int i = 0; i != numberRefSeqs; ++i ) {
-
-        // get length of reference name
-        m_stream.Read(buffer, sizeof(uint32_t));
-        uint32_t refNameLength = BamTools::UnpackUnsignedInt(buffer);
-        if ( m_isBigEndian ) BamTools::SwapEndian_32(refNameLength);
-        RaiiBuffer refName(refNameLength);
-
-        // get reference name and reference sequence length
-        m_stream.Read(refName.Buffer, refNameLength);
-        m_stream.Read(buffer, sizeof(int32_t));
-        int32_t refLength = BamTools::UnpackSignedInt(buffer);
-        if ( m_isBigEndian ) BamTools::SwapEndian_32(refLength);
-
-        // store data for reference
-        RefData aReference;
-        aReference.RefName   = (string)((const char*)refName.Buffer);
-        aReference.RefLength = refLength;
-        m_references.push_back(aReference);
-    }
-
-    // return success
-    return true;
-}
-
-bool BamReaderPrivate::LocateIndex(const BamIndex::IndexType& preferredType) {
-
-    if ( m_randomAccessController.LocateIndex(this, preferredType) )
-        return true;
-    else {
-        const string bracError = m_randomAccessController.GetErrorString();
-        const string message = string("could not locate index: \n\t") + bracError;
-        SetErrorString("BamReader::LocateIndex", message);
-        return false;
-    }
-}
-
-// opens BAM file (and index)
-bool BamReaderPrivate::Open(const string& filename) {
-
-    try {
-
-        // make sure we're starting with fresh state
-        Close();
-
-        // open BgzfStream
-        m_stream.Open(filename, IBamIODevice::ReadOnly);
-
-        // load BAM metadata
-        LoadHeaderData();
-        LoadReferenceData();
-
-        // store filename & offset of first alignment
-        m_filename = filename;
-        m_alignmentsBeginOffset = m_stream.Tell();
-
-        // return success
-        return true;
-
-    } catch ( BamException& e ) {
-        const string error = e.what();
-        const string message = string("could not open file: ") + filename +
-                               "\n\t" + error;
-        SetErrorString("BamReader::Open", message);
-        return false;
-    }
-}
-
-bool BamReaderPrivate::OpenIndex(const std::string& indexFilename) {
-
-    if ( m_randomAccessController.OpenIndex(indexFilename, this) )
-        return true;
-    else {
-        const string bracError = m_randomAccessController.GetErrorString();
-        const string message = string("could not open index: \n\t") + bracError;
-        SetErrorString("BamReader::OpenIndex", message);
-        return false;
-    }
-}
-
-// returns BAM file pointer to beginning of alignment data
-bool BamReaderPrivate::Rewind(void) {
-
-    // reset region
-    m_randomAccessController.ClearRegion();
-
-    // return status of seeking back to first alignment
-    if ( Seek(m_alignmentsBeginOffset) )
-        return true;
-    else {
-        const string currentError = m_errorString;
-        const string message = string("could not rewind: \n\t") + currentError;
-        SetErrorString("BamReader::Rewind", message);
-        return false;
-    }
-}
-
-bool BamReaderPrivate::Seek(const int64_t& position) {
-
-    // skip if BAM file not open
-    if ( !IsOpen() ) {
-        SetErrorString("BamReader::Seek", "cannot seek on unopened BAM file");
-        return false;
-    }
-
-    try {
-        m_stream.Seek(position);
-        return true;
-    }
-    catch ( BamException& e ) {
-        const string streamError = e.what();
-        const string message = string("could not seek in BAM file: \n\t") + streamError;
-        SetErrorString("BamReader::Seek", message);
-        return false;
-    }
-}
-
-void BamReaderPrivate::SetErrorString(const string& where, const string& what) {
-    static const string SEPARATOR = ": ";
-    m_errorString = where + SEPARATOR + what;
-}
-
-void BamReaderPrivate::SetIndex(BamIndex* index) {
-    m_randomAccessController.SetIndex(index);
-}
-
-// sets current region & attempts to jump to it
-// returns success/failure
-bool BamReaderPrivate::SetRegion(const BamRegion& region) {
-
-    if ( m_randomAccessController.SetRegion(region, m_references.size()) )
-        return true;
-    else {
-        const string bracError = m_randomAccessController.GetErrorString();
-        const string message = string("could not set region: \n\t") + bracError;
-        SetErrorString("BamReader::SetRegion", message);
-        return false;
-    }
-}
-
-int64_t BamReaderPrivate::Tell(void) const {
-    return m_stream.Tell();
-}
diff --git a/bamtools/src/api/internal/bam/BamReader_p.h b/bamtools/src/api/internal/bam/BamReader_p.h
deleted file mode 100644
index a49ad2a..0000000
--- a/bamtools/src/api/internal/bam/BamReader_p.h
+++ /dev/null
@@ -1,119 +0,0 @@
-// ***************************************************************************
-// BamReader_p.h (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 18 November 2012 (DB)
-// ---------------------------------------------------------------------------
-// Provides the basic functionality for reading BAM files
-// ***************************************************************************
-
-#ifndef BAMREADER_P_H
-#define BAMREADER_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#include "api/BamAlignment.h"
-#include "api/BamIndex.h"
-#include "api/BamReader.h"
-#include "api/SamHeader.h"
-#include "api/internal/bam/BamHeader_p.h"
-#include "api/internal/bam/BamRandomAccessController_p.h"
-#include "api/internal/io/BgzfStream_p.h"
-#include <string>
-
-namespace BamTools {
-namespace Internal {
-
-class BamReaderPrivate {
-
-    // ctor & dtor
-    public:
-        BamReaderPrivate(BamReader* parent);
-        ~BamReaderPrivate(void);
-
-    // BamReader interface
-    public:
-
-        // file operations
-        bool Close(void);
-        const std::string Filename(void) const;
-        bool IsOpen(void) const;
-        bool Open(const std::string& filename);
-        bool Rewind(void);
-        bool SetRegion(const BamRegion& region);
-
-        // access alignment data
-        bool GetNextAlignment(BamAlignment& alignment);
-        bool GetNextAlignmentCore(BamAlignment& alignment);
-
-        // access auxiliary data
-        std::string GetHeaderText(void) const;
-        const SamHeader& GetConstSamHeader(void) const;
-        SamHeader GetSamHeader(void) const;
-        int GetReferenceCount(void) const;
-        const RefVector& GetReferenceData(void) const;
-        int GetReferenceID(const std::string& refName) const;
-
-        // index operations
-        bool CreateIndex(const BamIndex::IndexType& type);
-        bool HasIndex(void) const;
-        bool LocateIndex(const BamIndex::IndexType& preferredType);
-        bool OpenIndex(const std::string& indexFilename);
-        void SetIndex(BamIndex* index);
-
-        // error handling
-        std::string GetErrorString(void) const;
-        void SetErrorString(const std::string& where, const std::string& what);
-
-    // internal methods, but available as a BamReaderPrivate 'interface'
-    //
-    // these methods should only be used by BamTools::Internal classes
-    // (currently only used by the BamIndex subclasses)
-    public:
-        // retrieves header text from BAM file
-        void LoadHeaderData(void);
-        // retrieves BAM alignment under file pointer
-        // (does no overlap checking or character data parsing)
-        bool LoadNextAlignment(BamAlignment& alignment);
-        // builds reference data structure from BAM file
-        bool LoadReferenceData(void);
-        // seek reader to file position
-        bool Seek(const int64_t& position);
-        // return reader's file position
-        int64_t Tell(void) const;
-
-    // data members
-    public:
-
-        // general BAM file data
-        int64_t     m_alignmentsBeginOffset;
-        std::string m_filename;
-        RefVector   m_references;
-
-        // system data
-        bool m_isBigEndian;
-
-        // parent BamReader
-        BamReader* m_parent;
-
-        // BamReaderPrivate components
-        BamHeader m_header;
-        BamRandomAccessController m_randomAccessController;
-        BgzfStream m_stream;
-
-        // error handling
-        std::string m_errorString;
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // BAMREADER_P_H
diff --git a/bamtools/src/api/internal/bam/BamWriter_p.cpp b/bamtools/src/api/internal/bam/BamWriter_p.cpp
deleted file mode 100644
index 637bb7a..0000000
--- a/bamtools/src/api/internal/bam/BamWriter_p.cpp
+++ /dev/null
@@ -1,475 +0,0 @@
-// ***************************************************************************
-// BamWriter_p.cpp (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 18 November 2012 (DB)
-// ---------------------------------------------------------------------------
-// Provides the basic functionality for producing BAM files
-// ***************************************************************************
-
-#include "api/BamAlignment.h"
-#include "api/BamConstants.h"
-#include "api/IBamIODevice.h"
-#include "api/internal/bam/BamWriter_p.h"
-#include "api/internal/utils/BamException_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#include <cstdlib>
-#include <cstring>
-using namespace std;
-
-// ctor
-BamWriterPrivate::BamWriterPrivate(void)
-    : m_isBigEndian( BamTools::SystemIsBigEndian() )
-{ }
-
-// dtor
-BamWriterPrivate::~BamWriterPrivate(void) {
-    Close();
-}
-
-// calculates minimum bin for a BAM alignment interval [begin, end)
-uint32_t BamWriterPrivate::CalculateMinimumBin(const int begin, int end) const {
-    --end;
-    if ( (begin >> 14) == (end >> 14) ) return 4681 + (begin >> 14);
-    if ( (begin >> 17) == (end >> 17) ) return  585 + (begin >> 17);
-    if ( (begin >> 20) == (end >> 20) ) return   73 + (begin >> 20);
-    if ( (begin >> 23) == (end >> 23) ) return    9 + (begin >> 23);
-    if ( (begin >> 26) == (end >> 26) ) return    1 + (begin >> 26);
-    return 0;
-}
-
-// closes the alignment archive
-void BamWriterPrivate::Close(void) {
-
-    // skip if file not open
-    if ( !IsOpen() ) return;
-
-    // close output stream
-    try {
-        m_stream.Close();
-    } catch ( BamException& e ) {
-        m_errorString = e.what();
-    }
-}
-
-// creates a cigar string from the supplied alignment
-void BamWriterPrivate::CreatePackedCigar(const vector<CigarOp>& cigarOperations, string& packedCigar) {
-
-    // initialize
-    const size_t numCigarOperations = cigarOperations.size();
-    packedCigar.resize(numCigarOperations * Constants::BAM_SIZEOF_INT);
-
-    // pack the cigar data into the string
-    unsigned int* pPackedCigar = (unsigned int*)packedCigar.data();
-
-    // iterate over cigar operations
-    vector<CigarOp>::const_iterator coIter = cigarOperations.begin();
-    vector<CigarOp>::const_iterator coEnd  = cigarOperations.end();
-    for ( ; coIter != coEnd; ++coIter ) {
-
-        // store op in packedCigar
-        uint8_t cigarOp;
-        switch ( coIter->Type ) {
-            case (Constants::BAM_CIGAR_MATCH_CHAR)    : cigarOp = Constants::BAM_CIGAR_MATCH;    break;
-            case (Constants::BAM_CIGAR_INS_CHAR)      : cigarOp = Constants::BAM_CIGAR_INS;      break;
-            case (Constants::BAM_CIGAR_DEL_CHAR)      : cigarOp = Constants::BAM_CIGAR_DEL;      break;
-            case (Constants::BAM_CIGAR_REFSKIP_CHAR)  : cigarOp = Constants::BAM_CIGAR_REFSKIP;  break;
-            case (Constants::BAM_CIGAR_SOFTCLIP_CHAR) : cigarOp = Constants::BAM_CIGAR_SOFTCLIP; break;
-            case (Constants::BAM_CIGAR_HARDCLIP_CHAR) : cigarOp = Constants::BAM_CIGAR_HARDCLIP; break;
-            case (Constants::BAM_CIGAR_PAD_CHAR)      : cigarOp = Constants::BAM_CIGAR_PAD;      break;
-            case (Constants::BAM_CIGAR_SEQMATCH_CHAR) : cigarOp = Constants::BAM_CIGAR_SEQMATCH; break;
-            case (Constants::BAM_CIGAR_MISMATCH_CHAR) : cigarOp = Constants::BAM_CIGAR_MISMATCH; break;
-            default:
-                const string message = string("invalid CIGAR operation type") + coIter->Type;
-                throw BamException("BamWriter::CreatePackedCigar", message);
-        }
-
-        *pPackedCigar = coIter->Length << Constants::BAM_CIGAR_SHIFT | cigarOp;
-        pPackedCigar++;
-    }
-}
-
-// encodes the supplied query sequence into 4-bit notation
-void BamWriterPrivate::EncodeQuerySequence(const string& query, string& encodedQuery) {
-
-    // prepare the encoded query string
-    const size_t queryLength = query.size();
-    const size_t encodedQueryLength = static_cast<size_t>((queryLength+1)/2);
-    encodedQuery.resize(encodedQueryLength);
-    char* pEncodedQuery = (char*)encodedQuery.data();
-    const char* pQuery = (const char*)query.data();
-
-    // walk through original query sequence, encoding its bases
-    unsigned char nucleotideCode;
-    bool useHighWord = true;
-    while ( *pQuery ) {
-        switch ( *pQuery ) {
-            case (Constants::BAM_DNA_EQUAL) : nucleotideCode = Constants::BAM_BASECODE_EQUAL; break;
-            case (Constants::BAM_DNA_A)     : nucleotideCode = Constants::BAM_BASECODE_A;     break;
-            case (Constants::BAM_DNA_C)     : nucleotideCode = Constants::BAM_BASECODE_C;     break;
-            case (Constants::BAM_DNA_M)     : nucleotideCode = Constants::BAM_BASECODE_M;     break;
-            case (Constants::BAM_DNA_G)     : nucleotideCode = Constants::BAM_BASECODE_G;     break;
-            case (Constants::BAM_DNA_R)     : nucleotideCode = Constants::BAM_BASECODE_R;     break;
-            case (Constants::BAM_DNA_S)     : nucleotideCode = Constants::BAM_BASECODE_S;     break;
-            case (Constants::BAM_DNA_V)     : nucleotideCode = Constants::BAM_BASECODE_V;     break;
-            case (Constants::BAM_DNA_T)     : nucleotideCode = Constants::BAM_BASECODE_T;     break;
-            case (Constants::BAM_DNA_W)     : nucleotideCode = Constants::BAM_BASECODE_W;     break;
-            case (Constants::BAM_DNA_Y)     : nucleotideCode = Constants::BAM_BASECODE_Y;     break;
-            case (Constants::BAM_DNA_H)     : nucleotideCode = Constants::BAM_BASECODE_H;     break;
-            case (Constants::BAM_DNA_K)     : nucleotideCode = Constants::BAM_BASECODE_K;     break;
-            case (Constants::BAM_DNA_D)     : nucleotideCode = Constants::BAM_BASECODE_D;     break;
-            case (Constants::BAM_DNA_B)     : nucleotideCode = Constants::BAM_BASECODE_B;     break;
-            case (Constants::BAM_DNA_N)     : nucleotideCode = Constants::BAM_BASECODE_N;     break;
-            default:
-                const string message = string("invalid base: ") + *pQuery;
-                throw BamException("BamWriter::EncodeQuerySequence", message);
-        }
-
-        // pack the nucleotide code
-        if ( useHighWord ) {
-            *pEncodedQuery = nucleotideCode << 4;
-            useHighWord = false;
-        } else {
-            *pEncodedQuery |= nucleotideCode;
-            ++pEncodedQuery;
-            useHighWord = true;
-        }
-
-        // increment the query position
-        ++pQuery;
-    }
-}
-
-// returns a description of the last error that occurred
-std::string BamWriterPrivate::GetErrorString(void) const {
-    return m_errorString;
-}
-
-// returns whether BAM file is open for writing or not
-bool BamWriterPrivate::IsOpen(void) const {
-    return m_stream.IsOpen();
-}
-
-// opens the alignment archive
-bool BamWriterPrivate::Open(const string& filename,
-                            const string& samHeaderText,
-                            const RefVector& referenceSequences)
-{
-    try {
-
-        // open the BGZF file for writing
-        m_stream.Open(filename, IBamIODevice::WriteOnly);
-
-        // write BAM file 'metadata' components
-        WriteMagicNumber();
-        WriteSamHeaderText(samHeaderText);
-        WriteReferences(referenceSequences);
-
-        // return success
-        return true;
-
-    } catch ( BamException& e ) {
-        m_errorString = e.what();
-        return false;
-    }
-}
-
-// saves the alignment to the alignment archive
-bool BamWriterPrivate::SaveAlignment(const BamAlignment& al) {
-
-    try {
-
-        // if BamAlignment contains only the core data and a raw char data buffer
-        // (as a result of BamReader::GetNextAlignmentCore())
-        if ( al.SupportData.HasCoreOnly )
-            WriteCoreAlignment(al);
-
-        // otherwise, BamAlignment should contain character in the standard fields: Name, QueryBases, etc
-        // (resulting from BamReader::GetNextAlignment() *OR* being generated directly by client code)
-        else WriteAlignment(al);
-
-        // if we get here, everything OK
-        return true;
-
-    } catch ( BamException& e ) {
-        m_errorString = e.what();
-        return false;
-    }
-}
-
-void BamWriterPrivate::SetWriteCompressed(bool ok) {
-    // modifying compression is not allowed if BAM file is open
-    if ( !IsOpen() )
-        m_stream.SetWriteCompressed(ok);
-}
-
-void BamWriterPrivate::WriteAlignment(const BamAlignment& al) {
-
-    // calculate char lengths
-    const unsigned int nameLength         = al.Name.size() + 1;
-    const unsigned int numCigarOperations = al.CigarData.size();
-    const unsigned int queryLength        = ( (al.QueryBases == "*") ? 0 : al.QueryBases.size() );
-    const unsigned int tagDataLength      = al.TagData.size();
-
-    // no way to tell if alignment's bin is already defined (there is no default, invalid value)
-    // so we'll go ahead calculate its bin ID before storing
-    const uint32_t alignmentBin = CalculateMinimumBin(al.Position, al.GetEndPosition());
-
-    // create our packed cigar string
-    string packedCigar;
-    CreatePackedCigar(al.CigarData, packedCigar);
-    const unsigned int packedCigarLength = packedCigar.size();
-
-    // encode the query
-    unsigned int encodedQueryLength = 0;
-    string encodedQuery;
-    if ( queryLength > 0 ) {
-        EncodeQuerySequence(al.QueryBases, encodedQuery);
-        encodedQueryLength = encodedQuery.size();
-    }
-
-    // write the block size
-    const unsigned int dataBlockSize = nameLength +
-                                       packedCigarLength +
-                                       encodedQueryLength +
-                                       queryLength +         // here referring to quality length
-                                       tagDataLength;
-    unsigned int blockSize = Constants::BAM_CORE_SIZE + dataBlockSize;
-    if ( m_isBigEndian ) BamTools::SwapEndian_32(blockSize);
-    m_stream.Write((char*)&blockSize, Constants::BAM_SIZEOF_INT);
-
-    // assign the BAM core data
-    uint32_t buffer[Constants::BAM_CORE_BUFFER_SIZE];
-    buffer[0] = al.RefID;
-    buffer[1] = al.Position;
-    buffer[2] = (alignmentBin << 16) | (al.MapQuality << 8) | nameLength;
-    buffer[3] = (al.AlignmentFlag << 16) | numCigarOperations;
-    buffer[4] = queryLength;
-    buffer[5] = al.MateRefID;
-    buffer[6] = al.MatePosition;
-    buffer[7] = al.InsertSize;
-
-    // swap BAM core endian-ness, if necessary
-    if ( m_isBigEndian ) {
-        for ( int i = 0; i < 8; ++i )
-            BamTools::SwapEndian_32(buffer[i]);
-    }
-
-    // write the BAM core
-    m_stream.Write((char*)&buffer, Constants::BAM_CORE_SIZE);
-
-    // write the query name
-    m_stream.Write(al.Name.c_str(), nameLength);
-
-    // write the packed cigar
-    if ( m_isBigEndian ) {
-        char* cigarData = new char[packedCigarLength]();
-        memcpy(cigarData, packedCigar.data(), packedCigarLength);
-        if ( m_isBigEndian ) {
-            for ( size_t i = 0; i < packedCigarLength; ++i )
-                BamTools::SwapEndian_32p(&cigarData[i]);
-        }
-        m_stream.Write(cigarData, packedCigarLength);
-        delete[] cigarData; // TODO: cleanup on Write exception thrown?
-    }
-    else
-        m_stream.Write(packedCigar.data(), packedCigarLength);
-
-    if ( queryLength > 0 ) {
-
-        // write the encoded query sequence
-        m_stream.Write(encodedQuery.data(), encodedQueryLength);
-
-        // write the base qualities
-        char* pBaseQualities = new char[queryLength]();
-        if ( al.Qualities.empty() || ( al.Qualities.size() == 1 && al.Qualities[0] == '*' ) || al.Qualities[0] == (char)0xFF )
-            memset(pBaseQualities, 0xFF, queryLength); // if missing or '*', fill with invalid qual
-        else {
-            for ( size_t i = 0; i < queryLength; ++i )
-                pBaseQualities[i] = al.Qualities.at(i) - 33; // FASTQ ASCII -> phred score conversion
-        }
-        m_stream.Write(pBaseQualities, queryLength);
-        delete[] pBaseQualities;
-    }
-
-    // write the tag data
-    if ( m_isBigEndian ) {
-
-        char* tagData = new char[tagDataLength]();
-        memcpy(tagData, al.TagData.data(), tagDataLength);
-
-        size_t i = 0;
-        while ( i < tagDataLength ) {
-
-            i += Constants::BAM_TAG_TAGSIZE;  // skip tag chars (e.g. "RG", "NM", etc.)
-            const char type = tagData[i];     // get tag type at position i
-            ++i;
-
-            switch ( type ) {
-
-                case(Constants::BAM_TAG_TYPE_ASCII) :
-                case(Constants::BAM_TAG_TYPE_INT8)  :
-                case(Constants::BAM_TAG_TYPE_UINT8) :
-                    ++i;
-                    break;
-
-                case(Constants::BAM_TAG_TYPE_INT16)  :
-                case(Constants::BAM_TAG_TYPE_UINT16) :
-                    BamTools::SwapEndian_16p(&tagData[i]);
-                    i += sizeof(uint16_t);
-                    break;
-
-                case(Constants::BAM_TAG_TYPE_FLOAT)  :
-                case(Constants::BAM_TAG_TYPE_INT32)  :
-                case(Constants::BAM_TAG_TYPE_UINT32) :
-                    BamTools::SwapEndian_32p(&tagData[i]);
-                    i += sizeof(uint32_t);
-                    break;
-
-                case(Constants::BAM_TAG_TYPE_HEX) :
-                case(Constants::BAM_TAG_TYPE_STRING) :
-                    // no endian swapping necessary for hex-string/string data
-                    while ( tagData[i] )
-                        ++i;
-                    // increment one more for null terminator
-                    ++i;
-                    break;
-
-                case(Constants::BAM_TAG_TYPE_ARRAY) :
-
-                {
-                    // read array type
-                    const char arrayType = tagData[i];
-                    ++i;
-
-                    // swap endian-ness of number of elements in place, then retrieve for loop
-                    BamTools::SwapEndian_32p(&tagData[i]);
-                    int32_t numElements;
-                    memcpy(&numElements, &tagData[i], sizeof(uint32_t));
-                    i += sizeof(uint32_t);
-
-                    // swap endian-ness of array elements
-                    for ( int j = 0; j < numElements; ++j ) {
-                        switch (arrayType) {
-                            case (Constants::BAM_TAG_TYPE_INT8)  :
-                            case (Constants::BAM_TAG_TYPE_UINT8) :
-                                // no endian-swapping necessary
-                                ++i;
-                                break;
-                            case (Constants::BAM_TAG_TYPE_INT16)  :
-                            case (Constants::BAM_TAG_TYPE_UINT16) :
-                                BamTools::SwapEndian_16p(&tagData[i]);
-                                i += sizeof(uint16_t);
-                                break;
-                            case (Constants::BAM_TAG_TYPE_FLOAT)  :
-                            case (Constants::BAM_TAG_TYPE_INT32)  :
-                            case (Constants::BAM_TAG_TYPE_UINT32) :
-                                BamTools::SwapEndian_32p(&tagData[i]);
-                                i += sizeof(uint32_t);
-                                break;
-                            default:
-                                delete[] tagData;
-                                const string message = string("invalid binary array type: ") + arrayType;
-                                throw BamException("BamWriter::SaveAlignment", message);
-                        }
-                    }
-
-                    break;
-                }
-
-                default :
-                    delete[] tagData;
-                    const string message = string("invalid tag type: ") + type;
-                    throw BamException("BamWriter::SaveAlignment", message);
-            }
-        }
-
-        m_stream.Write(tagData, tagDataLength);
-        delete[] tagData; // TODO: cleanup on Write exception thrown?
-    }
-    else
-        m_stream.Write(al.TagData.data(), tagDataLength);
-}
-
-void BamWriterPrivate::WriteCoreAlignment(const BamAlignment& al) {
-
-    // write the block size
-    unsigned int blockSize = al.SupportData.BlockLength;
-    if ( m_isBigEndian ) BamTools::SwapEndian_32(blockSize);
-    m_stream.Write((char*)&blockSize, Constants::BAM_SIZEOF_INT);
-
-    // re-calculate bin (in case BamAlignment's position has been previously modified)
-    const uint32_t alignmentBin = CalculateMinimumBin(al.Position, al.GetEndPosition());
-
-    // assign the BAM core data
-    uint32_t buffer[Constants::BAM_CORE_BUFFER_SIZE];
-    buffer[0] = al.RefID;
-    buffer[1] = al.Position;
-    buffer[2] = (alignmentBin << 16) | (al.MapQuality << 8) | al.SupportData.QueryNameLength;
-    buffer[3] = (al.AlignmentFlag << 16) | al.SupportData.NumCigarOperations;
-    buffer[4] = al.SupportData.QuerySequenceLength;
-    buffer[5] = al.MateRefID;
-    buffer[6] = al.MatePosition;
-    buffer[7] = al.InsertSize;
-
-    // swap BAM core endian-ness, if necessary
-    if ( m_isBigEndian ) {
-        for ( int i = 0; i < 8; ++i )
-            BamTools::SwapEndian_32(buffer[i]);
-    }
-
-    // write the BAM core
-    m_stream.Write((char*)&buffer, Constants::BAM_CORE_SIZE);
-
-    // write the raw char data
-    m_stream.Write((char*)al.SupportData.AllCharData.data(),
-                   al.SupportData.BlockLength-Constants::BAM_CORE_SIZE);
-}
-
-void BamWriterPrivate::WriteMagicNumber(void) {
-    // write BAM file 'magic number'
-    m_stream.Write(Constants::BAM_HEADER_MAGIC, Constants::BAM_HEADER_MAGIC_LENGTH);
-}
-
-void BamWriterPrivate::WriteReferences(const BamTools::RefVector& referenceSequences) {
-
-    // write the number of reference sequences
-    uint32_t numReferenceSequences = referenceSequences.size();
-    if ( m_isBigEndian ) BamTools::SwapEndian_32(numReferenceSequences);
-    m_stream.Write((char*)&numReferenceSequences, Constants::BAM_SIZEOF_INT);
-
-    // foreach reference sequence
-    RefVector::const_iterator rsIter = referenceSequences.begin();
-    RefVector::const_iterator rsEnd  = referenceSequences.end();
-    for ( ; rsIter != rsEnd; ++rsIter ) {
-
-        // write the reference sequence name length (+1 for terminator)
-        const uint32_t actualNameLen = rsIter->RefName.size() + 1;
-        uint32_t maybeSwappedNameLen = actualNameLen;
-        if ( m_isBigEndian ) BamTools::SwapEndian_32(maybeSwappedNameLen);
-        m_stream.Write((char*)&maybeSwappedNameLen, Constants::BAM_SIZEOF_INT);
-
-        // write the reference sequence name
-        m_stream.Write(rsIter->RefName.c_str(), actualNameLen);
-
-        // write the reference sequence length
-        int32_t referenceLength = rsIter->RefLength;
-        if ( m_isBigEndian ) BamTools::SwapEndian_32(referenceLength);
-        m_stream.Write((char*)&referenceLength, Constants::BAM_SIZEOF_INT);
-    }
-}
-
-void BamWriterPrivate::WriteSamHeaderText(const std::string& samHeaderText) {
-
-    // write the SAM header  text length
-    const uint32_t actualHeaderLen = samHeaderText.size();
-    uint32_t maybeSwappedHeaderLen = samHeaderText.size();
-    if ( m_isBigEndian ) BamTools::SwapEndian_32(maybeSwappedHeaderLen);
-    m_stream.Write((char*)&maybeSwappedHeaderLen, Constants::BAM_SIZEOF_INT);
-
-    // write the SAM header text
-    if ( actualHeaderLen > 0 )
-        m_stream.Write(samHeaderText.data(), actualHeaderLen);
-}
diff --git a/bamtools/src/api/internal/bam/BamWriter_p.h b/bamtools/src/api/internal/bam/BamWriter_p.h
deleted file mode 100644
index d5bbe8d..0000000
--- a/bamtools/src/api/internal/bam/BamWriter_p.h
+++ /dev/null
@@ -1,73 +0,0 @@
-// ***************************************************************************
-// BamWriter_p.h (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 25 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides the basic functionality for producing BAM files
-// ***************************************************************************
-
-#ifndef BAMWRITER_P_H
-#define BAMWRITER_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail.  This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-
-#include "api/BamAux.h"
-#include "api/internal/io/BgzfStream_p.h"
-#include <string>
-#include <vector>
-
-namespace BamTools {
-
-class BamAlignment;
-
-namespace Internal {
-
-class BamWriterPrivate {
-
-    // ctor & dtor
-    public:
-        BamWriterPrivate(void);
-        ~BamWriterPrivate(void);
-
-    // interface methods
-    public:
-        void Close(void);
-        std::string GetErrorString(void) const;
-        bool IsOpen(void) const;
-        bool Open(const std::string& filename,
-                  const std::string& samHeaderText,
-                  const BamTools::RefVector& referenceSequences);
-        bool SaveAlignment(const BamAlignment& al);
-        void SetWriteCompressed(bool ok);
-
-    // 'internal' methods
-    public:
-        uint32_t CalculateMinimumBin(const int begin, int end) const;
-        void CreatePackedCigar(const std::vector<BamTools::CigarOp>& cigarOperations, std::string& packedCigar);
-        void EncodeQuerySequence(const std::string& query, std::string& encodedQuery);
-        void WriteAlignment(const BamAlignment& al);
-        void WriteCoreAlignment(const BamAlignment& al);
-        void WriteMagicNumber(void);
-        void WriteReferences(const BamTools::RefVector& referenceSequences);
-        void WriteSamHeaderText(const std::string& samHeaderText);
-
-    // data members
-    private:
-        BgzfStream m_stream;
-        bool m_isBigEndian;
-        std::string m_errorString;
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // BAMWRITER_P_H
diff --git a/bamtools/src/api/internal/bam/CMakeLists.txt b/bamtools/src/api/internal/bam/CMakeLists.txt
deleted file mode 100644
index 1bd2569..0000000
--- a/bamtools/src/api/internal/bam/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-# ==========================
-# BamTools CMakeLists.txt
-# (c) 2011 Derek Barnett
-#
-# src/api/internal/bam
-# ==========================
-
-set( InternalBamDir "${InternalDir}/bam" )
-
-set( InternalBamSources
-         ${InternalBamDir}/BamHeader_p.cpp
-         ${InternalBamDir}/BamMultiReader_p.cpp
-         ${InternalBamDir}/BamRandomAccessController_p.cpp
-         ${InternalBamDir}/BamReader_p.cpp
-         ${InternalBamDir}/BamWriter_p.cpp
-
-         PARENT_SCOPE # <-- leave this last
-   )
-
diff --git a/bamtools/src/api/internal/index/BamIndexFactory_p.cpp b/bamtools/src/api/internal/index/BamIndexFactory_p.cpp
deleted file mode 100644
index ab7751f..0000000
--- a/bamtools/src/api/internal/index/BamIndexFactory_p.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-// ***************************************************************************
-// BamIndexFactory_p.cpp (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 November 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides interface for generating BamIndex implementations
-// ***************************************************************************
-
-#include "api/internal/index/BamIndexFactory_p.h"
-#include "api/internal/index/BamStandardIndex_p.h"
-#include "api/internal/index/BamToolsIndex_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-using namespace std;
-
-// generates index filename from BAM filename (depending on requested type)
-// if type is unknown, returns empty string
-const string BamIndexFactory::CreateIndexFilename(const string& bamFilename,
-                                                  const BamIndex::IndexType& type)
-{
-    switch ( type ) {
-        case ( BamIndex::STANDARD ) : return ( bamFilename + BamStandardIndex::Extension() );
-        case ( BamIndex::BAMTOOLS ) : return ( bamFilename + BamToolsIndex::Extension() );
-        default :
-            return string();
-    }
-}
-
-// creates a new BamIndex object, depending on extension of @indexFilename
-BamIndex* BamIndexFactory::CreateIndexFromFilename(const string& indexFilename, BamReaderPrivate* reader) {
-
-    // get file extension from index filename, including dot (".EXT")
-    // if can't get file extension, return null index
-    const string extension = FileExtension(indexFilename);
-    if ( extension.empty() )
-        return 0;
-
-    // create index based on extension
-    if      ( extension == BamStandardIndex::Extension() ) return new BamStandardIndex(reader);
-    else if ( extension == BamToolsIndex::Extension()    ) return new BamToolsIndex(reader);
-    else
-        return 0;
-}
-
-// creates a new BamIndex, object of requested @type
-BamIndex* BamIndexFactory::CreateIndexOfType(const BamIndex::IndexType& type,
-                                             BamReaderPrivate* reader)
-{
-    switch ( type ) {
-        case ( BamIndex::STANDARD ) : return new BamStandardIndex(reader);
-        case ( BamIndex::BAMTOOLS ) : return new BamToolsIndex(reader);
-        default :
-            return 0;
-    }
-}
-
-// retrieves file extension (including '.')
-const string BamIndexFactory::FileExtension(const string& filename) {
-
-    // if filename cannot contain valid path + extension, return empty string
-    if ( filename.empty() || filename.length() <= 4 )
-        return string();
-
-    // look for last dot in filename
-    const size_t lastDotPosition = filename.find_last_of('.');
-
-    // if none found, return empty string
-    if ( lastDotPosition == string::npos )
-        return string();
-
-    // return substring from last dot position
-    return filename.substr(lastDotPosition);
-}
-
-// returns name of existing index file that corresponds to @bamFilename
-// will defer to @preferredType if possible, if not will attempt to load any supported type
-// returns empty string if not found
-const string BamIndexFactory::FindIndexFilename(const string& bamFilename,
-                                                const BamIndex::IndexType& preferredType)
-{
-    // skip if BAM filename provided is empty
-    if ( bamFilename.empty() )
-        return string();
-
-    // try to find index of preferred type first
-    // return index filename if found
-    string indexFilename = CreateIndexFilename(bamFilename, preferredType);
-    if ( !indexFilename.empty() )
-        return indexFilename;
-
-    // couldn't find preferred type, try the other supported types
-    // return index filename if found
-    if ( preferredType != BamIndex::STANDARD ) {
-        indexFilename = CreateIndexFilename(bamFilename, BamIndex::STANDARD);
-        if ( !indexFilename.empty() )
-            return indexFilename;
-    }
-    if ( preferredType != BamIndex::BAMTOOLS ) {
-        indexFilename = CreateIndexFilename(bamFilename, BamIndex::BAMTOOLS);
-        if ( !indexFilename.empty() )
-            return indexFilename;
-    }
-
-    // otherwise couldn't find any index matching this filename
-    return string();
-}
diff --git a/bamtools/src/api/internal/index/BamIndexFactory_p.h b/bamtools/src/api/internal/index/BamIndexFactory_p.h
deleted file mode 100644
index 4e4f1cf..0000000
--- a/bamtools/src/api/internal/index/BamIndexFactory_p.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// ***************************************************************************
-// BamIndexFactory_p.h (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides interface for generating BamIndex implementations
-// ***************************************************************************
-
-#ifndef BAMINDEX_FACTORY_P_H
-#define BAMINDEX_FACTORY_P_H
-
-#include "api/BamIndex.h"
-#include <string>
-
-namespace BamTools {
-namespace Internal {
-
-class BamIndexFactory {
-
-    // static interface methods
-    public:
-        // creates a new BamIndex object, depending on extension of @indexFilename
-        static BamIndex* CreateIndexFromFilename(const std::string& indexFilename,
-                                                 BamReaderPrivate* reader);
-        // creates a new BamIndex object, of requested @type
-        static BamIndex* CreateIndexOfType(const BamIndex::IndexType& type,
-                                           BamReaderPrivate* reader);
-        // returns name of existing index file that corresponds to @bamFilename
-        // will defer to @preferredType if possible
-        // if @preferredType not found, will attempt to load any supported index type
-        // returns empty string if no index file (of any type) is found
-        static const std::string FindIndexFilename(const std::string& bamFilename,
-                                                   const BamIndex::IndexType& preferredType);
-
-    // internal methods
-    public:
-        // generates index filename from BAM filename (depending on requested type)
-        // if type is unknown, returns empty string
-        static const std::string CreateIndexFilename(const std::string& bamFilename,
-                                                     const BamIndex::IndexType& type);
-        // retrieves file extension (including '.')
-        static const std::string FileExtension(const std::string& filename);
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // BAMINDEX_FACTORY_P_H
diff --git a/bamtools/src/api/internal/index/BamStandardIndex_p.cpp b/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
deleted file mode 100644
index 2606a98..0000000
--- a/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
+++ /dev/null
@@ -1,965 +0,0 @@
-// ***************************************************************************
-// BamStandardIndex.cpp (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 25 May 2012 (DB)
-// ---------------------------------------------------------------------------
-// Provides index operations for the standardized BAM index format (".bai")
-// ***************************************************************************
-
-#include "api/BamAlignment.h"
-#include "api/internal/bam/BamReader_p.h"
-#include "api/internal/index/BamStandardIndex_p.h"
-#include "api/internal/io/BamDeviceFactory_p.h"
-#include "api/internal/utils/BamException_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#include <cstdio>
-#include <cstdlib>
-#include <cstring>
-#include <algorithm>
-#include <sstream>
-using namespace std;
-
-// -----------------------------------
-// static BamStandardIndex constants
-// -----------------------------------
-
-const int BamStandardIndex::MAX_BIN               = 37450;  // =(8^6-1)/7+1
-const int BamStandardIndex::BAM_LIDX_SHIFT        = 14;
-const string BamStandardIndex::BAI_EXTENSION      = ".bai";
-const char* const BamStandardIndex::BAI_MAGIC     = "BAI\1";
-const int BamStandardIndex::SIZEOF_ALIGNMENTCHUNK = sizeof(uint64_t)*2;
-const int BamStandardIndex::SIZEOF_BINCORE        = sizeof(uint32_t) + sizeof(int32_t);
-const int BamStandardIndex::SIZEOF_LINEAROFFSET   = sizeof(uint64_t);
-
-// ----------------------------
-// RaiiWrapper implementation
-// ----------------------------
-
-BamStandardIndex::RaiiWrapper::RaiiWrapper(void)
-    : Device(0)
-    , Buffer(0)
-{ }
-
-BamStandardIndex::RaiiWrapper::~RaiiWrapper(void) {
-
-    if ( Device ) {
-        Device->Close();
-        delete Device;
-        Device = 0;
-    }
-
-    if ( Buffer ) {
-        delete[] Buffer;
-        Buffer = 0;
-    }
-}
-
-// ---------------------------------
-// BamStandardIndex implementation
-// ---------------------------------
-
-// ctor
-BamStandardIndex::BamStandardIndex(Internal::BamReaderPrivate* reader)
-    : BamIndex(reader)
-    , m_bufferLength(0)
-{
-     m_isBigEndian = BamTools::SystemIsBigEndian();
-}
-
-// dtor
-BamStandardIndex::~BamStandardIndex(void) {
-    CloseFile();
-}
-
-void BamStandardIndex::AdjustRegion(const BamRegion& region, uint32_t& begin, uint32_t& end) {
-
-    // retrieve references from reader
-    const RefVector& references = m_reader->GetReferenceData();
-
-    // LeftPosition cannot be greater than or equal to reference length
-    if ( region.LeftPosition >= references.at(region.LeftRefID).RefLength )
-        throw BamException("BamStandardIndex::AdjustRegion", "invalid region requested");
-
-    // set region 'begin'
-    begin = (unsigned int)region.LeftPosition;
-
-    // if right bound specified AND left&right bounds are on same reference
-    // OK to use right bound position as region 'end'
-    if ( region.isRightBoundSpecified() && ( region.LeftRefID == region.RightRefID ) )
-        end = (unsigned int)region.RightPosition;
-
-    // otherwise, set region 'end' to last reference base
-    else end = (unsigned int)references.at(region.LeftRefID).RefLength;
-}
-
-// [begin, end)
-void BamStandardIndex::CalculateCandidateBins(const uint32_t& begin,
-                                              const uint32_t& end,
-                                              set<uint16_t>& candidateBins)
-{
-    // initialize list, bin '0' is always a valid bin
-    candidateBins.insert(0);
-
-    // get rest of bins that contain this region
-    unsigned int k;
-    for (k =    1 + (begin>>26); k <=    1 + (end>>26); ++k) { candidateBins.insert(k); }
-    for (k =    9 + (begin>>23); k <=    9 + (end>>23); ++k) { candidateBins.insert(k); }
-    for (k =   73 + (begin>>20); k <=   73 + (end>>20); ++k) { candidateBins.insert(k); }
-    for (k =  585 + (begin>>17); k <=  585 + (end>>17); ++k) { candidateBins.insert(k); }
-    for (k = 4681 + (begin>>14); k <= 4681 + (end>>14); ++k) { candidateBins.insert(k); }
-}
-
-void BamStandardIndex::CalculateCandidateOffsets(const BaiReferenceSummary& refSummary,
-                                                 const uint64_t& minOffset,
-                                                 set<uint16_t>& candidateBins,
-                                                 vector<int64_t>& offsets)
-{
-    // seek to first bin
-    Seek(refSummary.FirstBinFilePosition, SEEK_SET);
-
-    // iterate over reference bins
-    uint32_t binId;
-    int32_t numAlignmentChunks;
-    set<uint16_t>::iterator candidateBinIter;
-    for ( int i = 0; i < refSummary.NumBins; ++i ) {
-
-        // read bin contents (if successful, alignment chunks are now in m_buffer)
-        ReadBinIntoBuffer(binId, numAlignmentChunks);
-
-        // see if bin is a 'candidate bin'
-        candidateBinIter = candidateBins.find(binId);
-
-        // if not, move on to next bin
-        if ( candidateBinIter == candidateBins.end() )
-            continue;
-
-        // otherwise, check bin's contents against for overlap
-        else {
-
-            size_t offset = 0;
-            uint64_t chunkStart;
-            uint64_t chunkStop;
-
-            // iterate over alignment chunks
-            for ( int j = 0; j < numAlignmentChunks; ++j ) {
-
-                // read chunk start & stop from buffer
-                memcpy((char*)&chunkStart, m_resources.Buffer+offset, sizeof(uint64_t));
-                offset += sizeof(uint64_t);
-                memcpy((char*)&chunkStop, m_resources.Buffer+offset, sizeof(uint64_t));
-                offset += sizeof(uint64_t);
-
-                // swap endian-ness if necessary
-                if ( m_isBigEndian ) {
-                    SwapEndian_64(chunkStart);
-                    SwapEndian_64(chunkStop);
-                }
-
-                // store alignment chunk's start offset
-                // if its stop offset is larger than our 'minOffset'
-                if ( chunkStop >= minOffset )
-                    offsets.push_back(chunkStart);
-            }
-
-            // 'pop' bin ID from candidate bins set
-            candidateBins.erase(candidateBinIter);
-
-            // quit if no more candidates
-            if ( candidateBins.empty() )
-                break;
-        }
-    }
-}
-
-uint64_t BamStandardIndex::CalculateMinOffset(const BaiReferenceSummary& refSummary,
-                                              const uint32_t& begin)
-{
-    // if no linear offsets exist, return 0
-    if ( refSummary.NumLinearOffsets == 0 )
-        return 0;
-
-    // if 'begin' starts beyond last linear offset, use the last linear offset as minimum
-    // else use the offset corresponding to the requested start position
-    const int shiftedBegin = begin>>BamStandardIndex::BAM_LIDX_SHIFT;
-    if ( shiftedBegin >= refSummary.NumLinearOffsets )
-        return LookupLinearOffset( refSummary, refSummary.NumLinearOffsets-1 );
-    else
-        return LookupLinearOffset( refSummary, shiftedBegin );
-}
-
-void BamStandardIndex::CheckBufferSize(char*& buffer,
-                                       unsigned int& bufferLength,
-                                       const unsigned int& requestedBytes)
-{
-    try {
-        if ( requestedBytes > bufferLength ) {
-            bufferLength = requestedBytes + 10;
-            delete[] buffer;
-            buffer = new char[bufferLength];
-        }
-    } catch ( std::bad_alloc&  ) {
-        stringstream s("");
-        s << "out of memory when allocating " << requestedBytes << " bytes";
-        throw BamException("BamStandardIndex::CheckBufferSize", s.str());
-    }
-}
-
-void BamStandardIndex::CheckBufferSize(unsigned char*& buffer,
-                                       unsigned int& bufferLength,
-                                       const unsigned int& requestedBytes)
-{
-    try {
-        if ( requestedBytes > bufferLength ) {
-            bufferLength = requestedBytes + 10;
-            delete[] buffer;
-            buffer = new unsigned char[bufferLength];
-        }
-    } catch ( std::bad_alloc& ) {
-        stringstream s("");
-        s << "out of memory when allocating " << requestedBytes << " bytes";
-        throw BamException("BamStandardIndex::CheckBufferSize", s.str());
-    }
-}
-
-void BamStandardIndex::CheckMagicNumber(void) {
-
-    // check 'magic number' to see if file is BAI index
-    char magic[4];
-    const int64_t numBytesRead = m_resources.Device->Read(magic, sizeof(magic));
-    if ( numBytesRead != 4 )
-        throw BamException("BamStandardIndex::CheckMagicNumber", "could not read BAI magic number");
-
-    // compare to expected value
-    if ( strncmp(magic, BamStandardIndex::BAI_MAGIC, 4) != 0 )
-        throw BamException("BamStandardIndex::CheckMagicNumber", "invalid BAI magic number");
-}
-
-void BamStandardIndex::ClearReferenceEntry(BaiReferenceEntry& refEntry) {
-    refEntry.ID = -1;
-    refEntry.Bins.clear();
-    refEntry.LinearOffsets.clear();
-}
-
-void BamStandardIndex::CloseFile(void) {
-
-    // close file stream
-    if ( IsDeviceOpen() ) {
-        m_resources.Device->Close();
-        delete m_resources.Device;
-        m_resources.Device = 0;
-    }
-
-    // clear index file summary data
-    m_indexFileSummary.clear();
-
-    // clean up I/O buffer
-    delete[] m_resources.Buffer;
-    m_resources.Buffer = 0;
-    m_bufferLength = 0;
-}
-
-// builds index from associated BAM file & writes out to index file
-bool BamStandardIndex::Create(void) {
-
-    // skip if BamReader is invalid or not open
-    if ( m_reader == 0 || !m_reader->IsOpen() ) {
-        SetErrorString("BamStandardIndex::Create", "could not create index: reader is not open");
-        return false;
-    }
-
-    // rewind BamReader
-    if ( !m_reader->Rewind() ) {
-        const string readerError = m_reader->GetErrorString();
-        const string message = "could not create index: \n\t" + readerError;
-        SetErrorString("BamStandardIndex::Create", message);
-        return false;
-    }
-
-    try {
-
-        // open new index file (read & write)
-        string indexFilename = m_reader->Filename() + Extension();
-        OpenFile(indexFilename, IBamIODevice::ReadWrite);
-
-        // initialize BaiFileSummary with number of references
-        const int& numReferences = m_reader->GetReferenceCount();
-        ReserveForSummary(numReferences);
-
-        // initialize output file
-        WriteHeader();
-
-        // set up bin, ID, offset, & coordinate markers
-        const uint32_t defaultValue = 0xffffffffu;
-        uint32_t currentBin    = defaultValue;
-        uint32_t lastBin       = defaultValue;
-        int32_t  currentRefID  = defaultValue;
-        int32_t  lastRefID     = defaultValue;
-        uint64_t currentOffset = (uint64_t)m_reader->Tell();
-        uint64_t lastOffset    = currentOffset;
-        int32_t  lastPosition  = defaultValue;
-
-        // iterate through alignments in BAM file
-        BamAlignment al;
-        BaiReferenceEntry refEntry;
-        while ( m_reader->LoadNextAlignment(al) ) {
-
-            // changed to new reference
-            if ( lastRefID != al.RefID ) {
-
-                // if not first reference, save previous reference data
-                if ( lastRefID != (int32_t)defaultValue ) {
-
-                    SaveAlignmentChunkToBin(refEntry.Bins, currentBin, currentOffset, lastOffset);
-                    WriteReferenceEntry(refEntry);
-                    ClearReferenceEntry(refEntry);
-
-                    // write any empty references between (but *NOT* including) lastRefID & al.RefID
-                    for ( int i = lastRefID+1; i < al.RefID; ++i ) {
-                        BaiReferenceEntry emptyEntry(i);
-                        WriteReferenceEntry(emptyEntry);
-                    }
-
-                    // update bin markers
-                    currentOffset = lastOffset;
-                    currentBin    = al.Bin;
-                    lastBin       = al.Bin;
-                    currentRefID  = al.RefID;
-                }
-
-                // otherwise, this is first pass
-                // be sure to write any empty references up to (but *NOT* including) current RefID
-                else {
-                    for ( int i = 0; i < al.RefID; ++i ) {
-                        BaiReferenceEntry emptyEntry(i);
-                        WriteReferenceEntry(emptyEntry);
-                    }
-                }
-
-                // update reference markers
-                refEntry.ID = al.RefID;
-                lastRefID   = al.RefID;
-                lastBin     = defaultValue;
-            }
-
-            // if lastPosition greater than current alignment position - file not sorted properly
-            else if ( lastPosition > al.Position ) {
-                stringstream s("");
-                s << "BAM file is not properly sorted by coordinate" << endl
-                  << "Current alignment position: " << al.Position
-                  << " < previous alignment position: " << lastPosition
-                  << " on reference ID: " << al.RefID << endl;
-                SetErrorString("BamStandardIndex::Create", s.str());
-                return false;
-            }
-
-            // if alignment's ref ID is valid & its bin is not a 'leaf'
-            if ( (al.RefID >= 0) && (al.Bin < 4681) )
-                SaveLinearOffsetEntry(refEntry.LinearOffsets, al.Position, al.GetEndPosition(), lastOffset);
-
-            // changed to new BAI bin
-            if ( al.Bin != lastBin ) {
-
-                // if not first bin on reference, save previous bin data
-                if ( currentBin != defaultValue )
-                    SaveAlignmentChunkToBin(refEntry.Bins, currentBin, currentOffset, lastOffset);
-
-                // update markers
-                currentOffset = lastOffset;
-                currentBin    = al.Bin;
-                lastBin       = al.Bin;
-                currentRefID  = al.RefID;
-
-                // if invalid RefID, break out
-                if ( currentRefID < 0 )
-                    break;
-            }
-
-            // make sure that current file pointer is beyond lastOffset
-            if ( m_reader->Tell() <= (int64_t)lastOffset ) {
-                SetErrorString("BamStandardIndex::Create", "calculating offsets failed");
-                return false;
-            }
-
-            // update lastOffset & lastPosition
-            lastOffset   = m_reader->Tell();
-            lastPosition = al.Position;
-        }
-
-        // after finishing alignments, if any data was read, check:
-        if ( lastOffset != currentOffset ) {
-
-            // store last alignment chunk to its bin, then write last reference entry with data
-            SaveAlignmentChunkToBin(refEntry.Bins, currentBin, currentOffset, lastOffset);
-            WriteReferenceEntry(refEntry);
-        }
-
-        // then write any empty references remaining at end of file
-        for ( int i = currentRefID+1; i < numReferences; ++i ) {
-            BaiReferenceEntry emptyEntry(i);
-            WriteReferenceEntry(emptyEntry);
-        }
-
-    } catch ( BamException& e) {
-        m_errorString = e.what();
-        return false;
-    }
-
-    // rewind BamReader
-    if ( !m_reader->Rewind() ) {
-        const string readerError = m_reader->GetErrorString();
-        const string message = "could not create index: \n\t" + readerError;
-        SetErrorString("BamStandardIndex::Create", message);
-        return false;
-    }
-
-    // return success
-    return true;
-}
-
-// returns format's file extension
-const string BamStandardIndex::Extension(void) {
-    return BamStandardIndex::BAI_EXTENSION;
-}
-
-void BamStandardIndex::GetOffset(const BamRegion& region, int64_t& offset, bool* hasAlignmentsInRegion) {
-
-    // cannot calculate offsets if unknown/invalid reference ID requested
-    if ( region.LeftRefID < 0 || region.LeftRefID >= (int)m_indexFileSummary.size() )
-        throw BamException("BamStandardIndex::GetOffset", "invalid reference ID requested");
-
-    // retrieve index summary for left bound reference
-    const BaiReferenceSummary& refSummary = m_indexFileSummary.at(region.LeftRefID);
-
-    // set up region boundaries based on actual BamReader data
-    uint32_t begin;
-    uint32_t end;
-    AdjustRegion(region, begin, end);
-
-    // retrieve all candidate bin IDs for region
-    set<uint16_t> candidateBins;
-    CalculateCandidateBins(begin, end, candidateBins);
-
-    // use reference's linear offsets to calculate the minimum offset
-    // that must be considered to find overlap
-    const uint64_t& minOffset = CalculateMinOffset(refSummary, begin);
-
-    // attempt to use reference summary, minOffset, & candidateBins to calculate offsets
-    // no data should not be error, just bail
-    vector<int64_t> offsets;
-    CalculateCandidateOffsets(refSummary, minOffset, candidateBins, offsets);
-    if ( offsets.empty() )
-        return;
-    
-    // ensure that offsets are sorted before processing
-    sort( offsets.begin(), offsets.end() );
-
-    // binary search for an overlapping block (may not be first one though)
-    BamAlignment al;
-    typedef vector<int64_t>::const_iterator OffsetConstIterator;
-    OffsetConstIterator offsetFirst = offsets.begin();
-    OffsetConstIterator offsetIter  = offsetFirst;
-    OffsetConstIterator offsetLast  = offsets.end();
-    iterator_traits<OffsetConstIterator>::difference_type count = distance(offsetFirst, offsetLast);
-    iterator_traits<OffsetConstIterator>::difference_type step;
-    while ( count > 0 ) {
-        offsetIter = offsetFirst;
-        step = count/2;
-        advance(offsetIter, step);
-
-        // attempt seek to candidate offset
-        const int64_t& candidateOffset = (*offsetIter);
-        if ( !m_reader->Seek(candidateOffset) ) {
-            const string readerError = m_reader->GetErrorString();
-            const string message = "could not seek in BAM file: \n\t" + readerError;
-            throw BamException("BamToolsIndex::GetOffset", message);
-        }
-
-        // load first available alignment, setting flag to true if data exists
-        *hasAlignmentsInRegion = m_reader->LoadNextAlignment(al);
-
-        // check alignment against region
-        if ( al.GetEndPosition() <= region.LeftPosition ) {
-            offsetFirst = ++offsetIter;
-            count -= step+1;
-        } else count = step;
-    }
-
-    // step back to the offset before the 'current offset' (to make sure we cover overlaps)
-    if ( offsetIter != offsets.begin() )
-        --offsetIter;
-    offset = (*offsetIter);
-}
-
-// returns whether reference has alignments or no
-bool BamStandardIndex::HasAlignments(const int& referenceID) const {
-    if ( referenceID < 0 || referenceID >= (int)m_indexFileSummary.size() )
-        return false;
-    const BaiReferenceSummary& refSummary = m_indexFileSummary.at(referenceID);
-    return ( refSummary.NumBins > 0 );
-}
-
-bool BamStandardIndex::IsDeviceOpen(void) const {
-    if ( m_resources.Device == 0 )
-        return false;
-    return m_resources.Device->IsOpen();
-}
-
-// attempts to use index data to jump to @region, returns success/fail
-// a "successful" jump indicates no error, but not whether this region has data
-//   * thus, the method sets a flag to indicate whether there are alignments
-//     available after the jump position
-bool BamStandardIndex::Jump(const BamRegion& region, bool* hasAlignmentsInRegion) {
-
-    // clear out flag
-    *hasAlignmentsInRegion = false;
-
-    // skip if invalid reader or not open
-    if ( m_reader == 0 || !m_reader->IsOpen() ) {
-        SetErrorString("BamStandardIndex::Jump", "could not jump: reader is not open");
-        return false;
-    }
-
-    // calculate nearest offset to jump to
-    int64_t offset;
-    try {
-        GetOffset(region, offset, hasAlignmentsInRegion);
-    } catch ( BamException& e ) {
-        m_errorString = e.what();
-        return false;
-    }
-
-    // if region has alignments, return success/fail of seeking there
-    if ( *hasAlignmentsInRegion )
-        return m_reader->Seek(offset);
-
-    // otherwise, simply return true (but hasAlignmentsInRegion flag has been set to false)
-    // (this is OK, BamReader will check this flag before trying to load data)
-    return true;
-}
-
-// loads existing data from file into memory
-bool BamStandardIndex::Load(const std::string& filename) {
-
-    try {
-
-        // attempt to open file (read-only)
-        OpenFile(filename, IBamIODevice::ReadOnly);
-
-        // validate format
-        CheckMagicNumber();
-
-        // load in-memory summary of index data
-        SummarizeIndexFile();
-
-        // return success
-        return true;
-
-    } catch ( BamException& e ) {
-        m_errorString = e.what();
-        return false;
-    }
-}
-
-uint64_t BamStandardIndex::LookupLinearOffset(const BaiReferenceSummary& refSummary, const int& index) {
-
-    // attempt seek to proper index file position
-    const int64_t linearOffsetFilePosition = (int64_t)refSummary.FirstLinearOffsetFilePosition +
-                                             index*BamStandardIndex::SIZEOF_LINEAROFFSET;
-    Seek(linearOffsetFilePosition, SEEK_SET);
-
-    // read linear offset from BAI file
-    uint64_t linearOffset;
-    ReadLinearOffset(linearOffset);
-    return linearOffset;
-}
-
-void BamStandardIndex::MergeAlignmentChunks(BaiAlignmentChunkVector& chunks) {
-
-    // skip if chunks are empty, nothing to merge
-    if ( chunks.empty() )
-        return;
-
-    // set up merged alignment chunk container
-    BaiAlignmentChunkVector mergedChunks;
-    mergedChunks.push_back( chunks[0] );
-
-    // iterate over chunks
-    int i = 0;
-    BaiAlignmentChunkVector::iterator chunkIter = chunks.begin();
-    BaiAlignmentChunkVector::iterator chunkEnd  = chunks.end();
-    for ( ++chunkIter; chunkIter != chunkEnd; ++chunkIter) {
-
-        // get 'currentMergeChunk' based on numeric index
-        BaiAlignmentChunk& currentMergeChunk = mergedChunks[i];
-
-        // get sourceChunk based on source vector iterator
-        BaiAlignmentChunk& sourceChunk = (*chunkIter);
-
-        // if currentMergeChunk ends where sourceChunk starts, then merge the two
-        if ( currentMergeChunk.Stop>>16 == sourceChunk.Start>>16 )
-            currentMergeChunk.Stop = sourceChunk.Stop;
-
-        // otherwise
-        else {
-            // append sourceChunk after currentMergeChunk
-            mergedChunks.push_back(sourceChunk);
-
-            // update i, so the next iteration will consider the
-            // recently-appended sourceChunk as new mergeChunk candidate
-            ++i;
-        }
-    }
-
-    // saved newly-merged chunks into (parameter) chunks
-    chunks = mergedChunks;
-}
-
-void BamStandardIndex::OpenFile(const std::string& filename, IBamIODevice::OpenMode mode) {
-
-    // make sure any previous index file is closed
-    CloseFile();
-
-    m_resources.Device = BamDeviceFactory::CreateDevice(filename);
-    if ( m_resources.Device == 0 ) {
-        const string message = string("could not open file: ") + filename;
-        throw BamException("BamStandardIndex::OpenFile", message);
-    }
-
-    // attempt to open file
-    m_resources.Device->Open(mode);
-    if ( !IsDeviceOpen() ) {
-        const string message = string("could not open file: ") + filename;
-        throw BamException("BamStandardIndex::OpenFile", message);
-    }
-}
-
-void BamStandardIndex::ReadBinID(uint32_t& binId) {
-    const int64_t numBytesRead = m_resources.Device->Read((char*)&binId, sizeof(binId));
-    if ( m_isBigEndian ) SwapEndian_32(binId);
-    if ( numBytesRead != sizeof(binId) )
-        throw BamException("BamStandardIndex::ReadBinID", "could not read BAI bin ID");
-}
-
-void BamStandardIndex::ReadBinIntoBuffer(uint32_t& binId, int32_t& numAlignmentChunks) {
-
-    // read bin header
-    ReadBinID(binId);
-    ReadNumAlignmentChunks(numAlignmentChunks);
-
-    // read bin contents
-    const unsigned int bytesRequested = numAlignmentChunks*BamStandardIndex::SIZEOF_ALIGNMENTCHUNK;
-    ReadIntoBuffer(bytesRequested);
-}
-
-void BamStandardIndex::ReadIntoBuffer(const unsigned int& bytesRequested) {
-
-    // ensure that our buffer is big enough for request
-    BamStandardIndex::CheckBufferSize(m_resources.Buffer, m_bufferLength, bytesRequested);
-
-    // read from BAI file stream
-    const int64_t bytesRead = m_resources.Device->Read(m_resources.Buffer, bytesRequested);
-    if ( bytesRead != (int64_t)bytesRequested ) {
-        stringstream s("");
-        s << "expected to read: " << bytesRequested << " bytes, "
-          << "but instead read: " << bytesRead;
-        throw BamException("BamStandardIndex::ReadIntoBuffer", s.str());
-    }
-}
-
-void BamStandardIndex::ReadLinearOffset(uint64_t& linearOffset) {
-    const int64_t numBytesRead = m_resources.Device->Read((char*)&linearOffset, sizeof(linearOffset));
-    if ( m_isBigEndian ) SwapEndian_64(linearOffset);
-    if ( numBytesRead != sizeof(linearOffset) )
-        throw BamException("BamStandardIndex::ReadLinearOffset", "could not read BAI linear offset");
-}
-
-void BamStandardIndex::ReadNumAlignmentChunks(int& numAlignmentChunks) {
-    const int64_t numBytesRead = m_resources.Device->Read((char*)&numAlignmentChunks, sizeof(numAlignmentChunks));
-    if ( m_isBigEndian ) SwapEndian_32(numAlignmentChunks);
-    if ( numBytesRead != sizeof(numAlignmentChunks) )
-        throw BamException("BamStandardIndex::ReadNumAlignmentChunks", "could not read BAI chunk count");
-}
-
-void BamStandardIndex::ReadNumBins(int& numBins) {
-    const int64_t numBytesRead = m_resources.Device->Read((char*)&numBins, sizeof(numBins));
-    if ( m_isBigEndian ) SwapEndian_32(numBins);
-    if ( numBytesRead != sizeof(numBins) )
-        throw BamException("BamStandardIndex::ReadNumBins", "could not read BAI bin count");
-}
-
-void BamStandardIndex::ReadNumLinearOffsets(int& numLinearOffsets) {
-    const int64_t numBytesRead = m_resources.Device->Read((char*)&numLinearOffsets, sizeof(numLinearOffsets));
-    if ( m_isBigEndian ) SwapEndian_32(numLinearOffsets);
-    if ( numBytesRead != sizeof(numLinearOffsets) )
-        throw BamException("BamStandardIndex::ReadNumAlignmentChunks", "could not read BAI linear offset count");
-}
-
-void BamStandardIndex::ReadNumReferences(int& numReferences) {
-    const int64_t numBytesRead = m_resources.Device->Read((char*)&numReferences, sizeof(numReferences));
-    if ( m_isBigEndian ) SwapEndian_32(numReferences);
-    if ( numBytesRead != sizeof(numReferences) )
-        throw BamException("BamStandardIndex::ReadNumReferences", "could not read reference count");
-}
-
-void BamStandardIndex::ReserveForSummary(const int& numReferences) {
-    m_indexFileSummary.clear();
-    m_indexFileSummary.assign( numReferences, BaiReferenceSummary() );
-}
-
-void BamStandardIndex::SaveAlignmentChunkToBin(BaiBinMap& binMap,
-                                               const uint32_t& currentBin,
-                                               const uint64_t& currentOffset,
-                                               const uint64_t& lastOffset)
-{
-    // create new alignment chunk
-    BaiAlignmentChunk newChunk(currentOffset, lastOffset);
-
-    // if no entry exists yet for this bin, create one and store alignment chunk
-    BaiBinMap::iterator binIter = binMap.find(currentBin);
-    if ( binIter == binMap.end() ) {
-        BaiAlignmentChunkVector newChunks;
-        newChunks.push_back(newChunk);
-        binMap.insert( pair<uint32_t, BaiAlignmentChunkVector>(currentBin, newChunks));
-    }
-
-    // otherwise, just append alignment chunk
-    else {
-        BaiAlignmentChunkVector& binChunks = (*binIter).second;
-        binChunks.push_back( newChunk );
-    }
-}
-
-void BamStandardIndex::SaveBinsSummary(const int& refId, const int& numBins) {
-    BaiReferenceSummary& refSummary = m_indexFileSummary.at(refId);
-    refSummary.NumBins = numBins;
-    refSummary.FirstBinFilePosition = Tell();
-}
-
-void BamStandardIndex::SaveLinearOffsetEntry(BaiLinearOffsetVector& offsets,
-                                             const int& alignmentStartPosition,
-                                             const int& alignmentStopPosition,
-                                             const uint64_t& lastOffset)
-{
-    // get converted offsets
-    const int beginOffset = alignmentStartPosition >> BamStandardIndex::BAM_LIDX_SHIFT;
-    const int endOffset   = (alignmentStopPosition - 1) >> BamStandardIndex::BAM_LIDX_SHIFT;
-
-    // resize vector if necessary
-    int oldSize = offsets.size();
-    int newSize = endOffset + 1;
-    if ( oldSize < newSize )
-        offsets.resize(newSize, 0);
-
-    // store offset
-    for( int i = beginOffset + 1; i <= endOffset; ++i ) {
-        if ( offsets[i] == 0 )
-            offsets[i] = lastOffset;
-    }
-}
-
-void BamStandardIndex::SaveLinearOffsetsSummary(const int& refId, const int& numLinearOffsets) {
-    BaiReferenceSummary& refSummary = m_indexFileSummary.at(refId);
-    refSummary.NumLinearOffsets = numLinearOffsets;
-    refSummary.FirstLinearOffsetFilePosition = Tell();
-}
-
-// seek to position in index file stream
-void BamStandardIndex::Seek(const int64_t& position, const int origin) {
-    if ( !m_resources.Device->Seek(position, origin) )
-        throw BamException("BamStandardIndex::Seek", "could not seek in BAI file");
-}
-
-void BamStandardIndex::SkipBins(const int& numBins) {
-    uint32_t binId;
-    int32_t numAlignmentChunks;
-    for (int i = 0; i < numBins; ++i)
-        ReadBinIntoBuffer(binId, numAlignmentChunks); // results & buffer ignored
-}
-
-void BamStandardIndex::SkipLinearOffsets(const int& numLinearOffsets) {
-    const unsigned int bytesRequested = numLinearOffsets*BamStandardIndex::SIZEOF_LINEAROFFSET;
-    ReadIntoBuffer(bytesRequested);
-}
-
-void BamStandardIndex::SortLinearOffsets(BaiLinearOffsetVector& linearOffsets) {
-    sort( linearOffsets.begin(), linearOffsets.end() );
-}
-
-void BamStandardIndex::SummarizeBins(BaiReferenceSummary& refSummary) {
-
-    // load number of bins
-    int numBins;
-    ReadNumBins(numBins);
-
-    // store bins summary for this reference
-    refSummary.NumBins = numBins;
-    refSummary.FirstBinFilePosition = Tell();
-
-    // skip this reference's bins
-    SkipBins(numBins);
-}
-
-void BamStandardIndex::SummarizeIndexFile(void) {
-
-    // load number of reference sequences
-    int numReferences;
-    ReadNumReferences(numReferences);
-
-    // initialize file summary data
-    ReserveForSummary(numReferences);
-
-    // iterate over reference entries
-    BaiFileSummary::iterator summaryIter = m_indexFileSummary.begin();
-    BaiFileSummary::iterator summaryEnd  = m_indexFileSummary.end();
-    for ( int i = 0; summaryIter != summaryEnd; ++summaryIter, ++i )
-        SummarizeReference(*summaryIter);
-}
-
-void BamStandardIndex::SummarizeLinearOffsets(BaiReferenceSummary& refSummary) {
-
-    // load number of linear offsets
-    int numLinearOffsets;
-    ReadNumLinearOffsets(numLinearOffsets);
-
-    // store bin summary data for this reference
-    refSummary.NumLinearOffsets = numLinearOffsets;
-    refSummary.FirstLinearOffsetFilePosition = Tell();
-
-    // skip linear offsets in index file
-    SkipLinearOffsets(numLinearOffsets);
-}
-
-void BamStandardIndex::SummarizeReference(BaiReferenceSummary& refSummary) {
-    SummarizeBins(refSummary);
-    SummarizeLinearOffsets(refSummary);
-}
-
-// return position of file pointer in index file stream
-int64_t BamStandardIndex::Tell(void) const {
-    return m_resources.Device->Tell();
-}
-
-void BamStandardIndex::WriteAlignmentChunk(const BaiAlignmentChunk& chunk) {
-
-    // localize alignment chunk offsets
-    uint64_t start = chunk.Start;
-    uint64_t stop  = chunk.Stop;
-
-    // swap endian-ness if necessary
-    if ( m_isBigEndian ) {
-        SwapEndian_64(start);
-        SwapEndian_64(stop);
-    }
-
-    // write to index file
-    int64_t numBytesWritten = 0;
-    numBytesWritten += m_resources.Device->Write((const char*)&start, sizeof(start));
-    numBytesWritten += m_resources.Device->Write((const char*)&stop, sizeof(stop));
-    if ( numBytesWritten != (sizeof(start)+sizeof(stop)) )
-        throw BamException("BamStandardIndex::WriteAlignmentChunk", "could not write BAI alignment chunk");
-}
-
-void BamStandardIndex::WriteAlignmentChunks(BaiAlignmentChunkVector& chunks) {
-
-    // make sure chunks are merged (simplified) before writing & saving summary
-    MergeAlignmentChunks(chunks);
-
-    // write chunks
-    int32_t chunkCount = chunks.size();
-    if ( m_isBigEndian ) SwapEndian_32(chunkCount);
-    const int64_t numBytesWritten = m_resources.Device->Write((const char*)&chunkCount, sizeof(chunkCount));
-    if ( numBytesWritten != sizeof(chunkCount) )
-        throw BamException("BamStandardIndex::WriteAlignmentChunks", "could not write BAI chunk count");
-
-    // iterate over chunks
-    BaiAlignmentChunkVector::const_iterator chunkIter = chunks.begin();
-    BaiAlignmentChunkVector::const_iterator chunkEnd  = chunks.end();
-    for ( ; chunkIter != chunkEnd; ++chunkIter )
-        WriteAlignmentChunk( (*chunkIter) );
-}
-
-void BamStandardIndex::WriteBin(const uint32_t& binId, BaiAlignmentChunkVector& chunks) {
-
-    // write BAM bin ID
-    uint32_t binKey = binId;
-    if ( m_isBigEndian ) SwapEndian_32(binKey);
-    const int64_t numBytesWritten = m_resources.Device->Write((const char*)&binKey, sizeof(binKey));
-    if ( numBytesWritten != sizeof(binKey) )
-        throw BamException("BamStandardIndex::WriteBin", "could not write bin ID");
-
-    // write bin's alignment chunks
-    WriteAlignmentChunks(chunks);
-}
-
-void BamStandardIndex::WriteBins(const int& refId, BaiBinMap& bins) {
-
-    // write number of bins
-    int32_t binCount = bins.size();
-    if ( m_isBigEndian ) SwapEndian_32(binCount);
-    const int64_t numBytesWritten = m_resources.Device->Write((const char*)&binCount, sizeof(binCount));
-    if ( numBytesWritten != sizeof(binCount) )
-        throw BamException("BamStandardIndex::WriteBins", "could not write bin count");
-
-    // save summary for reference's bins
-    SaveBinsSummary(refId, bins.size());
-
-    // iterate over bins
-    BaiBinMap::iterator binIter = bins.begin();
-    BaiBinMap::iterator binEnd  = bins.end();
-    for ( ; binIter != binEnd; ++binIter )
-        WriteBin( (*binIter).first, (*binIter).second );
-}
-
-void BamStandardIndex::WriteHeader(void) {
-
-    int64_t numBytesWritten = 0;
-
-    // write magic number
-    numBytesWritten += m_resources.Device->Write(BamStandardIndex::BAI_MAGIC, 4);
-
-    // write number of reference sequences
-    int32_t numReferences = m_indexFileSummary.size();
-    if ( m_isBigEndian ) SwapEndian_32(numReferences);
-    numBytesWritten += m_resources.Device->Write((const char*)&numReferences, sizeof(numReferences));
-
-    if ( numBytesWritten != sizeof(numReferences)+4 )
-        throw BamException("BamStandardIndex::WriteHeader", "could not write BAI header");
-}
-
-void BamStandardIndex::WriteLinearOffsets(const int& refId, BaiLinearOffsetVector& linearOffsets) {
-
-    // make sure linear offsets are sorted before writing & saving summary
-    SortLinearOffsets(linearOffsets);
-
-    int64_t numBytesWritten = 0;
-
-    // write number of linear offsets
-    int32_t offsetCount = linearOffsets.size();
-    if ( m_isBigEndian ) SwapEndian_32(offsetCount);
-    numBytesWritten += m_resources.Device->Write((const char*)&offsetCount, sizeof(offsetCount));
-
-    // save summary for reference's linear offsets
-    SaveLinearOffsetsSummary(refId, linearOffsets.size());
-
-    // iterate over linear offsets
-    BaiLinearOffsetVector::const_iterator offsetIter = linearOffsets.begin();
-    BaiLinearOffsetVector::const_iterator offsetEnd  = linearOffsets.end();
-    for ( ; offsetIter != offsetEnd; ++offsetIter ) {
-
-        // write linear offset
-        uint64_t linearOffset = (*offsetIter);
-        if ( m_isBigEndian ) SwapEndian_64(linearOffset);
-        numBytesWritten += m_resources.Device->Write((const char*)&linearOffset, sizeof(linearOffset));
-    }
-
-    if ( numBytesWritten != (sizeof(offsetCount) + linearOffsets.size()*sizeof(uint64_t)) )
-        throw BamException("BamStandardIndex::WriteLinearOffsets", "could not write BAI linear offsets");
-}
-
-void BamStandardIndex::WriteReferenceEntry(BaiReferenceEntry& refEntry) {
-    WriteBins(refEntry.ID, refEntry.Bins);
-    WriteLinearOffsets(refEntry.ID, refEntry.LinearOffsets);
-}
diff --git a/bamtools/src/api/internal/index/BamStandardIndex_p.h b/bamtools/src/api/internal/index/BamStandardIndex_p.h
deleted file mode 100644
index 273d56e..0000000
--- a/bamtools/src/api/internal/index/BamStandardIndex_p.h
+++ /dev/null
@@ -1,237 +0,0 @@
-// ***************************************************************************
-// BamStandardIndex.h (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 November 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides index operations for the standardized BAM index format (".bai")
-// ***************************************************************************
-
-#ifndef BAM_STANDARD_INDEX_FORMAT_H
-#define BAM_STANDARD_INDEX_FORMAT_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail.  This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-
-#include "api/BamAux.h"
-#include "api/BamIndex.h"
-#include "api/IBamIODevice.h"
-#include <map>
-#include <set>
-#include <string>
-#include <vector>
-
-namespace BamTools {
-namespace Internal {
-
-// -----------------------------------------------------------------------------
-// BamStandardIndex data structures
-
-// defines start and end of a contiguous run of alignments
-struct BaiAlignmentChunk {
-
-    // data members
-    uint64_t Start;
-    uint64_t Stop;
-
-    // constructor
-    BaiAlignmentChunk(const uint64_t& start = 0,
-                      const uint64_t& stop = 0)
-        : Start(start)
-        , Stop(stop)
-    { }
-};
-
-// comparison operator (for sorting)
-inline
-bool operator<(const BaiAlignmentChunk& lhs, const BaiAlignmentChunk& rhs) {
-    return lhs.Start < rhs.Start;
-}
-
-// convenience typedef for a list of all alignment 'chunks' in a BAI bin
-typedef std::vector<BaiAlignmentChunk> BaiAlignmentChunkVector;
-
-// convenience typedef for a map of all BAI bins in a reference (ID => chunks)
-typedef std::map<uint32_t, BaiAlignmentChunkVector> BaiBinMap;
-
-// convenience typedef for a list of all 'linear offsets' in a reference
-typedef std::vector<uint64_t> BaiLinearOffsetVector;
-
-// contains all fields necessary for building, loading, & writing
-// full BAI index data for a single reference
-struct BaiReferenceEntry {
-
-    // data members
-    int32_t ID;
-    BaiBinMap Bins;
-    BaiLinearOffsetVector LinearOffsets;
-
-    // ctor
-    BaiReferenceEntry(const int32_t& id = -1)
-        : ID(id)
-    { }
-};
-
-// provides (persistent) summary of BaiReferenceEntry's index data
-struct BaiReferenceSummary {
-
-    // data members
-    int NumBins;
-    int NumLinearOffsets;
-    uint64_t FirstBinFilePosition;
-    uint64_t FirstLinearOffsetFilePosition;
-
-    // ctor
-    BaiReferenceSummary(void)
-        : NumBins(0)
-        , NumLinearOffsets(0)
-        , FirstBinFilePosition(0)
-        , FirstLinearOffsetFilePosition(0)
-    { }
-};
-
-// convenience typedef for describing a full BAI index file summary
-typedef std::vector<BaiReferenceSummary> BaiFileSummary;
-
-// end BamStandardIndex data structures
-// -----------------------------------------------------------------------------
-
-class BamStandardIndex : public BamIndex {
-
-    // ctor & dtor
-    public:
-        BamStandardIndex(Internal::BamReaderPrivate* reader);
-        ~BamStandardIndex(void);
-
-    // BamIndex implementation
-    public:
-        // builds index from associated BAM file & writes out to index file
-        bool Create(void);
-        // returns whether reference has alignments or no
-        bool HasAlignments(const int& referenceID) const;
-        // attempts to use index data to jump to @region, returns success/fail
-        // a "successful" jump indicates no error, but not whether this region has data
-        //   * thus, the method sets a flag to indicate whether there are alignments
-        //     available after the jump position
-        bool Jump(const BamTools::BamRegion& region, bool* hasAlignmentsInRegion);
-        // loads existing data from file into memory
-        bool Load(const std::string& filename);
-        BamIndex::IndexType Type(void) const { return BamIndex::STANDARD; }
-    public:
-        // returns format's file extension
-        static const std::string Extension(void);
-
-    // internal methods
-    private:
-
-        // index file ops
-        void CheckMagicNumber(void);
-        void CloseFile(void);
-        bool IsDeviceOpen(void) const;
-        void OpenFile(const std::string& filename, IBamIODevice::OpenMode mode);
-        void Seek(const int64_t& position, const int origin);
-        int64_t Tell(void) const;
-
-        // BAI index building methods
-        void ClearReferenceEntry(BaiReferenceEntry& refEntry);
-        void SaveAlignmentChunkToBin(BaiBinMap& binMap,
-                                     const uint32_t& currentBin,
-                                     const uint64_t& currentOffset,
-                                     const uint64_t& lastOffset);
-        void SaveLinearOffsetEntry(BaiLinearOffsetVector& offsets,
-                                   const int& alignmentStartPosition,
-                                   const int& alignmentStopPosition,
-                                   const uint64_t& lastOffset);
-
-        // random-access methods
-        void AdjustRegion(const BamRegion& region, uint32_t& begin, uint32_t& end);
-        void CalculateCandidateBins(const uint32_t& begin,
-                                    const uint32_t& end,
-                                    std::set<uint16_t>& candidateBins);
-        void CalculateCandidateOffsets(const BaiReferenceSummary& refSummary,
-                                       const uint64_t& minOffset,
-                                       std::set<uint16_t>& candidateBins,
-                                       std::vector<int64_t>& offsets);
-        uint64_t CalculateMinOffset(const BaiReferenceSummary& refSummary, const uint32_t& begin);
-        void GetOffset(const BamRegion& region, int64_t& offset, bool* hasAlignmentsInRegion);
-        uint64_t LookupLinearOffset(const BaiReferenceSummary& refSummary, const int& index);
-
-        // BAI summary (create/load) methods
-        void ReserveForSummary(const int& numReferences);
-        void SaveBinsSummary(const int& refId, const int& numBins);
-        void SaveLinearOffsetsSummary(const int& refId, const int& numLinearOffsets);
-        void SkipBins(const int& numBins);
-        void SkipLinearOffsets(const int& numLinearOffsets);
-        void SummarizeBins(BaiReferenceSummary& refSummary);
-        void SummarizeIndexFile(void);
-        void SummarizeLinearOffsets(BaiReferenceSummary& refSummary);
-        void SummarizeReference(BaiReferenceSummary& refSummary);
-
-        // BAI full index input methods
-        void ReadBinID(uint32_t& binId);
-        void ReadBinIntoBuffer(uint32_t& binId, int32_t& numAlignmentChunks);
-        void ReadIntoBuffer(const unsigned int& bytesRequested);
-        void ReadLinearOffset(uint64_t& linearOffset);
-        void ReadNumAlignmentChunks(int& numAlignmentChunks);
-        void ReadNumBins(int& numBins);
-        void ReadNumLinearOffsets(int& numLinearOffsets);
-        void ReadNumReferences(int& numReferences);
-
-        // BAI full index output methods
-        void MergeAlignmentChunks(BaiAlignmentChunkVector& chunks);
-        void SortLinearOffsets(BaiLinearOffsetVector& linearOffsets);
-        void WriteAlignmentChunk(const BaiAlignmentChunk& chunk);
-        void WriteAlignmentChunks(BaiAlignmentChunkVector& chunks);
-        void WriteBin(const uint32_t& binId, BaiAlignmentChunkVector& chunks);
-        void WriteBins(const int& refId, BaiBinMap& bins);
-        void WriteHeader(void);
-        void WriteLinearOffsets(const int& refId, BaiLinearOffsetVector& linearOffsets);
-        void WriteReferenceEntry(BaiReferenceEntry& refEntry);
-
-    // data members
-    private:
-        bool m_isBigEndian;
-        BaiFileSummary m_indexFileSummary;
-
-        // our input buffer
-        unsigned int m_bufferLength;
-        struct RaiiWrapper {
-            IBamIODevice* Device;
-            char* Buffer;
-            RaiiWrapper(void);
-            ~RaiiWrapper(void);
-        };
-        RaiiWrapper m_resources;
-
-    // static methods
-    private:
-        // checks if the buffer is large enough to accomodate the requested size
-        static void CheckBufferSize(char*& buffer,
-                                    unsigned int& bufferLength,
-                                    const unsigned int& requestedBytes);
-        // checks if the buffer is large enough to accomodate the requested size
-        static void CheckBufferSize(unsigned char*& buffer,
-                                    unsigned int& bufferLength,
-                                    const unsigned int& requestedBytes);
-    // static constants
-    private:
-        static const int MAX_BIN;
-        static const int BAM_LIDX_SHIFT;
-        static const std::string BAI_EXTENSION;
-        static const char* const BAI_MAGIC;
-        static const int SIZEOF_ALIGNMENTCHUNK;
-        static const int SIZEOF_BINCORE;
-        static const int SIZEOF_LINEAROFFSET;
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // BAM_STANDARD_INDEX_FORMAT_H
diff --git a/bamtools/src/api/internal/index/BamToolsIndex_p.cpp b/bamtools/src/api/internal/index/BamToolsIndex_p.cpp
deleted file mode 100644
index bb09bc9..0000000
--- a/bamtools/src/api/internal/index/BamToolsIndex_p.cpp
+++ /dev/null
@@ -1,642 +0,0 @@
-// ***************************************************************************
-// BamToolsIndex.cpp (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 November 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides index operations for the BamTools index format (".bti")
-// ***************************************************************************
-
-#include "api/BamAlignment.h"
-#include "api/internal/bam/BamReader_p.h"
-#include "api/internal/index/BamToolsIndex_p.h"
-#include "api/internal/io/BamDeviceFactory_p.h"
-#include "api/internal/io/BgzfStream_p.h"
-#include "api/internal/utils/BamException_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#include <cstdio>
-#include <cstdlib>
-#include <cstring>
-#include <algorithm>
-#include <iostream>
-#include <iterator>
-#include <map>
-using namespace std;
-
-// --------------------------------
-// static BamToolsIndex constants
-// --------------------------------
-
-const uint32_t BamToolsIndex::DEFAULT_BLOCK_LENGTH = 1000;
-const string BamToolsIndex::BTI_EXTENSION     = ".bti";
-const char* const BamToolsIndex::BTI_MAGIC    = "BTI\1";
-const int BamToolsIndex::SIZEOF_BLOCK         = sizeof(int32_t)*2 + sizeof(int64_t);
-
-// ----------------------------
-// RaiiWrapper implementation
-// ----------------------------
-
-BamToolsIndex::RaiiWrapper::RaiiWrapper(void)
-    : Device(0)
-{ }
-
-BamToolsIndex::RaiiWrapper::~RaiiWrapper(void) {
-    if ( Device ) {
-        Device->Close();
-        delete Device;
-        Device = 0;
-    }
-}
-
-// ------------------------------
-// BamToolsIndex implementation
-// ------------------------------
-
-// ctor
-BamToolsIndex::BamToolsIndex(Internal::BamReaderPrivate* reader)
-    : BamIndex(reader)
-    , m_blockSize(BamToolsIndex::DEFAULT_BLOCK_LENGTH)
-    , m_inputVersion(0)
-    , m_outputVersion(BTI_2_0) // latest version - used for writing new index files
-{
-    m_isBigEndian = BamTools::SystemIsBigEndian();
-}
-
-// dtor
-BamToolsIndex::~BamToolsIndex(void) {
-    CloseFile();
-}
-
-void BamToolsIndex::CheckMagicNumber(void) {
-
-    // read magic number
-    char magic[4];
-    const int64_t numBytesRead = m_resources.Device->Read(magic, 4);
-    if ( numBytesRead != 4 )
-        throw BamException("BamToolsIndex::CheckMagicNumber", "could not read BTI magic number");
-
-    // validate expected magic number
-    if ( strncmp(magic, BamToolsIndex::BTI_MAGIC, 4) != 0 )
-        throw BamException("BamToolsIndex::CheckMagicNumber", "invalid BTI magic number");
-}
-
-// check index file version, return true if OK
-void BamToolsIndex::CheckVersion(void) {
-
-    // read version from file
-    const int64_t numBytesRead = m_resources.Device->Read((char*)&m_inputVersion, sizeof(m_inputVersion));
-    if ( numBytesRead != sizeof(m_inputVersion) )
-        throw BamException("BamToolsIndex::CheckVersion", "could not read format version");
-    if ( m_isBigEndian ) SwapEndian_32(m_inputVersion);
-
-    // if version is negative, or zero
-    if ( m_inputVersion <= 0 )
-        throw BamException("BamToolsIndex::CheckVersion", "invalid format version");
-
-    // if version is newer than can be supported by this version of bamtools
-    else if ( m_inputVersion > m_outputVersion ) {
-        const string message = "unsupported format: this index was created by a newer version of BamTools. "
-                               "Update your local version of BamTools to use the index file.";
-        throw BamException("BamToolsIndex::CheckVersion", message);
-    }
-
-    // ------------------------------------------------------------------
-    // check for deprecated, unsupported versions
-    // (the format had to be modified to accomodate a particular bug fix)
-
-    // Version 2.0: introduced support for half-open intervals, instead of the old closed intervals
-    //   respondBy: throwing exception - we're not going to try to handle the old BTI files.
-    else if ( (Version)m_inputVersion < BamToolsIndex::BTI_2_0 ) {
-        const string message = "unsupported format: this version of the index may not properly handle "
-                               "coordinate intervals. Please run 'bamtools index -bti -in yourData.bam' "
-                               "to generate an up-to-date, fixed BTI file.";
-        throw BamException("BamToolsIndex::CheckVersion", message);
-    }
-}
-
-void BamToolsIndex::ClearReferenceEntry(BtiReferenceEntry& refEntry) {
-    refEntry.ID = -1;
-    refEntry.Blocks.clear();
-}
-
-void BamToolsIndex::CloseFile(void) {
-    if ( IsDeviceOpen() ) {
-        m_resources.Device->Close();
-        delete m_resources.Device;
-        m_resources.Device = 0;
-    }
-    m_indexFileSummary.clear();
-}
-
-// builds index from associated BAM file & writes out to index file
-bool BamToolsIndex::Create(void) {
-
-    // skip if BamReader is invalid or not open
-    if ( m_reader == 0 || !m_reader->IsOpen() ) {
-        SetErrorString("BamToolsIndex::Create", "could not create index: reader is not open");
-        return false;
-    }
-
-    // rewind BamReader
-    if ( !m_reader->Rewind() ) {
-        const string readerError = m_reader->GetErrorString();
-        const string message = "could not create index: \n\t" + readerError;
-        SetErrorString("BamToolsIndex::Create", message);
-        return false;
-    }
-
-    try {
-        // open new index file (read & write)
-        const string indexFilename = m_reader->Filename() + Extension();
-        OpenFile(indexFilename, IBamIODevice::ReadWrite);
-
-        // initialize BtiFileSummary with number of references
-        const int& numReferences = m_reader->GetReferenceCount();
-        InitializeFileSummary(numReferences);
-
-        // intialize output file header
-        WriteHeader();
-
-        // index building markers
-        uint32_t currentBlockCount      = 0;
-        int64_t currentAlignmentOffset  = m_reader->Tell();
-        int32_t blockRefId              = -1;
-        int32_t blockMaxEndPosition     = -1;
-        int64_t blockStartOffset        = currentAlignmentOffset;
-        int32_t blockStartPosition      = -1;
-
-        // plow through alignments, storing index entries
-        BamAlignment al;
-        BtiReferenceEntry refEntry;
-        while ( m_reader->LoadNextAlignment(al) ) {
-
-            // if moved to new reference
-            if ( al.RefID != blockRefId ) {
-
-                // if first pass, check:
-                if ( currentBlockCount == 0 ) {
-
-                    // write any empty references up to (but not including) al.RefID
-                    for ( int i = 0; i < al.RefID; ++i )
-                        WriteReferenceEntry( BtiReferenceEntry(i) );
-                }
-
-                // not first pass:
-                else {
-
-                    // store previous BTI block data in reference entry
-                    const BtiBlock block(blockMaxEndPosition, blockStartOffset, blockStartPosition);
-                    refEntry.Blocks.push_back(block);
-
-                    // write reference entry, then clear
-                    WriteReferenceEntry(refEntry);
-                    ClearReferenceEntry(refEntry);
-
-                    // write any empty references between (but not including)
-                    // the last blockRefID and current al.RefID
-                    for ( int i = blockRefId+1; i < al.RefID; ++i )
-                        WriteReferenceEntry( BtiReferenceEntry(i) );
-
-                    // reset block count
-                    currentBlockCount = 0;
-                }
-
-                // set ID for new reference entry
-                refEntry.ID = al.RefID;
-            }
-
-            // if beginning of block, update counters
-            if ( currentBlockCount == 0 ) {
-                blockRefId          = al.RefID;
-                blockStartOffset    = currentAlignmentOffset;
-                blockStartPosition  = al.Position;
-                blockMaxEndPosition = al.GetEndPosition();
-            }
-
-            // increment block counter
-            ++currentBlockCount;
-
-            // check end position
-            const int32_t alignmentEndPosition = al.GetEndPosition();
-            if ( alignmentEndPosition > blockMaxEndPosition )
-                blockMaxEndPosition = alignmentEndPosition;
-
-            // if block is full, get offset for next block, reset currentBlockCount
-            if ( currentBlockCount == m_blockSize ) {
-
-                // store previous block data in reference entry
-                const BtiBlock block(blockMaxEndPosition, blockStartOffset, blockStartPosition);
-                refEntry.Blocks.push_back(block);
-
-                // update markers
-                blockStartOffset  = m_reader->Tell();
-                currentBlockCount = 0;
-            }
-
-            // not the best name, but for the next iteration, this value will be the offset of the
-            // *current* alignment. this is necessary because we won't know if this next alignment
-            // is on a new reference until we actually read it
-            currentAlignmentOffset = m_reader->Tell();
-        }
-
-        // after finishing alignments, if any data was read, check:
-        if ( blockRefId >= 0 ) {
-
-            // store last BTI block data in reference entry
-            const BtiBlock block(blockMaxEndPosition, blockStartOffset, blockStartPosition);
-            refEntry.Blocks.push_back(block);
-
-            // write last reference entry, then clear
-            WriteReferenceEntry(refEntry);
-            ClearReferenceEntry(refEntry);
-
-            // then write any empty references remaining at end of file
-            for ( int i = blockRefId+1; i < numReferences; ++i )
-                WriteReferenceEntry( BtiReferenceEntry(i) );
-        }
-
-    } catch ( BamException& e ) {
-        m_errorString = e.what();
-        return false;
-    }
-
-    // rewind BamReader
-    if ( !m_reader->Rewind() ) {
-        const string readerError = m_reader->GetErrorString();
-        const string message = "could not create index: \n\t" + readerError;
-        SetErrorString("BamToolsIndex::Create", message);
-        return false;
-    }
-
-    // return success
-    return true;
-}
-
-// returns format's file extension
-const std::string BamToolsIndex::Extension(void) {
-    return BamToolsIndex::BTI_EXTENSION;
-}
-
-void BamToolsIndex::GetOffset(const BamRegion& region, int64_t& offset, bool* hasAlignmentsInRegion) {
-
-    // return false ref ID is not a valid index in file summary data
-    if ( region.LeftRefID < 0 || region.LeftRefID >= (int)m_indexFileSummary.size() )
-        throw BamException("BamToolsIndex::GetOffset", "invalid region requested");
-
-    // retrieve reference index data for left bound reference
-    BtiReferenceEntry refEntry(region.LeftRefID);
-    ReadReferenceEntry(refEntry);
-
-    // binary search for an overlapping block (may not be first one though)
-    bool found = false;
-    typedef BtiBlockVector::const_iterator BtiBlockConstIterator;
-    BtiBlockConstIterator blockFirst = refEntry.Blocks.begin();
-    BtiBlockConstIterator blockIter  = blockFirst;
-    BtiBlockConstIterator blockLast  = refEntry.Blocks.end();
-    iterator_traits<BtiBlockConstIterator>::difference_type count = distance(blockFirst, blockLast);
-    iterator_traits<BtiBlockConstIterator>::difference_type step;
-    while ( count > 0 ) {
-        blockIter = blockFirst;
-        step = count/2;
-        advance(blockIter, step);
-
-        const BtiBlock& block = (*blockIter);
-        if ( block.StartPosition <= region.RightPosition ) {
-            if ( block.MaxEndPosition > region.LeftPosition ) {
-                offset = block.StartOffset;
-                break;
-            }
-            blockFirst = ++blockIter;
-            count -= step+1;
-        }
-        else count = step;
-    }
-
-    // if we didn't search "off the end" of the blocks
-    if ( blockIter != blockLast ) {
-
-        // "walk back" until we've gone too far
-        while ( blockIter != blockFirst ) {
-            const BtiBlock& currentBlock = (*blockIter);
-
-            --blockIter;
-            const BtiBlock& previousBlock = (*blockIter);
-            if ( previousBlock.MaxEndPosition <= region.LeftPosition ) {
-                offset = currentBlock.StartOffset;
-                found = true;
-                break;
-            }
-        }
-
-        // if we walked all the way to first block, just return that and let the reader's
-        // region overlap parsing do the rest
-        if ( blockIter == blockFirst ) {
-            const BtiBlock& block = (*blockIter);
-            offset = block.StartOffset;
-            found = true;
-        }
-    }
-
-
-    // sets to false if blocks container is empty, or if no matching block could be found
-    *hasAlignmentsInRegion = found;
-}
-
-// returns whether reference has alignments or no
-bool BamToolsIndex::HasAlignments(const int& referenceID) const {
-    if ( referenceID < 0 || referenceID >= (int)m_indexFileSummary.size() )
-        return false;
-    const BtiReferenceSummary& refSummary = m_indexFileSummary.at(referenceID);
-    return ( refSummary.NumBlocks > 0 );
-}
-
-// pre-allocates space for each reference's summary data
-void BamToolsIndex::InitializeFileSummary(const int& numReferences) {
-    m_indexFileSummary.clear();
-    for ( int i = 0; i < numReferences; ++i )
-        m_indexFileSummary.push_back( BtiReferenceSummary() );
-}
-
-// returns true if the index stream is open
-bool BamToolsIndex::IsDeviceOpen(void) const {
-    if ( m_resources.Device == 0 )
-        return false;
-    return m_resources.Device->IsOpen();
-}
-
-// attempts to use index data to jump to @region, returns success/fail
-// a "successful" jump indicates no error, but not whether this region has data
-//   * thus, the method sets a flag to indicate whether there are alignments
-//     available after the jump position
-bool BamToolsIndex::Jump(const BamTools::BamRegion& region, bool* hasAlignmentsInRegion) {
-
-    // clear flag
-    *hasAlignmentsInRegion = false;
-
-    // skip if invalid reader or not open
-    if ( m_reader == 0 || !m_reader->IsOpen() ) {
-        SetErrorString("BamToolsIndex::Jump", "could not jump: reader is not open");
-        return false;
-    }
-
-    // make sure left-bound position is valid
-    const RefVector& references = m_reader->GetReferenceData();
-    if ( region.LeftPosition > references.at(region.LeftRefID).RefLength ) {
-        SetErrorString("BamToolsIndex::Jump", "could not create index: invalid region requested");
-        return false;
-    }
-
-    // calculate nearest offset to jump to
-    int64_t offset;
-    try {
-        GetOffset(region, offset, hasAlignmentsInRegion);
-    } catch ( BamException& e ) {
-        m_errorString = e.what();
-        return false;
-    }
-
-    // return success/failure of seek
-    return m_reader->Seek(offset);
-}
-
-// loads existing data from file into memory
-bool BamToolsIndex::Load(const std::string& filename) {
-
-    try {
-
-        // attempt to open file (read-only)
-        OpenFile(filename, IBamIODevice::ReadOnly);
-
-        // load metadata & generate in-memory summary
-        LoadHeader();
-        LoadFileSummary();
-
-        // return success
-        return true;
-
-    } catch ( BamException& e ) {
-        m_errorString = e.what();
-        return false;
-    }
-}
-
-void BamToolsIndex::LoadFileSummary(void) {
-
-    // load number of reference sequences
-    int numReferences;
-    LoadNumReferences(numReferences);
-
-    // initialize file summary data
-    InitializeFileSummary(numReferences);
-
-    // load summary for each reference
-    BtiFileSummary::iterator summaryIter = m_indexFileSummary.begin();
-    BtiFileSummary::iterator summaryEnd  = m_indexFileSummary.end();
-    for ( ; summaryIter != summaryEnd; ++summaryIter )
-        LoadReferenceSummary(*summaryIter);
-}
-
-void BamToolsIndex::LoadHeader(void) {
-
-    // check BTI file metadata
-    CheckMagicNumber();
-    CheckVersion();
-
-    // use file's BTI block size to set member variable
-    const int64_t numBytesRead = m_resources.Device->Read((char*)&m_blockSize, sizeof(m_blockSize));
-    if ( m_isBigEndian ) SwapEndian_32(m_blockSize);
-    if ( numBytesRead != sizeof(m_blockSize) )
-        throw BamException("BamToolsIndex::LoadHeader", "could not read BTI block size");
-}
-
-void BamToolsIndex::LoadNumBlocks(int& numBlocks) {
-    const int64_t numBytesRead = m_resources.Device->Read((char*)&numBlocks, sizeof(numBlocks));
-    if ( m_isBigEndian ) SwapEndian_32(numBlocks);
-    if ( numBytesRead != sizeof(numBlocks) )
-        throw BamException("BamToolsIndex::LoadNumBlocks", "could not read number of BTI blocks");
-}
-
-void BamToolsIndex::LoadNumReferences(int& numReferences) {
-    const int64_t numBytesRead = m_resources.Device->Read((char*)&numReferences, sizeof(numReferences));
-    if ( m_isBigEndian ) SwapEndian_32(numReferences);
-    if ( numBytesRead != sizeof(numReferences) )
-        throw BamException("BamToolsIndex::LoadNumReferences", "could not read number of references");
-}
-
-void BamToolsIndex::LoadReferenceSummary(BtiReferenceSummary& refSummary) {
-
-    // load number of blocks
-    int numBlocks;
-    LoadNumBlocks(numBlocks);
-
-    // store block summary data for this reference
-    refSummary.NumBlocks = numBlocks;
-    refSummary.FirstBlockFilePosition = Tell();
-
-    // skip reference's blocks
-    SkipBlocks(numBlocks);
-}
-
-void BamToolsIndex::OpenFile(const std::string& filename, IBamIODevice::OpenMode mode) {
-
-    // make sure any previous index file is closed
-    CloseFile();
-
-    m_resources.Device = BamDeviceFactory::CreateDevice(filename);
-    if ( m_resources.Device == 0 ) {
-        const string message = string("could not open file: ") + filename;
-        throw BamException("BamStandardIndex::OpenFile", message);
-    }
-
-    // attempt to open file
-    m_resources.Device->Open(mode);
-    if ( !IsDeviceOpen() ) {
-        const string message = string("could not open file: ") + filename;
-        throw BamException("BamToolsIndex::OpenFile", message);
-    }
-}
-
-void BamToolsIndex::ReadBlock(BtiBlock& block) {
-
-    // read in block data members
-    int64_t numBytesRead = 0;
-    numBytesRead += m_resources.Device->Read((char*)&block.MaxEndPosition, sizeof(block.MaxEndPosition));
-    numBytesRead += m_resources.Device->Read((char*)&block.StartOffset,    sizeof(block.StartOffset));
-    numBytesRead += m_resources.Device->Read((char*)&block.StartPosition,  sizeof(block.StartPosition));
-
-    // swap endian-ness if necessary
-    if ( m_isBigEndian ) {
-        SwapEndian_32(block.MaxEndPosition);
-        SwapEndian_64(block.StartOffset);
-        SwapEndian_32(block.StartPosition);
-    }
-
-    // check block read ok
-    const int expectedBytes = sizeof(block.MaxEndPosition) +
-                              sizeof(block.StartOffset) +
-                              sizeof(block.StartPosition);
-    if ( numBytesRead != expectedBytes )
-        throw BamException("BamToolsIndex::ReadBlock", "could not read block");
-}
-
-void BamToolsIndex::ReadBlocks(const BtiReferenceSummary& refSummary, BtiBlockVector& blocks) {
-
-    // prep blocks container
-    blocks.clear();
-    blocks.reserve(refSummary.NumBlocks);
-
-    // skip to first block entry
-    Seek( refSummary.FirstBlockFilePosition, SEEK_SET );
-
-    // read & store block entries
-    BtiBlock block;
-    for ( int i = 0; i < refSummary.NumBlocks; ++i ) {
-        ReadBlock(block);
-        blocks.push_back(block);
-    }
-}
-
-void BamToolsIndex::ReadReferenceEntry(BtiReferenceEntry& refEntry) {
-
-    // return false if refId not valid index in file summary structure
-    if ( refEntry.ID < 0 || refEntry.ID >= (int)m_indexFileSummary.size() )
-        throw BamException("BamToolsIndex::ReadReferenceEntry", "invalid reference requested");
-
-    // use index summary to assist reading the reference's BTI blocks
-    const BtiReferenceSummary& refSummary = m_indexFileSummary.at(refEntry.ID);
-    ReadBlocks(refSummary, refEntry.Blocks);
-}
-
-void BamToolsIndex::Seek(const int64_t& position, const int origin) {
-    if ( !m_resources.Device->Seek(position, origin) )
-        throw BamException("BamToolsIndex::Seek", "could not seek in BAI file");
-}
-
-void BamToolsIndex::SkipBlocks(const int& numBlocks) {
-    Seek( numBlocks*BamToolsIndex::SIZEOF_BLOCK, SEEK_CUR );
-}
-
-int64_t BamToolsIndex::Tell(void) const {
-    return m_resources.Device->Tell();
-}
-
-void BamToolsIndex::WriteBlock(const BtiBlock& block) {
-
-    // copy entry data
-    int32_t maxEndPosition = block.MaxEndPosition;
-    int64_t startOffset    = block.StartOffset;
-    int32_t startPosition  = block.StartPosition;
-
-    // swap endian-ness if necessary
-    if ( m_isBigEndian ) {
-        SwapEndian_32(maxEndPosition);
-        SwapEndian_64(startOffset);
-        SwapEndian_32(startPosition);
-    }
-
-    // write the reference index entry
-    int64_t numBytesWritten = 0;
-    numBytesWritten += m_resources.Device->Write((const char*)&maxEndPosition, sizeof(maxEndPosition));
-    numBytesWritten += m_resources.Device->Write((const char*)&startOffset,    sizeof(startOffset));
-    numBytesWritten += m_resources.Device->Write((const char*)&startPosition,  sizeof(startPosition));
-
-    // check block written ok
-    const int expectedBytes = sizeof(maxEndPosition) +
-                              sizeof(startOffset) +
-                              sizeof(startPosition);
-    if ( numBytesWritten != expectedBytes )
-        throw BamException("BamToolsIndex::WriteBlock", "could not write BTI block");
-}
-
-void BamToolsIndex::WriteBlocks(const BtiBlockVector& blocks) {
-    BtiBlockVector::const_iterator blockIter = blocks.begin();
-    BtiBlockVector::const_iterator blockEnd  = blocks.end();
-    for ( ; blockIter != blockEnd; ++blockIter )
-        WriteBlock(*blockIter);
-}
-
-void BamToolsIndex::WriteHeader(void) {
-
-    int64_t numBytesWritten = 0 ;
-
-    // write BTI index format 'magic number'
-    numBytesWritten += m_resources.Device->Write(BamToolsIndex::BTI_MAGIC, 4);
-
-    // write BTI index format version
-    int32_t currentVersion = (int32_t)m_outputVersion;
-    if ( m_isBigEndian ) SwapEndian_32(currentVersion);
-    numBytesWritten += m_resources.Device->Write((const char*)&currentVersion, sizeof(currentVersion));
-
-    // write block size
-    uint32_t blockSize = m_blockSize;
-    if ( m_isBigEndian ) SwapEndian_32(blockSize);
-    numBytesWritten += m_resources.Device->Write((const char*)&blockSize, sizeof(blockSize));
-
-    // write number of references
-    int32_t numReferences = m_indexFileSummary.size();
-    if ( m_isBigEndian ) SwapEndian_32(numReferences);
-    numBytesWritten += m_resources.Device->Write((const char*)&numReferences, sizeof(numReferences));
-
-    // check header written ok
-    const int expectedBytes = 4 +
-                              sizeof(currentVersion) +
-                              sizeof(blockSize) +
-                              sizeof(numReferences);
-    if ( numBytesWritten != expectedBytes )
-        throw BamException("BamToolsIndex::WriteHeader", "could not write BTI header");
-}
-
-void BamToolsIndex::WriteReferenceEntry(const BtiReferenceEntry& refEntry) {
-
-    // write number of blocks this reference
-    uint32_t numBlocks = refEntry.Blocks.size();
-    if ( m_isBigEndian ) SwapEndian_32(numBlocks);
-    const int64_t numBytesWritten = m_resources.Device->Write((const char*)&numBlocks, sizeof(numBlocks));
-    if ( numBytesWritten != sizeof(numBlocks) )
-        throw BamException("BamToolsIndex::WriteReferenceEntry", "could not write number of blocks");
-
-    // write actual block entries
-    WriteBlocks(refEntry.Blocks);
-}
diff --git a/bamtools/src/api/internal/index/BamToolsIndex_p.h b/bamtools/src/api/internal/index/BamToolsIndex_p.h
deleted file mode 100644
index c1e1aa0..0000000
--- a/bamtools/src/api/internal/index/BamToolsIndex_p.h
+++ /dev/null
@@ -1,186 +0,0 @@
-// ***************************************************************************
-// BamToolsIndex.h (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 November 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides index operations for the BamTools index format (".bti")
-// ***************************************************************************
-
-#ifndef BAMTOOLS_INDEX_FORMAT_H
-#define BAMTOOLS_INDEX_FORMAT_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail.  This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-
-#include "api/BamAux.h"
-#include "api/BamIndex.h"
-#include "api/IBamIODevice.h"
-#include <map>
-#include <string>
-#include <vector>
-
-namespace BamTools {
-namespace Internal {
-
-// contains data for each 'block' in a BTI index
-struct BtiBlock {
-
-    // data members
-    int32_t MaxEndPosition;
-    int64_t StartOffset;
-    int32_t StartPosition;
-
-    // ctor
-    BtiBlock(const int32_t& maxEndPosition = 0,
-             const int64_t& startOffset    = 0,
-             const int32_t& startPosition  = 0)
-        : MaxEndPosition(maxEndPosition)
-        , StartOffset(startOffset)
-        , StartPosition(startPosition)
-    { }
-};
-
-// convenience typedef for describing a a list of BTI blocks on a reference
-typedef std::vector<BtiBlock> BtiBlockVector;
-
-// contains all fields necessary for building, loading, & writing
-// full BTI index data for a single reference
-struct BtiReferenceEntry {
-
-    // data members
-    int32_t ID;
-    BtiBlockVector Blocks;
-
-    // ctor
-    BtiReferenceEntry(const int& id = -1)
-        : ID(id)
-    { }
-};
-
-// provides (persistent) summary of BtiReferenceEntry's index data
-struct BtiReferenceSummary {
-
-    // data members
-    int NumBlocks;
-    uint64_t FirstBlockFilePosition;
-
-    // ctor
-    BtiReferenceSummary(void)
-        : NumBlocks(0)
-        , FirstBlockFilePosition(0)
-    { }
-};
-
-// convenience typedef for describing a full BTI index file summary
-typedef std::vector<BtiReferenceSummary> BtiFileSummary;
-
-class BamToolsIndex : public BamIndex {
-
-    // keep a list of any supported versions here
-    // (might be useful later to handle any 'legacy' versions if the format changes)
-    // listed for example like: BTI_1_0 = 1, BTI_1_1 = 2, BTI_1_2 = 3, BTI_2_0 = 4, and so on
-    //
-    // so a change introduced in BTI_1_2 may be handled from then on by:
-    //
-    // if ( indexVersion >= BTI_1_2 )
-    //   do something new
-    // else
-    //   do the old thing
-    enum Version { BTI_1_0 = 1
-                 , BTI_1_1
-                 , BTI_1_2
-                 , BTI_2_0
-                 };
-
-    // ctor & dtor
-    public:
-        BamToolsIndex(Internal::BamReaderPrivate* reader);
-        ~BamToolsIndex(void);
-
-    // BamIndex implementation
-    public:
-        // builds index from associated BAM file & writes out to index file
-        bool Create(void);
-        // returns whether reference has alignments or no
-        bool HasAlignments(const int& referenceID) const;
-        // attempts to use index data to jump to @region, returns success/fail
-        // a "successful" jump indicates no error, but not whether this region has data
-        //   * thus, the method sets a flag to indicate whether there are alignments
-        //     available after the jump position
-        bool Jump(const BamTools::BamRegion& region, bool* hasAlignmentsInRegion);
-        // loads existing data from file into memory
-        bool Load(const std::string& filename);
-        BamIndex::IndexType Type(void) const { return BamIndex::BAMTOOLS; }
-    public:
-        // returns format's file extension
-        static const std::string Extension(void);
-
-    // internal methods
-    private:
-
-        // index file ops
-        void CheckMagicNumber(void);
-        void CheckVersion(void);
-        void CloseFile(void);
-        bool IsDeviceOpen(void) const;
-        void OpenFile(const std::string& filename, IBamIODevice::OpenMode mode);
-        void Seek(const int64_t& position, const int origin);
-        int64_t Tell(void) const;
-
-        // index-creation methods
-        void ClearReferenceEntry(BtiReferenceEntry& refEntry);
-        void WriteBlock(const BtiBlock& block);
-        void WriteBlocks(const BtiBlockVector& blocks);
-        void WriteHeader(void);
-        void WriteReferenceEntry(const BtiReferenceEntry& refEntry);
-
-        // random-access methods
-        void GetOffset(const BamRegion& region, int64_t& offset, bool* hasAlignmentsInRegion);
-        void ReadBlock(BtiBlock& block);
-        void ReadBlocks(const BtiReferenceSummary& refSummary, BtiBlockVector& blocks);
-        void ReadReferenceEntry(BtiReferenceEntry& refEntry);
-
-        // BTI summary data methods
-        void InitializeFileSummary(const int& numReferences);
-        void LoadFileSummary(void);
-        void LoadHeader(void);
-        void LoadNumBlocks(int& numBlocks);
-        void LoadNumReferences(int& numReferences);
-        void LoadReferenceSummary(BtiReferenceSummary& refSummary);
-        void SkipBlocks(const int& numBlocks);
-
-    // data members
-    private:
-        bool  m_isBigEndian;
-        BtiFileSummary m_indexFileSummary;
-        uint32_t m_blockSize;
-        int32_t m_inputVersion; // Version is serialized as int
-        Version m_outputVersion;
-
-        struct RaiiWrapper {
-            IBamIODevice* Device;
-            RaiiWrapper(void);
-            ~RaiiWrapper(void);
-        };
-        RaiiWrapper m_resources;
-
-    // static constants
-    private:
-        static const uint32_t DEFAULT_BLOCK_LENGTH;
-        static const std::string BTI_EXTENSION;
-        static const char* const BTI_MAGIC;
-        static const int SIZEOF_BLOCK;
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // BAMTOOLS_INDEX_FORMAT_H
diff --git a/bamtools/src/api/internal/index/CMakeLists.txt b/bamtools/src/api/internal/index/CMakeLists.txt
deleted file mode 100644
index d6a7df6..0000000
--- a/bamtools/src/api/internal/index/CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-# ==========================
-# BamTools CMakeLists.txt
-# (c) 2011 Derek Barnett
-#
-# src/api/internal/index
-# ==========================
-
-set( InternalIndexDir "${InternalDir}/index" )
-
-set( InternalIndexSources
-        ${InternalIndexDir}/BamIndexFactory_p.cpp
-        ${InternalIndexDir}/BamStandardIndex_p.cpp
-        ${InternalIndexDir}/BamToolsIndex_p.cpp
-
-        PARENT_SCOPE # <-- leave this last
-)
-
diff --git a/bamtools/src/api/internal/io/BamDeviceFactory_p.cpp b/bamtools/src/api/internal/io/BamDeviceFactory_p.cpp
deleted file mode 100644
index f9c7694..0000000
--- a/bamtools/src/api/internal/io/BamDeviceFactory_p.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-// ***************************************************************************
-// BamDeviceFactory_p.cpp (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 25 September 2011 (DB)
-// ---------------------------------------------------------------------------
-// Creates built-in concrete implementations of IBamIODevices
-// ***************************************************************************
-
-#include "api/internal/io/BamDeviceFactory_p.h"
-#include "api/internal/io/BamFile_p.h"
-#include "api/internal/io/BamFtp_p.h"
-#include "api/internal/io/BamHttp_p.h"
-#include "api/internal/io/BamPipe_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#include <iostream>
-using namespace std;
-
-IBamIODevice* BamDeviceFactory::CreateDevice(const string& source) {
-
-    // check for requested pipe
-    if ( source == "-" || source == "stdin" || source == "stdout" )
-        return new BamPipe;
-
-    // check for HTTP prefix
-    if ( source.find("http://") == 0 )
-        return new BamHttp(source);
-
-    // check for FTP prefix
-    if ( source.find("ftp://") == 0 )
-        return new BamFtp(source);
-
-    // otherwise assume a "normal" file
-    return new BamFile(source);
-}
diff --git a/bamtools/src/api/internal/io/BamDeviceFactory_p.h b/bamtools/src/api/internal/io/BamDeviceFactory_p.h
deleted file mode 100644
index 1d48533..0000000
--- a/bamtools/src/api/internal/io/BamDeviceFactory_p.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// ***************************************************************************
-// BamDeviceFactory_p.h (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Creates built-in concrete implementations of IBamIODevices
-// ***************************************************************************
-
-#ifndef BAMDEVICEFACTORY_P_H
-#define BAMDEVICEFACTORY_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#include "api/IBamIODevice.h"
-#include <string>
-
-namespace BamTools {
-namespace Internal {
-
-class BamDeviceFactory {
-    public:
-        static IBamIODevice* CreateDevice(const std::string& source);
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // BAMDEVICEFACTORY_P_H
diff --git a/bamtools/src/api/internal/io/BamFile_p.cpp b/bamtools/src/api/internal/io/BamFile_p.cpp
deleted file mode 100644
index 990d9bf..0000000
--- a/bamtools/src/api/internal/io/BamFile_p.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-// ***************************************************************************
-// BamFile_p.cpp (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 November 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides BAM file-specific IO behavior
-// ***************************************************************************
-
-#include "api/internal/io/BamFile_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#include <cstdio>
-#include <iostream>
-using namespace std;
-
-BamFile::BamFile(const string& filename)
-    : ILocalIODevice()
-    , m_filename(filename)
-{ }
-
-BamFile::~BamFile(void) { }
-
-void BamFile::Close(void) {
-    if ( IsOpen() ) {
-        m_filename.clear();
-        ILocalIODevice::Close();
-    }
-}
-
-bool BamFile::IsRandomAccess(void) const {
-    return true;
-}
-
-bool BamFile::Open(const IBamIODevice::OpenMode mode) {
-
-    // make sure we're starting with a fresh file stream
-    Close();
-
-    // attempt to open FILE* depending on requested openmode
-    if ( mode == IBamIODevice::ReadOnly )
-        m_stream = fopen(m_filename.c_str(), "rb");
-    else if ( mode == IBamIODevice::WriteOnly )
-        m_stream = fopen(m_filename.c_str(), "wb");
-    else if ( mode == IBamIODevice::ReadWrite )
-        m_stream = fopen(m_filename.c_str(), "w+b");
-    else {
-        SetErrorString("BamFile::Open", "unknown open mode requested");
-        return false;
-    }
-
-    // check that we obtained a valid FILE*
-    if ( m_stream == 0 ) {
-        const string message_base = string("could not open file handle for ");
-        const string message = message_base + ( (m_filename.empty()) ? "empty filename" : m_filename );
-        SetErrorString("BamFile::Open", message);
-        return false;
-    }
-
-    // store current IO mode & return success
-    m_mode = mode;
-    return true;
-}
-
-bool BamFile::Seek(const int64_t& position, const int origin) {
-    BT_ASSERT_X( m_stream, "BamFile::Seek() - null stream" );
-    return ( fseek64(m_stream, position, origin) == 0 );
-}
diff --git a/bamtools/src/api/internal/io/BamFile_p.h b/bamtools/src/api/internal/io/BamFile_p.h
deleted file mode 100644
index ed61813..0000000
--- a/bamtools/src/api/internal/io/BamFile_p.h
+++ /dev/null
@@ -1,51 +0,0 @@
-// ***************************************************************************
-// BamFile_p.h (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 November 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides BAM file-specific IO behavior
-// ***************************************************************************
-
-#ifndef BAMFILE_P_H
-#define BAMFILE_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#include "api/internal/io/ILocalIODevice_p.h"
-#include <string>
-
-namespace BamTools {
-namespace Internal {
-
-class BamFile : public ILocalIODevice {
-
-    // ctor & dtor
-    public:
-        BamFile(const std::string& filename);
-        ~BamFile(void);
-
-    // ILocalIODevice implementation
-    public:
-        void Close(void);
-        bool IsRandomAccess(void) const;
-        bool Open(const IBamIODevice::OpenMode mode);
-        bool Seek(const int64_t& position, const int origin = SEEK_SET);
-
-    // data members
-    private:
-        std::string m_filename;
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // BAMFILE_P_H
diff --git a/bamtools/src/api/internal/io/BamFtp_p.cpp b/bamtools/src/api/internal/io/BamFtp_p.cpp
deleted file mode 100644
index b851401..0000000
--- a/bamtools/src/api/internal/io/BamFtp_p.cpp
+++ /dev/null
@@ -1,490 +0,0 @@
-// ***************************************************************************
-// BamFtp_p.cpp (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 8 December 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides reading/writing of BAM files on FTP server
-// ***************************************************************************
-
-#include "api/BamAux.h"
-#include "api/internal/io/BamFtp_p.h"
-#include "api/internal/io/TcpSocket_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#include <cctype>
-#include <cstdlib>
-#include <sstream>
-#include <vector>
-using namespace std;
-
-namespace BamTools {
-namespace Internal {
-
-// -----------
-// constants
-// -----------
-
-static const uint16_t FTP_PORT          = 21;
-static const string   FTP_PREFIX        = "ftp://";
-static const size_t   FTP_PREFIX_LENGTH = 6;
-static const string   FTP_NEWLINE       = "\r\n";
-
-static const string DEFAULT_USER = "anonymous";
-static const string DEFAULT_PASS = "anonymous@";
-
-static const string ABOR_CMD = "ABOR";
-static const string USER_CMD = "USER";
-static const string PASS_CMD = "PASS";
-static const string PASV_CMD = "PASV";
-static const string REIN_CMD = "REIN";
-static const string REST_CMD = "REST";
-static const string RETR_CMD = "RETR";
-static const string TYPE_CMD = "TYPE";
-
-static const char CMD_SEPARATOR  = ' ';
-static const char HOST_SEPARATOR = '/';
-static const char IP_SEPARATOR   = '.';
-
-static const char MULTILINE_CONTINUE = '-';
-
-static const char PASV_REPLY_PREFIX    = '(';
-static const char PASV_REPLY_SEPARATOR = ',';
-static const char PASV_REPLY_SUFFIX    = ')';
-
-// -----------------
-// utility methods
-// -----------------
-
-static inline
-vector<string> split(const string& source, const char delim) {
-
-    stringstream ss(source);
-    string field;
-    vector<string> fields;
-
-    while ( getline(ss, field, delim) )
-        fields.push_back(field);
-    return fields;
-}
-
-static inline
-bool startsWith(const string& source, const string& pattern) {
-    return ( source.find(pattern) == 0 );
-}
-
-static inline
-string toLower(const string& s) {
-    string out;
-    const size_t sSize = s.size();
-    out.resize(sSize);
-    for ( size_t i = 0; i < sSize; ++i )
-        out[i] = tolower(s[i]);
-    return out;
-}
-
-} // namespace Internal
-} // namespace BamTools
-
-// -----------------------
-// BamFtp implementation
-// -----------------------
-
-BamFtp::BamFtp(const string& url)
-    : IBamIODevice()
-    , m_commandSocket(new TcpSocket)
-    , m_dataSocket(new TcpSocket)
-    , m_port(FTP_PORT)
-    , m_dataPort(0)
-    , m_username(DEFAULT_USER)
-    , m_password(DEFAULT_PASS)
-    , m_isUrlParsed(false)
-    , m_filePosition(-1)
-{
-    ParseUrl(url);
-}
-
-BamFtp::~BamFtp(void) {
-
-    // close connection & clean up
-    Close();
-    if ( m_commandSocket )
-        delete m_commandSocket;
-    if ( m_dataSocket )
-        delete m_dataSocket;
-}
-
-void BamFtp::Close(void) {
-
-    // disconnect socket
-    m_commandSocket->DisconnectFromHost();
-    m_dataSocket->DisconnectFromHost();
-
-    // reset state - necessary??
-    m_isUrlParsed = false;
-    m_filePosition = -1;
-    m_username = DEFAULT_USER;
-    m_password = DEFAULT_PASS;
-    m_dataHostname.clear();
-    m_dataPort = 0;
-}
-
-bool BamFtp::ConnectCommandSocket(void) {
-
-    BT_ASSERT_X(m_commandSocket, "null command socket?");
-
-    // connect to FTP server
-    if ( !m_commandSocket->ConnectToHost(m_hostname, m_port, m_mode) ) {
-        SetErrorString("BamFtp::ConnectCommandSocket", "could not connect to host - ");
-        return false;
-    }
-
-    // receive initial reply from host
-    if ( !ReceiveReply() ) {
-        Close();
-        return false;
-    }
-
-    // send USER command
-    string userCommand = USER_CMD + CMD_SEPARATOR + m_username + FTP_NEWLINE;
-    if ( !SendCommand(userCommand, true) ) {
-        Close();
-        return false;
-    }
-
-    // send PASS command
-    string passwordCommand = PASS_CMD + CMD_SEPARATOR + m_password + FTP_NEWLINE;
-    if ( !SendCommand(passwordCommand, true) ) {
-        Close();
-        return false;
-    }
-
-    // send TYPE command
-    string typeCommand = TYPE_CMD + CMD_SEPARATOR + 'I' + FTP_NEWLINE;
-    if ( !SendCommand(typeCommand, true) ) {
-        Close();
-        return false;
-    }
-
-    // return success
-    return true;
-}
-
-bool BamFtp::ConnectDataSocket(void) {
-
-    // failure if can't connect to command socket first
-    if ( !m_commandSocket->IsConnected() ) {
-        if ( !ConnectCommandSocket() )
-            return false;
-    }
-
-    // make sure we're starting with a fresh data channel
-    if ( m_dataSocket->IsConnected() )
-        m_dataSocket->DisconnectFromHost();
-
-    // send passive connection command
-    const string passiveCommand = PASV_CMD + FTP_NEWLINE;
-    if ( !SendCommand(passiveCommand, true) ) {
-        // TODO: set error string
-        return false;
-    }
-
-    // retrieve passive connection port
-    if ( !ParsePassiveResponse() ) {
-        // TODO: set error string
-        return false;
-    }
-
-    // set up restart command (tell server where to start fetching bytes from)
-    if ( m_filePosition >= 0 ) {
-
-        stringstream fpStream("");
-        fpStream << m_filePosition;
-        string restartCommand = REST_CMD + CMD_SEPARATOR + fpStream.str() + FTP_NEWLINE;
-        if ( !SendCommand(restartCommand, true) ) {
-            // TODO: set error string
-            return false;
-        }
-    }
-
-    // main file retrieval request
-    string retrieveCommand = RETR_CMD + CMD_SEPARATOR + m_filename + FTP_NEWLINE;
-    if ( !SendCommand(retrieveCommand, false) ) {
-        // TODO: set error string
-        return false;
-    }
-
-    // make data channel connection
-    if ( !m_dataSocket->ConnectToHost(m_dataHostname, m_dataPort) ) {
-        // TODO: set error string
-        return false;
-    }
-
-    // fetch intial reply from server
-    if ( !ReceiveReply() ) {
-        // TODO: set error string
-        m_dataSocket->DisconnectFromHost();
-        return false;
-    }
-
-    // make sure we have reply code 150 (all good)
-    if ( !startsWith(m_response, "150") ) {
-        // TODO: set error string
-        m_dataSocket->DisconnectFromHost();
-        return false;
-    }
-
-    // return success
-    return true;
-}
-
-bool BamFtp::IsOpen(void) const {
-    return IBamIODevice::IsOpen() && m_isUrlParsed;
-}
-
-bool BamFtp::IsRandomAccess(void) const {
-    return true;
-}
-
-bool BamFtp::Open(const IBamIODevice::OpenMode mode) {
-
-    // BamFtp only supports read-only access
-    if ( mode != IBamIODevice::ReadOnly ) {
-        SetErrorString("BamFtp::Open", "writing on this device is not supported");
-        return false;
-    }
-
-    // initialize basic valid state
-    m_mode = mode;
-    m_filePosition = 0;
-
-    // attempt connection to command & data sockets
-    return ( ConnectCommandSocket() && ConnectDataSocket() );
-}
-
-bool BamFtp::ParsePassiveResponse(void) {
-
-    // fail if empty
-    if ( m_response.empty() )
-        return false;
-
-    // find parentheses
-    const size_t leftParenFound  = m_response.find(PASV_REPLY_PREFIX);
-    const size_t rightParenFound = m_response.find(PASV_REPLY_SUFFIX);
-    if ( leftParenFound == string::npos || rightParenFound == string::npos )
-        return false;
-
-    // grab everything between ( should be "h1,h2,h3,h4,p1,p2" )
-    string::const_iterator responseBegin = m_response.begin();
-    const string hostAndPort(responseBegin+leftParenFound+1, responseBegin+rightParenFound);
-
-    // parse into string fields
-    vector<string> fields = split(hostAndPort, PASV_REPLY_SEPARATOR);
-    if ( fields.size() != 6 )
-        return false;
-
-    // fetch passive connection IP
-    m_dataHostname = fields[0] + IP_SEPARATOR +
-                     fields[1] + IP_SEPARATOR +
-                     fields[2] + IP_SEPARATOR +
-                     fields[3];
-
-    // fetch passive connection port
-    const uint8_t portUpper = static_cast<uint8_t>(atoi(fields[4].c_str()));
-    const uint8_t portLower = static_cast<uint8_t>(atoi(fields[5].c_str()));
-    m_dataPort = ( portUpper<<8 ) + portLower;
-
-    // return success
-    return true;
-}
-
-void BamFtp::ParseUrl(const string& url) {
-
-    // clear flag to start
-    m_isUrlParsed = false;
-
-    // make sure url starts with "ftp://", case-insensitive
-    string tempUrl(url);
-    toLower(tempUrl);
-    const size_t prefixFound = tempUrl.find(FTP_PREFIX);
-    if ( prefixFound == string::npos )
-        return;
-
-    // find end of host name portion (first '/' hit after the prefix)
-    const size_t firstSlashFound = tempUrl.find(HOST_SEPARATOR, FTP_PREFIX_LENGTH);
-    if ( firstSlashFound == string::npos ) {
-        ;  // no slash found... no filename given along with host?
-    }
-
-    // fetch hostname
-    string hostname = tempUrl.substr(FTP_PREFIX_LENGTH, (firstSlashFound - FTP_PREFIX_LENGTH));
-    m_hostname = hostname;
-    m_port = FTP_PORT;
-
-    // store remainder of URL as filename (must be non-empty)
-    string filename = tempUrl.substr(firstSlashFound);
-    if ( filename.empty() )
-        return;
-    m_filename = filename;
-
-    // set parsed OK flag
-    m_isUrlParsed = true;
-}
-
-int64_t BamFtp::Read(char* data, const unsigned int numBytes) {
-
-    // if BamHttp not in a valid state
-    if ( !IsOpen() )
-        return -1;
-
-    // read until hit desired @numBytes
-    int64_t bytesReadSoFar = 0;
-    while ( bytesReadSoFar < numBytes ) {
-
-        // calculate number of bytes we're going to try to read this iteration
-        const size_t remainingBytes = ( numBytes - bytesReadSoFar );
-
-        // if either disconnected somehow, or (more likely) we have seeked since last read
-        if ( !m_dataSocket->IsConnected() ) {
-            if ( !ConnectDataSocket() ) {
-                // TODO: set error string
-                return -1;
-            }
-        }
-
-        // read bytes from data socket
-        const int64_t socketBytesRead = ReadDataSocket(data+bytesReadSoFar, remainingBytes);
-        if ( socketBytesRead < 0 ) // error
-            return -1;
-        else if ( socketBytesRead == 0 ) // EOF
-            return bytesReadSoFar;
-        bytesReadSoFar += socketBytesRead;
-        m_filePosition += socketBytesRead;
-    }
-
-    // return actual number bytes successfully read
-    return bytesReadSoFar;
-}
-
-int64_t BamFtp::ReadCommandSocket(char* data, const unsigned int maxNumBytes) {
-    return m_commandSocket->Read(data, maxNumBytes);
-}
-
-int64_t BamFtp::ReadDataSocket(char* data, const unsigned int maxNumBytes) {
-    return m_dataSocket->Read(data, maxNumBytes);
-}
-
-bool BamFtp::ReceiveReply(void) {
-
-    // failure if not connected
-    if ( !m_commandSocket->IsConnected() ) {
-        SetErrorString("BamFtp::ReceiveReply()", "command socket not connected");
-        return false;
-    }
-
-    m_response.clear();
-
-    // read header data (& discard for now)
-    bool headerEnd = false;
-    while ( !headerEnd ) {
-
-        const string headerLine = m_commandSocket->ReadLine();
-        m_response += headerLine;
-
-        // if line is of form 'xyz ', quit reading lines
-        if ( (headerLine.length() >= 4 ) &&
-             isdigit(headerLine[0]) &&
-             isdigit(headerLine[1]) &&
-             isdigit(headerLine[2]) &&
-             ( headerLine[3] != MULTILINE_CONTINUE )
-           )
-        {
-            headerEnd = true;
-        }
-    }
-
-    // return success, depending on response
-    if ( m_response.empty() ) {
-        SetErrorString("BamFtp::ReceiveReply", "error reading server reply");
-        return false;
-    }
-    return true;
-}
-
-bool BamFtp::Seek(const int64_t& position, const int origin) {
-
-    // if FTP device not in a valid state
-    if ( !IsOpen() ) {
-        // TODO: set error string
-        return false;
-    }
-
-    // ----------------------
-    // UGLY !! but works??
-    // ----------------------
-    // disconnect from server
-    m_dataSocket->DisconnectFromHost();
-    m_commandSocket->DisconnectFromHost();
-
-    // update file position & return success
-    if ( origin == SEEK_CUR )
-        m_filePosition += position;
-    else if ( origin == SEEK_SET)
-        m_filePosition = position;
-    else {
-        // TODO: set error string
-        return false;
-    }
-    return true;
-}
-
-bool BamFtp::SendCommand(const string& command, bool waitForReply) {
-
-    // failure if not connected
-    if ( !m_commandSocket->IsConnected() ) {
-        SetErrorString("BamFtp::SendCommand", "command socket not connected");
-        return false;
-    }
-
-    // write command to 'command socket'
-    if ( WriteCommandSocket(command.c_str(), command.length()) == -1 ) {
-        SetErrorString("BamFtp::SendCommand", "error writing to socket");
-        // get actual error from command socket??
-        return false;
-    }
-
-    // if we sent a command that receives a response
-    if ( waitForReply )
-        return ReceiveReply();
-
-    // return success
-    return true;
-}
-
-int64_t BamFtp::Tell(void) const {
-    return ( IsOpen() ? m_filePosition : -1 );
-}
-
-int64_t BamFtp::Write(const char* data, const unsigned int numBytes) {
-    (void)data;
-    (void)numBytes;
-    BT_ASSERT_X(false, "BamFtp::Write : write-mode not supported on this device");
-    SetErrorString("BamFtp::Write", "write-mode not supported on this device");
-    return -1;
-}
-
-int64_t BamFtp::WriteCommandSocket(const char* data, const unsigned int numBytes) {
-    if ( !m_commandSocket->IsConnected() )
-        return -1;
-    m_commandSocket->ClearBuffer();
-    return m_commandSocket->Write(data, numBytes);
-}
-
-int64_t BamFtp::WriteDataSocket(const char* data, const unsigned int numBytes) {
-    (void)data;
-    (void)numBytes;
-    BT_ASSERT_X(false, "BamFtp::WriteDataSocket: write-mode not supported on this device");
-    SetErrorString("BamFtp::Write", "write-mode not supported on this device");
-    return -1;
-}
diff --git a/bamtools/src/api/internal/io/BamFtp_p.h b/bamtools/src/api/internal/io/BamFtp_p.h
deleted file mode 100644
index 11f549c..0000000
--- a/bamtools/src/api/internal/io/BamFtp_p.h
+++ /dev/null
@@ -1,91 +0,0 @@
-// ***************************************************************************
-// BamFtp_p.h (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 November 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides reading/writing of BAM files on FTP server
-// ***************************************************************************
-
-#ifndef BAMFTP_P_H
-#define BAMFTP_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#include "api/IBamIODevice.h"
-#include <string>
-
-namespace BamTools {
-namespace Internal {
-
-class TcpSocket;
-
-class BamFtp : public IBamIODevice {
-
-    // ctor & dtor
-    public:
-        BamFtp(const std::string& url);
-        ~BamFtp(void);
-
-    // IBamIODevice implementation
-    public:
-        void Close(void);
-        bool IsOpen(void) const;
-        bool IsRandomAccess(void) const;
-        bool Open(const IBamIODevice::OpenMode mode);
-        int64_t Read(char* data, const unsigned int numBytes);
-        bool Seek(const int64_t& position, const int origin = SEEK_SET);
-        int64_t Tell(void) const;
-        int64_t Write(const char* data, const unsigned int numBytes);
-
-    // internal methods
-    private:
-        bool ConnectCommandSocket(void);
-        bool ConnectDataSocket(void);        
-        bool ParsePassiveResponse(void);
-        void ParseUrl(const std::string& url);
-        int64_t ReadCommandSocket(char* data, const unsigned int numBytes);
-        int64_t ReadDataSocket(char* data, const unsigned int numBytes);
-        bool ReceiveReply(void);
-        bool SendCommand(const std::string& command, bool waitForReply);
-        int64_t WriteCommandSocket(const char* data, const unsigned int numBytes);
-        int64_t WriteDataSocket(const char* data, const unsigned int numBytes);
-
-    // data members
-    private:
-
-        // our main sockets
-        TcpSocket* m_commandSocket;
-        TcpSocket* m_dataSocket;
-
-        // our connection data
-        std::string m_hostname;
-        uint16_t    m_port;
-        std::string m_dataHostname;
-        uint16_t    m_dataPort;
-        std::string m_filename;
-
-        std::string m_username;
-        std::string m_password;
-
-        std::string m_response;
-
-        // internal state flags
-        bool m_isUrlParsed;
-
-        // file position
-        int64_t m_filePosition;
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // BAMFTP_P_H
diff --git a/bamtools/src/api/internal/io/BamHttp_p.cpp b/bamtools/src/api/internal/io/BamHttp_p.cpp
deleted file mode 100644
index b089172..0000000
--- a/bamtools/src/api/internal/io/BamHttp_p.cpp
+++ /dev/null
@@ -1,544 +0,0 @@
-// ***************************************************************************
-// BamHttp_p.cpp (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 24 July 2013 (DB)
-// ---------------------------------------------------------------------------
-// Provides reading/writing of BAM files on HTTP server
-// ***************************************************************************
-
-#include "api/BamAux.h"
-#include "api/internal/io/BamHttp_p.h"
-#include "api/internal/io/HttpHeader_p.h"
-#include "api/internal/io/TcpSocket_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#include <cassert>
-#include <cctype>
-#include <cstdlib>
-#include <algorithm>
-#include <sstream>
-using namespace std;
-
-namespace BamTools {
-namespace Internal {
-
-// -----------
-// constants
-// -----------
-
-static const string HTTP_PORT   = "80";
-static const string HTTP_PREFIX = "http://";
-static const size_t HTTP_PREFIX_LENGTH = 7;
-
-static const string DOUBLE_NEWLINE = "\n\n";
-
-static const string GET_METHOD   = "GET";
-static const string HEAD_METHOD  = "HEAD";
-static const string HOST_HEADER  = "Host";
-static const string RANGE_HEADER = "Range";
-static const string BYTES_PREFIX = "bytes=";
-static const string CONTENT_LENGTH_HEADER = "Content-Length";
-
-static const char HOST_SEPARATOR  = '/';
-static const char PROXY_SEPARATOR = ':';
-
-// -----------------
-// utility methods
-// -----------------
-
-static inline
-bool endsWith(const string& source, const string& pattern) {
-    return ( source.find(pattern) == (source.length() - pattern.length()) );
-}
-
-static inline
-string toLower(const string& s) {
-    string out;
-    const size_t sSize = s.size();
-    out.reserve(sSize);
-    for ( size_t i = 0; i < sSize; ++i )
-        out[i] = tolower(s[i]);
-    return out;
-}
-
-} // namespace Internal
-} // namespace BamTools
-
-// ------------------------
-// BamHttp implementation
-// ------------------------
-
-BamHttp::BamHttp(const string& url)
-    : IBamIODevice()
-    , m_socket(new TcpSocket)
-    , m_port(HTTP_PORT)
-    , m_request(0)
-    , m_response(0)
-    , m_isUrlParsed(false)
-    , m_filePosition(-1)
-    , m_fileEndPosition(-1)
-    , m_rangeEndPosition(-1)
-{
-    ParseUrl(url);
-}
-
-BamHttp::~BamHttp(void) {
-
-    // close connection & clean up
-    Close();
-    if ( m_socket )
-        delete m_socket;
-}
-
-void BamHttp::ClearResponse(void) {
-    if ( m_response ) {
-        delete m_response;
-        m_response = 0;
-    }
-}
-
-void BamHttp::Close(void) {
-
-    // disconnect socket & clear related resources
-    DisconnectSocket();
-
-    // reset state
-    m_isUrlParsed = false;
-    m_filePosition     = -1;
-    m_fileEndPosition  = -1;
-    m_rangeEndPosition = -1;
-    m_mode = IBamIODevice::NotOpen;
-}
-
-bool BamHttp::ConnectSocket(void) {
-
-    BT_ASSERT_X(m_socket, "null socket?");
-
-    // any state checks, etc?
-    if ( !m_socket->ConnectToHost(m_hostname, m_port, m_mode) ) {
-        SetErrorString("BamHttp::ConnectSocket", m_socket->GetErrorString());
-        return false;
-    }
-
-    // return success
-    return true;
-}
-
-void BamHttp::DisconnectSocket(void) {
-
-    // disconnect socket & clean up
-    m_socket->DisconnectFromHost();
-    ClearResponse();
-    if ( m_request )  {
-        delete m_request;
-        m_request = 0;
-    }
-}
-
-bool BamHttp::EnsureSocketConnection(void) {
-    if ( m_socket->IsConnected() )
-        return true;
-    return ConnectSocket();
-}
-
-bool BamHttp::IsOpen(void) const {
-    return IBamIODevice::IsOpen() && m_isUrlParsed;
-}
-
-bool BamHttp::IsRandomAccess(void) const {
-    return true;
-}
-
-bool BamHttp::Open(const IBamIODevice::OpenMode mode) {
-
-    // BamHttp only supports read-only access
-    if ( mode != IBamIODevice::ReadOnly ) {
-        SetErrorString("BamHttp::Open", "writing on this device is not supported");
-        return false;
-    }
-    m_mode = mode;
-
-    // attempt connection to socket
-    if ( !ConnectSocket() ) {
-        SetErrorString("BamHttp::Open", m_socket->GetErrorString());
-        return false;
-    }
-
-    // initialize our file positions
-    m_filePosition     = 0;
-    m_fileEndPosition  = 0;
-    m_rangeEndPosition = 0;
-
-    // attempt to send initial request (just 'HEAD' to check connection)
-    if ( !SendHeadRequest() ) {
-        SetErrorString("BamHttp::Open", m_socket->GetErrorString());
-        return false;
-    }
-
-    // clear response from HEAD request, not needed
-    ClearResponse();
-
-    // return success
-    return true;
-}
-
-void BamHttp::ParseUrl(const string& url) {
-
-    // clear flag to start
-    m_isUrlParsed = false;
-
-    // make sure url starts with "http://", case-insensitive
-    string tempUrl(url);
-    toLower(tempUrl);
-    const size_t prefixFound = tempUrl.find(HTTP_PREFIX);
-    if ( prefixFound == string::npos )
-        return;
-
-    // find end of host name portion (first '/' hit after the prefix)
-    const size_t firstSlashFound = tempUrl.find(HOST_SEPARATOR, HTTP_PREFIX_LENGTH);
-    if ( firstSlashFound == string::npos ) {
-        ;  // no slash found... no filename given along with host?
-    }
-
-    // fetch hostname (check for proxy port)
-    string hostname = tempUrl.substr(HTTP_PREFIX_LENGTH, (firstSlashFound - HTTP_PREFIX_LENGTH));
-    const size_t colonFound = hostname.find(PROXY_SEPARATOR);
-    if ( colonFound != string::npos ) {
-        ; // TODO: handle proxy port (later, just skip for now)
-    } else {
-        m_hostname = hostname;
-        m_port = HTTP_PORT;
-    }
-
-    // store remainder of URL as filename (must be non-empty)
-    string filename = tempUrl.substr(firstSlashFound);
-    if ( filename.empty() )
-        return;
-    m_filename = filename;
-
-    // set parsed OK flag
-    m_isUrlParsed = true;
-}
-
-int64_t BamHttp::Read(char* data, const unsigned int numBytes) {
-
-    // if BamHttp not in a valid state
-    if ( !IsOpen() )
-        return -1;
-
-    int64_t numBytesReadSoFar = 0;
-    while ( numBytesReadSoFar < numBytes ) {
-
-        const size_t remaining = static_cast<size_t>( numBytes - numBytesReadSoFar );
-
-        // if we're not holding a valid GET reponse, get one
-        if ( m_response == 0 ) {
-            if ( !SendGetRequest(remaining) )
-                return -1;
-        }
-        BT_ASSERT_X(m_response, "null HTTP response");
-
-        // check response status code
-        const int statusCode = m_response->GetStatusCode();
-
-        // if we receieved full file contents in response
-        if ( statusCode == 200 ) {
-
-            // try to read 'remaining' bytes from socket
-            const int64_t socketBytesRead = ReadFromSocket(data+numBytesReadSoFar, remaining);
-
-            // if error
-            if ( socketBytesRead < 0 ) {
-                SetErrorString("BamHttp::Read", m_socket->GetErrorString());
-                return -1;
-            }
-
-            // EOF
-            else if ( socketBytesRead == 0 )
-                return numBytesReadSoFar;
-
-            // update counters
-            numBytesReadSoFar += socketBytesRead;
-            m_filePosition    += socketBytesRead;
-
-        }
-
-        // else if we received a range of bytes in response
-        else if ( statusCode == 206 ) {
-
-            // if we've exhausted the last request
-            if ( m_filePosition == m_rangeEndPosition ) {
-                if ( !SendGetRequest(remaining) )
-                    return -1;
-            }
-
-            else {
-
-                // try to read 'remaining' bytes from socket
-                const int64_t socketBytesRead = ReadFromSocket(data+numBytesReadSoFar, remaining);
-
-                // if error
-                if ( socketBytesRead < 0 ) {
-                    SetErrorString("BamHttp::Read", m_socket->GetErrorString());
-                    return -1;
-                }
-
-                // maybe EOF
-                else if ( socketBytesRead == 0 ) {
-
-                    // if we know we're not at end position, fire off a new request
-                    if ( m_fileEndPosition > 0 && m_filePosition < m_fileEndPosition ) {
-                        if ( !SendGetRequest() )
-                            return -1;
-                    } else
-                        return numBytesReadSoFar;
-                }
-
-                // update counters
-                numBytesReadSoFar += socketBytesRead;
-                m_filePosition    += socketBytesRead;
-            }
-        }
-
-
-        // else some other HTTP status
-        else {
-            SetErrorString("BamHttp::Read", "unsupported status code in response");
-            return -1;
-        }
-    }
-
-    // return actual number of bytes read
-    return numBytesReadSoFar;
-}
-
-int64_t BamHttp::ReadFromSocket(char* data, const unsigned int maxNumBytes) {
-    return m_socket->Read(data, maxNumBytes);
-}
-
-bool BamHttp::ReceiveResponse(void) {
-
-    // fetch header, up until double new line
-    string responseHeader;
-    do {
-
-        // make sure we can read a line
-        if ( !m_socket->WaitForReadLine() )
-            return false;
-
-        // read line & append to full header
-        const string headerLine = m_socket->ReadLine();
-        responseHeader += headerLine;
-
-    } while ( !endsWith(responseHeader, DOUBLE_NEWLINE) );
-
-    // sanity check
-    if ( responseHeader.empty() ) {
-        SetErrorString("BamHttp::ReceiveResponse", "empty HTTP response");
-        Close();
-        return false;
-    }
-
-    // create response from header text
-    m_response = new HttpResponseHeader(responseHeader);
-    if ( !m_response->IsValid() ) {
-        SetErrorString("BamHttp::ReceiveResponse", "could not parse HTTP response");
-        Close();
-        return false;
-    }
-
-    // if we get here, success
-    return true;
-}
-
-bool BamHttp::Seek(const int64_t& position, const int origin) {
-
-    // if HTTP device not in a valid state
-    if ( !IsOpen() ) {
-        SetErrorString("BamHttp::Seek", "cannot seek on unopen connection");
-        return false;
-    }
-
-    // reset the connection
-    DisconnectSocket();
-    if ( !ConnectSocket() ) {
-        SetErrorString("BamHttp::Seek", m_socket->GetErrorString());
-        return false;
-    }
-
-    // udpate file position
-    switch ( origin ) {
-        case SEEK_CUR : m_filePosition += position; break;
-        case SEEK_SET : m_filePosition  = position; break;
-        default :
-            SetErrorString("BamHttp::Seek", "unsupported seek origin");
-            return false;
-    }
-
-    // return success
-    return true;
-}
-
-bool BamHttp::SendGetRequest(const size_t numBytes) {
-
-    // clear previous data
-    ClearResponse();
-    if ( m_request )
-        delete m_request;
-    m_socket->ClearBuffer();
-
-    // make sure we're connected
-    if ( !EnsureSocketConnection() )
-        return false;
-
-    // create range string
-    const int64_t endPosition = m_filePosition + std::max(static_cast<size_t>(0x10000), numBytes);
-    stringstream range("");
-    range << BYTES_PREFIX << m_filePosition << '-' << endPosition;
-
-    // create request
-    m_request = new HttpRequestHeader(GET_METHOD, m_filename);
-    m_request->SetField(HOST_HEADER,  m_hostname);
-    m_request->SetField(RANGE_HEADER, range.str());
-
-    // send request
-    const string requestHeader = m_request->ToString();
-    const size_t headerSize    = requestHeader.size();
-    if ( WriteToSocket(requestHeader.c_str(), headerSize) != headerSize ) {
-        SetErrorString("BamHttp::SendHeadRequest", m_socket->GetErrorString());
-        return false;
-    }
-
-    // ensure clean buffer
-    m_socket->ClearBuffer();
-
-    // wait for response
-    if ( !ReceiveResponse() ) {
-        SetErrorString("BamHttp::SendGetRequest", m_socket->GetErrorString());
-        Close();
-        return false;
-    }
-    BT_ASSERT_X(m_response, "BamHttp::SendGetRequest : null HttpResponse");
-    BT_ASSERT_X(m_response->IsValid(), "BamHttp::SendGetRequest : invalid HttpResponse");
-
-    // check response status code
-    const int statusCode = m_response->GetStatusCode();
-    switch ( statusCode ) {
-
-        // ranged response, as requested
-        case 206 :
-            // get content length if available
-            if ( m_response->ContainsKey(CONTENT_LENGTH_HEADER) ) {
-                const string contentLengthString = m_response->GetValue(CONTENT_LENGTH_HEADER);
-                m_rangeEndPosition = m_filePosition + atoi( contentLengthString.c_str() );
-            }
-            return true;
-
-        // full contents, not range
-        case 200 :
-        {
-            // skip up to current file position
-            RaiiBuffer tmp(0x8000);
-            int64_t numBytesRead = 0;
-            while ( numBytesRead < m_filePosition ) {
-
-                // read data from response
-                const int64_t remaining = m_filePosition - numBytesRead;
-                const size_t bytesToRead = static_cast<size_t>( (remaining > 0x8000) ? 0x8000 : remaining );
-                const int64_t socketBytesRead = ReadFromSocket(tmp.Buffer, bytesToRead);
-
-                // if error
-                if ( socketBytesRead < 0 ) {
-                    SetErrorString("BamHttp::SendGetRequest", m_socket->GetErrorString());
-                    Close();
-                    return false;
-                }
-
-                // else if EOF
-                else if ( socketBytesRead == 0 && m_socket->BufferBytesAvailable() == 0 )
-                    break;
-
-                // update byte counter
-                numBytesRead += socketBytesRead;
-            }
-
-            // return success
-            return ( numBytesRead == m_filePosition);
-        }
-
-        // any other status codes
-        default:
-            break;
-    }
-
-    // fail on unexpected status code
-    SetErrorString("BamHttp::SendGetRequest", "unsupported status code in response");
-    Close();
-    return false;
-}
-
-bool BamHttp::SendHeadRequest(void) {
-
-    // ensure clean slate
-    ClearResponse();
-    if ( m_request )
-        delete m_request;
-    m_socket->ClearBuffer();
-
-    // make sure we're connected
-    if ( !EnsureSocketConnection() )
-        return false;
-
-    // create request
-    m_request = new HttpRequestHeader(HEAD_METHOD, m_filename);
-    m_request->SetField(HOST_HEADER, m_hostname);
-
-    // send request
-    const string requestHeader = m_request->ToString();
-    const size_t headerSize    = requestHeader.size();
-    if ( WriteToSocket(requestHeader.c_str(), headerSize) != headerSize ) {
-        SetErrorString("BamHttp::SendHeadRequest", m_socket->GetErrorString());
-        return false;
-    }
-
-    m_socket->ClearBuffer();
-
-    // wait for response from server
-    if ( !ReceiveResponse() ) {
-        SetErrorString("BamHttp::SendHeadRequest", m_socket->GetErrorString());
-        Close();
-        return false;
-    }
-    BT_ASSERT_X(m_response, "BamHttp::SendHeadRequest : null HttpResponse");
-    BT_ASSERT_X(m_response->IsValid(), "BamHttp::SendHeadRequest : invalid HttpResponse");
-
-    // get content length if available
-    if ( m_response->ContainsKey(CONTENT_LENGTH_HEADER) ) {
-        const string contentLengthString = m_response->GetValue(CONTENT_LENGTH_HEADER);
-        m_fileEndPosition = atoi( contentLengthString.c_str() ) - 1;
-    }
-
-    // return whether we found any errors
-    return m_socket->GetError() == TcpSocket::NoError;
-}
-
-int64_t BamHttp::Tell(void) const {
-    return ( IsOpen() ? m_filePosition : -1 );
-}
-
-int64_t BamHttp::Write(const char* data, const unsigned int numBytes) {
-    (void)data;
-    (void)numBytes;
-    BT_ASSERT_X(false, "BamHttp::Write : write-mode not supported on this device");
-    SetErrorString("BamHttp::Write", "write-mode not supported on this device");
-    return -1;
-}
-
-int64_t BamHttp::WriteToSocket(const char* data, const unsigned int numBytes) {
-    if ( !m_socket->IsConnected() )
-        return -1;
-    m_socket->ClearBuffer();
-    return m_socket->Write(data, numBytes);
-}
diff --git a/bamtools/src/api/internal/io/BamHttp_p.h b/bamtools/src/api/internal/io/BamHttp_p.h
deleted file mode 100644
index cbbc95c..0000000
--- a/bamtools/src/api/internal/io/BamHttp_p.h
+++ /dev/null
@@ -1,91 +0,0 @@
-// ***************************************************************************
-// BamHttp_p.h (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 November 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides reading/writing of BAM files on HTTP server
-// ***************************************************************************
-
-#ifndef BAMHTTP_P_H
-#define BAMHTTP_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#include "api/IBamIODevice.h"
-#include <string>
-
-namespace BamTools {
-namespace Internal {
-
-class HttpRequestHeader;
-class HttpResponseHeader;
-class TcpSocket;
-
-class BamHttp : public IBamIODevice {
-
-    // ctor & dtor
-    public:
-        BamHttp(const std::string& url);
-        ~BamHttp(void);
-
-    // IBamIODevice implementation
-    public:
-        void Close(void);
-        bool IsOpen(void) const;
-        bool IsRandomAccess(void) const;
-        bool Open(const IBamIODevice::OpenMode mode);
-        int64_t Read(char* data, const unsigned int numBytes);
-        bool Seek(const int64_t& position, const int origin = SEEK_SET);
-        int64_t Tell(void) const;
-        int64_t Write(const char* data, const unsigned int numBytes);
-
-    // internal methods
-    private:
-        void ClearResponse(void);
-        bool ConnectSocket(void);
-        void DisconnectSocket(void);
-        bool EnsureSocketConnection(void);
-        void ParseUrl(const std::string& url);
-        int64_t ReadFromSocket(char* data, const unsigned int numBytes);
-        bool ReceiveResponse(void);
-        bool SendGetRequest(const size_t numBytes = 0x10000);
-        bool SendHeadRequest(void);
-        int64_t WriteToSocket(const char* data, const unsigned int numBytes);
-
-    // data members
-    private:
-
-        // our main socket
-        TcpSocket* m_socket;
-
-        // our connection data
-        std::string m_hostname;
-        std::string m_port;
-        std::string m_filename;
-
-        // our last (active) request & response info
-        HttpRequestHeader*  m_request;
-        HttpResponseHeader* m_response;
-
-        // internal state flags
-        bool m_isUrlParsed;
-
-        // file position
-        int64_t m_filePosition;
-        int64_t m_fileEndPosition;
-        int64_t m_rangeEndPosition;
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // BAMHTTP_P_H
diff --git a/bamtools/src/api/internal/io/BamPipe_p.cpp b/bamtools/src/api/internal/io/BamPipe_p.cpp
deleted file mode 100644
index 6af4af1..0000000
--- a/bamtools/src/api/internal/io/BamPipe_p.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-// ***************************************************************************
-// BamPipe_p.cpp (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 18 October 2012 (DB)
-// ---------------------------------------------------------------------------
-// Provides BAM pipe-specific IO behavior
-// ***************************************************************************
-
-#include "api/internal/io/BamPipe_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#include <cstdio>
-#include <iostream>
-using namespace std;
-
-BamPipe::BamPipe(void) : ILocalIODevice() { }
-
-BamPipe::~BamPipe(void) { }
-
-bool BamPipe::IsRandomAccess(void) const {
-    return false;
-}
-
-bool BamPipe::Open(const IBamIODevice::OpenMode mode) {
-
-    // make sure we're starting with a fresh pipe
-    Close();
-
-    // open stdin/stdout depending on requested openmode
-#if defined( SYSTEM_NODEJS ) && SYSTEM_NODEJS == 1
-    if ( mode == IBamIODevice::ReadOnly )
-        m_stream = stdin;
-    else if ( mode == IBamIODevice::WriteOnly )
-        m_stream = stdout;
-#else
-    if ( mode == IBamIODevice::ReadOnly )
-        m_stream = freopen(0, "rb", stdin);
-    else if ( mode == IBamIODevice::WriteOnly )
-        m_stream = freopen(0, "wb", stdout);
-#endif // SYSTEM_NODEJS
-
-    else {
-        const string errorType = string( (mode == IBamIODevice::ReadWrite) ? "unsupported"
-                                                                           : "unknown" );
-        const string message = errorType + " open mode requested";
-        SetErrorString("BamPipe::Open", message);
-        return false;
-    }
-
-    // check that we obtained a valid FILE*
-    if ( m_stream == 0 ) {
-        const string message_base = string("could not open handle on ");
-        const string message = message_base + ( (mode == IBamIODevice::ReadOnly) ? "stdin"
-                                                                                 : "stdout" );
-        SetErrorString("BamPipe::Open", message);
-        return false;
-    }
-
-    // store current IO mode & return success
-    m_mode = mode;
-    return true;
-}
-
-bool BamPipe::Seek(const int64_t&, const int) {
-    SetErrorString("BamPipe::Seek", "random access not allowed in FIFO pipe");
-    return false;
-}
diff --git a/bamtools/src/api/internal/io/BamPipe_p.h b/bamtools/src/api/internal/io/BamPipe_p.h
deleted file mode 100644
index 1a95cc7..0000000
--- a/bamtools/src/api/internal/io/BamPipe_p.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// ***************************************************************************
-// BamPipe_p.h (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 November 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides BAM pipe-specific IO behavior
-// ***************************************************************************
-
-#ifndef BAMPIPE_P_H
-#define BAMPIPE_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#include "api/internal/io/ILocalIODevice_p.h"
-#include <string>
-
-namespace BamTools {
-namespace Internal {
-
-class BamPipe : public ILocalIODevice {
-
-    // ctor & dtor
-    public:
-        BamPipe(void);
-        ~BamPipe(void);
-
-    // IBamIODevice implementation
-    public:
-        bool IsRandomAccess(void) const;
-        bool Open(const IBamIODevice::OpenMode mode);
-        bool Seek(const int64_t& position, const int origin = SEEK_SET);
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // BAMPIPE_P_H
diff --git a/bamtools/src/api/internal/io/BgzfStream_p.cpp b/bamtools/src/api/internal/io/BgzfStream_p.cpp
deleted file mode 100644
index 1f4e0d8..0000000
--- a/bamtools/src/api/internal/io/BgzfStream_p.cpp
+++ /dev/null
@@ -1,469 +0,0 @@
-// ***************************************************************************
-// BgzfStream_p.cpp (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 17 January 2012(DB)
-// ---------------------------------------------------------------------------
-// Based on BGZF routines developed at the Broad Institute.
-// Provides the basic functionality for reading & writing BGZF files
-// Replaces the old BGZF.* files to avoid clashing with other toolkits
-// ***************************************************************************
-
-#include "api/BamAux.h"
-#include "api/BamConstants.h"
-#include "api/internal/io/BamDeviceFactory_p.h"
-#include "api/internal/io/BgzfStream_p.h"
-#include "api/internal/utils/BamException_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#include "zlib.h"
-
-#include <cstring>
-#include <algorithm>
-#include <iostream>
-#include <sstream>
-using namespace std;
-
-// ---------------------------
-// BgzfStream implementation
-// ---------------------------
-
-// constructor
-BgzfStream::BgzfStream(void)
-  : m_blockLength(0)
-  , m_blockOffset(0)
-  , m_blockAddress(0)
-  , m_isWriteCompressed(true)
-  , m_device(0)
-  , m_uncompressedBlock(Constants::BGZF_DEFAULT_BLOCK_SIZE)
-  , m_compressedBlock(Constants::BGZF_MAX_BLOCK_SIZE)
-{ }
-
-// destructor
-BgzfStream::~BgzfStream(void) {
-    Close();
-}
-
-// checks BGZF block header
-bool BgzfStream::CheckBlockHeader(char* header) {
-    return (header[0] == Constants::GZIP_ID1 &&
-            header[1] == Constants::GZIP_ID2 &&
-            header[2] == Z_DEFLATED &&
-            (header[3] & Constants::FLG_FEXTRA) != 0 &&
-            BamTools::UnpackUnsignedShort(&header[10]) == Constants::BGZF_XLEN &&
-            header[12] == Constants::BGZF_ID1 &&
-            header[13] == Constants::BGZF_ID2 &&
-            BamTools::UnpackUnsignedShort(&header[14]) == Constants::BGZF_LEN );
-}
-
-// closes BGZF file
-void BgzfStream::Close(void) {
-
-    // skip if no device open
-    if ( m_device == 0 ) return;
-
-    // if writing to file, flush the current BGZF block,
-    // then write an empty block (as EOF marker)
-    if ( m_device->IsOpen() && (m_device->Mode() == IBamIODevice::WriteOnly) ) {
-        FlushBlock();
-        const size_t blockLength = DeflateBlock(0);
-        m_device->Write(m_compressedBlock.Buffer, blockLength);
-    }
-
-    // close device
-    m_device->Close();
-    delete m_device;
-    m_device = 0;
-
-    // ensure our buffers are cleared out
-    m_uncompressedBlock.Clear();
-    m_compressedBlock.Clear();
-
-    // reset state
-    m_blockLength = 0;
-    m_blockOffset = 0;
-    m_blockAddress = 0;
-    m_isWriteCompressed = true;
-}
-
-// compresses the current block
-size_t BgzfStream::DeflateBlock(int32_t blockLength) {
-
-    // initialize the gzip header
-    char* buffer = m_compressedBlock.Buffer;
-    memset(buffer, 0, 18);
-    buffer[0]  = Constants::GZIP_ID1;
-    buffer[1]  = Constants::GZIP_ID2;
-    buffer[2]  = Constants::CM_DEFLATE;
-    buffer[3]  = Constants::FLG_FEXTRA;
-    buffer[9]  = Constants::OS_UNKNOWN;
-    buffer[10] = Constants::BGZF_XLEN;
-    buffer[12] = Constants::BGZF_ID1;
-    buffer[13] = Constants::BGZF_ID2;
-    buffer[14] = Constants::BGZF_LEN;
-
-    // set compression level
-    const int compressionLevel = ( m_isWriteCompressed ? Z_DEFAULT_COMPRESSION : 0 );
-
-    // loop to retry for blocks that do not compress enough
-    int inputLength = blockLength;
-    size_t compressedLength = 0;
-    const unsigned int bufferSize = Constants::BGZF_MAX_BLOCK_SIZE;
-
-    while ( true ) {
-
-        // initialize zstream values
-        z_stream zs;
-        zs.zalloc    = NULL;
-        zs.zfree     = NULL;
-        zs.next_in   = (Bytef*)m_uncompressedBlock.Buffer;
-        zs.avail_in  = inputLength;
-        zs.next_out  = (Bytef*)&buffer[Constants::BGZF_BLOCK_HEADER_LENGTH];
-        zs.avail_out = bufferSize -
-                       Constants::BGZF_BLOCK_HEADER_LENGTH -
-                       Constants::BGZF_BLOCK_FOOTER_LENGTH;
-
-        // initialize the zlib compression algorithm
-        int status = deflateInit2(&zs,
-                                  compressionLevel,
-                                  Z_DEFLATED,
-                                  Constants::GZIP_WINDOW_BITS,
-                                  Constants::Z_DEFAULT_MEM_LEVEL,
-                                  Z_DEFAULT_STRATEGY);
-        if ( status != Z_OK )
-            throw BamException("BgzfStream::DeflateBlock", "zlib deflateInit2 failed");
-
-        // compress the data
-        status = deflate(&zs, Z_FINISH);
-
-        // if not at stream end
-        if ( status != Z_STREAM_END ) {
-
-            deflateEnd(&zs);
-
-            // there was not enough space available in buffer
-            // try to reduce the input length & re-start loop
-            if ( status == Z_OK ) {
-                inputLength -= 1024;
-                if ( inputLength < 0 )
-                    throw BamException("BgzfStream::DeflateBlock", "input reduction failed");
-                continue;
-            }
-
-            throw BamException("BgzfStream::DeflateBlock", "zlib deflate failed");
-        }
-
-        // finalize the compression routine
-        status = deflateEnd(&zs);
-        if ( status != Z_OK )
-            throw BamException("BgzfStream::DeflateBlock", "zlib deflateEnd failed");
-
-        // update compressedLength
-        compressedLength = zs.total_out +
-                           Constants::BGZF_BLOCK_HEADER_LENGTH +
-                           Constants::BGZF_BLOCK_FOOTER_LENGTH;
-        if ( compressedLength > Constants::BGZF_MAX_BLOCK_SIZE )
-            throw BamException("BgzfStream::DeflateBlock", "deflate overflow");
-
-        // quit while loop
-        break;
-    }
-
-    // store the compressed length
-    BamTools::PackUnsignedShort(&buffer[16], static_cast<uint16_t>(compressedLength - 1));
-
-    // store the CRC32 checksum
-    uint32_t crc = crc32(0, NULL, 0);
-    crc = crc32(crc, (Bytef*)m_uncompressedBlock.Buffer, inputLength);
-    BamTools::PackUnsignedInt(&buffer[compressedLength - 8], crc);
-    BamTools::PackUnsignedInt(&buffer[compressedLength - 4], inputLength);
-
-    // ensure that we have less than a block of data left
-    int remaining = blockLength - inputLength;
-    if ( remaining > 0 ) {
-        if ( remaining > inputLength )
-            throw BamException("BgzfStream::DeflateBlock", "after deflate, remainder too large");
-        memcpy(m_uncompressedBlock.Buffer, m_uncompressedBlock.Buffer + inputLength, remaining);
-    }
-
-    // update block data
-    m_blockOffset = remaining;
-
-    // return result
-    return compressedLength;
-}
-
-// flushes the data in the BGZF block
-void BgzfStream::FlushBlock(void) {
-
-    BT_ASSERT_X( m_device, "BgzfStream::FlushBlock() - attempting to flush to null device" );
-
-    // flush all of the remaining blocks
-    while ( m_blockOffset > 0 ) {
-
-        // compress the data block
-        const size_t blockLength = DeflateBlock(m_blockOffset);
-
-        // flush the data to our output device
-        const int64_t numBytesWritten = m_device->Write(m_compressedBlock.Buffer, blockLength);
-
-        // check for device error
-        if ( numBytesWritten < 0 ) {
-            const string message = string("device error: ") + m_device->GetErrorString();
-            throw BamException("BgzfStream::FlushBlock", message);
-        }
-
-        // check that we wrote expected numBytes
-        if ( numBytesWritten != static_cast<int64_t>(blockLength) ) {
-            stringstream s("");
-            s << "expected to write " << blockLength
-              << " bytes during flushing, but wrote " << numBytesWritten;
-            throw BamException("BgzfStream::FlushBlock", s.str());
-        }
-
-        // update block data
-        m_blockAddress += blockLength;
-    }
-}
-
-// decompresses the current block
-size_t BgzfStream::InflateBlock(const size_t& blockLength) {
-
-    // setup zlib stream object
-    z_stream zs;
-    zs.zalloc    = NULL;
-    zs.zfree     = NULL;
-    zs.next_in   = (Bytef*)m_compressedBlock.Buffer + 18;
-    zs.avail_in  = blockLength - 16;
-    zs.next_out  = (Bytef*)m_uncompressedBlock.Buffer;
-    zs.avail_out = Constants::BGZF_DEFAULT_BLOCK_SIZE;
-
-    // initialize
-    int status = inflateInit2(&zs, Constants::GZIP_WINDOW_BITS);
-    if ( status != Z_OK )
-        throw BamException("BgzfStream::InflateBlock", "zlib inflateInit failed");
-
-    // decompress
-    status = inflate(&zs, Z_FINISH);
-    if ( status != Z_STREAM_END ) {
-        inflateEnd(&zs);
-        throw BamException("BgzfStream::InflateBlock", "zlib inflate failed");
-    }
-
-    // finalize
-    status = inflateEnd(&zs);
-    if ( status != Z_OK ) {
-        inflateEnd(&zs);
-        throw BamException("BgzfStream::InflateBlock", "zlib inflateEnd failed");
-    }
-
-    // return result
-    return zs.total_out;
-}
-
-bool BgzfStream::IsOpen(void) const {
-    if ( m_device == 0 )
-        return false;
-    return m_device->IsOpen();
-}
-
-void BgzfStream::Open(const string& filename, const IBamIODevice::OpenMode mode) {
-
-    // close current device if necessary
-    Close();
-    BT_ASSERT_X( (m_device == 0), "BgzfStream::Open() - unable to properly close previous IO device" );
-
-    // retrieve new IO device depending on filename
-    m_device = BamDeviceFactory::CreateDevice(filename);
-    BT_ASSERT_X( m_device, "BgzfStream::Open() - unable to create IO device from filename" );
-
-    // if device fails to open
-    if ( !m_device->Open(mode) ) {
-        const string deviceError = m_device->GetErrorString();
-        const string message = string("could not open BGZF stream: \n\t") + deviceError;
-        throw BamException("BgzfStream::Open", message);
-    }
-}
-
-// reads BGZF data into a byte buffer
-size_t BgzfStream::Read(char* data, const size_t dataLength) {
-
-    if ( dataLength == 0 )
-        return 0;
-
-    // if stream not open for reading
-    BT_ASSERT_X( m_device, "BgzfStream::Read() - trying to read from null device");
-    if ( !m_device->IsOpen() || (m_device->Mode() != IBamIODevice::ReadOnly) )
-        return 0;
-
-    // read blocks as needed until desired data length is retrieved
-    char* output = data;
-    size_t numBytesRead = 0;
-    while ( numBytesRead < dataLength ) {
-
-        // determine bytes available in current block
-        int bytesAvailable = m_blockLength - m_blockOffset;
-
-        // read (and decompress) next block if needed
-        if ( bytesAvailable <= 0 ) {
-            ReadBlock();
-            bytesAvailable = m_blockLength - m_blockOffset;
-            if ( bytesAvailable <= 0 )
-                break;
-        }
-
-        // copy data from uncompressed source buffer into data destination buffer
-        const size_t copyLength = min( (dataLength-numBytesRead), (size_t)bytesAvailable );
-        memcpy(output, m_uncompressedBlock.Buffer + m_blockOffset, copyLength);
-
-        // update counters
-        m_blockOffset += copyLength;
-        output        += copyLength;
-        numBytesRead  += copyLength;
-    }
-
-    // update block data
-    if ( m_blockOffset == m_blockLength ) {
-        m_blockAddress = m_device->Tell();
-        m_blockOffset  = 0;
-        m_blockLength  = 0;
-    }
-
-    // return actual number of bytes read
-    return numBytesRead;
-}
-
-// reads a BGZF block
-void BgzfStream::ReadBlock(void) {
-
-    BT_ASSERT_X( m_device, "BgzfStream::ReadBlock() - trying to read from null IO device");
-
-    // store block's starting address
-    const int64_t blockAddress = m_device->Tell();
-
-    // read block header from file
-    char header[Constants::BGZF_BLOCK_HEADER_LENGTH];
-    int64_t numBytesRead = m_device->Read(header, Constants::BGZF_BLOCK_HEADER_LENGTH);
-
-    // check for device error
-    if ( numBytesRead < 0 ) {
-        const string message = string("device error: ") + m_device->GetErrorString();
-        throw BamException("BgzfStream::ReadBlock", message);
-    }
-
-    // if block header empty
-    if ( numBytesRead == 0 ) {
-        m_blockLength = 0;
-        return;
-    }
-
-    // if block header invalid size
-    if ( numBytesRead != static_cast<int8_t>(Constants::BGZF_BLOCK_HEADER_LENGTH) )
-        throw BamException("BgzfStream::ReadBlock", "invalid block header size");
-
-    // validate block header contents
-    if ( !BgzfStream::CheckBlockHeader(header) )
-        throw BamException("BgzfStream::ReadBlock", "invalid block header contents");
-
-    // copy header contents to compressed buffer
-    const size_t blockLength = BamTools::UnpackUnsignedShort(&header[16]) + 1;
-    memcpy(m_compressedBlock.Buffer, header, Constants::BGZF_BLOCK_HEADER_LENGTH);
-
-    // read remainder of block
-    const size_t remaining = blockLength - Constants::BGZF_BLOCK_HEADER_LENGTH;
-    numBytesRead = m_device->Read(&m_compressedBlock.Buffer[Constants::BGZF_BLOCK_HEADER_LENGTH], remaining);
-
-    // check for device error
-    if ( numBytesRead < 0 ) {
-        const string message = string("device error: ") + m_device->GetErrorString();
-        throw BamException("BgzfStream::ReadBlock", message);
-    }
-
-    // check that we read in expected numBytes
-    if ( numBytesRead != static_cast<int64_t>(remaining) )
-        throw BamException("BgzfStream::ReadBlock", "could not read data from block");
-
-    // decompress block data
-    const size_t newBlockLength = InflateBlock(blockLength);
-
-    // update block data
-    if ( m_blockLength != 0 )
-        m_blockOffset = 0;
-    m_blockAddress = blockAddress;
-    m_blockLength  = newBlockLength;
-}
-
-// seek to position in BGZF file
-void BgzfStream::Seek(const int64_t& position) {
-
-    BT_ASSERT_X( m_device, "BgzfStream::Seek() - trying to seek on null IO device");
-
-    // skip if device is not open
-    if ( !IsOpen() ) return;
-
-    // determine adjusted offset & address
-    int     blockOffset  = (position & 0xFFFF);
-    int64_t blockAddress = (position >> 16) & 0xFFFFFFFFFFFFLL;
-
-    // attempt seek in file
-    if ( m_device->IsRandomAccess() && m_device->Seek(blockAddress) ) {
-
-        // update block data & return success
-        m_blockLength  = 0;
-        m_blockAddress = blockAddress;
-        m_blockOffset  = blockOffset;
-    }
-    else {
-        stringstream s("");
-        s << "unable to seek to position: " << position;
-        throw BamException("BgzfStream::Seek", s.str());
-    }
-}
-
-void BgzfStream::SetWriteCompressed(bool ok) {
-    m_isWriteCompressed = ok;
-}
-
-// get file position in BGZF file
-int64_t BgzfStream::Tell(void) const {
-    if ( !IsOpen() )
-        return 0;
-    return ( (m_blockAddress << 16) | (m_blockOffset & 0xFFFF) );
-}
-
-// writes the supplied data into the BGZF buffer
-size_t BgzfStream::Write(const char* data, const size_t dataLength) {
-
-    BT_ASSERT_X( m_device, "BgzfStream::Write() - trying to write to null IO device");
-    BT_ASSERT_X( (m_device->Mode() == IBamIODevice::WriteOnly),
-                 "BgzfStream::Write() - trying to write to non-writable IO device");
-
-    // skip if file not open for writing
-    if ( !IsOpen() )
-        return 0;
-
-    // write blocks as needed til all data is written
-    size_t numBytesWritten = 0;
-    const char* input = data;
-    const size_t blockLength = Constants::BGZF_DEFAULT_BLOCK_SIZE;
-    while ( numBytesWritten < dataLength ) {
-
-        // copy data contents to uncompressed output buffer
-        unsigned int copyLength = min(blockLength - m_blockOffset, dataLength - numBytesWritten);
-        char* buffer = m_uncompressedBlock.Buffer;
-        memcpy(buffer + m_blockOffset, input, copyLength);
-
-        // update counter
-        m_blockOffset   += copyLength;
-        input           += copyLength;
-        numBytesWritten += copyLength;
-
-        // flush (& compress) output buffer when full
-        if ( m_blockOffset == static_cast<int32_t>(blockLength) )
-            FlushBlock();
-    }
-
-    // return actual number of bytes written
-    return numBytesWritten;
-}
diff --git a/bamtools/src/api/internal/io/BgzfStream_p.h b/bamtools/src/api/internal/io/BgzfStream_p.h
deleted file mode 100644
index a386c1a..0000000
--- a/bamtools/src/api/internal/io/BgzfStream_p.h
+++ /dev/null
@@ -1,93 +0,0 @@
-// ***************************************************************************
-// BgzfStream_p.h (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 17 January 2012(DB)
-// ---------------------------------------------------------------------------
-// Based on BGZF routines developed at the Broad Institute.
-// Provides the basic functionality for reading & writing BGZF files
-// Replaces the old BGZF.* files to avoid clashing with other toolkits
-// ***************************************************************************
-
-#ifndef BGZFSTREAM_P_H
-#define BGZFSTREAM_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#include "api/api_global.h"
-#include "api/BamAux.h"
-#include "api/IBamIODevice.h"
-#include <string>
-
-namespace BamTools {
-namespace Internal {
-
-class BgzfStream {
-
-    // constructor & destructor
-    public:
-        BgzfStream(void);
-        ~BgzfStream(void);
-
-    // main interface methods
-    public:
-        // closes BGZF file
-        void Close(void);
-        // returns true if BgzfStream open for IO
-        bool IsOpen(void) const;
-        // opens the BGZF file
-        void Open(const std::string& filename, const IBamIODevice::OpenMode mode);
-        // reads BGZF data into a byte buffer
-        size_t Read(char* data, const size_t dataLength);
-        // seek to position in BGZF file
-        void Seek(const int64_t& position);
-        // sets IO device (closes previous, if any, but does not attempt to open)
-        void SetIODevice(IBamIODevice* device);
-        // enable/disable compressed output
-        void SetWriteCompressed(bool ok);
-        // get file position in BGZF file
-        int64_t Tell(void) const;
-        // writes the supplied data into the BGZF buffer
-        size_t Write(const char* data, const size_t dataLength);
-
-    // internal methods
-    private:
-        // compresses the current block
-        size_t DeflateBlock(int32_t blockLength);
-        // flushes the data in the BGZF block
-        void FlushBlock(void);
-        // de-compresses the current block
-        size_t InflateBlock(const size_t& blockLength);
-        // reads a BGZF block
-        void ReadBlock(void);
-
-    // static 'utility' methods
-    public:
-        // checks BGZF block header
-        static bool CheckBlockHeader(char* header);
-
-    // data members
-    public:
-        int32_t m_blockLength;
-        int32_t m_blockOffset;
-        int64_t m_blockAddress;
-
-        bool m_isWriteCompressed;
-        IBamIODevice* m_device;
-
-        RaiiBuffer m_uncompressedBlock;
-        RaiiBuffer m_compressedBlock;
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // BGZFSTREAM_P_H
diff --git a/bamtools/src/api/internal/io/ByteArray_p.cpp b/bamtools/src/api/internal/io/ByteArray_p.cpp
deleted file mode 100644
index 5f54c83..0000000
--- a/bamtools/src/api/internal/io/ByteArray_p.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-// ***************************************************************************
-// ByteArray_p.cpp (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 November 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides a dynamic, variable-length byte buffer
-// ***************************************************************************
-
-#include "api/internal/io/ByteArray_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#include <cstdlib>
-#include <cstring>
-using namespace std;
-
-// --------------------------
-// ByteArray implementation
-// --------------------------
-
-ByteArray::ByteArray(void)
-    : m_data()
-{ }
-
-ByteArray::ByteArray(const string& value)
-    : m_data(value.begin(), value.end())
-{ }
-
-ByteArray::ByteArray(const vector<char>& value)
-    : m_data(value)
-{ }
-
-ByteArray::ByteArray(const char* value, size_t n) {
-    const string s(value, n);
-    m_data.assign(s.begin(), s.end());
-}
-
-ByteArray::ByteArray(const ByteArray& other)
-    : m_data(other.m_data)
-{ }
-
-ByteArray::~ByteArray(void) { }
-
-ByteArray& ByteArray::operator=(const ByteArray& other) {
-    m_data = other.m_data;
-    return *this;
-}
-
-void ByteArray::Clear(void) {
-    m_data.clear();
-}
-
-const char* ByteArray::ConstData(void) const {
-    return &m_data[0];
-}
-
-char* ByteArray::Data(void) {
-    return &m_data[0];
-}
-
-const char& ByteArray::operator[](size_t i) const {
-    return m_data[i];
-}
-
-char& ByteArray::operator[](size_t i) {
-    return m_data[i];
-}
-
-size_t ByteArray::IndexOf(const char c, const size_t from, const size_t to) const {
-    const size_t size = ( (to == 0 ) ? m_data.size() : to );
-    for ( size_t i = from; i < size; ++i ) {
-        if ( m_data.at(i) == c ) 
-            return i;
-    }
-    return m_data.size();
-}
-
-ByteArray& ByteArray::Remove(size_t from, size_t n) {
-
-    // if 'from' outside range, just return
-    const size_t originalSize = m_data.size();
-    if ( from >= originalSize )
-        return *this;
-
-    // if asked to clip from 'from' to end (or beyond), simply resize
-    if ( from + n >= originalSize )
-        Resize(from);
-
-    // otherwise, shift data & resize
-    else {
-        memmove( &m_data[from], &m_data[from+n], (originalSize-from-n) );
-        Resize(originalSize - n);
-    }
-
-    // return reference to modified byte array
-    return *this;
-}
-
-void ByteArray::Resize(size_t n) {
-    m_data.resize(n, 0);
-}
-
-size_t ByteArray::Size(void) const {
-    return m_data.size();
-}
-
-void ByteArray::Squeeze(void) {
-    vector<char> t(m_data);
-    t.swap(m_data);
-}
diff --git a/bamtools/src/api/internal/io/ByteArray_p.h b/bamtools/src/api/internal/io/ByteArray_p.h
deleted file mode 100644
index 7e95f6e..0000000
--- a/bamtools/src/api/internal/io/ByteArray_p.h
+++ /dev/null
@@ -1,69 +0,0 @@
-// ***************************************************************************
-// ByteArray_p.h (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 November 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides a dynamic, variable-length byte buffer
-// ***************************************************************************
-
-#ifndef BYTEARRAY_P_H
-#define BYTEARRAY_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#include "api/api_global.h"
-#include <string>
-#include <vector>
-
-namespace BamTools {
-namespace Internal {
-
-// provides a wrapper around a byte vector
-class ByteArray {
-
-    // ctors & dtor
-    public:
-        ByteArray(void);
-        ByteArray(const std::string& value);
-        ByteArray(const std::vector<char>& value);
-        ByteArray(const char* value, size_t n);
-        ByteArray(const ByteArray& other);
-        ~ByteArray(void);
-
-        ByteArray& operator=(const ByteArray& other);
-
-    // ByteArray interface
-    public:
-
-        // data access
-        const char* ConstData(void) const;
-        char* Data(void);
-        const char& operator[](size_t i) const;
-        char& operator[](size_t i);
-
-        // byte array manipulation
-        void Clear(void);
-        size_t IndexOf(const char c, const size_t from = 0, const size_t to = 0) const;
-        ByteArray& Remove(size_t from, size_t n);
-        void Resize(size_t n);
-        size_t Size(void) const;
-        void Squeeze(void);
-
-    // data members
-    private:
-        std::vector<char> m_data;
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // BYTEARRAY_P_H
diff --git a/bamtools/src/api/internal/io/CMakeLists.txt b/bamtools/src/api/internal/io/CMakeLists.txt
deleted file mode 100644
index 28153d5..0000000
--- a/bamtools/src/api/internal/io/CMakeLists.txt
+++ /dev/null
@@ -1,48 +0,0 @@
-# ==========================
-# BamTools CMakeLists.txt
-# (c) 2011 Derek Barnett
-#
-# src/api/internal/io
-# ==========================
-
-set( InternalIODir "${InternalDir}/io" )
-
-#--------------------------
-# platform-independent IO
-#--------------------------
-set( CommonIOSources
-        ${InternalIODir}/BamDeviceFactory_p.cpp
-        ${InternalIODir}/BamFile_p.cpp
-        ${InternalIODir}/BamFtp_p.cpp
-        ${InternalIODir}/BamHttp_p.cpp
-        ${InternalIODir}/BamPipe_p.cpp
-        ${InternalIODir}/BgzfStream_p.cpp
-        ${InternalIODir}/ByteArray_p.cpp
-        ${InternalIODir}/HostAddress_p.cpp
-        ${InternalIODir}/HostInfo_p.cpp
-        ${InternalIODir}/HttpHeader_p.cpp
-        ${InternalIODir}/ILocalIODevice_p.cpp
-        ${InternalIODir}/RollingBuffer_p.cpp
-        ${InternalIODir}/TcpSocket_p.cpp
-        ${InternalIODir}/TcpSocketEngine_p.cpp
-)
-
-#------------------------
-# platform-dependent IO
-#------------------------
-if( WIN32 )
-    set( PlatformIOSources ${InternalIODir}/TcpSocketEngine_win_p.cpp )
-else()
-    set( PlatformIOSources ${InternalIODir}/TcpSocketEngine_unix_p.cpp )
-endif()
-
-#---------------------------
-# make build-specific list
-#---------------------------
-set( InternalIOSources
-        ${CommonIOSources}
-        ${PlatformIOSources} 
-
-        PARENT_SCOPE # <-- leave this last
-)
-
diff --git a/bamtools/src/api/internal/io/HostAddress_p.cpp b/bamtools/src/api/internal/io/HostAddress_p.cpp
deleted file mode 100644
index 5c42c5b..0000000
--- a/bamtools/src/api/internal/io/HostAddress_p.cpp
+++ /dev/null
@@ -1,396 +0,0 @@
-// ***************************************************************************
-// HostAddress_p.cpp (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 8 December 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides a generic IP address container
-// ***************************************************************************
-
-#include "api/internal/io/HostAddress_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#include <cctype>
-#include <cstdlib>
-#include <sstream>
-#include <vector>
-using namespace std;
-
-// ------------------------
-// static utility methods
-// ------------------------
-
-namespace BamTools {
-namespace Internal {
-
-// split a string into fields, on delimiter character
-static inline
-vector<string> Split(const string& source, char delim) {
-    stringstream ss(source);
-    string field;
-    vector<string> fields;
-    while ( getline(ss, field, delim) )
-        fields.push_back(field);
-    return fields;
-}
-
-// return number of occurrences of @pattern in @source
-static inline
-uint8_t CountHits(const string& source, const string& pattern) {
-
-    uint8_t count(0);
-    size_t found = source.find(pattern);
-    while ( found != string::npos ) {
-        ++count;
-        found = source.find(pattern, found+1);
-    }
-    return count;
-}
-
-static
-bool ParseIp4(const string& address, uint32_t& maybeIp4 ) {
-
-    // split IP address into string fields
-    vector<string> addressFields = Split(address, '.');
-    if ( addressFields.size() != 4 )
-        return false;
-
-    // convert each field to integer value
-    uint32_t ipv4(0);
-    for ( uint8_t i = 0; i < 4; ++i ) {
-
-        const string& field = addressFields.at(i);
-        const size_t fieldSize = field.size();
-        for ( size_t j = 0; j < fieldSize; ++j ) {
-            if ( !isdigit(field[j]) )
-                return false;
-        }
-
-        int value = atoi( addressFields.at(i).c_str() );
-        if ( value < 0 || value > 255 )
-            return false;
-
-        // append byte value
-        ipv4 <<= 8;
-        ipv4 += value;
-    }
-
-    // store 32-bit IP address & return success
-    maybeIp4 = ipv4;
-    return true;
-}
-
-static
-bool ParseIp6(const string& address, uint8_t* maybeIp6 ) {
-
-    string tmp = address;
-
-    // look for '%' char (if found, lop off that part of address)
-    // we're going to ignore any link-local zone index, for now at least
-    const size_t percentFound = tmp.rfind('%');
-    if ( percentFound != string::npos )
-        tmp = tmp.substr(0, percentFound);
-
-    // split IP address into string fields
-    vector<string> fields = Split(tmp, ':');
-    const uint8_t numFields = fields.size();
-    if ( numFields < 3 || numFields > 8 )
-        return false;
-
-    // get number of '::' separators
-    const uint8_t numColonColons = CountHits(tmp, "::");
-    if ( numFields == 8 && numColonColons > 1 )
-        return false;
-
-    // check valid IPv6 'compression'
-    // must be valid 'pure' IPv6 or mixed IPv4/6 notation
-    const size_t dotFound = tmp.find('.');
-    const bool isMixed = ( dotFound != string::npos );
-    if ( numColonColons != 1 && (numFields < (isMixed ? 7 : 8)) )
-        return false;
-
-    // iterate over provided fields
-    size_t index = 16;
-    size_t fillCount = 9 - numFields;
-    for ( int8_t i = numFields - 1; i >= 0; --i ) {
-        if ( index == 0 )
-            return false;
-        const string& field = fields.at(i);
-
-        // if field empty
-        if ( field.empty() ) {
-
-            // if last field empty
-            if ( i == numFields - 1 ) {
-                const string& previousField = fields.at(i-1);
-                if ( previousField.empty() )
-                    return false;
-                maybeIp6[--index] = 0;
-                maybeIp6[--index] = 0;
-            }
-
-            // if first field empty
-            else if ( i == 0 ) {
-                // make sure ':' isn't first character
-                const string& nextField = fields.at(i+1);
-                if ( nextField.empty() ) return false;
-                maybeIp6[--index] = 0;
-                maybeIp6[--index] = 0;
-            }
-
-            // fill in 'compressed' 0s
-            else {
-                for ( uint8_t j = 0; j < fillCount; ++j ) {
-                    if ( index == 0 ) return false;
-                    maybeIp6[--index] = 0;
-                    maybeIp6[--index] = 0;
-                }
-            }
-        }
-
-        // field has data
-        else {
-            uint32_t value = static_cast<uint32_t>( strtoul(field.c_str(), 0, 16) );
-
-            if ( value <= 0xffff ) {
-                maybeIp6[--index] =  value       & 0xff;
-                maybeIp6[--index] = (value >> 8) & 0xff;
-            }
-
-            // possible mixed IPv4/6 notation
-            else {
-
-                // mixed field must be last
-                if ( i != numFields - 1 )
-                    return false;
-
-                // parse the IPv4 section
-                uint32_t maybeIp4;
-                if ( !ParseIp4(field, maybeIp4) )
-                    return false;
-
-                // store IPv4 fields in IPv6 container
-                maybeIp6[--index] =  maybeIp4        & 0xff;
-                maybeIp6[--index] = (maybeIp4 >> 8)  & 0xff;
-                maybeIp6[--index] = (maybeIp4 >> 16) & 0xff;
-                maybeIp6[--index] = (maybeIp4 >> 24) & 0xff;
-                --fillCount;
-            }
-        }
-    }
-
-    // should have parsed OK, return success
-    return true;
-}
-
-} // namespace Internal
-} // namespace BamTools
-
-// ----------------------------
-// HostAddress implementation
-// ----------------------------
-
-HostAddress::HostAddress(void)
-    : m_protocol(HostAddress::UnknownNetworkProtocol)
-    , m_ip4Address(0)
-    , m_hasIpAddress(true)
-{ }
-
-HostAddress::HostAddress(const uint32_t ip4Address)
-    : m_protocol(HostAddress::UnknownNetworkProtocol)
-    , m_ip4Address(0)
-    , m_hasIpAddress(true)
-{
-    SetAddress(ip4Address);
-}
-
-HostAddress::HostAddress(const uint8_t* ip6Address)
-    : m_protocol(HostAddress::UnknownNetworkProtocol)
-    , m_ip4Address(0)
-    , m_hasIpAddress(true)
-{
-    SetAddress(ip6Address);
-}
-
-HostAddress::HostAddress(const IPv6Address& ip6Address)
-    : m_protocol(HostAddress::UnknownNetworkProtocol)
-    , m_ip4Address(0)
-    , m_hasIpAddress(true)
-{
-    SetAddress(ip6Address);
-}
-
-HostAddress::HostAddress(const std::string& address)
-    : m_protocol(HostAddress::UnknownNetworkProtocol)
-    , m_ip4Address(0)
-{
-    SetAddress(address);
-}
-
-HostAddress::HostAddress(const HostAddress& other)
-    : m_protocol(other.m_protocol)
-    , m_ip4Address(other.m_ip4Address)
-    , m_ip6Address(other.m_ip6Address)
-    , m_ipString(other.m_ipString)
-    , m_hasIpAddress(other.m_hasIpAddress)
-{ }
-
-HostAddress::~HostAddress(void) { }
-
-bool HostAddress::operator==(const HostAddress& other) const {
-
-    // if self is IPv4
-    if ( m_protocol == HostAddress::IPv4Protocol ) {
-        return ( other.m_protocol == HostAddress::IPv4Protocol &&
-                 m_ip4Address == other.m_ip4Address
-               );
-    }
-
-    // if self is IPv6
-    else if ( m_protocol == HostAddress::IPv6Protocol ) {
-        return ( other.m_protocol == HostAddress::IPv6Protocol &&
-                 memcmp(&m_ip6Address, &other.m_ip6Address, sizeof(IPv6Address)) == 0
-               );
-    }
-
-    // otherwise compare protocols
-    else return m_protocol == other.m_protocol;
-}
-
-bool HostAddress::operator<(const HostAddress& other) const {
-
-    // if self is IPv4
-    if ( m_protocol == HostAddress::IPv4Protocol ) {
-        if ( other.m_protocol == HostAddress::IPv4Protocol )
-            return m_ip4Address < m_ip4Address;
-    }
-
-    // if self is IPv6
-    else if ( m_protocol == HostAddress::IPv6Protocol ) {
-        if ( other.m_protocol == HostAddress::IPv6Protocol )
-            return (memcmp(&m_ip6Address, &other.m_ip6Address, sizeof(IPv6Address)) < 0);
-    }
-
-    // otherwise compare protocol types
-    return m_protocol < other.m_protocol;
-}
-
-void HostAddress::Clear(void) {
-
-    m_protocol = HostAddress::UnknownNetworkProtocol;
-    m_ip4Address = 0;
-    memset(&m_ip6Address, 0, sizeof(IPv6Address));
-    m_ipString.clear();
-
-    // this may feel funny, but cleared IP (equivalent to '0.0.0.0') is technically valid
-    // and that's not really what this flag is checking anyway
-    //
-    // this flag is false *iff* the string passed in is a 'plain-text' hostname (www.foo.bar)
-    m_hasIpAddress = true;
-}
-
-bool HostAddress::HasIPAddress(void) const {
-    return m_hasIpAddress;
-}
-
-bool HostAddress::IsNull(void) const {
-    return m_protocol == HostAddress::UnknownNetworkProtocol;
-}
-
-uint32_t HostAddress::GetIPv4Address(void) const {
-    return m_ip4Address;
-}
-
-IPv6Address HostAddress::GetIPv6Address(void) const {
-    return m_ip6Address;
-}
-
-std::string HostAddress::GetIPString(void) const {
-
-    stringstream ss("");
-
-    // IPv4 format
-    if ( m_protocol == HostAddress::IPv4Protocol ) {
-        ss << ( (m_ip4Address>>24) & 0xff ) << '.'
-           << ( (m_ip4Address>>16) & 0xff ) << '.'
-           << ( (m_ip4Address>> 8) & 0xff ) << '.'
-           << (  m_ip4Address      & 0xff );
-
-    }
-
-    // IPv6 format
-    else if ( m_protocol == HostAddress::IPv6Protocol ) {
-        for ( uint8_t i = 0; i < 8; ++i ) {
-            if ( i != 0 )
-                ss << ':';
-                ss << hex << ( (uint16_t(m_ip6Address[2*i]) << 8) |
-                               (uint16_t(m_ip6Address[2*i+1]))
-                             );
-        }
-    }
-
-    // return result (empty string if unknown protocol)
-    return ss.str();
-}
-
-HostAddress::NetworkProtocol HostAddress::GetProtocol(void) const {
-    return m_protocol;
-}
-
-bool HostAddress::ParseAddress(void) {
-
-    // all IPv6 addresses should have a ':'
-    string s = m_ipString;
-    size_t found = s.find(':');
-    if ( found != string::npos ) {
-        // try parse IP6 address
-        uint8_t maybeIp6[16];
-        if ( ParseIp6(s, maybeIp6) ) {
-            SetAddress(maybeIp6);
-            m_protocol = HostAddress::IPv6Protocol;
-            return true;
-        }
-    }
-
-    // all IPv4 addresses should have a '.'
-    found = s.find('.');
-    if ( found != string::npos ) {
-        uint32_t maybeIp4(0);
-        if ( ParseIp4(s, maybeIp4) ) {
-            SetAddress(maybeIp4);
-            m_protocol = HostAddress::IPv4Protocol;
-            return true;
-        }
-    }
-
-    // else likely just a plain-text host name "www.foo.bar"
-    // will need to look up IP address info later
-    m_protocol = HostAddress::UnknownNetworkProtocol;
-    return false;
-}
-
-void HostAddress::SetAddress(const uint32_t ip4Address) {
-    m_ip4Address = ip4Address;
-    m_protocol = HostAddress::IPv4Protocol;
-    m_hasIpAddress = true;
-}
-
-void HostAddress::SetAddress(const uint8_t* ip6Address) {
-    for ( uint8_t i = 0; i < 16; ++i )
-        m_ip6Address[i] = ip6Address[i];
-    m_protocol = HostAddress::IPv6Protocol;
-    m_hasIpAddress = true;
-}
-
-void HostAddress::SetAddress(const IPv6Address& ip6Address) {
-    m_ip6Address = ip6Address;
-    m_ip4Address = 0;
-    m_protocol = HostAddress::IPv6Protocol;
-    m_hasIpAddress = true;
-}
-
-void HostAddress::SetAddress(const std::string& address) {
-    m_ipString = address;
-    m_hasIpAddress = ParseAddress();
-}
diff --git a/bamtools/src/api/internal/io/HostAddress_p.h b/bamtools/src/api/internal/io/HostAddress_p.h
deleted file mode 100644
index 4c1b360..0000000
--- a/bamtools/src/api/internal/io/HostAddress_p.h
+++ /dev/null
@@ -1,100 +0,0 @@
-// ***************************************************************************
-// HostAddress_p.h (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 November 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides a generic IP address container
-// ***************************************************************************
-
-#ifndef HOSTADDRESS_P_H
-#define HOSTADDRESS_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#include "api/api_global.h"
-#include <cstring>
-#include <string>
-
-namespace BamTools {
-namespace Internal {
-
-struct IPv6Address {
-
-    // ctor
-    inline IPv6Address(void) { memset(&data, 0, sizeof(uint8_t)*16); }
-
-    // data access (no bounds checking)
-    inline uint8_t& operator[](size_t index)       { return data[index]; }
-    inline uint8_t  operator[](size_t index) const { return data[index]; }
-
-    // data
-    uint8_t data[16];
-};
-
-class HostAddress {
-
-    // enums
-    public:
-        enum NetworkProtocol { UnknownNetworkProtocol = -1
-                             , IPv4Protocol = 0
-                             , IPv6Protocol
-                             };
-
-    // ctors & dtor
-    public:
-        HostAddress(void);
-        explicit HostAddress(const uint32_t ip4Address);
-        explicit HostAddress(const uint8_t* ip6Address);
-        explicit HostAddress(const IPv6Address& ip6Address);
-        explicit HostAddress(const std::string& address);
-        HostAddress(const HostAddress& other);
-        ~HostAddress(void);
-
-    // HostAddress interface
-    public:
-        void Clear(void);
-        bool HasIPAddress(void) const; // returns whether string address could be converted to IP address
-        bool IsNull(void) const;
-
-        uint32_t    GetIPv4Address(void) const;
-        IPv6Address GetIPv6Address(void) const;
-        std::string GetIPString(void) const;
-        HostAddress::NetworkProtocol GetProtocol(void) const;
-
-        void SetAddress(const uint32_t ip4Address);
-        void SetAddress(const uint8_t* ip6Address);
-        void SetAddress(const IPv6Address& ip6Address);
-        void SetAddress(const std::string& address);
-
-    // HostAddress comparison operators
-    public:
-        bool operator==(const HostAddress& other) const;
-        bool operator!=(const HostAddress& other) const { return !( operator==(other) ); }
-        bool operator<(const HostAddress& other) const;
-
-    // internal methods
-    private:
-        bool ParseAddress(void);
-
-    // data members
-    private:
-        HostAddress::NetworkProtocol m_protocol;
-        uint32_t    m_ip4Address;
-        IPv6Address m_ip6Address;
-        std::string m_ipString;
-        bool        m_hasIpAddress; // true until string passed in, then signifies whether string was an IP
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // HOSTADDRESS_P_H
diff --git a/bamtools/src/api/internal/io/HostInfo_p.cpp b/bamtools/src/api/internal/io/HostInfo_p.cpp
deleted file mode 100644
index 40b1047..0000000
--- a/bamtools/src/api/internal/io/HostInfo_p.cpp
+++ /dev/null
@@ -1,224 +0,0 @@
-// ***************************************************************************
-// HostInfo_p.cpp (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 8 December 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides DNS lookup functionality for hostname & its discovered addresses
-// ***************************************************************************
-
-#include "api/internal/io/HostInfo_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-// platorm-specifics
-#ifdef _WIN32
-#  include "api/internal/io/NetWin_p.h"
-#else
-#  include "api/internal/io/NetUnix_p.h"
-#endif
-
-// standard C++ includes
-#include <cstdlib>
-#include <cstring>
-#include <set>
-using namespace std;
-
-// -------------------------
-// HostInfo implementation
-// -------------------------
-
-HostInfo::HostInfo(void)
-    : m_error(HostInfo::NoError)
-{ }
-
-HostInfo::HostInfo(const HostInfo& other)
-    : m_hostName(other.m_hostName)
-    , m_addresses(other.m_addresses)
-    , m_error(other.m_error)
-    , m_errorString(other.m_errorString)
-{ }
-
-HostInfo::~HostInfo(void) { }
-
-vector<HostAddress> HostInfo::Addresses(void) const {
-    return m_addresses;
-}
-
-HostInfo::ErrorType HostInfo::GetError(void) const {
-    return m_error;
-}
-
-string HostInfo::GetErrorString(void) const {
-    return m_errorString;
-}
-
-string HostInfo::HostName(void) const {
-    return m_hostName;
-}
-
-void HostInfo::SetAddresses(const std::vector<HostAddress>& addresses) {
-    m_addresses = addresses;
-}
-
-void HostInfo::SetError(const HostInfo::ErrorType error) {
-    m_error = error;
-}
-
-void HostInfo::SetErrorString(const std::string& errorString) {
-    m_errorString = errorString;
-}
-
-void HostInfo::SetHostName(const string& name) {
-    m_hostName = name;
-}
-
-// ---------------------------------
-// HostInfo::Lookup(host, port)
-//  - the real "heavy-lifter" here
-// ---------------------------------
-
-HostInfo HostInfo::Lookup(const string& hostname, const string& port) {
-
-    HostInfo result;
-    result.SetHostName(hostname);
-    set<HostAddress> uniqueAddresses;
-
-#ifdef _WIN32
-    WindowsSockInit init;
-#endif
-
-    HostAddress address;
-    address.SetAddress(hostname);
-
-    // if hostname is an IP string ('0.0.0.0' or IPv6 format)
-    // do reverse lookup for host domain name
-    //
-    // TODO: might just remove this... not sure if proper 'hostname' from IP string is needed
-    //
-    //       so far, haven't been able to successfully fetch a domain name with reverse DNS
-    //       getnameinfo() on test sites just returns original IP string. BUT this is likely a rare
-    //       case that client code tries to use an IP string and the connection should work fine
-    //       anyway. GetHostName() just won't quite show what I was hoping for. :(
-    if ( address.HasIPAddress() ) {
-
-        const uint16_t portNum = static_cast<uint16_t>( atoi(port.c_str()) );
-
-        sockaddr_in  sa4;
-        sockaddr_in6 sa6;
-        sockaddr* sa = 0;
-        BT_SOCKLEN_T saSize = 0;
-
-        // IPv4
-        if ( address.GetProtocol() == HostAddress::IPv4Protocol ) {
-            sa = (sockaddr*)&sa4;
-            saSize = sizeof(sa4);
-            memset(&sa4, 0, sizeof(sa4));
-            sa4.sin_family = AF_INET;
-            sa4.sin_addr.s_addr = htonl(address.GetIPv4Address());
-            sa4.sin_port = htons(portNum);
-        }
-
-        // IPv6
-        else if ( address.GetProtocol() == HostAddress::IPv4Protocol ){
-            sa = (sockaddr*)&sa6;
-            saSize = sizeof(sa6);
-            memset(&sa6, 0, sizeof(sa6));
-            sa6.sin6_family = AF_INET6;
-            memcpy(sa6.sin6_addr.s6_addr, address.GetIPv6Address().data, sizeof(sa6.sin6_addr.s6_addr));
-            sa6.sin6_port = htons(portNum);
-        }
-
-        // unknown (should be unreachable)
-        else BT_ASSERT_X(false, "HostInfo::Lookup: unknown network protocol");
-
-        // lookup name for IP
-        char hbuf[NI_MAXHOST];
-        char serv[NI_MAXSERV];
-        if ( sa && (getnameinfo(sa, saSize, hbuf, sizeof(hbuf), serv, sizeof(serv), 0) == 0) )
-            result.SetHostName(string(hbuf));
-
-        // if no domain name found, just use the original address's IP string
-        if ( result.HostName().empty() )
-            result.SetHostName(address.GetIPString());
-
-        // store address in HostInfo
-        uniqueAddresses.insert(address);
-    }
-
-    // otherwise, hostname is a domain name ('www.foo.bar')
-    // do 'normal' lookup
-    else {
-
-        // setup address lookup 'hints'
-        addrinfo hints;
-        memset(&hints, 0, sizeof(hints));
-        hints.ai_family   = AF_UNSPEC;   // allow either IPv4 or IPv6
-        hints.ai_socktype = SOCK_STREAM; // for TCP
-        hints.ai_protocol = IPPROTO_TCP;
-
-        // fetch addresses for requested hostname/port
-        addrinfo* res;
-        int status = getaddrinfo(hostname.c_str(), port.c_str(), &hints, &res );
-
-        // if everything OK
-        if ( status == 0 ) {
-
-            // iterate over all IP addresses found
-            addrinfo* p = res;
-            for ( ; p != NULL; p = p->ai_next ) {
-
-                // IPv4
-                if ( p->ai_family == AF_INET ) {
-                    sockaddr_in* ipv4 = (sockaddr_in*)p->ai_addr;
-                    HostAddress a( ntohl(ipv4->sin_addr.s_addr) );
-                    uniqueAddresses.insert(a);
-                }
-
-                // IPv6
-                else if ( p->ai_family == AF_INET6 ) {
-                    sockaddr_in6* ipv6 = (sockaddr_in6*)p->ai_addr;
-                    HostAddress a(ipv6->sin6_addr.s6_addr);
-                    uniqueAddresses.insert(a);
-                }
-            }
-
-            // if we iterated, but no addresses were stored
-            if ( uniqueAddresses.empty() && (p == NULL) ) {
-                result.SetError(HostInfo::UnknownError);
-                result.SetErrorString("HostInfo: unknown address types found");
-            }
-        }
-
-        // handle error cases
-        else if (
-#ifndef _WIN32
-                     status == EAI_NONAME
-                  || status == EAI_FAIL
-#  ifdef EAI_NODATA
-                  || status == EAI_NODATA  // officially deprecated, but just in case we happen to hit it
-#  endif // EAI_NODATA
-
-#else  // _WIN32
-                     WSAGetLastError() == WSAHOST_NOT_FOUND
-                  || WSAGetLastError() == WSANO_DATA
-                  || WSAGetLastError() == WSANO_RECOVERY
-#endif // _WIN32
-                )
-        {
-            result.SetError(HostInfo::HostNotFound);
-            result.SetErrorString("HostInfo: host not found");
-        }
-        else {
-            result.SetError(HostInfo::UnknownError);
-            result.SetErrorString("HostInfo: unknown error encountered");
-        }
-
-        // cleanup
-        freeaddrinfo(res);
-    }
-
-    // store fetched addresses (converting set -> vector) in result & return
-    result.SetAddresses( vector<HostAddress>(uniqueAddresses.begin(), uniqueAddresses.end()) );
-    return result;
-}
diff --git a/bamtools/src/api/internal/io/HostInfo_p.h b/bamtools/src/api/internal/io/HostInfo_p.h
deleted file mode 100644
index ad03d37..0000000
--- a/bamtools/src/api/internal/io/HostInfo_p.h
+++ /dev/null
@@ -1,76 +0,0 @@
-// ***************************************************************************
-// HostInfo_p.h (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 November 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides DNS lookup functionality for hostname/IP addresses
-// ***************************************************************************
-
-#ifndef HOSTINFO_P_H
-#define HOSTINFO_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#include "api/internal/io/HostAddress_p.h"
-#include <string>
-#include <vector>
-
-namespace BamTools {
-namespace Internal {
-
-class HostInfo {
-
-    public:
-        enum ErrorType { NoError = 0
-                       , HostNotFound
-                       , UnknownError
-                       };
-
-    // ctors & dtor
-    public:
-        HostInfo(void);
-        HostInfo(const HostInfo& other);
-        ~HostInfo(void);
-
-    // HostInfo interface
-    public:
-        std::string HostName(void) const;
-        void SetHostName(const std::string& name);
-
-        std::vector<HostAddress> Addresses(void) const;
-        void SetAddresses(const std::vector<HostAddress>& addresses);
-
-        HostInfo::ErrorType GetError(void) const;
-        std::string GetErrorString(void) const;
-
-    // internal methods
-    private:
-        void SetError(const HostInfo::ErrorType error);
-        void SetErrorString(const std::string& errorString);
-
-    // static methods
-    public:
-        static HostInfo Lookup(const std::string& hostname,
-                               const std::string& port);
-
-    // data members
-    private:
-        std::string m_hostName;
-        std::vector<HostAddress> m_addresses;
-        HostInfo::ErrorType m_error;
-        std::string m_errorString;
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // HOSTINFO_P_H
diff --git a/bamtools/src/api/internal/io/HttpHeader_p.cpp b/bamtools/src/api/internal/io/HttpHeader_p.cpp
deleted file mode 100644
index 156df26..0000000
--- a/bamtools/src/api/internal/io/HttpHeader_p.cpp
+++ /dev/null
@@ -1,395 +0,0 @@
-// ***************************************************************************
-// HttpHeader_p.cpp (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 13 January 2012 (DB)
-// ---------------------------------------------------------------------------
-// Provides a generic interface for parsing/generating HTTP headers, along
-// with specialized request & response header types
-// ***************************************************************************
-
-#include "api/internal/io/HttpHeader_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#include <cstdlib>
-#include <sstream>
-#include <vector>
-using namespace std;
-
-namespace BamTools {
-
-// -----------
-// constants
-// -----------
-
-namespace Constants {
-
-static const char CAR_RET_CHAR = '\r';
-static const char COLON_CHAR   = ':';
-static const char DOT_CHAR     = '.';
-static const char NEWLINE_CHAR = '\n';
-static const char SPACE_CHAR   = ' ';
-static const char TAB_CHAR     = '\t';
-
-static const string FIELD_NEWLINE   = "\r\n";
-static const string FIELD_SEPARATOR = ": ";
-static const string HTTP_STRING     = "HTTP/";
-
-} // namespace Constants
-
-// ------------------------
-// static utility methods
-// ------------------------
-
-namespace Internal {
-
-static inline
-bool IsSpace(const char c) {
-    const int n = static_cast<int>(c);
-    return ( n== 0 || (n <= 13 && n >= 9) );
-}
-
-// split on hitting single char delim
-static vector<string> Split(const string& source, const char delim) {
-    stringstream ss(source);
-    string field;
-    vector<string> fields;
-    while ( getline(ss, field, delim) )
-        fields.push_back(field);
-    return fields;
-}
-
-static string Trim(const string& source) {
-
-    // skip if empty string
-    if ( source.empty() )
-        return source;
-
-    // fetch string data
-    const char*  s    = source.data(); // ignoring null-term on purpose
-    const size_t size = source.size();
-    size_t start = 0;
-    size_t end   = size-1;
-
-    // skip if no spaces at start or end
-    if ( !IsSpace(s[start]) && !IsSpace( s[end] ) )
-        return source;
-
-    // remove leading whitespace
-    while ( (start != end) && IsSpace(s[start]) )
-        ++start;
-
-    // remove trailing whitespace
-    if ( start <= end ) {
-        while ( end && IsSpace(s[end]) )
-            --end;
-    }
-
-    // return result
-    return string(s + start, (end-start) + 1);
-}
-
-} // namespace Internal
-} // namespace BamTools
-
-// ---------------------------
-// HttpHeader implementation
-// ---------------------------
-
-HttpHeader::HttpHeader(void)
-    : m_isValid(true)
-    , m_majorVersion(1)
-    , m_minorVersion(1)
-{ }
-
-HttpHeader::HttpHeader(const string& s)
-    : m_isValid(true)
-    , m_majorVersion(1)
-    , m_minorVersion(1)
-{
-    Parse(s);
-}
-
-HttpHeader::~HttpHeader(void) { }
-
-bool HttpHeader::ContainsKey(const string& key) const {
-    return ( m_fields.find(key) != m_fields.end() );
-}
-
-int HttpHeader::GetMajorVersion(void) const {
-    return m_majorVersion;
-}
-
-int HttpHeader::GetMinorVersion(void) const {
-    return m_minorVersion;
-}
-
-string HttpHeader::GetValue(const string& key) {
-    if ( ContainsKey(key) )
-        return m_fields[key];
-    else return string();
-}
-
-bool HttpHeader::IsValid(void) const {
-    return m_isValid;
-}
-
-void HttpHeader::Parse(const string& s) {
-
-    // trim whitespace from input string
-    const string trimmed = Trim(s);
-
-    // split into list of header lines
-    vector<string> rawFields = Split(trimmed, Constants::NEWLINE_CHAR);
-
-    // prep our 'cleaned' fields container
-    vector<string> cleanFields;
-    cleanFields.reserve(rawFields.size());
-
-    // remove any empty fields and clean any trailing windows-style carriage returns ('\r')
-    vector<string>::iterator rawFieldIter = rawFields.begin();
-    vector<string>::iterator rawFieldEnd  = rawFields.end();
-    for ( ; rawFieldIter != rawFieldEnd; ++rawFieldIter ) {
-        string& field = (*rawFieldIter);
-
-        // skip empty fields
-        if ( field.empty() )
-            continue;
-
-        // remove carriage returns
-        const size_t fieldSize = field.size();
-        if ( field[fieldSize-1] == Constants::CAR_RET_CHAR )
-            field.resize(fieldSize-1);
-
-        // store cleaned field
-        cleanFields.push_back(field);
-    }
-
-    // skip add'l processing if nothing here
-    if ( cleanFields.empty() )
-        return;
-
-    // parse header lines
-    int lineNumber = 0;
-    vector<string>::const_iterator fieldIter = cleanFields.begin();
-    vector<string>::const_iterator fieldEnd  = cleanFields.end();
-    for ( ; fieldIter != fieldEnd; ++fieldIter, ++lineNumber ) {
-        if ( !ParseLine( (*fieldIter), lineNumber ) ) {
-            m_isValid = false;
-            return;
-        }
-    }
-}
-
-bool HttpHeader::ParseLine(const string& line, int) {
-
-    // find colon position, return failure if not found
-    const size_t colonFound = line.find(Constants::COLON_CHAR);
-    if ( colonFound == string::npos )
-        return false;
-
-    // store key/value (without leading/trailing whitespace) & return success
-    const string key   = Trim(line.substr(0, colonFound));
-    const string value = Trim(line.substr(colonFound+1));
-    m_fields[key] = value;
-    return true;
-}
-
-void HttpHeader::RemoveField(const string& key) {
-    m_fields.erase(key);
-}
-
-void HttpHeader::SetField(const string& key, const string& value) {
-    m_fields[key] = value;
-}
-
-void HttpHeader::SetValid(bool ok) {
-    m_isValid = ok;
-}
-
-void HttpHeader::SetVersion(int major, int minor) {
-    m_majorVersion = major;
-    m_minorVersion = minor;
-}
-
-string HttpHeader::ToString(void) const {
-    string result("");
-    if ( m_isValid ) {
-        map<string, string>::const_iterator fieldIter = m_fields.begin();
-        map<string, string>::const_iterator fieldEnd  = m_fields.end();
-        for ( ; fieldIter != fieldEnd; ++fieldIter ) {
-            const string& key   = (*fieldIter).first;
-            const string& value = (*fieldIter).second;
-            const string& line  = key   + Constants::FIELD_SEPARATOR +
-                                  value + Constants::FIELD_NEWLINE;
-            result += line;
-        }
-    }
-    return result;
-}
-
-// ----------------------------------
-// HttpRequestHeader implementation
-// ----------------------------------
-
-HttpRequestHeader::HttpRequestHeader(const string& method,
-                                     const string& resource,
-                                     int majorVersion,
-                                     int minorVersion)
-    : HttpHeader()
-    , m_method(method)
-    , m_resource(resource)
-{
-    SetVersion(majorVersion, minorVersion);
-}
-
-HttpRequestHeader::~HttpRequestHeader(void) { }
-
-string HttpRequestHeader::GetMethod(void) const {
-    return m_method;
-}
-
-string HttpRequestHeader::GetResource(void) const {
-    return m_resource;
-}
-
-bool HttpRequestHeader::ParseLine(const string& line, int lineNumber) {
-
-    // if not 'request line', just let base class parse
-    if ( lineNumber != 0 )
-        return HttpHeader::ParseLine(line, lineNumber);
-
-    // fail if empty line
-    if ( line.empty() )
-        return false;
-
-    // walk through request line, storing positions
-    //    GET /path/to/resource HTTP/1.1
-    //    ^  ^^                ^^
-    const size_t foundMethod = line.find_first_not_of(Constants::SPACE_CHAR); // skip any leading whitespace
-    if ( foundMethod == string::npos ) return false;
-    const size_t foundFirstSpace = line.find(Constants::SPACE_CHAR, foundMethod+1);
-    if ( foundFirstSpace == string::npos ) return false;
-    const size_t foundResource = line.find_first_not_of(Constants::SPACE_CHAR, foundFirstSpace+1);
-    if ( foundResource == string::npos ) return false;
-    const size_t foundSecondSpace = line.find(Constants::SPACE_CHAR, foundResource+1);
-    if ( foundSecondSpace == string::npos ) return false;
-    const size_t foundVersion= line.find_first_not_of(Constants::SPACE_CHAR, foundSecondSpace+1);
-    if ( foundVersion == string::npos ) return false;
-
-    // parse out method & resource
-    m_method   = line.substr(foundMethod,   foundFirstSpace  - foundMethod);
-    m_resource = line.substr(foundResource, foundSecondSpace - foundResource);
-
-    // parse out version numbers
-    const string temp = line.substr(foundVersion);
-    if ( (temp.find(Constants::HTTP_STRING) != 0) || (temp.size() != 8) )
-        return false;
-    const int major = static_cast<int>(temp.at(5) - '0');
-    const int minor = static_cast<int>(temp.at(7) - '0');
-    SetVersion(major, minor);
-
-    // if we get here, return success
-    return true;
-}
-
-string HttpRequestHeader::ToString(void) const {
-    stringstream request("");
-    request << m_method   << Constants::SPACE_CHAR
-            << m_resource << Constants::SPACE_CHAR
-            << Constants::HTTP_STRING << GetMajorVersion() << Constants::DOT_CHAR << GetMinorVersion()
-            << Constants::FIELD_NEWLINE
-            << HttpHeader::ToString()
-            << Constants::FIELD_NEWLINE;
-    return request.str();
-}
-
-// -----------------------------------
-// HttpResponseHeader implementation
-// -----------------------------------
-
-HttpResponseHeader::HttpResponseHeader(const int statusCode,
-                                       const string& reason,
-                                       int majorVersion,
-                                       int minorVersion)
-
-    : HttpHeader()
-    , m_statusCode(statusCode)
-    , m_reason(reason)
-{
-    SetVersion(majorVersion, minorVersion);
-}
-
-HttpResponseHeader::HttpResponseHeader(const string& s)
-    : HttpHeader()
-    , m_statusCode(0)
-{
-    Parse(s);
-}
-
-HttpResponseHeader::~HttpResponseHeader(void) { }
-
-string HttpResponseHeader::GetReason(void) const  {
-    return m_reason;
-}
-
-int HttpResponseHeader::GetStatusCode(void) const {
-    return m_statusCode;
-}
-
-bool HttpResponseHeader::ParseLine(const string& line, int lineNumber) {
-
-    // if not 'status line', just let base class
-    if ( lineNumber != 0 )
-        return HttpHeader::ParseLine(line, lineNumber);
-
-    // fail if empty line
-    if ( line.empty() )
-        return false;
-
-    // walk through status line, storing positions
-    //    HTTP/1.1 200 OK
-    //    ^       ^^  ^^
-
-    const size_t foundVersion = line.find_first_not_of(Constants::SPACE_CHAR); // skip any leading whitespace
-    if ( foundVersion == string::npos ) return false;
-    const size_t foundFirstSpace = line.find(Constants::SPACE_CHAR, foundVersion+1);
-    if ( foundFirstSpace == string::npos ) return false;
-    const size_t foundStatusCode = line.find_first_not_of(Constants::SPACE_CHAR, foundFirstSpace+1);
-    if ( foundStatusCode == string::npos ) return false;
-    const size_t foundSecondSpace = line.find(Constants::SPACE_CHAR, foundStatusCode+1);
-    if ( foundSecondSpace == string::npos ) return false;
-    const size_t foundReason= line.find_first_not_of(Constants::SPACE_CHAR, foundSecondSpace+1);
-    if ( foundReason == string::npos ) return false;
-
-    // parse version numbers
-    string temp = line.substr(foundVersion, foundFirstSpace - foundVersion);
-    if ( (temp.find(Constants::HTTP_STRING) != 0) || (temp.size() != 8) )
-        return false;
-    const int major = static_cast<int>(temp.at(5) - '0');
-    const int minor = static_cast<int>(temp.at(7) - '0');
-    SetVersion(major, minor);
-
-    // parse status code
-    temp = line.substr(foundStatusCode, foundSecondSpace - foundStatusCode);
-    if ( temp.size() != 3 ) return false;
-    m_statusCode = atoi( temp.c_str() );
-
-    // reason phrase should be everything else left
-    m_reason = line.substr(foundReason);
-
-    // if we get here, return success
-    return true;
-}
-
-string HttpResponseHeader::ToString(void) const {
-    stringstream response("");
-    response << Constants::HTTP_STRING << GetMajorVersion() << Constants::DOT_CHAR << GetMinorVersion()
-             << Constants::SPACE_CHAR  << m_statusCode
-             << Constants::SPACE_CHAR  << m_reason
-             << Constants::FIELD_NEWLINE
-             << HttpHeader::ToString()
-             << Constants::FIELD_NEWLINE;
-    return response.str();
-}
diff --git a/bamtools/src/api/internal/io/HttpHeader_p.h b/bamtools/src/api/internal/io/HttpHeader_p.h
deleted file mode 100644
index 6b838ff..0000000
--- a/bamtools/src/api/internal/io/HttpHeader_p.h
+++ /dev/null
@@ -1,132 +0,0 @@
-// ***************************************************************************
-// HttpHeader_p.h (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 13 January 2012 (DB)
-// ---------------------------------------------------------------------------
-// Provides a generic interface for parsing/generating HTTP headers, along
-// with specialized request & response header types
-// ***************************************************************************
-
-#ifndef HTTP_HEADER_P_H
-#define HTTP_HEADER_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#include "api/api_global.h"
-#include <map>
-#include <string>
-
-namespace BamTools {
-namespace Internal {
-
-class HttpHeader {
-
-    // ctors & dtor
-    public:
-        HttpHeader(void);
-        HttpHeader(const std::string& s);
-        virtual ~HttpHeader(void);
-
-    // HttpHeader interface
-    public:
-
-        // header field=>value access
-        bool ContainsKey(const std::string& key) const;
-        std::string GetValue(const std::string& key);
-        void RemoveField(const std::string& key);
-        void SetField(const std::string& key, const std::string& value);
-
-        // get formatted header string
-        virtual std::string ToString(void) const;
-
-        // query HTTP version used
-        int GetMajorVersion(void) const;
-        int GetMinorVersion(void) const;
-
-        // see if header was parsed OK
-        bool IsValid(void) const;
-
-    // internal methods
-    protected:
-        void Parse(const std::string& s);
-        virtual bool ParseLine(const std::string& line, int lineNumber);
-        void SetValid(bool ok);
-        void SetVersion(int major, int minor);
-
-    // data members
-    private:
-        std::map<std::string, std::string> m_fields;
-
-        bool m_isValid;       // should usually be true, only false if error processing a header line
-        int  m_majorVersion;
-        int  m_minorVersion;
-};
-
-class HttpRequestHeader : public HttpHeader {
-
-    // ctor & dtor
-    public:
-        HttpRequestHeader(const std::string& method,      // "GET", "HEAD", ...
-                          const std::string& resource,    // filename
-                          int majorVersion = 1,           // version info
-                          int minorVersion = 1);
-        ~HttpRequestHeader(void);
-
-    // HttpRequestHeader interface
-    public:
-        std::string GetMethod(void) const;
-        std::string GetResource(void) const;
-
-    // HttpHeader implementation
-    public:
-        std::string ToString(void) const;
-    protected:
-        bool ParseLine(const std::string& line, int lineNumber);
-
-    // data members
-    private:
-        std::string m_method;
-        std::string m_resource;
-};
-
-class HttpResponseHeader : public HttpHeader {
-
-    // ctor & dtor
-    public:
-        HttpResponseHeader(const int statusCode,                       // 200, 404, etc
-                           const std::string& reason = std::string(),  // 'reason phrase' for code
-                           int majorVersion = 1,                       // version info
-                           int minorVersion = 1);
-        HttpResponseHeader(const std::string& s);
-        ~HttpResponseHeader(void);
-
-    // HttpRequestHeader interface
-    public:
-        std::string GetReason(void) const;
-        int GetStatusCode(void) const;
-
-    // HttpHeader implementation
-    public:
-        std::string ToString(void) const;
-    protected:
-        bool ParseLine(const std::string& line, int lineNumber);
-
-    // data members
-    private:
-        int m_statusCode;
-        std::string m_reason;
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // HTTP_HEADER_P_H
diff --git a/bamtools/src/api/internal/io/ILocalIODevice_p.cpp b/bamtools/src/api/internal/io/ILocalIODevice_p.cpp
deleted file mode 100644
index d515728..0000000
--- a/bamtools/src/api/internal/io/ILocalIODevice_p.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-// ***************************************************************************
-// ILocalIODevice_p.cpp (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 27 July 2012 (DB)
-// ---------------------------------------------------------------------------
-// Provides shared behavior for files & pipes
-// ***************************************************************************
-
-#include "api/internal/io/ILocalIODevice_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#include <cstdio>
-using namespace std;
-
-ILocalIODevice::ILocalIODevice(void)
-    : IBamIODevice()
-    , m_stream(0)
-{ }
-
-ILocalIODevice::~ILocalIODevice(void) {
-    Close();
-}
-
-void ILocalIODevice::Close(void) {
-
-    // skip if not open
-    if ( !IsOpen() )
-        return;
-
-    // flush & close FILE*
-    fflush(m_stream);
-    fclose(m_stream);
-    m_stream = 0;
-
-    // reset other device state
-    m_mode = IBamIODevice::NotOpen;
-}
-
-int64_t ILocalIODevice::Read(char* data, const unsigned int numBytes) {
-    BT_ASSERT_X( m_stream, "ILocalIODevice::Read: trying to read from null stream" );
-    BT_ASSERT_X( (m_mode & IBamIODevice::ReadOnly), "ILocalIODevice::Read: device not in read-able mode");
-    return static_cast<int64_t>( fread(data, sizeof(char), numBytes, m_stream) );
-}
-
-int64_t ILocalIODevice::Tell(void) const {
-    BT_ASSERT_X( m_stream, "ILocalIODevice::Tell: trying to get file position fromnull stream" );
-    return ftell64(m_stream);
-}
-
-int64_t ILocalIODevice::Write(const char* data, const unsigned int numBytes) {
-    BT_ASSERT_X( m_stream, "ILocalIODevice::Write: tryint to write to null stream" );
-    BT_ASSERT_X( (m_mode & IBamIODevice::WriteOnly), "ILocalIODevice::Write: device not in write-able mode" );
-    return static_cast<int64_t>( fwrite(data, sizeof(char), numBytes, m_stream) );
-}
diff --git a/bamtools/src/api/internal/io/ILocalIODevice_p.h b/bamtools/src/api/internal/io/ILocalIODevice_p.h
deleted file mode 100644
index cf01f90..0000000
--- a/bamtools/src/api/internal/io/ILocalIODevice_p.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// ***************************************************************************
-// ILocalIODevice_p.h (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides shared behavior for files & pipes
-// ***************************************************************************
-
-#ifndef ILOCALIODEVICE_P_H
-#define ILOCALIODEVICE_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#include "api/IBamIODevice.h"
-
-namespace BamTools {
-namespace Internal {
-
-class ILocalIODevice : public IBamIODevice {
-
-    // ctor & dtor
-    public:
-        ILocalIODevice(void);
-        virtual ~ILocalIODevice(void);
-
-    // IBamIODevice implementation
-    public:
-        virtual void Close(void);
-        virtual int64_t Read(char* data, const unsigned int numBytes);
-        virtual int64_t Tell(void) const;
-        virtual int64_t Write(const char* data, const unsigned int numBytes);
-
-    // data members
-    protected:
-        FILE* m_stream;
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // ILOCALIODEVICE_P_H
diff --git a/bamtools/src/api/internal/io/NetUnix_p.h b/bamtools/src/api/internal/io/NetUnix_p.h
deleted file mode 100644
index 8cf75f8..0000000
--- a/bamtools/src/api/internal/io/NetUnix_p.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// ***************************************************************************
-// NetUnix_p.h (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 November 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides common networking-related includes, etc. for all UNIX-like systems
-// ***************************************************************************
-
-#ifndef NETUNIX_P_H
-#define NETUNIX_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#ifndef _WIN32 // <-- source files only include the proper Net*_p.h, but this is a double-check
-
-#include <arpa/inet.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <netdb.h>
-#include <unistd.h>
-
-#ifndef   BT_SOCKLEN_T
-#  define BT_SOCKLEN_T socklen_t
-#endif
-
-#endif // _WIN32
-#endif // NETUNIX_P_H
diff --git a/bamtools/src/api/internal/io/NetWin_p.h b/bamtools/src/api/internal/io/NetWin_p.h
deleted file mode 100644
index 3796e01..0000000
--- a/bamtools/src/api/internal/io/NetWin_p.h
+++ /dev/null
@@ -1,60 +0,0 @@
-// ***************************************************************************
-// NetWin_p.h (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 8 December 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides common networking-related includes, etc. for Windows systems
-//
-// Note: requires Windows XP or later
-// ***************************************************************************
-
-#ifndef NETWIN_P_H
-#define NETWIN_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#ifdef _WIN32 // <-- source files only include the proper Net*_p.h, but this is a double-check
-
-#include <winsock2.h>  // <-- should bring 'windows.h' along with it
-#include <Ws2tcpip.h>
-
-#ifndef   BT_SOCKLEN_T
-#  define BT_SOCKLEN_T int
-#endif
-
-#ifdef _MSC_VER
-#  pragma comment(lib, "ws2_32.lib")
-#endif
-
-namespace BamTools {
-namespace Internal {
-
-// use RAII to ensure WSA is initialized
-class WindowsSockInit {
-    public:
-        WindowsSockInit(void) {
-            WSAData wsadata;
-            WSAStartup(MAKEWORD(2,2), &wsadata); // catch error ?
-        }
-
-        ~WindowsSockInit(void) {
-            WSACleanup();
-        }
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // _WIN32
-
-#endif // NETWIN_P_H
-
diff --git a/bamtools/src/api/internal/io/RollingBuffer_p.cpp b/bamtools/src/api/internal/io/RollingBuffer_p.cpp
deleted file mode 100644
index c712b57..0000000
--- a/bamtools/src/api/internal/io/RollingBuffer_p.cpp
+++ /dev/null
@@ -1,314 +0,0 @@
-// ***************************************************************************
-// RollingBuffer_p.cpp (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 8 December 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides a dynamic I/O FIFO byte queue, which removes bytes as they are
-// read from the front of the buffer and grows to accept bytes being written
-// to buffer end.
-//
-// implementation note: basically a 'smart' wrapper around 1..* ByteArrays
-// ***************************************************************************
-
-#include "api/internal/io/RollingBuffer_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#include <climits>
-#include <cstring>
-#include <algorithm>
-#include <string>
-using namespace std;
-
-// ------------------------------
-// RollingBuffer implementation
-// ------------------------------
-
-RollingBuffer::RollingBuffer(size_t growth)
-    : m_bufferGrowth(growth)
-{
-    // buffer always contains at least 1 (maybe empty) byte array
-    m_data.push_back( ByteArray() );
-
-    // set cleared state
-    Clear();
-}
-
-RollingBuffer::~RollingBuffer(void) { }
-
-size_t RollingBuffer::BlockSize(void) const {
-
-    // if only one byte array in buffer <- needed?
-    if ( m_tailBufferIndex == 0 )
-        return m_tail - m_head;
-
-    // otherwise return remaining num bytes in first array
-    const ByteArray& first = m_data.front();
-    return first.Size() - m_head;
-}
-
-bool RollingBuffer::CanReadLine(void) const {
-    return IndexOf('\n') != string::npos;
-}
-
-void RollingBuffer::Chop(size_t n) {
-
-    // update buffer size
-    if ( n > m_totalBufferSize )
-        m_totalBufferSize = 0;
-    else
-        m_totalBufferSize -= n;
-
-    // loop until target case hit
-    for ( ; ; ) {
-
-        // if only one array, decrement tail
-        if ( m_tailBufferIndex == 0 ) {
-            m_tail -= n;
-
-            // if all data chopped
-            if ( m_tail <= m_head ) {
-                m_head = 0;
-                m_tail = 0;
-            }
-            return;
-        }
-
-        // if there's room in last byte array to 'chop', just decrement tail
-        if ( n <= m_tail ) {
-            m_tail -= n;
-            return;
-        }
-
-        // otherwise we're going to overlap our internal byte arrays
-        // reduce our chop amount by the amount of data in the last byte array
-        n -= m_tail;
-
-        // remove last byte array & set tail to it's end
-        m_data.pop_back();
-        --m_tailBufferIndex;
-        m_tail = m_data.at(m_tailBufferIndex).Size();
-    }
-
-    // if buffer is now empty, reset state & clear up memory
-    if ( IsEmpty() )
-        Clear();
-}
-
-void RollingBuffer::Clear(void) {
-
-    // remove all byte arrays (except first)
-    m_data.erase( m_data.begin()+1, m_data.end() );
-
-    // clear out first byte array
-    m_data[0].Resize(0);
-    m_data[0].Squeeze();
-
-    // reset index & size markers
-    m_head = 0;
-    m_tail = 0;
-    m_tailBufferIndex = 0;
-    m_totalBufferSize = 0;
-}
-
-void RollingBuffer::Free(size_t n) {
-
-    // update buffer size
-    if ( n > m_totalBufferSize )
-        m_totalBufferSize = 0;
-    else
-        m_totalBufferSize -= n;
-
-    // loop until target case hit
-    for ( ; ; ) {
-
-        const size_t blockSize = BlockSize();
-
-        // if there's room in current array
-        if ( n < blockSize ) {
-
-            // shift 'head' over @n bytes
-            m_head += n;
-
-            // check for emptied, single byte array
-            if ( m_head == m_tail && m_tailBufferIndex == 0 ) {
-                m_head = 0;
-                m_tail = 0;
-            }
-
-            break;
-        }
-
-        // otherwise we need to check next byte array
-        // first update amount to remove
-        n -= blockSize;
-
-        // special case - there was only 1 array
-        if ( m_data.size() == 1 ) {
-            if ( m_data.at(0).Size() != m_bufferGrowth )
-                m_data[0].Resize(m_bufferGrowth);
-            m_head = 0;
-            m_tail = 0;
-            m_tailBufferIndex = 0;
-            break;
-        }
-
-        // otherwise, remove first array and move to next iteration
-        m_data.pop_front();
-        --m_tailBufferIndex;
-        m_head = 0;
-    }
-
-    // if buffer is now empty, reset state & clear up memory
-    if ( IsEmpty() )
-        Clear();
-}
-
-size_t RollingBuffer::IndexOf(char c) const {
-
-    // skip processing if empty buffer
-    if ( IsEmpty() )
-        return string::npos;
-
-    size_t index(0);
-
-    // iterate over byte arrays
-    const size_t numBuffers = m_data.size();
-    for ( size_t i = 0; i < numBuffers; ++i ) {
-        const ByteArray& current = m_data.at(i);
-
-        // if on first array, use head; else 0
-        const size_t start = ( (i==0) ? m_head : 0 );
-
-        // if on last array, set end; else use current byte array size
-        const size_t end   = ( (i==m_tailBufferIndex) ? m_tail : current.Size());
-
-        // look through this iteration's byte array for @c
-        const char* p = current.ConstData()+start;
-        for ( size_t j = start; j < end; ++j ) {
-            if ( *p++ == c )
-                return index;
-            ++index;
-        }
-    }
-
-    // no match found
-    return string::npos;
-}
-
-bool RollingBuffer::IsEmpty(void) const {
-    return (m_tailBufferIndex == 0) && (m_tail == 0);
-}
-
-size_t RollingBuffer::Read(char* dest, size_t max) {
-
-    size_t bytesToRead    = std::min(Size(), max);
-    size_t bytesReadSoFar = 0;
-
-    while ( bytesReadSoFar < bytesToRead ) {
-        const char* readPtr = ReadPointer();
-        size_t blockBytes = std::min( (bytesToRead - bytesReadSoFar), BlockSize() );
-        if ( dest )
-            memcpy(dest+bytesReadSoFar, readPtr, blockBytes);
-        bytesReadSoFar += blockBytes;
-        Free(blockBytes);
-    }
-
-    return bytesReadSoFar;
-}
-
-size_t RollingBuffer::ReadLine(char* dest, size_t max) {
-
-    // if we can't read line or if max is 0
-    if ( !CanReadLine() || max == 0 )
-        return 0;
-
-    // otherwise, read until we hit newline
-    size_t bytesReadSoFar = 0;
-    bool finished = false;
-    while ( !finished ) {
-
-        const size_t index = IndexOf('\n');
-        const char* readPtr = ReadPointer();
-        size_t bytesToRead = std::min( (index+1)-bytesReadSoFar, BlockSize() );
-        bytesToRead = std::min( bytesToRead, (max-1)-bytesReadSoFar );
-        memcpy(dest+bytesReadSoFar, readPtr, bytesToRead);
-        bytesReadSoFar += bytesToRead;
-        Free(bytesToRead);
-
-        if ( !((bytesReadSoFar < index+1) && (bytesReadSoFar < max-1)) )
-            finished = true;
-    }
-
-    // null terminate 'dest' & return numBytesRead
-    dest[bytesReadSoFar] = '\0';
-    return bytesReadSoFar;
-}
-
-const char* RollingBuffer::ReadPointer(void) const {
-
-    // return null if empty buffer
-    if ( m_data.empty() )
-        return 0;
-
-    // otherwise return pointer to current position
-    const ByteArray& first = m_data.front();
-    return first.ConstData() + m_head;
-}
-
-char* RollingBuffer::Reserve(size_t n) {
-
-    // if empty buffer
-    if ( m_totalBufferSize == 0 ) {
-        m_data[0].Resize( std::max(m_bufferGrowth, n) );
-        m_totalBufferSize += n;
-        m_tail = n;
-        return m_data[m_tailBufferIndex].Data();
-    }
-
-    // increment buffer's byte count
-    m_totalBufferSize += n;
-
-    // if buffer already contains enough space to fit @n more bytes
-    if ( (m_tail + n) <= m_data.at(m_tailBufferIndex).Size() ) {
-
-        // fetch write pointer at current 'tail', increment tail by @n & return
-        char* ptr = m_data[m_tailBufferIndex].Data(); //+ m_tail;
-        m_tail += n;
-        return ptr;
-    }
-
-    // if last byte array isn't half full
-    if ( m_tail < m_data.at(m_tailBufferIndex).Size()/2 ) {
-
-        // we'll allow simple resize
-        m_data[m_tailBufferIndex].Resize(m_tail + n);
-
-        // fetch write pointer at current 'tail', increment tail by @n & return
-        char* ptr = m_data[m_tailBufferIndex].Data(); //+ m_tail;
-        m_tail += n;
-        return ptr;
-    }
-
-    // otherwise, shrink last byte array to current used size
-    m_data[m_tailBufferIndex].Resize(m_tail);
-
-    // then append new byte array
-    m_data.push_back( ByteArray() );
-    ++m_tailBufferIndex;
-    m_data[m_tailBufferIndex].Resize( std::max(m_bufferGrowth, n) );
-    m_tail = n;
-
-    // return write-able pointer on new array
-    return m_data[m_tailBufferIndex].Data();
-}
-
-size_t RollingBuffer::Size(void) const {
-    return m_totalBufferSize;
-}
-
-void RollingBuffer::Write(const char* src, size_t n) {
-    char* writePtr = Reserve(n);
-    memcpy(writePtr, src, n);
-}
diff --git a/bamtools/src/api/internal/io/RollingBuffer_p.h b/bamtools/src/api/internal/io/RollingBuffer_p.h
deleted file mode 100644
index 55550c0..0000000
--- a/bamtools/src/api/internal/io/RollingBuffer_p.h
+++ /dev/null
@@ -1,87 +0,0 @@
-// ***************************************************************************
-// RollingBuffer_p.h (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 7 December 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides a dynamic I/O FIFO byte queue, which removes bytes as they are
-// read from the front of the buffer and grows to accept bytes being written
-// to buffer end.
-//
-// implementation note: basically a 'smart' wrapper around 1..* ByteArrays
-// ***************************************************************************
-
-#ifndef ROLLINGBUFFER_P_H
-#define ROLLINGBUFFER_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#include "api/api_global.h"
-#include "api/internal/io/ByteArray_p.h"
-#include <deque>
-#include <string>
-
-namespace BamTools {
-namespace Internal {
-
-class RollingBuffer {
-
-    // ctors & dtor
-    public:
-        RollingBuffer(size_t growth);
-        ~RollingBuffer(void);
-
-    // RollingBuffer interface
-    public:
-
-        // returns current buffer size
-        size_t BlockSize(void) const;
-        // checks buffer for new line
-        bool CanReadLine(void) const;
-        // frees @n bytes from end of buffer
-        void Chop(size_t n);
-        // clears entire buffer structure
-        void Clear(void);
-        // frees @n bytes from front of buffer
-        void Free(size_t n);
-        // checks buffer for @c
-        size_t IndexOf(char c) const;
-        // returns whether buffer contains data
-        bool IsEmpty(void) const;
-        // reads up to @maxLen bytes into @dest
-        // returns exactly how many bytes were read from buffer
-        size_t Read(char* dest, size_t max);
-        // reads until newline (or up to @maxLen bytes)
-        // returns exactly how many bytes were read from buffer
-        size_t ReadLine(char* dest, size_t max);
-        // returns a C-fxn compatible char* to byte data
-        const char* ReadPointer(void) const;
-        // ensures that buffer contains space for @n incoming bytes, returns write-able char*
-        char* Reserve(size_t n);
-        // returns current number of bytes stored in buffer
-        size_t Size(void) const;
-        // reserves space for @n bytes, then appends contents of @src to buffer
-        void Write(const char* src, size_t n);
-
-    // data members
-    private:
-        size_t m_head;                // index into current data (next char)
-        size_t m_tail;                // index into last data position
-        size_t m_tailBufferIndex;     // m_data::size() - 1
-        size_t m_totalBufferSize;     // total buffer size
-        size_t m_bufferGrowth;        // new buffers are typically initialized with this size
-        std::deque<ByteArray> m_data; // basic 'buffer of buffers'
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // ROLLINGBUFFER_P_H
diff --git a/bamtools/src/api/internal/io/TcpSocketEngine_p.cpp b/bamtools/src/api/internal/io/TcpSocketEngine_p.cpp
deleted file mode 100644
index 65587b2..0000000
--- a/bamtools/src/api/internal/io/TcpSocketEngine_p.cpp
+++ /dev/null
@@ -1,196 +0,0 @@
-// ***************************************************************************
-// TcpSocketEngine_p.cpp (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 8 December 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides low-level implementation of TCP I/O
-// ***************************************************************************
-
-// N.B. - this file contains the top-level, platform-independent logic. "Native" methods
-//        are called as needed from the TcpSocketEngine_<X>.cpp files. Selection of the proper
-//        native method file should have been handled at build-time by CMake.
-
-#include "api/internal/io/HostInfo_p.h"
-#include "api/internal/io/TcpSocketEngine_p.h"
-
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-TcpSocketEngine::TcpSocketEngine(void)
-    : m_socketDescriptor(-1)
-//    , m_localPort(0)
-    , m_remotePort(0)
-    , m_socketError(TcpSocket::UnknownSocketError)
-    , m_socketState(TcpSocket::UnconnectedState)
-{ }
-
-TcpSocketEngine::TcpSocketEngine(const TcpSocketEngine& other)
-    : m_socketDescriptor(other.m_socketDescriptor)
-//    , m_localAddress(other.m_localAddress)
-    , m_remoteAddress(other.m_remoteAddress)
-//    , m_localPort(other.m_localPort)
-    , m_remotePort(other.m_remotePort)
-    , m_socketError(other.m_socketError)
-    , m_socketState(other.m_socketState)
-    , m_errorString(other.m_errorString)
-{ }
-
-TcpSocketEngine::~TcpSocketEngine(void) {
-    Close();
-}
-
-void TcpSocketEngine::Close(void) {
-
-    // close socket if we have valid FD
-    if ( m_socketDescriptor != -1 ) {
-        nativeClose();
-        m_socketDescriptor = -1;
-    }
-
-    // reset state
-    m_socketState = TcpSocket::UnconnectedState;
-//    m_localAddress.Clear();
-    m_remoteAddress.Clear();
-//    m_localPort = 0;
-    m_remotePort = 0;
-}
-
-bool TcpSocketEngine::Connect(const HostAddress& address, const uint16_t port) {
-
-    // return failure if invalid FD or already connected
-    if ( !IsValid() || (m_socketState == TcpSocket::ConnectedState) ) {
-        // TODO: set error string
-        return false;
-    }
-
-    // attempt to connect to host address on requested port
-    if ( !nativeConnect(address, port) ) {
-        // TODO: set error string
-        return false;
-    }
-
-    // if successful, store remote host address port & return success
-    // TODO: (later) fetch proxied remote & local host/port  here
-    m_remoteAddress = address;
-    m_remotePort    = port;
-    return true;
-}
-
-std::string TcpSocketEngine::GetErrorString(void) const {
-    return m_errorString;
-}
-
-//HostAddress TcpSocketEngine::GetLocalAddress(void) const {
-//    return m_localAddress;
-//}
-
-//uint16_t TcpSocketEngine::GetLocalPort(void) const {
-//    return m_localPort;
-//}
-
-HostAddress TcpSocketEngine::GetRemoteAddress(void) const {
-    return m_remoteAddress;
-}
-
-uint16_t TcpSocketEngine::GetRemotePort(void) const {
-    return m_remotePort;
-}
-
-int TcpSocketEngine::GetSocketDescriptor(void) const {
-    return m_socketDescriptor;
-}
-
-TcpSocket::SocketError TcpSocketEngine::GetSocketError(void) {
-    return m_socketError;
-}
-
-TcpSocket::SocketState TcpSocketEngine::GetSocketState(void) {
-    return m_socketState;
-}
-
-bool TcpSocketEngine::Initialize(HostAddress::NetworkProtocol protocol) {
-
-    // close current socket if we have one open
-    if ( IsValid() )
-        Close();
-
-    // attempt to create new socket
-    return nativeCreateSocket(protocol);
-}
-
-bool TcpSocketEngine::IsValid(void) const {
-    return (m_socketDescriptor != -1);
-}
-
-int64_t TcpSocketEngine::NumBytesAvailable(void) const {
-
-    // return 0 if socket FD is invalid
-    if ( !IsValid() ) {
-        // TODO: set error string
-        return -1;
-    }
-
-    // otherwise check socket to see how much is ready
-    return nativeNumBytesAvailable();
-}
-
-int64_t TcpSocketEngine::Read(char* dest, size_t max) {
-
-    // return failure if can't read
-    if ( !IsValid() || (m_socketState != TcpSocket::ConnectedState) )
-        return -1;
-
-    // otherwise return number of bytes read
-    return nativeRead(dest, max);
-}
-
-bool TcpSocketEngine::WaitForRead(int msec, bool* timedOut) {
-
-    // reset timedOut flag
-    *timedOut = false;
-
-    // need to wait for our socket to be ready to read
-    const int ret = nativeSelect(msec, true);
-
-    // if timed out
-    if ( ret == 0 ) {
-        *timedOut = true;
-        m_socketError = TcpSocket::SocketTimeoutError;
-        m_errorString = "socket timed out";
-    }
-
-    // return if any sockets available for reading
-    return ( ret > 0 );
-}
-
-bool TcpSocketEngine::WaitForWrite(int msec, bool* timedOut) {
-
-    // reset timedOut flag
-    *timedOut = false;
-
-    // need to wait for our socket to be ready to write
-    const int ret = nativeSelect(msec, false);
-
-    // if timed out
-    if ( ret == 0 ) {
-        *timedOut = true;
-        m_socketError = TcpSocket::SocketTimeoutError;
-        m_errorString = "socket timed out";
-    }
-
-    // return if any sockets available for reading
-    return ( ret > 0 );
-}
-
-int64_t TcpSocketEngine::Write(const char* data, size_t length) {
-
-    // return failure if can't write
-    if ( !IsValid() || (m_socketState != TcpSocket::ConnectedState) ) {
-        // TODO: set error string
-        return -1;
-    }
-
-    // otherwise return number of bytes written
-    return nativeWrite(data, length);
-}
diff --git a/bamtools/src/api/internal/io/TcpSocketEngine_p.h b/bamtools/src/api/internal/io/TcpSocketEngine_p.h
deleted file mode 100644
index 9218278..0000000
--- a/bamtools/src/api/internal/io/TcpSocketEngine_p.h
+++ /dev/null
@@ -1,103 +0,0 @@
-// ***************************************************************************
-// TcpSocketEngine_p.h (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 8 December 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides low-level implementation of TCP I/O
-// ***************************************************************************
-
-#ifndef TCPSOCKETENGINE_P_H
-#define TCPSOCKETENGINE_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#include "api/internal/io/HostAddress_p.h"
-#include "api/internal/io/TcpSocket_p.h"
-
-#ifdef _WIN32
-#  include "api/internal/io/NetWin_p.h"
-#endif
-
-namespace BamTools {
-namespace Internal {
-
-struct TcpSocketEngine {
-
-    // ctors & dtor
-    public:
-        TcpSocketEngine(void);
-        TcpSocketEngine(const TcpSocketEngine& other);
-        ~TcpSocketEngine(void);
-
-    // TcpSocketEngine interface
-    public:
-
-        // connection-related methods
-        void Close(void);
-        bool Connect(const HostAddress& address, const uint16_t port);
-        bool Initialize(HostAddress::NetworkProtocol protocol);
-        bool IsValid(void) const;
-
-        // IO-related methods
-        int64_t NumBytesAvailable(void) const;
-        int64_t Read(char* dest, size_t max);
-        int64_t Write(const char* data, size_t length);
-
-        bool WaitForRead(int msec, bool* timedOut);
-        bool WaitForWrite(int msec, bool* timedOut);
-
-        // query connection state
-//        HostAddress GetLocalAddress(void) const;
-//        uint16_t GetLocalPort(void) const;
-        HostAddress GetRemoteAddress(void) const;
-        uint16_t    GetRemotePort(void) const;
-
-        int GetSocketDescriptor(void) const;
-        TcpSocket::SocketError GetSocketError(void);
-        TcpSocket::SocketState GetSocketState(void);
-
-        std::string GetErrorString(void) const;
-
-    // platform-dependent internal methods
-    // provided in the corresponding TcpSocketEngine_<OS>_p.cpp
-    private:
-        void    nativeClose(void);
-        bool    nativeConnect(const HostAddress& address, const uint16_t port);
-        bool    nativeCreateSocket(HostAddress::NetworkProtocol protocol);
-        void    nativeDisconnect(void);
-        int64_t nativeNumBytesAvailable(void) const;
-        int64_t nativeRead(char* dest, size_t max);
-        int     nativeSelect(int msecs, bool isRead) const;
-        int64_t nativeWrite(const char* data, size_t length);
-
-    // data members
-    private:
-        int m_socketDescriptor;
-
-//        HostAddress m_localAddress;
-        HostAddress m_remoteAddress;
-//        uint16_t m_localPort;
-        uint16_t m_remotePort;
-
-        TcpSocket::SocketError m_socketError;
-        TcpSocket::SocketState m_socketState;
-        std::string m_errorString;
-
-#ifdef _WIN32
-        WindowsSockInit m_win;
-#endif
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // TCPSOCKETENGINE_P_H
diff --git a/bamtools/src/api/internal/io/TcpSocketEngine_unix_p.cpp b/bamtools/src/api/internal/io/TcpSocketEngine_unix_p.cpp
deleted file mode 100644
index cf598af..0000000
--- a/bamtools/src/api/internal/io/TcpSocketEngine_unix_p.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-// ***************************************************************************
-// TcpSocketEngine_unix_p.cpp (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 15 November 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides low-level implementation of TCP I/O for all UNIX-like systems
-// ***************************************************************************
-
-#include "api/internal/io/TcpSocketEngine_p.h"
-#include "api/internal/io/NetUnix_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#ifdef SUN_OS
-#include <sys/filio.h> 
-#endif
-
-#include <cerrno>
-#include <ctime>
-#include <iostream>
-using namespace std;
-
-// ------------------------
-// static utility methods
-// ------------------------
-
-namespace BamTools {
-namespace Internal {
-
-} // namespace Internal
-} // namespace BamTools
-
-// --------------------------------
-// TcpSocketEngine implementation
-// --------------------------------
-
-void TcpSocketEngine::nativeClose(void) {
-    close(m_socketDescriptor);
-}
-
-bool TcpSocketEngine::nativeConnect(const HostAddress& address, const uint16_t port) {
-
-    // setup connection parameters from address/port
-    sockaddr_in  sockAddrIPv4;
-    sockaddr_in6 sockAddrIPv6;
-    sockaddr*    sockAddrPtr  = 0;
-    BT_SOCKLEN_T sockAddrSize = 0;
-
-    // IPv6
-    if ( address.GetProtocol() == HostAddress::IPv6Protocol ) {
-
-        memset(&sockAddrIPv6, 0, sizeof(sockAddrIPv6));
-        sockAddrIPv6.sin6_family = AF_INET6;
-        sockAddrIPv6.sin6_port   = htons(port);
-
-        IPv6Address ip6 = address.GetIPv6Address();
-        memcpy(&sockAddrIPv6.sin6_addr.s6_addr, &ip6, sizeof(ip6));
-
-        sockAddrSize = sizeof(sockAddrIPv6);
-        sockAddrPtr  = (sockaddr*)&sockAddrIPv6;
-    }
-
-    // IPv4
-    else if ( address.GetProtocol() == HostAddress::IPv4Protocol ) {
-
-        memset(&sockAddrIPv4, 0, sizeof(sockAddrIPv4));
-        sockAddrIPv4.sin_family      = AF_INET;
-        sockAddrIPv4.sin_port        = htons(port);
-        sockAddrIPv4.sin_addr.s_addr = htonl(address.GetIPv4Address());
-
-        sockAddrSize = sizeof(sockAddrIPv4);
-        sockAddrPtr  = (sockaddr*)&sockAddrIPv4;
-    }
-
-    // unknown (should be unreachable)
-    else BT_ASSERT_X(false, "TcpSocketEngine::nativeConnect() : unknown network protocol");
-
-    // attempt connection
-    int connectResult = connect(m_socketDescriptor, sockAddrPtr, sockAddrSize);
-
-    // if failed, handle error
-    if ( connectResult == -1 ) {
-
-        // ensure state is set before checking errno
-        m_socketState = TcpSocket::UnconnectedState;
-
-        // set error type/message depending on errno
-        switch ( errno ) { // <-- potential thread issues later? but can't get error type from connectResult
-
-            case EISCONN:
-                m_socketState = TcpSocket::ConnectedState; // socket was already connected
-                break;
-            case ECONNREFUSED:
-            case EINVAL:
-                m_socketError = TcpSocket::ConnectionRefusedError;
-                m_errorString = "connection refused";
-                break;
-            case ETIMEDOUT:
-                m_socketError = TcpSocket::NetworkError;
-                m_errorString = "connection timed out";
-                break;
-            case EHOSTUNREACH:
-                m_socketError = TcpSocket::NetworkError;
-                m_errorString = "host unreachable";
-                break;
-            case ENETUNREACH:
-                m_socketError = TcpSocket::NetworkError;
-                m_errorString = "network unreachable";
-                break;
-            case EADDRINUSE:
-                m_socketError = TcpSocket::SocketResourceError;
-                m_errorString = "address already in use";
-                break;
-            case EACCES:
-            case EPERM:
-                m_socketError = TcpSocket::SocketAccessError;
-                m_errorString = "permission denied";
-                break;
-            default:
-                break;
-        }
-
-        // double check that we're not in 'connected' state; if so, return failure
-        if ( m_socketState != TcpSocket::ConnectedState )
-            return false;
-    }
-
-    // otherwise, we should be good
-    // update state & return success
-    m_socketState = TcpSocket::ConnectedState;
-    return true;
-}
-
-bool TcpSocketEngine::nativeCreateSocket(HostAddress::NetworkProtocol protocol) {
-
-    // get protocol value for requested protocol type
-    const int protocolNum = ( (protocol == HostAddress::IPv6Protocol) ? AF_INET6
-                                                                      : AF_INET );
-
-    // attempt to create socket
-    int socketFd = socket(protocolNum, SOCK_STREAM, IPPROTO_TCP);
-
-    // if we fetched an invalid socket descriptor
-    if ( socketFd <= 0 ) {
-
-        // see what error we got
-        switch ( errno ) {
-            case EPROTONOSUPPORT:
-            case EAFNOSUPPORT:
-            case EINVAL:
-                m_socketError = TcpSocket::UnsupportedSocketOperationError;
-                m_errorString = "protocol not supported";
-                break;
-            case ENFILE:
-            case EMFILE:
-            case ENOBUFS:
-            case ENOMEM:
-                m_socketError = TcpSocket::SocketResourceError;
-                m_errorString = "out of resources";
-                break;
-            case EACCES:
-                m_socketError = TcpSocket::SocketAccessError;
-                m_errorString = "permission denied";
-                break;
-            default:
-                break;
-        }
-
-        // return failure
-        return false;
-    }
-
-    // otherwise, store our socket FD & return success
-    m_socketDescriptor = socketFd;
-    return true;
-}
-
-int64_t TcpSocketEngine::nativeNumBytesAvailable(void) const {
-
-    // fetch number of bytes, return 0 on error
-    int numBytes(0);
-    if ( ioctl(m_socketDescriptor, FIONREAD, (char*)&numBytes) < 0 )
-        return -1;
-    return static_cast<int64_t>(numBytes);
-}
-
-int64_t TcpSocketEngine::nativeRead(char* dest, size_t max) {
-    const ssize_t ret = read(m_socketDescriptor, dest, max);
-    return static_cast<int64_t>(ret);
-}
-
-// negative value for msecs will block (forever) until ready
-int TcpSocketEngine::nativeSelect(int msecs, bool isRead) const {
-
-    // set up FD set
-    fd_set fds;
-    FD_ZERO(&fds);
-    FD_SET(m_socketDescriptor, &fds);
-
-    // setup our timeout
-    timeval tv;
-    tv.tv_sec  = msecs / 1000;
-    tv.tv_usec = (msecs % 1000) * 1000;
-
-    // do 'select'
-    if ( isRead )
-        return select(m_socketDescriptor + 1, &fds, 0, 0, (msecs < 0 ? 0 : &tv));
-    else
-        return select(m_socketDescriptor + 1, 0, &fds, 0, (msecs < 0 ? 0 : &tv));
-}
-
-int64_t TcpSocketEngine::nativeWrite(const char* data, size_t length) {
-    const ssize_t writtenBytes = write(m_socketDescriptor, data, length);
-    return static_cast<int64_t>(writtenBytes);
-}
diff --git a/bamtools/src/api/internal/io/TcpSocketEngine_win_p.cpp b/bamtools/src/api/internal/io/TcpSocketEngine_win_p.cpp
deleted file mode 100644
index c4d9b47..0000000
--- a/bamtools/src/api/internal/io/TcpSocketEngine_win_p.cpp
+++ /dev/null
@@ -1,241 +0,0 @@
-// ***************************************************************************
-// TcpSocketEngine_win_p.cpp (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 8 December 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides low-level implementation of TCP I/O for all Windows systems
-// ***************************************************************************
-
-#include "api/internal/io/TcpSocketEngine_p.h"
-#include "api/internal/io/NetWin_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#include <cstring>
-#include <iostream>
-#include <sstream>
-using namespace std;
-
-// --------------------------------
-// TcpSocketEngine implementation
-// --------------------------------
-
-void TcpSocketEngine::nativeClose(void) {
-    closesocket(m_socketDescriptor);
-}
-
-bool TcpSocketEngine::nativeConnect(const HostAddress& address, const uint16_t port) {
-
-    // setup connection parameters from address/port
-    sockaddr_in  sockAddrIPv4;
-    sockaddr_in6 sockAddrIPv6;
-    sockaddr*    sockAddrPtr  = 0;
-    BT_SOCKLEN_T sockAddrSize = 0;
-
-    // IPv6
-    if ( address.GetProtocol() == HostAddress::IPv6Protocol ) {
-
-        memset(&sockAddrIPv6, 0, sizeof(sockAddrIPv6));
-        sockAddrIPv6.sin6_family = AF_INET6;
-        sockAddrIPv6.sin6_port   = htons(port);
-
-        IPv6Address ip6 = address.GetIPv6Address();
-        memcpy(&sockAddrIPv6.sin6_addr.s6_addr, &ip6, sizeof(ip6));
-
-        sockAddrSize = sizeof(sockAddrIPv6);
-        sockAddrPtr  = (sockaddr*)&sockAddrIPv6;
-    }
-
-    // IPv4
-    else if ( address.GetProtocol() == HostAddress::IPv4Protocol ) {
-
-        memset(&sockAddrIPv4, 0, sizeof(sockAddrIPv4));
-        sockAddrIPv4.sin_family      = AF_INET;
-        sockAddrIPv4.sin_port        = htons(port);
-        sockAddrIPv4.sin_addr.s_addr = htonl(address.GetIPv4Address());
-
-        sockAddrSize = sizeof(sockAddrIPv4);
-        sockAddrPtr  = (sockaddr*)&sockAddrIPv4;
-    }
-
-    // unknown (should be unreachable)
-    else BT_ASSERT_X(false, "TcpSocketEngine::nativeConnect() : unknown network protocol");
-
-    // attempt conenction
-    const int connectResult = WSAConnect(m_socketDescriptor, sockAddrPtr, sockAddrSize, 0, 0, 0, 0);
-
-    // if failed, handle error
-    if ( connectResult == SOCKET_ERROR ) {
-
-        // ensure state is set before checking error code
-        m_socketState = TcpSocket::UnconnectedState;
-
-        // set error type/message depending on errorCode
-        const int errorCode = WSAGetLastError();
-        switch ( errorCode ) {
-            case WSANOTINITIALISED:
-                m_socketError = TcpSocket::UnknownSocketError;
-                m_errorString = "Windows socket functionality not properly initialized";
-                break;
-            case WSAEISCONN:
-                m_socketState = TcpSocket::ConnectedState; // socket already connected
-                break;
-            case WSAECONNREFUSED:
-            case WSAEINVAL:
-                m_socketError = TcpSocket::ConnectionRefusedError;
-                m_errorString = "connection refused";
-                break;
-            case WSAETIMEDOUT:
-                m_socketError = TcpSocket::NetworkError;
-                m_errorString = "connection timed out";
-                break;
-            case WSAEHOSTUNREACH:
-                m_socketError = TcpSocket::NetworkError;
-                m_errorString = "host unreachable";
-                break;
-            case WSAENETUNREACH:
-                m_socketError = TcpSocket::NetworkError;
-                m_errorString = "network unreachable";
-                break;
-            case WSAEADDRINUSE:
-                m_socketError = TcpSocket::SocketResourceError;
-                m_errorString = "address already in use";
-                break;
-            case WSAEACCES:
-                m_socketError = TcpSocket::SocketAccessError;
-                m_errorString = "permission denied";
-                break;
-            default:
-                break;
-        }
-
-        // double check that we're not in 'connected' state; if so, return failure
-        if ( m_socketState != TcpSocket::ConnectedState )
-            return false;
-    }
-
-    // otherwise, we should be good
-    // update state & return success
-    m_socketState = TcpSocket::ConnectedState;
-    return true;
-}
-
-bool TcpSocketEngine::nativeCreateSocket(HostAddress::NetworkProtocol protocol) {
-
-    // get protocol value for requested protocol type
-    const int protocolNum = ( (protocol == HostAddress::IPv6Protocol) ? AF_INET6 : AF_INET );
-
-    // attempt to create socket
-    SOCKET socketFd = WSASocket(protocolNum, SOCK_STREAM, IPPROTO_TCP, 0, 0, WSA_FLAG_OVERLAPPED);
-
-    // if we fetched an invalid socket descriptor
-    if ( socketFd == INVALID_SOCKET ) {
-
-        // set error type/message depending on error code
-        const int errorCode = WSAGetLastError();
-        switch ( errorCode ) {
-            case WSANOTINITIALISED:
-                m_socketError = TcpSocket::UnknownSocketError;
-                m_errorString = "Windows socket functionality not properly initialized";
-                break;
-            case WSAEAFNOSUPPORT:
-            case WSAESOCKTNOSUPPORT:
-            case WSAEPROTOTYPE:
-            case WSAEINVAL:
-                m_socketError = TcpSocket::UnsupportedSocketOperationError;
-                m_errorString = "protocol not supported";
-                break;
-            case WSAEMFILE:
-            case WSAENOBUFS:
-                m_socketError = TcpSocket::SocketResourceError;
-                m_errorString = "out of resources";
-                break;
-            default:
-                m_socketError = TcpSocket::UnknownSocketError;
-                stringstream errStream("");
-                errStream << "WSA ErrorCode: " << errorCode;
-                m_errorString = errStream.str();
-                break;
-        }
-
-        // return failure
-        return false;
-    }
-
-    // otherwise, store our socket FD & return success
-    m_socketDescriptor = static_cast<int>(socketFd);
-    return true;
-}
-
-int64_t TcpSocketEngine::nativeNumBytesAvailable(void) const {
-
-    int64_t numBytes(0);
-    int64_t dummy(0);
-    DWORD bytesWritten(0);
-
-    const int ioctlResult = WSAIoctl( m_socketDescriptor, FIONREAD
-                                    , &dummy, sizeof(dummy)
-                                    , &numBytes, sizeof(numBytes)
-                                    , &bytesWritten, 0, 0
-                                    );
-    return ( ioctlResult == SOCKET_ERROR ? -1 : numBytes );
-}
-
-int64_t TcpSocketEngine::nativeRead(char* dest, size_t max) {
-
-    // skip if invalid socket
-    if ( !IsValid() )
-        return -1;
-
-    // set up our WSA output buffer
-    WSABUF buf;
-    buf.buf = dest;
-    buf.len = max;
-
-    // attempt to read bytes
-    DWORD flags = 0;
-    DWORD bytesRead = 0;
-    const int readResult = WSARecv(m_socketDescriptor, &buf, 1, &bytesRead, &flags, 0, 0);
-    if ( readResult == SOCKET_ERROR )
-        return -1;
-
-    // return number of bytes read
-    return static_cast<int64_t>(bytesRead);
-}
-
-// negative value for msecs will block (forever) until
-int TcpSocketEngine::nativeSelect(int msecs, bool isRead) const {
-
-    fd_set fds;
-    FD_ZERO(&fds);
-    FD_SET(m_socketDescriptor, &fds);
-
-    timeval tv;
-    tv.tv_sec  = msecs / 1000;
-    tv.tv_usec = (msecs % 1000) * 1000;
-
-    // do 'select'
-    if ( isRead )
-        return select(0, &fds, 0, 0, (msecs < 0 ? 0 : &tv));
-    else
-        return select(0, 0, &fds, 0, (msecs < 0 ? 0 : &tv));
-}
-
-int64_t TcpSocketEngine::nativeWrite(const char* data, size_t length) {
-
-    // setup our WSA write buffer
-    WSABUF buf;
-    buf.buf = (char*)data;
-    buf.len = length;
-
-    // attempt to write bytes
-    DWORD flags = 0;
-    DWORD bytesWritten = 0;
-    const int writeResult = WSASend(m_socketDescriptor, &buf, 1, &bytesWritten, flags, 0, 0);
-    if ( writeResult == SOCKET_ERROR )
-        return -1;
-
-    // return number of bytes written
-    return static_cast<int64_t>(bytesWritten);
-}
diff --git a/bamtools/src/api/internal/io/TcpSocket_p.cpp b/bamtools/src/api/internal/io/TcpSocket_p.cpp
deleted file mode 100644
index d390932..0000000
--- a/bamtools/src/api/internal/io/TcpSocket_p.cpp
+++ /dev/null
@@ -1,430 +0,0 @@
-// ***************************************************************************
-// TcpSocket_p.cpp (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 5 January 2012 (DB)
-// ---------------------------------------------------------------------------
-// Provides basic TCP I/O interface
-// ***************************************************************************
-
-#include "api/internal/io/ByteArray_p.h"
-#include "api/internal/io/TcpSocket_p.h"
-#include "api/internal/io/TcpSocketEngine_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#include <algorithm>
-#include <climits>
-#include <sstream>
-#include <vector>
-using namespace std;
-
-// ------------------------------------
-// static utility methods & constants
-// ------------------------------------
-
-namespace BamTools {
-namespace Internal {
-
-// constants
-static const size_t DEFAULT_BUFFER_SIZE = 0x10000;
-
-} // namespace Internal
-} // namespace BamTools
-
-// --------------------------
-// TcpSocket implementation
-// --------------------------
-
-TcpSocket::TcpSocket(void)
-    : m_mode(IBamIODevice::NotOpen)
-//    , m_localPort(0)
-    , m_remotePort(0)
-    , m_engine(0)
-    , m_cachedSocketDescriptor(-1)
-    , m_readBuffer(DEFAULT_BUFFER_SIZE)
-    , m_error(TcpSocket::NoError)
-    , m_state(TcpSocket::UnconnectedState)
-{ }
-
-TcpSocket::~TcpSocket(void) {
-    if ( m_state == TcpSocket::ConnectedState )
-        DisconnectFromHost();
-}
-
-size_t TcpSocket::BufferBytesAvailable(void) const {
-    return m_readBuffer.Size();
-}
-
-bool TcpSocket::CanReadLine(void) const {
-    return m_readBuffer.CanReadLine();
-}
-
-void TcpSocket::ClearBuffer(void) {
-    m_readBuffer.Clear();
-}
-
-bool TcpSocket::ConnectImpl(const HostInfo& hostInfo,
-                            const std::string& port,
-                            IBamIODevice::OpenMode mode)
-{
-    // skip if we're already connected
-    if ( m_state == TcpSocket::ConnectedState ) {
-        m_error = TcpSocket::SocketResourceError;
-        m_errorString = "socket already connected";
-        return false;
-    }
-
-    // reset socket state
-    m_hostName   = hostInfo.HostName();
-    m_mode       = mode;
-    m_state      = TcpSocket::UnconnectedState;
-    m_error      = TcpSocket::NoError;
-//    m_localPort  = 0;
-    m_remotePort = 0;
-//    m_localAddress.Clear();
-    m_remoteAddress.Clear();
-    m_readBuffer.Clear();
-
-    // fetch candidate addresses for requested host
-    vector<HostAddress> addresses = hostInfo.Addresses();
-    if ( addresses.empty() ) {
-        m_error = TcpSocket::HostNotFoundError;
-        m_errorString = "no IP addresses found for host";
-        return false;
-    }
-
-    // convert port string to integer
-    stringstream ss(port);
-    uint16_t portNumber(0);
-    ss >> portNumber;
-
-    // iterate through adddresses
-    vector<HostAddress>::const_iterator addrIter = addresses.begin();
-    vector<HostAddress>::const_iterator addrEnd  = addresses.end();
-    for ( ; addrIter != addrEnd; ++addrIter) {
-        const HostAddress& addr = (*addrIter);
-
-        // try to initialize socket engine with this address
-        if ( !InitializeSocketEngine(addr.GetProtocol()) ) {
-            // failure to initialize is OK here
-            // we'll just try the next available address
-            continue;
-        }
-
-        // attempt actual connection
-        if ( m_engine->Connect(addr, portNumber) ) {
-
-            // if connection successful, update our state & return true
-            m_mode = mode;
-//            m_localAddress  = m_engine->GetLocalAddress();
-//            m_localPort     = m_engine->GetLocalPort();
-            m_remoteAddress = m_engine->GetRemoteAddress();
-            m_remotePort    = m_engine->GetRemotePort();
-            m_cachedSocketDescriptor = m_engine->GetSocketDescriptor();
-            m_state = TcpSocket::ConnectedState;
-            return true;
-        }
-    }
-
-    // if we get here, no connection could be made
-    m_error = TcpSocket::HostNotFoundError;
-    m_errorString = "could not connect to any host addresses";
-    return false;
-}
-
-bool TcpSocket::ConnectToHost(const string& hostName,
-                              uint16_t port,
-                              IBamIODevice::OpenMode mode)
-{
-    stringstream ss("");
-    ss << port;
-    return ConnectToHost(hostName, ss.str(), mode);
-
-}
-
-bool TcpSocket::ConnectToHost(const string& hostName,
-                              const string& port,
-                              IBamIODevice::OpenMode mode)
-{
-    // create new address object with requested host name
-    HostAddress hostAddress;
-    hostAddress.SetAddress(hostName);
-
-    HostInfo info;
-    // if host name was IP address ("x.x.x.x" or IPv6 format)
-    // otherwise host name was 'plain-text' ("www.foo.bar")
-    // we need to look up IP address(es)
-    if ( hostAddress.HasIPAddress() )
-        info.SetAddresses( vector<HostAddress>(1, hostAddress) );
-    else
-        info = HostInfo::Lookup(hostName, port);
-
-    // attempt connection on requested port
-    return ConnectImpl(info, port, mode);
-}
-
-void TcpSocket::DisconnectFromHost(void) {
-
-    // close socket engine & delete
-    if ( m_state == TcpSocket::ConnectedState )
-        ResetSocketEngine();
-
-    // reset connection state
-//    m_localPort = 0;
-    m_remotePort = 0;
-//    m_localAddress.Clear();
-    m_remoteAddress.Clear();
-    m_hostName.clear();
-    m_cachedSocketDescriptor = -1;
-
-    // for future, make sure there's outgoing data that needs to be flushed
-    m_readBuffer.Clear();
-}
-
-TcpSocket::SocketError TcpSocket::GetError(void) const {
-    return m_error;
-}
-
-std::string TcpSocket::GetErrorString(void) const {
-    return m_errorString;
-}
-
-std::string TcpSocket::GetHostName(void) const {
-    return m_hostName;
-}
-
-//HostAddress TcpSocket::GetLocalAddress(void) const {
-//    return m_localAddress;
-//}
-
-//uint16_t TcpSocket::GetLocalPort(void) const {
-//    return m_localPort;
-//}
-
-HostAddress TcpSocket::GetRemoteAddress(void) const {
-    return m_remoteAddress;
-}
-
-uint16_t TcpSocket::GetRemotePort(void) const {
-    return m_remotePort;
-}
-
-TcpSocket::SocketState TcpSocket::GetState(void) const {
-    return m_state;
-}
-
-bool TcpSocket::InitializeSocketEngine(HostAddress::NetworkProtocol protocol) {
-    ResetSocketEngine();
-    m_engine = new TcpSocketEngine;
-    return m_engine->Initialize(protocol);
-}
-
-bool TcpSocket::IsConnected(void) const {
-    if ( m_engine == 0 )
-        return false;
-    return ( m_engine->IsValid() && (m_state == TcpSocket::ConnectedState) );
-}
-
-// may be read in a look until desired data amount has been read
-// returns: number of bytes read, or -1 if error
-int64_t TcpSocket::Read(char* data, const unsigned int numBytes) {
-
-    // if we have data in buffer, just return it
-    if ( !m_readBuffer.IsEmpty() ) {
-        const size_t bytesRead = m_readBuffer.Read(data, numBytes);
-        return static_cast<int64_t>(bytesRead);
-    }
-
-    // otherwise, we'll need to fetch data from socket
-    // first make sure we have a valid socket engine
-    if ( m_engine == 0 ) {
-        // TODO: set error string/state?
-        return -1;
-    }
-
-    // fetch data from socket, return 0 for success, -1 for failure
-    // since this should be called in a loop,
-    // we'll pull the actual bytes from the buffer on next iteration
-    const int64_t socketBytesRead = ReadFromSocket();
-    if ( socketBytesRead < 0 ) {
-        // TODO: set error string/state ?
-        return -1;
-    }
-
-    // we should have data now in buffer, try to fetch requested amount
-    // if nothing in buffer, we will return 0 bytes read (signals EOF reached)
-    const size_t numBytesRead = m_readBuffer.Read(data, numBytes);
-    return static_cast<int64_t>(numBytesRead);
-}
-
-int64_t TcpSocket::ReadFromSocket(void) {
-
-    // check for any socket engine errors
-    if ( !m_engine->IsValid() ) {
-        m_errorString = "TcpSocket::ReadFromSocket - socket disconnected";
-        ResetSocketEngine();
-        return -1;
-    }
-
-    // wait for ready read
-    bool timedOut;
-    const bool isReadyRead = m_engine->WaitForRead(5000, &timedOut);
-
-    // if not ready
-    if ( !isReadyRead ) {
-
-        // if we simply timed out
-        if ( timedOut ) {
-            // TODO: get add'l error info from engine ?
-            m_errorString = "TcpSocket::ReadFromSocket - timed out waiting for ready read";
-        }
-
-        // otherwise, there was some other error
-        else {
-            // TODO: get add'l error info from engine ?
-            m_errorString = "TcpSocket::ReadFromSocket - encountered error while waiting for ready read";
-        }
-
-        // return failure
-        return -1;
-    }
-
-    // get number of bytes available from socket
-    const int64_t bytesToRead = m_engine->NumBytesAvailable();
-    if ( bytesToRead < 0 ) {
-        // TODO: get add'l error info from engine ?
-        m_errorString = "TcpSocket::ReadFromSocket - encountered error while determining numBytesAvailable";
-        return -1;
-    }
-
-    // make space in buffer & read from socket
-    char* buffer = m_readBuffer.Reserve(bytesToRead);
-    const int64_t numBytesRead = m_engine->Read(buffer, bytesToRead);
-    if ( numBytesRead == -1 ) {
-        // TODO: get add'l error info from engine ?
-        m_errorString = "TcpSocket::ReadFromSocket - encountered error while reading bytes";
-    }
-
-    // return number of bytes actually read
-    return numBytesRead;
-}
-
-string TcpSocket::ReadLine(int64_t max) {
-
-    // prep result byte buffer
-    ByteArray result;
-    size_t bufferMax = ((max > static_cast<int64_t>(UINT_MAX))
-                        ? UINT_MAX : static_cast<size_t>(max));
-    result.Resize(bufferMax);
-
-    // read data
-    int64_t readBytes(0);
-    if ( result.Size() == 0 ) {
-
-        if ( bufferMax == 0 )
-            bufferMax = UINT_MAX;
-
-        result.Resize(1);
-
-        int64_t readResult;
-        do {
-            result.Resize( static_cast<size_t>(min(bufferMax, result.Size() + DEFAULT_BUFFER_SIZE)) );
-            readResult = ReadLine(result.Data()+readBytes, result.Size()-readBytes);
-            if ( readResult > 0 || readBytes == 0 )
-                readBytes += readResult;
-        } while ( readResult == DEFAULT_BUFFER_SIZE && result[static_cast<size_t>(readBytes-1)] != '\n' );
-
-    } else
-        readBytes = ReadLine(result.Data(), result.Size());
-
-    // clean up byte buffer
-    if ( readBytes <= 0 )
-        result.Clear();
-    else
-        result.Resize(static_cast<size_t>(readBytes));
-
-    // return byte buffer as string
-    return string( result.ConstData(), result.Size() );
-}
-
-int64_t TcpSocket::ReadLine(char* dest, size_t max) {
-
-    // wait for buffer to contain line contents
-    if ( !WaitForReadLine() ) {
-        m_errorString = "TcpSocket::ReadLine - error waiting for read line";
-        return -1;
-    }
-
-    // leave room for null term
-    if ( max < 2 )
-        return -1;
-    --max;
-
-    // read from buffer, handle newlines
-    int64_t readSoFar = m_readBuffer.ReadLine(dest, max);
-    if ( readSoFar && dest[readSoFar-1] == '\n' ) {
-
-        // adjust for windows-style '\r\n'
-        if ( readSoFar > 1 && dest[readSoFar-2] == '\r') {
-            --readSoFar;
-            dest[readSoFar-1] = '\n';
-        }
-    }
-
-    // null terminate & return number of bytes read
-    dest[readSoFar] = '\0';
-    return readSoFar;
-}
-
-void TcpSocket::ResetSocketEngine(void) {
-
-    // shut down socket engine
-    if ( m_engine ) {
-        m_engine->Close();
-        delete m_engine;
-        m_engine = 0;
-    }
-
-    // reset our state & cached socket handle
-    m_state = TcpSocket::UnconnectedState;
-    m_cachedSocketDescriptor = -1;
-}
-
-bool TcpSocket::WaitForReadLine(void) {
-
-    // wait until we can read a line (will return immediately if already capable)
-    while ( !CanReadLine() ) {
-        if ( !ReadFromSocket() )
-            return false;
-    }
-
-    // if we get here, success
-    return true;
-}
-
-int64_t TcpSocket::Write(const char* data, const unsigned int numBytes) {
-
-    // single-shot attempt at write (not buffered, just try to shove the data through socket)
-    // this method purely exists to send 'small' HTTP requests/FTP commands from client to server
-
-    // wait for our socket to be write-able
-    bool timedOut;
-    const bool isReadyWrite = m_engine->WaitForWrite(3000, &timedOut);
-
-    // if ready, return number of bytes written
-    if ( isReadyWrite )
-        return m_engine->Write(data, numBytes);
-
-    // otherwise, socket not ready for writing
-    // set error string depending on reason & return failure
-    if ( !timedOut ) {
-        // TODO: get add'l error info from engine ??
-        m_errorString = "TcpSocket::Write - timed out waiting for ready-write";
-    }
-    else {
-        // TODO: get add'l error info from engine ??
-        m_errorString = "TcpSocket::Write - error encountered while waiting for ready-write";
-    }
-    return -1;
-}
diff --git a/bamtools/src/api/internal/io/TcpSocket_p.h b/bamtools/src/api/internal/io/TcpSocket_p.h
deleted file mode 100644
index 2ad2dee..0000000
--- a/bamtools/src/api/internal/io/TcpSocket_p.h
+++ /dev/null
@@ -1,128 +0,0 @@
-// ***************************************************************************
-// TcpSocket_p.h (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 7 December 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides basic TCP I/O interface
-// ***************************************************************************
-
-#ifndef TCPSOCKET_P_H
-#define TCPSOCKET_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#include "api/IBamIODevice.h"
-#include "api/internal/io/HostInfo_p.h"
-#include "api/internal/io/RollingBuffer_p.h"
-#include <string>
-
-namespace BamTools {
-namespace Internal {
-
-class BamHttp;
-class TcpSocketEngine;
-
-class TcpSocket {
-
-    // enums
-    public:
-        enum SocketError { NoError                = -2
-                         , UnknownSocketError     = -1
-                         , ConnectionRefusedError = 0
-                         , RemoteHostClosedError
-                         , HostNotFoundError
-                         , SocketAccessError
-                         , SocketResourceError
-                         , SocketTimeoutError
-                         , NetworkError
-                         , UnsupportedSocketOperationError
-                         };
-
-        enum SocketState { UnconnectedState = 0
-                         , ConnectedState
-                         };
-
-    // ctor & dtor
-    public:
-        TcpSocket(void);
-        ~TcpSocket(void);
-
-    // TcpSocket interface
-    public:
-
-        // connection methods
-        bool ConnectToHost(const std::string& hostName,
-                           const uint16_t port,        // Connect("host", 80)
-                           IBamIODevice::OpenMode mode = IBamIODevice::ReadOnly);
-        bool ConnectToHost(const std::string& hostName,
-                           const std::string& port,    // Connect("host", "80")
-                           IBamIODevice::OpenMode mode = IBamIODevice::ReadOnly);
-        void DisconnectFromHost(void);
-        bool IsConnected(void) const;
-
-        // I/O methods
-        size_t BufferBytesAvailable(void) const;
-        bool CanReadLine(void) const;
-        void ClearBuffer(void); // force buffer to clear (not a 'flush', just a 'discard')
-        int64_t Read(char* data, const unsigned int numBytes);
-        std::string ReadLine(int64_t max = 0);
-        int64_t ReadLine(char* dest, size_t max);
-        bool WaitForReadLine(void);
-        int64_t Write(const char* data, const unsigned int numBytes);
-
-        // connection values
-        std::string GetHostName(void) const;
-//        HostAddress GetLocalAddress(void) const;
-//        uint16_t    GetLocalPort(void) const;
-        HostAddress GetRemoteAddress(void) const;
-        uint16_t    GetRemotePort(void) const;
-
-        // connection status
-        TcpSocket::SocketError GetError(void) const;
-        TcpSocket::SocketState GetState(void) const;
-        std::string GetErrorString(void) const;
-
-    // internal methods
-    private:
-        bool ConnectImpl(const HostInfo& hostInfo,
-                         const std::string& port,
-                         IBamIODevice::OpenMode mode);
-        bool InitializeSocketEngine(HostAddress::NetworkProtocol protocol);
-        int64_t ReadFromSocket(void);
-        void ResetSocketEngine(void);
-
-    // data members
-    private:
-        IBamIODevice::OpenMode m_mode;
-
-        std::string m_hostName;
-//        uint16_t    m_localPort;
-        uint16_t    m_remotePort;
-//        HostAddress m_localAddress;
-        HostAddress m_remoteAddress;
-
-        TcpSocketEngine* m_engine;
-        int m_cachedSocketDescriptor;
-
-        RollingBuffer m_readBuffer;
-
-        TcpSocket::SocketError m_error;
-        TcpSocket::SocketState m_state;
-        std::string m_errorString;
-
-        friend class BamHttp;
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // TCPSOCKET_P_H
diff --git a/bamtools/src/api/internal/sam/CMakeLists.txt b/bamtools/src/api/internal/sam/CMakeLists.txt
deleted file mode 100644
index 2f303bd..0000000
--- a/bamtools/src/api/internal/sam/CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-# ==========================
-# BamTools CMakeLists.txt
-# (c) 2011 Derek Barnett
-#
-# src/api/internal/sam
-# ==========================
-
-set( InternalSamDir "${InternalDir}/sam" )
-
-set( InternalSamSources
-        ${InternalSamDir}/SamFormatParser_p.cpp
-        ${InternalSamDir}/SamFormatPrinter_p.cpp
-        ${InternalSamDir}/SamHeaderValidator_p.cpp
-
-        PARENT_SCOPE # <-- leave this last
-)
-
diff --git a/bamtools/src/api/internal/sam/SamFormatParser_p.cpp b/bamtools/src/api/internal/sam/SamFormatParser_p.cpp
deleted file mode 100644
index 928cb5c..0000000
--- a/bamtools/src/api/internal/sam/SamFormatParser_p.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-// ***************************************************************************
-// SamFormatParser.cpp (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 8 December 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides functionality for parsing SAM header text into SamHeader object
-// ***************************************************************************
-
-#include "api/SamConstants.h"
-#include "api/SamHeader.h"
-#include "api/internal/sam/SamFormatParser_p.h"
-#include "api/internal/utils/BamException_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#include <iostream>
-#include <sstream>
-#include <vector>
-using namespace std;
-
-SamFormatParser::SamFormatParser(SamHeader& header)
-    : m_header(header)
-{ }
-
-SamFormatParser::~SamFormatParser(void) { }
-
-void SamFormatParser::Parse(const string& headerText) {
-
-    // clear header's prior contents
-    m_header.Clear();
-
-    // empty header is OK, but skip processing
-    if ( headerText.empty() )
-        return;
-
-    // other wise parse SAM lines
-    istringstream headerStream(headerText);
-    string headerLine("");
-    while ( getline(headerStream, headerLine) )
-         ParseSamLine(headerLine);
-}
-
-void SamFormatParser::ParseSamLine(const string& line) {
-
-    // skip if line is not long enough to contain true values
-    if ( line.length() < 5 ) return;
-
-    // determine token at beginning of line
-    const string firstToken = line.substr(0,3);
-    const string restOfLine = line.substr(4);
-    if      ( firstToken == Constants::SAM_HD_BEGIN_TOKEN) ParseHDLine(restOfLine);
-    else if ( firstToken == Constants::SAM_SQ_BEGIN_TOKEN) ParseSQLine(restOfLine);
-    else if ( firstToken == Constants::SAM_RG_BEGIN_TOKEN) ParseRGLine(restOfLine);
-    else if ( firstToken == Constants::SAM_PG_BEGIN_TOKEN) ParsePGLine(restOfLine);
-    else if ( firstToken == Constants::SAM_CO_BEGIN_TOKEN) ParseCOLine(restOfLine);
-}
-
-void SamFormatParser::ParseHDLine(const string& line) {
-
-    // split HD lines into tokens
-    vector<string> tokens = Split(line, Constants::SAM_TAB);
-
-    // iterate over tokens
-    vector<string>::const_iterator tokenIter = tokens.begin();
-    vector<string>::const_iterator tokenEnd  = tokens.end();
-    for ( ; tokenIter != tokenEnd; ++tokenIter ) {
-
-        // get tag/value
-        const string tokenTag = (*tokenIter).substr(0,2);
-        const string tokenValue = (*tokenIter).substr(3);
-
-        // set header contents
-        if      ( tokenTag == Constants::SAM_HD_VERSION_TAG    ) m_header.Version    = tokenValue;
-        else if ( tokenTag == Constants::SAM_HD_SORTORDER_TAG  ) m_header.SortOrder  = tokenValue;
-        else if ( tokenTag == Constants::SAM_HD_GROUPORDER_TAG ) m_header.GroupOrder = tokenValue;
-    }
-
-    // check for required tags
-    if ( !m_header.HasVersion() )
-        throw BamException("SamFormatParser::ParseHDLine", "@HD line is missing VN tag");
-}
-
-void SamFormatParser::ParseSQLine(const string& line) {
-
-    SamSequence seq;
-
-    // split SQ line into tokens
-    vector<string> tokens = Split(line, Constants::SAM_TAB);
-
-    // iterate over tokens
-    vector<string>::const_iterator tokenIter = tokens.begin();
-    vector<string>::const_iterator tokenEnd  = tokens.end();
-    for ( ; tokenIter != tokenEnd; ++tokenIter ) {
-
-        // get tag/value
-        const string tokenTag = (*tokenIter).substr(0,2);
-        const string tokenValue = (*tokenIter).substr(3);
-
-        // set sequence contents
-        if      ( tokenTag == Constants::SAM_SQ_NAME_TAG       ) seq.Name = tokenValue;
-        else if ( tokenTag == Constants::SAM_SQ_LENGTH_TAG     ) seq.Length = tokenValue;
-        else if ( tokenTag == Constants::SAM_SQ_ASSEMBLYID_TAG ) seq.AssemblyID = tokenValue;
-        else if ( tokenTag == Constants::SAM_SQ_CHECKSUM_TAG   ) seq.Checksum = tokenValue;
-        else if ( tokenTag == Constants::SAM_SQ_SPECIES_TAG    ) seq.Species = tokenValue;
-        else if ( tokenTag == Constants::SAM_SQ_URI_TAG        ) seq.URI = tokenValue;
-    }
-
-    // check for required tags
-    if ( !seq.HasName() )
-        throw BamException("SamFormatParser::ParseSQLine", "@SQ line is missing SN tag");
-    if ( !seq.HasLength() )
-        throw BamException("SamFormatParser::ParseSQLine", "@SQ line is missing LN tag");
-
-    // store SAM sequence entry
-    m_header.Sequences.Add(seq);
-}
-
-void SamFormatParser::ParseRGLine(const string& line) {
-
-    SamReadGroup rg;
-
-    // split string into tokens
-    vector<string> tokens = Split(line, Constants::SAM_TAB);
-
-    // iterate over tokens
-    vector<string>::const_iterator tokenIter = tokens.begin();
-    vector<string>::const_iterator tokenEnd  = tokens.end();
-    for ( ; tokenIter != tokenEnd; ++tokenIter ) {
-
-        // get token tag/value
-        const string tokenTag = (*tokenIter).substr(0,2);
-        const string tokenValue = (*tokenIter).substr(3);
-
-        // set read group contents
-        if      ( tokenTag == Constants::SAM_RG_ID_TAG                  ) rg.ID = tokenValue;
-        else if ( tokenTag == Constants::SAM_RG_DESCRIPTION_TAG         ) rg.Description = tokenValue;
-        else if ( tokenTag == Constants::SAM_RG_FLOWORDER_TAG           ) rg.FlowOrder = tokenValue;
-        else if ( tokenTag == Constants::SAM_RG_KEYSEQUENCE_TAG         ) rg.KeySequence = tokenValue;
-        else if ( tokenTag == Constants::SAM_RG_LIBRARY_TAG             ) rg.Library = tokenValue;
-        else if ( tokenTag == Constants::SAM_RG_PLATFORMUNIT_TAG        ) rg.PlatformUnit = tokenValue;
-        else if ( tokenTag == Constants::SAM_RG_PREDICTEDINSERTSIZE_TAG ) rg.PredictedInsertSize = tokenValue;
-        else if ( tokenTag == Constants::SAM_RG_PRODUCTIONDATE_TAG      ) rg.ProductionDate = tokenValue;
-        else if ( tokenTag == Constants::SAM_RG_PROGRAM_TAG             ) rg.Program = tokenValue;
-        else if ( tokenTag == Constants::SAM_RG_SAMPLE_TAG              ) rg.Sample = tokenValue;
-        else if ( tokenTag == Constants::SAM_RG_SEQCENTER_TAG           ) rg.SequencingCenter = tokenValue;
-        else if ( tokenTag == Constants::SAM_RG_SEQTECHNOLOGY_TAG       ) rg.SequencingTechnology = tokenValue;
-    }
-
-    // check for required tags
-    if ( !rg.HasID() )
-        throw BamException("SamFormatParser::ParseRGLine", "@RG line is missing ID tag");
-
-    // store SAM read group entry
-    m_header.ReadGroups.Add(rg);
-}
-
-void SamFormatParser::ParsePGLine(const string& line) {
-
-    SamProgram pg;
-
-    // split string into tokens
-    vector<string> tokens = Split(line, Constants::SAM_TAB);
-
-    // iterate over tokens
-    vector<string>::const_iterator tokenIter = tokens.begin();
-    vector<string>::const_iterator tokenEnd  = tokens.end();
-    for ( ; tokenIter != tokenEnd; ++tokenIter ) {
-
-        // get token tag/value
-        const string tokenTag = (*tokenIter).substr(0,2);
-        const string tokenValue = (*tokenIter).substr(3);
-
-        // set program record contents
-        if      ( tokenTag == Constants::SAM_PG_ID_TAG              ) pg.ID = tokenValue;
-        else if ( tokenTag == Constants::SAM_PG_NAME_TAG            ) pg.Name = tokenValue;
-        else if ( tokenTag == Constants::SAM_PG_COMMANDLINE_TAG     ) pg.CommandLine = tokenValue;
-        else if ( tokenTag == Constants::SAM_PG_PREVIOUSPROGRAM_TAG ) pg.PreviousProgramID = tokenValue;
-        else if ( tokenTag == Constants::SAM_PG_VERSION_TAG         ) pg.Version = tokenValue;
-    }
-
-    // check for required tags
-    if ( !pg.HasID() )
-        throw BamException("SamFormatParser::ParsePGLine", "@PG line is missing ID tag");
-
-    // store SAM program entry
-    m_header.Programs.Add(pg);
-}
-
-void SamFormatParser::ParseCOLine(const string& line) {
-    // simply add line to comments list
-    m_header.Comments.push_back(line);
-}
-
-const vector<string> SamFormatParser::Split(const string& line, const char delim) {
-    vector<string> tokens;
-    stringstream lineStream(line);
-    string token;
-    while ( getline(lineStream, token, delim) )
-        tokens.push_back(token);
-    return tokens;
-}
diff --git a/bamtools/src/api/internal/sam/SamFormatParser_p.h b/bamtools/src/api/internal/sam/SamFormatParser_p.h
deleted file mode 100644
index cf6d54c..0000000
--- a/bamtools/src/api/internal/sam/SamFormatParser_p.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// ***************************************************************************
-// SamFormatParser.h (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 23 December 2010 (DB)
-// ---------------------------------------------------------------------------
-// Provides functionality for parsing SAM header text into SamHeader object
-// ***************************************************************************
-
-#ifndef SAM_FORMAT_PARSER_H
-#define SAM_FORMAT_PARSER_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#include <string>
-#include <vector>
-
-namespace BamTools {
-
-class SamHeader;
-
-namespace Internal {
-
-class SamFormatParser {
-
-    // ctor & dtor
-    public:
-        SamFormatParser(BamTools::SamHeader& header);
-        ~SamFormatParser(void);
-
-    // parse text & populate header data
-    public:
-        void Parse(const std::string& headerText);
-
-    // internal methods
-    private:
-        void ParseSamLine(const std::string& line);
-        void ParseHDLine(const std::string& line);
-        void ParseSQLine(const std::string& line);
-        void ParseRGLine(const std::string& line);
-        void ParsePGLine(const std::string& line);
-        void ParseCOLine(const std::string& line);
-        const std::vector<std::string> Split(const std::string& line, const char delim);
-
-    // data members
-    private:
-        SamHeader& m_header;
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // SAM_FORMAT_PARSER_H
diff --git a/bamtools/src/api/internal/sam/SamFormatPrinter_p.cpp b/bamtools/src/api/internal/sam/SamFormatPrinter_p.cpp
deleted file mode 100644
index 5a51a2f..0000000
--- a/bamtools/src/api/internal/sam/SamFormatPrinter_p.cpp
+++ /dev/null
@@ -1,219 +0,0 @@
-// ***************************************************************************
-// SamFormatPrinter.cpp (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 25 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides functionality for printing formatted SAM header to string
-// ***************************************************************************
-
-#include "api/SamConstants.h"
-#include "api/SamHeader.h"
-#include "api/internal/sam/SamFormatPrinter_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#include <iostream>
-#include <sstream>
-#include <vector>
-using namespace std;
-
-// ------------------------
-// static utility methods
-// ------------------------
-
-static inline
-const string FormatTag(const string& tag, const string& value) {
-    return string(Constants::SAM_TAB + tag + Constants::SAM_COLON + value);
-}
-
-// ---------------------------------
-// SamFormatPrinter implementation
-// ---------------------------------
-
-SamFormatPrinter::SamFormatPrinter(const SamHeader& header)
-    : m_header(header)
-{ }
-
-SamFormatPrinter::~SamFormatPrinter(void) { }
-
-const string SamFormatPrinter::ToString(void) const {
-
-    // clear out stream
-    stringstream out("");
-
-    // generate formatted header text
-    PrintHD(out);
-    PrintSQ(out);
-    PrintRG(out);
-    PrintPG(out);
-    PrintCO(out);
-
-    // return result
-    return out.str();
-}
-
-void SamFormatPrinter::PrintHD(std::stringstream& out) const {
-
-    // if header has @HD data
-    if ( m_header.HasVersion() ) {
-
-        // @HD VN:<Version>
-        out << Constants::SAM_HD_BEGIN_TOKEN
-            << FormatTag(Constants::SAM_HD_VERSION_TAG, m_header.Version);
-
-        // SO:<SortOrder>
-        if ( m_header.HasSortOrder() )
-            out << FormatTag(Constants::SAM_HD_SORTORDER_TAG, m_header.SortOrder);
-
-        // GO:<GroupOrder>
-        if ( m_header.HasGroupOrder() )
-            out << FormatTag(Constants::SAM_HD_GROUPORDER_TAG, m_header.GroupOrder);
-
-        // newline
-        out << endl;
-    }
-}
-
-void SamFormatPrinter::PrintSQ(std::stringstream& out) const {
-
-    // iterate over sequence entries
-    SamSequenceConstIterator seqIter = m_header.Sequences.ConstBegin();
-    SamSequenceConstIterator seqEnd  = m_header.Sequences.ConstEnd();
-    for ( ; seqIter != seqEnd; ++seqIter ) {
-        const SamSequence& seq = (*seqIter);
-
-        // @SQ SN:<Name> LN:<Length>
-        out << Constants::SAM_SQ_BEGIN_TOKEN
-            << FormatTag(Constants::SAM_SQ_NAME_TAG, seq.Name)
-            << FormatTag(Constants::SAM_SQ_LENGTH_TAG, seq.Length);
-
-        // AS:<AssemblyID>
-        if ( seq.HasAssemblyID() )
-            out << FormatTag(Constants::SAM_SQ_ASSEMBLYID_TAG, seq.AssemblyID);
-
-        // M5:<Checksum>
-        if ( seq.HasChecksum() )
-            out << FormatTag(Constants::SAM_SQ_CHECKSUM_TAG, seq.Checksum);
-
-        // SP:<Species>
-        if ( seq.HasSpecies() )
-            out << FormatTag(Constants::SAM_SQ_SPECIES_TAG, seq.Species);
-
-        // UR:<URI>
-        if ( seq.HasURI() )
-            out << FormatTag(Constants::SAM_SQ_URI_TAG, seq.URI);
-
-        // newline
-        out << endl;
-    }
-}
-
-void SamFormatPrinter::PrintRG(std::stringstream& out) const {
-
-    // iterate over read group entries
-    SamReadGroupConstIterator rgIter = m_header.ReadGroups.ConstBegin();
-    SamReadGroupConstIterator rgEnd  = m_header.ReadGroups.ConstEnd();
-    for ( ; rgIter != rgEnd; ++rgIter ) {
-        const SamReadGroup& rg = (*rgIter);
-
-        // @RG ID:<ID>
-        out << Constants::SAM_RG_BEGIN_TOKEN
-            << FormatTag(Constants::SAM_RG_ID_TAG, rg.ID);
-
-        // CN:<SequencingCenter>
-        if ( rg.HasSequencingCenter() )
-            out << FormatTag(Constants::SAM_RG_SEQCENTER_TAG, rg.SequencingCenter);
-
-        // DS:<Description>
-        if ( rg.HasDescription() )
-            out << FormatTag(Constants::SAM_RG_DESCRIPTION_TAG, rg.Description);
-
-        // DT:<ProductionDate>
-        if ( rg.HasProductionDate() )
-            out << FormatTag(Constants::SAM_RG_PRODUCTIONDATE_TAG, rg.ProductionDate);
-
-        // FO:<FlowOrder>
-        if ( rg.HasFlowOrder() )
-            out << FormatTag(Constants::SAM_RG_FLOWORDER_TAG, rg.FlowOrder);
-
-        // KS:<KeySequence>
-        if ( rg.HasKeySequence() )
-            out << FormatTag(Constants::SAM_RG_KEYSEQUENCE_TAG, rg.KeySequence);
-
-        // LB:<Library>
-        if ( rg.HasLibrary() )
-            out << FormatTag(Constants::SAM_RG_LIBRARY_TAG, rg.Library);
-
-        // PG:<Program>
-        if ( rg.HasProgram() )
-            out << FormatTag(Constants::SAM_RG_PROGRAM_TAG, rg.Program);
-
-        // PI:<PredictedInsertSize>
-        if ( rg.HasPredictedInsertSize() )
-            out << FormatTag(Constants::SAM_RG_PREDICTEDINSERTSIZE_TAG, rg.PredictedInsertSize);
-
-        // PL:<SequencingTechnology>
-        if ( rg.HasSequencingTechnology() )
-            out << FormatTag(Constants::SAM_RG_SEQTECHNOLOGY_TAG, rg.SequencingTechnology);
-
-        // PU:<PlatformUnit>
-        if ( rg.HasPlatformUnit() )
-            out << FormatTag(Constants::SAM_RG_PLATFORMUNIT_TAG, rg.PlatformUnit);
-
-        // SM:<Sample>
-        if ( rg.HasSample() )
-            out << FormatTag(Constants::SAM_RG_SAMPLE_TAG, rg.Sample);
-
-        // newline
-        out << endl;
-    }
-}
-
-void SamFormatPrinter::PrintPG(std::stringstream& out) const {
-
-    // iterate over program record entries
-    SamProgramConstIterator pgIter = m_header.Programs.ConstBegin();
-    SamProgramConstIterator pgEnd  = m_header.Programs.ConstEnd();
-    for ( ; pgIter != pgEnd; ++pgIter ) {
-        const SamProgram& pg = (*pgIter);
-
-        // @PG ID:<ID>
-        out << Constants::SAM_PG_BEGIN_TOKEN
-            << FormatTag(Constants::SAM_PG_ID_TAG, pg.ID);
-
-        // PN:<Name>
-        if ( pg.HasName() )
-            out << FormatTag(Constants::SAM_PG_NAME_TAG, pg.Name);
-
-        // CL:<CommandLine>
-        if ( pg.HasCommandLine() )
-            out << FormatTag(Constants::SAM_PG_COMMANDLINE_TAG, pg.CommandLine);
-
-        // PP:<PreviousProgramID>
-        if ( pg.HasPreviousProgramID() )
-            out << FormatTag(Constants::SAM_PG_PREVIOUSPROGRAM_TAG, pg.PreviousProgramID);
-
-        // VN:<Version>
-        if ( pg.HasVersion() )
-            out << FormatTag(Constants::SAM_PG_VERSION_TAG, pg.Version);
-
-        // newline
-        out << endl;
-    }
-}
-
-void SamFormatPrinter::PrintCO(std::stringstream& out) const {
-
-    // iterate over comments
-    vector<string>::const_iterator commentIter = m_header.Comments.begin();
-    vector<string>::const_iterator commentEnd  = m_header.Comments.end();
-    for ( ; commentIter != commentEnd; ++commentIter ) {
-
-        // @CO <Comment>
-        out << Constants::SAM_CO_BEGIN_TOKEN
-            << Constants::SAM_TAB
-            << (*commentIter)
-            << endl;
-    }
-}
diff --git a/bamtools/src/api/internal/sam/SamFormatPrinter_p.h b/bamtools/src/api/internal/sam/SamFormatPrinter_p.h
deleted file mode 100644
index ea29181..0000000
--- a/bamtools/src/api/internal/sam/SamFormatPrinter_p.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// ***************************************************************************
-// SamFormatPrinter.h (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 6 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides functionality for printing formatted SAM header to string
-// ***************************************************************************
-
-#ifndef SAM_FORMAT_PRINTER_H
-#define SAM_FORMAT_PRINTER_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#include <sstream>
-#include <string>
-
-namespace BamTools {
-
-class SamHeader;
-
-namespace Internal {
-
-class SamFormatPrinter {
-
-    // ctor & dtor
-    public:
-        SamFormatPrinter(const BamTools::SamHeader& header);
-        ~SamFormatPrinter(void);
-
-    // generates SAM-formatted string from header data
-    public:
-        const std::string ToString(void) const;
-
-    // internal methods
-    private:
-        void PrintHD(std::stringstream& out) const;
-        void PrintSQ(std::stringstream& out) const;
-        void PrintRG(std::stringstream& out) const;
-        void PrintPG(std::stringstream& out) const;
-        void PrintCO(std::stringstream& out) const;
-
-    // data members
-    private:
-        const SamHeader& m_header;
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // SAM_FORMAT_PRINTER_H
diff --git a/bamtools/src/api/internal/sam/SamHeaderValidator_p.cpp b/bamtools/src/api/internal/sam/SamHeaderValidator_p.cpp
deleted file mode 100644
index 6bcb8a9..0000000
--- a/bamtools/src/api/internal/sam/SamHeaderValidator_p.cpp
+++ /dev/null
@@ -1,524 +0,0 @@
-// ***************************************************************************
-// SamHeaderValidator.cpp (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 25 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides functionality for validating SamHeader data
-// ***************************************************************************
-
-#include "api/SamConstants.h"
-#include "api/SamHeader.h"
-#include "api/internal/sam/SamHeaderValidator_p.h"
-#include "api/internal/sam/SamHeaderVersion_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-
-#include <cctype>
-#include <set>
-#include <sstream>
-using namespace std;
-
-// ------------------------
-// static utility methods
-// -------------------------
-
-static
-bool caseInsensitiveCompare(const string& lhs, const string& rhs) {
-
-    // can omit checking chars if lengths not equal
-    const int lhsLength = lhs.length();
-    const int rhsLength = rhs.length();
-    if ( lhsLength != rhsLength )
-        return false;
-
-    // do *basic* toupper checks on each string char's
-    for ( int i = 0; i < lhsLength; ++i ) {
-        if ( toupper( (int)lhs.at(i)) != toupper( (int)rhs.at(i)) )
-            return false;
-    }
-
-    // otherwise OK
-    return true;
-}
-
-// ------------------------------------------------------------------------
-// Allow validation rules to vary, as needed, between SAM header versions
-//
-// use SAM_VERSION_X_Y to tag important changes
-//
-// Together, they will allow for comparisons like:
-// if ( m_version < SAM_VERSION_2_0 ) {
-//     // use some older rule
-// else
-//     // use rule introduced with version 2.0
-
-static const SamHeaderVersion SAM_VERSION_1_0 = SamHeaderVersion(1,0);
-static const SamHeaderVersion SAM_VERSION_1_1 = SamHeaderVersion(1,1);
-static const SamHeaderVersion SAM_VERSION_1_2 = SamHeaderVersion(1,2);
-static const SamHeaderVersion SAM_VERSION_1_3 = SamHeaderVersion(1,3);
-static const SamHeaderVersion SAM_VERSION_1_4 = SamHeaderVersion(1,4);
-
-// TODO: This functionality is currently unused.
-//       Make validation "version-aware."
-//
-// ------------------------------------------------------------------------
-
-const string SamHeaderValidator::ERROR_PREFIX = "ERROR: ";
-const string SamHeaderValidator::WARN_PREFIX  = "WARNING: ";
-const string SamHeaderValidator::NEWLINE      = "\n";
-
-SamHeaderValidator::SamHeaderValidator(const SamHeader& header)
-    : m_header(header)
-{ }
-
-SamHeaderValidator::~SamHeaderValidator(void) { }
-
-void SamHeaderValidator::AddError(const string& message) {
-    m_errorMessages.push_back(ERROR_PREFIX + message + NEWLINE);
-}
-
-void SamHeaderValidator::AddWarning(const string& message) {
-    m_warningMessages.push_back(WARN_PREFIX + message + NEWLINE);
-}
-
-void SamHeaderValidator::PrintErrorMessages(ostream& stream) {
-
-    // skip if no error messages
-    if ( m_errorMessages.empty() )
-        return;
-
-    // print error header line
-    stream << "* SAM header has " << m_errorMessages.size() << " errors:" << endl;
-
-    // print each error message
-    vector<string>::const_iterator errorIter = m_errorMessages.begin();
-    vector<string>::const_iterator errorEnd  = m_errorMessages.end();
-    for ( ; errorIter != errorEnd; ++errorIter )
-        stream << (*errorIter);
-}
-
-void SamHeaderValidator::PrintMessages(ostream& stream) {
-    PrintErrorMessages(stream);
-    PrintWarningMessages(stream);
-}
-
-void SamHeaderValidator::PrintWarningMessages(ostream& stream) {
-
-    // skip if no warning messages
-    if ( m_warningMessages.empty() )
-        return;
-
-    // print warning header line
-    stream << "* SAM header has " << m_warningMessages.size() << " warnings:" << endl;
-
-    // print each warning message
-    vector<string>::const_iterator warnIter = m_warningMessages.begin();
-    vector<string>::const_iterator warnEnd  = m_warningMessages.end();
-    for ( ; warnIter != warnEnd; ++warnIter )
-        stream << (*warnIter);
-}
-
-// entry point for validation
-bool SamHeaderValidator::Validate(void) {
-    bool isValid = true;
-    isValid &= ValidateMetadata();
-    isValid &= ValidateSequenceDictionary();
-    isValid &= ValidateReadGroupDictionary();
-    isValid &= ValidateProgramChain();
-    return isValid;
-}
-
-// check all SAM header 'metadata'
-bool SamHeaderValidator::ValidateMetadata(void) {
-    bool isValid = true;
-    isValid &= ValidateVersion();
-    isValid &= ValidateSortOrder();
-    isValid &= ValidateGroupOrder();
-    return isValid;
-}
-
-// check SAM header version tag
-bool SamHeaderValidator::ValidateVersion(void) {
-
-    const string& version = m_header.Version;
-
-    // warn if version not present
-    if ( version.empty() ) {
-        AddWarning("Version (VN) missing. Not required, but strongly recommended");
-        return true;
-    }
-
-    // invalid if version does not contain a period
-    const size_t periodFound = version.find(Constants::SAM_PERIOD);
-    if ( periodFound == string::npos ) {
-        AddError("Invalid version (VN) format: " + version);
-        return false;
-    }
-
-    // invalid if major version is empty or contains non-digits
-    const string majorVersion = version.substr(0, periodFound);
-    if ( majorVersion.empty() || !ContainsOnlyDigits(majorVersion) ) {
-        AddError("Invalid version (VN) format: " + version);
-        return false;
-    }
-
-    // invalid if major version is empty or contains non-digits
-    const string minorVersion = version.substr(periodFound + 1);
-    if ( minorVersion.empty() || !ContainsOnlyDigits(minorVersion) ) {
-        AddError("Invalid version (VN) format: " + version);
-        return false;
-    }
-
-    // TODO: check if version is not just syntactically OK,
-    // but is also a valid SAM version ( 1.0 .. CURRENT )
-
-    // all checked out this far, then version is OK
-    return true;
-}
-
-// assumes non-empty input string
-bool SamHeaderValidator::ContainsOnlyDigits(const string& s) {
-    const size_t nonDigitPosition = s.find_first_not_of(Constants::SAM_DIGITS);
-    return ( nonDigitPosition == string::npos ) ;
-}
-
-// validate SAM header sort order tag
-bool SamHeaderValidator::ValidateSortOrder(void) {
-
-    const string& sortOrder = m_header.SortOrder;
-
-    // warn if sort order not present
-    if ( sortOrder.empty() ) {
-        AddWarning("Sort order (SO) missing. Not required, but strongly recommended");
-        return true;
-    }
-
-    // if sort order is valid keyword
-    if ( sortOrder == Constants::SAM_HD_SORTORDER_COORDINATE ||
-         sortOrder == Constants::SAM_HD_SORTORDER_QUERYNAME  ||
-         sortOrder == Constants::SAM_HD_SORTORDER_UNSORTED
-       )
-    {
-        return true;
-    }
-
-    // otherwise
-    AddError("Invalid sort order (SO): " + sortOrder);
-    return false;
-}
-
-// validate SAM header group order tag
-bool SamHeaderValidator::ValidateGroupOrder(void) {
-
-    const string& groupOrder = m_header.GroupOrder;
-
-    // if no group order, no problem, just return OK
-    if ( groupOrder.empty() )
-        return true;
-
-    // if group order is valid keyword
-    if ( groupOrder == Constants::SAM_HD_GROUPORDER_NONE  ||
-         groupOrder == Constants::SAM_HD_GROUPORDER_QUERY ||
-         groupOrder == Constants::SAM_HD_GROUPORDER_REFERENCE
-       )
-    {
-        return true;
-    }
-
-    // otherwise
-    AddError("Invalid group order (GO): " + groupOrder);
-    return false;
-}
-
-// validate SAM header sequence dictionary
-bool SamHeaderValidator::ValidateSequenceDictionary(void) {
-
-    bool isValid = true;
-
-    // check for unique sequence names
-    isValid &= ContainsUniqueSequenceNames();
-
-    // iterate over sequences
-    const SamSequenceDictionary& sequences = m_header.Sequences;
-    SamSequenceConstIterator seqIter = sequences.ConstBegin();
-    SamSequenceConstIterator seqEnd  = sequences.ConstEnd();
-    for ( ; seqIter != seqEnd; ++seqIter ) {
-        const SamSequence& seq = (*seqIter);
-        isValid &= ValidateSequence(seq);
-    }
-
-    // return validation state
-    return isValid;
-}
-
-// make sure all SQ names are unique
-bool SamHeaderValidator::ContainsUniqueSequenceNames(void) {
-
-    bool isValid = true;
-    set<string> sequenceNames;
-    set<string>::iterator nameIter;
-
-    // iterate over sequences
-    const SamSequenceDictionary& sequences = m_header.Sequences;
-    SamSequenceConstIterator seqIter = sequences.ConstBegin();
-    SamSequenceConstIterator seqEnd  = sequences.ConstEnd();
-    for ( ; seqIter != seqEnd; ++seqIter ) {
-        const SamSequence& seq = (*seqIter);
-
-        // lookup sequence name
-        const string& name = seq.Name;
-        nameIter = sequenceNames.find(name);
-
-        // error if found (duplicate entry)
-        if ( nameIter != sequenceNames.end() ) {
-            AddError("Sequence name (SN): " + name + " is not unique");
-            isValid = false;
-        }
-
-        // otherwise ok, store name
-        sequenceNames.insert(name);
-    }
-
-    // return validation state
-    return isValid;
-}
-
-// validate SAM header sequence entry
-bool SamHeaderValidator::ValidateSequence(const SamSequence& seq) {
-    bool isValid = true;
-    isValid &= CheckNameFormat(seq.Name);
-    isValid &= CheckLengthInRange(seq.Length);
-    return isValid;
-}
-
-// check sequence name is valid format
-bool SamHeaderValidator::CheckNameFormat(const string& name) {
-
-    // invalid if name is empty
-    if ( name.empty() ) {
-        AddError("Sequence entry (@SQ) is missing SN tag");
-        return false;
-    }
-
-    // invalid if first character is a reserved char
-    const char firstChar = name.at(0);
-    if ( firstChar == Constants::SAM_EQUAL || firstChar == Constants::SAM_STAR ) {
-        AddError("Invalid sequence name (SN): " + name);
-        return false;
-    }
-    // otherwise OK
-    return true;
-}
-
-// check that sequence length is within accepted range
-bool SamHeaderValidator::CheckLengthInRange(const string& length) {
-
-    // invalid if empty
-    if ( length.empty() ) {
-        AddError("Sequence entry (@SQ) is missing LN tag");
-        return false;
-    }
-
-    // convert string length to numeric
-    stringstream lengthStream(length);
-    unsigned int sequenceLength;
-    lengthStream >> sequenceLength;
-
-    // invalid if length outside accepted range
-    if ( sequenceLength < Constants::SAM_SQ_LENGTH_MIN || sequenceLength > Constants::SAM_SQ_LENGTH_MAX ) {
-        AddError("Sequence length (LN): " + length + " out of range");
-        return false;
-    }
-
-    // otherwise OK
-    return true;
-}
-
-// validate SAM header read group dictionary
-bool SamHeaderValidator::ValidateReadGroupDictionary(void) {
-
-    bool isValid = true;
-
-    // check for unique read group IDs & platform units
-    isValid &= ContainsUniqueIDsAndPlatformUnits();
-
-    // iterate over read groups
-    const SamReadGroupDictionary& readGroups = m_header.ReadGroups;
-    SamReadGroupConstIterator rgIter = readGroups.ConstBegin();
-    SamReadGroupConstIterator rgEnd  = readGroups.ConstEnd();
-    for ( ; rgIter != rgEnd; ++rgIter ) {
-        const SamReadGroup& rg = (*rgIter);
-        isValid &= ValidateReadGroup(rg);
-    }
-
-    // return validation state
-    return isValid;
-}
-
-// make sure RG IDs and platform units are unique
-bool SamHeaderValidator::ContainsUniqueIDsAndPlatformUnits(void) {
-
-    bool isValid = true;
-    set<string> readGroupIds;
-    set<string> platformUnits;
-    set<string>::iterator idIter;
-    set<string>::iterator puIter;
-
-    // iterate over sequences
-    const SamReadGroupDictionary& readGroups = m_header.ReadGroups;
-    SamReadGroupConstIterator rgIter = readGroups.ConstBegin();
-    SamReadGroupConstIterator rgEnd  = readGroups.ConstEnd();
-    for ( ; rgIter != rgEnd; ++rgIter ) {
-        const SamReadGroup& rg = (*rgIter);
-
-        // --------------------------------
-        // check for unique ID
-
-        // lookup read group ID
-        const string& id = rg.ID;
-        idIter = readGroupIds.find(id);
-
-        // error if found (duplicate entry)
-        if ( idIter != readGroupIds.end() ) {
-            AddError("Read group ID (ID): " + id + " is not unique");
-            isValid = false;
-        }
-
-        // otherwise ok, store id
-        readGroupIds.insert(id);
-
-        // --------------------------------
-        // check for unique platform unit
-
-        // lookup platform unit
-        const string& pu = rg.PlatformUnit;
-        puIter = platformUnits.find(pu);
-
-        // error if found (duplicate entry)
-        if ( puIter != platformUnits.end() ) {
-            AddError("Platform unit (PU): " + pu + " is not unique");
-            isValid = false;
-        }
-
-        // otherwise ok, store platform unit
-        platformUnits.insert(pu);
-    }
-
-    // return validation state
-    return isValid;
-}
-
-// validate SAM header read group entry
-bool SamHeaderValidator::ValidateReadGroup(const SamReadGroup& rg) {
-    bool isValid = true;
-    isValid &= CheckReadGroupID(rg.ID);
-    isValid &= CheckSequencingTechnology(rg.SequencingTechnology);
-    return isValid;
-}
-
-// make sure RG ID exists
-bool SamHeaderValidator::CheckReadGroupID(const string& id) {
-
-    // invalid if empty
-    if ( id.empty() ) {
-        AddError("Read group entry (@RG) is missing ID tag");
-        return false;
-    }
-
-    // otherwise OK
-    return true;
-}
-
-// make sure RG sequencing tech is one of the accepted keywords
-bool SamHeaderValidator::CheckSequencingTechnology(const string& technology) {
-
-    // if no technology provided, no problem, just return OK
-    if ( technology.empty() )
-        return true;
-
-    // if technology is valid keyword
-    if ( caseInsensitiveCompare(technology, Constants::SAM_RG_SEQTECHNOLOGY_CAPILLARY)  ||
-         caseInsensitiveCompare(technology, Constants::SAM_RG_SEQTECHNOLOGY_HELICOS)    ||
-         caseInsensitiveCompare(technology, Constants::SAM_RG_SEQTECHNOLOGY_ILLUMINA)   ||
-         caseInsensitiveCompare(technology, Constants::SAM_RG_SEQTECHNOLOGY_IONTORRENT) ||
-         caseInsensitiveCompare(technology, Constants::SAM_RG_SEQTECHNOLOGY_LS454)      ||
-         caseInsensitiveCompare(technology, Constants::SAM_RG_SEQTECHNOLOGY_PACBIO)     ||
-         caseInsensitiveCompare(technology, Constants::SAM_RG_SEQTECHNOLOGY_SOLID)
-       )
-    {
-        return true;
-    }
-
-    // otherwise
-    AddError("Invalid read group sequencing platform (PL): " + technology);
-    return false;
-}
-
-// validate the SAM header "program chain"
-bool SamHeaderValidator::ValidateProgramChain(void) {
-    bool isValid = true;
-    isValid &= ContainsUniqueProgramIds();
-    isValid &= ValidatePreviousProgramIds();
-    return isValid;
-}
-
-// make sure all PG IDs are unique
-bool SamHeaderValidator::ContainsUniqueProgramIds(void) {
-
-    bool isValid = true;
-    set<string> programIds;
-    set<string>::iterator pgIdIter;
-
-    // iterate over program records
-    const SamProgramChain& programs = m_header.Programs;
-    SamProgramConstIterator pgIter = programs.ConstBegin();
-    SamProgramConstIterator pgEnd  = programs.ConstEnd();
-    for ( ; pgIter != pgEnd; ++pgIter ) {
-        const SamProgram& pg = (*pgIter);
-
-        // lookup program ID
-        const string& pgId = pg.ID;
-        pgIdIter = programIds.find(pgId);
-
-        // error if found (duplicate entry)
-        if ( pgIdIter != programIds.end() ) {
-            AddError("Program ID (ID): " + pgId + " is not unique");
-            isValid = false;
-        }
-
-        // otherwise ok, store ID
-        programIds.insert(pgId);
-    }
-
-    // return validation state
-    return isValid;
-}
-
-// make sure that any PP tags present point to existing @PG IDs
-bool SamHeaderValidator::ValidatePreviousProgramIds(void) {
-
-    bool isValid = true;
-
-    // iterate over program records
-    const SamProgramChain& programs = m_header.Programs;
-    SamProgramConstIterator pgIter = programs.ConstBegin();
-    SamProgramConstIterator pgEnd  = programs.ConstEnd();
-    for ( ; pgIter != pgEnd; ++pgIter ) {
-        const SamProgram& pg = (*pgIter);
-
-        // ignore record for validation if PreviousProgramID is empty
-        const string& ppId = pg.PreviousProgramID;
-        if ( ppId.empty() )
-            continue;
-
-        // see if program "chain" contains an entry for ppId
-        if ( !programs.Contains(ppId) ) {
-            AddError("PreviousProgramID (PP): " + ppId + " is not a known ID");
-            isValid = false;
-        }
-    }
-
-    // return validation state
-    return isValid;
-}
diff --git a/bamtools/src/api/internal/sam/SamHeaderValidator_p.h b/bamtools/src/api/internal/sam/SamHeaderValidator_p.h
deleted file mode 100644
index 7d0c60a..0000000
--- a/bamtools/src/api/internal/sam/SamHeaderValidator_p.h
+++ /dev/null
@@ -1,105 +0,0 @@
-// ***************************************************************************
-// SamHeaderValidator.h (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 6 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides functionality for validating SamHeader data
-// ***************************************************************************
-
-#ifndef SAM_HEADER_VALIDATOR_P_H
-#define SAM_HEADER_VALIDATOR_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#include <iostream>
-#include <string>
-#include <vector>
-
-namespace BamTools {
-
-class SamHeader;
-class SamReadGroup;
-class SamSequence;
-
-namespace Internal {
-
-class SamHeaderValidator {
-
-    // ctor & dtor
-    public:
-        SamHeaderValidator(const SamHeader& header);
-        ~SamHeaderValidator(void);
-
-    // SamHeaderValidator interface
-    public:
-
-        // prints error & warning messages
-        void PrintMessages(std::ostream& stream);
-
-        // validates SamHeader data, returns true/false accordingly
-        bool Validate(void);
-
-    // internal methods
-    private:
-
-        // validate header metadata
-        bool ValidateMetadata(void);
-        bool ValidateVersion(void);
-        bool ContainsOnlyDigits(const std::string& s);
-        bool ValidateSortOrder(void);
-        bool ValidateGroupOrder(void);
-
-        // validate sequence dictionary
-        bool ValidateSequenceDictionary(void);
-        bool ContainsUniqueSequenceNames(void);
-        bool CheckNameFormat(const std::string& name);
-        bool ValidateSequence(const SamSequence& seq);
-        bool CheckLengthInRange(const std::string& length);
-
-        // validate read group dictionary
-        bool ValidateReadGroupDictionary(void);
-        bool ContainsUniqueIDsAndPlatformUnits(void);
-        bool ValidateReadGroup(const SamReadGroup& rg);
-        bool CheckReadGroupID(const std::string& id);
-        bool CheckSequencingTechnology(const std::string& technology);
-
-        // validate program data
-        bool ValidateProgramChain(void);
-        bool ContainsUniqueProgramIds(void);
-        bool ValidatePreviousProgramIds(void);
-
-        // error reporting
-        void AddError(const std::string& message);
-        void AddWarning(const std::string& message);
-        void PrintErrorMessages(std::ostream& stream);
-        void PrintWarningMessages(std::ostream& stream);
-
-    // data members
-    private:
-
-        // SamHeader being validated
-        const SamHeader& m_header;
-
-        // error reporting helpers
-        static const std::string ERROR_PREFIX;
-        static const std::string WARN_PREFIX;
-        static const std::string NEWLINE;
-
-        // error reporting messages
-        std::vector<std::string> m_errorMessages;
-        std::vector<std::string> m_warningMessages;
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // SAM_HEADER_VALIDATOR_P_H
diff --git a/bamtools/src/api/internal/sam/SamHeaderVersion_p.h b/bamtools/src/api/internal/sam/SamHeaderVersion_p.h
deleted file mode 100644
index 4f85df0..0000000
--- a/bamtools/src/api/internal/sam/SamHeaderVersion_p.h
+++ /dev/null
@@ -1,134 +0,0 @@
-// ***************************************************************************
-// SamHeaderVersion.h (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides functionality for comparing SAM header versions
-// *************************************************************************
-
-#ifndef SAM_HEADERVERSION_P_H
-#define SAM_HEADERVERSION_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#include "api/SamConstants.h"
-#include <sstream>
-#include <string>
-
-namespace BamTools {
-namespace Internal {
-
-class SamHeaderVersion {
-
-    // ctors & dtor
-    public:
-        SamHeaderVersion(void)
-            : m_majorVersion(0)
-            , m_minorVersion(0)
-        { }
-
-        explicit SamHeaderVersion(const std::string& version)
-            : m_majorVersion(0)
-            , m_minorVersion(0)
-        {
-            SetVersion(version);
-        }
-
-        SamHeaderVersion(const unsigned int& major, const unsigned int& minor)
-            : m_majorVersion(major)
-            , m_minorVersion(minor)
-        { }
-
-        ~SamHeaderVersion(void) {
-            m_majorVersion = 0;
-            m_minorVersion = 0;
-        }
-    
-    // acess data
-    public:
-        unsigned int MajorVersion(void) const { return m_majorVersion; }
-        unsigned int MinorVersion(void) const { return m_minorVersion; }
-
-        void SetVersion(const std::string& version);
-        std::string ToString(void) const;
-
-    // data members
-    private:
-        unsigned int m_majorVersion;
-        unsigned int m_minorVersion;
-};
-
-inline
-void SamHeaderVersion::SetVersion(const std::string& version) {
-
-    // do nothing if version is empty
-    if ( !version.empty() ) {
-
-        std::stringstream versionStream("");
-
-        // do nothing if period not found
-        const size_t periodFound = version.find(Constants::SAM_PERIOD);
-        if ( periodFound != std::string::npos ) {
-
-            // store major version if non-empty and contains only digits
-            const std::string& majorVersion = version.substr(0, periodFound);
-            versionStream.str(majorVersion);
-            if ( !majorVersion.empty() ) {
-                const size_t nonDigitFound = majorVersion.find_first_not_of(Constants::SAM_DIGITS);
-                if ( nonDigitFound == std::string::npos )
-                    versionStream >> m_majorVersion;
-            }
-
-            // store minor version if non-empty and contains only digits
-            const std::string& minorVersion = version.substr(periodFound + 1);
-            versionStream.str(minorVersion);
-            if ( !minorVersion.empty() ) {
-                const size_t nonDigitFound = minorVersion.find_first_not_of(Constants::SAM_DIGITS);
-                if ( nonDigitFound == std::string::npos )
-                    versionStream >> m_minorVersion;
-            }
-        }
-    }
-}
-
-// -----------------------------------------------------
-// printing
-
-inline std::string SamHeaderVersion::ToString(void) const {
-    std::stringstream version;
-    version << m_majorVersion << Constants::SAM_PERIOD << m_minorVersion;
-    return version.str();
-}
-
-// -----------------------------------------------------
-// comparison operators
-
-inline bool operator==(const SamHeaderVersion& lhs, const SamHeaderVersion& rhs) {
-    return (lhs.MajorVersion() == rhs.MajorVersion()) &&
-           (lhs.MinorVersion() == rhs.MinorVersion());
-}
-
-inline bool operator<(const SamHeaderVersion& lhs, const SamHeaderVersion& rhs) {
-    if ( lhs.MajorVersion() == rhs.MajorVersion() )
-        return lhs.MinorVersion() < rhs.MinorVersion();
-    else 
-        return lhs.MajorVersion() < rhs.MajorVersion();
-}
-
-inline bool operator> (const SamHeaderVersion& lhs, const SamHeaderVersion& rhs) { return rhs < lhs;  }
-inline bool operator<=(const SamHeaderVersion& lhs, const SamHeaderVersion& rhs) { return !(lhs>rhs); }
-inline bool operator>=(const SamHeaderVersion& lhs, const SamHeaderVersion& rhs) { return !(lhs<rhs); }
-
-} // namespace Internal 
-} // namespace BamTools
-
-#endif // SAM_HEADERVERSION_P_H
diff --git a/bamtools/src/api/internal/utils/BamException_p.cpp b/bamtools/src/api/internal/utils/BamException_p.cpp
deleted file mode 100644
index 103e34b..0000000
--- a/bamtools/src/api/internal/utils/BamException_p.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-// ***************************************************************************
-// BamException_p.cpp (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 25 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides a basic exception class for BamTools internals
-// ***************************************************************************
-
-#include "api/internal/utils/BamException_p.h"
-using namespace BamTools;
-using namespace BamTools::Internal;
-using namespace std;
-
-const string BamException::SEPARATOR = ": ";
diff --git a/bamtools/src/api/internal/utils/BamException_p.h b/bamtools/src/api/internal/utils/BamException_p.h
deleted file mode 100644
index 5199737..0000000
--- a/bamtools/src/api/internal/utils/BamException_p.h
+++ /dev/null
@@ -1,51 +0,0 @@
-// ***************************************************************************
-// BamException_p.h (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 6 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides a basic exception class for BamTools internals
-// ***************************************************************************
-
-#ifndef BAMEXCEPTION_P_H
-#define BAMEXCEPTION_P_H
-
-//  -------------
-//  W A R N I N G
-//  -------------
-//
-// This file is not part of the BamTools API.  It exists purely as an
-// implementation detail. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-
-#include <exception>
-#include <string>
-
-namespace BamTools {
-namespace Internal {
-
-class BamException : public std::exception {
-
-    public:
-        inline BamException(const std::string& where, const std::string& message)
-            : std::exception()
-            , m_errorString(where + SEPARATOR + message)
-        { }
-
-        inline ~BamException(void) throw() { }
-
-        inline const char* what(void) const throw() {
-            return m_errorString.c_str();
-        }
-
-    private:
-        std::string m_errorString;
-        static const std::string SEPARATOR;
-};
-
-} // namespace Internal
-} // namespace BamTools
-
-#endif // BAMEXCEPTION_P_H
diff --git a/bamtools/src/api/internal/utils/CMakeLists.txt b/bamtools/src/api/internal/utils/CMakeLists.txt
deleted file mode 100644
index 4b1e2c2..0000000
--- a/bamtools/src/api/internal/utils/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-# ==========================
-# BamTools CMakeLists.txt
-# (c) 2011 Derek Barnett
-#
-# src/api/internal/utils
-# ==========================
-
-set( InternalUtilsDir "${InternalDir}/utils" )
-
-set( InternalUtilsSources
-        ${InternalUtilsDir}/BamException_p.cpp
-
-        PARENT_SCOPE # <-- leave this last
-)
-
diff --git a/bamtools/src/shared/bamtools_global.h b/bamtools/src/shared/bamtools_global.h
deleted file mode 100644
index e37bff6..0000000
--- a/bamtools/src/shared/bamtools_global.h
+++ /dev/null
@@ -1,97 +0,0 @@
-// ***************************************************************************
-// bamtools_global.h (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011 (DB)
-// ---------------------------------------------------------------------------
-// Provides the basic definitions for exporting & importing library symbols.
-// Also provides some platform-specific rules for definitions.
-// ***************************************************************************
-
-#ifndef BAMTOOLS_GLOBAL_H
-#define BAMTOOLS_GLOBAL_H
-
-/*! \brief Library export macro
-    \internal
-*/
-#ifndef BAMTOOLS_LIBRARY_EXPORT
-#  if defined(WIN32)
-#    define BAMTOOLS_LIBRARY_EXPORT __declspec(dllexport)
-#  else
-#    define BAMTOOLS_LIBRARY_EXPORT __attribute__((visibility("default")))
-#  endif
-#endif // BAMTOOLS_LIBRARY_EXPORT
-
-/*! \brief Library import macro
-    \internal
-*/
-#ifndef BAMTOOLS_LIBRARY_IMPORT
-#  if defined(WIN32)
-#    define BAMTOOLS_LIBRARY_IMPORT __declspec(dllimport)
-#  else
-#    define BAMTOOLS_LIBRARY_IMPORT
-#  endif
-#endif // BAMTOOLS_LIBRARY_IMPORT
-
-/*! \brief Platform-specific type definitions
-    \internal
-*/
-#ifndef BAMTOOLS_LFS
-#define BAMTOOLS_LFS
-#  ifdef WIN32
-#    define ftell64(a)     _ftelli64(a)
-#    define fseek64(a,b,c) _fseeki64(a,b,c)
-#  else
-#    define ftell64(a)     ftello(a)
-#    define fseek64(a,b,c) fseeko(a,b,c)
-#  endif
-#endif // BAMTOOLS_LFS
-
-/*! \def ftell64(a)
-    \brief Platform-independent tell() operation.
-    \internal
-*/
-/*! \def fseek64(a,b,c)
-    \brief Platform-independent seek() operation.
-    \internal
-*/
-
-/*! \brief Platform-specific type definitions
-    \internal
-*/
-#ifndef BAMTOOLS_TYPES
-#define BAMTOOLS_TYPES
-#  ifdef _MSC_VER
-     typedef char                 int8_t;
-     typedef unsigned char       uint8_t;
-     typedef short               int16_t;
-     typedef unsigned short     uint16_t;
-     typedef int                 int32_t;
-     typedef unsigned int       uint32_t;
-     typedef long long           int64_t;
-     typedef unsigned long long uint64_t;
-#  else
-#    include <stdint.h>
-#  endif
-#endif // BAMTOOLS_TYPES
-
-//! \internal
-inline void bamtools_noop(void) { }
-
-/*! \brief Assert definitions
-    \internal
-*/
-#ifndef BAMTOOLS_ASSERTS
-#define BAMTOOLS_ASSERTS
-#  ifdef NDEBUG
-#    define BT_ASSERT_UNREACHABLE             bamtools_noop()
-#    define BT_ASSERT_X( condition, message ) bamtools_noop()
-#  else
-#    include <cassert>
-#    include <stdexcept>
-#    define BT_ASSERT_UNREACHABLE             assert( false )
-#    define BT_ASSERT_X( condition, message ) if (!( condition )) { throw std::runtime_error( message ); }
-#  endif
-#endif // BAMTOOLS_ASSERTS
-
-#endif // BAMTOOLS_GLOBAL_H
diff --git a/bamtools/src/third_party/CMakeLists.txt b/bamtools/src/third_party/CMakeLists.txt
deleted file mode 100644
index ec965be..0000000
--- a/bamtools/src/third_party/CMakeLists.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-# ==========================
-# BamTools CMakeLists.txt
-# (c) 2010 Derek Barnett
-#
-# src/third-party/
-# ==========================
-
-# list third-party subdirectories to build in
-add_subdirectory( jsoncpp )
diff --git a/bamtools/src/third_party/gtest-1.6.0/CHANGES b/bamtools/src/third_party/gtest-1.6.0/CHANGES
deleted file mode 100644
index 5919245..0000000
--- a/bamtools/src/third_party/gtest-1.6.0/CHANGES
+++ /dev/null
@@ -1,130 +0,0 @@
-Changes for 1.6.0:
-
-* New feature: ADD_FAILURE_AT() for reporting a test failure at the
-  given source location -- useful for writing testing utilities.
-* New feature: the universal value printer is moved from Google Mock
-  to Google Test.
-* New feature: type parameters and value parameters are reported in
-  the XML report now.
-* A gtest_disable_pthreads CMake option.
-* Colored output works in GNU Screen sessions now.
-* Parameters of value-parameterized tests are now printed in the
-  textual output.
-* Failures from ad hoc test assertions run before RUN_ALL_TESTS() are
-  now correctly reported.
-* Arguments of ASSERT_XY and EXPECT_XY no longer need to support << to
-  ostream.
-* More complete handling of exceptions.
-* GTEST_ASSERT_XY can be used instead of ASSERT_XY in case the latter
-  name is already used by another library.
-* --gtest_catch_exceptions is now true by default, allowing a test
-  program to continue after an exception is thrown.
-* Value-parameterized test fixtures can now derive from Test and
-  WithParamInterface<T> separately, easing conversion of legacy tests.
-* Death test messages are clearly marked to make them more
-  distinguishable from other messages.
-* Compatibility fixes for Android, Google Native Client, MinGW, HP UX,
-  PowerPC, Lucid autotools, libCStd, Sun C++, Borland C++ Builder (Code Gear),
-  IBM XL C++ (Visual Age C++), and C++0x.
-* Bug fixes and implementation clean-ups.
-* Potentially incompatible changes: disables the harmful 'make install'
-  command in autotools.
-
-Changes for 1.5.0:
-
- * New feature: assertions can be safely called in multiple threads
-   where the pthreads library is available.
- * New feature: predicates used inside EXPECT_TRUE() and friends
-   can now generate custom failure messages.
- * New feature: Google Test can now be compiled as a DLL.
- * New feature: fused source files are included.
- * New feature: prints help when encountering unrecognized Google Test flags.
- * Experimental feature: CMake build script (requires CMake 2.6.4+).
- * Experimental feature: the Pump script for meta programming.
- * double values streamed to an assertion are printed with enough precision
-   to differentiate any two different values.
- * Google Test now works on Solaris and AIX.
- * Build and test script improvements.
- * Bug fixes and implementation clean-ups.
-
- Potentially breaking changes:
-
- * Stopped supporting VC++ 7.1 with exceptions disabled.
- * Dropped support for 'make install'.
-
-Changes for 1.4.0:
-
- * New feature: the event listener API
- * New feature: test shuffling
- * New feature: the XML report format is closer to junitreport and can
-   be parsed by Hudson now.
- * New feature: when a test runs under Visual Studio, its failures are
-   integrated in the IDE.
- * New feature: /MD(d) versions of VC++ projects.
- * New feature: elapsed time for the tests is printed by default.
- * New feature: comes with a TR1 tuple implementation such that Boost
-   is no longer needed for Combine().
- * New feature: EXPECT_DEATH_IF_SUPPORTED macro and friends.
- * New feature: the Xcode project can now produce static gtest
-   libraries in addition to a framework.
- * Compatibility fixes for Solaris, Cygwin, minGW, Windows Mobile,
-   Symbian, gcc, and C++Builder.
- * Bug fixes and implementation clean-ups.
-
-Changes for 1.3.0:
-
- * New feature: death tests on Windows, Cygwin, and Mac.
- * New feature: ability to use Google Test assertions in other testing
-   frameworks.
- * New feature: ability to run disabled test via
-   --gtest_also_run_disabled_tests.
- * New feature: the --help flag for printing the usage.
- * New feature: access to Google Test flag values in user code.
- * New feature: a script that packs Google Test into one .h and one
-   .cc file for easy deployment.
- * New feature: support for distributing test functions to multiple
-   machines (requires support from the test runner).
- * Bug fixes and implementation clean-ups.
-
-Changes for 1.2.1:
-
- * Compatibility fixes for Linux IA-64 and IBM z/OS.
- * Added support for using Boost and other TR1 implementations.
- * Changes to the build scripts to support upcoming release of Google C++
-   Mocking Framework.
- * Added Makefile to the distribution package.
- * Improved build instructions in README.
-
-Changes for 1.2.0:
-
- * New feature: value-parameterized tests.
- * New feature: the ASSERT/EXPECT_(NON)FATAL_FAILURE(_ON_ALL_THREADS)
-   macros.
- * Changed the XML report format to match JUnit/Ant's.
- * Added tests to the Xcode project.
- * Added scons/SConscript for building with SCons.
- * Added src/gtest-all.cc for building Google Test from a single file.
- * Fixed compatibility with Solaris and z/OS.
- * Enabled running Python tests on systems with python 2.3 installed,
-   e.g. Mac OS X 10.4.
- * Bug fixes.
-
-Changes for 1.1.0:
-
- * New feature: type-parameterized tests.
- * New feature: exception assertions.
- * New feature: printing elapsed time of tests.
- * Improved the robustness of death tests.
- * Added an Xcode project and samples.
- * Adjusted the output format on Windows to be understandable by Visual Studio.
- * Minor bug fixes.
-
-Changes for 1.0.1:
-
- * Added project files for Visual Studio 7.1.
- * Fixed issues with compiling on Mac OS X.
- * Fixed issues with compiling on Cygwin.
-
-Changes for 1.0.0:
-
- * Initial Open Source release of Google Test
diff --git a/bamtools/src/third_party/gtest-1.6.0/CMakeLists.txt b/bamtools/src/third_party/gtest-1.6.0/CMakeLists.txt
deleted file mode 100644
index 0fe2654..0000000
--- a/bamtools/src/third_party/gtest-1.6.0/CMakeLists.txt
+++ /dev/null
@@ -1,240 +0,0 @@
-########################################################################
-# CMake build script for Google Test.
-#
-# To run the tests for Google Test itself on Linux, use 'make test' or
-# ctest.  You can select which tests to run using 'ctest -R regex'.
-# For more options, run 'ctest --help'.
-
-# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to
-# make it prominent in the GUI.
-option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF)
-
-# When other libraries are using a shared version of runtime libraries,
-# Google Test also has to use one.
-option(
-  gtest_force_shared_crt
-  "Use shared (DLL) run-time lib even when Google Test is built as static lib."
-  OFF)
-
-option(gtest_build_tests "Build all of gtest's own tests." OFF)
-
-option(gtest_build_samples "Build gtest's sample programs." OFF)
-
-option(gtest_disable_pthreads "Disable uses of pthreads in gtest." OFF)
-
-# Defines pre_project_set_up_hermetic_build() and set_up_hermetic_build().
-include(cmake/hermetic_build.cmake OPTIONAL)
-
-if (COMMAND pre_project_set_up_hermetic_build)
-  pre_project_set_up_hermetic_build()
-endif()
-
-########################################################################
-#
-# Project-wide settings
-
-# Name of the project.
-#
-# CMake files in this project can refer to the root source directory
-# as ${gtest_SOURCE_DIR} and to the root binary directory as
-# ${gtest_BINARY_DIR}.
-# Language "C" is required for find_package(Threads).
-project(gtest CXX C)
-cmake_minimum_required(VERSION 2.6.2)
-
-if (COMMAND set_up_hermetic_build)
-  set_up_hermetic_build()
-endif()
-
-# Define helper functions and macros used by Google Test.
-include(cmake/internal_utils.cmake)
-
-config_compiler_and_linker()  # Defined in internal_utils.cmake.
-
-# Where Google Test's .h files can be found.
-include_directories(
-  ${gtest_SOURCE_DIR}/include
-  ${gtest_SOURCE_DIR})
-
-# Where Google Test's libraries can be found.
-link_directories(${gtest_BINARY_DIR}/src)
-
-########################################################################
-#
-# Defines the gtest & gtest_main libraries.  User tests should link
-# with one of them.
-
-# Google Test libraries.  We build them using more strict warnings than what
-# are used for other targets, to ensure that gtest can be compiled by a user
-# aggressive about warnings.
-cxx_library(gtest "${cxx_strict}" src/gtest-all.cc)
-cxx_library(gtest_main "${cxx_strict}" src/gtest_main.cc)
-target_link_libraries(gtest_main gtest)
-
-########################################################################
-#
-# Samples on how to link user tests with gtest or gtest_main.
-#
-# They are not built by default.  To build them, set the
-# gtest_build_samples option to ON.  You can do it by running ccmake
-# or specifying the -Dbuild_gtest_samples=ON flag when running cmake.
-
-if (gtest_build_samples)
-  cxx_executable(sample1_unittest samples gtest_main samples/sample1.cc)
-  cxx_executable(sample2_unittest samples gtest_main samples/sample2.cc)
-  cxx_executable(sample3_unittest samples gtest_main)
-  cxx_executable(sample4_unittest samples gtest_main samples/sample4.cc)
-  cxx_executable(sample5_unittest samples gtest_main samples/sample1.cc)
-  cxx_executable(sample6_unittest samples gtest_main)
-  cxx_executable(sample7_unittest samples gtest_main)
-  cxx_executable(sample8_unittest samples gtest_main)
-  cxx_executable(sample9_unittest samples gtest)
-  cxx_executable(sample10_unittest samples gtest)
-endif()
-
-########################################################################
-#
-# Google Test's own tests.
-#
-# You can skip this section if you aren't interested in testing
-# Google Test itself.
-#
-# The tests are not built by default.  To build them, set the
-# gtest_build_tests option to ON.  You can do it by running ccmake
-# or specifying the -Dgtest_build_tests=ON flag when running cmake.
-
-if (gtest_build_tests)
-  # This must be set in the root directory for the tests to be run by
-  # 'make test' or ctest.
-  enable_testing()
-
-  ############################################################
-  # C++ tests built with standard compiler flags.
-
-  cxx_test(gtest-death-test_test gtest_main)
-  cxx_test(gtest_environment_test gtest)
-  cxx_test(gtest-filepath_test gtest_main)
-  cxx_test(gtest-linked_ptr_test gtest_main)
-  cxx_test(gtest-listener_test gtest_main)
-  cxx_test(gtest_main_unittest gtest_main)
-  cxx_test(gtest-message_test gtest_main)
-  cxx_test(gtest_no_test_unittest gtest)
-  cxx_test(gtest-options_test gtest_main)
-  cxx_test(gtest-param-test_test gtest
-    test/gtest-param-test2_test.cc)
-  cxx_test(gtest-port_test gtest_main)
-  cxx_test(gtest_pred_impl_unittest gtest_main)
-  cxx_test(gtest-printers_test gtest_main)
-  cxx_test(gtest_prod_test gtest_main
-    test/production.cc)
-  cxx_test(gtest_repeat_test gtest)
-  cxx_test(gtest_sole_header_test gtest_main)
-  cxx_test(gtest_stress_test gtest)
-  cxx_test(gtest-test-part_test gtest_main)
-  cxx_test(gtest_throw_on_failure_ex_test gtest)
-  cxx_test(gtest-typed-test_test gtest_main
-    test/gtest-typed-test2_test.cc)
-  cxx_test(gtest_unittest gtest_main)
-  cxx_test(gtest-unittest-api_test gtest)
-
-  ############################################################
-  # C++ tests built with non-standard compiler flags.
-
-  cxx_library(gtest_no_exception "${cxx_no_exception}"
-    src/gtest-all.cc)
-  cxx_library(gtest_main_no_exception "${cxx_no_exception}"
-    src/gtest-all.cc src/gtest_main.cc)
-  cxx_library(gtest_main_no_rtti "${cxx_no_rtti}"
-    src/gtest-all.cc src/gtest_main.cc)
-
-  cxx_test_with_flags(gtest-death-test_ex_nocatch_test
-    "${cxx_exception} -DGTEST_ENABLE_CATCH_EXCEPTIONS_=0"
-    gtest test/gtest-death-test_ex_test.cc)
-  cxx_test_with_flags(gtest-death-test_ex_catch_test
-    "${cxx_exception} -DGTEST_ENABLE_CATCH_EXCEPTIONS_=1"
-    gtest test/gtest-death-test_ex_test.cc)
-
-  cxx_test_with_flags(gtest_no_rtti_unittest "${cxx_no_rtti}"
-    gtest_main_no_rtti test/gtest_unittest.cc)
-
-  cxx_shared_library(gtest_dll "${cxx_default}"
-    src/gtest-all.cc src/gtest_main.cc)
-
-  cxx_executable_with_flags(gtest_dll_test_ "${cxx_default}"
-    gtest_dll test/gtest_all_test.cc)
-  set_target_properties(gtest_dll_test_
-                        PROPERTIES
-                        COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
-
-  if (NOT MSVC OR NOT MSVC_VERSION EQUAL 1600)
-    # The C++ Standard specifies tuple_element<int, class>.
-    # Yet MSVC 10's <utility> declares tuple_element<size_t, class>.
-    # That declaration conflicts with our own standard-conforming
-    # tuple implementation.  Therefore using our own tuple with
-    # MSVC 10 doesn't compile.
-    cxx_library(gtest_main_use_own_tuple "${cxx_use_own_tuple}"
-      src/gtest-all.cc src/gtest_main.cc)
-
-    cxx_test_with_flags(gtest-tuple_test "${cxx_use_own_tuple}"
-      gtest_main_use_own_tuple test/gtest-tuple_test.cc)
-
-    cxx_test_with_flags(gtest_use_own_tuple_test "${cxx_use_own_tuple}"
-      gtest_main_use_own_tuple
-      test/gtest-param-test_test.cc test/gtest-param-test2_test.cc)
-  endif()
-
-  ############################################################
-  # Python tests.
-
-  cxx_executable(gtest_break_on_failure_unittest_ test gtest)
-  py_test(gtest_break_on_failure_unittest)
-
-  cxx_executable_with_flags(
-    gtest_catch_exceptions_no_ex_test_
-    "${cxx_no_exception}"
-    gtest_main_no_exception
-    test/gtest_catch_exceptions_test_.cc)
-  cxx_executable_with_flags(
-    gtest_catch_exceptions_ex_test_
-    "${cxx_exception}"
-    gtest_main
-    test/gtest_catch_exceptions_test_.cc)
-  py_test(gtest_catch_exceptions_test)
-
-  cxx_executable(gtest_color_test_ test gtest)
-  py_test(gtest_color_test)
-
-  cxx_executable(gtest_env_var_test_ test gtest)
-  py_test(gtest_env_var_test)
-
-  cxx_executable(gtest_filter_unittest_ test gtest)
-  py_test(gtest_filter_unittest)
-
-  cxx_executable(gtest_help_test_ test gtest_main)
-  py_test(gtest_help_test)
-
-  cxx_executable(gtest_list_tests_unittest_ test gtest)
-  py_test(gtest_list_tests_unittest)
-
-  cxx_executable(gtest_output_test_ test gtest)
-  py_test(gtest_output_test)
-
-  cxx_executable(gtest_shuffle_test_ test gtest)
-  py_test(gtest_shuffle_test)
-
-  cxx_executable(gtest_throw_on_failure_test_ test gtest_no_exception)
-  set_target_properties(gtest_throw_on_failure_test_
-    PROPERTIES
-    COMPILE_FLAGS "${cxx_no_exception}")
-  py_test(gtest_throw_on_failure_test)
-
-  cxx_executable(gtest_uninitialized_test_ test gtest)
-  py_test(gtest_uninitialized_test)
-
-  cxx_executable(gtest_xml_outfile1_test_ test gtest_main)
-  cxx_executable(gtest_xml_outfile2_test_ test gtest_main)
-  py_test(gtest_xml_outfiles_test)
-
-  cxx_executable(gtest_xml_output_unittest_ test gtest)
-  py_test(gtest_xml_output_unittest)
-endif()
diff --git a/bamtools/src/third_party/gtest-1.6.0/CONTRIBUTORS b/bamtools/src/third_party/gtest-1.6.0/CONTRIBUTORS
deleted file mode 100644
index feae2fc..0000000
--- a/bamtools/src/third_party/gtest-1.6.0/CONTRIBUTORS
+++ /dev/null
@@ -1,37 +0,0 @@
-# This file contains a list of people who've made non-trivial
-# contribution to the Google C++ Testing Framework project.  People
-# who commit code to the project are encouraged to add their names
-# here.  Please keep the list sorted by first names.
-
-Ajay Joshi <jaj at google.com>
-Balázs Dán <balazs.dan at gmail.com>
-Bharat Mediratta <bharat at menalto.com>
-Chandler Carruth <chandlerc at google.com>
-Chris Prince <cprince at google.com>
-Chris Taylor <taylorc at google.com>
-Dan Egnor <egnor at google.com>
-Eric Roman <eroman at chromium.org>
-Hady Zalek <hady.zalek at gmail.com>
-Jeffrey Yasskin <jyasskin at google.com>
-Jói Sigurðsson <joi at google.com>
-Keir Mierle <mierle at gmail.com>
-Keith Ray <keith.ray at gmail.com>
-Kenton Varda <kenton at google.com>
-Manuel Klimek <klimek at google.com>
-Markus Heule <markus.heule at gmail.com>
-Mika Raento <mikie at iki.fi>
-Miklós Fazekas <mfazekas at szemafor.com>
-Pasi Valminen <pasi.valminen at gmail.com>
-Patrick Hanna <phanna at google.com>
-Patrick Riley <pfr at google.com>
-Peter Kaminski <piotrk at google.com>
-Preston Jackson <preston.a.jackson at gmail.com>
-Rainer Klaffenboeck <rainer.klaffenboeck at dynatrace.com>
-Russ Cox <rsc at google.com>
-Russ Rufer <russ at pentad.com>
-Sean Mcafee <eefacm at gmail.com>
-Sigurður Ásgeirsson <siggi at google.com>
-Tracy Bialik <tracy at pentad.com>
-Vadim Berman <vadimb at google.com>
-Vlad Losev <vladl at google.com>
-Zhanyong Wan <wan at google.com>
diff --git a/bamtools/src/third_party/gtest-1.6.0/COPYING b/bamtools/src/third_party/gtest-1.6.0/COPYING
deleted file mode 100644
index 1941a11..0000000
--- a/bamtools/src/third_party/gtest-1.6.0/COPYING
+++ /dev/null
@@ -1,28 +0,0 @@
-Copyright 2008, Google Inc.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    * Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
-    * Redistributions in binary form must reproduce the above
-copyright notice, this list of conditions and the following disclaimer
-in the documentation and/or other materials provided with the
-distribution.
-    * Neither the name of Google Inc. nor the names of its
-contributors may be used to endorse or promote products derived from
-this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/bamtools/src/third_party/gtest-1.6.0/README b/bamtools/src/third_party/gtest-1.6.0/README
deleted file mode 100644
index 51a9376..0000000
--- a/bamtools/src/third_party/gtest-1.6.0/README
+++ /dev/null
@@ -1,424 +0,0 @@
-Google C++ Testing Framework
-============================
-
-http://code.google.com/p/googletest/
-
-Overview
---------
-
-Google's framework for writing C++ tests on a variety of platforms
-(Linux, Mac OS X, Windows, Windows CE, Symbian, etc).  Based on the
-xUnit architecture.  Supports automatic test discovery, a rich set of
-assertions, user-defined assertions, death tests, fatal and non-fatal
-failures, various options for running the tests, and XML test report
-generation.
-
-Please see the project page above for more information as well as the
-mailing list for questions, discussions, and development.  There is
-also an IRC channel on OFTC (irc.oftc.net) #gtest available.  Please
-join us!
-
-Requirements for End Users
---------------------------
-
-Google Test is designed to have fairly minimal requirements to build
-and use with your projects, but there are some.  Currently, we support
-Linux, Windows, Mac OS X, and Cygwin.  We will also make our best
-effort to support other platforms (e.g. Solaris, AIX, and z/OS).
-However, since core members of the Google Test project have no access
-to these platforms, Google Test may have outstanding issues there.  If
-you notice any problems on your platform, please notify
-googletestframework at googlegroups.com.  Patches for fixing them are
-even more welcome!
-
-### Linux Requirements ###
-
-These are the base requirements to build and use Google Test from a source
-package (as described below):
-  * GNU-compatible Make or gmake
-  * POSIX-standard shell
-  * POSIX(-2) Regular Expressions (regex.h)
-  * A C++98-standard-compliant compiler
-
-### Windows Requirements ###
-
-  * Microsoft Visual C++ 7.1 or newer
-
-### Cygwin Requirements ###
-
-  * Cygwin 1.5.25-14 or newer
-
-### Mac OS X Requirements ###
-
-  * Mac OS X 10.4 Tiger or newer
-  * Developer Tools Installed
-
-Also, you'll need CMake 2.6.4 or higher if you want to build the
-samples using the provided CMake script, regardless of the platform.
-
-Requirements for Contributors
------------------------------
-
-We welcome patches.  If you plan to contribute a patch, you need to
-build Google Test and its own tests from an SVN checkout (described
-below), which has further requirements:
-
-  * Python version 2.3 or newer (for running some of the tests and
-    re-generating certain source files from templates)
-  * CMake 2.6.4 or newer
-
-Getting the Source
-------------------
-
-There are two primary ways of getting Google Test's source code: you
-can download a stable source release in your preferred archive format,
-or directly check out the source from our Subversion (SVN) repositary.
-The SVN checkout requires a few extra steps and some extra software
-packages on your system, but lets you track the latest development and
-make patches much more easily, so we highly encourage it.
-
-### Source Package ###
-
-Google Test is released in versioned source packages which can be
-downloaded from the download page [1].  Several different archive
-formats are provided, but the only difference is the tools used to
-manipulate them, and the size of the resulting file.  Download
-whichever you are most comfortable with.
-
-  [1] http://code.google.com/p/googletest/downloads/list
-
-Once the package is downloaded, expand it using whichever tools you
-prefer for that type.  This will result in a new directory with the
-name "gtest-X.Y.Z" which contains all of the source code.  Here are
-some examples on Linux:
-
-  tar -xvzf gtest-X.Y.Z.tar.gz
-  tar -xvjf gtest-X.Y.Z.tar.bz2
-  unzip gtest-X.Y.Z.zip
-
-### SVN Checkout ###
-
-To check out the main branch (also known as the "trunk") of Google
-Test, run the following Subversion command:
-
-  svn checkout http://googletest.googlecode.com/svn/trunk/ gtest-svn
-
-Setting up the Build
---------------------
-
-To build Google Test and your tests that use it, you need to tell your
-build system where to find its headers and source files.  The exact
-way to do it depends on which build system you use, and is usually
-straightforward.
-
-### Generic Build Instructions ###
-
-Suppose you put Google Test in directory ${GTEST_DIR}.  To build it,
-create a library build target (or a project as called by Visual Studio
-and Xcode) to compile
-
-  ${GTEST_DIR}/src/gtest-all.cc
-
-with
-
-  ${GTEST_DIR}/include and ${GTEST_DIR}
-
-in the header search path.  Assuming a Linux-like system and gcc,
-something like the following will do:
-
-  g++ -I${GTEST_DIR}/include -I${GTEST_DIR} -c ${GTEST_DIR}/src/gtest-all.cc
-  ar -rv libgtest.a gtest-all.o
-
-Next, you should compile your test source file with
-${GTEST_DIR}/include in the header search path, and link it with gtest
-and any other necessary libraries:
-
-  g++ -I${GTEST_DIR}/include path/to/your_test.cc libgtest.a -o your_test
-
-As an example, the make/ directory contains a Makefile that you can
-use to build Google Test on systems where GNU make is available
-(e.g. Linux, Mac OS X, and Cygwin).  It doesn't try to build Google
-Test's own tests.  Instead, it just builds the Google Test library and
-a sample test.  You can use it as a starting point for your own build
-script.
-
-If the default settings are correct for your environment, the
-following commands should succeed:
-
-  cd ${GTEST_DIR}/make
-  make
-  ./sample1_unittest
-
-If you see errors, try to tweak the contents of make/Makefile to make
-them go away.  There are instructions in make/Makefile on how to do
-it.
-
-### Using CMake ###
-
-Google Test comes with a CMake build script (CMakeLists.txt) that can
-be used on a wide range of platforms ("C" stands for cross-platofrm.).
-If you don't have CMake installed already, you can download it for
-free from http://www.cmake.org/.
-
-CMake works by generating native makefiles or build projects that can
-be used in the compiler environment of your choice.  The typical
-workflow starts with:
-
-  mkdir mybuild       # Create a directory to hold the build output.
-  cd mybuild
-  cmake ${GTEST_DIR}  # Generate native build scripts.
-
-If you want to build Google Test's samples, you should replace the
-last command with
-
-  cmake -Dgtest_build_samples=ON ${GTEST_DIR}
-
-If you are on a *nix system, you should now see a Makefile in the
-current directory.  Just type 'make' to build gtest.
-
-If you use Windows and have Vistual Studio installed, a gtest.sln file
-and several .vcproj files will be created.  You can then build them
-using Visual Studio.
-
-On Mac OS X with Xcode installed, a .xcodeproj file will be generated.
-
-### Legacy Build Scripts ###
-
-Before settling on CMake, we have been providing hand-maintained build
-projects/scripts for Visual Studio, Xcode, and Autotools.  While we
-continue to provide them for convenience, they are not actively
-maintained any more.  We highly recommend that you follow the
-instructions in the previous two sections to integrate Google Test
-with your existing build system.
-
-If you still need to use the legacy build scripts, here's how:
-
-The msvc\ folder contains two solutions with Visual C++ projects.
-Open the gtest.sln or gtest-md.sln file using Visual Studio, and you
-are ready to build Google Test the same way you build any Visual
-Studio project.  Files that have names ending with -md use DLL
-versions of Microsoft runtime libraries (the /MD or the /MDd compiler
-option).  Files without that suffix use static versions of the runtime
-libraries (the /MT or the /MTd option).  Please note that one must use
-the same option to compile both gtest and the test code.  If you use
-Visual Studio 2005 or above, we recommend the -md version as /MD is
-the default for new projects in these versions of Visual Studio.
-
-On Mac OS X, open the gtest.xcodeproj in the xcode/ folder using
-Xcode.  Build the "gtest" target.  The universal binary framework will
-end up in your selected build directory (selected in the Xcode
-"Preferences..." -> "Building" pane and defaults to xcode/build).
-Alternatively, at the command line, enter:
-
-  xcodebuild
-
-This will build the "Release" configuration of gtest.framework in your
-default build location.  See the "xcodebuild" man page for more
-information about building different configurations and building in
-different locations.
-
-Tweaking Google Test
---------------------
-
-Google Test can be used in diverse environments.  The default
-configuration may not work (or may not work well) out of the box in
-some environments.  However, you can easily tweak Google Test by
-defining control macros on the compiler command line.  Generally,
-these macros are named like GTEST_XYZ and you define them to either 1
-or 0 to enable or disable a certain feature.
-
-We list the most frequently used macros below.  For a complete list,
-see file include/gtest/internal/gtest-port.h.
-
-### Choosing a TR1 Tuple Library ###
-
-Some Google Test features require the C++ Technical Report 1 (TR1)
-tuple library, which is not yet available with all compilers.  The
-good news is that Google Test implements a subset of TR1 tuple that's
-enough for its own need, and will automatically use this when the
-compiler doesn't provide TR1 tuple.
-
-Usually you don't need to care about which tuple library Google Test
-uses.  However, if your project already uses TR1 tuple, you need to
-tell Google Test to use the same TR1 tuple library the rest of your
-project uses, or the two tuple implementations will clash.  To do
-that, add
-
-  -DGTEST_USE_OWN_TR1_TUPLE=0
-
-to the compiler flags while compiling Google Test and your tests.  If
-you want to force Google Test to use its own tuple library, just add
-
-  -DGTEST_USE_OWN_TR1_TUPLE=1
-
-to the compiler flags instead.
-
-If you don't want Google Test to use tuple at all, add
-
-  -DGTEST_HAS_TR1_TUPLE=0
-
-and all features using tuple will be disabled.
-
-### Multi-threaded Tests ###
-
-Google Test is thread-safe where the pthread library is available.
-After #include "gtest/gtest.h", you can check the GTEST_IS_THREADSAFE
-macro to see whether this is the case (yes if the macro is #defined to
-1, no if it's undefined.).
-
-If Google Test doesn't correctly detect whether pthread is available
-in your environment, you can force it with
-
-  -DGTEST_HAS_PTHREAD=1
-
-or
-
-  -DGTEST_HAS_PTHREAD=0
-
-When Google Test uses pthread, you may need to add flags to your
-compiler and/or linker to select the pthread library, or you'll get
-link errors.  If you use the CMake script or the deprecated Autotools
-script, this is taken care of for you.  If you use your own build
-script, you'll need to read your compiler and linker's manual to
-figure out what flags to add.
-
-### As a Shared Library (DLL) ###
-
-Google Test is compact, so most users can build and link it as a
-static library for the simplicity.  You can choose to use Google Test
-as a shared library (known as a DLL on Windows) if you prefer.
-
-To compile *gtest* as a shared library, add
-
-  -DGTEST_CREATE_SHARED_LIBRARY=1
-
-to the compiler flags.  You'll also need to tell the linker to produce
-a shared library instead - consult your linker's manual for how to do
-it.
-
-To compile your *tests* that use the gtest shared library, add
-
-  -DGTEST_LINKED_AS_SHARED_LIBRARY=1
-
-to the compiler flags.
-
-Note: while the above steps aren't technically necessary today when
-using some compilers (e.g. GCC), they may become necessary in the
-future, if we decide to improve the speed of loading the library (see
-http://gcc.gnu.org/wiki/Visibility for details).  Therefore you are
-recommended to always add the above flags when using Google Test as a
-shared library.  Otherwise a future release of Google Test may break
-your build script.
-
-### Avoiding Macro Name Clashes ###
-
-In C++, macros don't obey namespaces.  Therefore two libraries that
-both define a macro of the same name will clash if you #include both
-definitions.  In case a Google Test macro clashes with another
-library, you can force Google Test to rename its macro to avoid the
-conflict.
-
-Specifically, if both Google Test and some other code define macro
-FOO, you can add
-
-  -DGTEST_DONT_DEFINE_FOO=1
-
-to the compiler flags to tell Google Test to change the macro's name
-from FOO to GTEST_FOO.  Currently FOO can be FAIL, SUCCEED, or TEST.
-For example, with -DGTEST_DONT_DEFINE_TEST=1, you'll need to write
-
-  GTEST_TEST(SomeTest, DoesThis) { ... }
-
-instead of
-
-  TEST(SomeTest, DoesThis) { ... }
-
-in order to define a test.
-
-Upgrating from an Earlier Version
----------------------------------
-
-We strive to keep Google Test releases backward compatible.
-Sometimes, though, we have to make some breaking changes for the
-users' long-term benefits.  This section describes what you'll need to
-do if you are upgrading from an earlier version of Google Test.
-
-### Upgrading from 1.3.0 or Earlier ###
-
-You may need to explicitly enable or disable Google Test's own TR1
-tuple library.  See the instructions in section "Choosing a TR1 Tuple
-Library".
-
-### Upgrading from 1.4.0 or Earlier ###
-
-The Autotools build script (configure + make) is no longer officially
-supportted.  You are encouraged to migrate to your own build system or
-use CMake.  If you still need to use Autotools, you can find
-instructions in the README file from Google Test 1.4.0.
-
-On platforms where the pthread library is available, Google Test uses
-it in order to be thread-safe.  See the "Multi-threaded Tests" section
-for what this means to your build script.
-
-If you use Microsoft Visual C++ 7.1 with exceptions disabled, Google
-Test will no longer compile.  This should affect very few people, as a
-large portion of STL (including <string>) doesn't compile in this mode
-anyway.  We decided to stop supporting it in order to greatly simplify
-Google Test's implementation.
-
-Developing Google Test
-----------------------
-
-This section discusses how to make your own changes to Google Test.
-
-### Testing Google Test Itself ###
-
-To make sure your changes work as intended and don't break existing
-functionality, you'll want to compile and run Google Test's own tests.
-For that you can use CMake:
-
-  mkdir mybuild
-  cd mybuild
-  cmake -Dgtest_build_tests=ON ${GTEST_DIR}
-
-Make sure you have Python installed, as some of Google Test's tests
-are written in Python.  If the cmake command complains about not being
-able to find Python ("Could NOT find PythonInterp (missing:
-PYTHON_EXECUTABLE)"), try telling it explicitly where your Python
-executable can be found:
-
-  cmake -DPYTHON_EXECUTABLE=path/to/python -Dgtest_build_tests=ON ${GTEST_DIR}
-
-Next, you can build Google Test and all of its own tests.  On *nix,
-this is usually done by 'make'.  To run the tests, do
-
-  make test
-
-All tests should pass.
-
-### Regenerating Source Files ###
-
-Some of Google Test's source files are generated from templates (not
-in the C++ sense) using a script.  A template file is named FOO.pump,
-where FOO is the name of the file it will generate.  For example, the
-file include/gtest/internal/gtest-type-util.h.pump is used to generate
-gtest-type-util.h in the same directory.
-
-Normally you don't need to worry about regenerating the source files,
-unless you need to modify them.  In that case, you should modify the
-corresponding .pump files instead and run the pump.py Python script to
-regenerate them.  You can find pump.py in the scripts/ directory.
-Read the Pump manual [2] for how to use it.
-
-  [2] http://code.google.com/p/googletest/wiki/PumpManual
-
-### Contributing a Patch ###
-
-We welcome patches.  Please read the Google Test developer's guide [3]
-for how you can contribute.  In particular, make sure you have signed
-the Contributor License Agreement, or we won't be able to accept the
-patch.
-
-  [3] http://code.google.com/p/googletest/wiki/GoogleTestDevGuide
-
-Happy testing!
diff --git a/bamtools/src/third_party/gtest-1.6.0/cmake/internal_utils.cmake b/bamtools/src/third_party/gtest-1.6.0/cmake/internal_utils.cmake
deleted file mode 100644
index 7efc2ac..0000000
--- a/bamtools/src/third_party/gtest-1.6.0/cmake/internal_utils.cmake
+++ /dev/null
@@ -1,216 +0,0 @@
-# Defines functions and macros useful for building Google Test and
-# Google Mock.
-#
-# Note:
-#
-# - This file will be run twice when building Google Mock (once via
-#   Google Test's CMakeLists.txt, and once via Google Mock's).
-#   Therefore it shouldn't have any side effects other than defining
-#   the functions and macros.
-#
-# - The functions/macros defined in this file may depend on Google
-#   Test and Google Mock's option() definitions, and thus must be
-#   called *after* the options have been defined.
-
-# Tweaks CMake's default compiler/linker settings to suit Google Test's needs.
-#
-# This must be a macro(), as inside a function string() can only
-# update variables in the function scope.
-macro(fix_default_compiler_settings_)
-  if (MSVC)
-    # For MSVC, CMake sets certain flags to defaults we want to override.
-    # This replacement code is taken from sample in the CMake Wiki at
-    # http://www.cmake.org/Wiki/CMake_FAQ#Dynamic_Replace.
-    foreach (flag_var
-             CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
-             CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
-      if (NOT BUILD_SHARED_LIBS AND NOT gtest_force_shared_crt)
-        # When Google Test is built as a shared library, it should also use
-        # shared runtime libraries.  Otherwise, it may end up with multiple
-        # copies of runtime library data in different modules, resulting in
-        # hard-to-find crashes. When it is built as a static library, it is
-        # preferable to use CRT as static libraries, as we don't have to rely
-        # on CRT DLLs being available. CMake always defaults to using shared
-        # CRT libraries, so we override that default here.
-        string(REPLACE "/MD" "-MT" ${flag_var} "${${flag_var}}")
-      endif()
-
-      # We prefer more strict warning checking for building Google Test.
-      # Replaces /W3 with /W4 in defaults.
-      string(REPLACE "/W3" "-W4" ${flag_var} "${${flag_var}}")
-    endforeach()
-  endif()
-endmacro()
-
-# Defines the compiler/linker flags used to build Google Test and
-# Google Mock.  You can tweak these definitions to suit your need.  A
-# variable's value is empty before it's explicitly assigned to.
-macro(config_compiler_and_linker)
-  if (NOT gtest_disable_pthreads)
-    # Defines CMAKE_USE_PTHREADS_INIT and CMAKE_THREAD_LIBS_INIT.
-    find_package(Threads)
-  endif()
-
-  fix_default_compiler_settings_()
-  if (MSVC)
-    # Newlines inside flags variables break CMake's NMake generator.
-    # TODO(vladl at google.com): Add -RTCs and -RTCu to debug builds.
-    set(cxx_base_flags "-GS -W4 -WX -wd4127 -wd4251 -wd4275 -nologo -J -Zi")
-    set(cxx_base_flags "${cxx_base_flags} -D_UNICODE -DUNICODE -DWIN32 -D_WIN32")
-    set(cxx_base_flags "${cxx_base_flags} -DSTRICT -DWIN32_LEAN_AND_MEAN")
-    set(cxx_exception_flags "-EHsc -D_HAS_EXCEPTIONS=1")
-    set(cxx_no_exception_flags "-D_HAS_EXCEPTIONS=0")
-    set(cxx_no_rtti_flags "-GR-")
-  elseif (CMAKE_COMPILER_IS_GNUCXX)
-    set(cxx_base_flags "-Wall -Wshadow")
-    set(cxx_exception_flags "-fexceptions")
-    set(cxx_no_exception_flags "-fno-exceptions")
-    # Until version 4.3.2, GCC doesn't define a macro to indicate
-    # whether RTTI is enabled.  Therefore we define GTEST_HAS_RTTI
-    # explicitly.
-    set(cxx_no_rtti_flags "-fno-rtti -DGTEST_HAS_RTTI=0")
-    set(cxx_strict_flags "-Wextra")
-  elseif (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
-    set(cxx_exception_flags "-features=except")
-    # Sun Pro doesn't provide macros to indicate whether exceptions and
-    # RTTI are enabled, so we define GTEST_HAS_* explicitly.
-    set(cxx_no_exception_flags "-features=no%except -DGTEST_HAS_EXCEPTIONS=0")
-    set(cxx_no_rtti_flags "-features=no%rtti -DGTEST_HAS_RTTI=0")
-  elseif (CMAKE_CXX_COMPILER_ID STREQUAL "VisualAge" OR
-      CMAKE_CXX_COMPILER_ID STREQUAL "XL")
-    # CMake 2.8 changes Visual Age's compiler ID to "XL".
-    set(cxx_exception_flags "-qeh")
-    set(cxx_no_exception_flags "-qnoeh")
-    # Until version 9.0, Visual Age doesn't define a macro to indicate
-    # whether RTTI is enabled.  Therefore we define GTEST_HAS_RTTI
-    # explicitly.
-    set(cxx_no_rtti_flags "-qnortti -DGTEST_HAS_RTTI=0")
-  elseif (CMAKE_CXX_COMPILER_ID STREQUAL "HP")
-    set(cxx_base_flags "-AA -mt")
-    set(cxx_exception_flags "-DGTEST_HAS_EXCEPTIONS=1")
-    set(cxx_no_exception_flags "+noeh -DGTEST_HAS_EXCEPTIONS=0")
-    # RTTI can not be disabled in HP aCC compiler.
-    set(cxx_no_rtti_flags "")
-  endif()
-
-  if (CMAKE_USE_PTHREADS_INIT)  # The pthreads library is available and allowed.
-    set(cxx_base_flags "${cxx_base_flags} -DGTEST_HAS_PTHREAD=1")
-  else()
-    set(cxx_base_flags "${cxx_base_flags} -DGTEST_HAS_PTHREAD=0")
-  endif()
-
-  # For building gtest's own tests and samples.
-  set(cxx_exception "${CMAKE_CXX_FLAGS} ${cxx_base_flags} ${cxx_exception_flags}")
-  set(cxx_no_exception
-    "${CMAKE_CXX_FLAGS} ${cxx_base_flags} ${cxx_no_exception_flags}")
-  set(cxx_default "${cxx_exception}")
-  set(cxx_no_rtti "${cxx_default} ${cxx_no_rtti_flags}")
-  set(cxx_use_own_tuple "${cxx_default} -DGTEST_USE_OWN_TR1_TUPLE=1")
-
-  # For building the gtest libraries.
-  set(cxx_strict "${cxx_default} ${cxx_strict_flags}")
-endmacro()
-
-# Defines the gtest & gtest_main libraries.  User tests should link
-# with one of them.
-function(cxx_library_with_type name type cxx_flags)
-  # type can be either STATIC or SHARED to denote a static or shared library.
-  # ARGN refers to additional arguments after 'cxx_flags'.
-  add_library(${name} ${type} ${ARGN})
-  set_target_properties(${name}
-    PROPERTIES
-    COMPILE_FLAGS "${cxx_flags}")
-  if (BUILD_SHARED_LIBS OR type STREQUAL "SHARED")
-    set_target_properties(${name}
-      PROPERTIES
-      COMPILE_DEFINITIONS "GTEST_CREATE_SHARED_LIBRARY=1")
-  endif()
-  if (CMAKE_USE_PTHREADS_INIT)
-    target_link_libraries(${name} ${CMAKE_THREAD_LIBS_INIT})
-  endif()
-endfunction()
-
-########################################################################
-#
-# Helper functions for creating build targets.
-
-function(cxx_shared_library name cxx_flags)
-  cxx_library_with_type(${name} SHARED "${cxx_flags}" ${ARGN})
-endfunction()
-
-function(cxx_library name cxx_flags)
-  cxx_library_with_type(${name} "" "${cxx_flags}" ${ARGN})
-endfunction()
-
-# cxx_executable_with_flags(name cxx_flags libs srcs...)
-#
-# creates a named C++ executable that depends on the given libraries and
-# is built from the given source files with the given compiler flags.
-function(cxx_executable_with_flags name cxx_flags libs)
-  add_executable(${name} ${ARGN})
-  if (cxx_flags)
-    set_target_properties(${name}
-      PROPERTIES
-      COMPILE_FLAGS "${cxx_flags}")
-  endif()
-  if (BUILD_SHARED_LIBS)
-    set_target_properties(${name}
-      PROPERTIES
-      COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
-  endif()
-  # To support mixing linking in static and dynamic libraries, link each
-  # library in with an extra call to target_link_libraries.
-  foreach (lib "${libs}")
-    target_link_libraries(${name} ${lib})
-  endforeach()
-endfunction()
-
-# cxx_executable(name dir lib srcs...)
-#
-# creates a named target that depends on the given libs and is built
-# from the given source files.  dir/name.cc is implicitly included in
-# the source file list.
-function(cxx_executable name dir libs)
-  cxx_executable_with_flags(
-    ${name} "${cxx_default}" "${libs}" "${dir}/${name}.cc" ${ARGN})
-endfunction()
-
-# Sets PYTHONINTERP_FOUND and PYTHON_EXECUTABLE.
-find_package(PythonInterp)
-
-# cxx_test_with_flags(name cxx_flags libs srcs...)
-#
-# creates a named C++ test that depends on the given libs and is built
-# from the given source files with the given compiler flags.
-function(cxx_test_with_flags name cxx_flags libs)
-  cxx_executable_with_flags(${name} "${cxx_flags}" "${libs}" ${ARGN})
-  add_test(${name} ${name})
-endfunction()
-
-# cxx_test(name libs srcs...)
-#
-# creates a named test target that depends on the given libs and is
-# built from the given source files.  Unlike cxx_test_with_flags,
-# test/name.cc is already implicitly included in the source file list.
-function(cxx_test name libs)
-  cxx_test_with_flags("${name}" "${cxx_default}" "${libs}"
-    "test/${name}.cc" ${ARGN})
-endfunction()
-
-# py_test(name)
-#
-# creates a Python test with the given name whose main module is in
-# test/name.py.  It does nothing if Python is not installed.
-function(py_test name)
-  # We are not supporting Python tests on Linux yet as they consider
-  # all Linux environments to be google3 and try to use google3 features.
-  if (PYTHONINTERP_FOUND)
-    # ${CMAKE_BINARY_DIR} is known at configuration time, so we can
-    # directly bind it from cmake. ${CTEST_CONFIGURATION_TYPE} is known
-    # only at ctest runtime (by calling ctest -c <Configuration>), so
-    # we have to escape $ to delay variable substitution here.
-    add_test(${name}
-      ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
-          --build_dir=${CMAKE_CURRENT_BINARY_DIR}/\${CTEST_CONFIGURATION_TYPE})
-  endif()
-endfunction()
diff --git a/bamtools/src/third_party/gtest-1.6.0/fused-src/gtest/gtest-all.cc b/bamtools/src/third_party/gtest-1.6.0/fused-src/gtest/gtest-all.cc
deleted file mode 100644
index 5ced66a..0000000
--- a/bamtools/src/third_party/gtest-1.6.0/fused-src/gtest/gtest-all.cc
+++ /dev/null
@@ -1,9118 +0,0 @@
-// Copyright 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: mheule at google.com (Markus Heule)
-//
-// Google C++ Testing Framework (Google Test)
-//
-// Sometimes it's desirable to build Google Test by compiling a single file.
-// This file serves this purpose.
-
-// This line ensures that gtest.h can be compiled on its own, even
-// when it's fused.
-#include "gtest/gtest.h"
-
-// The following lines pull in the real gtest *.cc files.
-// Copyright 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan at google.com (Zhanyong Wan)
-//
-// The Google C++ Testing Framework (Google Test)
-
-// Copyright 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan at google.com (Zhanyong Wan)
-//
-// Utilities for testing Google Test itself and code that uses Google Test
-// (e.g. frameworks built on top of Google Test).
-
-#ifndef GTEST_INCLUDE_GTEST_GTEST_SPI_H_
-#define GTEST_INCLUDE_GTEST_GTEST_SPI_H_
-
-
-namespace testing {
-
-// This helper class can be used to mock out Google Test failure reporting
-// so that we can test Google Test or code that builds on Google Test.
-//
-// An object of this class appends a TestPartResult object to the
-// TestPartResultArray object given in the constructor whenever a Google Test
-// failure is reported. It can either intercept only failures that are
-// generated in the same thread that created this object or it can intercept
-// all generated failures. The scope of this mock object can be controlled with
-// the second argument to the two arguments constructor.
-class GTEST_API_ ScopedFakeTestPartResultReporter
-    : public TestPartResultReporterInterface {
- public:
-  // The two possible mocking modes of this object.
-  enum InterceptMode {
-    INTERCEPT_ONLY_CURRENT_THREAD,  // Intercepts only thread local failures.
-    INTERCEPT_ALL_THREADS           // Intercepts all failures.
-  };
-
-  // The c'tor sets this object as the test part result reporter used
-  // by Google Test.  The 'result' parameter specifies where to report the
-  // results. This reporter will only catch failures generated in the current
-  // thread. DEPRECATED
-  explicit ScopedFakeTestPartResultReporter(TestPartResultArray* result);
-
-  // Same as above, but you can choose the interception scope of this object.
-  ScopedFakeTestPartResultReporter(InterceptMode intercept_mode,
-                                   TestPartResultArray* result);
-
-  // The d'tor restores the previous test part result reporter.
-  virtual ~ScopedFakeTestPartResultReporter();
-
-  // Appends the TestPartResult object to the TestPartResultArray
-  // received in the constructor.
-  //
-  // This method is from the TestPartResultReporterInterface
-  // interface.
-  virtual void ReportTestPartResult(const TestPartResult& result);
- private:
-  void Init();
-
-  const InterceptMode intercept_mode_;
-  TestPartResultReporterInterface* old_reporter_;
-  TestPartResultArray* const result_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedFakeTestPartResultReporter);
-};
-
-namespace internal {
-
-// A helper class for implementing EXPECT_FATAL_FAILURE() and
-// EXPECT_NONFATAL_FAILURE().  Its destructor verifies that the given
-// TestPartResultArray contains exactly one failure that has the given
-// type and contains the given substring.  If that's not the case, a
-// non-fatal failure will be generated.
-class GTEST_API_ SingleFailureChecker {
- public:
-  // The constructor remembers the arguments.
-  SingleFailureChecker(const TestPartResultArray* results,
-                       TestPartResult::Type type,
-                       const string& substr);
-  ~SingleFailureChecker();
- private:
-  const TestPartResultArray* const results_;
-  const TestPartResult::Type type_;
-  const string substr_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(SingleFailureChecker);
-};
-
-}  // namespace internal
-
-}  // namespace testing
-
-// A set of macros for testing Google Test assertions or code that's expected
-// to generate Google Test fatal failures.  It verifies that the given
-// statement will cause exactly one fatal Google Test failure with 'substr'
-// being part of the failure message.
-//
-// There are two different versions of this macro. EXPECT_FATAL_FAILURE only
-// affects and considers failures generated in the current thread and
-// EXPECT_FATAL_FAILURE_ON_ALL_THREADS does the same but for all threads.
-//
-// The verification of the assertion is done correctly even when the statement
-// throws an exception or aborts the current function.
-//
-// Known restrictions:
-//   - 'statement' cannot reference local non-static variables or
-//     non-static members of the current object.
-//   - 'statement' cannot return a value.
-//   - You cannot stream a failure message to this macro.
-//
-// Note that even though the implementations of the following two
-// macros are much alike, we cannot refactor them to use a common
-// helper macro, due to some peculiarity in how the preprocessor
-// works.  The AcceptsMacroThatExpandsToUnprotectedComma test in
-// gtest_unittest.cc will fail to compile if we do that.
-#define EXPECT_FATAL_FAILURE(statement, substr) \
-  do { \
-    class GTestExpectFatalFailureHelper {\
-     public:\
-      static void Execute() { statement; }\
-    };\
-    ::testing::TestPartResultArray gtest_failures;\
-    ::testing::internal::SingleFailureChecker gtest_checker(\
-        &gtest_failures, ::testing::TestPartResult::kFatalFailure, (substr));\
-    {\
-      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
-          ::testing::ScopedFakeTestPartResultReporter:: \
-          INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\
-      GTestExpectFatalFailureHelper::Execute();\
-    }\
-  } while (::testing::internal::AlwaysFalse())
-
-#define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr) \
-  do { \
-    class GTestExpectFatalFailureHelper {\
-     public:\
-      static void Execute() { statement; }\
-    };\
-    ::testing::TestPartResultArray gtest_failures;\
-    ::testing::internal::SingleFailureChecker gtest_checker(\
-        &gtest_failures, ::testing::TestPartResult::kFatalFailure, (substr));\
-    {\
-      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
-          ::testing::ScopedFakeTestPartResultReporter:: \
-          INTERCEPT_ALL_THREADS, &gtest_failures);\
-      GTestExpectFatalFailureHelper::Execute();\
-    }\
-  } while (::testing::internal::AlwaysFalse())
-
-// A macro for testing Google Test assertions or code that's expected to
-// generate Google Test non-fatal failures.  It asserts that the given
-// statement will cause exactly one non-fatal Google Test failure with 'substr'
-// being part of the failure message.
-//
-// There are two different versions of this macro. EXPECT_NONFATAL_FAILURE only
-// affects and considers failures generated in the current thread and
-// EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS does the same but for all threads.
-//
-// 'statement' is allowed to reference local variables and members of
-// the current object.
-//
-// The verification of the assertion is done correctly even when the statement
-// throws an exception or aborts the current function.
-//
-// Known restrictions:
-//   - You cannot stream a failure message to this macro.
-//
-// Note that even though the implementations of the following two
-// macros are much alike, we cannot refactor them to use a common
-// helper macro, due to some peculiarity in how the preprocessor
-// works.  If we do that, the code won't compile when the user gives
-// EXPECT_NONFATAL_FAILURE() a statement that contains a macro that
-// expands to code containing an unprotected comma.  The
-// AcceptsMacroThatExpandsToUnprotectedComma test in gtest_unittest.cc
-// catches that.
-//
-// For the same reason, we have to write
-//   if (::testing::internal::AlwaysTrue()) { statement; }
-// instead of
-//   GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
-// to avoid an MSVC warning on unreachable code.
-#define EXPECT_NONFATAL_FAILURE(statement, substr) \
-  do {\
-    ::testing::TestPartResultArray gtest_failures;\
-    ::testing::internal::SingleFailureChecker gtest_checker(\
-        &gtest_failures, ::testing::TestPartResult::kNonFatalFailure, \
-        (substr));\
-    {\
-      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
-          ::testing::ScopedFakeTestPartResultReporter:: \
-          INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\
-      if (::testing::internal::AlwaysTrue()) { statement; }\
-    }\
-  } while (::testing::internal::AlwaysFalse())
-
-#define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr) \
-  do {\
-    ::testing::TestPartResultArray gtest_failures;\
-    ::testing::internal::SingleFailureChecker gtest_checker(\
-        &gtest_failures, ::testing::TestPartResult::kNonFatalFailure, \
-        (substr));\
-    {\
-      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
-          ::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS,\
-          &gtest_failures);\
-      if (::testing::internal::AlwaysTrue()) { statement; }\
-    }\
-  } while (::testing::internal::AlwaysFalse())
-
-#endif  // GTEST_INCLUDE_GTEST_GTEST_SPI_H_
-
-#include <ctype.h>
-#include <math.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <wchar.h>
-#include <wctype.h>
-
-#include <algorithm>
-#include <ostream>  // NOLINT
-#include <sstream>
-#include <vector>
-
-#if GTEST_OS_LINUX
-
-// TODO(kenton at google.com): Use autoconf to detect availability of
-// gettimeofday().
-# define GTEST_HAS_GETTIMEOFDAY_ 1
-
-# include <fcntl.h>  // NOLINT
-# include <limits.h>  // NOLINT
-# include <sched.h>  // NOLINT
-// Declares vsnprintf().  This header is not available on Windows.
-# include <strings.h>  // NOLINT
-# include <sys/mman.h>  // NOLINT
-# include <sys/time.h>  // NOLINT
-# include <unistd.h>  // NOLINT
-# include <string>
-
-#elif GTEST_OS_SYMBIAN
-# define GTEST_HAS_GETTIMEOFDAY_ 1
-# include <sys/time.h>  // NOLINT
-
-#elif GTEST_OS_ZOS
-# define GTEST_HAS_GETTIMEOFDAY_ 1
-# include <sys/time.h>  // NOLINT
-
-// On z/OS we additionally need strings.h for strcasecmp.
-# include <strings.h>  // NOLINT
-
-#elif GTEST_OS_WINDOWS_MOBILE  // We are on Windows CE.
-
-# include <windows.h>  // NOLINT
-
-#elif GTEST_OS_WINDOWS  // We are on Windows proper.
-
-# include <io.h>  // NOLINT
-# include <sys/timeb.h>  // NOLINT
-# include <sys/types.h>  // NOLINT
-# include <sys/stat.h>  // NOLINT
-
-# if GTEST_OS_WINDOWS_MINGW
-// MinGW has gettimeofday() but not _ftime64().
-// TODO(kenton at google.com): Use autoconf to detect availability of
-//   gettimeofday().
-// TODO(kenton at google.com): There are other ways to get the time on
-//   Windows, like GetTickCount() or GetSystemTimeAsFileTime().  MinGW
-//   supports these.  consider using them instead.
-#  define GTEST_HAS_GETTIMEOFDAY_ 1
-#  include <sys/time.h>  // NOLINT
-# endif  // GTEST_OS_WINDOWS_MINGW
-
-// cpplint thinks that the header is already included, so we want to
-// silence it.
-# include <windows.h>  // NOLINT
-
-#else
-
-// Assume other platforms have gettimeofday().
-// TODO(kenton at google.com): Use autoconf to detect availability of
-//   gettimeofday().
-# define GTEST_HAS_GETTIMEOFDAY_ 1
-
-// cpplint thinks that the header is already included, so we want to
-// silence it.
-# include <sys/time.h>  // NOLINT
-# include <unistd.h>  // NOLINT
-
-#endif  // GTEST_OS_LINUX
-
-#if GTEST_HAS_EXCEPTIONS
-# include <stdexcept>
-#endif
-
-#if GTEST_CAN_STREAM_RESULTS_
-# include <arpa/inet.h>  // NOLINT
-# include <netdb.h>  // NOLINT
-#endif
-
-// Indicates that this translation unit is part of Google Test's
-// implementation.  It must come before gtest-internal-inl.h is
-// included, or there will be a compiler error.  This trick is to
-// prevent a user from accidentally including gtest-internal-inl.h in
-// his code.
-#define GTEST_IMPLEMENTATION_ 1
-// Copyright 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// Utility functions and classes used by the Google C++ testing framework.
-//
-// Author: wan at google.com (Zhanyong Wan)
-//
-// This file contains purely Google Test's internal implementation.  Please
-// DO NOT #INCLUDE IT IN A USER PROGRAM.
-
-#ifndef GTEST_SRC_GTEST_INTERNAL_INL_H_
-#define GTEST_SRC_GTEST_INTERNAL_INL_H_
-
-// GTEST_IMPLEMENTATION_ is defined to 1 iff the current translation unit is
-// part of Google Test's implementation; otherwise it's undefined.
-#if !GTEST_IMPLEMENTATION_
-// A user is trying to include this from his code - just say no.
-# error "gtest-internal-inl.h is part of Google Test's internal implementation."
-# error "It must not be included except by Google Test itself."
-#endif  // GTEST_IMPLEMENTATION_
-
-#ifndef _WIN32_WCE
-# include <errno.h>
-#endif  // !_WIN32_WCE
-#include <stddef.h>
-#include <stdlib.h>  // For strtoll/_strtoul64/malloc/free.
-#include <string.h>  // For memmove.
-
-#include <algorithm>
-#include <string>
-#include <vector>
-
-
-#if GTEST_OS_WINDOWS
-# include <windows.h>  // NOLINT
-#endif  // GTEST_OS_WINDOWS
-
-
-namespace testing {
-
-// Declares the flags.
-//
-// We don't want the users to modify this flag in the code, but want
-// Google Test's own unit tests to be able to access it. Therefore we
-// declare it here as opposed to in gtest.h.
-GTEST_DECLARE_bool_(death_test_use_fork);
-
-namespace internal {
-
-// The value of GetTestTypeId() as seen from within the Google Test
-// library.  This is solely for testing GetTestTypeId().
-GTEST_API_ extern const TypeId kTestTypeIdInGoogleTest;
-
-// Names of the flags (needed for parsing Google Test flags).
-const char kAlsoRunDisabledTestsFlag[] = "also_run_disabled_tests";
-const char kBreakOnFailureFlag[] = "break_on_failure";
-const char kCatchExceptionsFlag[] = "catch_exceptions";
-const char kColorFlag[] = "color";
-const char kFilterFlag[] = "filter";
-const char kListTestsFlag[] = "list_tests";
-const char kOutputFlag[] = "output";
-const char kPrintTimeFlag[] = "print_time";
-const char kRandomSeedFlag[] = "random_seed";
-const char kRepeatFlag[] = "repeat";
-const char kShuffleFlag[] = "shuffle";
-const char kStackTraceDepthFlag[] = "stack_trace_depth";
-const char kStreamResultToFlag[] = "stream_result_to";
-const char kThrowOnFailureFlag[] = "throw_on_failure";
-
-// A valid random seed must be in [1, kMaxRandomSeed].
-const int kMaxRandomSeed = 99999;
-
-// g_help_flag is true iff the --help flag or an equivalent form is
-// specified on the command line.
-GTEST_API_ extern bool g_help_flag;
-
-// Returns the current time in milliseconds.
-GTEST_API_ TimeInMillis GetTimeInMillis();
-
-// Returns true iff Google Test should use colors in the output.
-GTEST_API_ bool ShouldUseColor(bool stdout_is_tty);
-
-// Formats the given time in milliseconds as seconds.
-GTEST_API_ std::string FormatTimeInMillisAsSeconds(TimeInMillis ms);
-
-// Parses a string for an Int32 flag, in the form of "--flag=value".
-//
-// On success, stores the value of the flag in *value, and returns
-// true.  On failure, returns false without changing *value.
-GTEST_API_ bool ParseInt32Flag(
-    const char* str, const char* flag, Int32* value);
-
-// Returns a random seed in range [1, kMaxRandomSeed] based on the
-// given --gtest_random_seed flag value.
-inline int GetRandomSeedFromFlag(Int32 random_seed_flag) {
-  const unsigned int raw_seed = (random_seed_flag == 0) ?
-      static_cast<unsigned int>(GetTimeInMillis()) :
-      static_cast<unsigned int>(random_seed_flag);
-
-  // Normalizes the actual seed to range [1, kMaxRandomSeed] such that
-  // it's easy to type.
-  const int normalized_seed =
-      static_cast<int>((raw_seed - 1U) %
-                       static_cast<unsigned int>(kMaxRandomSeed)) + 1;
-  return normalized_seed;
-}
-
-// Returns the first valid random seed after 'seed'.  The behavior is
-// undefined if 'seed' is invalid.  The seed after kMaxRandomSeed is
-// considered to be 1.
-inline int GetNextRandomSeed(int seed) {
-  GTEST_CHECK_(1 <= seed && seed <= kMaxRandomSeed)
-      << "Invalid random seed " << seed << " - must be in [1, "
-      << kMaxRandomSeed << "].";
-  const int next_seed = seed + 1;
-  return (next_seed > kMaxRandomSeed) ? 1 : next_seed;
-}
-
-// This class saves the values of all Google Test flags in its c'tor, and
-// restores them in its d'tor.
-class GTestFlagSaver {
- public:
-  // The c'tor.
-  GTestFlagSaver() {
-    also_run_disabled_tests_ = GTEST_FLAG(also_run_disabled_tests);
-    break_on_failure_ = GTEST_FLAG(break_on_failure);
-    catch_exceptions_ = GTEST_FLAG(catch_exceptions);
-    color_ = GTEST_FLAG(color);
-    death_test_style_ = GTEST_FLAG(death_test_style);
-    death_test_use_fork_ = GTEST_FLAG(death_test_use_fork);
-    filter_ = GTEST_FLAG(filter);
-    internal_run_death_test_ = GTEST_FLAG(internal_run_death_test);
-    list_tests_ = GTEST_FLAG(list_tests);
-    output_ = GTEST_FLAG(output);
-    print_time_ = GTEST_FLAG(print_time);
-    random_seed_ = GTEST_FLAG(random_seed);
-    repeat_ = GTEST_FLAG(repeat);
-    shuffle_ = GTEST_FLAG(shuffle);
-    stack_trace_depth_ = GTEST_FLAG(stack_trace_depth);
-    stream_result_to_ = GTEST_FLAG(stream_result_to);
-    throw_on_failure_ = GTEST_FLAG(throw_on_failure);
-  }
-
-  // The d'tor is not virtual.  DO NOT INHERIT FROM THIS CLASS.
-  ~GTestFlagSaver() {
-    GTEST_FLAG(also_run_disabled_tests) = also_run_disabled_tests_;
-    GTEST_FLAG(break_on_failure) = break_on_failure_;
-    GTEST_FLAG(catch_exceptions) = catch_exceptions_;
-    GTEST_FLAG(color) = color_;
-    GTEST_FLAG(death_test_style) = death_test_style_;
-    GTEST_FLAG(death_test_use_fork) = death_test_use_fork_;
-    GTEST_FLAG(filter) = filter_;
-    GTEST_FLAG(internal_run_death_test) = internal_run_death_test_;
-    GTEST_FLAG(list_tests) = list_tests_;
-    GTEST_FLAG(output) = output_;
-    GTEST_FLAG(print_time) = print_time_;
-    GTEST_FLAG(random_seed) = random_seed_;
-    GTEST_FLAG(repeat) = repeat_;
-    GTEST_FLAG(shuffle) = shuffle_;
-    GTEST_FLAG(stack_trace_depth) = stack_trace_depth_;
-    GTEST_FLAG(stream_result_to) = stream_result_to_;
-    GTEST_FLAG(throw_on_failure) = throw_on_failure_;
-  }
- private:
-  // Fields for saving the original values of flags.
-  bool also_run_disabled_tests_;
-  bool break_on_failure_;
-  bool catch_exceptions_;
-  String color_;
-  String death_test_style_;
-  bool death_test_use_fork_;
-  String filter_;
-  String internal_run_death_test_;
-  bool list_tests_;
-  String output_;
-  bool print_time_;
-  bool pretty_;
-  internal::Int32 random_seed_;
-  internal::Int32 repeat_;
-  bool shuffle_;
-  internal::Int32 stack_trace_depth_;
-  String stream_result_to_;
-  bool throw_on_failure_;
-} GTEST_ATTRIBUTE_UNUSED_;
-
-// Converts a Unicode code point to a narrow string in UTF-8 encoding.
-// code_point parameter is of type UInt32 because wchar_t may not be
-// wide enough to contain a code point.
-// The output buffer str must containt at least 32 characters.
-// The function returns the address of the output buffer.
-// If the code_point is not a valid Unicode code point
-// (i.e. outside of Unicode range U+0 to U+10FFFF) it will be output
-// as '(Invalid Unicode 0xXXXXXXXX)'.
-GTEST_API_ char* CodePointToUtf8(UInt32 code_point, char* str);
-
-// Converts a wide string to a narrow string in UTF-8 encoding.
-// The wide string is assumed to have the following encoding:
-//   UTF-16 if sizeof(wchar_t) == 2 (on Windows, Cygwin, Symbian OS)
-//   UTF-32 if sizeof(wchar_t) == 4 (on Linux)
-// Parameter str points to a null-terminated wide string.
-// Parameter num_chars may additionally limit the number
-// of wchar_t characters processed. -1 is used when the entire string
-// should be processed.
-// If the string contains code points that are not valid Unicode code points
-// (i.e. outside of Unicode range U+0 to U+10FFFF) they will be output
-// as '(Invalid Unicode 0xXXXXXXXX)'. If the string is in UTF16 encoding
-// and contains invalid UTF-16 surrogate pairs, values in those pairs
-// will be encoded as individual Unicode characters from Basic Normal Plane.
-GTEST_API_ String WideStringToUtf8(const wchar_t* str, int num_chars);
-
-// Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file
-// if the variable is present. If a file already exists at this location, this
-// function will write over it. If the variable is present, but the file cannot
-// be created, prints an error and exits.
-void WriteToShardStatusFileIfNeeded();
-
-// Checks whether sharding is enabled by examining the relevant
-// environment variable values. If the variables are present,
-// but inconsistent (e.g., shard_index >= total_shards), prints
-// an error and exits. If in_subprocess_for_death_test, sharding is
-// disabled because it must only be applied to the original test
-// process. Otherwise, we could filter out death tests we intended to execute.
-GTEST_API_ bool ShouldShard(const char* total_shards_str,
-                            const char* shard_index_str,
-                            bool in_subprocess_for_death_test);
-
-// Parses the environment variable var as an Int32. If it is unset,
-// returns default_val. If it is not an Int32, prints an error and
-// and aborts.
-GTEST_API_ Int32 Int32FromEnvOrDie(const char* env_var, Int32 default_val);
-
-// Given the total number of shards, the shard index, and the test id,
-// returns true iff the test should be run on this shard. The test id is
-// some arbitrary but unique non-negative integer assigned to each test
-// method. Assumes that 0 <= shard_index < total_shards.
-GTEST_API_ bool ShouldRunTestOnShard(
-    int total_shards, int shard_index, int test_id);
-
-// STL container utilities.
-
-// Returns the number of elements in the given container that satisfy
-// the given predicate.
-template <class Container, typename Predicate>
-inline int CountIf(const Container& c, Predicate predicate) {
-  // Implemented as an explicit loop since std::count_if() in libCstd on
-  // Solaris has a non-standard signature.
-  int count = 0;
-  for (typename Container::const_iterator it = c.begin(); it != c.end(); ++it) {
-    if (predicate(*it))
-      ++count;
-  }
-  return count;
-}
-
-// Applies a function/functor to each element in the container.
-template <class Container, typename Functor>
-void ForEach(const Container& c, Functor functor) {
-  std::for_each(c.begin(), c.end(), functor);
-}
-
-// Returns the i-th element of the vector, or default_value if i is not
-// in range [0, v.size()).
-template <typename E>
-inline E GetElementOr(const std::vector<E>& v, int i, E default_value) {
-  return (i < 0 || i >= static_cast<int>(v.size())) ? default_value : v[i];
-}
-
-// Performs an in-place shuffle of a range of the vector's elements.
-// 'begin' and 'end' are element indices as an STL-style range;
-// i.e. [begin, end) are shuffled, where 'end' == size() means to
-// shuffle to the end of the vector.
-template <typename E>
-void ShuffleRange(internal::Random* random, int begin, int end,
-                  std::vector<E>* v) {
-  const int size = static_cast<int>(v->size());
-  GTEST_CHECK_(0 <= begin && begin <= size)
-      << "Invalid shuffle range start " << begin << ": must be in range [0, "
-      << size << "].";
-  GTEST_CHECK_(begin <= end && end <= size)
-      << "Invalid shuffle range finish " << end << ": must be in range ["
-      << begin << ", " << size << "].";
-
-  // Fisher-Yates shuffle, from
-  // http://en.wikipedia.org/wiki/Fisher-Yates_shuffle
-  for (int range_width = end - begin; range_width >= 2; range_width--) {
-    const int last_in_range = begin + range_width - 1;
-    const int selected = begin + random->Generate(range_width);
-    std::swap((*v)[selected], (*v)[last_in_range]);
-  }
-}
-
-// Performs an in-place shuffle of the vector's elements.
-template <typename E>
-inline void Shuffle(internal::Random* random, std::vector<E>* v) {
-  ShuffleRange(random, 0, static_cast<int>(v->size()), v);
-}
-
-// A function for deleting an object.  Handy for being used as a
-// functor.
-template <typename T>
-static void Delete(T* x) {
-  delete x;
-}
-
-// A predicate that checks the key of a TestProperty against a known key.
-//
-// TestPropertyKeyIs is copyable.
-class TestPropertyKeyIs {
- public:
-  // Constructor.
-  //
-  // TestPropertyKeyIs has NO default constructor.
-  explicit TestPropertyKeyIs(const char* key)
-      : key_(key) {}
-
-  // Returns true iff the test name of test property matches on key_.
-  bool operator()(const TestProperty& test_property) const {
-    return String(test_property.key()).Compare(key_) == 0;
-  }
-
- private:
-  String key_;
-};
-
-// Class UnitTestOptions.
-//
-// This class contains functions for processing options the user
-// specifies when running the tests.  It has only static members.
-//
-// In most cases, the user can specify an option using either an
-// environment variable or a command line flag.  E.g. you can set the
-// test filter using either GTEST_FILTER or --gtest_filter.  If both
-// the variable and the flag are present, the latter overrides the
-// former.
-class GTEST_API_ UnitTestOptions {
- public:
-  // Functions for processing the gtest_output flag.
-
-  // Returns the output format, or "" for normal printed output.
-  static String GetOutputFormat();
-
-  // Returns the absolute path of the requested output file, or the
-  // default (test_detail.xml in the original working directory) if
-  // none was explicitly specified.
-  static String GetAbsolutePathToOutputFile();
-
-  // Functions for processing the gtest_filter flag.
-
-  // Returns true iff the wildcard pattern matches the string.  The
-  // first ':' or '\0' character in pattern marks the end of it.
-  //
-  // This recursive algorithm isn't very efficient, but is clear and
-  // works well enough for matching test names, which are short.
-  static bool PatternMatchesString(const char *pattern, const char *str);
-
-  // Returns true iff the user-specified filter matches the test case
-  // name and the test name.
-  static bool FilterMatchesTest(const String &test_case_name,
-                                const String &test_name);
-
-#if GTEST_OS_WINDOWS
-  // Function for supporting the gtest_catch_exception flag.
-
-  // Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the
-  // given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.
-  // This function is useful as an __except condition.
-  static int GTestShouldProcessSEH(DWORD exception_code);
-#endif  // GTEST_OS_WINDOWS
-
-  // Returns true if "name" matches the ':' separated list of glob-style
-  // filters in "filter".
-  static bool MatchesFilter(const String& name, const char* filter);
-};
-
-// Returns the current application's name, removing directory path if that
-// is present.  Used by UnitTestOptions::GetOutputFile.
-GTEST_API_ FilePath GetCurrentExecutableName();
-
-// The role interface for getting the OS stack trace as a string.
-class OsStackTraceGetterInterface {
- public:
-  OsStackTraceGetterInterface() {}
-  virtual ~OsStackTraceGetterInterface() {}
-
-  // Returns the current OS stack trace as a String.  Parameters:
-  //
-  //   max_depth  - the maximum number of stack frames to be included
-  //                in the trace.
-  //   skip_count - the number of top frames to be skipped; doesn't count
-  //                against max_depth.
-  virtual String CurrentStackTrace(int max_depth, int skip_count) = 0;
-
-  // UponLeavingGTest() should be called immediately before Google Test calls
-  // user code. It saves some information about the current stack that
-  // CurrentStackTrace() will use to find and hide Google Test stack frames.
-  virtual void UponLeavingGTest() = 0;
-
- private:
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetterInterface);
-};
-
-// A working implementation of the OsStackTraceGetterInterface interface.
-class OsStackTraceGetter : public OsStackTraceGetterInterface {
- public:
-  OsStackTraceGetter() : caller_frame_(NULL) {}
-  virtual String CurrentStackTrace(int max_depth, int skip_count);
-  virtual void UponLeavingGTest();
-
-  // This string is inserted in place of stack frames that are part of
-  // Google Test's implementation.
-  static const char* const kElidedFramesMarker;
-
- private:
-  Mutex mutex_;  // protects all internal state
-
-  // We save the stack frame below the frame that calls user code.
-  // We do this because the address of the frame immediately below
-  // the user code changes between the call to UponLeavingGTest()
-  // and any calls to CurrentStackTrace() from within the user code.
-  void* caller_frame_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetter);
-};
-
-// Information about a Google Test trace point.
-struct TraceInfo {
-  const char* file;
-  int line;
-  String message;
-};
-
-// This is the default global test part result reporter used in UnitTestImpl.
-// This class should only be used by UnitTestImpl.
-class DefaultGlobalTestPartResultReporter
-  : public TestPartResultReporterInterface {
- public:
-  explicit DefaultGlobalTestPartResultReporter(UnitTestImpl* unit_test);
-  // Implements the TestPartResultReporterInterface. Reports the test part
-  // result in the current test.
-  virtual void ReportTestPartResult(const TestPartResult& result);
-
- private:
-  UnitTestImpl* const unit_test_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultGlobalTestPartResultReporter);
-};
-
-// This is the default per thread test part result reporter used in
-// UnitTestImpl. This class should only be used by UnitTestImpl.
-class DefaultPerThreadTestPartResultReporter
-    : public TestPartResultReporterInterface {
- public:
-  explicit DefaultPerThreadTestPartResultReporter(UnitTestImpl* unit_test);
-  // Implements the TestPartResultReporterInterface. The implementation just
-  // delegates to the current global test part result reporter of *unit_test_.
-  virtual void ReportTestPartResult(const TestPartResult& result);
-
- private:
-  UnitTestImpl* const unit_test_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultPerThreadTestPartResultReporter);
-};
-
-// The private implementation of the UnitTest class.  We don't protect
-// the methods under a mutex, as this class is not accessible by a
-// user and the UnitTest class that delegates work to this class does
-// proper locking.
-class GTEST_API_ UnitTestImpl {
- public:
-  explicit UnitTestImpl(UnitTest* parent);
-  virtual ~UnitTestImpl();
-
-  // There are two different ways to register your own TestPartResultReporter.
-  // You can register your own repoter to listen either only for test results
-  // from the current thread or for results from all threads.
-  // By default, each per-thread test result repoter just passes a new
-  // TestPartResult to the global test result reporter, which registers the
-  // test part result for the currently running test.
-
-  // Returns the global test part result reporter.
-  TestPartResultReporterInterface* GetGlobalTestPartResultReporter();
-
-  // Sets the global test part result reporter.
-  void SetGlobalTestPartResultReporter(
-      TestPartResultReporterInterface* reporter);
-
-  // Returns the test part result reporter for the current thread.
-  TestPartResultReporterInterface* GetTestPartResultReporterForCurrentThread();
-
-  // Sets the test part result reporter for the current thread.
-  void SetTestPartResultReporterForCurrentThread(
-      TestPartResultReporterInterface* reporter);
-
-  // Gets the number of successful test cases.
-  int successful_test_case_count() const;
-
-  // Gets the number of failed test cases.
-  int failed_test_case_count() const;
-
-  // Gets the number of all test cases.
-  int total_test_case_count() const;
-
-  // Gets the number of all test cases that contain at least one test
-  // that should run.
-  int test_case_to_run_count() const;
-
-  // Gets the number of successful tests.
-  int successful_test_count() const;
-
-  // Gets the number of failed tests.
-  int failed_test_count() const;
-
-  // Gets the number of disabled tests.
-  int disabled_test_count() const;
-
-  // Gets the number of all tests.
-  int total_test_count() const;
-
-  // Gets the number of tests that should run.
-  int test_to_run_count() const;
-
-  // Gets the elapsed time, in milliseconds.
-  TimeInMillis elapsed_time() const { return elapsed_time_; }
-
-  // Returns true iff the unit test passed (i.e. all test cases passed).
-  bool Passed() const { return !Failed(); }
-
-  // Returns true iff the unit test failed (i.e. some test case failed
-  // or something outside of all tests failed).
-  bool Failed() const {
-    return failed_test_case_count() > 0 || ad_hoc_test_result()->Failed();
-  }
-
-  // Gets the i-th test case among all the test cases. i can range from 0 to
-  // total_test_case_count() - 1. If i is not in that range, returns NULL.
-  const TestCase* GetTestCase(int i) const {
-    const int index = GetElementOr(test_case_indices_, i, -1);
-    return index < 0 ? NULL : test_cases_[i];
-  }
-
-  // Gets the i-th test case among all the test cases. i can range from 0 to
-  // total_test_case_count() - 1. If i is not in that range, returns NULL.
-  TestCase* GetMutableTestCase(int i) {
-    const int index = GetElementOr(test_case_indices_, i, -1);
-    return index < 0 ? NULL : test_cases_[index];
-  }
-
-  // Provides access to the event listener list.
-  TestEventListeners* listeners() { return &listeners_; }
-
-  // Returns the TestResult for the test that's currently running, or
-  // the TestResult for the ad hoc test if no test is running.
-  TestResult* current_test_result();
-
-  // Returns the TestResult for the ad hoc test.
-  const TestResult* ad_hoc_test_result() const { return &ad_hoc_test_result_; }
-
-  // Sets the OS stack trace getter.
-  //
-  // Does nothing if the input and the current OS stack trace getter
-  // are the same; otherwise, deletes the old getter and makes the
-  // input the current getter.
-  void set_os_stack_trace_getter(OsStackTraceGetterInterface* getter);
-
-  // Returns the current OS stack trace getter if it is not NULL;
-  // otherwise, creates an OsStackTraceGetter, makes it the current
-  // getter, and returns it.
-  OsStackTraceGetterInterface* os_stack_trace_getter();
-
-  // Returns the current OS stack trace as a String.
-  //
-  // The maximum number of stack frames to be included is specified by
-  // the gtest_stack_trace_depth flag.  The skip_count parameter
-  // specifies the number of top frames to be skipped, which doesn't
-  // count against the number of frames to be included.
-  //
-  // For example, if Foo() calls Bar(), which in turn calls
-  // CurrentOsStackTraceExceptTop(1), Foo() will be included in the
-  // trace but Bar() and CurrentOsStackTraceExceptTop() won't.
-  String CurrentOsStackTraceExceptTop(int skip_count);
-
-  // Finds and returns a TestCase with the given name.  If one doesn't
-  // exist, creates one and returns it.
-  //
-  // Arguments:
-  //
-  //   test_case_name: name of the test case
-  //   type_param:     the name of the test's type parameter, or NULL if
-  //                   this is not a typed or a type-parameterized test.
-  //   set_up_tc:      pointer to the function that sets up the test case
-  //   tear_down_tc:   pointer to the function that tears down the test case
-  TestCase* GetTestCase(const char* test_case_name,
-                        const char* type_param,
-                        Test::SetUpTestCaseFunc set_up_tc,
-                        Test::TearDownTestCaseFunc tear_down_tc);
-
-  // Adds a TestInfo to the unit test.
-  //
-  // Arguments:
-  //
-  //   set_up_tc:    pointer to the function that sets up the test case
-  //   tear_down_tc: pointer to the function that tears down the test case
-  //   test_info:    the TestInfo object
-  void AddTestInfo(Test::SetUpTestCaseFunc set_up_tc,
-                   Test::TearDownTestCaseFunc tear_down_tc,
-                   TestInfo* test_info) {
-    // In order to support thread-safe death tests, we need to
-    // remember the original working directory when the test program
-    // was first invoked.  We cannot do this in RUN_ALL_TESTS(), as
-    // the user may have changed the current directory before calling
-    // RUN_ALL_TESTS().  Therefore we capture the current directory in
-    // AddTestInfo(), which is called to register a TEST or TEST_F
-    // before main() is reached.
-    if (original_working_dir_.IsEmpty()) {
-      original_working_dir_.Set(FilePath::GetCurrentDir());
-      GTEST_CHECK_(!original_working_dir_.IsEmpty())
-          << "Failed to get the current working directory.";
-    }
-
-    GetTestCase(test_info->test_case_name(),
-                test_info->type_param(),
-                set_up_tc,
-                tear_down_tc)->AddTestInfo(test_info);
-  }
-
-#if GTEST_HAS_PARAM_TEST
-  // Returns ParameterizedTestCaseRegistry object used to keep track of
-  // value-parameterized tests and instantiate and register them.
-  internal::ParameterizedTestCaseRegistry& parameterized_test_registry() {
-    return parameterized_test_registry_;
-  }
-#endif  // GTEST_HAS_PARAM_TEST
-
-  // Sets the TestCase object for the test that's currently running.
-  void set_current_test_case(TestCase* a_current_test_case) {
-    current_test_case_ = a_current_test_case;
-  }
-
-  // Sets the TestInfo object for the test that's currently running.  If
-  // current_test_info is NULL, the assertion results will be stored in
-  // ad_hoc_test_result_.
-  void set_current_test_info(TestInfo* a_current_test_info) {
-    current_test_info_ = a_current_test_info;
-  }
-
-  // Registers all parameterized tests defined using TEST_P and
-  // INSTANTIATE_TEST_CASE_P, creating regular tests for each test/parameter
-  // combination. This method can be called more then once; it has guards
-  // protecting from registering the tests more then once.  If
-  // value-parameterized tests are disabled, RegisterParameterizedTests is
-  // present but does nothing.
-  void RegisterParameterizedTests();
-
-  // Runs all tests in this UnitTest object, prints the result, and
-  // returns true if all tests are successful.  If any exception is
-  // thrown during a test, this test is considered to be failed, but
-  // the rest of the tests will still be run.
-  bool RunAllTests();
-
-  // Clears the results of all tests, except the ad hoc tests.
-  void ClearNonAdHocTestResult() {
-    ForEach(test_cases_, TestCase::ClearTestCaseResult);
-  }
-
-  // Clears the results of ad-hoc test assertions.
-  void ClearAdHocTestResult() {
-    ad_hoc_test_result_.Clear();
-  }
-
-  enum ReactionToSharding {
-    HONOR_SHARDING_PROTOCOL,
-    IGNORE_SHARDING_PROTOCOL
-  };
-
-  // Matches the full name of each test against the user-specified
-  // filter to decide whether the test should run, then records the
-  // result in each TestCase and TestInfo object.
-  // If shard_tests == HONOR_SHARDING_PROTOCOL, further filters tests
-  // based on sharding variables in the environment.
-  // Returns the number of tests that should run.
-  int FilterTests(ReactionToSharding shard_tests);
-
-  // Prints the names of the tests matching the user-specified filter flag.
-  void ListTestsMatchingFilter();
-
-  const TestCase* current_test_case() const { return current_test_case_; }
-  TestInfo* current_test_info() { return current_test_info_; }
-  const TestInfo* current_test_info() const { return current_test_info_; }
-
-  // Returns the vector of environments that need to be set-up/torn-down
-  // before/after the tests are run.
-  std::vector<Environment*>& environments() { return environments_; }
-
-  // Getters for the per-thread Google Test trace stack.
-  std::vector<TraceInfo>& gtest_trace_stack() {
-    return *(gtest_trace_stack_.pointer());
-  }
-  const std::vector<TraceInfo>& gtest_trace_stack() const {
-    return gtest_trace_stack_.get();
-  }
-
-#if GTEST_HAS_DEATH_TEST
-  void InitDeathTestSubprocessControlInfo() {
-    internal_run_death_test_flag_.reset(ParseInternalRunDeathTestFlag());
-  }
-  // Returns a pointer to the parsed --gtest_internal_run_death_test
-  // flag, or NULL if that flag was not specified.
-  // This information is useful only in a death test child process.
-  // Must not be called before a call to InitGoogleTest.
-  const InternalRunDeathTestFlag* internal_run_death_test_flag() const {
-    return internal_run_death_test_flag_.get();
-  }
-
-  // Returns a pointer to the current death test factory.
-  internal::DeathTestFactory* death_test_factory() {
-    return death_test_factory_.get();
-  }
-
-  void SuppressTestEventsIfInSubprocess();
-
-  friend class ReplaceDeathTestFactory;
-#endif  // GTEST_HAS_DEATH_TEST
-
-  // Initializes the event listener performing XML output as specified by
-  // UnitTestOptions. Must not be called before InitGoogleTest.
-  void ConfigureXmlOutput();
-
-#if GTEST_CAN_STREAM_RESULTS_
-  // Initializes the event listener for streaming test results to a socket.
-  // Must not be called before InitGoogleTest.
-  void ConfigureStreamingOutput();
-#endif
-
-  // Performs initialization dependent upon flag values obtained in
-  // ParseGoogleTestFlagsOnly.  Is called from InitGoogleTest after the call to
-  // ParseGoogleTestFlagsOnly.  In case a user neglects to call InitGoogleTest
-  // this function is also called from RunAllTests.  Since this function can be
-  // called more than once, it has to be idempotent.
-  void PostFlagParsingInit();
-
-  // Gets the random seed used at the start of the current test iteration.
-  int random_seed() const { return random_seed_; }
-
-  // Gets the random number generator.
-  internal::Random* random() { return &random_; }
-
-  // Shuffles all test cases, and the tests within each test case,
-  // making sure that death tests are still run first.
-  void ShuffleTests();
-
-  // Restores the test cases and tests to their order before the first shuffle.
-  void UnshuffleTests();
-
-  // Returns the value of GTEST_FLAG(catch_exceptions) at the moment
-  // UnitTest::Run() starts.
-  bool catch_exceptions() const { return catch_exceptions_; }
-
- private:
-  friend class ::testing::UnitTest;
-
-  // Used by UnitTest::Run() to capture the state of
-  // GTEST_FLAG(catch_exceptions) at the moment it starts.
-  void set_catch_exceptions(bool value) { catch_exceptions_ = value; }
-
-  // The UnitTest object that owns this implementation object.
-  UnitTest* const parent_;
-
-  // The working directory when the first TEST() or TEST_F() was
-  // executed.
-  internal::FilePath original_working_dir_;
-
-  // The default test part result reporters.
-  DefaultGlobalTestPartResultReporter default_global_test_part_result_reporter_;
-  DefaultPerThreadTestPartResultReporter
-      default_per_thread_test_part_result_reporter_;
-
-  // Points to (but doesn't own) the global test part result reporter.
-  TestPartResultReporterInterface* global_test_part_result_repoter_;
-
-  // Protects read and write access to global_test_part_result_reporter_.
-  internal::Mutex global_test_part_result_reporter_mutex_;
-
-  // Points to (but doesn't own) the per-thread test part result reporter.
-  internal::ThreadLocal<TestPartResultReporterInterface*>
-      per_thread_test_part_result_reporter_;
-
-  // The vector of environments that need to be set-up/torn-down
-  // before/after the tests are run.
-  std::vector<Environment*> environments_;
-
-  // The vector of TestCases in their original order.  It owns the
-  // elements in the vector.
-  std::vector<TestCase*> test_cases_;
-
-  // Provides a level of indirection for the test case list to allow
-  // easy shuffling and restoring the test case order.  The i-th
-  // element of this vector is the index of the i-th test case in the
-  // shuffled order.
-  std::vector<int> test_case_indices_;
-
-#if GTEST_HAS_PARAM_TEST
-  // ParameterizedTestRegistry object used to register value-parameterized
-  // tests.
-  internal::ParameterizedTestCaseRegistry parameterized_test_registry_;
-
-  // Indicates whether RegisterParameterizedTests() has been called already.
-  bool parameterized_tests_registered_;
-#endif  // GTEST_HAS_PARAM_TEST
-
-  // Index of the last death test case registered.  Initially -1.
-  int last_death_test_case_;
-
-  // This points to the TestCase for the currently running test.  It
-  // changes as Google Test goes through one test case after another.
-  // When no test is running, this is set to NULL and Google Test
-  // stores assertion results in ad_hoc_test_result_.  Initially NULL.
-  TestCase* current_test_case_;
-
-  // This points to the TestInfo for the currently running test.  It
-  // changes as Google Test goes through one test after another.  When
-  // no test is running, this is set to NULL and Google Test stores
-  // assertion results in ad_hoc_test_result_.  Initially NULL.
-  TestInfo* current_test_info_;
-
-  // Normally, a user only writes assertions inside a TEST or TEST_F,
-  // or inside a function called by a TEST or TEST_F.  Since Google
-  // Test keeps track of which test is current running, it can
-  // associate such an assertion with the test it belongs to.
-  //
-  // If an assertion is encountered when no TEST or TEST_F is running,
-  // Google Test attributes the assertion result to an imaginary "ad hoc"
-  // test, and records the result in ad_hoc_test_result_.
-  TestResult ad_hoc_test_result_;
-
-  // The list of event listeners that can be used to track events inside
-  // Google Test.
-  TestEventListeners listeners_;
-
-  // The OS stack trace getter.  Will be deleted when the UnitTest
-  // object is destructed.  By default, an OsStackTraceGetter is used,
-  // but the user can set this field to use a custom getter if that is
-  // desired.
-  OsStackTraceGetterInterface* os_stack_trace_getter_;
-
-  // True iff PostFlagParsingInit() has been called.
-  bool post_flag_parse_init_performed_;
-
-  // The random number seed used at the beginning of the test run.
-  int random_seed_;
-
-  // Our random number generator.
-  internal::Random random_;
-
-  // How long the test took to run, in milliseconds.
-  TimeInMillis elapsed_time_;
-
-#if GTEST_HAS_DEATH_TEST
-  // The decomposed components of the gtest_internal_run_death_test flag,
-  // parsed when RUN_ALL_TESTS is called.
-  internal::scoped_ptr<InternalRunDeathTestFlag> internal_run_death_test_flag_;
-  internal::scoped_ptr<internal::DeathTestFactory> death_test_factory_;
-#endif  // GTEST_HAS_DEATH_TEST
-
-  // A per-thread stack of traces created by the SCOPED_TRACE() macro.
-  internal::ThreadLocal<std::vector<TraceInfo> > gtest_trace_stack_;
-
-  // The value of GTEST_FLAG(catch_exceptions) at the moment RunAllTests()
-  // starts.
-  bool catch_exceptions_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTestImpl);
-};  // class UnitTestImpl
-
-// Convenience function for accessing the global UnitTest
-// implementation object.
-inline UnitTestImpl* GetUnitTestImpl() {
-  return UnitTest::GetInstance()->impl();
-}
-
-#if GTEST_USES_SIMPLE_RE
-
-// Internal helper functions for implementing the simple regular
-// expression matcher.
-GTEST_API_ bool IsInSet(char ch, const char* str);
-GTEST_API_ bool IsAsciiDigit(char ch);
-GTEST_API_ bool IsAsciiPunct(char ch);
-GTEST_API_ bool IsRepeat(char ch);
-GTEST_API_ bool IsAsciiWhiteSpace(char ch);
-GTEST_API_ bool IsAsciiWordChar(char ch);
-GTEST_API_ bool IsValidEscape(char ch);
-GTEST_API_ bool AtomMatchesChar(bool escaped, char pattern, char ch);
-GTEST_API_ bool ValidateRegex(const char* regex);
-GTEST_API_ bool MatchRegexAtHead(const char* regex, const char* str);
-GTEST_API_ bool MatchRepetitionAndRegexAtHead(
-    bool escaped, char ch, char repeat, const char* regex, const char* str);
-GTEST_API_ bool MatchRegexAnywhere(const char* regex, const char* str);
-
-#endif  // GTEST_USES_SIMPLE_RE
-
-// Parses the command line for Google Test flags, without initializing
-// other parts of Google Test.
-GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, char** argv);
-GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv);
-
-#if GTEST_HAS_DEATH_TEST
-
-// Returns the message describing the last system error, regardless of the
-// platform.
-GTEST_API_ String GetLastErrnoDescription();
-
-# if GTEST_OS_WINDOWS
-// Provides leak-safe Windows kernel handle ownership.
-class AutoHandle {
- public:
-  AutoHandle() : handle_(INVALID_HANDLE_VALUE) {}
-  explicit AutoHandle(HANDLE handle) : handle_(handle) {}
-
-  ~AutoHandle() { Reset(); }
-
-  HANDLE Get() const { return handle_; }
-  void Reset() { Reset(INVALID_HANDLE_VALUE); }
-  void Reset(HANDLE handle) {
-    if (handle != handle_) {
-      if (handle_ != INVALID_HANDLE_VALUE)
-        ::CloseHandle(handle_);
-      handle_ = handle;
-    }
-  }
-
- private:
-  HANDLE handle_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(AutoHandle);
-};
-# endif  // GTEST_OS_WINDOWS
-
-// Attempts to parse a string into a positive integer pointed to by the
-// number parameter.  Returns true if that is possible.
-// GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we can use
-// it here.
-template <typename Integer>
-bool ParseNaturalNumber(const ::std::string& str, Integer* number) {
-  // Fail fast if the given string does not begin with a digit;
-  // this bypasses strtoXXX's "optional leading whitespace and plus
-  // or minus sign" semantics, which are undesirable here.
-  if (str.empty() || !IsDigit(str[0])) {
-    return false;
-  }
-  errno = 0;
-
-  char* end;
-  // BiggestConvertible is the largest integer type that system-provided
-  // string-to-number conversion routines can return.
-
-# if GTEST_OS_WINDOWS && !defined(__GNUC__)
-
-  // MSVC and C++ Builder define __int64 instead of the standard long long.
-  typedef unsigned __int64 BiggestConvertible;
-  const BiggestConvertible parsed = _strtoui64(str.c_str(), &end, 10);
-
-# else
-
-  typedef unsigned long long BiggestConvertible;  // NOLINT
-  const BiggestConvertible parsed = strtoull(str.c_str(), &end, 10);
-
-# endif  // GTEST_OS_WINDOWS && !defined(__GNUC__)
-
-  const bool parse_success = *end == '\0' && errno == 0;
-
-  // TODO(vladl at google.com): Convert this to compile time assertion when it is
-  // available.
-  GTEST_CHECK_(sizeof(Integer) <= sizeof(parsed));
-
-  const Integer result = static_cast<Integer>(parsed);
-  if (parse_success && static_cast<BiggestConvertible>(result) == parsed) {
-    *number = result;
-    return true;
-  }
-  return false;
-}
-#endif  // GTEST_HAS_DEATH_TEST
-
-// TestResult contains some private methods that should be hidden from
-// Google Test user but are required for testing. This class allow our tests
-// to access them.
-//
-// This class is supplied only for the purpose of testing Google Test's own
-// constructs. Do not use it in user tests, either directly or indirectly.
-class TestResultAccessor {
- public:
-  static void RecordProperty(TestResult* test_result,
-                             const TestProperty& property) {
-    test_result->RecordProperty(property);
-  }
-
-  static void ClearTestPartResults(TestResult* test_result) {
-    test_result->ClearTestPartResults();
-  }
-
-  static const std::vector<testing::TestPartResult>& test_part_results(
-      const TestResult& test_result) {
-    return test_result.test_part_results();
-  }
-};
-
-}  // namespace internal
-}  // namespace testing
-
-#endif  // GTEST_SRC_GTEST_INTERNAL_INL_H_
-#undef GTEST_IMPLEMENTATION_
-
-#if GTEST_OS_WINDOWS
-# define vsnprintf _vsnprintf
-#endif  // GTEST_OS_WINDOWS
-
-namespace testing {
-
-using internal::CountIf;
-using internal::ForEach;
-using internal::GetElementOr;
-using internal::Shuffle;
-
-// Constants.
-
-// A test whose test case name or test name matches this filter is
-// disabled and not run.
-static const char kDisableTestFilter[] = "DISABLED_*:*/DISABLED_*";
-
-// A test case whose name matches this filter is considered a death
-// test case and will be run before test cases whose name doesn't
-// match this filter.
-static const char kDeathTestCaseFilter[] = "*DeathTest:*DeathTest/*";
-
-// A test filter that matches everything.
-static const char kUniversalFilter[] = "*";
-
-// The default output file for XML output.
-static const char kDefaultOutputFile[] = "test_detail.xml";
-
-// The environment variable name for the test shard index.
-static const char kTestShardIndex[] = "GTEST_SHARD_INDEX";
-// The environment variable name for the total number of test shards.
-static const char kTestTotalShards[] = "GTEST_TOTAL_SHARDS";
-// The environment variable name for the test shard status file.
-static const char kTestShardStatusFile[] = "GTEST_SHARD_STATUS_FILE";
-
-namespace internal {
-
-// The text used in failure messages to indicate the start of the
-// stack trace.
-const char kStackTraceMarker[] = "\nStack trace:\n";
-
-// g_help_flag is true iff the --help flag or an equivalent form is
-// specified on the command line.
-bool g_help_flag = false;
-
-}  // namespace internal
-
-GTEST_DEFINE_bool_(
-    also_run_disabled_tests,
-    internal::BoolFromGTestEnv("also_run_disabled_tests", false),
-    "Run disabled tests too, in addition to the tests normally being run.");
-
-GTEST_DEFINE_bool_(
-    break_on_failure,
-    internal::BoolFromGTestEnv("break_on_failure", false),
-    "True iff a failed assertion should be a debugger break-point.");
-
-GTEST_DEFINE_bool_(
-    catch_exceptions,
-    internal::BoolFromGTestEnv("catch_exceptions", true),
-    "True iff " GTEST_NAME_
-    " should catch exceptions and treat them as test failures.");
-
-GTEST_DEFINE_string_(
-    color,
-    internal::StringFromGTestEnv("color", "auto"),
-    "Whether to use colors in the output.  Valid values: yes, no, "
-    "and auto.  'auto' means to use colors if the output is "
-    "being sent to a terminal and the TERM environment variable "
-    "is set to xterm, xterm-color, xterm-256color, linux or cygwin.");
-
-GTEST_DEFINE_string_(
-    filter,
-    internal::StringFromGTestEnv("filter", kUniversalFilter),
-    "A colon-separated list of glob (not regex) patterns "
-    "for filtering the tests to run, optionally followed by a "
-    "'-' and a : separated list of negative patterns (tests to "
-    "exclude).  A test is run if it matches one of the positive "
-    "patterns and does not match any of the negative patterns.");
-
-GTEST_DEFINE_bool_(list_tests, false,
-                   "List all tests without running them.");
-
-GTEST_DEFINE_string_(
-    output,
-    internal::StringFromGTestEnv("output", ""),
-    "A format (currently must be \"xml\"), optionally followed "
-    "by a colon and an output file name or directory. A directory "
-    "is indicated by a trailing pathname separator. "
-    "Examples: \"xml:filename.xml\", \"xml::directoryname/\". "
-    "If a directory is specified, output files will be created "
-    "within that directory, with file-names based on the test "
-    "executable's name and, if necessary, made unique by adding "
-    "digits.");
-
-GTEST_DEFINE_bool_(
-    print_time,
-    internal::BoolFromGTestEnv("print_time", true),
-    "True iff " GTEST_NAME_
-    " should display elapsed time in text output.");
-
-GTEST_DEFINE_int32_(
-    random_seed,
-    internal::Int32FromGTestEnv("random_seed", 0),
-    "Random number seed to use when shuffling test orders.  Must be in range "
-    "[1, 99999], or 0 to use a seed based on the current time.");
-
-GTEST_DEFINE_int32_(
-    repeat,
-    internal::Int32FromGTestEnv("repeat", 1),
-    "How many times to repeat each test.  Specify a negative number "
-    "for repeating forever.  Useful for shaking out flaky tests.");
-
-GTEST_DEFINE_bool_(
-    show_internal_stack_frames, false,
-    "True iff " GTEST_NAME_ " should include internal stack frames when "
-    "printing test failure stack traces.");
-
-GTEST_DEFINE_bool_(
-    shuffle,
-    internal::BoolFromGTestEnv("shuffle", false),
-    "True iff " GTEST_NAME_
-    " should randomize tests' order on every run.");
-
-GTEST_DEFINE_int32_(
-    stack_trace_depth,
-    internal::Int32FromGTestEnv("stack_trace_depth", kMaxStackTraceDepth),
-    "The maximum number of stack frames to print when an "
-    "assertion fails.  The valid range is 0 through 100, inclusive.");
-
-GTEST_DEFINE_string_(
-    stream_result_to,
-    internal::StringFromGTestEnv("stream_result_to", ""),
-    "This flag specifies the host name and the port number on which to stream "
-    "test results. Example: \"localhost:555\". The flag is effective only on "
-    "Linux.");
-
-GTEST_DEFINE_bool_(
-    throw_on_failure,
-    internal::BoolFromGTestEnv("throw_on_failure", false),
-    "When this flag is specified, a failed assertion will throw an exception "
-    "if exceptions are enabled or exit the program with a non-zero code "
-    "otherwise.");
-
-namespace internal {
-
-// Generates a random number from [0, range), using a Linear
-// Congruential Generator (LCG).  Crashes if 'range' is 0 or greater
-// than kMaxRange.
-UInt32 Random::Generate(UInt32 range) {
-  // These constants are the same as are used in glibc's rand(3).
-  state_ = (1103515245U*state_ + 12345U) % kMaxRange;
-
-  GTEST_CHECK_(range > 0)
-      << "Cannot generate a number in the range [0, 0).";
-  GTEST_CHECK_(range <= kMaxRange)
-      << "Generation of a number in [0, " << range << ") was requested, "
-      << "but this can only generate numbers in [0, " << kMaxRange << ").";
-
-  // Converting via modulus introduces a bit of downward bias, but
-  // it's simple, and a linear congruential generator isn't too good
-  // to begin with.
-  return state_ % range;
-}
-
-// GTestIsInitialized() returns true iff the user has initialized
-// Google Test.  Useful for catching the user mistake of not initializing
-// Google Test before calling RUN_ALL_TESTS().
-//
-// A user must call testing::InitGoogleTest() to initialize Google
-// Test.  g_init_gtest_count is set to the number of times
-// InitGoogleTest() has been called.  We don't protect this variable
-// under a mutex as it is only accessed in the main thread.
-int g_init_gtest_count = 0;
-static bool GTestIsInitialized() { return g_init_gtest_count != 0; }
-
-// Iterates over a vector of TestCases, keeping a running sum of the
-// results of calling a given int-returning method on each.
-// Returns the sum.
-static int SumOverTestCaseList(const std::vector<TestCase*>& case_list,
-                               int (TestCase::*method)() const) {
-  int sum = 0;
-  for (size_t i = 0; i < case_list.size(); i++) {
-    sum += (case_list[i]->*method)();
-  }
-  return sum;
-}
-
-// Returns true iff the test case passed.
-static bool TestCasePassed(const TestCase* test_case) {
-  return test_case->should_run() && test_case->Passed();
-}
-
-// Returns true iff the test case failed.
-static bool TestCaseFailed(const TestCase* test_case) {
-  return test_case->should_run() && test_case->Failed();
-}
-
-// Returns true iff test_case contains at least one test that should
-// run.
-static bool ShouldRunTestCase(const TestCase* test_case) {
-  return test_case->should_run();
-}
-
-// AssertHelper constructor.
-AssertHelper::AssertHelper(TestPartResult::Type type,
-                           const char* file,
-                           int line,
-                           const char* message)
-    : data_(new AssertHelperData(type, file, line, message)) {
-}
-
-AssertHelper::~AssertHelper() {
-  delete data_;
-}
-
-// Message assignment, for assertion streaming support.
-void AssertHelper::operator=(const Message& message) const {
-  UnitTest::GetInstance()->
-    AddTestPartResult(data_->type, data_->file, data_->line,
-                      AppendUserMessage(data_->message, message),
-                      UnitTest::GetInstance()->impl()
-                      ->CurrentOsStackTraceExceptTop(1)
-                      // Skips the stack frame for this function itself.
-                      );  // NOLINT
-}
-
-// Mutex for linked pointers.
-GTEST_DEFINE_STATIC_MUTEX_(g_linked_ptr_mutex);
-
-// Application pathname gotten in InitGoogleTest.
-String g_executable_path;
-
-// Returns the current application's name, removing directory path if that
-// is present.
-FilePath GetCurrentExecutableName() {
-  FilePath result;
-
-#if GTEST_OS_WINDOWS
-  result.Set(FilePath(g_executable_path).RemoveExtension("exe"));
-#else
-  result.Set(FilePath(g_executable_path));
-#endif  // GTEST_OS_WINDOWS
-
-  return result.RemoveDirectoryName();
-}
-
-// Functions for processing the gtest_output flag.
-
-// Returns the output format, or "" for normal printed output.
-String UnitTestOptions::GetOutputFormat() {
-  const char* const gtest_output_flag = GTEST_FLAG(output).c_str();
-  if (gtest_output_flag == NULL) return String("");
-
-  const char* const colon = strchr(gtest_output_flag, ':');
-  return (colon == NULL) ?
-      String(gtest_output_flag) :
-      String(gtest_output_flag, colon - gtest_output_flag);
-}
-
-// Returns the name of the requested output file, or the default if none
-// was explicitly specified.
-String UnitTestOptions::GetAbsolutePathToOutputFile() {
-  const char* const gtest_output_flag = GTEST_FLAG(output).c_str();
-  if (gtest_output_flag == NULL)
-    return String("");
-
-  const char* const colon = strchr(gtest_output_flag, ':');
-  if (colon == NULL)
-    return String(internal::FilePath::ConcatPaths(
-               internal::FilePath(
-                   UnitTest::GetInstance()->original_working_dir()),
-               internal::FilePath(kDefaultOutputFile)).ToString() );
-
-  internal::FilePath output_name(colon + 1);
-  if (!output_name.IsAbsolutePath())
-    // TODO(wan at google.com): on Windows \some\path is not an absolute
-    // path (as its meaning depends on the current drive), yet the
-    // following logic for turning it into an absolute path is wrong.
-    // Fix it.
-    output_name = internal::FilePath::ConcatPaths(
-        internal::FilePath(UnitTest::GetInstance()->original_working_dir()),
-        internal::FilePath(colon + 1));
-
-  if (!output_name.IsDirectory())
-    return output_name.ToString();
-
-  internal::FilePath result(internal::FilePath::GenerateUniqueFileName(
-      output_name, internal::GetCurrentExecutableName(),
-      GetOutputFormat().c_str()));
-  return result.ToString();
-}
-
-// Returns true iff the wildcard pattern matches the string.  The
-// first ':' or '\0' character in pattern marks the end of it.
-//
-// This recursive algorithm isn't very efficient, but is clear and
-// works well enough for matching test names, which are short.
-bool UnitTestOptions::PatternMatchesString(const char *pattern,
-                                           const char *str) {
-  switch (*pattern) {
-    case '\0':
-    case ':':  // Either ':' or '\0' marks the end of the pattern.
-      return *str == '\0';
-    case '?':  // Matches any single character.
-      return *str != '\0' && PatternMatchesString(pattern + 1, str + 1);
-    case '*':  // Matches any string (possibly empty) of characters.
-      return (*str != '\0' && PatternMatchesString(pattern, str + 1)) ||
-          PatternMatchesString(pattern + 1, str);
-    default:  // Non-special character.  Matches itself.
-      return *pattern == *str &&
-          PatternMatchesString(pattern + 1, str + 1);
-  }
-}
-
-bool UnitTestOptions::MatchesFilter(const String& name, const char* filter) {
-  const char *cur_pattern = filter;
-  for (;;) {
-    if (PatternMatchesString(cur_pattern, name.c_str())) {
-      return true;
-    }
-
-    // Finds the next pattern in the filter.
-    cur_pattern = strchr(cur_pattern, ':');
-
-    // Returns if no more pattern can be found.
-    if (cur_pattern == NULL) {
-      return false;
-    }
-
-    // Skips the pattern separater (the ':' character).
-    cur_pattern++;
-  }
-}
-
-// TODO(keithray): move String function implementations to gtest-string.cc.
-
-// Returns true iff the user-specified filter matches the test case
-// name and the test name.
-bool UnitTestOptions::FilterMatchesTest(const String &test_case_name,
-                                        const String &test_name) {
-  const String& full_name = String::Format("%s.%s",
-                                           test_case_name.c_str(),
-                                           test_name.c_str());
-
-  // Split --gtest_filter at '-', if there is one, to separate into
-  // positive filter and negative filter portions
-  const char* const p = GTEST_FLAG(filter).c_str();
-  const char* const dash = strchr(p, '-');
-  String positive;
-  String negative;
-  if (dash == NULL) {
-    positive = GTEST_FLAG(filter).c_str();  // Whole string is a positive filter
-    negative = String("");
-  } else {
-    positive = String(p, dash - p);  // Everything up to the dash
-    negative = String(dash+1);       // Everything after the dash
-    if (positive.empty()) {
-      // Treat '-test1' as the same as '*-test1'
-      positive = kUniversalFilter;
-    }
-  }
-
-  // A filter is a colon-separated list of patterns.  It matches a
-  // test if any pattern in it matches the test.
-  return (MatchesFilter(full_name, positive.c_str()) &&
-          !MatchesFilter(full_name, negative.c_str()));
-}
-
-#if GTEST_HAS_SEH
-// Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the
-// given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.
-// This function is useful as an __except condition.
-int UnitTestOptions::GTestShouldProcessSEH(DWORD exception_code) {
-  // Google Test should handle a SEH exception if:
-  //   1. the user wants it to, AND
-  //   2. this is not a breakpoint exception, AND
-  //   3. this is not a C++ exception (VC++ implements them via SEH,
-  //      apparently).
-  //
-  // SEH exception code for C++ exceptions.
-  // (see http://support.microsoft.com/kb/185294 for more information).
-  const DWORD kCxxExceptionCode = 0xe06d7363;
-
-  bool should_handle = true;
-
-  if (!GTEST_FLAG(catch_exceptions))
-    should_handle = false;
-  else if (exception_code == EXCEPTION_BREAKPOINT)
-    should_handle = false;
-  else if (exception_code == kCxxExceptionCode)
-    should_handle = false;
-
-  return should_handle ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH;
-}
-#endif  // GTEST_HAS_SEH
-
-}  // namespace internal
-
-// The c'tor sets this object as the test part result reporter used by
-// Google Test.  The 'result' parameter specifies where to report the
-// results. Intercepts only failures from the current thread.
-ScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter(
-    TestPartResultArray* result)
-    : intercept_mode_(INTERCEPT_ONLY_CURRENT_THREAD),
-      result_(result) {
-  Init();
-}
-
-// The c'tor sets this object as the test part result reporter used by
-// Google Test.  The 'result' parameter specifies where to report the
-// results.
-ScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter(
-    InterceptMode intercept_mode, TestPartResultArray* result)
-    : intercept_mode_(intercept_mode),
-      result_(result) {
-  Init();
-}
-
-void ScopedFakeTestPartResultReporter::Init() {
-  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
-  if (intercept_mode_ == INTERCEPT_ALL_THREADS) {
-    old_reporter_ = impl->GetGlobalTestPartResultReporter();
-    impl->SetGlobalTestPartResultReporter(this);
-  } else {
-    old_reporter_ = impl->GetTestPartResultReporterForCurrentThread();
-    impl->SetTestPartResultReporterForCurrentThread(this);
-  }
-}
-
-// The d'tor restores the test part result reporter used by Google Test
-// before.
-ScopedFakeTestPartResultReporter::~ScopedFakeTestPartResultReporter() {
-  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
-  if (intercept_mode_ == INTERCEPT_ALL_THREADS) {
-    impl->SetGlobalTestPartResultReporter(old_reporter_);
-  } else {
-    impl->SetTestPartResultReporterForCurrentThread(old_reporter_);
-  }
-}
-
-// Increments the test part result count and remembers the result.
-// This method is from the TestPartResultReporterInterface interface.
-void ScopedFakeTestPartResultReporter::ReportTestPartResult(
-    const TestPartResult& result) {
-  result_->Append(result);
-}
-
-namespace internal {
-
-// Returns the type ID of ::testing::Test.  We should always call this
-// instead of GetTypeId< ::testing::Test>() to get the type ID of
-// testing::Test.  This is to work around a suspected linker bug when
-// using Google Test as a framework on Mac OS X.  The bug causes
-// GetTypeId< ::testing::Test>() to return different values depending
-// on whether the call is from the Google Test framework itself or
-// from user test code.  GetTestTypeId() is guaranteed to always
-// return the same value, as it always calls GetTypeId<>() from the
-// gtest.cc, which is within the Google Test framework.
-TypeId GetTestTypeId() {
-  return GetTypeId<Test>();
-}
-
-// The value of GetTestTypeId() as seen from within the Google Test
-// library.  This is solely for testing GetTestTypeId().
-extern const TypeId kTestTypeIdInGoogleTest = GetTestTypeId();
-
-// This predicate-formatter checks that 'results' contains a test part
-// failure of the given type and that the failure message contains the
-// given substring.
-AssertionResult HasOneFailure(const char* /* results_expr */,
-                              const char* /* type_expr */,
-                              const char* /* substr_expr */,
-                              const TestPartResultArray& results,
-                              TestPartResult::Type type,
-                              const string& substr) {
-  const String expected(type == TestPartResult::kFatalFailure ?
-                        "1 fatal failure" :
-                        "1 non-fatal failure");
-  Message msg;
-  if (results.size() != 1) {
-    msg << "Expected: " << expected << "\n"
-        << "  Actual: " << results.size() << " failures";
-    for (int i = 0; i < results.size(); i++) {
-      msg << "\n" << results.GetTestPartResult(i);
-    }
-    return AssertionFailure() << msg;
-  }
-
-  const TestPartResult& r = results.GetTestPartResult(0);
-  if (r.type() != type) {
-    return AssertionFailure() << "Expected: " << expected << "\n"
-                              << "  Actual:\n"
-                              << r;
-  }
-
-  if (strstr(r.message(), substr.c_str()) == NULL) {
-    return AssertionFailure() << "Expected: " << expected << " containing \""
-                              << substr << "\"\n"
-                              << "  Actual:\n"
-                              << r;
-  }
-
-  return AssertionSuccess();
-}
-
-// The constructor of SingleFailureChecker remembers where to look up
-// test part results, what type of failure we expect, and what
-// substring the failure message should contain.
-SingleFailureChecker:: SingleFailureChecker(
-    const TestPartResultArray* results,
-    TestPartResult::Type type,
-    const string& substr)
-    : results_(results),
-      type_(type),
-      substr_(substr) {}
-
-// The destructor of SingleFailureChecker verifies that the given
-// TestPartResultArray contains exactly one failure that has the given
-// type and contains the given substring.  If that's not the case, a
-// non-fatal failure will be generated.
-SingleFailureChecker::~SingleFailureChecker() {
-  EXPECT_PRED_FORMAT3(HasOneFailure, *results_, type_, substr_);
-}
-
-DefaultGlobalTestPartResultReporter::DefaultGlobalTestPartResultReporter(
-    UnitTestImpl* unit_test) : unit_test_(unit_test) {}
-
-void DefaultGlobalTestPartResultReporter::ReportTestPartResult(
-    const TestPartResult& result) {
-  unit_test_->current_test_result()->AddTestPartResult(result);
-  unit_test_->listeners()->repeater()->OnTestPartResult(result);
-}
-
-DefaultPerThreadTestPartResultReporter::DefaultPerThreadTestPartResultReporter(
-    UnitTestImpl* unit_test) : unit_test_(unit_test) {}
-
-void DefaultPerThreadTestPartResultReporter::ReportTestPartResult(
-    const TestPartResult& result) {
-  unit_test_->GetGlobalTestPartResultReporter()->ReportTestPartResult(result);
-}
-
-// Returns the global test part result reporter.
-TestPartResultReporterInterface*
-UnitTestImpl::GetGlobalTestPartResultReporter() {
-  internal::MutexLock lock(&global_test_part_result_reporter_mutex_);
-  return global_test_part_result_repoter_;
-}
-
-// Sets the global test part result reporter.
-void UnitTestImpl::SetGlobalTestPartResultReporter(
-    TestPartResultReporterInterface* reporter) {
-  internal::MutexLock lock(&global_test_part_result_reporter_mutex_);
-  global_test_part_result_repoter_ = reporter;
-}
-
-// Returns the test part result reporter for the current thread.
-TestPartResultReporterInterface*
-UnitTestImpl::GetTestPartResultReporterForCurrentThread() {
-  return per_thread_test_part_result_reporter_.get();
-}
-
-// Sets the test part result reporter for the current thread.
-void UnitTestImpl::SetTestPartResultReporterForCurrentThread(
-    TestPartResultReporterInterface* reporter) {
-  per_thread_test_part_result_reporter_.set(reporter);
-}
-
-// Gets the number of successful test cases.
-int UnitTestImpl::successful_test_case_count() const {
-  return CountIf(test_cases_, TestCasePassed);
-}
-
-// Gets the number of failed test cases.
-int UnitTestImpl::failed_test_case_count() const {
-  return CountIf(test_cases_, TestCaseFailed);
-}
-
-// Gets the number of all test cases.
-int UnitTestImpl::total_test_case_count() const {
-  return static_cast<int>(test_cases_.size());
-}
-
-// Gets the number of all test cases that contain at least one test
-// that should run.
-int UnitTestImpl::test_case_to_run_count() const {
-  return CountIf(test_cases_, ShouldRunTestCase);
-}
-
-// Gets the number of successful tests.
-int UnitTestImpl::successful_test_count() const {
-  return SumOverTestCaseList(test_cases_, &TestCase::successful_test_count);
-}
-
-// Gets the number of failed tests.
-int UnitTestImpl::failed_test_count() const {
-  return SumOverTestCaseList(test_cases_, &TestCase::failed_test_count);
-}
-
-// Gets the number of disabled tests.
-int UnitTestImpl::disabled_test_count() const {
-  return SumOverTestCaseList(test_cases_, &TestCase::disabled_test_count);
-}
-
-// Gets the number of all tests.
-int UnitTestImpl::total_test_count() const {
-  return SumOverTestCaseList(test_cases_, &TestCase::total_test_count);
-}
-
-// Gets the number of tests that should run.
-int UnitTestImpl::test_to_run_count() const {
-  return SumOverTestCaseList(test_cases_, &TestCase::test_to_run_count);
-}
-
-// Returns the current OS stack trace as a String.
-//
-// The maximum number of stack frames to be included is specified by
-// the gtest_stack_trace_depth flag.  The skip_count parameter
-// specifies the number of top frames to be skipped, which doesn't
-// count against the number of frames to be included.
-//
-// For example, if Foo() calls Bar(), which in turn calls
-// CurrentOsStackTraceExceptTop(1), Foo() will be included in the
-// trace but Bar() and CurrentOsStackTraceExceptTop() won't.
-String UnitTestImpl::CurrentOsStackTraceExceptTop(int skip_count) {
-  (void)skip_count;
-  return String("");
-}
-
-// Returns the current time in milliseconds.
-TimeInMillis GetTimeInMillis() {
-#if GTEST_OS_WINDOWS_MOBILE || defined(__BORLANDC__)
-  // Difference between 1970-01-01 and 1601-01-01 in milliseconds.
-  // http://analogous.blogspot.com/2005/04/epoch.html
-  const TimeInMillis kJavaEpochToWinFileTimeDelta =
-    static_cast<TimeInMillis>(116444736UL) * 100000UL;
-  const DWORD kTenthMicrosInMilliSecond = 10000;
-
-  SYSTEMTIME now_systime;
-  FILETIME now_filetime;
-  ULARGE_INTEGER now_int64;
-  // TODO(kenton at google.com): Shouldn't this just use
-  //   GetSystemTimeAsFileTime()?
-  GetSystemTime(&now_systime);
-  if (SystemTimeToFileTime(&now_systime, &now_filetime)) {
-    now_int64.LowPart = now_filetime.dwLowDateTime;
-    now_int64.HighPart = now_filetime.dwHighDateTime;
-    now_int64.QuadPart = (now_int64.QuadPart / kTenthMicrosInMilliSecond) -
-      kJavaEpochToWinFileTimeDelta;
-    return now_int64.QuadPart;
-  }
-  return 0;
-#elif GTEST_OS_WINDOWS && !GTEST_HAS_GETTIMEOFDAY_
-  __timeb64 now;
-
-# ifdef _MSC_VER
-
-  // MSVC 8 deprecates _ftime64(), so we want to suppress warning 4996
-  // (deprecated function) there.
-  // TODO(kenton at google.com): Use GetTickCount()?  Or use
-  //   SystemTimeToFileTime()
-#  pragma warning(push)          // Saves the current warning state.
-#  pragma warning(disable:4996)  // Temporarily disables warning 4996.
-  _ftime64(&now);
-#  pragma warning(pop)           // Restores the warning state.
-# else
-
-  _ftime64(&now);
-
-# endif  // _MSC_VER
-
-  return static_cast<TimeInMillis>(now.time) * 1000 + now.millitm;
-#elif GTEST_HAS_GETTIMEOFDAY_
-  struct timeval now;
-  gettimeofday(&now, NULL);
-  return static_cast<TimeInMillis>(now.tv_sec) * 1000 + now.tv_usec / 1000;
-#else
-# error "Don't know how to get the current time on your system."
-#endif
-}
-
-// Utilities
-
-// class String
-
-// Returns the input enclosed in double quotes if it's not NULL;
-// otherwise returns "(null)".  For example, "\"Hello\"" is returned
-// for input "Hello".
-//
-// This is useful for printing a C string in the syntax of a literal.
-//
-// Known issue: escape sequences are not handled yet.
-String String::ShowCStringQuoted(const char* c_str) {
-  return c_str ? String::Format("\"%s\"", c_str) : String("(null)");
-}
-
-// Copies at most length characters from str into a newly-allocated
-// piece of memory of size length+1.  The memory is allocated with new[].
-// A terminating null byte is written to the memory, and a pointer to it
-// is returned.  If str is NULL, NULL is returned.
-static char* CloneString(const char* str, size_t length) {
-  if (str == NULL) {
-    return NULL;
-  } else {
-    char* const clone = new char[length + 1];
-    posix::StrNCpy(clone, str, length);
-    clone[length] = '\0';
-    return clone;
-  }
-}
-
-// Clones a 0-terminated C string, allocating memory using new.  The
-// caller is responsible for deleting[] the return value.  Returns the
-// cloned string, or NULL if the input is NULL.
-const char * String::CloneCString(const char* c_str) {
-  return (c_str == NULL) ?
-                    NULL : CloneString(c_str, strlen(c_str));
-}
-
-#if GTEST_OS_WINDOWS_MOBILE
-// Creates a UTF-16 wide string from the given ANSI string, allocating
-// memory using new. The caller is responsible for deleting the return
-// value using delete[]. Returns the wide string, or NULL if the
-// input is NULL.
-LPCWSTR String::AnsiToUtf16(const char* ansi) {
-  if (!ansi) return NULL;
-  const int length = strlen(ansi);
-  const int unicode_length =
-      MultiByteToWideChar(CP_ACP, 0, ansi, length,
-                          NULL, 0);
-  WCHAR* unicode = new WCHAR[unicode_length + 1];
-  MultiByteToWideChar(CP_ACP, 0, ansi, length,
-                      unicode, unicode_length);
-  unicode[unicode_length] = 0;
-  return unicode;
-}
-
-// Creates an ANSI string from the given wide string, allocating
-// memory using new. The caller is responsible for deleting the return
-// value using delete[]. Returns the ANSI string, or NULL if the
-// input is NULL.
-const char* String::Utf16ToAnsi(LPCWSTR utf16_str)  {
-  if (!utf16_str) return NULL;
-  const int ansi_length =
-      WideCharToMultiByte(CP_ACP, 0, utf16_str, -1,
-                          NULL, 0, NULL, NULL);
-  char* ansi = new char[ansi_length + 1];
-  WideCharToMultiByte(CP_ACP, 0, utf16_str, -1,
-                      ansi, ansi_length, NULL, NULL);
-  ansi[ansi_length] = 0;
-  return ansi;
-}
-
-#endif  // GTEST_OS_WINDOWS_MOBILE
-
-// Compares two C strings.  Returns true iff they have the same content.
-//
-// Unlike strcmp(), this function can handle NULL argument(s).  A NULL
-// C string is considered different to any non-NULL C string,
-// including the empty string.
-bool String::CStringEquals(const char * lhs, const char * rhs) {
-  if ( lhs == NULL ) return rhs == NULL;
-
-  if ( rhs == NULL ) return false;
-
-  return strcmp(lhs, rhs) == 0;
-}
-
-#if GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING
-
-// Converts an array of wide chars to a narrow string using the UTF-8
-// encoding, and streams the result to the given Message object.
-static void StreamWideCharsToMessage(const wchar_t* wstr, size_t length,
-                                     Message* msg) {
-  // TODO(wan): consider allowing a testing::String object to
-  // contain '\0'.  This will make it behave more like std::string,
-  // and will allow ToUtf8String() to return the correct encoding
-  // for '\0' s.t. we can get rid of the conditional here (and in
-  // several other places).
-  for (size_t i = 0; i != length; ) {  // NOLINT
-    if (wstr[i] != L'\0') {
-      *msg << WideStringToUtf8(wstr + i, static_cast<int>(length - i));
-      while (i != length && wstr[i] != L'\0')
-        i++;
-    } else {
-      *msg << '\0';
-      i++;
-    }
-  }
-}
-
-#endif  // GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING
-
-}  // namespace internal
-
-#if GTEST_HAS_STD_WSTRING
-// Converts the given wide string to a narrow string using the UTF-8
-// encoding, and streams the result to this Message object.
-Message& Message::operator <<(const ::std::wstring& wstr) {
-  internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), this);
-  return *this;
-}
-#endif  // GTEST_HAS_STD_WSTRING
-
-#if GTEST_HAS_GLOBAL_WSTRING
-// Converts the given wide string to a narrow string using the UTF-8
-// encoding, and streams the result to this Message object.
-Message& Message::operator <<(const ::wstring& wstr) {
-  internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), this);
-  return *this;
-}
-#endif  // GTEST_HAS_GLOBAL_WSTRING
-
-// AssertionResult constructors.
-// Used in EXPECT_TRUE/FALSE(assertion_result).
-AssertionResult::AssertionResult(const AssertionResult& other)
-    : success_(other.success_),
-      message_(other.message_.get() != NULL ?
-               new ::std::string(*other.message_) :
-               static_cast< ::std::string*>(NULL)) {
-}
-
-// Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
-AssertionResult AssertionResult::operator!() const {
-  AssertionResult negation(!success_);
-  if (message_.get() != NULL)
-    negation << *message_;
-  return negation;
-}
-
-// Makes a successful assertion result.
-AssertionResult AssertionSuccess() {
-  return AssertionResult(true);
-}
-
-// Makes a failed assertion result.
-AssertionResult AssertionFailure() {
-  return AssertionResult(false);
-}
-
-// Makes a failed assertion result with the given failure message.
-// Deprecated; use AssertionFailure() << message.
-AssertionResult AssertionFailure(const Message& message) {
-  return AssertionFailure() << message;
-}
-
-namespace internal {
-
-// Constructs and returns the message for an equality assertion
-// (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure.
-//
-// The first four parameters are the expressions used in the assertion
-// and their values, as strings.  For example, for ASSERT_EQ(foo, bar)
-// where foo is 5 and bar is 6, we have:
-//
-//   expected_expression: "foo"
-//   actual_expression:   "bar"
-//   expected_value:      "5"
-//   actual_value:        "6"
-//
-// The ignoring_case parameter is true iff the assertion is a
-// *_STRCASEEQ*.  When it's true, the string " (ignoring case)" will
-// be inserted into the message.
-AssertionResult EqFailure(const char* expected_expression,
-                          const char* actual_expression,
-                          const String& expected_value,
-                          const String& actual_value,
-                          bool ignoring_case) {
-  Message msg;
-  msg << "Value of: " << actual_expression;
-  if (actual_value != actual_expression) {
-    msg << "\n  Actual: " << actual_value;
-  }
-
-  msg << "\nExpected: " << expected_expression;
-  if (ignoring_case) {
-    msg << " (ignoring case)";
-  }
-  if (expected_value != expected_expression) {
-    msg << "\nWhich is: " << expected_value;
-  }
-
-  return AssertionFailure() << msg;
-}
-
-// Constructs a failure message for Boolean assertions such as EXPECT_TRUE.
-String GetBoolAssertionFailureMessage(const AssertionResult& assertion_result,
-                                      const char* expression_text,
-                                      const char* actual_predicate_value,
-                                      const char* expected_predicate_value) {
-  const char* actual_message = assertion_result.message();
-  Message msg;
-  msg << "Value of: " << expression_text
-      << "\n  Actual: " << actual_predicate_value;
-  if (actual_message[0] != '\0')
-    msg << " (" << actual_message << ")";
-  msg << "\nExpected: " << expected_predicate_value;
-  return msg.GetString();
-}
-
-// Helper function for implementing ASSERT_NEAR.
-AssertionResult DoubleNearPredFormat(const char* expr1,
-                                     const char* expr2,
-                                     const char* abs_error_expr,
-                                     double val1,
-                                     double val2,
-                                     double abs_error) {
-  const double diff = fabs(val1 - val2);
-  if (diff <= abs_error) return AssertionSuccess();
-
-  // TODO(wan): do not print the value of an expression if it's
-  // already a literal.
-  return AssertionFailure()
-      << "The difference between " << expr1 << " and " << expr2
-      << " is " << diff << ", which exceeds " << abs_error_expr << ", where\n"
-      << expr1 << " evaluates to " << val1 << ",\n"
-      << expr2 << " evaluates to " << val2 << ", and\n"
-      << abs_error_expr << " evaluates to " << abs_error << ".";
-}
-
-
-// Helper template for implementing FloatLE() and DoubleLE().
-template <typename RawType>
-AssertionResult FloatingPointLE(const char* expr1,
-                                const char* expr2,
-                                RawType val1,
-                                RawType val2) {
-  // Returns success if val1 is less than val2,
-  if (val1 < val2) {
-    return AssertionSuccess();
-  }
-
-  // or if val1 is almost equal to val2.
-  const FloatingPoint<RawType> lhs(val1), rhs(val2);
-  if (lhs.AlmostEquals(rhs)) {
-    return AssertionSuccess();
-  }
-
-  // Note that the above two checks will both fail if either val1 or
-  // val2 is NaN, as the IEEE floating-point standard requires that
-  // any predicate involving a NaN must return false.
-
-  ::std::stringstream val1_ss;
-  val1_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
-          << val1;
-
-  ::std::stringstream val2_ss;
-  val2_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
-          << val2;
-
-  return AssertionFailure()
-      << "Expected: (" << expr1 << ") <= (" << expr2 << ")\n"
-      << "  Actual: " << StringStreamToString(&val1_ss) << " vs "
-      << StringStreamToString(&val2_ss);
-}
-
-}  // namespace internal
-
-// Asserts that val1 is less than, or almost equal to, val2.  Fails
-// otherwise.  In particular, it fails if either val1 or val2 is NaN.
-AssertionResult FloatLE(const char* expr1, const char* expr2,
-                        float val1, float val2) {
-  return internal::FloatingPointLE<float>(expr1, expr2, val1, val2);
-}
-
-// Asserts that val1 is less than, or almost equal to, val2.  Fails
-// otherwise.  In particular, it fails if either val1 or val2 is NaN.
-AssertionResult DoubleLE(const char* expr1, const char* expr2,
-                         double val1, double val2) {
-  return internal::FloatingPointLE<double>(expr1, expr2, val1, val2);
-}
-
-namespace internal {
-
-// The helper function for {ASSERT|EXPECT}_EQ with int or enum
-// arguments.
-AssertionResult CmpHelperEQ(const char* expected_expression,
-                            const char* actual_expression,
-                            BiggestInt expected,
-                            BiggestInt actual) {
-  if (expected == actual) {
-    return AssertionSuccess();
-  }
-
-  return EqFailure(expected_expression,
-                   actual_expression,
-                   FormatForComparisonFailureMessage(expected, actual),
-                   FormatForComparisonFailureMessage(actual, expected),
-                   false);
-}
-
-// A macro for implementing the helper functions needed to implement
-// ASSERT_?? and EXPECT_?? with integer or enum arguments.  It is here
-// just to avoid copy-and-paste of similar code.
-#define GTEST_IMPL_CMP_HELPER_(op_name, op)\
-AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
-                                   BiggestInt val1, BiggestInt val2) {\
-  if (val1 op val2) {\
-    return AssertionSuccess();\
-  } else {\
-    return AssertionFailure() \
-        << "Expected: (" << expr1 << ") " #op " (" << expr2\
-        << "), actual: " << FormatForComparisonFailureMessage(val1, val2)\
-        << " vs " << FormatForComparisonFailureMessage(val2, val1);\
-  }\
-}
-
-// Implements the helper function for {ASSERT|EXPECT}_NE with int or
-// enum arguments.
-GTEST_IMPL_CMP_HELPER_(NE, !=)
-// Implements the helper function for {ASSERT|EXPECT}_LE with int or
-// enum arguments.
-GTEST_IMPL_CMP_HELPER_(LE, <=)
-// Implements the helper function for {ASSERT|EXPECT}_LT with int or
-// enum arguments.
-GTEST_IMPL_CMP_HELPER_(LT, < )
-// Implements the helper function for {ASSERT|EXPECT}_GE with int or
-// enum arguments.
-GTEST_IMPL_CMP_HELPER_(GE, >=)
-// Implements the helper function for {ASSERT|EXPECT}_GT with int or
-// enum arguments.
-GTEST_IMPL_CMP_HELPER_(GT, > )
-
-#undef GTEST_IMPL_CMP_HELPER_
-
-// The helper function for {ASSERT|EXPECT}_STREQ.
-AssertionResult CmpHelperSTREQ(const char* expected_expression,
-                               const char* actual_expression,
-                               const char* expected,
-                               const char* actual) {
-  if (String::CStringEquals(expected, actual)) {
-    return AssertionSuccess();
-  }
-
-  return EqFailure(expected_expression,
-                   actual_expression,
-                   String::ShowCStringQuoted(expected),
-                   String::ShowCStringQuoted(actual),
-                   false);
-}
-
-// The helper function for {ASSERT|EXPECT}_STRCASEEQ.
-AssertionResult CmpHelperSTRCASEEQ(const char* expected_expression,
-                                   const char* actual_expression,
-                                   const char* expected,
-                                   const char* actual) {
-  if (String::CaseInsensitiveCStringEquals(expected, actual)) {
-    return AssertionSuccess();
-  }
-
-  return EqFailure(expected_expression,
-                   actual_expression,
-                   String::ShowCStringQuoted(expected),
-                   String::ShowCStringQuoted(actual),
-                   true);
-}
-
-// The helper function for {ASSERT|EXPECT}_STRNE.
-AssertionResult CmpHelperSTRNE(const char* s1_expression,
-                               const char* s2_expression,
-                               const char* s1,
-                               const char* s2) {
-  if (!String::CStringEquals(s1, s2)) {
-    return AssertionSuccess();
-  } else {
-    return AssertionFailure() << "Expected: (" << s1_expression << ") != ("
-                              << s2_expression << "), actual: \""
-                              << s1 << "\" vs \"" << s2 << "\"";
-  }
-}
-
-// The helper function for {ASSERT|EXPECT}_STRCASENE.
-AssertionResult CmpHelperSTRCASENE(const char* s1_expression,
-                                   const char* s2_expression,
-                                   const char* s1,
-                                   const char* s2) {
-  if (!String::CaseInsensitiveCStringEquals(s1, s2)) {
-    return AssertionSuccess();
-  } else {
-    return AssertionFailure()
-        << "Expected: (" << s1_expression << ") != ("
-        << s2_expression << ") (ignoring case), actual: \""
-        << s1 << "\" vs \"" << s2 << "\"";
-  }
-}
-
-}  // namespace internal
-
-namespace {
-
-// Helper functions for implementing IsSubString() and IsNotSubstring().
-
-// This group of overloaded functions return true iff needle is a
-// substring of haystack.  NULL is considered a substring of itself
-// only.
-
-bool IsSubstringPred(const char* needle, const char* haystack) {
-  if (needle == NULL || haystack == NULL)
-    return needle == haystack;
-
-  return strstr(haystack, needle) != NULL;
-}
-
-bool IsSubstringPred(const wchar_t* needle, const wchar_t* haystack) {
-  if (needle == NULL || haystack == NULL)
-    return needle == haystack;
-
-  return wcsstr(haystack, needle) != NULL;
-}
-
-// StringType here can be either ::std::string or ::std::wstring.
-template <typename StringType>
-bool IsSubstringPred(const StringType& needle,
-                     const StringType& haystack) {
-  return haystack.find(needle) != StringType::npos;
-}
-
-// This function implements either IsSubstring() or IsNotSubstring(),
-// depending on the value of the expected_to_be_substring parameter.
-// StringType here can be const char*, const wchar_t*, ::std::string,
-// or ::std::wstring.
-template <typename StringType>
-AssertionResult IsSubstringImpl(
-    bool expected_to_be_substring,
-    const char* needle_expr, const char* haystack_expr,
-    const StringType& needle, const StringType& haystack) {
-  if (IsSubstringPred(needle, haystack) == expected_to_be_substring)
-    return AssertionSuccess();
-
-  const bool is_wide_string = sizeof(needle[0]) > 1;
-  const char* const begin_string_quote = is_wide_string ? "L\"" : "\"";
-  return AssertionFailure()
-      << "Value of: " << needle_expr << "\n"
-      << "  Actual: " << begin_string_quote << needle << "\"\n"
-      << "Expected: " << (expected_to_be_substring ? "" : "not ")
-      << "a substring of " << haystack_expr << "\n"
-      << "Which is: " << begin_string_quote << haystack << "\"";
-}
-
-}  // namespace
-
-// IsSubstring() and IsNotSubstring() check whether needle is a
-// substring of haystack (NULL is considered a substring of itself
-// only), and return an appropriate error message when they fail.
-
-AssertionResult IsSubstring(
-    const char* needle_expr, const char* haystack_expr,
-    const char* needle, const char* haystack) {
-  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);
-}
-
-AssertionResult IsSubstring(
-    const char* needle_expr, const char* haystack_expr,
-    const wchar_t* needle, const wchar_t* haystack) {
-  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);
-}
-
-AssertionResult IsNotSubstring(
-    const char* needle_expr, const char* haystack_expr,
-    const char* needle, const char* haystack) {
-  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);
-}
-
-AssertionResult IsNotSubstring(
-    const char* needle_expr, const char* haystack_expr,
-    const wchar_t* needle, const wchar_t* haystack) {
-  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);
-}
-
-AssertionResult IsSubstring(
-    const char* needle_expr, const char* haystack_expr,
-    const ::std::string& needle, const ::std::string& haystack) {
-  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);
-}
-
-AssertionResult IsNotSubstring(
-    const char* needle_expr, const char* haystack_expr,
-    const ::std::string& needle, const ::std::string& haystack) {
-  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);
-}
-
-#if GTEST_HAS_STD_WSTRING
-AssertionResult IsSubstring(
-    const char* needle_expr, const char* haystack_expr,
-    const ::std::wstring& needle, const ::std::wstring& haystack) {
-  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);
-}
-
-AssertionResult IsNotSubstring(
-    const char* needle_expr, const char* haystack_expr,
-    const ::std::wstring& needle, const ::std::wstring& haystack) {
-  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);
-}
-#endif  // GTEST_HAS_STD_WSTRING
-
-namespace internal {
-
-#if GTEST_OS_WINDOWS
-
-namespace {
-
-// Helper function for IsHRESULT{SuccessFailure} predicates
-AssertionResult HRESULTFailureHelper(const char* expr,
-                                     const char* expected,
-                                     long hr) {  // NOLINT
-# if GTEST_OS_WINDOWS_MOBILE
-
-  // Windows CE doesn't support FormatMessage.
-  const char error_text[] = "";
-
-# else
-
-  // Looks up the human-readable system message for the HRESULT code
-  // and since we're not passing any params to FormatMessage, we don't
-  // want inserts expanded.
-  const DWORD kFlags = FORMAT_MESSAGE_FROM_SYSTEM |
-                       FORMAT_MESSAGE_IGNORE_INSERTS;
-  const DWORD kBufSize = 4096;  // String::Format can't exceed this length.
-  // Gets the system's human readable message string for this HRESULT.
-  char error_text[kBufSize] = { '\0' };
-  DWORD message_length = ::FormatMessageA(kFlags,
-                                          0,  // no source, we're asking system
-                                          hr,  // the error
-                                          0,  // no line width restrictions
-                                          error_text,  // output buffer
-                                          kBufSize,  // buf size
-                                          NULL);  // no arguments for inserts
-  // Trims tailing white space (FormatMessage leaves a trailing cr-lf)
-  for (; message_length && IsSpace(error_text[message_length - 1]);
-          --message_length) {
-    error_text[message_length - 1] = '\0';
-  }
-
-# endif  // GTEST_OS_WINDOWS_MOBILE
-
-  const String error_hex(String::Format("0x%08X ", hr));
-  return ::testing::AssertionFailure()
-      << "Expected: " << expr << " " << expected << ".\n"
-      << "  Actual: " << error_hex << error_text << "\n";
-}
-
-}  // namespace
-
-AssertionResult IsHRESULTSuccess(const char* expr, long hr) {  // NOLINT
-  if (SUCCEEDED(hr)) {
-    return AssertionSuccess();
-  }
-  return HRESULTFailureHelper(expr, "succeeds", hr);
-}
-
-AssertionResult IsHRESULTFailure(const char* expr, long hr) {  // NOLINT
-  if (FAILED(hr)) {
-    return AssertionSuccess();
-  }
-  return HRESULTFailureHelper(expr, "fails", hr);
-}
-
-#endif  // GTEST_OS_WINDOWS
-
-// Utility functions for encoding Unicode text (wide strings) in
-// UTF-8.
-
-// A Unicode code-point can have upto 21 bits, and is encoded in UTF-8
-// like this:
-//
-// Code-point length   Encoding
-//   0 -  7 bits       0xxxxxxx
-//   8 - 11 bits       110xxxxx 10xxxxxx
-//  12 - 16 bits       1110xxxx 10xxxxxx 10xxxxxx
-//  17 - 21 bits       11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
-
-// The maximum code-point a one-byte UTF-8 sequence can represent.
-const UInt32 kMaxCodePoint1 = (static_cast<UInt32>(1) <<  7) - 1;
-
-// The maximum code-point a two-byte UTF-8 sequence can represent.
-const UInt32 kMaxCodePoint2 = (static_cast<UInt32>(1) << (5 + 6)) - 1;
-
-// The maximum code-point a three-byte UTF-8 sequence can represent.
-const UInt32 kMaxCodePoint3 = (static_cast<UInt32>(1) << (4 + 2*6)) - 1;
-
-// The maximum code-point a four-byte UTF-8 sequence can represent.
-const UInt32 kMaxCodePoint4 = (static_cast<UInt32>(1) << (3 + 3*6)) - 1;
-
-// Chops off the n lowest bits from a bit pattern.  Returns the n
-// lowest bits.  As a side effect, the original bit pattern will be
-// shifted to the right by n bits.
-inline UInt32 ChopLowBits(UInt32* bits, int n) {
-  const UInt32 low_bits = *bits & ((static_cast<UInt32>(1) << n) - 1);
-  *bits >>= n;
-  return low_bits;
-}
-
-// Converts a Unicode code point to a narrow string in UTF-8 encoding.
-// code_point parameter is of type UInt32 because wchar_t may not be
-// wide enough to contain a code point.
-// The output buffer str must containt at least 32 characters.
-// The function returns the address of the output buffer.
-// If the code_point is not a valid Unicode code point
-// (i.e. outside of Unicode range U+0 to U+10FFFF) it will be output
-// as '(Invalid Unicode 0xXXXXXXXX)'.
-char* CodePointToUtf8(UInt32 code_point, char* str) {
-  if (code_point <= kMaxCodePoint1) {
-    str[1] = '\0';
-    str[0] = static_cast<char>(code_point);                          // 0xxxxxxx
-  } else if (code_point <= kMaxCodePoint2) {
-    str[2] = '\0';
-    str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx
-    str[0] = static_cast<char>(0xC0 | code_point);                   // 110xxxxx
-  } else if (code_point <= kMaxCodePoint3) {
-    str[3] = '\0';
-    str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx
-    str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx
-    str[0] = static_cast<char>(0xE0 | code_point);                   // 1110xxxx
-  } else if (code_point <= kMaxCodePoint4) {
-    str[4] = '\0';
-    str[3] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx
-    str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx
-    str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx
-    str[0] = static_cast<char>(0xF0 | code_point);                   // 11110xxx
-  } else {
-    // The longest string String::Format can produce when invoked
-    // with these parameters is 28 character long (not including
-    // the terminating nul character). We are asking for 32 character
-    // buffer just in case. This is also enough for strncpy to
-    // null-terminate the destination string.
-    posix::StrNCpy(
-        str, String::Format("(Invalid Unicode 0x%X)", code_point).c_str(), 32);
-    str[31] = '\0';  // Makes sure no change in the format to strncpy leaves
-                     // the result unterminated.
-  }
-  return str;
-}
-
-// The following two functions only make sense if the the system
-// uses UTF-16 for wide string encoding. All supported systems
-// with 16 bit wchar_t (Windows, Cygwin, Symbian OS) do use UTF-16.
-
-// Determines if the arguments constitute UTF-16 surrogate pair
-// and thus should be combined into a single Unicode code point
-// using CreateCodePointFromUtf16SurrogatePair.
-inline bool IsUtf16SurrogatePair(wchar_t first, wchar_t second) {
-  return sizeof(wchar_t) == 2 &&
-      (first & 0xFC00) == 0xD800 && (second & 0xFC00) == 0xDC00;
-}
-
-// Creates a Unicode code point from UTF16 surrogate pair.
-inline UInt32 CreateCodePointFromUtf16SurrogatePair(wchar_t first,
-                                                    wchar_t second) {
-  const UInt32 mask = (1 << 10) - 1;
-  return (sizeof(wchar_t) == 2) ?
-      (((first & mask) << 10) | (second & mask)) + 0x10000 :
-      // This function should not be called when the condition is
-      // false, but we provide a sensible default in case it is.
-      static_cast<UInt32>(first);
-}
-
-// Converts a wide string to a narrow string in UTF-8 encoding.
-// The wide string is assumed to have the following encoding:
-//   UTF-16 if sizeof(wchar_t) == 2 (on Windows, Cygwin, Symbian OS)
-//   UTF-32 if sizeof(wchar_t) == 4 (on Linux)
-// Parameter str points to a null-terminated wide string.
-// Parameter num_chars may additionally limit the number
-// of wchar_t characters processed. -1 is used when the entire string
-// should be processed.
-// If the string contains code points that are not valid Unicode code points
-// (i.e. outside of Unicode range U+0 to U+10FFFF) they will be output
-// as '(Invalid Unicode 0xXXXXXXXX)'. If the string is in UTF16 encoding
-// and contains invalid UTF-16 surrogate pairs, values in those pairs
-// will be encoded as individual Unicode characters from Basic Normal Plane.
-String WideStringToUtf8(const wchar_t* str, int num_chars) {
-  if (num_chars == -1)
-    num_chars = static_cast<int>(wcslen(str));
-
-  ::std::stringstream stream;
-  for (int i = 0; i < num_chars; ++i) {
-    UInt32 unicode_code_point;
-
-    if (str[i] == L'\0') {
-      break;
-    } else if (i + 1 < num_chars && IsUtf16SurrogatePair(str[i], str[i + 1])) {
-      unicode_code_point = CreateCodePointFromUtf16SurrogatePair(str[i],
-                                                                 str[i + 1]);
-      i++;
-    } else {
-      unicode_code_point = static_cast<UInt32>(str[i]);
-    }
-
-    char buffer[32];  // CodePointToUtf8 requires a buffer this big.
-    stream << CodePointToUtf8(unicode_code_point, buffer);
-  }
-  return StringStreamToString(&stream);
-}
-
-// Converts a wide C string to a String using the UTF-8 encoding.
-// NULL will be converted to "(null)".
-String String::ShowWideCString(const wchar_t * wide_c_str) {
-  if (wide_c_str == NULL) return String("(null)");
-
-  return String(internal::WideStringToUtf8(wide_c_str, -1).c_str());
-}
-
-// Similar to ShowWideCString(), except that this function encloses
-// the converted string in double quotes.
-String String::ShowWideCStringQuoted(const wchar_t* wide_c_str) {
-  if (wide_c_str == NULL) return String("(null)");
-
-  return String::Format("L\"%s\"",
-                        String::ShowWideCString(wide_c_str).c_str());
-}
-
-// Compares two wide C strings.  Returns true iff they have the same
-// content.
-//
-// Unlike wcscmp(), this function can handle NULL argument(s).  A NULL
-// C string is considered different to any non-NULL C string,
-// including the empty string.
-bool String::WideCStringEquals(const wchar_t * lhs, const wchar_t * rhs) {
-  if (lhs == NULL) return rhs == NULL;
-
-  if (rhs == NULL) return false;
-
-  return wcscmp(lhs, rhs) == 0;
-}
-
-// Helper function for *_STREQ on wide strings.
-AssertionResult CmpHelperSTREQ(const char* expected_expression,
-                               const char* actual_expression,
-                               const wchar_t* expected,
-                               const wchar_t* actual) {
-  if (String::WideCStringEquals(expected, actual)) {
-    return AssertionSuccess();
-  }
-
-  return EqFailure(expected_expression,
-                   actual_expression,
-                   String::ShowWideCStringQuoted(expected),
-                   String::ShowWideCStringQuoted(actual),
-                   false);
-}
-
-// Helper function for *_STRNE on wide strings.
-AssertionResult CmpHelperSTRNE(const char* s1_expression,
-                               const char* s2_expression,
-                               const wchar_t* s1,
-                               const wchar_t* s2) {
-  if (!String::WideCStringEquals(s1, s2)) {
-    return AssertionSuccess();
-  }
-
-  return AssertionFailure() << "Expected: (" << s1_expression << ") != ("
-                            << s2_expression << "), actual: "
-                            << String::ShowWideCStringQuoted(s1)
-                            << " vs " << String::ShowWideCStringQuoted(s2);
-}
-
-// Compares two C strings, ignoring case.  Returns true iff they have
-// the same content.
-//
-// Unlike strcasecmp(), this function can handle NULL argument(s).  A
-// NULL C string is considered different to any non-NULL C string,
-// including the empty string.
-bool String::CaseInsensitiveCStringEquals(const char * lhs, const char * rhs) {
-  if (lhs == NULL)
-    return rhs == NULL;
-  if (rhs == NULL)
-    return false;
-  return posix::StrCaseCmp(lhs, rhs) == 0;
-}
-
-  // Compares two wide C strings, ignoring case.  Returns true iff they
-  // have the same content.
-  //
-  // Unlike wcscasecmp(), this function can handle NULL argument(s).
-  // A NULL C string is considered different to any non-NULL wide C string,
-  // including the empty string.
-  // NB: The implementations on different platforms slightly differ.
-  // On windows, this method uses _wcsicmp which compares according to LC_CTYPE
-  // environment variable. On GNU platform this method uses wcscasecmp
-  // which compares according to LC_CTYPE category of the current locale.
-  // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the
-  // current locale.
-bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
-                                              const wchar_t* rhs) {
-  if (lhs == NULL) return rhs == NULL;
-
-  if (rhs == NULL) return false;
-
-#if GTEST_OS_WINDOWS
-  return _wcsicmp(lhs, rhs) == 0;
-#elif GTEST_OS_LINUX && !GTEST_OS_LINUX_ANDROID
-  return wcscasecmp(lhs, rhs) == 0;
-#else
-  // Android, Mac OS X and Cygwin don't define wcscasecmp.
-  // Other unknown OSes may not define it either.
-  wint_t left, right;
-  do {
-    left = towlower(*lhs++);
-    right = towlower(*rhs++);
-  } while (left && left == right);
-  return left == right;
-#endif  // OS selector
-}
-
-// Compares this with another String.
-// Returns < 0 if this is less than rhs, 0 if this is equal to rhs, or > 0
-// if this is greater than rhs.
-int String::Compare(const String & rhs) const {
-  const char* const lhs_c_str = c_str();
-  const char* const rhs_c_str = rhs.c_str();
-
-  if (lhs_c_str == NULL) {
-    return rhs_c_str == NULL ? 0 : -1;  // NULL < anything except NULL
-  } else if (rhs_c_str == NULL) {
-    return 1;
-  }
-
-  const size_t shorter_str_len =
-      length() <= rhs.length() ? length() : rhs.length();
-  for (size_t i = 0; i != shorter_str_len; i++) {
-    if (lhs_c_str[i] < rhs_c_str[i]) {
-      return -1;
-    } else if (lhs_c_str[i] > rhs_c_str[i]) {
-      return 1;
-    }
-  }
-  return (length() < rhs.length()) ? -1 :
-      (length() > rhs.length()) ? 1 : 0;
-}
-
-// Returns true iff this String ends with the given suffix.  *Any*
-// String is considered to end with a NULL or empty suffix.
-bool String::EndsWith(const char* suffix) const {
-  if (suffix == NULL || CStringEquals(suffix, "")) return true;
-
-  if (c_str() == NULL) return false;
-
-  const size_t this_len = strlen(c_str());
-  const size_t suffix_len = strlen(suffix);
-  return (this_len >= suffix_len) &&
-         CStringEquals(c_str() + this_len - suffix_len, suffix);
-}
-
-// Returns true iff this String ends with the given suffix, ignoring case.
-// Any String is considered to end with a NULL or empty suffix.
-bool String::EndsWithCaseInsensitive(const char* suffix) const {
-  if (suffix == NULL || CStringEquals(suffix, "")) return true;
-
-  if (c_str() == NULL) return false;
-
-  const size_t this_len = strlen(c_str());
-  const size_t suffix_len = strlen(suffix);
-  return (this_len >= suffix_len) &&
-         CaseInsensitiveCStringEquals(c_str() + this_len - suffix_len, suffix);
-}
-
-// Formats a list of arguments to a String, using the same format
-// spec string as for printf.
-//
-// We do not use the StringPrintf class as it is not universally
-// available.
-//
-// The result is limited to 4096 characters (including the tailing 0).
-// If 4096 characters are not enough to format the input, or if
-// there's an error, "<formatting error or buffer exceeded>" is
-// returned.
-String String::Format(const char * format, ...) {
-  va_list args;
-  va_start(args, format);
-
-  char buffer[4096];
-  const int kBufferSize = sizeof(buffer)/sizeof(buffer[0]);
-
-  // MSVC 8 deprecates vsnprintf(), so we want to suppress warning
-  // 4996 (deprecated function) there.
-#ifdef _MSC_VER  // We are using MSVC.
-# pragma warning(push)          // Saves the current warning state.
-# pragma warning(disable:4996)  // Temporarily disables warning 4996.
-
-  const int size = vsnprintf(buffer, kBufferSize, format, args);
-
-# pragma warning(pop)           // Restores the warning state.
-#else  // We are not using MSVC.
-  const int size = vsnprintf(buffer, kBufferSize, format, args);
-#endif  // _MSC_VER
-  va_end(args);
-
-  // vsnprintf()'s behavior is not portable.  When the buffer is not
-  // big enough, it returns a negative value in MSVC, and returns the
-  // needed buffer size on Linux.  When there is an output error, it
-  // always returns a negative value.  For simplicity, we lump the two
-  // error cases together.
-  if (size < 0 || size >= kBufferSize) {
-    return String("<formatting error or buffer exceeded>");
-  } else {
-    return String(buffer, size);
-  }
-}
-
-// Converts the buffer in a stringstream to a String, converting NUL
-// bytes to "\\0" along the way.
-String StringStreamToString(::std::stringstream* ss) {
-  const ::std::string& str = ss->str();
-  const char* const start = str.c_str();
-  const char* const end = start + str.length();
-
-  // We need to use a helper stringstream to do this transformation
-  // because String doesn't support push_back().
-  ::std::stringstream helper;
-  for (const char* ch = start; ch != end; ++ch) {
-    if (*ch == '\0') {
-      helper << "\\0";  // Replaces NUL with "\\0";
-    } else {
-      helper.put(*ch);
-    }
-  }
-
-  return String(helper.str().c_str());
-}
-
-// Appends the user-supplied message to the Google-Test-generated message.
-String AppendUserMessage(const String& gtest_msg,
-                         const Message& user_msg) {
-  // Appends the user message if it's non-empty.
-  const String user_msg_string = user_msg.GetString();
-  if (user_msg_string.empty()) {
-    return gtest_msg;
-  }
-
-  Message msg;
-  msg << gtest_msg << "\n" << user_msg_string;
-
-  return msg.GetString();
-}
-
-}  // namespace internal
-
-// class TestResult
-
-// Creates an empty TestResult.
-TestResult::TestResult()
-    : death_test_count_(0),
-      elapsed_time_(0) {
-}
-
-// D'tor.
-TestResult::~TestResult() {
-}
-
-// Returns the i-th test part result among all the results. i can
-// range from 0 to total_part_count() - 1. If i is not in that range,
-// aborts the program.
-const TestPartResult& TestResult::GetTestPartResult(int i) const {
-  if (i < 0 || i >= total_part_count())
-    internal::posix::Abort();
-  return test_part_results_.at(i);
-}
-
-// Returns the i-th test property. i can range from 0 to
-// test_property_count() - 1. If i is not in that range, aborts the
-// program.
-const TestProperty& TestResult::GetTestProperty(int i) const {
-  if (i < 0 || i >= test_property_count())
-    internal::posix::Abort();
-  return test_properties_.at(i);
-}
-
-// Clears the test part results.
-void TestResult::ClearTestPartResults() {
-  test_part_results_.clear();
-}
-
-// Adds a test part result to the list.
-void TestResult::AddTestPartResult(const TestPartResult& test_part_result) {
-  test_part_results_.push_back(test_part_result);
-}
-
-// Adds a test property to the list. If a property with the same key as the
-// supplied property is already represented, the value of this test_property
-// replaces the old value for that key.
-void TestResult::RecordProperty(const TestProperty& test_property) {
-  if (!ValidateTestProperty(test_property)) {
-    return;
-  }
-  internal::MutexLock lock(&test_properites_mutex_);
-  const std::vector<TestProperty>::iterator property_with_matching_key =
-      std::find_if(test_properties_.begin(), test_properties_.end(),
-                   internal::TestPropertyKeyIs(test_property.key()));
-  if (property_with_matching_key == test_properties_.end()) {
-    test_properties_.push_back(test_property);
-    return;
-  }
-  property_with_matching_key->SetValue(test_property.value());
-}
-
-// Adds a failure if the key is a reserved attribute of Google Test
-// testcase tags.  Returns true if the property is valid.
-bool TestResult::ValidateTestProperty(const TestProperty& test_property) {
-  internal::String key(test_property.key());
-  if (key == "name" || key == "status" || key == "time" || key == "classname") {
-    ADD_FAILURE()
-        << "Reserved key used in RecordProperty(): "
-        << key
-        << " ('name', 'status', 'time', and 'classname' are reserved by "
-        << GTEST_NAME_ << ")";
-    return false;
-  }
-  return true;
-}
-
-// Clears the object.
-void TestResult::Clear() {
-  test_part_results_.clear();
-  test_properties_.clear();
-  death_test_count_ = 0;
-  elapsed_time_ = 0;
-}
-
-// Returns true iff the test failed.
-bool TestResult::Failed() const {
-  for (int i = 0; i < total_part_count(); ++i) {
-    if (GetTestPartResult(i).failed())
-      return true;
-  }
-  return false;
-}
-
-// Returns true iff the test part fatally failed.
-static bool TestPartFatallyFailed(const TestPartResult& result) {
-  return result.fatally_failed();
-}
-
-// Returns true iff the test fatally failed.
-bool TestResult::HasFatalFailure() const {
-  return CountIf(test_part_results_, TestPartFatallyFailed) > 0;
-}
-
-// Returns true iff the test part non-fatally failed.
-static bool TestPartNonfatallyFailed(const TestPartResult& result) {
-  return result.nonfatally_failed();
-}
-
-// Returns true iff the test has a non-fatal failure.
-bool TestResult::HasNonfatalFailure() const {
-  return CountIf(test_part_results_, TestPartNonfatallyFailed) > 0;
-}
-
-// Gets the number of all test parts.  This is the sum of the number
-// of successful test parts and the number of failed test parts.
-int TestResult::total_part_count() const {
-  return static_cast<int>(test_part_results_.size());
-}
-
-// Returns the number of the test properties.
-int TestResult::test_property_count() const {
-  return static_cast<int>(test_properties_.size());
-}
-
-// class Test
-
-// Creates a Test object.
-
-// The c'tor saves the values of all Google Test flags.
-Test::Test()
-    : gtest_flag_saver_(new internal::GTestFlagSaver) {
-}
-
-// The d'tor restores the values of all Google Test flags.
-Test::~Test() {
-  delete gtest_flag_saver_;
-}
-
-// Sets up the test fixture.
-//
-// A sub-class may override this.
-void Test::SetUp() {
-}
-
-// Tears down the test fixture.
-//
-// A sub-class may override this.
-void Test::TearDown() {
-}
-
-// Allows user supplied key value pairs to be recorded for later output.
-void Test::RecordProperty(const char* key, const char* value) {
-  UnitTest::GetInstance()->RecordPropertyForCurrentTest(key, value);
-}
-
-// Allows user supplied key value pairs to be recorded for later output.
-void Test::RecordProperty(const char* key, int value) {
-  Message value_message;
-  value_message << value;
-  RecordProperty(key, value_message.GetString().c_str());
-}
-
-namespace internal {
-
-void ReportFailureInUnknownLocation(TestPartResult::Type result_type,
-                                    const String& message) {
-  // This function is a friend of UnitTest and as such has access to
-  // AddTestPartResult.
-  UnitTest::GetInstance()->AddTestPartResult(
-      result_type,
-      NULL,  // No info about the source file where the exception occurred.
-      -1,    // We have no info on which line caused the exception.
-      message,
-      String());  // No stack trace, either.
-}
-
-}  // namespace internal
-
-// Google Test requires all tests in the same test case to use the same test
-// fixture class.  This function checks if the current test has the
-// same fixture class as the first test in the current test case.  If
-// yes, it returns true; otherwise it generates a Google Test failure and
-// returns false.
-bool Test::HasSameFixtureClass() {
-  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
-  const TestCase* const test_case = impl->current_test_case();
-
-  // Info about the first test in the current test case.
-  const TestInfo* const first_test_info = test_case->test_info_list()[0];
-  const internal::TypeId first_fixture_id = first_test_info->fixture_class_id_;
-  const char* const first_test_name = first_test_info->name();
-
-  // Info about the current test.
-  const TestInfo* const this_test_info = impl->current_test_info();
-  const internal::TypeId this_fixture_id = this_test_info->fixture_class_id_;
-  const char* const this_test_name = this_test_info->name();
-
-  if (this_fixture_id != first_fixture_id) {
-    // Is the first test defined using TEST?
-    const bool first_is_TEST = first_fixture_id == internal::GetTestTypeId();
-    // Is this test defined using TEST?
-    const bool this_is_TEST = this_fixture_id == internal::GetTestTypeId();
-
-    if (first_is_TEST || this_is_TEST) {
-      // The user mixed TEST and TEST_F in this test case - we'll tell
-      // him/her how to fix it.
-
-      // Gets the name of the TEST and the name of the TEST_F.  Note
-      // that first_is_TEST and this_is_TEST cannot both be true, as
-      // the fixture IDs are different for the two tests.
-      const char* const TEST_name =
-          first_is_TEST ? first_test_name : this_test_name;
-      const char* const TEST_F_name =
-          first_is_TEST ? this_test_name : first_test_name;
-
-      ADD_FAILURE()
-          << "All tests in the same test case must use the same test fixture\n"
-          << "class, so mixing TEST_F and TEST in the same test case is\n"
-          << "illegal.  In test case " << this_test_info->test_case_name()
-          << ",\n"
-          << "test " << TEST_F_name << " is defined using TEST_F but\n"
-          << "test " << TEST_name << " is defined using TEST.  You probably\n"
-          << "want to change the TEST to TEST_F or move it to another test\n"
-          << "case.";
-    } else {
-      // The user defined two fixture classes with the same name in
-      // two namespaces - we'll tell him/her how to fix it.
-      ADD_FAILURE()
-          << "All tests in the same test case must use the same test fixture\n"
-          << "class.  However, in test case "
-          << this_test_info->test_case_name() << ",\n"
-          << "you defined test " << first_test_name
-          << " and test " << this_test_name << "\n"
-          << "using two different test fixture classes.  This can happen if\n"
-          << "the two classes are from different namespaces or translation\n"
-          << "units and have the same name.  You should probably rename one\n"
-          << "of the classes to put the tests into different test cases.";
-    }
-    return false;
-  }
-
-  return true;
-}
-
-#if GTEST_HAS_SEH
-
-// Adds an "exception thrown" fatal failure to the current test.  This
-// function returns its result via an output parameter pointer because VC++
-// prohibits creation of objects with destructors on stack in functions
-// using __try (see error C2712).
-static internal::String* FormatSehExceptionMessage(DWORD exception_code,
-                                                   const char* location) {
-  Message message;
-  message << "SEH exception with code 0x" << std::setbase(16) <<
-    exception_code << std::setbase(10) << " thrown in " << location << ".";
-
-  return new internal::String(message.GetString());
-}
-
-#endif  // GTEST_HAS_SEH
-
-#if GTEST_HAS_EXCEPTIONS
-
-// Adds an "exception thrown" fatal failure to the current test.
-static internal::String FormatCxxExceptionMessage(const char* description,
-                                                  const char* location) {
-  Message message;
-  if (description != NULL) {
-    message << "C++ exception with description \"" << description << "\"";
-  } else {
-    message << "Unknown C++ exception";
-  }
-  message << " thrown in " << location << ".";
-
-  return message.GetString();
-}
-
-static internal::String PrintTestPartResultToString(
-    const TestPartResult& test_part_result);
-
-// A failed Google Test assertion will throw an exception of this type when
-// GTEST_FLAG(throw_on_failure) is true (if exceptions are enabled).  We
-// derive it from std::runtime_error, which is for errors presumably
-// detectable only at run time.  Since std::runtime_error inherits from
-// std::exception, many testing frameworks know how to extract and print the
-// message inside it.
-class GoogleTestFailureException : public ::std::runtime_error {
- public:
-  explicit GoogleTestFailureException(const TestPartResult& failure)
-      : ::std::runtime_error(PrintTestPartResultToString(failure).c_str()) {}
-};
-#endif  // GTEST_HAS_EXCEPTIONS
-
-namespace internal {
-// We put these helper functions in the internal namespace as IBM's xlC
-// compiler rejects the code if they were declared static.
-
-// Runs the given method and handles SEH exceptions it throws, when
-// SEH is supported; returns the 0-value for type Result in case of an
-// SEH exception.  (Microsoft compilers cannot handle SEH and C++
-// exceptions in the same function.  Therefore, we provide a separate
-// wrapper function for handling SEH exceptions.)
-template <class T, typename Result>
-Result HandleSehExceptionsInMethodIfSupported(
-    T* object, Result (T::*method)(), const char* location) {
-#if GTEST_HAS_SEH
-  __try {
-    return (object->*method)();
-  } __except (internal::UnitTestOptions::GTestShouldProcessSEH(  // NOLINT
-      GetExceptionCode())) {
-    // We create the exception message on the heap because VC++ prohibits
-    // creation of objects with destructors on stack in functions using __try
-    // (see error C2712).
-    internal::String* exception_message = FormatSehExceptionMessage(
-        GetExceptionCode(), location);
-    internal::ReportFailureInUnknownLocation(TestPartResult::kFatalFailure,
-                                             *exception_message);
-    delete exception_message;
-    return static_cast<Result>(0);
-  }
-#else
-  (void)location;
-  return (object->*method)();
-#endif  // GTEST_HAS_SEH
-}
-
-// Runs the given method and catches and reports C++ and/or SEH-style
-// exceptions, if they are supported; returns the 0-value for type
-// Result in case of an SEH exception.
-template <class T, typename Result>
-Result HandleExceptionsInMethodIfSupported(
-    T* object, Result (T::*method)(), const char* location) {
-  // NOTE: The user code can affect the way in which Google Test handles
-  // exceptions by setting GTEST_FLAG(catch_exceptions), but only before
-  // RUN_ALL_TESTS() starts. It is technically possible to check the flag
-  // after the exception is caught and either report or re-throw the
-  // exception based on the flag's value:
-  //
-  // try {
-  //   // Perform the test method.
-  // } catch (...) {
-  //   if (GTEST_FLAG(catch_exceptions))
-  //     // Report the exception as failure.
-  //   else
-  //     throw;  // Re-throws the original exception.
-  // }
-  //
-  // However, the purpose of this flag is to allow the program to drop into
-  // the debugger when the exception is thrown. On most platforms, once the
-  // control enters the catch block, the exception origin information is
-  // lost and the debugger will stop the program at the point of the
-  // re-throw in this function -- instead of at the point of the original
-  // throw statement in the code under test.  For this reason, we perform
-  // the check early, sacrificing the ability to affect Google Test's
-  // exception handling in the method where the exception is thrown.
-  if (internal::GetUnitTestImpl()->catch_exceptions()) {
-#if GTEST_HAS_EXCEPTIONS
-    try {
-      return HandleSehExceptionsInMethodIfSupported(object, method, location);
-    } catch (const GoogleTestFailureException&) {  // NOLINT
-      // This exception doesn't originate in code under test. It makes no
-      // sense to report it as a test failure.
-      throw;
-    } catch (const std::exception& e) {  // NOLINT
-      internal::ReportFailureInUnknownLocation(
-          TestPartResult::kFatalFailure,
-          FormatCxxExceptionMessage(e.what(), location));
-    } catch (...) {  // NOLINT
-      internal::ReportFailureInUnknownLocation(
-          TestPartResult::kFatalFailure,
-          FormatCxxExceptionMessage(NULL, location));
-    }
-    return static_cast<Result>(0);
-#else
-    return HandleSehExceptionsInMethodIfSupported(object, method, location);
-#endif  // GTEST_HAS_EXCEPTIONS
-  } else {
-    return (object->*method)();
-  }
-}
-
-}  // namespace internal
-
-// Runs the test and updates the test result.
-void Test::Run() {
-  if (!HasSameFixtureClass()) return;
-
-  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
-  impl->os_stack_trace_getter()->UponLeavingGTest();
-  internal::HandleExceptionsInMethodIfSupported(this, &Test::SetUp, "SetUp()");
-  // We will run the test only if SetUp() was successful.
-  if (!HasFatalFailure()) {
-    impl->os_stack_trace_getter()->UponLeavingGTest();
-    internal::HandleExceptionsInMethodIfSupported(
-        this, &Test::TestBody, "the test body");
-  }
-
-  // However, we want to clean up as much as possible.  Hence we will
-  // always call TearDown(), even if SetUp() or the test body has
-  // failed.
-  impl->os_stack_trace_getter()->UponLeavingGTest();
-  internal::HandleExceptionsInMethodIfSupported(
-      this, &Test::TearDown, "TearDown()");
-}
-
-// Returns true iff the current test has a fatal failure.
-bool Test::HasFatalFailure() {
-  return internal::GetUnitTestImpl()->current_test_result()->HasFatalFailure();
-}
-
-// Returns true iff the current test has a non-fatal failure.
-bool Test::HasNonfatalFailure() {
-  return internal::GetUnitTestImpl()->current_test_result()->
-      HasNonfatalFailure();
-}
-
-// class TestInfo
-
-// Constructs a TestInfo object. It assumes ownership of the test factory
-// object.
-// TODO(vladl at google.com): Make a_test_case_name and a_name const string&'s
-// to signify they cannot be NULLs.
-TestInfo::TestInfo(const char* a_test_case_name,
-                   const char* a_name,
-                   const char* a_type_param,
-                   const char* a_value_param,
-                   internal::TypeId fixture_class_id,
-                   internal::TestFactoryBase* factory)
-    : test_case_name_(a_test_case_name),
-      name_(a_name),
-      type_param_(a_type_param ? new std::string(a_type_param) : NULL),
-      value_param_(a_value_param ? new std::string(a_value_param) : NULL),
-      fixture_class_id_(fixture_class_id),
-      should_run_(false),
-      is_disabled_(false),
-      matches_filter_(false),
-      factory_(factory),
-      result_() {}
-
-// Destructs a TestInfo object.
-TestInfo::~TestInfo() { delete factory_; }
-
-namespace internal {
-
-// Creates a new TestInfo object and registers it with Google Test;
-// returns the created object.
-//
-// Arguments:
-//
-//   test_case_name:   name of the test case
-//   name:             name of the test
-//   type_param:       the name of the test's type parameter, or NULL if
-//                     this is not a typed or a type-parameterized test.
-//   value_param:      text representation of the test's value parameter,
-//                     or NULL if this is not a value-parameterized test.
-//   fixture_class_id: ID of the test fixture class
-//   set_up_tc:        pointer to the function that sets up the test case
-//   tear_down_tc:     pointer to the function that tears down the test case
-//   factory:          pointer to the factory that creates a test object.
-//                     The newly created TestInfo instance will assume
-//                     ownership of the factory object.
-TestInfo* MakeAndRegisterTestInfo(
-    const char* test_case_name, const char* name,
-    const char* type_param,
-    const char* value_param,
-    TypeId fixture_class_id,
-    SetUpTestCaseFunc set_up_tc,
-    TearDownTestCaseFunc tear_down_tc,
-    TestFactoryBase* factory) {
-  TestInfo* const test_info =
-      new TestInfo(test_case_name, name, type_param, value_param,
-                   fixture_class_id, factory);
-  GetUnitTestImpl()->AddTestInfo(set_up_tc, tear_down_tc, test_info);
-  return test_info;
-}
-
-#if GTEST_HAS_PARAM_TEST
-void ReportInvalidTestCaseType(const char* test_case_name,
-                               const char* file, int line) {
-  Message errors;
-  errors
-      << "Attempted redefinition of test case " << test_case_name << ".\n"
-      << "All tests in the same test case must use the same test fixture\n"
-      << "class.  However, in test case " << test_case_name << ", you tried\n"
-      << "to define a test using a fixture class different from the one\n"
-      << "used earlier. This can happen if the two fixture classes are\n"
-      << "from different namespaces and have the same name. You should\n"
-      << "probably rename one of the classes to put the tests into different\n"
-      << "test cases.";
-
-  fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(),
-          errors.GetString().c_str());
-}
-#endif  // GTEST_HAS_PARAM_TEST
-
-}  // namespace internal
-
-namespace {
-
-// A predicate that checks the test name of a TestInfo against a known
-// value.
-//
-// This is used for implementation of the TestCase class only.  We put
-// it in the anonymous namespace to prevent polluting the outer
-// namespace.
-//
-// TestNameIs is copyable.
-class TestNameIs {
- public:
-  // Constructor.
-  //
-  // TestNameIs has NO default constructor.
-  explicit TestNameIs(const char* name)
-      : name_(name) {}
-
-  // Returns true iff the test name of test_info matches name_.
-  bool operator()(const TestInfo * test_info) const {
-    return test_info && internal::String(test_info->name()).Compare(name_) == 0;
-  }
-
- private:
-  internal::String name_;
-};
-
-}  // namespace
-
-namespace internal {
-
-// This method expands all parameterized tests registered with macros TEST_P
-// and INSTANTIATE_TEST_CASE_P into regular tests and registers those.
-// This will be done just once during the program runtime.
-void UnitTestImpl::RegisterParameterizedTests() {
-#if GTEST_HAS_PARAM_TEST
-  if (!parameterized_tests_registered_) {
-    parameterized_test_registry_.RegisterTests();
-    parameterized_tests_registered_ = true;
-  }
-#endif
-}
-
-}  // namespace internal
-
-// Creates the test object, runs it, records its result, and then
-// deletes it.
-void TestInfo::Run() {
-  if (!should_run_) return;
-
-  // Tells UnitTest where to store test result.
-  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
-  impl->set_current_test_info(this);
-
-  TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
-
-  // Notifies the unit test event listeners that a test is about to start.
-  repeater->OnTestStart(*this);
-
-  const TimeInMillis start = internal::GetTimeInMillis();
-
-  impl->os_stack_trace_getter()->UponLeavingGTest();
-
-  // Creates the test object.
-  Test* const test = internal::HandleExceptionsInMethodIfSupported(
-      factory_, &internal::TestFactoryBase::CreateTest,
-      "the test fixture's constructor");
-
-  // Runs the test only if the test object was created and its
-  // constructor didn't generate a fatal failure.
-  if ((test != NULL) && !Test::HasFatalFailure()) {
-    // This doesn't throw as all user code that can throw are wrapped into
-    // exception handling code.
-    test->Run();
-  }
-
-  // Deletes the test object.
-  impl->os_stack_trace_getter()->UponLeavingGTest();
-  internal::HandleExceptionsInMethodIfSupported(
-      test, &Test::DeleteSelf_, "the test fixture's destructor");
-
-  result_.set_elapsed_time(internal::GetTimeInMillis() - start);
-
-  // Notifies the unit test event listener that a test has just finished.
-  repeater->OnTestEnd(*this);
-
-  // Tells UnitTest to stop associating assertion results to this
-  // test.
-  impl->set_current_test_info(NULL);
-}
-
-// class TestCase
-
-// Gets the number of successful tests in this test case.
-int TestCase::successful_test_count() const {
-  return CountIf(test_info_list_, TestPassed);
-}
-
-// Gets the number of failed tests in this test case.
-int TestCase::failed_test_count() const {
-  return CountIf(test_info_list_, TestFailed);
-}
-
-int TestCase::disabled_test_count() const {
-  return CountIf(test_info_list_, TestDisabled);
-}
-
-// Get the number of tests in this test case that should run.
-int TestCase::test_to_run_count() const {
-  return CountIf(test_info_list_, ShouldRunTest);
-}
-
-// Gets the number of all tests.
-int TestCase::total_test_count() const {
-  return static_cast<int>(test_info_list_.size());
-}
-
-// Creates a TestCase with the given name.
-//
-// Arguments:
-//
-//   name:         name of the test case
-//   a_type_param: the name of the test case's type parameter, or NULL if
-//                 this is not a typed or a type-parameterized test case.
-//   set_up_tc:    pointer to the function that sets up the test case
-//   tear_down_tc: pointer to the function that tears down the test case
-TestCase::TestCase(const char* a_name, const char* a_type_param,
-                   Test::SetUpTestCaseFunc set_up_tc,
-                   Test::TearDownTestCaseFunc tear_down_tc)
-    : name_(a_name),
-      type_param_(a_type_param ? new std::string(a_type_param) : NULL),
-      set_up_tc_(set_up_tc),
-      tear_down_tc_(tear_down_tc),
-      should_run_(false),
-      elapsed_time_(0) {
-}
-
-// Destructor of TestCase.
-TestCase::~TestCase() {
-  // Deletes every Test in the collection.
-  ForEach(test_info_list_, internal::Delete<TestInfo>);
-}
-
-// Returns the i-th test among all the tests. i can range from 0 to
-// total_test_count() - 1. If i is not in that range, returns NULL.
-const TestInfo* TestCase::GetTestInfo(int i) const {
-  const int index = GetElementOr(test_indices_, i, -1);
-  return index < 0 ? NULL : test_info_list_[index];
-}
-
-// Returns the i-th test among all the tests. i can range from 0 to
-// total_test_count() - 1. If i is not in that range, returns NULL.
-TestInfo* TestCase::GetMutableTestInfo(int i) {
-  const int index = GetElementOr(test_indices_, i, -1);
-  return index < 0 ? NULL : test_info_list_[index];
-}
-
-// Adds a test to this test case.  Will delete the test upon
-// destruction of the TestCase object.
-void TestCase::AddTestInfo(TestInfo * test_info) {
-  test_info_list_.push_back(test_info);
-  test_indices_.push_back(static_cast<int>(test_indices_.size()));
-}
-
-// Runs every test in this TestCase.
-void TestCase::Run() {
-  if (!should_run_) return;
-
-  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
-  impl->set_current_test_case(this);
-
-  TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
-
-  repeater->OnTestCaseStart(*this);
-  impl->os_stack_trace_getter()->UponLeavingGTest();
-  internal::HandleExceptionsInMethodIfSupported(
-      this, &TestCase::RunSetUpTestCase, "SetUpTestCase()");
-
-  const internal::TimeInMillis start = internal::GetTimeInMillis();
-  for (int i = 0; i < total_test_count(); i++) {
-    GetMutableTestInfo(i)->Run();
-  }
-  elapsed_time_ = internal::GetTimeInMillis() - start;
-
-  impl->os_stack_trace_getter()->UponLeavingGTest();
-  internal::HandleExceptionsInMethodIfSupported(
-      this, &TestCase::RunTearDownTestCase, "TearDownTestCase()");
-
-  repeater->OnTestCaseEnd(*this);
-  impl->set_current_test_case(NULL);
-}
-
-// Clears the results of all tests in this test case.
-void TestCase::ClearResult() {
-  ForEach(test_info_list_, TestInfo::ClearTestResult);
-}
-
-// Shuffles the tests in this test case.
-void TestCase::ShuffleTests(internal::Random* random) {
-  Shuffle(random, &test_indices_);
-}
-
-// Restores the test order to before the first shuffle.
-void TestCase::UnshuffleTests() {
-  for (size_t i = 0; i < test_indices_.size(); i++) {
-    test_indices_[i] = static_cast<int>(i);
-  }
-}
-
-// Formats a countable noun.  Depending on its quantity, either the
-// singular form or the plural form is used. e.g.
-//
-// FormatCountableNoun(1, "formula", "formuli") returns "1 formula".
-// FormatCountableNoun(5, "book", "books") returns "5 books".
-static internal::String FormatCountableNoun(int count,
-                                            const char * singular_form,
-                                            const char * plural_form) {
-  return internal::String::Format("%d %s", count,
-                                  count == 1 ? singular_form : plural_form);
-}
-
-// Formats the count of tests.
-static internal::String FormatTestCount(int test_count) {
-  return FormatCountableNoun(test_count, "test", "tests");
-}
-
-// Formats the count of test cases.
-static internal::String FormatTestCaseCount(int test_case_count) {
-  return FormatCountableNoun(test_case_count, "test case", "test cases");
-}
-
-// Converts a TestPartResult::Type enum to human-friendly string
-// representation.  Both kNonFatalFailure and kFatalFailure are translated
-// to "Failure", as the user usually doesn't care about the difference
-// between the two when viewing the test result.
-static const char * TestPartResultTypeToString(TestPartResult::Type type) {
-  switch (type) {
-    case TestPartResult::kSuccess:
-      return "Success";
-
-    case TestPartResult::kNonFatalFailure:
-    case TestPartResult::kFatalFailure:
-#ifdef _MSC_VER
-      return "error: ";
-#else
-      return "Failure\n";
-#endif
-    default:
-      return "Unknown result type";
-  }
-}
-
-// Prints a TestPartResult to a String.
-static internal::String PrintTestPartResultToString(
-    const TestPartResult& test_part_result) {
-  return (Message()
-          << internal::FormatFileLocation(test_part_result.file_name(),
-                                          test_part_result.line_number())
-          << " " << TestPartResultTypeToString(test_part_result.type())
-          << test_part_result.message()).GetString();
-}
-
-// Prints a TestPartResult.
-static void PrintTestPartResult(const TestPartResult& test_part_result) {
-  const internal::String& result =
-      PrintTestPartResultToString(test_part_result);
-  printf("%s\n", result.c_str());
-  fflush(stdout);
-  // If the test program runs in Visual Studio or a debugger, the
-  // following statements add the test part result message to the Output
-  // window such that the user can double-click on it to jump to the
-  // corresponding source code location; otherwise they do nothing.
-#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
-  // We don't call OutputDebugString*() on Windows Mobile, as printing
-  // to stdout is done by OutputDebugString() there already - we don't
-  // want the same message printed twice.
-  ::OutputDebugStringA(result.c_str());
-  ::OutputDebugStringA("\n");
-#endif
-}
-
-// class PrettyUnitTestResultPrinter
-
-namespace internal {
-
-enum GTestColor {
-  COLOR_DEFAULT,
-  COLOR_RED,
-  COLOR_GREEN,
-  COLOR_YELLOW
-};
-
-#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
-
-// Returns the character attribute for the given color.
-WORD GetColorAttribute(GTestColor color) {
-  switch (color) {
-    case COLOR_RED:    return FOREGROUND_RED;
-    case COLOR_GREEN:  return FOREGROUND_GREEN;
-    case COLOR_YELLOW: return FOREGROUND_RED | FOREGROUND_GREEN;
-    default:           return 0;
-  }
-}
-
-#else
-
-// Returns the ANSI color code for the given color.  COLOR_DEFAULT is
-// an invalid input.
-const char* GetAnsiColorCode(GTestColor color) {
-  switch (color) {
-    case COLOR_RED:     return "1";
-    case COLOR_GREEN:   return "2";
-    case COLOR_YELLOW:  return "3";
-    default:            return NULL;
-  };
-}
-
-#endif  // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
-
-// Returns true iff Google Test should use colors in the output.
-bool ShouldUseColor(bool stdout_is_tty) {
-  const char* const gtest_color = GTEST_FLAG(color).c_str();
-
-  if (String::CaseInsensitiveCStringEquals(gtest_color, "auto")) {
-#if GTEST_OS_WINDOWS
-    // On Windows the TERM variable is usually not set, but the
-    // console there does support colors.
-    return stdout_is_tty;
-#else
-    // On non-Windows platforms, we rely on the TERM variable.
-    const char* const term = posix::GetEnv("TERM");
-    const bool term_supports_color =
-        String::CStringEquals(term, "xterm") ||
-        String::CStringEquals(term, "xterm-color") ||
-        String::CStringEquals(term, "xterm-256color") ||
-        String::CStringEquals(term, "screen") ||
-        String::CStringEquals(term, "linux") ||
-        String::CStringEquals(term, "cygwin");
-    return stdout_is_tty && term_supports_color;
-#endif  // GTEST_OS_WINDOWS
-  }
-
-  return String::CaseInsensitiveCStringEquals(gtest_color, "yes") ||
-      String::CaseInsensitiveCStringEquals(gtest_color, "true") ||
-      String::CaseInsensitiveCStringEquals(gtest_color, "t") ||
-      String::CStringEquals(gtest_color, "1");
-  // We take "yes", "true", "t", and "1" as meaning "yes".  If the
-  // value is neither one of these nor "auto", we treat it as "no" to
-  // be conservative.
-}
-
-// Helpers for printing colored strings to stdout. Note that on Windows, we
-// cannot simply emit special characters and have the terminal change colors.
-// This routine must actually emit the characters rather than return a string
-// that would be colored when printed, as can be done on Linux.
-void ColoredPrintf(GTestColor color, const char* fmt, ...) {
-  va_list args;
-  va_start(args, fmt);
-
-#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || GTEST_OS_ZOS
-  const bool use_color = false;
-#else
-  static const bool in_color_mode =
-      ShouldUseColor(posix::IsATTY(posix::FileNo(stdout)) != 0);
-  const bool use_color = in_color_mode && (color != COLOR_DEFAULT);
-#endif  // GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || GTEST_OS_ZOS
-  // The '!= 0' comparison is necessary to satisfy MSVC 7.1.
-
-  if (!use_color) {
-    vprintf(fmt, args);
-    va_end(args);
-    return;
-  }
-
-#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
-  const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
-
-  // Gets the current text color.
-  CONSOLE_SCREEN_BUFFER_INFO buffer_info;
-  GetConsoleScreenBufferInfo(stdout_handle, &buffer_info);
-  const WORD old_color_attrs = buffer_info.wAttributes;
-
-  // We need to flush the stream buffers into the console before each
-  // SetConsoleTextAttribute call lest it affect the text that is already
-  // printed but has not yet reached the console.
-  fflush(stdout);
-  SetConsoleTextAttribute(stdout_handle,
-                          GetColorAttribute(color) | FOREGROUND_INTENSITY);
-  vprintf(fmt, args);
-
-  fflush(stdout);
-  // Restores the text color.
-  SetConsoleTextAttribute(stdout_handle, old_color_attrs);
-#else
-  printf("\033[0;3%sm", GetAnsiColorCode(color));
-  vprintf(fmt, args);
-  printf("\033[m");  // Resets the terminal to default.
-#endif  // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
-  va_end(args);
-}
-
-void PrintFullTestCommentIfPresent(const TestInfo& test_info) {
-  const char* const type_param = test_info.type_param();
-  const char* const value_param = test_info.value_param();
-
-  if (type_param != NULL || value_param != NULL) {
-    printf(", where ");
-    if (type_param != NULL) {
-      printf("TypeParam = %s", type_param);
-      if (value_param != NULL)
-        printf(" and ");
-    }
-    if (value_param != NULL) {
-      printf("GetParam() = %s", value_param);
-    }
-  }
-}
-
-// This class implements the TestEventListener interface.
-//
-// Class PrettyUnitTestResultPrinter is copyable.
-class PrettyUnitTestResultPrinter : public TestEventListener {
- public:
-  PrettyUnitTestResultPrinter() {}
-  static void PrintTestName(const char * test_case, const char * test) {
-    printf("%s.%s", test_case, test);
-  }
-
-  // The following methods override what's in the TestEventListener class.
-  virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {}
-  virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration);
-  virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test);
-  virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {}
-  virtual void OnTestCaseStart(const TestCase& test_case);
-  virtual void OnTestStart(const TestInfo& test_info);
-  virtual void OnTestPartResult(const TestPartResult& result);
-  virtual void OnTestEnd(const TestInfo& test_info);
-  virtual void OnTestCaseEnd(const TestCase& test_case);
-  virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test);
-  virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {}
-  virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration);
-  virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {}
-
- private:
-  static void PrintFailedTests(const UnitTest& unit_test);
-
-  internal::String test_case_name_;
-};
-
-  // Fired before each iteration of tests starts.
-void PrettyUnitTestResultPrinter::OnTestIterationStart(
-    const UnitTest& unit_test, int iteration) {
-  if (GTEST_FLAG(repeat) != 1)
-    printf("\nRepeating all tests (iteration %d) . . .\n\n", iteration + 1);
-
-  const char* const filter = GTEST_FLAG(filter).c_str();
-
-  // Prints the filter if it's not *.  This reminds the user that some
-  // tests may be skipped.
-  if (!internal::String::CStringEquals(filter, kUniversalFilter)) {
-    ColoredPrintf(COLOR_YELLOW,
-                  "Note: %s filter = %s\n", GTEST_NAME_, filter);
-  }
-
-  if (internal::ShouldShard(kTestTotalShards, kTestShardIndex, false)) {
-    const Int32 shard_index = Int32FromEnvOrDie(kTestShardIndex, -1);
-    ColoredPrintf(COLOR_YELLOW,
-                  "Note: This is test shard %d of %s.\n",
-                  static_cast<int>(shard_index) + 1,
-                  internal::posix::GetEnv(kTestTotalShards));
-  }
-
-  if (GTEST_FLAG(shuffle)) {
-    ColoredPrintf(COLOR_YELLOW,
-                  "Note: Randomizing tests' orders with a seed of %d .\n",
-                  unit_test.random_seed());
-  }
-
-  ColoredPrintf(COLOR_GREEN,  "[==========] ");
-  printf("Running %s from %s.\n",
-         FormatTestCount(unit_test.test_to_run_count()).c_str(),
-         FormatTestCaseCount(unit_test.test_case_to_run_count()).c_str());
-  fflush(stdout);
-}
-
-void PrettyUnitTestResultPrinter::OnEnvironmentsSetUpStart(
-    const UnitTest& /*unit_test*/) {
-  ColoredPrintf(COLOR_GREEN,  "[----------] ");
-  printf("Global test environment set-up.\n");
-  fflush(stdout);
-}
-
-void PrettyUnitTestResultPrinter::OnTestCaseStart(const TestCase& test_case) {
-  test_case_name_ = test_case.name();
-  const internal::String counts =
-      FormatCountableNoun(test_case.test_to_run_count(), "test", "tests");
-  ColoredPrintf(COLOR_GREEN, "[----------] ");
-  printf("%s from %s", counts.c_str(), test_case_name_.c_str());
-  if (test_case.type_param() == NULL) {
-    printf("\n");
-  } else {
-    printf(", where TypeParam = %s\n", test_case.type_param());
-  }
-  fflush(stdout);
-}
-
-void PrettyUnitTestResultPrinter::OnTestStart(const TestInfo& test_info) {
-  ColoredPrintf(COLOR_GREEN,  "[ RUN      ] ");
-  PrintTestName(test_case_name_.c_str(), test_info.name());
-  printf("\n");
-  fflush(stdout);
-}
-
-// Called after an assertion failure.
-void PrettyUnitTestResultPrinter::OnTestPartResult(
-    const TestPartResult& result) {
-  // If the test part succeeded, we don't need to do anything.
-  if (result.type() == TestPartResult::kSuccess)
-    return;
-
-  // Print failure message from the assertion (e.g. expected this and got that).
-  PrintTestPartResult(result);
-  fflush(stdout);
-}
-
-void PrettyUnitTestResultPrinter::OnTestEnd(const TestInfo& test_info) {
-  if (test_info.result()->Passed()) {
-    ColoredPrintf(COLOR_GREEN, "[       OK ] ");
-  } else {
-    ColoredPrintf(COLOR_RED, "[  FAILED  ] ");
-  }
-  PrintTestName(test_case_name_.c_str(), test_info.name());
-  if (test_info.result()->Failed())
-    PrintFullTestCommentIfPresent(test_info);
-
-  if (GTEST_FLAG(print_time)) {
-    printf(" (%s ms)\n", internal::StreamableToString(
-           test_info.result()->elapsed_time()).c_str());
-  } else {
-    printf("\n");
-  }
-  fflush(stdout);
-}
-
-void PrettyUnitTestResultPrinter::OnTestCaseEnd(const TestCase& test_case) {
-  if (!GTEST_FLAG(print_time)) return;
-
-  test_case_name_ = test_case.name();
-  const internal::String counts =
-      FormatCountableNoun(test_case.test_to_run_count(), "test", "tests");
-  ColoredPrintf(COLOR_GREEN, "[----------] ");
-  printf("%s from %s (%s ms total)\n\n",
-         counts.c_str(), test_case_name_.c_str(),
-         internal::StreamableToString(test_case.elapsed_time()).c_str());
-  fflush(stdout);
-}
-
-void PrettyUnitTestResultPrinter::OnEnvironmentsTearDownStart(
-    const UnitTest& /*unit_test*/) {
-  ColoredPrintf(COLOR_GREEN,  "[----------] ");
-  printf("Global test environment tear-down\n");
-  fflush(stdout);
-}
-
-// Internal helper for printing the list of failed tests.
-void PrettyUnitTestResultPrinter::PrintFailedTests(const UnitTest& unit_test) {
-  const int failed_test_count = unit_test.failed_test_count();
-  if (failed_test_count == 0) {
-    return;
-  }
-
-  for (int i = 0; i < unit_test.total_test_case_count(); ++i) {
-    const TestCase& test_case = *unit_test.GetTestCase(i);
-    if (!test_case.should_run() || (test_case.failed_test_count() == 0)) {
-      continue;
-    }
-    for (int j = 0; j < test_case.total_test_count(); ++j) {
-      const TestInfo& test_info = *test_case.GetTestInfo(j);
-      if (!test_info.should_run() || test_info.result()->Passed()) {
-        continue;
-      }
-      ColoredPrintf(COLOR_RED, "[  FAILED  ] ");
-      printf("%s.%s", test_case.name(), test_info.name());
-      PrintFullTestCommentIfPresent(test_info);
-      printf("\n");
-    }
-  }
-}
-
-void PrettyUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
-                                                     int /*iteration*/) {
-  ColoredPrintf(COLOR_GREEN,  "[==========] ");
-  printf("%s from %s ran.",
-         FormatTestCount(unit_test.test_to_run_count()).c_str(),
-         FormatTestCaseCount(unit_test.test_case_to_run_count()).c_str());
-  if (GTEST_FLAG(print_time)) {
-    printf(" (%s ms total)",
-           internal::StreamableToString(unit_test.elapsed_time()).c_str());
-  }
-  printf("\n");
-  ColoredPrintf(COLOR_GREEN,  "[  PASSED  ] ");
-  printf("%s.\n", FormatTestCount(unit_test.successful_test_count()).c_str());
-
-  int num_failures = unit_test.failed_test_count();
-  if (!unit_test.Passed()) {
-    const int failed_test_count = unit_test.failed_test_count();
-    ColoredPrintf(COLOR_RED,  "[  FAILED  ] ");
-    printf("%s, listed below:\n", FormatTestCount(failed_test_count).c_str());
-    PrintFailedTests(unit_test);
-    printf("\n%2d FAILED %s\n", num_failures,
-                        num_failures == 1 ? "TEST" : "TESTS");
-  }
-
-  int num_disabled = unit_test.disabled_test_count();
-  if (num_disabled && !GTEST_FLAG(also_run_disabled_tests)) {
-    if (!num_failures) {
-      printf("\n");  // Add a spacer if no FAILURE banner is displayed.
-    }
-    ColoredPrintf(COLOR_YELLOW,
-                  "  YOU HAVE %d DISABLED %s\n\n",
-                  num_disabled,
-                  num_disabled == 1 ? "TEST" : "TESTS");
-  }
-  // Ensure that Google Test output is printed before, e.g., heapchecker output.
-  fflush(stdout);
-}
-
-// End PrettyUnitTestResultPrinter
-
-// class TestEventRepeater
-//
-// This class forwards events to other event listeners.
-class TestEventRepeater : public TestEventListener {
- public:
-  TestEventRepeater() : forwarding_enabled_(true) {}
-  virtual ~TestEventRepeater();
-  void Append(TestEventListener *listener);
-  TestEventListener* Release(TestEventListener* listener);
-
-  // Controls whether events will be forwarded to listeners_. Set to false
-  // in death test child processes.
-  bool forwarding_enabled() const { return forwarding_enabled_; }
-  void set_forwarding_enabled(bool enable) { forwarding_enabled_ = enable; }
-
-  virtual void OnTestProgramStart(const UnitTest& unit_test);
-  virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration);
-  virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test);
-  virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test);
-  virtual void OnTestCaseStart(const TestCase& test_case);
-  virtual void OnTestStart(const TestInfo& test_info);
-  virtual void OnTestPartResult(const TestPartResult& result);
-  virtual void OnTestEnd(const TestInfo& test_info);
-  virtual void OnTestCaseEnd(const TestCase& test_case);
-  virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test);
-  virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test);
-  virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration);
-  virtual void OnTestProgramEnd(const UnitTest& unit_test);
-
- private:
-  // Controls whether events will be forwarded to listeners_. Set to false
-  // in death test child processes.
-  bool forwarding_enabled_;
-  // The list of listeners that receive events.
-  std::vector<TestEventListener*> listeners_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventRepeater);
-};
-
-TestEventRepeater::~TestEventRepeater() {
-  ForEach(listeners_, Delete<TestEventListener>);
-}
-
-void TestEventRepeater::Append(TestEventListener *listener) {
-  listeners_.push_back(listener);
-}
-
-// TODO(vladl at google.com): Factor the search functionality into Vector::Find.
-TestEventListener* TestEventRepeater::Release(TestEventListener *listener) {
-  for (size_t i = 0; i < listeners_.size(); ++i) {
-    if (listeners_[i] == listener) {
-      listeners_.erase(listeners_.begin() + i);
-      return listener;
-    }
-  }
-
-  return NULL;
-}
-
-// Since most methods are very similar, use macros to reduce boilerplate.
-// This defines a member that forwards the call to all listeners.
-#define GTEST_REPEATER_METHOD_(Name, Type) \
-void TestEventRepeater::Name(const Type& parameter) { \
-  if (forwarding_enabled_) { \
-    for (size_t i = 0; i < listeners_.size(); i++) { \
-      listeners_[i]->Name(parameter); \
-    } \
-  } \
-}
-// This defines a member that forwards the call to all listeners in reverse
-// order.
-#define GTEST_REVERSE_REPEATER_METHOD_(Name, Type) \
-void TestEventRepeater::Name(const Type& parameter) { \
-  if (forwarding_enabled_) { \
-    for (int i = static_cast<int>(listeners_.size()) - 1; i >= 0; i--) { \
-      listeners_[i]->Name(parameter); \
-    } \
-  } \
-}
-
-GTEST_REPEATER_METHOD_(OnTestProgramStart, UnitTest)
-GTEST_REPEATER_METHOD_(OnEnvironmentsSetUpStart, UnitTest)
-GTEST_REPEATER_METHOD_(OnTestCaseStart, TestCase)
-GTEST_REPEATER_METHOD_(OnTestStart, TestInfo)
-GTEST_REPEATER_METHOD_(OnTestPartResult, TestPartResult)
-GTEST_REPEATER_METHOD_(OnEnvironmentsTearDownStart, UnitTest)
-GTEST_REVERSE_REPEATER_METHOD_(OnEnvironmentsSetUpEnd, UnitTest)
-GTEST_REVERSE_REPEATER_METHOD_(OnEnvironmentsTearDownEnd, UnitTest)
-GTEST_REVERSE_REPEATER_METHOD_(OnTestEnd, TestInfo)
-GTEST_REVERSE_REPEATER_METHOD_(OnTestCaseEnd, TestCase)
-GTEST_REVERSE_REPEATER_METHOD_(OnTestProgramEnd, UnitTest)
-
-#undef GTEST_REPEATER_METHOD_
-#undef GTEST_REVERSE_REPEATER_METHOD_
-
-void TestEventRepeater::OnTestIterationStart(const UnitTest& unit_test,
-                                             int iteration) {
-  if (forwarding_enabled_) {
-    for (size_t i = 0; i < listeners_.size(); i++) {
-      listeners_[i]->OnTestIterationStart(unit_test, iteration);
-    }
-  }
-}
-
-void TestEventRepeater::OnTestIterationEnd(const UnitTest& unit_test,
-                                           int iteration) {
-  if (forwarding_enabled_) {
-    for (int i = static_cast<int>(listeners_.size()) - 1; i >= 0; i--) {
-      listeners_[i]->OnTestIterationEnd(unit_test, iteration);
-    }
-  }
-}
-
-// End TestEventRepeater
-
-// This class generates an XML output file.
-class XmlUnitTestResultPrinter : public EmptyTestEventListener {
- public:
-  explicit XmlUnitTestResultPrinter(const char* output_file);
-
-  virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration);
-
- private:
-  // Is c a whitespace character that is normalized to a space character
-  // when it appears in an XML attribute value?
-  static bool IsNormalizableWhitespace(char c) {
-    return c == 0x9 || c == 0xA || c == 0xD;
-  }
-
-  // May c appear in a well-formed XML document?
-  static bool IsValidXmlCharacter(char c) {
-    return IsNormalizableWhitespace(c) || c >= 0x20;
-  }
-
-  // Returns an XML-escaped copy of the input string str.  If
-  // is_attribute is true, the text is meant to appear as an attribute
-  // value, and normalizable whitespace is preserved by replacing it
-  // with character references.
-  static String EscapeXml(const char* str, bool is_attribute);
-
-  // Returns the given string with all characters invalid in XML removed.
-  static string RemoveInvalidXmlCharacters(const string& str);
-
-  // Convenience wrapper around EscapeXml when str is an attribute value.
-  static String EscapeXmlAttribute(const char* str) {
-    return EscapeXml(str, true);
-  }
-
-  // Convenience wrapper around EscapeXml when str is not an attribute value.
-  static String EscapeXmlText(const char* str) { return EscapeXml(str, false); }
-
-  // Streams an XML CDATA section, escaping invalid CDATA sequences as needed.
-  static void OutputXmlCDataSection(::std::ostream* stream, const char* data);
-
-  // Streams an XML representation of a TestInfo object.
-  static void OutputXmlTestInfo(::std::ostream* stream,
-                                const char* test_case_name,
-                                const TestInfo& test_info);
-
-  // Prints an XML representation of a TestCase object
-  static void PrintXmlTestCase(FILE* out, const TestCase& test_case);
-
-  // Prints an XML summary of unit_test to output stream out.
-  static void PrintXmlUnitTest(FILE* out, const UnitTest& unit_test);
-
-  // Produces a string representing the test properties in a result as space
-  // delimited XML attributes based on the property key="value" pairs.
-  // When the String is not empty, it includes a space at the beginning,
-  // to delimit this attribute from prior attributes.
-  static String TestPropertiesAsXmlAttributes(const TestResult& result);
-
-  // The output file.
-  const String output_file_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(XmlUnitTestResultPrinter);
-};
-
-// Creates a new XmlUnitTestResultPrinter.
-XmlUnitTestResultPrinter::XmlUnitTestResultPrinter(const char* output_file)
-    : output_file_(output_file) {
-  if (output_file_.c_str() == NULL || output_file_.empty()) {
-    fprintf(stderr, "XML output file may not be null\n");
-    fflush(stderr);
-    exit(EXIT_FAILURE);
-  }
-}
-
-// Called after the unit test ends.
-void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
-                                                  int /*iteration*/) {
-  FILE* xmlout = NULL;
-  FilePath output_file(output_file_);
-  FilePath output_dir(output_file.RemoveFileName());
-
-  if (output_dir.CreateDirectoriesRecursively()) {
-    xmlout = posix::FOpen(output_file_.c_str(), "w");
-  }
-  if (xmlout == NULL) {
-    // TODO(wan): report the reason of the failure.
-    //
-    // We don't do it for now as:
-    //
-    //   1. There is no urgent need for it.
-    //   2. It's a bit involved to make the errno variable thread-safe on
-    //      all three operating systems (Linux, Windows, and Mac OS).
-    //   3. To interpret the meaning of errno in a thread-safe way,
-    //      we need the strerror_r() function, which is not available on
-    //      Windows.
-    fprintf(stderr,
-            "Unable to open file \"%s\"\n",
-            output_file_.c_str());
-    fflush(stderr);
-    exit(EXIT_FAILURE);
-  }
-  PrintXmlUnitTest(xmlout, unit_test);
-  fclose(xmlout);
-}
-
-// Returns an XML-escaped copy of the input string str.  If is_attribute
-// is true, the text is meant to appear as an attribute value, and
-// normalizable whitespace is preserved by replacing it with character
-// references.
-//
-// Invalid XML characters in str, if any, are stripped from the output.
-// It is expected that most, if not all, of the text processed by this
-// module will consist of ordinary English text.
-// If this module is ever modified to produce version 1.1 XML output,
-// most invalid characters can be retained using character references.
-// TODO(wan): It might be nice to have a minimally invasive, human-readable
-// escaping scheme for invalid characters, rather than dropping them.
-String XmlUnitTestResultPrinter::EscapeXml(const char* str, bool is_attribute) {
-  Message m;
-
-  if (str != NULL) {
-    for (const char* src = str; *src; ++src) {
-      switch (*src) {
-        case '<':
-          m << "<";
-          break;
-        case '>':
-          m << ">";
-          break;
-        case '&':
-          m << "&";
-          break;
-        case '\'':
-          if (is_attribute)
-            m << "'";
-          else
-            m << '\'';
-          break;
-        case '"':
-          if (is_attribute)
-            m << """;
-          else
-            m << '"';
-          break;
-        default:
-          if (IsValidXmlCharacter(*src)) {
-            if (is_attribute && IsNormalizableWhitespace(*src))
-              m << String::Format("&#x%02X;", unsigned(*src));
-            else
-              m << *src;
-          }
-          break;
-      }
-    }
-  }
-
-  return m.GetString();
-}
-
-// Returns the given string with all characters invalid in XML removed.
-// Currently invalid characters are dropped from the string. An
-// alternative is to replace them with certain characters such as . or ?.
-string XmlUnitTestResultPrinter::RemoveInvalidXmlCharacters(const string& str) {
-  string output;
-  output.reserve(str.size());
-  for (string::const_iterator it = str.begin(); it != str.end(); ++it)
-    if (IsValidXmlCharacter(*it))
-      output.push_back(*it);
-
-  return output;
-}
-
-// The following routines generate an XML representation of a UnitTest
-// object.
-//
-// This is how Google Test concepts map to the DTD:
-//
-// <testsuites name="AllTests">        <-- corresponds to a UnitTest object
-//   <testsuite name="testcase-name">  <-- corresponds to a TestCase object
-//     <testcase name="test-name">     <-- corresponds to a TestInfo object
-//       <failure message="...">...</failure>
-//       <failure message="...">...</failure>
-//       <failure message="...">...</failure>
-//                                     <-- individual assertion failures
-//     </testcase>
-//   </testsuite>
-// </testsuites>
-
-// Formats the given time in milliseconds as seconds.
-std::string FormatTimeInMillisAsSeconds(TimeInMillis ms) {
-  ::std::stringstream ss;
-  ss << ms/1000.0;
-  return ss.str();
-}
-
-// Streams an XML CDATA section, escaping invalid CDATA sequences as needed.
-void XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream,
-                                                     const char* data) {
-  const char* segment = data;
-  *stream << "<![CDATA[";
-  for (;;) {
-    const char* const next_segment = strstr(segment, "]]>");
-    if (next_segment != NULL) {
-      stream->write(
-          segment, static_cast<std::streamsize>(next_segment - segment));
-      *stream << "]]>]]><![CDATA[";
-      segment = next_segment + strlen("]]>");
-    } else {
-      *stream << segment;
-      break;
-    }
-  }
-  *stream << "]]>";
-}
-
-// Prints an XML representation of a TestInfo object.
-// TODO(wan): There is also value in printing properties with the plain printer.
-void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
-                                                 const char* test_case_name,
-                                                 const TestInfo& test_info) {
-  const TestResult& result = *test_info.result();
-  *stream << "    <testcase name=\""
-          << EscapeXmlAttribute(test_info.name()).c_str() << "\"";
-
-  if (test_info.value_param() != NULL) {
-    *stream << " value_param=\"" << EscapeXmlAttribute(test_info.value_param())
-            << "\"";
-  }
-  if (test_info.type_param() != NULL) {
-    *stream << " type_param=\"" << EscapeXmlAttribute(test_info.type_param())
-            << "\"";
-  }
-
-  *stream << " status=\""
-          << (test_info.should_run() ? "run" : "notrun")
-          << "\" time=\""
-          << FormatTimeInMillisAsSeconds(result.elapsed_time())
-          << "\" classname=\"" << EscapeXmlAttribute(test_case_name).c_str()
-          << "\"" << TestPropertiesAsXmlAttributes(result).c_str();
-
-  int failures = 0;
-  for (int i = 0; i < result.total_part_count(); ++i) {
-    const TestPartResult& part = result.GetTestPartResult(i);
-    if (part.failed()) {
-      if (++failures == 1)
-        *stream << ">\n";
-      *stream << "      <failure message=\""
-              << EscapeXmlAttribute(part.summary()).c_str()
-              << "\" type=\"\">";
-      const string location = internal::FormatCompilerIndependentFileLocation(
-          part.file_name(), part.line_number());
-      const string message = location + "\n" + part.message();
-      OutputXmlCDataSection(stream,
-                            RemoveInvalidXmlCharacters(message).c_str());
-      *stream << "</failure>\n";
-    }
-  }
-
-  if (failures == 0)
-    *stream << " />\n";
-  else
-    *stream << "    </testcase>\n";
-}
-
-// Prints an XML representation of a TestCase object
-void XmlUnitTestResultPrinter::PrintXmlTestCase(FILE* out,
-                                                const TestCase& test_case) {
-  fprintf(out,
-          "  <testsuite name=\"%s\" tests=\"%d\" failures=\"%d\" "
-          "disabled=\"%d\" ",
-          EscapeXmlAttribute(test_case.name()).c_str(),
-          test_case.total_test_count(),
-          test_case.failed_test_count(),
-          test_case.disabled_test_count());
-  fprintf(out,
-          "errors=\"0\" time=\"%s\">\n",
-          FormatTimeInMillisAsSeconds(test_case.elapsed_time()).c_str());
-  for (int i = 0; i < test_case.total_test_count(); ++i) {
-    ::std::stringstream stream;
-    OutputXmlTestInfo(&stream, test_case.name(), *test_case.GetTestInfo(i));
-    fprintf(out, "%s", StringStreamToString(&stream).c_str());
-  }
-  fprintf(out, "  </testsuite>\n");
-}
-
-// Prints an XML summary of unit_test to output stream out.
-void XmlUnitTestResultPrinter::PrintXmlUnitTest(FILE* out,
-                                                const UnitTest& unit_test) {
-  fprintf(out, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
-  fprintf(out,
-          "<testsuites tests=\"%d\" failures=\"%d\" disabled=\"%d\" "
-          "errors=\"0\" time=\"%s\" ",
-          unit_test.total_test_count(),
-          unit_test.failed_test_count(),
-          unit_test.disabled_test_count(),
-          FormatTimeInMillisAsSeconds(unit_test.elapsed_time()).c_str());
-  if (GTEST_FLAG(shuffle)) {
-    fprintf(out, "random_seed=\"%d\" ", unit_test.random_seed());
-  }
-  fprintf(out, "name=\"AllTests\">\n");
-  for (int i = 0; i < unit_test.total_test_case_count(); ++i)
-    PrintXmlTestCase(out, *unit_test.GetTestCase(i));
-  fprintf(out, "</testsuites>\n");
-}
-
-// Produces a string representing the test properties in a result as space
-// delimited XML attributes based on the property key="value" pairs.
-String XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes(
-    const TestResult& result) {
-  Message attributes;
-  for (int i = 0; i < result.test_property_count(); ++i) {
-    const TestProperty& property = result.GetTestProperty(i);
-    attributes << " " << property.key() << "="
-        << "\"" << EscapeXmlAttribute(property.value()) << "\"";
-  }
-  return attributes.GetString();
-}
-
-// End XmlUnitTestResultPrinter
-
-#if GTEST_CAN_STREAM_RESULTS_
-
-// Streams test results to the given port on the given host machine.
-class StreamingListener : public EmptyTestEventListener {
- public:
-  // Escapes '=', '&', '%', and '\n' characters in str as "%xx".
-  static string UrlEncode(const char* str);
-
-  StreamingListener(const string& host, const string& port)
-      : sockfd_(-1), host_name_(host), port_num_(port) {
-    MakeConnection();
-    Send("gtest_streaming_protocol_version=1.0\n");
-  }
-
-  virtual ~StreamingListener() {
-    if (sockfd_ != -1)
-      CloseConnection();
-  }
-
-  void OnTestProgramStart(const UnitTest& /* unit_test */) {
-    Send("event=TestProgramStart\n");
-  }
-
-  void OnTestProgramEnd(const UnitTest& unit_test) {
-    // Note that Google Test current only report elapsed time for each
-    // test iteration, not for the entire test program.
-    Send(String::Format("event=TestProgramEnd&passed=%d\n",
-                        unit_test.Passed()));
-
-    // Notify the streaming server to stop.
-    CloseConnection();
-  }
-
-  void OnTestIterationStart(const UnitTest& /* unit_test */, int iteration) {
-    Send(String::Format("event=TestIterationStart&iteration=%d\n",
-                        iteration));
-  }
-
-  void OnTestIterationEnd(const UnitTest& unit_test, int /* iteration */) {
-    Send(String::Format("event=TestIterationEnd&passed=%d&elapsed_time=%sms\n",
-                        unit_test.Passed(),
-                        StreamableToString(unit_test.elapsed_time()).c_str()));
-  }
-
-  void OnTestCaseStart(const TestCase& test_case) {
-    Send(String::Format("event=TestCaseStart&name=%s\n", test_case.name()));
-  }
-
-  void OnTestCaseEnd(const TestCase& test_case) {
-    Send(String::Format("event=TestCaseEnd&passed=%d&elapsed_time=%sms\n",
-                        test_case.Passed(),
-                        StreamableToString(test_case.elapsed_time()).c_str()));
-  }
-
-  void OnTestStart(const TestInfo& test_info) {
-    Send(String::Format("event=TestStart&name=%s\n", test_info.name()));
-  }
-
-  void OnTestEnd(const TestInfo& test_info) {
-    Send(String::Format(
-        "event=TestEnd&passed=%d&elapsed_time=%sms\n",
-        (test_info.result())->Passed(),
-        StreamableToString((test_info.result())->elapsed_time()).c_str()));
-  }
-
-  void OnTestPartResult(const TestPartResult& test_part_result) {
-    const char* file_name = test_part_result.file_name();
-    if (file_name == NULL)
-      file_name = "";
-    Send(String::Format("event=TestPartResult&file=%s&line=%d&message=",
-                        UrlEncode(file_name).c_str(),
-                        test_part_result.line_number()));
-    Send(UrlEncode(test_part_result.message()) + "\n");
-  }
-
- private:
-  // Creates a client socket and connects to the server.
-  void MakeConnection();
-
-  // Closes the socket.
-  void CloseConnection() {
-    GTEST_CHECK_(sockfd_ != -1)
-        << "CloseConnection() can be called only when there is a connection.";
-
-    close(sockfd_);
-    sockfd_ = -1;
-  }
-
-  // Sends a string to the socket.
-  void Send(const string& message) {
-    GTEST_CHECK_(sockfd_ != -1)
-        << "Send() can be called only when there is a connection.";
-
-    const int len = static_cast<int>(message.length());
-    if (write(sockfd_, message.c_str(), len) != len) {
-      GTEST_LOG_(WARNING)
-          << "stream_result_to: failed to stream to "
-          << host_name_ << ":" << port_num_;
-    }
-  }
-
-  int sockfd_;   // socket file descriptor
-  const string host_name_;
-  const string port_num_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamingListener);
-};  // class StreamingListener
-
-// Checks if str contains '=', '&', '%' or '\n' characters. If yes,
-// replaces them by "%xx" where xx is their hexadecimal value. For
-// example, replaces "=" with "%3D".  This algorithm is O(strlen(str))
-// in both time and space -- important as the input str may contain an
-// arbitrarily long test failure message and stack trace.
-string StreamingListener::UrlEncode(const char* str) {
-  string result;
-  result.reserve(strlen(str) + 1);
-  for (char ch = *str; ch != '\0'; ch = *++str) {
-    switch (ch) {
-      case '%':
-      case '=':
-      case '&':
-      case '\n':
-        result.append(String::Format("%%%02x", static_cast<unsigned char>(ch)));
-        break;
-      default:
-        result.push_back(ch);
-        break;
-    }
-  }
-  return result;
-}
-
-void StreamingListener::MakeConnection() {
-  GTEST_CHECK_(sockfd_ == -1)
-      << "MakeConnection() can't be called when there is already a connection.";
-
-  addrinfo hints;
-  memset(&hints, 0, sizeof(hints));
-  hints.ai_family = AF_UNSPEC;    // To allow both IPv4 and IPv6 addresses.
-  hints.ai_socktype = SOCK_STREAM;
-  addrinfo* servinfo = NULL;
-
-  // Use the getaddrinfo() to get a linked list of IP addresses for
-  // the given host name.
-  const int error_num = getaddrinfo(
-      host_name_.c_str(), port_num_.c_str(), &hints, &servinfo);
-  if (error_num != 0) {
-    GTEST_LOG_(WARNING) << "stream_result_to: getaddrinfo() failed: "
-                        << gai_strerror(error_num);
-  }
-
-  // Loop through all the results and connect to the first we can.
-  for (addrinfo* cur_addr = servinfo; sockfd_ == -1 && cur_addr != NULL;
-       cur_addr = cur_addr->ai_next) {
-    sockfd_ = socket(
-        cur_addr->ai_family, cur_addr->ai_socktype, cur_addr->ai_protocol);
-    if (sockfd_ != -1) {
-      // Connect the client socket to the server socket.
-      if (connect(sockfd_, cur_addr->ai_addr, cur_addr->ai_addrlen) == -1) {
-        close(sockfd_);
-        sockfd_ = -1;
-      }
-    }
-  }
-
-  freeaddrinfo(servinfo);  // all done with this structure
-
-  if (sockfd_ == -1) {
-    GTEST_LOG_(WARNING) << "stream_result_to: failed to connect to "
-                        << host_name_ << ":" << port_num_;
-  }
-}
-
-// End of class Streaming Listener
-#endif  // GTEST_CAN_STREAM_RESULTS__
-
-// Class ScopedTrace
-
-// Pushes the given source file location and message onto a per-thread
-// trace stack maintained by Google Test.
-// L < UnitTest::mutex_
-ScopedTrace::ScopedTrace(const char* file, int line, const Message& message) {
-  TraceInfo trace;
-  trace.file = file;
-  trace.line = line;
-  trace.message = message.GetString();
-
-  UnitTest::GetInstance()->PushGTestTrace(trace);
-}
-
-// Pops the info pushed by the c'tor.
-// L < UnitTest::mutex_
-ScopedTrace::~ScopedTrace() {
-  UnitTest::GetInstance()->PopGTestTrace();
-}
-
-
-// class OsStackTraceGetter
-
-// Returns the current OS stack trace as a String.  Parameters:
-//
-//   max_depth  - the maximum number of stack frames to be included
-//                in the trace.
-//   skip_count - the number of top frames to be skipped; doesn't count
-//                against max_depth.
-//
-// L < mutex_
-// We use "L < mutex_" to denote that the function may acquire mutex_.
-String OsStackTraceGetter::CurrentStackTrace(int, int) {
-  return String("");
-}
-
-// L < mutex_
-void OsStackTraceGetter::UponLeavingGTest() {
-}
-
-const char* const
-OsStackTraceGetter::kElidedFramesMarker =
-    "... " GTEST_NAME_ " internal frames ...";
-
-}  // namespace internal
-
-// class TestEventListeners
-
-TestEventListeners::TestEventListeners()
-    : repeater_(new internal::TestEventRepeater()),
-      default_result_printer_(NULL),
-      default_xml_generator_(NULL) {
-}
-
-TestEventListeners::~TestEventListeners() { delete repeater_; }
-
-// Returns the standard listener responsible for the default console
-// output.  Can be removed from the listeners list to shut down default
-// console output.  Note that removing this object from the listener list
-// with Release transfers its ownership to the user.
-void TestEventListeners::Append(TestEventListener* listener) {
-  repeater_->Append(listener);
-}
-
-// Removes the given event listener from the list and returns it.  It then
-// becomes the caller's responsibility to delete the listener. Returns
-// NULL if the listener is not found in the list.
-TestEventListener* TestEventListeners::Release(TestEventListener* listener) {
-  if (listener == default_result_printer_)
-    default_result_printer_ = NULL;
-  else if (listener == default_xml_generator_)
-    default_xml_generator_ = NULL;
-  return repeater_->Release(listener);
-}
-
-// Returns repeater that broadcasts the TestEventListener events to all
-// subscribers.
-TestEventListener* TestEventListeners::repeater() { return repeater_; }
-
-// Sets the default_result_printer attribute to the provided listener.
-// The listener is also added to the listener list and previous
-// default_result_printer is removed from it and deleted. The listener can
-// also be NULL in which case it will not be added to the list. Does
-// nothing if the previous and the current listener objects are the same.
-void TestEventListeners::SetDefaultResultPrinter(TestEventListener* listener) {
-  if (default_result_printer_ != listener) {
-    // It is an error to pass this method a listener that is already in the
-    // list.
-    delete Release(default_result_printer_);
-    default_result_printer_ = listener;
-    if (listener != NULL)
-      Append(listener);
-  }
-}
-
-// Sets the default_xml_generator attribute to the provided listener.  The
-// listener is also added to the listener list and previous
-// default_xml_generator is removed from it and deleted. The listener can
-// also be NULL in which case it will not be added to the list. Does
-// nothing if the previous and the current listener objects are the same.
-void TestEventListeners::SetDefaultXmlGenerator(TestEventListener* listener) {
-  if (default_xml_generator_ != listener) {
-    // It is an error to pass this method a listener that is already in the
-    // list.
-    delete Release(default_xml_generator_);
-    default_xml_generator_ = listener;
-    if (listener != NULL)
-      Append(listener);
-  }
-}
-
-// Controls whether events will be forwarded by the repeater to the
-// listeners in the list.
-bool TestEventListeners::EventForwardingEnabled() const {
-  return repeater_->forwarding_enabled();
-}
-
-void TestEventListeners::SuppressEventForwarding() {
-  repeater_->set_forwarding_enabled(false);
-}
-
-// class UnitTest
-
-// Gets the singleton UnitTest object.  The first time this method is
-// called, a UnitTest object is constructed and returned.  Consecutive
-// calls will return the same object.
-//
-// We don't protect this under mutex_ as a user is not supposed to
-// call this before main() starts, from which point on the return
-// value will never change.
-UnitTest * UnitTest::GetInstance() {
-  // When compiled with MSVC 7.1 in optimized mode, destroying the
-  // UnitTest object upon exiting the program messes up the exit code,
-  // causing successful tests to appear failed.  We have to use a
-  // different implementation in this case to bypass the compiler bug.
-  // This implementation makes the compiler happy, at the cost of
-  // leaking the UnitTest object.
-
-  // CodeGear C++Builder insists on a public destructor for the
-  // default implementation.  Use this implementation to keep good OO
-  // design with private destructor.
-
-#if (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)
-  static UnitTest* const instance = new UnitTest;
-  return instance;
-#else
-  static UnitTest instance;
-  return &instance;
-#endif  // (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)
-}
-
-// Gets the number of successful test cases.
-int UnitTest::successful_test_case_count() const {
-  return impl()->successful_test_case_count();
-}
-
-// Gets the number of failed test cases.
-int UnitTest::failed_test_case_count() const {
-  return impl()->failed_test_case_count();
-}
-
-// Gets the number of all test cases.
-int UnitTest::total_test_case_count() const {
-  return impl()->total_test_case_count();
-}
-
-// Gets the number of all test cases that contain at least one test
-// that should run.
-int UnitTest::test_case_to_run_count() const {
-  return impl()->test_case_to_run_count();
-}
-
-// Gets the number of successful tests.
-int UnitTest::successful_test_count() const {
-  return impl()->successful_test_count();
-}
-
-// Gets the number of failed tests.
-int UnitTest::failed_test_count() const { return impl()->failed_test_count(); }
-
-// Gets the number of disabled tests.
-int UnitTest::disabled_test_count() const {
-  return impl()->disabled_test_count();
-}
-
-// Gets the number of all tests.
-int UnitTest::total_test_count() const { return impl()->total_test_count(); }
-
-// Gets the number of tests that should run.
-int UnitTest::test_to_run_count() const { return impl()->test_to_run_count(); }
-
-// Gets the elapsed time, in milliseconds.
-internal::TimeInMillis UnitTest::elapsed_time() const {
-  return impl()->elapsed_time();
-}
-
-// Returns true iff the unit test passed (i.e. all test cases passed).
-bool UnitTest::Passed() const { return impl()->Passed(); }
-
-// Returns true iff the unit test failed (i.e. some test case failed
-// or something outside of all tests failed).
-bool UnitTest::Failed() const { return impl()->Failed(); }
-
-// Gets the i-th test case among all the test cases. i can range from 0 to
-// total_test_case_count() - 1. If i is not in that range, returns NULL.
-const TestCase* UnitTest::GetTestCase(int i) const {
-  return impl()->GetTestCase(i);
-}
-
-// Gets the i-th test case among all the test cases. i can range from 0 to
-// total_test_case_count() - 1. If i is not in that range, returns NULL.
-TestCase* UnitTest::GetMutableTestCase(int i) {
-  return impl()->GetMutableTestCase(i);
-}
-
-// Returns the list of event listeners that can be used to track events
-// inside Google Test.
-TestEventListeners& UnitTest::listeners() {
-  return *impl()->listeners();
-}
-
-// Registers and returns a global test environment.  When a test
-// program is run, all global test environments will be set-up in the
-// order they were registered.  After all tests in the program have
-// finished, all global test environments will be torn-down in the
-// *reverse* order they were registered.
-//
-// The UnitTest object takes ownership of the given environment.
-//
-// We don't protect this under mutex_, as we only support calling it
-// from the main thread.
-Environment* UnitTest::AddEnvironment(Environment* env) {
-  if (env == NULL) {
-    return NULL;
-  }
-
-  impl_->environments().push_back(env);
-  return env;
-}
-
-// Adds a TestPartResult to the current TestResult object.  All Google Test
-// assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc) eventually call
-// this to report their results.  The user code should use the
-// assertion macros instead of calling this directly.
-// L < mutex_
-void UnitTest::AddTestPartResult(TestPartResult::Type result_type,
-                                 const char* file_name,
-                                 int line_number,
-                                 const internal::String& message,
-                                 const internal::String& os_stack_trace) {
-  Message msg;
-  msg << message;
-
-  internal::MutexLock lock(&mutex_);
-  if (impl_->gtest_trace_stack().size() > 0) {
-    msg << "\n" << GTEST_NAME_ << " trace:";
-
-    for (int i = static_cast<int>(impl_->gtest_trace_stack().size());
-         i > 0; --i) {
-      const internal::TraceInfo& trace = impl_->gtest_trace_stack()[i - 1];
-      msg << "\n" << internal::FormatFileLocation(trace.file, trace.line)
-          << " " << trace.message;
-    }
-  }
-
-  if (os_stack_trace.c_str() != NULL && !os_stack_trace.empty()) {
-    msg << internal::kStackTraceMarker << os_stack_trace;
-  }
-
-  const TestPartResult result =
-    TestPartResult(result_type, file_name, line_number,
-                   msg.GetString().c_str());
-  impl_->GetTestPartResultReporterForCurrentThread()->
-      ReportTestPartResult(result);
-
-  if (result_type != TestPartResult::kSuccess) {
-    // gtest_break_on_failure takes precedence over
-    // gtest_throw_on_failure.  This allows a user to set the latter
-    // in the code (perhaps in order to use Google Test assertions
-    // with another testing framework) and specify the former on the
-    // command line for debugging.
-    if (GTEST_FLAG(break_on_failure)) {
-#if GTEST_OS_WINDOWS
-      // Using DebugBreak on Windows allows gtest to still break into a debugger
-      // when a failure happens and both the --gtest_break_on_failure and
-      // the --gtest_catch_exceptions flags are specified.
-      DebugBreak();
-#else
-      // Dereference NULL through a volatile pointer to prevent the compiler
-      // from removing. We use this rather than abort() or __builtin_trap() for
-      // portability: Symbian doesn't implement abort() well, and some debuggers
-      // don't correctly trap abort().
-      *static_cast<volatile int*>(NULL) = 1;
-#endif  // GTEST_OS_WINDOWS
-    } else if (GTEST_FLAG(throw_on_failure)) {
-#if GTEST_HAS_EXCEPTIONS
-      throw GoogleTestFailureException(result);
-#else
-      // We cannot call abort() as it generates a pop-up in debug mode
-      // that cannot be suppressed in VC 7.1 or below.
-      exit(1);
-#endif
-    }
-  }
-}
-
-// Creates and adds a property to the current TestResult. If a property matching
-// the supplied value already exists, updates its value instead.
-void UnitTest::RecordPropertyForCurrentTest(const char* key,
-                                            const char* value) {
-  const TestProperty test_property(key, value);
-  impl_->current_test_result()->RecordProperty(test_property);
-}
-
-// Runs all tests in this UnitTest object and prints the result.
-// Returns 0 if successful, or 1 otherwise.
-//
-// We don't protect this under mutex_, as we only support calling it
-// from the main thread.
-int UnitTest::Run() {
-  // Captures the value of GTEST_FLAG(catch_exceptions).  This value will be
-  // used for the duration of the program.
-  impl()->set_catch_exceptions(GTEST_FLAG(catch_exceptions));
-
-#if GTEST_HAS_SEH
-  const bool in_death_test_child_process =
-      internal::GTEST_FLAG(internal_run_death_test).length() > 0;
-
-  // Either the user wants Google Test to catch exceptions thrown by the
-  // tests or this is executing in the context of death test child
-  // process. In either case the user does not want to see pop-up dialogs
-  // about crashes - they are expected.
-  if (impl()->catch_exceptions() || in_death_test_child_process) {
-
-# if !GTEST_OS_WINDOWS_MOBILE
-    // SetErrorMode doesn't exist on CE.
-    SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT |
-                 SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
-# endif  // !GTEST_OS_WINDOWS_MOBILE
-
-# if (defined(_MSC_VER) || GTEST_OS_WINDOWS_MINGW) && !GTEST_OS_WINDOWS_MOBILE
-    // Death test children can be terminated with _abort().  On Windows,
-    // _abort() can show a dialog with a warning message.  This forces the
-    // abort message to go to stderr instead.
-    _set_error_mode(_OUT_TO_STDERR);
-# endif
-
-# if _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE
-    // In the debug version, Visual Studio pops up a separate dialog
-    // offering a choice to debug the aborted program. We need to suppress
-    // this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement
-    // executed. Google Test will notify the user of any unexpected
-    // failure via stderr.
-    //
-    // VC++ doesn't define _set_abort_behavior() prior to the version 8.0.
-    // Users of prior VC versions shall suffer the agony and pain of
-    // clicking through the countless debug dialogs.
-    // TODO(vladl at google.com): find a way to suppress the abort dialog() in the
-    // debug mode when compiled with VC 7.1 or lower.
-    if (!GTEST_FLAG(break_on_failure))
-      _set_abort_behavior(
-          0x0,                                    // Clear the following flags:
-          _WRITE_ABORT_MSG | _CALL_REPORTFAULT);  // pop-up window, core dump.
-# endif
-
-  }
-#endif  // GTEST_HAS_SEH
-
-  return internal::HandleExceptionsInMethodIfSupported(
-      impl(),
-      &internal::UnitTestImpl::RunAllTests,
-      "auxiliary test code (environments or event listeners)") ? 0 : 1;
-}
-
-// Returns the working directory when the first TEST() or TEST_F() was
-// executed.
-const char* UnitTest::original_working_dir() const {
-  return impl_->original_working_dir_.c_str();
-}
-
-// Returns the TestCase object for the test that's currently running,
-// or NULL if no test is running.
-// L < mutex_
-const TestCase* UnitTest::current_test_case() const {
-  internal::MutexLock lock(&mutex_);
-  return impl_->current_test_case();
-}
-
-// Returns the TestInfo object for the test that's currently running,
-// or NULL if no test is running.
-// L < mutex_
-const TestInfo* UnitTest::current_test_info() const {
-  internal::MutexLock lock(&mutex_);
-  return impl_->current_test_info();
-}
-
-// Returns the random seed used at the start of the current test run.
-int UnitTest::random_seed() const { return impl_->random_seed(); }
-
-#if GTEST_HAS_PARAM_TEST
-// Returns ParameterizedTestCaseRegistry object used to keep track of
-// value-parameterized tests and instantiate and register them.
-// L < mutex_
-internal::ParameterizedTestCaseRegistry&
-    UnitTest::parameterized_test_registry() {
-  return impl_->parameterized_test_registry();
-}
-#endif  // GTEST_HAS_PARAM_TEST
-
-// Creates an empty UnitTest.
-UnitTest::UnitTest() {
-  impl_ = new internal::UnitTestImpl(this);
-}
-
-// Destructor of UnitTest.
-UnitTest::~UnitTest() {
-  delete impl_;
-}
-
-// Pushes a trace defined by SCOPED_TRACE() on to the per-thread
-// Google Test trace stack.
-// L < mutex_
-void UnitTest::PushGTestTrace(const internal::TraceInfo& trace) {
-  internal::MutexLock lock(&mutex_);
-  impl_->gtest_trace_stack().push_back(trace);
-}
-
-// Pops a trace from the per-thread Google Test trace stack.
-// L < mutex_
-void UnitTest::PopGTestTrace() {
-  internal::MutexLock lock(&mutex_);
-  impl_->gtest_trace_stack().pop_back();
-}
-
-namespace internal {
-
-UnitTestImpl::UnitTestImpl(UnitTest* parent)
-    : parent_(parent),
-#ifdef _MSC_VER
-# pragma warning(push)                    // Saves the current warning state.
-# pragma warning(disable:4355)            // Temporarily disables warning 4355
-                                         // (using this in initializer).
-      default_global_test_part_result_reporter_(this),
-      default_per_thread_test_part_result_reporter_(this),
-# pragma warning(pop)                     // Restores the warning state again.
-#else
-      default_global_test_part_result_reporter_(this),
-      default_per_thread_test_part_result_reporter_(this),
-#endif  // _MSC_VER
-      global_test_part_result_repoter_(
-          &default_global_test_part_result_reporter_),
-      per_thread_test_part_result_reporter_(
-          &default_per_thread_test_part_result_reporter_),
-#if GTEST_HAS_PARAM_TEST
-      parameterized_test_registry_(),
-      parameterized_tests_registered_(false),
-#endif  // GTEST_HAS_PARAM_TEST
-      last_death_test_case_(-1),
-      current_test_case_(NULL),
-      current_test_info_(NULL),
-      ad_hoc_test_result_(),
-      os_stack_trace_getter_(NULL),
-      post_flag_parse_init_performed_(false),
-      random_seed_(0),  // Will be overridden by the flag before first use.
-      random_(0),  // Will be reseeded before first use.
-      elapsed_time_(0),
-#if GTEST_HAS_DEATH_TEST
-      internal_run_death_test_flag_(NULL),
-      death_test_factory_(new DefaultDeathTestFactory),
-#endif
-      // Will be overridden by the flag before first use.
-      catch_exceptions_(false) {
-  listeners()->SetDefaultResultPrinter(new PrettyUnitTestResultPrinter);
-}
-
-UnitTestImpl::~UnitTestImpl() {
-  // Deletes every TestCase.
-  ForEach(test_cases_, internal::Delete<TestCase>);
-
-  // Deletes every Environment.
-  ForEach(environments_, internal::Delete<Environment>);
-
-  delete os_stack_trace_getter_;
-}
-
-#if GTEST_HAS_DEATH_TEST
-// Disables event forwarding if the control is currently in a death test
-// subprocess. Must not be called before InitGoogleTest.
-void UnitTestImpl::SuppressTestEventsIfInSubprocess() {
-  if (internal_run_death_test_flag_.get() != NULL)
-    listeners()->SuppressEventForwarding();
-}
-#endif  // GTEST_HAS_DEATH_TEST
-
-// Initializes event listeners performing XML output as specified by
-// UnitTestOptions. Must not be called before InitGoogleTest.
-void UnitTestImpl::ConfigureXmlOutput() {
-  const String& output_format = UnitTestOptions::GetOutputFormat();
-  if (output_format == "xml") {
-    listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter(
-        UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));
-  } else if (output_format != "") {
-    printf("WARNING: unrecognized output format \"%s\" ignored.\n",
-           output_format.c_str());
-    fflush(stdout);
-  }
-}
-
-#if GTEST_CAN_STREAM_RESULTS_
-// Initializes event listeners for streaming test results in String form.
-// Must not be called before InitGoogleTest.
-void UnitTestImpl::ConfigureStreamingOutput() {
-  const string& target = GTEST_FLAG(stream_result_to);
-  if (!target.empty()) {
-    const size_t pos = target.find(':');
-    if (pos != string::npos) {
-      listeners()->Append(new StreamingListener(target.substr(0, pos),
-                                                target.substr(pos+1)));
-    } else {
-      printf("WARNING: unrecognized streaming target \"%s\" ignored.\n",
-             target.c_str());
-      fflush(stdout);
-    }
-  }
-}
-#endif  // GTEST_CAN_STREAM_RESULTS_
-
-// Performs initialization dependent upon flag values obtained in
-// ParseGoogleTestFlagsOnly.  Is called from InitGoogleTest after the call to
-// ParseGoogleTestFlagsOnly.  In case a user neglects to call InitGoogleTest
-// this function is also called from RunAllTests.  Since this function can be
-// called more than once, it has to be idempotent.
-void UnitTestImpl::PostFlagParsingInit() {
-  // Ensures that this function does not execute more than once.
-  if (!post_flag_parse_init_performed_) {
-    post_flag_parse_init_performed_ = true;
-
-#if GTEST_HAS_DEATH_TEST
-    InitDeathTestSubprocessControlInfo();
-    SuppressTestEventsIfInSubprocess();
-#endif  // GTEST_HAS_DEATH_TEST
-
-    // Registers parameterized tests. This makes parameterized tests
-    // available to the UnitTest reflection API without running
-    // RUN_ALL_TESTS.
-    RegisterParameterizedTests();
-
-    // Configures listeners for XML output. This makes it possible for users
-    // to shut down the default XML output before invoking RUN_ALL_TESTS.
-    ConfigureXmlOutput();
-
-#if GTEST_CAN_STREAM_RESULTS_
-    // Configures listeners for streaming test results to the specified server.
-    ConfigureStreamingOutput();
-#endif  // GTEST_CAN_STREAM_RESULTS_
-  }
-}
-
-// A predicate that checks the name of a TestCase against a known
-// value.
-//
-// This is used for implementation of the UnitTest class only.  We put
-// it in the anonymous namespace to prevent polluting the outer
-// namespace.
-//
-// TestCaseNameIs is copyable.
-class TestCaseNameIs {
- public:
-  // Constructor.
-  explicit TestCaseNameIs(const String& name)
-      : name_(name) {}
-
-  // Returns true iff the name of test_case matches name_.
-  bool operator()(const TestCase* test_case) const {
-    return test_case != NULL && strcmp(test_case->name(), name_.c_str()) == 0;
-  }
-
- private:
-  String name_;
-};
-
-// Finds and returns a TestCase with the given name.  If one doesn't
-// exist, creates one and returns it.  It's the CALLER'S
-// RESPONSIBILITY to ensure that this function is only called WHEN THE
-// TESTS ARE NOT SHUFFLED.
-//
-// Arguments:
-//
-//   test_case_name: name of the test case
-//   type_param:     the name of the test case's type parameter, or NULL if
-//                   this is not a typed or a type-parameterized test case.
-//   set_up_tc:      pointer to the function that sets up the test case
-//   tear_down_tc:   pointer to the function that tears down the test case
-TestCase* UnitTestImpl::GetTestCase(const char* test_case_name,
-                                    const char* type_param,
-                                    Test::SetUpTestCaseFunc set_up_tc,
-                                    Test::TearDownTestCaseFunc tear_down_tc) {
-  // Can we find a TestCase with the given name?
-  const std::vector<TestCase*>::const_iterator test_case =
-      std::find_if(test_cases_.begin(), test_cases_.end(),
-                   TestCaseNameIs(test_case_name));
-
-  if (test_case != test_cases_.end())
-    return *test_case;
-
-  // No.  Let's create one.
-  TestCase* const new_test_case =
-      new TestCase(test_case_name, type_param, set_up_tc, tear_down_tc);
-
-  // Is this a death test case?
-  if (internal::UnitTestOptions::MatchesFilter(String(test_case_name),
-                                               kDeathTestCaseFilter)) {
-    // Yes.  Inserts the test case after the last death test case
-    // defined so far.  This only works when the test cases haven't
-    // been shuffled.  Otherwise we may end up running a death test
-    // after a non-death test.
-    ++last_death_test_case_;
-    test_cases_.insert(test_cases_.begin() + last_death_test_case_,
-                       new_test_case);
-  } else {
-    // No.  Appends to the end of the list.
-    test_cases_.push_back(new_test_case);
-  }
-
-  test_case_indices_.push_back(static_cast<int>(test_case_indices_.size()));
-  return new_test_case;
-}
-
-// Helpers for setting up / tearing down the given environment.  They
-// are for use in the ForEach() function.
-static void SetUpEnvironment(Environment* env) { env->SetUp(); }
-static void TearDownEnvironment(Environment* env) { env->TearDown(); }
-
-// Runs all tests in this UnitTest object, prints the result, and
-// returns true if all tests are successful.  If any exception is
-// thrown during a test, the test is considered to be failed, but the
-// rest of the tests will still be run.
-//
-// When parameterized tests are enabled, it expands and registers
-// parameterized tests first in RegisterParameterizedTests().
-// All other functions called from RunAllTests() may safely assume that
-// parameterized tests are ready to be counted and run.
-bool UnitTestImpl::RunAllTests() {
-  // Makes sure InitGoogleTest() was called.
-  if (!GTestIsInitialized()) {
-    printf("%s",
-           "\nThis test program did NOT call ::testing::InitGoogleTest "
-           "before calling RUN_ALL_TESTS().  Please fix it.\n");
-    return false;
-  }
-
-  // Do not run any test if the --help flag was specified.
-  if (g_help_flag)
-    return true;
-
-  // Repeats the call to the post-flag parsing initialization in case the
-  // user didn't call InitGoogleTest.
-  PostFlagParsingInit();
-
-  // Even if sharding is not on, test runners may want to use the
-  // GTEST_SHARD_STATUS_FILE to query whether the test supports the sharding
-  // protocol.
-  internal::WriteToShardStatusFileIfNeeded();
-
-  // True iff we are in a subprocess for running a thread-safe-style
-  // death test.
-  bool in_subprocess_for_death_test = false;
-
-#if GTEST_HAS_DEATH_TEST
-  in_subprocess_for_death_test = (internal_run_death_test_flag_.get() != NULL);
-#endif  // GTEST_HAS_DEATH_TEST
-
-  const bool should_shard = ShouldShard(kTestTotalShards, kTestShardIndex,
-                                        in_subprocess_for_death_test);
-
-  // Compares the full test names with the filter to decide which
-  // tests to run.
-  const bool has_tests_to_run = FilterTests(should_shard
-                                              ? HONOR_SHARDING_PROTOCOL
-                                              : IGNORE_SHARDING_PROTOCOL) > 0;
-
-  // Lists the tests and exits if the --gtest_list_tests flag was specified.
-  if (GTEST_FLAG(list_tests)) {
-    // This must be called *after* FilterTests() has been called.
-    ListTestsMatchingFilter();
-    return true;
-  }
-
-  random_seed_ = GTEST_FLAG(shuffle) ?
-      GetRandomSeedFromFlag(GTEST_FLAG(random_seed)) : 0;
-
-  // True iff at least one test has failed.
-  bool failed = false;
-
-  TestEventListener* repeater = listeners()->repeater();
-
-  repeater->OnTestProgramStart(*parent_);
-
-  // How many times to repeat the tests?  We don't want to repeat them
-  // when we are inside the subprocess of a death test.
-  const int repeat = in_subprocess_for_death_test ? 1 : GTEST_FLAG(repeat);
-  // Repeats forever if the repeat count is negative.
-  const bool forever = repeat < 0;
-  for (int i = 0; forever || i != repeat; i++) {
-    // We want to preserve failures generated by ad-hoc test
-    // assertions executed before RUN_ALL_TESTS().
-    ClearNonAdHocTestResult();
-
-    const TimeInMillis start = GetTimeInMillis();
-
-    // Shuffles test cases and tests if requested.
-    if (has_tests_to_run && GTEST_FLAG(shuffle)) {
-      random()->Reseed(random_seed_);
-      // This should be done before calling OnTestIterationStart(),
-      // such that a test event listener can see the actual test order
-      // in the event.
-      ShuffleTests();
-    }
-
-    // Tells the unit test event listeners that the tests are about to start.
-    repeater->OnTestIterationStart(*parent_, i);
-
-    // Runs each test case if there is at least one test to run.
-    if (has_tests_to_run) {
-      // Sets up all environments beforehand.
-      repeater->OnEnvironmentsSetUpStart(*parent_);
-      ForEach(environments_, SetUpEnvironment);
-      repeater->OnEnvironmentsSetUpEnd(*parent_);
-
-      // Runs the tests only if there was no fatal failure during global
-      // set-up.
-      if (!Test::HasFatalFailure()) {
-        for (int test_index = 0; test_index < total_test_case_count();
-             test_index++) {
-          GetMutableTestCase(test_index)->Run();
-        }
-      }
-
-      // Tears down all environments in reverse order afterwards.
-      repeater->OnEnvironmentsTearDownStart(*parent_);
-      std::for_each(environments_.rbegin(), environments_.rend(),
-                    TearDownEnvironment);
-      repeater->OnEnvironmentsTearDownEnd(*parent_);
-    }
-
-    elapsed_time_ = GetTimeInMillis() - start;
-
-    // Tells the unit test event listener that the tests have just finished.
-    repeater->OnTestIterationEnd(*parent_, i);
-
-    // Gets the result and clears it.
-    if (!Passed()) {
-      failed = true;
-    }
-
-    // Restores the original test order after the iteration.  This
-    // allows the user to quickly repro a failure that happens in the
-    // N-th iteration without repeating the first (N - 1) iterations.
-    // This is not enclosed in "if (GTEST_FLAG(shuffle)) { ... }", in
-    // case the user somehow changes the value of the flag somewhere
-    // (it's always safe to unshuffle the tests).
-    UnshuffleTests();
-
-    if (GTEST_FLAG(shuffle)) {
-      // Picks a new random seed for each iteration.
-      random_seed_ = GetNextRandomSeed(random_seed_);
-    }
-  }
-
-  repeater->OnTestProgramEnd(*parent_);
-
-  return !failed;
-}
-
-// Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file
-// if the variable is present. If a file already exists at this location, this
-// function will write over it. If the variable is present, but the file cannot
-// be created, prints an error and exits.
-void WriteToShardStatusFileIfNeeded() {
-  const char* const test_shard_file = posix::GetEnv(kTestShardStatusFile);
-  if (test_shard_file != NULL) {
-    FILE* const file = posix::FOpen(test_shard_file, "w");
-    if (file == NULL) {
-      ColoredPrintf(COLOR_RED,
-                    "Could not write to the test shard status file \"%s\" "
-                    "specified by the %s environment variable.\n",
-                    test_shard_file, kTestShardStatusFile);
-      fflush(stdout);
-      exit(EXIT_FAILURE);
-    }
-    fclose(file);
-  }
-}
-
-// Checks whether sharding is enabled by examining the relevant
-// environment variable values. If the variables are present,
-// but inconsistent (i.e., shard_index >= total_shards), prints
-// an error and exits. If in_subprocess_for_death_test, sharding is
-// disabled because it must only be applied to the original test
-// process. Otherwise, we could filter out death tests we intended to execute.
-bool ShouldShard(const char* total_shards_env,
-                 const char* shard_index_env,
-                 bool in_subprocess_for_death_test) {
-  if (in_subprocess_for_death_test) {
-    return false;
-  }
-
-  const Int32 total_shards = Int32FromEnvOrDie(total_shards_env, -1);
-  const Int32 shard_index = Int32FromEnvOrDie(shard_index_env, -1);
-
-  if (total_shards == -1 && shard_index == -1) {
-    return false;
-  } else if (total_shards == -1 && shard_index != -1) {
-    const Message msg = Message()
-      << "Invalid environment variables: you have "
-      << kTestShardIndex << " = " << shard_index
-      << ", but have left " << kTestTotalShards << " unset.\n";
-    ColoredPrintf(COLOR_RED, msg.GetString().c_str());
-    fflush(stdout);
-    exit(EXIT_FAILURE);
-  } else if (total_shards != -1 && shard_index == -1) {
-    const Message msg = Message()
-      << "Invalid environment variables: you have "
-      << kTestTotalShards << " = " << total_shards
-      << ", but have left " << kTestShardIndex << " unset.\n";
-    ColoredPrintf(COLOR_RED, msg.GetString().c_str());
-    fflush(stdout);
-    exit(EXIT_FAILURE);
-  } else if (shard_index < 0 || shard_index >= total_shards) {
-    const Message msg = Message()
-      << "Invalid environment variables: we require 0 <= "
-      << kTestShardIndex << " < " << kTestTotalShards
-      << ", but you have " << kTestShardIndex << "=" << shard_index
-      << ", " << kTestTotalShards << "=" << total_shards << ".\n";
-    ColoredPrintf(COLOR_RED, msg.GetString().c_str());
-    fflush(stdout);
-    exit(EXIT_FAILURE);
-  }
-
-  return total_shards > 1;
-}
-
-// Parses the environment variable var as an Int32. If it is unset,
-// returns default_val. If it is not an Int32, prints an error
-// and aborts.
-Int32 Int32FromEnvOrDie(const char* var, Int32 default_val) {
-  const char* str_val = posix::GetEnv(var);
-  if (str_val == NULL) {
-    return default_val;
-  }
-
-  Int32 result;
-  if (!ParseInt32(Message() << "The value of environment variable " << var,
-                  str_val, &result)) {
-    exit(EXIT_FAILURE);
-  }
-  return result;
-}
-
-// Given the total number of shards, the shard index, and the test id,
-// returns true iff the test should be run on this shard. The test id is
-// some arbitrary but unique non-negative integer assigned to each test
-// method. Assumes that 0 <= shard_index < total_shards.
-bool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id) {
-  return (test_id % total_shards) == shard_index;
-}
-
-// Compares the name of each test with the user-specified filter to
-// decide whether the test should be run, then records the result in
-// each TestCase and TestInfo object.
-// If shard_tests == true, further filters tests based on sharding
-// variables in the environment - see
-// http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide.
-// Returns the number of tests that should run.
-int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) {
-  const Int32 total_shards = shard_tests == HONOR_SHARDING_PROTOCOL ?
-      Int32FromEnvOrDie(kTestTotalShards, -1) : -1;
-  const Int32 shard_index = shard_tests == HONOR_SHARDING_PROTOCOL ?
-      Int32FromEnvOrDie(kTestShardIndex, -1) : -1;
-
-  // num_runnable_tests are the number of tests that will
-  // run across all shards (i.e., match filter and are not disabled).
-  // num_selected_tests are the number of tests to be run on
-  // this shard.
-  int num_runnable_tests = 0;
-  int num_selected_tests = 0;
-  for (size_t i = 0; i < test_cases_.size(); i++) {
-    TestCase* const test_case = test_cases_[i];
-    const String &test_case_name = test_case->name();
-    test_case->set_should_run(false);
-
-    for (size_t j = 0; j < test_case->test_info_list().size(); j++) {
-      TestInfo* const test_info = test_case->test_info_list()[j];
-      const String test_name(test_info->name());
-      // A test is disabled if test case name or test name matches
-      // kDisableTestFilter.
-      const bool is_disabled =
-          internal::UnitTestOptions::MatchesFilter(test_case_name,
-                                                   kDisableTestFilter) ||
-          internal::UnitTestOptions::MatchesFilter(test_name,
-                                                   kDisableTestFilter);
-      test_info->is_disabled_ = is_disabled;
-
-      const bool matches_filter =
-          internal::UnitTestOptions::FilterMatchesTest(test_case_name,
-                                                       test_name);
-      test_info->matches_filter_ = matches_filter;
-
-      const bool is_runnable =
-          (GTEST_FLAG(also_run_disabled_tests) || !is_disabled) &&
-          matches_filter;
-
-      const bool is_selected = is_runnable &&
-          (shard_tests == IGNORE_SHARDING_PROTOCOL ||
-           ShouldRunTestOnShard(total_shards, shard_index,
-                                num_runnable_tests));
-
-      num_runnable_tests += is_runnable;
-      num_selected_tests += is_selected;
-
-      test_info->should_run_ = is_selected;
-      test_case->set_should_run(test_case->should_run() || is_selected);
-    }
-  }
-  return num_selected_tests;
-}
-
-// Prints the names of the tests matching the user-specified filter flag.
-void UnitTestImpl::ListTestsMatchingFilter() {
-  for (size_t i = 0; i < test_cases_.size(); i++) {
-    const TestCase* const test_case = test_cases_[i];
-    bool printed_test_case_name = false;
-
-    for (size_t j = 0; j < test_case->test_info_list().size(); j++) {
-      const TestInfo* const test_info =
-          test_case->test_info_list()[j];
-      if (test_info->matches_filter_) {
-        if (!printed_test_case_name) {
-          printed_test_case_name = true;
-          printf("%s.\n", test_case->name());
-        }
-        printf("  %s\n", test_info->name());
-      }
-    }
-  }
-  fflush(stdout);
-}
-
-// Sets the OS stack trace getter.
-//
-// Does nothing if the input and the current OS stack trace getter are
-// the same; otherwise, deletes the old getter and makes the input the
-// current getter.
-void UnitTestImpl::set_os_stack_trace_getter(
-    OsStackTraceGetterInterface* getter) {
-  if (os_stack_trace_getter_ != getter) {
-    delete os_stack_trace_getter_;
-    os_stack_trace_getter_ = getter;
-  }
-}
-
-// Returns the current OS stack trace getter if it is not NULL;
-// otherwise, creates an OsStackTraceGetter, makes it the current
-// getter, and returns it.
-OsStackTraceGetterInterface* UnitTestImpl::os_stack_trace_getter() {
-  if (os_stack_trace_getter_ == NULL) {
-    os_stack_trace_getter_ = new OsStackTraceGetter;
-  }
-
-  return os_stack_trace_getter_;
-}
-
-// Returns the TestResult for the test that's currently running, or
-// the TestResult for the ad hoc test if no test is running.
-TestResult* UnitTestImpl::current_test_result() {
-  return current_test_info_ ?
-      &(current_test_info_->result_) : &ad_hoc_test_result_;
-}
-
-// Shuffles all test cases, and the tests within each test case,
-// making sure that death tests are still run first.
-void UnitTestImpl::ShuffleTests() {
-  // Shuffles the death test cases.
-  ShuffleRange(random(), 0, last_death_test_case_ + 1, &test_case_indices_);
-
-  // Shuffles the non-death test cases.
-  ShuffleRange(random(), last_death_test_case_ + 1,
-               static_cast<int>(test_cases_.size()), &test_case_indices_);
-
-  // Shuffles the tests inside each test case.
-  for (size_t i = 0; i < test_cases_.size(); i++) {
-    test_cases_[i]->ShuffleTests(random());
-  }
-}
-
-// Restores the test cases and tests to their order before the first shuffle.
-void UnitTestImpl::UnshuffleTests() {
-  for (size_t i = 0; i < test_cases_.size(); i++) {
-    // Unshuffles the tests in each test case.
-    test_cases_[i]->UnshuffleTests();
-    // Resets the index of each test case.
-    test_case_indices_[i] = static_cast<int>(i);
-  }
-}
-
-// Returns the current OS stack trace as a String.
-//
-// The maximum number of stack frames to be included is specified by
-// the gtest_stack_trace_depth flag.  The skip_count parameter
-// specifies the number of top frames to be skipped, which doesn't
-// count against the number of frames to be included.
-//
-// For example, if Foo() calls Bar(), which in turn calls
-// GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in
-// the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.
-String GetCurrentOsStackTraceExceptTop(UnitTest* /*unit_test*/,
-                                       int skip_count) {
-  // We pass skip_count + 1 to skip this wrapper function in addition
-  // to what the user really wants to skip.
-  return GetUnitTestImpl()->CurrentOsStackTraceExceptTop(skip_count + 1);
-}
-
-// Used by the GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_ macro to
-// suppress unreachable code warnings.
-namespace {
-class ClassUniqueToAlwaysTrue {};
-}
-
-bool IsTrue(bool condition) { return condition; }
-
-bool AlwaysTrue() {
-#if GTEST_HAS_EXCEPTIONS
-  // This condition is always false so AlwaysTrue() never actually throws,
-  // but it makes the compiler think that it may throw.
-  if (IsTrue(false))
-    throw ClassUniqueToAlwaysTrue();
-#endif  // GTEST_HAS_EXCEPTIONS
-  return true;
-}
-
-// If *pstr starts with the given prefix, modifies *pstr to be right
-// past the prefix and returns true; otherwise leaves *pstr unchanged
-// and returns false.  None of pstr, *pstr, and prefix can be NULL.
-bool SkipPrefix(const char* prefix, const char** pstr) {
-  const size_t prefix_len = strlen(prefix);
-  if (strncmp(*pstr, prefix, prefix_len) == 0) {
-    *pstr += prefix_len;
-    return true;
-  }
-  return false;
-}
-
-// Parses a string as a command line flag.  The string should have
-// the format "--flag=value".  When def_optional is true, the "=value"
-// part can be omitted.
-//
-// Returns the value of the flag, or NULL if the parsing failed.
-const char* ParseFlagValue(const char* str,
-                           const char* flag,
-                           bool def_optional) {
-  // str and flag must not be NULL.
-  if (str == NULL || flag == NULL) return NULL;
-
-  // The flag must start with "--" followed by GTEST_FLAG_PREFIX_.
-  const String flag_str = String::Format("--%s%s", GTEST_FLAG_PREFIX_, flag);
-  const size_t flag_len = flag_str.length();
-  if (strncmp(str, flag_str.c_str(), flag_len) != 0) return NULL;
-
-  // Skips the flag name.
-  const char* flag_end = str + flag_len;
-
-  // When def_optional is true, it's OK to not have a "=value" part.
-  if (def_optional && (flag_end[0] == '\0')) {
-    return flag_end;
-  }
-
-  // If def_optional is true and there are more characters after the
-  // flag name, or if def_optional is false, there must be a '=' after
-  // the flag name.
-  if (flag_end[0] != '=') return NULL;
-
-  // Returns the string after "=".
-  return flag_end + 1;
-}
-
-// Parses a string for a bool flag, in the form of either
-// "--flag=value" or "--flag".
-//
-// In the former case, the value is taken as true as long as it does
-// not start with '0', 'f', or 'F'.
-//
-// In the latter case, the value is taken as true.
-//
-// On success, stores the value of the flag in *value, and returns
-// true.  On failure, returns false without changing *value.
-bool ParseBoolFlag(const char* str, const char* flag, bool* value) {
-  // Gets the value of the flag as a string.
-  const char* const value_str = ParseFlagValue(str, flag, true);
-
-  // Aborts if the parsing failed.
-  if (value_str == NULL) return false;
-
-  // Converts the string value to a bool.
-  *value = !(*value_str == '0' || *value_str == 'f' || *value_str == 'F');
-  return true;
-}
-
-// Parses a string for an Int32 flag, in the form of
-// "--flag=value".
-//
-// On success, stores the value of the flag in *value, and returns
-// true.  On failure, returns false without changing *value.
-bool ParseInt32Flag(const char* str, const char* flag, Int32* value) {
-  // Gets the value of the flag as a string.
-  const char* const value_str = ParseFlagValue(str, flag, false);
-
-  // Aborts if the parsing failed.
-  if (value_str == NULL) return false;
-
-  // Sets *value to the value of the flag.
-  return ParseInt32(Message() << "The value of flag --" << flag,
-                    value_str, value);
-}
-
-// Parses a string for a string flag, in the form of
-// "--flag=value".
-//
-// On success, stores the value of the flag in *value, and returns
-// true.  On failure, returns false without changing *value.
-bool ParseStringFlag(const char* str, const char* flag, String* value) {
-  // Gets the value of the flag as a string.
-  const char* const value_str = ParseFlagValue(str, flag, false);
-
-  // Aborts if the parsing failed.
-  if (value_str == NULL) return false;
-
-  // Sets *value to the value of the flag.
-  *value = value_str;
-  return true;
-}
-
-// Determines whether a string has a prefix that Google Test uses for its
-// flags, i.e., starts with GTEST_FLAG_PREFIX_ or GTEST_FLAG_PREFIX_DASH_.
-// If Google Test detects that a command line flag has its prefix but is not
-// recognized, it will print its help message. Flags starting with
-// GTEST_INTERNAL_PREFIX_ followed by "internal_" are considered Google Test
-// internal flags and do not trigger the help message.
-static bool HasGoogleTestFlagPrefix(const char* str) {
-  return (SkipPrefix("--", &str) ||
-          SkipPrefix("-", &str) ||
-          SkipPrefix("/", &str)) &&
-         !SkipPrefix(GTEST_FLAG_PREFIX_ "internal_", &str) &&
-         (SkipPrefix(GTEST_FLAG_PREFIX_, &str) ||
-          SkipPrefix(GTEST_FLAG_PREFIX_DASH_, &str));
-}
-
-// Prints a string containing code-encoded text.  The following escape
-// sequences can be used in the string to control the text color:
-//
-//   @@    prints a single '@' character.
-//   @R    changes the color to red.
-//   @G    changes the color to green.
-//   @Y    changes the color to yellow.
-//   @D    changes to the default terminal text color.
-//
-// TODO(wan at google.com): Write tests for this once we add stdout
-// capturing to Google Test.
-static void PrintColorEncoded(const char* str) {
-  GTestColor color = COLOR_DEFAULT;  // The current color.
-
-  // Conceptually, we split the string into segments divided by escape
-  // sequences.  Then we print one segment at a time.  At the end of
-  // each iteration, the str pointer advances to the beginning of the
-  // next segment.
-  for (;;) {
-    const char* p = strchr(str, '@');
-    if (p == NULL) {
-      ColoredPrintf(color, "%s", str);
-      return;
-    }
-
-    ColoredPrintf(color, "%s", String(str, p - str).c_str());
-
-    const char ch = p[1];
-    str = p + 2;
-    if (ch == '@') {
-      ColoredPrintf(color, "@");
-    } else if (ch == 'D') {
-      color = COLOR_DEFAULT;
-    } else if (ch == 'R') {
-      color = COLOR_RED;
-    } else if (ch == 'G') {
-      color = COLOR_GREEN;
-    } else if (ch == 'Y') {
-      color = COLOR_YELLOW;
-    } else {
-      --str;
-    }
-  }
-}
-
-static const char kColorEncodedHelpMessage[] =
-"This program contains tests written using " GTEST_NAME_ ". You can use the\n"
-"following command line flags to control its behavior:\n"
-"\n"
-"Test Selection:\n"
-"  @G--" GTEST_FLAG_PREFIX_ "list_tests at D\n"
-"      List the names of all tests instead of running them. The name of\n"
-"      TEST(Foo, Bar) is \"Foo.Bar\".\n"
-"  @G--" GTEST_FLAG_PREFIX_ "filter=@YPOSTIVE_PATTERNS"
-    "[@G- at YNEGATIVE_PATTERNS]@D\n"
-"      Run only the tests whose name matches one of the positive patterns but\n"
-"      none of the negative patterns. '?' matches any single character; '*'\n"
-"      matches any substring; ':' separates two patterns.\n"
-"  @G--" GTEST_FLAG_PREFIX_ "also_run_disabled_tests at D\n"
-"      Run all disabled tests too.\n"
-"\n"
-"Test Execution:\n"
-"  @G--" GTEST_FLAG_PREFIX_ "repeat=@Y[COUNT]@D\n"
-"      Run the tests repeatedly; use a negative count to repeat forever.\n"
-"  @G--" GTEST_FLAG_PREFIX_ "shuffle at D\n"
-"      Randomize tests' orders on every iteration.\n"
-"  @G--" GTEST_FLAG_PREFIX_ "random_seed=@Y[NUMBER]@D\n"
-"      Random number seed to use for shuffling test orders (between 1 and\n"
-"      99999, or 0 to use a seed based on the current time).\n"
-"\n"
-"Test Output:\n"
-"  @G--" GTEST_FLAG_PREFIX_ "color=@Y(@Gyes at Y|@Gno at Y|@Gauto at Y)@D\n"
-"      Enable/disable colored output. The default is @Gauto at D.\n"
-"  - at G-" GTEST_FLAG_PREFIX_ "print_time=0 at D\n"
-"      Don't print the elapsed time of each test.\n"
-"  @G--" GTEST_FLAG_PREFIX_ "output=xml at Y[@G:@YDIRECTORY_PATH at G"
-    GTEST_PATH_SEP_ "@Y|@G:@YFILE_PATH]@D\n"
-"      Generate an XML report in the given directory or with the given file\n"
-"      name. @YFILE_PATH at D defaults to @Gtest_details.xml at D.\n"
-#if GTEST_CAN_STREAM_RESULTS_
-"  @G--" GTEST_FLAG_PREFIX_ "stream_result_to=@YHOST at G:@YPORT at D\n"
-"      Stream test results to the given server.\n"
-#endif  // GTEST_CAN_STREAM_RESULTS_
-"\n"
-"Assertion Behavior:\n"
-#if GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS
-"  @G--" GTEST_FLAG_PREFIX_ "death_test_style=@Y(@Gfast at Y|@Gthreadsafe at Y)@D\n"
-"      Set the default death test style.\n"
-#endif  // GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS
-"  @G--" GTEST_FLAG_PREFIX_ "break_on_failure at D\n"
-"      Turn assertion failures into debugger break-points.\n"
-"  @G--" GTEST_FLAG_PREFIX_ "throw_on_failure at D\n"
-"      Turn assertion failures into C++ exceptions.\n"
-"  @G--" GTEST_FLAG_PREFIX_ "catch_exceptions=0 at D\n"
-"      Do not report exceptions as test failures. Instead, allow them\n"
-"      to crash the program or throw a pop-up (on Windows).\n"
-"\n"
-"Except for @G--" GTEST_FLAG_PREFIX_ "list_tests at D, you can alternatively set "
-    "the corresponding\n"
-"environment variable of a flag (all letters in upper-case). For example, to\n"
-"disable colored text output, you can either specify @G--" GTEST_FLAG_PREFIX_
-    "color=no at D or set\n"
-"the @G" GTEST_FLAG_PREFIX_UPPER_ "COLOR at D environment variable to @Gno at D.\n"
-"\n"
-"For more information, please read the " GTEST_NAME_ " documentation at\n"
-"@G" GTEST_PROJECT_URL_ "@D. If you find a bug in " GTEST_NAME_ "\n"
-"(not one in your own code or tests), please report it to\n"
-"@G<" GTEST_DEV_EMAIL_ ">@D.\n";
-
-// Parses the command line for Google Test flags, without initializing
-// other parts of Google Test.  The type parameter CharType can be
-// instantiated to either char or wchar_t.
-template <typename CharType>
-void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {
-  for (int i = 1; i < *argc; i++) {
-    const String arg_string = StreamableToString(argv[i]);
-    const char* const arg = arg_string.c_str();
-
-    using internal::ParseBoolFlag;
-    using internal::ParseInt32Flag;
-    using internal::ParseStringFlag;
-
-    // Do we see a Google Test flag?
-    if (ParseBoolFlag(arg, kAlsoRunDisabledTestsFlag,
-                      &GTEST_FLAG(also_run_disabled_tests)) ||
-        ParseBoolFlag(arg, kBreakOnFailureFlag,
-                      &GTEST_FLAG(break_on_failure)) ||
-        ParseBoolFlag(arg, kCatchExceptionsFlag,
-                      &GTEST_FLAG(catch_exceptions)) ||
-        ParseStringFlag(arg, kColorFlag, &GTEST_FLAG(color)) ||
-        ParseStringFlag(arg, kDeathTestStyleFlag,
-                        &GTEST_FLAG(death_test_style)) ||
-        ParseBoolFlag(arg, kDeathTestUseFork,
-                      &GTEST_FLAG(death_test_use_fork)) ||
-        ParseStringFlag(arg, kFilterFlag, &GTEST_FLAG(filter)) ||
-        ParseStringFlag(arg, kInternalRunDeathTestFlag,
-                        &GTEST_FLAG(internal_run_death_test)) ||
-        ParseBoolFlag(arg, kListTestsFlag, &GTEST_FLAG(list_tests)) ||
-        ParseStringFlag(arg, kOutputFlag, &GTEST_FLAG(output)) ||
-        ParseBoolFlag(arg, kPrintTimeFlag, &GTEST_FLAG(print_time)) ||
-        ParseInt32Flag(arg, kRandomSeedFlag, &GTEST_FLAG(random_seed)) ||
-        ParseInt32Flag(arg, kRepeatFlag, &GTEST_FLAG(repeat)) ||
-        ParseBoolFlag(arg, kShuffleFlag, &GTEST_FLAG(shuffle)) ||
-        ParseInt32Flag(arg, kStackTraceDepthFlag,
-                       &GTEST_FLAG(stack_trace_depth)) ||
-        ParseStringFlag(arg, kStreamResultToFlag,
-                        &GTEST_FLAG(stream_result_to)) ||
-        ParseBoolFlag(arg, kThrowOnFailureFlag,
-                      &GTEST_FLAG(throw_on_failure))
-        ) {
-      // Yes.  Shift the remainder of the argv list left by one.  Note
-      // that argv has (*argc + 1) elements, the last one always being
-      // NULL.  The following loop moves the trailing NULL element as
-      // well.
-      for (int j = i; j != *argc; j++) {
-        argv[j] = argv[j + 1];
-      }
-
-      // Decrements the argument count.
-      (*argc)--;
-
-      // We also need to decrement the iterator as we just removed
-      // an element.
-      i--;
-    } else if (arg_string == "--help" || arg_string == "-h" ||
-               arg_string == "-?" || arg_string == "/?" ||
-               HasGoogleTestFlagPrefix(arg)) {
-      // Both help flag and unrecognized Google Test flags (excluding
-      // internal ones) trigger help display.
-      g_help_flag = true;
-    }
-  }
-
-  if (g_help_flag) {
-    // We print the help here instead of in RUN_ALL_TESTS(), as the
-    // latter may not be called at all if the user is using Google
-    // Test with another testing framework.
-    PrintColorEncoded(kColorEncodedHelpMessage);
-  }
-}
-
-// Parses the command line for Google Test flags, without initializing
-// other parts of Google Test.
-void ParseGoogleTestFlagsOnly(int* argc, char** argv) {
-  ParseGoogleTestFlagsOnlyImpl(argc, argv);
-}
-void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv) {
-  ParseGoogleTestFlagsOnlyImpl(argc, argv);
-}
-
-// The internal implementation of InitGoogleTest().
-//
-// The type parameter CharType can be instantiated to either char or
-// wchar_t.
-template <typename CharType>
-void InitGoogleTestImpl(int* argc, CharType** argv) {
-  g_init_gtest_count++;
-
-  // We don't want to run the initialization code twice.
-  if (g_init_gtest_count != 1) return;
-
-  if (*argc <= 0) return;
-
-  internal::g_executable_path = internal::StreamableToString(argv[0]);
-
-#if GTEST_HAS_DEATH_TEST
-
-  g_argvs.clear();
-  for (int i = 0; i != *argc; i++) {
-    g_argvs.push_back(StreamableToString(argv[i]));
-  }
-
-#endif  // GTEST_HAS_DEATH_TEST
-
-  ParseGoogleTestFlagsOnly(argc, argv);
-  GetUnitTestImpl()->PostFlagParsingInit();
-}
-
-}  // namespace internal
-
-// Initializes Google Test.  This must be called before calling
-// RUN_ALL_TESTS().  In particular, it parses a command line for the
-// flags that Google Test recognizes.  Whenever a Google Test flag is
-// seen, it is removed from argv, and *argc is decremented.
-//
-// No value is returned.  Instead, the Google Test flag variables are
-// updated.
-//
-// Calling the function for the second time has no user-visible effect.
-void InitGoogleTest(int* argc, char** argv) {
-  internal::InitGoogleTestImpl(argc, argv);
-}
-
-// This overloaded version can be used in Windows programs compiled in
-// UNICODE mode.
-void InitGoogleTest(int* argc, wchar_t** argv) {
-  internal::InitGoogleTestImpl(argc, argv);
-}
-
-}  // namespace testing
-// Copyright 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan at google.com (Zhanyong Wan), vladl at google.com (Vlad Losev)
-//
-// This file implements death tests.
-
-
-#if GTEST_HAS_DEATH_TEST
-
-# if GTEST_OS_MAC
-#  include <crt_externs.h>
-# endif  // GTEST_OS_MAC
-
-# include <errno.h>
-# include <fcntl.h>
-# include <limits.h>
-# include <stdarg.h>
-
-# if GTEST_OS_WINDOWS
-#  include <windows.h>
-# else
-#  include <sys/mman.h>
-#  include <sys/wait.h>
-# endif  // GTEST_OS_WINDOWS
-
-#endif  // GTEST_HAS_DEATH_TEST
-
-
-// Indicates that this translation unit is part of Google Test's
-// implementation.  It must come before gtest-internal-inl.h is
-// included, or there will be a compiler error.  This trick is to
-// prevent a user from accidentally including gtest-internal-inl.h in
-// his code.
-#define GTEST_IMPLEMENTATION_ 1
-#undef GTEST_IMPLEMENTATION_
-
-namespace testing {
-
-// Constants.
-
-// The default death test style.
-static const char kDefaultDeathTestStyle[] = "fast";
-
-GTEST_DEFINE_string_(
-    death_test_style,
-    internal::StringFromGTestEnv("death_test_style", kDefaultDeathTestStyle),
-    "Indicates how to run a death test in a forked child process: "
-    "\"threadsafe\" (child process re-executes the test binary "
-    "from the beginning, running only the specific death test) or "
-    "\"fast\" (child process runs the death test immediately "
-    "after forking).");
-
-GTEST_DEFINE_bool_(
-    death_test_use_fork,
-    internal::BoolFromGTestEnv("death_test_use_fork", false),
-    "Instructs to use fork()/_exit() instead of clone() in death tests. "
-    "Ignored and always uses fork() on POSIX systems where clone() is not "
-    "implemented. Useful when running under valgrind or similar tools if "
-    "those do not support clone(). Valgrind 3.3.1 will just fail if "
-    "it sees an unsupported combination of clone() flags. "
-    "It is not recommended to use this flag w/o valgrind though it will "
-    "work in 99% of the cases. Once valgrind is fixed, this flag will "
-    "most likely be removed.");
-
-namespace internal {
-GTEST_DEFINE_string_(
-    internal_run_death_test, "",
-    "Indicates the file, line number, temporal index of "
-    "the single death test to run, and a file descriptor to "
-    "which a success code may be sent, all separated by "
-    "colons.  This flag is specified if and only if the current "
-    "process is a sub-process launched for running a thread-safe "
-    "death test.  FOR INTERNAL USE ONLY.");
-}  // namespace internal
-
-#if GTEST_HAS_DEATH_TEST
-
-// ExitedWithCode constructor.
-ExitedWithCode::ExitedWithCode(int exit_code) : exit_code_(exit_code) {
-}
-
-// ExitedWithCode function-call operator.
-bool ExitedWithCode::operator()(int exit_status) const {
-# if GTEST_OS_WINDOWS
-
-  return exit_status == exit_code_;
-
-# else
-
-  return WIFEXITED(exit_status) && WEXITSTATUS(exit_status) == exit_code_;
-
-# endif  // GTEST_OS_WINDOWS
-}
-
-# if !GTEST_OS_WINDOWS
-// KilledBySignal constructor.
-KilledBySignal::KilledBySignal(int signum) : signum_(signum) {
-}
-
-// KilledBySignal function-call operator.
-bool KilledBySignal::operator()(int exit_status) const {
-  return WIFSIGNALED(exit_status) && WTERMSIG(exit_status) == signum_;
-}
-# endif  // !GTEST_OS_WINDOWS
-
-namespace internal {
-
-// Utilities needed for death tests.
-
-// Generates a textual description of a given exit code, in the format
-// specified by wait(2).
-static String ExitSummary(int exit_code) {
-  Message m;
-
-# if GTEST_OS_WINDOWS
-
-  m << "Exited with exit status " << exit_code;
-
-# else
-
-  if (WIFEXITED(exit_code)) {
-    m << "Exited with exit status " << WEXITSTATUS(exit_code);
-  } else if (WIFSIGNALED(exit_code)) {
-    m << "Terminated by signal " << WTERMSIG(exit_code);
-  }
-#  ifdef WCOREDUMP
-  if (WCOREDUMP(exit_code)) {
-    m << " (core dumped)";
-  }
-#  endif
-# endif  // GTEST_OS_WINDOWS
-
-  return m.GetString();
-}
-
-// Returns true if exit_status describes a process that was terminated
-// by a signal, or exited normally with a nonzero exit code.
-bool ExitedUnsuccessfully(int exit_status) {
-  return !ExitedWithCode(0)(exit_status);
-}
-
-# if !GTEST_OS_WINDOWS
-// Generates a textual failure message when a death test finds more than
-// one thread running, or cannot determine the number of threads, prior
-// to executing the given statement.  It is the responsibility of the
-// caller not to pass a thread_count of 1.
-static String DeathTestThreadWarning(size_t thread_count) {
-  Message msg;
-  msg << "Death tests use fork(), which is unsafe particularly"
-      << " in a threaded context. For this test, " << GTEST_NAME_ << " ";
-  if (thread_count == 0)
-    msg << "couldn't detect the number of threads.";
-  else
-    msg << "detected " << thread_count << " threads.";
-  return msg.GetString();
-}
-# endif  // !GTEST_OS_WINDOWS
-
-// Flag characters for reporting a death test that did not die.
-static const char kDeathTestLived = 'L';
-static const char kDeathTestReturned = 'R';
-static const char kDeathTestThrew = 'T';
-static const char kDeathTestInternalError = 'I';
-
-// An enumeration describing all of the possible ways that a death test can
-// conclude.  DIED means that the process died while executing the test
-// code; LIVED means that process lived beyond the end of the test code;
-// RETURNED means that the test statement attempted to execute a return
-// statement, which is not allowed; THREW means that the test statement
-// returned control by throwing an exception.  IN_PROGRESS means the test
-// has not yet concluded.
-// TODO(vladl at google.com): Unify names and possibly values for
-// AbortReason, DeathTestOutcome, and flag characters above.
-enum DeathTestOutcome { IN_PROGRESS, DIED, LIVED, RETURNED, THREW };
-
-// Routine for aborting the program which is safe to call from an
-// exec-style death test child process, in which case the error
-// message is propagated back to the parent process.  Otherwise, the
-// message is simply printed to stderr.  In either case, the program
-// then exits with status 1.
-void DeathTestAbort(const String& message) {
-  // On a POSIX system, this function may be called from a threadsafe-style
-  // death test child process, which operates on a very small stack.  Use
-  // the heap for any additional non-minuscule memory requirements.
-  const InternalRunDeathTestFlag* const flag =
-      GetUnitTestImpl()->internal_run_death_test_flag();
-  if (flag != NULL) {
-    FILE* parent = posix::FDOpen(flag->write_fd(), "w");
-    fputc(kDeathTestInternalError, parent);
-    fprintf(parent, "%s", message.c_str());
-    fflush(parent);
-    _exit(1);
-  } else {
-    fprintf(stderr, "%s", message.c_str());
-    fflush(stderr);
-    posix::Abort();
-  }
-}
-
-// A replacement for CHECK that calls DeathTestAbort if the assertion
-// fails.
-# define GTEST_DEATH_TEST_CHECK_(expression) \
-  do { \
-    if (!::testing::internal::IsTrue(expression)) { \
-      DeathTestAbort(::testing::internal::String::Format( \
-          "CHECK failed: File %s, line %d: %s", \
-          __FILE__, __LINE__, #expression)); \
-    } \
-  } while (::testing::internal::AlwaysFalse())
-
-// This macro is similar to GTEST_DEATH_TEST_CHECK_, but it is meant for
-// evaluating any system call that fulfills two conditions: it must return
-// -1 on failure, and set errno to EINTR when it is interrupted and
-// should be tried again.  The macro expands to a loop that repeatedly
-// evaluates the expression as long as it evaluates to -1 and sets
-// errno to EINTR.  If the expression evaluates to -1 but errno is
-// something other than EINTR, DeathTestAbort is called.
-# define GTEST_DEATH_TEST_CHECK_SYSCALL_(expression) \
-  do { \
-    int gtest_retval; \
-    do { \
-      gtest_retval = (expression); \
-    } while (gtest_retval == -1 && errno == EINTR); \
-    if (gtest_retval == -1) { \
-      DeathTestAbort(::testing::internal::String::Format( \
-          "CHECK failed: File %s, line %d: %s != -1", \
-          __FILE__, __LINE__, #expression)); \
-    } \
-  } while (::testing::internal::AlwaysFalse())
-
-// Returns the message describing the last system error in errno.
-String GetLastErrnoDescription() {
-    return String(errno == 0 ? "" : posix::StrError(errno));
-}
-
-// This is called from a death test parent process to read a failure
-// message from the death test child process and log it with the FATAL
-// severity. On Windows, the message is read from a pipe handle. On other
-// platforms, it is read from a file descriptor.
-static void FailFromInternalError(int fd) {
-  Message error;
-  char buffer[256];
-  int num_read;
-
-  do {
-    while ((num_read = posix::Read(fd, buffer, 255)) > 0) {
-      buffer[num_read] = '\0';
-      error << buffer;
-    }
-  } while (num_read == -1 && errno == EINTR);
-
-  if (num_read == 0) {
-    GTEST_LOG_(FATAL) << error.GetString();
-  } else {
-    const int last_error = errno;
-    GTEST_LOG_(FATAL) << "Error while reading death test internal: "
-                      << GetLastErrnoDescription() << " [" << last_error << "]";
-  }
-}
-
-// Death test constructor.  Increments the running death test count
-// for the current test.
-DeathTest::DeathTest() {
-  TestInfo* const info = GetUnitTestImpl()->current_test_info();
-  if (info == NULL) {
-    DeathTestAbort("Cannot run a death test outside of a TEST or "
-                   "TEST_F construct");
-  }
-}
-
-// Creates and returns a death test by dispatching to the current
-// death test factory.
-bool DeathTest::Create(const char* statement, const RE* regex,
-                       const char* file, int line, DeathTest** test) {
-  return GetUnitTestImpl()->death_test_factory()->Create(
-      statement, regex, file, line, test);
-}
-
-const char* DeathTest::LastMessage() {
-  return last_death_test_message_.c_str();
-}
-
-void DeathTest::set_last_death_test_message(const String& message) {
-  last_death_test_message_ = message;
-}
-
-String DeathTest::last_death_test_message_;
-
-// Provides cross platform implementation for some death functionality.
-class DeathTestImpl : public DeathTest {
- protected:
-  DeathTestImpl(const char* a_statement, const RE* a_regex)
-      : statement_(a_statement),
-        regex_(a_regex),
-        spawned_(false),
-        status_(-1),
-        outcome_(IN_PROGRESS),
-        read_fd_(-1),
-        write_fd_(-1) {}
-
-  // read_fd_ is expected to be closed and cleared by a derived class.
-  ~DeathTestImpl() { GTEST_DEATH_TEST_CHECK_(read_fd_ == -1); }
-
-  void Abort(AbortReason reason);
-  virtual bool Passed(bool status_ok);
-
-  const char* statement() const { return statement_; }
-  const RE* regex() const { return regex_; }
-  bool spawned() const { return spawned_; }
-  void set_spawned(bool is_spawned) { spawned_ = is_spawned; }
-  int status() const { return status_; }
-  void set_status(int a_status) { status_ = a_status; }
-  DeathTestOutcome outcome() const { return outcome_; }
-  void set_outcome(DeathTestOutcome an_outcome) { outcome_ = an_outcome; }
-  int read_fd() const { return read_fd_; }
-  void set_read_fd(int fd) { read_fd_ = fd; }
-  int write_fd() const { return write_fd_; }
-  void set_write_fd(int fd) { write_fd_ = fd; }
-
-  // Called in the parent process only. Reads the result code of the death
-  // test child process via a pipe, interprets it to set the outcome_
-  // member, and closes read_fd_.  Outputs diagnostics and terminates in
-  // case of unexpected codes.
-  void ReadAndInterpretStatusByte();
-
- private:
-  // The textual content of the code this object is testing.  This class
-  // doesn't own this string and should not attempt to delete it.
-  const char* const statement_;
-  // The regular expression which test output must match.  DeathTestImpl
-  // doesn't own this object and should not attempt to delete it.
-  const RE* const regex_;
-  // True if the death test child process has been successfully spawned.
-  bool spawned_;
-  // The exit status of the child process.
-  int status_;
-  // How the death test concluded.
-  DeathTestOutcome outcome_;
-  // Descriptor to the read end of the pipe to the child process.  It is
-  // always -1 in the child process.  The child keeps its write end of the
-  // pipe in write_fd_.
-  int read_fd_;
-  // Descriptor to the child's write end of the pipe to the parent process.
-  // It is always -1 in the parent process.  The parent keeps its end of the
-  // pipe in read_fd_.
-  int write_fd_;
-};
-
-// Called in the parent process only. Reads the result code of the death
-// test child process via a pipe, interprets it to set the outcome_
-// member, and closes read_fd_.  Outputs diagnostics and terminates in
-// case of unexpected codes.
-void DeathTestImpl::ReadAndInterpretStatusByte() {
-  char flag;
-  int bytes_read;
-
-  // The read() here blocks until data is available (signifying the
-  // failure of the death test) or until the pipe is closed (signifying
-  // its success), so it's okay to call this in the parent before
-  // the child process has exited.
-  do {
-    bytes_read = posix::Read(read_fd(), &flag, 1);
-  } while (bytes_read == -1 && errno == EINTR);
-
-  if (bytes_read == 0) {
-    set_outcome(DIED);
-  } else if (bytes_read == 1) {
-    switch (flag) {
-      case kDeathTestReturned:
-        set_outcome(RETURNED);
-        break;
-      case kDeathTestThrew:
-        set_outcome(THREW);
-        break;
-      case kDeathTestLived:
-        set_outcome(LIVED);
-        break;
-      case kDeathTestInternalError:
-        FailFromInternalError(read_fd());  // Does not return.
-        break;
-      default:
-        GTEST_LOG_(FATAL) << "Death test child process reported "
-                          << "unexpected status byte ("
-                          << static_cast<unsigned int>(flag) << ")";
-    }
-  } else {
-    GTEST_LOG_(FATAL) << "Read from death test child process failed: "
-                      << GetLastErrnoDescription();
-  }
-  GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Close(read_fd()));
-  set_read_fd(-1);
-}
-
-// Signals that the death test code which should have exited, didn't.
-// Should be called only in a death test child process.
-// Writes a status byte to the child's status file descriptor, then
-// calls _exit(1).
-void DeathTestImpl::Abort(AbortReason reason) {
-  // The parent process considers the death test to be a failure if
-  // it finds any data in our pipe.  So, here we write a single flag byte
-  // to the pipe, then exit.
-  const char status_ch =
-      reason == TEST_DID_NOT_DIE ? kDeathTestLived :
-      reason == TEST_THREW_EXCEPTION ? kDeathTestThrew : kDeathTestReturned;
-
-  GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Write(write_fd(), &status_ch, 1));
-  // We are leaking the descriptor here because on some platforms (i.e.,
-  // when built as Windows DLL), destructors of global objects will still
-  // run after calling _exit(). On such systems, write_fd_ will be
-  // indirectly closed from the destructor of UnitTestImpl, causing double
-  // close if it is also closed here. On debug configurations, double close
-  // may assert. As there are no in-process buffers to flush here, we are
-  // relying on the OS to close the descriptor after the process terminates
-  // when the destructors are not run.
-  _exit(1);  // Exits w/o any normal exit hooks (we were supposed to crash)
-}
-
-// Returns an indented copy of stderr output for a death test.
-// This makes distinguishing death test output lines from regular log lines
-// much easier.
-static ::std::string FormatDeathTestOutput(const ::std::string& output) {
-  ::std::string ret;
-  for (size_t at = 0; ; ) {
-    const size_t line_end = output.find('\n', at);
-    ret += "[  DEATH   ] ";
-    if (line_end == ::std::string::npos) {
-      ret += output.substr(at);
-      break;
-    }
-    ret += output.substr(at, line_end + 1 - at);
-    at = line_end + 1;
-  }
-  return ret;
-}
-
-// Assesses the success or failure of a death test, using both private
-// members which have previously been set, and one argument:
-//
-// Private data members:
-//   outcome:  An enumeration describing how the death test
-//             concluded: DIED, LIVED, THREW, or RETURNED.  The death test
-//             fails in the latter three cases.
-//   status:   The exit status of the child process. On *nix, it is in the
-//             in the format specified by wait(2). On Windows, this is the
-//             value supplied to the ExitProcess() API or a numeric code
-//             of the exception that terminated the program.
-//   regex:    A regular expression object to be applied to
-//             the test's captured standard error output; the death test
-//             fails if it does not match.
-//
-// Argument:
-//   status_ok: true if exit_status is acceptable in the context of
-//              this particular death test, which fails if it is false
-//
-// Returns true iff all of the above conditions are met.  Otherwise, the
-// first failing condition, in the order given above, is the one that is
-// reported. Also sets the last death test message string.
-bool DeathTestImpl::Passed(bool status_ok) {
-  if (!spawned())
-    return false;
-
-  const String error_message = GetCapturedStderr();
-
-  bool success = false;
-  Message buffer;
-
-  buffer << "Death test: " << statement() << "\n";
-  switch (outcome()) {
-    case LIVED:
-      buffer << "    Result: failed to die.\n"
-             << " Error msg:\n" << FormatDeathTestOutput(error_message);
-      break;
-    case THREW:
-      buffer << "    Result: threw an exception.\n"
-             << " Error msg:\n" << FormatDeathTestOutput(error_message);
-      break;
-    case RETURNED:
-      buffer << "    Result: illegal return in test statement.\n"
-             << " Error msg:\n" << FormatDeathTestOutput(error_message);
-      break;
-    case DIED:
-      if (status_ok) {
-        const bool matched = RE::PartialMatch(error_message.c_str(), *regex());
-        if (matched) {
-          success = true;
-        } else {
-          buffer << "    Result: died but not with expected error.\n"
-                 << "  Expected: " << regex()->pattern() << "\n"
-                 << "Actual msg:\n" << FormatDeathTestOutput(error_message);
-        }
-      } else {
-        buffer << "    Result: died but not with expected exit code:\n"
-               << "            " << ExitSummary(status()) << "\n"
-               << "Actual msg:\n" << FormatDeathTestOutput(error_message);
-      }
-      break;
-    case IN_PROGRESS:
-    default:
-      GTEST_LOG_(FATAL)
-          << "DeathTest::Passed somehow called before conclusion of test";
-  }
-
-  DeathTest::set_last_death_test_message(buffer.GetString());
-  return success;
-}
-
-# if GTEST_OS_WINDOWS
-// WindowsDeathTest implements death tests on Windows. Due to the
-// specifics of starting new processes on Windows, death tests there are
-// always threadsafe, and Google Test considers the
-// --gtest_death_test_style=fast setting to be equivalent to
-// --gtest_death_test_style=threadsafe there.
-//
-// A few implementation notes:  Like the Linux version, the Windows
-// implementation uses pipes for child-to-parent communication. But due to
-// the specifics of pipes on Windows, some extra steps are required:
-//
-// 1. The parent creates a communication pipe and stores handles to both
-//    ends of it.
-// 2. The parent starts the child and provides it with the information
-//    necessary to acquire the handle to the write end of the pipe.
-// 3. The child acquires the write end of the pipe and signals the parent
-//    using a Windows event.
-// 4. Now the parent can release the write end of the pipe on its side. If
-//    this is done before step 3, the object's reference count goes down to
-//    0 and it is destroyed, preventing the child from acquiring it. The
-//    parent now has to release it, or read operations on the read end of
-//    the pipe will not return when the child terminates.
-// 5. The parent reads child's output through the pipe (outcome code and
-//    any possible error messages) from the pipe, and its stderr and then
-//    determines whether to fail the test.
-//
-// Note: to distinguish Win32 API calls from the local method and function
-// calls, the former are explicitly resolved in the global namespace.
-//
-class WindowsDeathTest : public DeathTestImpl {
- public:
-  WindowsDeathTest(const char* a_statement,
-                   const RE* a_regex,
-                   const char* file,
-                   int line)
-      : DeathTestImpl(a_statement, a_regex), file_(file), line_(line) {}
-
-  // All of these virtual functions are inherited from DeathTest.
-  virtual int Wait();
-  virtual TestRole AssumeRole();
-
- private:
-  // The name of the file in which the death test is located.
-  const char* const file_;
-  // The line number on which the death test is located.
-  const int line_;
-  // Handle to the write end of the pipe to the child process.
-  AutoHandle write_handle_;
-  // Child process handle.
-  AutoHandle child_handle_;
-  // Event the child process uses to signal the parent that it has
-  // acquired the handle to the write end of the pipe. After seeing this
-  // event the parent can release its own handles to make sure its
-  // ReadFile() calls return when the child terminates.
-  AutoHandle event_handle_;
-};
-
-// Waits for the child in a death test to exit, returning its exit
-// status, or 0 if no child process exists.  As a side effect, sets the
-// outcome data member.
-int WindowsDeathTest::Wait() {
-  if (!spawned())
-    return 0;
-
-  // Wait until the child either signals that it has acquired the write end
-  // of the pipe or it dies.
-  const HANDLE wait_handles[2] = { child_handle_.Get(), event_handle_.Get() };
-  switch (::WaitForMultipleObjects(2,
-                                   wait_handles,
-                                   FALSE,  // Waits for any of the handles.
-                                   INFINITE)) {
-    case WAIT_OBJECT_0:
-    case WAIT_OBJECT_0 + 1:
-      break;
-    default:
-      GTEST_DEATH_TEST_CHECK_(false);  // Should not get here.
-  }
-
-  // The child has acquired the write end of the pipe or exited.
-  // We release the handle on our side and continue.
-  write_handle_.Reset();
-  event_handle_.Reset();
-
-  ReadAndInterpretStatusByte();
-
-  // Waits for the child process to exit if it haven't already. This
-  // returns immediately if the child has already exited, regardless of
-  // whether previous calls to WaitForMultipleObjects synchronized on this
-  // handle or not.
-  GTEST_DEATH_TEST_CHECK_(
-      WAIT_OBJECT_0 == ::WaitForSingleObject(child_handle_.Get(),
-                                             INFINITE));
-  DWORD status_code;
-  GTEST_DEATH_TEST_CHECK_(
-      ::GetExitCodeProcess(child_handle_.Get(), &status_code) != FALSE);
-  child_handle_.Reset();
-  set_status(static_cast<int>(status_code));
-  return status();
-}
-
-// The AssumeRole process for a Windows death test.  It creates a child
-// process with the same executable as the current process to run the
-// death test.  The child process is given the --gtest_filter and
-// --gtest_internal_run_death_test flags such that it knows to run the
-// current death test only.
-DeathTest::TestRole WindowsDeathTest::AssumeRole() {
-  const UnitTestImpl* const impl = GetUnitTestImpl();
-  const InternalRunDeathTestFlag* const flag =
-      impl->internal_run_death_test_flag();
-  const TestInfo* const info = impl->current_test_info();
-  const int death_test_index = info->result()->death_test_count();
-
-  if (flag != NULL) {
-    // ParseInternalRunDeathTestFlag() has performed all the necessary
-    // processing.
-    set_write_fd(flag->write_fd());
-    return EXECUTE_TEST;
-  }
-
-  // WindowsDeathTest uses an anonymous pipe to communicate results of
-  // a death test.
-  SECURITY_ATTRIBUTES handles_are_inheritable = {
-    sizeof(SECURITY_ATTRIBUTES), NULL, TRUE };
-  HANDLE read_handle, write_handle;
-  GTEST_DEATH_TEST_CHECK_(
-      ::CreatePipe(&read_handle, &write_handle, &handles_are_inheritable,
-                   0)  // Default buffer size.
-      != FALSE);
-  set_read_fd(::_open_osfhandle(reinterpret_cast<intptr_t>(read_handle),
-                                O_RDONLY));
-  write_handle_.Reset(write_handle);
-  event_handle_.Reset(::CreateEvent(
-      &handles_are_inheritable,
-      TRUE,    // The event will automatically reset to non-signaled state.
-      FALSE,   // The initial state is non-signalled.
-      NULL));  // The even is unnamed.
-  GTEST_DEATH_TEST_CHECK_(event_handle_.Get() != NULL);
-  const String filter_flag = String::Format("--%s%s=%s.%s",
-                                            GTEST_FLAG_PREFIX_, kFilterFlag,
-                                            info->test_case_name(),
-                                            info->name());
-  const String internal_flag = String::Format(
-    "--%s%s=%s|%d|%d|%u|%Iu|%Iu",
-      GTEST_FLAG_PREFIX_,
-      kInternalRunDeathTestFlag,
-      file_, line_,
-      death_test_index,
-      static_cast<unsigned int>(::GetCurrentProcessId()),
-      // size_t has the same with as pointers on both 32-bit and 64-bit
-      // Windows platforms.
-      // See http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx.
-      reinterpret_cast<size_t>(write_handle),
-      reinterpret_cast<size_t>(event_handle_.Get()));
-
-  char executable_path[_MAX_PATH + 1];  // NOLINT
-  GTEST_DEATH_TEST_CHECK_(
-      _MAX_PATH + 1 != ::GetModuleFileNameA(NULL,
-                                            executable_path,
-                                            _MAX_PATH));
-
-  String command_line = String::Format("%s %s \"%s\"",
-                                       ::GetCommandLineA(),
-                                       filter_flag.c_str(),
-                                       internal_flag.c_str());
-
-  DeathTest::set_last_death_test_message("");
-
-  CaptureStderr();
-  // Flush the log buffers since the log streams are shared with the child.
-  FlushInfoLog();
-
-  // The child process will share the standard handles with the parent.
-  STARTUPINFOA startup_info;
-  memset(&startup_info, 0, sizeof(STARTUPINFO));
-  startup_info.dwFlags = STARTF_USESTDHANDLES;
-  startup_info.hStdInput = ::GetStdHandle(STD_INPUT_HANDLE);
-  startup_info.hStdOutput = ::GetStdHandle(STD_OUTPUT_HANDLE);
-  startup_info.hStdError = ::GetStdHandle(STD_ERROR_HANDLE);
-
-  PROCESS_INFORMATION process_info;
-  GTEST_DEATH_TEST_CHECK_(::CreateProcessA(
-      executable_path,
-      const_cast<char*>(command_line.c_str()),
-      NULL,   // Retuned process handle is not inheritable.
-      NULL,   // Retuned thread handle is not inheritable.
-      TRUE,   // Child inherits all inheritable handles (for write_handle_).
-      0x0,    // Default creation flags.
-      NULL,   // Inherit the parent's environment.
-      UnitTest::GetInstance()->original_working_dir(),
-      &startup_info,
-      &process_info) != FALSE);
-  child_handle_.Reset(process_info.hProcess);
-  ::CloseHandle(process_info.hThread);
-  set_spawned(true);
-  return OVERSEE_TEST;
-}
-# else  // We are not on Windows.
-
-// ForkingDeathTest provides implementations for most of the abstract
-// methods of the DeathTest interface.  Only the AssumeRole method is
-// left undefined.
-class ForkingDeathTest : public DeathTestImpl {
- public:
-  ForkingDeathTest(const char* statement, const RE* regex);
-
-  // All of these virtual functions are inherited from DeathTest.
-  virtual int Wait();
-
- protected:
-  void set_child_pid(pid_t child_pid) { child_pid_ = child_pid; }
-
- private:
-  // PID of child process during death test; 0 in the child process itself.
-  pid_t child_pid_;
-};
-
-// Constructs a ForkingDeathTest.
-ForkingDeathTest::ForkingDeathTest(const char* a_statement, const RE* a_regex)
-    : DeathTestImpl(a_statement, a_regex),
-      child_pid_(-1) {}
-
-// Waits for the child in a death test to exit, returning its exit
-// status, or 0 if no child process exists.  As a side effect, sets the
-// outcome data member.
-int ForkingDeathTest::Wait() {
-  if (!spawned())
-    return 0;
-
-  ReadAndInterpretStatusByte();
-
-  int status_value;
-  GTEST_DEATH_TEST_CHECK_SYSCALL_(waitpid(child_pid_, &status_value, 0));
-  set_status(status_value);
-  return status_value;
-}
-
-// A concrete death test class that forks, then immediately runs the test
-// in the child process.
-class NoExecDeathTest : public ForkingDeathTest {
- public:
-  NoExecDeathTest(const char* a_statement, const RE* a_regex) :
-      ForkingDeathTest(a_statement, a_regex) { }
-  virtual TestRole AssumeRole();
-};
-
-// The AssumeRole process for a fork-and-run death test.  It implements a
-// straightforward fork, with a simple pipe to transmit the status byte.
-DeathTest::TestRole NoExecDeathTest::AssumeRole() {
-  const size_t thread_count = GetThreadCount();
-  if (thread_count != 1) {
-    GTEST_LOG_(WARNING) << DeathTestThreadWarning(thread_count);
-  }
-
-  int pipe_fd[2];
-  GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1);
-
-  DeathTest::set_last_death_test_message("");
-  CaptureStderr();
-  // When we fork the process below, the log file buffers are copied, but the
-  // file descriptors are shared.  We flush all log files here so that closing
-  // the file descriptors in the child process doesn't throw off the
-  // synchronization between descriptors and buffers in the parent process.
-  // This is as close to the fork as possible to avoid a race condition in case
-  // there are multiple threads running before the death test, and another
-  // thread writes to the log file.
-  FlushInfoLog();
-
-  const pid_t child_pid = fork();
-  GTEST_DEATH_TEST_CHECK_(child_pid != -1);
-  set_child_pid(child_pid);
-  if (child_pid == 0) {
-    GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[0]));
-    set_write_fd(pipe_fd[1]);
-    // Redirects all logging to stderr in the child process to prevent
-    // concurrent writes to the log files.  We capture stderr in the parent
-    // process and append the child process' output to a log.
-    LogToStderr();
-    // Event forwarding to the listeners of event listener API mush be shut
-    // down in death test subprocesses.
-    GetUnitTestImpl()->listeners()->SuppressEventForwarding();
-    return EXECUTE_TEST;
-  } else {
-    GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1]));
-    set_read_fd(pipe_fd[0]);
-    set_spawned(true);
-    return OVERSEE_TEST;
-  }
-}
-
-// A concrete death test class that forks and re-executes the main
-// program from the beginning, with command-line flags set that cause
-// only this specific death test to be run.
-class ExecDeathTest : public ForkingDeathTest {
- public:
-  ExecDeathTest(const char* a_statement, const RE* a_regex,
-                const char* file, int line) :
-      ForkingDeathTest(a_statement, a_regex), file_(file), line_(line) { }
-  virtual TestRole AssumeRole();
- private:
-  // The name of the file in which the death test is located.
-  const char* const file_;
-  // The line number on which the death test is located.
-  const int line_;
-};
-
-// Utility class for accumulating command-line arguments.
-class Arguments {
- public:
-  Arguments() {
-    args_.push_back(NULL);
-  }
-
-  ~Arguments() {
-    for (std::vector<char*>::iterator i = args_.begin(); i != args_.end();
-         ++i) {
-      free(*i);
-    }
-  }
-  void AddArgument(const char* argument) {
-    args_.insert(args_.end() - 1, posix::StrDup(argument));
-  }
-
-  template <typename Str>
-  void AddArguments(const ::std::vector<Str>& arguments) {
-    for (typename ::std::vector<Str>::const_iterator i = arguments.begin();
-         i != arguments.end();
-         ++i) {
-      args_.insert(args_.end() - 1, posix::StrDup(i->c_str()));
-    }
-  }
-  char* const* Argv() {
-    return &args_[0];
-  }
- private:
-  std::vector<char*> args_;
-};
-
-// A struct that encompasses the arguments to the child process of a
-// threadsafe-style death test process.
-struct ExecDeathTestArgs {
-  char* const* argv;  // Command-line arguments for the child's call to exec
-  int close_fd;       // File descriptor to close; the read end of a pipe
-};
-
-#  if GTEST_OS_MAC
-inline char** GetEnviron() {
-  // When Google Test is built as a framework on MacOS X, the environ variable
-  // is unavailable. Apple's documentation (man environ) recommends using
-  // _NSGetEnviron() instead.
-  return *_NSGetEnviron();
-}
-#  else
-// Some POSIX platforms expect you to declare environ. extern "C" makes
-// it reside in the global namespace.
-extern "C" char** environ;
-inline char** GetEnviron() { return environ; }
-#  endif  // GTEST_OS_MAC
-
-// The main function for a threadsafe-style death test child process.
-// This function is called in a clone()-ed process and thus must avoid
-// any potentially unsafe operations like malloc or libc functions.
-static int ExecDeathTestChildMain(void* child_arg) {
-  ExecDeathTestArgs* const args = static_cast<ExecDeathTestArgs*>(child_arg);
-  GTEST_DEATH_TEST_CHECK_SYSCALL_(close(args->close_fd));
-
-  // We need to execute the test program in the same environment where
-  // it was originally invoked.  Therefore we change to the original
-  // working directory first.
-  const char* const original_dir =
-      UnitTest::GetInstance()->original_working_dir();
-  // We can safely call chdir() as it's a direct system call.
-  if (chdir(original_dir) != 0) {
-    DeathTestAbort(String::Format("chdir(\"%s\") failed: %s",
-                                  original_dir,
-                                  GetLastErrnoDescription().c_str()));
-    return EXIT_FAILURE;
-  }
-
-  // We can safely call execve() as it's a direct system call.  We
-  // cannot use execvp() as it's a libc function and thus potentially
-  // unsafe.  Since execve() doesn't search the PATH, the user must
-  // invoke the test program via a valid path that contains at least
-  // one path separator.
-  execve(args->argv[0], args->argv, GetEnviron());
-  DeathTestAbort(String::Format("execve(%s, ...) in %s failed: %s",
-                                args->argv[0],
-                                original_dir,
-                                GetLastErrnoDescription().c_str()));
-  return EXIT_FAILURE;
-}
-
-// Two utility routines that together determine the direction the stack
-// grows.
-// This could be accomplished more elegantly by a single recursive
-// function, but we want to guard against the unlikely possibility of
-// a smart compiler optimizing the recursion away.
-//
-// GTEST_NO_INLINE_ is required to prevent GCC 4.6 from inlining
-// StackLowerThanAddress into StackGrowsDown, which then doesn't give
-// correct answer.
-bool StackLowerThanAddress(const void* ptr) GTEST_NO_INLINE_;
-bool StackLowerThanAddress(const void* ptr) {
-  int dummy;
-  return &dummy < ptr;
-}
-
-bool StackGrowsDown() {
-  int dummy;
-  return StackLowerThanAddress(&dummy);
-}
-
-// A threadsafe implementation of fork(2) for threadsafe-style death tests
-// that uses clone(2).  It dies with an error message if anything goes
-// wrong.
-static pid_t ExecDeathTestFork(char* const* argv, int close_fd) {
-  ExecDeathTestArgs args = { argv, close_fd };
-  pid_t child_pid = -1;
-
-#  if GTEST_HAS_CLONE
-  const bool use_fork = GTEST_FLAG(death_test_use_fork);
-
-  if (!use_fork) {
-    static const bool stack_grows_down = StackGrowsDown();
-    const size_t stack_size = getpagesize();
-    // MMAP_ANONYMOUS is not defined on Mac, so we use MAP_ANON instead.
-    void* const stack = mmap(NULL, stack_size, PROT_READ | PROT_WRITE,
-                             MAP_ANON | MAP_PRIVATE, -1, 0);
-    GTEST_DEATH_TEST_CHECK_(stack != MAP_FAILED);
-    void* const stack_top =
-        static_cast<char*>(stack) + (stack_grows_down ? stack_size : 0);
-
-    child_pid = clone(&ExecDeathTestChildMain, stack_top, SIGCHLD, &args);
-
-    GTEST_DEATH_TEST_CHECK_(munmap(stack, stack_size) != -1);
-  }
-#  else
-  const bool use_fork = true;
-#  endif  // GTEST_HAS_CLONE
-
-  if (use_fork && (child_pid = fork()) == 0) {
-      ExecDeathTestChildMain(&args);
-      _exit(0);
-  }
-
-  GTEST_DEATH_TEST_CHECK_(child_pid != -1);
-  return child_pid;
-}
-
-// The AssumeRole process for a fork-and-exec death test.  It re-executes the
-// main program from the beginning, setting the --gtest_filter
-// and --gtest_internal_run_death_test flags to cause only the current
-// death test to be re-run.
-DeathTest::TestRole ExecDeathTest::AssumeRole() {
-  const UnitTestImpl* const impl = GetUnitTestImpl();
-  const InternalRunDeathTestFlag* const flag =
-      impl->internal_run_death_test_flag();
-  const TestInfo* const info = impl->current_test_info();
-  const int death_test_index = info->result()->death_test_count();
-
-  if (flag != NULL) {
-    set_write_fd(flag->write_fd());
-    return EXECUTE_TEST;
-  }
-
-  int pipe_fd[2];
-  GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1);
-  // Clear the close-on-exec flag on the write end of the pipe, lest
-  // it be closed when the child process does an exec:
-  GTEST_DEATH_TEST_CHECK_(fcntl(pipe_fd[1], F_SETFD, 0) != -1);
-
-  const String filter_flag =
-      String::Format("--%s%s=%s.%s",
-                     GTEST_FLAG_PREFIX_, kFilterFlag,
-                     info->test_case_name(), info->name());
-  const String internal_flag =
-      String::Format("--%s%s=%s|%d|%d|%d",
-                     GTEST_FLAG_PREFIX_, kInternalRunDeathTestFlag,
-                     file_, line_, death_test_index, pipe_fd[1]);
-  Arguments args;
-  args.AddArguments(GetArgvs());
-  args.AddArgument(filter_flag.c_str());
-  args.AddArgument(internal_flag.c_str());
-
-  DeathTest::set_last_death_test_message("");
-
-  CaptureStderr();
-  // See the comment in NoExecDeathTest::AssumeRole for why the next line
-  // is necessary.
-  FlushInfoLog();
-
-  const pid_t child_pid = ExecDeathTestFork(args.Argv(), pipe_fd[0]);
-  GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1]));
-  set_child_pid(child_pid);
-  set_read_fd(pipe_fd[0]);
-  set_spawned(true);
-  return OVERSEE_TEST;
-}
-
-# endif  // !GTEST_OS_WINDOWS
-
-// Creates a concrete DeathTest-derived class that depends on the
-// --gtest_death_test_style flag, and sets the pointer pointed to
-// by the "test" argument to its address.  If the test should be
-// skipped, sets that pointer to NULL.  Returns true, unless the
-// flag is set to an invalid value.
-bool DefaultDeathTestFactory::Create(const char* statement, const RE* regex,
-                                     const char* file, int line,
-                                     DeathTest** test) {
-  UnitTestImpl* const impl = GetUnitTestImpl();
-  const InternalRunDeathTestFlag* const flag =
-      impl->internal_run_death_test_flag();
-  const int death_test_index = impl->current_test_info()
-      ->increment_death_test_count();
-
-  if (flag != NULL) {
-    if (death_test_index > flag->index()) {
-      DeathTest::set_last_death_test_message(String::Format(
-          "Death test count (%d) somehow exceeded expected maximum (%d)",
-          death_test_index, flag->index()));
-      return false;
-    }
-
-    if (!(flag->file() == file && flag->line() == line &&
-          flag->index() == death_test_index)) {
-      *test = NULL;
-      return true;
-    }
-  }
-
-# if GTEST_OS_WINDOWS
-
-  if (GTEST_FLAG(death_test_style) == "threadsafe" ||
-      GTEST_FLAG(death_test_style) == "fast") {
-    *test = new WindowsDeathTest(statement, regex, file, line);
-  }
-
-# else
-
-  if (GTEST_FLAG(death_test_style) == "threadsafe") {
-    *test = new ExecDeathTest(statement, regex, file, line);
-  } else if (GTEST_FLAG(death_test_style) == "fast") {
-    *test = new NoExecDeathTest(statement, regex);
-  }
-
-# endif  // GTEST_OS_WINDOWS
-
-  else {  // NOLINT - this is more readable than unbalanced brackets inside #if.
-    DeathTest::set_last_death_test_message(String::Format(
-        "Unknown death test style \"%s\" encountered",
-        GTEST_FLAG(death_test_style).c_str()));
-    return false;
-  }
-
-  return true;
-}
-
-// Splits a given string on a given delimiter, populating a given
-// vector with the fields.  GTEST_HAS_DEATH_TEST implies that we have
-// ::std::string, so we can use it here.
-static void SplitString(const ::std::string& str, char delimiter,
-                        ::std::vector< ::std::string>* dest) {
-  ::std::vector< ::std::string> parsed;
-  ::std::string::size_type pos = 0;
-  while (::testing::internal::AlwaysTrue()) {
-    const ::std::string::size_type colon = str.find(delimiter, pos);
-    if (colon == ::std::string::npos) {
-      parsed.push_back(str.substr(pos));
-      break;
-    } else {
-      parsed.push_back(str.substr(pos, colon - pos));
-      pos = colon + 1;
-    }
-  }
-  dest->swap(parsed);
-}
-
-# if GTEST_OS_WINDOWS
-// Recreates the pipe and event handles from the provided parameters,
-// signals the event, and returns a file descriptor wrapped around the pipe
-// handle. This function is called in the child process only.
-int GetStatusFileDescriptor(unsigned int parent_process_id,
-                            size_t write_handle_as_size_t,
-                            size_t event_handle_as_size_t) {
-  AutoHandle parent_process_handle(::OpenProcess(PROCESS_DUP_HANDLE,
-                                                   FALSE,  // Non-inheritable.
-                                                   parent_process_id));
-  if (parent_process_handle.Get() == INVALID_HANDLE_VALUE) {
-    DeathTestAbort(String::Format("Unable to open parent process %u",
-                                  parent_process_id));
-  }
-
-  // TODO(vladl at google.com): Replace the following check with a
-  // compile-time assertion when available.
-  GTEST_CHECK_(sizeof(HANDLE) <= sizeof(size_t));
-
-  const HANDLE write_handle =
-      reinterpret_cast<HANDLE>(write_handle_as_size_t);
-  HANDLE dup_write_handle;
-
-  // The newly initialized handle is accessible only in in the parent
-  // process. To obtain one accessible within the child, we need to use
-  // DuplicateHandle.
-  if (!::DuplicateHandle(parent_process_handle.Get(), write_handle,
-                         ::GetCurrentProcess(), &dup_write_handle,
-                         0x0,    // Requested privileges ignored since
-                                 // DUPLICATE_SAME_ACCESS is used.
-                         FALSE,  // Request non-inheritable handler.
-                         DUPLICATE_SAME_ACCESS)) {
-    DeathTestAbort(String::Format(
-        "Unable to duplicate the pipe handle %Iu from the parent process %u",
-        write_handle_as_size_t, parent_process_id));
-  }
-
-  const HANDLE event_handle = reinterpret_cast<HANDLE>(event_handle_as_size_t);
-  HANDLE dup_event_handle;
-
-  if (!::DuplicateHandle(parent_process_handle.Get(), event_handle,
-                         ::GetCurrentProcess(), &dup_event_handle,
-                         0x0,
-                         FALSE,
-                         DUPLICATE_SAME_ACCESS)) {
-    DeathTestAbort(String::Format(
-        "Unable to duplicate the event handle %Iu from the parent process %u",
-        event_handle_as_size_t, parent_process_id));
-  }
-
-  const int write_fd =
-      ::_open_osfhandle(reinterpret_cast<intptr_t>(dup_write_handle), O_APPEND);
-  if (write_fd == -1) {
-    DeathTestAbort(String::Format(
-        "Unable to convert pipe handle %Iu to a file descriptor",
-        write_handle_as_size_t));
-  }
-
-  // Signals the parent that the write end of the pipe has been acquired
-  // so the parent can release its own write end.
-  ::SetEvent(dup_event_handle);
-
-  return write_fd;
-}
-# endif  // GTEST_OS_WINDOWS
-
-// Returns a newly created InternalRunDeathTestFlag object with fields
-// initialized from the GTEST_FLAG(internal_run_death_test) flag if
-// the flag is specified; otherwise returns NULL.
-InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {
-  if (GTEST_FLAG(internal_run_death_test) == "") return NULL;
-
-  // GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we
-  // can use it here.
-  int line = -1;
-  int index = -1;
-  ::std::vector< ::std::string> fields;
-  SplitString(GTEST_FLAG(internal_run_death_test).c_str(), '|', &fields);
-  int write_fd = -1;
-
-# if GTEST_OS_WINDOWS
-
-  unsigned int parent_process_id = 0;
-  size_t write_handle_as_size_t = 0;
-  size_t event_handle_as_size_t = 0;
-
-  if (fields.size() != 6
-      || !ParseNaturalNumber(fields[1], &line)
-      || !ParseNaturalNumber(fields[2], &index)
-      || !ParseNaturalNumber(fields[3], &parent_process_id)
-      || !ParseNaturalNumber(fields[4], &write_handle_as_size_t)
-      || !ParseNaturalNumber(fields[5], &event_handle_as_size_t)) {
-    DeathTestAbort(String::Format(
-        "Bad --gtest_internal_run_death_test flag: %s",
-        GTEST_FLAG(internal_run_death_test).c_str()));
-  }
-  write_fd = GetStatusFileDescriptor(parent_process_id,
-                                     write_handle_as_size_t,
-                                     event_handle_as_size_t);
-# else
-
-  if (fields.size() != 4
-      || !ParseNaturalNumber(fields[1], &line)
-      || !ParseNaturalNumber(fields[2], &index)
-      || !ParseNaturalNumber(fields[3], &write_fd)) {
-    DeathTestAbort(String::Format(
-        "Bad --gtest_internal_run_death_test flag: %s",
-        GTEST_FLAG(internal_run_death_test).c_str()));
-  }
-
-# endif  // GTEST_OS_WINDOWS
-
-  return new InternalRunDeathTestFlag(fields[0], line, index, write_fd);
-}
-
-}  // namespace internal
-
-#endif  // GTEST_HAS_DEATH_TEST
-
-}  // namespace testing
-// Copyright 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Authors: keith.ray at gmail.com (Keith Ray)
-
-
-#include <stdlib.h>
-
-#if GTEST_OS_WINDOWS_MOBILE
-# include <windows.h>
-#elif GTEST_OS_WINDOWS
-# include <direct.h>
-# include <io.h>
-#elif GTEST_OS_SYMBIAN || GTEST_OS_NACL
-// Symbian OpenC and NaCl have PATH_MAX in sys/syslimits.h
-# include <sys/syslimits.h>
-#else
-# include <limits.h>
-# include <climits>  // Some Linux distributions define PATH_MAX here.
-#endif  // GTEST_OS_WINDOWS_MOBILE
-
-#if GTEST_OS_WINDOWS
-# define GTEST_PATH_MAX_ _MAX_PATH
-#elif defined(PATH_MAX)
-# define GTEST_PATH_MAX_ PATH_MAX
-#elif defined(_XOPEN_PATH_MAX)
-# define GTEST_PATH_MAX_ _XOPEN_PATH_MAX
-#else
-# define GTEST_PATH_MAX_ _POSIX_PATH_MAX
-#endif  // GTEST_OS_WINDOWS
-
-
-namespace testing {
-namespace internal {
-
-#if GTEST_OS_WINDOWS
-// On Windows, '\\' is the standard path separator, but many tools and the
-// Windows API also accept '/' as an alternate path separator. Unless otherwise
-// noted, a file path can contain either kind of path separators, or a mixture
-// of them.
-const char kPathSeparator = '\\';
-const char kAlternatePathSeparator = '/';
-const char kPathSeparatorString[] = "\\";
-const char kAlternatePathSeparatorString[] = "/";
-# if GTEST_OS_WINDOWS_MOBILE
-// Windows CE doesn't have a current directory. You should not use
-// the current directory in tests on Windows CE, but this at least
-// provides a reasonable fallback.
-const char kCurrentDirectoryString[] = "\\";
-// Windows CE doesn't define INVALID_FILE_ATTRIBUTES
-const DWORD kInvalidFileAttributes = 0xffffffff;
-# else
-const char kCurrentDirectoryString[] = ".\\";
-# endif  // GTEST_OS_WINDOWS_MOBILE
-#else
-const char kPathSeparator = '/';
-const char kPathSeparatorString[] = "/";
-const char kCurrentDirectoryString[] = "./";
-#endif  // GTEST_OS_WINDOWS
-
-// Returns whether the given character is a valid path separator.
-static bool IsPathSeparator(char c) {
-#if GTEST_HAS_ALT_PATH_SEP_
-  return (c == kPathSeparator) || (c == kAlternatePathSeparator);
-#else
-  return c == kPathSeparator;
-#endif
-}
-
-// Returns the current working directory, or "" if unsuccessful.
-FilePath FilePath::GetCurrentDir() {
-#if GTEST_OS_WINDOWS_MOBILE
-  // Windows CE doesn't have a current directory, so we just return
-  // something reasonable.
-  return FilePath(kCurrentDirectoryString);
-#elif GTEST_OS_WINDOWS
-  char cwd[GTEST_PATH_MAX_ + 1] = { '\0' };
-  return FilePath(_getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd);
-#else
-  char cwd[GTEST_PATH_MAX_ + 1] = { '\0' };
-  return FilePath(getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd);
-#endif  // GTEST_OS_WINDOWS_MOBILE
-}
-
-// Returns a copy of the FilePath with the case-insensitive extension removed.
-// Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns
-// FilePath("dir/file"). If a case-insensitive extension is not
-// found, returns a copy of the original FilePath.
-FilePath FilePath::RemoveExtension(const char* extension) const {
-  String dot_extension(String::Format(".%s", extension));
-  if (pathname_.EndsWithCaseInsensitive(dot_extension.c_str())) {
-    return FilePath(String(pathname_.c_str(), pathname_.length() - 4));
-  }
-  return *this;
-}
-
-// Returns a pointer to the last occurence of a valid path separator in
-// the FilePath. On Windows, for example, both '/' and '\' are valid path
-// separators. Returns NULL if no path separator was found.
-const char* FilePath::FindLastPathSeparator() const {
-  const char* const last_sep = strrchr(c_str(), kPathSeparator);
-#if GTEST_HAS_ALT_PATH_SEP_
-  const char* const last_alt_sep = strrchr(c_str(), kAlternatePathSeparator);
-  // Comparing two pointers of which only one is NULL is undefined.
-  if (last_alt_sep != NULL &&
-      (last_sep == NULL || last_alt_sep > last_sep)) {
-    return last_alt_sep;
-  }
-#endif
-  return last_sep;
-}
-
-// Returns a copy of the FilePath with the directory part removed.
-// Example: FilePath("path/to/file").RemoveDirectoryName() returns
-// FilePath("file"). If there is no directory part ("just_a_file"), it returns
-// the FilePath unmodified. If there is no file part ("just_a_dir/") it
-// returns an empty FilePath ("").
-// On Windows platform, '\' is the path separator, otherwise it is '/'.
-FilePath FilePath::RemoveDirectoryName() const {
-  const char* const last_sep = FindLastPathSeparator();
-  return last_sep ? FilePath(String(last_sep + 1)) : *this;
-}
-
-// RemoveFileName returns the directory path with the filename removed.
-// Example: FilePath("path/to/file").RemoveFileName() returns "path/to/".
-// If the FilePath is "a_file" or "/a_file", RemoveFileName returns
-// FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does
-// not have a file, like "just/a/dir/", it returns the FilePath unmodified.
-// On Windows platform, '\' is the path separator, otherwise it is '/'.
-FilePath FilePath::RemoveFileName() const {
-  const char* const last_sep = FindLastPathSeparator();
-  String dir;
-  if (last_sep) {
-    dir = String(c_str(), last_sep + 1 - c_str());
-  } else {
-    dir = kCurrentDirectoryString;
-  }
-  return FilePath(dir);
-}
-
-// Helper functions for naming files in a directory for xml output.
-
-// Given directory = "dir", base_name = "test", number = 0,
-// extension = "xml", returns "dir/test.xml". If number is greater
-// than zero (e.g., 12), returns "dir/test_12.xml".
-// On Windows platform, uses \ as the separator rather than /.
-FilePath FilePath::MakeFileName(const FilePath& directory,
-                                const FilePath& base_name,
-                                int number,
-                                const char* extension) {
-  String file;
-  if (number == 0) {
-    file = String::Format("%s.%s", base_name.c_str(), extension);
-  } else {
-    file = String::Format("%s_%d.%s", base_name.c_str(), number, extension);
-  }
-  return ConcatPaths(directory, FilePath(file));
-}
-
-// Given directory = "dir", relative_path = "test.xml", returns "dir/test.xml".
-// On Windows, uses \ as the separator rather than /.
-FilePath FilePath::ConcatPaths(const FilePath& directory,
-                               const FilePath& relative_path) {
-  if (directory.IsEmpty())
-    return relative_path;
-  const FilePath dir(directory.RemoveTrailingPathSeparator());
-  return FilePath(String::Format("%s%c%s", dir.c_str(), kPathSeparator,
-                                 relative_path.c_str()));
-}
-
-// Returns true if pathname describes something findable in the file-system,
-// either a file, directory, or whatever.
-bool FilePath::FileOrDirectoryExists() const {
-#if GTEST_OS_WINDOWS_MOBILE
-  LPCWSTR unicode = String::AnsiToUtf16(pathname_.c_str());
-  const DWORD attributes = GetFileAttributes(unicode);
-  delete [] unicode;
-  return attributes != kInvalidFileAttributes;
-#else
-  posix::StatStruct file_stat;
-  return posix::Stat(pathname_.c_str(), &file_stat) == 0;
-#endif  // GTEST_OS_WINDOWS_MOBILE
-}
-
-// Returns true if pathname describes a directory in the file-system
-// that exists.
-bool FilePath::DirectoryExists() const {
-  bool result = false;
-#if GTEST_OS_WINDOWS
-  // Don't strip off trailing separator if path is a root directory on
-  // Windows (like "C:\\").
-  const FilePath& path(IsRootDirectory() ? *this :
-                                           RemoveTrailingPathSeparator());
-#else
-  const FilePath& path(*this);
-#endif
-
-#if GTEST_OS_WINDOWS_MOBILE
-  LPCWSTR unicode = String::AnsiToUtf16(path.c_str());
-  const DWORD attributes = GetFileAttributes(unicode);
-  delete [] unicode;
-  if ((attributes != kInvalidFileAttributes) &&
-      (attributes & FILE_ATTRIBUTE_DIRECTORY)) {
-    result = true;
-  }
-#else
-  posix::StatStruct file_stat;
-  result = posix::Stat(path.c_str(), &file_stat) == 0 &&
-      posix::IsDir(file_stat);
-#endif  // GTEST_OS_WINDOWS_MOBILE
-
-  return result;
-}
-
-// Returns true if pathname describes a root directory. (Windows has one
-// root directory per disk drive.)
-bool FilePath::IsRootDirectory() const {
-#if GTEST_OS_WINDOWS
-  // TODO(wan at google.com): on Windows a network share like
-  // \\server\share can be a root directory, although it cannot be the
-  // current directory.  Handle this properly.
-  return pathname_.length() == 3 && IsAbsolutePath();
-#else
-  return pathname_.length() == 1 && IsPathSeparator(pathname_.c_str()[0]);
-#endif
-}
-
-// Returns true if pathname describes an absolute path.
-bool FilePath::IsAbsolutePath() const {
-  const char* const name = pathname_.c_str();
-#if GTEST_OS_WINDOWS
-  return pathname_.length() >= 3 &&
-     ((name[0] >= 'a' && name[0] <= 'z') ||
-      (name[0] >= 'A' && name[0] <= 'Z')) &&
-     name[1] == ':' &&
-     IsPathSeparator(name[2]);
-#else
-  return IsPathSeparator(name[0]);
-#endif
-}
-
-// Returns a pathname for a file that does not currently exist. The pathname
-// will be directory/base_name.extension or
-// directory/base_name_<number>.extension if directory/base_name.extension
-// already exists. The number will be incremented until a pathname is found
-// that does not already exist.
-// Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.
-// There could be a race condition if two or more processes are calling this
-// function at the same time -- they could both pick the same filename.
-FilePath FilePath::GenerateUniqueFileName(const FilePath& directory,
-                                          const FilePath& base_name,
-                                          const char* extension) {
-  FilePath full_pathname;
-  int number = 0;
-  do {
-    full_pathname.Set(MakeFileName(directory, base_name, number++, extension));
-  } while (full_pathname.FileOrDirectoryExists());
-  return full_pathname;
-}
-
-// Returns true if FilePath ends with a path separator, which indicates that
-// it is intended to represent a directory. Returns false otherwise.
-// This does NOT check that a directory (or file) actually exists.
-bool FilePath::IsDirectory() const {
-  return !pathname_.empty() &&
-         IsPathSeparator(pathname_.c_str()[pathname_.length() - 1]);
-}
-
-// Create directories so that path exists. Returns true if successful or if
-// the directories already exist; returns false if unable to create directories
-// for any reason.
-bool FilePath::CreateDirectoriesRecursively() const {
-  if (!this->IsDirectory()) {
-    return false;
-  }
-
-  if (pathname_.length() == 0 || this->DirectoryExists()) {
-    return true;
-  }
-
-  const FilePath parent(this->RemoveTrailingPathSeparator().RemoveFileName());
-  return parent.CreateDirectoriesRecursively() && this->CreateFolder();
-}
-
-// Create the directory so that path exists. Returns true if successful or
-// if the directory already exists; returns false if unable to create the
-// directory for any reason, including if the parent directory does not
-// exist. Not named "CreateDirectory" because that's a macro on Windows.
-bool FilePath::CreateFolder() const {
-#if GTEST_OS_WINDOWS_MOBILE
-  FilePath removed_sep(this->RemoveTrailingPathSeparator());
-  LPCWSTR unicode = String::AnsiToUtf16(removed_sep.c_str());
-  int result = CreateDirectory(unicode, NULL) ? 0 : -1;
-  delete [] unicode;
-#elif GTEST_OS_WINDOWS
-  int result = _mkdir(pathname_.c_str());
-#else
-  int result = mkdir(pathname_.c_str(), 0777);
-#endif  // GTEST_OS_WINDOWS_MOBILE
-
-  if (result == -1) {
-    return this->DirectoryExists();  // An error is OK if the directory exists.
-  }
-  return true;  // No error.
-}
-
-// If input name has a trailing separator character, remove it and return the
-// name, otherwise return the name string unmodified.
-// On Windows platform, uses \ as the separator, other platforms use /.
-FilePath FilePath::RemoveTrailingPathSeparator() const {
-  return IsDirectory()
-      ? FilePath(String(pathname_.c_str(), pathname_.length() - 1))
-      : *this;
-}
-
-// Removes any redundant separators that might be in the pathname.
-// For example, "bar///foo" becomes "bar/foo". Does not eliminate other
-// redundancies that might be in a pathname involving "." or "..".
-// TODO(wan at google.com): handle Windows network shares (e.g. \\server\share).
-void FilePath::Normalize() {
-  if (pathname_.c_str() == NULL) {
-    pathname_ = "";
-    return;
-  }
-  const char* src = pathname_.c_str();
-  char* const dest = new char[pathname_.length() + 1];
-  char* dest_ptr = dest;
-  memset(dest_ptr, 0, pathname_.length() + 1);
-
-  while (*src != '\0') {
-    *dest_ptr = *src;
-    if (!IsPathSeparator(*src)) {
-      src++;
-    } else {
-#if GTEST_HAS_ALT_PATH_SEP_
-      if (*dest_ptr == kAlternatePathSeparator) {
-        *dest_ptr = kPathSeparator;
-      }
-#endif
-      while (IsPathSeparator(*src))
-        src++;
-    }
-    dest_ptr++;
-  }
-  *dest_ptr = '\0';
-  pathname_ = dest;
-  delete[] dest;
-}
-
-}  // namespace internal
-}  // namespace testing
-// Copyright 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan at google.com (Zhanyong Wan)
-
-
-#include <limits.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#if GTEST_OS_WINDOWS_MOBILE
-# include <windows.h>  // For TerminateProcess()
-#elif GTEST_OS_WINDOWS
-# include <io.h>
-# include <sys/stat.h>
-#else
-# include <unistd.h>
-#endif  // GTEST_OS_WINDOWS_MOBILE
-
-#if GTEST_OS_MAC
-# include <mach/mach_init.h>
-# include <mach/task.h>
-# include <mach/vm_map.h>
-#endif  // GTEST_OS_MAC
-
-
-// Indicates that this translation unit is part of Google Test's
-// implementation.  It must come before gtest-internal-inl.h is
-// included, or there will be a compiler error.  This trick is to
-// prevent a user from accidentally including gtest-internal-inl.h in
-// his code.
-#define GTEST_IMPLEMENTATION_ 1
-#undef GTEST_IMPLEMENTATION_
-
-namespace testing {
-namespace internal {
-
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-// MSVC and C++Builder do not provide a definition of STDERR_FILENO.
-const int kStdOutFileno = 1;
-const int kStdErrFileno = 2;
-#else
-const int kStdOutFileno = STDOUT_FILENO;
-const int kStdErrFileno = STDERR_FILENO;
-#endif  // _MSC_VER
-
-#if GTEST_OS_MAC
-
-// Returns the number of threads running in the process, or 0 to indicate that
-// we cannot detect it.
-size_t GetThreadCount() {
-  const task_t task = mach_task_self();
-  mach_msg_type_number_t thread_count;
-  thread_act_array_t thread_list;
-  const kern_return_t status = task_threads(task, &thread_list, &thread_count);
-  if (status == KERN_SUCCESS) {
-    // task_threads allocates resources in thread_list and we need to free them
-    // to avoid leaks.
-    vm_deallocate(task,
-                  reinterpret_cast<vm_address_t>(thread_list),
-                  sizeof(thread_t) * thread_count);
-    return static_cast<size_t>(thread_count);
-  } else {
-    return 0;
-  }
-}
-
-#else
-
-size_t GetThreadCount() {
-  // There's no portable way to detect the number of threads, so we just
-  // return 0 to indicate that we cannot detect it.
-  return 0;
-}
-
-#endif  // GTEST_OS_MAC
-
-#if GTEST_USES_POSIX_RE
-
-// Implements RE.  Currently only needed for death tests.
-
-RE::~RE() {
-  if (is_valid_) {
-    // regfree'ing an invalid regex might crash because the content
-    // of the regex is undefined. Since the regex's are essentially
-    // the same, one cannot be valid (or invalid) without the other
-    // being so too.
-    regfree(&partial_regex_);
-    regfree(&full_regex_);
-  }
-  free(const_cast<char*>(pattern_));
-}
-
-// Returns true iff regular expression re matches the entire str.
-bool RE::FullMatch(const char* str, const RE& re) {
-  if (!re.is_valid_) return false;
-
-  regmatch_t match;
-  return regexec(&re.full_regex_, str, 1, &match, 0) == 0;
-}
-
-// Returns true iff regular expression re matches a substring of str
-// (including str itself).
-bool RE::PartialMatch(const char* str, const RE& re) {
-  if (!re.is_valid_) return false;
-
-  regmatch_t match;
-  return regexec(&re.partial_regex_, str, 1, &match, 0) == 0;
-}
-
-// Initializes an RE from its string representation.
-void RE::Init(const char* regex) {
-  pattern_ = posix::StrDup(regex);
-
-  // Reserves enough bytes to hold the regular expression used for a
-  // full match.
-  const size_t full_regex_len = strlen(regex) + 10;
-  char* const full_pattern = new char[full_regex_len];
-
-  snprintf(full_pattern, full_regex_len, "^(%s)$", regex);
-  is_valid_ = regcomp(&full_regex_, full_pattern, REG_EXTENDED) == 0;
-  // We want to call regcomp(&partial_regex_, ...) even if the
-  // previous expression returns false.  Otherwise partial_regex_ may
-  // not be properly initialized can may cause trouble when it's
-  // freed.
-  //
-  // Some implementation of POSIX regex (e.g. on at least some
-  // versions of Cygwin) doesn't accept the empty string as a valid
-  // regex.  We change it to an equivalent form "()" to be safe.
-  if (is_valid_) {
-    const char* const partial_regex = (*regex == '\0') ? "()" : regex;
-    is_valid_ = regcomp(&partial_regex_, partial_regex, REG_EXTENDED) == 0;
-  }
-  EXPECT_TRUE(is_valid_)
-      << "Regular expression \"" << regex
-      << "\" is not a valid POSIX Extended regular expression.";
-
-  delete[] full_pattern;
-}
-
-#elif GTEST_USES_SIMPLE_RE
-
-// Returns true iff ch appears anywhere in str (excluding the
-// terminating '\0' character).
-bool IsInSet(char ch, const char* str) {
-  return ch != '\0' && strchr(str, ch) != NULL;
-}
-
-// Returns true iff ch belongs to the given classification.  Unlike
-// similar functions in <ctype.h>, these aren't affected by the
-// current locale.
-bool IsAsciiDigit(char ch) { return '0' <= ch && ch <= '9'; }
-bool IsAsciiPunct(char ch) {
-  return IsInSet(ch, "^-!\"#$%&'()*+,./:;<=>?@[\\]_`{|}~");
-}
-bool IsRepeat(char ch) { return IsInSet(ch, "?*+"); }
-bool IsAsciiWhiteSpace(char ch) { return IsInSet(ch, " \f\n\r\t\v"); }
-bool IsAsciiWordChar(char ch) {
-  return ('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z') ||
-      ('0' <= ch && ch <= '9') || ch == '_';
-}
-
-// Returns true iff "\\c" is a supported escape sequence.
-bool IsValidEscape(char c) {
-  return (IsAsciiPunct(c) || IsInSet(c, "dDfnrsStvwW"));
-}
-
-// Returns true iff the given atom (specified by escaped and pattern)
-// matches ch.  The result is undefined if the atom is invalid.
-bool AtomMatchesChar(bool escaped, char pattern_char, char ch) {
-  if (escaped) {  // "\\p" where p is pattern_char.
-    switch (pattern_char) {
-      case 'd': return IsAsciiDigit(ch);
-      case 'D': return !IsAsciiDigit(ch);
-      case 'f': return ch == '\f';
-      case 'n': return ch == '\n';
-      case 'r': return ch == '\r';
-      case 's': return IsAsciiWhiteSpace(ch);
-      case 'S': return !IsAsciiWhiteSpace(ch);
-      case 't': return ch == '\t';
-      case 'v': return ch == '\v';
-      case 'w': return IsAsciiWordChar(ch);
-      case 'W': return !IsAsciiWordChar(ch);
-    }
-    return IsAsciiPunct(pattern_char) && pattern_char == ch;
-  }
-
-  return (pattern_char == '.' && ch != '\n') || pattern_char == ch;
-}
-
-// Helper function used by ValidateRegex() to format error messages.
-String FormatRegexSyntaxError(const char* regex, int index) {
-  return (Message() << "Syntax error at index " << index
-          << " in simple regular expression \"" << regex << "\": ").GetString();
-}
-
-// Generates non-fatal failures and returns false if regex is invalid;
-// otherwise returns true.
-bool ValidateRegex(const char* regex) {
-  if (regex == NULL) {
-    // TODO(wan at google.com): fix the source file location in the
-    // assertion failures to match where the regex is used in user
-    // code.
-    ADD_FAILURE() << "NULL is not a valid simple regular expression.";
-    return false;
-  }
-
-  bool is_valid = true;
-
-  // True iff ?, *, or + can follow the previous atom.
-  bool prev_repeatable = false;
-  for (int i = 0; regex[i]; i++) {
-    if (regex[i] == '\\') {  // An escape sequence
-      i++;
-      if (regex[i] == '\0') {
-        ADD_FAILURE() << FormatRegexSyntaxError(regex, i - 1)
-                      << "'\\' cannot appear at the end.";
-        return false;
-      }
-
-      if (!IsValidEscape(regex[i])) {
-        ADD_FAILURE() << FormatRegexSyntaxError(regex, i - 1)
-                      << "invalid escape sequence \"\\" << regex[i] << "\".";
-        is_valid = false;
-      }
-      prev_repeatable = true;
-    } else {  // Not an escape sequence.
-      const char ch = regex[i];
-
-      if (ch == '^' && i > 0) {
-        ADD_FAILURE() << FormatRegexSyntaxError(regex, i)
-                      << "'^' can only appear at the beginning.";
-        is_valid = false;
-      } else if (ch == '$' && regex[i + 1] != '\0') {
-        ADD_FAILURE() << FormatRegexSyntaxError(regex, i)
-                      << "'$' can only appear at the end.";
-        is_valid = false;
-      } else if (IsInSet(ch, "()[]{}|")) {
-        ADD_FAILURE() << FormatRegexSyntaxError(regex, i)
-                      << "'" << ch << "' is unsupported.";
-        is_valid = false;
-      } else if (IsRepeat(ch) && !prev_repeatable) {
-        ADD_FAILURE() << FormatRegexSyntaxError(regex, i)
-                      << "'" << ch << "' can only follow a repeatable token.";
-        is_valid = false;
-      }
-
-      prev_repeatable = !IsInSet(ch, "^$?*+");
-    }
-  }
-
-  return is_valid;
-}
-
-// Matches a repeated regex atom followed by a valid simple regular
-// expression.  The regex atom is defined as c if escaped is false,
-// or \c otherwise.  repeat is the repetition meta character (?, *,
-// or +).  The behavior is undefined if str contains too many
-// characters to be indexable by size_t, in which case the test will
-// probably time out anyway.  We are fine with this limitation as
-// std::string has it too.
-bool MatchRepetitionAndRegexAtHead(
-    bool escaped, char c, char repeat, const char* regex,
-    const char* str) {
-  const size_t min_count = (repeat == '+') ? 1 : 0;
-  const size_t max_count = (repeat == '?') ? 1 :
-      static_cast<size_t>(-1) - 1;
-  // We cannot call numeric_limits::max() as it conflicts with the
-  // max() macro on Windows.
-
-  for (size_t i = 0; i <= max_count; ++i) {
-    // We know that the atom matches each of the first i characters in str.
-    if (i >= min_count && MatchRegexAtHead(regex, str + i)) {
-      // We have enough matches at the head, and the tail matches too.
-      // Since we only care about *whether* the pattern matches str
-      // (as opposed to *how* it matches), there is no need to find a
-      // greedy match.
-      return true;
-    }
-    if (str[i] == '\0' || !AtomMatchesChar(escaped, c, str[i]))
-      return false;
-  }
-  return false;
-}
-
-// Returns true iff regex matches a prefix of str.  regex must be a
-// valid simple regular expression and not start with "^", or the
-// result is undefined.
-bool MatchRegexAtHead(const char* regex, const char* str) {
-  if (*regex == '\0')  // An empty regex matches a prefix of anything.
-    return true;
-
-  // "$" only matches the end of a string.  Note that regex being
-  // valid guarantees that there's nothing after "$" in it.
-  if (*regex == '$')
-    return *str == '\0';
-
-  // Is the first thing in regex an escape sequence?
-  const bool escaped = *regex == '\\';
-  if (escaped)
-    ++regex;
-  if (IsRepeat(regex[1])) {
-    // MatchRepetitionAndRegexAtHead() calls MatchRegexAtHead(), so
-    // here's an indirect recursion.  It terminates as the regex gets
-    // shorter in each recursion.
-    return MatchRepetitionAndRegexAtHead(
-        escaped, regex[0], regex[1], regex + 2, str);
-  } else {
-    // regex isn't empty, isn't "$", and doesn't start with a
-    // repetition.  We match the first atom of regex with the first
-    // character of str and recurse.
-    return (*str != '\0') && AtomMatchesChar(escaped, *regex, *str) &&
-        MatchRegexAtHead(regex + 1, str + 1);
-  }
-}
-
-// Returns true iff regex matches any substring of str.  regex must be
-// a valid simple regular expression, or the result is undefined.
-//
-// The algorithm is recursive, but the recursion depth doesn't exceed
-// the regex length, so we won't need to worry about running out of
-// stack space normally.  In rare cases the time complexity can be
-// exponential with respect to the regex length + the string length,
-// but usually it's must faster (often close to linear).
-bool MatchRegexAnywhere(const char* regex, const char* str) {
-  if (regex == NULL || str == NULL)
-    return false;
-
-  if (*regex == '^')
-    return MatchRegexAtHead(regex + 1, str);
-
-  // A successful match can be anywhere in str.
-  do {
-    if (MatchRegexAtHead(regex, str))
-      return true;
-  } while (*str++ != '\0');
-  return false;
-}
-
-// Implements the RE class.
-
-RE::~RE() {
-  free(const_cast<char*>(pattern_));
-  free(const_cast<char*>(full_pattern_));
-}
-
-// Returns true iff regular expression re matches the entire str.
-bool RE::FullMatch(const char* str, const RE& re) {
-  return re.is_valid_ && MatchRegexAnywhere(re.full_pattern_, str);
-}
-
-// Returns true iff regular expression re matches a substring of str
-// (including str itself).
-bool RE::PartialMatch(const char* str, const RE& re) {
-  return re.is_valid_ && MatchRegexAnywhere(re.pattern_, str);
-}
-
-// Initializes an RE from its string representation.
-void RE::Init(const char* regex) {
-  pattern_ = full_pattern_ = NULL;
-  if (regex != NULL) {
-    pattern_ = posix::StrDup(regex);
-  }
-
-  is_valid_ = ValidateRegex(regex);
-  if (!is_valid_) {
-    // No need to calculate the full pattern when the regex is invalid.
-    return;
-  }
-
-  const size_t len = strlen(regex);
-  // Reserves enough bytes to hold the regular expression used for a
-  // full match: we need space to prepend a '^', append a '$', and
-  // terminate the string with '\0'.
-  char* buffer = static_cast<char*>(malloc(len + 3));
-  full_pattern_ = buffer;
-
-  if (*regex != '^')
-    *buffer++ = '^';  // Makes sure full_pattern_ starts with '^'.
-
-  // We don't use snprintf or strncpy, as they trigger a warning when
-  // compiled with VC++ 8.0.
-  memcpy(buffer, regex, len);
-  buffer += len;
-
-  if (len == 0 || regex[len - 1] != '$')
-    *buffer++ = '$';  // Makes sure full_pattern_ ends with '$'.
-
-  *buffer = '\0';
-}
-
-#endif  // GTEST_USES_POSIX_RE
-
-const char kUnknownFile[] = "unknown file";
-
-// Formats a source file path and a line number as they would appear
-// in an error message from the compiler used to compile this code.
-GTEST_API_ ::std::string FormatFileLocation(const char* file, int line) {
-  const char* const file_name = file == NULL ? kUnknownFile : file;
-
-  if (line < 0) {
-    return String::Format("%s:", file_name).c_str();
-  }
-#ifdef _MSC_VER
-  return String::Format("%s(%d):", file_name, line).c_str();
-#else
-  return String::Format("%s:%d:", file_name, line).c_str();
-#endif  // _MSC_VER
-}
-
-// Formats a file location for compiler-independent XML output.
-// Although this function is not platform dependent, we put it next to
-// FormatFileLocation in order to contrast the two functions.
-// Note that FormatCompilerIndependentFileLocation() does NOT append colon
-// to the file location it produces, unlike FormatFileLocation().
-GTEST_API_ ::std::string FormatCompilerIndependentFileLocation(
-    const char* file, int line) {
-  const char* const file_name = file == NULL ? kUnknownFile : file;
-
-  if (line < 0)
-    return file_name;
-  else
-    return String::Format("%s:%d", file_name, line).c_str();
-}
-
-
-GTestLog::GTestLog(GTestLogSeverity severity, const char* file, int line)
-    : severity_(severity) {
-  const char* const marker =
-      severity == GTEST_INFO ?    "[  INFO ]" :
-      severity == GTEST_WARNING ? "[WARNING]" :
-      severity == GTEST_ERROR ?   "[ ERROR ]" : "[ FATAL ]";
-  GetStream() << ::std::endl << marker << " "
-              << FormatFileLocation(file, line).c_str() << ": ";
-}
-
-// Flushes the buffers and, if severity is GTEST_FATAL, aborts the program.
-GTestLog::~GTestLog() {
-  GetStream() << ::std::endl;
-  if (severity_ == GTEST_FATAL) {
-    fflush(stderr);
-    posix::Abort();
-  }
-}
-// Disable Microsoft deprecation warnings for POSIX functions called from
-// this class (creat, dup, dup2, and close)
-#ifdef _MSC_VER
-# pragma warning(push)
-# pragma warning(disable: 4996)
-#endif  // _MSC_VER
-
-#if GTEST_HAS_STREAM_REDIRECTION
-
-// Object that captures an output stream (stdout/stderr).
-class CapturedStream {
- public:
-  // The ctor redirects the stream to a temporary file.
-  CapturedStream(int fd) : fd_(fd), uncaptured_fd_(dup(fd)) {
-
-# if GTEST_OS_WINDOWS
-    char temp_dir_path[MAX_PATH + 1] = { '\0' };  // NOLINT
-    char temp_file_path[MAX_PATH + 1] = { '\0' };  // NOLINT
-
-    ::GetTempPathA(sizeof(temp_dir_path), temp_dir_path);
-    const UINT success = ::GetTempFileNameA(temp_dir_path,
-                                            "gtest_redir",
-                                            0,  // Generate unique file name.
-                                            temp_file_path);
-    GTEST_CHECK_(success != 0)
-        << "Unable to create a temporary file in " << temp_dir_path;
-    const int captured_fd = creat(temp_file_path, _S_IREAD | _S_IWRITE);
-    GTEST_CHECK_(captured_fd != -1) << "Unable to open temporary file "
-                                    << temp_file_path;
-    filename_ = temp_file_path;
-# else
-    // There's no guarantee that a test has write access to the
-    // current directory, so we create the temporary file in the /tmp
-    // directory instead.
-    char name_template[] = "/tmp/captured_stream.XXXXXX";
-    const int captured_fd = mkstemp(name_template);
-    filename_ = name_template;
-# endif  // GTEST_OS_WINDOWS
-    fflush(NULL);
-    dup2(captured_fd, fd_);
-    close(captured_fd);
-  }
-
-  ~CapturedStream() {
-    remove(filename_.c_str());
-  }
-
-  String GetCapturedString() {
-    if (uncaptured_fd_ != -1) {
-      // Restores the original stream.
-      fflush(NULL);
-      dup2(uncaptured_fd_, fd_);
-      close(uncaptured_fd_);
-      uncaptured_fd_ = -1;
-    }
-
-    FILE* const file = posix::FOpen(filename_.c_str(), "r");
-    const String content = ReadEntireFile(file);
-    posix::FClose(file);
-    return content;
-  }
-
- private:
-  // Reads the entire content of a file as a String.
-  static String ReadEntireFile(FILE* file);
-
-  // Returns the size (in bytes) of a file.
-  static size_t GetFileSize(FILE* file);
-
-  const int fd_;  // A stream to capture.
-  int uncaptured_fd_;
-  // Name of the temporary file holding the stderr output.
-  ::std::string filename_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(CapturedStream);
-};
-
-// Returns the size (in bytes) of a file.
-size_t CapturedStream::GetFileSize(FILE* file) {
-  fseek(file, 0, SEEK_END);
-  return static_cast<size_t>(ftell(file));
-}
-
-// Reads the entire content of a file as a string.
-String CapturedStream::ReadEntireFile(FILE* file) {
-  const size_t file_size = GetFileSize(file);
-  char* const buffer = new char[file_size];
-
-  size_t bytes_last_read = 0;  // # of bytes read in the last fread()
-  size_t bytes_read = 0;       // # of bytes read so far
-
-  fseek(file, 0, SEEK_SET);
-
-  // Keeps reading the file until we cannot read further or the
-  // pre-determined file size is reached.
-  do {
-    bytes_last_read = fread(buffer+bytes_read, 1, file_size-bytes_read, file);
-    bytes_read += bytes_last_read;
-  } while (bytes_last_read > 0 && bytes_read < file_size);
-
-  const String content(buffer, bytes_read);
-  delete[] buffer;
-
-  return content;
-}
-
-# ifdef _MSC_VER
-#  pragma warning(pop)
-# endif  // _MSC_VER
-
-static CapturedStream* g_captured_stderr = NULL;
-static CapturedStream* g_captured_stdout = NULL;
-
-// Starts capturing an output stream (stdout/stderr).
-void CaptureStream(int fd, const char* stream_name, CapturedStream** stream) {
-  if (*stream != NULL) {
-    GTEST_LOG_(FATAL) << "Only one " << stream_name
-                      << " capturer can exist at a time.";
-  }
-  *stream = new CapturedStream(fd);
-}
-
-// Stops capturing the output stream and returns the captured string.
-String GetCapturedStream(CapturedStream** captured_stream) {
-  const String content = (*captured_stream)->GetCapturedString();
-
-  delete *captured_stream;
-  *captured_stream = NULL;
-
-  return content;
-}
-
-// Starts capturing stdout.
-void CaptureStdout() {
-  CaptureStream(kStdOutFileno, "stdout", &g_captured_stdout);
-}
-
-// Starts capturing stderr.
-void CaptureStderr() {
-  CaptureStream(kStdErrFileno, "stderr", &g_captured_stderr);
-}
-
-// Stops capturing stdout and returns the captured string.
-String GetCapturedStdout() { return GetCapturedStream(&g_captured_stdout); }
-
-// Stops capturing stderr and returns the captured string.
-String GetCapturedStderr() { return GetCapturedStream(&g_captured_stderr); }
-
-#endif  // GTEST_HAS_STREAM_REDIRECTION
-
-#if GTEST_HAS_DEATH_TEST
-
-// A copy of all command line arguments.  Set by InitGoogleTest().
-::std::vector<String> g_argvs;
-
-// Returns the command line as a vector of strings.
-const ::std::vector<String>& GetArgvs() { return g_argvs; }
-
-#endif  // GTEST_HAS_DEATH_TEST
-
-#if GTEST_OS_WINDOWS_MOBILE
-namespace posix {
-void Abort() {
-  DebugBreak();
-  TerminateProcess(GetCurrentProcess(), 1);
-}
-}  // namespace posix
-#endif  // GTEST_OS_WINDOWS_MOBILE
-
-// Returns the name of the environment variable corresponding to the
-// given flag.  For example, FlagToEnvVar("foo") will return
-// "GTEST_FOO" in the open-source version.
-static String FlagToEnvVar(const char* flag) {
-  const String full_flag =
-      (Message() << GTEST_FLAG_PREFIX_ << flag).GetString();
-
-  Message env_var;
-  for (size_t i = 0; i != full_flag.length(); i++) {
-    env_var << ToUpper(full_flag.c_str()[i]);
-  }
-
-  return env_var.GetString();
-}
-
-// Parses 'str' for a 32-bit signed integer.  If successful, writes
-// the result to *value and returns true; otherwise leaves *value
-// unchanged and returns false.
-bool ParseInt32(const Message& src_text, const char* str, Int32* value) {
-  // Parses the environment variable as a decimal integer.
-  char* end = NULL;
-  const long long_value = strtol(str, &end, 10);  // NOLINT
-
-  // Has strtol() consumed all characters in the string?
-  if (*end != '\0') {
-    // No - an invalid character was encountered.
-    Message msg;
-    msg << "WARNING: " << src_text
-        << " is expected to be a 32-bit integer, but actually"
-        << " has value \"" << str << "\".\n";
-    printf("%s", msg.GetString().c_str());
-    fflush(stdout);
-    return false;
-  }
-
-  // Is the parsed value in the range of an Int32?
-  const Int32 result = static_cast<Int32>(long_value);
-  if (long_value == LONG_MAX || long_value == LONG_MIN ||
-      // The parsed value overflows as a long.  (strtol() returns
-      // LONG_MAX or LONG_MIN when the input overflows.)
-      result != long_value
-      // The parsed value overflows as an Int32.
-      ) {
-    Message msg;
-    msg << "WARNING: " << src_text
-        << " is expected to be a 32-bit integer, but actually"
-        << " has value " << str << ", which overflows.\n";
-    printf("%s", msg.GetString().c_str());
-    fflush(stdout);
-    return false;
-  }
-
-  *value = result;
-  return true;
-}
-
-// Reads and returns the Boolean environment variable corresponding to
-// the given flag; if it's not set, returns default_value.
-//
-// The value is considered true iff it's not "0".
-bool BoolFromGTestEnv(const char* flag, bool default_value) {
-  const String env_var = FlagToEnvVar(flag);
-  const char* const string_value = posix::GetEnv(env_var.c_str());
-  return string_value == NULL ?
-      default_value : strcmp(string_value, "0") != 0;
-}
-
-// Reads and returns a 32-bit integer stored in the environment
-// variable corresponding to the given flag; if it isn't set or
-// doesn't represent a valid 32-bit integer, returns default_value.
-Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) {
-  const String env_var = FlagToEnvVar(flag);
-  const char* const string_value = posix::GetEnv(env_var.c_str());
-  if (string_value == NULL) {
-    // The environment variable is not set.
-    return default_value;
-  }
-
-  Int32 result = default_value;
-  if (!ParseInt32(Message() << "Environment variable " << env_var,
-                  string_value, &result)) {
-    printf("The default value %s is used.\n",
-           (Message() << default_value).GetString().c_str());
-    fflush(stdout);
-    return default_value;
-  }
-
-  return result;
-}
-
-// Reads and returns the string environment variable corresponding to
-// the given flag; if it's not set, returns default_value.
-const char* StringFromGTestEnv(const char* flag, const char* default_value) {
-  const String env_var = FlagToEnvVar(flag);
-  const char* const value = posix::GetEnv(env_var.c_str());
-  return value == NULL ? default_value : value;
-}
-
-}  // namespace internal
-}  // namespace testing
-// Copyright 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan at google.com (Zhanyong Wan)
-
-// Google Test - The Google C++ Testing Framework
-//
-// This file implements a universal value printer that can print a
-// value of any type T:
-//
-//   void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_ptr);
-//
-// It uses the << operator when possible, and prints the bytes in the
-// object otherwise.  A user can override its behavior for a class
-// type Foo by defining either operator<<(::std::ostream&, const Foo&)
-// or void PrintTo(const Foo&, ::std::ostream*) in the namespace that
-// defines Foo.
-
-#include <ctype.h>
-#include <stdio.h>
-#include <ostream>  // NOLINT
-#include <string>
-
-namespace testing {
-
-namespace {
-
-using ::std::ostream;
-
-#if GTEST_OS_WINDOWS_MOBILE  // Windows CE does not define _snprintf_s.
-# define snprintf _snprintf
-#elif _MSC_VER >= 1400  // VC 8.0 and later deprecate snprintf and _snprintf.
-# define snprintf _snprintf_s
-#elif _MSC_VER
-# define snprintf _snprintf
-#endif  // GTEST_OS_WINDOWS_MOBILE
-
-// Prints a segment of bytes in the given object.
-void PrintByteSegmentInObjectTo(const unsigned char* obj_bytes, size_t start,
-                                size_t count, ostream* os) {
-  char text[5] = "";
-  for (size_t i = 0; i != count; i++) {
-    const size_t j = start + i;
-    if (i != 0) {
-      // Organizes the bytes into groups of 2 for easy parsing by
-      // human.
-      if ((j % 2) == 0)
-        *os << ' ';
-      else
-        *os << '-';
-    }
-    snprintf(text, sizeof(text), "%02X", obj_bytes[j]);
-    *os << text;
-  }
-}
-
-// Prints the bytes in the given value to the given ostream.
-void PrintBytesInObjectToImpl(const unsigned char* obj_bytes, size_t count,
-                              ostream* os) {
-  // Tells the user how big the object is.
-  *os << count << "-byte object <";
-
-  const size_t kThreshold = 132;
-  const size_t kChunkSize = 64;
-  // If the object size is bigger than kThreshold, we'll have to omit
-  // some details by printing only the first and the last kChunkSize
-  // bytes.
-  // TODO(wan): let the user control the threshold using a flag.
-  if (count < kThreshold) {
-    PrintByteSegmentInObjectTo(obj_bytes, 0, count, os);
-  } else {
-    PrintByteSegmentInObjectTo(obj_bytes, 0, kChunkSize, os);
-    *os << " ... ";
-    // Rounds up to 2-byte boundary.
-    const size_t resume_pos = (count - kChunkSize + 1)/2*2;
-    PrintByteSegmentInObjectTo(obj_bytes, resume_pos, count - resume_pos, os);
-  }
-  *os << ">";
-}
-
-}  // namespace
-
-namespace internal2 {
-
-// Delegates to PrintBytesInObjectToImpl() to print the bytes in the
-// given object.  The delegation simplifies the implementation, which
-// uses the << operator and thus is easier done outside of the
-// ::testing::internal namespace, which contains a << operator that
-// sometimes conflicts with the one in STL.
-void PrintBytesInObjectTo(const unsigned char* obj_bytes, size_t count,
-                          ostream* os) {
-  PrintBytesInObjectToImpl(obj_bytes, count, os);
-}
-
-}  // namespace internal2
-
-namespace internal {
-
-// Depending on the value of a char (or wchar_t), we print it in one
-// of three formats:
-//   - as is if it's a printable ASCII (e.g. 'a', '2', ' '),
-//   - as a hexidecimal escape sequence (e.g. '\x7F'), or
-//   - as a special escape sequence (e.g. '\r', '\n').
-enum CharFormat {
-  kAsIs,
-  kHexEscape,
-  kSpecialEscape
-};
-
-// Returns true if c is a printable ASCII character.  We test the
-// value of c directly instead of calling isprint(), which is buggy on
-// Windows Mobile.
-inline bool IsPrintableAscii(wchar_t c) {
-  return 0x20 <= c && c <= 0x7E;
-}
-
-// Prints a wide or narrow char c as a character literal without the
-// quotes, escaping it when necessary; returns how c was formatted.
-// The template argument UnsignedChar is the unsigned version of Char,
-// which is the type of c.
-template <typename UnsignedChar, typename Char>
-static CharFormat PrintAsCharLiteralTo(Char c, ostream* os) {
-  switch (static_cast<wchar_t>(c)) {
-    case L'\0':
-      *os << "\\0";
-      break;
-    case L'\'':
-      *os << "\\'";
-      break;
-    case L'\\':
-      *os << "\\\\";
-      break;
-    case L'\a':
-      *os << "\\a";
-      break;
-    case L'\b':
-      *os << "\\b";
-      break;
-    case L'\f':
-      *os << "\\f";
-      break;
-    case L'\n':
-      *os << "\\n";
-      break;
-    case L'\r':
-      *os << "\\r";
-      break;
-    case L'\t':
-      *os << "\\t";
-      break;
-    case L'\v':
-      *os << "\\v";
-      break;
-    default:
-      if (IsPrintableAscii(c)) {
-        *os << static_cast<char>(c);
-        return kAsIs;
-      } else {
-        *os << String::Format("\\x%X", static_cast<UnsignedChar>(c));
-        return kHexEscape;
-      }
-  }
-  return kSpecialEscape;
-}
-
-// Prints a char c as if it's part of a string literal, escaping it when
-// necessary; returns how c was formatted.
-static CharFormat PrintAsWideStringLiteralTo(wchar_t c, ostream* os) {
-  switch (c) {
-    case L'\'':
-      *os << "'";
-      return kAsIs;
-    case L'"':
-      *os << "\\\"";
-      return kSpecialEscape;
-    default:
-      return PrintAsCharLiteralTo<wchar_t>(c, os);
-  }
-}
-
-// Prints a char c as if it's part of a string literal, escaping it when
-// necessary; returns how c was formatted.
-static CharFormat PrintAsNarrowStringLiteralTo(char c, ostream* os) {
-  return PrintAsWideStringLiteralTo(static_cast<unsigned char>(c), os);
-}
-
-// Prints a wide or narrow character c and its code.  '\0' is printed
-// as "'\\0'", other unprintable characters are also properly escaped
-// using the standard C++ escape sequence.  The template argument
-// UnsignedChar is the unsigned version of Char, which is the type of c.
-template <typename UnsignedChar, typename Char>
-void PrintCharAndCodeTo(Char c, ostream* os) {
-  // First, print c as a literal in the most readable form we can find.
-  *os << ((sizeof(c) > 1) ? "L'" : "'");
-  const CharFormat format = PrintAsCharLiteralTo<UnsignedChar>(c, os);
-  *os << "'";
-
-  // To aid user debugging, we also print c's code in decimal, unless
-  // it's 0 (in which case c was printed as '\\0', making the code
-  // obvious).
-  if (c == 0)
-    return;
-  *os << " (" << String::Format("%d", c).c_str();
-
-  // For more convenience, we print c's code again in hexidecimal,
-  // unless c was already printed in the form '\x##' or the code is in
-  // [1, 9].
-  if (format == kHexEscape || (1 <= c && c <= 9)) {
-    // Do nothing.
-  } else {
-    *os << String::Format(", 0x%X",
-                          static_cast<UnsignedChar>(c)).c_str();
-  }
-  *os << ")";
-}
-
-void PrintTo(unsigned char c, ::std::ostream* os) {
-  PrintCharAndCodeTo<unsigned char>(c, os);
-}
-void PrintTo(signed char c, ::std::ostream* os) {
-  PrintCharAndCodeTo<unsigned char>(c, os);
-}
-
-// Prints a wchar_t as a symbol if it is printable or as its internal
-// code otherwise and also as its code.  L'\0' is printed as "L'\\0'".
-void PrintTo(wchar_t wc, ostream* os) {
-  PrintCharAndCodeTo<wchar_t>(wc, os);
-}
-
-// Prints the given array of characters to the ostream.
-// The array starts at *begin, the length is len, it may include '\0' characters
-// and may not be null-terminated.
-static void PrintCharsAsStringTo(const char* begin, size_t len, ostream* os) {
-  *os << "\"";
-  bool is_previous_hex = false;
-  for (size_t index = 0; index < len; ++index) {
-    const char cur = begin[index];
-    if (is_previous_hex && IsXDigit(cur)) {
-      // Previous character is of '\x..' form and this character can be
-      // interpreted as another hexadecimal digit in its number. Break string to
-      // disambiguate.
-      *os << "\" \"";
-    }
-    is_previous_hex = PrintAsNarrowStringLiteralTo(cur, os) == kHexEscape;
-  }
-  *os << "\"";
-}
-
-// Prints a (const) char array of 'len' elements, starting at address 'begin'.
-void UniversalPrintArray(const char* begin, size_t len, ostream* os) {
-  PrintCharsAsStringTo(begin, len, os);
-}
-
-// Prints the given array of wide characters to the ostream.
-// The array starts at *begin, the length is len, it may include L'\0'
-// characters and may not be null-terminated.
-static void PrintWideCharsAsStringTo(const wchar_t* begin, size_t len,
-                                     ostream* os) {
-  *os << "L\"";
-  bool is_previous_hex = false;
-  for (size_t index = 0; index < len; ++index) {
-    const wchar_t cur = begin[index];
-    if (is_previous_hex && isascii(cur) && IsXDigit(static_cast<char>(cur))) {
-      // Previous character is of '\x..' form and this character can be
-      // interpreted as another hexadecimal digit in its number. Break string to
-      // disambiguate.
-      *os << "\" L\"";
-    }
-    is_previous_hex = PrintAsWideStringLiteralTo(cur, os) == kHexEscape;
-  }
-  *os << "\"";
-}
-
-// Prints the given C string to the ostream.
-void PrintTo(const char* s, ostream* os) {
-  if (s == NULL) {
-    *os << "NULL";
-  } else {
-    *os << ImplicitCast_<const void*>(s) << " pointing to ";
-    PrintCharsAsStringTo(s, strlen(s), os);
-  }
-}
-
-// MSVC compiler can be configured to define whar_t as a typedef
-// of unsigned short. Defining an overload for const wchar_t* in that case
-// would cause pointers to unsigned shorts be printed as wide strings,
-// possibly accessing more memory than intended and causing invalid
-// memory accesses. MSVC defines _NATIVE_WCHAR_T_DEFINED symbol when
-// wchar_t is implemented as a native type.
-#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
-// Prints the given wide C string to the ostream.
-void PrintTo(const wchar_t* s, ostream* os) {
-  if (s == NULL) {
-    *os << "NULL";
-  } else {
-    *os << ImplicitCast_<const void*>(s) << " pointing to ";
-    PrintWideCharsAsStringTo(s, wcslen(s), os);
-  }
-}
-#endif  // wchar_t is native
-
-// Prints a ::string object.
-#if GTEST_HAS_GLOBAL_STRING
-void PrintStringTo(const ::string& s, ostream* os) {
-  PrintCharsAsStringTo(s.data(), s.size(), os);
-}
-#endif  // GTEST_HAS_GLOBAL_STRING
-
-void PrintStringTo(const ::std::string& s, ostream* os) {
-  PrintCharsAsStringTo(s.data(), s.size(), os);
-}
-
-// Prints a ::wstring object.
-#if GTEST_HAS_GLOBAL_WSTRING
-void PrintWideStringTo(const ::wstring& s, ostream* os) {
-  PrintWideCharsAsStringTo(s.data(), s.size(), os);
-}
-#endif  // GTEST_HAS_GLOBAL_WSTRING
-
-#if GTEST_HAS_STD_WSTRING
-void PrintWideStringTo(const ::std::wstring& s, ostream* os) {
-  PrintWideCharsAsStringTo(s.data(), s.size(), os);
-}
-#endif  // GTEST_HAS_STD_WSTRING
-
-}  // namespace internal
-
-}  // namespace testing
-// Copyright 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: mheule at google.com (Markus Heule)
-//
-// The Google C++ Testing Framework (Google Test)
-
-
-// Indicates that this translation unit is part of Google Test's
-// implementation.  It must come before gtest-internal-inl.h is
-// included, or there will be a compiler error.  This trick is to
-// prevent a user from accidentally including gtest-internal-inl.h in
-// his code.
-#define GTEST_IMPLEMENTATION_ 1
-#undef GTEST_IMPLEMENTATION_
-
-namespace testing {
-
-using internal::GetUnitTestImpl;
-
-// Gets the summary of the failure message by omitting the stack trace
-// in it.
-internal::String TestPartResult::ExtractSummary(const char* message) {
-  const char* const stack_trace = strstr(message, internal::kStackTraceMarker);
-  return stack_trace == NULL ? internal::String(message) :
-      internal::String(message, stack_trace - message);
-}
-
-// Prints a TestPartResult object.
-std::ostream& operator<<(std::ostream& os, const TestPartResult& result) {
-  return os
-      << result.file_name() << ":" << result.line_number() << ": "
-      << (result.type() == TestPartResult::kSuccess ? "Success" :
-          result.type() == TestPartResult::kFatalFailure ? "Fatal failure" :
-          "Non-fatal failure") << ":\n"
-      << result.message() << std::endl;
-}
-
-// Appends a TestPartResult to the array.
-void TestPartResultArray::Append(const TestPartResult& result) {
-  array_.push_back(result);
-}
-
-// Returns the TestPartResult at the given index (0-based).
-const TestPartResult& TestPartResultArray::GetTestPartResult(int index) const {
-  if (index < 0 || index >= size()) {
-    printf("\nInvalid index (%d) into TestPartResultArray.\n", index);
-    internal::posix::Abort();
-  }
-
-  return array_[index];
-}
-
-// Returns the number of TestPartResult objects in the array.
-int TestPartResultArray::size() const {
-  return static_cast<int>(array_.size());
-}
-
-namespace internal {
-
-HasNewFatalFailureHelper::HasNewFatalFailureHelper()
-    : has_new_fatal_failure_(false),
-      original_reporter_(GetUnitTestImpl()->
-                         GetTestPartResultReporterForCurrentThread()) {
-  GetUnitTestImpl()->SetTestPartResultReporterForCurrentThread(this);
-}
-
-HasNewFatalFailureHelper::~HasNewFatalFailureHelper() {
-  GetUnitTestImpl()->SetTestPartResultReporterForCurrentThread(
-      original_reporter_);
-}
-
-void HasNewFatalFailureHelper::ReportTestPartResult(
-    const TestPartResult& result) {
-  if (result.fatally_failed())
-    has_new_fatal_failure_ = true;
-  original_reporter_->ReportTestPartResult(result);
-}
-
-}  // namespace internal
-
-}  // namespace testing
-// Copyright 2008 Google Inc.
-// All Rights Reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan at google.com (Zhanyong Wan)
-
-
-namespace testing {
-namespace internal {
-
-#if GTEST_HAS_TYPED_TEST_P
-
-// Skips to the first non-space char in str. Returns an empty string if str
-// contains only whitespace characters.
-static const char* SkipSpaces(const char* str) {
-  while (IsSpace(*str))
-    str++;
-  return str;
-}
-
-// Verifies that registered_tests match the test names in
-// defined_test_names_; returns registered_tests if successful, or
-// aborts the program otherwise.
-const char* TypedTestCasePState::VerifyRegisteredTestNames(
-    const char* file, int line, const char* registered_tests) {
-  typedef ::std::set<const char*>::const_iterator DefinedTestIter;
-  registered_ = true;
-
-  // Skip initial whitespace in registered_tests since some
-  // preprocessors prefix stringizied literals with whitespace.
-  registered_tests = SkipSpaces(registered_tests);
-
-  Message errors;
-  ::std::set<String> tests;
-  for (const char* names = registered_tests; names != NULL;
-       names = SkipComma(names)) {
-    const String name = GetPrefixUntilComma(names);
-    if (tests.count(name) != 0) {
-      errors << "Test " << name << " is listed more than once.\n";
-      continue;
-    }
-
-    bool found = false;
-    for (DefinedTestIter it = defined_test_names_.begin();
-         it != defined_test_names_.end();
-         ++it) {
-      if (name == *it) {
-        found = true;
-        break;
-      }
-    }
-
-    if (found) {
-      tests.insert(name);
-    } else {
-      errors << "No test named " << name
-             << " can be found in this test case.\n";
-    }
-  }
-
-  for (DefinedTestIter it = defined_test_names_.begin();
-       it != defined_test_names_.end();
-       ++it) {
-    if (tests.count(*it) == 0) {
-      errors << "You forgot to list test " << *it << ".\n";
-    }
-  }
-
-  const String& errors_str = errors.GetString();
-  if (errors_str != "") {
-    fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(),
-            errors_str.c_str());
-    fflush(stderr);
-    posix::Abort();
-  }
-
-  return registered_tests;
-}
-
-#endif  // GTEST_HAS_TYPED_TEST_P
-
-}  // namespace internal
-}  // namespace testing
diff --git a/bamtools/src/third_party/gtest-1.6.0/fused-src/gtest/gtest.h b/bamtools/src/third_party/gtest-1.6.0/fused-src/gtest/gtest.h
deleted file mode 100644
index 3143bd6..0000000
--- a/bamtools/src/third_party/gtest-1.6.0/fused-src/gtest/gtest.h
+++ /dev/null
@@ -1,19537 +0,0 @@
-// Copyright 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan at google.com (Zhanyong Wan)
-//
-// The Google C++ Testing Framework (Google Test)
-//
-// This header file defines the public API for Google Test.  It should be
-// included by any test program that uses Google Test.
-//
-// IMPORTANT NOTE: Due to limitation of the C++ language, we have to
-// leave some internal implementation details in this header file.
-// They are clearly marked by comments like this:
-//
-//   // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
-//
-// Such code is NOT meant to be used by a user directly, and is subject
-// to CHANGE WITHOUT NOTICE.  Therefore DO NOT DEPEND ON IT in a user
-// program!
-//
-// Acknowledgment: Google Test borrowed the idea of automatic test
-// registration from Barthelemy Dagenais' (barthelemy at prologique.com)
-// easyUnit framework.
-
-#ifndef GTEST_INCLUDE_GTEST_GTEST_H_
-#define GTEST_INCLUDE_GTEST_GTEST_H_
-
-#include <limits>
-#include <vector>
-
-// Copyright 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Authors: wan at google.com (Zhanyong Wan), eefacm at gmail.com (Sean Mcafee)
-//
-// The Google C++ Testing Framework (Google Test)
-//
-// This header file declares functions and macros used internally by
-// Google Test.  They are subject to change without notice.
-
-#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
-#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
-
-// Copyright 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Authors: wan at google.com (Zhanyong Wan)
-//
-// Low-level types and utilities for porting Google Test to various
-// platforms.  They are subject to change without notice.  DO NOT USE
-// THEM IN USER CODE.
-
-#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
-#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
-
-// The user can define the following macros in the build script to
-// control Google Test's behavior.  If the user doesn't define a macro
-// in this list, Google Test will define it.
-//
-//   GTEST_HAS_CLONE          - Define it to 1/0 to indicate that clone(2)
-//                              is/isn't available.
-//   GTEST_HAS_EXCEPTIONS     - Define it to 1/0 to indicate that exceptions
-//                              are enabled.
-//   GTEST_HAS_GLOBAL_STRING  - Define it to 1/0 to indicate that ::string
-//                              is/isn't available (some systems define
-//                              ::string, which is different to std::string).
-//   GTEST_HAS_GLOBAL_WSTRING - Define it to 1/0 to indicate that ::string
-//                              is/isn't available (some systems define
-//                              ::wstring, which is different to std::wstring).
-//   GTEST_HAS_POSIX_RE       - Define it to 1/0 to indicate that POSIX regular
-//                              expressions are/aren't available.
-//   GTEST_HAS_PTHREAD        - Define it to 1/0 to indicate that <pthread.h>
-//                              is/isn't available.
-//   GTEST_HAS_RTTI           - Define it to 1/0 to indicate that RTTI is/isn't
-//                              enabled.
-//   GTEST_HAS_STD_WSTRING    - Define it to 1/0 to indicate that
-//                              std::wstring does/doesn't work (Google Test can
-//                              be used where std::wstring is unavailable).
-//   GTEST_HAS_TR1_TUPLE      - Define it to 1/0 to indicate tr1::tuple
-//                              is/isn't available.
-//   GTEST_HAS_SEH            - Define it to 1/0 to indicate whether the
-//                              compiler supports Microsoft's "Structured
-//                              Exception Handling".
-//   GTEST_HAS_STREAM_REDIRECTION
-//                            - Define it to 1/0 to indicate whether the
-//                              platform supports I/O stream redirection using
-//                              dup() and dup2().
-//   GTEST_USE_OWN_TR1_TUPLE  - Define it to 1/0 to indicate whether Google
-//                              Test's own tr1 tuple implementation should be
-//                              used.  Unused when the user sets
-//                              GTEST_HAS_TR1_TUPLE to 0.
-//   GTEST_LINKED_AS_SHARED_LIBRARY
-//                            - Define to 1 when compiling tests that use
-//                              Google Test as a shared library (known as
-//                              DLL on Windows).
-//   GTEST_CREATE_SHARED_LIBRARY
-//                            - Define to 1 when compiling Google Test itself
-//                              as a shared library.
-
-// This header defines the following utilities:
-//
-// Macros indicating the current platform (defined to 1 if compiled on
-// the given platform; otherwise undefined):
-//   GTEST_OS_AIX      - IBM AIX
-//   GTEST_OS_CYGWIN   - Cygwin
-//   GTEST_OS_HPUX     - HP-UX
-//   GTEST_OS_LINUX    - Linux
-//     GTEST_OS_LINUX_ANDROID - Google Android
-//   GTEST_OS_MAC      - Mac OS X
-//   GTEST_OS_NACL     - Google Native Client (NaCl)
-//   GTEST_OS_SOLARIS  - Sun Solaris
-//   GTEST_OS_SYMBIAN  - Symbian
-//   GTEST_OS_WINDOWS  - Windows (Desktop, MinGW, or Mobile)
-//     GTEST_OS_WINDOWS_DESKTOP  - Windows Desktop
-//     GTEST_OS_WINDOWS_MINGW    - MinGW
-//     GTEST_OS_WINDOWS_MOBILE   - Windows Mobile
-//   GTEST_OS_ZOS      - z/OS
-//
-// Among the platforms, Cygwin, Linux, Max OS X, and Windows have the
-// most stable support.  Since core members of the Google Test project
-// don't have access to other platforms, support for them may be less
-// stable.  If you notice any problems on your platform, please notify
-// googletestframework at googlegroups.com (patches for fixing them are
-// even more welcome!).
-//
-// Note that it is possible that none of the GTEST_OS_* macros are defined.
-//
-// Macros indicating available Google Test features (defined to 1 if
-// the corresponding feature is supported; otherwise undefined):
-//   GTEST_HAS_COMBINE      - the Combine() function (for value-parameterized
-//                            tests)
-//   GTEST_HAS_DEATH_TEST   - death tests
-//   GTEST_HAS_PARAM_TEST   - value-parameterized tests
-//   GTEST_HAS_TYPED_TEST   - typed tests
-//   GTEST_HAS_TYPED_TEST_P - type-parameterized tests
-//   GTEST_USES_POSIX_RE    - enhanced POSIX regex is used. Do not confuse with
-//                            GTEST_HAS_POSIX_RE (see above) which users can
-//                            define themselves.
-//   GTEST_USES_SIMPLE_RE   - our own simple regex is used;
-//                            the above two are mutually exclusive.
-//   GTEST_CAN_COMPARE_NULL - accepts untyped NULL in EXPECT_EQ().
-//
-// Macros for basic C++ coding:
-//   GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning.
-//   GTEST_ATTRIBUTE_UNUSED_  - declares that a class' instances or a
-//                              variable don't have to be used.
-//   GTEST_DISALLOW_ASSIGN_   - disables operator=.
-//   GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=.
-//   GTEST_MUST_USE_RESULT_   - declares that a function's result must be used.
-//
-// Synchronization:
-//   Mutex, MutexLock, ThreadLocal, GetThreadCount()
-//                  - synchronization primitives.
-//   GTEST_IS_THREADSAFE - defined to 1 to indicate that the above
-//                         synchronization primitives have real implementations
-//                         and Google Test is thread-safe; or 0 otherwise.
-//
-// Template meta programming:
-//   is_pointer     - as in TR1; needed on Symbian and IBM XL C/C++ only.
-//   IteratorTraits - partial implementation of std::iterator_traits, which
-//                    is not available in libCstd when compiled with Sun C++.
-//
-// Smart pointers:
-//   scoped_ptr     - as in TR2.
-//
-// Regular expressions:
-//   RE             - a simple regular expression class using the POSIX
-//                    Extended Regular Expression syntax on UNIX-like
-//                    platforms, or a reduced regular exception syntax on
-//                    other platforms, including Windows.
-//
-// Logging:
-//   GTEST_LOG_()   - logs messages at the specified severity level.
-//   LogToStderr()  - directs all log messages to stderr.
-//   FlushInfoLog() - flushes informational log messages.
-//
-// Stdout and stderr capturing:
-//   CaptureStdout()     - starts capturing stdout.
-//   GetCapturedStdout() - stops capturing stdout and returns the captured
-//                         string.
-//   CaptureStderr()     - starts capturing stderr.
-//   GetCapturedStderr() - stops capturing stderr and returns the captured
-//                         string.
-//
-// Integer types:
-//   TypeWithSize   - maps an integer to a int type.
-//   Int32, UInt32, Int64, UInt64, TimeInMillis
-//                  - integers of known sizes.
-//   BiggestInt     - the biggest signed integer type.
-//
-// Command-line utilities:
-//   GTEST_FLAG()       - references a flag.
-//   GTEST_DECLARE_*()  - declares a flag.
-//   GTEST_DEFINE_*()   - defines a flag.
-//   GetArgvs()         - returns the command line as a vector of strings.
-//
-// Environment variable utilities:
-//   GetEnv()             - gets the value of an environment variable.
-//   BoolFromGTestEnv()   - parses a bool environment variable.
-//   Int32FromGTestEnv()  - parses an Int32 environment variable.
-//   StringFromGTestEnv() - parses a string environment variable.
-
-#include <ctype.h>   // for isspace, etc
-#include <stddef.h>  // for ptrdiff_t
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#ifndef _WIN32_WCE
-# include <sys/types.h>
-# include <sys/stat.h>
-#endif  // !_WIN32_WCE
-
-#include <iostream>  // NOLINT
-#include <sstream>  // NOLINT
-#include <string>  // NOLINT
-
-#define GTEST_DEV_EMAIL_ "googletestframework@@googlegroups.com"
-#define GTEST_FLAG_PREFIX_ "gtest_"
-#define GTEST_FLAG_PREFIX_DASH_ "gtest-"
-#define GTEST_FLAG_PREFIX_UPPER_ "GTEST_"
-#define GTEST_NAME_ "Google Test"
-#define GTEST_PROJECT_URL_ "http://code.google.com/p/googletest/"
-
-// Determines the version of gcc that is used to compile this.
-#ifdef __GNUC__
-// 40302 means version 4.3.2.
-# define GTEST_GCC_VER_ \
-    (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__)
-#endif  // __GNUC__
-
-// Determines the platform on which Google Test is compiled.
-#ifdef __CYGWIN__
-# define GTEST_OS_CYGWIN 1
-#elif defined __SYMBIAN32__
-# define GTEST_OS_SYMBIAN 1
-#elif defined _WIN32
-# define GTEST_OS_WINDOWS 1
-# ifdef _WIN32_WCE
-#  define GTEST_OS_WINDOWS_MOBILE 1
-# elif defined(__MINGW__) || defined(__MINGW32__)
-#  define GTEST_OS_WINDOWS_MINGW 1
-# else
-#  define GTEST_OS_WINDOWS_DESKTOP 1
-# endif  // _WIN32_WCE
-#elif defined __APPLE__
-# define GTEST_OS_MAC 1
-#elif defined __linux__
-# define GTEST_OS_LINUX 1
-# ifdef ANDROID
-#  define GTEST_OS_LINUX_ANDROID 1
-# endif  // ANDROID
-#elif defined __MVS__
-# define GTEST_OS_ZOS 1
-#elif defined(__sun) && defined(__SVR4)
-# define GTEST_OS_SOLARIS 1
-#elif defined(_AIX)
-# define GTEST_OS_AIX 1
-#elif defined(__hpux)
-# define GTEST_OS_HPUX 1
-#elif defined __native_client__
-# define GTEST_OS_NACL 1
-#endif  // __CYGWIN__
-
-// Brings in definitions for functions used in the testing::internal::posix
-// namespace (read, write, close, chdir, isatty, stat). We do not currently
-// use them on Windows Mobile.
-#if !GTEST_OS_WINDOWS
-// This assumes that non-Windows OSes provide unistd.h. For OSes where this
-// is not the case, we need to include headers that provide the functions
-// mentioned above.
-# include <unistd.h>
-# if !GTEST_OS_NACL
-// TODO(vladl at google.com): Remove this condition when Native Client SDK adds
-// strings.h (tracked in
-// http://code.google.com/p/nativeclient/issues/detail?id=1175).
-#  include <strings.h>  // Native Client doesn't provide strings.h.
-# endif
-#elif !GTEST_OS_WINDOWS_MOBILE
-# include <direct.h>
-# include <io.h>
-#endif
-
-// Defines this to true iff Google Test can use POSIX regular expressions.
-#ifndef GTEST_HAS_POSIX_RE
-# define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS)
-#endif
-
-#if GTEST_HAS_POSIX_RE
-
-// On some platforms, <regex.h> needs someone to define size_t, and
-// won't compile otherwise.  We can #include it here as we already
-// included <stdlib.h>, which is guaranteed to define size_t through
-// <stddef.h>.
-# include <regex.h>  // NOLINT
-
-# define GTEST_USES_POSIX_RE 1
-
-#elif GTEST_OS_WINDOWS
-
-// <regex.h> is not available on Windows.  Use our own simple regex
-// implementation instead.
-# define GTEST_USES_SIMPLE_RE 1
-
-#else
-
-// <regex.h> may not be available on this platform.  Use our own
-// simple regex implementation instead.
-# define GTEST_USES_SIMPLE_RE 1
-
-#endif  // GTEST_HAS_POSIX_RE
-
-#ifndef GTEST_HAS_EXCEPTIONS
-// The user didn't tell us whether exceptions are enabled, so we need
-// to figure it out.
-# if defined(_MSC_VER) || defined(__BORLANDC__)
-// MSVC's and C++Builder's implementations of the STL use the _HAS_EXCEPTIONS
-// macro to enable exceptions, so we'll do the same.
-// Assumes that exceptions are enabled by default.
-#  ifndef _HAS_EXCEPTIONS
-#   define _HAS_EXCEPTIONS 1
-#  endif  // _HAS_EXCEPTIONS
-#  define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS
-# elif defined(__GNUC__) && __EXCEPTIONS
-// gcc defines __EXCEPTIONS to 1 iff exceptions are enabled.
-#  define GTEST_HAS_EXCEPTIONS 1
-# elif defined(__SUNPRO_CC)
-// Sun Pro CC supports exceptions.  However, there is no compile-time way of
-// detecting whether they are enabled or not.  Therefore, we assume that
-// they are enabled unless the user tells us otherwise.
-#  define GTEST_HAS_EXCEPTIONS 1
-# elif defined(__IBMCPP__) && __EXCEPTIONS
-// xlC defines __EXCEPTIONS to 1 iff exceptions are enabled.
-#  define GTEST_HAS_EXCEPTIONS 1
-# elif defined(__HP_aCC)
-// Exception handling is in effect by default in HP aCC compiler. It has to
-// be turned of by +noeh compiler option if desired.
-#  define GTEST_HAS_EXCEPTIONS 1
-# else
-// For other compilers, we assume exceptions are disabled to be
-// conservative.
-#  define GTEST_HAS_EXCEPTIONS 0
-# endif  // defined(_MSC_VER) || defined(__BORLANDC__)
-#endif  // GTEST_HAS_EXCEPTIONS
-
-#if !defined(GTEST_HAS_STD_STRING)
-// Even though we don't use this macro any longer, we keep it in case
-// some clients still depend on it.
-# define GTEST_HAS_STD_STRING 1
-#elif !GTEST_HAS_STD_STRING
-// The user told us that ::std::string isn't available.
-# error "Google Test cannot be used where ::std::string isn't available."
-#endif  // !defined(GTEST_HAS_STD_STRING)
-
-#ifndef GTEST_HAS_GLOBAL_STRING
-// The user didn't tell us whether ::string is available, so we need
-// to figure it out.
-
-# define GTEST_HAS_GLOBAL_STRING 0
-
-#endif  // GTEST_HAS_GLOBAL_STRING
-
-#ifndef GTEST_HAS_STD_WSTRING
-// The user didn't tell us whether ::std::wstring is available, so we need
-// to figure it out.
-// TODO(wan at google.com): uses autoconf to detect whether ::std::wstring
-//   is available.
-
-// Cygwin 1.7 and below doesn't support ::std::wstring.
-// Solaris' libc++ doesn't support it either.  Android has
-// no support for it at least as recent as Froyo (2.2).
-# define GTEST_HAS_STD_WSTRING \
-    (!(GTEST_OS_LINUX_ANDROID || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS))
-
-#endif  // GTEST_HAS_STD_WSTRING
-
-#ifndef GTEST_HAS_GLOBAL_WSTRING
-// The user didn't tell us whether ::wstring is available, so we need
-// to figure it out.
-# define GTEST_HAS_GLOBAL_WSTRING \
-    (GTEST_HAS_STD_WSTRING && GTEST_HAS_GLOBAL_STRING)
-#endif  // GTEST_HAS_GLOBAL_WSTRING
-
-// Determines whether RTTI is available.
-#ifndef GTEST_HAS_RTTI
-// The user didn't tell us whether RTTI is enabled, so we need to
-// figure it out.
-
-# ifdef _MSC_VER
-
-#  ifdef _CPPRTTI  // MSVC defines this macro iff RTTI is enabled.
-#   define GTEST_HAS_RTTI 1
-#  else
-#   define GTEST_HAS_RTTI 0
-#  endif
-
-// Starting with version 4.3.2, gcc defines __GXX_RTTI iff RTTI is enabled.
-# elif defined(__GNUC__) && (GTEST_GCC_VER_ >= 40302)
-
-#  ifdef __GXX_RTTI
-#   define GTEST_HAS_RTTI 1
-#  else
-#   define GTEST_HAS_RTTI 0
-#  endif  // __GXX_RTTI
-
-// Starting with version 9.0 IBM Visual Age defines __RTTI_ALL__ to 1 if
-// both the typeid and dynamic_cast features are present.
-# elif defined(__IBMCPP__) && (__IBMCPP__ >= 900)
-
-#  ifdef __RTTI_ALL__
-#   define GTEST_HAS_RTTI 1
-#  else
-#   define GTEST_HAS_RTTI 0
-#  endif
-
-# else
-
-// For all other compilers, we assume RTTI is enabled.
-#  define GTEST_HAS_RTTI 1
-
-# endif  // _MSC_VER
-
-#endif  // GTEST_HAS_RTTI
-
-// It's this header's responsibility to #include <typeinfo> when RTTI
-// is enabled.
-#if GTEST_HAS_RTTI
-# include <typeinfo>
-#endif
-
-// Determines whether Google Test can use the pthreads library.
-#ifndef GTEST_HAS_PTHREAD
-// The user didn't tell us explicitly, so we assume pthreads support is
-// available on Linux and Mac.
-//
-// To disable threading support in Google Test, add -DGTEST_HAS_PTHREAD=0
-// to your compiler flags.
-# define GTEST_HAS_PTHREAD (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX)
-#endif  // GTEST_HAS_PTHREAD
-
-#if GTEST_HAS_PTHREAD
-// gtest-port.h guarantees to #include <pthread.h> when GTEST_HAS_PTHREAD is
-// true.
-# include <pthread.h>  // NOLINT
-
-// For timespec and nanosleep, used below.
-# include <time.h>  // NOLINT
-#endif
-
-// Determines whether Google Test can use tr1/tuple.  You can define
-// this macro to 0 to prevent Google Test from using tuple (any
-// feature depending on tuple with be disabled in this mode).
-#ifndef GTEST_HAS_TR1_TUPLE
-// The user didn't tell us not to do it, so we assume it's OK.
-# define GTEST_HAS_TR1_TUPLE 1
-#endif  // GTEST_HAS_TR1_TUPLE
-
-// Determines whether Google Test's own tr1 tuple implementation
-// should be used.
-#ifndef GTEST_USE_OWN_TR1_TUPLE
-// The user didn't tell us, so we need to figure it out.
-
-// We use our own TR1 tuple if we aren't sure the user has an
-// implementation of it already.  At this time, GCC 4.0.0+ and MSVC
-// 2010 are the only mainstream compilers that come with a TR1 tuple
-// implementation.  NVIDIA's CUDA NVCC compiler pretends to be GCC by
-// defining __GNUC__ and friends, but cannot compile GCC's tuple
-// implementation.  MSVC 2008 (9.0) provides TR1 tuple in a 323 MB
-// Feature Pack download, which we cannot assume the user has.
-# if (defined(__GNUC__) && !defined(__CUDACC__) && (GTEST_GCC_VER_ >= 40000)) \
-    || _MSC_VER >= 1600
-#  define GTEST_USE_OWN_TR1_TUPLE 0
-# else
-#  define GTEST_USE_OWN_TR1_TUPLE 1
-# endif
-
-#endif  // GTEST_USE_OWN_TR1_TUPLE
-
-// To avoid conditional compilation everywhere, we make it
-// gtest-port.h's responsibility to #include the header implementing
-// tr1/tuple.
-#if GTEST_HAS_TR1_TUPLE
-
-# if GTEST_USE_OWN_TR1_TUPLE
-// This file was GENERATED by a script.  DO NOT EDIT BY HAND!!!
-
-// Copyright 2009 Google Inc.
-// All Rights Reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan at google.com (Zhanyong Wan)
-
-// Implements a subset of TR1 tuple needed by Google Test and Google Mock.
-
-#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
-#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
-
-#include <utility>  // For ::std::pair.
-
-// The compiler used in Symbian has a bug that prevents us from declaring the
-// tuple template as a friend (it complains that tuple is redefined).  This
-// hack bypasses the bug by declaring the members that should otherwise be
-// private as public.
-// Sun Studio versions < 12 also have the above bug.
-#if defined(__SYMBIAN32__) || (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590)
-# define GTEST_DECLARE_TUPLE_AS_FRIEND_ public:
-#else
-# define GTEST_DECLARE_TUPLE_AS_FRIEND_ \
-    template <GTEST_10_TYPENAMES_(U)> friend class tuple; \
-   private:
-#endif
-
-// GTEST_n_TUPLE_(T) is the type of an n-tuple.
-#define GTEST_0_TUPLE_(T) tuple<>
-#define GTEST_1_TUPLE_(T) tuple<T##0, void, void, void, void, void, void, \
-    void, void, void>
-#define GTEST_2_TUPLE_(T) tuple<T##0, T##1, void, void, void, void, void, \
-    void, void, void>
-#define GTEST_3_TUPLE_(T) tuple<T##0, T##1, T##2, void, void, void, void, \
-    void, void, void>
-#define GTEST_4_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, void, void, void, \
-    void, void, void>
-#define GTEST_5_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, void, void, \
-    void, void, void>
-#define GTEST_6_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, void, \
-    void, void, void>
-#define GTEST_7_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
-    void, void, void>
-#define GTEST_8_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
-    T##7, void, void>
-#define GTEST_9_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
-    T##7, T##8, void>
-#define GTEST_10_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
-    T##7, T##8, T##9>
-
-// GTEST_n_TYPENAMES_(T) declares a list of n typenames.
-#define GTEST_0_TYPENAMES_(T)
-#define GTEST_1_TYPENAMES_(T) typename T##0
-#define GTEST_2_TYPENAMES_(T) typename T##0, typename T##1
-#define GTEST_3_TYPENAMES_(T) typename T##0, typename T##1, typename T##2
-#define GTEST_4_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
-    typename T##3
-#define GTEST_5_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
-    typename T##3, typename T##4
-#define GTEST_6_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
-    typename T##3, typename T##4, typename T##5
-#define GTEST_7_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
-    typename T##3, typename T##4, typename T##5, typename T##6
-#define GTEST_8_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
-    typename T##3, typename T##4, typename T##5, typename T##6, typename T##7
-#define GTEST_9_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
-    typename T##3, typename T##4, typename T##5, typename T##6, \
-    typename T##7, typename T##8
-#define GTEST_10_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
-    typename T##3, typename T##4, typename T##5, typename T##6, \
-    typename T##7, typename T##8, typename T##9
-
-// In theory, defining stuff in the ::std namespace is undefined
-// behavior.  We can do this as we are playing the role of a standard
-// library vendor.
-namespace std {
-namespace tr1 {
-
-template <typename T0 = void, typename T1 = void, typename T2 = void,
-    typename T3 = void, typename T4 = void, typename T5 = void,
-    typename T6 = void, typename T7 = void, typename T8 = void,
-    typename T9 = void>
-class tuple;
-
-// Anything in namespace gtest_internal is Google Test's INTERNAL
-// IMPLEMENTATION DETAIL and MUST NOT BE USED DIRECTLY in user code.
-namespace gtest_internal {
-
-// ByRef<T>::type is T if T is a reference; otherwise it's const T&.
-template <typename T>
-struct ByRef { typedef const T& type; };  // NOLINT
-template <typename T>
-struct ByRef<T&> { typedef T& type; };  // NOLINT
-
-// A handy wrapper for ByRef.
-#define GTEST_BY_REF_(T) typename ::std::tr1::gtest_internal::ByRef<T>::type
-
-// AddRef<T>::type is T if T is a reference; otherwise it's T&.  This
-// is the same as tr1::add_reference<T>::type.
-template <typename T>
-struct AddRef { typedef T& type; };  // NOLINT
-template <typename T>
-struct AddRef<T&> { typedef T& type; };  // NOLINT
-
-// A handy wrapper for AddRef.
-#define GTEST_ADD_REF_(T) typename ::std::tr1::gtest_internal::AddRef<T>::type
-
-// A helper for implementing get<k>().
-template <int k> class Get;
-
-// A helper for implementing tuple_element<k, T>.  kIndexValid is true
-// iff k < the number of fields in tuple type T.
-template <bool kIndexValid, int kIndex, class Tuple>
-struct TupleElement;
-
-template <GTEST_10_TYPENAMES_(T)>
-struct TupleElement<true, 0, GTEST_10_TUPLE_(T)> { typedef T0 type; };
-
-template <GTEST_10_TYPENAMES_(T)>
-struct TupleElement<true, 1, GTEST_10_TUPLE_(T)> { typedef T1 type; };
-
-template <GTEST_10_TYPENAMES_(T)>
-struct TupleElement<true, 2, GTEST_10_TUPLE_(T)> { typedef T2 type; };
-
-template <GTEST_10_TYPENAMES_(T)>
-struct TupleElement<true, 3, GTEST_10_TUPLE_(T)> { typedef T3 type; };
-
-template <GTEST_10_TYPENAMES_(T)>
-struct TupleElement<true, 4, GTEST_10_TUPLE_(T)> { typedef T4 type; };
-
-template <GTEST_10_TYPENAMES_(T)>
-struct TupleElement<true, 5, GTEST_10_TUPLE_(T)> { typedef T5 type; };
-
-template <GTEST_10_TYPENAMES_(T)>
-struct TupleElement<true, 6, GTEST_10_TUPLE_(T)> { typedef T6 type; };
-
-template <GTEST_10_TYPENAMES_(T)>
-struct TupleElement<true, 7, GTEST_10_TUPLE_(T)> { typedef T7 type; };
-
-template <GTEST_10_TYPENAMES_(T)>
-struct TupleElement<true, 8, GTEST_10_TUPLE_(T)> { typedef T8 type; };
-
-template <GTEST_10_TYPENAMES_(T)>
-struct TupleElement<true, 9, GTEST_10_TUPLE_(T)> { typedef T9 type; };
-
-}  // namespace gtest_internal
-
-template <>
-class tuple<> {
- public:
-  tuple() {}
-  tuple(const tuple& /* t */)  {}
-  tuple& operator=(const tuple& /* t */) { return *this; }
-};
-
-template <GTEST_1_TYPENAMES_(T)>
-class GTEST_1_TUPLE_(T) {
- public:
-  template <int k> friend class gtest_internal::Get;
-
-  tuple() : f0_() {}
-
-  explicit tuple(GTEST_BY_REF_(T0) f0) : f0_(f0) {}
-
-  tuple(const tuple& t) : f0_(t.f0_) {}
-
-  template <GTEST_1_TYPENAMES_(U)>
-  tuple(const GTEST_1_TUPLE_(U)& t) : f0_(t.f0_) {}
-
-  tuple& operator=(const tuple& t) { return CopyFrom(t); }
-
-  template <GTEST_1_TYPENAMES_(U)>
-  tuple& operator=(const GTEST_1_TUPLE_(U)& t) {
-    return CopyFrom(t);
-  }
-
-  GTEST_DECLARE_TUPLE_AS_FRIEND_
-
-  template <GTEST_1_TYPENAMES_(U)>
-  tuple& CopyFrom(const GTEST_1_TUPLE_(U)& t) {
-    f0_ = t.f0_;
-    return *this;
-  }
-
-  T0 f0_;
-};
-
-template <GTEST_2_TYPENAMES_(T)>
-class GTEST_2_TUPLE_(T) {
- public:
-  template <int k> friend class gtest_internal::Get;
-
-  tuple() : f0_(), f1_() {}
-
-  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1) : f0_(f0),
-      f1_(f1) {}
-
-  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_) {}
-
-  template <GTEST_2_TYPENAMES_(U)>
-  tuple(const GTEST_2_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_) {}
-  template <typename U0, typename U1>
-  tuple(const ::std::pair<U0, U1>& p) : f0_(p.first), f1_(p.second) {}
-
-  tuple& operator=(const tuple& t) { return CopyFrom(t); }
-
-  template <GTEST_2_TYPENAMES_(U)>
-  tuple& operator=(const GTEST_2_TUPLE_(U)& t) {
-    return CopyFrom(t);
-  }
-  template <typename U0, typename U1>
-  tuple& operator=(const ::std::pair<U0, U1>& p) {
-    f0_ = p.first;
-    f1_ = p.second;
-    return *this;
-  }
-
-  GTEST_DECLARE_TUPLE_AS_FRIEND_
-
-  template <GTEST_2_TYPENAMES_(U)>
-  tuple& CopyFrom(const GTEST_2_TUPLE_(U)& t) {
-    f0_ = t.f0_;
-    f1_ = t.f1_;
-    return *this;
-  }
-
-  T0 f0_;
-  T1 f1_;
-};
-
-template <GTEST_3_TYPENAMES_(T)>
-class GTEST_3_TUPLE_(T) {
- public:
-  template <int k> friend class gtest_internal::Get;
-
-  tuple() : f0_(), f1_(), f2_() {}
-
-  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
-      GTEST_BY_REF_(T2) f2) : f0_(f0), f1_(f1), f2_(f2) {}
-
-  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_) {}
-
-  template <GTEST_3_TYPENAMES_(U)>
-  tuple(const GTEST_3_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_) {}
-
-  tuple& operator=(const tuple& t) { return CopyFrom(t); }
-
-  template <GTEST_3_TYPENAMES_(U)>
-  tuple& operator=(const GTEST_3_TUPLE_(U)& t) {
-    return CopyFrom(t);
-  }
-
-  GTEST_DECLARE_TUPLE_AS_FRIEND_
-
-  template <GTEST_3_TYPENAMES_(U)>
-  tuple& CopyFrom(const GTEST_3_TUPLE_(U)& t) {
-    f0_ = t.f0_;
-    f1_ = t.f1_;
-    f2_ = t.f2_;
-    return *this;
-  }
-
-  T0 f0_;
-  T1 f1_;
-  T2 f2_;
-};
-
-template <GTEST_4_TYPENAMES_(T)>
-class GTEST_4_TUPLE_(T) {
- public:
-  template <int k> friend class gtest_internal::Get;
-
-  tuple() : f0_(), f1_(), f2_(), f3_() {}
-
-  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
-      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3) : f0_(f0), f1_(f1), f2_(f2),
-      f3_(f3) {}
-
-  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_) {}
-
-  template <GTEST_4_TYPENAMES_(U)>
-  tuple(const GTEST_4_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
-      f3_(t.f3_) {}
-
-  tuple& operator=(const tuple& t) { return CopyFrom(t); }
-
-  template <GTEST_4_TYPENAMES_(U)>
-  tuple& operator=(const GTEST_4_TUPLE_(U)& t) {
-    return CopyFrom(t);
-  }
-
-  GTEST_DECLARE_TUPLE_AS_FRIEND_
-
-  template <GTEST_4_TYPENAMES_(U)>
-  tuple& CopyFrom(const GTEST_4_TUPLE_(U)& t) {
-    f0_ = t.f0_;
-    f1_ = t.f1_;
-    f2_ = t.f2_;
-    f3_ = t.f3_;
-    return *this;
-  }
-
-  T0 f0_;
-  T1 f1_;
-  T2 f2_;
-  T3 f3_;
-};
-
-template <GTEST_5_TYPENAMES_(T)>
-class GTEST_5_TUPLE_(T) {
- public:
-  template <int k> friend class gtest_internal::Get;
-
-  tuple() : f0_(), f1_(), f2_(), f3_(), f4_() {}
-
-  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
-      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3,
-      GTEST_BY_REF_(T4) f4) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4) {}
-
-  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
-      f4_(t.f4_) {}
-
-  template <GTEST_5_TYPENAMES_(U)>
-  tuple(const GTEST_5_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
-      f3_(t.f3_), f4_(t.f4_) {}
-
-  tuple& operator=(const tuple& t) { return CopyFrom(t); }
-
-  template <GTEST_5_TYPENAMES_(U)>
-  tuple& operator=(const GTEST_5_TUPLE_(U)& t) {
-    return CopyFrom(t);
-  }
-
-  GTEST_DECLARE_TUPLE_AS_FRIEND_
-
-  template <GTEST_5_TYPENAMES_(U)>
-  tuple& CopyFrom(const GTEST_5_TUPLE_(U)& t) {
-    f0_ = t.f0_;
-    f1_ = t.f1_;
-    f2_ = t.f2_;
-    f3_ = t.f3_;
-    f4_ = t.f4_;
-    return *this;
-  }
-
-  T0 f0_;
-  T1 f1_;
-  T2 f2_;
-  T3 f3_;
-  T4 f4_;
-};
-
-template <GTEST_6_TYPENAMES_(T)>
-class GTEST_6_TUPLE_(T) {
- public:
-  template <int k> friend class gtest_internal::Get;
-
-  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_() {}
-
-  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
-      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
-      GTEST_BY_REF_(T5) f5) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),
-      f5_(f5) {}
-
-  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
-      f4_(t.f4_), f5_(t.f5_) {}
-
-  template <GTEST_6_TYPENAMES_(U)>
-  tuple(const GTEST_6_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
-      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_) {}
-
-  tuple& operator=(const tuple& t) { return CopyFrom(t); }
-
-  template <GTEST_6_TYPENAMES_(U)>
-  tuple& operator=(const GTEST_6_TUPLE_(U)& t) {
-    return CopyFrom(t);
-  }
-
-  GTEST_DECLARE_TUPLE_AS_FRIEND_
-
-  template <GTEST_6_TYPENAMES_(U)>
-  tuple& CopyFrom(const GTEST_6_TUPLE_(U)& t) {
-    f0_ = t.f0_;
-    f1_ = t.f1_;
-    f2_ = t.f2_;
-    f3_ = t.f3_;
-    f4_ = t.f4_;
-    f5_ = t.f5_;
-    return *this;
-  }
-
-  T0 f0_;
-  T1 f1_;
-  T2 f2_;
-  T3 f3_;
-  T4 f4_;
-  T5 f5_;
-};
-
-template <GTEST_7_TYPENAMES_(T)>
-class GTEST_7_TUPLE_(T) {
- public:
-  template <int k> friend class gtest_internal::Get;
-
-  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_() {}
-
-  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
-      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
-      GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6) : f0_(f0), f1_(f1), f2_(f2),
-      f3_(f3), f4_(f4), f5_(f5), f6_(f6) {}
-
-  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
-      f4_(t.f4_), f5_(t.f5_), f6_(t.f6_) {}
-
-  template <GTEST_7_TYPENAMES_(U)>
-  tuple(const GTEST_7_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
-      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_) {}
-
-  tuple& operator=(const tuple& t) { return CopyFrom(t); }
-
-  template <GTEST_7_TYPENAMES_(U)>
-  tuple& operator=(const GTEST_7_TUPLE_(U)& t) {
-    return CopyFrom(t);
-  }
-
-  GTEST_DECLARE_TUPLE_AS_FRIEND_
-
-  template <GTEST_7_TYPENAMES_(U)>
-  tuple& CopyFrom(const GTEST_7_TUPLE_(U)& t) {
-    f0_ = t.f0_;
-    f1_ = t.f1_;
-    f2_ = t.f2_;
-    f3_ = t.f3_;
-    f4_ = t.f4_;
-    f5_ = t.f5_;
-    f6_ = t.f6_;
-    return *this;
-  }
-
-  T0 f0_;
-  T1 f1_;
-  T2 f2_;
-  T3 f3_;
-  T4 f4_;
-  T5 f5_;
-  T6 f6_;
-};
-
-template <GTEST_8_TYPENAMES_(T)>
-class GTEST_8_TUPLE_(T) {
- public:
-  template <int k> friend class gtest_internal::Get;
-
-  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_() {}
-
-  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
-      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
-      GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6,
-      GTEST_BY_REF_(T7) f7) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),
-      f5_(f5), f6_(f6), f7_(f7) {}
-
-  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
-      f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_) {}
-
-  template <GTEST_8_TYPENAMES_(U)>
-  tuple(const GTEST_8_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
-      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_) {}
-
-  tuple& operator=(const tuple& t) { return CopyFrom(t); }
-
-  template <GTEST_8_TYPENAMES_(U)>
-  tuple& operator=(const GTEST_8_TUPLE_(U)& t) {
-    return CopyFrom(t);
-  }
-
-  GTEST_DECLARE_TUPLE_AS_FRIEND_
-
-  template <GTEST_8_TYPENAMES_(U)>
-  tuple& CopyFrom(const GTEST_8_TUPLE_(U)& t) {
-    f0_ = t.f0_;
-    f1_ = t.f1_;
-    f2_ = t.f2_;
-    f3_ = t.f3_;
-    f4_ = t.f4_;
-    f5_ = t.f5_;
-    f6_ = t.f6_;
-    f7_ = t.f7_;
-    return *this;
-  }
-
-  T0 f0_;
-  T1 f1_;
-  T2 f2_;
-  T3 f3_;
-  T4 f4_;
-  T5 f5_;
-  T6 f6_;
-  T7 f7_;
-};
-
-template <GTEST_9_TYPENAMES_(T)>
-class GTEST_9_TUPLE_(T) {
- public:
-  template <int k> friend class gtest_internal::Get;
-
-  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_(), f8_() {}
-
-  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
-      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
-      GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6, GTEST_BY_REF_(T7) f7,
-      GTEST_BY_REF_(T8) f8) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),
-      f5_(f5), f6_(f6), f7_(f7), f8_(f8) {}
-
-  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
-      f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_) {}
-
-  template <GTEST_9_TYPENAMES_(U)>
-  tuple(const GTEST_9_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
-      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_) {}
-
-  tuple& operator=(const tuple& t) { return CopyFrom(t); }
-
-  template <GTEST_9_TYPENAMES_(U)>
-  tuple& operator=(const GTEST_9_TUPLE_(U)& t) {
-    return CopyFrom(t);
-  }
-
-  GTEST_DECLARE_TUPLE_AS_FRIEND_
-
-  template <GTEST_9_TYPENAMES_(U)>
-  tuple& CopyFrom(const GTEST_9_TUPLE_(U)& t) {
-    f0_ = t.f0_;
-    f1_ = t.f1_;
-    f2_ = t.f2_;
-    f3_ = t.f3_;
-    f4_ = t.f4_;
-    f5_ = t.f5_;
-    f6_ = t.f6_;
-    f7_ = t.f7_;
-    f8_ = t.f8_;
-    return *this;
-  }
-
-  T0 f0_;
-  T1 f1_;
-  T2 f2_;
-  T3 f3_;
-  T4 f4_;
-  T5 f5_;
-  T6 f6_;
-  T7 f7_;
-  T8 f8_;
-};
-
-template <GTEST_10_TYPENAMES_(T)>
-class tuple {
- public:
-  template <int k> friend class gtest_internal::Get;
-
-  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_(), f8_(),
-      f9_() {}
-
-  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
-      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
-      GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6, GTEST_BY_REF_(T7) f7,
-      GTEST_BY_REF_(T8) f8, GTEST_BY_REF_(T9) f9) : f0_(f0), f1_(f1), f2_(f2),
-      f3_(f3), f4_(f4), f5_(f5), f6_(f6), f7_(f7), f8_(f8), f9_(f9) {}
-
-  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
-      f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_), f9_(t.f9_) {}
-
-  template <GTEST_10_TYPENAMES_(U)>
-  tuple(const GTEST_10_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
-      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_),
-      f9_(t.f9_) {}
-
-  tuple& operator=(const tuple& t) { return CopyFrom(t); }
-
-  template <GTEST_10_TYPENAMES_(U)>
-  tuple& operator=(const GTEST_10_TUPLE_(U)& t) {
-    return CopyFrom(t);
-  }
-
-  GTEST_DECLARE_TUPLE_AS_FRIEND_
-
-  template <GTEST_10_TYPENAMES_(U)>
-  tuple& CopyFrom(const GTEST_10_TUPLE_(U)& t) {
-    f0_ = t.f0_;
-    f1_ = t.f1_;
-    f2_ = t.f2_;
-    f3_ = t.f3_;
-    f4_ = t.f4_;
-    f5_ = t.f5_;
-    f6_ = t.f6_;
-    f7_ = t.f7_;
-    f8_ = t.f8_;
-    f9_ = t.f9_;
-    return *this;
-  }
-
-  T0 f0_;
-  T1 f1_;
-  T2 f2_;
-  T3 f3_;
-  T4 f4_;
-  T5 f5_;
-  T6 f6_;
-  T7 f7_;
-  T8 f8_;
-  T9 f9_;
-};
-
-// 6.1.3.2 Tuple creation functions.
-
-// Known limitations: we don't support passing an
-// std::tr1::reference_wrapper<T> to make_tuple().  And we don't
-// implement tie().
-
-inline tuple<> make_tuple() { return tuple<>(); }
-
-template <GTEST_1_TYPENAMES_(T)>
-inline GTEST_1_TUPLE_(T) make_tuple(const T0& f0) {
-  return GTEST_1_TUPLE_(T)(f0);
-}
-
-template <GTEST_2_TYPENAMES_(T)>
-inline GTEST_2_TUPLE_(T) make_tuple(const T0& f0, const T1& f1) {
-  return GTEST_2_TUPLE_(T)(f0, f1);
-}
-
-template <GTEST_3_TYPENAMES_(T)>
-inline GTEST_3_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2) {
-  return GTEST_3_TUPLE_(T)(f0, f1, f2);
-}
-
-template <GTEST_4_TYPENAMES_(T)>
-inline GTEST_4_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
-    const T3& f3) {
-  return GTEST_4_TUPLE_(T)(f0, f1, f2, f3);
-}
-
-template <GTEST_5_TYPENAMES_(T)>
-inline GTEST_5_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
-    const T3& f3, const T4& f4) {
-  return GTEST_5_TUPLE_(T)(f0, f1, f2, f3, f4);
-}
-
-template <GTEST_6_TYPENAMES_(T)>
-inline GTEST_6_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
-    const T3& f3, const T4& f4, const T5& f5) {
-  return GTEST_6_TUPLE_(T)(f0, f1, f2, f3, f4, f5);
-}
-
-template <GTEST_7_TYPENAMES_(T)>
-inline GTEST_7_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
-    const T3& f3, const T4& f4, const T5& f5, const T6& f6) {
-  return GTEST_7_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6);
-}
-
-template <GTEST_8_TYPENAMES_(T)>
-inline GTEST_8_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
-    const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7) {
-  return GTEST_8_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7);
-}
-
-template <GTEST_9_TYPENAMES_(T)>
-inline GTEST_9_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
-    const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7,
-    const T8& f8) {
-  return GTEST_9_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7, f8);
-}
-
-template <GTEST_10_TYPENAMES_(T)>
-inline GTEST_10_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
-    const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7,
-    const T8& f8, const T9& f9) {
-  return GTEST_10_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7, f8, f9);
-}
-
-// 6.1.3.3 Tuple helper classes.
-
-template <typename Tuple> struct tuple_size;
-
-template <GTEST_0_TYPENAMES_(T)>
-struct tuple_size<GTEST_0_TUPLE_(T)> { static const int value = 0; };
-
-template <GTEST_1_TYPENAMES_(T)>
-struct tuple_size<GTEST_1_TUPLE_(T)> { static const int value = 1; };
-
-template <GTEST_2_TYPENAMES_(T)>
-struct tuple_size<GTEST_2_TUPLE_(T)> { static const int value = 2; };
-
-template <GTEST_3_TYPENAMES_(T)>
-struct tuple_size<GTEST_3_TUPLE_(T)> { static const int value = 3; };
-
-template <GTEST_4_TYPENAMES_(T)>
-struct tuple_size<GTEST_4_TUPLE_(T)> { static const int value = 4; };
-
-template <GTEST_5_TYPENAMES_(T)>
-struct tuple_size<GTEST_5_TUPLE_(T)> { static const int value = 5; };
-
-template <GTEST_6_TYPENAMES_(T)>
-struct tuple_size<GTEST_6_TUPLE_(T)> { static const int value = 6; };
-
-template <GTEST_7_TYPENAMES_(T)>
-struct tuple_size<GTEST_7_TUPLE_(T)> { static const int value = 7; };
-
-template <GTEST_8_TYPENAMES_(T)>
-struct tuple_size<GTEST_8_TUPLE_(T)> { static const int value = 8; };
-
-template <GTEST_9_TYPENAMES_(T)>
-struct tuple_size<GTEST_9_TUPLE_(T)> { static const int value = 9; };
-
-template <GTEST_10_TYPENAMES_(T)>
-struct tuple_size<GTEST_10_TUPLE_(T)> { static const int value = 10; };
-
-template <int k, class Tuple>
-struct tuple_element {
-  typedef typename gtest_internal::TupleElement<
-      k < (tuple_size<Tuple>::value), k, Tuple>::type type;
-};
-
-#define GTEST_TUPLE_ELEMENT_(k, Tuple) typename tuple_element<k, Tuple >::type
-
-// 6.1.3.4 Element access.
-
-namespace gtest_internal {
-
-template <>
-class Get<0> {
- public:
-  template <class Tuple>
-  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(0, Tuple))
-  Field(Tuple& t) { return t.f0_; }  // NOLINT
-
-  template <class Tuple>
-  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(0, Tuple))
-  ConstField(const Tuple& t) { return t.f0_; }
-};
-
-template <>
-class Get<1> {
- public:
-  template <class Tuple>
-  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(1, Tuple))
-  Field(Tuple& t) { return t.f1_; }  // NOLINT
-
-  template <class Tuple>
-  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(1, Tuple))
-  ConstField(const Tuple& t) { return t.f1_; }
-};
-
-template <>
-class Get<2> {
- public:
-  template <class Tuple>
-  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(2, Tuple))
-  Field(Tuple& t) { return t.f2_; }  // NOLINT
-
-  template <class Tuple>
-  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(2, Tuple))
-  ConstField(const Tuple& t) { return t.f2_; }
-};
-
-template <>
-class Get<3> {
- public:
-  template <class Tuple>
-  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(3, Tuple))
-  Field(Tuple& t) { return t.f3_; }  // NOLINT
-
-  template <class Tuple>
-  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(3, Tuple))
-  ConstField(const Tuple& t) { return t.f3_; }
-};
-
-template <>
-class Get<4> {
- public:
-  template <class Tuple>
-  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(4, Tuple))
-  Field(Tuple& t) { return t.f4_; }  // NOLINT
-
-  template <class Tuple>
-  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(4, Tuple))
-  ConstField(const Tuple& t) { return t.f4_; }
-};
-
-template <>
-class Get<5> {
- public:
-  template <class Tuple>
-  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(5, Tuple))
-  Field(Tuple& t) { return t.f5_; }  // NOLINT
-
-  template <class Tuple>
-  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(5, Tuple))
-  ConstField(const Tuple& t) { return t.f5_; }
-};
-
-template <>
-class Get<6> {
- public:
-  template <class Tuple>
-  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(6, Tuple))
-  Field(Tuple& t) { return t.f6_; }  // NOLINT
-
-  template <class Tuple>
-  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(6, Tuple))
-  ConstField(const Tuple& t) { return t.f6_; }
-};
-
-template <>
-class Get<7> {
- public:
-  template <class Tuple>
-  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(7, Tuple))
-  Field(Tuple& t) { return t.f7_; }  // NOLINT
-
-  template <class Tuple>
-  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(7, Tuple))
-  ConstField(const Tuple& t) { return t.f7_; }
-};
-
-template <>
-class Get<8> {
- public:
-  template <class Tuple>
-  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(8, Tuple))
-  Field(Tuple& t) { return t.f8_; }  // NOLINT
-
-  template <class Tuple>
-  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(8, Tuple))
-  ConstField(const Tuple& t) { return t.f8_; }
-};
-
-template <>
-class Get<9> {
- public:
-  template <class Tuple>
-  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(9, Tuple))
-  Field(Tuple& t) { return t.f9_; }  // NOLINT
-
-  template <class Tuple>
-  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(9, Tuple))
-  ConstField(const Tuple& t) { return t.f9_; }
-};
-
-}  // namespace gtest_internal
-
-template <int k, GTEST_10_TYPENAMES_(T)>
-GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_10_TUPLE_(T)))
-get(GTEST_10_TUPLE_(T)& t) {
-  return gtest_internal::Get<k>::Field(t);
-}
-
-template <int k, GTEST_10_TYPENAMES_(T)>
-GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(k,  GTEST_10_TUPLE_(T)))
-get(const GTEST_10_TUPLE_(T)& t) {
-  return gtest_internal::Get<k>::ConstField(t);
-}
-
-// 6.1.3.5 Relational operators
-
-// We only implement == and !=, as we don't have a need for the rest yet.
-
-namespace gtest_internal {
-
-// SameSizeTuplePrefixComparator<k, k>::Eq(t1, t2) returns true if the
-// first k fields of t1 equals the first k fields of t2.
-// SameSizeTuplePrefixComparator(k1, k2) would be a compiler error if
-// k1 != k2.
-template <int kSize1, int kSize2>
-struct SameSizeTuplePrefixComparator;
-
-template <>
-struct SameSizeTuplePrefixComparator<0, 0> {
-  template <class Tuple1, class Tuple2>
-  static bool Eq(const Tuple1& /* t1 */, const Tuple2& /* t2 */) {
-    return true;
-  }
-};
-
-template <int k>
-struct SameSizeTuplePrefixComparator<k, k> {
-  template <class Tuple1, class Tuple2>
-  static bool Eq(const Tuple1& t1, const Tuple2& t2) {
-    return SameSizeTuplePrefixComparator<k - 1, k - 1>::Eq(t1, t2) &&
-        ::std::tr1::get<k - 1>(t1) == ::std::tr1::get<k - 1>(t2);
-  }
-};
-
-}  // namespace gtest_internal
-
-template <GTEST_10_TYPENAMES_(T), GTEST_10_TYPENAMES_(U)>
-inline bool operator==(const GTEST_10_TUPLE_(T)& t,
-                       const GTEST_10_TUPLE_(U)& u) {
-  return gtest_internal::SameSizeTuplePrefixComparator<
-      tuple_size<GTEST_10_TUPLE_(T)>::value,
-      tuple_size<GTEST_10_TUPLE_(U)>::value>::Eq(t, u);
-}
-
-template <GTEST_10_TYPENAMES_(T), GTEST_10_TYPENAMES_(U)>
-inline bool operator!=(const GTEST_10_TUPLE_(T)& t,
-                       const GTEST_10_TUPLE_(U)& u) { return !(t == u); }
-
-// 6.1.4 Pairs.
-// Unimplemented.
-
-}  // namespace tr1
-}  // namespace std
-
-#undef GTEST_0_TUPLE_
-#undef GTEST_1_TUPLE_
-#undef GTEST_2_TUPLE_
-#undef GTEST_3_TUPLE_
-#undef GTEST_4_TUPLE_
-#undef GTEST_5_TUPLE_
-#undef GTEST_6_TUPLE_
-#undef GTEST_7_TUPLE_
-#undef GTEST_8_TUPLE_
-#undef GTEST_9_TUPLE_
-#undef GTEST_10_TUPLE_
-
-#undef GTEST_0_TYPENAMES_
-#undef GTEST_1_TYPENAMES_
-#undef GTEST_2_TYPENAMES_
-#undef GTEST_3_TYPENAMES_
-#undef GTEST_4_TYPENAMES_
-#undef GTEST_5_TYPENAMES_
-#undef GTEST_6_TYPENAMES_
-#undef GTEST_7_TYPENAMES_
-#undef GTEST_8_TYPENAMES_
-#undef GTEST_9_TYPENAMES_
-#undef GTEST_10_TYPENAMES_
-
-#undef GTEST_DECLARE_TUPLE_AS_FRIEND_
-#undef GTEST_BY_REF_
-#undef GTEST_ADD_REF_
-#undef GTEST_TUPLE_ELEMENT_
-
-#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
-# elif GTEST_OS_SYMBIAN
-
-// On Symbian, BOOST_HAS_TR1_TUPLE causes Boost's TR1 tuple library to
-// use STLport's tuple implementation, which unfortunately doesn't
-// work as the copy of STLport distributed with Symbian is incomplete.
-// By making sure BOOST_HAS_TR1_TUPLE is undefined, we force Boost to
-// use its own tuple implementation.
-#  ifdef BOOST_HAS_TR1_TUPLE
-#   undef BOOST_HAS_TR1_TUPLE
-#  endif  // BOOST_HAS_TR1_TUPLE
-
-// This prevents <boost/tr1/detail/config.hpp>, which defines
-// BOOST_HAS_TR1_TUPLE, from being #included by Boost's <tuple>.
-#  define BOOST_TR1_DETAIL_CONFIG_HPP_INCLUDED
-#  include <tuple>
-
-# elif defined(__GNUC__) && (GTEST_GCC_VER_ >= 40000)
-// GCC 4.0+ implements tr1/tuple in the <tr1/tuple> header.  This does
-// not conform to the TR1 spec, which requires the header to be <tuple>.
-
-#  if !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302
-// Until version 4.3.2, gcc has a bug that causes <tr1/functional>,
-// which is #included by <tr1/tuple>, to not compile when RTTI is
-// disabled.  _TR1_FUNCTIONAL is the header guard for
-// <tr1/functional>.  Hence the following #define is a hack to prevent
-// <tr1/functional> from being included.
-#   define _TR1_FUNCTIONAL 1
-#   include <tr1/tuple>
-#   undef _TR1_FUNCTIONAL  // Allows the user to #include
-                        // <tr1/functional> if he chooses to.
-#  else
-#   include <tr1/tuple>  // NOLINT
-#  endif  // !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302
-
-# else
-// If the compiler is not GCC 4.0+, we assume the user is using a
-// spec-conforming TR1 implementation.
-#  include <tuple>  // NOLINT
-# endif  // GTEST_USE_OWN_TR1_TUPLE
-
-#endif  // GTEST_HAS_TR1_TUPLE
-
-// Determines whether clone(2) is supported.
-// Usually it will only be available on Linux, excluding
-// Linux on the Itanium architecture.
-// Also see http://linux.die.net/man/2/clone.
-#ifndef GTEST_HAS_CLONE
-// The user didn't tell us, so we need to figure it out.
-
-# if GTEST_OS_LINUX && !defined(__ia64__)
-#  define GTEST_HAS_CLONE 1
-# else
-#  define GTEST_HAS_CLONE 0
-# endif  // GTEST_OS_LINUX && !defined(__ia64__)
-
-#endif  // GTEST_HAS_CLONE
-
-// Determines whether to support stream redirection. This is used to test
-// output correctness and to implement death tests.
-#ifndef GTEST_HAS_STREAM_REDIRECTION
-// By default, we assume that stream redirection is supported on all
-// platforms except known mobile ones.
-# if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN
-#  define GTEST_HAS_STREAM_REDIRECTION 0
-# else
-#  define GTEST_HAS_STREAM_REDIRECTION 1
-# endif  // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_SYMBIAN
-#endif  // GTEST_HAS_STREAM_REDIRECTION
-
-// Determines whether to support death tests.
-// Google Test does not support death tests for VC 7.1 and earlier as
-// abort() in a VC 7.1 application compiled as GUI in debug config
-// pops up a dialog window that cannot be suppressed programmatically.
-#if (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \
-     (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || \
-     GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX)
-# define GTEST_HAS_DEATH_TEST 1
-# include <vector>  // NOLINT
-#endif
-
-// We don't support MSVC 7.1 with exceptions disabled now.  Therefore
-// all the compilers we care about are adequate for supporting
-// value-parameterized tests.
-#define GTEST_HAS_PARAM_TEST 1
-
-// Determines whether to support type-driven tests.
-
-// Typed tests need <typeinfo> and variadic macros, which GCC, VC++ 8.0,
-// Sun Pro CC, IBM Visual Age, and HP aCC support.
-#if defined(__GNUC__) || (_MSC_VER >= 1400) || defined(__SUNPRO_CC) || \
-    defined(__IBMCPP__) || defined(__HP_aCC)
-# define GTEST_HAS_TYPED_TEST 1
-# define GTEST_HAS_TYPED_TEST_P 1
-#endif
-
-// Determines whether to support Combine(). This only makes sense when
-// value-parameterized tests are enabled.  The implementation doesn't
-// work on Sun Studio since it doesn't understand templated conversion
-// operators.
-#if GTEST_HAS_PARAM_TEST && GTEST_HAS_TR1_TUPLE && !defined(__SUNPRO_CC)
-# define GTEST_HAS_COMBINE 1
-#endif
-
-// Determines whether the system compiler uses UTF-16 for encoding wide strings.
-#define GTEST_WIDE_STRING_USES_UTF16_ \
-    (GTEST_OS_WINDOWS || GTEST_OS_CYGWIN || GTEST_OS_SYMBIAN || GTEST_OS_AIX)
-
-// Determines whether test results can be streamed to a socket.
-#if GTEST_OS_LINUX
-# define GTEST_CAN_STREAM_RESULTS_ 1
-#endif
-
-// Defines some utility macros.
-
-// The GNU compiler emits a warning if nested "if" statements are followed by
-// an "else" statement and braces are not used to explicitly disambiguate the
-// "else" binding.  This leads to problems with code like:
-//
-//   if (gate)
-//     ASSERT_*(condition) << "Some message";
-//
-// The "switch (0) case 0:" idiom is used to suppress this.
-#ifdef __INTEL_COMPILER
-# define GTEST_AMBIGUOUS_ELSE_BLOCKER_
-#else
-# define GTEST_AMBIGUOUS_ELSE_BLOCKER_ switch (0) case 0: default:  // NOLINT
-#endif
-
-// Use this annotation at the end of a struct/class definition to
-// prevent the compiler from optimizing away instances that are never
-// used.  This is useful when all interesting logic happens inside the
-// c'tor and / or d'tor.  Example:
-//
-//   struct Foo {
-//     Foo() { ... }
-//   } GTEST_ATTRIBUTE_UNUSED_;
-//
-// Also use it after a variable or parameter declaration to tell the
-// compiler the variable/parameter does not have to be used.
-#if defined(__GNUC__) && !defined(COMPILER_ICC)
-# define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused))
-#else
-# define GTEST_ATTRIBUTE_UNUSED_
-#endif
-
-// A macro to disallow operator=
-// This should be used in the private: declarations for a class.
-#define GTEST_DISALLOW_ASSIGN_(type)\
-  void operator=(type const &)
-
-// A macro to disallow copy constructor and operator=
-// This should be used in the private: declarations for a class.
-#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)\
-  type(type const &);\
-  GTEST_DISALLOW_ASSIGN_(type)
-
-// Tell the compiler to warn about unused return values for functions declared
-// with this macro.  The macro should be used on function declarations
-// following the argument list:
-//
-//   Sprocket* AllocateSprocket() GTEST_MUST_USE_RESULT_;
-#if defined(__GNUC__) && (GTEST_GCC_VER_ >= 30400) && !defined(COMPILER_ICC)
-# define GTEST_MUST_USE_RESULT_ __attribute__ ((warn_unused_result))
-#else
-# define GTEST_MUST_USE_RESULT_
-#endif  // __GNUC__ && (GTEST_GCC_VER_ >= 30400) && !COMPILER_ICC
-
-// Determine whether the compiler supports Microsoft's Structured Exception
-// Handling.  This is supported by several Windows compilers but generally
-// does not exist on any other system.
-#ifndef GTEST_HAS_SEH
-// The user didn't tell us, so we need to figure it out.
-
-# if defined(_MSC_VER) || defined(__BORLANDC__)
-// These two compilers are known to support SEH.
-#  define GTEST_HAS_SEH 1
-# else
-// Assume no SEH.
-#  define GTEST_HAS_SEH 0
-# endif
-
-#endif  // GTEST_HAS_SEH
-
-#ifdef _MSC_VER
-
-# if GTEST_LINKED_AS_SHARED_LIBRARY
-#  define GTEST_API_ __declspec(dllimport)
-# elif GTEST_CREATE_SHARED_LIBRARY
-#  define GTEST_API_ __declspec(dllexport)
-# endif
-
-#endif  // _MSC_VER
-
-#ifndef GTEST_API_
-# define GTEST_API_
-#endif
-
-#ifdef __GNUC__
-// Ask the compiler to never inline a given function.
-# define GTEST_NO_INLINE_ __attribute__((noinline))
-#else
-# define GTEST_NO_INLINE_
-#endif
-
-namespace testing {
-
-class Message;
-
-namespace internal {
-
-class String;
-
-// The GTEST_COMPILE_ASSERT_ macro can be used to verify that a compile time
-// expression is true. For example, you could use it to verify the
-// size of a static array:
-//
-//   GTEST_COMPILE_ASSERT_(ARRAYSIZE(content_type_names) == CONTENT_NUM_TYPES,
-//                         content_type_names_incorrect_size);
-//
-// or to make sure a struct is smaller than a certain size:
-//
-//   GTEST_COMPILE_ASSERT_(sizeof(foo) < 128, foo_too_large);
-//
-// The second argument to the macro is the name of the variable. If
-// the expression is false, most compilers will issue a warning/error
-// containing the name of the variable.
-
-template <bool>
-struct CompileAssert {
-};
-
-#define GTEST_COMPILE_ASSERT_(expr, msg) \
-  typedef ::testing::internal::CompileAssert<(bool(expr))> \
-      msg[bool(expr) ? 1 : -1]
-
-// Implementation details of GTEST_COMPILE_ASSERT_:
-//
-// - GTEST_COMPILE_ASSERT_ works by defining an array type that has -1
-//   elements (and thus is invalid) when the expression is false.
-//
-// - The simpler definition
-//
-//    #define GTEST_COMPILE_ASSERT_(expr, msg) typedef char msg[(expr) ? 1 : -1]
-//
-//   does not work, as gcc supports variable-length arrays whose sizes
-//   are determined at run-time (this is gcc's extension and not part
-//   of the C++ standard).  As a result, gcc fails to reject the
-//   following code with the simple definition:
-//
-//     int foo;
-//     GTEST_COMPILE_ASSERT_(foo, msg); // not supposed to compile as foo is
-//                                      // not a compile-time constant.
-//
-// - By using the type CompileAssert<(bool(expr))>, we ensures that
-//   expr is a compile-time constant.  (Template arguments must be
-//   determined at compile-time.)
-//
-// - The outter parentheses in CompileAssert<(bool(expr))> are necessary
-//   to work around a bug in gcc 3.4.4 and 4.0.1.  If we had written
-//
-//     CompileAssert<bool(expr)>
-//
-//   instead, these compilers will refuse to compile
-//
-//     GTEST_COMPILE_ASSERT_(5 > 0, some_message);
-//
-//   (They seem to think the ">" in "5 > 0" marks the end of the
-//   template argument list.)
-//
-// - The array size is (bool(expr) ? 1 : -1), instead of simply
-//
-//     ((expr) ? 1 : -1).
-//
-//   This is to avoid running into a bug in MS VC 7.1, which
-//   causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1.
-
-// StaticAssertTypeEqHelper is used by StaticAssertTypeEq defined in gtest.h.
-//
-// This template is declared, but intentionally undefined.
-template <typename T1, typename T2>
-struct StaticAssertTypeEqHelper;
-
-template <typename T>
-struct StaticAssertTypeEqHelper<T, T> {};
-
-#if GTEST_HAS_GLOBAL_STRING
-typedef ::string string;
-#else
-typedef ::std::string string;
-#endif  // GTEST_HAS_GLOBAL_STRING
-
-#if GTEST_HAS_GLOBAL_WSTRING
-typedef ::wstring wstring;
-#elif GTEST_HAS_STD_WSTRING
-typedef ::std::wstring wstring;
-#endif  // GTEST_HAS_GLOBAL_WSTRING
-
-// A helper for suppressing warnings on constant condition.  It just
-// returns 'condition'.
-GTEST_API_ bool IsTrue(bool condition);
-
-// Defines scoped_ptr.
-
-// This implementation of scoped_ptr is PARTIAL - it only contains
-// enough stuff to satisfy Google Test's need.
-template <typename T>
-class scoped_ptr {
- public:
-  typedef T element_type;
-
-  explicit scoped_ptr(T* p = NULL) : ptr_(p) {}
-  ~scoped_ptr() { reset(); }
-
-  T& operator*() const { return *ptr_; }
-  T* operator->() const { return ptr_; }
-  T* get() const { return ptr_; }
-
-  T* release() {
-    T* const ptr = ptr_;
-    ptr_ = NULL;
-    return ptr;
-  }
-
-  void reset(T* p = NULL) {
-    if (p != ptr_) {
-      if (IsTrue(sizeof(T) > 0)) {  // Makes sure T is a complete type.
-        delete ptr_;
-      }
-      ptr_ = p;
-    }
-  }
- private:
-  T* ptr_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(scoped_ptr);
-};
-
-// Defines RE.
-
-// A simple C++ wrapper for <regex.h>.  It uses the POSIX Extended
-// Regular Expression syntax.
-class GTEST_API_ RE {
- public:
-  // A copy constructor is required by the Standard to initialize object
-  // references from r-values.
-  RE(const RE& other) { Init(other.pattern()); }
-
-  // Constructs an RE from a string.
-  RE(const ::std::string& regex) { Init(regex.c_str()); }  // NOLINT
-
-#if GTEST_HAS_GLOBAL_STRING
-
-  RE(const ::string& regex) { Init(regex.c_str()); }  // NOLINT
-
-#endif  // GTEST_HAS_GLOBAL_STRING
-
-  RE(const char* regex) { Init(regex); }  // NOLINT
-  ~RE();
-
-  // Returns the string representation of the regex.
-  const char* pattern() const { return pattern_; }
-
-  // FullMatch(str, re) returns true iff regular expression re matches
-  // the entire str.
-  // PartialMatch(str, re) returns true iff regular expression re
-  // matches a substring of str (including str itself).
-  //
-  // TODO(wan at google.com): make FullMatch() and PartialMatch() work
-  // when str contains NUL characters.
-  static bool FullMatch(const ::std::string& str, const RE& re) {
-    return FullMatch(str.c_str(), re);
-  }
-  static bool PartialMatch(const ::std::string& str, const RE& re) {
-    return PartialMatch(str.c_str(), re);
-  }
-
-#if GTEST_HAS_GLOBAL_STRING
-
-  static bool FullMatch(const ::string& str, const RE& re) {
-    return FullMatch(str.c_str(), re);
-  }
-  static bool PartialMatch(const ::string& str, const RE& re) {
-    return PartialMatch(str.c_str(), re);
-  }
-
-#endif  // GTEST_HAS_GLOBAL_STRING
-
-  static bool FullMatch(const char* str, const RE& re);
-  static bool PartialMatch(const char* str, const RE& re);
-
- private:
-  void Init(const char* regex);
-
-  // We use a const char* instead of a string, as Google Test may be used
-  // where string is not available.  We also do not use Google Test's own
-  // String type here, in order to simplify dependencies between the
-  // files.
-  const char* pattern_;
-  bool is_valid_;
-
-#if GTEST_USES_POSIX_RE
-
-  regex_t full_regex_;     // For FullMatch().
-  regex_t partial_regex_;  // For PartialMatch().
-
-#else  // GTEST_USES_SIMPLE_RE
-
-  const char* full_pattern_;  // For FullMatch();
-
-#endif
-
-  GTEST_DISALLOW_ASSIGN_(RE);
-};
-
-// Formats a source file path and a line number as they would appear
-// in an error message from the compiler used to compile this code.
-GTEST_API_ ::std::string FormatFileLocation(const char* file, int line);
-
-// Formats a file location for compiler-independent XML output.
-// Although this function is not platform dependent, we put it next to
-// FormatFileLocation in order to contrast the two functions.
-GTEST_API_ ::std::string FormatCompilerIndependentFileLocation(const char* file,
-                                                               int line);
-
-// Defines logging utilities:
-//   GTEST_LOG_(severity) - logs messages at the specified severity level. The
-//                          message itself is streamed into the macro.
-//   LogToStderr()  - directs all log messages to stderr.
-//   FlushInfoLog() - flushes informational log messages.
-
-enum GTestLogSeverity {
-  GTEST_INFO,
-  GTEST_WARNING,
-  GTEST_ERROR,
-  GTEST_FATAL
-};
-
-// Formats log entry severity, provides a stream object for streaming the
-// log message, and terminates the message with a newline when going out of
-// scope.
-class GTEST_API_ GTestLog {
- public:
-  GTestLog(GTestLogSeverity severity, const char* file, int line);
-
-  // Flushes the buffers and, if severity is GTEST_FATAL, aborts the program.
-  ~GTestLog();
-
-  ::std::ostream& GetStream() { return ::std::cerr; }
-
- private:
-  const GTestLogSeverity severity_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestLog);
-};
-
-#define GTEST_LOG_(severity) \
-    ::testing::internal::GTestLog(::testing::internal::GTEST_##severity, \
-                                  __FILE__, __LINE__).GetStream()
-
-inline void LogToStderr() {}
-inline void FlushInfoLog() { fflush(NULL); }
-
-// INTERNAL IMPLEMENTATION - DO NOT USE.
-//
-// GTEST_CHECK_ is an all-mode assert. It aborts the program if the condition
-// is not satisfied.
-//  Synopsys:
-//    GTEST_CHECK_(boolean_condition);
-//     or
-//    GTEST_CHECK_(boolean_condition) << "Additional message";
-//
-//    This checks the condition and if the condition is not satisfied
-//    it prints message about the condition violation, including the
-//    condition itself, plus additional message streamed into it, if any,
-//    and then it aborts the program. It aborts the program irrespective of
-//    whether it is built in the debug mode or not.
-#define GTEST_CHECK_(condition) \
-    GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
-    if (::testing::internal::IsTrue(condition)) \
-      ; \
-    else \
-      GTEST_LOG_(FATAL) << "Condition " #condition " failed. "
-
-// An all-mode assert to verify that the given POSIX-style function
-// call returns 0 (indicating success).  Known limitation: this
-// doesn't expand to a balanced 'if' statement, so enclose the macro
-// in {} if you need to use it as the only statement in an 'if'
-// branch.
-#define GTEST_CHECK_POSIX_SUCCESS_(posix_call) \
-  if (const int gtest_error = (posix_call)) \
-    GTEST_LOG_(FATAL) << #posix_call << "failed with error " \
-                      << gtest_error
-
-// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
-//
-// Use ImplicitCast_ as a safe version of static_cast for upcasting in
-// the type hierarchy (e.g. casting a Foo* to a SuperclassOfFoo* or a
-// const Foo*).  When you use ImplicitCast_, the compiler checks that
-// the cast is safe.  Such explicit ImplicitCast_s are necessary in
-// surprisingly many situations where C++ demands an exact type match
-// instead of an argument type convertable to a target type.
-//
-// The syntax for using ImplicitCast_ is the same as for static_cast:
-//
-//   ImplicitCast_<ToType>(expr)
-//
-// ImplicitCast_ would have been part of the C++ standard library,
-// but the proposal was submitted too late.  It will probably make
-// its way into the language in the future.
-//
-// This relatively ugly name is intentional. It prevents clashes with
-// similar functions users may have (e.g., implicit_cast). The internal
-// namespace alone is not enough because the function can be found by ADL.
-template<typename To>
-inline To ImplicitCast_(To x) { return x; }
-
-// When you upcast (that is, cast a pointer from type Foo to type
-// SuperclassOfFoo), it's fine to use ImplicitCast_<>, since upcasts
-// always succeed.  When you downcast (that is, cast a pointer from
-// type Foo to type SubclassOfFoo), static_cast<> isn't safe, because
-// how do you know the pointer is really of type SubclassOfFoo?  It
-// could be a bare Foo, or of type DifferentSubclassOfFoo.  Thus,
-// when you downcast, you should use this macro.  In debug mode, we
-// use dynamic_cast<> to double-check the downcast is legal (we die
-// if it's not).  In normal mode, we do the efficient static_cast<>
-// instead.  Thus, it's important to test in debug mode to make sure
-// the cast is legal!
-//    This is the only place in the code we should use dynamic_cast<>.
-// In particular, you SHOULDN'T be using dynamic_cast<> in order to
-// do RTTI (eg code like this:
-//    if (dynamic_cast<Subclass1>(foo)) HandleASubclass1Object(foo);
-//    if (dynamic_cast<Subclass2>(foo)) HandleASubclass2Object(foo);
-// You should design the code some other way not to need this.
-//
-// This relatively ugly name is intentional. It prevents clashes with
-// similar functions users may have (e.g., down_cast). The internal
-// namespace alone is not enough because the function can be found by ADL.
-template<typename To, typename From>  // use like this: DownCast_<T*>(foo);
-inline To DownCast_(From* f) {  // so we only accept pointers
-  // Ensures that To is a sub-type of From *.  This test is here only
-  // for compile-time type checking, and has no overhead in an
-  // optimized build at run-time, as it will be optimized away
-  // completely.
-  if (false) {
-    const To to = NULL;
-    ::testing::internal::ImplicitCast_<From*>(to);
-  }
-
-#if GTEST_HAS_RTTI
-  // RTTI: debug mode only!
-  GTEST_CHECK_(f == NULL || dynamic_cast<To>(f) != NULL);
-#endif
-  return static_cast<To>(f);
-}
-
-// Downcasts the pointer of type Base to Derived.
-// Derived must be a subclass of Base. The parameter MUST
-// point to a class of type Derived, not any subclass of it.
-// When RTTI is available, the function performs a runtime
-// check to enforce this.
-template <class Derived, class Base>
-Derived* CheckedDowncastToActualType(Base* base) {
-#if GTEST_HAS_RTTI
-  GTEST_CHECK_(typeid(*base) == typeid(Derived));
-  return dynamic_cast<Derived*>(base);  // NOLINT
-#else
-  return static_cast<Derived*>(base);  // Poor man's downcast.
-#endif
-}
-
-#if GTEST_HAS_STREAM_REDIRECTION
-
-// Defines the stderr capturer:
-//   CaptureStdout     - starts capturing stdout.
-//   GetCapturedStdout - stops capturing stdout and returns the captured string.
-//   CaptureStderr     - starts capturing stderr.
-//   GetCapturedStderr - stops capturing stderr and returns the captured string.
-//
-GTEST_API_ void CaptureStdout();
-GTEST_API_ String GetCapturedStdout();
-GTEST_API_ void CaptureStderr();
-GTEST_API_ String GetCapturedStderr();
-
-#endif  // GTEST_HAS_STREAM_REDIRECTION
-
-
-#if GTEST_HAS_DEATH_TEST
-
-// A copy of all command line arguments.  Set by InitGoogleTest().
-extern ::std::vector<String> g_argvs;
-
-// GTEST_HAS_DEATH_TEST implies we have ::std::string.
-const ::std::vector<String>& GetArgvs();
-
-#endif  // GTEST_HAS_DEATH_TEST
-
-// Defines synchronization primitives.
-
-#if GTEST_HAS_PTHREAD
-
-// Sleeps for (roughly) n milli-seconds.  This function is only for
-// testing Google Test's own constructs.  Don't use it in user tests,
-// either directly or indirectly.
-inline void SleepMilliseconds(int n) {
-  const timespec time = {
-    0,                  // 0 seconds.
-    n * 1000L * 1000L,  // And n ms.
-  };
-  nanosleep(&time, NULL);
-}
-
-// Allows a controller thread to pause execution of newly created
-// threads until notified.  Instances of this class must be created
-// and destroyed in the controller thread.
-//
-// This class is only for testing Google Test's own constructs. Do not
-// use it in user tests, either directly or indirectly.
-class Notification {
- public:
-  Notification() : notified_(false) {}
-
-  // Notifies all threads created with this notification to start. Must
-  // be called from the controller thread.
-  void Notify() { notified_ = true; }
-
-  // Blocks until the controller thread notifies. Must be called from a test
-  // thread.
-  void WaitForNotification() {
-    while(!notified_) {
-      SleepMilliseconds(10);
-    }
-  }
-
- private:
-  volatile bool notified_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification);
-};
-
-// As a C-function, ThreadFuncWithCLinkage cannot be templated itself.
-// Consequently, it cannot select a correct instantiation of ThreadWithParam
-// in order to call its Run(). Introducing ThreadWithParamBase as a
-// non-templated base class for ThreadWithParam allows us to bypass this
-// problem.
-class ThreadWithParamBase {
- public:
-  virtual ~ThreadWithParamBase() {}
-  virtual void Run() = 0;
-};
-
-// pthread_create() accepts a pointer to a function type with the C linkage.
-// According to the Standard (7.5/1), function types with different linkages
-// are different even if they are otherwise identical.  Some compilers (for
-// example, SunStudio) treat them as different types.  Since class methods
-// cannot be defined with C-linkage we need to define a free C-function to
-// pass into pthread_create().
-extern "C" inline void* ThreadFuncWithCLinkage(void* thread) {
-  static_cast<ThreadWithParamBase*>(thread)->Run();
-  return NULL;
-}
-
-// Helper class for testing Google Test's multi-threading constructs.
-// To use it, write:
-//
-//   void ThreadFunc(int param) { /* Do things with param */ }
-//   Notification thread_can_start;
-//   ...
-//   // The thread_can_start parameter is optional; you can supply NULL.
-//   ThreadWithParam<int> thread(&ThreadFunc, 5, &thread_can_start);
-//   thread_can_start.Notify();
-//
-// These classes are only for testing Google Test's own constructs. Do
-// not use them in user tests, either directly or indirectly.
-template <typename T>
-class ThreadWithParam : public ThreadWithParamBase {
- public:
-  typedef void (*UserThreadFunc)(T);
-
-  ThreadWithParam(
-      UserThreadFunc func, T param, Notification* thread_can_start)
-      : func_(func),
-        param_(param),
-        thread_can_start_(thread_can_start),
-        finished_(false) {
-    ThreadWithParamBase* const base = this;
-    // The thread can be created only after all fields except thread_
-    // have been initialized.
-    GTEST_CHECK_POSIX_SUCCESS_(
-        pthread_create(&thread_, 0, &ThreadFuncWithCLinkage, base));
-  }
-  ~ThreadWithParam() { Join(); }
-
-  void Join() {
-    if (!finished_) {
-      GTEST_CHECK_POSIX_SUCCESS_(pthread_join(thread_, 0));
-      finished_ = true;
-    }
-  }
-
-  virtual void Run() {
-    if (thread_can_start_ != NULL)
-      thread_can_start_->WaitForNotification();
-    func_(param_);
-  }
-
- private:
-  const UserThreadFunc func_;  // User-supplied thread function.
-  const T param_;  // User-supplied parameter to the thread function.
-  // When non-NULL, used to block execution until the controller thread
-  // notifies.
-  Notification* const thread_can_start_;
-  bool finished_;  // true iff we know that the thread function has finished.
-  pthread_t thread_;  // The native thread object.
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam);
-};
-
-// MutexBase and Mutex implement mutex on pthreads-based platforms. They
-// are used in conjunction with class MutexLock:
-//
-//   Mutex mutex;
-//   ...
-//   MutexLock lock(&mutex);  // Acquires the mutex and releases it at the end
-//                            // of the current scope.
-//
-// MutexBase implements behavior for both statically and dynamically
-// allocated mutexes.  Do not use MutexBase directly.  Instead, write
-// the following to define a static mutex:
-//
-//   GTEST_DEFINE_STATIC_MUTEX_(g_some_mutex);
-//
-// You can forward declare a static mutex like this:
-//
-//   GTEST_DECLARE_STATIC_MUTEX_(g_some_mutex);
-//
-// To create a dynamic mutex, just define an object of type Mutex.
-class MutexBase {
- public:
-  // Acquires this mutex.
-  void Lock() {
-    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_lock(&mutex_));
-    owner_ = pthread_self();
-  }
-
-  // Releases this mutex.
-  void Unlock() {
-    // We don't protect writing to owner_ here, as it's the caller's
-    // responsibility to ensure that the current thread holds the
-    // mutex when this is called.
-    owner_ = 0;
-    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_unlock(&mutex_));
-  }
-
-  // Does nothing if the current thread holds the mutex. Otherwise, crashes
-  // with high probability.
-  void AssertHeld() const {
-    GTEST_CHECK_(owner_ == pthread_self())
-        << "The current thread is not holding the mutex @" << this;
-  }
-
-  // A static mutex may be used before main() is entered.  It may even
-  // be used before the dynamic initialization stage.  Therefore we
-  // must be able to initialize a static mutex object at link time.
-  // This means MutexBase has to be a POD and its member variables
-  // have to be public.
- public:
-  pthread_mutex_t mutex_;  // The underlying pthread mutex.
-  pthread_t owner_;  // The thread holding the mutex; 0 means no one holds it.
-};
-
-// Forward-declares a static mutex.
-# define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
-    extern ::testing::internal::MutexBase mutex
-
-// Defines and statically (i.e. at link time) initializes a static mutex.
-# define GTEST_DEFINE_STATIC_MUTEX_(mutex) \
-    ::testing::internal::MutexBase mutex = { PTHREAD_MUTEX_INITIALIZER, 0 }
-
-// The Mutex class can only be used for mutexes created at runtime. It
-// shares its API with MutexBase otherwise.
-class Mutex : public MutexBase {
- public:
-  Mutex() {
-    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, NULL));
-    owner_ = 0;
-  }
-  ~Mutex() {
-    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&mutex_));
-  }
-
- private:
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex);
-};
-
-// We cannot name this class MutexLock as the ctor declaration would
-// conflict with a macro named MutexLock, which is defined on some
-// platforms.  Hence the typedef trick below.
-class GTestMutexLock {
- public:
-  explicit GTestMutexLock(MutexBase* mutex)
-      : mutex_(mutex) { mutex_->Lock(); }
-
-  ~GTestMutexLock() { mutex_->Unlock(); }
-
- private:
-  MutexBase* const mutex_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock);
-};
-
-typedef GTestMutexLock MutexLock;
-
-// Helpers for ThreadLocal.
-
-// pthread_key_create() requires DeleteThreadLocalValue() to have
-// C-linkage.  Therefore it cannot be templatized to access
-// ThreadLocal<T>.  Hence the need for class
-// ThreadLocalValueHolderBase.
-class ThreadLocalValueHolderBase {
- public:
-  virtual ~ThreadLocalValueHolderBase() {}
-};
-
-// Called by pthread to delete thread-local data stored by
-// pthread_setspecific().
-extern "C" inline void DeleteThreadLocalValue(void* value_holder) {
-  delete static_cast<ThreadLocalValueHolderBase*>(value_holder);
-}
-
-// Implements thread-local storage on pthreads-based systems.
-//
-//   // Thread 1
-//   ThreadLocal<int> tl(100);  // 100 is the default value for each thread.
-//
-//   // Thread 2
-//   tl.set(150);  // Changes the value for thread 2 only.
-//   EXPECT_EQ(150, tl.get());
-//
-//   // Thread 1
-//   EXPECT_EQ(100, tl.get());  // In thread 1, tl has the original value.
-//   tl.set(200);
-//   EXPECT_EQ(200, tl.get());
-//
-// The template type argument T must have a public copy constructor.
-// In addition, the default ThreadLocal constructor requires T to have
-// a public default constructor.
-//
-// An object managed for a thread by a ThreadLocal instance is deleted
-// when the thread exits.  Or, if the ThreadLocal instance dies in
-// that thread, when the ThreadLocal dies.  It's the user's
-// responsibility to ensure that all other threads using a ThreadLocal
-// have exited when it dies, or the per-thread objects for those
-// threads will not be deleted.
-//
-// Google Test only uses global ThreadLocal objects.  That means they
-// will die after main() has returned.  Therefore, no per-thread
-// object managed by Google Test will be leaked as long as all threads
-// using Google Test have exited when main() returns.
-template <typename T>
-class ThreadLocal {
- public:
-  ThreadLocal() : key_(CreateKey()),
-                  default_() {}
-  explicit ThreadLocal(const T& value) : key_(CreateKey()),
-                                         default_(value) {}
-
-  ~ThreadLocal() {
-    // Destroys the managed object for the current thread, if any.
-    DeleteThreadLocalValue(pthread_getspecific(key_));
-
-    // Releases resources associated with the key.  This will *not*
-    // delete managed objects for other threads.
-    GTEST_CHECK_POSIX_SUCCESS_(pthread_key_delete(key_));
-  }
-
-  T* pointer() { return GetOrCreateValue(); }
-  const T* pointer() const { return GetOrCreateValue(); }
-  const T& get() const { return *pointer(); }
-  void set(const T& value) { *pointer() = value; }
-
- private:
-  // Holds a value of type T.
-  class ValueHolder : public ThreadLocalValueHolderBase {
-   public:
-    explicit ValueHolder(const T& value) : value_(value) {}
-
-    T* pointer() { return &value_; }
-
-   private:
-    T value_;
-    GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder);
-  };
-
-  static pthread_key_t CreateKey() {
-    pthread_key_t key;
-    // When a thread exits, DeleteThreadLocalValue() will be called on
-    // the object managed for that thread.
-    GTEST_CHECK_POSIX_SUCCESS_(
-        pthread_key_create(&key, &DeleteThreadLocalValue));
-    return key;
-  }
-
-  T* GetOrCreateValue() const {
-    ThreadLocalValueHolderBase* const holder =
-        static_cast<ThreadLocalValueHolderBase*>(pthread_getspecific(key_));
-    if (holder != NULL) {
-      return CheckedDowncastToActualType<ValueHolder>(holder)->pointer();
-    }
-
-    ValueHolder* const new_holder = new ValueHolder(default_);
-    ThreadLocalValueHolderBase* const holder_base = new_holder;
-    GTEST_CHECK_POSIX_SUCCESS_(pthread_setspecific(key_, holder_base));
-    return new_holder->pointer();
-  }
-
-  // A key pthreads uses for looking up per-thread values.
-  const pthread_key_t key_;
-  const T default_;  // The default value for each thread.
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal);
-};
-
-# define GTEST_IS_THREADSAFE 1
-
-#else  // GTEST_HAS_PTHREAD
-
-// A dummy implementation of synchronization primitives (mutex, lock,
-// and thread-local variable).  Necessary for compiling Google Test where
-// mutex is not supported - using Google Test in multiple threads is not
-// supported on such platforms.
-
-class Mutex {
- public:
-  Mutex() {}
-  void AssertHeld() const {}
-};
-
-# define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
-  extern ::testing::internal::Mutex mutex
-
-# define GTEST_DEFINE_STATIC_MUTEX_(mutex) ::testing::internal::Mutex mutex
-
-class GTestMutexLock {
- public:
-  explicit GTestMutexLock(Mutex*) {}  // NOLINT
-};
-
-typedef GTestMutexLock MutexLock;
-
-template <typename T>
-class ThreadLocal {
- public:
-  ThreadLocal() : value_() {}
-  explicit ThreadLocal(const T& value) : value_(value) {}
-  T* pointer() { return &value_; }
-  const T* pointer() const { return &value_; }
-  const T& get() const { return value_; }
-  void set(const T& value) { value_ = value; }
- private:
-  T value_;
-};
-
-// The above synchronization primitives have dummy implementations.
-// Therefore Google Test is not thread-safe.
-# define GTEST_IS_THREADSAFE 0
-
-#endif  // GTEST_HAS_PTHREAD
-
-// Returns the number of threads running in the process, or 0 to indicate that
-// we cannot detect it.
-GTEST_API_ size_t GetThreadCount();
-
-// Passing non-POD classes through ellipsis (...) crashes the ARM
-// compiler and generates a warning in Sun Studio.  The Nokia Symbian
-// and the IBM XL C/C++ compiler try to instantiate a copy constructor
-// for objects passed through ellipsis (...), failing for uncopyable
-// objects.  We define this to ensure that only POD is passed through
-// ellipsis on these systems.
-#if defined(__SYMBIAN32__) || defined(__IBMCPP__) || defined(__SUNPRO_CC)
-// We lose support for NULL detection where the compiler doesn't like
-// passing non-POD classes through ellipsis (...).
-# define GTEST_ELLIPSIS_NEEDS_POD_ 1
-#else
-# define GTEST_CAN_COMPARE_NULL 1
-#endif
-
-// The Nokia Symbian and IBM XL C/C++ compilers cannot decide between
-// const T& and const T* in a function template.  These compilers
-// _can_ decide between class template specializations for T and T*,
-// so a tr1::type_traits-like is_pointer works.
-#if defined(__SYMBIAN32__) || defined(__IBMCPP__)
-# define GTEST_NEEDS_IS_POINTER_ 1
-#endif
-
-template <bool bool_value>
-struct bool_constant {
-  typedef bool_constant<bool_value> type;
-  static const bool value = bool_value;
-};
-template <bool bool_value> const bool bool_constant<bool_value>::value;
-
-typedef bool_constant<false> false_type;
-typedef bool_constant<true> true_type;
-
-template <typename T>
-struct is_pointer : public false_type {};
-
-template <typename T>
-struct is_pointer<T*> : public true_type {};
-
-template <typename Iterator>
-struct IteratorTraits {
-  typedef typename Iterator::value_type value_type;
-};
-
-template <typename T>
-struct IteratorTraits<T*> {
-  typedef T value_type;
-};
-
-template <typename T>
-struct IteratorTraits<const T*> {
-  typedef T value_type;
-};
-
-#if GTEST_OS_WINDOWS
-# define GTEST_PATH_SEP_ "\\"
-# define GTEST_HAS_ALT_PATH_SEP_ 1
-// The biggest signed integer type the compiler supports.
-typedef __int64 BiggestInt;
-#else
-# define GTEST_PATH_SEP_ "/"
-# define GTEST_HAS_ALT_PATH_SEP_ 0
-typedef long long BiggestInt;  // NOLINT
-#endif  // GTEST_OS_WINDOWS
-
-// Utilities for char.
-
-// isspace(int ch) and friends accept an unsigned char or EOF.  char
-// may be signed, depending on the compiler (or compiler flags).
-// Therefore we need to cast a char to unsigned char before calling
-// isspace(), etc.
-
-inline bool IsAlpha(char ch) {
-  return isalpha(static_cast<unsigned char>(ch)) != 0;
-}
-inline bool IsAlNum(char ch) {
-  return isalnum(static_cast<unsigned char>(ch)) != 0;
-}
-inline bool IsDigit(char ch) {
-  return isdigit(static_cast<unsigned char>(ch)) != 0;
-}
-inline bool IsLower(char ch) {
-  return islower(static_cast<unsigned char>(ch)) != 0;
-}
-inline bool IsSpace(char ch) {
-  return isspace(static_cast<unsigned char>(ch)) != 0;
-}
-inline bool IsUpper(char ch) {
-  return isupper(static_cast<unsigned char>(ch)) != 0;
-}
-inline bool IsXDigit(char ch) {
-  return isxdigit(static_cast<unsigned char>(ch)) != 0;
-}
-
-inline char ToLower(char ch) {
-  return static_cast<char>(tolower(static_cast<unsigned char>(ch)));
-}
-inline char ToUpper(char ch) {
-  return static_cast<char>(toupper(static_cast<unsigned char>(ch)));
-}
-
-// The testing::internal::posix namespace holds wrappers for common
-// POSIX functions.  These wrappers hide the differences between
-// Windows/MSVC and POSIX systems.  Since some compilers define these
-// standard functions as macros, the wrapper cannot have the same name
-// as the wrapped function.
-
-namespace posix {
-
-// Functions with a different name on Windows.
-
-#if GTEST_OS_WINDOWS
-
-typedef struct _stat StatStruct;
-
-# ifdef __BORLANDC__
-inline int IsATTY(int fd) { return isatty(fd); }
-inline int StrCaseCmp(const char* s1, const char* s2) {
-  return stricmp(s1, s2);
-}
-inline char* StrDup(const char* src) { return strdup(src); }
-# else  // !__BORLANDC__
-#  if GTEST_OS_WINDOWS_MOBILE
-inline int IsATTY(int /* fd */) { return 0; }
-#  else
-inline int IsATTY(int fd) { return _isatty(fd); }
-#  endif  // GTEST_OS_WINDOWS_MOBILE
-inline int StrCaseCmp(const char* s1, const char* s2) {
-  return _stricmp(s1, s2);
-}
-inline char* StrDup(const char* src) { return _strdup(src); }
-# endif  // __BORLANDC__
-
-# if GTEST_OS_WINDOWS_MOBILE
-inline int FileNo(FILE* file) { return reinterpret_cast<int>(_fileno(file)); }
-// Stat(), RmDir(), and IsDir() are not needed on Windows CE at this
-// time and thus not defined there.
-# else
-inline int FileNo(FILE* file) { return _fileno(file); }
-inline int Stat(const char* path, StatStruct* buf) { return _stat(path, buf); }
-inline int RmDir(const char* dir) { return _rmdir(dir); }
-inline bool IsDir(const StatStruct& st) {
-  return (_S_IFDIR & st.st_mode) != 0;
-}
-# endif  // GTEST_OS_WINDOWS_MOBILE
-
-#else
-
-typedef struct stat StatStruct;
-
-inline int FileNo(FILE* file) { return fileno(file); }
-inline int IsATTY(int fd) { return isatty(fd); }
-inline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); }
-inline int StrCaseCmp(const char* s1, const char* s2) {
-  return strcasecmp(s1, s2);
-}
-inline char* StrDup(const char* src) { return strdup(src); }
-inline int RmDir(const char* dir) { return rmdir(dir); }
-inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
-
-#endif  // GTEST_OS_WINDOWS
-
-// Functions deprecated by MSVC 8.0.
-
-#ifdef _MSC_VER
-// Temporarily disable warning 4996 (deprecated function).
-# pragma warning(push)
-# pragma warning(disable:4996)
-#endif
-
-inline const char* StrNCpy(char* dest, const char* src, size_t n) {
-  return strncpy(dest, src, n);
-}
-
-// ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and
-// StrError() aren't needed on Windows CE at this time and thus not
-// defined there.
-
-#if !GTEST_OS_WINDOWS_MOBILE
-inline int ChDir(const char* dir) { return chdir(dir); }
-#endif
-inline FILE* FOpen(const char* path, const char* mode) {
-  return fopen(path, mode);
-}
-#if !GTEST_OS_WINDOWS_MOBILE
-inline FILE *FReopen(const char* path, const char* mode, FILE* stream) {
-  return freopen(path, mode, stream);
-}
-inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }
-#endif
-inline int FClose(FILE* fp) { return fclose(fp); }
-#if !GTEST_OS_WINDOWS_MOBILE
-inline int Read(int fd, void* buf, unsigned int count) {
-  return static_cast<int>(read(fd, buf, count));
-}
-inline int Write(int fd, const void* buf, unsigned int count) {
-  return static_cast<int>(write(fd, buf, count));
-}
-inline int Close(int fd) { return close(fd); }
-inline const char* StrError(int errnum) { return strerror(errnum); }
-#endif
-inline const char* GetEnv(const char* name) {
-#if GTEST_OS_WINDOWS_MOBILE
-  // We are on Windows CE, which has no environment variables.
-  return NULL;
-#elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9)
-  // Environment variables which we programmatically clear will be set to the
-  // empty string rather than unset (NULL).  Handle that case.
-  const char* const env = getenv(name);
-  return (env != NULL && env[0] != '\0') ? env : NULL;
-#else
-  return getenv(name);
-#endif
-}
-
-#ifdef _MSC_VER
-# pragma warning(pop)  // Restores the warning state.
-#endif
-
-#if GTEST_OS_WINDOWS_MOBILE
-// Windows CE has no C library. The abort() function is used in
-// several places in Google Test. This implementation provides a reasonable
-// imitation of standard behaviour.
-void Abort();
-#else
-inline void Abort() { abort(); }
-#endif  // GTEST_OS_WINDOWS_MOBILE
-
-}  // namespace posix
-
-// The maximum number a BiggestInt can represent.  This definition
-// works no matter BiggestInt is represented in one's complement or
-// two's complement.
-//
-// We cannot rely on numeric_limits in STL, as __int64 and long long
-// are not part of standard C++ and numeric_limits doesn't need to be
-// defined for them.
-const BiggestInt kMaxBiggestInt =
-    ~(static_cast<BiggestInt>(1) << (8*sizeof(BiggestInt) - 1));
-
-// This template class serves as a compile-time function from size to
-// type.  It maps a size in bytes to a primitive type with that
-// size. e.g.
-//
-//   TypeWithSize<4>::UInt
-//
-// is typedef-ed to be unsigned int (unsigned integer made up of 4
-// bytes).
-//
-// Such functionality should belong to STL, but I cannot find it
-// there.
-//
-// Google Test uses this class in the implementation of floating-point
-// comparison.
-//
-// For now it only handles UInt (unsigned int) as that's all Google Test
-// needs.  Other types can be easily added in the future if need
-// arises.
-template <size_t size>
-class TypeWithSize {
- public:
-  // This prevents the user from using TypeWithSize<N> with incorrect
-  // values of N.
-  typedef void UInt;
-};
-
-// The specialization for size 4.
-template <>
-class TypeWithSize<4> {
- public:
-  // unsigned int has size 4 in both gcc and MSVC.
-  //
-  // As base/basictypes.h doesn't compile on Windows, we cannot use
-  // uint32, uint64, and etc here.
-  typedef int Int;
-  typedef unsigned int UInt;
-};
-
-// The specialization for size 8.
-template <>
-class TypeWithSize<8> {
- public:
-
-#if GTEST_OS_WINDOWS
-  typedef __int64 Int;
-  typedef unsigned __int64 UInt;
-#else
-  typedef long long Int;  // NOLINT
-  typedef unsigned long long UInt;  // NOLINT
-#endif  // GTEST_OS_WINDOWS
-};
-
-// Integer types of known sizes.
-typedef TypeWithSize<4>::Int Int32;
-typedef TypeWithSize<4>::UInt UInt32;
-typedef TypeWithSize<8>::Int Int64;
-typedef TypeWithSize<8>::UInt UInt64;
-typedef TypeWithSize<8>::Int TimeInMillis;  // Represents time in milliseconds.
-
-// Utilities for command line flags and environment variables.
-
-// Macro for referencing flags.
-#define GTEST_FLAG(name) FLAGS_gtest_##name
-
-// Macros for declaring flags.
-#define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name)
-#define GTEST_DECLARE_int32_(name) \
-    GTEST_API_ extern ::testing::internal::Int32 GTEST_FLAG(name)
-#define GTEST_DECLARE_string_(name) \
-    GTEST_API_ extern ::testing::internal::String GTEST_FLAG(name)
-
-// Macros for defining flags.
-#define GTEST_DEFINE_bool_(name, default_val, doc) \
-    GTEST_API_ bool GTEST_FLAG(name) = (default_val)
-#define GTEST_DEFINE_int32_(name, default_val, doc) \
-    GTEST_API_ ::testing::internal::Int32 GTEST_FLAG(name) = (default_val)
-#define GTEST_DEFINE_string_(name, default_val, doc) \
-    GTEST_API_ ::testing::internal::String GTEST_FLAG(name) = (default_val)
-
-// Parses 'str' for a 32-bit signed integer.  If successful, writes the result
-// to *value and returns true; otherwise leaves *value unchanged and returns
-// false.
-// TODO(chandlerc): Find a better way to refactor flag and environment parsing
-// out of both gtest-port.cc and gtest.cc to avoid exporting this utility
-// function.
-bool ParseInt32(const Message& src_text, const char* str, Int32* value);
-
-// Parses a bool/Int32/string from the environment variable
-// corresponding to the given Google Test flag.
-bool BoolFromGTestEnv(const char* flag, bool default_val);
-GTEST_API_ Int32 Int32FromGTestEnv(const char* flag, Int32 default_val);
-const char* StringFromGTestEnv(const char* flag, const char* default_val);
-
-}  // namespace internal
-}  // namespace testing
-
-#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
-
-#if GTEST_OS_LINUX
-# include <stdlib.h>
-# include <sys/types.h>
-# include <sys/wait.h>
-# include <unistd.h>
-#endif  // GTEST_OS_LINUX
-
-#include <ctype.h>
-#include <string.h>
-#include <iomanip>
-#include <limits>
-#include <set>
-
-// Copyright 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Authors: wan at google.com (Zhanyong Wan), eefacm at gmail.com (Sean Mcafee)
-//
-// The Google C++ Testing Framework (Google Test)
-//
-// This header file declares the String class and functions used internally by
-// Google Test.  They are subject to change without notice. They should not used
-// by code external to Google Test.
-//
-// This header file is #included by <gtest/internal/gtest-internal.h>.
-// It should not be #included by other files.
-
-#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
-#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
-
-#ifdef __BORLANDC__
-// string.h is not guaranteed to provide strcpy on C++ Builder.
-# include <mem.h>
-#endif
-
-#include <string.h>
-
-#include <string>
-
-namespace testing {
-namespace internal {
-
-// String - a UTF-8 string class.
-//
-// For historic reasons, we don't use std::string.
-//
-// TODO(wan at google.com): replace this class with std::string or
-// implement it in terms of the latter.
-//
-// Note that String can represent both NULL and the empty string,
-// while std::string cannot represent NULL.
-//
-// NULL and the empty string are considered different.  NULL is less
-// than anything (including the empty string) except itself.
-//
-// This class only provides minimum functionality necessary for
-// implementing Google Test.  We do not intend to implement a full-fledged
-// string class here.
-//
-// Since the purpose of this class is to provide a substitute for
-// std::string on platforms where it cannot be used, we define a copy
-// constructor and assignment operators such that we don't need
-// conditional compilation in a lot of places.
-//
-// In order to make the representation efficient, the d'tor of String
-// is not virtual.  Therefore DO NOT INHERIT FROM String.
-class GTEST_API_ String {
- public:
-  // Static utility methods
-
-  // Returns the input enclosed in double quotes if it's not NULL;
-  // otherwise returns "(null)".  For example, "\"Hello\"" is returned
-  // for input "Hello".
-  //
-  // This is useful for printing a C string in the syntax of a literal.
-  //
-  // Known issue: escape sequences are not handled yet.
-  static String ShowCStringQuoted(const char* c_str);
-
-  // Clones a 0-terminated C string, allocating memory using new.  The
-  // caller is responsible for deleting the return value using
-  // delete[].  Returns the cloned string, or NULL if the input is
-  // NULL.
-  //
-  // This is different from strdup() in string.h, which allocates
-  // memory using malloc().
-  static const char* CloneCString(const char* c_str);
-
-#if GTEST_OS_WINDOWS_MOBILE
-  // Windows CE does not have the 'ANSI' versions of Win32 APIs. To be
-  // able to pass strings to Win32 APIs on CE we need to convert them
-  // to 'Unicode', UTF-16.
-
-  // Creates a UTF-16 wide string from the given ANSI string, allocating
-  // memory using new. The caller is responsible for deleting the return
-  // value using delete[]. Returns the wide string, or NULL if the
-  // input is NULL.
-  //
-  // The wide string is created using the ANSI codepage (CP_ACP) to
-  // match the behaviour of the ANSI versions of Win32 calls and the
-  // C runtime.
-  static LPCWSTR AnsiToUtf16(const char* c_str);
-
-  // Creates an ANSI string from the given wide string, allocating
-  // memory using new. The caller is responsible for deleting the return
-  // value using delete[]. Returns the ANSI string, or NULL if the
-  // input is NULL.
-  //
-  // The returned string is created using the ANSI codepage (CP_ACP) to
-  // match the behaviour of the ANSI versions of Win32 calls and the
-  // C runtime.
-  static const char* Utf16ToAnsi(LPCWSTR utf16_str);
-#endif
-
-  // Compares two C strings.  Returns true iff they have the same content.
-  //
-  // Unlike strcmp(), this function can handle NULL argument(s).  A
-  // NULL C string is considered different to any non-NULL C string,
-  // including the empty string.
-  static bool CStringEquals(const char* lhs, const char* rhs);
-
-  // Converts a wide C string to a String using the UTF-8 encoding.
-  // NULL will be converted to "(null)".  If an error occurred during
-  // the conversion, "(failed to convert from wide string)" is
-  // returned.
-  static String ShowWideCString(const wchar_t* wide_c_str);
-
-  // Similar to ShowWideCString(), except that this function encloses
-  // the converted string in double quotes.
-  static String ShowWideCStringQuoted(const wchar_t* wide_c_str);
-
-  // Compares two wide C strings.  Returns true iff they have the same
-  // content.
-  //
-  // Unlike wcscmp(), this function can handle NULL argument(s).  A
-  // NULL C string is considered different to any non-NULL C string,
-  // including the empty string.
-  static bool WideCStringEquals(const wchar_t* lhs, const wchar_t* rhs);
-
-  // Compares two C strings, ignoring case.  Returns true iff they
-  // have the same content.
-  //
-  // Unlike strcasecmp(), this function can handle NULL argument(s).
-  // A NULL C string is considered different to any non-NULL C string,
-  // including the empty string.
-  static bool CaseInsensitiveCStringEquals(const char* lhs,
-                                           const char* rhs);
-
-  // Compares two wide C strings, ignoring case.  Returns true iff they
-  // have the same content.
-  //
-  // Unlike wcscasecmp(), this function can handle NULL argument(s).
-  // A NULL C string is considered different to any non-NULL wide C string,
-  // including the empty string.
-  // NB: The implementations on different platforms slightly differ.
-  // On windows, this method uses _wcsicmp which compares according to LC_CTYPE
-  // environment variable. On GNU platform this method uses wcscasecmp
-  // which compares according to LC_CTYPE category of the current locale.
-  // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the
-  // current locale.
-  static bool CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
-                                               const wchar_t* rhs);
-
-  // Formats a list of arguments to a String, using the same format
-  // spec string as for printf.
-  //
-  // We do not use the StringPrintf class as it is not universally
-  // available.
-  //
-  // The result is limited to 4096 characters (including the tailing
-  // 0).  If 4096 characters are not enough to format the input,
-  // "<buffer exceeded>" is returned.
-  static String Format(const char* format, ...);
-
-  // C'tors
-
-  // The default c'tor constructs a NULL string.
-  String() : c_str_(NULL), length_(0) {}
-
-  // Constructs a String by cloning a 0-terminated C string.
-  String(const char* a_c_str) {  // NOLINT
-    if (a_c_str == NULL) {
-      c_str_ = NULL;
-      length_ = 0;
-    } else {
-      ConstructNonNull(a_c_str, strlen(a_c_str));
-    }
-  }
-
-  // Constructs a String by copying a given number of chars from a
-  // buffer.  E.g. String("hello", 3) creates the string "hel",
-  // String("a\0bcd", 4) creates "a\0bc", String(NULL, 0) creates "",
-  // and String(NULL, 1) results in access violation.
-  String(const char* buffer, size_t a_length) {
-    ConstructNonNull(buffer, a_length);
-  }
-
-  // The copy c'tor creates a new copy of the string.  The two
-  // String objects do not share content.
-  String(const String& str) : c_str_(NULL), length_(0) { *this = str; }
-
-  // D'tor.  String is intended to be a final class, so the d'tor
-  // doesn't need to be virtual.
-  ~String() { delete[] c_str_; }
-
-  // Allows a String to be implicitly converted to an ::std::string or
-  // ::string, and vice versa.  Converting a String containing a NULL
-  // pointer to ::std::string or ::string is undefined behavior.
-  // Converting a ::std::string or ::string containing an embedded NUL
-  // character to a String will result in the prefix up to the first
-  // NUL character.
-  String(const ::std::string& str) {
-    ConstructNonNull(str.c_str(), str.length());
-  }
-
-  operator ::std::string() const { return ::std::string(c_str(), length()); }
-
-#if GTEST_HAS_GLOBAL_STRING
-  String(const ::string& str) {
-    ConstructNonNull(str.c_str(), str.length());
-  }
-
-  operator ::string() const { return ::string(c_str(), length()); }
-#endif  // GTEST_HAS_GLOBAL_STRING
-
-  // Returns true iff this is an empty string (i.e. "").
-  bool empty() const { return (c_str() != NULL) && (length() == 0); }
-
-  // Compares this with another String.
-  // Returns < 0 if this is less than rhs, 0 if this is equal to rhs, or > 0
-  // if this is greater than rhs.
-  int Compare(const String& rhs) const;
-
-  // Returns true iff this String equals the given C string.  A NULL
-  // string and a non-NULL string are considered not equal.
-  bool operator==(const char* a_c_str) const { return Compare(a_c_str) == 0; }
-
-  // Returns true iff this String is less than the given String.  A
-  // NULL string is considered less than "".
-  bool operator<(const String& rhs) const { return Compare(rhs) < 0; }
-
-  // Returns true iff this String doesn't equal the given C string.  A NULL
-  // string and a non-NULL string are considered not equal.
-  bool operator!=(const char* a_c_str) const { return !(*this == a_c_str); }
-
-  // Returns true iff this String ends with the given suffix.  *Any*
-  // String is considered to end with a NULL or empty suffix.
-  bool EndsWith(const char* suffix) const;
-
-  // Returns true iff this String ends with the given suffix, not considering
-  // case. Any String is considered to end with a NULL or empty suffix.
-  bool EndsWithCaseInsensitive(const char* suffix) const;
-
-  // Returns the length of the encapsulated string, or 0 if the
-  // string is NULL.
-  size_t length() const { return length_; }
-
-  // Gets the 0-terminated C string this String object represents.
-  // The String object still owns the string.  Therefore the caller
-  // should NOT delete the return value.
-  const char* c_str() const { return c_str_; }
-
-  // Assigns a C string to this object.  Self-assignment works.
-  const String& operator=(const char* a_c_str) {
-    return *this = String(a_c_str);
-  }
-
-  // Assigns a String object to this object.  Self-assignment works.
-  const String& operator=(const String& rhs) {
-    if (this != &rhs) {
-      delete[] c_str_;
-      if (rhs.c_str() == NULL) {
-        c_str_ = NULL;
-        length_ = 0;
-      } else {
-        ConstructNonNull(rhs.c_str(), rhs.length());
-      }
-    }
-
-    return *this;
-  }
-
- private:
-  // Constructs a non-NULL String from the given content.  This
-  // function can only be called when c_str_ has not been allocated.
-  // ConstructNonNull(NULL, 0) results in an empty string ("").
-  // ConstructNonNull(NULL, non_zero) is undefined behavior.
-  void ConstructNonNull(const char* buffer, size_t a_length) {
-    char* const str = new char[a_length + 1];
-    memcpy(str, buffer, a_length);
-    str[a_length] = '\0';
-    c_str_ = str;
-    length_ = a_length;
-  }
-
-  const char* c_str_;
-  size_t length_;
-};  // class String
-
-// Streams a String to an ostream.  Each '\0' character in the String
-// is replaced with "\\0".
-inline ::std::ostream& operator<<(::std::ostream& os, const String& str) {
-  if (str.c_str() == NULL) {
-    os << "(null)";
-  } else {
-    const char* const c_str = str.c_str();
-    for (size_t i = 0; i != str.length(); i++) {
-      if (c_str[i] == '\0') {
-        os << "\\0";
-      } else {
-        os << c_str[i];
-      }
-    }
-  }
-  return os;
-}
-
-// Gets the content of the stringstream's buffer as a String.  Each '\0'
-// character in the buffer is replaced with "\\0".
-GTEST_API_ String StringStreamToString(::std::stringstream* stream);
-
-// Converts a streamable value to a String.  A NULL pointer is
-// converted to "(null)".  When the input value is a ::string,
-// ::std::string, ::wstring, or ::std::wstring object, each NUL
-// character in it is replaced with "\\0".
-
-// Declared here but defined in gtest.h, so that it has access
-// to the definition of the Message class, required by the ARM
-// compiler.
-template <typename T>
-String StreamableToString(const T& streamable);
-
-}  // namespace internal
-}  // namespace testing
-
-#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
-// Copyright 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: keith.ray at gmail.com (Keith Ray)
-//
-// Google Test filepath utilities
-//
-// This header file declares classes and functions used internally by
-// Google Test.  They are subject to change without notice.
-//
-// This file is #included in <gtest/internal/gtest-internal.h>.
-// Do not include this header file separately!
-
-#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
-#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
-
-
-namespace testing {
-namespace internal {
-
-// FilePath - a class for file and directory pathname manipulation which
-// handles platform-specific conventions (like the pathname separator).
-// Used for helper functions for naming files in a directory for xml output.
-// Except for Set methods, all methods are const or static, which provides an
-// "immutable value object" -- useful for peace of mind.
-// A FilePath with a value ending in a path separator ("like/this/") represents
-// a directory, otherwise it is assumed to represent a file. In either case,
-// it may or may not represent an actual file or directory in the file system.
-// Names are NOT checked for syntax correctness -- no checking for illegal
-// characters, malformed paths, etc.
-
-class GTEST_API_ FilePath {
- public:
-  FilePath() : pathname_("") { }
-  FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) { }
-
-  explicit FilePath(const char* pathname) : pathname_(pathname) {
-    Normalize();
-  }
-
-  explicit FilePath(const String& pathname) : pathname_(pathname) {
-    Normalize();
-  }
-
-  FilePath& operator=(const FilePath& rhs) {
-    Set(rhs);
-    return *this;
-  }
-
-  void Set(const FilePath& rhs) {
-    pathname_ = rhs.pathname_;
-  }
-
-  String ToString() const { return pathname_; }
-  const char* c_str() const { return pathname_.c_str(); }
-
-  // Returns the current working directory, or "" if unsuccessful.
-  static FilePath GetCurrentDir();
-
-  // Given directory = "dir", base_name = "test", number = 0,
-  // extension = "xml", returns "dir/test.xml". If number is greater
-  // than zero (e.g., 12), returns "dir/test_12.xml".
-  // On Windows platform, uses \ as the separator rather than /.
-  static FilePath MakeFileName(const FilePath& directory,
-                               const FilePath& base_name,
-                               int number,
-                               const char* extension);
-
-  // Given directory = "dir", relative_path = "test.xml",
-  // returns "dir/test.xml".
-  // On Windows, uses \ as the separator rather than /.
-  static FilePath ConcatPaths(const FilePath& directory,
-                              const FilePath& relative_path);
-
-  // Returns a pathname for a file that does not currently exist. The pathname
-  // will be directory/base_name.extension or
-  // directory/base_name_<number>.extension if directory/base_name.extension
-  // already exists. The number will be incremented until a pathname is found
-  // that does not already exist.
-  // Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.
-  // There could be a race condition if two or more processes are calling this
-  // function at the same time -- they could both pick the same filename.
-  static FilePath GenerateUniqueFileName(const FilePath& directory,
-                                         const FilePath& base_name,
-                                         const char* extension);
-
-  // Returns true iff the path is NULL or "".
-  bool IsEmpty() const { return c_str() == NULL || *c_str() == '\0'; }
-
-  // If input name has a trailing separator character, removes it and returns
-  // the name, otherwise return the name string unmodified.
-  // On Windows platform, uses \ as the separator, other platforms use /.
-  FilePath RemoveTrailingPathSeparator() const;
-
-  // Returns a copy of the FilePath with the directory part removed.
-  // Example: FilePath("path/to/file").RemoveDirectoryName() returns
-  // FilePath("file"). If there is no directory part ("just_a_file"), it returns
-  // the FilePath unmodified. If there is no file part ("just_a_dir/") it
-  // returns an empty FilePath ("").
-  // On Windows platform, '\' is the path separator, otherwise it is '/'.
-  FilePath RemoveDirectoryName() const;
-
-  // RemoveFileName returns the directory path with the filename removed.
-  // Example: FilePath("path/to/file").RemoveFileName() returns "path/to/".
-  // If the FilePath is "a_file" or "/a_file", RemoveFileName returns
-  // FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does
-  // not have a file, like "just/a/dir/", it returns the FilePath unmodified.
-  // On Windows platform, '\' is the path separator, otherwise it is '/'.
-  FilePath RemoveFileName() const;
-
-  // Returns a copy of the FilePath with the case-insensitive extension removed.
-  // Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns
-  // FilePath("dir/file"). If a case-insensitive extension is not
-  // found, returns a copy of the original FilePath.
-  FilePath RemoveExtension(const char* extension) const;
-
-  // Creates directories so that path exists. Returns true if successful or if
-  // the directories already exist; returns false if unable to create
-  // directories for any reason. Will also return false if the FilePath does
-  // not represent a directory (that is, it doesn't end with a path separator).
-  bool CreateDirectoriesRecursively() const;
-
-  // Create the directory so that path exists. Returns true if successful or
-  // if the directory already exists; returns false if unable to create the
-  // directory for any reason, including if the parent directory does not
-  // exist. Not named "CreateDirectory" because that's a macro on Windows.
-  bool CreateFolder() const;
-
-  // Returns true if FilePath describes something in the file-system,
-  // either a file, directory, or whatever, and that something exists.
-  bool FileOrDirectoryExists() const;
-
-  // Returns true if pathname describes a directory in the file-system
-  // that exists.
-  bool DirectoryExists() const;
-
-  // Returns true if FilePath ends with a path separator, which indicates that
-  // it is intended to represent a directory. Returns false otherwise.
-  // This does NOT check that a directory (or file) actually exists.
-  bool IsDirectory() const;
-
-  // Returns true if pathname describes a root directory. (Windows has one
-  // root directory per disk drive.)
-  bool IsRootDirectory() const;
-
-  // Returns true if pathname describes an absolute path.
-  bool IsAbsolutePath() const;
-
- private:
-  // Replaces multiple consecutive separators with a single separator.
-  // For example, "bar///foo" becomes "bar/foo". Does not eliminate other
-  // redundancies that might be in a pathname involving "." or "..".
-  //
-  // A pathname with multiple consecutive separators may occur either through
-  // user error or as a result of some scripts or APIs that generate a pathname
-  // with a trailing separator. On other platforms the same API or script
-  // may NOT generate a pathname with a trailing "/". Then elsewhere that
-  // pathname may have another "/" and pathname components added to it,
-  // without checking for the separator already being there.
-  // The script language and operating system may allow paths like "foo//bar"
-  // but some of the functions in FilePath will not handle that correctly. In
-  // particular, RemoveTrailingPathSeparator() only removes one separator, and
-  // it is called in CreateDirectoriesRecursively() assuming that it will change
-  // a pathname from directory syntax (trailing separator) to filename syntax.
-  //
-  // On Windows this method also replaces the alternate path separator '/' with
-  // the primary path separator '\\', so that for example "bar\\/\\foo" becomes
-  // "bar\\foo".
-
-  void Normalize();
-
-  // Returns a pointer to the last occurence of a valid path separator in
-  // the FilePath. On Windows, for example, both '/' and '\' are valid path
-  // separators. Returns NULL if no path separator was found.
-  const char* FindLastPathSeparator() const;
-
-  String pathname_;
-};  // class FilePath
-
-}  // namespace internal
-}  // namespace testing
-
-#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
-// This file was GENERATED by command:
-//     pump.py gtest-type-util.h.pump
-// DO NOT EDIT BY HAND!!!
-
-// Copyright 2008 Google Inc.
-// All Rights Reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan at google.com (Zhanyong Wan)
-
-// Type utilities needed for implementing typed and type-parameterized
-// tests.  This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!
-//
-// Currently we support at most 50 types in a list, and at most 50
-// type-parameterized tests in one type-parameterized test case.
-// Please contact googletestframework at googlegroups.com if you need
-// more.
-
-#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
-#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
-
-
-// #ifdef __GNUC__ is too general here.  It is possible to use gcc without using
-// libstdc++ (which is where cxxabi.h comes from).
-# ifdef __GLIBCXX__
-#  include <cxxabi.h>
-# elif defined(__HP_aCC)
-#  include <acxx_demangle.h>
-# endif  // __GLIBCXX__
-
-namespace testing {
-namespace internal {
-
-// GetTypeName<T>() returns a human-readable name of type T.
-// NB: This function is also used in Google Mock, so don't move it inside of
-// the typed-test-only section below.
-template <typename T>
-String GetTypeName() {
-# if GTEST_HAS_RTTI
-
-  const char* const name = typeid(T).name();
-#  if defined(__GLIBCXX__) || defined(__HP_aCC)
-  int status = 0;
-  // gcc's implementation of typeid(T).name() mangles the type name,
-  // so we have to demangle it.
-#   ifdef __GLIBCXX__
-  using abi::__cxa_demangle;
-#   endif // __GLIBCXX__
-  char* const readable_name = __cxa_demangle(name, 0, 0, &status);
-  const String name_str(status == 0 ? readable_name : name);
-  free(readable_name);
-  return name_str;
-#  else
-  return name;
-#  endif  // __GLIBCXX__ || __HP_aCC
-
-# else
-
-  return "<type>";
-
-# endif  // GTEST_HAS_RTTI
-}
-
-#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
-
-// AssertyTypeEq<T1, T2>::type is defined iff T1 and T2 are the same
-// type.  This can be used as a compile-time assertion to ensure that
-// two types are equal.
-
-template <typename T1, typename T2>
-struct AssertTypeEq;
-
-template <typename T>
-struct AssertTypeEq<T, T> {
-  typedef bool type;
-};
-
-// A unique type used as the default value for the arguments of class
-// template Types.  This allows us to simulate variadic templates
-// (e.g. Types<int>, Type<int, double>, and etc), which C++ doesn't
-// support directly.
-struct None {};
-
-// The following family of struct and struct templates are used to
-// represent type lists.  In particular, TypesN<T1, T2, ..., TN>
-// represents a type list with N types (T1, T2, ..., and TN) in it.
-// Except for Types0, every struct in the family has two member types:
-// Head for the first type in the list, and Tail for the rest of the
-// list.
-
-// The empty type list.
-struct Types0 {};
-
-// Type lists of length 1, 2, 3, and so on.
-
-template <typename T1>
-struct Types1 {
-  typedef T1 Head;
-  typedef Types0 Tail;
-};
-template <typename T1, typename T2>
-struct Types2 {
-  typedef T1 Head;
-  typedef Types1<T2> Tail;
-};
-
-template <typename T1, typename T2, typename T3>
-struct Types3 {
-  typedef T1 Head;
-  typedef Types2<T2, T3> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4>
-struct Types4 {
-  typedef T1 Head;
-  typedef Types3<T2, T3, T4> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5>
-struct Types5 {
-  typedef T1 Head;
-  typedef Types4<T2, T3, T4, T5> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6>
-struct Types6 {
-  typedef T1 Head;
-  typedef Types5<T2, T3, T4, T5, T6> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7>
-struct Types7 {
-  typedef T1 Head;
-  typedef Types6<T2, T3, T4, T5, T6, T7> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8>
-struct Types8 {
-  typedef T1 Head;
-  typedef Types7<T2, T3, T4, T5, T6, T7, T8> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9>
-struct Types9 {
-  typedef T1 Head;
-  typedef Types8<T2, T3, T4, T5, T6, T7, T8, T9> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10>
-struct Types10 {
-  typedef T1 Head;
-  typedef Types9<T2, T3, T4, T5, T6, T7, T8, T9, T10> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11>
-struct Types11 {
-  typedef T1 Head;
-  typedef Types10<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12>
-struct Types12 {
-  typedef T1 Head;
-  typedef Types11<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13>
-struct Types13 {
-  typedef T1 Head;
-  typedef Types12<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14>
-struct Types14 {
-  typedef T1 Head;
-  typedef Types13<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15>
-struct Types15 {
-  typedef T1 Head;
-  typedef Types14<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16>
-struct Types16 {
-  typedef T1 Head;
-  typedef Types15<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17>
-struct Types17 {
-  typedef T1 Head;
-  typedef Types16<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18>
-struct Types18 {
-  typedef T1 Head;
-  typedef Types17<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19>
-struct Types19 {
-  typedef T1 Head;
-  typedef Types18<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20>
-struct Types20 {
-  typedef T1 Head;
-  typedef Types19<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21>
-struct Types21 {
-  typedef T1 Head;
-  typedef Types20<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22>
-struct Types22 {
-  typedef T1 Head;
-  typedef Types21<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23>
-struct Types23 {
-  typedef T1 Head;
-  typedef Types22<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24>
-struct Types24 {
-  typedef T1 Head;
-  typedef Types23<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25>
-struct Types25 {
-  typedef T1 Head;
-  typedef Types24<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26>
-struct Types26 {
-  typedef T1 Head;
-  typedef Types25<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27>
-struct Types27 {
-  typedef T1 Head;
-  typedef Types26<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28>
-struct Types28 {
-  typedef T1 Head;
-  typedef Types27<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29>
-struct Types29 {
-  typedef T1 Head;
-  typedef Types28<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-      T29> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30>
-struct Types30 {
-  typedef T1 Head;
-  typedef Types29<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-      T30> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31>
-struct Types31 {
-  typedef T1 Head;
-  typedef Types30<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-      T30, T31> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32>
-struct Types32 {
-  typedef T1 Head;
-  typedef Types31<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-      T30, T31, T32> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33>
-struct Types33 {
-  typedef T1 Head;
-  typedef Types32<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-      T30, T31, T32, T33> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34>
-struct Types34 {
-  typedef T1 Head;
-  typedef Types33<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-      T30, T31, T32, T33, T34> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35>
-struct Types35 {
-  typedef T1 Head;
-  typedef Types34<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-      T30, T31, T32, T33, T34, T35> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36>
-struct Types36 {
-  typedef T1 Head;
-  typedef Types35<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-      T30, T31, T32, T33, T34, T35, T36> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37>
-struct Types37 {
-  typedef T1 Head;
-  typedef Types36<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-      T30, T31, T32, T33, T34, T35, T36, T37> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38>
-struct Types38 {
-  typedef T1 Head;
-  typedef Types37<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-      T30, T31, T32, T33, T34, T35, T36, T37, T38> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39>
-struct Types39 {
-  typedef T1 Head;
-  typedef Types38<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40>
-struct Types40 {
-  typedef T1 Head;
-  typedef Types39<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41>
-struct Types41 {
-  typedef T1 Head;
-  typedef Types40<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42>
-struct Types42 {
-  typedef T1 Head;
-  typedef Types41<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43>
-struct Types43 {
-  typedef T1 Head;
-  typedef Types42<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
-      T43> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44>
-struct Types44 {
-  typedef T1 Head;
-  typedef Types43<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
-      T44> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44, typename T45>
-struct Types45 {
-  typedef T1 Head;
-  typedef Types44<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
-      T44, T45> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44, typename T45,
-    typename T46>
-struct Types46 {
-  typedef T1 Head;
-  typedef Types45<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
-      T44, T45, T46> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44, typename T45,
-    typename T46, typename T47>
-struct Types47 {
-  typedef T1 Head;
-  typedef Types46<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
-      T44, T45, T46, T47> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44, typename T45,
-    typename T46, typename T47, typename T48>
-struct Types48 {
-  typedef T1 Head;
-  typedef Types47<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
-      T44, T45, T46, T47, T48> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44, typename T45,
-    typename T46, typename T47, typename T48, typename T49>
-struct Types49 {
-  typedef T1 Head;
-  typedef Types48<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
-      T44, T45, T46, T47, T48, T49> Tail;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44, typename T45,
-    typename T46, typename T47, typename T48, typename T49, typename T50>
-struct Types50 {
-  typedef T1 Head;
-  typedef Types49<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
-      T44, T45, T46, T47, T48, T49, T50> Tail;
-};
-
-
-}  // namespace internal
-
-// We don't want to require the users to write TypesN<...> directly,
-// as that would require them to count the length.  Types<...> is much
-// easier to write, but generates horrible messages when there is a
-// compiler error, as gcc insists on printing out each template
-// argument, even if it has the default value (this means Types<int>
-// will appear as Types<int, None, None, ..., None> in the compiler
-// errors).
-//
-// Our solution is to combine the best part of the two approaches: a
-// user would write Types<T1, ..., TN>, and Google Test will translate
-// that to TypesN<T1, ..., TN> internally to make error messages
-// readable.  The translation is done by the 'type' member of the
-// Types template.
-template <typename T1 = internal::None, typename T2 = internal::None,
-    typename T3 = internal::None, typename T4 = internal::None,
-    typename T5 = internal::None, typename T6 = internal::None,
-    typename T7 = internal::None, typename T8 = internal::None,
-    typename T9 = internal::None, typename T10 = internal::None,
-    typename T11 = internal::None, typename T12 = internal::None,
-    typename T13 = internal::None, typename T14 = internal::None,
-    typename T15 = internal::None, typename T16 = internal::None,
-    typename T17 = internal::None, typename T18 = internal::None,
-    typename T19 = internal::None, typename T20 = internal::None,
-    typename T21 = internal::None, typename T22 = internal::None,
-    typename T23 = internal::None, typename T24 = internal::None,
-    typename T25 = internal::None, typename T26 = internal::None,
-    typename T27 = internal::None, typename T28 = internal::None,
-    typename T29 = internal::None, typename T30 = internal::None,
-    typename T31 = internal::None, typename T32 = internal::None,
-    typename T33 = internal::None, typename T34 = internal::None,
-    typename T35 = internal::None, typename T36 = internal::None,
-    typename T37 = internal::None, typename T38 = internal::None,
-    typename T39 = internal::None, typename T40 = internal::None,
-    typename T41 = internal::None, typename T42 = internal::None,
-    typename T43 = internal::None, typename T44 = internal::None,
-    typename T45 = internal::None, typename T46 = internal::None,
-    typename T47 = internal::None, typename T48 = internal::None,
-    typename T49 = internal::None, typename T50 = internal::None>
-struct Types {
-  typedef internal::Types50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
-      T41, T42, T43, T44, T45, T46, T47, T48, T49, T50> type;
-};
-
-template <>
-struct Types<internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None> {
-  typedef internal::Types0 type;
-};
-template <typename T1>
-struct Types<T1, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None> {
-  typedef internal::Types1<T1> type;
-};
-template <typename T1, typename T2>
-struct Types<T1, T2, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None> {
-  typedef internal::Types2<T1, T2> type;
-};
-template <typename T1, typename T2, typename T3>
-struct Types<T1, T2, T3, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None> {
-  typedef internal::Types3<T1, T2, T3> type;
-};
-template <typename T1, typename T2, typename T3, typename T4>
-struct Types<T1, T2, T3, T4, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None> {
-  typedef internal::Types4<T1, T2, T3, T4> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5>
-struct Types<T1, T2, T3, T4, T5, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None> {
-  typedef internal::Types5<T1, T2, T3, T4, T5> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6>
-struct Types<T1, T2, T3, T4, T5, T6, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None> {
-  typedef internal::Types6<T1, T2, T3, T4, T5, T6> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7>
-struct Types<T1, T2, T3, T4, T5, T6, T7, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None> {
-  typedef internal::Types7<T1, T2, T3, T4, T5, T6, T7> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None> {
-  typedef internal::Types8<T1, T2, T3, T4, T5, T6, T7, T8> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None> {
-  typedef internal::Types9<T1, T2, T3, T4, T5, T6, T7, T8, T9> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None> {
-  typedef internal::Types10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None> {
-  typedef internal::Types11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None> {
-  typedef internal::Types12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None> {
-  typedef internal::Types13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None> {
-  typedef internal::Types14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None> {
-  typedef internal::Types15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None> {
-  typedef internal::Types16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None> {
-  typedef internal::Types17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None> {
-  typedef internal::Types18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None> {
-  typedef internal::Types19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None> {
-  typedef internal::Types20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None> {
-  typedef internal::Types21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None> {
-  typedef internal::Types22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None> {
-  typedef internal::Types23<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None> {
-  typedef internal::Types24<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None> {
-  typedef internal::Types25<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None> {
-  typedef internal::Types26<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None> {
-  typedef internal::Types27<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None> {
-  typedef internal::Types28<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27, T28> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None> {
-  typedef internal::Types29<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27, T28, T29> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None> {
-  typedef internal::Types30<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27, T28, T29, T30> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
-    T31, internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None> {
-  typedef internal::Types31<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27, T28, T29, T30, T31> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
-    T31, T32, internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None> {
-  typedef internal::Types32<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27, T28, T29, T30, T31, T32> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
-    T31, T32, T33, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None> {
-  typedef internal::Types33<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27, T28, T29, T30, T31, T32, T33> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
-    T31, T32, T33, T34, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None> {
-  typedef internal::Types34<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27, T28, T29, T30, T31, T32, T33, T34> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
-    T31, T32, T33, T34, T35, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None> {
-  typedef internal::Types35<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27, T28, T29, T30, T31, T32, T33, T34, T35> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
-    T31, T32, T33, T34, T35, T36, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None> {
-  typedef internal::Types36<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
-    T31, T32, T33, T34, T35, T36, T37, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None> {
-  typedef internal::Types37<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
-    T31, T32, T33, T34, T35, T36, T37, T38, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None> {
-  typedef internal::Types38<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
-    T31, T32, T33, T34, T35, T36, T37, T38, T39, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None> {
-  typedef internal::Types39<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
-    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None> {
-  typedef internal::Types40<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
-      T40> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
-    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None, internal::None> {
-  typedef internal::Types41<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
-      T41> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
-    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, internal::None,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None> {
-  typedef internal::Types42<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
-      T41, T42> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
-    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None, internal::None> {
-  typedef internal::Types43<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
-      T41, T42, T43> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
-    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None, internal::None> {
-  typedef internal::Types44<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
-      T41, T42, T43, T44> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44, typename T45>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
-    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
-    internal::None, internal::None, internal::None, internal::None,
-    internal::None> {
-  typedef internal::Types45<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
-      T41, T42, T43, T44, T45> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44, typename T45,
-    typename T46>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
-    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
-    T46, internal::None, internal::None, internal::None, internal::None> {
-  typedef internal::Types46<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
-      T41, T42, T43, T44, T45, T46> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44, typename T45,
-    typename T46, typename T47>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
-    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
-    T46, T47, internal::None, internal::None, internal::None> {
-  typedef internal::Types47<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
-      T41, T42, T43, T44, T45, T46, T47> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44, typename T45,
-    typename T46, typename T47, typename T48>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
-    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
-    T46, T47, T48, internal::None, internal::None> {
-  typedef internal::Types48<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
-      T41, T42, T43, T44, T45, T46, T47, T48> type;
-};
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44, typename T45,
-    typename T46, typename T47, typename T48, typename T49>
-struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
-    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
-    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
-    T46, T47, T48, T49, internal::None> {
-  typedef internal::Types49<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
-      T41, T42, T43, T44, T45, T46, T47, T48, T49> type;
-};
-
-namespace internal {
-
-# define GTEST_TEMPLATE_ template <typename T> class
-
-// The template "selector" struct TemplateSel<Tmpl> is used to
-// represent Tmpl, which must be a class template with one type
-// parameter, as a type.  TemplateSel<Tmpl>::Bind<T>::type is defined
-// as the type Tmpl<T>.  This allows us to actually instantiate the
-// template "selected" by TemplateSel<Tmpl>.
-//
-// This trick is necessary for simulating typedef for class templates,
-// which C++ doesn't support directly.
-template <GTEST_TEMPLATE_ Tmpl>
-struct TemplateSel {
-  template <typename T>
-  struct Bind {
-    typedef Tmpl<T> type;
-  };
-};
-
-# define GTEST_BIND_(TmplSel, T) \
-  TmplSel::template Bind<T>::type
-
-// A unique struct template used as the default value for the
-// arguments of class template Templates.  This allows us to simulate
-// variadic templates (e.g. Templates<int>, Templates<int, double>,
-// and etc), which C++ doesn't support directly.
-template <typename T>
-struct NoneT {};
-
-// The following family of struct and struct templates are used to
-// represent template lists.  In particular, TemplatesN<T1, T2, ...,
-// TN> represents a list of N templates (T1, T2, ..., and TN).  Except
-// for Templates0, every struct in the family has two member types:
-// Head for the selector of the first template in the list, and Tail
-// for the rest of the list.
-
-// The empty template list.
-struct Templates0 {};
-
-// Template lists of length 1, 2, 3, and so on.
-
-template <GTEST_TEMPLATE_ T1>
-struct Templates1 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates0 Tail;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2>
-struct Templates2 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates1<T2> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3>
-struct Templates3 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates2<T2, T3> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4>
-struct Templates4 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates3<T2, T3, T4> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5>
-struct Templates5 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates4<T2, T3, T4, T5> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6>
-struct Templates6 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates5<T2, T3, T4, T5, T6> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7>
-struct Templates7 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates6<T2, T3, T4, T5, T6, T7> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8>
-struct Templates8 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates7<T2, T3, T4, T5, T6, T7, T8> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9>
-struct Templates9 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates8<T2, T3, T4, T5, T6, T7, T8, T9> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10>
-struct Templates10 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates9<T2, T3, T4, T5, T6, T7, T8, T9, T10> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11>
-struct Templates11 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates10<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12>
-struct Templates12 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates11<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13>
-struct Templates13 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates12<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14>
-struct Templates14 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates13<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15>
-struct Templates15 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates14<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16>
-struct Templates16 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates15<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17>
-struct Templates17 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates16<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18>
-struct Templates18 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates17<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19>
-struct Templates19 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates18<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20>
-struct Templates20 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates19<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21>
-struct Templates21 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates20<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22>
-struct Templates22 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates21<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23>
-struct Templates23 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates22<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24>
-struct Templates24 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates23<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25>
-struct Templates25 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates24<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26>
-struct Templates26 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates25<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27>
-struct Templates27 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates26<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28>
-struct Templates28 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates27<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-      T28> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29>
-struct Templates29 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates28<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-      T29> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30>
-struct Templates30 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates29<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-      T29, T30> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31>
-struct Templates31 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates30<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-      T29, T30, T31> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32>
-struct Templates32 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates31<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-      T29, T30, T31, T32> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33>
-struct Templates33 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates32<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-      T29, T30, T31, T32, T33> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34>
-struct Templates34 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates33<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-      T29, T30, T31, T32, T33, T34> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35>
-struct Templates35 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates34<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-      T29, T30, T31, T32, T33, T34, T35> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36>
-struct Templates36 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates35<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-      T29, T30, T31, T32, T33, T34, T35, T36> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37>
-struct Templates37 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates36<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-      T29, T30, T31, T32, T33, T34, T35, T36, T37> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38>
-struct Templates38 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates37<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39>
-struct Templates39 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates38<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
-    GTEST_TEMPLATE_ T40>
-struct Templates40 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates39<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
-    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41>
-struct Templates41 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates40<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
-    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42>
-struct Templates42 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates41<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
-      T42> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
-    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
-    GTEST_TEMPLATE_ T43>
-struct Templates43 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates42<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
-      T43> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
-    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
-    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44>
-struct Templates44 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates43<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
-      T43, T44> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
-    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
-    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45>
-struct Templates45 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates44<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
-      T43, T44, T45> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
-    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
-    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
-    GTEST_TEMPLATE_ T46>
-struct Templates46 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates45<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
-      T43, T44, T45, T46> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
-    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
-    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
-    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47>
-struct Templates47 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates46<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
-      T43, T44, T45, T46, T47> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
-    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
-    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
-    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48>
-struct Templates48 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates47<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
-      T43, T44, T45, T46, T47, T48> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
-    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
-    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
-    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48,
-    GTEST_TEMPLATE_ T49>
-struct Templates49 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates48<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
-      T43, T44, T45, T46, T47, T48, T49> Tail;
-};
-
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
-    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
-    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
-    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48,
-    GTEST_TEMPLATE_ T49, GTEST_TEMPLATE_ T50>
-struct Templates50 {
-  typedef TemplateSel<T1> Head;
-  typedef Templates49<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
-      T43, T44, T45, T46, T47, T48, T49, T50> Tail;
-};
-
-
-// We don't want to require the users to write TemplatesN<...> directly,
-// as that would require them to count the length.  Templates<...> is much
-// easier to write, but generates horrible messages when there is a
-// compiler error, as gcc insists on printing out each template
-// argument, even if it has the default value (this means Templates<list>
-// will appear as Templates<list, NoneT, NoneT, ..., NoneT> in the compiler
-// errors).
-//
-// Our solution is to combine the best part of the two approaches: a
-// user would write Templates<T1, ..., TN>, and Google Test will translate
-// that to TemplatesN<T1, ..., TN> internally to make error messages
-// readable.  The translation is done by the 'type' member of the
-// Templates template.
-template <GTEST_TEMPLATE_ T1 = NoneT, GTEST_TEMPLATE_ T2 = NoneT,
-    GTEST_TEMPLATE_ T3 = NoneT, GTEST_TEMPLATE_ T4 = NoneT,
-    GTEST_TEMPLATE_ T5 = NoneT, GTEST_TEMPLATE_ T6 = NoneT,
-    GTEST_TEMPLATE_ T7 = NoneT, GTEST_TEMPLATE_ T8 = NoneT,
-    GTEST_TEMPLATE_ T9 = NoneT, GTEST_TEMPLATE_ T10 = NoneT,
-    GTEST_TEMPLATE_ T11 = NoneT, GTEST_TEMPLATE_ T12 = NoneT,
-    GTEST_TEMPLATE_ T13 = NoneT, GTEST_TEMPLATE_ T14 = NoneT,
-    GTEST_TEMPLATE_ T15 = NoneT, GTEST_TEMPLATE_ T16 = NoneT,
-    GTEST_TEMPLATE_ T17 = NoneT, GTEST_TEMPLATE_ T18 = NoneT,
-    GTEST_TEMPLATE_ T19 = NoneT, GTEST_TEMPLATE_ T20 = NoneT,
-    GTEST_TEMPLATE_ T21 = NoneT, GTEST_TEMPLATE_ T22 = NoneT,
-    GTEST_TEMPLATE_ T23 = NoneT, GTEST_TEMPLATE_ T24 = NoneT,
-    GTEST_TEMPLATE_ T25 = NoneT, GTEST_TEMPLATE_ T26 = NoneT,
-    GTEST_TEMPLATE_ T27 = NoneT, GTEST_TEMPLATE_ T28 = NoneT,
-    GTEST_TEMPLATE_ T29 = NoneT, GTEST_TEMPLATE_ T30 = NoneT,
-    GTEST_TEMPLATE_ T31 = NoneT, GTEST_TEMPLATE_ T32 = NoneT,
-    GTEST_TEMPLATE_ T33 = NoneT, GTEST_TEMPLATE_ T34 = NoneT,
-    GTEST_TEMPLATE_ T35 = NoneT, GTEST_TEMPLATE_ T36 = NoneT,
-    GTEST_TEMPLATE_ T37 = NoneT, GTEST_TEMPLATE_ T38 = NoneT,
-    GTEST_TEMPLATE_ T39 = NoneT, GTEST_TEMPLATE_ T40 = NoneT,
-    GTEST_TEMPLATE_ T41 = NoneT, GTEST_TEMPLATE_ T42 = NoneT,
-    GTEST_TEMPLATE_ T43 = NoneT, GTEST_TEMPLATE_ T44 = NoneT,
-    GTEST_TEMPLATE_ T45 = NoneT, GTEST_TEMPLATE_ T46 = NoneT,
-    GTEST_TEMPLATE_ T47 = NoneT, GTEST_TEMPLATE_ T48 = NoneT,
-    GTEST_TEMPLATE_ T49 = NoneT, GTEST_TEMPLATE_ T50 = NoneT>
-struct Templates {
-  typedef Templates50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
-      T42, T43, T44, T45, T46, T47, T48, T49, T50> type;
-};
-
-template <>
-struct Templates<NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT> {
-  typedef Templates0 type;
-};
-template <GTEST_TEMPLATE_ T1>
-struct Templates<T1, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT> {
-  typedef Templates1<T1> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2>
-struct Templates<T1, T2, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT> {
-  typedef Templates2<T1, T2> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3>
-struct Templates<T1, T2, T3, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates3<T1, T2, T3> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4>
-struct Templates<T1, T2, T3, T4, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates4<T1, T2, T3, T4> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5>
-struct Templates<T1, T2, T3, T4, T5, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates5<T1, T2, T3, T4, T5> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6>
-struct Templates<T1, T2, T3, T4, T5, T6, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates6<T1, T2, T3, T4, T5, T6> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates7<T1, T2, T3, T4, T5, T6, T7> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates8<T1, T2, T3, T4, T5, T6, T7, T8> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates9<T1, T2, T3, T4, T5, T6, T7, T8, T9> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT> {
-  typedef Templates22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT> {
-  typedef Templates23<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT> {
-  typedef Templates24<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT> {
-  typedef Templates25<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT> {
-  typedef Templates26<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT> {
-  typedef Templates27<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT> {
-  typedef Templates28<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-      T28> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT> {
-  typedef Templates29<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-      T28, T29> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-    T30, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates30<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-      T28, T29, T30> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-    T30, T31, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates31<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-      T28, T29, T30, T31> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-    T30, T31, T32, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates32<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-      T28, T29, T30, T31, T32> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-    T30, T31, T32, T33, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates33<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-      T28, T29, T30, T31, T32, T33> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-    T30, T31, T32, T33, T34, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates34<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-      T28, T29, T30, T31, T32, T33, T34> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-    T30, T31, T32, T33, T34, T35, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates35<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-      T28, T29, T30, T31, T32, T33, T34, T35> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-    T30, T31, T32, T33, T34, T35, T36, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates36<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-      T28, T29, T30, T31, T32, T33, T34, T35, T36> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-    T30, T31, T32, T33, T34, T35, T36, T37, NoneT, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates37<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-    T30, T31, T32, T33, T34, T35, T36, T37, T38, NoneT, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates38<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates39<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
-    GTEST_TEMPLATE_ T40>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, NoneT, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates40<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
-    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, NoneT, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates41<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
-      T41> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
-    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, NoneT,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates42<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
-      T42> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
-    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
-    GTEST_TEMPLATE_ T43>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates43<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
-      T42, T43> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
-    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
-    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
-    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates44<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
-      T42, T43, T44> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
-    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
-    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
-    T45, NoneT, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates45<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
-      T42, T43, T44, T45> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
-    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
-    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
-    GTEST_TEMPLATE_ T46>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
-    T45, T46, NoneT, NoneT, NoneT, NoneT> {
-  typedef Templates46<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
-      T42, T43, T44, T45, T46> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
-    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
-    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
-    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
-    T45, T46, T47, NoneT, NoneT, NoneT> {
-  typedef Templates47<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
-      T42, T43, T44, T45, T46, T47> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
-    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
-    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
-    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
-    T45, T46, T47, T48, NoneT, NoneT> {
-  typedef Templates48<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
-      T42, T43, T44, T45, T46, T47, T48> type;
-};
-template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
-    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
-    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
-    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
-    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
-    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
-    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
-    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
-    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
-    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
-    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
-    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
-    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
-    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
-    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
-    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48,
-    GTEST_TEMPLATE_ T49>
-struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
-    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
-    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
-    T45, T46, T47, T48, T49, NoneT> {
-  typedef Templates49<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
-      T42, T43, T44, T45, T46, T47, T48, T49> type;
-};
-
-// The TypeList template makes it possible to use either a single type
-// or a Types<...> list in TYPED_TEST_CASE() and
-// INSTANTIATE_TYPED_TEST_CASE_P().
-
-template <typename T>
-struct TypeList { typedef Types1<T> type; };
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44, typename T45,
-    typename T46, typename T47, typename T48, typename T49, typename T50>
-struct TypeList<Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
-    T44, T45, T46, T47, T48, T49, T50> > {
-  typedef typename Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
-      T41, T42, T43, T44, T45, T46, T47, T48, T49, T50>::type type;
-};
-
-#endif  // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
-
-}  // namespace internal
-}  // namespace testing
-
-#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
-
-// Due to C++ preprocessor weirdness, we need double indirection to
-// concatenate two tokens when one of them is __LINE__.  Writing
-//
-//   foo ## __LINE__
-//
-// will result in the token foo__LINE__, instead of foo followed by
-// the current line number.  For more details, see
-// http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.6
-#define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar)
-#define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo ## bar
-
-// Google Test defines the testing::Message class to allow construction of
-// test messages via the << operator.  The idea is that anything
-// streamable to std::ostream can be streamed to a testing::Message.
-// This allows a user to use his own types in Google Test assertions by
-// overloading the << operator.
-//
-// util/gtl/stl_logging-inl.h overloads << for STL containers.  These
-// overloads cannot be defined in the std namespace, as that will be
-// undefined behavior.  Therefore, they are defined in the global
-// namespace instead.
-//
-// C++'s symbol lookup rule (i.e. Koenig lookup) says that these
-// overloads are visible in either the std namespace or the global
-// namespace, but not other namespaces, including the testing
-// namespace which Google Test's Message class is in.
-//
-// To allow STL containers (and other types that has a << operator
-// defined in the global namespace) to be used in Google Test assertions,
-// testing::Message must access the custom << operator from the global
-// namespace.  Hence this helper function.
-//
-// Note: Jeffrey Yasskin suggested an alternative fix by "using
-// ::operator<<;" in the definition of Message's operator<<.  That fix
-// doesn't require a helper function, but unfortunately doesn't
-// compile with MSVC.
-template <typename T>
-inline void GTestStreamToHelper(std::ostream* os, const T& val) {
-  *os << val;
-}
-
-class ProtocolMessage;
-namespace proto2 { class Message; }
-
-namespace testing {
-
-// Forward declarations.
-
-class AssertionResult;                 // Result of an assertion.
-class Message;                         // Represents a failure message.
-class Test;                            // Represents a test.
-class TestInfo;                        // Information about a test.
-class TestPartResult;                  // Result of a test part.
-class UnitTest;                        // A collection of test cases.
-
-template <typename T>
-::std::string PrintToString(const T& value);
-
-namespace internal {
-
-struct TraceInfo;                      // Information about a trace point.
-class ScopedTrace;                     // Implements scoped trace.
-class TestInfoImpl;                    // Opaque implementation of TestInfo
-class UnitTestImpl;                    // Opaque implementation of UnitTest
-
-// How many times InitGoogleTest() has been called.
-extern int g_init_gtest_count;
-
-// The text used in failure messages to indicate the start of the
-// stack trace.
-GTEST_API_ extern const char kStackTraceMarker[];
-
-// A secret type that Google Test users don't know about.  It has no
-// definition on purpose.  Therefore it's impossible to create a
-// Secret object, which is what we want.
-class Secret;
-
-// Two overloaded helpers for checking at compile time whether an
-// expression is a null pointer literal (i.e. NULL or any 0-valued
-// compile-time integral constant).  Their return values have
-// different sizes, so we can use sizeof() to test which version is
-// picked by the compiler.  These helpers have no implementations, as
-// we only need their signatures.
-//
-// Given IsNullLiteralHelper(x), the compiler will pick the first
-// version if x can be implicitly converted to Secret*, and pick the
-// second version otherwise.  Since Secret is a secret and incomplete
-// type, the only expression a user can write that has type Secret* is
-// a null pointer literal.  Therefore, we know that x is a null
-// pointer literal if and only if the first version is picked by the
-// compiler.
-char IsNullLiteralHelper(Secret* p);
-char (&IsNullLiteralHelper(...))[2];  // NOLINT
-
-// A compile-time bool constant that is true if and only if x is a
-// null pointer literal (i.e. NULL or any 0-valued compile-time
-// integral constant).
-#ifdef GTEST_ELLIPSIS_NEEDS_POD_
-// We lose support for NULL detection where the compiler doesn't like
-// passing non-POD classes through ellipsis (...).
-# define GTEST_IS_NULL_LITERAL_(x) false
-#else
-# define GTEST_IS_NULL_LITERAL_(x) \
-    (sizeof(::testing::internal::IsNullLiteralHelper(x)) == 1)
-#endif  // GTEST_ELLIPSIS_NEEDS_POD_
-
-// Appends the user-supplied message to the Google-Test-generated message.
-GTEST_API_ String AppendUserMessage(const String& gtest_msg,
-                                    const Message& user_msg);
-
-// A helper class for creating scoped traces in user programs.
-class GTEST_API_ ScopedTrace {
- public:
-  // The c'tor pushes the given source file location and message onto
-  // a trace stack maintained by Google Test.
-  ScopedTrace(const char* file, int line, const Message& message);
-
-  // The d'tor pops the info pushed by the c'tor.
-  //
-  // Note that the d'tor is not virtual in order to be efficient.
-  // Don't inherit from ScopedTrace!
-  ~ScopedTrace();
-
- private:
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedTrace);
-} GTEST_ATTRIBUTE_UNUSED_;  // A ScopedTrace object does its job in its
-                            // c'tor and d'tor.  Therefore it doesn't
-                            // need to be used otherwise.
-
-// Converts a streamable value to a String.  A NULL pointer is
-// converted to "(null)".  When the input value is a ::string,
-// ::std::string, ::wstring, or ::std::wstring object, each NUL
-// character in it is replaced with "\\0".
-// Declared here but defined in gtest.h, so that it has access
-// to the definition of the Message class, required by the ARM
-// compiler.
-template <typename T>
-String StreamableToString(const T& streamable);
-
-// The Symbian compiler has a bug that prevents it from selecting the
-// correct overload of FormatForComparisonFailureMessage (see below)
-// unless we pass the first argument by reference.  If we do that,
-// however, Visual Age C++ 10.1 generates a compiler error.  Therefore
-// we only apply the work-around for Symbian.
-#if defined(__SYMBIAN32__)
-# define GTEST_CREF_WORKAROUND_ const&
-#else
-# define GTEST_CREF_WORKAROUND_
-#endif
-
-// When this operand is a const char* or char*, if the other operand
-// is a ::std::string or ::string, we print this operand as a C string
-// rather than a pointer (we do the same for wide strings); otherwise
-// we print it as a pointer to be safe.
-
-// This internal macro is used to avoid duplicated code.
-#define GTEST_FORMAT_IMPL_(operand2_type, operand1_printer)\
-inline String FormatForComparisonFailureMessage(\
-    operand2_type::value_type* GTEST_CREF_WORKAROUND_ str, \
-    const operand2_type& /*operand2*/) {\
-  return operand1_printer(str);\
-}\
-inline String FormatForComparisonFailureMessage(\
-    const operand2_type::value_type* GTEST_CREF_WORKAROUND_ str, \
-    const operand2_type& /*operand2*/) {\
-  return operand1_printer(str);\
-}
-
-GTEST_FORMAT_IMPL_(::std::string, String::ShowCStringQuoted)
-#if GTEST_HAS_STD_WSTRING
-GTEST_FORMAT_IMPL_(::std::wstring, String::ShowWideCStringQuoted)
-#endif  // GTEST_HAS_STD_WSTRING
-
-#if GTEST_HAS_GLOBAL_STRING
-GTEST_FORMAT_IMPL_(::string, String::ShowCStringQuoted)
-#endif  // GTEST_HAS_GLOBAL_STRING
-#if GTEST_HAS_GLOBAL_WSTRING
-GTEST_FORMAT_IMPL_(::wstring, String::ShowWideCStringQuoted)
-#endif  // GTEST_HAS_GLOBAL_WSTRING
-
-#undef GTEST_FORMAT_IMPL_
-
-// The next four overloads handle the case where the operand being
-// printed is a char/wchar_t pointer and the other operand is not a
-// string/wstring object.  In such cases, we just print the operand as
-// a pointer to be safe.
-#define GTEST_FORMAT_CHAR_PTR_IMPL_(CharType)                       \
-  template <typename T>                                             \
-  String FormatForComparisonFailureMessage(CharType* GTEST_CREF_WORKAROUND_ p, \
-                                           const T&) { \
-    return PrintToString(static_cast<const void*>(p));              \
-  }
-
-GTEST_FORMAT_CHAR_PTR_IMPL_(char)
-GTEST_FORMAT_CHAR_PTR_IMPL_(const char)
-GTEST_FORMAT_CHAR_PTR_IMPL_(wchar_t)
-GTEST_FORMAT_CHAR_PTR_IMPL_(const wchar_t)
-
-#undef GTEST_FORMAT_CHAR_PTR_IMPL_
-
-// Constructs and returns the message for an equality assertion
-// (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure.
-//
-// The first four parameters are the expressions used in the assertion
-// and their values, as strings.  For example, for ASSERT_EQ(foo, bar)
-// where foo is 5 and bar is 6, we have:
-//
-//   expected_expression: "foo"
-//   actual_expression:   "bar"
-//   expected_value:      "5"
-//   actual_value:        "6"
-//
-// The ignoring_case parameter is true iff the assertion is a
-// *_STRCASEEQ*.  When it's true, the string " (ignoring case)" will
-// be inserted into the message.
-GTEST_API_ AssertionResult EqFailure(const char* expected_expression,
-                                     const char* actual_expression,
-                                     const String& expected_value,
-                                     const String& actual_value,
-                                     bool ignoring_case);
-
-// Constructs a failure message for Boolean assertions such as EXPECT_TRUE.
-GTEST_API_ String GetBoolAssertionFailureMessage(
-    const AssertionResult& assertion_result,
-    const char* expression_text,
-    const char* actual_predicate_value,
-    const char* expected_predicate_value);
-
-// This template class represents an IEEE floating-point number
-// (either single-precision or double-precision, depending on the
-// template parameters).
-//
-// The purpose of this class is to do more sophisticated number
-// comparison.  (Due to round-off error, etc, it's very unlikely that
-// two floating-points will be equal exactly.  Hence a naive
-// comparison by the == operation often doesn't work.)
-//
-// Format of IEEE floating-point:
-//
-//   The most-significant bit being the leftmost, an IEEE
-//   floating-point looks like
-//
-//     sign_bit exponent_bits fraction_bits
-//
-//   Here, sign_bit is a single bit that designates the sign of the
-//   number.
-//
-//   For float, there are 8 exponent bits and 23 fraction bits.
-//
-//   For double, there are 11 exponent bits and 52 fraction bits.
-//
-//   More details can be found at
-//   http://en.wikipedia.org/wiki/IEEE_floating-point_standard.
-//
-// Template parameter:
-//
-//   RawType: the raw floating-point type (either float or double)
-template <typename RawType>
-class FloatingPoint {
- public:
-  // Defines the unsigned integer type that has the same size as the
-  // floating point number.
-  typedef typename TypeWithSize<sizeof(RawType)>::UInt Bits;
-
-  // Constants.
-
-  // # of bits in a number.
-  static const size_t kBitCount = 8*sizeof(RawType);
-
-  // # of fraction bits in a number.
-  static const size_t kFractionBitCount =
-    std::numeric_limits<RawType>::digits - 1;
-
-  // # of exponent bits in a number.
-  static const size_t kExponentBitCount = kBitCount - 1 - kFractionBitCount;
-
-  // The mask for the sign bit.
-  static const Bits kSignBitMask = static_cast<Bits>(1) << (kBitCount - 1);
-
-  // The mask for the fraction bits.
-  static const Bits kFractionBitMask =
-    ~static_cast<Bits>(0) >> (kExponentBitCount + 1);
-
-  // The mask for the exponent bits.
-  static const Bits kExponentBitMask = ~(kSignBitMask | kFractionBitMask);
-
-  // How many ULP's (Units in the Last Place) we want to tolerate when
-  // comparing two numbers.  The larger the value, the more error we
-  // allow.  A 0 value means that two numbers must be exactly the same
-  // to be considered equal.
-  //
-  // The maximum error of a single floating-point operation is 0.5
-  // units in the last place.  On Intel CPU's, all floating-point
-  // calculations are done with 80-bit precision, while double has 64
-  // bits.  Therefore, 4 should be enough for ordinary use.
-  //
-  // See the following article for more details on ULP:
-  // http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm.
-  static const size_t kMaxUlps = 4;
-
-  // Constructs a FloatingPoint from a raw floating-point number.
-  //
-  // On an Intel CPU, passing a non-normalized NAN (Not a Number)
-  // around may change its bits, although the new value is guaranteed
-  // to be also a NAN.  Therefore, don't expect this constructor to
-  // preserve the bits in x when x is a NAN.
-  explicit FloatingPoint(const RawType& x) { u_.value_ = x; }
-
-  // Static methods
-
-  // Reinterprets a bit pattern as a floating-point number.
-  //
-  // This function is needed to test the AlmostEquals() method.
-  static RawType ReinterpretBits(const Bits bits) {
-    FloatingPoint fp(0);
-    fp.u_.bits_ = bits;
-    return fp.u_.value_;
-  }
-
-  // Returns the floating-point number that represent positive infinity.
-  static RawType Infinity() {
-    return ReinterpretBits(kExponentBitMask);
-  }
-
-  // Non-static methods
-
-  // Returns the bits that represents this number.
-  const Bits &bits() const { return u_.bits_; }
-
-  // Returns the exponent bits of this number.
-  Bits exponent_bits() const { return kExponentBitMask & u_.bits_; }
-
-  // Returns the fraction bits of this number.
-  Bits fraction_bits() const { return kFractionBitMask & u_.bits_; }
-
-  // Returns the sign bit of this number.
-  Bits sign_bit() const { return kSignBitMask & u_.bits_; }
-
-  // Returns true iff this is NAN (not a number).
-  bool is_nan() const {
-    // It's a NAN if the exponent bits are all ones and the fraction
-    // bits are not entirely zeros.
-    return (exponent_bits() == kExponentBitMask) && (fraction_bits() != 0);
-  }
-
-  // Returns true iff this number is at most kMaxUlps ULP's away from
-  // rhs.  In particular, this function:
-  //
-  //   - returns false if either number is (or both are) NAN.
-  //   - treats really large numbers as almost equal to infinity.
-  //   - thinks +0.0 and -0.0 are 0 DLP's apart.
-  bool AlmostEquals(const FloatingPoint& rhs) const {
-    // The IEEE standard says that any comparison operation involving
-    // a NAN must return false.
-    if (is_nan() || rhs.is_nan()) return false;
-
-    return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_)
-        <= kMaxUlps;
-  }
-
- private:
-  // The data type used to store the actual floating-point number.
-  union FloatingPointUnion {
-    RawType value_;  // The raw floating-point number.
-    Bits bits_;      // The bits that represent the number.
-  };
-
-  // Converts an integer from the sign-and-magnitude representation to
-  // the biased representation.  More precisely, let N be 2 to the
-  // power of (kBitCount - 1), an integer x is represented by the
-  // unsigned number x + N.
-  //
-  // For instance,
-  //
-  //   -N + 1 (the most negative number representable using
-  //          sign-and-magnitude) is represented by 1;
-  //   0      is represented by N; and
-  //   N - 1  (the biggest number representable using
-  //          sign-and-magnitude) is represented by 2N - 1.
-  //
-  // Read http://en.wikipedia.org/wiki/Signed_number_representations
-  // for more details on signed number representations.
-  static Bits SignAndMagnitudeToBiased(const Bits &sam) {
-    if (kSignBitMask & sam) {
-      // sam represents a negative number.
-      return ~sam + 1;
-    } else {
-      // sam represents a positive number.
-      return kSignBitMask | sam;
-    }
-  }
-
-  // Given two numbers in the sign-and-magnitude representation,
-  // returns the distance between them as an unsigned number.
-  static Bits DistanceBetweenSignAndMagnitudeNumbers(const Bits &sam1,
-                                                     const Bits &sam2) {
-    const Bits biased1 = SignAndMagnitudeToBiased(sam1);
-    const Bits biased2 = SignAndMagnitudeToBiased(sam2);
-    return (biased1 >= biased2) ? (biased1 - biased2) : (biased2 - biased1);
-  }
-
-  FloatingPointUnion u_;
-};
-
-// Typedefs the instances of the FloatingPoint template class that we
-// care to use.
-typedef FloatingPoint<float> Float;
-typedef FloatingPoint<double> Double;
-
-// In order to catch the mistake of putting tests that use different
-// test fixture classes in the same test case, we need to assign
-// unique IDs to fixture classes and compare them.  The TypeId type is
-// used to hold such IDs.  The user should treat TypeId as an opaque
-// type: the only operation allowed on TypeId values is to compare
-// them for equality using the == operator.
-typedef const void* TypeId;
-
-template <typename T>
-class TypeIdHelper {
- public:
-  // dummy_ must not have a const type.  Otherwise an overly eager
-  // compiler (e.g. MSVC 7.1 & 8.0) may try to merge
-  // TypeIdHelper<T>::dummy_ for different Ts as an "optimization".
-  static bool dummy_;
-};
-
-template <typename T>
-bool TypeIdHelper<T>::dummy_ = false;
-
-// GetTypeId<T>() returns the ID of type T.  Different values will be
-// returned for different types.  Calling the function twice with the
-// same type argument is guaranteed to return the same ID.
-template <typename T>
-TypeId GetTypeId() {
-  // The compiler is required to allocate a different
-  // TypeIdHelper<T>::dummy_ variable for each T used to instantiate
-  // the template.  Therefore, the address of dummy_ is guaranteed to
-  // be unique.
-  return &(TypeIdHelper<T>::dummy_);
-}
-
-// Returns the type ID of ::testing::Test.  Always call this instead
-// of GetTypeId< ::testing::Test>() to get the type ID of
-// ::testing::Test, as the latter may give the wrong result due to a
-// suspected linker bug when compiling Google Test as a Mac OS X
-// framework.
-GTEST_API_ TypeId GetTestTypeId();
-
-// Defines the abstract factory interface that creates instances
-// of a Test object.
-class TestFactoryBase {
- public:
-  virtual ~TestFactoryBase() {}
-
-  // Creates a test instance to run. The instance is both created and destroyed
-  // within TestInfoImpl::Run()
-  virtual Test* CreateTest() = 0;
-
- protected:
-  TestFactoryBase() {}
-
- private:
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestFactoryBase);
-};
-
-// This class provides implementation of TeastFactoryBase interface.
-// It is used in TEST and TEST_F macros.
-template <class TestClass>
-class TestFactoryImpl : public TestFactoryBase {
- public:
-  virtual Test* CreateTest() { return new TestClass; }
-};
-
-#if GTEST_OS_WINDOWS
-
-// Predicate-formatters for implementing the HRESULT checking macros
-// {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}
-// We pass a long instead of HRESULT to avoid causing an
-// include dependency for the HRESULT type.
-GTEST_API_ AssertionResult IsHRESULTSuccess(const char* expr,
-                                            long hr);  // NOLINT
-GTEST_API_ AssertionResult IsHRESULTFailure(const char* expr,
-                                            long hr);  // NOLINT
-
-#endif  // GTEST_OS_WINDOWS
-
-// Types of SetUpTestCase() and TearDownTestCase() functions.
-typedef void (*SetUpTestCaseFunc)();
-typedef void (*TearDownTestCaseFunc)();
-
-// Creates a new TestInfo object and registers it with Google Test;
-// returns the created object.
-//
-// Arguments:
-//
-//   test_case_name:   name of the test case
-//   name:             name of the test
-//   type_param        the name of the test's type parameter, or NULL if
-//                     this is not  a typed or a type-parameterized test.
-//   value_param       text representation of the test's value parameter,
-//                     or NULL if this is not a type-parameterized test.
-//   fixture_class_id: ID of the test fixture class
-//   set_up_tc:        pointer to the function that sets up the test case
-//   tear_down_tc:     pointer to the function that tears down the test case
-//   factory:          pointer to the factory that creates a test object.
-//                     The newly created TestInfo instance will assume
-//                     ownership of the factory object.
-GTEST_API_ TestInfo* MakeAndRegisterTestInfo(
-    const char* test_case_name, const char* name,
-    const char* type_param,
-    const char* value_param,
-    TypeId fixture_class_id,
-    SetUpTestCaseFunc set_up_tc,
-    TearDownTestCaseFunc tear_down_tc,
-    TestFactoryBase* factory);
-
-// If *pstr starts with the given prefix, modifies *pstr to be right
-// past the prefix and returns true; otherwise leaves *pstr unchanged
-// and returns false.  None of pstr, *pstr, and prefix can be NULL.
-GTEST_API_ bool SkipPrefix(const char* prefix, const char** pstr);
-
-#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
-
-// State of the definition of a type-parameterized test case.
-class GTEST_API_ TypedTestCasePState {
- public:
-  TypedTestCasePState() : registered_(false) {}
-
-  // Adds the given test name to defined_test_names_ and return true
-  // if the test case hasn't been registered; otherwise aborts the
-  // program.
-  bool AddTestName(const char* file, int line, const char* case_name,
-                   const char* test_name) {
-    if (registered_) {
-      fprintf(stderr, "%s Test %s must be defined before "
-              "REGISTER_TYPED_TEST_CASE_P(%s, ...).\n",
-              FormatFileLocation(file, line).c_str(), test_name, case_name);
-      fflush(stderr);
-      posix::Abort();
-    }
-    defined_test_names_.insert(test_name);
-    return true;
-  }
-
-  // Verifies that registered_tests match the test names in
-  // defined_test_names_; returns registered_tests if successful, or
-  // aborts the program otherwise.
-  const char* VerifyRegisteredTestNames(
-      const char* file, int line, const char* registered_tests);
-
- private:
-  bool registered_;
-  ::std::set<const char*> defined_test_names_;
-};
-
-// Skips to the first non-space char after the first comma in 'str';
-// returns NULL if no comma is found in 'str'.
-inline const char* SkipComma(const char* str) {
-  const char* comma = strchr(str, ',');
-  if (comma == NULL) {
-    return NULL;
-  }
-  while (IsSpace(*(++comma))) {}
-  return comma;
-}
-
-// Returns the prefix of 'str' before the first comma in it; returns
-// the entire string if it contains no comma.
-inline String GetPrefixUntilComma(const char* str) {
-  const char* comma = strchr(str, ',');
-  return comma == NULL ? String(str) : String(str, comma - str);
-}
-
-// TypeParameterizedTest<Fixture, TestSel, Types>::Register()
-// registers a list of type-parameterized tests with Google Test.  The
-// return value is insignificant - we just need to return something
-// such that we can call this function in a namespace scope.
-//
-// Implementation note: The GTEST_TEMPLATE_ macro declares a template
-// template parameter.  It's defined in gtest-type-util.h.
-template <GTEST_TEMPLATE_ Fixture, class TestSel, typename Types>
-class TypeParameterizedTest {
- public:
-  // 'index' is the index of the test in the type list 'Types'
-  // specified in INSTANTIATE_TYPED_TEST_CASE_P(Prefix, TestCase,
-  // Types).  Valid values for 'index' are [0, N - 1] where N is the
-  // length of Types.
-  static bool Register(const char* prefix, const char* case_name,
-                       const char* test_names, int index) {
-    typedef typename Types::Head Type;
-    typedef Fixture<Type> FixtureClass;
-    typedef typename GTEST_BIND_(TestSel, Type) TestClass;
-
-    // First, registers the first type-parameterized test in the type
-    // list.
-    MakeAndRegisterTestInfo(
-        String::Format("%s%s%s/%d", prefix, prefix[0] == '\0' ? "" : "/",
-                       case_name, index).c_str(),
-        GetPrefixUntilComma(test_names).c_str(),
-        GetTypeName<Type>().c_str(),
-        NULL,  // No value parameter.
-        GetTypeId<FixtureClass>(),
-        TestClass::SetUpTestCase,
-        TestClass::TearDownTestCase,
-        new TestFactoryImpl<TestClass>);
-
-    // Next, recurses (at compile time) with the tail of the type list.
-    return TypeParameterizedTest<Fixture, TestSel, typename Types::Tail>
-        ::Register(prefix, case_name, test_names, index + 1);
-  }
-};
-
-// The base case for the compile time recursion.
-template <GTEST_TEMPLATE_ Fixture, class TestSel>
-class TypeParameterizedTest<Fixture, TestSel, Types0> {
- public:
-  static bool Register(const char* /*prefix*/, const char* /*case_name*/,
-                       const char* /*test_names*/, int /*index*/) {
-    return true;
-  }
-};
-
-// TypeParameterizedTestCase<Fixture, Tests, Types>::Register()
-// registers *all combinations* of 'Tests' and 'Types' with Google
-// Test.  The return value is insignificant - we just need to return
-// something such that we can call this function in a namespace scope.
-template <GTEST_TEMPLATE_ Fixture, typename Tests, typename Types>
-class TypeParameterizedTestCase {
- public:
-  static bool Register(const char* prefix, const char* case_name,
-                       const char* test_names) {
-    typedef typename Tests::Head Head;
-
-    // First, register the first test in 'Test' for each type in 'Types'.
-    TypeParameterizedTest<Fixture, Head, Types>::Register(
-        prefix, case_name, test_names, 0);
-
-    // Next, recurses (at compile time) with the tail of the test list.
-    return TypeParameterizedTestCase<Fixture, typename Tests::Tail, Types>
-        ::Register(prefix, case_name, SkipComma(test_names));
-  }
-};
-
-// The base case for the compile time recursion.
-template <GTEST_TEMPLATE_ Fixture, typename Types>
-class TypeParameterizedTestCase<Fixture, Templates0, Types> {
- public:
-  static bool Register(const char* /*prefix*/, const char* /*case_name*/,
-                       const char* /*test_names*/) {
-    return true;
-  }
-};
-
-#endif  // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
-
-// Returns the current OS stack trace as a String.
-//
-// The maximum number of stack frames to be included is specified by
-// the gtest_stack_trace_depth flag.  The skip_count parameter
-// specifies the number of top frames to be skipped, which doesn't
-// count against the number of frames to be included.
-//
-// For example, if Foo() calls Bar(), which in turn calls
-// GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in
-// the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.
-GTEST_API_ String GetCurrentOsStackTraceExceptTop(UnitTest* unit_test,
-                                                  int skip_count);
-
-// Helpers for suppressing warnings on unreachable code or constant
-// condition.
-
-// Always returns true.
-GTEST_API_ bool AlwaysTrue();
-
-// Always returns false.
-inline bool AlwaysFalse() { return !AlwaysTrue(); }
-
-// Helper for suppressing false warning from Clang on a const char*
-// variable declared in a conditional expression always being NULL in
-// the else branch.
-struct GTEST_API_ ConstCharPtr {
-  ConstCharPtr(const char* str) : value(str) {}
-  operator bool() const { return true; }
-  const char* value;
-};
-
-// A simple Linear Congruential Generator for generating random
-// numbers with a uniform distribution.  Unlike rand() and srand(), it
-// doesn't use global state (and therefore can't interfere with user
-// code).  Unlike rand_r(), it's portable.  An LCG isn't very random,
-// but it's good enough for our purposes.
-class GTEST_API_ Random {
- public:
-  static const UInt32 kMaxRange = 1u << 31;
-
-  explicit Random(UInt32 seed) : state_(seed) {}
-
-  void Reseed(UInt32 seed) { state_ = seed; }
-
-  // Generates a random number from [0, range).  Crashes if 'range' is
-  // 0 or greater than kMaxRange.
-  UInt32 Generate(UInt32 range);
-
- private:
-  UInt32 state_;
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(Random);
-};
-
-// Defining a variable of type CompileAssertTypesEqual<T1, T2> will cause a
-// compiler error iff T1 and T2 are different types.
-template <typename T1, typename T2>
-struct CompileAssertTypesEqual;
-
-template <typename T>
-struct CompileAssertTypesEqual<T, T> {
-};
-
-// Removes the reference from a type if it is a reference type,
-// otherwise leaves it unchanged.  This is the same as
-// tr1::remove_reference, which is not widely available yet.
-template <typename T>
-struct RemoveReference { typedef T type; };  // NOLINT
-template <typename T>
-struct RemoveReference<T&> { typedef T type; };  // NOLINT
-
-// A handy wrapper around RemoveReference that works when the argument
-// T depends on template parameters.
-#define GTEST_REMOVE_REFERENCE_(T) \
-    typename ::testing::internal::RemoveReference<T>::type
-
-// Removes const from a type if it is a const type, otherwise leaves
-// it unchanged.  This is the same as tr1::remove_const, which is not
-// widely available yet.
-template <typename T>
-struct RemoveConst { typedef T type; };  // NOLINT
-template <typename T>
-struct RemoveConst<const T> { typedef T type; };  // NOLINT
-
-// MSVC 8.0, Sun C++, and IBM XL C++ have a bug which causes the above
-// definition to fail to remove the const in 'const int[3]' and 'const
-// char[3][4]'.  The following specialization works around the bug.
-// However, it causes trouble with GCC and thus needs to be
-// conditionally compiled.
-#if defined(_MSC_VER) || defined(__SUNPRO_CC) || defined(__IBMCPP__)
-template <typename T, size_t N>
-struct RemoveConst<const T[N]> {
-  typedef typename RemoveConst<T>::type type[N];
-};
-#endif
-
-// A handy wrapper around RemoveConst that works when the argument
-// T depends on template parameters.
-#define GTEST_REMOVE_CONST_(T) \
-    typename ::testing::internal::RemoveConst<T>::type
-
-// Turns const U&, U&, const U, and U all into U.
-#define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \
-    GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(T))
-
-// Adds reference to a type if it is not a reference type,
-// otherwise leaves it unchanged.  This is the same as
-// tr1::add_reference, which is not widely available yet.
-template <typename T>
-struct AddReference { typedef T& type; };  // NOLINT
-template <typename T>
-struct AddReference<T&> { typedef T& type; };  // NOLINT
-
-// A handy wrapper around AddReference that works when the argument T
-// depends on template parameters.
-#define GTEST_ADD_REFERENCE_(T) \
-    typename ::testing::internal::AddReference<T>::type
-
-// Adds a reference to const on top of T as necessary.  For example,
-// it transforms
-//
-//   char         ==> const char&
-//   const char   ==> const char&
-//   char&        ==> const char&
-//   const char&  ==> const char&
-//
-// The argument T must depend on some template parameters.
-#define GTEST_REFERENCE_TO_CONST_(T) \
-    GTEST_ADD_REFERENCE_(const GTEST_REMOVE_REFERENCE_(T))
-
-// ImplicitlyConvertible<From, To>::value is a compile-time bool
-// constant that's true iff type From can be implicitly converted to
-// type To.
-template <typename From, typename To>
-class ImplicitlyConvertible {
- private:
-  // We need the following helper functions only for their types.
-  // They have no implementations.
-
-  // MakeFrom() is an expression whose type is From.  We cannot simply
-  // use From(), as the type From may not have a public default
-  // constructor.
-  static From MakeFrom();
-
-  // These two functions are overloaded.  Given an expression
-  // Helper(x), the compiler will pick the first version if x can be
-  // implicitly converted to type To; otherwise it will pick the
-  // second version.
-  //
-  // The first version returns a value of size 1, and the second
-  // version returns a value of size 2.  Therefore, by checking the
-  // size of Helper(x), which can be done at compile time, we can tell
-  // which version of Helper() is used, and hence whether x can be
-  // implicitly converted to type To.
-  static char Helper(To);
-  static char (&Helper(...))[2];  // NOLINT
-
-  // We have to put the 'public' section after the 'private' section,
-  // or MSVC refuses to compile the code.
- public:
-  // MSVC warns about implicitly converting from double to int for
-  // possible loss of data, so we need to temporarily disable the
-  // warning.
-#ifdef _MSC_VER
-# pragma warning(push)          // Saves the current warning state.
-# pragma warning(disable:4244)  // Temporarily disables warning 4244.
-
-  static const bool value =
-      sizeof(Helper(ImplicitlyConvertible::MakeFrom())) == 1;
-# pragma warning(pop)           // Restores the warning state.
-#elif defined(__BORLANDC__)
-  // C++Builder cannot use member overload resolution during template
-  // instantiation.  The simplest workaround is to use its C++0x type traits
-  // functions (C++Builder 2009 and above only).
-  static const bool value = __is_convertible(From, To);
-#else
-  static const bool value =
-      sizeof(Helper(ImplicitlyConvertible::MakeFrom())) == 1;
-#endif  // _MSV_VER
-};
-template <typename From, typename To>
-const bool ImplicitlyConvertible<From, To>::value;
-
-// IsAProtocolMessage<T>::value is a compile-time bool constant that's
-// true iff T is type ProtocolMessage, proto2::Message, or a subclass
-// of those.
-template <typename T>
-struct IsAProtocolMessage
-    : public bool_constant<
-  ImplicitlyConvertible<const T*, const ::ProtocolMessage*>::value ||
-  ImplicitlyConvertible<const T*, const ::proto2::Message*>::value> {
-};
-
-// When the compiler sees expression IsContainerTest<C>(0), if C is an
-// STL-style container class, the first overload of IsContainerTest
-// will be viable (since both C::iterator* and C::const_iterator* are
-// valid types and NULL can be implicitly converted to them).  It will
-// be picked over the second overload as 'int' is a perfect match for
-// the type of argument 0.  If C::iterator or C::const_iterator is not
-// a valid type, the first overload is not viable, and the second
-// overload will be picked.  Therefore, we can determine whether C is
-// a container class by checking the type of IsContainerTest<C>(0).
-// The value of the expression is insignificant.
-//
-// Note that we look for both C::iterator and C::const_iterator.  The
-// reason is that C++ injects the name of a class as a member of the
-// class itself (e.g. you can refer to class iterator as either
-// 'iterator' or 'iterator::iterator').  If we look for C::iterator
-// only, for example, we would mistakenly think that a class named
-// iterator is an STL container.
-//
-// Also note that the simpler approach of overloading
-// IsContainerTest(typename C::const_iterator*) and
-// IsContainerTest(...) doesn't work with Visual Age C++ and Sun C++.
-typedef int IsContainer;
-template <class C>
-IsContainer IsContainerTest(int /* dummy */,
-                            typename C::iterator* /* it */ = NULL,
-                            typename C::const_iterator* /* const_it */ = NULL) {
-  return 0;
-}
-
-typedef char IsNotContainer;
-template <class C>
-IsNotContainer IsContainerTest(long /* dummy */) { return '\0'; }
-
-// EnableIf<condition>::type is void when 'Cond' is true, and
-// undefined when 'Cond' is false.  To use SFINAE to make a function
-// overload only apply when a particular expression is true, add
-// "typename EnableIf<expression>::type* = 0" as the last parameter.
-template<bool> struct EnableIf;
-template<> struct EnableIf<true> { typedef void type; };  // NOLINT
-
-// Utilities for native arrays.
-
-// ArrayEq() compares two k-dimensional native arrays using the
-// elements' operator==, where k can be any integer >= 0.  When k is
-// 0, ArrayEq() degenerates into comparing a single pair of values.
-
-template <typename T, typename U>
-bool ArrayEq(const T* lhs, size_t size, const U* rhs);
-
-// This generic version is used when k is 0.
-template <typename T, typename U>
-inline bool ArrayEq(const T& lhs, const U& rhs) { return lhs == rhs; }
-
-// This overload is used when k >= 1.
-template <typename T, typename U, size_t N>
-inline bool ArrayEq(const T(&lhs)[N], const U(&rhs)[N]) {
-  return internal::ArrayEq(lhs, N, rhs);
-}
-
-// This helper reduces code bloat.  If we instead put its logic inside
-// the previous ArrayEq() function, arrays with different sizes would
-// lead to different copies of the template code.
-template <typename T, typename U>
-bool ArrayEq(const T* lhs, size_t size, const U* rhs) {
-  for (size_t i = 0; i != size; i++) {
-    if (!internal::ArrayEq(lhs[i], rhs[i]))
-      return false;
-  }
-  return true;
-}
-
-// Finds the first element in the iterator range [begin, end) that
-// equals elem.  Element may be a native array type itself.
-template <typename Iter, typename Element>
-Iter ArrayAwareFind(Iter begin, Iter end, const Element& elem) {
-  for (Iter it = begin; it != end; ++it) {
-    if (internal::ArrayEq(*it, elem))
-      return it;
-  }
-  return end;
-}
-
-// CopyArray() copies a k-dimensional native array using the elements'
-// operator=, where k can be any integer >= 0.  When k is 0,
-// CopyArray() degenerates into copying a single value.
-
-template <typename T, typename U>
-void CopyArray(const T* from, size_t size, U* to);
-
-// This generic version is used when k is 0.
-template <typename T, typename U>
-inline void CopyArray(const T& from, U* to) { *to = from; }
-
-// This overload is used when k >= 1.
-template <typename T, typename U, size_t N>
-inline void CopyArray(const T(&from)[N], U(*to)[N]) {
-  internal::CopyArray(from, N, *to);
-}
-
-// This helper reduces code bloat.  If we instead put its logic inside
-// the previous CopyArray() function, arrays with different sizes
-// would lead to different copies of the template code.
-template <typename T, typename U>
-void CopyArray(const T* from, size_t size, U* to) {
-  for (size_t i = 0; i != size; i++) {
-    internal::CopyArray(from[i], to + i);
-  }
-}
-
-// The relation between an NativeArray object (see below) and the
-// native array it represents.
-enum RelationToSource {
-  kReference,  // The NativeArray references the native array.
-  kCopy        // The NativeArray makes a copy of the native array and
-               // owns the copy.
-};
-
-// Adapts a native array to a read-only STL-style container.  Instead
-// of the complete STL container concept, this adaptor only implements
-// members useful for Google Mock's container matchers.  New members
-// should be added as needed.  To simplify the implementation, we only
-// support Element being a raw type (i.e. having no top-level const or
-// reference modifier).  It's the client's responsibility to satisfy
-// this requirement.  Element can be an array type itself (hence
-// multi-dimensional arrays are supported).
-template <typename Element>
-class NativeArray {
- public:
-  // STL-style container typedefs.
-  typedef Element value_type;
-  typedef Element* iterator;
-  typedef const Element* const_iterator;
-
-  // Constructs from a native array.
-  NativeArray(const Element* array, size_t count, RelationToSource relation) {
-    Init(array, count, relation);
-  }
-
-  // Copy constructor.
-  NativeArray(const NativeArray& rhs) {
-    Init(rhs.array_, rhs.size_, rhs.relation_to_source_);
-  }
-
-  ~NativeArray() {
-    // Ensures that the user doesn't instantiate NativeArray with a
-    // const or reference type.
-    static_cast<void>(StaticAssertTypeEqHelper<Element,
-        GTEST_REMOVE_REFERENCE_AND_CONST_(Element)>());
-    if (relation_to_source_ == kCopy)
-      delete[] array_;
-  }
-
-  // STL-style container methods.
-  size_t size() const { return size_; }
-  const_iterator begin() const { return array_; }
-  const_iterator end() const { return array_ + size_; }
-  bool operator==(const NativeArray& rhs) const {
-    return size() == rhs.size() &&
-        ArrayEq(begin(), size(), rhs.begin());
-  }
-
- private:
-  // Initializes this object; makes a copy of the input array if
-  // 'relation' is kCopy.
-  void Init(const Element* array, size_t a_size, RelationToSource relation) {
-    if (relation == kReference) {
-      array_ = array;
-    } else {
-      Element* const copy = new Element[a_size];
-      CopyArray(array, a_size, copy);
-      array_ = copy;
-    }
-    size_ = a_size;
-    relation_to_source_ = relation;
-  }
-
-  const Element* array_;
-  size_t size_;
-  RelationToSource relation_to_source_;
-
-  GTEST_DISALLOW_ASSIGN_(NativeArray);
-};
-
-}  // namespace internal
-}  // namespace testing
-
-#define GTEST_MESSAGE_AT_(file, line, message, result_type) \
-  ::testing::internal::AssertHelper(result_type, file, line, message) \
-    = ::testing::Message()
-
-#define GTEST_MESSAGE_(message, result_type) \
-  GTEST_MESSAGE_AT_(__FILE__, __LINE__, message, result_type)
-
-#define GTEST_FATAL_FAILURE_(message) \
-  return GTEST_MESSAGE_(message, ::testing::TestPartResult::kFatalFailure)
-
-#define GTEST_NONFATAL_FAILURE_(message) \
-  GTEST_MESSAGE_(message, ::testing::TestPartResult::kNonFatalFailure)
-
-#define GTEST_SUCCESS_(message) \
-  GTEST_MESSAGE_(message, ::testing::TestPartResult::kSuccess)
-
-// Suppresses MSVC warnings 4072 (unreachable code) for the code following
-// statement if it returns or throws (or doesn't return or throw in some
-// situations).
-#define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \
-  if (::testing::internal::AlwaysTrue()) { statement; }
-
-#define GTEST_TEST_THROW_(statement, expected_exception, fail) \
-  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
-  if (::testing::internal::ConstCharPtr gtest_msg = "") { \
-    bool gtest_caught_expected = false; \
-    try { \
-      GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
-    } \
-    catch (expected_exception const&) { \
-      gtest_caught_expected = true; \
-    } \
-    catch (...) { \
-      gtest_msg.value = \
-          "Expected: " #statement " throws an exception of type " \
-          #expected_exception ".\n  Actual: it throws a different type."; \
-      goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
-    } \
-    if (!gtest_caught_expected) { \
-      gtest_msg.value = \
-          "Expected: " #statement " throws an exception of type " \
-          #expected_exception ".\n  Actual: it throws nothing."; \
-      goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
-    } \
-  } else \
-    GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \
-      fail(gtest_msg.value)
-
-#define GTEST_TEST_NO_THROW_(statement, fail) \
-  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
-  if (::testing::internal::AlwaysTrue()) { \
-    try { \
-      GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
-    } \
-    catch (...) { \
-      goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
-    } \
-  } else \
-    GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \
-      fail("Expected: " #statement " doesn't throw an exception.\n" \
-           "  Actual: it throws.")
-
-#define GTEST_TEST_ANY_THROW_(statement, fail) \
-  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
-  if (::testing::internal::AlwaysTrue()) { \
-    bool gtest_caught_any = false; \
-    try { \
-      GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
-    } \
-    catch (...) { \
-      gtest_caught_any = true; \
-    } \
-    if (!gtest_caught_any) { \
-      goto GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__); \
-    } \
-  } else \
-    GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__): \
-      fail("Expected: " #statement " throws an exception.\n" \
-           "  Actual: it doesn't.")
-
-
-// Implements Boolean test assertions such as EXPECT_TRUE. expression can be
-// either a boolean expression or an AssertionResult. text is a textual
-// represenation of expression as it was passed into the EXPECT_TRUE.
-#define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \
-  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
-  if (const ::testing::AssertionResult gtest_ar_ = \
-      ::testing::AssertionResult(expression)) \
-    ; \
-  else \
-    fail(::testing::internal::GetBoolAssertionFailureMessage(\
-        gtest_ar_, text, #actual, #expected).c_str())
-
-#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \
-  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
-  if (::testing::internal::AlwaysTrue()) { \
-    ::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \
-    GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
-    if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \
-      goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \
-    } \
-  } else \
-    GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \
-      fail("Expected: " #statement " doesn't generate new fatal " \
-           "failures in the current thread.\n" \
-           "  Actual: it does.")
-
-// Expands to the name of the class that implements the given test.
-#define GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
-  test_case_name##_##test_name##_Test
-
-// Helper macro for defining tests.
-#define GTEST_TEST_(test_case_name, test_name, parent_class, parent_id)\
-class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public parent_class {\
- public:\
-  GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {}\
- private:\
-  virtual void TestBody();\
-  static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;\
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(\
-      GTEST_TEST_CLASS_NAME_(test_case_name, test_name));\
-};\
-\
-::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_case_name, test_name)\
-  ::test_info_ =\
-    ::testing::internal::MakeAndRegisterTestInfo(\
-        #test_case_name, #test_name, NULL, NULL, \
-        (parent_id), \
-        parent_class::SetUpTestCase, \
-        parent_class::TearDownTestCase, \
-        new ::testing::internal::TestFactoryImpl<\
-            GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>);\
-void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody()
-
-#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
-// Copyright 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan at google.com (Zhanyong Wan)
-//
-// The Google C++ Testing Framework (Google Test)
-//
-// This header file defines the public API for death tests.  It is
-// #included by gtest.h so a user doesn't need to include this
-// directly.
-
-#ifndef GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
-#define GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
-
-// Copyright 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Authors: wan at google.com (Zhanyong Wan), eefacm at gmail.com (Sean Mcafee)
-//
-// The Google C++ Testing Framework (Google Test)
-//
-// This header file defines internal utilities needed for implementing
-// death tests.  They are subject to change without notice.
-
-#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
-#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
-
-
-#include <stdio.h>
-
-namespace testing {
-namespace internal {
-
-GTEST_DECLARE_string_(internal_run_death_test);
-
-// Names of the flags (needed for parsing Google Test flags).
-const char kDeathTestStyleFlag[] = "death_test_style";
-const char kDeathTestUseFork[] = "death_test_use_fork";
-const char kInternalRunDeathTestFlag[] = "internal_run_death_test";
-
-#if GTEST_HAS_DEATH_TEST
-
-// DeathTest is a class that hides much of the complexity of the
-// GTEST_DEATH_TEST_ macro.  It is abstract; its static Create method
-// returns a concrete class that depends on the prevailing death test
-// style, as defined by the --gtest_death_test_style and/or
-// --gtest_internal_run_death_test flags.
-
-// In describing the results of death tests, these terms are used with
-// the corresponding definitions:
-//
-// exit status:  The integer exit information in the format specified
-//               by wait(2)
-// exit code:    The integer code passed to exit(3), _exit(2), or
-//               returned from main()
-class GTEST_API_ DeathTest {
- public:
-  // Create returns false if there was an error determining the
-  // appropriate action to take for the current death test; for example,
-  // if the gtest_death_test_style flag is set to an invalid value.
-  // The LastMessage method will return a more detailed message in that
-  // case.  Otherwise, the DeathTest pointer pointed to by the "test"
-  // argument is set.  If the death test should be skipped, the pointer
-  // is set to NULL; otherwise, it is set to the address of a new concrete
-  // DeathTest object that controls the execution of the current test.
-  static bool Create(const char* statement, const RE* regex,
-                     const char* file, int line, DeathTest** test);
-  DeathTest();
-  virtual ~DeathTest() { }
-
-  // A helper class that aborts a death test when it's deleted.
-  class ReturnSentinel {
-   public:
-    explicit ReturnSentinel(DeathTest* test) : test_(test) { }
-    ~ReturnSentinel() { test_->Abort(TEST_ENCOUNTERED_RETURN_STATEMENT); }
-   private:
-    DeathTest* const test_;
-    GTEST_DISALLOW_COPY_AND_ASSIGN_(ReturnSentinel);
-  } GTEST_ATTRIBUTE_UNUSED_;
-
-  // An enumeration of possible roles that may be taken when a death
-  // test is encountered.  EXECUTE means that the death test logic should
-  // be executed immediately.  OVERSEE means that the program should prepare
-  // the appropriate environment for a child process to execute the death
-  // test, then wait for it to complete.
-  enum TestRole { OVERSEE_TEST, EXECUTE_TEST };
-
-  // An enumeration of the three reasons that a test might be aborted.
-  enum AbortReason {
-    TEST_ENCOUNTERED_RETURN_STATEMENT,
-    TEST_THREW_EXCEPTION,
-    TEST_DID_NOT_DIE
-  };
-
-  // Assumes one of the above roles.
-  virtual TestRole AssumeRole() = 0;
-
-  // Waits for the death test to finish and returns its status.
-  virtual int Wait() = 0;
-
-  // Returns true if the death test passed; that is, the test process
-  // exited during the test, its exit status matches a user-supplied
-  // predicate, and its stderr output matches a user-supplied regular
-  // expression.
-  // The user-supplied predicate may be a macro expression rather
-  // than a function pointer or functor, or else Wait and Passed could
-  // be combined.
-  virtual bool Passed(bool exit_status_ok) = 0;
-
-  // Signals that the death test did not die as expected.
-  virtual void Abort(AbortReason reason) = 0;
-
-  // Returns a human-readable outcome message regarding the outcome of
-  // the last death test.
-  static const char* LastMessage();
-
-  static void set_last_death_test_message(const String& message);
-
- private:
-  // A string containing a description of the outcome of the last death test.
-  static String last_death_test_message_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(DeathTest);
-};
-
-// Factory interface for death tests.  May be mocked out for testing.
-class DeathTestFactory {
- public:
-  virtual ~DeathTestFactory() { }
-  virtual bool Create(const char* statement, const RE* regex,
-                      const char* file, int line, DeathTest** test) = 0;
-};
-
-// A concrete DeathTestFactory implementation for normal use.
-class DefaultDeathTestFactory : public DeathTestFactory {
- public:
-  virtual bool Create(const char* statement, const RE* regex,
-                      const char* file, int line, DeathTest** test);
-};
-
-// Returns true if exit_status describes a process that was terminated
-// by a signal, or exited normally with a nonzero exit code.
-GTEST_API_ bool ExitedUnsuccessfully(int exit_status);
-
-// Traps C++ exceptions escaping statement and reports them as test
-// failures. Note that trapping SEH exceptions is not implemented here.
-# if GTEST_HAS_EXCEPTIONS
-#  define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
-  try { \
-    GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
-  } catch (const ::std::exception& gtest_exception) { \
-    fprintf(\
-        stderr, \
-        "\n%s: Caught std::exception-derived exception escaping the " \
-        "death test statement. Exception message: %s\n", \
-        ::testing::internal::FormatFileLocation(__FILE__, __LINE__).c_str(), \
-        gtest_exception.what()); \
-    fflush(stderr); \
-    death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
-  } catch (...) { \
-    death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
-  }
-
-# else
-#  define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
-  GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
-
-# endif
-
-// This macro is for implementing ASSERT_DEATH*, EXPECT_DEATH*,
-// ASSERT_EXIT*, and EXPECT_EXIT*.
-# define GTEST_DEATH_TEST_(statement, predicate, regex, fail) \
-  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
-  if (::testing::internal::AlwaysTrue()) { \
-    const ::testing::internal::RE& gtest_regex = (regex); \
-    ::testing::internal::DeathTest* gtest_dt; \
-    if (!::testing::internal::DeathTest::Create(#statement, &gtest_regex, \
-        __FILE__, __LINE__, &gtest_dt)) { \
-      goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
-    } \
-    if (gtest_dt != NULL) { \
-      ::testing::internal::scoped_ptr< ::testing::internal::DeathTest> \
-          gtest_dt_ptr(gtest_dt); \
-      switch (gtest_dt->AssumeRole()) { \
-        case ::testing::internal::DeathTest::OVERSEE_TEST: \
-          if (!gtest_dt->Passed(predicate(gtest_dt->Wait()))) { \
-            goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
-          } \
-          break; \
-        case ::testing::internal::DeathTest::EXECUTE_TEST: { \
-          ::testing::internal::DeathTest::ReturnSentinel \
-              gtest_sentinel(gtest_dt); \
-          GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, gtest_dt); \
-          gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); \
-          break; \
-        } \
-        default: \
-          break; \
-      } \
-    } \
-  } else \
-    GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__): \
-      fail(::testing::internal::DeathTest::LastMessage())
-// The symbol "fail" here expands to something into which a message
-// can be streamed.
-
-// A class representing the parsed contents of the
-// --gtest_internal_run_death_test flag, as it existed when
-// RUN_ALL_TESTS was called.
-class InternalRunDeathTestFlag {
- public:
-  InternalRunDeathTestFlag(const String& a_file,
-                           int a_line,
-                           int an_index,
-                           int a_write_fd)
-      : file_(a_file), line_(a_line), index_(an_index),
-        write_fd_(a_write_fd) {}
-
-  ~InternalRunDeathTestFlag() {
-    if (write_fd_ >= 0)
-      posix::Close(write_fd_);
-  }
-
-  String file() const { return file_; }
-  int line() const { return line_; }
-  int index() const { return index_; }
-  int write_fd() const { return write_fd_; }
-
- private:
-  String file_;
-  int line_;
-  int index_;
-  int write_fd_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(InternalRunDeathTestFlag);
-};
-
-// Returns a newly created InternalRunDeathTestFlag object with fields
-// initialized from the GTEST_FLAG(internal_run_death_test) flag if
-// the flag is specified; otherwise returns NULL.
-InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag();
-
-#else  // GTEST_HAS_DEATH_TEST
-
-// This macro is used for implementing macros such as
-// EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED on systems where
-// death tests are not supported. Those macros must compile on such systems
-// iff EXPECT_DEATH and ASSERT_DEATH compile with the same parameters on
-// systems that support death tests. This allows one to write such a macro
-// on a system that does not support death tests and be sure that it will
-// compile on a death-test supporting system.
-//
-// Parameters:
-//   statement -  A statement that a macro such as EXPECT_DEATH would test
-//                for program termination. This macro has to make sure this
-//                statement is compiled but not executed, to ensure that
-//                EXPECT_DEATH_IF_SUPPORTED compiles with a certain
-//                parameter iff EXPECT_DEATH compiles with it.
-//   regex     -  A regex that a macro such as EXPECT_DEATH would use to test
-//                the output of statement.  This parameter has to be
-//                compiled but not evaluated by this macro, to ensure that
-//                this macro only accepts expressions that a macro such as
-//                EXPECT_DEATH would accept.
-//   terminator - Must be an empty statement for EXPECT_DEATH_IF_SUPPORTED
-//                and a return statement for ASSERT_DEATH_IF_SUPPORTED.
-//                This ensures that ASSERT_DEATH_IF_SUPPORTED will not
-//                compile inside functions where ASSERT_DEATH doesn't
-//                compile.
-//
-//  The branch that has an always false condition is used to ensure that
-//  statement and regex are compiled (and thus syntactically correct) but
-//  never executed. The unreachable code macro protects the terminator
-//  statement from generating an 'unreachable code' warning in case
-//  statement unconditionally returns or throws. The Message constructor at
-//  the end allows the syntax of streaming additional messages into the
-//  macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH.
-# define GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, terminator) \
-    GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
-    if (::testing::internal::AlwaysTrue()) { \
-      GTEST_LOG_(WARNING) \
-          << "Death tests are not supported on this platform.\n" \
-          << "Statement '" #statement "' cannot be verified."; \
-    } else if (::testing::internal::AlwaysFalse()) { \
-      ::testing::internal::RE::PartialMatch(".*", (regex)); \
-      GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
-      terminator; \
-    } else \
-      ::testing::Message()
-
-#endif  // GTEST_HAS_DEATH_TEST
-
-}  // namespace internal
-}  // namespace testing
-
-#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
-
-namespace testing {
-
-// This flag controls the style of death tests.  Valid values are "threadsafe",
-// meaning that the death test child process will re-execute the test binary
-// from the start, running only a single death test, or "fast",
-// meaning that the child process will execute the test logic immediately
-// after forking.
-GTEST_DECLARE_string_(death_test_style);
-
-#if GTEST_HAS_DEATH_TEST
-
-// The following macros are useful for writing death tests.
-
-// Here's what happens when an ASSERT_DEATH* or EXPECT_DEATH* is
-// executed:
-//
-//   1. It generates a warning if there is more than one active
-//   thread.  This is because it's safe to fork() or clone() only
-//   when there is a single thread.
-//
-//   2. The parent process clone()s a sub-process and runs the death
-//   test in it; the sub-process exits with code 0 at the end of the
-//   death test, if it hasn't exited already.
-//
-//   3. The parent process waits for the sub-process to terminate.
-//
-//   4. The parent process checks the exit code and error message of
-//   the sub-process.
-//
-// Examples:
-//
-//   ASSERT_DEATH(server.SendMessage(56, "Hello"), "Invalid port number");
-//   for (int i = 0; i < 5; i++) {
-//     EXPECT_DEATH(server.ProcessRequest(i),
-//                  "Invalid request .* in ProcessRequest()")
-//         << "Failed to die on request " << i);
-//   }
-//
-//   ASSERT_EXIT(server.ExitNow(), ::testing::ExitedWithCode(0), "Exiting");
-//
-//   bool KilledBySIGHUP(int exit_code) {
-//     return WIFSIGNALED(exit_code) && WTERMSIG(exit_code) == SIGHUP;
-//   }
-//
-//   ASSERT_EXIT(client.HangUpServer(), KilledBySIGHUP, "Hanging up!");
-//
-// On the regular expressions used in death tests:
-//
-//   On POSIX-compliant systems (*nix), we use the <regex.h> library,
-//   which uses the POSIX extended regex syntax.
-//
-//   On other platforms (e.g. Windows), we only support a simple regex
-//   syntax implemented as part of Google Test.  This limited
-//   implementation should be enough most of the time when writing
-//   death tests; though it lacks many features you can find in PCRE
-//   or POSIX extended regex syntax.  For example, we don't support
-//   union ("x|y"), grouping ("(xy)"), brackets ("[xy]"), and
-//   repetition count ("x{5,7}"), among others.
-//
-//   Below is the syntax that we do support.  We chose it to be a
-//   subset of both PCRE and POSIX extended regex, so it's easy to
-//   learn wherever you come from.  In the following: 'A' denotes a
-//   literal character, period (.), or a single \\ escape sequence;
-//   'x' and 'y' denote regular expressions; 'm' and 'n' are for
-//   natural numbers.
-//
-//     c     matches any literal character c
-//     \\d   matches any decimal digit
-//     \\D   matches any character that's not a decimal digit
-//     \\f   matches \f
-//     \\n   matches \n
-//     \\r   matches \r
-//     \\s   matches any ASCII whitespace, including \n
-//     \\S   matches any character that's not a whitespace
-//     \\t   matches \t
-//     \\v   matches \v
-//     \\w   matches any letter, _, or decimal digit
-//     \\W   matches any character that \\w doesn't match
-//     \\c   matches any literal character c, which must be a punctuation
-//     .     matches any single character except \n
-//     A?    matches 0 or 1 occurrences of A
-//     A*    matches 0 or many occurrences of A
-//     A+    matches 1 or many occurrences of A
-//     ^     matches the beginning of a string (not that of each line)
-//     $     matches the end of a string (not that of each line)
-//     xy    matches x followed by y
-//
-//   If you accidentally use PCRE or POSIX extended regex features
-//   not implemented by us, you will get a run-time failure.  In that
-//   case, please try to rewrite your regular expression within the
-//   above syntax.
-//
-//   This implementation is *not* meant to be as highly tuned or robust
-//   as a compiled regex library, but should perform well enough for a
-//   death test, which already incurs significant overhead by launching
-//   a child process.
-//
-// Known caveats:
-//
-//   A "threadsafe" style death test obtains the path to the test
-//   program from argv[0] and re-executes it in the sub-process.  For
-//   simplicity, the current implementation doesn't search the PATH
-//   when launching the sub-process.  This means that the user must
-//   invoke the test program via a path that contains at least one
-//   path separator (e.g. path/to/foo_test and
-//   /absolute/path/to/bar_test are fine, but foo_test is not).  This
-//   is rarely a problem as people usually don't put the test binary
-//   directory in PATH.
-//
-// TODO(wan at google.com): make thread-safe death tests search the PATH.
-
-// Asserts that a given statement causes the program to exit, with an
-// integer exit status that satisfies predicate, and emitting error output
-// that matches regex.
-# define ASSERT_EXIT(statement, predicate, regex) \
-    GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_)
-
-// Like ASSERT_EXIT, but continues on to successive tests in the
-// test case, if any:
-# define EXPECT_EXIT(statement, predicate, regex) \
-    GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_)
-
-// Asserts that a given statement causes the program to exit, either by
-// explicitly exiting with a nonzero exit code or being killed by a
-// signal, and emitting error output that matches regex.
-# define ASSERT_DEATH(statement, regex) \
-    ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
-
-// Like ASSERT_DEATH, but continues on to successive tests in the
-// test case, if any:
-# define EXPECT_DEATH(statement, regex) \
-    EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
-
-// Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*:
-
-// Tests that an exit code describes a normal exit with a given exit code.
-class GTEST_API_ ExitedWithCode {
- public:
-  explicit ExitedWithCode(int exit_code);
-  bool operator()(int exit_status) const;
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ExitedWithCode& other);
-
-  const int exit_code_;
-};
-
-# if !GTEST_OS_WINDOWS
-// Tests that an exit code describes an exit due to termination by a
-// given signal.
-class GTEST_API_ KilledBySignal {
- public:
-  explicit KilledBySignal(int signum);
-  bool operator()(int exit_status) const;
- private:
-  const int signum_;
-};
-# endif  // !GTEST_OS_WINDOWS
-
-// EXPECT_DEBUG_DEATH asserts that the given statements die in debug mode.
-// The death testing framework causes this to have interesting semantics,
-// since the sideeffects of the call are only visible in opt mode, and not
-// in debug mode.
-//
-// In practice, this can be used to test functions that utilize the
-// LOG(DFATAL) macro using the following style:
-//
-// int DieInDebugOr12(int* sideeffect) {
-//   if (sideeffect) {
-//     *sideeffect = 12;
-//   }
-//   LOG(DFATAL) << "death";
-//   return 12;
-// }
-//
-// TEST(TestCase, TestDieOr12WorksInDgbAndOpt) {
-//   int sideeffect = 0;
-//   // Only asserts in dbg.
-//   EXPECT_DEBUG_DEATH(DieInDebugOr12(&sideeffect), "death");
-//
-// #ifdef NDEBUG
-//   // opt-mode has sideeffect visible.
-//   EXPECT_EQ(12, sideeffect);
-// #else
-//   // dbg-mode no visible sideeffect.
-//   EXPECT_EQ(0, sideeffect);
-// #endif
-// }
-//
-// This will assert that DieInDebugReturn12InOpt() crashes in debug
-// mode, usually due to a DCHECK or LOG(DFATAL), but returns the
-// appropriate fallback value (12 in this case) in opt mode. If you
-// need to test that a function has appropriate side-effects in opt
-// mode, include assertions against the side-effects.  A general
-// pattern for this is:
-//
-// EXPECT_DEBUG_DEATH({
-//   // Side-effects here will have an effect after this statement in
-//   // opt mode, but none in debug mode.
-//   EXPECT_EQ(12, DieInDebugOr12(&sideeffect));
-// }, "death");
-//
-# ifdef NDEBUG
-
-#  define EXPECT_DEBUG_DEATH(statement, regex) \
-  do { statement; } while (::testing::internal::AlwaysFalse())
-
-#  define ASSERT_DEBUG_DEATH(statement, regex) \
-  do { statement; } while (::testing::internal::AlwaysFalse())
-
-# else
-
-#  define EXPECT_DEBUG_DEATH(statement, regex) \
-  EXPECT_DEATH(statement, regex)
-
-#  define ASSERT_DEBUG_DEATH(statement, regex) \
-  ASSERT_DEATH(statement, regex)
-
-# endif  // NDEBUG for EXPECT_DEBUG_DEATH
-#endif  // GTEST_HAS_DEATH_TEST
-
-// EXPECT_DEATH_IF_SUPPORTED(statement, regex) and
-// ASSERT_DEATH_IF_SUPPORTED(statement, regex) expand to real death tests if
-// death tests are supported; otherwise they just issue a warning.  This is
-// useful when you are combining death test assertions with normal test
-// assertions in one test.
-#if GTEST_HAS_DEATH_TEST
-# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
-    EXPECT_DEATH(statement, regex)
-# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
-    ASSERT_DEATH(statement, regex)
-#else
-# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
-    GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, )
-# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
-    GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, return)
-#endif
-
-}  // namespace testing
-
-#endif  // GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
-// Copyright 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan at google.com (Zhanyong Wan)
-//
-// The Google C++ Testing Framework (Google Test)
-//
-// This header file defines the Message class.
-//
-// IMPORTANT NOTE: Due to limitation of the C++ language, we have to
-// leave some internal implementation details in this header file.
-// They are clearly marked by comments like this:
-//
-//   // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
-//
-// Such code is NOT meant to be used by a user directly, and is subject
-// to CHANGE WITHOUT NOTICE.  Therefore DO NOT DEPEND ON IT in a user
-// program!
-
-#ifndef GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
-#define GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
-
-#include <limits>
-
-
-namespace testing {
-
-// The Message class works like an ostream repeater.
-//
-// Typical usage:
-//
-//   1. You stream a bunch of values to a Message object.
-//      It will remember the text in a stringstream.
-//   2. Then you stream the Message object to an ostream.
-//      This causes the text in the Message to be streamed
-//      to the ostream.
-//
-// For example;
-//
-//   testing::Message foo;
-//   foo << 1 << " != " << 2;
-//   std::cout << foo;
-//
-// will print "1 != 2".
-//
-// Message is not intended to be inherited from.  In particular, its
-// destructor is not virtual.
-//
-// Note that stringstream behaves differently in gcc and in MSVC.  You
-// can stream a NULL char pointer to it in the former, but not in the
-// latter (it causes an access violation if you do).  The Message
-// class hides this difference by treating a NULL char pointer as
-// "(null)".
-class GTEST_API_ Message {
- private:
-  // The type of basic IO manipulators (endl, ends, and flush) for
-  // narrow streams.
-  typedef std::ostream& (*BasicNarrowIoManip)(std::ostream&);
-
- public:
-  // Constructs an empty Message.
-  // We allocate the stringstream separately because otherwise each use of
-  // ASSERT/EXPECT in a procedure adds over 200 bytes to the procedure's
-  // stack frame leading to huge stack frames in some cases; gcc does not reuse
-  // the stack space.
-  Message() : ss_(new ::std::stringstream) {
-    // By default, we want there to be enough precision when printing
-    // a double to a Message.
-    *ss_ << std::setprecision(std::numeric_limits<double>::digits10 + 2);
-  }
-
-  // Copy constructor.
-  Message(const Message& msg) : ss_(new ::std::stringstream) {  // NOLINT
-    *ss_ << msg.GetString();
-  }
-
-  // Constructs a Message from a C-string.
-  explicit Message(const char* str) : ss_(new ::std::stringstream) {
-    *ss_ << str;
-  }
-
-#if GTEST_OS_SYMBIAN
-  // Streams a value (either a pointer or not) to this object.
-  template <typename T>
-  inline Message& operator <<(const T& value) {
-    StreamHelper(typename internal::is_pointer<T>::type(), value);
-    return *this;
-  }
-#else
-  // Streams a non-pointer value to this object.
-  template <typename T>
-  inline Message& operator <<(const T& val) {
-    ::GTestStreamToHelper(ss_.get(), val);
-    return *this;
-  }
-
-  // Streams a pointer value to this object.
-  //
-  // This function is an overload of the previous one.  When you
-  // stream a pointer to a Message, this definition will be used as it
-  // is more specialized.  (The C++ Standard, section
-  // [temp.func.order].)  If you stream a non-pointer, then the
-  // previous definition will be used.
-  //
-  // The reason for this overload is that streaming a NULL pointer to
-  // ostream is undefined behavior.  Depending on the compiler, you
-  // may get "0", "(nil)", "(null)", or an access violation.  To
-  // ensure consistent result across compilers, we always treat NULL
-  // as "(null)".
-  template <typename T>
-  inline Message& operator <<(T* const& pointer) {  // NOLINT
-    if (pointer == NULL) {
-      *ss_ << "(null)";
-    } else {
-      ::GTestStreamToHelper(ss_.get(), pointer);
-    }
-    return *this;
-  }
-#endif  // GTEST_OS_SYMBIAN
-
-  // Since the basic IO manipulators are overloaded for both narrow
-  // and wide streams, we have to provide this specialized definition
-  // of operator <<, even though its body is the same as the
-  // templatized version above.  Without this definition, streaming
-  // endl or other basic IO manipulators to Message will confuse the
-  // compiler.
-  Message& operator <<(BasicNarrowIoManip val) {
-    *ss_ << val;
-    return *this;
-  }
-
-  // Instead of 1/0, we want to see true/false for bool values.
-  Message& operator <<(bool b) {
-    return *this << (b ? "true" : "false");
-  }
-
-  // These two overloads allow streaming a wide C string to a Message
-  // using the UTF-8 encoding.
-  Message& operator <<(const wchar_t* wide_c_str) {
-    return *this << internal::String::ShowWideCString(wide_c_str);
-  }
-  Message& operator <<(wchar_t* wide_c_str) {
-    return *this << internal::String::ShowWideCString(wide_c_str);
-  }
-
-#if GTEST_HAS_STD_WSTRING
-  // Converts the given wide string to a narrow string using the UTF-8
-  // encoding, and streams the result to this Message object.
-  Message& operator <<(const ::std::wstring& wstr);
-#endif  // GTEST_HAS_STD_WSTRING
-
-#if GTEST_HAS_GLOBAL_WSTRING
-  // Converts the given wide string to a narrow string using the UTF-8
-  // encoding, and streams the result to this Message object.
-  Message& operator <<(const ::wstring& wstr);
-#endif  // GTEST_HAS_GLOBAL_WSTRING
-
-  // Gets the text streamed to this object so far as a String.
-  // Each '\0' character in the buffer is replaced with "\\0".
-  //
-  // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
-  internal::String GetString() const {
-    return internal::StringStreamToString(ss_.get());
-  }
-
- private:
-
-#if GTEST_OS_SYMBIAN
-  // These are needed as the Nokia Symbian Compiler cannot decide between
-  // const T& and const T* in a function template. The Nokia compiler _can_
-  // decide between class template specializations for T and T*, so a
-  // tr1::type_traits-like is_pointer works, and we can overload on that.
-  template <typename T>
-  inline void StreamHelper(internal::true_type /*dummy*/, T* pointer) {
-    if (pointer == NULL) {
-      *ss_ << "(null)";
-    } else {
-      ::GTestStreamToHelper(ss_.get(), pointer);
-    }
-  }
-  template <typename T>
-  inline void StreamHelper(internal::false_type /*dummy*/, const T& value) {
-    ::GTestStreamToHelper(ss_.get(), value);
-  }
-#endif  // GTEST_OS_SYMBIAN
-
-  // We'll hold the text streamed to this object here.
-  const internal::scoped_ptr< ::std::stringstream> ss_;
-
-  // We declare (but don't implement) this to prevent the compiler
-  // from implementing the assignment operator.
-  void operator=(const Message&);
-};
-
-// Streams a Message to an ostream.
-inline std::ostream& operator <<(std::ostream& os, const Message& sb) {
-  return os << sb.GetString();
-}
-
-}  // namespace testing
-
-#endif  // GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
-// This file was GENERATED by command:
-//     pump.py gtest-param-test.h.pump
-// DO NOT EDIT BY HAND!!!
-
-// Copyright 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Authors: vladl at google.com (Vlad Losev)
-//
-// Macros and functions for implementing parameterized tests
-// in Google C++ Testing Framework (Google Test)
-//
-// This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!
-//
-#ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
-#define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
-
-
-// Value-parameterized tests allow you to test your code with different
-// parameters without writing multiple copies of the same test.
-//
-// Here is how you use value-parameterized tests:
-
-#if 0
-
-// To write value-parameterized tests, first you should define a fixture
-// class. It is usually derived from testing::TestWithParam<T> (see below for
-// another inheritance scheme that's sometimes useful in more complicated
-// class hierarchies), where the type of your parameter values.
-// TestWithParam<T> is itself derived from testing::Test. T can be any
-// copyable type. If it's a raw pointer, you are responsible for managing the
-// lifespan of the pointed values.
-
-class FooTest : public ::testing::TestWithParam<const char*> {
-  // You can implement all the usual class fixture members here.
-};
-
-// Then, use the TEST_P macro to define as many parameterized tests
-// for this fixture as you want. The _P suffix is for "parameterized"
-// or "pattern", whichever you prefer to think.
-
-TEST_P(FooTest, DoesBlah) {
-  // Inside a test, access the test parameter with the GetParam() method
-  // of the TestWithParam<T> class:
-  EXPECT_TRUE(foo.Blah(GetParam()));
-  ...
-}
-
-TEST_P(FooTest, HasBlahBlah) {
-  ...
-}
-
-// Finally, you can use INSTANTIATE_TEST_CASE_P to instantiate the test
-// case with any set of parameters you want. Google Test defines a number
-// of functions for generating test parameters. They return what we call
-// (surprise!) parameter generators. Here is a  summary of them, which
-// are all in the testing namespace:
-//
-//
-//  Range(begin, end [, step]) - Yields values {begin, begin+step,
-//                               begin+step+step, ...}. The values do not
-//                               include end. step defaults to 1.
-//  Values(v1, v2, ..., vN)    - Yields values {v1, v2, ..., vN}.
-//  ValuesIn(container)        - Yields values from a C-style array, an STL
-//  ValuesIn(begin,end)          container, or an iterator range [begin, end).
-//  Bool()                     - Yields sequence {false, true}.
-//  Combine(g1, g2, ..., gN)   - Yields all combinations (the Cartesian product
-//                               for the math savvy) of the values generated
-//                               by the N generators.
-//
-// For more details, see comments at the definitions of these functions below
-// in this file.
-//
-// The following statement will instantiate tests from the FooTest test case
-// each with parameter values "meeny", "miny", and "moe".
-
-INSTANTIATE_TEST_CASE_P(InstantiationName,
-                        FooTest,
-                        Values("meeny", "miny", "moe"));
-
-// To distinguish different instances of the pattern, (yes, you
-// can instantiate it more then once) the first argument to the
-// INSTANTIATE_TEST_CASE_P macro is a prefix that will be added to the
-// actual test case name. Remember to pick unique prefixes for different
-// instantiations. The tests from the instantiation above will have
-// these names:
-//
-//    * InstantiationName/FooTest.DoesBlah/0 for "meeny"
-//    * InstantiationName/FooTest.DoesBlah/1 for "miny"
-//    * InstantiationName/FooTest.DoesBlah/2 for "moe"
-//    * InstantiationName/FooTest.HasBlahBlah/0 for "meeny"
-//    * InstantiationName/FooTest.HasBlahBlah/1 for "miny"
-//    * InstantiationName/FooTest.HasBlahBlah/2 for "moe"
-//
-// You can use these names in --gtest_filter.
-//
-// This statement will instantiate all tests from FooTest again, each
-// with parameter values "cat" and "dog":
-
-const char* pets[] = {"cat", "dog"};
-INSTANTIATE_TEST_CASE_P(AnotherInstantiationName, FooTest, ValuesIn(pets));
-
-// The tests from the instantiation above will have these names:
-//
-//    * AnotherInstantiationName/FooTest.DoesBlah/0 for "cat"
-//    * AnotherInstantiationName/FooTest.DoesBlah/1 for "dog"
-//    * AnotherInstantiationName/FooTest.HasBlahBlah/0 for "cat"
-//    * AnotherInstantiationName/FooTest.HasBlahBlah/1 for "dog"
-//
-// Please note that INSTANTIATE_TEST_CASE_P will instantiate all tests
-// in the given test case, whether their definitions come before or
-// AFTER the INSTANTIATE_TEST_CASE_P statement.
-//
-// Please also note that generator expressions (including parameters to the
-// generators) are evaluated in InitGoogleTest(), after main() has started.
-// This allows the user on one hand, to adjust generator parameters in order
-// to dynamically determine a set of tests to run and on the other hand,
-// give the user a chance to inspect the generated tests with Google Test
-// reflection API before RUN_ALL_TESTS() is executed.
-//
-// You can see samples/sample7_unittest.cc and samples/sample8_unittest.cc
-// for more examples.
-//
-// In the future, we plan to publish the API for defining new parameter
-// generators. But for now this interface remains part of the internal
-// implementation and is subject to change.
-//
-//
-// A parameterized test fixture must be derived from testing::Test and from
-// testing::WithParamInterface<T>, where T is the type of the parameter
-// values. Inheriting from TestWithParam<T> satisfies that requirement because
-// TestWithParam<T> inherits from both Test and WithParamInterface. In more
-// complicated hierarchies, however, it is occasionally useful to inherit
-// separately from Test and WithParamInterface. For example:
-
-class BaseTest : public ::testing::Test {
-  // You can inherit all the usual members for a non-parameterized test
-  // fixture here.
-};
-
-class DerivedTest : public BaseTest, public ::testing::WithParamInterface<int> {
-  // The usual test fixture members go here too.
-};
-
-TEST_F(BaseTest, HasFoo) {
-  // This is an ordinary non-parameterized test.
-}
-
-TEST_P(DerivedTest, DoesBlah) {
-  // GetParam works just the same here as if you inherit from TestWithParam.
-  EXPECT_TRUE(foo.Blah(GetParam()));
-}
-
-#endif  // 0
-
-
-#if !GTEST_OS_SYMBIAN
-# include <utility>
-#endif
-
-// scripts/fuse_gtest.py depends on gtest's own header being #included
-// *unconditionally*.  Therefore these #includes cannot be moved
-// inside #if GTEST_HAS_PARAM_TEST.
-// Copyright 2008 Google Inc.
-// All Rights Reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: vladl at google.com (Vlad Losev)
-
-// Type and function utilities for implementing parameterized tests.
-
-#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
-#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
-
-#include <iterator>
-#include <utility>
-#include <vector>
-
-// scripts/fuse_gtest.py depends on gtest's own header being #included
-// *unconditionally*.  Therefore these #includes cannot be moved
-// inside #if GTEST_HAS_PARAM_TEST.
-// Copyright 2003 Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Authors: Dan Egnor (egnor at google.com)
-//
-// A "smart" pointer type with reference tracking.  Every pointer to a
-// particular object is kept on a circular linked list.  When the last pointer
-// to an object is destroyed or reassigned, the object is deleted.
-//
-// Used properly, this deletes the object when the last reference goes away.
-// There are several caveats:
-// - Like all reference counting schemes, cycles lead to leaks.
-// - Each smart pointer is actually two pointers (8 bytes instead of 4).
-// - Every time a pointer is assigned, the entire list of pointers to that
-//   object is traversed.  This class is therefore NOT SUITABLE when there
-//   will often be more than two or three pointers to a particular object.
-// - References are only tracked as long as linked_ptr<> objects are copied.
-//   If a linked_ptr<> is converted to a raw pointer and back, BAD THINGS
-//   will happen (double deletion).
-//
-// A good use of this class is storing object references in STL containers.
-// You can safely put linked_ptr<> in a vector<>.
-// Other uses may not be as good.
-//
-// Note: If you use an incomplete type with linked_ptr<>, the class
-// *containing* linked_ptr<> must have a constructor and destructor (even
-// if they do nothing!).
-//
-// Bill Gibbons suggested we use something like this.
-//
-// Thread Safety:
-//   Unlike other linked_ptr implementations, in this implementation
-//   a linked_ptr object is thread-safe in the sense that:
-//     - it's safe to copy linked_ptr objects concurrently,
-//     - it's safe to copy *from* a linked_ptr and read its underlying
-//       raw pointer (e.g. via get()) concurrently, and
-//     - it's safe to write to two linked_ptrs that point to the same
-//       shared object concurrently.
-// TODO(wan at google.com): rename this to safe_linked_ptr to avoid
-// confusion with normal linked_ptr.
-
-#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_
-#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_
-
-#include <stdlib.h>
-#include <assert.h>
-
-
-namespace testing {
-namespace internal {
-
-// Protects copying of all linked_ptr objects.
-GTEST_API_ GTEST_DECLARE_STATIC_MUTEX_(g_linked_ptr_mutex);
-
-// This is used internally by all instances of linked_ptr<>.  It needs to be
-// a non-template class because different types of linked_ptr<> can refer to
-// the same object (linked_ptr<Superclass>(obj) vs linked_ptr<Subclass>(obj)).
-// So, it needs to be possible for different types of linked_ptr to participate
-// in the same circular linked list, so we need a single class type here.
-//
-// DO NOT USE THIS CLASS DIRECTLY YOURSELF.  Use linked_ptr<T>.
-class linked_ptr_internal {
- public:
-  // Create a new circle that includes only this instance.
-  void join_new() {
-    next_ = this;
-  }
-
-  // Many linked_ptr operations may change p.link_ for some linked_ptr
-  // variable p in the same circle as this object.  Therefore we need
-  // to prevent two such operations from occurring concurrently.
-  //
-  // Note that different types of linked_ptr objects can coexist in a
-  // circle (e.g. linked_ptr<Base>, linked_ptr<Derived1>, and
-  // linked_ptr<Derived2>).  Therefore we must use a single mutex to
-  // protect all linked_ptr objects.  This can create serious
-  // contention in production code, but is acceptable in a testing
-  // framework.
-
-  // Join an existing circle.
-  // L < g_linked_ptr_mutex
-  void join(linked_ptr_internal const* ptr) {
-    MutexLock lock(&g_linked_ptr_mutex);
-
-    linked_ptr_internal const* p = ptr;
-    while (p->next_ != ptr) p = p->next_;
-    p->next_ = this;
-    next_ = ptr;
-  }
-
-  // Leave whatever circle we're part of.  Returns true if we were the
-  // last member of the circle.  Once this is done, you can join() another.
-  // L < g_linked_ptr_mutex
-  bool depart() {
-    MutexLock lock(&g_linked_ptr_mutex);
-
-    if (next_ == this) return true;
-    linked_ptr_internal const* p = next_;
-    while (p->next_ != this) p = p->next_;
-    p->next_ = next_;
-    return false;
-  }
-
- private:
-  mutable linked_ptr_internal const* next_;
-};
-
-template <typename T>
-class linked_ptr {
- public:
-  typedef T element_type;
-
-  // Take over ownership of a raw pointer.  This should happen as soon as
-  // possible after the object is created.
-  explicit linked_ptr(T* ptr = NULL) { capture(ptr); }
-  ~linked_ptr() { depart(); }
-
-  // Copy an existing linked_ptr<>, adding ourselves to the list of references.
-  template <typename U> linked_ptr(linked_ptr<U> const& ptr) { copy(&ptr); }
-  linked_ptr(linked_ptr const& ptr) {  // NOLINT
-    assert(&ptr != this);
-    copy(&ptr);
-  }
-
-  // Assignment releases the old value and acquires the new.
-  template <typename U> linked_ptr& operator=(linked_ptr<U> const& ptr) {
-    depart();
-    copy(&ptr);
-    return *this;
-  }
-
-  linked_ptr& operator=(linked_ptr const& ptr) {
-    if (&ptr != this) {
-      depart();
-      copy(&ptr);
-    }
-    return *this;
-  }
-
-  // Smart pointer members.
-  void reset(T* ptr = NULL) {
-    depart();
-    capture(ptr);
-  }
-  T* get() const { return value_; }
-  T* operator->() const { return value_; }
-  T& operator*() const { return *value_; }
-
-  bool operator==(T* p) const { return value_ == p; }
-  bool operator!=(T* p) const { return value_ != p; }
-  template <typename U>
-  bool operator==(linked_ptr<U> const& ptr) const {
-    return value_ == ptr.get();
-  }
-  template <typename U>
-  bool operator!=(linked_ptr<U> const& ptr) const {
-    return value_ != ptr.get();
-  }
-
- private:
-  template <typename U>
-  friend class linked_ptr;
-
-  T* value_;
-  linked_ptr_internal link_;
-
-  void depart() {
-    if (link_.depart()) delete value_;
-  }
-
-  void capture(T* ptr) {
-    value_ = ptr;
-    link_.join_new();
-  }
-
-  template <typename U> void copy(linked_ptr<U> const* ptr) {
-    value_ = ptr->get();
-    if (value_)
-      link_.join(&ptr->link_);
-    else
-      link_.join_new();
-  }
-};
-
-template<typename T> inline
-bool operator==(T* ptr, const linked_ptr<T>& x) {
-  return ptr == x.get();
-}
-
-template<typename T> inline
-bool operator!=(T* ptr, const linked_ptr<T>& x) {
-  return ptr != x.get();
-}
-
-// A function to convert T* into linked_ptr<T>
-// Doing e.g. make_linked_ptr(new FooBarBaz<type>(arg)) is a shorter notation
-// for linked_ptr<FooBarBaz<type> >(new FooBarBaz<type>(arg))
-template <typename T>
-linked_ptr<T> make_linked_ptr(T* ptr) {
-  return linked_ptr<T>(ptr);
-}
-
-}  // namespace internal
-}  // namespace testing
-
-#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_
-// Copyright 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan at google.com (Zhanyong Wan)
-
-// Google Test - The Google C++ Testing Framework
-//
-// This file implements a universal value printer that can print a
-// value of any type T:
-//
-//   void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_ptr);
-//
-// A user can teach this function how to print a class type T by
-// defining either operator<<() or PrintTo() in the namespace that
-// defines T.  More specifically, the FIRST defined function in the
-// following list will be used (assuming T is defined in namespace
-// foo):
-//
-//   1. foo::PrintTo(const T&, ostream*)
-//   2. operator<<(ostream&, const T&) defined in either foo or the
-//      global namespace.
-//
-// If none of the above is defined, it will print the debug string of
-// the value if it is a protocol buffer, or print the raw bytes in the
-// value otherwise.
-//
-// To aid debugging: when T is a reference type, the address of the
-// value is also printed; when T is a (const) char pointer, both the
-// pointer value and the NUL-terminated string it points to are
-// printed.
-//
-// We also provide some convenient wrappers:
-//
-//   // Prints a value to a string.  For a (const or not) char
-//   // pointer, the NUL-terminated string (but not the pointer) is
-//   // printed.
-//   std::string ::testing::PrintToString(const T& value);
-//
-//   // Prints a value tersely: for a reference type, the referenced
-//   // value (but not the address) is printed; for a (const or not) char
-//   // pointer, the NUL-terminated string (but not the pointer) is
-//   // printed.
-//   void ::testing::internal::UniversalTersePrint(const T& value, ostream*);
-//
-//   // Prints value using the type inferred by the compiler.  The difference
-//   // from UniversalTersePrint() is that this function prints both the
-//   // pointer and the NUL-terminated string for a (const or not) char pointer.
-//   void ::testing::internal::UniversalPrint(const T& value, ostream*);
-//
-//   // Prints the fields of a tuple tersely to a string vector, one
-//   // element for each field. Tuple support must be enabled in
-//   // gtest-port.h.
-//   std::vector<string> UniversalTersePrintTupleFieldsToStrings(
-//       const Tuple& value);
-//
-// Known limitation:
-//
-// The print primitives print the elements of an STL-style container
-// using the compiler-inferred type of *iter where iter is a
-// const_iterator of the container.  When const_iterator is an input
-// iterator but not a forward iterator, this inferred type may not
-// match value_type, and the print output may be incorrect.  In
-// practice, this is rarely a problem as for most containers
-// const_iterator is a forward iterator.  We'll fix this if there's an
-// actual need for it.  Note that this fix cannot rely on value_type
-// being defined as many user-defined container types don't have
-// value_type.
-
-#ifndef GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
-#define GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
-
-#include <ostream>  // NOLINT
-#include <sstream>
-#include <string>
-#include <utility>
-#include <vector>
-
-namespace testing {
-
-// Definitions in the 'internal' and 'internal2' name spaces are
-// subject to change without notice.  DO NOT USE THEM IN USER CODE!
-namespace internal2 {
-
-// Prints the given number of bytes in the given object to the given
-// ostream.
-GTEST_API_ void PrintBytesInObjectTo(const unsigned char* obj_bytes,
-                                     size_t count,
-                                     ::std::ostream* os);
-
-// For selecting which printer to use when a given type has neither <<
-// nor PrintTo().
-enum TypeKind {
-  kProtobuf,              // a protobuf type
-  kConvertibleToInteger,  // a type implicitly convertible to BiggestInt
-                          // (e.g. a named or unnamed enum type)
-  kOtherType              // anything else
-};
-
-// TypeWithoutFormatter<T, kTypeKind>::PrintValue(value, os) is called
-// by the universal printer to print a value of type T when neither
-// operator<< nor PrintTo() is defined for T, where kTypeKind is the
-// "kind" of T as defined by enum TypeKind.
-template <typename T, TypeKind kTypeKind>
-class TypeWithoutFormatter {
- public:
-  // This default version is called when kTypeKind is kOtherType.
-  static void PrintValue(const T& value, ::std::ostream* os) {
-    PrintBytesInObjectTo(reinterpret_cast<const unsigned char*>(&value),
-                         sizeof(value), os);
-  }
-};
-
-// We print a protobuf using its ShortDebugString() when the string
-// doesn't exceed this many characters; otherwise we print it using
-// DebugString() for better readability.
-const size_t kProtobufOneLinerMaxLength = 50;
-
-template <typename T>
-class TypeWithoutFormatter<T, kProtobuf> {
- public:
-  static void PrintValue(const T& value, ::std::ostream* os) {
-    const ::testing::internal::string short_str = value.ShortDebugString();
-    const ::testing::internal::string pretty_str =
-        short_str.length() <= kProtobufOneLinerMaxLength ?
-        short_str : ("\n" + value.DebugString());
-    *os << ("<" + pretty_str + ">");
-  }
-};
-
-template <typename T>
-class TypeWithoutFormatter<T, kConvertibleToInteger> {
- public:
-  // Since T has no << operator or PrintTo() but can be implicitly
-  // converted to BiggestInt, we print it as a BiggestInt.
-  //
-  // Most likely T is an enum type (either named or unnamed), in which
-  // case printing it as an integer is the desired behavior.  In case
-  // T is not an enum, printing it as an integer is the best we can do
-  // given that it has no user-defined printer.
-  static void PrintValue(const T& value, ::std::ostream* os) {
-    const internal::BiggestInt kBigInt = value;
-    *os << kBigInt;
-  }
-};
-
-// Prints the given value to the given ostream.  If the value is a
-// protocol message, its debug string is printed; if it's an enum or
-// of a type implicitly convertible to BiggestInt, it's printed as an
-// integer; otherwise the bytes in the value are printed.  This is
-// what UniversalPrinter<T>::Print() does when it knows nothing about
-// type T and T has neither << operator nor PrintTo().
-//
-// A user can override this behavior for a class type Foo by defining
-// a << operator in the namespace where Foo is defined.
-//
-// We put this operator in namespace 'internal2' instead of 'internal'
-// to simplify the implementation, as much code in 'internal' needs to
-// use << in STL, which would conflict with our own << were it defined
-// in 'internal'.
-//
-// Note that this operator<< takes a generic std::basic_ostream<Char,
-// CharTraits> type instead of the more restricted std::ostream.  If
-// we define it to take an std::ostream instead, we'll get an
-// "ambiguous overloads" compiler error when trying to print a type
-// Foo that supports streaming to std::basic_ostream<Char,
-// CharTraits>, as the compiler cannot tell whether
-// operator<<(std::ostream&, const T&) or
-// operator<<(std::basic_stream<Char, CharTraits>, const Foo&) is more
-// specific.
-template <typename Char, typename CharTraits, typename T>
-::std::basic_ostream<Char, CharTraits>& operator<<(
-    ::std::basic_ostream<Char, CharTraits>& os, const T& x) {
-  TypeWithoutFormatter<T,
-      (internal::IsAProtocolMessage<T>::value ? kProtobuf :
-       internal::ImplicitlyConvertible<const T&, internal::BiggestInt>::value ?
-       kConvertibleToInteger : kOtherType)>::PrintValue(x, &os);
-  return os;
-}
-
-}  // namespace internal2
-}  // namespace testing
-
-// This namespace MUST NOT BE NESTED IN ::testing, or the name look-up
-// magic needed for implementing UniversalPrinter won't work.
-namespace testing_internal {
-
-// Used to print a value that is not an STL-style container when the
-// user doesn't define PrintTo() for it.
-template <typename T>
-void DefaultPrintNonContainerTo(const T& value, ::std::ostream* os) {
-  // With the following statement, during unqualified name lookup,
-  // testing::internal2::operator<< appears as if it was declared in
-  // the nearest enclosing namespace that contains both
-  // ::testing_internal and ::testing::internal2, i.e. the global
-  // namespace.  For more details, refer to the C++ Standard section
-  // 7.3.4-1 [namespace.udir].  This allows us to fall back onto
-  // testing::internal2::operator<< in case T doesn't come with a <<
-  // operator.
-  //
-  // We cannot write 'using ::testing::internal2::operator<<;', which
-  // gcc 3.3 fails to compile due to a compiler bug.
-  using namespace ::testing::internal2;  // NOLINT
-
-  // Assuming T is defined in namespace foo, in the next statement,
-  // the compiler will consider all of:
-  //
-  //   1. foo::operator<< (thanks to Koenig look-up),
-  //   2. ::operator<< (as the current namespace is enclosed in ::),
-  //   3. testing::internal2::operator<< (thanks to the using statement above).
-  //
-  // The operator<< whose type matches T best will be picked.
-  //
-  // We deliberately allow #2 to be a candidate, as sometimes it's
-  // impossible to define #1 (e.g. when foo is ::std, defining
-  // anything in it is undefined behavior unless you are a compiler
-  // vendor.).
-  *os << value;
-}
-
-}  // namespace testing_internal
-
-namespace testing {
-namespace internal {
-
-// UniversalPrinter<T>::Print(value, ostream_ptr) prints the given
-// value to the given ostream.  The caller must ensure that
-// 'ostream_ptr' is not NULL, or the behavior is undefined.
-//
-// We define UniversalPrinter as a class template (as opposed to a
-// function template), as we need to partially specialize it for
-// reference types, which cannot be done with function templates.
-template <typename T>
-class UniversalPrinter;
-
-template <typename T>
-void UniversalPrint(const T& value, ::std::ostream* os);
-
-// Used to print an STL-style container when the user doesn't define
-// a PrintTo() for it.
-template <typename C>
-void DefaultPrintTo(IsContainer /* dummy */,
-                    false_type /* is not a pointer */,
-                    const C& container, ::std::ostream* os) {
-  const size_t kMaxCount = 32;  // The maximum number of elements to print.
-  *os << '{';
-  size_t count = 0;
-  for (typename C::const_iterator it = container.begin();
-       it != container.end(); ++it, ++count) {
-    if (count > 0) {
-      *os << ',';
-      if (count == kMaxCount) {  // Enough has been printed.
-        *os << " ...";
-        break;
-      }
-    }
-    *os << ' ';
-    // We cannot call PrintTo(*it, os) here as PrintTo() doesn't
-    // handle *it being a native array.
-    internal::UniversalPrint(*it, os);
-  }
-
-  if (count > 0) {
-    *os << ' ';
-  }
-  *os << '}';
-}
-
-// Used to print a pointer that is neither a char pointer nor a member
-// pointer, when the user doesn't define PrintTo() for it.  (A member
-// variable pointer or member function pointer doesn't really point to
-// a location in the address space.  Their representation is
-// implementation-defined.  Therefore they will be printed as raw
-// bytes.)
-template <typename T>
-void DefaultPrintTo(IsNotContainer /* dummy */,
-                    true_type /* is a pointer */,
-                    T* p, ::std::ostream* os) {
-  if (p == NULL) {
-    *os << "NULL";
-  } else {
-    // C++ doesn't allow casting from a function pointer to any object
-    // pointer.
-    //
-    // IsTrue() silences warnings: "Condition is always true",
-    // "unreachable code".
-    if (IsTrue(ImplicitlyConvertible<T*, const void*>::value)) {
-      // T is not a function type.  We just call << to print p,
-      // relying on ADL to pick up user-defined << for their pointer
-      // types, if any.
-      *os << p;
-    } else {
-      // T is a function type, so '*os << p' doesn't do what we want
-      // (it just prints p as bool).  We want to print p as a const
-      // void*.  However, we cannot cast it to const void* directly,
-      // even using reinterpret_cast, as earlier versions of gcc
-      // (e.g. 3.4.5) cannot compile the cast when p is a function
-      // pointer.  Casting to UInt64 first solves the problem.
-      *os << reinterpret_cast<const void*>(
-          reinterpret_cast<internal::UInt64>(p));
-    }
-  }
-}
-
-// Used to print a non-container, non-pointer value when the user
-// doesn't define PrintTo() for it.
-template <typename T>
-void DefaultPrintTo(IsNotContainer /* dummy */,
-                    false_type /* is not a pointer */,
-                    const T& value, ::std::ostream* os) {
-  ::testing_internal::DefaultPrintNonContainerTo(value, os);
-}
-
-// Prints the given value using the << operator if it has one;
-// otherwise prints the bytes in it.  This is what
-// UniversalPrinter<T>::Print() does when PrintTo() is not specialized
-// or overloaded for type T.
-//
-// A user can override this behavior for a class type Foo by defining
-// an overload of PrintTo() in the namespace where Foo is defined.  We
-// give the user this option as sometimes defining a << operator for
-// Foo is not desirable (e.g. the coding style may prevent doing it,
-// or there is already a << operator but it doesn't do what the user
-// wants).
-template <typename T>
-void PrintTo(const T& value, ::std::ostream* os) {
-  // DefaultPrintTo() is overloaded.  The type of its first two
-  // arguments determine which version will be picked.  If T is an
-  // STL-style container, the version for container will be called; if
-  // T is a pointer, the pointer version will be called; otherwise the
-  // generic version will be called.
-  //
-  // Note that we check for container types here, prior to we check
-  // for protocol message types in our operator<<.  The rationale is:
-  //
-  // For protocol messages, we want to give people a chance to
-  // override Google Mock's format by defining a PrintTo() or
-  // operator<<.  For STL containers, other formats can be
-  // incompatible with Google Mock's format for the container
-  // elements; therefore we check for container types here to ensure
-  // that our format is used.
-  //
-  // The second argument of DefaultPrintTo() is needed to bypass a bug
-  // in Symbian's C++ compiler that prevents it from picking the right
-  // overload between:
-  //
-  //   PrintTo(const T& x, ...);
-  //   PrintTo(T* x, ...);
-  DefaultPrintTo(IsContainerTest<T>(0), is_pointer<T>(), value, os);
-}
-
-// The following list of PrintTo() overloads tells
-// UniversalPrinter<T>::Print() how to print standard types (built-in
-// types, strings, plain arrays, and pointers).
-
-// Overloads for various char types.
-GTEST_API_ void PrintTo(unsigned char c, ::std::ostream* os);
-GTEST_API_ void PrintTo(signed char c, ::std::ostream* os);
-inline void PrintTo(char c, ::std::ostream* os) {
-  // When printing a plain char, we always treat it as unsigned.  This
-  // way, the output won't be affected by whether the compiler thinks
-  // char is signed or not.
-  PrintTo(static_cast<unsigned char>(c), os);
-}
-
-// Overloads for other simple built-in types.
-inline void PrintTo(bool x, ::std::ostream* os) {
-  *os << (x ? "true" : "false");
-}
-
-// Overload for wchar_t type.
-// Prints a wchar_t as a symbol if it is printable or as its internal
-// code otherwise and also as its decimal code (except for L'\0').
-// The L'\0' char is printed as "L'\\0'". The decimal code is printed
-// as signed integer when wchar_t is implemented by the compiler
-// as a signed type and is printed as an unsigned integer when wchar_t
-// is implemented as an unsigned type.
-GTEST_API_ void PrintTo(wchar_t wc, ::std::ostream* os);
-
-// Overloads for C strings.
-GTEST_API_ void PrintTo(const char* s, ::std::ostream* os);
-inline void PrintTo(char* s, ::std::ostream* os) {
-  PrintTo(ImplicitCast_<const char*>(s), os);
-}
-
-// signed/unsigned char is often used for representing binary data, so
-// we print pointers to it as void* to be safe.
-inline void PrintTo(const signed char* s, ::std::ostream* os) {
-  PrintTo(ImplicitCast_<const void*>(s), os);
-}
-inline void PrintTo(signed char* s, ::std::ostream* os) {
-  PrintTo(ImplicitCast_<const void*>(s), os);
-}
-inline void PrintTo(const unsigned char* s, ::std::ostream* os) {
-  PrintTo(ImplicitCast_<const void*>(s), os);
-}
-inline void PrintTo(unsigned char* s, ::std::ostream* os) {
-  PrintTo(ImplicitCast_<const void*>(s), os);
-}
-
-// MSVC can be configured to define wchar_t as a typedef of unsigned
-// short.  It defines _NATIVE_WCHAR_T_DEFINED when wchar_t is a native
-// type.  When wchar_t is a typedef, defining an overload for const
-// wchar_t* would cause unsigned short* be printed as a wide string,
-// possibly causing invalid memory accesses.
-#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
-// Overloads for wide C strings
-GTEST_API_ void PrintTo(const wchar_t* s, ::std::ostream* os);
-inline void PrintTo(wchar_t* s, ::std::ostream* os) {
-  PrintTo(ImplicitCast_<const wchar_t*>(s), os);
-}
-#endif
-
-// Overload for C arrays.  Multi-dimensional arrays are printed
-// properly.
-
-// Prints the given number of elements in an array, without printing
-// the curly braces.
-template <typename T>
-void PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) {
-  UniversalPrint(a[0], os);
-  for (size_t i = 1; i != count; i++) {
-    *os << ", ";
-    UniversalPrint(a[i], os);
-  }
-}
-
-// Overloads for ::string and ::std::string.
-#if GTEST_HAS_GLOBAL_STRING
-GTEST_API_ void PrintStringTo(const ::string&s, ::std::ostream* os);
-inline void PrintTo(const ::string& s, ::std::ostream* os) {
-  PrintStringTo(s, os);
-}
-#endif  // GTEST_HAS_GLOBAL_STRING
-
-GTEST_API_ void PrintStringTo(const ::std::string&s, ::std::ostream* os);
-inline void PrintTo(const ::std::string& s, ::std::ostream* os) {
-  PrintStringTo(s, os);
-}
-
-// Overloads for ::wstring and ::std::wstring.
-#if GTEST_HAS_GLOBAL_WSTRING
-GTEST_API_ void PrintWideStringTo(const ::wstring&s, ::std::ostream* os);
-inline void PrintTo(const ::wstring& s, ::std::ostream* os) {
-  PrintWideStringTo(s, os);
-}
-#endif  // GTEST_HAS_GLOBAL_WSTRING
-
-#if GTEST_HAS_STD_WSTRING
-GTEST_API_ void PrintWideStringTo(const ::std::wstring&s, ::std::ostream* os);
-inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {
-  PrintWideStringTo(s, os);
-}
-#endif  // GTEST_HAS_STD_WSTRING
-
-#if GTEST_HAS_TR1_TUPLE
-// Overload for ::std::tr1::tuple.  Needed for printing function arguments,
-// which are packed as tuples.
-
-// Helper function for printing a tuple.  T must be instantiated with
-// a tuple type.
-template <typename T>
-void PrintTupleTo(const T& t, ::std::ostream* os);
-
-// Overloaded PrintTo() for tuples of various arities.  We support
-// tuples of up-to 10 fields.  The following implementation works
-// regardless of whether tr1::tuple is implemented using the
-// non-standard variadic template feature or not.
-
-inline void PrintTo(const ::std::tr1::tuple<>& t, ::std::ostream* os) {
-  PrintTupleTo(t, os);
-}
-
-template <typename T1>
-void PrintTo(const ::std::tr1::tuple<T1>& t, ::std::ostream* os) {
-  PrintTupleTo(t, os);
-}
-
-template <typename T1, typename T2>
-void PrintTo(const ::std::tr1::tuple<T1, T2>& t, ::std::ostream* os) {
-  PrintTupleTo(t, os);
-}
-
-template <typename T1, typename T2, typename T3>
-void PrintTo(const ::std::tr1::tuple<T1, T2, T3>& t, ::std::ostream* os) {
-  PrintTupleTo(t, os);
-}
-
-template <typename T1, typename T2, typename T3, typename T4>
-void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4>& t, ::std::ostream* os) {
-  PrintTupleTo(t, os);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5>
-void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5>& t,
-             ::std::ostream* os) {
-  PrintTupleTo(t, os);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-          typename T6>
-void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6>& t,
-             ::std::ostream* os) {
-  PrintTupleTo(t, os);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-          typename T6, typename T7>
-void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7>& t,
-             ::std::ostream* os) {
-  PrintTupleTo(t, os);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-          typename T6, typename T7, typename T8>
-void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8>& t,
-             ::std::ostream* os) {
-  PrintTupleTo(t, os);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-          typename T6, typename T7, typename T8, typename T9>
-void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>& t,
-             ::std::ostream* os) {
-  PrintTupleTo(t, os);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-          typename T6, typename T7, typename T8, typename T9, typename T10>
-void PrintTo(
-    const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& t,
-    ::std::ostream* os) {
-  PrintTupleTo(t, os);
-}
-#endif  // GTEST_HAS_TR1_TUPLE
-
-// Overload for std::pair.
-template <typename T1, typename T2>
-void PrintTo(const ::std::pair<T1, T2>& value, ::std::ostream* os) {
-  *os << '(';
-  // We cannot use UniversalPrint(value.first, os) here, as T1 may be
-  // a reference type.  The same for printing value.second.
-  UniversalPrinter<T1>::Print(value.first, os);
-  *os << ", ";
-  UniversalPrinter<T2>::Print(value.second, os);
-  *os << ')';
-}
-
-// Implements printing a non-reference type T by letting the compiler
-// pick the right overload of PrintTo() for T.
-template <typename T>
-class UniversalPrinter {
- public:
-  // MSVC warns about adding const to a function type, so we want to
-  // disable the warning.
-#ifdef _MSC_VER
-# pragma warning(push)          // Saves the current warning state.
-# pragma warning(disable:4180)  // Temporarily disables warning 4180.
-#endif  // _MSC_VER
-
-  // Note: we deliberately don't call this PrintTo(), as that name
-  // conflicts with ::testing::internal::PrintTo in the body of the
-  // function.
-  static void Print(const T& value, ::std::ostream* os) {
-    // By default, ::testing::internal::PrintTo() is used for printing
-    // the value.
-    //
-    // Thanks to Koenig look-up, if T is a class and has its own
-    // PrintTo() function defined in its namespace, that function will
-    // be visible here.  Since it is more specific than the generic ones
-    // in ::testing::internal, it will be picked by the compiler in the
-    // following statement - exactly what we want.
-    PrintTo(value, os);
-  }
-
-#ifdef _MSC_VER
-# pragma warning(pop)           // Restores the warning state.
-#endif  // _MSC_VER
-};
-
-// UniversalPrintArray(begin, len, os) prints an array of 'len'
-// elements, starting at address 'begin'.
-template <typename T>
-void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) {
-  if (len == 0) {
-    *os << "{}";
-  } else {
-    *os << "{ ";
-    const size_t kThreshold = 18;
-    const size_t kChunkSize = 8;
-    // If the array has more than kThreshold elements, we'll have to
-    // omit some details by printing only the first and the last
-    // kChunkSize elements.
-    // TODO(wan at google.com): let the user control the threshold using a flag.
-    if (len <= kThreshold) {
-      PrintRawArrayTo(begin, len, os);
-    } else {
-      PrintRawArrayTo(begin, kChunkSize, os);
-      *os << ", ..., ";
-      PrintRawArrayTo(begin + len - kChunkSize, kChunkSize, os);
-    }
-    *os << " }";
-  }
-}
-// This overload prints a (const) char array compactly.
-GTEST_API_ void UniversalPrintArray(const char* begin,
-                                    size_t len,
-                                    ::std::ostream* os);
-
-// Implements printing an array type T[N].
-template <typename T, size_t N>
-class UniversalPrinter<T[N]> {
- public:
-  // Prints the given array, omitting some elements when there are too
-  // many.
-  static void Print(const T (&a)[N], ::std::ostream* os) {
-    UniversalPrintArray(a, N, os);
-  }
-};
-
-// Implements printing a reference type T&.
-template <typename T>
-class UniversalPrinter<T&> {
- public:
-  // MSVC warns about adding const to a function type, so we want to
-  // disable the warning.
-#ifdef _MSC_VER
-# pragma warning(push)          // Saves the current warning state.
-# pragma warning(disable:4180)  // Temporarily disables warning 4180.
-#endif  // _MSC_VER
-
-  static void Print(const T& value, ::std::ostream* os) {
-    // Prints the address of the value.  We use reinterpret_cast here
-    // as static_cast doesn't compile when T is a function type.
-    *os << "@" << reinterpret_cast<const void*>(&value) << " ";
-
-    // Then prints the value itself.
-    UniversalPrint(value, os);
-  }
-
-#ifdef _MSC_VER
-# pragma warning(pop)           // Restores the warning state.
-#endif  // _MSC_VER
-};
-
-// Prints a value tersely: for a reference type, the referenced value
-// (but not the address) is printed; for a (const) char pointer, the
-// NUL-terminated string (but not the pointer) is printed.
-template <typename T>
-void UniversalTersePrint(const T& value, ::std::ostream* os) {
-  UniversalPrint(value, os);
-}
-inline void UniversalTersePrint(const char* str, ::std::ostream* os) {
-  if (str == NULL) {
-    *os << "NULL";
-  } else {
-    UniversalPrint(string(str), os);
-  }
-}
-inline void UniversalTersePrint(char* str, ::std::ostream* os) {
-  UniversalTersePrint(static_cast<const char*>(str), os);
-}
-
-// Prints a value using the type inferred by the compiler.  The
-// difference between this and UniversalTersePrint() is that for a
-// (const) char pointer, this prints both the pointer and the
-// NUL-terminated string.
-template <typename T>
-void UniversalPrint(const T& value, ::std::ostream* os) {
-  UniversalPrinter<T>::Print(value, os);
-}
-
-#if GTEST_HAS_TR1_TUPLE
-typedef ::std::vector<string> Strings;
-
-// This helper template allows PrintTo() for tuples and
-// UniversalTersePrintTupleFieldsToStrings() to be defined by
-// induction on the number of tuple fields.  The idea is that
-// TuplePrefixPrinter<N>::PrintPrefixTo(t, os) prints the first N
-// fields in tuple t, and can be defined in terms of
-// TuplePrefixPrinter<N - 1>.
-
-// The inductive case.
-template <size_t N>
-struct TuplePrefixPrinter {
-  // Prints the first N fields of a tuple.
-  template <typename Tuple>
-  static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) {
-    TuplePrefixPrinter<N - 1>::PrintPrefixTo(t, os);
-    *os << ", ";
-    UniversalPrinter<typename ::std::tr1::tuple_element<N - 1, Tuple>::type>
-        ::Print(::std::tr1::get<N - 1>(t), os);
-  }
-
-  // Tersely prints the first N fields of a tuple to a string vector,
-  // one element for each field.
-  template <typename Tuple>
-  static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) {
-    TuplePrefixPrinter<N - 1>::TersePrintPrefixToStrings(t, strings);
-    ::std::stringstream ss;
-    UniversalTersePrint(::std::tr1::get<N - 1>(t), &ss);
-    strings->push_back(ss.str());
-  }
-};
-
-// Base cases.
-template <>
-struct TuplePrefixPrinter<0> {
-  template <typename Tuple>
-  static void PrintPrefixTo(const Tuple&, ::std::ostream*) {}
-
-  template <typename Tuple>
-  static void TersePrintPrefixToStrings(const Tuple&, Strings*) {}
-};
-// We have to specialize the entire TuplePrefixPrinter<> class
-// template here, even though the definition of
-// TersePrintPrefixToStrings() is the same as the generic version, as
-// Embarcadero (formerly CodeGear, formerly Borland) C++ doesn't
-// support specializing a method template of a class template.
-template <>
-struct TuplePrefixPrinter<1> {
-  template <typename Tuple>
-  static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) {
-    UniversalPrinter<typename ::std::tr1::tuple_element<0, Tuple>::type>::
-        Print(::std::tr1::get<0>(t), os);
-  }
-
-  template <typename Tuple>
-  static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) {
-    ::std::stringstream ss;
-    UniversalTersePrint(::std::tr1::get<0>(t), &ss);
-    strings->push_back(ss.str());
-  }
-};
-
-// Helper function for printing a tuple.  T must be instantiated with
-// a tuple type.
-template <typename T>
-void PrintTupleTo(const T& t, ::std::ostream* os) {
-  *os << "(";
-  TuplePrefixPrinter< ::std::tr1::tuple_size<T>::value>::
-      PrintPrefixTo(t, os);
-  *os << ")";
-}
-
-// Prints the fields of a tuple tersely to a string vector, one
-// element for each field.  See the comment before
-// UniversalTersePrint() for how we define "tersely".
-template <typename Tuple>
-Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) {
-  Strings result;
-  TuplePrefixPrinter< ::std::tr1::tuple_size<Tuple>::value>::
-      TersePrintPrefixToStrings(value, &result);
-  return result;
-}
-#endif  // GTEST_HAS_TR1_TUPLE
-
-}  // namespace internal
-
-template <typename T>
-::std::string PrintToString(const T& value) {
-  ::std::stringstream ss;
-  internal::UniversalTersePrint(value, &ss);
-  return ss.str();
-}
-
-}  // namespace testing
-
-#endif  // GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
-
-#if GTEST_HAS_PARAM_TEST
-
-namespace testing {
-namespace internal {
-
-// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
-//
-// Outputs a message explaining invalid registration of different
-// fixture class for the same test case. This may happen when
-// TEST_P macro is used to define two tests with the same name
-// but in different namespaces.
-GTEST_API_ void ReportInvalidTestCaseType(const char* test_case_name,
-                                          const char* file, int line);
-
-template <typename> class ParamGeneratorInterface;
-template <typename> class ParamGenerator;
-
-// Interface for iterating over elements provided by an implementation
-// of ParamGeneratorInterface<T>.
-template <typename T>
-class ParamIteratorInterface {
- public:
-  virtual ~ParamIteratorInterface() {}
-  // A pointer to the base generator instance.
-  // Used only for the purposes of iterator comparison
-  // to make sure that two iterators belong to the same generator.
-  virtual const ParamGeneratorInterface<T>* BaseGenerator() const = 0;
-  // Advances iterator to point to the next element
-  // provided by the generator. The caller is responsible
-  // for not calling Advance() on an iterator equal to
-  // BaseGenerator()->End().
-  virtual void Advance() = 0;
-  // Clones the iterator object. Used for implementing copy semantics
-  // of ParamIterator<T>.
-  virtual ParamIteratorInterface* Clone() const = 0;
-  // Dereferences the current iterator and provides (read-only) access
-  // to the pointed value. It is the caller's responsibility not to call
-  // Current() on an iterator equal to BaseGenerator()->End().
-  // Used for implementing ParamGenerator<T>::operator*().
-  virtual const T* Current() const = 0;
-  // Determines whether the given iterator and other point to the same
-  // element in the sequence generated by the generator.
-  // Used for implementing ParamGenerator<T>::operator==().
-  virtual bool Equals(const ParamIteratorInterface& other) const = 0;
-};
-
-// Class iterating over elements provided by an implementation of
-// ParamGeneratorInterface<T>. It wraps ParamIteratorInterface<T>
-// and implements the const forward iterator concept.
-template <typename T>
-class ParamIterator {
- public:
-  typedef T value_type;
-  typedef const T& reference;
-  typedef ptrdiff_t difference_type;
-
-  // ParamIterator assumes ownership of the impl_ pointer.
-  ParamIterator(const ParamIterator& other) : impl_(other.impl_->Clone()) {}
-  ParamIterator& operator=(const ParamIterator& other) {
-    if (this != &other)
-      impl_.reset(other.impl_->Clone());
-    return *this;
-  }
-
-  const T& operator*() const { return *impl_->Current(); }
-  const T* operator->() const { return impl_->Current(); }
-  // Prefix version of operator++.
-  ParamIterator& operator++() {
-    impl_->Advance();
-    return *this;
-  }
-  // Postfix version of operator++.
-  ParamIterator operator++(int /*unused*/) {
-    ParamIteratorInterface<T>* clone = impl_->Clone();
-    impl_->Advance();
-    return ParamIterator(clone);
-  }
-  bool operator==(const ParamIterator& other) const {
-    return impl_.get() == other.impl_.get() || impl_->Equals(*other.impl_);
-  }
-  bool operator!=(const ParamIterator& other) const {
-    return !(*this == other);
-  }
-
- private:
-  friend class ParamGenerator<T>;
-  explicit ParamIterator(ParamIteratorInterface<T>* impl) : impl_(impl) {}
-  scoped_ptr<ParamIteratorInterface<T> > impl_;
-};
-
-// ParamGeneratorInterface<T> is the binary interface to access generators
-// defined in other translation units.
-template <typename T>
-class ParamGeneratorInterface {
- public:
-  typedef T ParamType;
-
-  virtual ~ParamGeneratorInterface() {}
-
-  // Generator interface definition
-  virtual ParamIteratorInterface<T>* Begin() const = 0;
-  virtual ParamIteratorInterface<T>* End() const = 0;
-};
-
-// Wraps ParamGeneratorInterface<T> and provides general generator syntax
-// compatible with the STL Container concept.
-// This class implements copy initialization semantics and the contained
-// ParamGeneratorInterface<T> instance is shared among all copies
-// of the original object. This is possible because that instance is immutable.
-template<typename T>
-class ParamGenerator {
- public:
-  typedef ParamIterator<T> iterator;
-
-  explicit ParamGenerator(ParamGeneratorInterface<T>* impl) : impl_(impl) {}
-  ParamGenerator(const ParamGenerator& other) : impl_(other.impl_) {}
-
-  ParamGenerator& operator=(const ParamGenerator& other) {
-    impl_ = other.impl_;
-    return *this;
-  }
-
-  iterator begin() const { return iterator(impl_->Begin()); }
-  iterator end() const { return iterator(impl_->End()); }
-
- private:
-  linked_ptr<const ParamGeneratorInterface<T> > impl_;
-};
-
-// Generates values from a range of two comparable values. Can be used to
-// generate sequences of user-defined types that implement operator+() and
-// operator<().
-// This class is used in the Range() function.
-template <typename T, typename IncrementT>
-class RangeGenerator : public ParamGeneratorInterface<T> {
- public:
-  RangeGenerator(T begin, T end, IncrementT step)
-      : begin_(begin), end_(end),
-        step_(step), end_index_(CalculateEndIndex(begin, end, step)) {}
-  virtual ~RangeGenerator() {}
-
-  virtual ParamIteratorInterface<T>* Begin() const {
-    return new Iterator(this, begin_, 0, step_);
-  }
-  virtual ParamIteratorInterface<T>* End() const {
-    return new Iterator(this, end_, end_index_, step_);
-  }
-
- private:
-  class Iterator : public ParamIteratorInterface<T> {
-   public:
-    Iterator(const ParamGeneratorInterface<T>* base, T value, int index,
-             IncrementT step)
-        : base_(base), value_(value), index_(index), step_(step) {}
-    virtual ~Iterator() {}
-
-    virtual const ParamGeneratorInterface<T>* BaseGenerator() const {
-      return base_;
-    }
-    virtual void Advance() {
-      value_ = value_ + step_;
-      index_++;
-    }
-    virtual ParamIteratorInterface<T>* Clone() const {
-      return new Iterator(*this);
-    }
-    virtual const T* Current() const { return &value_; }
-    virtual bool Equals(const ParamIteratorInterface<T>& other) const {
-      // Having the same base generator guarantees that the other
-      // iterator is of the same type and we can downcast.
-      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
-          << "The program attempted to compare iterators "
-          << "from different generators." << std::endl;
-      const int other_index =
-          CheckedDowncastToActualType<const Iterator>(&other)->index_;
-      return index_ == other_index;
-    }
-
-   private:
-    Iterator(const Iterator& other)
-        : ParamIteratorInterface<T>(),
-          base_(other.base_), value_(other.value_), index_(other.index_),
-          step_(other.step_) {}
-
-    // No implementation - assignment is unsupported.
-    void operator=(const Iterator& other);
-
-    const ParamGeneratorInterface<T>* const base_;
-    T value_;
-    int index_;
-    const IncrementT step_;
-  };  // class RangeGenerator::Iterator
-
-  static int CalculateEndIndex(const T& begin,
-                               const T& end,
-                               const IncrementT& step) {
-    int end_index = 0;
-    for (T i = begin; i < end; i = i + step)
-      end_index++;
-    return end_index;
-  }
-
-  // No implementation - assignment is unsupported.
-  void operator=(const RangeGenerator& other);
-
-  const T begin_;
-  const T end_;
-  const IncrementT step_;
-  // The index for the end() iterator. All the elements in the generated
-  // sequence are indexed (0-based) to aid iterator comparison.
-  const int end_index_;
-};  // class RangeGenerator
-
-
-// Generates values from a pair of STL-style iterators. Used in the
-// ValuesIn() function. The elements are copied from the source range
-// since the source can be located on the stack, and the generator
-// is likely to persist beyond that stack frame.
-template <typename T>
-class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
- public:
-  template <typename ForwardIterator>
-  ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end)
-      : container_(begin, end) {}
-  virtual ~ValuesInIteratorRangeGenerator() {}
-
-  virtual ParamIteratorInterface<T>* Begin() const {
-    return new Iterator(this, container_.begin());
-  }
-  virtual ParamIteratorInterface<T>* End() const {
-    return new Iterator(this, container_.end());
-  }
-
- private:
-  typedef typename ::std::vector<T> ContainerType;
-
-  class Iterator : public ParamIteratorInterface<T> {
-   public:
-    Iterator(const ParamGeneratorInterface<T>* base,
-             typename ContainerType::const_iterator iterator)
-        : base_(base), iterator_(iterator) {}
-    virtual ~Iterator() {}
-
-    virtual const ParamGeneratorInterface<T>* BaseGenerator() const {
-      return base_;
-    }
-    virtual void Advance() {
-      ++iterator_;
-      value_.reset();
-    }
-    virtual ParamIteratorInterface<T>* Clone() const {
-      return new Iterator(*this);
-    }
-    // We need to use cached value referenced by iterator_ because *iterator_
-    // can return a temporary object (and of type other then T), so just
-    // having "return &*iterator_;" doesn't work.
-    // value_ is updated here and not in Advance() because Advance()
-    // can advance iterator_ beyond the end of the range, and we cannot
-    // detect that fact. The client code, on the other hand, is
-    // responsible for not calling Current() on an out-of-range iterator.
-    virtual const T* Current() const {
-      if (value_.get() == NULL)
-        value_.reset(new T(*iterator_));
-      return value_.get();
-    }
-    virtual bool Equals(const ParamIteratorInterface<T>& other) const {
-      // Having the same base generator guarantees that the other
-      // iterator is of the same type and we can downcast.
-      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
-          << "The program attempted to compare iterators "
-          << "from different generators." << std::endl;
-      return iterator_ ==
-          CheckedDowncastToActualType<const Iterator>(&other)->iterator_;
-    }
-
-   private:
-    Iterator(const Iterator& other)
-          // The explicit constructor call suppresses a false warning
-          // emitted by gcc when supplied with the -Wextra option.
-        : ParamIteratorInterface<T>(),
-          base_(other.base_),
-          iterator_(other.iterator_) {}
-
-    const ParamGeneratorInterface<T>* const base_;
-    typename ContainerType::const_iterator iterator_;
-    // A cached value of *iterator_. We keep it here to allow access by
-    // pointer in the wrapping iterator's operator->().
-    // value_ needs to be mutable to be accessed in Current().
-    // Use of scoped_ptr helps manage cached value's lifetime,
-    // which is bound by the lifespan of the iterator itself.
-    mutable scoped_ptr<const T> value_;
-  };  // class ValuesInIteratorRangeGenerator::Iterator
-
-  // No implementation - assignment is unsupported.
-  void operator=(const ValuesInIteratorRangeGenerator& other);
-
-  const ContainerType container_;
-};  // class ValuesInIteratorRangeGenerator
-
-// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
-//
-// Stores a parameter value and later creates tests parameterized with that
-// value.
-template <class TestClass>
-class ParameterizedTestFactory : public TestFactoryBase {
- public:
-  typedef typename TestClass::ParamType ParamType;
-  explicit ParameterizedTestFactory(ParamType parameter) :
-      parameter_(parameter) {}
-  virtual Test* CreateTest() {
-    TestClass::SetParam(&parameter_);
-    return new TestClass();
-  }
-
- private:
-  const ParamType parameter_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestFactory);
-};
-
-// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
-//
-// TestMetaFactoryBase is a base class for meta-factories that create
-// test factories for passing into MakeAndRegisterTestInfo function.
-template <class ParamType>
-class TestMetaFactoryBase {
- public:
-  virtual ~TestMetaFactoryBase() {}
-
-  virtual TestFactoryBase* CreateTestFactory(ParamType parameter) = 0;
-};
-
-// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
-//
-// TestMetaFactory creates test factories for passing into
-// MakeAndRegisterTestInfo function. Since MakeAndRegisterTestInfo receives
-// ownership of test factory pointer, same factory object cannot be passed
-// into that method twice. But ParameterizedTestCaseInfo is going to call
-// it for each Test/Parameter value combination. Thus it needs meta factory
-// creator class.
-template <class TestCase>
-class TestMetaFactory
-    : public TestMetaFactoryBase<typename TestCase::ParamType> {
- public:
-  typedef typename TestCase::ParamType ParamType;
-
-  TestMetaFactory() {}
-
-  virtual TestFactoryBase* CreateTestFactory(ParamType parameter) {
-    return new ParameterizedTestFactory<TestCase>(parameter);
-  }
-
- private:
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestMetaFactory);
-};
-
-// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
-//
-// ParameterizedTestCaseInfoBase is a generic interface
-// to ParameterizedTestCaseInfo classes. ParameterizedTestCaseInfoBase
-// accumulates test information provided by TEST_P macro invocations
-// and generators provided by INSTANTIATE_TEST_CASE_P macro invocations
-// and uses that information to register all resulting test instances
-// in RegisterTests method. The ParameterizeTestCaseRegistry class holds
-// a collection of pointers to the ParameterizedTestCaseInfo objects
-// and calls RegisterTests() on each of them when asked.
-class ParameterizedTestCaseInfoBase {
- public:
-  virtual ~ParameterizedTestCaseInfoBase() {}
-
-  // Base part of test case name for display purposes.
-  virtual const string& GetTestCaseName() const = 0;
-  // Test case id to verify identity.
-  virtual TypeId GetTestCaseTypeId() const = 0;
-  // UnitTest class invokes this method to register tests in this
-  // test case right before running them in RUN_ALL_TESTS macro.
-  // This method should not be called more then once on any single
-  // instance of a ParameterizedTestCaseInfoBase derived class.
-  virtual void RegisterTests() = 0;
-
- protected:
-  ParameterizedTestCaseInfoBase() {}
-
- private:
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseInfoBase);
-};
-
-// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
-//
-// ParameterizedTestCaseInfo accumulates tests obtained from TEST_P
-// macro invocations for a particular test case and generators
-// obtained from INSTANTIATE_TEST_CASE_P macro invocations for that
-// test case. It registers tests with all values generated by all
-// generators when asked.
-template <class TestCase>
-class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase {
- public:
-  // ParamType and GeneratorCreationFunc are private types but are required
-  // for declarations of public methods AddTestPattern() and
-  // AddTestCaseInstantiation().
-  typedef typename TestCase::ParamType ParamType;
-  // A function that returns an instance of appropriate generator type.
-  typedef ParamGenerator<ParamType>(GeneratorCreationFunc)();
-
-  explicit ParameterizedTestCaseInfo(const char* name)
-      : test_case_name_(name) {}
-
-  // Test case base name for display purposes.
-  virtual const string& GetTestCaseName() const { return test_case_name_; }
-  // Test case id to verify identity.
-  virtual TypeId GetTestCaseTypeId() const { return GetTypeId<TestCase>(); }
-  // TEST_P macro uses AddTestPattern() to record information
-  // about a single test in a LocalTestInfo structure.
-  // test_case_name is the base name of the test case (without invocation
-  // prefix). test_base_name is the name of an individual test without
-  // parameter index. For the test SequenceA/FooTest.DoBar/1 FooTest is
-  // test case base name and DoBar is test base name.
-  void AddTestPattern(const char* test_case_name,
-                      const char* test_base_name,
-                      TestMetaFactoryBase<ParamType>* meta_factory) {
-    tests_.push_back(linked_ptr<TestInfo>(new TestInfo(test_case_name,
-                                                       test_base_name,
-                                                       meta_factory)));
-  }
-  // INSTANTIATE_TEST_CASE_P macro uses AddGenerator() to record information
-  // about a generator.
-  int AddTestCaseInstantiation(const string& instantiation_name,
-                               GeneratorCreationFunc* func,
-                               const char* /* file */,
-                               int /* line */) {
-    instantiations_.push_back(::std::make_pair(instantiation_name, func));
-    return 0;  // Return value used only to run this method in namespace scope.
-  }
-  // UnitTest class invokes this method to register tests in this test case
-  // test cases right before running tests in RUN_ALL_TESTS macro.
-  // This method should not be called more then once on any single
-  // instance of a ParameterizedTestCaseInfoBase derived class.
-  // UnitTest has a guard to prevent from calling this method more then once.
-  virtual void RegisterTests() {
-    for (typename TestInfoContainer::iterator test_it = tests_.begin();
-         test_it != tests_.end(); ++test_it) {
-      linked_ptr<TestInfo> test_info = *test_it;
-      for (typename InstantiationContainer::iterator gen_it =
-               instantiations_.begin(); gen_it != instantiations_.end();
-               ++gen_it) {
-        const string& instantiation_name = gen_it->first;
-        ParamGenerator<ParamType> generator((*gen_it->second)());
-
-        Message test_case_name_stream;
-        if ( !instantiation_name.empty() )
-          test_case_name_stream << instantiation_name << "/";
-        test_case_name_stream << test_info->test_case_base_name;
-
-        int i = 0;
-        for (typename ParamGenerator<ParamType>::iterator param_it =
-                 generator.begin();
-             param_it != generator.end(); ++param_it, ++i) {
-          Message test_name_stream;
-          test_name_stream << test_info->test_base_name << "/" << i;
-          MakeAndRegisterTestInfo(
-              test_case_name_stream.GetString().c_str(),
-              test_name_stream.GetString().c_str(),
-              NULL,  // No type parameter.
-              PrintToString(*param_it).c_str(),
-              GetTestCaseTypeId(),
-              TestCase::SetUpTestCase,
-              TestCase::TearDownTestCase,
-              test_info->test_meta_factory->CreateTestFactory(*param_it));
-        }  // for param_it
-      }  // for gen_it
-    }  // for test_it
-  }  // RegisterTests
-
- private:
-  // LocalTestInfo structure keeps information about a single test registered
-  // with TEST_P macro.
-  struct TestInfo {
-    TestInfo(const char* a_test_case_base_name,
-             const char* a_test_base_name,
-             TestMetaFactoryBase<ParamType>* a_test_meta_factory) :
-        test_case_base_name(a_test_case_base_name),
-        test_base_name(a_test_base_name),
-        test_meta_factory(a_test_meta_factory) {}
-
-    const string test_case_base_name;
-    const string test_base_name;
-    const scoped_ptr<TestMetaFactoryBase<ParamType> > test_meta_factory;
-  };
-  typedef ::std::vector<linked_ptr<TestInfo> > TestInfoContainer;
-  // Keeps pairs of <Instantiation name, Sequence generator creation function>
-  // received from INSTANTIATE_TEST_CASE_P macros.
-  typedef ::std::vector<std::pair<string, GeneratorCreationFunc*> >
-      InstantiationContainer;
-
-  const string test_case_name_;
-  TestInfoContainer tests_;
-  InstantiationContainer instantiations_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseInfo);
-};  // class ParameterizedTestCaseInfo
-
-// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
-//
-// ParameterizedTestCaseRegistry contains a map of ParameterizedTestCaseInfoBase
-// classes accessed by test case names. TEST_P and INSTANTIATE_TEST_CASE_P
-// macros use it to locate their corresponding ParameterizedTestCaseInfo
-// descriptors.
-class ParameterizedTestCaseRegistry {
- public:
-  ParameterizedTestCaseRegistry() {}
-  ~ParameterizedTestCaseRegistry() {
-    for (TestCaseInfoContainer::iterator it = test_case_infos_.begin();
-         it != test_case_infos_.end(); ++it) {
-      delete *it;
-    }
-  }
-
-  // Looks up or creates and returns a structure containing information about
-  // tests and instantiations of a particular test case.
-  template <class TestCase>
-  ParameterizedTestCaseInfo<TestCase>* GetTestCasePatternHolder(
-      const char* test_case_name,
-      const char* file,
-      int line) {
-    ParameterizedTestCaseInfo<TestCase>* typed_test_info = NULL;
-    for (TestCaseInfoContainer::iterator it = test_case_infos_.begin();
-         it != test_case_infos_.end(); ++it) {
-      if ((*it)->GetTestCaseName() == test_case_name) {
-        if ((*it)->GetTestCaseTypeId() != GetTypeId<TestCase>()) {
-          // Complain about incorrect usage of Google Test facilities
-          // and terminate the program since we cannot guaranty correct
-          // test case setup and tear-down in this case.
-          ReportInvalidTestCaseType(test_case_name,  file, line);
-          posix::Abort();
-        } else {
-          // At this point we are sure that the object we found is of the same
-          // type we are looking for, so we downcast it to that type
-          // without further checks.
-          typed_test_info = CheckedDowncastToActualType<
-              ParameterizedTestCaseInfo<TestCase> >(*it);
-        }
-        break;
-      }
-    }
-    if (typed_test_info == NULL) {
-      typed_test_info = new ParameterizedTestCaseInfo<TestCase>(test_case_name);
-      test_case_infos_.push_back(typed_test_info);
-    }
-    return typed_test_info;
-  }
-  void RegisterTests() {
-    for (TestCaseInfoContainer::iterator it = test_case_infos_.begin();
-         it != test_case_infos_.end(); ++it) {
-      (*it)->RegisterTests();
-    }
-  }
-
- private:
-  typedef ::std::vector<ParameterizedTestCaseInfoBase*> TestCaseInfoContainer;
-
-  TestCaseInfoContainer test_case_infos_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseRegistry);
-};
-
-}  // namespace internal
-}  // namespace testing
-
-#endif  //  GTEST_HAS_PARAM_TEST
-
-#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
-// This file was GENERATED by command:
-//     pump.py gtest-param-util-generated.h.pump
-// DO NOT EDIT BY HAND!!!
-
-// Copyright 2008 Google Inc.
-// All Rights Reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: vladl at google.com (Vlad Losev)
-
-// Type and function utilities for implementing parameterized tests.
-// This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!
-//
-// Currently Google Test supports at most 50 arguments in Values,
-// and at most 10 arguments in Combine. Please contact
-// googletestframework at googlegroups.com if you need more.
-// Please note that the number of arguments to Combine is limited
-// by the maximum arity of the implementation of tr1::tuple which is
-// currently set at 10.
-
-#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
-#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
-
-// scripts/fuse_gtest.py depends on gtest's own header being #included
-// *unconditionally*.  Therefore these #includes cannot be moved
-// inside #if GTEST_HAS_PARAM_TEST.
-
-#if GTEST_HAS_PARAM_TEST
-
-namespace testing {
-
-// Forward declarations of ValuesIn(), which is implemented in
-// include/gtest/gtest-param-test.h.
-template <typename ForwardIterator>
-internal::ParamGenerator<
-  typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>
-ValuesIn(ForwardIterator begin, ForwardIterator end);
-
-template <typename T, size_t N>
-internal::ParamGenerator<T> ValuesIn(const T (&array)[N]);
-
-template <class Container>
-internal::ParamGenerator<typename Container::value_type> ValuesIn(
-    const Container& container);
-
-namespace internal {
-
-// Used in the Values() function to provide polymorphic capabilities.
-template <typename T1>
-class ValueArray1 {
- public:
-  explicit ValueArray1(T1 v1) : v1_(v1) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const { return ValuesIn(&v1_, &v1_ + 1); }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray1& other);
-
-  const T1 v1_;
-};
-
-template <typename T1, typename T2>
-class ValueArray2 {
- public:
-  ValueArray2(T1 v1, T2 v2) : v1_(v1), v2_(v2) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray2& other);
-
-  const T1 v1_;
-  const T2 v2_;
-};
-
-template <typename T1, typename T2, typename T3>
-class ValueArray3 {
- public:
-  ValueArray3(T1 v1, T2 v2, T3 v3) : v1_(v1), v2_(v2), v3_(v3) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray3& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4>
-class ValueArray4 {
- public:
-  ValueArray4(T1 v1, T2 v2, T3 v3, T4 v4) : v1_(v1), v2_(v2), v3_(v3),
-      v4_(v4) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray4& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5>
-class ValueArray5 {
- public:
-  ValueArray5(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) : v1_(v1), v2_(v2), v3_(v3),
-      v4_(v4), v5_(v5) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray5& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6>
-class ValueArray6 {
- public:
-  ValueArray6(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6) : v1_(v1), v2_(v2),
-      v3_(v3), v4_(v4), v5_(v5), v6_(v6) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray6& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7>
-class ValueArray7 {
- public:
-  ValueArray7(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7) : v1_(v1),
-      v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray7& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8>
-class ValueArray8 {
- public:
-  ValueArray8(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
-      T8 v8) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
-      v8_(v8) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray8& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9>
-class ValueArray9 {
- public:
-  ValueArray9(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,
-      T9 v9) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
-      v8_(v8), v9_(v9) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray9& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10>
-class ValueArray10 {
- public:
-  ValueArray10(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
-      v8_(v8), v9_(v9), v10_(v10) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray10& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11>
-class ValueArray11 {
- public:
-  ValueArray11(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),
-      v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray11& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12>
-class ValueArray12 {
- public:
-  ValueArray12(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),
-      v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray12& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13>
-class ValueArray13 {
- public:
-  ValueArray13(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),
-      v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),
-      v12_(v12), v13_(v13) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray13& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14>
-class ValueArray14 {
- public:
-  ValueArray14(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14) : v1_(v1), v2_(v2), v3_(v3),
-      v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
-      v11_(v11), v12_(v12), v13_(v13), v14_(v14) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray14& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15>
-class ValueArray15 {
- public:
-  ValueArray15(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15) : v1_(v1), v2_(v2),
-      v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
-      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray15& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16>
-class ValueArray16 {
- public:
-  ValueArray16(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16) : v1_(v1),
-      v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),
-      v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),
-      v16_(v16) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray16& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17>
-class ValueArray17 {
- public:
-  ValueArray17(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16,
-      T17 v17) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
-      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
-      v15_(v15), v16_(v16), v17_(v17) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray17& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18>
-class ValueArray18 {
- public:
-  ValueArray18(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
-      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
-      v15_(v15), v16_(v16), v17_(v17), v18_(v18) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray18& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19>
-class ValueArray19 {
- public:
-  ValueArray19(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),
-      v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13),
-      v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray19& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20>
-class ValueArray20 {
- public:
-  ValueArray20(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),
-      v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12),
-      v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18),
-      v19_(v19), v20_(v20) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray20& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21>
-class ValueArray21 {
- public:
-  ValueArray21(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),
-      v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),
-      v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17),
-      v18_(v18), v19_(v19), v20_(v20), v21_(v21) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray21& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22>
-class ValueArray22 {
- public:
-  ValueArray22(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22) : v1_(v1), v2_(v2), v3_(v3),
-      v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
-      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),
-      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray22& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23>
-class ValueArray23 {
- public:
-  ValueArray23(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23) : v1_(v1), v2_(v2),
-      v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
-      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),
-      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),
-      v23_(v23) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_,
-        v23_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray23& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24>
-class ValueArray24 {
- public:
-  ValueArray24(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24) : v1_(v1),
-      v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),
-      v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),
-      v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21),
-      v22_(v22), v23_(v23), v24_(v24) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray24& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25>
-class ValueArray25 {
- public:
-  ValueArray25(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24,
-      T25 v25) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
-      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
-      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),
-      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray25& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26>
-class ValueArray26 {
- public:
-  ValueArray26(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
-      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
-      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),
-      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray26& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27>
-class ValueArray27 {
- public:
-  ValueArray27(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26, T27 v27) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),
-      v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13),
-      v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19),
-      v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25),
-      v26_(v26), v27_(v27) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_, v27_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray27& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-  const T27 v27_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28>
-class ValueArray28 {
- public:
-  ValueArray28(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26, T27 v27, T28 v28) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),
-      v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12),
-      v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18),
-      v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24),
-      v25_(v25), v26_(v26), v27_(v27), v28_(v28) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_, v27_, v28_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray28& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-  const T27 v27_;
-  const T28 v28_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29>
-class ValueArray29 {
- public:
-  ValueArray29(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26, T27 v27, T28 v28, T29 v29) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),
-      v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),
-      v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17),
-      v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23),
-      v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_, v27_, v28_, v29_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray29& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-  const T27 v27_;
-  const T28 v28_;
-  const T29 v29_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30>
-class ValueArray30 {
- public:
-  ValueArray30(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30) : v1_(v1), v2_(v2), v3_(v3),
-      v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
-      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),
-      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),
-      v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),
-      v29_(v29), v30_(v30) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_, v27_, v28_, v29_, v30_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray30& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-  const T27 v27_;
-  const T28 v28_;
-  const T29 v29_;
-  const T30 v30_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31>
-class ValueArray31 {
- public:
-  ValueArray31(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31) : v1_(v1), v2_(v2),
-      v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
-      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),
-      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),
-      v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),
-      v29_(v29), v30_(v30), v31_(v31) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray31& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-  const T27 v27_;
-  const T28 v28_;
-  const T29 v29_;
-  const T30 v30_;
-  const T31 v31_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32>
-class ValueArray32 {
- public:
-  ValueArray32(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32) : v1_(v1),
-      v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),
-      v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),
-      v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21),
-      v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27),
-      v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray32& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-  const T27 v27_;
-  const T28 v28_;
-  const T29 v29_;
-  const T30 v30_;
-  const T31 v31_;
-  const T32 v32_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33>
-class ValueArray33 {
- public:
-  ValueArray33(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32,
-      T33 v33) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
-      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
-      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),
-      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),
-      v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),
-      v33_(v33) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray33& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-  const T27 v27_;
-  const T28 v28_;
-  const T29 v29_;
-  const T30 v30_;
-  const T31 v31_;
-  const T32 v32_;
-  const T33 v33_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34>
-class ValueArray34 {
- public:
-  ValueArray34(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
-      T34 v34) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
-      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
-      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),
-      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),
-      v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),
-      v33_(v33), v34_(v34) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray34& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-  const T27 v27_;
-  const T28 v28_;
-  const T29 v29_;
-  const T30 v30_;
-  const T31 v31_;
-  const T32 v32_;
-  const T33 v33_;
-  const T34 v34_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35>
-class ValueArray35 {
- public:
-  ValueArray35(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
-      T34 v34, T35 v35) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),
-      v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13),
-      v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19),
-      v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25),
-      v26_(v26), v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31),
-      v32_(v32), v33_(v33), v34_(v34), v35_(v35) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_,
-        v35_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray35& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-  const T27 v27_;
-  const T28 v28_;
-  const T29 v29_;
-  const T30 v30_;
-  const T31 v31_;
-  const T32 v32_;
-  const T33 v33_;
-  const T34 v34_;
-  const T35 v35_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36>
-class ValueArray36 {
- public:
-  ValueArray36(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
-      T34 v34, T35 v35, T36 v36) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),
-      v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12),
-      v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18),
-      v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24),
-      v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29), v30_(v30),
-      v31_(v31), v32_(v32), v33_(v33), v34_(v34), v35_(v35), v36_(v36) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v35_,
-        v36_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray36& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-  const T27 v27_;
-  const T28 v28_;
-  const T29 v29_;
-  const T30 v30_;
-  const T31 v31_;
-  const T32 v32_;
-  const T33 v33_;
-  const T34 v34_;
-  const T35 v35_;
-  const T36 v36_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37>
-class ValueArray37 {
- public:
-  ValueArray37(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
-      T34 v34, T35 v35, T36 v36, T37 v37) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),
-      v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),
-      v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17),
-      v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23),
-      v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29),
-      v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34), v35_(v35),
-      v36_(v36), v37_(v37) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v35_,
-        v36_, v37_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray37& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-  const T27 v27_;
-  const T28 v28_;
-  const T29 v29_;
-  const T30 v30_;
-  const T31 v31_;
-  const T32 v32_;
-  const T33 v33_;
-  const T34 v34_;
-  const T35 v35_;
-  const T36 v36_;
-  const T37 v37_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38>
-class ValueArray38 {
- public:
-  ValueArray38(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
-      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38) : v1_(v1), v2_(v2), v3_(v3),
-      v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
-      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),
-      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),
-      v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),
-      v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34),
-      v35_(v35), v36_(v36), v37_(v37), v38_(v38) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v35_,
-        v36_, v37_, v38_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray38& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-  const T27 v27_;
-  const T28 v28_;
-  const T29 v29_;
-  const T30 v30_;
-  const T31 v31_;
-  const T32 v32_;
-  const T33 v33_;
-  const T34 v34_;
-  const T35 v35_;
-  const T36 v36_;
-  const T37 v37_;
-  const T38 v38_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39>
-class ValueArray39 {
- public:
-  ValueArray39(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
-      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39) : v1_(v1), v2_(v2),
-      v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
-      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),
-      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),
-      v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),
-      v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34),
-      v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v35_,
-        v36_, v37_, v38_, v39_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray39& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-  const T27 v27_;
-  const T28 v28_;
-  const T29 v29_;
-  const T30 v30_;
-  const T31 v31_;
-  const T32 v32_;
-  const T33 v33_;
-  const T34 v34_;
-  const T35 v35_;
-  const T36 v36_;
-  const T37 v37_;
-  const T38 v38_;
-  const T39 v39_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40>
-class ValueArray40 {
- public:
-  ValueArray40(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
-      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40) : v1_(v1),
-      v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),
-      v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),
-      v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21),
-      v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27),
-      v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33),
-      v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39),
-      v40_(v40) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v35_,
-        v36_, v37_, v38_, v39_, v40_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray40& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-  const T27 v27_;
-  const T28 v28_;
-  const T29 v29_;
-  const T30 v30_;
-  const T31 v31_;
-  const T32 v32_;
-  const T33 v33_;
-  const T34 v34_;
-  const T35 v35_;
-  const T36 v36_;
-  const T37 v37_;
-  const T38 v38_;
-  const T39 v39_;
-  const T40 v40_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41>
-class ValueArray41 {
- public:
-  ValueArray41(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
-      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40,
-      T41 v41) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
-      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
-      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),
-      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),
-      v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),
-      v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38),
-      v39_(v39), v40_(v40), v41_(v41) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v35_,
-        v36_, v37_, v38_, v39_, v40_, v41_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray41& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-  const T27 v27_;
-  const T28 v28_;
-  const T29 v29_;
-  const T30 v30_;
-  const T31 v31_;
-  const T32 v32_;
-  const T33 v33_;
-  const T34 v34_;
-  const T35 v35_;
-  const T36 v36_;
-  const T37 v37_;
-  const T38 v38_;
-  const T39 v39_;
-  const T40 v40_;
-  const T41 v41_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42>
-class ValueArray42 {
- public:
-  ValueArray42(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
-      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
-      T42 v42) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
-      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
-      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),
-      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),
-      v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),
-      v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38),
-      v39_(v39), v40_(v40), v41_(v41), v42_(v42) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v35_,
-        v36_, v37_, v38_, v39_, v40_, v41_, v42_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray42& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-  const T27 v27_;
-  const T28 v28_;
-  const T29 v29_;
-  const T30 v30_;
-  const T31 v31_;
-  const T32 v32_;
-  const T33 v33_;
-  const T34 v34_;
-  const T35 v35_;
-  const T36 v36_;
-  const T37 v37_;
-  const T38 v38_;
-  const T39 v39_;
-  const T40 v40_;
-  const T41 v41_;
-  const T42 v42_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43>
-class ValueArray43 {
- public:
-  ValueArray43(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
-      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
-      T42 v42, T43 v43) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),
-      v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13),
-      v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19),
-      v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25),
-      v26_(v26), v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31),
-      v32_(v32), v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37),
-      v38_(v38), v39_(v39), v40_(v40), v41_(v41), v42_(v42), v43_(v43) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v35_,
-        v36_, v37_, v38_, v39_, v40_, v41_, v42_, v43_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray43& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-  const T27 v27_;
-  const T28 v28_;
-  const T29 v29_;
-  const T30 v30_;
-  const T31 v31_;
-  const T32 v32_;
-  const T33 v33_;
-  const T34 v34_;
-  const T35 v35_;
-  const T36 v36_;
-  const T37 v37_;
-  const T38 v38_;
-  const T39 v39_;
-  const T40 v40_;
-  const T41 v41_;
-  const T42 v42_;
-  const T43 v43_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44>
-class ValueArray44 {
- public:
-  ValueArray44(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
-      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
-      T42 v42, T43 v43, T44 v44) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),
-      v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12),
-      v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18),
-      v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24),
-      v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29), v30_(v30),
-      v31_(v31), v32_(v32), v33_(v33), v34_(v34), v35_(v35), v36_(v36),
-      v37_(v37), v38_(v38), v39_(v39), v40_(v40), v41_(v41), v42_(v42),
-      v43_(v43), v44_(v44) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v35_,
-        v36_, v37_, v38_, v39_, v40_, v41_, v42_, v43_, v44_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray44& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-  const T27 v27_;
-  const T28 v28_;
-  const T29 v29_;
-  const T30 v30_;
-  const T31 v31_;
-  const T32 v32_;
-  const T33 v33_;
-  const T34 v34_;
-  const T35 v35_;
-  const T36 v36_;
-  const T37 v37_;
-  const T38 v38_;
-  const T39 v39_;
-  const T40 v40_;
-  const T41 v41_;
-  const T42 v42_;
-  const T43 v43_;
-  const T44 v44_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44, typename T45>
-class ValueArray45 {
- public:
-  ValueArray45(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
-      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
-      T42 v42, T43 v43, T44 v44, T45 v45) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),
-      v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),
-      v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17),
-      v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23),
-      v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29),
-      v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34), v35_(v35),
-      v36_(v36), v37_(v37), v38_(v38), v39_(v39), v40_(v40), v41_(v41),
-      v42_(v42), v43_(v43), v44_(v44), v45_(v45) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v35_,
-        v36_, v37_, v38_, v39_, v40_, v41_, v42_, v43_, v44_, v45_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray45& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-  const T27 v27_;
-  const T28 v28_;
-  const T29 v29_;
-  const T30 v30_;
-  const T31 v31_;
-  const T32 v32_;
-  const T33 v33_;
-  const T34 v34_;
-  const T35 v35_;
-  const T36 v36_;
-  const T37 v37_;
-  const T38 v38_;
-  const T39 v39_;
-  const T40 v40_;
-  const T41 v41_;
-  const T42 v42_;
-  const T43 v43_;
-  const T44 v44_;
-  const T45 v45_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44, typename T45,
-    typename T46>
-class ValueArray46 {
- public:
-  ValueArray46(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
-      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
-      T42 v42, T43 v43, T44 v44, T45 v45, T46 v46) : v1_(v1), v2_(v2), v3_(v3),
-      v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
-      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),
-      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),
-      v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),
-      v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34),
-      v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39), v40_(v40),
-      v41_(v41), v42_(v42), v43_(v43), v44_(v44), v45_(v45), v46_(v46) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v35_,
-        v36_, v37_, v38_, v39_, v40_, v41_, v42_, v43_, v44_, v45_, v46_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray46& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-  const T27 v27_;
-  const T28 v28_;
-  const T29 v29_;
-  const T30 v30_;
-  const T31 v31_;
-  const T32 v32_;
-  const T33 v33_;
-  const T34 v34_;
-  const T35 v35_;
-  const T36 v36_;
-  const T37 v37_;
-  const T38 v38_;
-  const T39 v39_;
-  const T40 v40_;
-  const T41 v41_;
-  const T42 v42_;
-  const T43 v43_;
-  const T44 v44_;
-  const T45 v45_;
-  const T46 v46_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44, typename T45,
-    typename T46, typename T47>
-class ValueArray47 {
- public:
-  ValueArray47(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
-      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
-      T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47) : v1_(v1), v2_(v2),
-      v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),
-      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),
-      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),
-      v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),
-      v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34),
-      v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39), v40_(v40),
-      v41_(v41), v42_(v42), v43_(v43), v44_(v44), v45_(v45), v46_(v46),
-      v47_(v47) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v35_,
-        v36_, v37_, v38_, v39_, v40_, v41_, v42_, v43_, v44_, v45_, v46_,
-        v47_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray47& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-  const T27 v27_;
-  const T28 v28_;
-  const T29 v29_;
-  const T30 v30_;
-  const T31 v31_;
-  const T32 v32_;
-  const T33 v33_;
-  const T34 v34_;
-  const T35 v35_;
-  const T36 v36_;
-  const T37 v37_;
-  const T38 v38_;
-  const T39 v39_;
-  const T40 v40_;
-  const T41 v41_;
-  const T42 v42_;
-  const T43 v43_;
-  const T44 v44_;
-  const T45 v45_;
-  const T46 v46_;
-  const T47 v47_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44, typename T45,
-    typename T46, typename T47, typename T48>
-class ValueArray48 {
- public:
-  ValueArray48(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
-      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
-      T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47, T48 v48) : v1_(v1),
-      v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),
-      v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),
-      v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21),
-      v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27),
-      v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33),
-      v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39),
-      v40_(v40), v41_(v41), v42_(v42), v43_(v43), v44_(v44), v45_(v45),
-      v46_(v46), v47_(v47), v48_(v48) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v35_,
-        v36_, v37_, v38_, v39_, v40_, v41_, v42_, v43_, v44_, v45_, v46_, v47_,
-        v48_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray48& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-  const T27 v27_;
-  const T28 v28_;
-  const T29 v29_;
-  const T30 v30_;
-  const T31 v31_;
-  const T32 v32_;
-  const T33 v33_;
-  const T34 v34_;
-  const T35 v35_;
-  const T36 v36_;
-  const T37 v37_;
-  const T38 v38_;
-  const T39 v39_;
-  const T40 v40_;
-  const T41 v41_;
-  const T42 v42_;
-  const T43 v43_;
-  const T44 v44_;
-  const T45 v45_;
-  const T46 v46_;
-  const T47 v47_;
-  const T48 v48_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44, typename T45,
-    typename T46, typename T47, typename T48, typename T49>
-class ValueArray49 {
- public:
-  ValueArray49(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
-      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
-      T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47, T48 v48,
-      T49 v49) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
-      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
-      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),
-      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),
-      v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),
-      v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38),
-      v39_(v39), v40_(v40), v41_(v41), v42_(v42), v43_(v43), v44_(v44),
-      v45_(v45), v46_(v46), v47_(v47), v48_(v48), v49_(v49) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v35_,
-        v36_, v37_, v38_, v39_, v40_, v41_, v42_, v43_, v44_, v45_, v46_, v47_,
-        v48_, v49_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray49& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-  const T27 v27_;
-  const T28 v28_;
-  const T29 v29_;
-  const T30 v30_;
-  const T31 v31_;
-  const T32 v32_;
-  const T33 v33_;
-  const T34 v34_;
-  const T35 v35_;
-  const T36 v36_;
-  const T37 v37_;
-  const T38 v38_;
-  const T39 v39_;
-  const T40 v40_;
-  const T41 v41_;
-  const T42 v42_;
-  const T43 v43_;
-  const T44 v44_;
-  const T45 v45_;
-  const T46 v46_;
-  const T47 v47_;
-  const T48 v48_;
-  const T49 v49_;
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44, typename T45,
-    typename T46, typename T47, typename T48, typename T49, typename T50>
-class ValueArray50 {
- public:
-  ValueArray50(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
-      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
-      T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47, T48 v48, T49 v49,
-      T50 v50) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),
-      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),
-      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),
-      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),
-      v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),
-      v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38),
-      v39_(v39), v40_(v40), v41_(v41), v42_(v42), v43_(v43), v44_(v44),
-      v45_(v45), v46_(v46), v47_(v47), v48_(v48), v49_(v49), v50_(v50) {}
-
-  template <typename T>
-  operator ParamGenerator<T>() const {
-    const T array[] = {v1_, v2_, v3_, v4_, v5_, v6_, v7_, v8_, v9_, v10_, v11_,
-        v12_, v13_, v14_, v15_, v16_, v17_, v18_, v19_, v20_, v21_, v22_, v23_,
-        v24_, v25_, v26_, v27_, v28_, v29_, v30_, v31_, v32_, v33_, v34_, v35_,
-        v36_, v37_, v38_, v39_, v40_, v41_, v42_, v43_, v44_, v45_, v46_, v47_,
-        v48_, v49_, v50_};
-    return ValuesIn(array);
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const ValueArray50& other);
-
-  const T1 v1_;
-  const T2 v2_;
-  const T3 v3_;
-  const T4 v4_;
-  const T5 v5_;
-  const T6 v6_;
-  const T7 v7_;
-  const T8 v8_;
-  const T9 v9_;
-  const T10 v10_;
-  const T11 v11_;
-  const T12 v12_;
-  const T13 v13_;
-  const T14 v14_;
-  const T15 v15_;
-  const T16 v16_;
-  const T17 v17_;
-  const T18 v18_;
-  const T19 v19_;
-  const T20 v20_;
-  const T21 v21_;
-  const T22 v22_;
-  const T23 v23_;
-  const T24 v24_;
-  const T25 v25_;
-  const T26 v26_;
-  const T27 v27_;
-  const T28 v28_;
-  const T29 v29_;
-  const T30 v30_;
-  const T31 v31_;
-  const T32 v32_;
-  const T33 v33_;
-  const T34 v34_;
-  const T35 v35_;
-  const T36 v36_;
-  const T37 v37_;
-  const T38 v38_;
-  const T39 v39_;
-  const T40 v40_;
-  const T41 v41_;
-  const T42 v42_;
-  const T43 v43_;
-  const T44 v44_;
-  const T45 v45_;
-  const T46 v46_;
-  const T47 v47_;
-  const T48 v48_;
-  const T49 v49_;
-  const T50 v50_;
-};
-
-# if GTEST_HAS_COMBINE
-// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
-//
-// Generates values from the Cartesian product of values produced
-// by the argument generators.
-//
-template <typename T1, typename T2>
-class CartesianProductGenerator2
-    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2> > {
- public:
-  typedef ::std::tr1::tuple<T1, T2> ParamType;
-
-  CartesianProductGenerator2(const ParamGenerator<T1>& g1,
-      const ParamGenerator<T2>& g2)
-      : g1_(g1), g2_(g2) {}
-  virtual ~CartesianProductGenerator2() {}
-
-  virtual ParamIteratorInterface<ParamType>* Begin() const {
-    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin());
-  }
-  virtual ParamIteratorInterface<ParamType>* End() const {
-    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end());
-  }
-
- private:
-  class Iterator : public ParamIteratorInterface<ParamType> {
-   public:
-    Iterator(const ParamGeneratorInterface<ParamType>* base,
-      const ParamGenerator<T1>& g1,
-      const typename ParamGenerator<T1>::iterator& current1,
-      const ParamGenerator<T2>& g2,
-      const typename ParamGenerator<T2>::iterator& current2)
-        : base_(base),
-          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
-          begin2_(g2.begin()), end2_(g2.end()), current2_(current2)    {
-      ComputeCurrentValue();
-    }
-    virtual ~Iterator() {}
-
-    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
-      return base_;
-    }
-    // Advance should not be called on beyond-of-range iterators
-    // so no component iterators must be beyond end of range, either.
-    virtual void Advance() {
-      assert(!AtEnd());
-      ++current2_;
-      if (current2_ == end2_) {
-        current2_ = begin2_;
-        ++current1_;
-      }
-      ComputeCurrentValue();
-    }
-    virtual ParamIteratorInterface<ParamType>* Clone() const {
-      return new Iterator(*this);
-    }
-    virtual const ParamType* Current() const { return &current_value_; }
-    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
-      // Having the same base generator guarantees that the other
-      // iterator is of the same type and we can downcast.
-      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
-          << "The program attempted to compare iterators "
-          << "from different generators." << std::endl;
-      const Iterator* typed_other =
-          CheckedDowncastToActualType<const Iterator>(&other);
-      // We must report iterators equal if they both point beyond their
-      // respective ranges. That can happen in a variety of fashions,
-      // so we have to consult AtEnd().
-      return (AtEnd() && typed_other->AtEnd()) ||
-         (
-          current1_ == typed_other->current1_ &&
-          current2_ == typed_other->current2_);
-    }
-
-   private:
-    Iterator(const Iterator& other)
-        : base_(other.base_),
-        begin1_(other.begin1_),
-        end1_(other.end1_),
-        current1_(other.current1_),
-        begin2_(other.begin2_),
-        end2_(other.end2_),
-        current2_(other.current2_) {
-      ComputeCurrentValue();
-    }
-
-    void ComputeCurrentValue() {
-      if (!AtEnd())
-        current_value_ = ParamType(*current1_, *current2_);
-    }
-    bool AtEnd() const {
-      // We must report iterator past the end of the range when either of the
-      // component iterators has reached the end of its range.
-      return
-          current1_ == end1_ ||
-          current2_ == end2_;
-    }
-
-    // No implementation - assignment is unsupported.
-    void operator=(const Iterator& other);
-
-    const ParamGeneratorInterface<ParamType>* const base_;
-    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
-    // current[i]_ is the actual traversing iterator.
-    const typename ParamGenerator<T1>::iterator begin1_;
-    const typename ParamGenerator<T1>::iterator end1_;
-    typename ParamGenerator<T1>::iterator current1_;
-    const typename ParamGenerator<T2>::iterator begin2_;
-    const typename ParamGenerator<T2>::iterator end2_;
-    typename ParamGenerator<T2>::iterator current2_;
-    ParamType current_value_;
-  };  // class CartesianProductGenerator2::Iterator
-
-  // No implementation - assignment is unsupported.
-  void operator=(const CartesianProductGenerator2& other);
-
-  const ParamGenerator<T1> g1_;
-  const ParamGenerator<T2> g2_;
-};  // class CartesianProductGenerator2
-
-
-template <typename T1, typename T2, typename T3>
-class CartesianProductGenerator3
-    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3> > {
- public:
-  typedef ::std::tr1::tuple<T1, T2, T3> ParamType;
-
-  CartesianProductGenerator3(const ParamGenerator<T1>& g1,
-      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3)
-      : g1_(g1), g2_(g2), g3_(g3) {}
-  virtual ~CartesianProductGenerator3() {}
-
-  virtual ParamIteratorInterface<ParamType>* Begin() const {
-    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
-        g3_.begin());
-  }
-  virtual ParamIteratorInterface<ParamType>* End() const {
-    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end());
-  }
-
- private:
-  class Iterator : public ParamIteratorInterface<ParamType> {
-   public:
-    Iterator(const ParamGeneratorInterface<ParamType>* base,
-      const ParamGenerator<T1>& g1,
-      const typename ParamGenerator<T1>::iterator& current1,
-      const ParamGenerator<T2>& g2,
-      const typename ParamGenerator<T2>::iterator& current2,
-      const ParamGenerator<T3>& g3,
-      const typename ParamGenerator<T3>::iterator& current3)
-        : base_(base),
-          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
-          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
-          begin3_(g3.begin()), end3_(g3.end()), current3_(current3)    {
-      ComputeCurrentValue();
-    }
-    virtual ~Iterator() {}
-
-    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
-      return base_;
-    }
-    // Advance should not be called on beyond-of-range iterators
-    // so no component iterators must be beyond end of range, either.
-    virtual void Advance() {
-      assert(!AtEnd());
-      ++current3_;
-      if (current3_ == end3_) {
-        current3_ = begin3_;
-        ++current2_;
-      }
-      if (current2_ == end2_) {
-        current2_ = begin2_;
-        ++current1_;
-      }
-      ComputeCurrentValue();
-    }
-    virtual ParamIteratorInterface<ParamType>* Clone() const {
-      return new Iterator(*this);
-    }
-    virtual const ParamType* Current() const { return &current_value_; }
-    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
-      // Having the same base generator guarantees that the other
-      // iterator is of the same type and we can downcast.
-      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
-          << "The program attempted to compare iterators "
-          << "from different generators." << std::endl;
-      const Iterator* typed_other =
-          CheckedDowncastToActualType<const Iterator>(&other);
-      // We must report iterators equal if they both point beyond their
-      // respective ranges. That can happen in a variety of fashions,
-      // so we have to consult AtEnd().
-      return (AtEnd() && typed_other->AtEnd()) ||
-         (
-          current1_ == typed_other->current1_ &&
-          current2_ == typed_other->current2_ &&
-          current3_ == typed_other->current3_);
-    }
-
-   private:
-    Iterator(const Iterator& other)
-        : base_(other.base_),
-        begin1_(other.begin1_),
-        end1_(other.end1_),
-        current1_(other.current1_),
-        begin2_(other.begin2_),
-        end2_(other.end2_),
-        current2_(other.current2_),
-        begin3_(other.begin3_),
-        end3_(other.end3_),
-        current3_(other.current3_) {
-      ComputeCurrentValue();
-    }
-
-    void ComputeCurrentValue() {
-      if (!AtEnd())
-        current_value_ = ParamType(*current1_, *current2_, *current3_);
-    }
-    bool AtEnd() const {
-      // We must report iterator past the end of the range when either of the
-      // component iterators has reached the end of its range.
-      return
-          current1_ == end1_ ||
-          current2_ == end2_ ||
-          current3_ == end3_;
-    }
-
-    // No implementation - assignment is unsupported.
-    void operator=(const Iterator& other);
-
-    const ParamGeneratorInterface<ParamType>* const base_;
-    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
-    // current[i]_ is the actual traversing iterator.
-    const typename ParamGenerator<T1>::iterator begin1_;
-    const typename ParamGenerator<T1>::iterator end1_;
-    typename ParamGenerator<T1>::iterator current1_;
-    const typename ParamGenerator<T2>::iterator begin2_;
-    const typename ParamGenerator<T2>::iterator end2_;
-    typename ParamGenerator<T2>::iterator current2_;
-    const typename ParamGenerator<T3>::iterator begin3_;
-    const typename ParamGenerator<T3>::iterator end3_;
-    typename ParamGenerator<T3>::iterator current3_;
-    ParamType current_value_;
-  };  // class CartesianProductGenerator3::Iterator
-
-  // No implementation - assignment is unsupported.
-  void operator=(const CartesianProductGenerator3& other);
-
-  const ParamGenerator<T1> g1_;
-  const ParamGenerator<T2> g2_;
-  const ParamGenerator<T3> g3_;
-};  // class CartesianProductGenerator3
-
-
-template <typename T1, typename T2, typename T3, typename T4>
-class CartesianProductGenerator4
-    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4> > {
- public:
-  typedef ::std::tr1::tuple<T1, T2, T3, T4> ParamType;
-
-  CartesianProductGenerator4(const ParamGenerator<T1>& g1,
-      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
-      const ParamGenerator<T4>& g4)
-      : g1_(g1), g2_(g2), g3_(g3), g4_(g4) {}
-  virtual ~CartesianProductGenerator4() {}
-
-  virtual ParamIteratorInterface<ParamType>* Begin() const {
-    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
-        g3_.begin(), g4_, g4_.begin());
-  }
-  virtual ParamIteratorInterface<ParamType>* End() const {
-    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
-        g4_, g4_.end());
-  }
-
- private:
-  class Iterator : public ParamIteratorInterface<ParamType> {
-   public:
-    Iterator(const ParamGeneratorInterface<ParamType>* base,
-      const ParamGenerator<T1>& g1,
-      const typename ParamGenerator<T1>::iterator& current1,
-      const ParamGenerator<T2>& g2,
-      const typename ParamGenerator<T2>::iterator& current2,
-      const ParamGenerator<T3>& g3,
-      const typename ParamGenerator<T3>::iterator& current3,
-      const ParamGenerator<T4>& g4,
-      const typename ParamGenerator<T4>::iterator& current4)
-        : base_(base),
-          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
-          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
-          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
-          begin4_(g4.begin()), end4_(g4.end()), current4_(current4)    {
-      ComputeCurrentValue();
-    }
-    virtual ~Iterator() {}
-
-    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
-      return base_;
-    }
-    // Advance should not be called on beyond-of-range iterators
-    // so no component iterators must be beyond end of range, either.
-    virtual void Advance() {
-      assert(!AtEnd());
-      ++current4_;
-      if (current4_ == end4_) {
-        current4_ = begin4_;
-        ++current3_;
-      }
-      if (current3_ == end3_) {
-        current3_ = begin3_;
-        ++current2_;
-      }
-      if (current2_ == end2_) {
-        current2_ = begin2_;
-        ++current1_;
-      }
-      ComputeCurrentValue();
-    }
-    virtual ParamIteratorInterface<ParamType>* Clone() const {
-      return new Iterator(*this);
-    }
-    virtual const ParamType* Current() const { return &current_value_; }
-    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
-      // Having the same base generator guarantees that the other
-      // iterator is of the same type and we can downcast.
-      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
-          << "The program attempted to compare iterators "
-          << "from different generators." << std::endl;
-      const Iterator* typed_other =
-          CheckedDowncastToActualType<const Iterator>(&other);
-      // We must report iterators equal if they both point beyond their
-      // respective ranges. That can happen in a variety of fashions,
-      // so we have to consult AtEnd().
-      return (AtEnd() && typed_other->AtEnd()) ||
-         (
-          current1_ == typed_other->current1_ &&
-          current2_ == typed_other->current2_ &&
-          current3_ == typed_other->current3_ &&
-          current4_ == typed_other->current4_);
-    }
-
-   private:
-    Iterator(const Iterator& other)
-        : base_(other.base_),
-        begin1_(other.begin1_),
-        end1_(other.end1_),
-        current1_(other.current1_),
-        begin2_(other.begin2_),
-        end2_(other.end2_),
-        current2_(other.current2_),
-        begin3_(other.begin3_),
-        end3_(other.end3_),
-        current3_(other.current3_),
-        begin4_(other.begin4_),
-        end4_(other.end4_),
-        current4_(other.current4_) {
-      ComputeCurrentValue();
-    }
-
-    void ComputeCurrentValue() {
-      if (!AtEnd())
-        current_value_ = ParamType(*current1_, *current2_, *current3_,
-            *current4_);
-    }
-    bool AtEnd() const {
-      // We must report iterator past the end of the range when either of the
-      // component iterators has reached the end of its range.
-      return
-          current1_ == end1_ ||
-          current2_ == end2_ ||
-          current3_ == end3_ ||
-          current4_ == end4_;
-    }
-
-    // No implementation - assignment is unsupported.
-    void operator=(const Iterator& other);
-
-    const ParamGeneratorInterface<ParamType>* const base_;
-    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
-    // current[i]_ is the actual traversing iterator.
-    const typename ParamGenerator<T1>::iterator begin1_;
-    const typename ParamGenerator<T1>::iterator end1_;
-    typename ParamGenerator<T1>::iterator current1_;
-    const typename ParamGenerator<T2>::iterator begin2_;
-    const typename ParamGenerator<T2>::iterator end2_;
-    typename ParamGenerator<T2>::iterator current2_;
-    const typename ParamGenerator<T3>::iterator begin3_;
-    const typename ParamGenerator<T3>::iterator end3_;
-    typename ParamGenerator<T3>::iterator current3_;
-    const typename ParamGenerator<T4>::iterator begin4_;
-    const typename ParamGenerator<T4>::iterator end4_;
-    typename ParamGenerator<T4>::iterator current4_;
-    ParamType current_value_;
-  };  // class CartesianProductGenerator4::Iterator
-
-  // No implementation - assignment is unsupported.
-  void operator=(const CartesianProductGenerator4& other);
-
-  const ParamGenerator<T1> g1_;
-  const ParamGenerator<T2> g2_;
-  const ParamGenerator<T3> g3_;
-  const ParamGenerator<T4> g4_;
-};  // class CartesianProductGenerator4
-
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5>
-class CartesianProductGenerator5
-    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5> > {
- public:
-  typedef ::std::tr1::tuple<T1, T2, T3, T4, T5> ParamType;
-
-  CartesianProductGenerator5(const ParamGenerator<T1>& g1,
-      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
-      const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5)
-      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5) {}
-  virtual ~CartesianProductGenerator5() {}
-
-  virtual ParamIteratorInterface<ParamType>* Begin() const {
-    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
-        g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin());
-  }
-  virtual ParamIteratorInterface<ParamType>* End() const {
-    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
-        g4_, g4_.end(), g5_, g5_.end());
-  }
-
- private:
-  class Iterator : public ParamIteratorInterface<ParamType> {
-   public:
-    Iterator(const ParamGeneratorInterface<ParamType>* base,
-      const ParamGenerator<T1>& g1,
-      const typename ParamGenerator<T1>::iterator& current1,
-      const ParamGenerator<T2>& g2,
-      const typename ParamGenerator<T2>::iterator& current2,
-      const ParamGenerator<T3>& g3,
-      const typename ParamGenerator<T3>::iterator& current3,
-      const ParamGenerator<T4>& g4,
-      const typename ParamGenerator<T4>::iterator& current4,
-      const ParamGenerator<T5>& g5,
-      const typename ParamGenerator<T5>::iterator& current5)
-        : base_(base),
-          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
-          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
-          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
-          begin4_(g4.begin()), end4_(g4.end()), current4_(current4),
-          begin5_(g5.begin()), end5_(g5.end()), current5_(current5)    {
-      ComputeCurrentValue();
-    }
-    virtual ~Iterator() {}
-
-    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
-      return base_;
-    }
-    // Advance should not be called on beyond-of-range iterators
-    // so no component iterators must be beyond end of range, either.
-    virtual void Advance() {
-      assert(!AtEnd());
-      ++current5_;
-      if (current5_ == end5_) {
-        current5_ = begin5_;
-        ++current4_;
-      }
-      if (current4_ == end4_) {
-        current4_ = begin4_;
-        ++current3_;
-      }
-      if (current3_ == end3_) {
-        current3_ = begin3_;
-        ++current2_;
-      }
-      if (current2_ == end2_) {
-        current2_ = begin2_;
-        ++current1_;
-      }
-      ComputeCurrentValue();
-    }
-    virtual ParamIteratorInterface<ParamType>* Clone() const {
-      return new Iterator(*this);
-    }
-    virtual const ParamType* Current() const { return &current_value_; }
-    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
-      // Having the same base generator guarantees that the other
-      // iterator is of the same type and we can downcast.
-      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
-          << "The program attempted to compare iterators "
-          << "from different generators." << std::endl;
-      const Iterator* typed_other =
-          CheckedDowncastToActualType<const Iterator>(&other);
-      // We must report iterators equal if they both point beyond their
-      // respective ranges. That can happen in a variety of fashions,
-      // so we have to consult AtEnd().
-      return (AtEnd() && typed_other->AtEnd()) ||
-         (
-          current1_ == typed_other->current1_ &&
-          current2_ == typed_other->current2_ &&
-          current3_ == typed_other->current3_ &&
-          current4_ == typed_other->current4_ &&
-          current5_ == typed_other->current5_);
-    }
-
-   private:
-    Iterator(const Iterator& other)
-        : base_(other.base_),
-        begin1_(other.begin1_),
-        end1_(other.end1_),
-        current1_(other.current1_),
-        begin2_(other.begin2_),
-        end2_(other.end2_),
-        current2_(other.current2_),
-        begin3_(other.begin3_),
-        end3_(other.end3_),
-        current3_(other.current3_),
-        begin4_(other.begin4_),
-        end4_(other.end4_),
-        current4_(other.current4_),
-        begin5_(other.begin5_),
-        end5_(other.end5_),
-        current5_(other.current5_) {
-      ComputeCurrentValue();
-    }
-
-    void ComputeCurrentValue() {
-      if (!AtEnd())
-        current_value_ = ParamType(*current1_, *current2_, *current3_,
-            *current4_, *current5_);
-    }
-    bool AtEnd() const {
-      // We must report iterator past the end of the range when either of the
-      // component iterators has reached the end of its range.
-      return
-          current1_ == end1_ ||
-          current2_ == end2_ ||
-          current3_ == end3_ ||
-          current4_ == end4_ ||
-          current5_ == end5_;
-    }
-
-    // No implementation - assignment is unsupported.
-    void operator=(const Iterator& other);
-
-    const ParamGeneratorInterface<ParamType>* const base_;
-    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
-    // current[i]_ is the actual traversing iterator.
-    const typename ParamGenerator<T1>::iterator begin1_;
-    const typename ParamGenerator<T1>::iterator end1_;
-    typename ParamGenerator<T1>::iterator current1_;
-    const typename ParamGenerator<T2>::iterator begin2_;
-    const typename ParamGenerator<T2>::iterator end2_;
-    typename ParamGenerator<T2>::iterator current2_;
-    const typename ParamGenerator<T3>::iterator begin3_;
-    const typename ParamGenerator<T3>::iterator end3_;
-    typename ParamGenerator<T3>::iterator current3_;
-    const typename ParamGenerator<T4>::iterator begin4_;
-    const typename ParamGenerator<T4>::iterator end4_;
-    typename ParamGenerator<T4>::iterator current4_;
-    const typename ParamGenerator<T5>::iterator begin5_;
-    const typename ParamGenerator<T5>::iterator end5_;
-    typename ParamGenerator<T5>::iterator current5_;
-    ParamType current_value_;
-  };  // class CartesianProductGenerator5::Iterator
-
-  // No implementation - assignment is unsupported.
-  void operator=(const CartesianProductGenerator5& other);
-
-  const ParamGenerator<T1> g1_;
-  const ParamGenerator<T2> g2_;
-  const ParamGenerator<T3> g3_;
-  const ParamGenerator<T4> g4_;
-  const ParamGenerator<T5> g5_;
-};  // class CartesianProductGenerator5
-
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6>
-class CartesianProductGenerator6
-    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5,
-        T6> > {
- public:
-  typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6> ParamType;
-
-  CartesianProductGenerator6(const ParamGenerator<T1>& g1,
-      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
-      const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,
-      const ParamGenerator<T6>& g6)
-      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6) {}
-  virtual ~CartesianProductGenerator6() {}
-
-  virtual ParamIteratorInterface<ParamType>* Begin() const {
-    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
-        g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin());
-  }
-  virtual ParamIteratorInterface<ParamType>* End() const {
-    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
-        g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end());
-  }
-
- private:
-  class Iterator : public ParamIteratorInterface<ParamType> {
-   public:
-    Iterator(const ParamGeneratorInterface<ParamType>* base,
-      const ParamGenerator<T1>& g1,
-      const typename ParamGenerator<T1>::iterator& current1,
-      const ParamGenerator<T2>& g2,
-      const typename ParamGenerator<T2>::iterator& current2,
-      const ParamGenerator<T3>& g3,
-      const typename ParamGenerator<T3>::iterator& current3,
-      const ParamGenerator<T4>& g4,
-      const typename ParamGenerator<T4>::iterator& current4,
-      const ParamGenerator<T5>& g5,
-      const typename ParamGenerator<T5>::iterator& current5,
-      const ParamGenerator<T6>& g6,
-      const typename ParamGenerator<T6>::iterator& current6)
-        : base_(base),
-          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
-          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
-          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
-          begin4_(g4.begin()), end4_(g4.end()), current4_(current4),
-          begin5_(g5.begin()), end5_(g5.end()), current5_(current5),
-          begin6_(g6.begin()), end6_(g6.end()), current6_(current6)    {
-      ComputeCurrentValue();
-    }
-    virtual ~Iterator() {}
-
-    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
-      return base_;
-    }
-    // Advance should not be called on beyond-of-range iterators
-    // so no component iterators must be beyond end of range, either.
-    virtual void Advance() {
-      assert(!AtEnd());
-      ++current6_;
-      if (current6_ == end6_) {
-        current6_ = begin6_;
-        ++current5_;
-      }
-      if (current5_ == end5_) {
-        current5_ = begin5_;
-        ++current4_;
-      }
-      if (current4_ == end4_) {
-        current4_ = begin4_;
-        ++current3_;
-      }
-      if (current3_ == end3_) {
-        current3_ = begin3_;
-        ++current2_;
-      }
-      if (current2_ == end2_) {
-        current2_ = begin2_;
-        ++current1_;
-      }
-      ComputeCurrentValue();
-    }
-    virtual ParamIteratorInterface<ParamType>* Clone() const {
-      return new Iterator(*this);
-    }
-    virtual const ParamType* Current() const { return &current_value_; }
-    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
-      // Having the same base generator guarantees that the other
-      // iterator is of the same type and we can downcast.
-      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
-          << "The program attempted to compare iterators "
-          << "from different generators." << std::endl;
-      const Iterator* typed_other =
-          CheckedDowncastToActualType<const Iterator>(&other);
-      // We must report iterators equal if they both point beyond their
-      // respective ranges. That can happen in a variety of fashions,
-      // so we have to consult AtEnd().
-      return (AtEnd() && typed_other->AtEnd()) ||
-         (
-          current1_ == typed_other->current1_ &&
-          current2_ == typed_other->current2_ &&
-          current3_ == typed_other->current3_ &&
-          current4_ == typed_other->current4_ &&
-          current5_ == typed_other->current5_ &&
-          current6_ == typed_other->current6_);
-    }
-
-   private:
-    Iterator(const Iterator& other)
-        : base_(other.base_),
-        begin1_(other.begin1_),
-        end1_(other.end1_),
-        current1_(other.current1_),
-        begin2_(other.begin2_),
-        end2_(other.end2_),
-        current2_(other.current2_),
-        begin3_(other.begin3_),
-        end3_(other.end3_),
-        current3_(other.current3_),
-        begin4_(other.begin4_),
-        end4_(other.end4_),
-        current4_(other.current4_),
-        begin5_(other.begin5_),
-        end5_(other.end5_),
-        current5_(other.current5_),
-        begin6_(other.begin6_),
-        end6_(other.end6_),
-        current6_(other.current6_) {
-      ComputeCurrentValue();
-    }
-
-    void ComputeCurrentValue() {
-      if (!AtEnd())
-        current_value_ = ParamType(*current1_, *current2_, *current3_,
-            *current4_, *current5_, *current6_);
-    }
-    bool AtEnd() const {
-      // We must report iterator past the end of the range when either of the
-      // component iterators has reached the end of its range.
-      return
-          current1_ == end1_ ||
-          current2_ == end2_ ||
-          current3_ == end3_ ||
-          current4_ == end4_ ||
-          current5_ == end5_ ||
-          current6_ == end6_;
-    }
-
-    // No implementation - assignment is unsupported.
-    void operator=(const Iterator& other);
-
-    const ParamGeneratorInterface<ParamType>* const base_;
-    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
-    // current[i]_ is the actual traversing iterator.
-    const typename ParamGenerator<T1>::iterator begin1_;
-    const typename ParamGenerator<T1>::iterator end1_;
-    typename ParamGenerator<T1>::iterator current1_;
-    const typename ParamGenerator<T2>::iterator begin2_;
-    const typename ParamGenerator<T2>::iterator end2_;
-    typename ParamGenerator<T2>::iterator current2_;
-    const typename ParamGenerator<T3>::iterator begin3_;
-    const typename ParamGenerator<T3>::iterator end3_;
-    typename ParamGenerator<T3>::iterator current3_;
-    const typename ParamGenerator<T4>::iterator begin4_;
-    const typename ParamGenerator<T4>::iterator end4_;
-    typename ParamGenerator<T4>::iterator current4_;
-    const typename ParamGenerator<T5>::iterator begin5_;
-    const typename ParamGenerator<T5>::iterator end5_;
-    typename ParamGenerator<T5>::iterator current5_;
-    const typename ParamGenerator<T6>::iterator begin6_;
-    const typename ParamGenerator<T6>::iterator end6_;
-    typename ParamGenerator<T6>::iterator current6_;
-    ParamType current_value_;
-  };  // class CartesianProductGenerator6::Iterator
-
-  // No implementation - assignment is unsupported.
-  void operator=(const CartesianProductGenerator6& other);
-
-  const ParamGenerator<T1> g1_;
-  const ParamGenerator<T2> g2_;
-  const ParamGenerator<T3> g3_;
-  const ParamGenerator<T4> g4_;
-  const ParamGenerator<T5> g5_;
-  const ParamGenerator<T6> g6_;
-};  // class CartesianProductGenerator6
-
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7>
-class CartesianProductGenerator7
-    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6,
-        T7> > {
- public:
-  typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7> ParamType;
-
-  CartesianProductGenerator7(const ParamGenerator<T1>& g1,
-      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
-      const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,
-      const ParamGenerator<T6>& g6, const ParamGenerator<T7>& g7)
-      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7) {}
-  virtual ~CartesianProductGenerator7() {}
-
-  virtual ParamIteratorInterface<ParamType>* Begin() const {
-    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
-        g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_,
-        g7_.begin());
-  }
-  virtual ParamIteratorInterface<ParamType>* End() const {
-    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
-        g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end());
-  }
-
- private:
-  class Iterator : public ParamIteratorInterface<ParamType> {
-   public:
-    Iterator(const ParamGeneratorInterface<ParamType>* base,
-      const ParamGenerator<T1>& g1,
-      const typename ParamGenerator<T1>::iterator& current1,
-      const ParamGenerator<T2>& g2,
-      const typename ParamGenerator<T2>::iterator& current2,
-      const ParamGenerator<T3>& g3,
-      const typename ParamGenerator<T3>::iterator& current3,
-      const ParamGenerator<T4>& g4,
-      const typename ParamGenerator<T4>::iterator& current4,
-      const ParamGenerator<T5>& g5,
-      const typename ParamGenerator<T5>::iterator& current5,
-      const ParamGenerator<T6>& g6,
-      const typename ParamGenerator<T6>::iterator& current6,
-      const ParamGenerator<T7>& g7,
-      const typename ParamGenerator<T7>::iterator& current7)
-        : base_(base),
-          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
-          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
-          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
-          begin4_(g4.begin()), end4_(g4.end()), current4_(current4),
-          begin5_(g5.begin()), end5_(g5.end()), current5_(current5),
-          begin6_(g6.begin()), end6_(g6.end()), current6_(current6),
-          begin7_(g7.begin()), end7_(g7.end()), current7_(current7)    {
-      ComputeCurrentValue();
-    }
-    virtual ~Iterator() {}
-
-    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
-      return base_;
-    }
-    // Advance should not be called on beyond-of-range iterators
-    // so no component iterators must be beyond end of range, either.
-    virtual void Advance() {
-      assert(!AtEnd());
-      ++current7_;
-      if (current7_ == end7_) {
-        current7_ = begin7_;
-        ++current6_;
-      }
-      if (current6_ == end6_) {
-        current6_ = begin6_;
-        ++current5_;
-      }
-      if (current5_ == end5_) {
-        current5_ = begin5_;
-        ++current4_;
-      }
-      if (current4_ == end4_) {
-        current4_ = begin4_;
-        ++current3_;
-      }
-      if (current3_ == end3_) {
-        current3_ = begin3_;
-        ++current2_;
-      }
-      if (current2_ == end2_) {
-        current2_ = begin2_;
-        ++current1_;
-      }
-      ComputeCurrentValue();
-    }
-    virtual ParamIteratorInterface<ParamType>* Clone() const {
-      return new Iterator(*this);
-    }
-    virtual const ParamType* Current() const { return &current_value_; }
-    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
-      // Having the same base generator guarantees that the other
-      // iterator is of the same type and we can downcast.
-      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
-          << "The program attempted to compare iterators "
-          << "from different generators." << std::endl;
-      const Iterator* typed_other =
-          CheckedDowncastToActualType<const Iterator>(&other);
-      // We must report iterators equal if they both point beyond their
-      // respective ranges. That can happen in a variety of fashions,
-      // so we have to consult AtEnd().
-      return (AtEnd() && typed_other->AtEnd()) ||
-         (
-          current1_ == typed_other->current1_ &&
-          current2_ == typed_other->current2_ &&
-          current3_ == typed_other->current3_ &&
-          current4_ == typed_other->current4_ &&
-          current5_ == typed_other->current5_ &&
-          current6_ == typed_other->current6_ &&
-          current7_ == typed_other->current7_);
-    }
-
-   private:
-    Iterator(const Iterator& other)
-        : base_(other.base_),
-        begin1_(other.begin1_),
-        end1_(other.end1_),
-        current1_(other.current1_),
-        begin2_(other.begin2_),
-        end2_(other.end2_),
-        current2_(other.current2_),
-        begin3_(other.begin3_),
-        end3_(other.end3_),
-        current3_(other.current3_),
-        begin4_(other.begin4_),
-        end4_(other.end4_),
-        current4_(other.current4_),
-        begin5_(other.begin5_),
-        end5_(other.end5_),
-        current5_(other.current5_),
-        begin6_(other.begin6_),
-        end6_(other.end6_),
-        current6_(other.current6_),
-        begin7_(other.begin7_),
-        end7_(other.end7_),
-        current7_(other.current7_) {
-      ComputeCurrentValue();
-    }
-
-    void ComputeCurrentValue() {
-      if (!AtEnd())
-        current_value_ = ParamType(*current1_, *current2_, *current3_,
-            *current4_, *current5_, *current6_, *current7_);
-    }
-    bool AtEnd() const {
-      // We must report iterator past the end of the range when either of the
-      // component iterators has reached the end of its range.
-      return
-          current1_ == end1_ ||
-          current2_ == end2_ ||
-          current3_ == end3_ ||
-          current4_ == end4_ ||
-          current5_ == end5_ ||
-          current6_ == end6_ ||
-          current7_ == end7_;
-    }
-
-    // No implementation - assignment is unsupported.
-    void operator=(const Iterator& other);
-
-    const ParamGeneratorInterface<ParamType>* const base_;
-    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
-    // current[i]_ is the actual traversing iterator.
-    const typename ParamGenerator<T1>::iterator begin1_;
-    const typename ParamGenerator<T1>::iterator end1_;
-    typename ParamGenerator<T1>::iterator current1_;
-    const typename ParamGenerator<T2>::iterator begin2_;
-    const typename ParamGenerator<T2>::iterator end2_;
-    typename ParamGenerator<T2>::iterator current2_;
-    const typename ParamGenerator<T3>::iterator begin3_;
-    const typename ParamGenerator<T3>::iterator end3_;
-    typename ParamGenerator<T3>::iterator current3_;
-    const typename ParamGenerator<T4>::iterator begin4_;
-    const typename ParamGenerator<T4>::iterator end4_;
-    typename ParamGenerator<T4>::iterator current4_;
-    const typename ParamGenerator<T5>::iterator begin5_;
-    const typename ParamGenerator<T5>::iterator end5_;
-    typename ParamGenerator<T5>::iterator current5_;
-    const typename ParamGenerator<T6>::iterator begin6_;
-    const typename ParamGenerator<T6>::iterator end6_;
-    typename ParamGenerator<T6>::iterator current6_;
-    const typename ParamGenerator<T7>::iterator begin7_;
-    const typename ParamGenerator<T7>::iterator end7_;
-    typename ParamGenerator<T7>::iterator current7_;
-    ParamType current_value_;
-  };  // class CartesianProductGenerator7::Iterator
-
-  // No implementation - assignment is unsupported.
-  void operator=(const CartesianProductGenerator7& other);
-
-  const ParamGenerator<T1> g1_;
-  const ParamGenerator<T2> g2_;
-  const ParamGenerator<T3> g3_;
-  const ParamGenerator<T4> g4_;
-  const ParamGenerator<T5> g5_;
-  const ParamGenerator<T6> g6_;
-  const ParamGenerator<T7> g7_;
-};  // class CartesianProductGenerator7
-
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8>
-class CartesianProductGenerator8
-    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6,
-        T7, T8> > {
- public:
-  typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8> ParamType;
-
-  CartesianProductGenerator8(const ParamGenerator<T1>& g1,
-      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
-      const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,
-      const ParamGenerator<T6>& g6, const ParamGenerator<T7>& g7,
-      const ParamGenerator<T8>& g8)
-      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7),
-          g8_(g8) {}
-  virtual ~CartesianProductGenerator8() {}
-
-  virtual ParamIteratorInterface<ParamType>* Begin() const {
-    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
-        g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_,
-        g7_.begin(), g8_, g8_.begin());
-  }
-  virtual ParamIteratorInterface<ParamType>* End() const {
-    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
-        g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end(), g8_,
-        g8_.end());
-  }
-
- private:
-  class Iterator : public ParamIteratorInterface<ParamType> {
-   public:
-    Iterator(const ParamGeneratorInterface<ParamType>* base,
-      const ParamGenerator<T1>& g1,
-      const typename ParamGenerator<T1>::iterator& current1,
-      const ParamGenerator<T2>& g2,
-      const typename ParamGenerator<T2>::iterator& current2,
-      const ParamGenerator<T3>& g3,
-      const typename ParamGenerator<T3>::iterator& current3,
-      const ParamGenerator<T4>& g4,
-      const typename ParamGenerator<T4>::iterator& current4,
-      const ParamGenerator<T5>& g5,
-      const typename ParamGenerator<T5>::iterator& current5,
-      const ParamGenerator<T6>& g6,
-      const typename ParamGenerator<T6>::iterator& current6,
-      const ParamGenerator<T7>& g7,
-      const typename ParamGenerator<T7>::iterator& current7,
-      const ParamGenerator<T8>& g8,
-      const typename ParamGenerator<T8>::iterator& current8)
-        : base_(base),
-          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
-          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
-          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
-          begin4_(g4.begin()), end4_(g4.end()), current4_(current4),
-          begin5_(g5.begin()), end5_(g5.end()), current5_(current5),
-          begin6_(g6.begin()), end6_(g6.end()), current6_(current6),
-          begin7_(g7.begin()), end7_(g7.end()), current7_(current7),
-          begin8_(g8.begin()), end8_(g8.end()), current8_(current8)    {
-      ComputeCurrentValue();
-    }
-    virtual ~Iterator() {}
-
-    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
-      return base_;
-    }
-    // Advance should not be called on beyond-of-range iterators
-    // so no component iterators must be beyond end of range, either.
-    virtual void Advance() {
-      assert(!AtEnd());
-      ++current8_;
-      if (current8_ == end8_) {
-        current8_ = begin8_;
-        ++current7_;
-      }
-      if (current7_ == end7_) {
-        current7_ = begin7_;
-        ++current6_;
-      }
-      if (current6_ == end6_) {
-        current6_ = begin6_;
-        ++current5_;
-      }
-      if (current5_ == end5_) {
-        current5_ = begin5_;
-        ++current4_;
-      }
-      if (current4_ == end4_) {
-        current4_ = begin4_;
-        ++current3_;
-      }
-      if (current3_ == end3_) {
-        current3_ = begin3_;
-        ++current2_;
-      }
-      if (current2_ == end2_) {
-        current2_ = begin2_;
-        ++current1_;
-      }
-      ComputeCurrentValue();
-    }
-    virtual ParamIteratorInterface<ParamType>* Clone() const {
-      return new Iterator(*this);
-    }
-    virtual const ParamType* Current() const { return &current_value_; }
-    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
-      // Having the same base generator guarantees that the other
-      // iterator is of the same type and we can downcast.
-      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
-          << "The program attempted to compare iterators "
-          << "from different generators." << std::endl;
-      const Iterator* typed_other =
-          CheckedDowncastToActualType<const Iterator>(&other);
-      // We must report iterators equal if they both point beyond their
-      // respective ranges. That can happen in a variety of fashions,
-      // so we have to consult AtEnd().
-      return (AtEnd() && typed_other->AtEnd()) ||
-         (
-          current1_ == typed_other->current1_ &&
-          current2_ == typed_other->current2_ &&
-          current3_ == typed_other->current3_ &&
-          current4_ == typed_other->current4_ &&
-          current5_ == typed_other->current5_ &&
-          current6_ == typed_other->current6_ &&
-          current7_ == typed_other->current7_ &&
-          current8_ == typed_other->current8_);
-    }
-
-   private:
-    Iterator(const Iterator& other)
-        : base_(other.base_),
-        begin1_(other.begin1_),
-        end1_(other.end1_),
-        current1_(other.current1_),
-        begin2_(other.begin2_),
-        end2_(other.end2_),
-        current2_(other.current2_),
-        begin3_(other.begin3_),
-        end3_(other.end3_),
-        current3_(other.current3_),
-        begin4_(other.begin4_),
-        end4_(other.end4_),
-        current4_(other.current4_),
-        begin5_(other.begin5_),
-        end5_(other.end5_),
-        current5_(other.current5_),
-        begin6_(other.begin6_),
-        end6_(other.end6_),
-        current6_(other.current6_),
-        begin7_(other.begin7_),
-        end7_(other.end7_),
-        current7_(other.current7_),
-        begin8_(other.begin8_),
-        end8_(other.end8_),
-        current8_(other.current8_) {
-      ComputeCurrentValue();
-    }
-
-    void ComputeCurrentValue() {
-      if (!AtEnd())
-        current_value_ = ParamType(*current1_, *current2_, *current3_,
-            *current4_, *current5_, *current6_, *current7_, *current8_);
-    }
-    bool AtEnd() const {
-      // We must report iterator past the end of the range when either of the
-      // component iterators has reached the end of its range.
-      return
-          current1_ == end1_ ||
-          current2_ == end2_ ||
-          current3_ == end3_ ||
-          current4_ == end4_ ||
-          current5_ == end5_ ||
-          current6_ == end6_ ||
-          current7_ == end7_ ||
-          current8_ == end8_;
-    }
-
-    // No implementation - assignment is unsupported.
-    void operator=(const Iterator& other);
-
-    const ParamGeneratorInterface<ParamType>* const base_;
-    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
-    // current[i]_ is the actual traversing iterator.
-    const typename ParamGenerator<T1>::iterator begin1_;
-    const typename ParamGenerator<T1>::iterator end1_;
-    typename ParamGenerator<T1>::iterator current1_;
-    const typename ParamGenerator<T2>::iterator begin2_;
-    const typename ParamGenerator<T2>::iterator end2_;
-    typename ParamGenerator<T2>::iterator current2_;
-    const typename ParamGenerator<T3>::iterator begin3_;
-    const typename ParamGenerator<T3>::iterator end3_;
-    typename ParamGenerator<T3>::iterator current3_;
-    const typename ParamGenerator<T4>::iterator begin4_;
-    const typename ParamGenerator<T4>::iterator end4_;
-    typename ParamGenerator<T4>::iterator current4_;
-    const typename ParamGenerator<T5>::iterator begin5_;
-    const typename ParamGenerator<T5>::iterator end5_;
-    typename ParamGenerator<T5>::iterator current5_;
-    const typename ParamGenerator<T6>::iterator begin6_;
-    const typename ParamGenerator<T6>::iterator end6_;
-    typename ParamGenerator<T6>::iterator current6_;
-    const typename ParamGenerator<T7>::iterator begin7_;
-    const typename ParamGenerator<T7>::iterator end7_;
-    typename ParamGenerator<T7>::iterator current7_;
-    const typename ParamGenerator<T8>::iterator begin8_;
-    const typename ParamGenerator<T8>::iterator end8_;
-    typename ParamGenerator<T8>::iterator current8_;
-    ParamType current_value_;
-  };  // class CartesianProductGenerator8::Iterator
-
-  // No implementation - assignment is unsupported.
-  void operator=(const CartesianProductGenerator8& other);
-
-  const ParamGenerator<T1> g1_;
-  const ParamGenerator<T2> g2_;
-  const ParamGenerator<T3> g3_;
-  const ParamGenerator<T4> g4_;
-  const ParamGenerator<T5> g5_;
-  const ParamGenerator<T6> g6_;
-  const ParamGenerator<T7> g7_;
-  const ParamGenerator<T8> g8_;
-};  // class CartesianProductGenerator8
-
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9>
-class CartesianProductGenerator9
-    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6,
-        T7, T8, T9> > {
- public:
-  typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> ParamType;
-
-  CartesianProductGenerator9(const ParamGenerator<T1>& g1,
-      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
-      const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,
-      const ParamGenerator<T6>& g6, const ParamGenerator<T7>& g7,
-      const ParamGenerator<T8>& g8, const ParamGenerator<T9>& g9)
-      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8),
-          g9_(g9) {}
-  virtual ~CartesianProductGenerator9() {}
-
-  virtual ParamIteratorInterface<ParamType>* Begin() const {
-    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
-        g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_,
-        g7_.begin(), g8_, g8_.begin(), g9_, g9_.begin());
-  }
-  virtual ParamIteratorInterface<ParamType>* End() const {
-    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
-        g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end(), g8_,
-        g8_.end(), g9_, g9_.end());
-  }
-
- private:
-  class Iterator : public ParamIteratorInterface<ParamType> {
-   public:
-    Iterator(const ParamGeneratorInterface<ParamType>* base,
-      const ParamGenerator<T1>& g1,
-      const typename ParamGenerator<T1>::iterator& current1,
-      const ParamGenerator<T2>& g2,
-      const typename ParamGenerator<T2>::iterator& current2,
-      const ParamGenerator<T3>& g3,
-      const typename ParamGenerator<T3>::iterator& current3,
-      const ParamGenerator<T4>& g4,
-      const typename ParamGenerator<T4>::iterator& current4,
-      const ParamGenerator<T5>& g5,
-      const typename ParamGenerator<T5>::iterator& current5,
-      const ParamGenerator<T6>& g6,
-      const typename ParamGenerator<T6>::iterator& current6,
-      const ParamGenerator<T7>& g7,
-      const typename ParamGenerator<T7>::iterator& current7,
-      const ParamGenerator<T8>& g8,
-      const typename ParamGenerator<T8>::iterator& current8,
-      const ParamGenerator<T9>& g9,
-      const typename ParamGenerator<T9>::iterator& current9)
-        : base_(base),
-          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
-          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
-          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
-          begin4_(g4.begin()), end4_(g4.end()), current4_(current4),
-          begin5_(g5.begin()), end5_(g5.end()), current5_(current5),
-          begin6_(g6.begin()), end6_(g6.end()), current6_(current6),
-          begin7_(g7.begin()), end7_(g7.end()), current7_(current7),
-          begin8_(g8.begin()), end8_(g8.end()), current8_(current8),
-          begin9_(g9.begin()), end9_(g9.end()), current9_(current9)    {
-      ComputeCurrentValue();
-    }
-    virtual ~Iterator() {}
-
-    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
-      return base_;
-    }
-    // Advance should not be called on beyond-of-range iterators
-    // so no component iterators must be beyond end of range, either.
-    virtual void Advance() {
-      assert(!AtEnd());
-      ++current9_;
-      if (current9_ == end9_) {
-        current9_ = begin9_;
-        ++current8_;
-      }
-      if (current8_ == end8_) {
-        current8_ = begin8_;
-        ++current7_;
-      }
-      if (current7_ == end7_) {
-        current7_ = begin7_;
-        ++current6_;
-      }
-      if (current6_ == end6_) {
-        current6_ = begin6_;
-        ++current5_;
-      }
-      if (current5_ == end5_) {
-        current5_ = begin5_;
-        ++current4_;
-      }
-      if (current4_ == end4_) {
-        current4_ = begin4_;
-        ++current3_;
-      }
-      if (current3_ == end3_) {
-        current3_ = begin3_;
-        ++current2_;
-      }
-      if (current2_ == end2_) {
-        current2_ = begin2_;
-        ++current1_;
-      }
-      ComputeCurrentValue();
-    }
-    virtual ParamIteratorInterface<ParamType>* Clone() const {
-      return new Iterator(*this);
-    }
-    virtual const ParamType* Current() const { return &current_value_; }
-    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
-      // Having the same base generator guarantees that the other
-      // iterator is of the same type and we can downcast.
-      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
-          << "The program attempted to compare iterators "
-          << "from different generators." << std::endl;
-      const Iterator* typed_other =
-          CheckedDowncastToActualType<const Iterator>(&other);
-      // We must report iterators equal if they both point beyond their
-      // respective ranges. That can happen in a variety of fashions,
-      // so we have to consult AtEnd().
-      return (AtEnd() && typed_other->AtEnd()) ||
-         (
-          current1_ == typed_other->current1_ &&
-          current2_ == typed_other->current2_ &&
-          current3_ == typed_other->current3_ &&
-          current4_ == typed_other->current4_ &&
-          current5_ == typed_other->current5_ &&
-          current6_ == typed_other->current6_ &&
-          current7_ == typed_other->current7_ &&
-          current8_ == typed_other->current8_ &&
-          current9_ == typed_other->current9_);
-    }
-
-   private:
-    Iterator(const Iterator& other)
-        : base_(other.base_),
-        begin1_(other.begin1_),
-        end1_(other.end1_),
-        current1_(other.current1_),
-        begin2_(other.begin2_),
-        end2_(other.end2_),
-        current2_(other.current2_),
-        begin3_(other.begin3_),
-        end3_(other.end3_),
-        current3_(other.current3_),
-        begin4_(other.begin4_),
-        end4_(other.end4_),
-        current4_(other.current4_),
-        begin5_(other.begin5_),
-        end5_(other.end5_),
-        current5_(other.current5_),
-        begin6_(other.begin6_),
-        end6_(other.end6_),
-        current6_(other.current6_),
-        begin7_(other.begin7_),
-        end7_(other.end7_),
-        current7_(other.current7_),
-        begin8_(other.begin8_),
-        end8_(other.end8_),
-        current8_(other.current8_),
-        begin9_(other.begin9_),
-        end9_(other.end9_),
-        current9_(other.current9_) {
-      ComputeCurrentValue();
-    }
-
-    void ComputeCurrentValue() {
-      if (!AtEnd())
-        current_value_ = ParamType(*current1_, *current2_, *current3_,
-            *current4_, *current5_, *current6_, *current7_, *current8_,
-            *current9_);
-    }
-    bool AtEnd() const {
-      // We must report iterator past the end of the range when either of the
-      // component iterators has reached the end of its range.
-      return
-          current1_ == end1_ ||
-          current2_ == end2_ ||
-          current3_ == end3_ ||
-          current4_ == end4_ ||
-          current5_ == end5_ ||
-          current6_ == end6_ ||
-          current7_ == end7_ ||
-          current8_ == end8_ ||
-          current9_ == end9_;
-    }
-
-    // No implementation - assignment is unsupported.
-    void operator=(const Iterator& other);
-
-    const ParamGeneratorInterface<ParamType>* const base_;
-    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
-    // current[i]_ is the actual traversing iterator.
-    const typename ParamGenerator<T1>::iterator begin1_;
-    const typename ParamGenerator<T1>::iterator end1_;
-    typename ParamGenerator<T1>::iterator current1_;
-    const typename ParamGenerator<T2>::iterator begin2_;
-    const typename ParamGenerator<T2>::iterator end2_;
-    typename ParamGenerator<T2>::iterator current2_;
-    const typename ParamGenerator<T3>::iterator begin3_;
-    const typename ParamGenerator<T3>::iterator end3_;
-    typename ParamGenerator<T3>::iterator current3_;
-    const typename ParamGenerator<T4>::iterator begin4_;
-    const typename ParamGenerator<T4>::iterator end4_;
-    typename ParamGenerator<T4>::iterator current4_;
-    const typename ParamGenerator<T5>::iterator begin5_;
-    const typename ParamGenerator<T5>::iterator end5_;
-    typename ParamGenerator<T5>::iterator current5_;
-    const typename ParamGenerator<T6>::iterator begin6_;
-    const typename ParamGenerator<T6>::iterator end6_;
-    typename ParamGenerator<T6>::iterator current6_;
-    const typename ParamGenerator<T7>::iterator begin7_;
-    const typename ParamGenerator<T7>::iterator end7_;
-    typename ParamGenerator<T7>::iterator current7_;
-    const typename ParamGenerator<T8>::iterator begin8_;
-    const typename ParamGenerator<T8>::iterator end8_;
-    typename ParamGenerator<T8>::iterator current8_;
-    const typename ParamGenerator<T9>::iterator begin9_;
-    const typename ParamGenerator<T9>::iterator end9_;
-    typename ParamGenerator<T9>::iterator current9_;
-    ParamType current_value_;
-  };  // class CartesianProductGenerator9::Iterator
-
-  // No implementation - assignment is unsupported.
-  void operator=(const CartesianProductGenerator9& other);
-
-  const ParamGenerator<T1> g1_;
-  const ParamGenerator<T2> g2_;
-  const ParamGenerator<T3> g3_;
-  const ParamGenerator<T4> g4_;
-  const ParamGenerator<T5> g5_;
-  const ParamGenerator<T6> g6_;
-  const ParamGenerator<T7> g7_;
-  const ParamGenerator<T8> g8_;
-  const ParamGenerator<T9> g9_;
-};  // class CartesianProductGenerator9
-
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10>
-class CartesianProductGenerator10
-    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6,
-        T7, T8, T9, T10> > {
- public:
-  typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ParamType;
-
-  CartesianProductGenerator10(const ParamGenerator<T1>& g1,
-      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
-      const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,
-      const ParamGenerator<T6>& g6, const ParamGenerator<T7>& g7,
-      const ParamGenerator<T8>& g8, const ParamGenerator<T9>& g9,
-      const ParamGenerator<T10>& g10)
-      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8),
-          g9_(g9), g10_(g10) {}
-  virtual ~CartesianProductGenerator10() {}
-
-  virtual ParamIteratorInterface<ParamType>* Begin() const {
-    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
-        g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_,
-        g7_.begin(), g8_, g8_.begin(), g9_, g9_.begin(), g10_, g10_.begin());
-  }
-  virtual ParamIteratorInterface<ParamType>* End() const {
-    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
-        g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end(), g8_,
-        g8_.end(), g9_, g9_.end(), g10_, g10_.end());
-  }
-
- private:
-  class Iterator : public ParamIteratorInterface<ParamType> {
-   public:
-    Iterator(const ParamGeneratorInterface<ParamType>* base,
-      const ParamGenerator<T1>& g1,
-      const typename ParamGenerator<T1>::iterator& current1,
-      const ParamGenerator<T2>& g2,
-      const typename ParamGenerator<T2>::iterator& current2,
-      const ParamGenerator<T3>& g3,
-      const typename ParamGenerator<T3>::iterator& current3,
-      const ParamGenerator<T4>& g4,
-      const typename ParamGenerator<T4>::iterator& current4,
-      const ParamGenerator<T5>& g5,
-      const typename ParamGenerator<T5>::iterator& current5,
-      const ParamGenerator<T6>& g6,
-      const typename ParamGenerator<T6>::iterator& current6,
-      const ParamGenerator<T7>& g7,
-      const typename ParamGenerator<T7>::iterator& current7,
-      const ParamGenerator<T8>& g8,
-      const typename ParamGenerator<T8>::iterator& current8,
-      const ParamGenerator<T9>& g9,
-      const typename ParamGenerator<T9>::iterator& current9,
-      const ParamGenerator<T10>& g10,
-      const typename ParamGenerator<T10>::iterator& current10)
-        : base_(base),
-          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
-          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
-          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
-          begin4_(g4.begin()), end4_(g4.end()), current4_(current4),
-          begin5_(g5.begin()), end5_(g5.end()), current5_(current5),
-          begin6_(g6.begin()), end6_(g6.end()), current6_(current6),
-          begin7_(g7.begin()), end7_(g7.end()), current7_(current7),
-          begin8_(g8.begin()), end8_(g8.end()), current8_(current8),
-          begin9_(g9.begin()), end9_(g9.end()), current9_(current9),
-          begin10_(g10.begin()), end10_(g10.end()), current10_(current10)    {
-      ComputeCurrentValue();
-    }
-    virtual ~Iterator() {}
-
-    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {
-      return base_;
-    }
-    // Advance should not be called on beyond-of-range iterators
-    // so no component iterators must be beyond end of range, either.
-    virtual void Advance() {
-      assert(!AtEnd());
-      ++current10_;
-      if (current10_ == end10_) {
-        current10_ = begin10_;
-        ++current9_;
-      }
-      if (current9_ == end9_) {
-        current9_ = begin9_;
-        ++current8_;
-      }
-      if (current8_ == end8_) {
-        current8_ = begin8_;
-        ++current7_;
-      }
-      if (current7_ == end7_) {
-        current7_ = begin7_;
-        ++current6_;
-      }
-      if (current6_ == end6_) {
-        current6_ = begin6_;
-        ++current5_;
-      }
-      if (current5_ == end5_) {
-        current5_ = begin5_;
-        ++current4_;
-      }
-      if (current4_ == end4_) {
-        current4_ = begin4_;
-        ++current3_;
-      }
-      if (current3_ == end3_) {
-        current3_ = begin3_;
-        ++current2_;
-      }
-      if (current2_ == end2_) {
-        current2_ = begin2_;
-        ++current1_;
-      }
-      ComputeCurrentValue();
-    }
-    virtual ParamIteratorInterface<ParamType>* Clone() const {
-      return new Iterator(*this);
-    }
-    virtual const ParamType* Current() const { return &current_value_; }
-    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {
-      // Having the same base generator guarantees that the other
-      // iterator is of the same type and we can downcast.
-      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
-          << "The program attempted to compare iterators "
-          << "from different generators." << std::endl;
-      const Iterator* typed_other =
-          CheckedDowncastToActualType<const Iterator>(&other);
-      // We must report iterators equal if they both point beyond their
-      // respective ranges. That can happen in a variety of fashions,
-      // so we have to consult AtEnd().
-      return (AtEnd() && typed_other->AtEnd()) ||
-         (
-          current1_ == typed_other->current1_ &&
-          current2_ == typed_other->current2_ &&
-          current3_ == typed_other->current3_ &&
-          current4_ == typed_other->current4_ &&
-          current5_ == typed_other->current5_ &&
-          current6_ == typed_other->current6_ &&
-          current7_ == typed_other->current7_ &&
-          current8_ == typed_other->current8_ &&
-          current9_ == typed_other->current9_ &&
-          current10_ == typed_other->current10_);
-    }
-
-   private:
-    Iterator(const Iterator& other)
-        : base_(other.base_),
-        begin1_(other.begin1_),
-        end1_(other.end1_),
-        current1_(other.current1_),
-        begin2_(other.begin2_),
-        end2_(other.end2_),
-        current2_(other.current2_),
-        begin3_(other.begin3_),
-        end3_(other.end3_),
-        current3_(other.current3_),
-        begin4_(other.begin4_),
-        end4_(other.end4_),
-        current4_(other.current4_),
-        begin5_(other.begin5_),
-        end5_(other.end5_),
-        current5_(other.current5_),
-        begin6_(other.begin6_),
-        end6_(other.end6_),
-        current6_(other.current6_),
-        begin7_(other.begin7_),
-        end7_(other.end7_),
-        current7_(other.current7_),
-        begin8_(other.begin8_),
-        end8_(other.end8_),
-        current8_(other.current8_),
-        begin9_(other.begin9_),
-        end9_(other.end9_),
-        current9_(other.current9_),
-        begin10_(other.begin10_),
-        end10_(other.end10_),
-        current10_(other.current10_) {
-      ComputeCurrentValue();
-    }
-
-    void ComputeCurrentValue() {
-      if (!AtEnd())
-        current_value_ = ParamType(*current1_, *current2_, *current3_,
-            *current4_, *current5_, *current6_, *current7_, *current8_,
-            *current9_, *current10_);
-    }
-    bool AtEnd() const {
-      // We must report iterator past the end of the range when either of the
-      // component iterators has reached the end of its range.
-      return
-          current1_ == end1_ ||
-          current2_ == end2_ ||
-          current3_ == end3_ ||
-          current4_ == end4_ ||
-          current5_ == end5_ ||
-          current6_ == end6_ ||
-          current7_ == end7_ ||
-          current8_ == end8_ ||
-          current9_ == end9_ ||
-          current10_ == end10_;
-    }
-
-    // No implementation - assignment is unsupported.
-    void operator=(const Iterator& other);
-
-    const ParamGeneratorInterface<ParamType>* const base_;
-    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
-    // current[i]_ is the actual traversing iterator.
-    const typename ParamGenerator<T1>::iterator begin1_;
-    const typename ParamGenerator<T1>::iterator end1_;
-    typename ParamGenerator<T1>::iterator current1_;
-    const typename ParamGenerator<T2>::iterator begin2_;
-    const typename ParamGenerator<T2>::iterator end2_;
-    typename ParamGenerator<T2>::iterator current2_;
-    const typename ParamGenerator<T3>::iterator begin3_;
-    const typename ParamGenerator<T3>::iterator end3_;
-    typename ParamGenerator<T3>::iterator current3_;
-    const typename ParamGenerator<T4>::iterator begin4_;
-    const typename ParamGenerator<T4>::iterator end4_;
-    typename ParamGenerator<T4>::iterator current4_;
-    const typename ParamGenerator<T5>::iterator begin5_;
-    const typename ParamGenerator<T5>::iterator end5_;
-    typename ParamGenerator<T5>::iterator current5_;
-    const typename ParamGenerator<T6>::iterator begin6_;
-    const typename ParamGenerator<T6>::iterator end6_;
-    typename ParamGenerator<T6>::iterator current6_;
-    const typename ParamGenerator<T7>::iterator begin7_;
-    const typename ParamGenerator<T7>::iterator end7_;
-    typename ParamGenerator<T7>::iterator current7_;
-    const typename ParamGenerator<T8>::iterator begin8_;
-    const typename ParamGenerator<T8>::iterator end8_;
-    typename ParamGenerator<T8>::iterator current8_;
-    const typename ParamGenerator<T9>::iterator begin9_;
-    const typename ParamGenerator<T9>::iterator end9_;
-    typename ParamGenerator<T9>::iterator current9_;
-    const typename ParamGenerator<T10>::iterator begin10_;
-    const typename ParamGenerator<T10>::iterator end10_;
-    typename ParamGenerator<T10>::iterator current10_;
-    ParamType current_value_;
-  };  // class CartesianProductGenerator10::Iterator
-
-  // No implementation - assignment is unsupported.
-  void operator=(const CartesianProductGenerator10& other);
-
-  const ParamGenerator<T1> g1_;
-  const ParamGenerator<T2> g2_;
-  const ParamGenerator<T3> g3_;
-  const ParamGenerator<T4> g4_;
-  const ParamGenerator<T5> g5_;
-  const ParamGenerator<T6> g6_;
-  const ParamGenerator<T7> g7_;
-  const ParamGenerator<T8> g8_;
-  const ParamGenerator<T9> g9_;
-  const ParamGenerator<T10> g10_;
-};  // class CartesianProductGenerator10
-
-
-// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
-//
-// Helper classes providing Combine() with polymorphic features. They allow
-// casting CartesianProductGeneratorN<T> to ParamGenerator<U> if T is
-// convertible to U.
-//
-template <class Generator1, class Generator2>
-class CartesianProductHolder2 {
- public:
-CartesianProductHolder2(const Generator1& g1, const Generator2& g2)
-      : g1_(g1), g2_(g2) {}
-  template <typename T1, typename T2>
-  operator ParamGenerator< ::std::tr1::tuple<T1, T2> >() const {
-    return ParamGenerator< ::std::tr1::tuple<T1, T2> >(
-        new CartesianProductGenerator2<T1, T2>(
-        static_cast<ParamGenerator<T1> >(g1_),
-        static_cast<ParamGenerator<T2> >(g2_)));
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const CartesianProductHolder2& other);
-
-  const Generator1 g1_;
-  const Generator2 g2_;
-};  // class CartesianProductHolder2
-
-template <class Generator1, class Generator2, class Generator3>
-class CartesianProductHolder3 {
- public:
-CartesianProductHolder3(const Generator1& g1, const Generator2& g2,
-    const Generator3& g3)
-      : g1_(g1), g2_(g2), g3_(g3) {}
-  template <typename T1, typename T2, typename T3>
-  operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3> >() const {
-    return ParamGenerator< ::std::tr1::tuple<T1, T2, T3> >(
-        new CartesianProductGenerator3<T1, T2, T3>(
-        static_cast<ParamGenerator<T1> >(g1_),
-        static_cast<ParamGenerator<T2> >(g2_),
-        static_cast<ParamGenerator<T3> >(g3_)));
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const CartesianProductHolder3& other);
-
-  const Generator1 g1_;
-  const Generator2 g2_;
-  const Generator3 g3_;
-};  // class CartesianProductHolder3
-
-template <class Generator1, class Generator2, class Generator3,
-    class Generator4>
-class CartesianProductHolder4 {
- public:
-CartesianProductHolder4(const Generator1& g1, const Generator2& g2,
-    const Generator3& g3, const Generator4& g4)
-      : g1_(g1), g2_(g2), g3_(g3), g4_(g4) {}
-  template <typename T1, typename T2, typename T3, typename T4>
-  operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4> >() const {
-    return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4> >(
-        new CartesianProductGenerator4<T1, T2, T3, T4>(
-        static_cast<ParamGenerator<T1> >(g1_),
-        static_cast<ParamGenerator<T2> >(g2_),
-        static_cast<ParamGenerator<T3> >(g3_),
-        static_cast<ParamGenerator<T4> >(g4_)));
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const CartesianProductHolder4& other);
-
-  const Generator1 g1_;
-  const Generator2 g2_;
-  const Generator3 g3_;
-  const Generator4 g4_;
-};  // class CartesianProductHolder4
-
-template <class Generator1, class Generator2, class Generator3,
-    class Generator4, class Generator5>
-class CartesianProductHolder5 {
- public:
-CartesianProductHolder5(const Generator1& g1, const Generator2& g2,
-    const Generator3& g3, const Generator4& g4, const Generator5& g5)
-      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5) {}
-  template <typename T1, typename T2, typename T3, typename T4, typename T5>
-  operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5> >() const {
-    return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5> >(
-        new CartesianProductGenerator5<T1, T2, T3, T4, T5>(
-        static_cast<ParamGenerator<T1> >(g1_),
-        static_cast<ParamGenerator<T2> >(g2_),
-        static_cast<ParamGenerator<T3> >(g3_),
-        static_cast<ParamGenerator<T4> >(g4_),
-        static_cast<ParamGenerator<T5> >(g5_)));
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const CartesianProductHolder5& other);
-
-  const Generator1 g1_;
-  const Generator2 g2_;
-  const Generator3 g3_;
-  const Generator4 g4_;
-  const Generator5 g5_;
-};  // class CartesianProductHolder5
-
-template <class Generator1, class Generator2, class Generator3,
-    class Generator4, class Generator5, class Generator6>
-class CartesianProductHolder6 {
- public:
-CartesianProductHolder6(const Generator1& g1, const Generator2& g2,
-    const Generator3& g3, const Generator4& g4, const Generator5& g5,
-    const Generator6& g6)
-      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6) {}
-  template <typename T1, typename T2, typename T3, typename T4, typename T5,
-      typename T6>
-  operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6> >() const {
-    return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6> >(
-        new CartesianProductGenerator6<T1, T2, T3, T4, T5, T6>(
-        static_cast<ParamGenerator<T1> >(g1_),
-        static_cast<ParamGenerator<T2> >(g2_),
-        static_cast<ParamGenerator<T3> >(g3_),
-        static_cast<ParamGenerator<T4> >(g4_),
-        static_cast<ParamGenerator<T5> >(g5_),
-        static_cast<ParamGenerator<T6> >(g6_)));
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const CartesianProductHolder6& other);
-
-  const Generator1 g1_;
-  const Generator2 g2_;
-  const Generator3 g3_;
-  const Generator4 g4_;
-  const Generator5 g5_;
-  const Generator6 g6_;
-};  // class CartesianProductHolder6
-
-template <class Generator1, class Generator2, class Generator3,
-    class Generator4, class Generator5, class Generator6, class Generator7>
-class CartesianProductHolder7 {
- public:
-CartesianProductHolder7(const Generator1& g1, const Generator2& g2,
-    const Generator3& g3, const Generator4& g4, const Generator5& g5,
-    const Generator6& g6, const Generator7& g7)
-      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7) {}
-  template <typename T1, typename T2, typename T3, typename T4, typename T5,
-      typename T6, typename T7>
-  operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6,
-      T7> >() const {
-    return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7> >(
-        new CartesianProductGenerator7<T1, T2, T3, T4, T5, T6, T7>(
-        static_cast<ParamGenerator<T1> >(g1_),
-        static_cast<ParamGenerator<T2> >(g2_),
-        static_cast<ParamGenerator<T3> >(g3_),
-        static_cast<ParamGenerator<T4> >(g4_),
-        static_cast<ParamGenerator<T5> >(g5_),
-        static_cast<ParamGenerator<T6> >(g6_),
-        static_cast<ParamGenerator<T7> >(g7_)));
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const CartesianProductHolder7& other);
-
-  const Generator1 g1_;
-  const Generator2 g2_;
-  const Generator3 g3_;
-  const Generator4 g4_;
-  const Generator5 g5_;
-  const Generator6 g6_;
-  const Generator7 g7_;
-};  // class CartesianProductHolder7
-
-template <class Generator1, class Generator2, class Generator3,
-    class Generator4, class Generator5, class Generator6, class Generator7,
-    class Generator8>
-class CartesianProductHolder8 {
- public:
-CartesianProductHolder8(const Generator1& g1, const Generator2& g2,
-    const Generator3& g3, const Generator4& g4, const Generator5& g5,
-    const Generator6& g6, const Generator7& g7, const Generator8& g8)
-      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7),
-          g8_(g8) {}
-  template <typename T1, typename T2, typename T3, typename T4, typename T5,
-      typename T6, typename T7, typename T8>
-  operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7,
-      T8> >() const {
-    return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8> >(
-        new CartesianProductGenerator8<T1, T2, T3, T4, T5, T6, T7, T8>(
-        static_cast<ParamGenerator<T1> >(g1_),
-        static_cast<ParamGenerator<T2> >(g2_),
-        static_cast<ParamGenerator<T3> >(g3_),
-        static_cast<ParamGenerator<T4> >(g4_),
-        static_cast<ParamGenerator<T5> >(g5_),
-        static_cast<ParamGenerator<T6> >(g6_),
-        static_cast<ParamGenerator<T7> >(g7_),
-        static_cast<ParamGenerator<T8> >(g8_)));
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const CartesianProductHolder8& other);
-
-  const Generator1 g1_;
-  const Generator2 g2_;
-  const Generator3 g3_;
-  const Generator4 g4_;
-  const Generator5 g5_;
-  const Generator6 g6_;
-  const Generator7 g7_;
-  const Generator8 g8_;
-};  // class CartesianProductHolder8
-
-template <class Generator1, class Generator2, class Generator3,
-    class Generator4, class Generator5, class Generator6, class Generator7,
-    class Generator8, class Generator9>
-class CartesianProductHolder9 {
- public:
-CartesianProductHolder9(const Generator1& g1, const Generator2& g2,
-    const Generator3& g3, const Generator4& g4, const Generator5& g5,
-    const Generator6& g6, const Generator7& g7, const Generator8& g8,
-    const Generator9& g9)
-      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8),
-          g9_(g9) {}
-  template <typename T1, typename T2, typename T3, typename T4, typename T5,
-      typename T6, typename T7, typename T8, typename T9>
-  operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8,
-      T9> >() const {
-    return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8,
-        T9> >(
-        new CartesianProductGenerator9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(
-        static_cast<ParamGenerator<T1> >(g1_),
-        static_cast<ParamGenerator<T2> >(g2_),
-        static_cast<ParamGenerator<T3> >(g3_),
-        static_cast<ParamGenerator<T4> >(g4_),
-        static_cast<ParamGenerator<T5> >(g5_),
-        static_cast<ParamGenerator<T6> >(g6_),
-        static_cast<ParamGenerator<T7> >(g7_),
-        static_cast<ParamGenerator<T8> >(g8_),
-        static_cast<ParamGenerator<T9> >(g9_)));
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const CartesianProductHolder9& other);
-
-  const Generator1 g1_;
-  const Generator2 g2_;
-  const Generator3 g3_;
-  const Generator4 g4_;
-  const Generator5 g5_;
-  const Generator6 g6_;
-  const Generator7 g7_;
-  const Generator8 g8_;
-  const Generator9 g9_;
-};  // class CartesianProductHolder9
-
-template <class Generator1, class Generator2, class Generator3,
-    class Generator4, class Generator5, class Generator6, class Generator7,
-    class Generator8, class Generator9, class Generator10>
-class CartesianProductHolder10 {
- public:
-CartesianProductHolder10(const Generator1& g1, const Generator2& g2,
-    const Generator3& g3, const Generator4& g4, const Generator5& g5,
-    const Generator6& g6, const Generator7& g7, const Generator8& g8,
-    const Generator9& g9, const Generator10& g10)
-      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8),
-          g9_(g9), g10_(g10) {}
-  template <typename T1, typename T2, typename T3, typename T4, typename T5,
-      typename T6, typename T7, typename T8, typename T9, typename T10>
-  operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8,
-      T9, T10> >() const {
-    return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8,
-        T9, T10> >(
-        new CartesianProductGenerator10<T1, T2, T3, T4, T5, T6, T7, T8, T9,
-            T10>(
-        static_cast<ParamGenerator<T1> >(g1_),
-        static_cast<ParamGenerator<T2> >(g2_),
-        static_cast<ParamGenerator<T3> >(g3_),
-        static_cast<ParamGenerator<T4> >(g4_),
-        static_cast<ParamGenerator<T5> >(g5_),
-        static_cast<ParamGenerator<T6> >(g6_),
-        static_cast<ParamGenerator<T7> >(g7_),
-        static_cast<ParamGenerator<T8> >(g8_),
-        static_cast<ParamGenerator<T9> >(g9_),
-        static_cast<ParamGenerator<T10> >(g10_)));
-  }
-
- private:
-  // No implementation - assignment is unsupported.
-  void operator=(const CartesianProductHolder10& other);
-
-  const Generator1 g1_;
-  const Generator2 g2_;
-  const Generator3 g3_;
-  const Generator4 g4_;
-  const Generator5 g5_;
-  const Generator6 g6_;
-  const Generator7 g7_;
-  const Generator8 g8_;
-  const Generator9 g9_;
-  const Generator10 g10_;
-};  // class CartesianProductHolder10
-
-# endif  // GTEST_HAS_COMBINE
-
-}  // namespace internal
-}  // namespace testing
-
-#endif  //  GTEST_HAS_PARAM_TEST
-
-#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
-
-#if GTEST_HAS_PARAM_TEST
-
-namespace testing {
-
-// Functions producing parameter generators.
-//
-// Google Test uses these generators to produce parameters for value-
-// parameterized tests. When a parameterized test case is instantiated
-// with a particular generator, Google Test creates and runs tests
-// for each element in the sequence produced by the generator.
-//
-// In the following sample, tests from test case FooTest are instantiated
-// each three times with parameter values 3, 5, and 8:
-//
-// class FooTest : public TestWithParam<int> { ... };
-//
-// TEST_P(FooTest, TestThis) {
-// }
-// TEST_P(FooTest, TestThat) {
-// }
-// INSTANTIATE_TEST_CASE_P(TestSequence, FooTest, Values(3, 5, 8));
-//
-
-// Range() returns generators providing sequences of values in a range.
-//
-// Synopsis:
-// Range(start, end)
-//   - returns a generator producing a sequence of values {start, start+1,
-//     start+2, ..., }.
-// Range(start, end, step)
-//   - returns a generator producing a sequence of values {start, start+step,
-//     start+step+step, ..., }.
-// Notes:
-//   * The generated sequences never include end. For example, Range(1, 5)
-//     returns a generator producing a sequence {1, 2, 3, 4}. Range(1, 9, 2)
-//     returns a generator producing {1, 3, 5, 7}.
-//   * start and end must have the same type. That type may be any integral or
-//     floating-point type or a user defined type satisfying these conditions:
-//     * It must be assignable (have operator=() defined).
-//     * It must have operator+() (operator+(int-compatible type) for
-//       two-operand version).
-//     * It must have operator<() defined.
-//     Elements in the resulting sequences will also have that type.
-//   * Condition start < end must be satisfied in order for resulting sequences
-//     to contain any elements.
-//
-template <typename T, typename IncrementT>
-internal::ParamGenerator<T> Range(T start, T end, IncrementT step) {
-  return internal::ParamGenerator<T>(
-      new internal::RangeGenerator<T, IncrementT>(start, end, step));
-}
-
-template <typename T>
-internal::ParamGenerator<T> Range(T start, T end) {
-  return Range(start, end, 1);
-}
-
-// ValuesIn() function allows generation of tests with parameters coming from
-// a container.
-//
-// Synopsis:
-// ValuesIn(const T (&array)[N])
-//   - returns a generator producing sequences with elements from
-//     a C-style array.
-// ValuesIn(const Container& container)
-//   - returns a generator producing sequences with elements from
-//     an STL-style container.
-// ValuesIn(Iterator begin, Iterator end)
-//   - returns a generator producing sequences with elements from
-//     a range [begin, end) defined by a pair of STL-style iterators. These
-//     iterators can also be plain C pointers.
-//
-// Please note that ValuesIn copies the values from the containers
-// passed in and keeps them to generate tests in RUN_ALL_TESTS().
-//
-// Examples:
-//
-// This instantiates tests from test case StringTest
-// each with C-string values of "foo", "bar", and "baz":
-//
-// const char* strings[] = {"foo", "bar", "baz"};
-// INSTANTIATE_TEST_CASE_P(StringSequence, SrtingTest, ValuesIn(strings));
-//
-// This instantiates tests from test case StlStringTest
-// each with STL strings with values "a" and "b":
-//
-// ::std::vector< ::std::string> GetParameterStrings() {
-//   ::std::vector< ::std::string> v;
-//   v.push_back("a");
-//   v.push_back("b");
-//   return v;
-// }
-//
-// INSTANTIATE_TEST_CASE_P(CharSequence,
-//                         StlStringTest,
-//                         ValuesIn(GetParameterStrings()));
-//
-//
-// This will also instantiate tests from CharTest
-// each with parameter values 'a' and 'b':
-//
-// ::std::list<char> GetParameterChars() {
-//   ::std::list<char> list;
-//   list.push_back('a');
-//   list.push_back('b');
-//   return list;
-// }
-// ::std::list<char> l = GetParameterChars();
-// INSTANTIATE_TEST_CASE_P(CharSequence2,
-//                         CharTest,
-//                         ValuesIn(l.begin(), l.end()));
-//
-template <typename ForwardIterator>
-internal::ParamGenerator<
-  typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>
-ValuesIn(ForwardIterator begin, ForwardIterator end) {
-  typedef typename ::testing::internal::IteratorTraits<ForwardIterator>
-      ::value_type ParamType;
-  return internal::ParamGenerator<ParamType>(
-      new internal::ValuesInIteratorRangeGenerator<ParamType>(begin, end));
-}
-
-template <typename T, size_t N>
-internal::ParamGenerator<T> ValuesIn(const T (&array)[N]) {
-  return ValuesIn(array, array + N);
-}
-
-template <class Container>
-internal::ParamGenerator<typename Container::value_type> ValuesIn(
-    const Container& container) {
-  return ValuesIn(container.begin(), container.end());
-}
-
-// Values() allows generating tests from explicitly specified list of
-// parameters.
-//
-// Synopsis:
-// Values(T v1, T v2, ..., T vN)
-//   - returns a generator producing sequences with elements v1, v2, ..., vN.
-//
-// For example, this instantiates tests from test case BarTest each
-// with values "one", "two", and "three":
-//
-// INSTANTIATE_TEST_CASE_P(NumSequence, BarTest, Values("one", "two", "three"));
-//
-// This instantiates tests from test case BazTest each with values 1, 2, 3.5.
-// The exact type of values will depend on the type of parameter in BazTest.
-//
-// INSTANTIATE_TEST_CASE_P(FloatingNumbers, BazTest, Values(1, 2, 3.5));
-//
-// Currently, Values() supports from 1 to 50 parameters.
-//
-template <typename T1>
-internal::ValueArray1<T1> Values(T1 v1) {
-  return internal::ValueArray1<T1>(v1);
-}
-
-template <typename T1, typename T2>
-internal::ValueArray2<T1, T2> Values(T1 v1, T2 v2) {
-  return internal::ValueArray2<T1, T2>(v1, v2);
-}
-
-template <typename T1, typename T2, typename T3>
-internal::ValueArray3<T1, T2, T3> Values(T1 v1, T2 v2, T3 v3) {
-  return internal::ValueArray3<T1, T2, T3>(v1, v2, v3);
-}
-
-template <typename T1, typename T2, typename T3, typename T4>
-internal::ValueArray4<T1, T2, T3, T4> Values(T1 v1, T2 v2, T3 v3, T4 v4) {
-  return internal::ValueArray4<T1, T2, T3, T4>(v1, v2, v3, v4);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5>
-internal::ValueArray5<T1, T2, T3, T4, T5> Values(T1 v1, T2 v2, T3 v3, T4 v4,
-    T5 v5) {
-  return internal::ValueArray5<T1, T2, T3, T4, T5>(v1, v2, v3, v4, v5);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6>
-internal::ValueArray6<T1, T2, T3, T4, T5, T6> Values(T1 v1, T2 v2, T3 v3,
-    T4 v4, T5 v5, T6 v6) {
-  return internal::ValueArray6<T1, T2, T3, T4, T5, T6>(v1, v2, v3, v4, v5, v6);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7>
-internal::ValueArray7<T1, T2, T3, T4, T5, T6, T7> Values(T1 v1, T2 v2, T3 v3,
-    T4 v4, T5 v5, T6 v6, T7 v7) {
-  return internal::ValueArray7<T1, T2, T3, T4, T5, T6, T7>(v1, v2, v3, v4, v5,
-      v6, v7);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8>
-internal::ValueArray8<T1, T2, T3, T4, T5, T6, T7, T8> Values(T1 v1, T2 v2,
-    T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8) {
-  return internal::ValueArray8<T1, T2, T3, T4, T5, T6, T7, T8>(v1, v2, v3, v4,
-      v5, v6, v7, v8);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9>
-internal::ValueArray9<T1, T2, T3, T4, T5, T6, T7, T8, T9> Values(T1 v1, T2 v2,
-    T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9) {
-  return internal::ValueArray9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(v1, v2, v3,
-      v4, v5, v6, v7, v8, v9);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10>
-internal::ValueArray10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Values(T1 v1,
-    T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10) {
-  return internal::ValueArray10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(v1,
-      v2, v3, v4, v5, v6, v7, v8, v9, v10);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11>
-internal::ValueArray11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10,
-    T11> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-    T10 v10, T11 v11) {
-  return internal::ValueArray11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10,
-      T11>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12>
-internal::ValueArray12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-    T12> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-    T10 v10, T11 v11, T12 v12) {
-  return internal::ValueArray12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13>
-internal::ValueArray13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
-    T13> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-    T10 v10, T11 v11, T12 v12, T13 v13) {
-  return internal::ValueArray13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14>
-internal::ValueArray14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14) {
-  return internal::ValueArray14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,
-      v14);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15>
-internal::ValueArray15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,
-    T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15) {
-  return internal::ValueArray15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12,
-      v13, v14, v15);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16>
-internal::ValueArray16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
-    T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
-    T16 v16) {
-  return internal::ValueArray16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
-      v12, v13, v14, v15, v16);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17>
-internal::ValueArray17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
-    T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
-    T16 v16, T17 v17) {
-  return internal::ValueArray17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10,
-      v11, v12, v13, v14, v15, v16, v17);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18>
-internal::ValueArray18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6,
-    T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
-    T16 v16, T17 v17, T18 v18) {
-  return internal::ValueArray18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18>(v1, v2, v3, v4, v5, v6, v7, v8, v9,
-      v10, v11, v12, v13, v14, v15, v16, v17, v18);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19>
-internal::ValueArray19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5,
-    T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14,
-    T15 v15, T16 v16, T17 v17, T18 v18, T19 v19) {
-  return internal::ValueArray19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19>(v1, v2, v3, v4, v5, v6, v7, v8,
-      v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20>
-internal::ValueArray20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20> Values(T1 v1, T2 v2, T3 v3, T4 v4,
-    T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
-    T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20) {
-  return internal::ValueArray20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20>(v1, v2, v3, v4, v5, v6, v7,
-      v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21>
-internal::ValueArray21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21> Values(T1 v1, T2 v2, T3 v3, T4 v4,
-    T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
-    T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21) {
-  return internal::ValueArray21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>(v1, v2, v3, v4, v5, v6,
-      v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22>
-internal::ValueArray22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22> Values(T1 v1, T2 v2, T3 v3,
-    T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
-    T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
-    T21 v21, T22 v22) {
-  return internal::ValueArray22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22>(v1, v2, v3, v4,
-      v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
-      v20, v21, v22);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23>
-internal::ValueArray23<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> Values(T1 v1, T2 v2,
-    T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
-    T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
-    T21 v21, T22 v22, T23 v23) {
-  return internal::ValueArray23<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23>(v1, v2, v3,
-      v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
-      v20, v21, v22, v23);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24>
-internal::ValueArray24<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> Values(T1 v1, T2 v2,
-    T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
-    T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
-    T21 v21, T22 v22, T23 v23, T24 v24) {
-  return internal::ValueArray24<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24>(v1, v2,
-      v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18,
-      v19, v20, v21, v22, v23, v24);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25>
-internal::ValueArray25<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> Values(T1 v1,
-    T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11,
-    T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19,
-    T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25) {
-  return internal::ValueArray25<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25>(v1,
-      v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17,
-      v18, v19, v20, v21, v22, v23, v24, v25);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26>
-internal::ValueArray26<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-    T26> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-    T26 v26) {
-  return internal::ValueArray26<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15,
-      v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27>
-internal::ValueArray27<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
-    T27> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-    T26 v26, T27 v27) {
-  return internal::ValueArray27<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26, T27>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14,
-      v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28>
-internal::ValueArray28<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
-    T28> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-    T26 v26, T27 v27, T28 v28) {
-  return internal::ValueArray28<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26, T27, T28>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,
-      v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27,
-      v28);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29>
-internal::ValueArray29<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    T29> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-    T26 v26, T27 v27, T28 v28, T29 v29) {
-  return internal::ValueArray29<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26, T27, T28, T29>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12,
-      v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26,
-      v27, v28, v29);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30>
-internal::ValueArray30<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    T29, T30> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,
-    T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16,
-    T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24,
-    T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30) {
-  return internal::ValueArray30<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26, T27, T28, T29, T30>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
-      v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25,
-      v26, v27, v28, v29, v30);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31>
-internal::ValueArray31<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    T29, T30, T31> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
-    T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
-    T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
-    T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31) {
-  return internal::ValueArray31<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26, T27, T28, T29, T30, T31>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10,
-      v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24,
-      v25, v26, v27, v28, v29, v30, v31);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32>
-internal::ValueArray32<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    T29, T30, T31, T32> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
-    T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
-    T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
-    T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
-    T32 v32) {
-  return internal::ValueArray32<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26, T27, T28, T29, T30, T31, T32>(v1, v2, v3, v4, v5, v6, v7, v8, v9,
-      v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,
-      v24, v25, v26, v27, v28, v29, v30, v31, v32);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33>
-internal::ValueArray33<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    T29, T30, T31, T32, T33> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6,
-    T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
-    T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
-    T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
-    T32 v32, T33 v33) {
-  return internal::ValueArray33<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26, T27, T28, T29, T30, T31, T32, T33>(v1, v2, v3, v4, v5, v6, v7, v8,
-      v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,
-      v24, v25, v26, v27, v28, v29, v30, v31, v32, v33);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34>
-internal::ValueArray34<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    T29, T30, T31, T32, T33, T34> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5,
-    T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14,
-    T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22,
-    T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30,
-    T31 v31, T32 v32, T33 v33, T34 v34) {
-  return internal::ValueArray34<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26, T27, T28, T29, T30, T31, T32, T33, T34>(v1, v2, v3, v4, v5, v6, v7,
-      v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22,
-      v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35>
-internal::ValueArray35<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    T29, T30, T31, T32, T33, T34, T35> Values(T1 v1, T2 v2, T3 v3, T4 v4,
-    T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
-    T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21,
-    T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29,
-    T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35) {
-  return internal::ValueArray35<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35>(v1, v2, v3, v4, v5, v6,
-      v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21,
-      v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36>
-internal::ValueArray36<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    T29, T30, T31, T32, T33, T34, T35, T36> Values(T1 v1, T2 v2, T3 v3, T4 v4,
-    T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
-    T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21,
-    T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29,
-    T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36) {
-  return internal::ValueArray36<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36>(v1, v2, v3, v4,
-      v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
-      v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33,
-      v34, v35, v36);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37>
-internal::ValueArray37<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    T29, T30, T31, T32, T33, T34, T35, T36, T37> Values(T1 v1, T2 v2, T3 v3,
-    T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
-    T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
-    T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28,
-    T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36,
-    T37 v37) {
-  return internal::ValueArray37<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37>(v1, v2, v3,
-      v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
-      v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33,
-      v34, v35, v36, v37);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38>
-internal::ValueArray38<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> Values(T1 v1, T2 v2,
-    T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
-    T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
-    T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28,
-    T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36,
-    T37 v37, T38 v38) {
-  return internal::ValueArray38<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38>(v1, v2,
-      v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18,
-      v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32,
-      v33, v34, v35, v36, v37, v38);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39>
-internal::ValueArray39<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> Values(T1 v1, T2 v2,
-    T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
-    T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
-    T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28,
-    T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36,
-    T37 v37, T38 v38, T39 v39) {
-  return internal::ValueArray39<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39>(v1,
-      v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17,
-      v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31,
-      v32, v33, v34, v35, v36, v37, v38, v39);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40>
-internal::ValueArray40<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> Values(T1 v1,
-    T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11,
-    T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19,
-    T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27,
-    T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35,
-    T36 v36, T37 v37, T38 v38, T39 v39, T40 v40) {
-  return internal::ValueArray40<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
-      T40>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15,
-      v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29,
-      v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41>
-internal::ValueArray41<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
-    T41> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-    T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
-    T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41) {
-  return internal::ValueArray41<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
-      T40, T41>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14,
-      v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28,
-      v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42>
-internal::ValueArray42<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
-    T42> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-    T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
-    T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
-    T42 v42) {
-  return internal::ValueArray42<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
-      T40, T41, T42>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,
-      v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27,
-      v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41,
-      v42);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43>
-internal::ValueArray43<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
-    T43> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-    T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
-    T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
-    T42 v42, T43 v43) {
-  return internal::ValueArray43<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
-      T40, T41, T42, T43>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12,
-      v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26,
-      v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40,
-      v41, v42, v43);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44>
-internal::ValueArray44<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
-    T44> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
-    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
-    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
-    T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
-    T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
-    T42 v42, T43 v43, T44 v44) {
-  return internal::ValueArray44<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
-      T40, T41, T42, T43, T44>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
-      v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25,
-      v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39,
-      v40, v41, v42, v43, v44);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44, typename T45>
-internal::ValueArray45<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
-    T44, T45> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,
-    T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16,
-    T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24,
-    T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32,
-    T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40,
-    T41 v41, T42 v42, T43 v43, T44 v44, T45 v45) {
-  return internal::ValueArray45<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
-      T40, T41, T42, T43, T44, T45>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10,
-      v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24,
-      v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38,
-      v39, v40, v41, v42, v43, v44, v45);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44, typename T45,
-    typename T46>
-internal::ValueArray46<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
-    T44, T45, T46> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
-    T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
-    T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
-    T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
-    T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39,
-    T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46) {
-  return internal::ValueArray46<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
-      T40, T41, T42, T43, T44, T45, T46>(v1, v2, v3, v4, v5, v6, v7, v8, v9,
-      v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,
-      v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37,
-      v38, v39, v40, v41, v42, v43, v44, v45, v46);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44, typename T45,
-    typename T46, typename T47>
-internal::ValueArray47<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
-    T44, T45, T46, T47> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
-    T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
-    T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
-    T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
-    T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39,
-    T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47) {
-  return internal::ValueArray47<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
-      T40, T41, T42, T43, T44, T45, T46, T47>(v1, v2, v3, v4, v5, v6, v7, v8,
-      v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,
-      v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37,
-      v38, v39, v40, v41, v42, v43, v44, v45, v46, v47);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44, typename T45,
-    typename T46, typename T47, typename T48>
-internal::ValueArray48<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
-    T44, T45, T46, T47, T48> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6,
-    T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
-    T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
-    T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
-    T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39,
-    T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47,
-    T48 v48) {
-  return internal::ValueArray48<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
-      T40, T41, T42, T43, T44, T45, T46, T47, T48>(v1, v2, v3, v4, v5, v6, v7,
-      v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22,
-      v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36,
-      v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44, typename T45,
-    typename T46, typename T47, typename T48, typename T49>
-internal::ValueArray49<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
-    T44, T45, T46, T47, T48, T49> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5,
-    T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14,
-    T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22,
-    T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30,
-    T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38,
-    T39 v39, T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46,
-    T47 v47, T48 v48, T49 v49) {
-  return internal::ValueArray49<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
-      T40, T41, T42, T43, T44, T45, T46, T47, T48, T49>(v1, v2, v3, v4, v5, v6,
-      v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21,
-      v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35,
-      v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10,
-    typename T11, typename T12, typename T13, typename T14, typename T15,
-    typename T16, typename T17, typename T18, typename T19, typename T20,
-    typename T21, typename T22, typename T23, typename T24, typename T25,
-    typename T26, typename T27, typename T28, typename T29, typename T30,
-    typename T31, typename T32, typename T33, typename T34, typename T35,
-    typename T36, typename T37, typename T38, typename T39, typename T40,
-    typename T41, typename T42, typename T43, typename T44, typename T45,
-    typename T46, typename T47, typename T48, typename T49, typename T50>
-internal::ValueArray50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
-    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
-    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
-    T44, T45, T46, T47, T48, T49, T50> Values(T1 v1, T2 v2, T3 v3, T4 v4,
-    T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
-    T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21,
-    T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29,
-    T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37,
-    T38 v38, T39 v39, T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45,
-    T46 v46, T47 v47, T48 v48, T49 v49, T50 v50) {
-  return internal::ValueArray50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
-      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
-      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
-      T40, T41, T42, T43, T44, T45, T46, T47, T48, T49, T50>(v1, v2, v3, v4,
-      v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
-      v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33,
-      v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47,
-      v48, v49, v50);
-}
-
-// Bool() allows generating tests with parameters in a set of (false, true).
-//
-// Synopsis:
-// Bool()
-//   - returns a generator producing sequences with elements {false, true}.
-//
-// It is useful when testing code that depends on Boolean flags. Combinations
-// of multiple flags can be tested when several Bool()'s are combined using
-// Combine() function.
-//
-// In the following example all tests in the test case FlagDependentTest
-// will be instantiated twice with parameters false and true.
-//
-// class FlagDependentTest : public testing::TestWithParam<bool> {
-//   virtual void SetUp() {
-//     external_flag = GetParam();
-//   }
-// }
-// INSTANTIATE_TEST_CASE_P(BoolSequence, FlagDependentTest, Bool());
-//
-inline internal::ParamGenerator<bool> Bool() {
-  return Values(false, true);
-}
-
-# if GTEST_HAS_COMBINE
-// Combine() allows the user to combine two or more sequences to produce
-// values of a Cartesian product of those sequences' elements.
-//
-// Synopsis:
-// Combine(gen1, gen2, ..., genN)
-//   - returns a generator producing sequences with elements coming from
-//     the Cartesian product of elements from the sequences generated by
-//     gen1, gen2, ..., genN. The sequence elements will have a type of
-//     tuple<T1, T2, ..., TN> where T1, T2, ..., TN are the types
-//     of elements from sequences produces by gen1, gen2, ..., genN.
-//
-// Combine can have up to 10 arguments. This number is currently limited
-// by the maximum number of elements in the tuple implementation used by Google
-// Test.
-//
-// Example:
-//
-// This will instantiate tests in test case AnimalTest each one with
-// the parameter values tuple("cat", BLACK), tuple("cat", WHITE),
-// tuple("dog", BLACK), and tuple("dog", WHITE):
-//
-// enum Color { BLACK, GRAY, WHITE };
-// class AnimalTest
-//     : public testing::TestWithParam<tuple<const char*, Color> > {...};
-//
-// TEST_P(AnimalTest, AnimalLooksNice) {...}
-//
-// INSTANTIATE_TEST_CASE_P(AnimalVariations, AnimalTest,
-//                         Combine(Values("cat", "dog"),
-//                                 Values(BLACK, WHITE)));
-//
-// This will instantiate tests in FlagDependentTest with all variations of two
-// Boolean flags:
-//
-// class FlagDependentTest
-//     : public testing::TestWithParam<tuple(bool, bool)> > {
-//   virtual void SetUp() {
-//     // Assigns external_flag_1 and external_flag_2 values from the tuple.
-//     tie(external_flag_1, external_flag_2) = GetParam();
-//   }
-// };
-//
-// TEST_P(FlagDependentTest, TestFeature1) {
-//   // Test your code using external_flag_1 and external_flag_2 here.
-// }
-// INSTANTIATE_TEST_CASE_P(TwoBoolSequence, FlagDependentTest,
-//                         Combine(Bool(), Bool()));
-//
-template <typename Generator1, typename Generator2>
-internal::CartesianProductHolder2<Generator1, Generator2> Combine(
-    const Generator1& g1, const Generator2& g2) {
-  return internal::CartesianProductHolder2<Generator1, Generator2>(
-      g1, g2);
-}
-
-template <typename Generator1, typename Generator2, typename Generator3>
-internal::CartesianProductHolder3<Generator1, Generator2, Generator3> Combine(
-    const Generator1& g1, const Generator2& g2, const Generator3& g3) {
-  return internal::CartesianProductHolder3<Generator1, Generator2, Generator3>(
-      g1, g2, g3);
-}
-
-template <typename Generator1, typename Generator2, typename Generator3,
-    typename Generator4>
-internal::CartesianProductHolder4<Generator1, Generator2, Generator3,
-    Generator4> Combine(
-    const Generator1& g1, const Generator2& g2, const Generator3& g3,
-        const Generator4& g4) {
-  return internal::CartesianProductHolder4<Generator1, Generator2, Generator3,
-      Generator4>(
-      g1, g2, g3, g4);
-}
-
-template <typename Generator1, typename Generator2, typename Generator3,
-    typename Generator4, typename Generator5>
-internal::CartesianProductHolder5<Generator1, Generator2, Generator3,
-    Generator4, Generator5> Combine(
-    const Generator1& g1, const Generator2& g2, const Generator3& g3,
-        const Generator4& g4, const Generator5& g5) {
-  return internal::CartesianProductHolder5<Generator1, Generator2, Generator3,
-      Generator4, Generator5>(
-      g1, g2, g3, g4, g5);
-}
-
-template <typename Generator1, typename Generator2, typename Generator3,
-    typename Generator4, typename Generator5, typename Generator6>
-internal::CartesianProductHolder6<Generator1, Generator2, Generator3,
-    Generator4, Generator5, Generator6> Combine(
-    const Generator1& g1, const Generator2& g2, const Generator3& g3,
-        const Generator4& g4, const Generator5& g5, const Generator6& g6) {
-  return internal::CartesianProductHolder6<Generator1, Generator2, Generator3,
-      Generator4, Generator5, Generator6>(
-      g1, g2, g3, g4, g5, g6);
-}
-
-template <typename Generator1, typename Generator2, typename Generator3,
-    typename Generator4, typename Generator5, typename Generator6,
-    typename Generator7>
-internal::CartesianProductHolder7<Generator1, Generator2, Generator3,
-    Generator4, Generator5, Generator6, Generator7> Combine(
-    const Generator1& g1, const Generator2& g2, const Generator3& g3,
-        const Generator4& g4, const Generator5& g5, const Generator6& g6,
-        const Generator7& g7) {
-  return internal::CartesianProductHolder7<Generator1, Generator2, Generator3,
-      Generator4, Generator5, Generator6, Generator7>(
-      g1, g2, g3, g4, g5, g6, g7);
-}
-
-template <typename Generator1, typename Generator2, typename Generator3,
-    typename Generator4, typename Generator5, typename Generator6,
-    typename Generator7, typename Generator8>
-internal::CartesianProductHolder8<Generator1, Generator2, Generator3,
-    Generator4, Generator5, Generator6, Generator7, Generator8> Combine(
-    const Generator1& g1, const Generator2& g2, const Generator3& g3,
-        const Generator4& g4, const Generator5& g5, const Generator6& g6,
-        const Generator7& g7, const Generator8& g8) {
-  return internal::CartesianProductHolder8<Generator1, Generator2, Generator3,
-      Generator4, Generator5, Generator6, Generator7, Generator8>(
-      g1, g2, g3, g4, g5, g6, g7, g8);
-}
-
-template <typename Generator1, typename Generator2, typename Generator3,
-    typename Generator4, typename Generator5, typename Generator6,
-    typename Generator7, typename Generator8, typename Generator9>
-internal::CartesianProductHolder9<Generator1, Generator2, Generator3,
-    Generator4, Generator5, Generator6, Generator7, Generator8,
-    Generator9> Combine(
-    const Generator1& g1, const Generator2& g2, const Generator3& g3,
-        const Generator4& g4, const Generator5& g5, const Generator6& g6,
-        const Generator7& g7, const Generator8& g8, const Generator9& g9) {
-  return internal::CartesianProductHolder9<Generator1, Generator2, Generator3,
-      Generator4, Generator5, Generator6, Generator7, Generator8, Generator9>(
-      g1, g2, g3, g4, g5, g6, g7, g8, g9);
-}
-
-template <typename Generator1, typename Generator2, typename Generator3,
-    typename Generator4, typename Generator5, typename Generator6,
-    typename Generator7, typename Generator8, typename Generator9,
-    typename Generator10>
-internal::CartesianProductHolder10<Generator1, Generator2, Generator3,
-    Generator4, Generator5, Generator6, Generator7, Generator8, Generator9,
-    Generator10> Combine(
-    const Generator1& g1, const Generator2& g2, const Generator3& g3,
-        const Generator4& g4, const Generator5& g5, const Generator6& g6,
-        const Generator7& g7, const Generator8& g8, const Generator9& g9,
-        const Generator10& g10) {
-  return internal::CartesianProductHolder10<Generator1, Generator2, Generator3,
-      Generator4, Generator5, Generator6, Generator7, Generator8, Generator9,
-      Generator10>(
-      g1, g2, g3, g4, g5, g6, g7, g8, g9, g10);
-}
-# endif  // GTEST_HAS_COMBINE
-
-
-
-# define TEST_P(test_case_name, test_name) \
-  class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
-      : public test_case_name { \
-   public: \
-    GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \
-    virtual void TestBody(); \
-   private: \
-    static int AddToRegistry() { \
-      ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
-          GetTestCasePatternHolder<test_case_name>(\
-              #test_case_name, __FILE__, __LINE__)->AddTestPattern(\
-                  #test_case_name, \
-                  #test_name, \
-                  new ::testing::internal::TestMetaFactory< \
-                      GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>()); \
-      return 0; \
-    } \
-    static int gtest_registering_dummy_; \
-    GTEST_DISALLOW_COPY_AND_ASSIGN_(\
-        GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \
-  }; \
-  int GTEST_TEST_CLASS_NAME_(test_case_name, \
-                             test_name)::gtest_registering_dummy_ = \
-      GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \
-  void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody()
-
-# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator) \
-  ::testing::internal::ParamGenerator<test_case_name::ParamType> \
-      gtest_##prefix##test_case_name##_EvalGenerator_() { return generator; } \
-  int gtest_##prefix##test_case_name##_dummy_ = \
-      ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
-          GetTestCasePatternHolder<test_case_name>(\
-              #test_case_name, __FILE__, __LINE__)->AddTestCaseInstantiation(\
-                  #prefix, \
-                  &gtest_##prefix##test_case_name##_EvalGenerator_, \
-                  __FILE__, __LINE__)
-
-}  // namespace testing
-
-#endif  // GTEST_HAS_PARAM_TEST
-
-#endif  // GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
-// Copyright 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan at google.com (Zhanyong Wan)
-//
-// Google C++ Testing Framework definitions useful in production code.
-
-#ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_
-#define GTEST_INCLUDE_GTEST_GTEST_PROD_H_
-
-// When you need to test the private or protected members of a class,
-// use the FRIEND_TEST macro to declare your tests as friends of the
-// class.  For example:
-//
-// class MyClass {
-//  private:
-//   void MyMethod();
-//   FRIEND_TEST(MyClassTest, MyMethod);
-// };
-//
-// class MyClassTest : public testing::Test {
-//   // ...
-// };
-//
-// TEST_F(MyClassTest, MyMethod) {
-//   // Can call MyClass::MyMethod() here.
-// }
-
-#define FRIEND_TEST(test_case_name, test_name)\
-friend class test_case_name##_##test_name##_Test
-
-#endif  // GTEST_INCLUDE_GTEST_GTEST_PROD_H_
-// Copyright 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: mheule at google.com (Markus Heule)
-//
-
-#ifndef GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
-#define GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
-
-#include <iosfwd>
-#include <vector>
-
-namespace testing {
-
-// A copyable object representing the result of a test part (i.e. an
-// assertion or an explicit FAIL(), ADD_FAILURE(), or SUCCESS()).
-//
-// Don't inherit from TestPartResult as its destructor is not virtual.
-class GTEST_API_ TestPartResult {
- public:
-  // The possible outcomes of a test part (i.e. an assertion or an
-  // explicit SUCCEED(), FAIL(), or ADD_FAILURE()).
-  enum Type {
-    kSuccess,          // Succeeded.
-    kNonFatalFailure,  // Failed but the test can continue.
-    kFatalFailure      // Failed and the test should be terminated.
-  };
-
-  // C'tor.  TestPartResult does NOT have a default constructor.
-  // Always use this constructor (with parameters) to create a
-  // TestPartResult object.
-  TestPartResult(Type a_type,
-                 const char* a_file_name,
-                 int a_line_number,
-                 const char* a_message)
-      : type_(a_type),
-        file_name_(a_file_name),
-        line_number_(a_line_number),
-        summary_(ExtractSummary(a_message)),
-        message_(a_message) {
-  }
-
-  // Gets the outcome of the test part.
-  Type type() const { return type_; }
-
-  // Gets the name of the source file where the test part took place, or
-  // NULL if it's unknown.
-  const char* file_name() const { return file_name_.c_str(); }
-
-  // Gets the line in the source file where the test part took place,
-  // or -1 if it's unknown.
-  int line_number() const { return line_number_; }
-
-  // Gets the summary of the failure message.
-  const char* summary() const { return summary_.c_str(); }
-
-  // Gets the message associated with the test part.
-  const char* message() const { return message_.c_str(); }
-
-  // Returns true iff the test part passed.
-  bool passed() const { return type_ == kSuccess; }
-
-  // Returns true iff the test part failed.
-  bool failed() const { return type_ != kSuccess; }
-
-  // Returns true iff the test part non-fatally failed.
-  bool nonfatally_failed() const { return type_ == kNonFatalFailure; }
-
-  // Returns true iff the test part fatally failed.
-  bool fatally_failed() const { return type_ == kFatalFailure; }
- private:
-  Type type_;
-
-  // Gets the summary of the failure message by omitting the stack
-  // trace in it.
-  static internal::String ExtractSummary(const char* message);
-
-  // The name of the source file where the test part took place, or
-  // NULL if the source file is unknown.
-  internal::String file_name_;
-  // The line in the source file where the test part took place, or -1
-  // if the line number is unknown.
-  int line_number_;
-  internal::String summary_;  // The test failure summary.
-  internal::String message_;  // The test failure message.
-};
-
-// Prints a TestPartResult object.
-std::ostream& operator<<(std::ostream& os, const TestPartResult& result);
-
-// An array of TestPartResult objects.
-//
-// Don't inherit from TestPartResultArray as its destructor is not
-// virtual.
-class GTEST_API_ TestPartResultArray {
- public:
-  TestPartResultArray() {}
-
-  // Appends the given TestPartResult to the array.
-  void Append(const TestPartResult& result);
-
-  // Returns the TestPartResult at the given index (0-based).
-  const TestPartResult& GetTestPartResult(int index) const;
-
-  // Returns the number of TestPartResult objects in the array.
-  int size() const;
-
- private:
-  std::vector<TestPartResult> array_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestPartResultArray);
-};
-
-// This interface knows how to report a test part result.
-class TestPartResultReporterInterface {
- public:
-  virtual ~TestPartResultReporterInterface() {}
-
-  virtual void ReportTestPartResult(const TestPartResult& result) = 0;
-};
-
-namespace internal {
-
-// This helper class is used by {ASSERT|EXPECT}_NO_FATAL_FAILURE to check if a
-// statement generates new fatal failures. To do so it registers itself as the
-// current test part result reporter. Besides checking if fatal failures were
-// reported, it only delegates the reporting to the former result reporter.
-// The original result reporter is restored in the destructor.
-// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
-class GTEST_API_ HasNewFatalFailureHelper
-    : public TestPartResultReporterInterface {
- public:
-  HasNewFatalFailureHelper();
-  virtual ~HasNewFatalFailureHelper();
-  virtual void ReportTestPartResult(const TestPartResult& result);
-  bool has_new_fatal_failure() const { return has_new_fatal_failure_; }
- private:
-  bool has_new_fatal_failure_;
-  TestPartResultReporterInterface* original_reporter_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(HasNewFatalFailureHelper);
-};
-
-}  // namespace internal
-
-}  // namespace testing
-
-#endif  // GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
-// Copyright 2008 Google Inc.
-// All Rights Reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan at google.com (Zhanyong Wan)
-
-#ifndef GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
-#define GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
-
-// This header implements typed tests and type-parameterized tests.
-
-// Typed (aka type-driven) tests repeat the same test for types in a
-// list.  You must know which types you want to test with when writing
-// typed tests. Here's how you do it:
-
-#if 0
-
-// First, define a fixture class template.  It should be parameterized
-// by a type.  Remember to derive it from testing::Test.
-template <typename T>
-class FooTest : public testing::Test {
- public:
-  ...
-  typedef std::list<T> List;
-  static T shared_;
-  T value_;
-};
-
-// Next, associate a list of types with the test case, which will be
-// repeated for each type in the list.  The typedef is necessary for
-// the macro to parse correctly.
-typedef testing::Types<char, int, unsigned int> MyTypes;
-TYPED_TEST_CASE(FooTest, MyTypes);
-
-// If the type list contains only one type, you can write that type
-// directly without Types<...>:
-//   TYPED_TEST_CASE(FooTest, int);
-
-// Then, use TYPED_TEST() instead of TEST_F() to define as many typed
-// tests for this test case as you want.
-TYPED_TEST(FooTest, DoesBlah) {
-  // Inside a test, refer to TypeParam to get the type parameter.
-  // Since we are inside a derived class template, C++ requires use to
-  // visit the members of FooTest via 'this'.
-  TypeParam n = this->value_;
-
-  // To visit static members of the fixture, add the TestFixture::
-  // prefix.
-  n += TestFixture::shared_;
-
-  // To refer to typedefs in the fixture, add the "typename
-  // TestFixture::" prefix.
-  typename TestFixture::List values;
-  values.push_back(n);
-  ...
-}
-
-TYPED_TEST(FooTest, HasPropertyA) { ... }
-
-#endif  // 0
-
-// Type-parameterized tests are abstract test patterns parameterized
-// by a type.  Compared with typed tests, type-parameterized tests
-// allow you to define the test pattern without knowing what the type
-// parameters are.  The defined pattern can be instantiated with
-// different types any number of times, in any number of translation
-// units.
-//
-// If you are designing an interface or concept, you can define a
-// suite of type-parameterized tests to verify properties that any
-// valid implementation of the interface/concept should have.  Then,
-// each implementation can easily instantiate the test suite to verify
-// that it conforms to the requirements, without having to write
-// similar tests repeatedly.  Here's an example:
-
-#if 0
-
-// First, define a fixture class template.  It should be parameterized
-// by a type.  Remember to derive it from testing::Test.
-template <typename T>
-class FooTest : public testing::Test {
-  ...
-};
-
-// Next, declare that you will define a type-parameterized test case
-// (the _P suffix is for "parameterized" or "pattern", whichever you
-// prefer):
-TYPED_TEST_CASE_P(FooTest);
-
-// Then, use TYPED_TEST_P() to define as many type-parameterized tests
-// for this type-parameterized test case as you want.
-TYPED_TEST_P(FooTest, DoesBlah) {
-  // Inside a test, refer to TypeParam to get the type parameter.
-  TypeParam n = 0;
-  ...
-}
-
-TYPED_TEST_P(FooTest, HasPropertyA) { ... }
-
-// Now the tricky part: you need to register all test patterns before
-// you can instantiate them.  The first argument of the macro is the
-// test case name; the rest are the names of the tests in this test
-// case.
-REGISTER_TYPED_TEST_CASE_P(FooTest,
-                           DoesBlah, HasPropertyA);
-
-// Finally, you are free to instantiate the pattern with the types you
-// want.  If you put the above code in a header file, you can #include
-// it in multiple C++ source files and instantiate it multiple times.
-//
-// To distinguish different instances of the pattern, the first
-// argument to the INSTANTIATE_* macro is a prefix that will be added
-// to the actual test case name.  Remember to pick unique prefixes for
-// different instances.
-typedef testing::Types<char, int, unsigned int> MyTypes;
-INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes);
-
-// If the type list contains only one type, you can write that type
-// directly without Types<...>:
-//   INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, int);
-
-#endif  // 0
-
-
-// Implements typed tests.
-
-#if GTEST_HAS_TYPED_TEST
-
-// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
-//
-// Expands to the name of the typedef for the type parameters of the
-// given test case.
-# define GTEST_TYPE_PARAMS_(TestCaseName) gtest_type_params_##TestCaseName##_
-
-// The 'Types' template argument below must have spaces around it
-// since some compilers may choke on '>>' when passing a template
-// instance (e.g. Types<int>)
-# define TYPED_TEST_CASE(CaseName, Types) \
-  typedef ::testing::internal::TypeList< Types >::type \
-      GTEST_TYPE_PARAMS_(CaseName)
-
-# define TYPED_TEST(CaseName, TestName) \
-  template <typename gtest_TypeParam_> \
-  class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \
-      : public CaseName<gtest_TypeParam_> { \
-   private: \
-    typedef CaseName<gtest_TypeParam_> TestFixture; \
-    typedef gtest_TypeParam_ TypeParam; \
-    virtual void TestBody(); \
-  }; \
-  bool gtest_##CaseName##_##TestName##_registered_ GTEST_ATTRIBUTE_UNUSED_ = \
-      ::testing::internal::TypeParameterizedTest< \
-          CaseName, \
-          ::testing::internal::TemplateSel< \
-              GTEST_TEST_CLASS_NAME_(CaseName, TestName)>, \
-          GTEST_TYPE_PARAMS_(CaseName)>::Register(\
-              "", #CaseName, #TestName, 0); \
-  template <typename gtest_TypeParam_> \
-  void GTEST_TEST_CLASS_NAME_(CaseName, TestName)<gtest_TypeParam_>::TestBody()
-
-#endif  // GTEST_HAS_TYPED_TEST
-
-// Implements type-parameterized tests.
-
-#if GTEST_HAS_TYPED_TEST_P
-
-// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
-//
-// Expands to the namespace name that the type-parameterized tests for
-// the given type-parameterized test case are defined in.  The exact
-// name of the namespace is subject to change without notice.
-# define GTEST_CASE_NAMESPACE_(TestCaseName) \
-  gtest_case_##TestCaseName##_
-
-// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
-//
-// Expands to the name of the variable used to remember the names of
-// the defined tests in the given test case.
-# define GTEST_TYPED_TEST_CASE_P_STATE_(TestCaseName) \
-  gtest_typed_test_case_p_state_##TestCaseName##_
-
-// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE DIRECTLY.
-//
-// Expands to the name of the variable used to remember the names of
-// the registered tests in the given test case.
-# define GTEST_REGISTERED_TEST_NAMES_(TestCaseName) \
-  gtest_registered_test_names_##TestCaseName##_
-
-// The variables defined in the type-parameterized test macros are
-// static as typically these macros are used in a .h file that can be
-// #included in multiple translation units linked together.
-# define TYPED_TEST_CASE_P(CaseName) \
-  static ::testing::internal::TypedTestCasePState \
-      GTEST_TYPED_TEST_CASE_P_STATE_(CaseName)
-
-# define TYPED_TEST_P(CaseName, TestName) \
-  namespace GTEST_CASE_NAMESPACE_(CaseName) { \
-  template <typename gtest_TypeParam_> \
-  class TestName : public CaseName<gtest_TypeParam_> { \
-   private: \
-    typedef CaseName<gtest_TypeParam_> TestFixture; \
-    typedef gtest_TypeParam_ TypeParam; \
-    virtual void TestBody(); \
-  }; \
-  static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \
-      GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).AddTestName(\
-          __FILE__, __LINE__, #CaseName, #TestName); \
-  } \
-  template <typename gtest_TypeParam_> \
-  void GTEST_CASE_NAMESPACE_(CaseName)::TestName<gtest_TypeParam_>::TestBody()
-
-# define REGISTER_TYPED_TEST_CASE_P(CaseName, ...) \
-  namespace GTEST_CASE_NAMESPACE_(CaseName) { \
-  typedef ::testing::internal::Templates<__VA_ARGS__>::type gtest_AllTests_; \
-  } \
-  static const char* const GTEST_REGISTERED_TEST_NAMES_(CaseName) = \
-      GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).VerifyRegisteredTestNames(\
-          __FILE__, __LINE__, #__VA_ARGS__)
-
-// The 'Types' template argument below must have spaces around it
-// since some compilers may choke on '>>' when passing a template
-// instance (e.g. Types<int>)
-# define INSTANTIATE_TYPED_TEST_CASE_P(Prefix, CaseName, Types) \
-  bool gtest_##Prefix##_##CaseName GTEST_ATTRIBUTE_UNUSED_ = \
-      ::testing::internal::TypeParameterizedTestCase<CaseName, \
-          GTEST_CASE_NAMESPACE_(CaseName)::gtest_AllTests_, \
-          ::testing::internal::TypeList< Types >::type>::Register(\
-              #Prefix, #CaseName, GTEST_REGISTERED_TEST_NAMES_(CaseName))
-
-#endif  // GTEST_HAS_TYPED_TEST_P
-
-#endif  // GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
-
-// Depending on the platform, different string classes are available.
-// On Linux, in addition to ::std::string, Google also makes use of
-// class ::string, which has the same interface as ::std::string, but
-// has a different implementation.
-//
-// The user can define GTEST_HAS_GLOBAL_STRING to 1 to indicate that
-// ::string is available AND is a distinct type to ::std::string, or
-// define it to 0 to indicate otherwise.
-//
-// If the user's ::std::string and ::string are the same class due to
-// aliasing, he should define GTEST_HAS_GLOBAL_STRING to 0.
-//
-// If the user doesn't define GTEST_HAS_GLOBAL_STRING, it is defined
-// heuristically.
-
-namespace testing {
-
-// Declares the flags.
-
-// This flag temporary enables the disabled tests.
-GTEST_DECLARE_bool_(also_run_disabled_tests);
-
-// This flag brings the debugger on an assertion failure.
-GTEST_DECLARE_bool_(break_on_failure);
-
-// This flag controls whether Google Test catches all test-thrown exceptions
-// and logs them as failures.
-GTEST_DECLARE_bool_(catch_exceptions);
-
-// This flag enables using colors in terminal output. Available values are
-// "yes" to enable colors, "no" (disable colors), or "auto" (the default)
-// to let Google Test decide.
-GTEST_DECLARE_string_(color);
-
-// This flag sets up the filter to select by name using a glob pattern
-// the tests to run. If the filter is not given all tests are executed.
-GTEST_DECLARE_string_(filter);
-
-// This flag causes the Google Test to list tests. None of the tests listed
-// are actually run if the flag is provided.
-GTEST_DECLARE_bool_(list_tests);
-
-// This flag controls whether Google Test emits a detailed XML report to a file
-// in addition to its normal textual output.
-GTEST_DECLARE_string_(output);
-
-// This flags control whether Google Test prints the elapsed time for each
-// test.
-GTEST_DECLARE_bool_(print_time);
-
-// This flag specifies the random number seed.
-GTEST_DECLARE_int32_(random_seed);
-
-// This flag sets how many times the tests are repeated. The default value
-// is 1. If the value is -1 the tests are repeating forever.
-GTEST_DECLARE_int32_(repeat);
-
-// This flag controls whether Google Test includes Google Test internal
-// stack frames in failure stack traces.
-GTEST_DECLARE_bool_(show_internal_stack_frames);
-
-// When this flag is specified, tests' order is randomized on every iteration.
-GTEST_DECLARE_bool_(shuffle);
-
-// This flag specifies the maximum number of stack frames to be
-// printed in a failure message.
-GTEST_DECLARE_int32_(stack_trace_depth);
-
-// When this flag is specified, a failed assertion will throw an
-// exception if exceptions are enabled, or exit the program with a
-// non-zero code otherwise.
-GTEST_DECLARE_bool_(throw_on_failure);
-
-// When this flag is set with a "host:port" string, on supported
-// platforms test results are streamed to the specified port on
-// the specified host machine.
-GTEST_DECLARE_string_(stream_result_to);
-
-// The upper limit for valid stack trace depths.
-const int kMaxStackTraceDepth = 100;
-
-namespace internal {
-
-class AssertHelper;
-class DefaultGlobalTestPartResultReporter;
-class ExecDeathTest;
-class NoExecDeathTest;
-class FinalSuccessChecker;
-class GTestFlagSaver;
-class TestResultAccessor;
-class TestEventListenersAccessor;
-class TestEventRepeater;
-class WindowsDeathTest;
-class UnitTestImpl* GetUnitTestImpl();
-void ReportFailureInUnknownLocation(TestPartResult::Type result_type,
-                                    const String& message);
-
-// Converts a streamable value to a String.  A NULL pointer is
-// converted to "(null)".  When the input value is a ::string,
-// ::std::string, ::wstring, or ::std::wstring object, each NUL
-// character in it is replaced with "\\0".
-// Declared in gtest-internal.h but defined here, so that it has access
-// to the definition of the Message class, required by the ARM
-// compiler.
-template <typename T>
-String StreamableToString(const T& streamable) {
-  return (Message() << streamable).GetString();
-}
-
-}  // namespace internal
-
-// The friend relationship of some of these classes is cyclic.
-// If we don't forward declare them the compiler might confuse the classes
-// in friendship clauses with same named classes on the scope.
-class Test;
-class TestCase;
-class TestInfo;
-class UnitTest;
-
-// A class for indicating whether an assertion was successful.  When
-// the assertion wasn't successful, the AssertionResult object
-// remembers a non-empty message that describes how it failed.
-//
-// To create an instance of this class, use one of the factory functions
-// (AssertionSuccess() and AssertionFailure()).
-//
-// This class is useful for two purposes:
-//   1. Defining predicate functions to be used with Boolean test assertions
-//      EXPECT_TRUE/EXPECT_FALSE and their ASSERT_ counterparts
-//   2. Defining predicate-format functions to be
-//      used with predicate assertions (ASSERT_PRED_FORMAT*, etc).
-//
-// For example, if you define IsEven predicate:
-//
-//   testing::AssertionResult IsEven(int n) {
-//     if ((n % 2) == 0)
-//       return testing::AssertionSuccess();
-//     else
-//       return testing::AssertionFailure() << n << " is odd";
-//   }
-//
-// Then the failed expectation EXPECT_TRUE(IsEven(Fib(5)))
-// will print the message
-//
-//   Value of: IsEven(Fib(5))
-//     Actual: false (5 is odd)
-//   Expected: true
-//
-// instead of a more opaque
-//
-//   Value of: IsEven(Fib(5))
-//     Actual: false
-//   Expected: true
-//
-// in case IsEven is a simple Boolean predicate.
-//
-// If you expect your predicate to be reused and want to support informative
-// messages in EXPECT_FALSE and ASSERT_FALSE (negative assertions show up
-// about half as often as positive ones in our tests), supply messages for
-// both success and failure cases:
-//
-//   testing::AssertionResult IsEven(int n) {
-//     if ((n % 2) == 0)
-//       return testing::AssertionSuccess() << n << " is even";
-//     else
-//       return testing::AssertionFailure() << n << " is odd";
-//   }
-//
-// Then a statement EXPECT_FALSE(IsEven(Fib(6))) will print
-//
-//   Value of: IsEven(Fib(6))
-//     Actual: true (8 is even)
-//   Expected: false
-//
-// NB: Predicates that support negative Boolean assertions have reduced
-// performance in positive ones so be careful not to use them in tests
-// that have lots (tens of thousands) of positive Boolean assertions.
-//
-// To use this class with EXPECT_PRED_FORMAT assertions such as:
-//
-//   // Verifies that Foo() returns an even number.
-//   EXPECT_PRED_FORMAT1(IsEven, Foo());
-//
-// you need to define:
-//
-//   testing::AssertionResult IsEven(const char* expr, int n) {
-//     if ((n % 2) == 0)
-//       return testing::AssertionSuccess();
-//     else
-//       return testing::AssertionFailure()
-//         << "Expected: " << expr << " is even\n  Actual: it's " << n;
-//   }
-//
-// If Foo() returns 5, you will see the following message:
-//
-//   Expected: Foo() is even
-//     Actual: it's 5
-//
-class GTEST_API_ AssertionResult {
- public:
-  // Copy constructor.
-  // Used in EXPECT_TRUE/FALSE(assertion_result).
-  AssertionResult(const AssertionResult& other);
-  // Used in the EXPECT_TRUE/FALSE(bool_expression).
-  explicit AssertionResult(bool success) : success_(success) {}
-
-  // Returns true iff the assertion succeeded.
-  operator bool() const { return success_; }  // NOLINT
-
-  // Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
-  AssertionResult operator!() const;
-
-  // Returns the text streamed into this AssertionResult. Test assertions
-  // use it when they fail (i.e., the predicate's outcome doesn't match the
-  // assertion's expectation). When nothing has been streamed into the
-  // object, returns an empty string.
-  const char* message() const {
-    return message_.get() != NULL ?  message_->c_str() : "";
-  }
-  // TODO(vladl at google.com): Remove this after making sure no clients use it.
-  // Deprecated; please use message() instead.
-  const char* failure_message() const { return message(); }
-
-  // Streams a custom failure message into this object.
-  template <typename T> AssertionResult& operator<<(const T& value) {
-    AppendMessage(Message() << value);
-    return *this;
-  }
-
-  // Allows streaming basic output manipulators such as endl or flush into
-  // this object.
-  AssertionResult& operator<<(
-      ::std::ostream& (*basic_manipulator)(::std::ostream& stream)) {
-    AppendMessage(Message() << basic_manipulator);
-    return *this;
-  }
-
- private:
-  // Appends the contents of message to message_.
-  void AppendMessage(const Message& a_message) {
-    if (message_.get() == NULL)
-      message_.reset(new ::std::string);
-    message_->append(a_message.GetString().c_str());
-  }
-
-  // Stores result of the assertion predicate.
-  bool success_;
-  // Stores the message describing the condition in case the expectation
-  // construct is not satisfied with the predicate's outcome.
-  // Referenced via a pointer to avoid taking too much stack frame space
-  // with test assertions.
-  internal::scoped_ptr< ::std::string> message_;
-
-  GTEST_DISALLOW_ASSIGN_(AssertionResult);
-};
-
-// Makes a successful assertion result.
-GTEST_API_ AssertionResult AssertionSuccess();
-
-// Makes a failed assertion result.
-GTEST_API_ AssertionResult AssertionFailure();
-
-// Makes a failed assertion result with the given failure message.
-// Deprecated; use AssertionFailure() << msg.
-GTEST_API_ AssertionResult AssertionFailure(const Message& msg);
-
-// The abstract class that all tests inherit from.
-//
-// In Google Test, a unit test program contains one or many TestCases, and
-// each TestCase contains one or many Tests.
-//
-// When you define a test using the TEST macro, you don't need to
-// explicitly derive from Test - the TEST macro automatically does
-// this for you.
-//
-// The only time you derive from Test is when defining a test fixture
-// to be used a TEST_F.  For example:
-//
-//   class FooTest : public testing::Test {
-//    protected:
-//     virtual void SetUp() { ... }
-//     virtual void TearDown() { ... }
-//     ...
-//   };
-//
-//   TEST_F(FooTest, Bar) { ... }
-//   TEST_F(FooTest, Baz) { ... }
-//
-// Test is not copyable.
-class GTEST_API_ Test {
- public:
-  friend class TestInfo;
-
-  // Defines types for pointers to functions that set up and tear down
-  // a test case.
-  typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc;
-  typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc;
-
-  // The d'tor is virtual as we intend to inherit from Test.
-  virtual ~Test();
-
-  // Sets up the stuff shared by all tests in this test case.
-  //
-  // Google Test will call Foo::SetUpTestCase() before running the first
-  // test in test case Foo.  Hence a sub-class can define its own
-  // SetUpTestCase() method to shadow the one defined in the super
-  // class.
-  static void SetUpTestCase() {}
-
-  // Tears down the stuff shared by all tests in this test case.
-  //
-  // Google Test will call Foo::TearDownTestCase() after running the last
-  // test in test case Foo.  Hence a sub-class can define its own
-  // TearDownTestCase() method to shadow the one defined in the super
-  // class.
-  static void TearDownTestCase() {}
-
-  // Returns true iff the current test has a fatal failure.
-  static bool HasFatalFailure();
-
-  // Returns true iff the current test has a non-fatal failure.
-  static bool HasNonfatalFailure();
-
-  // Returns true iff the current test has a (either fatal or
-  // non-fatal) failure.
-  static bool HasFailure() { return HasFatalFailure() || HasNonfatalFailure(); }
-
-  // Logs a property for the current test.  Only the last value for a given
-  // key is remembered.
-  // These are public static so they can be called from utility functions
-  // that are not members of the test fixture.
-  // The arguments are const char* instead strings, as Google Test is used
-  // on platforms where string doesn't compile.
-  //
-  // Note that a driving consideration for these RecordProperty methods
-  // was to produce xml output suited to the Greenspan charting utility,
-  // which at present will only chart values that fit in a 32-bit int. It
-  // is the user's responsibility to restrict their values to 32-bit ints
-  // if they intend them to be used with Greenspan.
-  static void RecordProperty(const char* key, const char* value);
-  static void RecordProperty(const char* key, int value);
-
- protected:
-  // Creates a Test object.
-  Test();
-
-  // Sets up the test fixture.
-  virtual void SetUp();
-
-  // Tears down the test fixture.
-  virtual void TearDown();
-
- private:
-  // Returns true iff the current test has the same fixture class as
-  // the first test in the current test case.
-  static bool HasSameFixtureClass();
-
-  // Runs the test after the test fixture has been set up.
-  //
-  // A sub-class must implement this to define the test logic.
-  //
-  // DO NOT OVERRIDE THIS FUNCTION DIRECTLY IN A USER PROGRAM.
-  // Instead, use the TEST or TEST_F macro.
-  virtual void TestBody() = 0;
-
-  // Sets up, executes, and tears down the test.
-  void Run();
-
-  // Deletes self.  We deliberately pick an unusual name for this
-  // internal method to avoid clashing with names used in user TESTs.
-  void DeleteSelf_() { delete this; }
-
-  // Uses a GTestFlagSaver to save and restore all Google Test flags.
-  const internal::GTestFlagSaver* const gtest_flag_saver_;
-
-  // Often a user mis-spells SetUp() as Setup() and spends a long time
-  // wondering why it is never called by Google Test.  The declaration of
-  // the following method is solely for catching such an error at
-  // compile time:
-  //
-  //   - The return type is deliberately chosen to be not void, so it
-  //   will be a conflict if a user declares void Setup() in his test
-  //   fixture.
-  //
-  //   - This method is private, so it will be another compiler error
-  //   if a user calls it from his test fixture.
-  //
-  // DO NOT OVERRIDE THIS FUNCTION.
-  //
-  // If you see an error about overriding the following function or
-  // about it being private, you have mis-spelled SetUp() as Setup().
-  struct Setup_should_be_spelled_SetUp {};
-  virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; }
-
-  // We disallow copying Tests.
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(Test);
-};
-
-typedef internal::TimeInMillis TimeInMillis;
-
-// A copyable object representing a user specified test property which can be
-// output as a key/value string pair.
-//
-// Don't inherit from TestProperty as its destructor is not virtual.
-class TestProperty {
- public:
-  // C'tor.  TestProperty does NOT have a default constructor.
-  // Always use this constructor (with parameters) to create a
-  // TestProperty object.
-  TestProperty(const char* a_key, const char* a_value) :
-    key_(a_key), value_(a_value) {
-  }
-
-  // Gets the user supplied key.
-  const char* key() const {
-    return key_.c_str();
-  }
-
-  // Gets the user supplied value.
-  const char* value() const {
-    return value_.c_str();
-  }
-
-  // Sets a new value, overriding the one supplied in the constructor.
-  void SetValue(const char* new_value) {
-    value_ = new_value;
-  }
-
- private:
-  // The key supplied by the user.
-  internal::String key_;
-  // The value supplied by the user.
-  internal::String value_;
-};
-
-// The result of a single Test.  This includes a list of
-// TestPartResults, a list of TestProperties, a count of how many
-// death tests there are in the Test, and how much time it took to run
-// the Test.
-//
-// TestResult is not copyable.
-class GTEST_API_ TestResult {
- public:
-  // Creates an empty TestResult.
-  TestResult();
-
-  // D'tor.  Do not inherit from TestResult.
-  ~TestResult();
-
-  // Gets the number of all test parts.  This is the sum of the number
-  // of successful test parts and the number of failed test parts.
-  int total_part_count() const;
-
-  // Returns the number of the test properties.
-  int test_property_count() const;
-
-  // Returns true iff the test passed (i.e. no test part failed).
-  bool Passed() const { return !Failed(); }
-
-  // Returns true iff the test failed.
-  bool Failed() const;
-
-  // Returns true iff the test fatally failed.
-  bool HasFatalFailure() const;
-
-  // Returns true iff the test has a non-fatal failure.
-  bool HasNonfatalFailure() const;
-
-  // Returns the elapsed time, in milliseconds.
-  TimeInMillis elapsed_time() const { return elapsed_time_; }
-
-  // Returns the i-th test part result among all the results. i can range
-  // from 0 to test_property_count() - 1. If i is not in that range, aborts
-  // the program.
-  const TestPartResult& GetTestPartResult(int i) const;
-
-  // Returns the i-th test property. i can range from 0 to
-  // test_property_count() - 1. If i is not in that range, aborts the
-  // program.
-  const TestProperty& GetTestProperty(int i) const;
-
- private:
-  friend class TestInfo;
-  friend class UnitTest;
-  friend class internal::DefaultGlobalTestPartResultReporter;
-  friend class internal::ExecDeathTest;
-  friend class internal::TestResultAccessor;
-  friend class internal::UnitTestImpl;
-  friend class internal::WindowsDeathTest;
-
-  // Gets the vector of TestPartResults.
-  const std::vector<TestPartResult>& test_part_results() const {
-    return test_part_results_;
-  }
-
-  // Gets the vector of TestProperties.
-  const std::vector<TestProperty>& test_properties() const {
-    return test_properties_;
-  }
-
-  // Sets the elapsed time.
-  void set_elapsed_time(TimeInMillis elapsed) { elapsed_time_ = elapsed; }
-
-  // Adds a test property to the list. The property is validated and may add
-  // a non-fatal failure if invalid (e.g., if it conflicts with reserved
-  // key names). If a property is already recorded for the same key, the
-  // value will be updated, rather than storing multiple values for the same
-  // key.
-  void RecordProperty(const TestProperty& test_property);
-
-  // Adds a failure if the key is a reserved attribute of Google Test
-  // testcase tags.  Returns true if the property is valid.
-  // TODO(russr): Validate attribute names are legal and human readable.
-  static bool ValidateTestProperty(const TestProperty& test_property);
-
-  // Adds a test part result to the list.
-  void AddTestPartResult(const TestPartResult& test_part_result);
-
-  // Returns the death test count.
-  int death_test_count() const { return death_test_count_; }
-
-  // Increments the death test count, returning the new count.
-  int increment_death_test_count() { return ++death_test_count_; }
-
-  // Clears the test part results.
-  void ClearTestPartResults();
-
-  // Clears the object.
-  void Clear();
-
-  // Protects mutable state of the property vector and of owned
-  // properties, whose values may be updated.
-  internal::Mutex test_properites_mutex_;
-
-  // The vector of TestPartResults
-  std::vector<TestPartResult> test_part_results_;
-  // The vector of TestProperties
-  std::vector<TestProperty> test_properties_;
-  // Running count of death tests.
-  int death_test_count_;
-  // The elapsed time, in milliseconds.
-  TimeInMillis elapsed_time_;
-
-  // We disallow copying TestResult.
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestResult);
-};  // class TestResult
-
-// A TestInfo object stores the following information about a test:
-//
-//   Test case name
-//   Test name
-//   Whether the test should be run
-//   A function pointer that creates the test object when invoked
-//   Test result
-//
-// The constructor of TestInfo registers itself with the UnitTest
-// singleton such that the RUN_ALL_TESTS() macro knows which tests to
-// run.
-class GTEST_API_ TestInfo {
- public:
-  // Destructs a TestInfo object.  This function is not virtual, so
-  // don't inherit from TestInfo.
-  ~TestInfo();
-
-  // Returns the test case name.
-  const char* test_case_name() const { return test_case_name_.c_str(); }
-
-  // Returns the test name.
-  const char* name() const { return name_.c_str(); }
-
-  // Returns the name of the parameter type, or NULL if this is not a typed
-  // or a type-parameterized test.
-  const char* type_param() const {
-    if (type_param_.get() != NULL)
-      return type_param_->c_str();
-    return NULL;
-  }
-
-  // Returns the text representation of the value parameter, or NULL if this
-  // is not a value-parameterized test.
-  const char* value_param() const {
-    if (value_param_.get() != NULL)
-      return value_param_->c_str();
-    return NULL;
-  }
-
-  // Returns true if this test should run, that is if the test is not disabled
-  // (or it is disabled but the also_run_disabled_tests flag has been specified)
-  // and its full name matches the user-specified filter.
-  //
-  // Google Test allows the user to filter the tests by their full names.
-  // The full name of a test Bar in test case Foo is defined as
-  // "Foo.Bar".  Only the tests that match the filter will run.
-  //
-  // A filter is a colon-separated list of glob (not regex) patterns,
-  // optionally followed by a '-' and a colon-separated list of
-  // negative patterns (tests to exclude).  A test is run if it
-  // matches one of the positive patterns and does not match any of
-  // the negative patterns.
-  //
-  // For example, *A*:Foo.* is a filter that matches any string that
-  // contains the character 'A' or starts with "Foo.".
-  bool should_run() const { return should_run_; }
-
-  // Returns the result of the test.
-  const TestResult* result() const { return &result_; }
-
- private:
-
-#if GTEST_HAS_DEATH_TEST
-  friend class internal::DefaultDeathTestFactory;
-#endif  // GTEST_HAS_DEATH_TEST
-  friend class Test;
-  friend class TestCase;
-  friend class internal::UnitTestImpl;
-  friend TestInfo* internal::MakeAndRegisterTestInfo(
-      const char* test_case_name, const char* name,
-      const char* type_param,
-      const char* value_param,
-      internal::TypeId fixture_class_id,
-      Test::SetUpTestCaseFunc set_up_tc,
-      Test::TearDownTestCaseFunc tear_down_tc,
-      internal::TestFactoryBase* factory);
-
-  // Constructs a TestInfo object. The newly constructed instance assumes
-  // ownership of the factory object.
-  TestInfo(const char* test_case_name, const char* name,
-           const char* a_type_param,
-           const char* a_value_param,
-           internal::TypeId fixture_class_id,
-           internal::TestFactoryBase* factory);
-
-  // Increments the number of death tests encountered in this test so
-  // far.
-  int increment_death_test_count() {
-    return result_.increment_death_test_count();
-  }
-
-  // Creates the test object, runs it, records its result, and then
-  // deletes it.
-  void Run();
-
-  static void ClearTestResult(TestInfo* test_info) {
-    test_info->result_.Clear();
-  }
-
-  // These fields are immutable properties of the test.
-  const std::string test_case_name_;     // Test case name
-  const std::string name_;               // Test name
-  // Name of the parameter type, or NULL if this is not a typed or a
-  // type-parameterized test.
-  const internal::scoped_ptr<const ::std::string> type_param_;
-  // Text representation of the value parameter, or NULL if this is not a
-  // value-parameterized test.
-  const internal::scoped_ptr<const ::std::string> value_param_;
-  const internal::TypeId fixture_class_id_;   // ID of the test fixture class
-  bool should_run_;                 // True iff this test should run
-  bool is_disabled_;                // True iff this test is disabled
-  bool matches_filter_;             // True if this test matches the
-                                    // user-specified filter.
-  internal::TestFactoryBase* const factory_;  // The factory that creates
-                                              // the test object
-
-  // This field is mutable and needs to be reset before running the
-  // test for the second time.
-  TestResult result_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestInfo);
-};
-
-// A test case, which consists of a vector of TestInfos.
-//
-// TestCase is not copyable.
-class GTEST_API_ TestCase {
- public:
-  // Creates a TestCase with the given name.
-  //
-  // TestCase does NOT have a default constructor.  Always use this
-  // constructor to create a TestCase object.
-  //
-  // Arguments:
-  //
-  //   name:         name of the test case
-  //   a_type_param: the name of the test's type parameter, or NULL if
-  //                 this is not a type-parameterized test.
-  //   set_up_tc:    pointer to the function that sets up the test case
-  //   tear_down_tc: pointer to the function that tears down the test case
-  TestCase(const char* name, const char* a_type_param,
-           Test::SetUpTestCaseFunc set_up_tc,
-           Test::TearDownTestCaseFunc tear_down_tc);
-
-  // Destructor of TestCase.
-  virtual ~TestCase();
-
-  // Gets the name of the TestCase.
-  const char* name() const { return name_.c_str(); }
-
-  // Returns the name of the parameter type, or NULL if this is not a
-  // type-parameterized test case.
-  const char* type_param() const {
-    if (type_param_.get() != NULL)
-      return type_param_->c_str();
-    return NULL;
-  }
-
-  // Returns true if any test in this test case should run.
-  bool should_run() const { return should_run_; }
-
-  // Gets the number of successful tests in this test case.
-  int successful_test_count() const;
-
-  // Gets the number of failed tests in this test case.
-  int failed_test_count() const;
-
-  // Gets the number of disabled tests in this test case.
-  int disabled_test_count() const;
-
-  // Get the number of tests in this test case that should run.
-  int test_to_run_count() const;
-
-  // Gets the number of all tests in this test case.
-  int total_test_count() const;
-
-  // Returns true iff the test case passed.
-  bool Passed() const { return !Failed(); }
-
-  // Returns true iff the test case failed.
-  bool Failed() const { return failed_test_count() > 0; }
-
-  // Returns the elapsed time, in milliseconds.
-  TimeInMillis elapsed_time() const { return elapsed_time_; }
-
-  // Returns the i-th test among all the tests. i can range from 0 to
-  // total_test_count() - 1. If i is not in that range, returns NULL.
-  const TestInfo* GetTestInfo(int i) const;
-
- private:
-  friend class Test;
-  friend class internal::UnitTestImpl;
-
-  // Gets the (mutable) vector of TestInfos in this TestCase.
-  std::vector<TestInfo*>& test_info_list() { return test_info_list_; }
-
-  // Gets the (immutable) vector of TestInfos in this TestCase.
-  const std::vector<TestInfo*>& test_info_list() const {
-    return test_info_list_;
-  }
-
-  // Returns the i-th test among all the tests. i can range from 0 to
-  // total_test_count() - 1. If i is not in that range, returns NULL.
-  TestInfo* GetMutableTestInfo(int i);
-
-  // Sets the should_run member.
-  void set_should_run(bool should) { should_run_ = should; }
-
-  // Adds a TestInfo to this test case.  Will delete the TestInfo upon
-  // destruction of the TestCase object.
-  void AddTestInfo(TestInfo * test_info);
-
-  // Clears the results of all tests in this test case.
-  void ClearResult();
-
-  // Clears the results of all tests in the given test case.
-  static void ClearTestCaseResult(TestCase* test_case) {
-    test_case->ClearResult();
-  }
-
-  // Runs every test in this TestCase.
-  void Run();
-
-  // Runs SetUpTestCase() for this TestCase.  This wrapper is needed
-  // for catching exceptions thrown from SetUpTestCase().
-  void RunSetUpTestCase() { (*set_up_tc_)(); }
-
-  // Runs TearDownTestCase() for this TestCase.  This wrapper is
-  // needed for catching exceptions thrown from TearDownTestCase().
-  void RunTearDownTestCase() { (*tear_down_tc_)(); }
-
-  // Returns true iff test passed.
-  static bool TestPassed(const TestInfo* test_info) {
-    return test_info->should_run() && test_info->result()->Passed();
-  }
-
-  // Returns true iff test failed.
-  static bool TestFailed(const TestInfo* test_info) {
-    return test_info->should_run() && test_info->result()->Failed();
-  }
-
-  // Returns true iff test is disabled.
-  static bool TestDisabled(const TestInfo* test_info) {
-    return test_info->is_disabled_;
-  }
-
-  // Returns true if the given test should run.
-  static bool ShouldRunTest(const TestInfo* test_info) {
-    return test_info->should_run();
-  }
-
-  // Shuffles the tests in this test case.
-  void ShuffleTests(internal::Random* random);
-
-  // Restores the test order to before the first shuffle.
-  void UnshuffleTests();
-
-  // Name of the test case.
-  internal::String name_;
-  // Name of the parameter type, or NULL if this is not a typed or a
-  // type-parameterized test.
-  const internal::scoped_ptr<const ::std::string> type_param_;
-  // The vector of TestInfos in their original order.  It owns the
-  // elements in the vector.
-  std::vector<TestInfo*> test_info_list_;
-  // Provides a level of indirection for the test list to allow easy
-  // shuffling and restoring the test order.  The i-th element in this
-  // vector is the index of the i-th test in the shuffled test list.
-  std::vector<int> test_indices_;
-  // Pointer to the function that sets up the test case.
-  Test::SetUpTestCaseFunc set_up_tc_;
-  // Pointer to the function that tears down the test case.
-  Test::TearDownTestCaseFunc tear_down_tc_;
-  // True iff any test in this test case should run.
-  bool should_run_;
-  // Elapsed time, in milliseconds.
-  TimeInMillis elapsed_time_;
-
-  // We disallow copying TestCases.
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestCase);
-};
-
-// An Environment object is capable of setting up and tearing down an
-// environment.  The user should subclass this to define his own
-// environment(s).
-//
-// An Environment object does the set-up and tear-down in virtual
-// methods SetUp() and TearDown() instead of the constructor and the
-// destructor, as:
-//
-//   1. You cannot safely throw from a destructor.  This is a problem
-//      as in some cases Google Test is used where exceptions are enabled, and
-//      we may want to implement ASSERT_* using exceptions where they are
-//      available.
-//   2. You cannot use ASSERT_* directly in a constructor or
-//      destructor.
-class Environment {
- public:
-  // The d'tor is virtual as we need to subclass Environment.
-  virtual ~Environment() {}
-
-  // Override this to define how to set up the environment.
-  virtual void SetUp() {}
-
-  // Override this to define how to tear down the environment.
-  virtual void TearDown() {}
- private:
-  // If you see an error about overriding the following function or
-  // about it being private, you have mis-spelled SetUp() as Setup().
-  struct Setup_should_be_spelled_SetUp {};
-  virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; }
-};
-
-// The interface for tracing execution of tests. The methods are organized in
-// the order the corresponding events are fired.
-class TestEventListener {
- public:
-  virtual ~TestEventListener() {}
-
-  // Fired before any test activity starts.
-  virtual void OnTestProgramStart(const UnitTest& unit_test) = 0;
-
-  // Fired before each iteration of tests starts.  There may be more than
-  // one iteration if GTEST_FLAG(repeat) is set. iteration is the iteration
-  // index, starting from 0.
-  virtual void OnTestIterationStart(const UnitTest& unit_test,
-                                    int iteration) = 0;
-
-  // Fired before environment set-up for each iteration of tests starts.
-  virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test) = 0;
-
-  // Fired after environment set-up for each iteration of tests ends.
-  virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test) = 0;
-
-  // Fired before the test case starts.
-  virtual void OnTestCaseStart(const TestCase& test_case) = 0;
-
-  // Fired before the test starts.
-  virtual void OnTestStart(const TestInfo& test_info) = 0;
-
-  // Fired after a failed assertion or a SUCCEED() invocation.
-  virtual void OnTestPartResult(const TestPartResult& test_part_result) = 0;
-
-  // Fired after the test ends.
-  virtual void OnTestEnd(const TestInfo& test_info) = 0;
-
-  // Fired after the test case ends.
-  virtual void OnTestCaseEnd(const TestCase& test_case) = 0;
-
-  // Fired before environment tear-down for each iteration of tests starts.
-  virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test) = 0;
-
-  // Fired after environment tear-down for each iteration of tests ends.
-  virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) = 0;
-
-  // Fired after each iteration of tests finishes.
-  virtual void OnTestIterationEnd(const UnitTest& unit_test,
-                                  int iteration) = 0;
-
-  // Fired after all test activities have ended.
-  virtual void OnTestProgramEnd(const UnitTest& unit_test) = 0;
-};
-
-// The convenience class for users who need to override just one or two
-// methods and are not concerned that a possible change to a signature of
-// the methods they override will not be caught during the build.  For
-// comments about each method please see the definition of TestEventListener
-// above.
-class EmptyTestEventListener : public TestEventListener {
- public:
-  virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {}
-  virtual void OnTestIterationStart(const UnitTest& /*unit_test*/,
-                                    int /*iteration*/) {}
-  virtual void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) {}
-  virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {}
-  virtual void OnTestCaseStart(const TestCase& /*test_case*/) {}
-  virtual void OnTestStart(const TestInfo& /*test_info*/) {}
-  virtual void OnTestPartResult(const TestPartResult& /*test_part_result*/) {}
-  virtual void OnTestEnd(const TestInfo& /*test_info*/) {}
-  virtual void OnTestCaseEnd(const TestCase& /*test_case*/) {}
-  virtual void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) {}
-  virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {}
-  virtual void OnTestIterationEnd(const UnitTest& /*unit_test*/,
-                                  int /*iteration*/) {}
-  virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {}
-};
-
-// TestEventListeners lets users add listeners to track events in Google Test.
-class GTEST_API_ TestEventListeners {
- public:
-  TestEventListeners();
-  ~TestEventListeners();
-
-  // Appends an event listener to the end of the list. Google Test assumes
-  // the ownership of the listener (i.e. it will delete the listener when
-  // the test program finishes).
-  void Append(TestEventListener* listener);
-
-  // Removes the given event listener from the list and returns it.  It then
-  // becomes the caller's responsibility to delete the listener. Returns
-  // NULL if the listener is not found in the list.
-  TestEventListener* Release(TestEventListener* listener);
-
-  // Returns the standard listener responsible for the default console
-  // output.  Can be removed from the listeners list to shut down default
-  // console output.  Note that removing this object from the listener list
-  // with Release transfers its ownership to the caller and makes this
-  // function return NULL the next time.
-  TestEventListener* default_result_printer() const {
-    return default_result_printer_;
-  }
-
-  // Returns the standard listener responsible for the default XML output
-  // controlled by the --gtest_output=xml flag.  Can be removed from the
-  // listeners list by users who want to shut down the default XML output
-  // controlled by this flag and substitute it with custom one.  Note that
-  // removing this object from the listener list with Release transfers its
-  // ownership to the caller and makes this function return NULL the next
-  // time.
-  TestEventListener* default_xml_generator() const {
-    return default_xml_generator_;
-  }
-
- private:
-  friend class TestCase;
-  friend class TestInfo;
-  friend class internal::DefaultGlobalTestPartResultReporter;
-  friend class internal::NoExecDeathTest;
-  friend class internal::TestEventListenersAccessor;
-  friend class internal::UnitTestImpl;
-
-  // Returns repeater that broadcasts the TestEventListener events to all
-  // subscribers.
-  TestEventListener* repeater();
-
-  // Sets the default_result_printer attribute to the provided listener.
-  // The listener is also added to the listener list and previous
-  // default_result_printer is removed from it and deleted. The listener can
-  // also be NULL in which case it will not be added to the list. Does
-  // nothing if the previous and the current listener objects are the same.
-  void SetDefaultResultPrinter(TestEventListener* listener);
-
-  // Sets the default_xml_generator attribute to the provided listener.  The
-  // listener is also added to the listener list and previous
-  // default_xml_generator is removed from it and deleted. The listener can
-  // also be NULL in which case it will not be added to the list. Does
-  // nothing if the previous and the current listener objects are the same.
-  void SetDefaultXmlGenerator(TestEventListener* listener);
-
-  // Controls whether events will be forwarded by the repeater to the
-  // listeners in the list.
-  bool EventForwardingEnabled() const;
-  void SuppressEventForwarding();
-
-  // The actual list of listeners.
-  internal::TestEventRepeater* repeater_;
-  // Listener responsible for the standard result output.
-  TestEventListener* default_result_printer_;
-  // Listener responsible for the creation of the XML output file.
-  TestEventListener* default_xml_generator_;
-
-  // We disallow copying TestEventListeners.
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventListeners);
-};
-
-// A UnitTest consists of a vector of TestCases.
-//
-// This is a singleton class.  The only instance of UnitTest is
-// created when UnitTest::GetInstance() is first called.  This
-// instance is never deleted.
-//
-// UnitTest is not copyable.
-//
-// This class is thread-safe as long as the methods are called
-// according to their specification.
-class GTEST_API_ UnitTest {
- public:
-  // Gets the singleton UnitTest object.  The first time this method
-  // is called, a UnitTest object is constructed and returned.
-  // Consecutive calls will return the same object.
-  static UnitTest* GetInstance();
-
-  // Runs all tests in this UnitTest object and prints the result.
-  // Returns 0 if successful, or 1 otherwise.
-  //
-  // This method can only be called from the main thread.
-  //
-  // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
-  int Run() GTEST_MUST_USE_RESULT_;
-
-  // Returns the working directory when the first TEST() or TEST_F()
-  // was executed.  The UnitTest object owns the string.
-  const char* original_working_dir() const;
-
-  // Returns the TestCase object for the test that's currently running,
-  // or NULL if no test is running.
-  const TestCase* current_test_case() const;
-
-  // Returns the TestInfo object for the test that's currently running,
-  // or NULL if no test is running.
-  const TestInfo* current_test_info() const;
-
-  // Returns the random seed used at the start of the current test run.
-  int random_seed() const;
-
-#if GTEST_HAS_PARAM_TEST
-  // Returns the ParameterizedTestCaseRegistry object used to keep track of
-  // value-parameterized tests and instantiate and register them.
-  //
-  // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
-  internal::ParameterizedTestCaseRegistry& parameterized_test_registry();
-#endif  // GTEST_HAS_PARAM_TEST
-
-  // Gets the number of successful test cases.
-  int successful_test_case_count() const;
-
-  // Gets the number of failed test cases.
-  int failed_test_case_count() const;
-
-  // Gets the number of all test cases.
-  int total_test_case_count() const;
-
-  // Gets the number of all test cases that contain at least one test
-  // that should run.
-  int test_case_to_run_count() const;
-
-  // Gets the number of successful tests.
-  int successful_test_count() const;
-
-  // Gets the number of failed tests.
-  int failed_test_count() const;
-
-  // Gets the number of disabled tests.
-  int disabled_test_count() const;
-
-  // Gets the number of all tests.
-  int total_test_count() const;
-
-  // Gets the number of tests that should run.
-  int test_to_run_count() const;
-
-  // Gets the elapsed time, in milliseconds.
-  TimeInMillis elapsed_time() const;
-
-  // Returns true iff the unit test passed (i.e. all test cases passed).
-  bool Passed() const;
-
-  // Returns true iff the unit test failed (i.e. some test case failed
-  // or something outside of all tests failed).
-  bool Failed() const;
-
-  // Gets the i-th test case among all the test cases. i can range from 0 to
-  // total_test_case_count() - 1. If i is not in that range, returns NULL.
-  const TestCase* GetTestCase(int i) const;
-
-  // Returns the list of event listeners that can be used to track events
-  // inside Google Test.
-  TestEventListeners& listeners();
-
- private:
-  // Registers and returns a global test environment.  When a test
-  // program is run, all global test environments will be set-up in
-  // the order they were registered.  After all tests in the program
-  // have finished, all global test environments will be torn-down in
-  // the *reverse* order they were registered.
-  //
-  // The UnitTest object takes ownership of the given environment.
-  //
-  // This method can only be called from the main thread.
-  Environment* AddEnvironment(Environment* env);
-
-  // Adds a TestPartResult to the current TestResult object.  All
-  // Google Test assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc)
-  // eventually call this to report their results.  The user code
-  // should use the assertion macros instead of calling this directly.
-  void AddTestPartResult(TestPartResult::Type result_type,
-                         const char* file_name,
-                         int line_number,
-                         const internal::String& message,
-                         const internal::String& os_stack_trace);
-
-  // Adds a TestProperty to the current TestResult object. If the result already
-  // contains a property with the same key, the value will be updated.
-  void RecordPropertyForCurrentTest(const char* key, const char* value);
-
-  // Gets the i-th test case among all the test cases. i can range from 0 to
-  // total_test_case_count() - 1. If i is not in that range, returns NULL.
-  TestCase* GetMutableTestCase(int i);
-
-  // Accessors for the implementation object.
-  internal::UnitTestImpl* impl() { return impl_; }
-  const internal::UnitTestImpl* impl() const { return impl_; }
-
-  // These classes and funcions are friends as they need to access private
-  // members of UnitTest.
-  friend class Test;
-  friend class internal::AssertHelper;
-  friend class internal::ScopedTrace;
-  friend Environment* AddGlobalTestEnvironment(Environment* env);
-  friend internal::UnitTestImpl* internal::GetUnitTestImpl();
-  friend void internal::ReportFailureInUnknownLocation(
-      TestPartResult::Type result_type,
-      const internal::String& message);
-
-  // Creates an empty UnitTest.
-  UnitTest();
-
-  // D'tor
-  virtual ~UnitTest();
-
-  // Pushes a trace defined by SCOPED_TRACE() on to the per-thread
-  // Google Test trace stack.
-  void PushGTestTrace(const internal::TraceInfo& trace);
-
-  // Pops a trace from the per-thread Google Test trace stack.
-  void PopGTestTrace();
-
-  // Protects mutable state in *impl_.  This is mutable as some const
-  // methods need to lock it too.
-  mutable internal::Mutex mutex_;
-
-  // Opaque implementation object.  This field is never changed once
-  // the object is constructed.  We don't mark it as const here, as
-  // doing so will cause a warning in the constructor of UnitTest.
-  // Mutable state in *impl_ is protected by mutex_.
-  internal::UnitTestImpl* impl_;
-
-  // We disallow copying UnitTest.
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTest);
-};
-
-// A convenient wrapper for adding an environment for the test
-// program.
-//
-// You should call this before RUN_ALL_TESTS() is called, probably in
-// main().  If you use gtest_main, you need to call this before main()
-// starts for it to take effect.  For example, you can define a global
-// variable like this:
-//
-//   testing::Environment* const foo_env =
-//       testing::AddGlobalTestEnvironment(new FooEnvironment);
-//
-// However, we strongly recommend you to write your own main() and
-// call AddGlobalTestEnvironment() there, as relying on initialization
-// of global variables makes the code harder to read and may cause
-// problems when you register multiple environments from different
-// translation units and the environments have dependencies among them
-// (remember that the compiler doesn't guarantee the order in which
-// global variables from different translation units are initialized).
-inline Environment* AddGlobalTestEnvironment(Environment* env) {
-  return UnitTest::GetInstance()->AddEnvironment(env);
-}
-
-// Initializes Google Test.  This must be called before calling
-// RUN_ALL_TESTS().  In particular, it parses a command line for the
-// flags that Google Test recognizes.  Whenever a Google Test flag is
-// seen, it is removed from argv, and *argc is decremented.
-//
-// No value is returned.  Instead, the Google Test flag variables are
-// updated.
-//
-// Calling the function for the second time has no user-visible effect.
-GTEST_API_ void InitGoogleTest(int* argc, char** argv);
-
-// This overloaded version can be used in Windows programs compiled in
-// UNICODE mode.
-GTEST_API_ void InitGoogleTest(int* argc, wchar_t** argv);
-
-namespace internal {
-
-// Formats a comparison assertion (e.g. ASSERT_EQ, EXPECT_LT, and etc)
-// operand to be used in a failure message.  The type (but not value)
-// of the other operand may affect the format.  This allows us to
-// print a char* as a raw pointer when it is compared against another
-// char*, and print it as a C string when it is compared against an
-// std::string object, for example.
-//
-// The default implementation ignores the type of the other operand.
-// Some specialized versions are used to handle formatting wide or
-// narrow C strings.
-//
-// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
-template <typename T1, typename T2>
-String FormatForComparisonFailureMessage(const T1& value,
-                                         const T2& /* other_operand */) {
-  // C++Builder compiles this incorrectly if the namespace isn't explicitly
-  // given.
-  return ::testing::PrintToString(value);
-}
-
-// The helper function for {ASSERT|EXPECT}_EQ.
-template <typename T1, typename T2>
-AssertionResult CmpHelperEQ(const char* expected_expression,
-                            const char* actual_expression,
-                            const T1& expected,
-                            const T2& actual) {
-#ifdef _MSC_VER
-# pragma warning(push)          // Saves the current warning state.
-# pragma warning(disable:4389)  // Temporarily disables warning on
-                               // signed/unsigned mismatch.
-#endif
-
-  if (expected == actual) {
-    return AssertionSuccess();
-  }
-
-#ifdef _MSC_VER
-# pragma warning(pop)          // Restores the warning state.
-#endif
-
-  return EqFailure(expected_expression,
-                   actual_expression,
-                   FormatForComparisonFailureMessage(expected, actual),
-                   FormatForComparisonFailureMessage(actual, expected),
-                   false);
-}
-
-// With this overloaded version, we allow anonymous enums to be used
-// in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous enums
-// can be implicitly cast to BiggestInt.
-GTEST_API_ AssertionResult CmpHelperEQ(const char* expected_expression,
-                                       const char* actual_expression,
-                                       BiggestInt expected,
-                                       BiggestInt actual);
-
-// The helper class for {ASSERT|EXPECT}_EQ.  The template argument
-// lhs_is_null_literal is true iff the first argument to ASSERT_EQ()
-// is a null pointer literal.  The following default implementation is
-// for lhs_is_null_literal being false.
-template <bool lhs_is_null_literal>
-class EqHelper {
- public:
-  // This templatized version is for the general case.
-  template <typename T1, typename T2>
-  static AssertionResult Compare(const char* expected_expression,
-                                 const char* actual_expression,
-                                 const T1& expected,
-                                 const T2& actual) {
-    return CmpHelperEQ(expected_expression, actual_expression, expected,
-                       actual);
-  }
-
-  // With this overloaded version, we allow anonymous enums to be used
-  // in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous
-  // enums can be implicitly cast to BiggestInt.
-  //
-  // Even though its body looks the same as the above version, we
-  // cannot merge the two, as it will make anonymous enums unhappy.
-  static AssertionResult Compare(const char* expected_expression,
-                                 const char* actual_expression,
-                                 BiggestInt expected,
-                                 BiggestInt actual) {
-    return CmpHelperEQ(expected_expression, actual_expression, expected,
-                       actual);
-  }
-};
-
-// This specialization is used when the first argument to ASSERT_EQ()
-// is a null pointer literal, like NULL, false, or 0.
-template <>
-class EqHelper<true> {
- public:
-  // We define two overloaded versions of Compare().  The first
-  // version will be picked when the second argument to ASSERT_EQ() is
-  // NOT a pointer, e.g. ASSERT_EQ(0, AnIntFunction()) or
-  // EXPECT_EQ(false, a_bool).
-  template <typename T1, typename T2>
-  static AssertionResult Compare(
-      const char* expected_expression,
-      const char* actual_expression,
-      const T1& expected,
-      const T2& actual,
-      // The following line prevents this overload from being considered if T2
-      // is not a pointer type.  We need this because ASSERT_EQ(NULL, my_ptr)
-      // expands to Compare("", "", NULL, my_ptr), which requires a conversion
-      // to match the Secret* in the other overload, which would otherwise make
-      // this template match better.
-      typename EnableIf<!is_pointer<T2>::value>::type* = 0) {
-    return CmpHelperEQ(expected_expression, actual_expression, expected,
-                       actual);
-  }
-
-  // This version will be picked when the second argument to ASSERT_EQ() is a
-  // pointer, e.g. ASSERT_EQ(NULL, a_pointer).
-  template <typename T>
-  static AssertionResult Compare(
-      const char* expected_expression,
-      const char* actual_expression,
-      // We used to have a second template parameter instead of Secret*.  That
-      // template parameter would deduce to 'long', making this a better match
-      // than the first overload even without the first overload's EnableIf.
-      // Unfortunately, gcc with -Wconversion-null warns when "passing NULL to
-      // non-pointer argument" (even a deduced integral argument), so the old
-      // implementation caused warnings in user code.
-      Secret* /* expected (NULL) */,
-      T* actual) {
-    // We already know that 'expected' is a null pointer.
-    return CmpHelperEQ(expected_expression, actual_expression,
-                       static_cast<T*>(NULL), actual);
-  }
-};
-
-// A macro for implementing the helper functions needed to implement
-// ASSERT_?? and EXPECT_??.  It is here just to avoid copy-and-paste
-// of similar code.
-//
-// For each templatized helper function, we also define an overloaded
-// version for BiggestInt in order to reduce code bloat and allow
-// anonymous enums to be used with {ASSERT|EXPECT}_?? when compiled
-// with gcc 4.
-//
-// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
-#define GTEST_IMPL_CMP_HELPER_(op_name, op)\
-template <typename T1, typename T2>\
-AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
-                                   const T1& val1, const T2& val2) {\
-  if (val1 op val2) {\
-    return AssertionSuccess();\
-  } else {\
-    return AssertionFailure() \
-        << "Expected: (" << expr1 << ") " #op " (" << expr2\
-        << "), actual: " << FormatForComparisonFailureMessage(val1, val2)\
-        << " vs " << FormatForComparisonFailureMessage(val2, val1);\
-  }\
-}\
-GTEST_API_ AssertionResult CmpHelper##op_name(\
-    const char* expr1, const char* expr2, BiggestInt val1, BiggestInt val2)
-
-// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
-
-// Implements the helper function for {ASSERT|EXPECT}_NE
-GTEST_IMPL_CMP_HELPER_(NE, !=);
-// Implements the helper function for {ASSERT|EXPECT}_LE
-GTEST_IMPL_CMP_HELPER_(LE, <=);
-// Implements the helper function for {ASSERT|EXPECT}_LT
-GTEST_IMPL_CMP_HELPER_(LT, < );
-// Implements the helper function for {ASSERT|EXPECT}_GE
-GTEST_IMPL_CMP_HELPER_(GE, >=);
-// Implements the helper function for {ASSERT|EXPECT}_GT
-GTEST_IMPL_CMP_HELPER_(GT, > );
-
-#undef GTEST_IMPL_CMP_HELPER_
-
-// The helper function for {ASSERT|EXPECT}_STREQ.
-//
-// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
-GTEST_API_ AssertionResult CmpHelperSTREQ(const char* expected_expression,
-                                          const char* actual_expression,
-                                          const char* expected,
-                                          const char* actual);
-
-// The helper function for {ASSERT|EXPECT}_STRCASEEQ.
-//
-// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
-GTEST_API_ AssertionResult CmpHelperSTRCASEEQ(const char* expected_expression,
-                                              const char* actual_expression,
-                                              const char* expected,
-                                              const char* actual);
-
-// The helper function for {ASSERT|EXPECT}_STRNE.
-//
-// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
-GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,
-                                          const char* s2_expression,
-                                          const char* s1,
-                                          const char* s2);
-
-// The helper function for {ASSERT|EXPECT}_STRCASENE.
-//
-// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
-GTEST_API_ AssertionResult CmpHelperSTRCASENE(const char* s1_expression,
-                                              const char* s2_expression,
-                                              const char* s1,
-                                              const char* s2);
-
-
-// Helper function for *_STREQ on wide strings.
-//
-// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
-GTEST_API_ AssertionResult CmpHelperSTREQ(const char* expected_expression,
-                                          const char* actual_expression,
-                                          const wchar_t* expected,
-                                          const wchar_t* actual);
-
-// Helper function for *_STRNE on wide strings.
-//
-// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
-GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,
-                                          const char* s2_expression,
-                                          const wchar_t* s1,
-                                          const wchar_t* s2);
-
-}  // namespace internal
-
-// IsSubstring() and IsNotSubstring() are intended to be used as the
-// first argument to {EXPECT,ASSERT}_PRED_FORMAT2(), not by
-// themselves.  They check whether needle is a substring of haystack
-// (NULL is considered a substring of itself only), and return an
-// appropriate error message when they fail.
-//
-// The {needle,haystack}_expr arguments are the stringified
-// expressions that generated the two real arguments.
-GTEST_API_ AssertionResult IsSubstring(
-    const char* needle_expr, const char* haystack_expr,
-    const char* needle, const char* haystack);
-GTEST_API_ AssertionResult IsSubstring(
-    const char* needle_expr, const char* haystack_expr,
-    const wchar_t* needle, const wchar_t* haystack);
-GTEST_API_ AssertionResult IsNotSubstring(
-    const char* needle_expr, const char* haystack_expr,
-    const char* needle, const char* haystack);
-GTEST_API_ AssertionResult IsNotSubstring(
-    const char* needle_expr, const char* haystack_expr,
-    const wchar_t* needle, const wchar_t* haystack);
-GTEST_API_ AssertionResult IsSubstring(
-    const char* needle_expr, const char* haystack_expr,
-    const ::std::string& needle, const ::std::string& haystack);
-GTEST_API_ AssertionResult IsNotSubstring(
-    const char* needle_expr, const char* haystack_expr,
-    const ::std::string& needle, const ::std::string& haystack);
-
-#if GTEST_HAS_STD_WSTRING
-GTEST_API_ AssertionResult IsSubstring(
-    const char* needle_expr, const char* haystack_expr,
-    const ::std::wstring& needle, const ::std::wstring& haystack);
-GTEST_API_ AssertionResult IsNotSubstring(
-    const char* needle_expr, const char* haystack_expr,
-    const ::std::wstring& needle, const ::std::wstring& haystack);
-#endif  // GTEST_HAS_STD_WSTRING
-
-namespace internal {
-
-// Helper template function for comparing floating-points.
-//
-// Template parameter:
-//
-//   RawType: the raw floating-point type (either float or double)
-//
-// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
-template <typename RawType>
-AssertionResult CmpHelperFloatingPointEQ(const char* expected_expression,
-                                         const char* actual_expression,
-                                         RawType expected,
-                                         RawType actual) {
-  const FloatingPoint<RawType> lhs(expected), rhs(actual);
-
-  if (lhs.AlmostEquals(rhs)) {
-    return AssertionSuccess();
-  }
-
-  ::std::stringstream expected_ss;
-  expected_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
-              << expected;
-
-  ::std::stringstream actual_ss;
-  actual_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
-            << actual;
-
-  return EqFailure(expected_expression,
-                   actual_expression,
-                   StringStreamToString(&expected_ss),
-                   StringStreamToString(&actual_ss),
-                   false);
-}
-
-// Helper function for implementing ASSERT_NEAR.
-//
-// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
-GTEST_API_ AssertionResult DoubleNearPredFormat(const char* expr1,
-                                                const char* expr2,
-                                                const char* abs_error_expr,
-                                                double val1,
-                                                double val2,
-                                                double abs_error);
-
-// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
-// A class that enables one to stream messages to assertion macros
-class GTEST_API_ AssertHelper {
- public:
-  // Constructor.
-  AssertHelper(TestPartResult::Type type,
-               const char* file,
-               int line,
-               const char* message);
-  ~AssertHelper();
-
-  // Message assignment is a semantic trick to enable assertion
-  // streaming; see the GTEST_MESSAGE_ macro below.
-  void operator=(const Message& message) const;
-
- private:
-  // We put our data in a struct so that the size of the AssertHelper class can
-  // be as small as possible.  This is important because gcc is incapable of
-  // re-using stack space even for temporary variables, so every EXPECT_EQ
-  // reserves stack space for another AssertHelper.
-  struct AssertHelperData {
-    AssertHelperData(TestPartResult::Type t,
-                     const char* srcfile,
-                     int line_num,
-                     const char* msg)
-        : type(t), file(srcfile), line(line_num), message(msg) { }
-
-    TestPartResult::Type const type;
-    const char*        const file;
-    int                const line;
-    String             const message;
-
-   private:
-    GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelperData);
-  };
-
-  AssertHelperData* const data_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelper);
-};
-
-}  // namespace internal
-
-#if GTEST_HAS_PARAM_TEST
-// The pure interface class that all value-parameterized tests inherit from.
-// A value-parameterized class must inherit from both ::testing::Test and
-// ::testing::WithParamInterface. In most cases that just means inheriting
-// from ::testing::TestWithParam, but more complicated test hierarchies
-// may need to inherit from Test and WithParamInterface at different levels.
-//
-// This interface has support for accessing the test parameter value via
-// the GetParam() method.
-//
-// Use it with one of the parameter generator defining functions, like Range(),
-// Values(), ValuesIn(), Bool(), and Combine().
-//
-// class FooTest : public ::testing::TestWithParam<int> {
-//  protected:
-//   FooTest() {
-//     // Can use GetParam() here.
-//   }
-//   virtual ~FooTest() {
-//     // Can use GetParam() here.
-//   }
-//   virtual void SetUp() {
-//     // Can use GetParam() here.
-//   }
-//   virtual void TearDown {
-//     // Can use GetParam() here.
-//   }
-// };
-// TEST_P(FooTest, DoesBar) {
-//   // Can use GetParam() method here.
-//   Foo foo;
-//   ASSERT_TRUE(foo.DoesBar(GetParam()));
-// }
-// INSTANTIATE_TEST_CASE_P(OneToTenRange, FooTest, ::testing::Range(1, 10));
-
-template <typename T>
-class WithParamInterface {
- public:
-  typedef T ParamType;
-  virtual ~WithParamInterface() {}
-
-  // The current parameter value. Is also available in the test fixture's
-  // constructor. This member function is non-static, even though it only
-  // references static data, to reduce the opportunity for incorrect uses
-  // like writing 'WithParamInterface<bool>::GetParam()' for a test that
-  // uses a fixture whose parameter type is int.
-  const ParamType& GetParam() const { return *parameter_; }
-
- private:
-  // Sets parameter value. The caller is responsible for making sure the value
-  // remains alive and unchanged throughout the current test.
-  static void SetParam(const ParamType* parameter) {
-    parameter_ = parameter;
-  }
-
-  // Static value used for accessing parameter during a test lifetime.
-  static const ParamType* parameter_;
-
-  // TestClass must be a subclass of WithParamInterface<T> and Test.
-  template <class TestClass> friend class internal::ParameterizedTestFactory;
-};
-
-template <typename T>
-const T* WithParamInterface<T>::parameter_ = NULL;
-
-// Most value-parameterized classes can ignore the existence of
-// WithParamInterface, and can just inherit from ::testing::TestWithParam.
-
-template <typename T>
-class TestWithParam : public Test, public WithParamInterface<T> {
-};
-
-#endif  // GTEST_HAS_PARAM_TEST
-
-// Macros for indicating success/failure in test code.
-
-// ADD_FAILURE unconditionally adds a failure to the current test.
-// SUCCEED generates a success - it doesn't automatically make the
-// current test successful, as a test is only successful when it has
-// no failure.
-//
-// EXPECT_* verifies that a certain condition is satisfied.  If not,
-// it behaves like ADD_FAILURE.  In particular:
-//
-//   EXPECT_TRUE  verifies that a Boolean condition is true.
-//   EXPECT_FALSE verifies that a Boolean condition is false.
-//
-// FAIL and ASSERT_* are similar to ADD_FAILURE and EXPECT_*, except
-// that they will also abort the current function on failure.  People
-// usually want the fail-fast behavior of FAIL and ASSERT_*, but those
-// writing data-driven tests often find themselves using ADD_FAILURE
-// and EXPECT_* more.
-//
-// Examples:
-//
-//   EXPECT_TRUE(server.StatusIsOK());
-//   ASSERT_FALSE(server.HasPendingRequest(port))
-//       << "There are still pending requests " << "on port " << port;
-
-// Generates a nonfatal failure with a generic message.
-#define ADD_FAILURE() GTEST_NONFATAL_FAILURE_("Failed")
-
-// Generates a nonfatal failure at the given source file location with
-// a generic message.
-#define ADD_FAILURE_AT(file, line) \
-  GTEST_MESSAGE_AT_(file, line, "Failed", \
-                    ::testing::TestPartResult::kNonFatalFailure)
-
-// Generates a fatal failure with a generic message.
-#define GTEST_FAIL() GTEST_FATAL_FAILURE_("Failed")
-
-// Define this macro to 1 to omit the definition of FAIL(), which is a
-// generic name and clashes with some other libraries.
-#if !GTEST_DONT_DEFINE_FAIL
-# define FAIL() GTEST_FAIL()
-#endif
-
-// Generates a success with a generic message.
-#define GTEST_SUCCEED() GTEST_SUCCESS_("Succeeded")
-
-// Define this macro to 1 to omit the definition of SUCCEED(), which
-// is a generic name and clashes with some other libraries.
-#if !GTEST_DONT_DEFINE_SUCCEED
-# define SUCCEED() GTEST_SUCCEED()
-#endif
-
-// Macros for testing exceptions.
-//
-//    * {ASSERT|EXPECT}_THROW(statement, expected_exception):
-//         Tests that the statement throws the expected exception.
-//    * {ASSERT|EXPECT}_NO_THROW(statement):
-//         Tests that the statement doesn't throw any exception.
-//    * {ASSERT|EXPECT}_ANY_THROW(statement):
-//         Tests that the statement throws an exception.
-
-#define EXPECT_THROW(statement, expected_exception) \
-  GTEST_TEST_THROW_(statement, expected_exception, GTEST_NONFATAL_FAILURE_)
-#define EXPECT_NO_THROW(statement) \
-  GTEST_TEST_NO_THROW_(statement, GTEST_NONFATAL_FAILURE_)
-#define EXPECT_ANY_THROW(statement) \
-  GTEST_TEST_ANY_THROW_(statement, GTEST_NONFATAL_FAILURE_)
-#define ASSERT_THROW(statement, expected_exception) \
-  GTEST_TEST_THROW_(statement, expected_exception, GTEST_FATAL_FAILURE_)
-#define ASSERT_NO_THROW(statement) \
-  GTEST_TEST_NO_THROW_(statement, GTEST_FATAL_FAILURE_)
-#define ASSERT_ANY_THROW(statement) \
-  GTEST_TEST_ANY_THROW_(statement, GTEST_FATAL_FAILURE_)
-
-// Boolean assertions. Condition can be either a Boolean expression or an
-// AssertionResult. For more information on how to use AssertionResult with
-// these macros see comments on that class.
-#define EXPECT_TRUE(condition) \
-  GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
-                      GTEST_NONFATAL_FAILURE_)
-#define EXPECT_FALSE(condition) \
-  GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
-                      GTEST_NONFATAL_FAILURE_)
-#define ASSERT_TRUE(condition) \
-  GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
-                      GTEST_FATAL_FAILURE_)
-#define ASSERT_FALSE(condition) \
-  GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
-                      GTEST_FATAL_FAILURE_)
-
-// Includes the auto-generated header that implements a family of
-// generic predicate assertion macros.
-// Copyright 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// This file is AUTOMATICALLY GENERATED on 09/24/2010 by command
-// 'gen_gtest_pred_impl.py 5'.  DO NOT EDIT BY HAND!
-//
-// Implements a family of generic predicate assertion macros.
-
-#ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
-#define GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
-
-// Makes sure this header is not included before gtest.h.
-#ifndef GTEST_INCLUDE_GTEST_GTEST_H_
-# error Do not include gtest_pred_impl.h directly.  Include gtest.h instead.
-#endif  // GTEST_INCLUDE_GTEST_GTEST_H_
-
-// This header implements a family of generic predicate assertion
-// macros:
-//
-//   ASSERT_PRED_FORMAT1(pred_format, v1)
-//   ASSERT_PRED_FORMAT2(pred_format, v1, v2)
-//   ...
-//
-// where pred_format is a function or functor that takes n (in the
-// case of ASSERT_PRED_FORMATn) values and their source expression
-// text, and returns a testing::AssertionResult.  See the definition
-// of ASSERT_EQ in gtest.h for an example.
-//
-// If you don't care about formatting, you can use the more
-// restrictive version:
-//
-//   ASSERT_PRED1(pred, v1)
-//   ASSERT_PRED2(pred, v1, v2)
-//   ...
-//
-// where pred is an n-ary function or functor that returns bool,
-// and the values v1, v2, ..., must support the << operator for
-// streaming to std::ostream.
-//
-// We also define the EXPECT_* variations.
-//
-// For now we only support predicates whose arity is at most 5.
-// Please email googletestframework at googlegroups.com if you need
-// support for higher arities.
-
-// GTEST_ASSERT_ is the basic statement to which all of the assertions
-// in this file reduce.  Don't use this in your code.
-
-#define GTEST_ASSERT_(expression, on_failure) \
-  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
-  if (const ::testing::AssertionResult gtest_ar = (expression)) \
-    ; \
-  else \
-    on_failure(gtest_ar.failure_message())
-
-
-// Helper function for implementing {EXPECT|ASSERT}_PRED1.  Don't use
-// this in your code.
-template <typename Pred,
-          typename T1>
-AssertionResult AssertPred1Helper(const char* pred_text,
-                                  const char* e1,
-                                  Pred pred,
-                                  const T1& v1) {
-  if (pred(v1)) return AssertionSuccess();
-
-  return AssertionFailure() << pred_text << "("
-                            << e1 << ") evaluates to false, where"
-                            << "\n" << e1 << " evaluates to " << v1;
-}
-
-// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT1.
-// Don't use this in your code.
-#define GTEST_PRED_FORMAT1_(pred_format, v1, on_failure)\
-  GTEST_ASSERT_(pred_format(#v1, v1),\
-                on_failure)
-
-// Internal macro for implementing {EXPECT|ASSERT}_PRED1.  Don't use
-// this in your code.
-#define GTEST_PRED1_(pred, v1, on_failure)\
-  GTEST_ASSERT_(::testing::AssertPred1Helper(#pred, \
-                                             #v1, \
-                                             pred, \
-                                             v1), on_failure)
-
-// Unary predicate assertion macros.
-#define EXPECT_PRED_FORMAT1(pred_format, v1) \
-  GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_NONFATAL_FAILURE_)
-#define EXPECT_PRED1(pred, v1) \
-  GTEST_PRED1_(pred, v1, GTEST_NONFATAL_FAILURE_)
-#define ASSERT_PRED_FORMAT1(pred_format, v1) \
-  GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_FATAL_FAILURE_)
-#define ASSERT_PRED1(pred, v1) \
-  GTEST_PRED1_(pred, v1, GTEST_FATAL_FAILURE_)
-
-
-
-// Helper function for implementing {EXPECT|ASSERT}_PRED2.  Don't use
-// this in your code.
-template <typename Pred,
-          typename T1,
-          typename T2>
-AssertionResult AssertPred2Helper(const char* pred_text,
-                                  const char* e1,
-                                  const char* e2,
-                                  Pred pred,
-                                  const T1& v1,
-                                  const T2& v2) {
-  if (pred(v1, v2)) return AssertionSuccess();
-
-  return AssertionFailure() << pred_text << "("
-                            << e1 << ", "
-                            << e2 << ") evaluates to false, where"
-                            << "\n" << e1 << " evaluates to " << v1
-                            << "\n" << e2 << " evaluates to " << v2;
-}
-
-// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT2.
-// Don't use this in your code.
-#define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure)\
-  GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2),\
-                on_failure)
-
-// Internal macro for implementing {EXPECT|ASSERT}_PRED2.  Don't use
-// this in your code.
-#define GTEST_PRED2_(pred, v1, v2, on_failure)\
-  GTEST_ASSERT_(::testing::AssertPred2Helper(#pred, \
-                                             #v1, \
-                                             #v2, \
-                                             pred, \
-                                             v1, \
-                                             v2), on_failure)
-
-// Binary predicate assertion macros.
-#define EXPECT_PRED_FORMAT2(pred_format, v1, v2) \
-  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
-#define EXPECT_PRED2(pred, v1, v2) \
-  GTEST_PRED2_(pred, v1, v2, GTEST_NONFATAL_FAILURE_)
-#define ASSERT_PRED_FORMAT2(pred_format, v1, v2) \
-  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
-#define ASSERT_PRED2(pred, v1, v2) \
-  GTEST_PRED2_(pred, v1, v2, GTEST_FATAL_FAILURE_)
-
-
-
-// Helper function for implementing {EXPECT|ASSERT}_PRED3.  Don't use
-// this in your code.
-template <typename Pred,
-          typename T1,
-          typename T2,
-          typename T3>
-AssertionResult AssertPred3Helper(const char* pred_text,
-                                  const char* e1,
-                                  const char* e2,
-                                  const char* e3,
-                                  Pred pred,
-                                  const T1& v1,
-                                  const T2& v2,
-                                  const T3& v3) {
-  if (pred(v1, v2, v3)) return AssertionSuccess();
-
-  return AssertionFailure() << pred_text << "("
-                            << e1 << ", "
-                            << e2 << ", "
-                            << e3 << ") evaluates to false, where"
-                            << "\n" << e1 << " evaluates to " << v1
-                            << "\n" << e2 << " evaluates to " << v2
-                            << "\n" << e3 << " evaluates to " << v3;
-}
-
-// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT3.
-// Don't use this in your code.
-#define GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, on_failure)\
-  GTEST_ASSERT_(pred_format(#v1, #v2, #v3, v1, v2, v3),\
-                on_failure)
-
-// Internal macro for implementing {EXPECT|ASSERT}_PRED3.  Don't use
-// this in your code.
-#define GTEST_PRED3_(pred, v1, v2, v3, on_failure)\
-  GTEST_ASSERT_(::testing::AssertPred3Helper(#pred, \
-                                             #v1, \
-                                             #v2, \
-                                             #v3, \
-                                             pred, \
-                                             v1, \
-                                             v2, \
-                                             v3), on_failure)
-
-// Ternary predicate assertion macros.
-#define EXPECT_PRED_FORMAT3(pred_format, v1, v2, v3) \
-  GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_NONFATAL_FAILURE_)
-#define EXPECT_PRED3(pred, v1, v2, v3) \
-  GTEST_PRED3_(pred, v1, v2, v3, GTEST_NONFATAL_FAILURE_)
-#define ASSERT_PRED_FORMAT3(pred_format, v1, v2, v3) \
-  GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_FATAL_FAILURE_)
-#define ASSERT_PRED3(pred, v1, v2, v3) \
-  GTEST_PRED3_(pred, v1, v2, v3, GTEST_FATAL_FAILURE_)
-
-
-
-// Helper function for implementing {EXPECT|ASSERT}_PRED4.  Don't use
-// this in your code.
-template <typename Pred,
-          typename T1,
-          typename T2,
-          typename T3,
-          typename T4>
-AssertionResult AssertPred4Helper(const char* pred_text,
-                                  const char* e1,
-                                  const char* e2,
-                                  const char* e3,
-                                  const char* e4,
-                                  Pred pred,
-                                  const T1& v1,
-                                  const T2& v2,
-                                  const T3& v3,
-                                  const T4& v4) {
-  if (pred(v1, v2, v3, v4)) return AssertionSuccess();
-
-  return AssertionFailure() << pred_text << "("
-                            << e1 << ", "
-                            << e2 << ", "
-                            << e3 << ", "
-                            << e4 << ") evaluates to false, where"
-                            << "\n" << e1 << " evaluates to " << v1
-                            << "\n" << e2 << " evaluates to " << v2
-                            << "\n" << e3 << " evaluates to " << v3
-                            << "\n" << e4 << " evaluates to " << v4;
-}
-
-// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT4.
-// Don't use this in your code.
-#define GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, on_failure)\
-  GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4),\
-                on_failure)
-
-// Internal macro for implementing {EXPECT|ASSERT}_PRED4.  Don't use
-// this in your code.
-#define GTEST_PRED4_(pred, v1, v2, v3, v4, on_failure)\
-  GTEST_ASSERT_(::testing::AssertPred4Helper(#pred, \
-                                             #v1, \
-                                             #v2, \
-                                             #v3, \
-                                             #v4, \
-                                             pred, \
-                                             v1, \
-                                             v2, \
-                                             v3, \
-                                             v4), on_failure)
-
-// 4-ary predicate assertion macros.
-#define EXPECT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
-  GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)
-#define EXPECT_PRED4(pred, v1, v2, v3, v4) \
-  GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)
-#define ASSERT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
-  GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
-#define ASSERT_PRED4(pred, v1, v2, v3, v4) \
-  GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
-
-
-
-// Helper function for implementing {EXPECT|ASSERT}_PRED5.  Don't use
-// this in your code.
-template <typename Pred,
-          typename T1,
-          typename T2,
-          typename T3,
-          typename T4,
-          typename T5>
-AssertionResult AssertPred5Helper(const char* pred_text,
-                                  const char* e1,
-                                  const char* e2,
-                                  const char* e3,
-                                  const char* e4,
-                                  const char* e5,
-                                  Pred pred,
-                                  const T1& v1,
-                                  const T2& v2,
-                                  const T3& v3,
-                                  const T4& v4,
-                                  const T5& v5) {
-  if (pred(v1, v2, v3, v4, v5)) return AssertionSuccess();
-
-  return AssertionFailure() << pred_text << "("
-                            << e1 << ", "
-                            << e2 << ", "
-                            << e3 << ", "
-                            << e4 << ", "
-                            << e5 << ") evaluates to false, where"
-                            << "\n" << e1 << " evaluates to " << v1
-                            << "\n" << e2 << " evaluates to " << v2
-                            << "\n" << e3 << " evaluates to " << v3
-                            << "\n" << e4 << " evaluates to " << v4
-                            << "\n" << e5 << " evaluates to " << v5;
-}
-
-// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT5.
-// Don't use this in your code.
-#define GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, on_failure)\
-  GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, #v5, v1, v2, v3, v4, v5),\
-                on_failure)
-
-// Internal macro for implementing {EXPECT|ASSERT}_PRED5.  Don't use
-// this in your code.
-#define GTEST_PRED5_(pred, v1, v2, v3, v4, v5, on_failure)\
-  GTEST_ASSERT_(::testing::AssertPred5Helper(#pred, \
-                                             #v1, \
-                                             #v2, \
-                                             #v3, \
-                                             #v4, \
-                                             #v5, \
-                                             pred, \
-                                             v1, \
-                                             v2, \
-                                             v3, \
-                                             v4, \
-                                             v5), on_failure)
-
-// 5-ary predicate assertion macros.
-#define EXPECT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
-  GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)
-#define EXPECT_PRED5(pred, v1, v2, v3, v4, v5) \
-  GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)
-#define ASSERT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
-  GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
-#define ASSERT_PRED5(pred, v1, v2, v3, v4, v5) \
-  GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
-
-
-
-#endif  // GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
-
-// Macros for testing equalities and inequalities.
-//
-//    * {ASSERT|EXPECT}_EQ(expected, actual): Tests that expected == actual
-//    * {ASSERT|EXPECT}_NE(v1, v2):           Tests that v1 != v2
-//    * {ASSERT|EXPECT}_LT(v1, v2):           Tests that v1 < v2
-//    * {ASSERT|EXPECT}_LE(v1, v2):           Tests that v1 <= v2
-//    * {ASSERT|EXPECT}_GT(v1, v2):           Tests that v1 > v2
-//    * {ASSERT|EXPECT}_GE(v1, v2):           Tests that v1 >= v2
-//
-// When they are not, Google Test prints both the tested expressions and
-// their actual values.  The values must be compatible built-in types,
-// or you will get a compiler error.  By "compatible" we mean that the
-// values can be compared by the respective operator.
-//
-// Note:
-//
-//   1. It is possible to make a user-defined type work with
-//   {ASSERT|EXPECT}_??(), but that requires overloading the
-//   comparison operators and is thus discouraged by the Google C++
-//   Usage Guide.  Therefore, you are advised to use the
-//   {ASSERT|EXPECT}_TRUE() macro to assert that two objects are
-//   equal.
-//
-//   2. The {ASSERT|EXPECT}_??() macros do pointer comparisons on
-//   pointers (in particular, C strings).  Therefore, if you use it
-//   with two C strings, you are testing how their locations in memory
-//   are related, not how their content is related.  To compare two C
-//   strings by content, use {ASSERT|EXPECT}_STR*().
-//
-//   3. {ASSERT|EXPECT}_EQ(expected, actual) is preferred to
-//   {ASSERT|EXPECT}_TRUE(expected == actual), as the former tells you
-//   what the actual value is when it fails, and similarly for the
-//   other comparisons.
-//
-//   4. Do not depend on the order in which {ASSERT|EXPECT}_??()
-//   evaluate their arguments, which is undefined.
-//
-//   5. These macros evaluate their arguments exactly once.
-//
-// Examples:
-//
-//   EXPECT_NE(5, Foo());
-//   EXPECT_EQ(NULL, a_pointer);
-//   ASSERT_LT(i, array_size);
-//   ASSERT_GT(records.size(), 0) << "There is no record left.";
-
-#define EXPECT_EQ(expected, actual) \
-  EXPECT_PRED_FORMAT2(::testing::internal:: \
-                      EqHelper<GTEST_IS_NULL_LITERAL_(expected)>::Compare, \
-                      expected, actual)
-#define EXPECT_NE(expected, actual) \
-  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNE, expected, actual)
-#define EXPECT_LE(val1, val2) \
-  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)
-#define EXPECT_LT(val1, val2) \
-  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)
-#define EXPECT_GE(val1, val2) \
-  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)
-#define EXPECT_GT(val1, val2) \
-  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)
-
-#define GTEST_ASSERT_EQ(expected, actual) \
-  ASSERT_PRED_FORMAT2(::testing::internal:: \
-                      EqHelper<GTEST_IS_NULL_LITERAL_(expected)>::Compare, \
-                      expected, actual)
-#define GTEST_ASSERT_NE(val1, val2) \
-  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
-#define GTEST_ASSERT_LE(val1, val2) \
-  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)
-#define GTEST_ASSERT_LT(val1, val2) \
-  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)
-#define GTEST_ASSERT_GE(val1, val2) \
-  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)
-#define GTEST_ASSERT_GT(val1, val2) \
-  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)
-
-// Define macro GTEST_DONT_DEFINE_ASSERT_XY to 1 to omit the definition of
-// ASSERT_XY(), which clashes with some users' own code.
-
-#if !GTEST_DONT_DEFINE_ASSERT_EQ
-# define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
-#endif
-
-#if !GTEST_DONT_DEFINE_ASSERT_NE
-# define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)
-#endif
-
-#if !GTEST_DONT_DEFINE_ASSERT_LE
-# define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2)
-#endif
-
-#if !GTEST_DONT_DEFINE_ASSERT_LT
-# define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2)
-#endif
-
-#if !GTEST_DONT_DEFINE_ASSERT_GE
-# define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2)
-#endif
-
-#if !GTEST_DONT_DEFINE_ASSERT_GT
-# define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2)
-#endif
-
-// C String Comparisons.  All tests treat NULL and any non-NULL string
-// as different.  Two NULLs are equal.
-//
-//    * {ASSERT|EXPECT}_STREQ(s1, s2):     Tests that s1 == s2
-//    * {ASSERT|EXPECT}_STRNE(s1, s2):     Tests that s1 != s2
-//    * {ASSERT|EXPECT}_STRCASEEQ(s1, s2): Tests that s1 == s2, ignoring case
-//    * {ASSERT|EXPECT}_STRCASENE(s1, s2): Tests that s1 != s2, ignoring case
-//
-// For wide or narrow string objects, you can use the
-// {ASSERT|EXPECT}_??() macros.
-//
-// Don't depend on the order in which the arguments are evaluated,
-// which is undefined.
-//
-// These macros evaluate their arguments exactly once.
-
-#define EXPECT_STREQ(expected, actual) \
-  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, expected, actual)
-#define EXPECT_STRNE(s1, s2) \
-  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)
-#define EXPECT_STRCASEEQ(expected, actual) \
-  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, expected, actual)
-#define EXPECT_STRCASENE(s1, s2)\
-  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)
-
-#define ASSERT_STREQ(expected, actual) \
-  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, expected, actual)
-#define ASSERT_STRNE(s1, s2) \
-  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)
-#define ASSERT_STRCASEEQ(expected, actual) \
-  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, expected, actual)
-#define ASSERT_STRCASENE(s1, s2)\
-  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)
-
-// Macros for comparing floating-point numbers.
-//
-//    * {ASSERT|EXPECT}_FLOAT_EQ(expected, actual):
-//         Tests that two float values are almost equal.
-//    * {ASSERT|EXPECT}_DOUBLE_EQ(expected, actual):
-//         Tests that two double values are almost equal.
-//    * {ASSERT|EXPECT}_NEAR(v1, v2, abs_error):
-//         Tests that v1 and v2 are within the given distance to each other.
-//
-// Google Test uses ULP-based comparison to automatically pick a default
-// error bound that is appropriate for the operands.  See the
-// FloatingPoint template class in gtest-internal.h if you are
-// interested in the implementation details.
-
-#define EXPECT_FLOAT_EQ(expected, actual)\
-  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \
-                      expected, actual)
-
-#define EXPECT_DOUBLE_EQ(expected, actual)\
-  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \
-                      expected, actual)
-
-#define ASSERT_FLOAT_EQ(expected, actual)\
-  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \
-                      expected, actual)
-
-#define ASSERT_DOUBLE_EQ(expected, actual)\
-  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \
-                      expected, actual)
-
-#define EXPECT_NEAR(val1, val2, abs_error)\
-  EXPECT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \
-                      val1, val2, abs_error)
-
-#define ASSERT_NEAR(val1, val2, abs_error)\
-  ASSERT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \
-                      val1, val2, abs_error)
-
-// These predicate format functions work on floating-point values, and
-// can be used in {ASSERT|EXPECT}_PRED_FORMAT2*(), e.g.
-//
-//   EXPECT_PRED_FORMAT2(testing::DoubleLE, Foo(), 5.0);
-
-// Asserts that val1 is less than, or almost equal to, val2.  Fails
-// otherwise.  In particular, it fails if either val1 or val2 is NaN.
-GTEST_API_ AssertionResult FloatLE(const char* expr1, const char* expr2,
-                                   float val1, float val2);
-GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2,
-                                    double val1, double val2);
-
-
-#if GTEST_OS_WINDOWS
-
-// Macros that test for HRESULT failure and success, these are only useful
-// on Windows, and rely on Windows SDK macros and APIs to compile.
-//
-//    * {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}(expr)
-//
-// When expr unexpectedly fails or succeeds, Google Test prints the
-// expected result and the actual result with both a human-readable
-// string representation of the error, if available, as well as the
-// hex result code.
-# define EXPECT_HRESULT_SUCCEEDED(expr) \
-    EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))
-
-# define ASSERT_HRESULT_SUCCEEDED(expr) \
-    ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))
-
-# define EXPECT_HRESULT_FAILED(expr) \
-    EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))
-
-# define ASSERT_HRESULT_FAILED(expr) \
-    ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))
-
-#endif  // GTEST_OS_WINDOWS
-
-// Macros that execute statement and check that it doesn't generate new fatal
-// failures in the current thread.
-//
-//   * {ASSERT|EXPECT}_NO_FATAL_FAILURE(statement);
-//
-// Examples:
-//
-//   EXPECT_NO_FATAL_FAILURE(Process());
-//   ASSERT_NO_FATAL_FAILURE(Process()) << "Process() failed";
-//
-#define ASSERT_NO_FATAL_FAILURE(statement) \
-    GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_FATAL_FAILURE_)
-#define EXPECT_NO_FATAL_FAILURE(statement) \
-    GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_)
-
-// Causes a trace (including the source file path, the current line
-// number, and the given message) to be included in every test failure
-// message generated by code in the current scope.  The effect is
-// undone when the control leaves the current scope.
-//
-// The message argument can be anything streamable to std::ostream.
-//
-// In the implementation, we include the current line number as part
-// of the dummy variable name, thus allowing multiple SCOPED_TRACE()s
-// to appear in the same block - as long as they are on different
-// lines.
-#define SCOPED_TRACE(message) \
-  ::testing::internal::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\
-    __FILE__, __LINE__, ::testing::Message() << (message))
-
-// Compile-time assertion for type equality.
-// StaticAssertTypeEq<type1, type2>() compiles iff type1 and type2 are
-// the same type.  The value it returns is not interesting.
-//
-// Instead of making StaticAssertTypeEq a class template, we make it a
-// function template that invokes a helper class template.  This
-// prevents a user from misusing StaticAssertTypeEq<T1, T2> by
-// defining objects of that type.
-//
-// CAVEAT:
-//
-// When used inside a method of a class template,
-// StaticAssertTypeEq<T1, T2>() is effective ONLY IF the method is
-// instantiated.  For example, given:
-//
-//   template <typename T> class Foo {
-//    public:
-//     void Bar() { testing::StaticAssertTypeEq<int, T>(); }
-//   };
-//
-// the code:
-//
-//   void Test1() { Foo<bool> foo; }
-//
-// will NOT generate a compiler error, as Foo<bool>::Bar() is never
-// actually instantiated.  Instead, you need:
-//
-//   void Test2() { Foo<bool> foo; foo.Bar(); }
-//
-// to cause a compiler error.
-template <typename T1, typename T2>
-bool StaticAssertTypeEq() {
-  (void)internal::StaticAssertTypeEqHelper<T1, T2>();
-  return true;
-}
-
-// Defines a test.
-//
-// The first parameter is the name of the test case, and the second
-// parameter is the name of the test within the test case.
-//
-// The convention is to end the test case name with "Test".  For
-// example, a test case for the Foo class can be named FooTest.
-//
-// The user should put his test code between braces after using this
-// macro.  Example:
-//
-//   TEST(FooTest, InitializesCorrectly) {
-//     Foo foo;
-//     EXPECT_TRUE(foo.StatusIsOK());
-//   }
-
-// Note that we call GetTestTypeId() instead of GetTypeId<
-// ::testing::Test>() here to get the type ID of testing::Test.  This
-// is to work around a suspected linker bug when using Google Test as
-// a framework on Mac OS X.  The bug causes GetTypeId<
-// ::testing::Test>() to return different values depending on whether
-// the call is from the Google Test framework itself or from user test
-// code.  GetTestTypeId() is guaranteed to always return the same
-// value, as it always calls GetTypeId<>() from the Google Test
-// framework.
-#define GTEST_TEST(test_case_name, test_name)\
-  GTEST_TEST_(test_case_name, test_name, \
-              ::testing::Test, ::testing::internal::GetTestTypeId())
-
-// Define this macro to 1 to omit the definition of TEST(), which
-// is a generic name and clashes with some other libraries.
-#if !GTEST_DONT_DEFINE_TEST
-# define TEST(test_case_name, test_name) GTEST_TEST(test_case_name, test_name)
-#endif
-
-// Defines a test that uses a test fixture.
-//
-// The first parameter is the name of the test fixture class, which
-// also doubles as the test case name.  The second parameter is the
-// name of the test within the test case.
-//
-// A test fixture class must be declared earlier.  The user should put
-// his test code between braces after using this macro.  Example:
-//
-//   class FooTest : public testing::Test {
-//    protected:
-//     virtual void SetUp() { b_.AddElement(3); }
-//
-//     Foo a_;
-//     Foo b_;
-//   };
-//
-//   TEST_F(FooTest, InitializesCorrectly) {
-//     EXPECT_TRUE(a_.StatusIsOK());
-//   }
-//
-//   TEST_F(FooTest, ReturnsElementCountCorrectly) {
-//     EXPECT_EQ(0, a_.size());
-//     EXPECT_EQ(1, b_.size());
-//   }
-
-#define TEST_F(test_fixture, test_name)\
-  GTEST_TEST_(test_fixture, test_name, test_fixture, \
-              ::testing::internal::GetTypeId<test_fixture>())
-
-// Use this macro in main() to run all tests.  It returns 0 if all
-// tests are successful, or 1 otherwise.
-//
-// RUN_ALL_TESTS() should be invoked after the command line has been
-// parsed by InitGoogleTest().
-
-#define RUN_ALL_TESTS()\
-  (::testing::UnitTest::GetInstance()->Run())
-
-}  // namespace testing
-
-#endif  // GTEST_INCLUDE_GTEST_GTEST_H_
diff --git a/bamtools/src/third_party/gtest-1.6.0/fused-src/gtest/gtest_main.cc b/bamtools/src/third_party/gtest-1.6.0/fused-src/gtest/gtest_main.cc
deleted file mode 100644
index a09bbe0..0000000
--- a/bamtools/src/third_party/gtest-1.6.0/fused-src/gtest/gtest_main.cc
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#include <iostream>
-
-#include "gtest/gtest.h"
-
-GTEST_API_ int main(int argc, char **argv) {
-  std::cout << "Running main() from gtest_main.cc\n";
-
-  testing::InitGoogleTest(&argc, argv);
-  return RUN_ALL_TESTS();
-}
diff --git a/bamtools/src/third_party/gtest-1.6.0/src/gtest-all.cc b/bamtools/src/third_party/gtest-1.6.0/src/gtest-all.cc
deleted file mode 100644
index 0a9cee5..0000000
--- a/bamtools/src/third_party/gtest-1.6.0/src/gtest-all.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: mheule at google.com (Markus Heule)
-//
-// Google C++ Testing Framework (Google Test)
-//
-// Sometimes it's desirable to build Google Test by compiling a single file.
-// This file serves this purpose.
-
-// This line ensures that gtest.h can be compiled on its own, even
-// when it's fused.
-#include "gtest/gtest.h"
-
-// The following lines pull in the real gtest *.cc files.
-#include "src/gtest.cc"
-#include "src/gtest-death-test.cc"
-#include "src/gtest-filepath.cc"
-#include "src/gtest-port.cc"
-#include "src/gtest-printers.cc"
-#include "src/gtest-test-part.cc"
-#include "src/gtest-typed-test.cc"
diff --git a/bamtools/src/third_party/gtest-1.6.0/src/gtest-death-test.cc b/bamtools/src/third_party/gtest-1.6.0/src/gtest-death-test.cc
deleted file mode 100644
index 8b2e413..0000000
--- a/bamtools/src/third_party/gtest-1.6.0/src/gtest-death-test.cc
+++ /dev/null
@@ -1,1234 +0,0 @@
-// Copyright 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan at google.com (Zhanyong Wan), vladl at google.com (Vlad Losev)
-//
-// This file implements death tests.
-
-#include "gtest/gtest-death-test.h"
-#include "gtest/internal/gtest-port.h"
-
-#if GTEST_HAS_DEATH_TEST
-
-# if GTEST_OS_MAC
-#  include <crt_externs.h>
-# endif  // GTEST_OS_MAC
-
-# include <errno.h>
-# include <fcntl.h>
-# include <limits.h>
-# include <stdarg.h>
-
-# if GTEST_OS_WINDOWS
-#  include <windows.h>
-# else
-#  include <sys/mman.h>
-#  include <sys/wait.h>
-# endif  // GTEST_OS_WINDOWS
-
-#endif  // GTEST_HAS_DEATH_TEST
-
-#include "gtest/gtest-message.h"
-#include "gtest/internal/gtest-string.h"
-
-// Indicates that this translation unit is part of Google Test's
-// implementation.  It must come before gtest-internal-inl.h is
-// included, or there will be a compiler error.  This trick is to
-// prevent a user from accidentally including gtest-internal-inl.h in
-// his code.
-#define GTEST_IMPLEMENTATION_ 1
-#include "src/gtest-internal-inl.h"
-#undef GTEST_IMPLEMENTATION_
-
-namespace testing {
-
-// Constants.
-
-// The default death test style.
-static const char kDefaultDeathTestStyle[] = "fast";
-
-GTEST_DEFINE_string_(
-    death_test_style,
-    internal::StringFromGTestEnv("death_test_style", kDefaultDeathTestStyle),
-    "Indicates how to run a death test in a forked child process: "
-    "\"threadsafe\" (child process re-executes the test binary "
-    "from the beginning, running only the specific death test) or "
-    "\"fast\" (child process runs the death test immediately "
-    "after forking).");
-
-GTEST_DEFINE_bool_(
-    death_test_use_fork,
-    internal::BoolFromGTestEnv("death_test_use_fork", false),
-    "Instructs to use fork()/_exit() instead of clone() in death tests. "
-    "Ignored and always uses fork() on POSIX systems where clone() is not "
-    "implemented. Useful when running under valgrind or similar tools if "
-    "those do not support clone(). Valgrind 3.3.1 will just fail if "
-    "it sees an unsupported combination of clone() flags. "
-    "It is not recommended to use this flag w/o valgrind though it will "
-    "work in 99% of the cases. Once valgrind is fixed, this flag will "
-    "most likely be removed.");
-
-namespace internal {
-GTEST_DEFINE_string_(
-    internal_run_death_test, "",
-    "Indicates the file, line number, temporal index of "
-    "the single death test to run, and a file descriptor to "
-    "which a success code may be sent, all separated by "
-    "colons.  This flag is specified if and only if the current "
-    "process is a sub-process launched for running a thread-safe "
-    "death test.  FOR INTERNAL USE ONLY.");
-}  // namespace internal
-
-#if GTEST_HAS_DEATH_TEST
-
-// ExitedWithCode constructor.
-ExitedWithCode::ExitedWithCode(int exit_code) : exit_code_(exit_code) {
-}
-
-// ExitedWithCode function-call operator.
-bool ExitedWithCode::operator()(int exit_status) const {
-# if GTEST_OS_WINDOWS
-
-  return exit_status == exit_code_;
-
-# else
-
-  return WIFEXITED(exit_status) && WEXITSTATUS(exit_status) == exit_code_;
-
-# endif  // GTEST_OS_WINDOWS
-}
-
-# if !GTEST_OS_WINDOWS
-// KilledBySignal constructor.
-KilledBySignal::KilledBySignal(int signum) : signum_(signum) {
-}
-
-// KilledBySignal function-call operator.
-bool KilledBySignal::operator()(int exit_status) const {
-  return WIFSIGNALED(exit_status) && WTERMSIG(exit_status) == signum_;
-}
-# endif  // !GTEST_OS_WINDOWS
-
-namespace internal {
-
-// Utilities needed for death tests.
-
-// Generates a textual description of a given exit code, in the format
-// specified by wait(2).
-static String ExitSummary(int exit_code) {
-  Message m;
-
-# if GTEST_OS_WINDOWS
-
-  m << "Exited with exit status " << exit_code;
-
-# else
-
-  if (WIFEXITED(exit_code)) {
-    m << "Exited with exit status " << WEXITSTATUS(exit_code);
-  } else if (WIFSIGNALED(exit_code)) {
-    m << "Terminated by signal " << WTERMSIG(exit_code);
-  }
-#  ifdef WCOREDUMP
-  if (WCOREDUMP(exit_code)) {
-    m << " (core dumped)";
-  }
-#  endif
-# endif  // GTEST_OS_WINDOWS
-
-  return m.GetString();
-}
-
-// Returns true if exit_status describes a process that was terminated
-// by a signal, or exited normally with a nonzero exit code.
-bool ExitedUnsuccessfully(int exit_status) {
-  return !ExitedWithCode(0)(exit_status);
-}
-
-# if !GTEST_OS_WINDOWS
-// Generates a textual failure message when a death test finds more than
-// one thread running, or cannot determine the number of threads, prior
-// to executing the given statement.  It is the responsibility of the
-// caller not to pass a thread_count of 1.
-static String DeathTestThreadWarning(size_t thread_count) {
-  Message msg;
-  msg << "Death tests use fork(), which is unsafe particularly"
-      << " in a threaded context. For this test, " << GTEST_NAME_ << " ";
-  if (thread_count == 0)
-    msg << "couldn't detect the number of threads.";
-  else
-    msg << "detected " << thread_count << " threads.";
-  return msg.GetString();
-}
-# endif  // !GTEST_OS_WINDOWS
-
-// Flag characters for reporting a death test that did not die.
-static const char kDeathTestLived = 'L';
-static const char kDeathTestReturned = 'R';
-static const char kDeathTestThrew = 'T';
-static const char kDeathTestInternalError = 'I';
-
-// An enumeration describing all of the possible ways that a death test can
-// conclude.  DIED means that the process died while executing the test
-// code; LIVED means that process lived beyond the end of the test code;
-// RETURNED means that the test statement attempted to execute a return
-// statement, which is not allowed; THREW means that the test statement
-// returned control by throwing an exception.  IN_PROGRESS means the test
-// has not yet concluded.
-// TODO(vladl at google.com): Unify names and possibly values for
-// AbortReason, DeathTestOutcome, and flag characters above.
-enum DeathTestOutcome { IN_PROGRESS, DIED, LIVED, RETURNED, THREW };
-
-// Routine for aborting the program which is safe to call from an
-// exec-style death test child process, in which case the error
-// message is propagated back to the parent process.  Otherwise, the
-// message is simply printed to stderr.  In either case, the program
-// then exits with status 1.
-void DeathTestAbort(const String& message) {
-  // On a POSIX system, this function may be called from a threadsafe-style
-  // death test child process, which operates on a very small stack.  Use
-  // the heap for any additional non-minuscule memory requirements.
-  const InternalRunDeathTestFlag* const flag =
-      GetUnitTestImpl()->internal_run_death_test_flag();
-  if (flag != NULL) {
-    FILE* parent = posix::FDOpen(flag->write_fd(), "w");
-    fputc(kDeathTestInternalError, parent);
-    fprintf(parent, "%s", message.c_str());
-    fflush(parent);
-    _exit(1);
-  } else {
-    fprintf(stderr, "%s", message.c_str());
-    fflush(stderr);
-    posix::Abort();
-  }
-}
-
-// A replacement for CHECK that calls DeathTestAbort if the assertion
-// fails.
-# define GTEST_DEATH_TEST_CHECK_(expression) \
-  do { \
-    if (!::testing::internal::IsTrue(expression)) { \
-      DeathTestAbort(::testing::internal::String::Format( \
-          "CHECK failed: File %s, line %d: %s", \
-          __FILE__, __LINE__, #expression)); \
-    } \
-  } while (::testing::internal::AlwaysFalse())
-
-// This macro is similar to GTEST_DEATH_TEST_CHECK_, but it is meant for
-// evaluating any system call that fulfills two conditions: it must return
-// -1 on failure, and set errno to EINTR when it is interrupted and
-// should be tried again.  The macro expands to a loop that repeatedly
-// evaluates the expression as long as it evaluates to -1 and sets
-// errno to EINTR.  If the expression evaluates to -1 but errno is
-// something other than EINTR, DeathTestAbort is called.
-# define GTEST_DEATH_TEST_CHECK_SYSCALL_(expression) \
-  do { \
-    int gtest_retval; \
-    do { \
-      gtest_retval = (expression); \
-    } while (gtest_retval == -1 && errno == EINTR); \
-    if (gtest_retval == -1) { \
-      DeathTestAbort(::testing::internal::String::Format( \
-          "CHECK failed: File %s, line %d: %s != -1", \
-          __FILE__, __LINE__, #expression)); \
-    } \
-  } while (::testing::internal::AlwaysFalse())
-
-// Returns the message describing the last system error in errno.
-String GetLastErrnoDescription() {
-    return String(errno == 0 ? "" : posix::StrError(errno));
-}
-
-// This is called from a death test parent process to read a failure
-// message from the death test child process and log it with the FATAL
-// severity. On Windows, the message is read from a pipe handle. On other
-// platforms, it is read from a file descriptor.
-static void FailFromInternalError(int fd) {
-  Message error;
-  char buffer[256];
-  int num_read;
-
-  do {
-    while ((num_read = posix::Read(fd, buffer, 255)) > 0) {
-      buffer[num_read] = '\0';
-      error << buffer;
-    }
-  } while (num_read == -1 && errno == EINTR);
-
-  if (num_read == 0) {
-    GTEST_LOG_(FATAL) << error.GetString();
-  } else {
-    const int last_error = errno;
-    GTEST_LOG_(FATAL) << "Error while reading death test internal: "
-                      << GetLastErrnoDescription() << " [" << last_error << "]";
-  }
-}
-
-// Death test constructor.  Increments the running death test count
-// for the current test.
-DeathTest::DeathTest() {
-  TestInfo* const info = GetUnitTestImpl()->current_test_info();
-  if (info == NULL) {
-    DeathTestAbort("Cannot run a death test outside of a TEST or "
-                   "TEST_F construct");
-  }
-}
-
-// Creates and returns a death test by dispatching to the current
-// death test factory.
-bool DeathTest::Create(const char* statement, const RE* regex,
-                       const char* file, int line, DeathTest** test) {
-  return GetUnitTestImpl()->death_test_factory()->Create(
-      statement, regex, file, line, test);
-}
-
-const char* DeathTest::LastMessage() {
-  return last_death_test_message_.c_str();
-}
-
-void DeathTest::set_last_death_test_message(const String& message) {
-  last_death_test_message_ = message;
-}
-
-String DeathTest::last_death_test_message_;
-
-// Provides cross platform implementation for some death functionality.
-class DeathTestImpl : public DeathTest {
- protected:
-  DeathTestImpl(const char* a_statement, const RE* a_regex)
-      : statement_(a_statement),
-        regex_(a_regex),
-        spawned_(false),
-        status_(-1),
-        outcome_(IN_PROGRESS),
-        read_fd_(-1),
-        write_fd_(-1) {}
-
-  // read_fd_ is expected to be closed and cleared by a derived class.
-  ~DeathTestImpl() { GTEST_DEATH_TEST_CHECK_(read_fd_ == -1); }
-
-  void Abort(AbortReason reason);
-  virtual bool Passed(bool status_ok);
-
-  const char* statement() const { return statement_; }
-  const RE* regex() const { return regex_; }
-  bool spawned() const { return spawned_; }
-  void set_spawned(bool is_spawned) { spawned_ = is_spawned; }
-  int status() const { return status_; }
-  void set_status(int a_status) { status_ = a_status; }
-  DeathTestOutcome outcome() const { return outcome_; }
-  void set_outcome(DeathTestOutcome an_outcome) { outcome_ = an_outcome; }
-  int read_fd() const { return read_fd_; }
-  void set_read_fd(int fd) { read_fd_ = fd; }
-  int write_fd() const { return write_fd_; }
-  void set_write_fd(int fd) { write_fd_ = fd; }
-
-  // Called in the parent process only. Reads the result code of the death
-  // test child process via a pipe, interprets it to set the outcome_
-  // member, and closes read_fd_.  Outputs diagnostics and terminates in
-  // case of unexpected codes.
-  void ReadAndInterpretStatusByte();
-
- private:
-  // The textual content of the code this object is testing.  This class
-  // doesn't own this string and should not attempt to delete it.
-  const char* const statement_;
-  // The regular expression which test output must match.  DeathTestImpl
-  // doesn't own this object and should not attempt to delete it.
-  const RE* const regex_;
-  // True if the death test child process has been successfully spawned.
-  bool spawned_;
-  // The exit status of the child process.
-  int status_;
-  // How the death test concluded.
-  DeathTestOutcome outcome_;
-  // Descriptor to the read end of the pipe to the child process.  It is
-  // always -1 in the child process.  The child keeps its write end of the
-  // pipe in write_fd_.
-  int read_fd_;
-  // Descriptor to the child's write end of the pipe to the parent process.
-  // It is always -1 in the parent process.  The parent keeps its end of the
-  // pipe in read_fd_.
-  int write_fd_;
-};
-
-// Called in the parent process only. Reads the result code of the death
-// test child process via a pipe, interprets it to set the outcome_
-// member, and closes read_fd_.  Outputs diagnostics and terminates in
-// case of unexpected codes.
-void DeathTestImpl::ReadAndInterpretStatusByte() {
-  char flag;
-  int bytes_read;
-
-  // The read() here blocks until data is available (signifying the
-  // failure of the death test) or until the pipe is closed (signifying
-  // its success), so it's okay to call this in the parent before
-  // the child process has exited.
-  do {
-    bytes_read = posix::Read(read_fd(), &flag, 1);
-  } while (bytes_read == -1 && errno == EINTR);
-
-  if (bytes_read == 0) {
-    set_outcome(DIED);
-  } else if (bytes_read == 1) {
-    switch (flag) {
-      case kDeathTestReturned:
-        set_outcome(RETURNED);
-        break;
-      case kDeathTestThrew:
-        set_outcome(THREW);
-        break;
-      case kDeathTestLived:
-        set_outcome(LIVED);
-        break;
-      case kDeathTestInternalError:
-        FailFromInternalError(read_fd());  // Does not return.
-        break;
-      default:
-        GTEST_LOG_(FATAL) << "Death test child process reported "
-                          << "unexpected status byte ("
-                          << static_cast<unsigned int>(flag) << ")";
-    }
-  } else {
-    GTEST_LOG_(FATAL) << "Read from death test child process failed: "
-                      << GetLastErrnoDescription();
-  }
-  GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Close(read_fd()));
-  set_read_fd(-1);
-}
-
-// Signals that the death test code which should have exited, didn't.
-// Should be called only in a death test child process.
-// Writes a status byte to the child's status file descriptor, then
-// calls _exit(1).
-void DeathTestImpl::Abort(AbortReason reason) {
-  // The parent process considers the death test to be a failure if
-  // it finds any data in our pipe.  So, here we write a single flag byte
-  // to the pipe, then exit.
-  const char status_ch =
-      reason == TEST_DID_NOT_DIE ? kDeathTestLived :
-      reason == TEST_THREW_EXCEPTION ? kDeathTestThrew : kDeathTestReturned;
-
-  GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Write(write_fd(), &status_ch, 1));
-  // We are leaking the descriptor here because on some platforms (i.e.,
-  // when built as Windows DLL), destructors of global objects will still
-  // run after calling _exit(). On such systems, write_fd_ will be
-  // indirectly closed from the destructor of UnitTestImpl, causing double
-  // close if it is also closed here. On debug configurations, double close
-  // may assert. As there are no in-process buffers to flush here, we are
-  // relying on the OS to close the descriptor after the process terminates
-  // when the destructors are not run.
-  _exit(1);  // Exits w/o any normal exit hooks (we were supposed to crash)
-}
-
-// Returns an indented copy of stderr output for a death test.
-// This makes distinguishing death test output lines from regular log lines
-// much easier.
-static ::std::string FormatDeathTestOutput(const ::std::string& output) {
-  ::std::string ret;
-  for (size_t at = 0; ; ) {
-    const size_t line_end = output.find('\n', at);
-    ret += "[  DEATH   ] ";
-    if (line_end == ::std::string::npos) {
-      ret += output.substr(at);
-      break;
-    }
-    ret += output.substr(at, line_end + 1 - at);
-    at = line_end + 1;
-  }
-  return ret;
-}
-
-// Assesses the success or failure of a death test, using both private
-// members which have previously been set, and one argument:
-//
-// Private data members:
-//   outcome:  An enumeration describing how the death test
-//             concluded: DIED, LIVED, THREW, or RETURNED.  The death test
-//             fails in the latter three cases.
-//   status:   The exit status of the child process. On *nix, it is in the
-//             in the format specified by wait(2). On Windows, this is the
-//             value supplied to the ExitProcess() API or a numeric code
-//             of the exception that terminated the program.
-//   regex:    A regular expression object to be applied to
-//             the test's captured standard error output; the death test
-//             fails if it does not match.
-//
-// Argument:
-//   status_ok: true if exit_status is acceptable in the context of
-//              this particular death test, which fails if it is false
-//
-// Returns true iff all of the above conditions are met.  Otherwise, the
-// first failing condition, in the order given above, is the one that is
-// reported. Also sets the last death test message string.
-bool DeathTestImpl::Passed(bool status_ok) {
-  if (!spawned())
-    return false;
-
-  const String error_message = GetCapturedStderr();
-
-  bool success = false;
-  Message buffer;
-
-  buffer << "Death test: " << statement() << "\n";
-  switch (outcome()) {
-    case LIVED:
-      buffer << "    Result: failed to die.\n"
-             << " Error msg:\n" << FormatDeathTestOutput(error_message);
-      break;
-    case THREW:
-      buffer << "    Result: threw an exception.\n"
-             << " Error msg:\n" << FormatDeathTestOutput(error_message);
-      break;
-    case RETURNED:
-      buffer << "    Result: illegal return in test statement.\n"
-             << " Error msg:\n" << FormatDeathTestOutput(error_message);
-      break;
-    case DIED:
-      if (status_ok) {
-        const bool matched = RE::PartialMatch(error_message.c_str(), *regex());
-        if (matched) {
-          success = true;
-        } else {
-          buffer << "    Result: died but not with expected error.\n"
-                 << "  Expected: " << regex()->pattern() << "\n"
-                 << "Actual msg:\n" << FormatDeathTestOutput(error_message);
-        }
-      } else {
-        buffer << "    Result: died but not with expected exit code:\n"
-               << "            " << ExitSummary(status()) << "\n"
-               << "Actual msg:\n" << FormatDeathTestOutput(error_message);
-      }
-      break;
-    case IN_PROGRESS:
-    default:
-      GTEST_LOG_(FATAL)
-          << "DeathTest::Passed somehow called before conclusion of test";
-  }
-
-  DeathTest::set_last_death_test_message(buffer.GetString());
-  return success;
-}
-
-# if GTEST_OS_WINDOWS
-// WindowsDeathTest implements death tests on Windows. Due to the
-// specifics of starting new processes on Windows, death tests there are
-// always threadsafe, and Google Test considers the
-// --gtest_death_test_style=fast setting to be equivalent to
-// --gtest_death_test_style=threadsafe there.
-//
-// A few implementation notes:  Like the Linux version, the Windows
-// implementation uses pipes for child-to-parent communication. But due to
-// the specifics of pipes on Windows, some extra steps are required:
-//
-// 1. The parent creates a communication pipe and stores handles to both
-//    ends of it.
-// 2. The parent starts the child and provides it with the information
-//    necessary to acquire the handle to the write end of the pipe.
-// 3. The child acquires the write end of the pipe and signals the parent
-//    using a Windows event.
-// 4. Now the parent can release the write end of the pipe on its side. If
-//    this is done before step 3, the object's reference count goes down to
-//    0 and it is destroyed, preventing the child from acquiring it. The
-//    parent now has to release it, or read operations on the read end of
-//    the pipe will not return when the child terminates.
-// 5. The parent reads child's output through the pipe (outcome code and
-//    any possible error messages) from the pipe, and its stderr and then
-//    determines whether to fail the test.
-//
-// Note: to distinguish Win32 API calls from the local method and function
-// calls, the former are explicitly resolved in the global namespace.
-//
-class WindowsDeathTest : public DeathTestImpl {
- public:
-  WindowsDeathTest(const char* a_statement,
-                   const RE* a_regex,
-                   const char* file,
-                   int line)
-      : DeathTestImpl(a_statement, a_regex), file_(file), line_(line) {}
-
-  // All of these virtual functions are inherited from DeathTest.
-  virtual int Wait();
-  virtual TestRole AssumeRole();
-
- private:
-  // The name of the file in which the death test is located.
-  const char* const file_;
-  // The line number on which the death test is located.
-  const int line_;
-  // Handle to the write end of the pipe to the child process.
-  AutoHandle write_handle_;
-  // Child process handle.
-  AutoHandle child_handle_;
-  // Event the child process uses to signal the parent that it has
-  // acquired the handle to the write end of the pipe. After seeing this
-  // event the parent can release its own handles to make sure its
-  // ReadFile() calls return when the child terminates.
-  AutoHandle event_handle_;
-};
-
-// Waits for the child in a death test to exit, returning its exit
-// status, or 0 if no child process exists.  As a side effect, sets the
-// outcome data member.
-int WindowsDeathTest::Wait() {
-  if (!spawned())
-    return 0;
-
-  // Wait until the child either signals that it has acquired the write end
-  // of the pipe or it dies.
-  const HANDLE wait_handles[2] = { child_handle_.Get(), event_handle_.Get() };
-  switch (::WaitForMultipleObjects(2,
-                                   wait_handles,
-                                   FALSE,  // Waits for any of the handles.
-                                   INFINITE)) {
-    case WAIT_OBJECT_0:
-    case WAIT_OBJECT_0 + 1:
-      break;
-    default:
-      GTEST_DEATH_TEST_CHECK_(false);  // Should not get here.
-  }
-
-  // The child has acquired the write end of the pipe or exited.
-  // We release the handle on our side and continue.
-  write_handle_.Reset();
-  event_handle_.Reset();
-
-  ReadAndInterpretStatusByte();
-
-  // Waits for the child process to exit if it haven't already. This
-  // returns immediately if the child has already exited, regardless of
-  // whether previous calls to WaitForMultipleObjects synchronized on this
-  // handle or not.
-  GTEST_DEATH_TEST_CHECK_(
-      WAIT_OBJECT_0 == ::WaitForSingleObject(child_handle_.Get(),
-                                             INFINITE));
-  DWORD status_code;
-  GTEST_DEATH_TEST_CHECK_(
-      ::GetExitCodeProcess(child_handle_.Get(), &status_code) != FALSE);
-  child_handle_.Reset();
-  set_status(static_cast<int>(status_code));
-  return status();
-}
-
-// The AssumeRole process for a Windows death test.  It creates a child
-// process with the same executable as the current process to run the
-// death test.  The child process is given the --gtest_filter and
-// --gtest_internal_run_death_test flags such that it knows to run the
-// current death test only.
-DeathTest::TestRole WindowsDeathTest::AssumeRole() {
-  const UnitTestImpl* const impl = GetUnitTestImpl();
-  const InternalRunDeathTestFlag* const flag =
-      impl->internal_run_death_test_flag();
-  const TestInfo* const info = impl->current_test_info();
-  const int death_test_index = info->result()->death_test_count();
-
-  if (flag != NULL) {
-    // ParseInternalRunDeathTestFlag() has performed all the necessary
-    // processing.
-    set_write_fd(flag->write_fd());
-    return EXECUTE_TEST;
-  }
-
-  // WindowsDeathTest uses an anonymous pipe to communicate results of
-  // a death test.
-  SECURITY_ATTRIBUTES handles_are_inheritable = {
-    sizeof(SECURITY_ATTRIBUTES), NULL, TRUE };
-  HANDLE read_handle, write_handle;
-  GTEST_DEATH_TEST_CHECK_(
-      ::CreatePipe(&read_handle, &write_handle, &handles_are_inheritable,
-                   0)  // Default buffer size.
-      != FALSE);
-  set_read_fd(::_open_osfhandle(reinterpret_cast<intptr_t>(read_handle),
-                                O_RDONLY));
-  write_handle_.Reset(write_handle);
-  event_handle_.Reset(::CreateEvent(
-      &handles_are_inheritable,
-      TRUE,    // The event will automatically reset to non-signaled state.
-      FALSE,   // The initial state is non-signalled.
-      NULL));  // The even is unnamed.
-  GTEST_DEATH_TEST_CHECK_(event_handle_.Get() != NULL);
-  const String filter_flag = String::Format("--%s%s=%s.%s",
-                                            GTEST_FLAG_PREFIX_, kFilterFlag,
-                                            info->test_case_name(),
-                                            info->name());
-  const String internal_flag = String::Format(
-    "--%s%s=%s|%d|%d|%u|%Iu|%Iu",
-      GTEST_FLAG_PREFIX_,
-      kInternalRunDeathTestFlag,
-      file_, line_,
-      death_test_index,
-      static_cast<unsigned int>(::GetCurrentProcessId()),
-      // size_t has the same with as pointers on both 32-bit and 64-bit
-      // Windows platforms.
-      // See http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx.
-      reinterpret_cast<size_t>(write_handle),
-      reinterpret_cast<size_t>(event_handle_.Get()));
-
-  char executable_path[_MAX_PATH + 1];  // NOLINT
-  GTEST_DEATH_TEST_CHECK_(
-      _MAX_PATH + 1 != ::GetModuleFileNameA(NULL,
-                                            executable_path,
-                                            _MAX_PATH));
-
-  String command_line = String::Format("%s %s \"%s\"",
-                                       ::GetCommandLineA(),
-                                       filter_flag.c_str(),
-                                       internal_flag.c_str());
-
-  DeathTest::set_last_death_test_message("");
-
-  CaptureStderr();
-  // Flush the log buffers since the log streams are shared with the child.
-  FlushInfoLog();
-
-  // The child process will share the standard handles with the parent.
-  STARTUPINFOA startup_info;
-  memset(&startup_info, 0, sizeof(STARTUPINFO));
-  startup_info.dwFlags = STARTF_USESTDHANDLES;
-  startup_info.hStdInput = ::GetStdHandle(STD_INPUT_HANDLE);
-  startup_info.hStdOutput = ::GetStdHandle(STD_OUTPUT_HANDLE);
-  startup_info.hStdError = ::GetStdHandle(STD_ERROR_HANDLE);
-
-  PROCESS_INFORMATION process_info;
-  GTEST_DEATH_TEST_CHECK_(::CreateProcessA(
-      executable_path,
-      const_cast<char*>(command_line.c_str()),
-      NULL,   // Retuned process handle is not inheritable.
-      NULL,   // Retuned thread handle is not inheritable.
-      TRUE,   // Child inherits all inheritable handles (for write_handle_).
-      0x0,    // Default creation flags.
-      NULL,   // Inherit the parent's environment.
-      UnitTest::GetInstance()->original_working_dir(),
-      &startup_info,
-      &process_info) != FALSE);
-  child_handle_.Reset(process_info.hProcess);
-  ::CloseHandle(process_info.hThread);
-  set_spawned(true);
-  return OVERSEE_TEST;
-}
-# else  // We are not on Windows.
-
-// ForkingDeathTest provides implementations for most of the abstract
-// methods of the DeathTest interface.  Only the AssumeRole method is
-// left undefined.
-class ForkingDeathTest : public DeathTestImpl {
- public:
-  ForkingDeathTest(const char* statement, const RE* regex);
-
-  // All of these virtual functions are inherited from DeathTest.
-  virtual int Wait();
-
- protected:
-  void set_child_pid(pid_t child_pid) { child_pid_ = child_pid; }
-
- private:
-  // PID of child process during death test; 0 in the child process itself.
-  pid_t child_pid_;
-};
-
-// Constructs a ForkingDeathTest.
-ForkingDeathTest::ForkingDeathTest(const char* a_statement, const RE* a_regex)
-    : DeathTestImpl(a_statement, a_regex),
-      child_pid_(-1) {}
-
-// Waits for the child in a death test to exit, returning its exit
-// status, or 0 if no child process exists.  As a side effect, sets the
-// outcome data member.
-int ForkingDeathTest::Wait() {
-  if (!spawned())
-    return 0;
-
-  ReadAndInterpretStatusByte();
-
-  int status_value;
-  GTEST_DEATH_TEST_CHECK_SYSCALL_(waitpid(child_pid_, &status_value, 0));
-  set_status(status_value);
-  return status_value;
-}
-
-// A concrete death test class that forks, then immediately runs the test
-// in the child process.
-class NoExecDeathTest : public ForkingDeathTest {
- public:
-  NoExecDeathTest(const char* a_statement, const RE* a_regex) :
-      ForkingDeathTest(a_statement, a_regex) { }
-  virtual TestRole AssumeRole();
-};
-
-// The AssumeRole process for a fork-and-run death test.  It implements a
-// straightforward fork, with a simple pipe to transmit the status byte.
-DeathTest::TestRole NoExecDeathTest::AssumeRole() {
-  const size_t thread_count = GetThreadCount();
-  if (thread_count != 1) {
-    GTEST_LOG_(WARNING) << DeathTestThreadWarning(thread_count);
-  }
-
-  int pipe_fd[2];
-  GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1);
-
-  DeathTest::set_last_death_test_message("");
-  CaptureStderr();
-  // When we fork the process below, the log file buffers are copied, but the
-  // file descriptors are shared.  We flush all log files here so that closing
-  // the file descriptors in the child process doesn't throw off the
-  // synchronization between descriptors and buffers in the parent process.
-  // This is as close to the fork as possible to avoid a race condition in case
-  // there are multiple threads running before the death test, and another
-  // thread writes to the log file.
-  FlushInfoLog();
-
-  const pid_t child_pid = fork();
-  GTEST_DEATH_TEST_CHECK_(child_pid != -1);
-  set_child_pid(child_pid);
-  if (child_pid == 0) {
-    GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[0]));
-    set_write_fd(pipe_fd[1]);
-    // Redirects all logging to stderr in the child process to prevent
-    // concurrent writes to the log files.  We capture stderr in the parent
-    // process and append the child process' output to a log.
-    LogToStderr();
-    // Event forwarding to the listeners of event listener API mush be shut
-    // down in death test subprocesses.
-    GetUnitTestImpl()->listeners()->SuppressEventForwarding();
-    return EXECUTE_TEST;
-  } else {
-    GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1]));
-    set_read_fd(pipe_fd[0]);
-    set_spawned(true);
-    return OVERSEE_TEST;
-  }
-}
-
-// A concrete death test class that forks and re-executes the main
-// program from the beginning, with command-line flags set that cause
-// only this specific death test to be run.
-class ExecDeathTest : public ForkingDeathTest {
- public:
-  ExecDeathTest(const char* a_statement, const RE* a_regex,
-                const char* file, int line) :
-      ForkingDeathTest(a_statement, a_regex), file_(file), line_(line) { }
-  virtual TestRole AssumeRole();
- private:
-  // The name of the file in which the death test is located.
-  const char* const file_;
-  // The line number on which the death test is located.
-  const int line_;
-};
-
-// Utility class for accumulating command-line arguments.
-class Arguments {
- public:
-  Arguments() {
-    args_.push_back(NULL);
-  }
-
-  ~Arguments() {
-    for (std::vector<char*>::iterator i = args_.begin(); i != args_.end();
-         ++i) {
-      free(*i);
-    }
-  }
-  void AddArgument(const char* argument) {
-    args_.insert(args_.end() - 1, posix::StrDup(argument));
-  }
-
-  template <typename Str>
-  void AddArguments(const ::std::vector<Str>& arguments) {
-    for (typename ::std::vector<Str>::const_iterator i = arguments.begin();
-         i != arguments.end();
-         ++i) {
-      args_.insert(args_.end() - 1, posix::StrDup(i->c_str()));
-    }
-  }
-  char* const* Argv() {
-    return &args_[0];
-  }
- private:
-  std::vector<char*> args_;
-};
-
-// A struct that encompasses the arguments to the child process of a
-// threadsafe-style death test process.
-struct ExecDeathTestArgs {
-  char* const* argv;  // Command-line arguments for the child's call to exec
-  int close_fd;       // File descriptor to close; the read end of a pipe
-};
-
-#  if GTEST_OS_MAC
-inline char** GetEnviron() {
-  // When Google Test is built as a framework on MacOS X, the environ variable
-  // is unavailable. Apple's documentation (man environ) recommends using
-  // _NSGetEnviron() instead.
-  return *_NSGetEnviron();
-}
-#  else
-// Some POSIX platforms expect you to declare environ. extern "C" makes
-// it reside in the global namespace.
-extern "C" char** environ;
-inline char** GetEnviron() { return environ; }
-#  endif  // GTEST_OS_MAC
-
-// The main function for a threadsafe-style death test child process.
-// This function is called in a clone()-ed process and thus must avoid
-// any potentially unsafe operations like malloc or libc functions.
-static int ExecDeathTestChildMain(void* child_arg) {
-  ExecDeathTestArgs* const args = static_cast<ExecDeathTestArgs*>(child_arg);
-  GTEST_DEATH_TEST_CHECK_SYSCALL_(close(args->close_fd));
-
-  // We need to execute the test program in the same environment where
-  // it was originally invoked.  Therefore we change to the original
-  // working directory first.
-  const char* const original_dir =
-      UnitTest::GetInstance()->original_working_dir();
-  // We can safely call chdir() as it's a direct system call.
-  if (chdir(original_dir) != 0) {
-    DeathTestAbort(String::Format("chdir(\"%s\") failed: %s",
-                                  original_dir,
-                                  GetLastErrnoDescription().c_str()));
-    return EXIT_FAILURE;
-  }
-
-  // We can safely call execve() as it's a direct system call.  We
-  // cannot use execvp() as it's a libc function and thus potentially
-  // unsafe.  Since execve() doesn't search the PATH, the user must
-  // invoke the test program via a valid path that contains at least
-  // one path separator.
-  execve(args->argv[0], args->argv, GetEnviron());
-  DeathTestAbort(String::Format("execve(%s, ...) in %s failed: %s",
-                                args->argv[0],
-                                original_dir,
-                                GetLastErrnoDescription().c_str()));
-  return EXIT_FAILURE;
-}
-
-// Two utility routines that together determine the direction the stack
-// grows.
-// This could be accomplished more elegantly by a single recursive
-// function, but we want to guard against the unlikely possibility of
-// a smart compiler optimizing the recursion away.
-//
-// GTEST_NO_INLINE_ is required to prevent GCC 4.6 from inlining
-// StackLowerThanAddress into StackGrowsDown, which then doesn't give
-// correct answer.
-bool StackLowerThanAddress(const void* ptr) GTEST_NO_INLINE_;
-bool StackLowerThanAddress(const void* ptr) {
-  int dummy;
-  return &dummy < ptr;
-}
-
-bool StackGrowsDown() {
-  int dummy;
-  return StackLowerThanAddress(&dummy);
-}
-
-// A threadsafe implementation of fork(2) for threadsafe-style death tests
-// that uses clone(2).  It dies with an error message if anything goes
-// wrong.
-static pid_t ExecDeathTestFork(char* const* argv, int close_fd) {
-  ExecDeathTestArgs args = { argv, close_fd };
-  pid_t child_pid = -1;
-
-#  if GTEST_HAS_CLONE
-  const bool use_fork = GTEST_FLAG(death_test_use_fork);
-
-  if (!use_fork) {
-    static const bool stack_grows_down = StackGrowsDown();
-    const size_t stack_size = getpagesize();
-    // MMAP_ANONYMOUS is not defined on Mac, so we use MAP_ANON instead.
-    void* const stack = mmap(NULL, stack_size, PROT_READ | PROT_WRITE,
-                             MAP_ANON | MAP_PRIVATE, -1, 0);
-    GTEST_DEATH_TEST_CHECK_(stack != MAP_FAILED);
-    void* const stack_top =
-        static_cast<char*>(stack) + (stack_grows_down ? stack_size : 0);
-
-    child_pid = clone(&ExecDeathTestChildMain, stack_top, SIGCHLD, &args);
-
-    GTEST_DEATH_TEST_CHECK_(munmap(stack, stack_size) != -1);
-  }
-#  else
-  const bool use_fork = true;
-#  endif  // GTEST_HAS_CLONE
-
-  if (use_fork && (child_pid = fork()) == 0) {
-      ExecDeathTestChildMain(&args);
-      _exit(0);
-  }
-
-  GTEST_DEATH_TEST_CHECK_(child_pid != -1);
-  return child_pid;
-}
-
-// The AssumeRole process for a fork-and-exec death test.  It re-executes the
-// main program from the beginning, setting the --gtest_filter
-// and --gtest_internal_run_death_test flags to cause only the current
-// death test to be re-run.
-DeathTest::TestRole ExecDeathTest::AssumeRole() {
-  const UnitTestImpl* const impl = GetUnitTestImpl();
-  const InternalRunDeathTestFlag* const flag =
-      impl->internal_run_death_test_flag();
-  const TestInfo* const info = impl->current_test_info();
-  const int death_test_index = info->result()->death_test_count();
-
-  if (flag != NULL) {
-    set_write_fd(flag->write_fd());
-    return EXECUTE_TEST;
-  }
-
-  int pipe_fd[2];
-  GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1);
-  // Clear the close-on-exec flag on the write end of the pipe, lest
-  // it be closed when the child process does an exec:
-  GTEST_DEATH_TEST_CHECK_(fcntl(pipe_fd[1], F_SETFD, 0) != -1);
-
-  const String filter_flag =
-      String::Format("--%s%s=%s.%s",
-                     GTEST_FLAG_PREFIX_, kFilterFlag,
-                     info->test_case_name(), info->name());
-  const String internal_flag =
-      String::Format("--%s%s=%s|%d|%d|%d",
-                     GTEST_FLAG_PREFIX_, kInternalRunDeathTestFlag,
-                     file_, line_, death_test_index, pipe_fd[1]);
-  Arguments args;
-  args.AddArguments(GetArgvs());
-  args.AddArgument(filter_flag.c_str());
-  args.AddArgument(internal_flag.c_str());
-
-  DeathTest::set_last_death_test_message("");
-
-  CaptureStderr();
-  // See the comment in NoExecDeathTest::AssumeRole for why the next line
-  // is necessary.
-  FlushInfoLog();
-
-  const pid_t child_pid = ExecDeathTestFork(args.Argv(), pipe_fd[0]);
-  GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1]));
-  set_child_pid(child_pid);
-  set_read_fd(pipe_fd[0]);
-  set_spawned(true);
-  return OVERSEE_TEST;
-}
-
-# endif  // !GTEST_OS_WINDOWS
-
-// Creates a concrete DeathTest-derived class that depends on the
-// --gtest_death_test_style flag, and sets the pointer pointed to
-// by the "test" argument to its address.  If the test should be
-// skipped, sets that pointer to NULL.  Returns true, unless the
-// flag is set to an invalid value.
-bool DefaultDeathTestFactory::Create(const char* statement, const RE* regex,
-                                     const char* file, int line,
-                                     DeathTest** test) {
-  UnitTestImpl* const impl = GetUnitTestImpl();
-  const InternalRunDeathTestFlag* const flag =
-      impl->internal_run_death_test_flag();
-  const int death_test_index = impl->current_test_info()
-      ->increment_death_test_count();
-
-  if (flag != NULL) {
-    if (death_test_index > flag->index()) {
-      DeathTest::set_last_death_test_message(String::Format(
-          "Death test count (%d) somehow exceeded expected maximum (%d)",
-          death_test_index, flag->index()));
-      return false;
-    }
-
-    if (!(flag->file() == file && flag->line() == line &&
-          flag->index() == death_test_index)) {
-      *test = NULL;
-      return true;
-    }
-  }
-
-# if GTEST_OS_WINDOWS
-
-  if (GTEST_FLAG(death_test_style) == "threadsafe" ||
-      GTEST_FLAG(death_test_style) == "fast") {
-    *test = new WindowsDeathTest(statement, regex, file, line);
-  }
-
-# else
-
-  if (GTEST_FLAG(death_test_style) == "threadsafe") {
-    *test = new ExecDeathTest(statement, regex, file, line);
-  } else if (GTEST_FLAG(death_test_style) == "fast") {
-    *test = new NoExecDeathTest(statement, regex);
-  }
-
-# endif  // GTEST_OS_WINDOWS
-
-  else {  // NOLINT - this is more readable than unbalanced brackets inside #if.
-    DeathTest::set_last_death_test_message(String::Format(
-        "Unknown death test style \"%s\" encountered",
-        GTEST_FLAG(death_test_style).c_str()));
-    return false;
-  }
-
-  return true;
-}
-
-// Splits a given string on a given delimiter, populating a given
-// vector with the fields.  GTEST_HAS_DEATH_TEST implies that we have
-// ::std::string, so we can use it here.
-static void SplitString(const ::std::string& str, char delimiter,
-                        ::std::vector< ::std::string>* dest) {
-  ::std::vector< ::std::string> parsed;
-  ::std::string::size_type pos = 0;
-  while (::testing::internal::AlwaysTrue()) {
-    const ::std::string::size_type colon = str.find(delimiter, pos);
-    if (colon == ::std::string::npos) {
-      parsed.push_back(str.substr(pos));
-      break;
-    } else {
-      parsed.push_back(str.substr(pos, colon - pos));
-      pos = colon + 1;
-    }
-  }
-  dest->swap(parsed);
-}
-
-# if GTEST_OS_WINDOWS
-// Recreates the pipe and event handles from the provided parameters,
-// signals the event, and returns a file descriptor wrapped around the pipe
-// handle. This function is called in the child process only.
-int GetStatusFileDescriptor(unsigned int parent_process_id,
-                            size_t write_handle_as_size_t,
-                            size_t event_handle_as_size_t) {
-  AutoHandle parent_process_handle(::OpenProcess(PROCESS_DUP_HANDLE,
-                                                   FALSE,  // Non-inheritable.
-                                                   parent_process_id));
-  if (parent_process_handle.Get() == INVALID_HANDLE_VALUE) {
-    DeathTestAbort(String::Format("Unable to open parent process %u",
-                                  parent_process_id));
-  }
-
-  // TODO(vladl at google.com): Replace the following check with a
-  // compile-time assertion when available.
-  GTEST_CHECK_(sizeof(HANDLE) <= sizeof(size_t));
-
-  const HANDLE write_handle =
-      reinterpret_cast<HANDLE>(write_handle_as_size_t);
-  HANDLE dup_write_handle;
-
-  // The newly initialized handle is accessible only in in the parent
-  // process. To obtain one accessible within the child, we need to use
-  // DuplicateHandle.
-  if (!::DuplicateHandle(parent_process_handle.Get(), write_handle,
-                         ::GetCurrentProcess(), &dup_write_handle,
-                         0x0,    // Requested privileges ignored since
-                                 // DUPLICATE_SAME_ACCESS is used.
-                         FALSE,  // Request non-inheritable handler.
-                         DUPLICATE_SAME_ACCESS)) {
-    DeathTestAbort(String::Format(
-        "Unable to duplicate the pipe handle %Iu from the parent process %u",
-        write_handle_as_size_t, parent_process_id));
-  }
-
-  const HANDLE event_handle = reinterpret_cast<HANDLE>(event_handle_as_size_t);
-  HANDLE dup_event_handle;
-
-  if (!::DuplicateHandle(parent_process_handle.Get(), event_handle,
-                         ::GetCurrentProcess(), &dup_event_handle,
-                         0x0,
-                         FALSE,
-                         DUPLICATE_SAME_ACCESS)) {
-    DeathTestAbort(String::Format(
-        "Unable to duplicate the event handle %Iu from the parent process %u",
-        event_handle_as_size_t, parent_process_id));
-  }
-
-  const int write_fd =
-      ::_open_osfhandle(reinterpret_cast<intptr_t>(dup_write_handle), O_APPEND);
-  if (write_fd == -1) {
-    DeathTestAbort(String::Format(
-        "Unable to convert pipe handle %Iu to a file descriptor",
-        write_handle_as_size_t));
-  }
-
-  // Signals the parent that the write end of the pipe has been acquired
-  // so the parent can release its own write end.
-  ::SetEvent(dup_event_handle);
-
-  return write_fd;
-}
-# endif  // GTEST_OS_WINDOWS
-
-// Returns a newly created InternalRunDeathTestFlag object with fields
-// initialized from the GTEST_FLAG(internal_run_death_test) flag if
-// the flag is specified; otherwise returns NULL.
-InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {
-  if (GTEST_FLAG(internal_run_death_test) == "") return NULL;
-
-  // GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we
-  // can use it here.
-  int line = -1;
-  int index = -1;
-  ::std::vector< ::std::string> fields;
-  SplitString(GTEST_FLAG(internal_run_death_test).c_str(), '|', &fields);
-  int write_fd = -1;
-
-# if GTEST_OS_WINDOWS
-
-  unsigned int parent_process_id = 0;
-  size_t write_handle_as_size_t = 0;
-  size_t event_handle_as_size_t = 0;
-
-  if (fields.size() != 6
-      || !ParseNaturalNumber(fields[1], &line)
-      || !ParseNaturalNumber(fields[2], &index)
-      || !ParseNaturalNumber(fields[3], &parent_process_id)
-      || !ParseNaturalNumber(fields[4], &write_handle_as_size_t)
-      || !ParseNaturalNumber(fields[5], &event_handle_as_size_t)) {
-    DeathTestAbort(String::Format(
-        "Bad --gtest_internal_run_death_test flag: %s",
-        GTEST_FLAG(internal_run_death_test).c_str()));
-  }
-  write_fd = GetStatusFileDescriptor(parent_process_id,
-                                     write_handle_as_size_t,
-                                     event_handle_as_size_t);
-# else
-
-  if (fields.size() != 4
-      || !ParseNaturalNumber(fields[1], &line)
-      || !ParseNaturalNumber(fields[2], &index)
-      || !ParseNaturalNumber(fields[3], &write_fd)) {
-    DeathTestAbort(String::Format(
-        "Bad --gtest_internal_run_death_test flag: %s",
-        GTEST_FLAG(internal_run_death_test).c_str()));
-  }
-
-# endif  // GTEST_OS_WINDOWS
-
-  return new InternalRunDeathTestFlag(fields[0], line, index, write_fd);
-}
-
-}  // namespace internal
-
-#endif  // GTEST_HAS_DEATH_TEST
-
-}  // namespace testing
diff --git a/bamtools/src/third_party/gtest-1.6.0/src/gtest-filepath.cc b/bamtools/src/third_party/gtest-1.6.0/src/gtest-filepath.cc
deleted file mode 100644
index 91b2571..0000000
--- a/bamtools/src/third_party/gtest-1.6.0/src/gtest-filepath.cc
+++ /dev/null
@@ -1,380 +0,0 @@
-// Copyright 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Authors: keith.ray at gmail.com (Keith Ray)
-
-#include "gtest/internal/gtest-filepath.h"
-#include "gtest/internal/gtest-port.h"
-
-#include <stdlib.h>
-
-#if GTEST_OS_WINDOWS_MOBILE
-# include <windows.h>
-#elif GTEST_OS_WINDOWS
-# include <direct.h>
-# include <io.h>
-#elif GTEST_OS_SYMBIAN || GTEST_OS_NACL
-// Symbian OpenC and NaCl have PATH_MAX in sys/syslimits.h
-# include <sys/syslimits.h>
-#else
-# include <limits.h>
-# include <climits>  // Some Linux distributions define PATH_MAX here.
-#endif  // GTEST_OS_WINDOWS_MOBILE
-
-#if GTEST_OS_WINDOWS
-# define GTEST_PATH_MAX_ _MAX_PATH
-#elif defined(PATH_MAX)
-# define GTEST_PATH_MAX_ PATH_MAX
-#elif defined(_XOPEN_PATH_MAX)
-# define GTEST_PATH_MAX_ _XOPEN_PATH_MAX
-#else
-# define GTEST_PATH_MAX_ _POSIX_PATH_MAX
-#endif  // GTEST_OS_WINDOWS
-
-#include "gtest/internal/gtest-string.h"
-
-namespace testing {
-namespace internal {
-
-#if GTEST_OS_WINDOWS
-// On Windows, '\\' is the standard path separator, but many tools and the
-// Windows API also accept '/' as an alternate path separator. Unless otherwise
-// noted, a file path can contain either kind of path separators, or a mixture
-// of them.
-const char kPathSeparator = '\\';
-const char kAlternatePathSeparator = '/';
-const char kPathSeparatorString[] = "\\";
-const char kAlternatePathSeparatorString[] = "/";
-# if GTEST_OS_WINDOWS_MOBILE
-// Windows CE doesn't have a current directory. You should not use
-// the current directory in tests on Windows CE, but this at least
-// provides a reasonable fallback.
-const char kCurrentDirectoryString[] = "\\";
-// Windows CE doesn't define INVALID_FILE_ATTRIBUTES
-const DWORD kInvalidFileAttributes = 0xffffffff;
-# else
-const char kCurrentDirectoryString[] = ".\\";
-# endif  // GTEST_OS_WINDOWS_MOBILE
-#else
-const char kPathSeparator = '/';
-const char kPathSeparatorString[] = "/";
-const char kCurrentDirectoryString[] = "./";
-#endif  // GTEST_OS_WINDOWS
-
-// Returns whether the given character is a valid path separator.
-static bool IsPathSeparator(char c) {
-#if GTEST_HAS_ALT_PATH_SEP_
-  return (c == kPathSeparator) || (c == kAlternatePathSeparator);
-#else
-  return c == kPathSeparator;
-#endif
-}
-
-// Returns the current working directory, or "" if unsuccessful.
-FilePath FilePath::GetCurrentDir() {
-#if GTEST_OS_WINDOWS_MOBILE
-  // Windows CE doesn't have a current directory, so we just return
-  // something reasonable.
-  return FilePath(kCurrentDirectoryString);
-#elif GTEST_OS_WINDOWS
-  char cwd[GTEST_PATH_MAX_ + 1] = { '\0' };
-  return FilePath(_getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd);
-#else
-  char cwd[GTEST_PATH_MAX_ + 1] = { '\0' };
-  return FilePath(getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd);
-#endif  // GTEST_OS_WINDOWS_MOBILE
-}
-
-// Returns a copy of the FilePath with the case-insensitive extension removed.
-// Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns
-// FilePath("dir/file"). If a case-insensitive extension is not
-// found, returns a copy of the original FilePath.
-FilePath FilePath::RemoveExtension(const char* extension) const {
-  String dot_extension(String::Format(".%s", extension));
-  if (pathname_.EndsWithCaseInsensitive(dot_extension.c_str())) {
-    return FilePath(String(pathname_.c_str(), pathname_.length() - 4));
-  }
-  return *this;
-}
-
-// Returns a pointer to the last occurence of a valid path separator in
-// the FilePath. On Windows, for example, both '/' and '\' are valid path
-// separators. Returns NULL if no path separator was found.
-const char* FilePath::FindLastPathSeparator() const {
-  const char* const last_sep = strrchr(c_str(), kPathSeparator);
-#if GTEST_HAS_ALT_PATH_SEP_
-  const char* const last_alt_sep = strrchr(c_str(), kAlternatePathSeparator);
-  // Comparing two pointers of which only one is NULL is undefined.
-  if (last_alt_sep != NULL &&
-      (last_sep == NULL || last_alt_sep > last_sep)) {
-    return last_alt_sep;
-  }
-#endif
-  return last_sep;
-}
-
-// Returns a copy of the FilePath with the directory part removed.
-// Example: FilePath("path/to/file").RemoveDirectoryName() returns
-// FilePath("file"). If there is no directory part ("just_a_file"), it returns
-// the FilePath unmodified. If there is no file part ("just_a_dir/") it
-// returns an empty FilePath ("").
-// On Windows platform, '\' is the path separator, otherwise it is '/'.
-FilePath FilePath::RemoveDirectoryName() const {
-  const char* const last_sep = FindLastPathSeparator();
-  return last_sep ? FilePath(String(last_sep + 1)) : *this;
-}
-
-// RemoveFileName returns the directory path with the filename removed.
-// Example: FilePath("path/to/file").RemoveFileName() returns "path/to/".
-// If the FilePath is "a_file" or "/a_file", RemoveFileName returns
-// FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does
-// not have a file, like "just/a/dir/", it returns the FilePath unmodified.
-// On Windows platform, '\' is the path separator, otherwise it is '/'.
-FilePath FilePath::RemoveFileName() const {
-  const char* const last_sep = FindLastPathSeparator();
-  String dir;
-  if (last_sep) {
-    dir = String(c_str(), last_sep + 1 - c_str());
-  } else {
-    dir = kCurrentDirectoryString;
-  }
-  return FilePath(dir);
-}
-
-// Helper functions for naming files in a directory for xml output.
-
-// Given directory = "dir", base_name = "test", number = 0,
-// extension = "xml", returns "dir/test.xml". If number is greater
-// than zero (e.g., 12), returns "dir/test_12.xml".
-// On Windows platform, uses \ as the separator rather than /.
-FilePath FilePath::MakeFileName(const FilePath& directory,
-                                const FilePath& base_name,
-                                int number,
-                                const char* extension) {
-  String file;
-  if (number == 0) {
-    file = String::Format("%s.%s", base_name.c_str(), extension);
-  } else {
-    file = String::Format("%s_%d.%s", base_name.c_str(), number, extension);
-  }
-  return ConcatPaths(directory, FilePath(file));
-}
-
-// Given directory = "dir", relative_path = "test.xml", returns "dir/test.xml".
-// On Windows, uses \ as the separator rather than /.
-FilePath FilePath::ConcatPaths(const FilePath& directory,
-                               const FilePath& relative_path) {
-  if (directory.IsEmpty())
-    return relative_path;
-  const FilePath dir(directory.RemoveTrailingPathSeparator());
-  return FilePath(String::Format("%s%c%s", dir.c_str(), kPathSeparator,
-                                 relative_path.c_str()));
-}
-
-// Returns true if pathname describes something findable in the file-system,
-// either a file, directory, or whatever.
-bool FilePath::FileOrDirectoryExists() const {
-#if GTEST_OS_WINDOWS_MOBILE
-  LPCWSTR unicode = String::AnsiToUtf16(pathname_.c_str());
-  const DWORD attributes = GetFileAttributes(unicode);
-  delete [] unicode;
-  return attributes != kInvalidFileAttributes;
-#else
-  posix::StatStruct file_stat;
-  return posix::Stat(pathname_.c_str(), &file_stat) == 0;
-#endif  // GTEST_OS_WINDOWS_MOBILE
-}
-
-// Returns true if pathname describes a directory in the file-system
-// that exists.
-bool FilePath::DirectoryExists() const {
-  bool result = false;
-#if GTEST_OS_WINDOWS
-  // Don't strip off trailing separator if path is a root directory on
-  // Windows (like "C:\\").
-  const FilePath& path(IsRootDirectory() ? *this :
-                                           RemoveTrailingPathSeparator());
-#else
-  const FilePath& path(*this);
-#endif
-
-#if GTEST_OS_WINDOWS_MOBILE
-  LPCWSTR unicode = String::AnsiToUtf16(path.c_str());
-  const DWORD attributes = GetFileAttributes(unicode);
-  delete [] unicode;
-  if ((attributes != kInvalidFileAttributes) &&
-      (attributes & FILE_ATTRIBUTE_DIRECTORY)) {
-    result = true;
-  }
-#else
-  posix::StatStruct file_stat;
-  result = posix::Stat(path.c_str(), &file_stat) == 0 &&
-      posix::IsDir(file_stat);
-#endif  // GTEST_OS_WINDOWS_MOBILE
-
-  return result;
-}
-
-// Returns true if pathname describes a root directory. (Windows has one
-// root directory per disk drive.)
-bool FilePath::IsRootDirectory() const {
-#if GTEST_OS_WINDOWS
-  // TODO(wan at google.com): on Windows a network share like
-  // \\server\share can be a root directory, although it cannot be the
-  // current directory.  Handle this properly.
-  return pathname_.length() == 3 && IsAbsolutePath();
-#else
-  return pathname_.length() == 1 && IsPathSeparator(pathname_.c_str()[0]);
-#endif
-}
-
-// Returns true if pathname describes an absolute path.
-bool FilePath::IsAbsolutePath() const {
-  const char* const name = pathname_.c_str();
-#if GTEST_OS_WINDOWS
-  return pathname_.length() >= 3 &&
-     ((name[0] >= 'a' && name[0] <= 'z') ||
-      (name[0] >= 'A' && name[0] <= 'Z')) &&
-     name[1] == ':' &&
-     IsPathSeparator(name[2]);
-#else
-  return IsPathSeparator(name[0]);
-#endif
-}
-
-// Returns a pathname for a file that does not currently exist. The pathname
-// will be directory/base_name.extension or
-// directory/base_name_<number>.extension if directory/base_name.extension
-// already exists. The number will be incremented until a pathname is found
-// that does not already exist.
-// Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.
-// There could be a race condition if two or more processes are calling this
-// function at the same time -- they could both pick the same filename.
-FilePath FilePath::GenerateUniqueFileName(const FilePath& directory,
-                                          const FilePath& base_name,
-                                          const char* extension) {
-  FilePath full_pathname;
-  int number = 0;
-  do {
-    full_pathname.Set(MakeFileName(directory, base_name, number++, extension));
-  } while (full_pathname.FileOrDirectoryExists());
-  return full_pathname;
-}
-
-// Returns true if FilePath ends with a path separator, which indicates that
-// it is intended to represent a directory. Returns false otherwise.
-// This does NOT check that a directory (or file) actually exists.
-bool FilePath::IsDirectory() const {
-  return !pathname_.empty() &&
-         IsPathSeparator(pathname_.c_str()[pathname_.length() - 1]);
-}
-
-// Create directories so that path exists. Returns true if successful or if
-// the directories already exist; returns false if unable to create directories
-// for any reason.
-bool FilePath::CreateDirectoriesRecursively() const {
-  if (!this->IsDirectory()) {
-    return false;
-  }
-
-  if (pathname_.length() == 0 || this->DirectoryExists()) {
-    return true;
-  }
-
-  const FilePath parent(this->RemoveTrailingPathSeparator().RemoveFileName());
-  return parent.CreateDirectoriesRecursively() && this->CreateFolder();
-}
-
-// Create the directory so that path exists. Returns true if successful or
-// if the directory already exists; returns false if unable to create the
-// directory for any reason, including if the parent directory does not
-// exist. Not named "CreateDirectory" because that's a macro on Windows.
-bool FilePath::CreateFolder() const {
-#if GTEST_OS_WINDOWS_MOBILE
-  FilePath removed_sep(this->RemoveTrailingPathSeparator());
-  LPCWSTR unicode = String::AnsiToUtf16(removed_sep.c_str());
-  int result = CreateDirectory(unicode, NULL) ? 0 : -1;
-  delete [] unicode;
-#elif GTEST_OS_WINDOWS
-  int result = _mkdir(pathname_.c_str());
-#else
-  int result = mkdir(pathname_.c_str(), 0777);
-#endif  // GTEST_OS_WINDOWS_MOBILE
-
-  if (result == -1) {
-    return this->DirectoryExists();  // An error is OK if the directory exists.
-  }
-  return true;  // No error.
-}
-
-// If input name has a trailing separator character, remove it and return the
-// name, otherwise return the name string unmodified.
-// On Windows platform, uses \ as the separator, other platforms use /.
-FilePath FilePath::RemoveTrailingPathSeparator() const {
-  return IsDirectory()
-      ? FilePath(String(pathname_.c_str(), pathname_.length() - 1))
-      : *this;
-}
-
-// Removes any redundant separators that might be in the pathname.
-// For example, "bar///foo" becomes "bar/foo". Does not eliminate other
-// redundancies that might be in a pathname involving "." or "..".
-// TODO(wan at google.com): handle Windows network shares (e.g. \\server\share).
-void FilePath::Normalize() {
-  if (pathname_.c_str() == NULL) {
-    pathname_ = "";
-    return;
-  }
-  const char* src = pathname_.c_str();
-  char* const dest = new char[pathname_.length() + 1];
-  char* dest_ptr = dest;
-  memset(dest_ptr, 0, pathname_.length() + 1);
-
-  while (*src != '\0') {
-    *dest_ptr = *src;
-    if (!IsPathSeparator(*src)) {
-      src++;
-    } else {
-#if GTEST_HAS_ALT_PATH_SEP_
-      if (*dest_ptr == kAlternatePathSeparator) {
-        *dest_ptr = kPathSeparator;
-      }
-#endif
-      while (IsPathSeparator(*src))
-        src++;
-    }
-    dest_ptr++;
-  }
-  *dest_ptr = '\0';
-  pathname_ = dest;
-  delete[] dest;
-}
-
-}  // namespace internal
-}  // namespace testing
diff --git a/bamtools/src/third_party/gtest-1.6.0/src/gtest-internal-inl.h b/bamtools/src/third_party/gtest-1.6.0/src/gtest-internal-inl.h
deleted file mode 100644
index 65a2101..0000000
--- a/bamtools/src/third_party/gtest-1.6.0/src/gtest-internal-inl.h
+++ /dev/null
@@ -1,1038 +0,0 @@
-// Copyright 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// Utility functions and classes used by the Google C++ testing framework.
-//
-// Author: wan at google.com (Zhanyong Wan)
-//
-// This file contains purely Google Test's internal implementation.  Please
-// DO NOT #INCLUDE IT IN A USER PROGRAM.
-
-#ifndef GTEST_SRC_GTEST_INTERNAL_INL_H_
-#define GTEST_SRC_GTEST_INTERNAL_INL_H_
-
-// GTEST_IMPLEMENTATION_ is defined to 1 iff the current translation unit is
-// part of Google Test's implementation; otherwise it's undefined.
-#if !GTEST_IMPLEMENTATION_
-// A user is trying to include this from his code - just say no.
-# error "gtest-internal-inl.h is part of Google Test's internal implementation."
-# error "It must not be included except by Google Test itself."
-#endif  // GTEST_IMPLEMENTATION_
-
-#ifndef _WIN32_WCE
-# include <errno.h>
-#endif  // !_WIN32_WCE
-#include <stddef.h>
-#include <stdlib.h>  // For strtoll/_strtoul64/malloc/free.
-#include <string.h>  // For memmove.
-
-#include <algorithm>
-#include <string>
-#include <vector>
-
-#include "gtest/internal/gtest-port.h"
-
-#if GTEST_OS_WINDOWS
-# include <windows.h>  // NOLINT
-#endif  // GTEST_OS_WINDOWS
-
-#include "gtest/gtest.h"  // NOLINT
-#include "gtest/gtest-spi.h"
-
-namespace testing {
-
-// Declares the flags.
-//
-// We don't want the users to modify this flag in the code, but want
-// Google Test's own unit tests to be able to access it. Therefore we
-// declare it here as opposed to in gtest.h.
-GTEST_DECLARE_bool_(death_test_use_fork);
-
-namespace internal {
-
-// The value of GetTestTypeId() as seen from within the Google Test
-// library.  This is solely for testing GetTestTypeId().
-GTEST_API_ extern const TypeId kTestTypeIdInGoogleTest;
-
-// Names of the flags (needed for parsing Google Test flags).
-const char kAlsoRunDisabledTestsFlag[] = "also_run_disabled_tests";
-const char kBreakOnFailureFlag[] = "break_on_failure";
-const char kCatchExceptionsFlag[] = "catch_exceptions";
-const char kColorFlag[] = "color";
-const char kFilterFlag[] = "filter";
-const char kListTestsFlag[] = "list_tests";
-const char kOutputFlag[] = "output";
-const char kPrintTimeFlag[] = "print_time";
-const char kRandomSeedFlag[] = "random_seed";
-const char kRepeatFlag[] = "repeat";
-const char kShuffleFlag[] = "shuffle";
-const char kStackTraceDepthFlag[] = "stack_trace_depth";
-const char kStreamResultToFlag[] = "stream_result_to";
-const char kThrowOnFailureFlag[] = "throw_on_failure";
-
-// A valid random seed must be in [1, kMaxRandomSeed].
-const int kMaxRandomSeed = 99999;
-
-// g_help_flag is true iff the --help flag or an equivalent form is
-// specified on the command line.
-GTEST_API_ extern bool g_help_flag;
-
-// Returns the current time in milliseconds.
-GTEST_API_ TimeInMillis GetTimeInMillis();
-
-// Returns true iff Google Test should use colors in the output.
-GTEST_API_ bool ShouldUseColor(bool stdout_is_tty);
-
-// Formats the given time in milliseconds as seconds.
-GTEST_API_ std::string FormatTimeInMillisAsSeconds(TimeInMillis ms);
-
-// Parses a string for an Int32 flag, in the form of "--flag=value".
-//
-// On success, stores the value of the flag in *value, and returns
-// true.  On failure, returns false without changing *value.
-GTEST_API_ bool ParseInt32Flag(
-    const char* str, const char* flag, Int32* value);
-
-// Returns a random seed in range [1, kMaxRandomSeed] based on the
-// given --gtest_random_seed flag value.
-inline int GetRandomSeedFromFlag(Int32 random_seed_flag) {
-  const unsigned int raw_seed = (random_seed_flag == 0) ?
-      static_cast<unsigned int>(GetTimeInMillis()) :
-      static_cast<unsigned int>(random_seed_flag);
-
-  // Normalizes the actual seed to range [1, kMaxRandomSeed] such that
-  // it's easy to type.
-  const int normalized_seed =
-      static_cast<int>((raw_seed - 1U) %
-                       static_cast<unsigned int>(kMaxRandomSeed)) + 1;
-  return normalized_seed;
-}
-
-// Returns the first valid random seed after 'seed'.  The behavior is
-// undefined if 'seed' is invalid.  The seed after kMaxRandomSeed is
-// considered to be 1.
-inline int GetNextRandomSeed(int seed) {
-  GTEST_CHECK_(1 <= seed && seed <= kMaxRandomSeed)
-      << "Invalid random seed " << seed << " - must be in [1, "
-      << kMaxRandomSeed << "].";
-  const int next_seed = seed + 1;
-  return (next_seed > kMaxRandomSeed) ? 1 : next_seed;
-}
-
-// This class saves the values of all Google Test flags in its c'tor, and
-// restores them in its d'tor.
-class GTestFlagSaver {
- public:
-  // The c'tor.
-  GTestFlagSaver() {
-    also_run_disabled_tests_ = GTEST_FLAG(also_run_disabled_tests);
-    break_on_failure_ = GTEST_FLAG(break_on_failure);
-    catch_exceptions_ = GTEST_FLAG(catch_exceptions);
-    color_ = GTEST_FLAG(color);
-    death_test_style_ = GTEST_FLAG(death_test_style);
-    death_test_use_fork_ = GTEST_FLAG(death_test_use_fork);
-    filter_ = GTEST_FLAG(filter);
-    internal_run_death_test_ = GTEST_FLAG(internal_run_death_test);
-    list_tests_ = GTEST_FLAG(list_tests);
-    output_ = GTEST_FLAG(output);
-    print_time_ = GTEST_FLAG(print_time);
-    random_seed_ = GTEST_FLAG(random_seed);
-    repeat_ = GTEST_FLAG(repeat);
-    shuffle_ = GTEST_FLAG(shuffle);
-    stack_trace_depth_ = GTEST_FLAG(stack_trace_depth);
-    stream_result_to_ = GTEST_FLAG(stream_result_to);
-    throw_on_failure_ = GTEST_FLAG(throw_on_failure);
-  }
-
-  // The d'tor is not virtual.  DO NOT INHERIT FROM THIS CLASS.
-  ~GTestFlagSaver() {
-    GTEST_FLAG(also_run_disabled_tests) = also_run_disabled_tests_;
-    GTEST_FLAG(break_on_failure) = break_on_failure_;
-    GTEST_FLAG(catch_exceptions) = catch_exceptions_;
-    GTEST_FLAG(color) = color_;
-    GTEST_FLAG(death_test_style) = death_test_style_;
-    GTEST_FLAG(death_test_use_fork) = death_test_use_fork_;
-    GTEST_FLAG(filter) = filter_;
-    GTEST_FLAG(internal_run_death_test) = internal_run_death_test_;
-    GTEST_FLAG(list_tests) = list_tests_;
-    GTEST_FLAG(output) = output_;
-    GTEST_FLAG(print_time) = print_time_;
-    GTEST_FLAG(random_seed) = random_seed_;
-    GTEST_FLAG(repeat) = repeat_;
-    GTEST_FLAG(shuffle) = shuffle_;
-    GTEST_FLAG(stack_trace_depth) = stack_trace_depth_;
-    GTEST_FLAG(stream_result_to) = stream_result_to_;
-    GTEST_FLAG(throw_on_failure) = throw_on_failure_;
-  }
- private:
-  // Fields for saving the original values of flags.
-  bool also_run_disabled_tests_;
-  bool break_on_failure_;
-  bool catch_exceptions_;
-  String color_;
-  String death_test_style_;
-  bool death_test_use_fork_;
-  String filter_;
-  String internal_run_death_test_;
-  bool list_tests_;
-  String output_;
-  bool print_time_;
-  bool pretty_;
-  internal::Int32 random_seed_;
-  internal::Int32 repeat_;
-  bool shuffle_;
-  internal::Int32 stack_trace_depth_;
-  String stream_result_to_;
-  bool throw_on_failure_;
-} GTEST_ATTRIBUTE_UNUSED_;
-
-// Converts a Unicode code point to a narrow string in UTF-8 encoding.
-// code_point parameter is of type UInt32 because wchar_t may not be
-// wide enough to contain a code point.
-// The output buffer str must containt at least 32 characters.
-// The function returns the address of the output buffer.
-// If the code_point is not a valid Unicode code point
-// (i.e. outside of Unicode range U+0 to U+10FFFF) it will be output
-// as '(Invalid Unicode 0xXXXXXXXX)'.
-GTEST_API_ char* CodePointToUtf8(UInt32 code_point, char* str);
-
-// Converts a wide string to a narrow string in UTF-8 encoding.
-// The wide string is assumed to have the following encoding:
-//   UTF-16 if sizeof(wchar_t) == 2 (on Windows, Cygwin, Symbian OS)
-//   UTF-32 if sizeof(wchar_t) == 4 (on Linux)
-// Parameter str points to a null-terminated wide string.
-// Parameter num_chars may additionally limit the number
-// of wchar_t characters processed. -1 is used when the entire string
-// should be processed.
-// If the string contains code points that are not valid Unicode code points
-// (i.e. outside of Unicode range U+0 to U+10FFFF) they will be output
-// as '(Invalid Unicode 0xXXXXXXXX)'. If the string is in UTF16 encoding
-// and contains invalid UTF-16 surrogate pairs, values in those pairs
-// will be encoded as individual Unicode characters from Basic Normal Plane.
-GTEST_API_ String WideStringToUtf8(const wchar_t* str, int num_chars);
-
-// Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file
-// if the variable is present. If a file already exists at this location, this
-// function will write over it. If the variable is present, but the file cannot
-// be created, prints an error and exits.
-void WriteToShardStatusFileIfNeeded();
-
-// Checks whether sharding is enabled by examining the relevant
-// environment variable values. If the variables are present,
-// but inconsistent (e.g., shard_index >= total_shards), prints
-// an error and exits. If in_subprocess_for_death_test, sharding is
-// disabled because it must only be applied to the original test
-// process. Otherwise, we could filter out death tests we intended to execute.
-GTEST_API_ bool ShouldShard(const char* total_shards_str,
-                            const char* shard_index_str,
-                            bool in_subprocess_for_death_test);
-
-// Parses the environment variable var as an Int32. If it is unset,
-// returns default_val. If it is not an Int32, prints an error and
-// and aborts.
-GTEST_API_ Int32 Int32FromEnvOrDie(const char* env_var, Int32 default_val);
-
-// Given the total number of shards, the shard index, and the test id,
-// returns true iff the test should be run on this shard. The test id is
-// some arbitrary but unique non-negative integer assigned to each test
-// method. Assumes that 0 <= shard_index < total_shards.
-GTEST_API_ bool ShouldRunTestOnShard(
-    int total_shards, int shard_index, int test_id);
-
-// STL container utilities.
-
-// Returns the number of elements in the given container that satisfy
-// the given predicate.
-template <class Container, typename Predicate>
-inline int CountIf(const Container& c, Predicate predicate) {
-  // Implemented as an explicit loop since std::count_if() in libCstd on
-  // Solaris has a non-standard signature.
-  int count = 0;
-  for (typename Container::const_iterator it = c.begin(); it != c.end(); ++it) {
-    if (predicate(*it))
-      ++count;
-  }
-  return count;
-}
-
-// Applies a function/functor to each element in the container.
-template <class Container, typename Functor>
-void ForEach(const Container& c, Functor functor) {
-  std::for_each(c.begin(), c.end(), functor);
-}
-
-// Returns the i-th element of the vector, or default_value if i is not
-// in range [0, v.size()).
-template <typename E>
-inline E GetElementOr(const std::vector<E>& v, int i, E default_value) {
-  return (i < 0 || i >= static_cast<int>(v.size())) ? default_value : v[i];
-}
-
-// Performs an in-place shuffle of a range of the vector's elements.
-// 'begin' and 'end' are element indices as an STL-style range;
-// i.e. [begin, end) are shuffled, where 'end' == size() means to
-// shuffle to the end of the vector.
-template <typename E>
-void ShuffleRange(internal::Random* random, int begin, int end,
-                  std::vector<E>* v) {
-  const int size = static_cast<int>(v->size());
-  GTEST_CHECK_(0 <= begin && begin <= size)
-      << "Invalid shuffle range start " << begin << ": must be in range [0, "
-      << size << "].";
-  GTEST_CHECK_(begin <= end && end <= size)
-      << "Invalid shuffle range finish " << end << ": must be in range ["
-      << begin << ", " << size << "].";
-
-  // Fisher-Yates shuffle, from
-  // http://en.wikipedia.org/wiki/Fisher-Yates_shuffle
-  for (int range_width = end - begin; range_width >= 2; range_width--) {
-    const int last_in_range = begin + range_width - 1;
-    const int selected = begin + random->Generate(range_width);
-    std::swap((*v)[selected], (*v)[last_in_range]);
-  }
-}
-
-// Performs an in-place shuffle of the vector's elements.
-template <typename E>
-inline void Shuffle(internal::Random* random, std::vector<E>* v) {
-  ShuffleRange(random, 0, static_cast<int>(v->size()), v);
-}
-
-// A function for deleting an object.  Handy for being used as a
-// functor.
-template <typename T>
-static void Delete(T* x) {
-  delete x;
-}
-
-// A predicate that checks the key of a TestProperty against a known key.
-//
-// TestPropertyKeyIs is copyable.
-class TestPropertyKeyIs {
- public:
-  // Constructor.
-  //
-  // TestPropertyKeyIs has NO default constructor.
-  explicit TestPropertyKeyIs(const char* key)
-      : key_(key) {}
-
-  // Returns true iff the test name of test property matches on key_.
-  bool operator()(const TestProperty& test_property) const {
-    return String(test_property.key()).Compare(key_) == 0;
-  }
-
- private:
-  String key_;
-};
-
-// Class UnitTestOptions.
-//
-// This class contains functions for processing options the user
-// specifies when running the tests.  It has only static members.
-//
-// In most cases, the user can specify an option using either an
-// environment variable or a command line flag.  E.g. you can set the
-// test filter using either GTEST_FILTER or --gtest_filter.  If both
-// the variable and the flag are present, the latter overrides the
-// former.
-class GTEST_API_ UnitTestOptions {
- public:
-  // Functions for processing the gtest_output flag.
-
-  // Returns the output format, or "" for normal printed output.
-  static String GetOutputFormat();
-
-  // Returns the absolute path of the requested output file, or the
-  // default (test_detail.xml in the original working directory) if
-  // none was explicitly specified.
-  static String GetAbsolutePathToOutputFile();
-
-  // Functions for processing the gtest_filter flag.
-
-  // Returns true iff the wildcard pattern matches the string.  The
-  // first ':' or '\0' character in pattern marks the end of it.
-  //
-  // This recursive algorithm isn't very efficient, but is clear and
-  // works well enough for matching test names, which are short.
-  static bool PatternMatchesString(const char *pattern, const char *str);
-
-  // Returns true iff the user-specified filter matches the test case
-  // name and the test name.
-  static bool FilterMatchesTest(const String &test_case_name,
-                                const String &test_name);
-
-#if GTEST_OS_WINDOWS
-  // Function for supporting the gtest_catch_exception flag.
-
-  // Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the
-  // given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.
-  // This function is useful as an __except condition.
-  static int GTestShouldProcessSEH(DWORD exception_code);
-#endif  // GTEST_OS_WINDOWS
-
-  // Returns true if "name" matches the ':' separated list of glob-style
-  // filters in "filter".
-  static bool MatchesFilter(const String& name, const char* filter);
-};
-
-// Returns the current application's name, removing directory path if that
-// is present.  Used by UnitTestOptions::GetOutputFile.
-GTEST_API_ FilePath GetCurrentExecutableName();
-
-// The role interface for getting the OS stack trace as a string.
-class OsStackTraceGetterInterface {
- public:
-  OsStackTraceGetterInterface() {}
-  virtual ~OsStackTraceGetterInterface() {}
-
-  // Returns the current OS stack trace as a String.  Parameters:
-  //
-  //   max_depth  - the maximum number of stack frames to be included
-  //                in the trace.
-  //   skip_count - the number of top frames to be skipped; doesn't count
-  //                against max_depth.
-  virtual String CurrentStackTrace(int max_depth, int skip_count) = 0;
-
-  // UponLeavingGTest() should be called immediately before Google Test calls
-  // user code. It saves some information about the current stack that
-  // CurrentStackTrace() will use to find and hide Google Test stack frames.
-  virtual void UponLeavingGTest() = 0;
-
- private:
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetterInterface);
-};
-
-// A working implementation of the OsStackTraceGetterInterface interface.
-class OsStackTraceGetter : public OsStackTraceGetterInterface {
- public:
-  OsStackTraceGetter() : caller_frame_(NULL) {}
-  virtual String CurrentStackTrace(int max_depth, int skip_count);
-  virtual void UponLeavingGTest();
-
-  // This string is inserted in place of stack frames that are part of
-  // Google Test's implementation.
-  static const char* const kElidedFramesMarker;
-
- private:
-  Mutex mutex_;  // protects all internal state
-
-  // We save the stack frame below the frame that calls user code.
-  // We do this because the address of the frame immediately below
-  // the user code changes between the call to UponLeavingGTest()
-  // and any calls to CurrentStackTrace() from within the user code.
-  void* caller_frame_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetter);
-};
-
-// Information about a Google Test trace point.
-struct TraceInfo {
-  const char* file;
-  int line;
-  String message;
-};
-
-// This is the default global test part result reporter used in UnitTestImpl.
-// This class should only be used by UnitTestImpl.
-class DefaultGlobalTestPartResultReporter
-  : public TestPartResultReporterInterface {
- public:
-  explicit DefaultGlobalTestPartResultReporter(UnitTestImpl* unit_test);
-  // Implements the TestPartResultReporterInterface. Reports the test part
-  // result in the current test.
-  virtual void ReportTestPartResult(const TestPartResult& result);
-
- private:
-  UnitTestImpl* const unit_test_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultGlobalTestPartResultReporter);
-};
-
-// This is the default per thread test part result reporter used in
-// UnitTestImpl. This class should only be used by UnitTestImpl.
-class DefaultPerThreadTestPartResultReporter
-    : public TestPartResultReporterInterface {
- public:
-  explicit DefaultPerThreadTestPartResultReporter(UnitTestImpl* unit_test);
-  // Implements the TestPartResultReporterInterface. The implementation just
-  // delegates to the current global test part result reporter of *unit_test_.
-  virtual void ReportTestPartResult(const TestPartResult& result);
-
- private:
-  UnitTestImpl* const unit_test_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultPerThreadTestPartResultReporter);
-};
-
-// The private implementation of the UnitTest class.  We don't protect
-// the methods under a mutex, as this class is not accessible by a
-// user and the UnitTest class that delegates work to this class does
-// proper locking.
-class GTEST_API_ UnitTestImpl {
- public:
-  explicit UnitTestImpl(UnitTest* parent);
-  virtual ~UnitTestImpl();
-
-  // There are two different ways to register your own TestPartResultReporter.
-  // You can register your own repoter to listen either only for test results
-  // from the current thread or for results from all threads.
-  // By default, each per-thread test result repoter just passes a new
-  // TestPartResult to the global test result reporter, which registers the
-  // test part result for the currently running test.
-
-  // Returns the global test part result reporter.
-  TestPartResultReporterInterface* GetGlobalTestPartResultReporter();
-
-  // Sets the global test part result reporter.
-  void SetGlobalTestPartResultReporter(
-      TestPartResultReporterInterface* reporter);
-
-  // Returns the test part result reporter for the current thread.
-  TestPartResultReporterInterface* GetTestPartResultReporterForCurrentThread();
-
-  // Sets the test part result reporter for the current thread.
-  void SetTestPartResultReporterForCurrentThread(
-      TestPartResultReporterInterface* reporter);
-
-  // Gets the number of successful test cases.
-  int successful_test_case_count() const;
-
-  // Gets the number of failed test cases.
-  int failed_test_case_count() const;
-
-  // Gets the number of all test cases.
-  int total_test_case_count() const;
-
-  // Gets the number of all test cases that contain at least one test
-  // that should run.
-  int test_case_to_run_count() const;
-
-  // Gets the number of successful tests.
-  int successful_test_count() const;
-
-  // Gets the number of failed tests.
-  int failed_test_count() const;
-
-  // Gets the number of disabled tests.
-  int disabled_test_count() const;
-
-  // Gets the number of all tests.
-  int total_test_count() const;
-
-  // Gets the number of tests that should run.
-  int test_to_run_count() const;
-
-  // Gets the elapsed time, in milliseconds.
-  TimeInMillis elapsed_time() const { return elapsed_time_; }
-
-  // Returns true iff the unit test passed (i.e. all test cases passed).
-  bool Passed() const { return !Failed(); }
-
-  // Returns true iff the unit test failed (i.e. some test case failed
-  // or something outside of all tests failed).
-  bool Failed() const {
-    return failed_test_case_count() > 0 || ad_hoc_test_result()->Failed();
-  }
-
-  // Gets the i-th test case among all the test cases. i can range from 0 to
-  // total_test_case_count() - 1. If i is not in that range, returns NULL.
-  const TestCase* GetTestCase(int i) const {
-    const int index = GetElementOr(test_case_indices_, i, -1);
-    return index < 0 ? NULL : test_cases_[i];
-  }
-
-  // Gets the i-th test case among all the test cases. i can range from 0 to
-  // total_test_case_count() - 1. If i is not in that range, returns NULL.
-  TestCase* GetMutableTestCase(int i) {
-    const int index = GetElementOr(test_case_indices_, i, -1);
-    return index < 0 ? NULL : test_cases_[index];
-  }
-
-  // Provides access to the event listener list.
-  TestEventListeners* listeners() { return &listeners_; }
-
-  // Returns the TestResult for the test that's currently running, or
-  // the TestResult for the ad hoc test if no test is running.
-  TestResult* current_test_result();
-
-  // Returns the TestResult for the ad hoc test.
-  const TestResult* ad_hoc_test_result() const { return &ad_hoc_test_result_; }
-
-  // Sets the OS stack trace getter.
-  //
-  // Does nothing if the input and the current OS stack trace getter
-  // are the same; otherwise, deletes the old getter and makes the
-  // input the current getter.
-  void set_os_stack_trace_getter(OsStackTraceGetterInterface* getter);
-
-  // Returns the current OS stack trace getter if it is not NULL;
-  // otherwise, creates an OsStackTraceGetter, makes it the current
-  // getter, and returns it.
-  OsStackTraceGetterInterface* os_stack_trace_getter();
-
-  // Returns the current OS stack trace as a String.
-  //
-  // The maximum number of stack frames to be included is specified by
-  // the gtest_stack_trace_depth flag.  The skip_count parameter
-  // specifies the number of top frames to be skipped, which doesn't
-  // count against the number of frames to be included.
-  //
-  // For example, if Foo() calls Bar(), which in turn calls
-  // CurrentOsStackTraceExceptTop(1), Foo() will be included in the
-  // trace but Bar() and CurrentOsStackTraceExceptTop() won't.
-  String CurrentOsStackTraceExceptTop(int skip_count);
-
-  // Finds and returns a TestCase with the given name.  If one doesn't
-  // exist, creates one and returns it.
-  //
-  // Arguments:
-  //
-  //   test_case_name: name of the test case
-  //   type_param:     the name of the test's type parameter, or NULL if
-  //                   this is not a typed or a type-parameterized test.
-  //   set_up_tc:      pointer to the function that sets up the test case
-  //   tear_down_tc:   pointer to the function that tears down the test case
-  TestCase* GetTestCase(const char* test_case_name,
-                        const char* type_param,
-                        Test::SetUpTestCaseFunc set_up_tc,
-                        Test::TearDownTestCaseFunc tear_down_tc);
-
-  // Adds a TestInfo to the unit test.
-  //
-  // Arguments:
-  //
-  //   set_up_tc:    pointer to the function that sets up the test case
-  //   tear_down_tc: pointer to the function that tears down the test case
-  //   test_info:    the TestInfo object
-  void AddTestInfo(Test::SetUpTestCaseFunc set_up_tc,
-                   Test::TearDownTestCaseFunc tear_down_tc,
-                   TestInfo* test_info) {
-    // In order to support thread-safe death tests, we need to
-    // remember the original working directory when the test program
-    // was first invoked.  We cannot do this in RUN_ALL_TESTS(), as
-    // the user may have changed the current directory before calling
-    // RUN_ALL_TESTS().  Therefore we capture the current directory in
-    // AddTestInfo(), which is called to register a TEST or TEST_F
-    // before main() is reached.
-    if (original_working_dir_.IsEmpty()) {
-      original_working_dir_.Set(FilePath::GetCurrentDir());
-      GTEST_CHECK_(!original_working_dir_.IsEmpty())
-          << "Failed to get the current working directory.";
-    }
-
-    GetTestCase(test_info->test_case_name(),
-                test_info->type_param(),
-                set_up_tc,
-                tear_down_tc)->AddTestInfo(test_info);
-  }
-
-#if GTEST_HAS_PARAM_TEST
-  // Returns ParameterizedTestCaseRegistry object used to keep track of
-  // value-parameterized tests and instantiate and register them.
-  internal::ParameterizedTestCaseRegistry& parameterized_test_registry() {
-    return parameterized_test_registry_;
-  }
-#endif  // GTEST_HAS_PARAM_TEST
-
-  // Sets the TestCase object for the test that's currently running.
-  void set_current_test_case(TestCase* a_current_test_case) {
-    current_test_case_ = a_current_test_case;
-  }
-
-  // Sets the TestInfo object for the test that's currently running.  If
-  // current_test_info is NULL, the assertion results will be stored in
-  // ad_hoc_test_result_.
-  void set_current_test_info(TestInfo* a_current_test_info) {
-    current_test_info_ = a_current_test_info;
-  }
-
-  // Registers all parameterized tests defined using TEST_P and
-  // INSTANTIATE_TEST_CASE_P, creating regular tests for each test/parameter
-  // combination. This method can be called more then once; it has guards
-  // protecting from registering the tests more then once.  If
-  // value-parameterized tests are disabled, RegisterParameterizedTests is
-  // present but does nothing.
-  void RegisterParameterizedTests();
-
-  // Runs all tests in this UnitTest object, prints the result, and
-  // returns true if all tests are successful.  If any exception is
-  // thrown during a test, this test is considered to be failed, but
-  // the rest of the tests will still be run.
-  bool RunAllTests();
-
-  // Clears the results of all tests, except the ad hoc tests.
-  void ClearNonAdHocTestResult() {
-    ForEach(test_cases_, TestCase::ClearTestCaseResult);
-  }
-
-  // Clears the results of ad-hoc test assertions.
-  void ClearAdHocTestResult() {
-    ad_hoc_test_result_.Clear();
-  }
-
-  enum ReactionToSharding {
-    HONOR_SHARDING_PROTOCOL,
-    IGNORE_SHARDING_PROTOCOL
-  };
-
-  // Matches the full name of each test against the user-specified
-  // filter to decide whether the test should run, then records the
-  // result in each TestCase and TestInfo object.
-  // If shard_tests == HONOR_SHARDING_PROTOCOL, further filters tests
-  // based on sharding variables in the environment.
-  // Returns the number of tests that should run.
-  int FilterTests(ReactionToSharding shard_tests);
-
-  // Prints the names of the tests matching the user-specified filter flag.
-  void ListTestsMatchingFilter();
-
-  const TestCase* current_test_case() const { return current_test_case_; }
-  TestInfo* current_test_info() { return current_test_info_; }
-  const TestInfo* current_test_info() const { return current_test_info_; }
-
-  // Returns the vector of environments that need to be set-up/torn-down
-  // before/after the tests are run.
-  std::vector<Environment*>& environments() { return environments_; }
-
-  // Getters for the per-thread Google Test trace stack.
-  std::vector<TraceInfo>& gtest_trace_stack() {
-    return *(gtest_trace_stack_.pointer());
-  }
-  const std::vector<TraceInfo>& gtest_trace_stack() const {
-    return gtest_trace_stack_.get();
-  }
-
-#if GTEST_HAS_DEATH_TEST
-  void InitDeathTestSubprocessControlInfo() {
-    internal_run_death_test_flag_.reset(ParseInternalRunDeathTestFlag());
-  }
-  // Returns a pointer to the parsed --gtest_internal_run_death_test
-  // flag, or NULL if that flag was not specified.
-  // This information is useful only in a death test child process.
-  // Must not be called before a call to InitGoogleTest.
-  const InternalRunDeathTestFlag* internal_run_death_test_flag() const {
-    return internal_run_death_test_flag_.get();
-  }
-
-  // Returns a pointer to the current death test factory.
-  internal::DeathTestFactory* death_test_factory() {
-    return death_test_factory_.get();
-  }
-
-  void SuppressTestEventsIfInSubprocess();
-
-  friend class ReplaceDeathTestFactory;
-#endif  // GTEST_HAS_DEATH_TEST
-
-  // Initializes the event listener performing XML output as specified by
-  // UnitTestOptions. Must not be called before InitGoogleTest.
-  void ConfigureXmlOutput();
-
-#if GTEST_CAN_STREAM_RESULTS_
-  // Initializes the event listener for streaming test results to a socket.
-  // Must not be called before InitGoogleTest.
-  void ConfigureStreamingOutput();
-#endif
-
-  // Performs initialization dependent upon flag values obtained in
-  // ParseGoogleTestFlagsOnly.  Is called from InitGoogleTest after the call to
-  // ParseGoogleTestFlagsOnly.  In case a user neglects to call InitGoogleTest
-  // this function is also called from RunAllTests.  Since this function can be
-  // called more than once, it has to be idempotent.
-  void PostFlagParsingInit();
-
-  // Gets the random seed used at the start of the current test iteration.
-  int random_seed() const { return random_seed_; }
-
-  // Gets the random number generator.
-  internal::Random* random() { return &random_; }
-
-  // Shuffles all test cases, and the tests within each test case,
-  // making sure that death tests are still run first.
-  void ShuffleTests();
-
-  // Restores the test cases and tests to their order before the first shuffle.
-  void UnshuffleTests();
-
-  // Returns the value of GTEST_FLAG(catch_exceptions) at the moment
-  // UnitTest::Run() starts.
-  bool catch_exceptions() const { return catch_exceptions_; }
-
- private:
-  friend class ::testing::UnitTest;
-
-  // Used by UnitTest::Run() to capture the state of
-  // GTEST_FLAG(catch_exceptions) at the moment it starts.
-  void set_catch_exceptions(bool value) { catch_exceptions_ = value; }
-
-  // The UnitTest object that owns this implementation object.
-  UnitTest* const parent_;
-
-  // The working directory when the first TEST() or TEST_F() was
-  // executed.
-  internal::FilePath original_working_dir_;
-
-  // The default test part result reporters.
-  DefaultGlobalTestPartResultReporter default_global_test_part_result_reporter_;
-  DefaultPerThreadTestPartResultReporter
-      default_per_thread_test_part_result_reporter_;
-
-  // Points to (but doesn't own) the global test part result reporter.
-  TestPartResultReporterInterface* global_test_part_result_repoter_;
-
-  // Protects read and write access to global_test_part_result_reporter_.
-  internal::Mutex global_test_part_result_reporter_mutex_;
-
-  // Points to (but doesn't own) the per-thread test part result reporter.
-  internal::ThreadLocal<TestPartResultReporterInterface*>
-      per_thread_test_part_result_reporter_;
-
-  // The vector of environments that need to be set-up/torn-down
-  // before/after the tests are run.
-  std::vector<Environment*> environments_;
-
-  // The vector of TestCases in their original order.  It owns the
-  // elements in the vector.
-  std::vector<TestCase*> test_cases_;
-
-  // Provides a level of indirection for the test case list to allow
-  // easy shuffling and restoring the test case order.  The i-th
-  // element of this vector is the index of the i-th test case in the
-  // shuffled order.
-  std::vector<int> test_case_indices_;
-
-#if GTEST_HAS_PARAM_TEST
-  // ParameterizedTestRegistry object used to register value-parameterized
-  // tests.
-  internal::ParameterizedTestCaseRegistry parameterized_test_registry_;
-
-  // Indicates whether RegisterParameterizedTests() has been called already.
-  bool parameterized_tests_registered_;
-#endif  // GTEST_HAS_PARAM_TEST
-
-  // Index of the last death test case registered.  Initially -1.
-  int last_death_test_case_;
-
-  // This points to the TestCase for the currently running test.  It
-  // changes as Google Test goes through one test case after another.
-  // When no test is running, this is set to NULL and Google Test
-  // stores assertion results in ad_hoc_test_result_.  Initially NULL.
-  TestCase* current_test_case_;
-
-  // This points to the TestInfo for the currently running test.  It
-  // changes as Google Test goes through one test after another.  When
-  // no test is running, this is set to NULL and Google Test stores
-  // assertion results in ad_hoc_test_result_.  Initially NULL.
-  TestInfo* current_test_info_;
-
-  // Normally, a user only writes assertions inside a TEST or TEST_F,
-  // or inside a function called by a TEST or TEST_F.  Since Google
-  // Test keeps track of which test is current running, it can
-  // associate such an assertion with the test it belongs to.
-  //
-  // If an assertion is encountered when no TEST or TEST_F is running,
-  // Google Test attributes the assertion result to an imaginary "ad hoc"
-  // test, and records the result in ad_hoc_test_result_.
-  TestResult ad_hoc_test_result_;
-
-  // The list of event listeners that can be used to track events inside
-  // Google Test.
-  TestEventListeners listeners_;
-
-  // The OS stack trace getter.  Will be deleted when the UnitTest
-  // object is destructed.  By default, an OsStackTraceGetter is used,
-  // but the user can set this field to use a custom getter if that is
-  // desired.
-  OsStackTraceGetterInterface* os_stack_trace_getter_;
-
-  // True iff PostFlagParsingInit() has been called.
-  bool post_flag_parse_init_performed_;
-
-  // The random number seed used at the beginning of the test run.
-  int random_seed_;
-
-  // Our random number generator.
-  internal::Random random_;
-
-  // How long the test took to run, in milliseconds.
-  TimeInMillis elapsed_time_;
-
-#if GTEST_HAS_DEATH_TEST
-  // The decomposed components of the gtest_internal_run_death_test flag,
-  // parsed when RUN_ALL_TESTS is called.
-  internal::scoped_ptr<InternalRunDeathTestFlag> internal_run_death_test_flag_;
-  internal::scoped_ptr<internal::DeathTestFactory> death_test_factory_;
-#endif  // GTEST_HAS_DEATH_TEST
-
-  // A per-thread stack of traces created by the SCOPED_TRACE() macro.
-  internal::ThreadLocal<std::vector<TraceInfo> > gtest_trace_stack_;
-
-  // The value of GTEST_FLAG(catch_exceptions) at the moment RunAllTests()
-  // starts.
-  bool catch_exceptions_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTestImpl);
-};  // class UnitTestImpl
-
-// Convenience function for accessing the global UnitTest
-// implementation object.
-inline UnitTestImpl* GetUnitTestImpl() {
-  return UnitTest::GetInstance()->impl();
-}
-
-#if GTEST_USES_SIMPLE_RE
-
-// Internal helper functions for implementing the simple regular
-// expression matcher.
-GTEST_API_ bool IsInSet(char ch, const char* str);
-GTEST_API_ bool IsAsciiDigit(char ch);
-GTEST_API_ bool IsAsciiPunct(char ch);
-GTEST_API_ bool IsRepeat(char ch);
-GTEST_API_ bool IsAsciiWhiteSpace(char ch);
-GTEST_API_ bool IsAsciiWordChar(char ch);
-GTEST_API_ bool IsValidEscape(char ch);
-GTEST_API_ bool AtomMatchesChar(bool escaped, char pattern, char ch);
-GTEST_API_ bool ValidateRegex(const char* regex);
-GTEST_API_ bool MatchRegexAtHead(const char* regex, const char* str);
-GTEST_API_ bool MatchRepetitionAndRegexAtHead(
-    bool escaped, char ch, char repeat, const char* regex, const char* str);
-GTEST_API_ bool MatchRegexAnywhere(const char* regex, const char* str);
-
-#endif  // GTEST_USES_SIMPLE_RE
-
-// Parses the command line for Google Test flags, without initializing
-// other parts of Google Test.
-GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, char** argv);
-GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv);
-
-#if GTEST_HAS_DEATH_TEST
-
-// Returns the message describing the last system error, regardless of the
-// platform.
-GTEST_API_ String GetLastErrnoDescription();
-
-# if GTEST_OS_WINDOWS
-// Provides leak-safe Windows kernel handle ownership.
-class AutoHandle {
- public:
-  AutoHandle() : handle_(INVALID_HANDLE_VALUE) {}
-  explicit AutoHandle(HANDLE handle) : handle_(handle) {}
-
-  ~AutoHandle() { Reset(); }
-
-  HANDLE Get() const { return handle_; }
-  void Reset() { Reset(INVALID_HANDLE_VALUE); }
-  void Reset(HANDLE handle) {
-    if (handle != handle_) {
-      if (handle_ != INVALID_HANDLE_VALUE)
-        ::CloseHandle(handle_);
-      handle_ = handle;
-    }
-  }
-
- private:
-  HANDLE handle_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(AutoHandle);
-};
-# endif  // GTEST_OS_WINDOWS
-
-// Attempts to parse a string into a positive integer pointed to by the
-// number parameter.  Returns true if that is possible.
-// GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we can use
-// it here.
-template <typename Integer>
-bool ParseNaturalNumber(const ::std::string& str, Integer* number) {
-  // Fail fast if the given string does not begin with a digit;
-  // this bypasses strtoXXX's "optional leading whitespace and plus
-  // or minus sign" semantics, which are undesirable here.
-  if (str.empty() || !IsDigit(str[0])) {
-    return false;
-  }
-  errno = 0;
-
-  char* end;
-  // BiggestConvertible is the largest integer type that system-provided
-  // string-to-number conversion routines can return.
-
-# if GTEST_OS_WINDOWS && !defined(__GNUC__)
-
-  // MSVC and C++ Builder define __int64 instead of the standard long long.
-  typedef unsigned __int64 BiggestConvertible;
-  const BiggestConvertible parsed = _strtoui64(str.c_str(), &end, 10);
-
-# else
-
-  typedef unsigned long long BiggestConvertible;  // NOLINT
-  const BiggestConvertible parsed = strtoull(str.c_str(), &end, 10);
-
-# endif  // GTEST_OS_WINDOWS && !defined(__GNUC__)
-
-  const bool parse_success = *end == '\0' && errno == 0;
-
-  // TODO(vladl at google.com): Convert this to compile time assertion when it is
-  // available.
-  GTEST_CHECK_(sizeof(Integer) <= sizeof(parsed));
-
-  const Integer result = static_cast<Integer>(parsed);
-  if (parse_success && static_cast<BiggestConvertible>(result) == parsed) {
-    *number = result;
-    return true;
-  }
-  return false;
-}
-#endif  // GTEST_HAS_DEATH_TEST
-
-// TestResult contains some private methods that should be hidden from
-// Google Test user but are required for testing. This class allow our tests
-// to access them.
-//
-// This class is supplied only for the purpose of testing Google Test's own
-// constructs. Do not use it in user tests, either directly or indirectly.
-class TestResultAccessor {
- public:
-  static void RecordProperty(TestResult* test_result,
-                             const TestProperty& property) {
-    test_result->RecordProperty(property);
-  }
-
-  static void ClearTestPartResults(TestResult* test_result) {
-    test_result->ClearTestPartResults();
-  }
-
-  static const std::vector<testing::TestPartResult>& test_part_results(
-      const TestResult& test_result) {
-    return test_result.test_part_results();
-  }
-};
-
-}  // namespace internal
-}  // namespace testing
-
-#endif  // GTEST_SRC_GTEST_INTERNAL_INL_H_
diff --git a/bamtools/src/third_party/gtest-1.6.0/src/gtest-port.cc b/bamtools/src/third_party/gtest-1.6.0/src/gtest-port.cc
deleted file mode 100644
index b860d48..0000000
--- a/bamtools/src/third_party/gtest-1.6.0/src/gtest-port.cc
+++ /dev/null
@@ -1,746 +0,0 @@
-// Copyright 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan at google.com (Zhanyong Wan)
-
-#include "gtest/internal/gtest-port.h"
-
-#include <limits.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#if GTEST_OS_WINDOWS_MOBILE
-# include <windows.h>  // For TerminateProcess()
-#elif GTEST_OS_WINDOWS
-# include <io.h>
-# include <sys/stat.h>
-#else
-# include <unistd.h>
-#endif  // GTEST_OS_WINDOWS_MOBILE
-
-#if GTEST_OS_MAC
-# include <mach/mach_init.h>
-# include <mach/task.h>
-# include <mach/vm_map.h>
-#endif  // GTEST_OS_MAC
-
-#include "gtest/gtest-spi.h"
-#include "gtest/gtest-message.h"
-#include "gtest/internal/gtest-internal.h"
-#include "gtest/internal/gtest-string.h"
-
-// Indicates that this translation unit is part of Google Test's
-// implementation.  It must come before gtest-internal-inl.h is
-// included, or there will be a compiler error.  This trick is to
-// prevent a user from accidentally including gtest-internal-inl.h in
-// his code.
-#define GTEST_IMPLEMENTATION_ 1
-#include "src/gtest-internal-inl.h"
-#undef GTEST_IMPLEMENTATION_
-
-namespace testing {
-namespace internal {
-
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-// MSVC and C++Builder do not provide a definition of STDERR_FILENO.
-const int kStdOutFileno = 1;
-const int kStdErrFileno = 2;
-#else
-const int kStdOutFileno = STDOUT_FILENO;
-const int kStdErrFileno = STDERR_FILENO;
-#endif  // _MSC_VER
-
-#if GTEST_OS_MAC
-
-// Returns the number of threads running in the process, or 0 to indicate that
-// we cannot detect it.
-size_t GetThreadCount() {
-  const task_t task = mach_task_self();
-  mach_msg_type_number_t thread_count;
-  thread_act_array_t thread_list;
-  const kern_return_t status = task_threads(task, &thread_list, &thread_count);
-  if (status == KERN_SUCCESS) {
-    // task_threads allocates resources in thread_list and we need to free them
-    // to avoid leaks.
-    vm_deallocate(task,
-                  reinterpret_cast<vm_address_t>(thread_list),
-                  sizeof(thread_t) * thread_count);
-    return static_cast<size_t>(thread_count);
-  } else {
-    return 0;
-  }
-}
-
-#else
-
-size_t GetThreadCount() {
-  // There's no portable way to detect the number of threads, so we just
-  // return 0 to indicate that we cannot detect it.
-  return 0;
-}
-
-#endif  // GTEST_OS_MAC
-
-#if GTEST_USES_POSIX_RE
-
-// Implements RE.  Currently only needed for death tests.
-
-RE::~RE() {
-  if (is_valid_) {
-    // regfree'ing an invalid regex might crash because the content
-    // of the regex is undefined. Since the regex's are essentially
-    // the same, one cannot be valid (or invalid) without the other
-    // being so too.
-    regfree(&partial_regex_);
-    regfree(&full_regex_);
-  }
-  free(const_cast<char*>(pattern_));
-}
-
-// Returns true iff regular expression re matches the entire str.
-bool RE::FullMatch(const char* str, const RE& re) {
-  if (!re.is_valid_) return false;
-
-  regmatch_t match;
-  return regexec(&re.full_regex_, str, 1, &match, 0) == 0;
-}
-
-// Returns true iff regular expression re matches a substring of str
-// (including str itself).
-bool RE::PartialMatch(const char* str, const RE& re) {
-  if (!re.is_valid_) return false;
-
-  regmatch_t match;
-  return regexec(&re.partial_regex_, str, 1, &match, 0) == 0;
-}
-
-// Initializes an RE from its string representation.
-void RE::Init(const char* regex) {
-  pattern_ = posix::StrDup(regex);
-
-  // Reserves enough bytes to hold the regular expression used for a
-  // full match.
-  const size_t full_regex_len = strlen(regex) + 10;
-  char* const full_pattern = new char[full_regex_len];
-
-  snprintf(full_pattern, full_regex_len, "^(%s)$", regex);
-  is_valid_ = regcomp(&full_regex_, full_pattern, REG_EXTENDED) == 0;
-  // We want to call regcomp(&partial_regex_, ...) even if the
-  // previous expression returns false.  Otherwise partial_regex_ may
-  // not be properly initialized can may cause trouble when it's
-  // freed.
-  //
-  // Some implementation of POSIX regex (e.g. on at least some
-  // versions of Cygwin) doesn't accept the empty string as a valid
-  // regex.  We change it to an equivalent form "()" to be safe.
-  if (is_valid_) {
-    const char* const partial_regex = (*regex == '\0') ? "()" : regex;
-    is_valid_ = regcomp(&partial_regex_, partial_regex, REG_EXTENDED) == 0;
-  }
-  EXPECT_TRUE(is_valid_)
-      << "Regular expression \"" << regex
-      << "\" is not a valid POSIX Extended regular expression.";
-
-  delete[] full_pattern;
-}
-
-#elif GTEST_USES_SIMPLE_RE
-
-// Returns true iff ch appears anywhere in str (excluding the
-// terminating '\0' character).
-bool IsInSet(char ch, const char* str) {
-  return ch != '\0' && strchr(str, ch) != NULL;
-}
-
-// Returns true iff ch belongs to the given classification.  Unlike
-// similar functions in <ctype.h>, these aren't affected by the
-// current locale.
-bool IsAsciiDigit(char ch) { return '0' <= ch && ch <= '9'; }
-bool IsAsciiPunct(char ch) {
-  return IsInSet(ch, "^-!\"#$%&'()*+,./:;<=>?@[\\]_`{|}~");
-}
-bool IsRepeat(char ch) { return IsInSet(ch, "?*+"); }
-bool IsAsciiWhiteSpace(char ch) { return IsInSet(ch, " \f\n\r\t\v"); }
-bool IsAsciiWordChar(char ch) {
-  return ('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z') ||
-      ('0' <= ch && ch <= '9') || ch == '_';
-}
-
-// Returns true iff "\\c" is a supported escape sequence.
-bool IsValidEscape(char c) {
-  return (IsAsciiPunct(c) || IsInSet(c, "dDfnrsStvwW"));
-}
-
-// Returns true iff the given atom (specified by escaped and pattern)
-// matches ch.  The result is undefined if the atom is invalid.
-bool AtomMatchesChar(bool escaped, char pattern_char, char ch) {
-  if (escaped) {  // "\\p" where p is pattern_char.
-    switch (pattern_char) {
-      case 'd': return IsAsciiDigit(ch);
-      case 'D': return !IsAsciiDigit(ch);
-      case 'f': return ch == '\f';
-      case 'n': return ch == '\n';
-      case 'r': return ch == '\r';
-      case 's': return IsAsciiWhiteSpace(ch);
-      case 'S': return !IsAsciiWhiteSpace(ch);
-      case 't': return ch == '\t';
-      case 'v': return ch == '\v';
-      case 'w': return IsAsciiWordChar(ch);
-      case 'W': return !IsAsciiWordChar(ch);
-    }
-    return IsAsciiPunct(pattern_char) && pattern_char == ch;
-  }
-
-  return (pattern_char == '.' && ch != '\n') || pattern_char == ch;
-}
-
-// Helper function used by ValidateRegex() to format error messages.
-String FormatRegexSyntaxError(const char* regex, int index) {
-  return (Message() << "Syntax error at index " << index
-          << " in simple regular expression \"" << regex << "\": ").GetString();
-}
-
-// Generates non-fatal failures and returns false if regex is invalid;
-// otherwise returns true.
-bool ValidateRegex(const char* regex) {
-  if (regex == NULL) {
-    // TODO(wan at google.com): fix the source file location in the
-    // assertion failures to match where the regex is used in user
-    // code.
-    ADD_FAILURE() << "NULL is not a valid simple regular expression.";
-    return false;
-  }
-
-  bool is_valid = true;
-
-  // True iff ?, *, or + can follow the previous atom.
-  bool prev_repeatable = false;
-  for (int i = 0; regex[i]; i++) {
-    if (regex[i] == '\\') {  // An escape sequence
-      i++;
-      if (regex[i] == '\0') {
-        ADD_FAILURE() << FormatRegexSyntaxError(regex, i - 1)
-                      << "'\\' cannot appear at the end.";
-        return false;
-      }
-
-      if (!IsValidEscape(regex[i])) {
-        ADD_FAILURE() << FormatRegexSyntaxError(regex, i - 1)
-                      << "invalid escape sequence \"\\" << regex[i] << "\".";
-        is_valid = false;
-      }
-      prev_repeatable = true;
-    } else {  // Not an escape sequence.
-      const char ch = regex[i];
-
-      if (ch == '^' && i > 0) {
-        ADD_FAILURE() << FormatRegexSyntaxError(regex, i)
-                      << "'^' can only appear at the beginning.";
-        is_valid = false;
-      } else if (ch == '$' && regex[i + 1] != '\0') {
-        ADD_FAILURE() << FormatRegexSyntaxError(regex, i)
-                      << "'$' can only appear at the end.";
-        is_valid = false;
-      } else if (IsInSet(ch, "()[]{}|")) {
-        ADD_FAILURE() << FormatRegexSyntaxError(regex, i)
-                      << "'" << ch << "' is unsupported.";
-        is_valid = false;
-      } else if (IsRepeat(ch) && !prev_repeatable) {
-        ADD_FAILURE() << FormatRegexSyntaxError(regex, i)
-                      << "'" << ch << "' can only follow a repeatable token.";
-        is_valid = false;
-      }
-
-      prev_repeatable = !IsInSet(ch, "^$?*+");
-    }
-  }
-
-  return is_valid;
-}
-
-// Matches a repeated regex atom followed by a valid simple regular
-// expression.  The regex atom is defined as c if escaped is false,
-// or \c otherwise.  repeat is the repetition meta character (?, *,
-// or +).  The behavior is undefined if str contains too many
-// characters to be indexable by size_t, in which case the test will
-// probably time out anyway.  We are fine with this limitation as
-// std::string has it too.
-bool MatchRepetitionAndRegexAtHead(
-    bool escaped, char c, char repeat, const char* regex,
-    const char* str) {
-  const size_t min_count = (repeat == '+') ? 1 : 0;
-  const size_t max_count = (repeat == '?') ? 1 :
-      static_cast<size_t>(-1) - 1;
-  // We cannot call numeric_limits::max() as it conflicts with the
-  // max() macro on Windows.
-
-  for (size_t i = 0; i <= max_count; ++i) {
-    // We know that the atom matches each of the first i characters in str.
-    if (i >= min_count && MatchRegexAtHead(regex, str + i)) {
-      // We have enough matches at the head, and the tail matches too.
-      // Since we only care about *whether* the pattern matches str
-      // (as opposed to *how* it matches), there is no need to find a
-      // greedy match.
-      return true;
-    }
-    if (str[i] == '\0' || !AtomMatchesChar(escaped, c, str[i]))
-      return false;
-  }
-  return false;
-}
-
-// Returns true iff regex matches a prefix of str.  regex must be a
-// valid simple regular expression and not start with "^", or the
-// result is undefined.
-bool MatchRegexAtHead(const char* regex, const char* str) {
-  if (*regex == '\0')  // An empty regex matches a prefix of anything.
-    return true;
-
-  // "$" only matches the end of a string.  Note that regex being
-  // valid guarantees that there's nothing after "$" in it.
-  if (*regex == '$')
-    return *str == '\0';
-
-  // Is the first thing in regex an escape sequence?
-  const bool escaped = *regex == '\\';
-  if (escaped)
-    ++regex;
-  if (IsRepeat(regex[1])) {
-    // MatchRepetitionAndRegexAtHead() calls MatchRegexAtHead(), so
-    // here's an indirect recursion.  It terminates as the regex gets
-    // shorter in each recursion.
-    return MatchRepetitionAndRegexAtHead(
-        escaped, regex[0], regex[1], regex + 2, str);
-  } else {
-    // regex isn't empty, isn't "$", and doesn't start with a
-    // repetition.  We match the first atom of regex with the first
-    // character of str and recurse.
-    return (*str != '\0') && AtomMatchesChar(escaped, *regex, *str) &&
-        MatchRegexAtHead(regex + 1, str + 1);
-  }
-}
-
-// Returns true iff regex matches any substring of str.  regex must be
-// a valid simple regular expression, or the result is undefined.
-//
-// The algorithm is recursive, but the recursion depth doesn't exceed
-// the regex length, so we won't need to worry about running out of
-// stack space normally.  In rare cases the time complexity can be
-// exponential with respect to the regex length + the string length,
-// but usually it's must faster (often close to linear).
-bool MatchRegexAnywhere(const char* regex, const char* str) {
-  if (regex == NULL || str == NULL)
-    return false;
-
-  if (*regex == '^')
-    return MatchRegexAtHead(regex + 1, str);
-
-  // A successful match can be anywhere in str.
-  do {
-    if (MatchRegexAtHead(regex, str))
-      return true;
-  } while (*str++ != '\0');
-  return false;
-}
-
-// Implements the RE class.
-
-RE::~RE() {
-  free(const_cast<char*>(pattern_));
-  free(const_cast<char*>(full_pattern_));
-}
-
-// Returns true iff regular expression re matches the entire str.
-bool RE::FullMatch(const char* str, const RE& re) {
-  return re.is_valid_ && MatchRegexAnywhere(re.full_pattern_, str);
-}
-
-// Returns true iff regular expression re matches a substring of str
-// (including str itself).
-bool RE::PartialMatch(const char* str, const RE& re) {
-  return re.is_valid_ && MatchRegexAnywhere(re.pattern_, str);
-}
-
-// Initializes an RE from its string representation.
-void RE::Init(const char* regex) {
-  pattern_ = full_pattern_ = NULL;
-  if (regex != NULL) {
-    pattern_ = posix::StrDup(regex);
-  }
-
-  is_valid_ = ValidateRegex(regex);
-  if (!is_valid_) {
-    // No need to calculate the full pattern when the regex is invalid.
-    return;
-  }
-
-  const size_t len = strlen(regex);
-  // Reserves enough bytes to hold the regular expression used for a
-  // full match: we need space to prepend a '^', append a '$', and
-  // terminate the string with '\0'.
-  char* buffer = static_cast<char*>(malloc(len + 3));
-  full_pattern_ = buffer;
-
-  if (*regex != '^')
-    *buffer++ = '^';  // Makes sure full_pattern_ starts with '^'.
-
-  // We don't use snprintf or strncpy, as they trigger a warning when
-  // compiled with VC++ 8.0.
-  memcpy(buffer, regex, len);
-  buffer += len;
-
-  if (len == 0 || regex[len - 1] != '$')
-    *buffer++ = '$';  // Makes sure full_pattern_ ends with '$'.
-
-  *buffer = '\0';
-}
-
-#endif  // GTEST_USES_POSIX_RE
-
-const char kUnknownFile[] = "unknown file";
-
-// Formats a source file path and a line number as they would appear
-// in an error message from the compiler used to compile this code.
-GTEST_API_ ::std::string FormatFileLocation(const char* file, int line) {
-  const char* const file_name = file == NULL ? kUnknownFile : file;
-
-  if (line < 0) {
-    return String::Format("%s:", file_name).c_str();
-  }
-#ifdef _MSC_VER
-  return String::Format("%s(%d):", file_name, line).c_str();
-#else
-  return String::Format("%s:%d:", file_name, line).c_str();
-#endif  // _MSC_VER
-}
-
-// Formats a file location for compiler-independent XML output.
-// Although this function is not platform dependent, we put it next to
-// FormatFileLocation in order to contrast the two functions.
-// Note that FormatCompilerIndependentFileLocation() does NOT append colon
-// to the file location it produces, unlike FormatFileLocation().
-GTEST_API_ ::std::string FormatCompilerIndependentFileLocation(
-    const char* file, int line) {
-  const char* const file_name = file == NULL ? kUnknownFile : file;
-
-  if (line < 0)
-    return file_name;
-  else
-    return String::Format("%s:%d", file_name, line).c_str();
-}
-
-
-GTestLog::GTestLog(GTestLogSeverity severity, const char* file, int line)
-    : severity_(severity) {
-  const char* const marker =
-      severity == GTEST_INFO ?    "[  INFO ]" :
-      severity == GTEST_WARNING ? "[WARNING]" :
-      severity == GTEST_ERROR ?   "[ ERROR ]" : "[ FATAL ]";
-  GetStream() << ::std::endl << marker << " "
-              << FormatFileLocation(file, line).c_str() << ": ";
-}
-
-// Flushes the buffers and, if severity is GTEST_FATAL, aborts the program.
-GTestLog::~GTestLog() {
-  GetStream() << ::std::endl;
-  if (severity_ == GTEST_FATAL) {
-    fflush(stderr);
-    posix::Abort();
-  }
-}
-// Disable Microsoft deprecation warnings for POSIX functions called from
-// this class (creat, dup, dup2, and close)
-#ifdef _MSC_VER
-# pragma warning(push)
-# pragma warning(disable: 4996)
-#endif  // _MSC_VER
-
-#if GTEST_HAS_STREAM_REDIRECTION
-
-// Object that captures an output stream (stdout/stderr).
-class CapturedStream {
- public:
-  // The ctor redirects the stream to a temporary file.
-  CapturedStream(int fd) : fd_(fd), uncaptured_fd_(dup(fd)) {
-
-# if GTEST_OS_WINDOWS
-    char temp_dir_path[MAX_PATH + 1] = { '\0' };  // NOLINT
-    char temp_file_path[MAX_PATH + 1] = { '\0' };  // NOLINT
-
-    ::GetTempPathA(sizeof(temp_dir_path), temp_dir_path);
-    const UINT success = ::GetTempFileNameA(temp_dir_path,
-                                            "gtest_redir",
-                                            0,  // Generate unique file name.
-                                            temp_file_path);
-    GTEST_CHECK_(success != 0)
-        << "Unable to create a temporary file in " << temp_dir_path;
-    const int captured_fd = creat(temp_file_path, _S_IREAD | _S_IWRITE);
-    GTEST_CHECK_(captured_fd != -1) << "Unable to open temporary file "
-                                    << temp_file_path;
-    filename_ = temp_file_path;
-# else
-    // There's no guarantee that a test has write access to the
-    // current directory, so we create the temporary file in the /tmp
-    // directory instead.
-    char name_template[] = "/tmp/captured_stream.XXXXXX";
-    const int captured_fd = mkstemp(name_template);
-    filename_ = name_template;
-# endif  // GTEST_OS_WINDOWS
-    fflush(NULL);
-    dup2(captured_fd, fd_);
-    close(captured_fd);
-  }
-
-  ~CapturedStream() {
-    remove(filename_.c_str());
-  }
-
-  String GetCapturedString() {
-    if (uncaptured_fd_ != -1) {
-      // Restores the original stream.
-      fflush(NULL);
-      dup2(uncaptured_fd_, fd_);
-      close(uncaptured_fd_);
-      uncaptured_fd_ = -1;
-    }
-
-    FILE* const file = posix::FOpen(filename_.c_str(), "r");
-    const String content = ReadEntireFile(file);
-    posix::FClose(file);
-    return content;
-  }
-
- private:
-  // Reads the entire content of a file as a String.
-  static String ReadEntireFile(FILE* file);
-
-  // Returns the size (in bytes) of a file.
-  static size_t GetFileSize(FILE* file);
-
-  const int fd_;  // A stream to capture.
-  int uncaptured_fd_;
-  // Name of the temporary file holding the stderr output.
-  ::std::string filename_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(CapturedStream);
-};
-
-// Returns the size (in bytes) of a file.
-size_t CapturedStream::GetFileSize(FILE* file) {
-  fseek(file, 0, SEEK_END);
-  return static_cast<size_t>(ftell(file));
-}
-
-// Reads the entire content of a file as a string.
-String CapturedStream::ReadEntireFile(FILE* file) {
-  const size_t file_size = GetFileSize(file);
-  char* const buffer = new char[file_size];
-
-  size_t bytes_last_read = 0;  // # of bytes read in the last fread()
-  size_t bytes_read = 0;       // # of bytes read so far
-
-  fseek(file, 0, SEEK_SET);
-
-  // Keeps reading the file until we cannot read further or the
-  // pre-determined file size is reached.
-  do {
-    bytes_last_read = fread(buffer+bytes_read, 1, file_size-bytes_read, file);
-    bytes_read += bytes_last_read;
-  } while (bytes_last_read > 0 && bytes_read < file_size);
-
-  const String content(buffer, bytes_read);
-  delete[] buffer;
-
-  return content;
-}
-
-# ifdef _MSC_VER
-#  pragma warning(pop)
-# endif  // _MSC_VER
-
-static CapturedStream* g_captured_stderr = NULL;
-static CapturedStream* g_captured_stdout = NULL;
-
-// Starts capturing an output stream (stdout/stderr).
-void CaptureStream(int fd, const char* stream_name, CapturedStream** stream) {
-  if (*stream != NULL) {
-    GTEST_LOG_(FATAL) << "Only one " << stream_name
-                      << " capturer can exist at a time.";
-  }
-  *stream = new CapturedStream(fd);
-}
-
-// Stops capturing the output stream and returns the captured string.
-String GetCapturedStream(CapturedStream** captured_stream) {
-  const String content = (*captured_stream)->GetCapturedString();
-
-  delete *captured_stream;
-  *captured_stream = NULL;
-
-  return content;
-}
-
-// Starts capturing stdout.
-void CaptureStdout() {
-  CaptureStream(kStdOutFileno, "stdout", &g_captured_stdout);
-}
-
-// Starts capturing stderr.
-void CaptureStderr() {
-  CaptureStream(kStdErrFileno, "stderr", &g_captured_stderr);
-}
-
-// Stops capturing stdout and returns the captured string.
-String GetCapturedStdout() { return GetCapturedStream(&g_captured_stdout); }
-
-// Stops capturing stderr and returns the captured string.
-String GetCapturedStderr() { return GetCapturedStream(&g_captured_stderr); }
-
-#endif  // GTEST_HAS_STREAM_REDIRECTION
-
-#if GTEST_HAS_DEATH_TEST
-
-// A copy of all command line arguments.  Set by InitGoogleTest().
-::std::vector<String> g_argvs;
-
-// Returns the command line as a vector of strings.
-const ::std::vector<String>& GetArgvs() { return g_argvs; }
-
-#endif  // GTEST_HAS_DEATH_TEST
-
-#if GTEST_OS_WINDOWS_MOBILE
-namespace posix {
-void Abort() {
-  DebugBreak();
-  TerminateProcess(GetCurrentProcess(), 1);
-}
-}  // namespace posix
-#endif  // GTEST_OS_WINDOWS_MOBILE
-
-// Returns the name of the environment variable corresponding to the
-// given flag.  For example, FlagToEnvVar("foo") will return
-// "GTEST_FOO" in the open-source version.
-static String FlagToEnvVar(const char* flag) {
-  const String full_flag =
-      (Message() << GTEST_FLAG_PREFIX_ << flag).GetString();
-
-  Message env_var;
-  for (size_t i = 0; i != full_flag.length(); i++) {
-    env_var << ToUpper(full_flag.c_str()[i]);
-  }
-
-  return env_var.GetString();
-}
-
-// Parses 'str' for a 32-bit signed integer.  If successful, writes
-// the result to *value and returns true; otherwise leaves *value
-// unchanged and returns false.
-bool ParseInt32(const Message& src_text, const char* str, Int32* value) {
-  // Parses the environment variable as a decimal integer.
-  char* end = NULL;
-  const long long_value = strtol(str, &end, 10);  // NOLINT
-
-  // Has strtol() consumed all characters in the string?
-  if (*end != '\0') {
-    // No - an invalid character was encountered.
-    Message msg;
-    msg << "WARNING: " << src_text
-        << " is expected to be a 32-bit integer, but actually"
-        << " has value \"" << str << "\".\n";
-    printf("%s", msg.GetString().c_str());
-    fflush(stdout);
-    return false;
-  }
-
-  // Is the parsed value in the range of an Int32?
-  const Int32 result = static_cast<Int32>(long_value);
-  if (long_value == LONG_MAX || long_value == LONG_MIN ||
-      // The parsed value overflows as a long.  (strtol() returns
-      // LONG_MAX or LONG_MIN when the input overflows.)
-      result != long_value
-      // The parsed value overflows as an Int32.
-      ) {
-    Message msg;
-    msg << "WARNING: " << src_text
-        << " is expected to be a 32-bit integer, but actually"
-        << " has value " << str << ", which overflows.\n";
-    printf("%s", msg.GetString().c_str());
-    fflush(stdout);
-    return false;
-  }
-
-  *value = result;
-  return true;
-}
-
-// Reads and returns the Boolean environment variable corresponding to
-// the given flag; if it's not set, returns default_value.
-//
-// The value is considered true iff it's not "0".
-bool BoolFromGTestEnv(const char* flag, bool default_value) {
-  const String env_var = FlagToEnvVar(flag);
-  const char* const string_value = posix::GetEnv(env_var.c_str());
-  return string_value == NULL ?
-      default_value : strcmp(string_value, "0") != 0;
-}
-
-// Reads and returns a 32-bit integer stored in the environment
-// variable corresponding to the given flag; if it isn't set or
-// doesn't represent a valid 32-bit integer, returns default_value.
-Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) {
-  const String env_var = FlagToEnvVar(flag);
-  const char* const string_value = posix::GetEnv(env_var.c_str());
-  if (string_value == NULL) {
-    // The environment variable is not set.
-    return default_value;
-  }
-
-  Int32 result = default_value;
-  if (!ParseInt32(Message() << "Environment variable " << env_var,
-                  string_value, &result)) {
-    printf("The default value %s is used.\n",
-           (Message() << default_value).GetString().c_str());
-    fflush(stdout);
-    return default_value;
-  }
-
-  return result;
-}
-
-// Reads and returns the string environment variable corresponding to
-// the given flag; if it's not set, returns default_value.
-const char* StringFromGTestEnv(const char* flag, const char* default_value) {
-  const String env_var = FlagToEnvVar(flag);
-  const char* const value = posix::GetEnv(env_var.c_str());
-  return value == NULL ? default_value : value;
-}
-
-}  // namespace internal
-}  // namespace testing
diff --git a/bamtools/src/third_party/gtest-1.6.0/src/gtest-printers.cc b/bamtools/src/third_party/gtest-1.6.0/src/gtest-printers.cc
deleted file mode 100644
index ed63c7b..0000000
--- a/bamtools/src/third_party/gtest-1.6.0/src/gtest-printers.cc
+++ /dev/null
@@ -1,356 +0,0 @@
-// Copyright 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan at google.com (Zhanyong Wan)
-
-// Google Test - The Google C++ Testing Framework
-//
-// This file implements a universal value printer that can print a
-// value of any type T:
-//
-//   void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_ptr);
-//
-// It uses the << operator when possible, and prints the bytes in the
-// object otherwise.  A user can override its behavior for a class
-// type Foo by defining either operator<<(::std::ostream&, const Foo&)
-// or void PrintTo(const Foo&, ::std::ostream*) in the namespace that
-// defines Foo.
-
-#include "gtest/gtest-printers.h"
-#include <ctype.h>
-#include <stdio.h>
-#include <ostream>  // NOLINT
-#include <string>
-#include "gtest/internal/gtest-port.h"
-
-namespace testing {
-
-namespace {
-
-using ::std::ostream;
-
-#if GTEST_OS_WINDOWS_MOBILE  // Windows CE does not define _snprintf_s.
-# define snprintf _snprintf
-#elif _MSC_VER >= 1400  // VC 8.0 and later deprecate snprintf and _snprintf.
-# define snprintf _snprintf_s
-#elif _MSC_VER
-# define snprintf _snprintf
-#endif  // GTEST_OS_WINDOWS_MOBILE
-
-// Prints a segment of bytes in the given object.
-void PrintByteSegmentInObjectTo(const unsigned char* obj_bytes, size_t start,
-                                size_t count, ostream* os) {
-  char text[5] = "";
-  for (size_t i = 0; i != count; i++) {
-    const size_t j = start + i;
-    if (i != 0) {
-      // Organizes the bytes into groups of 2 for easy parsing by
-      // human.
-      if ((j % 2) == 0)
-        *os << ' ';
-      else
-        *os << '-';
-    }
-    snprintf(text, sizeof(text), "%02X", obj_bytes[j]);
-    *os << text;
-  }
-}
-
-// Prints the bytes in the given value to the given ostream.
-void PrintBytesInObjectToImpl(const unsigned char* obj_bytes, size_t count,
-                              ostream* os) {
-  // Tells the user how big the object is.
-  *os << count << "-byte object <";
-
-  const size_t kThreshold = 132;
-  const size_t kChunkSize = 64;
-  // If the object size is bigger than kThreshold, we'll have to omit
-  // some details by printing only the first and the last kChunkSize
-  // bytes.
-  // TODO(wan): let the user control the threshold using a flag.
-  if (count < kThreshold) {
-    PrintByteSegmentInObjectTo(obj_bytes, 0, count, os);
-  } else {
-    PrintByteSegmentInObjectTo(obj_bytes, 0, kChunkSize, os);
-    *os << " ... ";
-    // Rounds up to 2-byte boundary.
-    const size_t resume_pos = (count - kChunkSize + 1)/2*2;
-    PrintByteSegmentInObjectTo(obj_bytes, resume_pos, count - resume_pos, os);
-  }
-  *os << ">";
-}
-
-}  // namespace
-
-namespace internal2 {
-
-// Delegates to PrintBytesInObjectToImpl() to print the bytes in the
-// given object.  The delegation simplifies the implementation, which
-// uses the << operator and thus is easier done outside of the
-// ::testing::internal namespace, which contains a << operator that
-// sometimes conflicts with the one in STL.
-void PrintBytesInObjectTo(const unsigned char* obj_bytes, size_t count,
-                          ostream* os) {
-  PrintBytesInObjectToImpl(obj_bytes, count, os);
-}
-
-}  // namespace internal2
-
-namespace internal {
-
-// Depending on the value of a char (or wchar_t), we print it in one
-// of three formats:
-//   - as is if it's a printable ASCII (e.g. 'a', '2', ' '),
-//   - as a hexidecimal escape sequence (e.g. '\x7F'), or
-//   - as a special escape sequence (e.g. '\r', '\n').
-enum CharFormat {
-  kAsIs,
-  kHexEscape,
-  kSpecialEscape
-};
-
-// Returns true if c is a printable ASCII character.  We test the
-// value of c directly instead of calling isprint(), which is buggy on
-// Windows Mobile.
-inline bool IsPrintableAscii(wchar_t c) {
-  return 0x20 <= c && c <= 0x7E;
-}
-
-// Prints a wide or narrow char c as a character literal without the
-// quotes, escaping it when necessary; returns how c was formatted.
-// The template argument UnsignedChar is the unsigned version of Char,
-// which is the type of c.
-template <typename UnsignedChar, typename Char>
-static CharFormat PrintAsCharLiteralTo(Char c, ostream* os) {
-  switch (static_cast<wchar_t>(c)) {
-    case L'\0':
-      *os << "\\0";
-      break;
-    case L'\'':
-      *os << "\\'";
-      break;
-    case L'\\':
-      *os << "\\\\";
-      break;
-    case L'\a':
-      *os << "\\a";
-      break;
-    case L'\b':
-      *os << "\\b";
-      break;
-    case L'\f':
-      *os << "\\f";
-      break;
-    case L'\n':
-      *os << "\\n";
-      break;
-    case L'\r':
-      *os << "\\r";
-      break;
-    case L'\t':
-      *os << "\\t";
-      break;
-    case L'\v':
-      *os << "\\v";
-      break;
-    default:
-      if (IsPrintableAscii(c)) {
-        *os << static_cast<char>(c);
-        return kAsIs;
-      } else {
-        *os << String::Format("\\x%X", static_cast<UnsignedChar>(c));
-        return kHexEscape;
-      }
-  }
-  return kSpecialEscape;
-}
-
-// Prints a char c as if it's part of a string literal, escaping it when
-// necessary; returns how c was formatted.
-static CharFormat PrintAsWideStringLiteralTo(wchar_t c, ostream* os) {
-  switch (c) {
-    case L'\'':
-      *os << "'";
-      return kAsIs;
-    case L'"':
-      *os << "\\\"";
-      return kSpecialEscape;
-    default:
-      return PrintAsCharLiteralTo<wchar_t>(c, os);
-  }
-}
-
-// Prints a char c as if it's part of a string literal, escaping it when
-// necessary; returns how c was formatted.
-static CharFormat PrintAsNarrowStringLiteralTo(char c, ostream* os) {
-  return PrintAsWideStringLiteralTo(static_cast<unsigned char>(c), os);
-}
-
-// Prints a wide or narrow character c and its code.  '\0' is printed
-// as "'\\0'", other unprintable characters are also properly escaped
-// using the standard C++ escape sequence.  The template argument
-// UnsignedChar is the unsigned version of Char, which is the type of c.
-template <typename UnsignedChar, typename Char>
-void PrintCharAndCodeTo(Char c, ostream* os) {
-  // First, print c as a literal in the most readable form we can find.
-  *os << ((sizeof(c) > 1) ? "L'" : "'");
-  const CharFormat format = PrintAsCharLiteralTo<UnsignedChar>(c, os);
-  *os << "'";
-
-  // To aid user debugging, we also print c's code in decimal, unless
-  // it's 0 (in which case c was printed as '\\0', making the code
-  // obvious).
-  if (c == 0)
-    return;
-  *os << " (" << String::Format("%d", c).c_str();
-
-  // For more convenience, we print c's code again in hexidecimal,
-  // unless c was already printed in the form '\x##' or the code is in
-  // [1, 9].
-  if (format == kHexEscape || (1 <= c && c <= 9)) {
-    // Do nothing.
-  } else {
-    *os << String::Format(", 0x%X",
-                          static_cast<UnsignedChar>(c)).c_str();
-  }
-  *os << ")";
-}
-
-void PrintTo(unsigned char c, ::std::ostream* os) {
-  PrintCharAndCodeTo<unsigned char>(c, os);
-}
-void PrintTo(signed char c, ::std::ostream* os) {
-  PrintCharAndCodeTo<unsigned char>(c, os);
-}
-
-// Prints a wchar_t as a symbol if it is printable or as its internal
-// code otherwise and also as its code.  L'\0' is printed as "L'\\0'".
-void PrintTo(wchar_t wc, ostream* os) {
-  PrintCharAndCodeTo<wchar_t>(wc, os);
-}
-
-// Prints the given array of characters to the ostream.
-// The array starts at *begin, the length is len, it may include '\0' characters
-// and may not be null-terminated.
-static void PrintCharsAsStringTo(const char* begin, size_t len, ostream* os) {
-  *os << "\"";
-  bool is_previous_hex = false;
-  for (size_t index = 0; index < len; ++index) {
-    const char cur = begin[index];
-    if (is_previous_hex && IsXDigit(cur)) {
-      // Previous character is of '\x..' form and this character can be
-      // interpreted as another hexadecimal digit in its number. Break string to
-      // disambiguate.
-      *os << "\" \"";
-    }
-    is_previous_hex = PrintAsNarrowStringLiteralTo(cur, os) == kHexEscape;
-  }
-  *os << "\"";
-}
-
-// Prints a (const) char array of 'len' elements, starting at address 'begin'.
-void UniversalPrintArray(const char* begin, size_t len, ostream* os) {
-  PrintCharsAsStringTo(begin, len, os);
-}
-
-// Prints the given array of wide characters to the ostream.
-// The array starts at *begin, the length is len, it may include L'\0'
-// characters and may not be null-terminated.
-static void PrintWideCharsAsStringTo(const wchar_t* begin, size_t len,
-                                     ostream* os) {
-  *os << "L\"";
-  bool is_previous_hex = false;
-  for (size_t index = 0; index < len; ++index) {
-    const wchar_t cur = begin[index];
-    if (is_previous_hex && isascii(cur) && IsXDigit(static_cast<char>(cur))) {
-      // Previous character is of '\x..' form and this character can be
-      // interpreted as another hexadecimal digit in its number. Break string to
-      // disambiguate.
-      *os << "\" L\"";
-    }
-    is_previous_hex = PrintAsWideStringLiteralTo(cur, os) == kHexEscape;
-  }
-  *os << "\"";
-}
-
-// Prints the given C string to the ostream.
-void PrintTo(const char* s, ostream* os) {
-  if (s == NULL) {
-    *os << "NULL";
-  } else {
-    *os << ImplicitCast_<const void*>(s) << " pointing to ";
-    PrintCharsAsStringTo(s, strlen(s), os);
-  }
-}
-
-// MSVC compiler can be configured to define whar_t as a typedef
-// of unsigned short. Defining an overload for const wchar_t* in that case
-// would cause pointers to unsigned shorts be printed as wide strings,
-// possibly accessing more memory than intended and causing invalid
-// memory accesses. MSVC defines _NATIVE_WCHAR_T_DEFINED symbol when
-// wchar_t is implemented as a native type.
-#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
-// Prints the given wide C string to the ostream.
-void PrintTo(const wchar_t* s, ostream* os) {
-  if (s == NULL) {
-    *os << "NULL";
-  } else {
-    *os << ImplicitCast_<const void*>(s) << " pointing to ";
-    PrintWideCharsAsStringTo(s, wcslen(s), os);
-  }
-}
-#endif  // wchar_t is native
-
-// Prints a ::string object.
-#if GTEST_HAS_GLOBAL_STRING
-void PrintStringTo(const ::string& s, ostream* os) {
-  PrintCharsAsStringTo(s.data(), s.size(), os);
-}
-#endif  // GTEST_HAS_GLOBAL_STRING
-
-void PrintStringTo(const ::std::string& s, ostream* os) {
-  PrintCharsAsStringTo(s.data(), s.size(), os);
-}
-
-// Prints a ::wstring object.
-#if GTEST_HAS_GLOBAL_WSTRING
-void PrintWideStringTo(const ::wstring& s, ostream* os) {
-  PrintWideCharsAsStringTo(s.data(), s.size(), os);
-}
-#endif  // GTEST_HAS_GLOBAL_WSTRING
-
-#if GTEST_HAS_STD_WSTRING
-void PrintWideStringTo(const ::std::wstring& s, ostream* os) {
-  PrintWideCharsAsStringTo(s.data(), s.size(), os);
-}
-#endif  // GTEST_HAS_STD_WSTRING
-
-}  // namespace internal
-
-}  // namespace testing
diff --git a/bamtools/src/third_party/gtest-1.6.0/src/gtest-test-part.cc b/bamtools/src/third_party/gtest-1.6.0/src/gtest-test-part.cc
deleted file mode 100644
index 5ddc67c..0000000
--- a/bamtools/src/third_party/gtest-1.6.0/src/gtest-test-part.cc
+++ /dev/null
@@ -1,110 +0,0 @@
-// Copyright 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: mheule at google.com (Markus Heule)
-//
-// The Google C++ Testing Framework (Google Test)
-
-#include "gtest/gtest-test-part.h"
-
-// Indicates that this translation unit is part of Google Test's
-// implementation.  It must come before gtest-internal-inl.h is
-// included, or there will be a compiler error.  This trick is to
-// prevent a user from accidentally including gtest-internal-inl.h in
-// his code.
-#define GTEST_IMPLEMENTATION_ 1
-#include "src/gtest-internal-inl.h"
-#undef GTEST_IMPLEMENTATION_
-
-namespace testing {
-
-using internal::GetUnitTestImpl;
-
-// Gets the summary of the failure message by omitting the stack trace
-// in it.
-internal::String TestPartResult::ExtractSummary(const char* message) {
-  const char* const stack_trace = strstr(message, internal::kStackTraceMarker);
-  return stack_trace == NULL ? internal::String(message) :
-      internal::String(message, stack_trace - message);
-}
-
-// Prints a TestPartResult object.
-std::ostream& operator<<(std::ostream& os, const TestPartResult& result) {
-  return os
-      << result.file_name() << ":" << result.line_number() << ": "
-      << (result.type() == TestPartResult::kSuccess ? "Success" :
-          result.type() == TestPartResult::kFatalFailure ? "Fatal failure" :
-          "Non-fatal failure") << ":\n"
-      << result.message() << std::endl;
-}
-
-// Appends a TestPartResult to the array.
-void TestPartResultArray::Append(const TestPartResult& result) {
-  array_.push_back(result);
-}
-
-// Returns the TestPartResult at the given index (0-based).
-const TestPartResult& TestPartResultArray::GetTestPartResult(int index) const {
-  if (index < 0 || index >= size()) {
-    printf("\nInvalid index (%d) into TestPartResultArray.\n", index);
-    internal::posix::Abort();
-  }
-
-  return array_[index];
-}
-
-// Returns the number of TestPartResult objects in the array.
-int TestPartResultArray::size() const {
-  return static_cast<int>(array_.size());
-}
-
-namespace internal {
-
-HasNewFatalFailureHelper::HasNewFatalFailureHelper()
-    : has_new_fatal_failure_(false),
-      original_reporter_(GetUnitTestImpl()->
-                         GetTestPartResultReporterForCurrentThread()) {
-  GetUnitTestImpl()->SetTestPartResultReporterForCurrentThread(this);
-}
-
-HasNewFatalFailureHelper::~HasNewFatalFailureHelper() {
-  GetUnitTestImpl()->SetTestPartResultReporterForCurrentThread(
-      original_reporter_);
-}
-
-void HasNewFatalFailureHelper::ReportTestPartResult(
-    const TestPartResult& result) {
-  if (result.fatally_failed())
-    has_new_fatal_failure_ = true;
-  original_reporter_->ReportTestPartResult(result);
-}
-
-}  // namespace internal
-
-}  // namespace testing
diff --git a/bamtools/src/third_party/gtest-1.6.0/src/gtest-typed-test.cc b/bamtools/src/third_party/gtest-1.6.0/src/gtest-typed-test.cc
deleted file mode 100644
index a5cc88f..0000000
--- a/bamtools/src/third_party/gtest-1.6.0/src/gtest-typed-test.cc
+++ /dev/null
@@ -1,110 +0,0 @@
-// Copyright 2008 Google Inc.
-// All Rights Reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan at google.com (Zhanyong Wan)
-
-#include "gtest/gtest-typed-test.h"
-#include "gtest/gtest.h"
-
-namespace testing {
-namespace internal {
-
-#if GTEST_HAS_TYPED_TEST_P
-
-// Skips to the first non-space char in str. Returns an empty string if str
-// contains only whitespace characters.
-static const char* SkipSpaces(const char* str) {
-  while (IsSpace(*str))
-    str++;
-  return str;
-}
-
-// Verifies that registered_tests match the test names in
-// defined_test_names_; returns registered_tests if successful, or
-// aborts the program otherwise.
-const char* TypedTestCasePState::VerifyRegisteredTestNames(
-    const char* file, int line, const char* registered_tests) {
-  typedef ::std::set<const char*>::const_iterator DefinedTestIter;
-  registered_ = true;
-
-  // Skip initial whitespace in registered_tests since some
-  // preprocessors prefix stringizied literals with whitespace.
-  registered_tests = SkipSpaces(registered_tests);
-
-  Message errors;
-  ::std::set<String> tests;
-  for (const char* names = registered_tests; names != NULL;
-       names = SkipComma(names)) {
-    const String name = GetPrefixUntilComma(names);
-    if (tests.count(name) != 0) {
-      errors << "Test " << name << " is listed more than once.\n";
-      continue;
-    }
-
-    bool found = false;
-    for (DefinedTestIter it = defined_test_names_.begin();
-         it != defined_test_names_.end();
-         ++it) {
-      if (name == *it) {
-        found = true;
-        break;
-      }
-    }
-
-    if (found) {
-      tests.insert(name);
-    } else {
-      errors << "No test named " << name
-             << " can be found in this test case.\n";
-    }
-  }
-
-  for (DefinedTestIter it = defined_test_names_.begin();
-       it != defined_test_names_.end();
-       ++it) {
-    if (tests.count(*it) == 0) {
-      errors << "You forgot to list test " << *it << ".\n";
-    }
-  }
-
-  const String& errors_str = errors.GetString();
-  if (errors_str != "") {
-    fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(),
-            errors_str.c_str());
-    fflush(stderr);
-    posix::Abort();
-  }
-
-  return registered_tests;
-}
-
-#endif  // GTEST_HAS_TYPED_TEST_P
-
-}  // namespace internal
-}  // namespace testing
diff --git a/bamtools/src/third_party/gtest-1.6.0/src/gtest.cc b/bamtools/src/third_party/gtest-1.6.0/src/gtest.cc
deleted file mode 100644
index 904d9d7..0000000
--- a/bamtools/src/third_party/gtest-1.6.0/src/gtest.cc
+++ /dev/null
@@ -1,4898 +0,0 @@
-// Copyright 2005, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan at google.com (Zhanyong Wan)
-//
-// The Google C++ Testing Framework (Google Test)
-
-#include "gtest/gtest.h"
-#include "gtest/gtest-spi.h"
-
-#include <ctype.h>
-#include <math.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <wchar.h>
-#include <wctype.h>
-
-#include <algorithm>
-#include <ostream>  // NOLINT
-#include <sstream>
-#include <vector>
-
-#if GTEST_OS_LINUX
-
-// TODO(kenton at google.com): Use autoconf to detect availability of
-// gettimeofday().
-# define GTEST_HAS_GETTIMEOFDAY_ 1
-
-# include <fcntl.h>  // NOLINT
-# include <limits.h>  // NOLINT
-# include <sched.h>  // NOLINT
-// Declares vsnprintf().  This header is not available on Windows.
-# include <strings.h>  // NOLINT
-# include <sys/mman.h>  // NOLINT
-# include <sys/time.h>  // NOLINT
-# include <unistd.h>  // NOLINT
-# include <string>
-
-#elif GTEST_OS_SYMBIAN
-# define GTEST_HAS_GETTIMEOFDAY_ 1
-# include <sys/time.h>  // NOLINT
-
-#elif GTEST_OS_ZOS
-# define GTEST_HAS_GETTIMEOFDAY_ 1
-# include <sys/time.h>  // NOLINT
-
-// On z/OS we additionally need strings.h for strcasecmp.
-# include <strings.h>  // NOLINT
-
-#elif GTEST_OS_WINDOWS_MOBILE  // We are on Windows CE.
-
-# include <windows.h>  // NOLINT
-
-#elif GTEST_OS_WINDOWS  // We are on Windows proper.
-
-# include <io.h>  // NOLINT
-# include <sys/timeb.h>  // NOLINT
-# include <sys/types.h>  // NOLINT
-# include <sys/stat.h>  // NOLINT
-
-# if GTEST_OS_WINDOWS_MINGW
-// MinGW has gettimeofday() but not _ftime64().
-// TODO(kenton at google.com): Use autoconf to detect availability of
-//   gettimeofday().
-// TODO(kenton at google.com): There are other ways to get the time on
-//   Windows, like GetTickCount() or GetSystemTimeAsFileTime().  MinGW
-//   supports these.  consider using them instead.
-#  define GTEST_HAS_GETTIMEOFDAY_ 1
-#  include <sys/time.h>  // NOLINT
-# endif  // GTEST_OS_WINDOWS_MINGW
-
-// cpplint thinks that the header is already included, so we want to
-// silence it.
-# include <windows.h>  // NOLINT
-
-#else
-
-// Assume other platforms have gettimeofday().
-// TODO(kenton at google.com): Use autoconf to detect availability of
-//   gettimeofday().
-# define GTEST_HAS_GETTIMEOFDAY_ 1
-
-// cpplint thinks that the header is already included, so we want to
-// silence it.
-# include <sys/time.h>  // NOLINT
-# include <unistd.h>  // NOLINT
-
-#endif  // GTEST_OS_LINUX
-
-#if GTEST_HAS_EXCEPTIONS
-# include <stdexcept>
-#endif
-
-#if GTEST_CAN_STREAM_RESULTS_
-# include <arpa/inet.h>  // NOLINT
-# include <netdb.h>  // NOLINT
-#endif
-
-// Indicates that this translation unit is part of Google Test's
-// implementation.  It must come before gtest-internal-inl.h is
-// included, or there will be a compiler error.  This trick is to
-// prevent a user from accidentally including gtest-internal-inl.h in
-// his code.
-#define GTEST_IMPLEMENTATION_ 1
-#include "src/gtest-internal-inl.h"
-#undef GTEST_IMPLEMENTATION_
-
-#if GTEST_OS_WINDOWS
-# define vsnprintf _vsnprintf
-#endif  // GTEST_OS_WINDOWS
-
-namespace testing {
-
-using internal::CountIf;
-using internal::ForEach;
-using internal::GetElementOr;
-using internal::Shuffle;
-
-// Constants.
-
-// A test whose test case name or test name matches this filter is
-// disabled and not run.
-static const char kDisableTestFilter[] = "DISABLED_*:*/DISABLED_*";
-
-// A test case whose name matches this filter is considered a death
-// test case and will be run before test cases whose name doesn't
-// match this filter.
-static const char kDeathTestCaseFilter[] = "*DeathTest:*DeathTest/*";
-
-// A test filter that matches everything.
-static const char kUniversalFilter[] = "*";
-
-// The default output file for XML output.
-static const char kDefaultOutputFile[] = "test_detail.xml";
-
-// The environment variable name for the test shard index.
-static const char kTestShardIndex[] = "GTEST_SHARD_INDEX";
-// The environment variable name for the total number of test shards.
-static const char kTestTotalShards[] = "GTEST_TOTAL_SHARDS";
-// The environment variable name for the test shard status file.
-static const char kTestShardStatusFile[] = "GTEST_SHARD_STATUS_FILE";
-
-namespace internal {
-
-// The text used in failure messages to indicate the start of the
-// stack trace.
-const char kStackTraceMarker[] = "\nStack trace:\n";
-
-// g_help_flag is true iff the --help flag or an equivalent form is
-// specified on the command line.
-bool g_help_flag = false;
-
-}  // namespace internal
-
-GTEST_DEFINE_bool_(
-    also_run_disabled_tests,
-    internal::BoolFromGTestEnv("also_run_disabled_tests", false),
-    "Run disabled tests too, in addition to the tests normally being run.");
-
-GTEST_DEFINE_bool_(
-    break_on_failure,
-    internal::BoolFromGTestEnv("break_on_failure", false),
-    "True iff a failed assertion should be a debugger break-point.");
-
-GTEST_DEFINE_bool_(
-    catch_exceptions,
-    internal::BoolFromGTestEnv("catch_exceptions", true),
-    "True iff " GTEST_NAME_
-    " should catch exceptions and treat them as test failures.");
-
-GTEST_DEFINE_string_(
-    color,
-    internal::StringFromGTestEnv("color", "auto"),
-    "Whether to use colors in the output.  Valid values: yes, no, "
-    "and auto.  'auto' means to use colors if the output is "
-    "being sent to a terminal and the TERM environment variable "
-    "is set to xterm, xterm-color, xterm-256color, linux or cygwin.");
-
-GTEST_DEFINE_string_(
-    filter,
-    internal::StringFromGTestEnv("filter", kUniversalFilter),
-    "A colon-separated list of glob (not regex) patterns "
-    "for filtering the tests to run, optionally followed by a "
-    "'-' and a : separated list of negative patterns (tests to "
-    "exclude).  A test is run if it matches one of the positive "
-    "patterns and does not match any of the negative patterns.");
-
-GTEST_DEFINE_bool_(list_tests, false,
-                   "List all tests without running them.");
-
-GTEST_DEFINE_string_(
-    output,
-    internal::StringFromGTestEnv("output", ""),
-    "A format (currently must be \"xml\"), optionally followed "
-    "by a colon and an output file name or directory. A directory "
-    "is indicated by a trailing pathname separator. "
-    "Examples: \"xml:filename.xml\", \"xml::directoryname/\". "
-    "If a directory is specified, output files will be created "
-    "within that directory, with file-names based on the test "
-    "executable's name and, if necessary, made unique by adding "
-    "digits.");
-
-GTEST_DEFINE_bool_(
-    print_time,
-    internal::BoolFromGTestEnv("print_time", true),
-    "True iff " GTEST_NAME_
-    " should display elapsed time in text output.");
-
-GTEST_DEFINE_int32_(
-    random_seed,
-    internal::Int32FromGTestEnv("random_seed", 0),
-    "Random number seed to use when shuffling test orders.  Must be in range "
-    "[1, 99999], or 0 to use a seed based on the current time.");
-
-GTEST_DEFINE_int32_(
-    repeat,
-    internal::Int32FromGTestEnv("repeat", 1),
-    "How many times to repeat each test.  Specify a negative number "
-    "for repeating forever.  Useful for shaking out flaky tests.");
-
-GTEST_DEFINE_bool_(
-    show_internal_stack_frames, false,
-    "True iff " GTEST_NAME_ " should include internal stack frames when "
-    "printing test failure stack traces.");
-
-GTEST_DEFINE_bool_(
-    shuffle,
-    internal::BoolFromGTestEnv("shuffle", false),
-    "True iff " GTEST_NAME_
-    " should randomize tests' order on every run.");
-
-GTEST_DEFINE_int32_(
-    stack_trace_depth,
-    internal::Int32FromGTestEnv("stack_trace_depth", kMaxStackTraceDepth),
-    "The maximum number of stack frames to print when an "
-    "assertion fails.  The valid range is 0 through 100, inclusive.");
-
-GTEST_DEFINE_string_(
-    stream_result_to,
-    internal::StringFromGTestEnv("stream_result_to", ""),
-    "This flag specifies the host name and the port number on which to stream "
-    "test results. Example: \"localhost:555\". The flag is effective only on "
-    "Linux.");
-
-GTEST_DEFINE_bool_(
-    throw_on_failure,
-    internal::BoolFromGTestEnv("throw_on_failure", false),
-    "When this flag is specified, a failed assertion will throw an exception "
-    "if exceptions are enabled or exit the program with a non-zero code "
-    "otherwise.");
-
-namespace internal {
-
-// Generates a random number from [0, range), using a Linear
-// Congruential Generator (LCG).  Crashes if 'range' is 0 or greater
-// than kMaxRange.
-UInt32 Random::Generate(UInt32 range) {
-  // These constants are the same as are used in glibc's rand(3).
-  state_ = (1103515245U*state_ + 12345U) % kMaxRange;
-
-  GTEST_CHECK_(range > 0)
-      << "Cannot generate a number in the range [0, 0).";
-  GTEST_CHECK_(range <= kMaxRange)
-      << "Generation of a number in [0, " << range << ") was requested, "
-      << "but this can only generate numbers in [0, " << kMaxRange << ").";
-
-  // Converting via modulus introduces a bit of downward bias, but
-  // it's simple, and a linear congruential generator isn't too good
-  // to begin with.
-  return state_ % range;
-}
-
-// GTestIsInitialized() returns true iff the user has initialized
-// Google Test.  Useful for catching the user mistake of not initializing
-// Google Test before calling RUN_ALL_TESTS().
-//
-// A user must call testing::InitGoogleTest() to initialize Google
-// Test.  g_init_gtest_count is set to the number of times
-// InitGoogleTest() has been called.  We don't protect this variable
-// under a mutex as it is only accessed in the main thread.
-int g_init_gtest_count = 0;
-static bool GTestIsInitialized() { return g_init_gtest_count != 0; }
-
-// Iterates over a vector of TestCases, keeping a running sum of the
-// results of calling a given int-returning method on each.
-// Returns the sum.
-static int SumOverTestCaseList(const std::vector<TestCase*>& case_list,
-                               int (TestCase::*method)() const) {
-  int sum = 0;
-  for (size_t i = 0; i < case_list.size(); i++) {
-    sum += (case_list[i]->*method)();
-  }
-  return sum;
-}
-
-// Returns true iff the test case passed.
-static bool TestCasePassed(const TestCase* test_case) {
-  return test_case->should_run() && test_case->Passed();
-}
-
-// Returns true iff the test case failed.
-static bool TestCaseFailed(const TestCase* test_case) {
-  return test_case->should_run() && test_case->Failed();
-}
-
-// Returns true iff test_case contains at least one test that should
-// run.
-static bool ShouldRunTestCase(const TestCase* test_case) {
-  return test_case->should_run();
-}
-
-// AssertHelper constructor.
-AssertHelper::AssertHelper(TestPartResult::Type type,
-                           const char* file,
-                           int line,
-                           const char* message)
-    : data_(new AssertHelperData(type, file, line, message)) {
-}
-
-AssertHelper::~AssertHelper() {
-  delete data_;
-}
-
-// Message assignment, for assertion streaming support.
-void AssertHelper::operator=(const Message& message) const {
-  UnitTest::GetInstance()->
-    AddTestPartResult(data_->type, data_->file, data_->line,
-                      AppendUserMessage(data_->message, message),
-                      UnitTest::GetInstance()->impl()
-                      ->CurrentOsStackTraceExceptTop(1)
-                      // Skips the stack frame for this function itself.
-                      );  // NOLINT
-}
-
-// Mutex for linked pointers.
-GTEST_DEFINE_STATIC_MUTEX_(g_linked_ptr_mutex);
-
-// Application pathname gotten in InitGoogleTest.
-String g_executable_path;
-
-// Returns the current application's name, removing directory path if that
-// is present.
-FilePath GetCurrentExecutableName() {
-  FilePath result;
-
-#if GTEST_OS_WINDOWS
-  result.Set(FilePath(g_executable_path).RemoveExtension("exe"));
-#else
-  result.Set(FilePath(g_executable_path));
-#endif  // GTEST_OS_WINDOWS
-
-  return result.RemoveDirectoryName();
-}
-
-// Functions for processing the gtest_output flag.
-
-// Returns the output format, or "" for normal printed output.
-String UnitTestOptions::GetOutputFormat() {
-  const char* const gtest_output_flag = GTEST_FLAG(output).c_str();
-  if (gtest_output_flag == NULL) return String("");
-
-  const char* const colon = strchr(gtest_output_flag, ':');
-  return (colon == NULL) ?
-      String(gtest_output_flag) :
-      String(gtest_output_flag, colon - gtest_output_flag);
-}
-
-// Returns the name of the requested output file, or the default if none
-// was explicitly specified.
-String UnitTestOptions::GetAbsolutePathToOutputFile() {
-  const char* const gtest_output_flag = GTEST_FLAG(output).c_str();
-  if (gtest_output_flag == NULL)
-    return String("");
-
-  const char* const colon = strchr(gtest_output_flag, ':');
-  if (colon == NULL)
-    return String(internal::FilePath::ConcatPaths(
-               internal::FilePath(
-                   UnitTest::GetInstance()->original_working_dir()),
-               internal::FilePath(kDefaultOutputFile)).ToString() );
-
-  internal::FilePath output_name(colon + 1);
-  if (!output_name.IsAbsolutePath())
-    // TODO(wan at google.com): on Windows \some\path is not an absolute
-    // path (as its meaning depends on the current drive), yet the
-    // following logic for turning it into an absolute path is wrong.
-    // Fix it.
-    output_name = internal::FilePath::ConcatPaths(
-        internal::FilePath(UnitTest::GetInstance()->original_working_dir()),
-        internal::FilePath(colon + 1));
-
-  if (!output_name.IsDirectory())
-    return output_name.ToString();
-
-  internal::FilePath result(internal::FilePath::GenerateUniqueFileName(
-      output_name, internal::GetCurrentExecutableName(),
-      GetOutputFormat().c_str()));
-  return result.ToString();
-}
-
-// Returns true iff the wildcard pattern matches the string.  The
-// first ':' or '\0' character in pattern marks the end of it.
-//
-// This recursive algorithm isn't very efficient, but is clear and
-// works well enough for matching test names, which are short.
-bool UnitTestOptions::PatternMatchesString(const char *pattern,
-                                           const char *str) {
-  switch (*pattern) {
-    case '\0':
-    case ':':  // Either ':' or '\0' marks the end of the pattern.
-      return *str == '\0';
-    case '?':  // Matches any single character.
-      return *str != '\0' && PatternMatchesString(pattern + 1, str + 1);
-    case '*':  // Matches any string (possibly empty) of characters.
-      return (*str != '\0' && PatternMatchesString(pattern, str + 1)) ||
-          PatternMatchesString(pattern + 1, str);
-    default:  // Non-special character.  Matches itself.
-      return *pattern == *str &&
-          PatternMatchesString(pattern + 1, str + 1);
-  }
-}
-
-bool UnitTestOptions::MatchesFilter(const String& name, const char* filter) {
-  const char *cur_pattern = filter;
-  for (;;) {
-    if (PatternMatchesString(cur_pattern, name.c_str())) {
-      return true;
-    }
-
-    // Finds the next pattern in the filter.
-    cur_pattern = strchr(cur_pattern, ':');
-
-    // Returns if no more pattern can be found.
-    if (cur_pattern == NULL) {
-      return false;
-    }
-
-    // Skips the pattern separater (the ':' character).
-    cur_pattern++;
-  }
-}
-
-// TODO(keithray): move String function implementations to gtest-string.cc.
-
-// Returns true iff the user-specified filter matches the test case
-// name and the test name.
-bool UnitTestOptions::FilterMatchesTest(const String &test_case_name,
-                                        const String &test_name) {
-  const String& full_name = String::Format("%s.%s",
-                                           test_case_name.c_str(),
-                                           test_name.c_str());
-
-  // Split --gtest_filter at '-', if there is one, to separate into
-  // positive filter and negative filter portions
-  const char* const p = GTEST_FLAG(filter).c_str();
-  const char* const dash = strchr(p, '-');
-  String positive;
-  String negative;
-  if (dash == NULL) {
-    positive = GTEST_FLAG(filter).c_str();  // Whole string is a positive filter
-    negative = String("");
-  } else {
-    positive = String(p, dash - p);  // Everything up to the dash
-    negative = String(dash+1);       // Everything after the dash
-    if (positive.empty()) {
-      // Treat '-test1' as the same as '*-test1'
-      positive = kUniversalFilter;
-    }
-  }
-
-  // A filter is a colon-separated list of patterns.  It matches a
-  // test if any pattern in it matches the test.
-  return (MatchesFilter(full_name, positive.c_str()) &&
-          !MatchesFilter(full_name, negative.c_str()));
-}
-
-#if GTEST_HAS_SEH
-// Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the
-// given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.
-// This function is useful as an __except condition.
-int UnitTestOptions::GTestShouldProcessSEH(DWORD exception_code) {
-  // Google Test should handle a SEH exception if:
-  //   1. the user wants it to, AND
-  //   2. this is not a breakpoint exception, AND
-  //   3. this is not a C++ exception (VC++ implements them via SEH,
-  //      apparently).
-  //
-  // SEH exception code for C++ exceptions.
-  // (see http://support.microsoft.com/kb/185294 for more information).
-  const DWORD kCxxExceptionCode = 0xe06d7363;
-
-  bool should_handle = true;
-
-  if (!GTEST_FLAG(catch_exceptions))
-    should_handle = false;
-  else if (exception_code == EXCEPTION_BREAKPOINT)
-    should_handle = false;
-  else if (exception_code == kCxxExceptionCode)
-    should_handle = false;
-
-  return should_handle ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH;
-}
-#endif  // GTEST_HAS_SEH
-
-}  // namespace internal
-
-// The c'tor sets this object as the test part result reporter used by
-// Google Test.  The 'result' parameter specifies where to report the
-// results. Intercepts only failures from the current thread.
-ScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter(
-    TestPartResultArray* result)
-    : intercept_mode_(INTERCEPT_ONLY_CURRENT_THREAD),
-      result_(result) {
-  Init();
-}
-
-// The c'tor sets this object as the test part result reporter used by
-// Google Test.  The 'result' parameter specifies where to report the
-// results.
-ScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter(
-    InterceptMode intercept_mode, TestPartResultArray* result)
-    : intercept_mode_(intercept_mode),
-      result_(result) {
-  Init();
-}
-
-void ScopedFakeTestPartResultReporter::Init() {
-  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
-  if (intercept_mode_ == INTERCEPT_ALL_THREADS) {
-    old_reporter_ = impl->GetGlobalTestPartResultReporter();
-    impl->SetGlobalTestPartResultReporter(this);
-  } else {
-    old_reporter_ = impl->GetTestPartResultReporterForCurrentThread();
-    impl->SetTestPartResultReporterForCurrentThread(this);
-  }
-}
-
-// The d'tor restores the test part result reporter used by Google Test
-// before.
-ScopedFakeTestPartResultReporter::~ScopedFakeTestPartResultReporter() {
-  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
-  if (intercept_mode_ == INTERCEPT_ALL_THREADS) {
-    impl->SetGlobalTestPartResultReporter(old_reporter_);
-  } else {
-    impl->SetTestPartResultReporterForCurrentThread(old_reporter_);
-  }
-}
-
-// Increments the test part result count and remembers the result.
-// This method is from the TestPartResultReporterInterface interface.
-void ScopedFakeTestPartResultReporter::ReportTestPartResult(
-    const TestPartResult& result) {
-  result_->Append(result);
-}
-
-namespace internal {
-
-// Returns the type ID of ::testing::Test.  We should always call this
-// instead of GetTypeId< ::testing::Test>() to get the type ID of
-// testing::Test.  This is to work around a suspected linker bug when
-// using Google Test as a framework on Mac OS X.  The bug causes
-// GetTypeId< ::testing::Test>() to return different values depending
-// on whether the call is from the Google Test framework itself or
-// from user test code.  GetTestTypeId() is guaranteed to always
-// return the same value, as it always calls GetTypeId<>() from the
-// gtest.cc, which is within the Google Test framework.
-TypeId GetTestTypeId() {
-  return GetTypeId<Test>();
-}
-
-// The value of GetTestTypeId() as seen from within the Google Test
-// library.  This is solely for testing GetTestTypeId().
-extern const TypeId kTestTypeIdInGoogleTest = GetTestTypeId();
-
-// This predicate-formatter checks that 'results' contains a test part
-// failure of the given type and that the failure message contains the
-// given substring.
-AssertionResult HasOneFailure(const char* /* results_expr */,
-                              const char* /* type_expr */,
-                              const char* /* substr_expr */,
-                              const TestPartResultArray& results,
-                              TestPartResult::Type type,
-                              const string& substr) {
-  const String expected(type == TestPartResult::kFatalFailure ?
-                        "1 fatal failure" :
-                        "1 non-fatal failure");
-  Message msg;
-  if (results.size() != 1) {
-    msg << "Expected: " << expected << "\n"
-        << "  Actual: " << results.size() << " failures";
-    for (int i = 0; i < results.size(); i++) {
-      msg << "\n" << results.GetTestPartResult(i);
-    }
-    return AssertionFailure() << msg;
-  }
-
-  const TestPartResult& r = results.GetTestPartResult(0);
-  if (r.type() != type) {
-    return AssertionFailure() << "Expected: " << expected << "\n"
-                              << "  Actual:\n"
-                              << r;
-  }
-
-  if (strstr(r.message(), substr.c_str()) == NULL) {
-    return AssertionFailure() << "Expected: " << expected << " containing \""
-                              << substr << "\"\n"
-                              << "  Actual:\n"
-                              << r;
-  }
-
-  return AssertionSuccess();
-}
-
-// The constructor of SingleFailureChecker remembers where to look up
-// test part results, what type of failure we expect, and what
-// substring the failure message should contain.
-SingleFailureChecker:: SingleFailureChecker(
-    const TestPartResultArray* results,
-    TestPartResult::Type type,
-    const string& substr)
-    : results_(results),
-      type_(type),
-      substr_(substr) {}
-
-// The destructor of SingleFailureChecker verifies that the given
-// TestPartResultArray contains exactly one failure that has the given
-// type and contains the given substring.  If that's not the case, a
-// non-fatal failure will be generated.
-SingleFailureChecker::~SingleFailureChecker() {
-  EXPECT_PRED_FORMAT3(HasOneFailure, *results_, type_, substr_);
-}
-
-DefaultGlobalTestPartResultReporter::DefaultGlobalTestPartResultReporter(
-    UnitTestImpl* unit_test) : unit_test_(unit_test) {}
-
-void DefaultGlobalTestPartResultReporter::ReportTestPartResult(
-    const TestPartResult& result) {
-  unit_test_->current_test_result()->AddTestPartResult(result);
-  unit_test_->listeners()->repeater()->OnTestPartResult(result);
-}
-
-DefaultPerThreadTestPartResultReporter::DefaultPerThreadTestPartResultReporter(
-    UnitTestImpl* unit_test) : unit_test_(unit_test) {}
-
-void DefaultPerThreadTestPartResultReporter::ReportTestPartResult(
-    const TestPartResult& result) {
-  unit_test_->GetGlobalTestPartResultReporter()->ReportTestPartResult(result);
-}
-
-// Returns the global test part result reporter.
-TestPartResultReporterInterface*
-UnitTestImpl::GetGlobalTestPartResultReporter() {
-  internal::MutexLock lock(&global_test_part_result_reporter_mutex_);
-  return global_test_part_result_repoter_;
-}
-
-// Sets the global test part result reporter.
-void UnitTestImpl::SetGlobalTestPartResultReporter(
-    TestPartResultReporterInterface* reporter) {
-  internal::MutexLock lock(&global_test_part_result_reporter_mutex_);
-  global_test_part_result_repoter_ = reporter;
-}
-
-// Returns the test part result reporter for the current thread.
-TestPartResultReporterInterface*
-UnitTestImpl::GetTestPartResultReporterForCurrentThread() {
-  return per_thread_test_part_result_reporter_.get();
-}
-
-// Sets the test part result reporter for the current thread.
-void UnitTestImpl::SetTestPartResultReporterForCurrentThread(
-    TestPartResultReporterInterface* reporter) {
-  per_thread_test_part_result_reporter_.set(reporter);
-}
-
-// Gets the number of successful test cases.
-int UnitTestImpl::successful_test_case_count() const {
-  return CountIf(test_cases_, TestCasePassed);
-}
-
-// Gets the number of failed test cases.
-int UnitTestImpl::failed_test_case_count() const {
-  return CountIf(test_cases_, TestCaseFailed);
-}
-
-// Gets the number of all test cases.
-int UnitTestImpl::total_test_case_count() const {
-  return static_cast<int>(test_cases_.size());
-}
-
-// Gets the number of all test cases that contain at least one test
-// that should run.
-int UnitTestImpl::test_case_to_run_count() const {
-  return CountIf(test_cases_, ShouldRunTestCase);
-}
-
-// Gets the number of successful tests.
-int UnitTestImpl::successful_test_count() const {
-  return SumOverTestCaseList(test_cases_, &TestCase::successful_test_count);
-}
-
-// Gets the number of failed tests.
-int UnitTestImpl::failed_test_count() const {
-  return SumOverTestCaseList(test_cases_, &TestCase::failed_test_count);
-}
-
-// Gets the number of disabled tests.
-int UnitTestImpl::disabled_test_count() const {
-  return SumOverTestCaseList(test_cases_, &TestCase::disabled_test_count);
-}
-
-// Gets the number of all tests.
-int UnitTestImpl::total_test_count() const {
-  return SumOverTestCaseList(test_cases_, &TestCase::total_test_count);
-}
-
-// Gets the number of tests that should run.
-int UnitTestImpl::test_to_run_count() const {
-  return SumOverTestCaseList(test_cases_, &TestCase::test_to_run_count);
-}
-
-// Returns the current OS stack trace as a String.
-//
-// The maximum number of stack frames to be included is specified by
-// the gtest_stack_trace_depth flag.  The skip_count parameter
-// specifies the number of top frames to be skipped, which doesn't
-// count against the number of frames to be included.
-//
-// For example, if Foo() calls Bar(), which in turn calls
-// CurrentOsStackTraceExceptTop(1), Foo() will be included in the
-// trace but Bar() and CurrentOsStackTraceExceptTop() won't.
-String UnitTestImpl::CurrentOsStackTraceExceptTop(int skip_count) {
-  (void)skip_count;
-  return String("");
-}
-
-// Returns the current time in milliseconds.
-TimeInMillis GetTimeInMillis() {
-#if GTEST_OS_WINDOWS_MOBILE || defined(__BORLANDC__)
-  // Difference between 1970-01-01 and 1601-01-01 in milliseconds.
-  // http://analogous.blogspot.com/2005/04/epoch.html
-  const TimeInMillis kJavaEpochToWinFileTimeDelta =
-    static_cast<TimeInMillis>(116444736UL) * 100000UL;
-  const DWORD kTenthMicrosInMilliSecond = 10000;
-
-  SYSTEMTIME now_systime;
-  FILETIME now_filetime;
-  ULARGE_INTEGER now_int64;
-  // TODO(kenton at google.com): Shouldn't this just use
-  //   GetSystemTimeAsFileTime()?
-  GetSystemTime(&now_systime);
-  if (SystemTimeToFileTime(&now_systime, &now_filetime)) {
-    now_int64.LowPart = now_filetime.dwLowDateTime;
-    now_int64.HighPart = now_filetime.dwHighDateTime;
-    now_int64.QuadPart = (now_int64.QuadPart / kTenthMicrosInMilliSecond) -
-      kJavaEpochToWinFileTimeDelta;
-    return now_int64.QuadPart;
-  }
-  return 0;
-#elif GTEST_OS_WINDOWS && !GTEST_HAS_GETTIMEOFDAY_
-  __timeb64 now;
-
-# ifdef _MSC_VER
-
-  // MSVC 8 deprecates _ftime64(), so we want to suppress warning 4996
-  // (deprecated function) there.
-  // TODO(kenton at google.com): Use GetTickCount()?  Or use
-  //   SystemTimeToFileTime()
-#  pragma warning(push)          // Saves the current warning state.
-#  pragma warning(disable:4996)  // Temporarily disables warning 4996.
-  _ftime64(&now);
-#  pragma warning(pop)           // Restores the warning state.
-# else
-
-  _ftime64(&now);
-
-# endif  // _MSC_VER
-
-  return static_cast<TimeInMillis>(now.time) * 1000 + now.millitm;
-#elif GTEST_HAS_GETTIMEOFDAY_
-  struct timeval now;
-  gettimeofday(&now, NULL);
-  return static_cast<TimeInMillis>(now.tv_sec) * 1000 + now.tv_usec / 1000;
-#else
-# error "Don't know how to get the current time on your system."
-#endif
-}
-
-// Utilities
-
-// class String
-
-// Returns the input enclosed in double quotes if it's not NULL;
-// otherwise returns "(null)".  For example, "\"Hello\"" is returned
-// for input "Hello".
-//
-// This is useful for printing a C string in the syntax of a literal.
-//
-// Known issue: escape sequences are not handled yet.
-String String::ShowCStringQuoted(const char* c_str) {
-  return c_str ? String::Format("\"%s\"", c_str) : String("(null)");
-}
-
-// Copies at most length characters from str into a newly-allocated
-// piece of memory of size length+1.  The memory is allocated with new[].
-// A terminating null byte is written to the memory, and a pointer to it
-// is returned.  If str is NULL, NULL is returned.
-static char* CloneString(const char* str, size_t length) {
-  if (str == NULL) {
-    return NULL;
-  } else {
-    char* const clone = new char[length + 1];
-    posix::StrNCpy(clone, str, length);
-    clone[length] = '\0';
-    return clone;
-  }
-}
-
-// Clones a 0-terminated C string, allocating memory using new.  The
-// caller is responsible for deleting[] the return value.  Returns the
-// cloned string, or NULL if the input is NULL.
-const char * String::CloneCString(const char* c_str) {
-  return (c_str == NULL) ?
-                    NULL : CloneString(c_str, strlen(c_str));
-}
-
-#if GTEST_OS_WINDOWS_MOBILE
-// Creates a UTF-16 wide string from the given ANSI string, allocating
-// memory using new. The caller is responsible for deleting the return
-// value using delete[]. Returns the wide string, or NULL if the
-// input is NULL.
-LPCWSTR String::AnsiToUtf16(const char* ansi) {
-  if (!ansi) return NULL;
-  const int length = strlen(ansi);
-  const int unicode_length =
-      MultiByteToWideChar(CP_ACP, 0, ansi, length,
-                          NULL, 0);
-  WCHAR* unicode = new WCHAR[unicode_length + 1];
-  MultiByteToWideChar(CP_ACP, 0, ansi, length,
-                      unicode, unicode_length);
-  unicode[unicode_length] = 0;
-  return unicode;
-}
-
-// Creates an ANSI string from the given wide string, allocating
-// memory using new. The caller is responsible for deleting the return
-// value using delete[]. Returns the ANSI string, or NULL if the
-// input is NULL.
-const char* String::Utf16ToAnsi(LPCWSTR utf16_str)  {
-  if (!utf16_str) return NULL;
-  const int ansi_length =
-      WideCharToMultiByte(CP_ACP, 0, utf16_str, -1,
-                          NULL, 0, NULL, NULL);
-  char* ansi = new char[ansi_length + 1];
-  WideCharToMultiByte(CP_ACP, 0, utf16_str, -1,
-                      ansi, ansi_length, NULL, NULL);
-  ansi[ansi_length] = 0;
-  return ansi;
-}
-
-#endif  // GTEST_OS_WINDOWS_MOBILE
-
-// Compares two C strings.  Returns true iff they have the same content.
-//
-// Unlike strcmp(), this function can handle NULL argument(s).  A NULL
-// C string is considered different to any non-NULL C string,
-// including the empty string.
-bool String::CStringEquals(const char * lhs, const char * rhs) {
-  if ( lhs == NULL ) return rhs == NULL;
-
-  if ( rhs == NULL ) return false;
-
-  return strcmp(lhs, rhs) == 0;
-}
-
-#if GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING
-
-// Converts an array of wide chars to a narrow string using the UTF-8
-// encoding, and streams the result to the given Message object.
-static void StreamWideCharsToMessage(const wchar_t* wstr, size_t length,
-                                     Message* msg) {
-  // TODO(wan): consider allowing a testing::String object to
-  // contain '\0'.  This will make it behave more like std::string,
-  // and will allow ToUtf8String() to return the correct encoding
-  // for '\0' s.t. we can get rid of the conditional here (and in
-  // several other places).
-  for (size_t i = 0; i != length; ) {  // NOLINT
-    if (wstr[i] != L'\0') {
-      *msg << WideStringToUtf8(wstr + i, static_cast<int>(length - i));
-      while (i != length && wstr[i] != L'\0')
-        i++;
-    } else {
-      *msg << '\0';
-      i++;
-    }
-  }
-}
-
-#endif  // GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING
-
-}  // namespace internal
-
-#if GTEST_HAS_STD_WSTRING
-// Converts the given wide string to a narrow string using the UTF-8
-// encoding, and streams the result to this Message object.
-Message& Message::operator <<(const ::std::wstring& wstr) {
-  internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), this);
-  return *this;
-}
-#endif  // GTEST_HAS_STD_WSTRING
-
-#if GTEST_HAS_GLOBAL_WSTRING
-// Converts the given wide string to a narrow string using the UTF-8
-// encoding, and streams the result to this Message object.
-Message& Message::operator <<(const ::wstring& wstr) {
-  internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), this);
-  return *this;
-}
-#endif  // GTEST_HAS_GLOBAL_WSTRING
-
-// AssertionResult constructors.
-// Used in EXPECT_TRUE/FALSE(assertion_result).
-AssertionResult::AssertionResult(const AssertionResult& other)
-    : success_(other.success_),
-      message_(other.message_.get() != NULL ?
-               new ::std::string(*other.message_) :
-               static_cast< ::std::string*>(NULL)) {
-}
-
-// Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
-AssertionResult AssertionResult::operator!() const {
-  AssertionResult negation(!success_);
-  if (message_.get() != NULL)
-    negation << *message_;
-  return negation;
-}
-
-// Makes a successful assertion result.
-AssertionResult AssertionSuccess() {
-  return AssertionResult(true);
-}
-
-// Makes a failed assertion result.
-AssertionResult AssertionFailure() {
-  return AssertionResult(false);
-}
-
-// Makes a failed assertion result with the given failure message.
-// Deprecated; use AssertionFailure() << message.
-AssertionResult AssertionFailure(const Message& message) {
-  return AssertionFailure() << message;
-}
-
-namespace internal {
-
-// Constructs and returns the message for an equality assertion
-// (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure.
-//
-// The first four parameters are the expressions used in the assertion
-// and their values, as strings.  For example, for ASSERT_EQ(foo, bar)
-// where foo is 5 and bar is 6, we have:
-//
-//   expected_expression: "foo"
-//   actual_expression:   "bar"
-//   expected_value:      "5"
-//   actual_value:        "6"
-//
-// The ignoring_case parameter is true iff the assertion is a
-// *_STRCASEEQ*.  When it's true, the string " (ignoring case)" will
-// be inserted into the message.
-AssertionResult EqFailure(const char* expected_expression,
-                          const char* actual_expression,
-                          const String& expected_value,
-                          const String& actual_value,
-                          bool ignoring_case) {
-  Message msg;
-  msg << "Value of: " << actual_expression;
-  if (actual_value != actual_expression) {
-    msg << "\n  Actual: " << actual_value;
-  }
-
-  msg << "\nExpected: " << expected_expression;
-  if (ignoring_case) {
-    msg << " (ignoring case)";
-  }
-  if (expected_value != expected_expression) {
-    msg << "\nWhich is: " << expected_value;
-  }
-
-  return AssertionFailure() << msg;
-}
-
-// Constructs a failure message for Boolean assertions such as EXPECT_TRUE.
-String GetBoolAssertionFailureMessage(const AssertionResult& assertion_result,
-                                      const char* expression_text,
-                                      const char* actual_predicate_value,
-                                      const char* expected_predicate_value) {
-  const char* actual_message = assertion_result.message();
-  Message msg;
-  msg << "Value of: " << expression_text
-      << "\n  Actual: " << actual_predicate_value;
-  if (actual_message[0] != '\0')
-    msg << " (" << actual_message << ")";
-  msg << "\nExpected: " << expected_predicate_value;
-  return msg.GetString();
-}
-
-// Helper function for implementing ASSERT_NEAR.
-AssertionResult DoubleNearPredFormat(const char* expr1,
-                                     const char* expr2,
-                                     const char* abs_error_expr,
-                                     double val1,
-                                     double val2,
-                                     double abs_error) {
-  const double diff = fabs(val1 - val2);
-  if (diff <= abs_error) return AssertionSuccess();
-
-  // TODO(wan): do not print the value of an expression if it's
-  // already a literal.
-  return AssertionFailure()
-      << "The difference between " << expr1 << " and " << expr2
-      << " is " << diff << ", which exceeds " << abs_error_expr << ", where\n"
-      << expr1 << " evaluates to " << val1 << ",\n"
-      << expr2 << " evaluates to " << val2 << ", and\n"
-      << abs_error_expr << " evaluates to " << abs_error << ".";
-}
-
-
-// Helper template for implementing FloatLE() and DoubleLE().
-template <typename RawType>
-AssertionResult FloatingPointLE(const char* expr1,
-                                const char* expr2,
-                                RawType val1,
-                                RawType val2) {
-  // Returns success if val1 is less than val2,
-  if (val1 < val2) {
-    return AssertionSuccess();
-  }
-
-  // or if val1 is almost equal to val2.
-  const FloatingPoint<RawType> lhs(val1), rhs(val2);
-  if (lhs.AlmostEquals(rhs)) {
-    return AssertionSuccess();
-  }
-
-  // Note that the above two checks will both fail if either val1 or
-  // val2 is NaN, as the IEEE floating-point standard requires that
-  // any predicate involving a NaN must return false.
-
-  ::std::stringstream val1_ss;
-  val1_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
-          << val1;
-
-  ::std::stringstream val2_ss;
-  val2_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
-          << val2;
-
-  return AssertionFailure()
-      << "Expected: (" << expr1 << ") <= (" << expr2 << ")\n"
-      << "  Actual: " << StringStreamToString(&val1_ss) << " vs "
-      << StringStreamToString(&val2_ss);
-}
-
-}  // namespace internal
-
-// Asserts that val1 is less than, or almost equal to, val2.  Fails
-// otherwise.  In particular, it fails if either val1 or val2 is NaN.
-AssertionResult FloatLE(const char* expr1, const char* expr2,
-                        float val1, float val2) {
-  return internal::FloatingPointLE<float>(expr1, expr2, val1, val2);
-}
-
-// Asserts that val1 is less than, or almost equal to, val2.  Fails
-// otherwise.  In particular, it fails if either val1 or val2 is NaN.
-AssertionResult DoubleLE(const char* expr1, const char* expr2,
-                         double val1, double val2) {
-  return internal::FloatingPointLE<double>(expr1, expr2, val1, val2);
-}
-
-namespace internal {
-
-// The helper function for {ASSERT|EXPECT}_EQ with int or enum
-// arguments.
-AssertionResult CmpHelperEQ(const char* expected_expression,
-                            const char* actual_expression,
-                            BiggestInt expected,
-                            BiggestInt actual) {
-  if (expected == actual) {
-    return AssertionSuccess();
-  }
-
-  return EqFailure(expected_expression,
-                   actual_expression,
-                   FormatForComparisonFailureMessage(expected, actual),
-                   FormatForComparisonFailureMessage(actual, expected),
-                   false);
-}
-
-// A macro for implementing the helper functions needed to implement
-// ASSERT_?? and EXPECT_?? with integer or enum arguments.  It is here
-// just to avoid copy-and-paste of similar code.
-#define GTEST_IMPL_CMP_HELPER_(op_name, op)\
-AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
-                                   BiggestInt val1, BiggestInt val2) {\
-  if (val1 op val2) {\
-    return AssertionSuccess();\
-  } else {\
-    return AssertionFailure() \
-        << "Expected: (" << expr1 << ") " #op " (" << expr2\
-        << "), actual: " << FormatForComparisonFailureMessage(val1, val2)\
-        << " vs " << FormatForComparisonFailureMessage(val2, val1);\
-  }\
-}
-
-// Implements the helper function for {ASSERT|EXPECT}_NE with int or
-// enum arguments.
-GTEST_IMPL_CMP_HELPER_(NE, !=)
-// Implements the helper function for {ASSERT|EXPECT}_LE with int or
-// enum arguments.
-GTEST_IMPL_CMP_HELPER_(LE, <=)
-// Implements the helper function for {ASSERT|EXPECT}_LT with int or
-// enum arguments.
-GTEST_IMPL_CMP_HELPER_(LT, < )
-// Implements the helper function for {ASSERT|EXPECT}_GE with int or
-// enum arguments.
-GTEST_IMPL_CMP_HELPER_(GE, >=)
-// Implements the helper function for {ASSERT|EXPECT}_GT with int or
-// enum arguments.
-GTEST_IMPL_CMP_HELPER_(GT, > )
-
-#undef GTEST_IMPL_CMP_HELPER_
-
-// The helper function for {ASSERT|EXPECT}_STREQ.
-AssertionResult CmpHelperSTREQ(const char* expected_expression,
-                               const char* actual_expression,
-                               const char* expected,
-                               const char* actual) {
-  if (String::CStringEquals(expected, actual)) {
-    return AssertionSuccess();
-  }
-
-  return EqFailure(expected_expression,
-                   actual_expression,
-                   String::ShowCStringQuoted(expected),
-                   String::ShowCStringQuoted(actual),
-                   false);
-}
-
-// The helper function for {ASSERT|EXPECT}_STRCASEEQ.
-AssertionResult CmpHelperSTRCASEEQ(const char* expected_expression,
-                                   const char* actual_expression,
-                                   const char* expected,
-                                   const char* actual) {
-  if (String::CaseInsensitiveCStringEquals(expected, actual)) {
-    return AssertionSuccess();
-  }
-
-  return EqFailure(expected_expression,
-                   actual_expression,
-                   String::ShowCStringQuoted(expected),
-                   String::ShowCStringQuoted(actual),
-                   true);
-}
-
-// The helper function for {ASSERT|EXPECT}_STRNE.
-AssertionResult CmpHelperSTRNE(const char* s1_expression,
-                               const char* s2_expression,
-                               const char* s1,
-                               const char* s2) {
-  if (!String::CStringEquals(s1, s2)) {
-    return AssertionSuccess();
-  } else {
-    return AssertionFailure() << "Expected: (" << s1_expression << ") != ("
-                              << s2_expression << "), actual: \""
-                              << s1 << "\" vs \"" << s2 << "\"";
-  }
-}
-
-// The helper function for {ASSERT|EXPECT}_STRCASENE.
-AssertionResult CmpHelperSTRCASENE(const char* s1_expression,
-                                   const char* s2_expression,
-                                   const char* s1,
-                                   const char* s2) {
-  if (!String::CaseInsensitiveCStringEquals(s1, s2)) {
-    return AssertionSuccess();
-  } else {
-    return AssertionFailure()
-        << "Expected: (" << s1_expression << ") != ("
-        << s2_expression << ") (ignoring case), actual: \""
-        << s1 << "\" vs \"" << s2 << "\"";
-  }
-}
-
-}  // namespace internal
-
-namespace {
-
-// Helper functions for implementing IsSubString() and IsNotSubstring().
-
-// This group of overloaded functions return true iff needle is a
-// substring of haystack.  NULL is considered a substring of itself
-// only.
-
-bool IsSubstringPred(const char* needle, const char* haystack) {
-  if (needle == NULL || haystack == NULL)
-    return needle == haystack;
-
-  return strstr(haystack, needle) != NULL;
-}
-
-bool IsSubstringPred(const wchar_t* needle, const wchar_t* haystack) {
-  if (needle == NULL || haystack == NULL)
-    return needle == haystack;
-
-  return wcsstr(haystack, needle) != NULL;
-}
-
-// StringType here can be either ::std::string or ::std::wstring.
-template <typename StringType>
-bool IsSubstringPred(const StringType& needle,
-                     const StringType& haystack) {
-  return haystack.find(needle) != StringType::npos;
-}
-
-// This function implements either IsSubstring() or IsNotSubstring(),
-// depending on the value of the expected_to_be_substring parameter.
-// StringType here can be const char*, const wchar_t*, ::std::string,
-// or ::std::wstring.
-template <typename StringType>
-AssertionResult IsSubstringImpl(
-    bool expected_to_be_substring,
-    const char* needle_expr, const char* haystack_expr,
-    const StringType& needle, const StringType& haystack) {
-  if (IsSubstringPred(needle, haystack) == expected_to_be_substring)
-    return AssertionSuccess();
-
-  const bool is_wide_string = sizeof(needle[0]) > 1;
-  const char* const begin_string_quote = is_wide_string ? "L\"" : "\"";
-  return AssertionFailure()
-      << "Value of: " << needle_expr << "\n"
-      << "  Actual: " << begin_string_quote << needle << "\"\n"
-      << "Expected: " << (expected_to_be_substring ? "" : "not ")
-      << "a substring of " << haystack_expr << "\n"
-      << "Which is: " << begin_string_quote << haystack << "\"";
-}
-
-}  // namespace
-
-// IsSubstring() and IsNotSubstring() check whether needle is a
-// substring of haystack (NULL is considered a substring of itself
-// only), and return an appropriate error message when they fail.
-
-AssertionResult IsSubstring(
-    const char* needle_expr, const char* haystack_expr,
-    const char* needle, const char* haystack) {
-  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);
-}
-
-AssertionResult IsSubstring(
-    const char* needle_expr, const char* haystack_expr,
-    const wchar_t* needle, const wchar_t* haystack) {
-  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);
-}
-
-AssertionResult IsNotSubstring(
-    const char* needle_expr, const char* haystack_expr,
-    const char* needle, const char* haystack) {
-  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);
-}
-
-AssertionResult IsNotSubstring(
-    const char* needle_expr, const char* haystack_expr,
-    const wchar_t* needle, const wchar_t* haystack) {
-  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);
-}
-
-AssertionResult IsSubstring(
-    const char* needle_expr, const char* haystack_expr,
-    const ::std::string& needle, const ::std::string& haystack) {
-  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);
-}
-
-AssertionResult IsNotSubstring(
-    const char* needle_expr, const char* haystack_expr,
-    const ::std::string& needle, const ::std::string& haystack) {
-  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);
-}
-
-#if GTEST_HAS_STD_WSTRING
-AssertionResult IsSubstring(
-    const char* needle_expr, const char* haystack_expr,
-    const ::std::wstring& needle, const ::std::wstring& haystack) {
-  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);
-}
-
-AssertionResult IsNotSubstring(
-    const char* needle_expr, const char* haystack_expr,
-    const ::std::wstring& needle, const ::std::wstring& haystack) {
-  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);
-}
-#endif  // GTEST_HAS_STD_WSTRING
-
-namespace internal {
-
-#if GTEST_OS_WINDOWS
-
-namespace {
-
-// Helper function for IsHRESULT{SuccessFailure} predicates
-AssertionResult HRESULTFailureHelper(const char* expr,
-                                     const char* expected,
-                                     long hr) {  // NOLINT
-# if GTEST_OS_WINDOWS_MOBILE
-
-  // Windows CE doesn't support FormatMessage.
-  const char error_text[] = "";
-
-# else
-
-  // Looks up the human-readable system message for the HRESULT code
-  // and since we're not passing any params to FormatMessage, we don't
-  // want inserts expanded.
-  const DWORD kFlags = FORMAT_MESSAGE_FROM_SYSTEM |
-                       FORMAT_MESSAGE_IGNORE_INSERTS;
-  const DWORD kBufSize = 4096;  // String::Format can't exceed this length.
-  // Gets the system's human readable message string for this HRESULT.
-  char error_text[kBufSize] = { '\0' };
-  DWORD message_length = ::FormatMessageA(kFlags,
-                                          0,  // no source, we're asking system
-                                          hr,  // the error
-                                          0,  // no line width restrictions
-                                          error_text,  // output buffer
-                                          kBufSize,  // buf size
-                                          NULL);  // no arguments for inserts
-  // Trims tailing white space (FormatMessage leaves a trailing cr-lf)
-  for (; message_length && IsSpace(error_text[message_length - 1]);
-          --message_length) {
-    error_text[message_length - 1] = '\0';
-  }
-
-# endif  // GTEST_OS_WINDOWS_MOBILE
-
-  const String error_hex(String::Format("0x%08X ", hr));
-  return ::testing::AssertionFailure()
-      << "Expected: " << expr << " " << expected << ".\n"
-      << "  Actual: " << error_hex << error_text << "\n";
-}
-
-}  // namespace
-
-AssertionResult IsHRESULTSuccess(const char* expr, long hr) {  // NOLINT
-  if (SUCCEEDED(hr)) {
-    return AssertionSuccess();
-  }
-  return HRESULTFailureHelper(expr, "succeeds", hr);
-}
-
-AssertionResult IsHRESULTFailure(const char* expr, long hr) {  // NOLINT
-  if (FAILED(hr)) {
-    return AssertionSuccess();
-  }
-  return HRESULTFailureHelper(expr, "fails", hr);
-}
-
-#endif  // GTEST_OS_WINDOWS
-
-// Utility functions for encoding Unicode text (wide strings) in
-// UTF-8.
-
-// A Unicode code-point can have upto 21 bits, and is encoded in UTF-8
-// like this:
-//
-// Code-point length   Encoding
-//   0 -  7 bits       0xxxxxxx
-//   8 - 11 bits       110xxxxx 10xxxxxx
-//  12 - 16 bits       1110xxxx 10xxxxxx 10xxxxxx
-//  17 - 21 bits       11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
-
-// The maximum code-point a one-byte UTF-8 sequence can represent.
-const UInt32 kMaxCodePoint1 = (static_cast<UInt32>(1) <<  7) - 1;
-
-// The maximum code-point a two-byte UTF-8 sequence can represent.
-const UInt32 kMaxCodePoint2 = (static_cast<UInt32>(1) << (5 + 6)) - 1;
-
-// The maximum code-point a three-byte UTF-8 sequence can represent.
-const UInt32 kMaxCodePoint3 = (static_cast<UInt32>(1) << (4 + 2*6)) - 1;
-
-// The maximum code-point a four-byte UTF-8 sequence can represent.
-const UInt32 kMaxCodePoint4 = (static_cast<UInt32>(1) << (3 + 3*6)) - 1;
-
-// Chops off the n lowest bits from a bit pattern.  Returns the n
-// lowest bits.  As a side effect, the original bit pattern will be
-// shifted to the right by n bits.
-inline UInt32 ChopLowBits(UInt32* bits, int n) {
-  const UInt32 low_bits = *bits & ((static_cast<UInt32>(1) << n) - 1);
-  *bits >>= n;
-  return low_bits;
-}
-
-// Converts a Unicode code point to a narrow string in UTF-8 encoding.
-// code_point parameter is of type UInt32 because wchar_t may not be
-// wide enough to contain a code point.
-// The output buffer str must containt at least 32 characters.
-// The function returns the address of the output buffer.
-// If the code_point is not a valid Unicode code point
-// (i.e. outside of Unicode range U+0 to U+10FFFF) it will be output
-// as '(Invalid Unicode 0xXXXXXXXX)'.
-char* CodePointToUtf8(UInt32 code_point, char* str) {
-  if (code_point <= kMaxCodePoint1) {
-    str[1] = '\0';
-    str[0] = static_cast<char>(code_point);                          // 0xxxxxxx
-  } else if (code_point <= kMaxCodePoint2) {
-    str[2] = '\0';
-    str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx
-    str[0] = static_cast<char>(0xC0 | code_point);                   // 110xxxxx
-  } else if (code_point <= kMaxCodePoint3) {
-    str[3] = '\0';
-    str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx
-    str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx
-    str[0] = static_cast<char>(0xE0 | code_point);                   // 1110xxxx
-  } else if (code_point <= kMaxCodePoint4) {
-    str[4] = '\0';
-    str[3] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx
-    str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx
-    str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx
-    str[0] = static_cast<char>(0xF0 | code_point);                   // 11110xxx
-  } else {
-    // The longest string String::Format can produce when invoked
-    // with these parameters is 28 character long (not including
-    // the terminating nul character). We are asking for 32 character
-    // buffer just in case. This is also enough for strncpy to
-    // null-terminate the destination string.
-    posix::StrNCpy(
-        str, String::Format("(Invalid Unicode 0x%X)", code_point).c_str(), 32);
-    str[31] = '\0';  // Makes sure no change in the format to strncpy leaves
-                     // the result unterminated.
-  }
-  return str;
-}
-
-// The following two functions only make sense if the the system
-// uses UTF-16 for wide string encoding. All supported systems
-// with 16 bit wchar_t (Windows, Cygwin, Symbian OS) do use UTF-16.
-
-// Determines if the arguments constitute UTF-16 surrogate pair
-// and thus should be combined into a single Unicode code point
-// using CreateCodePointFromUtf16SurrogatePair.
-inline bool IsUtf16SurrogatePair(wchar_t first, wchar_t second) {
-  return sizeof(wchar_t) == 2 &&
-      (first & 0xFC00) == 0xD800 && (second & 0xFC00) == 0xDC00;
-}
-
-// Creates a Unicode code point from UTF16 surrogate pair.
-inline UInt32 CreateCodePointFromUtf16SurrogatePair(wchar_t first,
-                                                    wchar_t second) {
-  const UInt32 mask = (1 << 10) - 1;
-  return (sizeof(wchar_t) == 2) ?
-      (((first & mask) << 10) | (second & mask)) + 0x10000 :
-      // This function should not be called when the condition is
-      // false, but we provide a sensible default in case it is.
-      static_cast<UInt32>(first);
-}
-
-// Converts a wide string to a narrow string in UTF-8 encoding.
-// The wide string is assumed to have the following encoding:
-//   UTF-16 if sizeof(wchar_t) == 2 (on Windows, Cygwin, Symbian OS)
-//   UTF-32 if sizeof(wchar_t) == 4 (on Linux)
-// Parameter str points to a null-terminated wide string.
-// Parameter num_chars may additionally limit the number
-// of wchar_t characters processed. -1 is used when the entire string
-// should be processed.
-// If the string contains code points that are not valid Unicode code points
-// (i.e. outside of Unicode range U+0 to U+10FFFF) they will be output
-// as '(Invalid Unicode 0xXXXXXXXX)'. If the string is in UTF16 encoding
-// and contains invalid UTF-16 surrogate pairs, values in those pairs
-// will be encoded as individual Unicode characters from Basic Normal Plane.
-String WideStringToUtf8(const wchar_t* str, int num_chars) {
-  if (num_chars == -1)
-    num_chars = static_cast<int>(wcslen(str));
-
-  ::std::stringstream stream;
-  for (int i = 0; i < num_chars; ++i) {
-    UInt32 unicode_code_point;
-
-    if (str[i] == L'\0') {
-      break;
-    } else if (i + 1 < num_chars && IsUtf16SurrogatePair(str[i], str[i + 1])) {
-      unicode_code_point = CreateCodePointFromUtf16SurrogatePair(str[i],
-                                                                 str[i + 1]);
-      i++;
-    } else {
-      unicode_code_point = static_cast<UInt32>(str[i]);
-    }
-
-    char buffer[32];  // CodePointToUtf8 requires a buffer this big.
-    stream << CodePointToUtf8(unicode_code_point, buffer);
-  }
-  return StringStreamToString(&stream);
-}
-
-// Converts a wide C string to a String using the UTF-8 encoding.
-// NULL will be converted to "(null)".
-String String::ShowWideCString(const wchar_t * wide_c_str) {
-  if (wide_c_str == NULL) return String("(null)");
-
-  return String(internal::WideStringToUtf8(wide_c_str, -1).c_str());
-}
-
-// Similar to ShowWideCString(), except that this function encloses
-// the converted string in double quotes.
-String String::ShowWideCStringQuoted(const wchar_t* wide_c_str) {
-  if (wide_c_str == NULL) return String("(null)");
-
-  return String::Format("L\"%s\"",
-                        String::ShowWideCString(wide_c_str).c_str());
-}
-
-// Compares two wide C strings.  Returns true iff they have the same
-// content.
-//
-// Unlike wcscmp(), this function can handle NULL argument(s).  A NULL
-// C string is considered different to any non-NULL C string,
-// including the empty string.
-bool String::WideCStringEquals(const wchar_t * lhs, const wchar_t * rhs) {
-  if (lhs == NULL) return rhs == NULL;
-
-  if (rhs == NULL) return false;
-
-  return wcscmp(lhs, rhs) == 0;
-}
-
-// Helper function for *_STREQ on wide strings.
-AssertionResult CmpHelperSTREQ(const char* expected_expression,
-                               const char* actual_expression,
-                               const wchar_t* expected,
-                               const wchar_t* actual) {
-  if (String::WideCStringEquals(expected, actual)) {
-    return AssertionSuccess();
-  }
-
-  return EqFailure(expected_expression,
-                   actual_expression,
-                   String::ShowWideCStringQuoted(expected),
-                   String::ShowWideCStringQuoted(actual),
-                   false);
-}
-
-// Helper function for *_STRNE on wide strings.
-AssertionResult CmpHelperSTRNE(const char* s1_expression,
-                               const char* s2_expression,
-                               const wchar_t* s1,
-                               const wchar_t* s2) {
-  if (!String::WideCStringEquals(s1, s2)) {
-    return AssertionSuccess();
-  }
-
-  return AssertionFailure() << "Expected: (" << s1_expression << ") != ("
-                            << s2_expression << "), actual: "
-                            << String::ShowWideCStringQuoted(s1)
-                            << " vs " << String::ShowWideCStringQuoted(s2);
-}
-
-// Compares two C strings, ignoring case.  Returns true iff they have
-// the same content.
-//
-// Unlike strcasecmp(), this function can handle NULL argument(s).  A
-// NULL C string is considered different to any non-NULL C string,
-// including the empty string.
-bool String::CaseInsensitiveCStringEquals(const char * lhs, const char * rhs) {
-  if (lhs == NULL)
-    return rhs == NULL;
-  if (rhs == NULL)
-    return false;
-  return posix::StrCaseCmp(lhs, rhs) == 0;
-}
-
-  // Compares two wide C strings, ignoring case.  Returns true iff they
-  // have the same content.
-  //
-  // Unlike wcscasecmp(), this function can handle NULL argument(s).
-  // A NULL C string is considered different to any non-NULL wide C string,
-  // including the empty string.
-  // NB: The implementations on different platforms slightly differ.
-  // On windows, this method uses _wcsicmp which compares according to LC_CTYPE
-  // environment variable. On GNU platform this method uses wcscasecmp
-  // which compares according to LC_CTYPE category of the current locale.
-  // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the
-  // current locale.
-bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
-                                              const wchar_t* rhs) {
-  if (lhs == NULL) return rhs == NULL;
-
-  if (rhs == NULL) return false;
-
-#if GTEST_OS_WINDOWS
-  return _wcsicmp(lhs, rhs) == 0;
-#elif GTEST_OS_LINUX && !GTEST_OS_LINUX_ANDROID
-  return wcscasecmp(lhs, rhs) == 0;
-#else
-  // Android, Mac OS X and Cygwin don't define wcscasecmp.
-  // Other unknown OSes may not define it either.
-  wint_t left, right;
-  do {
-    left = towlower(*lhs++);
-    right = towlower(*rhs++);
-  } while (left && left == right);
-  return left == right;
-#endif  // OS selector
-}
-
-// Compares this with another String.
-// Returns < 0 if this is less than rhs, 0 if this is equal to rhs, or > 0
-// if this is greater than rhs.
-int String::Compare(const String & rhs) const {
-  const char* const lhs_c_str = c_str();
-  const char* const rhs_c_str = rhs.c_str();
-
-  if (lhs_c_str == NULL) {
-    return rhs_c_str == NULL ? 0 : -1;  // NULL < anything except NULL
-  } else if (rhs_c_str == NULL) {
-    return 1;
-  }
-
-  const size_t shorter_str_len =
-      length() <= rhs.length() ? length() : rhs.length();
-  for (size_t i = 0; i != shorter_str_len; i++) {
-    if (lhs_c_str[i] < rhs_c_str[i]) {
-      return -1;
-    } else if (lhs_c_str[i] > rhs_c_str[i]) {
-      return 1;
-    }
-  }
-  return (length() < rhs.length()) ? -1 :
-      (length() > rhs.length()) ? 1 : 0;
-}
-
-// Returns true iff this String ends with the given suffix.  *Any*
-// String is considered to end with a NULL or empty suffix.
-bool String::EndsWith(const char* suffix) const {
-  if (suffix == NULL || CStringEquals(suffix, "")) return true;
-
-  if (c_str() == NULL) return false;
-
-  const size_t this_len = strlen(c_str());
-  const size_t suffix_len = strlen(suffix);
-  return (this_len >= suffix_len) &&
-         CStringEquals(c_str() + this_len - suffix_len, suffix);
-}
-
-// Returns true iff this String ends with the given suffix, ignoring case.
-// Any String is considered to end with a NULL or empty suffix.
-bool String::EndsWithCaseInsensitive(const char* suffix) const {
-  if (suffix == NULL || CStringEquals(suffix, "")) return true;
-
-  if (c_str() == NULL) return false;
-
-  const size_t this_len = strlen(c_str());
-  const size_t suffix_len = strlen(suffix);
-  return (this_len >= suffix_len) &&
-         CaseInsensitiveCStringEquals(c_str() + this_len - suffix_len, suffix);
-}
-
-// Formats a list of arguments to a String, using the same format
-// spec string as for printf.
-//
-// We do not use the StringPrintf class as it is not universally
-// available.
-//
-// The result is limited to 4096 characters (including the tailing 0).
-// If 4096 characters are not enough to format the input, or if
-// there's an error, "<formatting error or buffer exceeded>" is
-// returned.
-String String::Format(const char * format, ...) {
-  va_list args;
-  va_start(args, format);
-
-  char buffer[4096];
-  const int kBufferSize = sizeof(buffer)/sizeof(buffer[0]);
-
-  // MSVC 8 deprecates vsnprintf(), so we want to suppress warning
-  // 4996 (deprecated function) there.
-#ifdef _MSC_VER  // We are using MSVC.
-# pragma warning(push)          // Saves the current warning state.
-# pragma warning(disable:4996)  // Temporarily disables warning 4996.
-
-  const int size = vsnprintf(buffer, kBufferSize, format, args);
-
-# pragma warning(pop)           // Restores the warning state.
-#else  // We are not using MSVC.
-  const int size = vsnprintf(buffer, kBufferSize, format, args);
-#endif  // _MSC_VER
-  va_end(args);
-
-  // vsnprintf()'s behavior is not portable.  When the buffer is not
-  // big enough, it returns a negative value in MSVC, and returns the
-  // needed buffer size on Linux.  When there is an output error, it
-  // always returns a negative value.  For simplicity, we lump the two
-  // error cases together.
-  if (size < 0 || size >= kBufferSize) {
-    return String("<formatting error or buffer exceeded>");
-  } else {
-    return String(buffer, size);
-  }
-}
-
-// Converts the buffer in a stringstream to a String, converting NUL
-// bytes to "\\0" along the way.
-String StringStreamToString(::std::stringstream* ss) {
-  const ::std::string& str = ss->str();
-  const char* const start = str.c_str();
-  const char* const end = start + str.length();
-
-  // We need to use a helper stringstream to do this transformation
-  // because String doesn't support push_back().
-  ::std::stringstream helper;
-  for (const char* ch = start; ch != end; ++ch) {
-    if (*ch == '\0') {
-      helper << "\\0";  // Replaces NUL with "\\0";
-    } else {
-      helper.put(*ch);
-    }
-  }
-
-  return String(helper.str().c_str());
-}
-
-// Appends the user-supplied message to the Google-Test-generated message.
-String AppendUserMessage(const String& gtest_msg,
-                         const Message& user_msg) {
-  // Appends the user message if it's non-empty.
-  const String user_msg_string = user_msg.GetString();
-  if (user_msg_string.empty()) {
-    return gtest_msg;
-  }
-
-  Message msg;
-  msg << gtest_msg << "\n" << user_msg_string;
-
-  return msg.GetString();
-}
-
-}  // namespace internal
-
-// class TestResult
-
-// Creates an empty TestResult.
-TestResult::TestResult()
-    : death_test_count_(0),
-      elapsed_time_(0) {
-}
-
-// D'tor.
-TestResult::~TestResult() {
-}
-
-// Returns the i-th test part result among all the results. i can
-// range from 0 to total_part_count() - 1. If i is not in that range,
-// aborts the program.
-const TestPartResult& TestResult::GetTestPartResult(int i) const {
-  if (i < 0 || i >= total_part_count())
-    internal::posix::Abort();
-  return test_part_results_.at(i);
-}
-
-// Returns the i-th test property. i can range from 0 to
-// test_property_count() - 1. If i is not in that range, aborts the
-// program.
-const TestProperty& TestResult::GetTestProperty(int i) const {
-  if (i < 0 || i >= test_property_count())
-    internal::posix::Abort();
-  return test_properties_.at(i);
-}
-
-// Clears the test part results.
-void TestResult::ClearTestPartResults() {
-  test_part_results_.clear();
-}
-
-// Adds a test part result to the list.
-void TestResult::AddTestPartResult(const TestPartResult& test_part_result) {
-  test_part_results_.push_back(test_part_result);
-}
-
-// Adds a test property to the list. If a property with the same key as the
-// supplied property is already represented, the value of this test_property
-// replaces the old value for that key.
-void TestResult::RecordProperty(const TestProperty& test_property) {
-  if (!ValidateTestProperty(test_property)) {
-    return;
-  }
-  internal::MutexLock lock(&test_properites_mutex_);
-  const std::vector<TestProperty>::iterator property_with_matching_key =
-      std::find_if(test_properties_.begin(), test_properties_.end(),
-                   internal::TestPropertyKeyIs(test_property.key()));
-  if (property_with_matching_key == test_properties_.end()) {
-    test_properties_.push_back(test_property);
-    return;
-  }
-  property_with_matching_key->SetValue(test_property.value());
-}
-
-// Adds a failure if the key is a reserved attribute of Google Test
-// testcase tags.  Returns true if the property is valid.
-bool TestResult::ValidateTestProperty(const TestProperty& test_property) {
-  internal::String key(test_property.key());
-  if (key == "name" || key == "status" || key == "time" || key == "classname") {
-    ADD_FAILURE()
-        << "Reserved key used in RecordProperty(): "
-        << key
-        << " ('name', 'status', 'time', and 'classname' are reserved by "
-        << GTEST_NAME_ << ")";
-    return false;
-  }
-  return true;
-}
-
-// Clears the object.
-void TestResult::Clear() {
-  test_part_results_.clear();
-  test_properties_.clear();
-  death_test_count_ = 0;
-  elapsed_time_ = 0;
-}
-
-// Returns true iff the test failed.
-bool TestResult::Failed() const {
-  for (int i = 0; i < total_part_count(); ++i) {
-    if (GetTestPartResult(i).failed())
-      return true;
-  }
-  return false;
-}
-
-// Returns true iff the test part fatally failed.
-static bool TestPartFatallyFailed(const TestPartResult& result) {
-  return result.fatally_failed();
-}
-
-// Returns true iff the test fatally failed.
-bool TestResult::HasFatalFailure() const {
-  return CountIf(test_part_results_, TestPartFatallyFailed) > 0;
-}
-
-// Returns true iff the test part non-fatally failed.
-static bool TestPartNonfatallyFailed(const TestPartResult& result) {
-  return result.nonfatally_failed();
-}
-
-// Returns true iff the test has a non-fatal failure.
-bool TestResult::HasNonfatalFailure() const {
-  return CountIf(test_part_results_, TestPartNonfatallyFailed) > 0;
-}
-
-// Gets the number of all test parts.  This is the sum of the number
-// of successful test parts and the number of failed test parts.
-int TestResult::total_part_count() const {
-  return static_cast<int>(test_part_results_.size());
-}
-
-// Returns the number of the test properties.
-int TestResult::test_property_count() const {
-  return static_cast<int>(test_properties_.size());
-}
-
-// class Test
-
-// Creates a Test object.
-
-// The c'tor saves the values of all Google Test flags.
-Test::Test()
-    : gtest_flag_saver_(new internal::GTestFlagSaver) {
-}
-
-// The d'tor restores the values of all Google Test flags.
-Test::~Test() {
-  delete gtest_flag_saver_;
-}
-
-// Sets up the test fixture.
-//
-// A sub-class may override this.
-void Test::SetUp() {
-}
-
-// Tears down the test fixture.
-//
-// A sub-class may override this.
-void Test::TearDown() {
-}
-
-// Allows user supplied key value pairs to be recorded for later output.
-void Test::RecordProperty(const char* key, const char* value) {
-  UnitTest::GetInstance()->RecordPropertyForCurrentTest(key, value);
-}
-
-// Allows user supplied key value pairs to be recorded for later output.
-void Test::RecordProperty(const char* key, int value) {
-  Message value_message;
-  value_message << value;
-  RecordProperty(key, value_message.GetString().c_str());
-}
-
-namespace internal {
-
-void ReportFailureInUnknownLocation(TestPartResult::Type result_type,
-                                    const String& message) {
-  // This function is a friend of UnitTest and as such has access to
-  // AddTestPartResult.
-  UnitTest::GetInstance()->AddTestPartResult(
-      result_type,
-      NULL,  // No info about the source file where the exception occurred.
-      -1,    // We have no info on which line caused the exception.
-      message,
-      String());  // No stack trace, either.
-}
-
-}  // namespace internal
-
-// Google Test requires all tests in the same test case to use the same test
-// fixture class.  This function checks if the current test has the
-// same fixture class as the first test in the current test case.  If
-// yes, it returns true; otherwise it generates a Google Test failure and
-// returns false.
-bool Test::HasSameFixtureClass() {
-  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
-  const TestCase* const test_case = impl->current_test_case();
-
-  // Info about the first test in the current test case.
-  const TestInfo* const first_test_info = test_case->test_info_list()[0];
-  const internal::TypeId first_fixture_id = first_test_info->fixture_class_id_;
-  const char* const first_test_name = first_test_info->name();
-
-  // Info about the current test.
-  const TestInfo* const this_test_info = impl->current_test_info();
-  const internal::TypeId this_fixture_id = this_test_info->fixture_class_id_;
-  const char* const this_test_name = this_test_info->name();
-
-  if (this_fixture_id != first_fixture_id) {
-    // Is the first test defined using TEST?
-    const bool first_is_TEST = first_fixture_id == internal::GetTestTypeId();
-    // Is this test defined using TEST?
-    const bool this_is_TEST = this_fixture_id == internal::GetTestTypeId();
-
-    if (first_is_TEST || this_is_TEST) {
-      // The user mixed TEST and TEST_F in this test case - we'll tell
-      // him/her how to fix it.
-
-      // Gets the name of the TEST and the name of the TEST_F.  Note
-      // that first_is_TEST and this_is_TEST cannot both be true, as
-      // the fixture IDs are different for the two tests.
-      const char* const TEST_name =
-          first_is_TEST ? first_test_name : this_test_name;
-      const char* const TEST_F_name =
-          first_is_TEST ? this_test_name : first_test_name;
-
-      ADD_FAILURE()
-          << "All tests in the same test case must use the same test fixture\n"
-          << "class, so mixing TEST_F and TEST in the same test case is\n"
-          << "illegal.  In test case " << this_test_info->test_case_name()
-          << ",\n"
-          << "test " << TEST_F_name << " is defined using TEST_F but\n"
-          << "test " << TEST_name << " is defined using TEST.  You probably\n"
-          << "want to change the TEST to TEST_F or move it to another test\n"
-          << "case.";
-    } else {
-      // The user defined two fixture classes with the same name in
-      // two namespaces - we'll tell him/her how to fix it.
-      ADD_FAILURE()
-          << "All tests in the same test case must use the same test fixture\n"
-          << "class.  However, in test case "
-          << this_test_info->test_case_name() << ",\n"
-          << "you defined test " << first_test_name
-          << " and test " << this_test_name << "\n"
-          << "using two different test fixture classes.  This can happen if\n"
-          << "the two classes are from different namespaces or translation\n"
-          << "units and have the same name.  You should probably rename one\n"
-          << "of the classes to put the tests into different test cases.";
-    }
-    return false;
-  }
-
-  return true;
-}
-
-#if GTEST_HAS_SEH
-
-// Adds an "exception thrown" fatal failure to the current test.  This
-// function returns its result via an output parameter pointer because VC++
-// prohibits creation of objects with destructors on stack in functions
-// using __try (see error C2712).
-static internal::String* FormatSehExceptionMessage(DWORD exception_code,
-                                                   const char* location) {
-  Message message;
-  message << "SEH exception with code 0x" << std::setbase(16) <<
-    exception_code << std::setbase(10) << " thrown in " << location << ".";
-
-  return new internal::String(message.GetString());
-}
-
-#endif  // GTEST_HAS_SEH
-
-#if GTEST_HAS_EXCEPTIONS
-
-// Adds an "exception thrown" fatal failure to the current test.
-static internal::String FormatCxxExceptionMessage(const char* description,
-                                                  const char* location) {
-  Message message;
-  if (description != NULL) {
-    message << "C++ exception with description \"" << description << "\"";
-  } else {
-    message << "Unknown C++ exception";
-  }
-  message << " thrown in " << location << ".";
-
-  return message.GetString();
-}
-
-static internal::String PrintTestPartResultToString(
-    const TestPartResult& test_part_result);
-
-// A failed Google Test assertion will throw an exception of this type when
-// GTEST_FLAG(throw_on_failure) is true (if exceptions are enabled).  We
-// derive it from std::runtime_error, which is for errors presumably
-// detectable only at run time.  Since std::runtime_error inherits from
-// std::exception, many testing frameworks know how to extract and print the
-// message inside it.
-class GoogleTestFailureException : public ::std::runtime_error {
- public:
-  explicit GoogleTestFailureException(const TestPartResult& failure)
-      : ::std::runtime_error(PrintTestPartResultToString(failure).c_str()) {}
-};
-#endif  // GTEST_HAS_EXCEPTIONS
-
-namespace internal {
-// We put these helper functions in the internal namespace as IBM's xlC
-// compiler rejects the code if they were declared static.
-
-// Runs the given method and handles SEH exceptions it throws, when
-// SEH is supported; returns the 0-value for type Result in case of an
-// SEH exception.  (Microsoft compilers cannot handle SEH and C++
-// exceptions in the same function.  Therefore, we provide a separate
-// wrapper function for handling SEH exceptions.)
-template <class T, typename Result>
-Result HandleSehExceptionsInMethodIfSupported(
-    T* object, Result (T::*method)(), const char* location) {
-#if GTEST_HAS_SEH
-  __try {
-    return (object->*method)();
-  } __except (internal::UnitTestOptions::GTestShouldProcessSEH(  // NOLINT
-      GetExceptionCode())) {
-    // We create the exception message on the heap because VC++ prohibits
-    // creation of objects with destructors on stack in functions using __try
-    // (see error C2712).
-    internal::String* exception_message = FormatSehExceptionMessage(
-        GetExceptionCode(), location);
-    internal::ReportFailureInUnknownLocation(TestPartResult::kFatalFailure,
-                                             *exception_message);
-    delete exception_message;
-    return static_cast<Result>(0);
-  }
-#else
-  (void)location;
-  return (object->*method)();
-#endif  // GTEST_HAS_SEH
-}
-
-// Runs the given method and catches and reports C++ and/or SEH-style
-// exceptions, if they are supported; returns the 0-value for type
-// Result in case of an SEH exception.
-template <class T, typename Result>
-Result HandleExceptionsInMethodIfSupported(
-    T* object, Result (T::*method)(), const char* location) {
-  // NOTE: The user code can affect the way in which Google Test handles
-  // exceptions by setting GTEST_FLAG(catch_exceptions), but only before
-  // RUN_ALL_TESTS() starts. It is technically possible to check the flag
-  // after the exception is caught and either report or re-throw the
-  // exception based on the flag's value:
-  //
-  // try {
-  //   // Perform the test method.
-  // } catch (...) {
-  //   if (GTEST_FLAG(catch_exceptions))
-  //     // Report the exception as failure.
-  //   else
-  //     throw;  // Re-throws the original exception.
-  // }
-  //
-  // However, the purpose of this flag is to allow the program to drop into
-  // the debugger when the exception is thrown. On most platforms, once the
-  // control enters the catch block, the exception origin information is
-  // lost and the debugger will stop the program at the point of the
-  // re-throw in this function -- instead of at the point of the original
-  // throw statement in the code under test.  For this reason, we perform
-  // the check early, sacrificing the ability to affect Google Test's
-  // exception handling in the method where the exception is thrown.
-  if (internal::GetUnitTestImpl()->catch_exceptions()) {
-#if GTEST_HAS_EXCEPTIONS
-    try {
-      return HandleSehExceptionsInMethodIfSupported(object, method, location);
-    } catch (const GoogleTestFailureException&) {  // NOLINT
-      // This exception doesn't originate in code under test. It makes no
-      // sense to report it as a test failure.
-      throw;
-    } catch (const std::exception& e) {  // NOLINT
-      internal::ReportFailureInUnknownLocation(
-          TestPartResult::kFatalFailure,
-          FormatCxxExceptionMessage(e.what(), location));
-    } catch (...) {  // NOLINT
-      internal::ReportFailureInUnknownLocation(
-          TestPartResult::kFatalFailure,
-          FormatCxxExceptionMessage(NULL, location));
-    }
-    return static_cast<Result>(0);
-#else
-    return HandleSehExceptionsInMethodIfSupported(object, method, location);
-#endif  // GTEST_HAS_EXCEPTIONS
-  } else {
-    return (object->*method)();
-  }
-}
-
-}  // namespace internal
-
-// Runs the test and updates the test result.
-void Test::Run() {
-  if (!HasSameFixtureClass()) return;
-
-  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
-  impl->os_stack_trace_getter()->UponLeavingGTest();
-  internal::HandleExceptionsInMethodIfSupported(this, &Test::SetUp, "SetUp()");
-  // We will run the test only if SetUp() was successful.
-  if (!HasFatalFailure()) {
-    impl->os_stack_trace_getter()->UponLeavingGTest();
-    internal::HandleExceptionsInMethodIfSupported(
-        this, &Test::TestBody, "the test body");
-  }
-
-  // However, we want to clean up as much as possible.  Hence we will
-  // always call TearDown(), even if SetUp() or the test body has
-  // failed.
-  impl->os_stack_trace_getter()->UponLeavingGTest();
-  internal::HandleExceptionsInMethodIfSupported(
-      this, &Test::TearDown, "TearDown()");
-}
-
-// Returns true iff the current test has a fatal failure.
-bool Test::HasFatalFailure() {
-  return internal::GetUnitTestImpl()->current_test_result()->HasFatalFailure();
-}
-
-// Returns true iff the current test has a non-fatal failure.
-bool Test::HasNonfatalFailure() {
-  return internal::GetUnitTestImpl()->current_test_result()->
-      HasNonfatalFailure();
-}
-
-// class TestInfo
-
-// Constructs a TestInfo object. It assumes ownership of the test factory
-// object.
-// TODO(vladl at google.com): Make a_test_case_name and a_name const string&'s
-// to signify they cannot be NULLs.
-TestInfo::TestInfo(const char* a_test_case_name,
-                   const char* a_name,
-                   const char* a_type_param,
-                   const char* a_value_param,
-                   internal::TypeId fixture_class_id,
-                   internal::TestFactoryBase* factory)
-    : test_case_name_(a_test_case_name),
-      name_(a_name),
-      type_param_(a_type_param ? new std::string(a_type_param) : NULL),
-      value_param_(a_value_param ? new std::string(a_value_param) : NULL),
-      fixture_class_id_(fixture_class_id),
-      should_run_(false),
-      is_disabled_(false),
-      matches_filter_(false),
-      factory_(factory),
-      result_() {}
-
-// Destructs a TestInfo object.
-TestInfo::~TestInfo() { delete factory_; }
-
-namespace internal {
-
-// Creates a new TestInfo object and registers it with Google Test;
-// returns the created object.
-//
-// Arguments:
-//
-//   test_case_name:   name of the test case
-//   name:             name of the test
-//   type_param:       the name of the test's type parameter, or NULL if
-//                     this is not a typed or a type-parameterized test.
-//   value_param:      text representation of the test's value parameter,
-//                     or NULL if this is not a value-parameterized test.
-//   fixture_class_id: ID of the test fixture class
-//   set_up_tc:        pointer to the function that sets up the test case
-//   tear_down_tc:     pointer to the function that tears down the test case
-//   factory:          pointer to the factory that creates a test object.
-//                     The newly created TestInfo instance will assume
-//                     ownership of the factory object.
-TestInfo* MakeAndRegisterTestInfo(
-    const char* test_case_name, const char* name,
-    const char* type_param,
-    const char* value_param,
-    TypeId fixture_class_id,
-    SetUpTestCaseFunc set_up_tc,
-    TearDownTestCaseFunc tear_down_tc,
-    TestFactoryBase* factory) {
-  TestInfo* const test_info =
-      new TestInfo(test_case_name, name, type_param, value_param,
-                   fixture_class_id, factory);
-  GetUnitTestImpl()->AddTestInfo(set_up_tc, tear_down_tc, test_info);
-  return test_info;
-}
-
-#if GTEST_HAS_PARAM_TEST
-void ReportInvalidTestCaseType(const char* test_case_name,
-                               const char* file, int line) {
-  Message errors;
-  errors
-      << "Attempted redefinition of test case " << test_case_name << ".\n"
-      << "All tests in the same test case must use the same test fixture\n"
-      << "class.  However, in test case " << test_case_name << ", you tried\n"
-      << "to define a test using a fixture class different from the one\n"
-      << "used earlier. This can happen if the two fixture classes are\n"
-      << "from different namespaces and have the same name. You should\n"
-      << "probably rename one of the classes to put the tests into different\n"
-      << "test cases.";
-
-  fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(),
-          errors.GetString().c_str());
-}
-#endif  // GTEST_HAS_PARAM_TEST
-
-}  // namespace internal
-
-namespace {
-
-// A predicate that checks the test name of a TestInfo against a known
-// value.
-//
-// This is used for implementation of the TestCase class only.  We put
-// it in the anonymous namespace to prevent polluting the outer
-// namespace.
-//
-// TestNameIs is copyable.
-class TestNameIs {
- public:
-  // Constructor.
-  //
-  // TestNameIs has NO default constructor.
-  explicit TestNameIs(const char* name)
-      : name_(name) {}
-
-  // Returns true iff the test name of test_info matches name_.
-  bool operator()(const TestInfo * test_info) const {
-    return test_info && internal::String(test_info->name()).Compare(name_) == 0;
-  }
-
- private:
-  internal::String name_;
-};
-
-}  // namespace
-
-namespace internal {
-
-// This method expands all parameterized tests registered with macros TEST_P
-// and INSTANTIATE_TEST_CASE_P into regular tests and registers those.
-// This will be done just once during the program runtime.
-void UnitTestImpl::RegisterParameterizedTests() {
-#if GTEST_HAS_PARAM_TEST
-  if (!parameterized_tests_registered_) {
-    parameterized_test_registry_.RegisterTests();
-    parameterized_tests_registered_ = true;
-  }
-#endif
-}
-
-}  // namespace internal
-
-// Creates the test object, runs it, records its result, and then
-// deletes it.
-void TestInfo::Run() {
-  if (!should_run_) return;
-
-  // Tells UnitTest where to store test result.
-  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
-  impl->set_current_test_info(this);
-
-  TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
-
-  // Notifies the unit test event listeners that a test is about to start.
-  repeater->OnTestStart(*this);
-
-  const TimeInMillis start = internal::GetTimeInMillis();
-
-  impl->os_stack_trace_getter()->UponLeavingGTest();
-
-  // Creates the test object.
-  Test* const test = internal::HandleExceptionsInMethodIfSupported(
-      factory_, &internal::TestFactoryBase::CreateTest,
-      "the test fixture's constructor");
-
-  // Runs the test only if the test object was created and its
-  // constructor didn't generate a fatal failure.
-  if ((test != NULL) && !Test::HasFatalFailure()) {
-    // This doesn't throw as all user code that can throw are wrapped into
-    // exception handling code.
-    test->Run();
-  }
-
-  // Deletes the test object.
-  impl->os_stack_trace_getter()->UponLeavingGTest();
-  internal::HandleExceptionsInMethodIfSupported(
-      test, &Test::DeleteSelf_, "the test fixture's destructor");
-
-  result_.set_elapsed_time(internal::GetTimeInMillis() - start);
-
-  // Notifies the unit test event listener that a test has just finished.
-  repeater->OnTestEnd(*this);
-
-  // Tells UnitTest to stop associating assertion results to this
-  // test.
-  impl->set_current_test_info(NULL);
-}
-
-// class TestCase
-
-// Gets the number of successful tests in this test case.
-int TestCase::successful_test_count() const {
-  return CountIf(test_info_list_, TestPassed);
-}
-
-// Gets the number of failed tests in this test case.
-int TestCase::failed_test_count() const {
-  return CountIf(test_info_list_, TestFailed);
-}
-
-int TestCase::disabled_test_count() const {
-  return CountIf(test_info_list_, TestDisabled);
-}
-
-// Get the number of tests in this test case that should run.
-int TestCase::test_to_run_count() const {
-  return CountIf(test_info_list_, ShouldRunTest);
-}
-
-// Gets the number of all tests.
-int TestCase::total_test_count() const {
-  return static_cast<int>(test_info_list_.size());
-}
-
-// Creates a TestCase with the given name.
-//
-// Arguments:
-//
-//   name:         name of the test case
-//   a_type_param: the name of the test case's type parameter, or NULL if
-//                 this is not a typed or a type-parameterized test case.
-//   set_up_tc:    pointer to the function that sets up the test case
-//   tear_down_tc: pointer to the function that tears down the test case
-TestCase::TestCase(const char* a_name, const char* a_type_param,
-                   Test::SetUpTestCaseFunc set_up_tc,
-                   Test::TearDownTestCaseFunc tear_down_tc)
-    : name_(a_name),
-      type_param_(a_type_param ? new std::string(a_type_param) : NULL),
-      set_up_tc_(set_up_tc),
-      tear_down_tc_(tear_down_tc),
-      should_run_(false),
-      elapsed_time_(0) {
-}
-
-// Destructor of TestCase.
-TestCase::~TestCase() {
-  // Deletes every Test in the collection.
-  ForEach(test_info_list_, internal::Delete<TestInfo>);
-}
-
-// Returns the i-th test among all the tests. i can range from 0 to
-// total_test_count() - 1. If i is not in that range, returns NULL.
-const TestInfo* TestCase::GetTestInfo(int i) const {
-  const int index = GetElementOr(test_indices_, i, -1);
-  return index < 0 ? NULL : test_info_list_[index];
-}
-
-// Returns the i-th test among all the tests. i can range from 0 to
-// total_test_count() - 1. If i is not in that range, returns NULL.
-TestInfo* TestCase::GetMutableTestInfo(int i) {
-  const int index = GetElementOr(test_indices_, i, -1);
-  return index < 0 ? NULL : test_info_list_[index];
-}
-
-// Adds a test to this test case.  Will delete the test upon
-// destruction of the TestCase object.
-void TestCase::AddTestInfo(TestInfo * test_info) {
-  test_info_list_.push_back(test_info);
-  test_indices_.push_back(static_cast<int>(test_indices_.size()));
-}
-
-// Runs every test in this TestCase.
-void TestCase::Run() {
-  if (!should_run_) return;
-
-  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
-  impl->set_current_test_case(this);
-
-  TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
-
-  repeater->OnTestCaseStart(*this);
-  impl->os_stack_trace_getter()->UponLeavingGTest();
-  internal::HandleExceptionsInMethodIfSupported(
-      this, &TestCase::RunSetUpTestCase, "SetUpTestCase()");
-
-  const internal::TimeInMillis start = internal::GetTimeInMillis();
-  for (int i = 0; i < total_test_count(); i++) {
-    GetMutableTestInfo(i)->Run();
-  }
-  elapsed_time_ = internal::GetTimeInMillis() - start;
-
-  impl->os_stack_trace_getter()->UponLeavingGTest();
-  internal::HandleExceptionsInMethodIfSupported(
-      this, &TestCase::RunTearDownTestCase, "TearDownTestCase()");
-
-  repeater->OnTestCaseEnd(*this);
-  impl->set_current_test_case(NULL);
-}
-
-// Clears the results of all tests in this test case.
-void TestCase::ClearResult() {
-  ForEach(test_info_list_, TestInfo::ClearTestResult);
-}
-
-// Shuffles the tests in this test case.
-void TestCase::ShuffleTests(internal::Random* random) {
-  Shuffle(random, &test_indices_);
-}
-
-// Restores the test order to before the first shuffle.
-void TestCase::UnshuffleTests() {
-  for (size_t i = 0; i < test_indices_.size(); i++) {
-    test_indices_[i] = static_cast<int>(i);
-  }
-}
-
-// Formats a countable noun.  Depending on its quantity, either the
-// singular form or the plural form is used. e.g.
-//
-// FormatCountableNoun(1, "formula", "formuli") returns "1 formula".
-// FormatCountableNoun(5, "book", "books") returns "5 books".
-static internal::String FormatCountableNoun(int count,
-                                            const char * singular_form,
-                                            const char * plural_form) {
-  return internal::String::Format("%d %s", count,
-                                  count == 1 ? singular_form : plural_form);
-}
-
-// Formats the count of tests.
-static internal::String FormatTestCount(int test_count) {
-  return FormatCountableNoun(test_count, "test", "tests");
-}
-
-// Formats the count of test cases.
-static internal::String FormatTestCaseCount(int test_case_count) {
-  return FormatCountableNoun(test_case_count, "test case", "test cases");
-}
-
-// Converts a TestPartResult::Type enum to human-friendly string
-// representation.  Both kNonFatalFailure and kFatalFailure are translated
-// to "Failure", as the user usually doesn't care about the difference
-// between the two when viewing the test result.
-static const char * TestPartResultTypeToString(TestPartResult::Type type) {
-  switch (type) {
-    case TestPartResult::kSuccess:
-      return "Success";
-
-    case TestPartResult::kNonFatalFailure:
-    case TestPartResult::kFatalFailure:
-#ifdef _MSC_VER
-      return "error: ";
-#else
-      return "Failure\n";
-#endif
-    default:
-      return "Unknown result type";
-  }
-}
-
-// Prints a TestPartResult to a String.
-static internal::String PrintTestPartResultToString(
-    const TestPartResult& test_part_result) {
-  return (Message()
-          << internal::FormatFileLocation(test_part_result.file_name(),
-                                          test_part_result.line_number())
-          << " " << TestPartResultTypeToString(test_part_result.type())
-          << test_part_result.message()).GetString();
-}
-
-// Prints a TestPartResult.
-static void PrintTestPartResult(const TestPartResult& test_part_result) {
-  const internal::String& result =
-      PrintTestPartResultToString(test_part_result);
-  printf("%s\n", result.c_str());
-  fflush(stdout);
-  // If the test program runs in Visual Studio or a debugger, the
-  // following statements add the test part result message to the Output
-  // window such that the user can double-click on it to jump to the
-  // corresponding source code location; otherwise they do nothing.
-#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
-  // We don't call OutputDebugString*() on Windows Mobile, as printing
-  // to stdout is done by OutputDebugString() there already - we don't
-  // want the same message printed twice.
-  ::OutputDebugStringA(result.c_str());
-  ::OutputDebugStringA("\n");
-#endif
-}
-
-// class PrettyUnitTestResultPrinter
-
-namespace internal {
-
-enum GTestColor {
-  COLOR_DEFAULT,
-  COLOR_RED,
-  COLOR_GREEN,
-  COLOR_YELLOW
-};
-
-#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
-
-// Returns the character attribute for the given color.
-WORD GetColorAttribute(GTestColor color) {
-  switch (color) {
-    case COLOR_RED:    return FOREGROUND_RED;
-    case COLOR_GREEN:  return FOREGROUND_GREEN;
-    case COLOR_YELLOW: return FOREGROUND_RED | FOREGROUND_GREEN;
-    default:           return 0;
-  }
-}
-
-#else
-
-// Returns the ANSI color code for the given color.  COLOR_DEFAULT is
-// an invalid input.
-const char* GetAnsiColorCode(GTestColor color) {
-  switch (color) {
-    case COLOR_RED:     return "1";
-    case COLOR_GREEN:   return "2";
-    case COLOR_YELLOW:  return "3";
-    default:            return NULL;
-  };
-}
-
-#endif  // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
-
-// Returns true iff Google Test should use colors in the output.
-bool ShouldUseColor(bool stdout_is_tty) {
-  const char* const gtest_color = GTEST_FLAG(color).c_str();
-
-  if (String::CaseInsensitiveCStringEquals(gtest_color, "auto")) {
-#if GTEST_OS_WINDOWS
-    // On Windows the TERM variable is usually not set, but the
-    // console there does support colors.
-    return stdout_is_tty;
-#else
-    // On non-Windows platforms, we rely on the TERM variable.
-    const char* const term = posix::GetEnv("TERM");
-    const bool term_supports_color =
-        String::CStringEquals(term, "xterm") ||
-        String::CStringEquals(term, "xterm-color") ||
-        String::CStringEquals(term, "xterm-256color") ||
-        String::CStringEquals(term, "screen") ||
-        String::CStringEquals(term, "linux") ||
-        String::CStringEquals(term, "cygwin");
-    return stdout_is_tty && term_supports_color;
-#endif  // GTEST_OS_WINDOWS
-  }
-
-  return String::CaseInsensitiveCStringEquals(gtest_color, "yes") ||
-      String::CaseInsensitiveCStringEquals(gtest_color, "true") ||
-      String::CaseInsensitiveCStringEquals(gtest_color, "t") ||
-      String::CStringEquals(gtest_color, "1");
-  // We take "yes", "true", "t", and "1" as meaning "yes".  If the
-  // value is neither one of these nor "auto", we treat it as "no" to
-  // be conservative.
-}
-
-// Helpers for printing colored strings to stdout. Note that on Windows, we
-// cannot simply emit special characters and have the terminal change colors.
-// This routine must actually emit the characters rather than return a string
-// that would be colored when printed, as can be done on Linux.
-void ColoredPrintf(GTestColor color, const char* fmt, ...) {
-  va_list args;
-  va_start(args, fmt);
-
-#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || GTEST_OS_ZOS
-  const bool use_color = false;
-#else
-  static const bool in_color_mode =
-      ShouldUseColor(posix::IsATTY(posix::FileNo(stdout)) != 0);
-  const bool use_color = in_color_mode && (color != COLOR_DEFAULT);
-#endif  // GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || GTEST_OS_ZOS
-  // The '!= 0' comparison is necessary to satisfy MSVC 7.1.
-
-  if (!use_color) {
-    vprintf(fmt, args);
-    va_end(args);
-    return;
-  }
-
-#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
-  const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
-
-  // Gets the current text color.
-  CONSOLE_SCREEN_BUFFER_INFO buffer_info;
-  GetConsoleScreenBufferInfo(stdout_handle, &buffer_info);
-  const WORD old_color_attrs = buffer_info.wAttributes;
-
-  // We need to flush the stream buffers into the console before each
-  // SetConsoleTextAttribute call lest it affect the text that is already
-  // printed but has not yet reached the console.
-  fflush(stdout);
-  SetConsoleTextAttribute(stdout_handle,
-                          GetColorAttribute(color) | FOREGROUND_INTENSITY);
-  vprintf(fmt, args);
-
-  fflush(stdout);
-  // Restores the text color.
-  SetConsoleTextAttribute(stdout_handle, old_color_attrs);
-#else
-  printf("\033[0;3%sm", GetAnsiColorCode(color));
-  vprintf(fmt, args);
-  printf("\033[m");  // Resets the terminal to default.
-#endif  // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
-  va_end(args);
-}
-
-void PrintFullTestCommentIfPresent(const TestInfo& test_info) {
-  const char* const type_param = test_info.type_param();
-  const char* const value_param = test_info.value_param();
-
-  if (type_param != NULL || value_param != NULL) {
-    printf(", where ");
-    if (type_param != NULL) {
-      printf("TypeParam = %s", type_param);
-      if (value_param != NULL)
-        printf(" and ");
-    }
-    if (value_param != NULL) {
-      printf("GetParam() = %s", value_param);
-    }
-  }
-}
-
-// This class implements the TestEventListener interface.
-//
-// Class PrettyUnitTestResultPrinter is copyable.
-class PrettyUnitTestResultPrinter : public TestEventListener {
- public:
-  PrettyUnitTestResultPrinter() {}
-  static void PrintTestName(const char * test_case, const char * test) {
-    printf("%s.%s", test_case, test);
-  }
-
-  // The following methods override what's in the TestEventListener class.
-  virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {}
-  virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration);
-  virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test);
-  virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {}
-  virtual void OnTestCaseStart(const TestCase& test_case);
-  virtual void OnTestStart(const TestInfo& test_info);
-  virtual void OnTestPartResult(const TestPartResult& result);
-  virtual void OnTestEnd(const TestInfo& test_info);
-  virtual void OnTestCaseEnd(const TestCase& test_case);
-  virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test);
-  virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {}
-  virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration);
-  virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {}
-
- private:
-  static void PrintFailedTests(const UnitTest& unit_test);
-
-  internal::String test_case_name_;
-};
-
-  // Fired before each iteration of tests starts.
-void PrettyUnitTestResultPrinter::OnTestIterationStart(
-    const UnitTest& unit_test, int iteration) {
-  if (GTEST_FLAG(repeat) != 1)
-    printf("\nRepeating all tests (iteration %d) . . .\n\n", iteration + 1);
-
-  const char* const filter = GTEST_FLAG(filter).c_str();
-
-  // Prints the filter if it's not *.  This reminds the user that some
-  // tests may be skipped.
-  if (!internal::String::CStringEquals(filter, kUniversalFilter)) {
-    ColoredPrintf(COLOR_YELLOW,
-                  "Note: %s filter = %s\n", GTEST_NAME_, filter);
-  }
-
-  if (internal::ShouldShard(kTestTotalShards, kTestShardIndex, false)) {
-    const Int32 shard_index = Int32FromEnvOrDie(kTestShardIndex, -1);
-    ColoredPrintf(COLOR_YELLOW,
-                  "Note: This is test shard %d of %s.\n",
-                  static_cast<int>(shard_index) + 1,
-                  internal::posix::GetEnv(kTestTotalShards));
-  }
-
-  if (GTEST_FLAG(shuffle)) {
-    ColoredPrintf(COLOR_YELLOW,
-                  "Note: Randomizing tests' orders with a seed of %d .\n",
-                  unit_test.random_seed());
-  }
-
-  ColoredPrintf(COLOR_GREEN,  "[==========] ");
-  printf("Running %s from %s.\n",
-         FormatTestCount(unit_test.test_to_run_count()).c_str(),
-         FormatTestCaseCount(unit_test.test_case_to_run_count()).c_str());
-  fflush(stdout);
-}
-
-void PrettyUnitTestResultPrinter::OnEnvironmentsSetUpStart(
-    const UnitTest& /*unit_test*/) {
-  ColoredPrintf(COLOR_GREEN,  "[----------] ");
-  printf("Global test environment set-up.\n");
-  fflush(stdout);
-}
-
-void PrettyUnitTestResultPrinter::OnTestCaseStart(const TestCase& test_case) {
-  test_case_name_ = test_case.name();
-  const internal::String counts =
-      FormatCountableNoun(test_case.test_to_run_count(), "test", "tests");
-  ColoredPrintf(COLOR_GREEN, "[----------] ");
-  printf("%s from %s", counts.c_str(), test_case_name_.c_str());
-  if (test_case.type_param() == NULL) {
-    printf("\n");
-  } else {
-    printf(", where TypeParam = %s\n", test_case.type_param());
-  }
-  fflush(stdout);
-}
-
-void PrettyUnitTestResultPrinter::OnTestStart(const TestInfo& test_info) {
-  ColoredPrintf(COLOR_GREEN,  "[ RUN      ] ");
-  PrintTestName(test_case_name_.c_str(), test_info.name());
-  printf("\n");
-  fflush(stdout);
-}
-
-// Called after an assertion failure.
-void PrettyUnitTestResultPrinter::OnTestPartResult(
-    const TestPartResult& result) {
-  // If the test part succeeded, we don't need to do anything.
-  if (result.type() == TestPartResult::kSuccess)
-    return;
-
-  // Print failure message from the assertion (e.g. expected this and got that).
-  PrintTestPartResult(result);
-  fflush(stdout);
-}
-
-void PrettyUnitTestResultPrinter::OnTestEnd(const TestInfo& test_info) {
-  if (test_info.result()->Passed()) {
-    ColoredPrintf(COLOR_GREEN, "[       OK ] ");
-  } else {
-    ColoredPrintf(COLOR_RED, "[  FAILED  ] ");
-  }
-  PrintTestName(test_case_name_.c_str(), test_info.name());
-  if (test_info.result()->Failed())
-    PrintFullTestCommentIfPresent(test_info);
-
-  if (GTEST_FLAG(print_time)) {
-    printf(" (%s ms)\n", internal::StreamableToString(
-           test_info.result()->elapsed_time()).c_str());
-  } else {
-    printf("\n");
-  }
-  fflush(stdout);
-}
-
-void PrettyUnitTestResultPrinter::OnTestCaseEnd(const TestCase& test_case) {
-  if (!GTEST_FLAG(print_time)) return;
-
-  test_case_name_ = test_case.name();
-  const internal::String counts =
-      FormatCountableNoun(test_case.test_to_run_count(), "test", "tests");
-  ColoredPrintf(COLOR_GREEN, "[----------] ");
-  printf("%s from %s (%s ms total)\n\n",
-         counts.c_str(), test_case_name_.c_str(),
-         internal::StreamableToString(test_case.elapsed_time()).c_str());
-  fflush(stdout);
-}
-
-void PrettyUnitTestResultPrinter::OnEnvironmentsTearDownStart(
-    const UnitTest& /*unit_test*/) {
-  ColoredPrintf(COLOR_GREEN,  "[----------] ");
-  printf("Global test environment tear-down\n");
-  fflush(stdout);
-}
-
-// Internal helper for printing the list of failed tests.
-void PrettyUnitTestResultPrinter::PrintFailedTests(const UnitTest& unit_test) {
-  const int failed_test_count = unit_test.failed_test_count();
-  if (failed_test_count == 0) {
-    return;
-  }
-
-  for (int i = 0; i < unit_test.total_test_case_count(); ++i) {
-    const TestCase& test_case = *unit_test.GetTestCase(i);
-    if (!test_case.should_run() || (test_case.failed_test_count() == 0)) {
-      continue;
-    }
-    for (int j = 0; j < test_case.total_test_count(); ++j) {
-      const TestInfo& test_info = *test_case.GetTestInfo(j);
-      if (!test_info.should_run() || test_info.result()->Passed()) {
-        continue;
-      }
-      ColoredPrintf(COLOR_RED, "[  FAILED  ] ");
-      printf("%s.%s", test_case.name(), test_info.name());
-      PrintFullTestCommentIfPresent(test_info);
-      printf("\n");
-    }
-  }
-}
-
-void PrettyUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
-                                                     int /*iteration*/) {
-  ColoredPrintf(COLOR_GREEN,  "[==========] ");
-  printf("%s from %s ran.",
-         FormatTestCount(unit_test.test_to_run_count()).c_str(),
-         FormatTestCaseCount(unit_test.test_case_to_run_count()).c_str());
-  if (GTEST_FLAG(print_time)) {
-    printf(" (%s ms total)",
-           internal::StreamableToString(unit_test.elapsed_time()).c_str());
-  }
-  printf("\n");
-  ColoredPrintf(COLOR_GREEN,  "[  PASSED  ] ");
-  printf("%s.\n", FormatTestCount(unit_test.successful_test_count()).c_str());
-
-  int num_failures = unit_test.failed_test_count();
-  if (!unit_test.Passed()) {
-    const int failed_test_count = unit_test.failed_test_count();
-    ColoredPrintf(COLOR_RED,  "[  FAILED  ] ");
-    printf("%s, listed below:\n", FormatTestCount(failed_test_count).c_str());
-    PrintFailedTests(unit_test);
-    printf("\n%2d FAILED %s\n", num_failures,
-                        num_failures == 1 ? "TEST" : "TESTS");
-  }
-
-  int num_disabled = unit_test.disabled_test_count();
-  if (num_disabled && !GTEST_FLAG(also_run_disabled_tests)) {
-    if (!num_failures) {
-      printf("\n");  // Add a spacer if no FAILURE banner is displayed.
-    }
-    ColoredPrintf(COLOR_YELLOW,
-                  "  YOU HAVE %d DISABLED %s\n\n",
-                  num_disabled,
-                  num_disabled == 1 ? "TEST" : "TESTS");
-  }
-  // Ensure that Google Test output is printed before, e.g., heapchecker output.
-  fflush(stdout);
-}
-
-// End PrettyUnitTestResultPrinter
-
-// class TestEventRepeater
-//
-// This class forwards events to other event listeners.
-class TestEventRepeater : public TestEventListener {
- public:
-  TestEventRepeater() : forwarding_enabled_(true) {}
-  virtual ~TestEventRepeater();
-  void Append(TestEventListener *listener);
-  TestEventListener* Release(TestEventListener* listener);
-
-  // Controls whether events will be forwarded to listeners_. Set to false
-  // in death test child processes.
-  bool forwarding_enabled() const { return forwarding_enabled_; }
-  void set_forwarding_enabled(bool enable) { forwarding_enabled_ = enable; }
-
-  virtual void OnTestProgramStart(const UnitTest& unit_test);
-  virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration);
-  virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test);
-  virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test);
-  virtual void OnTestCaseStart(const TestCase& test_case);
-  virtual void OnTestStart(const TestInfo& test_info);
-  virtual void OnTestPartResult(const TestPartResult& result);
-  virtual void OnTestEnd(const TestInfo& test_info);
-  virtual void OnTestCaseEnd(const TestCase& test_case);
-  virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test);
-  virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test);
-  virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration);
-  virtual void OnTestProgramEnd(const UnitTest& unit_test);
-
- private:
-  // Controls whether events will be forwarded to listeners_. Set to false
-  // in death test child processes.
-  bool forwarding_enabled_;
-  // The list of listeners that receive events.
-  std::vector<TestEventListener*> listeners_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventRepeater);
-};
-
-TestEventRepeater::~TestEventRepeater() {
-  ForEach(listeners_, Delete<TestEventListener>);
-}
-
-void TestEventRepeater::Append(TestEventListener *listener) {
-  listeners_.push_back(listener);
-}
-
-// TODO(vladl at google.com): Factor the search functionality into Vector::Find.
-TestEventListener* TestEventRepeater::Release(TestEventListener *listener) {
-  for (size_t i = 0; i < listeners_.size(); ++i) {
-    if (listeners_[i] == listener) {
-      listeners_.erase(listeners_.begin() + i);
-      return listener;
-    }
-  }
-
-  return NULL;
-}
-
-// Since most methods are very similar, use macros to reduce boilerplate.
-// This defines a member that forwards the call to all listeners.
-#define GTEST_REPEATER_METHOD_(Name, Type) \
-void TestEventRepeater::Name(const Type& parameter) { \
-  if (forwarding_enabled_) { \
-    for (size_t i = 0; i < listeners_.size(); i++) { \
-      listeners_[i]->Name(parameter); \
-    } \
-  } \
-}
-// This defines a member that forwards the call to all listeners in reverse
-// order.
-#define GTEST_REVERSE_REPEATER_METHOD_(Name, Type) \
-void TestEventRepeater::Name(const Type& parameter) { \
-  if (forwarding_enabled_) { \
-    for (int i = static_cast<int>(listeners_.size()) - 1; i >= 0; i--) { \
-      listeners_[i]->Name(parameter); \
-    } \
-  } \
-}
-
-GTEST_REPEATER_METHOD_(OnTestProgramStart, UnitTest)
-GTEST_REPEATER_METHOD_(OnEnvironmentsSetUpStart, UnitTest)
-GTEST_REPEATER_METHOD_(OnTestCaseStart, TestCase)
-GTEST_REPEATER_METHOD_(OnTestStart, TestInfo)
-GTEST_REPEATER_METHOD_(OnTestPartResult, TestPartResult)
-GTEST_REPEATER_METHOD_(OnEnvironmentsTearDownStart, UnitTest)
-GTEST_REVERSE_REPEATER_METHOD_(OnEnvironmentsSetUpEnd, UnitTest)
-GTEST_REVERSE_REPEATER_METHOD_(OnEnvironmentsTearDownEnd, UnitTest)
-GTEST_REVERSE_REPEATER_METHOD_(OnTestEnd, TestInfo)
-GTEST_REVERSE_REPEATER_METHOD_(OnTestCaseEnd, TestCase)
-GTEST_REVERSE_REPEATER_METHOD_(OnTestProgramEnd, UnitTest)
-
-#undef GTEST_REPEATER_METHOD_
-#undef GTEST_REVERSE_REPEATER_METHOD_
-
-void TestEventRepeater::OnTestIterationStart(const UnitTest& unit_test,
-                                             int iteration) {
-  if (forwarding_enabled_) {
-    for (size_t i = 0; i < listeners_.size(); i++) {
-      listeners_[i]->OnTestIterationStart(unit_test, iteration);
-    }
-  }
-}
-
-void TestEventRepeater::OnTestIterationEnd(const UnitTest& unit_test,
-                                           int iteration) {
-  if (forwarding_enabled_) {
-    for (int i = static_cast<int>(listeners_.size()) - 1; i >= 0; i--) {
-      listeners_[i]->OnTestIterationEnd(unit_test, iteration);
-    }
-  }
-}
-
-// End TestEventRepeater
-
-// This class generates an XML output file.
-class XmlUnitTestResultPrinter : public EmptyTestEventListener {
- public:
-  explicit XmlUnitTestResultPrinter(const char* output_file);
-
-  virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration);
-
- private:
-  // Is c a whitespace character that is normalized to a space character
-  // when it appears in an XML attribute value?
-  static bool IsNormalizableWhitespace(char c) {
-    return c == 0x9 || c == 0xA || c == 0xD;
-  }
-
-  // May c appear in a well-formed XML document?
-  static bool IsValidXmlCharacter(char c) {
-    return IsNormalizableWhitespace(c) || c >= 0x20;
-  }
-
-  // Returns an XML-escaped copy of the input string str.  If
-  // is_attribute is true, the text is meant to appear as an attribute
-  // value, and normalizable whitespace is preserved by replacing it
-  // with character references.
-  static String EscapeXml(const char* str, bool is_attribute);
-
-  // Returns the given string with all characters invalid in XML removed.
-  static string RemoveInvalidXmlCharacters(const string& str);
-
-  // Convenience wrapper around EscapeXml when str is an attribute value.
-  static String EscapeXmlAttribute(const char* str) {
-    return EscapeXml(str, true);
-  }
-
-  // Convenience wrapper around EscapeXml when str is not an attribute value.
-  static String EscapeXmlText(const char* str) { return EscapeXml(str, false); }
-
-  // Streams an XML CDATA section, escaping invalid CDATA sequences as needed.
-  static void OutputXmlCDataSection(::std::ostream* stream, const char* data);
-
-  // Streams an XML representation of a TestInfo object.
-  static void OutputXmlTestInfo(::std::ostream* stream,
-                                const char* test_case_name,
-                                const TestInfo& test_info);
-
-  // Prints an XML representation of a TestCase object
-  static void PrintXmlTestCase(FILE* out, const TestCase& test_case);
-
-  // Prints an XML summary of unit_test to output stream out.
-  static void PrintXmlUnitTest(FILE* out, const UnitTest& unit_test);
-
-  // Produces a string representing the test properties in a result as space
-  // delimited XML attributes based on the property key="value" pairs.
-  // When the String is not empty, it includes a space at the beginning,
-  // to delimit this attribute from prior attributes.
-  static String TestPropertiesAsXmlAttributes(const TestResult& result);
-
-  // The output file.
-  const String output_file_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(XmlUnitTestResultPrinter);
-};
-
-// Creates a new XmlUnitTestResultPrinter.
-XmlUnitTestResultPrinter::XmlUnitTestResultPrinter(const char* output_file)
-    : output_file_(output_file) {
-  if (output_file_.c_str() == NULL || output_file_.empty()) {
-    fprintf(stderr, "XML output file may not be null\n");
-    fflush(stderr);
-    exit(EXIT_FAILURE);
-  }
-}
-
-// Called after the unit test ends.
-void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
-                                                  int /*iteration*/) {
-  FILE* xmlout = NULL;
-  FilePath output_file(output_file_);
-  FilePath output_dir(output_file.RemoveFileName());
-
-  if (output_dir.CreateDirectoriesRecursively()) {
-    xmlout = posix::FOpen(output_file_.c_str(), "w");
-  }
-  if (xmlout == NULL) {
-    // TODO(wan): report the reason of the failure.
-    //
-    // We don't do it for now as:
-    //
-    //   1. There is no urgent need for it.
-    //   2. It's a bit involved to make the errno variable thread-safe on
-    //      all three operating systems (Linux, Windows, and Mac OS).
-    //   3. To interpret the meaning of errno in a thread-safe way,
-    //      we need the strerror_r() function, which is not available on
-    //      Windows.
-    fprintf(stderr,
-            "Unable to open file \"%s\"\n",
-            output_file_.c_str());
-    fflush(stderr);
-    exit(EXIT_FAILURE);
-  }
-  PrintXmlUnitTest(xmlout, unit_test);
-  fclose(xmlout);
-}
-
-// Returns an XML-escaped copy of the input string str.  If is_attribute
-// is true, the text is meant to appear as an attribute value, and
-// normalizable whitespace is preserved by replacing it with character
-// references.
-//
-// Invalid XML characters in str, if any, are stripped from the output.
-// It is expected that most, if not all, of the text processed by this
-// module will consist of ordinary English text.
-// If this module is ever modified to produce version 1.1 XML output,
-// most invalid characters can be retained using character references.
-// TODO(wan): It might be nice to have a minimally invasive, human-readable
-// escaping scheme for invalid characters, rather than dropping them.
-String XmlUnitTestResultPrinter::EscapeXml(const char* str, bool is_attribute) {
-  Message m;
-
-  if (str != NULL) {
-    for (const char* src = str; *src; ++src) {
-      switch (*src) {
-        case '<':
-          m << "<";
-          break;
-        case '>':
-          m << ">";
-          break;
-        case '&':
-          m << "&";
-          break;
-        case '\'':
-          if (is_attribute)
-            m << "'";
-          else
-            m << '\'';
-          break;
-        case '"':
-          if (is_attribute)
-            m << """;
-          else
-            m << '"';
-          break;
-        default:
-          if (IsValidXmlCharacter(*src)) {
-            if (is_attribute && IsNormalizableWhitespace(*src))
-              m << String::Format("&#x%02X;", unsigned(*src));
-            else
-              m << *src;
-          }
-          break;
-      }
-    }
-  }
-
-  return m.GetString();
-}
-
-// Returns the given string with all characters invalid in XML removed.
-// Currently invalid characters are dropped from the string. An
-// alternative is to replace them with certain characters such as . or ?.
-string XmlUnitTestResultPrinter::RemoveInvalidXmlCharacters(const string& str) {
-  string output;
-  output.reserve(str.size());
-  for (string::const_iterator it = str.begin(); it != str.end(); ++it)
-    if (IsValidXmlCharacter(*it))
-      output.push_back(*it);
-
-  return output;
-}
-
-// The following routines generate an XML representation of a UnitTest
-// object.
-//
-// This is how Google Test concepts map to the DTD:
-//
-// <testsuites name="AllTests">        <-- corresponds to a UnitTest object
-//   <testsuite name="testcase-name">  <-- corresponds to a TestCase object
-//     <testcase name="test-name">     <-- corresponds to a TestInfo object
-//       <failure message="...">...</failure>
-//       <failure message="...">...</failure>
-//       <failure message="...">...</failure>
-//                                     <-- individual assertion failures
-//     </testcase>
-//   </testsuite>
-// </testsuites>
-
-// Formats the given time in milliseconds as seconds.
-std::string FormatTimeInMillisAsSeconds(TimeInMillis ms) {
-  ::std::stringstream ss;
-  ss << ms/1000.0;
-  return ss.str();
-}
-
-// Streams an XML CDATA section, escaping invalid CDATA sequences as needed.
-void XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream,
-                                                     const char* data) {
-  const char* segment = data;
-  *stream << "<![CDATA[";
-  for (;;) {
-    const char* const next_segment = strstr(segment, "]]>");
-    if (next_segment != NULL) {
-      stream->write(
-          segment, static_cast<std::streamsize>(next_segment - segment));
-      *stream << "]]>]]><![CDATA[";
-      segment = next_segment + strlen("]]>");
-    } else {
-      *stream << segment;
-      break;
-    }
-  }
-  *stream << "]]>";
-}
-
-// Prints an XML representation of a TestInfo object.
-// TODO(wan): There is also value in printing properties with the plain printer.
-void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
-                                                 const char* test_case_name,
-                                                 const TestInfo& test_info) {
-  const TestResult& result = *test_info.result();
-  *stream << "    <testcase name=\""
-          << EscapeXmlAttribute(test_info.name()).c_str() << "\"";
-
-  if (test_info.value_param() != NULL) {
-    *stream << " value_param=\"" << EscapeXmlAttribute(test_info.value_param())
-            << "\"";
-  }
-  if (test_info.type_param() != NULL) {
-    *stream << " type_param=\"" << EscapeXmlAttribute(test_info.type_param())
-            << "\"";
-  }
-
-  *stream << " status=\""
-          << (test_info.should_run() ? "run" : "notrun")
-          << "\" time=\""
-          << FormatTimeInMillisAsSeconds(result.elapsed_time())
-          << "\" classname=\"" << EscapeXmlAttribute(test_case_name).c_str()
-          << "\"" << TestPropertiesAsXmlAttributes(result).c_str();
-
-  int failures = 0;
-  for (int i = 0; i < result.total_part_count(); ++i) {
-    const TestPartResult& part = result.GetTestPartResult(i);
-    if (part.failed()) {
-      if (++failures == 1)
-        *stream << ">\n";
-      *stream << "      <failure message=\""
-              << EscapeXmlAttribute(part.summary()).c_str()
-              << "\" type=\"\">";
-      const string location = internal::FormatCompilerIndependentFileLocation(
-          part.file_name(), part.line_number());
-      const string message = location + "\n" + part.message();
-      OutputXmlCDataSection(stream,
-                            RemoveInvalidXmlCharacters(message).c_str());
-      *stream << "</failure>\n";
-    }
-  }
-
-  if (failures == 0)
-    *stream << " />\n";
-  else
-    *stream << "    </testcase>\n";
-}
-
-// Prints an XML representation of a TestCase object
-void XmlUnitTestResultPrinter::PrintXmlTestCase(FILE* out,
-                                                const TestCase& test_case) {
-  fprintf(out,
-          "  <testsuite name=\"%s\" tests=\"%d\" failures=\"%d\" "
-          "disabled=\"%d\" ",
-          EscapeXmlAttribute(test_case.name()).c_str(),
-          test_case.total_test_count(),
-          test_case.failed_test_count(),
-          test_case.disabled_test_count());
-  fprintf(out,
-          "errors=\"0\" time=\"%s\">\n",
-          FormatTimeInMillisAsSeconds(test_case.elapsed_time()).c_str());
-  for (int i = 0; i < test_case.total_test_count(); ++i) {
-    ::std::stringstream stream;
-    OutputXmlTestInfo(&stream, test_case.name(), *test_case.GetTestInfo(i));
-    fprintf(out, "%s", StringStreamToString(&stream).c_str());
-  }
-  fprintf(out, "  </testsuite>\n");
-}
-
-// Prints an XML summary of unit_test to output stream out.
-void XmlUnitTestResultPrinter::PrintXmlUnitTest(FILE* out,
-                                                const UnitTest& unit_test) {
-  fprintf(out, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
-  fprintf(out,
-          "<testsuites tests=\"%d\" failures=\"%d\" disabled=\"%d\" "
-          "errors=\"0\" time=\"%s\" ",
-          unit_test.total_test_count(),
-          unit_test.failed_test_count(),
-          unit_test.disabled_test_count(),
-          FormatTimeInMillisAsSeconds(unit_test.elapsed_time()).c_str());
-  if (GTEST_FLAG(shuffle)) {
-    fprintf(out, "random_seed=\"%d\" ", unit_test.random_seed());
-  }
-  fprintf(out, "name=\"AllTests\">\n");
-  for (int i = 0; i < unit_test.total_test_case_count(); ++i)
-    PrintXmlTestCase(out, *unit_test.GetTestCase(i));
-  fprintf(out, "</testsuites>\n");
-}
-
-// Produces a string representing the test properties in a result as space
-// delimited XML attributes based on the property key="value" pairs.
-String XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes(
-    const TestResult& result) {
-  Message attributes;
-  for (int i = 0; i < result.test_property_count(); ++i) {
-    const TestProperty& property = result.GetTestProperty(i);
-    attributes << " " << property.key() << "="
-        << "\"" << EscapeXmlAttribute(property.value()) << "\"";
-  }
-  return attributes.GetString();
-}
-
-// End XmlUnitTestResultPrinter
-
-#if GTEST_CAN_STREAM_RESULTS_
-
-// Streams test results to the given port on the given host machine.
-class StreamingListener : public EmptyTestEventListener {
- public:
-  // Escapes '=', '&', '%', and '\n' characters in str as "%xx".
-  static string UrlEncode(const char* str);
-
-  StreamingListener(const string& host, const string& port)
-      : sockfd_(-1), host_name_(host), port_num_(port) {
-    MakeConnection();
-    Send("gtest_streaming_protocol_version=1.0\n");
-  }
-
-  virtual ~StreamingListener() {
-    if (sockfd_ != -1)
-      CloseConnection();
-  }
-
-  void OnTestProgramStart(const UnitTest& /* unit_test */) {
-    Send("event=TestProgramStart\n");
-  }
-
-  void OnTestProgramEnd(const UnitTest& unit_test) {
-    // Note that Google Test current only report elapsed time for each
-    // test iteration, not for the entire test program.
-    Send(String::Format("event=TestProgramEnd&passed=%d\n",
-                        unit_test.Passed()));
-
-    // Notify the streaming server to stop.
-    CloseConnection();
-  }
-
-  void OnTestIterationStart(const UnitTest& /* unit_test */, int iteration) {
-    Send(String::Format("event=TestIterationStart&iteration=%d\n",
-                        iteration));
-  }
-
-  void OnTestIterationEnd(const UnitTest& unit_test, int /* iteration */) {
-    Send(String::Format("event=TestIterationEnd&passed=%d&elapsed_time=%sms\n",
-                        unit_test.Passed(),
-                        StreamableToString(unit_test.elapsed_time()).c_str()));
-  }
-
-  void OnTestCaseStart(const TestCase& test_case) {
-    Send(String::Format("event=TestCaseStart&name=%s\n", test_case.name()));
-  }
-
-  void OnTestCaseEnd(const TestCase& test_case) {
-    Send(String::Format("event=TestCaseEnd&passed=%d&elapsed_time=%sms\n",
-                        test_case.Passed(),
-                        StreamableToString(test_case.elapsed_time()).c_str()));
-  }
-
-  void OnTestStart(const TestInfo& test_info) {
-    Send(String::Format("event=TestStart&name=%s\n", test_info.name()));
-  }
-
-  void OnTestEnd(const TestInfo& test_info) {
-    Send(String::Format(
-        "event=TestEnd&passed=%d&elapsed_time=%sms\n",
-        (test_info.result())->Passed(),
-        StreamableToString((test_info.result())->elapsed_time()).c_str()));
-  }
-
-  void OnTestPartResult(const TestPartResult& test_part_result) {
-    const char* file_name = test_part_result.file_name();
-    if (file_name == NULL)
-      file_name = "";
-    Send(String::Format("event=TestPartResult&file=%s&line=%d&message=",
-                        UrlEncode(file_name).c_str(),
-                        test_part_result.line_number()));
-    Send(UrlEncode(test_part_result.message()) + "\n");
-  }
-
- private:
-  // Creates a client socket and connects to the server.
-  void MakeConnection();
-
-  // Closes the socket.
-  void CloseConnection() {
-    GTEST_CHECK_(sockfd_ != -1)
-        << "CloseConnection() can be called only when there is a connection.";
-
-    close(sockfd_);
-    sockfd_ = -1;
-  }
-
-  // Sends a string to the socket.
-  void Send(const string& message) {
-    GTEST_CHECK_(sockfd_ != -1)
-        << "Send() can be called only when there is a connection.";
-
-    const int len = static_cast<int>(message.length());
-    if (write(sockfd_, message.c_str(), len) != len) {
-      GTEST_LOG_(WARNING)
-          << "stream_result_to: failed to stream to "
-          << host_name_ << ":" << port_num_;
-    }
-  }
-
-  int sockfd_;   // socket file descriptor
-  const string host_name_;
-  const string port_num_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamingListener);
-};  // class StreamingListener
-
-// Checks if str contains '=', '&', '%' or '\n' characters. If yes,
-// replaces them by "%xx" where xx is their hexadecimal value. For
-// example, replaces "=" with "%3D".  This algorithm is O(strlen(str))
-// in both time and space -- important as the input str may contain an
-// arbitrarily long test failure message and stack trace.
-string StreamingListener::UrlEncode(const char* str) {
-  string result;
-  result.reserve(strlen(str) + 1);
-  for (char ch = *str; ch != '\0'; ch = *++str) {
-    switch (ch) {
-      case '%':
-      case '=':
-      case '&':
-      case '\n':
-        result.append(String::Format("%%%02x", static_cast<unsigned char>(ch)));
-        break;
-      default:
-        result.push_back(ch);
-        break;
-    }
-  }
-  return result;
-}
-
-void StreamingListener::MakeConnection() {
-  GTEST_CHECK_(sockfd_ == -1)
-      << "MakeConnection() can't be called when there is already a connection.";
-
-  addrinfo hints;
-  memset(&hints, 0, sizeof(hints));
-  hints.ai_family = AF_UNSPEC;    // To allow both IPv4 and IPv6 addresses.
-  hints.ai_socktype = SOCK_STREAM;
-  addrinfo* servinfo = NULL;
-
-  // Use the getaddrinfo() to get a linked list of IP addresses for
-  // the given host name.
-  const int error_num = getaddrinfo(
-      host_name_.c_str(), port_num_.c_str(), &hints, &servinfo);
-  if (error_num != 0) {
-    GTEST_LOG_(WARNING) << "stream_result_to: getaddrinfo() failed: "
-                        << gai_strerror(error_num);
-  }
-
-  // Loop through all the results and connect to the first we can.
-  for (addrinfo* cur_addr = servinfo; sockfd_ == -1 && cur_addr != NULL;
-       cur_addr = cur_addr->ai_next) {
-    sockfd_ = socket(
-        cur_addr->ai_family, cur_addr->ai_socktype, cur_addr->ai_protocol);
-    if (sockfd_ != -1) {
-      // Connect the client socket to the server socket.
-      if (connect(sockfd_, cur_addr->ai_addr, cur_addr->ai_addrlen) == -1) {
-        close(sockfd_);
-        sockfd_ = -1;
-      }
-    }
-  }
-
-  freeaddrinfo(servinfo);  // all done with this structure
-
-  if (sockfd_ == -1) {
-    GTEST_LOG_(WARNING) << "stream_result_to: failed to connect to "
-                        << host_name_ << ":" << port_num_;
-  }
-}
-
-// End of class Streaming Listener
-#endif  // GTEST_CAN_STREAM_RESULTS__
-
-// Class ScopedTrace
-
-// Pushes the given source file location and message onto a per-thread
-// trace stack maintained by Google Test.
-// L < UnitTest::mutex_
-ScopedTrace::ScopedTrace(const char* file, int line, const Message& message) {
-  TraceInfo trace;
-  trace.file = file;
-  trace.line = line;
-  trace.message = message.GetString();
-
-  UnitTest::GetInstance()->PushGTestTrace(trace);
-}
-
-// Pops the info pushed by the c'tor.
-// L < UnitTest::mutex_
-ScopedTrace::~ScopedTrace() {
-  UnitTest::GetInstance()->PopGTestTrace();
-}
-
-
-// class OsStackTraceGetter
-
-// Returns the current OS stack trace as a String.  Parameters:
-//
-//   max_depth  - the maximum number of stack frames to be included
-//                in the trace.
-//   skip_count - the number of top frames to be skipped; doesn't count
-//                against max_depth.
-//
-// L < mutex_
-// We use "L < mutex_" to denote that the function may acquire mutex_.
-String OsStackTraceGetter::CurrentStackTrace(int, int) {
-  return String("");
-}
-
-// L < mutex_
-void OsStackTraceGetter::UponLeavingGTest() {
-}
-
-const char* const
-OsStackTraceGetter::kElidedFramesMarker =
-    "... " GTEST_NAME_ " internal frames ...";
-
-}  // namespace internal
-
-// class TestEventListeners
-
-TestEventListeners::TestEventListeners()
-    : repeater_(new internal::TestEventRepeater()),
-      default_result_printer_(NULL),
-      default_xml_generator_(NULL) {
-}
-
-TestEventListeners::~TestEventListeners() { delete repeater_; }
-
-// Returns the standard listener responsible for the default console
-// output.  Can be removed from the listeners list to shut down default
-// console output.  Note that removing this object from the listener list
-// with Release transfers its ownership to the user.
-void TestEventListeners::Append(TestEventListener* listener) {
-  repeater_->Append(listener);
-}
-
-// Removes the given event listener from the list and returns it.  It then
-// becomes the caller's responsibility to delete the listener. Returns
-// NULL if the listener is not found in the list.
-TestEventListener* TestEventListeners::Release(TestEventListener* listener) {
-  if (listener == default_result_printer_)
-    default_result_printer_ = NULL;
-  else if (listener == default_xml_generator_)
-    default_xml_generator_ = NULL;
-  return repeater_->Release(listener);
-}
-
-// Returns repeater that broadcasts the TestEventListener events to all
-// subscribers.
-TestEventListener* TestEventListeners::repeater() { return repeater_; }
-
-// Sets the default_result_printer attribute to the provided listener.
-// The listener is also added to the listener list and previous
-// default_result_printer is removed from it and deleted. The listener can
-// also be NULL in which case it will not be added to the list. Does
-// nothing if the previous and the current listener objects are the same.
-void TestEventListeners::SetDefaultResultPrinter(TestEventListener* listener) {
-  if (default_result_printer_ != listener) {
-    // It is an error to pass this method a listener that is already in the
-    // list.
-    delete Release(default_result_printer_);
-    default_result_printer_ = listener;
-    if (listener != NULL)
-      Append(listener);
-  }
-}
-
-// Sets the default_xml_generator attribute to the provided listener.  The
-// listener is also added to the listener list and previous
-// default_xml_generator is removed from it and deleted. The listener can
-// also be NULL in which case it will not be added to the list. Does
-// nothing if the previous and the current listener objects are the same.
-void TestEventListeners::SetDefaultXmlGenerator(TestEventListener* listener) {
-  if (default_xml_generator_ != listener) {
-    // It is an error to pass this method a listener that is already in the
-    // list.
-    delete Release(default_xml_generator_);
-    default_xml_generator_ = listener;
-    if (listener != NULL)
-      Append(listener);
-  }
-}
-
-// Controls whether events will be forwarded by the repeater to the
-// listeners in the list.
-bool TestEventListeners::EventForwardingEnabled() const {
-  return repeater_->forwarding_enabled();
-}
-
-void TestEventListeners::SuppressEventForwarding() {
-  repeater_->set_forwarding_enabled(false);
-}
-
-// class UnitTest
-
-// Gets the singleton UnitTest object.  The first time this method is
-// called, a UnitTest object is constructed and returned.  Consecutive
-// calls will return the same object.
-//
-// We don't protect this under mutex_ as a user is not supposed to
-// call this before main() starts, from which point on the return
-// value will never change.
-UnitTest * UnitTest::GetInstance() {
-  // When compiled with MSVC 7.1 in optimized mode, destroying the
-  // UnitTest object upon exiting the program messes up the exit code,
-  // causing successful tests to appear failed.  We have to use a
-  // different implementation in this case to bypass the compiler bug.
-  // This implementation makes the compiler happy, at the cost of
-  // leaking the UnitTest object.
-
-  // CodeGear C++Builder insists on a public destructor for the
-  // default implementation.  Use this implementation to keep good OO
-  // design with private destructor.
-
-#if (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)
-  static UnitTest* const instance = new UnitTest;
-  return instance;
-#else
-  static UnitTest instance;
-  return &instance;
-#endif  // (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)
-}
-
-// Gets the number of successful test cases.
-int UnitTest::successful_test_case_count() const {
-  return impl()->successful_test_case_count();
-}
-
-// Gets the number of failed test cases.
-int UnitTest::failed_test_case_count() const {
-  return impl()->failed_test_case_count();
-}
-
-// Gets the number of all test cases.
-int UnitTest::total_test_case_count() const {
-  return impl()->total_test_case_count();
-}
-
-// Gets the number of all test cases that contain at least one test
-// that should run.
-int UnitTest::test_case_to_run_count() const {
-  return impl()->test_case_to_run_count();
-}
-
-// Gets the number of successful tests.
-int UnitTest::successful_test_count() const {
-  return impl()->successful_test_count();
-}
-
-// Gets the number of failed tests.
-int UnitTest::failed_test_count() const { return impl()->failed_test_count(); }
-
-// Gets the number of disabled tests.
-int UnitTest::disabled_test_count() const {
-  return impl()->disabled_test_count();
-}
-
-// Gets the number of all tests.
-int UnitTest::total_test_count() const { return impl()->total_test_count(); }
-
-// Gets the number of tests that should run.
-int UnitTest::test_to_run_count() const { return impl()->test_to_run_count(); }
-
-// Gets the elapsed time, in milliseconds.
-internal::TimeInMillis UnitTest::elapsed_time() const {
-  return impl()->elapsed_time();
-}
-
-// Returns true iff the unit test passed (i.e. all test cases passed).
-bool UnitTest::Passed() const { return impl()->Passed(); }
-
-// Returns true iff the unit test failed (i.e. some test case failed
-// or something outside of all tests failed).
-bool UnitTest::Failed() const { return impl()->Failed(); }
-
-// Gets the i-th test case among all the test cases. i can range from 0 to
-// total_test_case_count() - 1. If i is not in that range, returns NULL.
-const TestCase* UnitTest::GetTestCase(int i) const {
-  return impl()->GetTestCase(i);
-}
-
-// Gets the i-th test case among all the test cases. i can range from 0 to
-// total_test_case_count() - 1. If i is not in that range, returns NULL.
-TestCase* UnitTest::GetMutableTestCase(int i) {
-  return impl()->GetMutableTestCase(i);
-}
-
-// Returns the list of event listeners that can be used to track events
-// inside Google Test.
-TestEventListeners& UnitTest::listeners() {
-  return *impl()->listeners();
-}
-
-// Registers and returns a global test environment.  When a test
-// program is run, all global test environments will be set-up in the
-// order they were registered.  After all tests in the program have
-// finished, all global test environments will be torn-down in the
-// *reverse* order they were registered.
-//
-// The UnitTest object takes ownership of the given environment.
-//
-// We don't protect this under mutex_, as we only support calling it
-// from the main thread.
-Environment* UnitTest::AddEnvironment(Environment* env) {
-  if (env == NULL) {
-    return NULL;
-  }
-
-  impl_->environments().push_back(env);
-  return env;
-}
-
-// Adds a TestPartResult to the current TestResult object.  All Google Test
-// assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc) eventually call
-// this to report their results.  The user code should use the
-// assertion macros instead of calling this directly.
-// L < mutex_
-void UnitTest::AddTestPartResult(TestPartResult::Type result_type,
-                                 const char* file_name,
-                                 int line_number,
-                                 const internal::String& message,
-                                 const internal::String& os_stack_trace) {
-  Message msg;
-  msg << message;
-
-  internal::MutexLock lock(&mutex_);
-  if (impl_->gtest_trace_stack().size() > 0) {
-    msg << "\n" << GTEST_NAME_ << " trace:";
-
-    for (int i = static_cast<int>(impl_->gtest_trace_stack().size());
-         i > 0; --i) {
-      const internal::TraceInfo& trace = impl_->gtest_trace_stack()[i - 1];
-      msg << "\n" << internal::FormatFileLocation(trace.file, trace.line)
-          << " " << trace.message;
-    }
-  }
-
-  if (os_stack_trace.c_str() != NULL && !os_stack_trace.empty()) {
-    msg << internal::kStackTraceMarker << os_stack_trace;
-  }
-
-  const TestPartResult result =
-    TestPartResult(result_type, file_name, line_number,
-                   msg.GetString().c_str());
-  impl_->GetTestPartResultReporterForCurrentThread()->
-      ReportTestPartResult(result);
-
-  if (result_type != TestPartResult::kSuccess) {
-    // gtest_break_on_failure takes precedence over
-    // gtest_throw_on_failure.  This allows a user to set the latter
-    // in the code (perhaps in order to use Google Test assertions
-    // with another testing framework) and specify the former on the
-    // command line for debugging.
-    if (GTEST_FLAG(break_on_failure)) {
-#if GTEST_OS_WINDOWS
-      // Using DebugBreak on Windows allows gtest to still break into a debugger
-      // when a failure happens and both the --gtest_break_on_failure and
-      // the --gtest_catch_exceptions flags are specified.
-      DebugBreak();
-#else
-      // Dereference NULL through a volatile pointer to prevent the compiler
-      // from removing. We use this rather than abort() or __builtin_trap() for
-      // portability: Symbian doesn't implement abort() well, and some debuggers
-      // don't correctly trap abort().
-      *static_cast<volatile int*>(NULL) = 1;
-#endif  // GTEST_OS_WINDOWS
-    } else if (GTEST_FLAG(throw_on_failure)) {
-#if GTEST_HAS_EXCEPTIONS
-      throw GoogleTestFailureException(result);
-#else
-      // We cannot call abort() as it generates a pop-up in debug mode
-      // that cannot be suppressed in VC 7.1 or below.
-      exit(1);
-#endif
-    }
-  }
-}
-
-// Creates and adds a property to the current TestResult. If a property matching
-// the supplied value already exists, updates its value instead.
-void UnitTest::RecordPropertyForCurrentTest(const char* key,
-                                            const char* value) {
-  const TestProperty test_property(key, value);
-  impl_->current_test_result()->RecordProperty(test_property);
-}
-
-// Runs all tests in this UnitTest object and prints the result.
-// Returns 0 if successful, or 1 otherwise.
-//
-// We don't protect this under mutex_, as we only support calling it
-// from the main thread.
-int UnitTest::Run() {
-  // Captures the value of GTEST_FLAG(catch_exceptions).  This value will be
-  // used for the duration of the program.
-  impl()->set_catch_exceptions(GTEST_FLAG(catch_exceptions));
-
-#if GTEST_HAS_SEH
-  const bool in_death_test_child_process =
-      internal::GTEST_FLAG(internal_run_death_test).length() > 0;
-
-  // Either the user wants Google Test to catch exceptions thrown by the
-  // tests or this is executing in the context of death test child
-  // process. In either case the user does not want to see pop-up dialogs
-  // about crashes - they are expected.
-  if (impl()->catch_exceptions() || in_death_test_child_process) {
-
-# if !GTEST_OS_WINDOWS_MOBILE
-    // SetErrorMode doesn't exist on CE.
-    SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT |
-                 SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
-# endif  // !GTEST_OS_WINDOWS_MOBILE
-
-# if (defined(_MSC_VER) || GTEST_OS_WINDOWS_MINGW) && !GTEST_OS_WINDOWS_MOBILE
-    // Death test children can be terminated with _abort().  On Windows,
-    // _abort() can show a dialog with a warning message.  This forces the
-    // abort message to go to stderr instead.
-    _set_error_mode(_OUT_TO_STDERR);
-# endif
-
-# if _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE
-    // In the debug version, Visual Studio pops up a separate dialog
-    // offering a choice to debug the aborted program. We need to suppress
-    // this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement
-    // executed. Google Test will notify the user of any unexpected
-    // failure via stderr.
-    //
-    // VC++ doesn't define _set_abort_behavior() prior to the version 8.0.
-    // Users of prior VC versions shall suffer the agony and pain of
-    // clicking through the countless debug dialogs.
-    // TODO(vladl at google.com): find a way to suppress the abort dialog() in the
-    // debug mode when compiled with VC 7.1 or lower.
-    if (!GTEST_FLAG(break_on_failure))
-      _set_abort_behavior(
-          0x0,                                    // Clear the following flags:
-          _WRITE_ABORT_MSG | _CALL_REPORTFAULT);  // pop-up window, core dump.
-# endif
-
-  }
-#endif  // GTEST_HAS_SEH
-
-  return internal::HandleExceptionsInMethodIfSupported(
-      impl(),
-      &internal::UnitTestImpl::RunAllTests,
-      "auxiliary test code (environments or event listeners)") ? 0 : 1;
-}
-
-// Returns the working directory when the first TEST() or TEST_F() was
-// executed.
-const char* UnitTest::original_working_dir() const {
-  return impl_->original_working_dir_.c_str();
-}
-
-// Returns the TestCase object for the test that's currently running,
-// or NULL if no test is running.
-// L < mutex_
-const TestCase* UnitTest::current_test_case() const {
-  internal::MutexLock lock(&mutex_);
-  return impl_->current_test_case();
-}
-
-// Returns the TestInfo object for the test that's currently running,
-// or NULL if no test is running.
-// L < mutex_
-const TestInfo* UnitTest::current_test_info() const {
-  internal::MutexLock lock(&mutex_);
-  return impl_->current_test_info();
-}
-
-// Returns the random seed used at the start of the current test run.
-int UnitTest::random_seed() const { return impl_->random_seed(); }
-
-#if GTEST_HAS_PARAM_TEST
-// Returns ParameterizedTestCaseRegistry object used to keep track of
-// value-parameterized tests and instantiate and register them.
-// L < mutex_
-internal::ParameterizedTestCaseRegistry&
-    UnitTest::parameterized_test_registry() {
-  return impl_->parameterized_test_registry();
-}
-#endif  // GTEST_HAS_PARAM_TEST
-
-// Creates an empty UnitTest.
-UnitTest::UnitTest() {
-  impl_ = new internal::UnitTestImpl(this);
-}
-
-// Destructor of UnitTest.
-UnitTest::~UnitTest() {
-  delete impl_;
-}
-
-// Pushes a trace defined by SCOPED_TRACE() on to the per-thread
-// Google Test trace stack.
-// L < mutex_
-void UnitTest::PushGTestTrace(const internal::TraceInfo& trace) {
-  internal::MutexLock lock(&mutex_);
-  impl_->gtest_trace_stack().push_back(trace);
-}
-
-// Pops a trace from the per-thread Google Test trace stack.
-// L < mutex_
-void UnitTest::PopGTestTrace() {
-  internal::MutexLock lock(&mutex_);
-  impl_->gtest_trace_stack().pop_back();
-}
-
-namespace internal {
-
-UnitTestImpl::UnitTestImpl(UnitTest* parent)
-    : parent_(parent),
-#ifdef _MSC_VER
-# pragma warning(push)                    // Saves the current warning state.
-# pragma warning(disable:4355)            // Temporarily disables warning 4355
-                                         // (using this in initializer).
-      default_global_test_part_result_reporter_(this),
-      default_per_thread_test_part_result_reporter_(this),
-# pragma warning(pop)                     // Restores the warning state again.
-#else
-      default_global_test_part_result_reporter_(this),
-      default_per_thread_test_part_result_reporter_(this),
-#endif  // _MSC_VER
-      global_test_part_result_repoter_(
-          &default_global_test_part_result_reporter_),
-      per_thread_test_part_result_reporter_(
-          &default_per_thread_test_part_result_reporter_),
-#if GTEST_HAS_PARAM_TEST
-      parameterized_test_registry_(),
-      parameterized_tests_registered_(false),
-#endif  // GTEST_HAS_PARAM_TEST
-      last_death_test_case_(-1),
-      current_test_case_(NULL),
-      current_test_info_(NULL),
-      ad_hoc_test_result_(),
-      os_stack_trace_getter_(NULL),
-      post_flag_parse_init_performed_(false),
-      random_seed_(0),  // Will be overridden by the flag before first use.
-      random_(0),  // Will be reseeded before first use.
-      elapsed_time_(0),
-#if GTEST_HAS_DEATH_TEST
-      internal_run_death_test_flag_(NULL),
-      death_test_factory_(new DefaultDeathTestFactory),
-#endif
-      // Will be overridden by the flag before first use.
-      catch_exceptions_(false) {
-  listeners()->SetDefaultResultPrinter(new PrettyUnitTestResultPrinter);
-}
-
-UnitTestImpl::~UnitTestImpl() {
-  // Deletes every TestCase.
-  ForEach(test_cases_, internal::Delete<TestCase>);
-
-  // Deletes every Environment.
-  ForEach(environments_, internal::Delete<Environment>);
-
-  delete os_stack_trace_getter_;
-}
-
-#if GTEST_HAS_DEATH_TEST
-// Disables event forwarding if the control is currently in a death test
-// subprocess. Must not be called before InitGoogleTest.
-void UnitTestImpl::SuppressTestEventsIfInSubprocess() {
-  if (internal_run_death_test_flag_.get() != NULL)
-    listeners()->SuppressEventForwarding();
-}
-#endif  // GTEST_HAS_DEATH_TEST
-
-// Initializes event listeners performing XML output as specified by
-// UnitTestOptions. Must not be called before InitGoogleTest.
-void UnitTestImpl::ConfigureXmlOutput() {
-  const String& output_format = UnitTestOptions::GetOutputFormat();
-  if (output_format == "xml") {
-    listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter(
-        UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));
-  } else if (output_format != "") {
-    printf("WARNING: unrecognized output format \"%s\" ignored.\n",
-           output_format.c_str());
-    fflush(stdout);
-  }
-}
-
-#if GTEST_CAN_STREAM_RESULTS_
-// Initializes event listeners for streaming test results in String form.
-// Must not be called before InitGoogleTest.
-void UnitTestImpl::ConfigureStreamingOutput() {
-  const string& target = GTEST_FLAG(stream_result_to);
-  if (!target.empty()) {
-    const size_t pos = target.find(':');
-    if (pos != string::npos) {
-      listeners()->Append(new StreamingListener(target.substr(0, pos),
-                                                target.substr(pos+1)));
-    } else {
-      printf("WARNING: unrecognized streaming target \"%s\" ignored.\n",
-             target.c_str());
-      fflush(stdout);
-    }
-  }
-}
-#endif  // GTEST_CAN_STREAM_RESULTS_
-
-// Performs initialization dependent upon flag values obtained in
-// ParseGoogleTestFlagsOnly.  Is called from InitGoogleTest after the call to
-// ParseGoogleTestFlagsOnly.  In case a user neglects to call InitGoogleTest
-// this function is also called from RunAllTests.  Since this function can be
-// called more than once, it has to be idempotent.
-void UnitTestImpl::PostFlagParsingInit() {
-  // Ensures that this function does not execute more than once.
-  if (!post_flag_parse_init_performed_) {
-    post_flag_parse_init_performed_ = true;
-
-#if GTEST_HAS_DEATH_TEST
-    InitDeathTestSubprocessControlInfo();
-    SuppressTestEventsIfInSubprocess();
-#endif  // GTEST_HAS_DEATH_TEST
-
-    // Registers parameterized tests. This makes parameterized tests
-    // available to the UnitTest reflection API without running
-    // RUN_ALL_TESTS.
-    RegisterParameterizedTests();
-
-    // Configures listeners for XML output. This makes it possible for users
-    // to shut down the default XML output before invoking RUN_ALL_TESTS.
-    ConfigureXmlOutput();
-
-#if GTEST_CAN_STREAM_RESULTS_
-    // Configures listeners for streaming test results to the specified server.
-    ConfigureStreamingOutput();
-#endif  // GTEST_CAN_STREAM_RESULTS_
-  }
-}
-
-// A predicate that checks the name of a TestCase against a known
-// value.
-//
-// This is used for implementation of the UnitTest class only.  We put
-// it in the anonymous namespace to prevent polluting the outer
-// namespace.
-//
-// TestCaseNameIs is copyable.
-class TestCaseNameIs {
- public:
-  // Constructor.
-  explicit TestCaseNameIs(const String& name)
-      : name_(name) {}
-
-  // Returns true iff the name of test_case matches name_.
-  bool operator()(const TestCase* test_case) const {
-    return test_case != NULL && strcmp(test_case->name(), name_.c_str()) == 0;
-  }
-
- private:
-  String name_;
-};
-
-// Finds and returns a TestCase with the given name.  If one doesn't
-// exist, creates one and returns it.  It's the CALLER'S
-// RESPONSIBILITY to ensure that this function is only called WHEN THE
-// TESTS ARE NOT SHUFFLED.
-//
-// Arguments:
-//
-//   test_case_name: name of the test case
-//   type_param:     the name of the test case's type parameter, or NULL if
-//                   this is not a typed or a type-parameterized test case.
-//   set_up_tc:      pointer to the function that sets up the test case
-//   tear_down_tc:   pointer to the function that tears down the test case
-TestCase* UnitTestImpl::GetTestCase(const char* test_case_name,
-                                    const char* type_param,
-                                    Test::SetUpTestCaseFunc set_up_tc,
-                                    Test::TearDownTestCaseFunc tear_down_tc) {
-  // Can we find a TestCase with the given name?
-  const std::vector<TestCase*>::const_iterator test_case =
-      std::find_if(test_cases_.begin(), test_cases_.end(),
-                   TestCaseNameIs(test_case_name));
-
-  if (test_case != test_cases_.end())
-    return *test_case;
-
-  // No.  Let's create one.
-  TestCase* const new_test_case =
-      new TestCase(test_case_name, type_param, set_up_tc, tear_down_tc);
-
-  // Is this a death test case?
-  if (internal::UnitTestOptions::MatchesFilter(String(test_case_name),
-                                               kDeathTestCaseFilter)) {
-    // Yes.  Inserts the test case after the last death test case
-    // defined so far.  This only works when the test cases haven't
-    // been shuffled.  Otherwise we may end up running a death test
-    // after a non-death test.
-    ++last_death_test_case_;
-    test_cases_.insert(test_cases_.begin() + last_death_test_case_,
-                       new_test_case);
-  } else {
-    // No.  Appends to the end of the list.
-    test_cases_.push_back(new_test_case);
-  }
-
-  test_case_indices_.push_back(static_cast<int>(test_case_indices_.size()));
-  return new_test_case;
-}
-
-// Helpers for setting up / tearing down the given environment.  They
-// are for use in the ForEach() function.
-static void SetUpEnvironment(Environment* env) { env->SetUp(); }
-static void TearDownEnvironment(Environment* env) { env->TearDown(); }
-
-// Runs all tests in this UnitTest object, prints the result, and
-// returns true if all tests are successful.  If any exception is
-// thrown during a test, the test is considered to be failed, but the
-// rest of the tests will still be run.
-//
-// When parameterized tests are enabled, it expands and registers
-// parameterized tests first in RegisterParameterizedTests().
-// All other functions called from RunAllTests() may safely assume that
-// parameterized tests are ready to be counted and run.
-bool UnitTestImpl::RunAllTests() {
-  // Makes sure InitGoogleTest() was called.
-  if (!GTestIsInitialized()) {
-    printf("%s",
-           "\nThis test program did NOT call ::testing::InitGoogleTest "
-           "before calling RUN_ALL_TESTS().  Please fix it.\n");
-    return false;
-  }
-
-  // Do not run any test if the --help flag was specified.
-  if (g_help_flag)
-    return true;
-
-  // Repeats the call to the post-flag parsing initialization in case the
-  // user didn't call InitGoogleTest.
-  PostFlagParsingInit();
-
-  // Even if sharding is not on, test runners may want to use the
-  // GTEST_SHARD_STATUS_FILE to query whether the test supports the sharding
-  // protocol.
-  internal::WriteToShardStatusFileIfNeeded();
-
-  // True iff we are in a subprocess for running a thread-safe-style
-  // death test.
-  bool in_subprocess_for_death_test = false;
-
-#if GTEST_HAS_DEATH_TEST
-  in_subprocess_for_death_test = (internal_run_death_test_flag_.get() != NULL);
-#endif  // GTEST_HAS_DEATH_TEST
-
-  const bool should_shard = ShouldShard(kTestTotalShards, kTestShardIndex,
-                                        in_subprocess_for_death_test);
-
-  // Compares the full test names with the filter to decide which
-  // tests to run.
-  const bool has_tests_to_run = FilterTests(should_shard
-                                              ? HONOR_SHARDING_PROTOCOL
-                                              : IGNORE_SHARDING_PROTOCOL) > 0;
-
-  // Lists the tests and exits if the --gtest_list_tests flag was specified.
-  if (GTEST_FLAG(list_tests)) {
-    // This must be called *after* FilterTests() has been called.
-    ListTestsMatchingFilter();
-    return true;
-  }
-
-  random_seed_ = GTEST_FLAG(shuffle) ?
-      GetRandomSeedFromFlag(GTEST_FLAG(random_seed)) : 0;
-
-  // True iff at least one test has failed.
-  bool failed = false;
-
-  TestEventListener* repeater = listeners()->repeater();
-
-  repeater->OnTestProgramStart(*parent_);
-
-  // How many times to repeat the tests?  We don't want to repeat them
-  // when we are inside the subprocess of a death test.
-  const int repeat = in_subprocess_for_death_test ? 1 : GTEST_FLAG(repeat);
-  // Repeats forever if the repeat count is negative.
-  const bool forever = repeat < 0;
-  for (int i = 0; forever || i != repeat; i++) {
-    // We want to preserve failures generated by ad-hoc test
-    // assertions executed before RUN_ALL_TESTS().
-    ClearNonAdHocTestResult();
-
-    const TimeInMillis start = GetTimeInMillis();
-
-    // Shuffles test cases and tests if requested.
-    if (has_tests_to_run && GTEST_FLAG(shuffle)) {
-      random()->Reseed(random_seed_);
-      // This should be done before calling OnTestIterationStart(),
-      // such that a test event listener can see the actual test order
-      // in the event.
-      ShuffleTests();
-    }
-
-    // Tells the unit test event listeners that the tests are about to start.
-    repeater->OnTestIterationStart(*parent_, i);
-
-    // Runs each test case if there is at least one test to run.
-    if (has_tests_to_run) {
-      // Sets up all environments beforehand.
-      repeater->OnEnvironmentsSetUpStart(*parent_);
-      ForEach(environments_, SetUpEnvironment);
-      repeater->OnEnvironmentsSetUpEnd(*parent_);
-
-      // Runs the tests only if there was no fatal failure during global
-      // set-up.
-      if (!Test::HasFatalFailure()) {
-        for (int test_index = 0; test_index < total_test_case_count();
-             test_index++) {
-          GetMutableTestCase(test_index)->Run();
-        }
-      }
-
-      // Tears down all environments in reverse order afterwards.
-      repeater->OnEnvironmentsTearDownStart(*parent_);
-      std::for_each(environments_.rbegin(), environments_.rend(),
-                    TearDownEnvironment);
-      repeater->OnEnvironmentsTearDownEnd(*parent_);
-    }
-
-    elapsed_time_ = GetTimeInMillis() - start;
-
-    // Tells the unit test event listener that the tests have just finished.
-    repeater->OnTestIterationEnd(*parent_, i);
-
-    // Gets the result and clears it.
-    if (!Passed()) {
-      failed = true;
-    }
-
-    // Restores the original test order after the iteration.  This
-    // allows the user to quickly repro a failure that happens in the
-    // N-th iteration without repeating the first (N - 1) iterations.
-    // This is not enclosed in "if (GTEST_FLAG(shuffle)) { ... }", in
-    // case the user somehow changes the value of the flag somewhere
-    // (it's always safe to unshuffle the tests).
-    UnshuffleTests();
-
-    if (GTEST_FLAG(shuffle)) {
-      // Picks a new random seed for each iteration.
-      random_seed_ = GetNextRandomSeed(random_seed_);
-    }
-  }
-
-  repeater->OnTestProgramEnd(*parent_);
-
-  return !failed;
-}
-
-// Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file
-// if the variable is present. If a file already exists at this location, this
-// function will write over it. If the variable is present, but the file cannot
-// be created, prints an error and exits.
-void WriteToShardStatusFileIfNeeded() {
-  const char* const test_shard_file = posix::GetEnv(kTestShardStatusFile);
-  if (test_shard_file != NULL) {
-    FILE* const file = posix::FOpen(test_shard_file, "w");
-    if (file == NULL) {
-      ColoredPrintf(COLOR_RED,
-                    "Could not write to the test shard status file \"%s\" "
-                    "specified by the %s environment variable.\n",
-                    test_shard_file, kTestShardStatusFile);
-      fflush(stdout);
-      exit(EXIT_FAILURE);
-    }
-    fclose(file);
-  }
-}
-
-// Checks whether sharding is enabled by examining the relevant
-// environment variable values. If the variables are present,
-// but inconsistent (i.e., shard_index >= total_shards), prints
-// an error and exits. If in_subprocess_for_death_test, sharding is
-// disabled because it must only be applied to the original test
-// process. Otherwise, we could filter out death tests we intended to execute.
-bool ShouldShard(const char* total_shards_env,
-                 const char* shard_index_env,
-                 bool in_subprocess_for_death_test) {
-  if (in_subprocess_for_death_test) {
-    return false;
-  }
-
-  const Int32 total_shards = Int32FromEnvOrDie(total_shards_env, -1);
-  const Int32 shard_index = Int32FromEnvOrDie(shard_index_env, -1);
-
-  if (total_shards == -1 && shard_index == -1) {
-    return false;
-  } else if (total_shards == -1 && shard_index != -1) {
-    const Message msg = Message()
-      << "Invalid environment variables: you have "
-      << kTestShardIndex << " = " << shard_index
-      << ", but have left " << kTestTotalShards << " unset.\n";
-    ColoredPrintf(COLOR_RED, msg.GetString().c_str());
-    fflush(stdout);
-    exit(EXIT_FAILURE);
-  } else if (total_shards != -1 && shard_index == -1) {
-    const Message msg = Message()
-      << "Invalid environment variables: you have "
-      << kTestTotalShards << " = " << total_shards
-      << ", but have left " << kTestShardIndex << " unset.\n";
-    ColoredPrintf(COLOR_RED, msg.GetString().c_str());
-    fflush(stdout);
-    exit(EXIT_FAILURE);
-  } else if (shard_index < 0 || shard_index >= total_shards) {
-    const Message msg = Message()
-      << "Invalid environment variables: we require 0 <= "
-      << kTestShardIndex << " < " << kTestTotalShards
-      << ", but you have " << kTestShardIndex << "=" << shard_index
-      << ", " << kTestTotalShards << "=" << total_shards << ".\n";
-    ColoredPrintf(COLOR_RED, msg.GetString().c_str());
-    fflush(stdout);
-    exit(EXIT_FAILURE);
-  }
-
-  return total_shards > 1;
-}
-
-// Parses the environment variable var as an Int32. If it is unset,
-// returns default_val. If it is not an Int32, prints an error
-// and aborts.
-Int32 Int32FromEnvOrDie(const char* var, Int32 default_val) {
-  const char* str_val = posix::GetEnv(var);
-  if (str_val == NULL) {
-    return default_val;
-  }
-
-  Int32 result;
-  if (!ParseInt32(Message() << "The value of environment variable " << var,
-                  str_val, &result)) {
-    exit(EXIT_FAILURE);
-  }
-  return result;
-}
-
-// Given the total number of shards, the shard index, and the test id,
-// returns true iff the test should be run on this shard. The test id is
-// some arbitrary but unique non-negative integer assigned to each test
-// method. Assumes that 0 <= shard_index < total_shards.
-bool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id) {
-  return (test_id % total_shards) == shard_index;
-}
-
-// Compares the name of each test with the user-specified filter to
-// decide whether the test should be run, then records the result in
-// each TestCase and TestInfo object.
-// If shard_tests == true, further filters tests based on sharding
-// variables in the environment - see
-// http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide.
-// Returns the number of tests that should run.
-int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) {
-  const Int32 total_shards = shard_tests == HONOR_SHARDING_PROTOCOL ?
-      Int32FromEnvOrDie(kTestTotalShards, -1) : -1;
-  const Int32 shard_index = shard_tests == HONOR_SHARDING_PROTOCOL ?
-      Int32FromEnvOrDie(kTestShardIndex, -1) : -1;
-
-  // num_runnable_tests are the number of tests that will
-  // run across all shards (i.e., match filter and are not disabled).
-  // num_selected_tests are the number of tests to be run on
-  // this shard.
-  int num_runnable_tests = 0;
-  int num_selected_tests = 0;
-  for (size_t i = 0; i < test_cases_.size(); i++) {
-    TestCase* const test_case = test_cases_[i];
-    const String &test_case_name = test_case->name();
-    test_case->set_should_run(false);
-
-    for (size_t j = 0; j < test_case->test_info_list().size(); j++) {
-      TestInfo* const test_info = test_case->test_info_list()[j];
-      const String test_name(test_info->name());
-      // A test is disabled if test case name or test name matches
-      // kDisableTestFilter.
-      const bool is_disabled =
-          internal::UnitTestOptions::MatchesFilter(test_case_name,
-                                                   kDisableTestFilter) ||
-          internal::UnitTestOptions::MatchesFilter(test_name,
-                                                   kDisableTestFilter);
-      test_info->is_disabled_ = is_disabled;
-
-      const bool matches_filter =
-          internal::UnitTestOptions::FilterMatchesTest(test_case_name,
-                                                       test_name);
-      test_info->matches_filter_ = matches_filter;
-
-      const bool is_runnable =
-          (GTEST_FLAG(also_run_disabled_tests) || !is_disabled) &&
-          matches_filter;
-
-      const bool is_selected = is_runnable &&
-          (shard_tests == IGNORE_SHARDING_PROTOCOL ||
-           ShouldRunTestOnShard(total_shards, shard_index,
-                                num_runnable_tests));
-
-      num_runnable_tests += is_runnable;
-      num_selected_tests += is_selected;
-
-      test_info->should_run_ = is_selected;
-      test_case->set_should_run(test_case->should_run() || is_selected);
-    }
-  }
-  return num_selected_tests;
-}
-
-// Prints the names of the tests matching the user-specified filter flag.
-void UnitTestImpl::ListTestsMatchingFilter() {
-  for (size_t i = 0; i < test_cases_.size(); i++) {
-    const TestCase* const test_case = test_cases_[i];
-    bool printed_test_case_name = false;
-
-    for (size_t j = 0; j < test_case->test_info_list().size(); j++) {
-      const TestInfo* const test_info =
-          test_case->test_info_list()[j];
-      if (test_info->matches_filter_) {
-        if (!printed_test_case_name) {
-          printed_test_case_name = true;
-          printf("%s.\n", test_case->name());
-        }
-        printf("  %s\n", test_info->name());
-      }
-    }
-  }
-  fflush(stdout);
-}
-
-// Sets the OS stack trace getter.
-//
-// Does nothing if the input and the current OS stack trace getter are
-// the same; otherwise, deletes the old getter and makes the input the
-// current getter.
-void UnitTestImpl::set_os_stack_trace_getter(
-    OsStackTraceGetterInterface* getter) {
-  if (os_stack_trace_getter_ != getter) {
-    delete os_stack_trace_getter_;
-    os_stack_trace_getter_ = getter;
-  }
-}
-
-// Returns the current OS stack trace getter if it is not NULL;
-// otherwise, creates an OsStackTraceGetter, makes it the current
-// getter, and returns it.
-OsStackTraceGetterInterface* UnitTestImpl::os_stack_trace_getter() {
-  if (os_stack_trace_getter_ == NULL) {
-    os_stack_trace_getter_ = new OsStackTraceGetter;
-  }
-
-  return os_stack_trace_getter_;
-}
-
-// Returns the TestResult for the test that's currently running, or
-// the TestResult for the ad hoc test if no test is running.
-TestResult* UnitTestImpl::current_test_result() {
-  return current_test_info_ ?
-      &(current_test_info_->result_) : &ad_hoc_test_result_;
-}
-
-// Shuffles all test cases, and the tests within each test case,
-// making sure that death tests are still run first.
-void UnitTestImpl::ShuffleTests() {
-  // Shuffles the death test cases.
-  ShuffleRange(random(), 0, last_death_test_case_ + 1, &test_case_indices_);
-
-  // Shuffles the non-death test cases.
-  ShuffleRange(random(), last_death_test_case_ + 1,
-               static_cast<int>(test_cases_.size()), &test_case_indices_);
-
-  // Shuffles the tests inside each test case.
-  for (size_t i = 0; i < test_cases_.size(); i++) {
-    test_cases_[i]->ShuffleTests(random());
-  }
-}
-
-// Restores the test cases and tests to their order before the first shuffle.
-void UnitTestImpl::UnshuffleTests() {
-  for (size_t i = 0; i < test_cases_.size(); i++) {
-    // Unshuffles the tests in each test case.
-    test_cases_[i]->UnshuffleTests();
-    // Resets the index of each test case.
-    test_case_indices_[i] = static_cast<int>(i);
-  }
-}
-
-// Returns the current OS stack trace as a String.
-//
-// The maximum number of stack frames to be included is specified by
-// the gtest_stack_trace_depth flag.  The skip_count parameter
-// specifies the number of top frames to be skipped, which doesn't
-// count against the number of frames to be included.
-//
-// For example, if Foo() calls Bar(), which in turn calls
-// GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in
-// the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.
-String GetCurrentOsStackTraceExceptTop(UnitTest* /*unit_test*/,
-                                       int skip_count) {
-  // We pass skip_count + 1 to skip this wrapper function in addition
-  // to what the user really wants to skip.
-  return GetUnitTestImpl()->CurrentOsStackTraceExceptTop(skip_count + 1);
-}
-
-// Used by the GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_ macro to
-// suppress unreachable code warnings.
-namespace {
-class ClassUniqueToAlwaysTrue {};
-}
-
-bool IsTrue(bool condition) { return condition; }
-
-bool AlwaysTrue() {
-#if GTEST_HAS_EXCEPTIONS
-  // This condition is always false so AlwaysTrue() never actually throws,
-  // but it makes the compiler think that it may throw.
-  if (IsTrue(false))
-    throw ClassUniqueToAlwaysTrue();
-#endif  // GTEST_HAS_EXCEPTIONS
-  return true;
-}
-
-// If *pstr starts with the given prefix, modifies *pstr to be right
-// past the prefix and returns true; otherwise leaves *pstr unchanged
-// and returns false.  None of pstr, *pstr, and prefix can be NULL.
-bool SkipPrefix(const char* prefix, const char** pstr) {
-  const size_t prefix_len = strlen(prefix);
-  if (strncmp(*pstr, prefix, prefix_len) == 0) {
-    *pstr += prefix_len;
-    return true;
-  }
-  return false;
-}
-
-// Parses a string as a command line flag.  The string should have
-// the format "--flag=value".  When def_optional is true, the "=value"
-// part can be omitted.
-//
-// Returns the value of the flag, or NULL if the parsing failed.
-const char* ParseFlagValue(const char* str,
-                           const char* flag,
-                           bool def_optional) {
-  // str and flag must not be NULL.
-  if (str == NULL || flag == NULL) return NULL;
-
-  // The flag must start with "--" followed by GTEST_FLAG_PREFIX_.
-  const String flag_str = String::Format("--%s%s", GTEST_FLAG_PREFIX_, flag);
-  const size_t flag_len = flag_str.length();
-  if (strncmp(str, flag_str.c_str(), flag_len) != 0) return NULL;
-
-  // Skips the flag name.
-  const char* flag_end = str + flag_len;
-
-  // When def_optional is true, it's OK to not have a "=value" part.
-  if (def_optional && (flag_end[0] == '\0')) {
-    return flag_end;
-  }
-
-  // If def_optional is true and there are more characters after the
-  // flag name, or if def_optional is false, there must be a '=' after
-  // the flag name.
-  if (flag_end[0] != '=') return NULL;
-
-  // Returns the string after "=".
-  return flag_end + 1;
-}
-
-// Parses a string for a bool flag, in the form of either
-// "--flag=value" or "--flag".
-//
-// In the former case, the value is taken as true as long as it does
-// not start with '0', 'f', or 'F'.
-//
-// In the latter case, the value is taken as true.
-//
-// On success, stores the value of the flag in *value, and returns
-// true.  On failure, returns false without changing *value.
-bool ParseBoolFlag(const char* str, const char* flag, bool* value) {
-  // Gets the value of the flag as a string.
-  const char* const value_str = ParseFlagValue(str, flag, true);
-
-  // Aborts if the parsing failed.
-  if (value_str == NULL) return false;
-
-  // Converts the string value to a bool.
-  *value = !(*value_str == '0' || *value_str == 'f' || *value_str == 'F');
-  return true;
-}
-
-// Parses a string for an Int32 flag, in the form of
-// "--flag=value".
-//
-// On success, stores the value of the flag in *value, and returns
-// true.  On failure, returns false without changing *value.
-bool ParseInt32Flag(const char* str, const char* flag, Int32* value) {
-  // Gets the value of the flag as a string.
-  const char* const value_str = ParseFlagValue(str, flag, false);
-
-  // Aborts if the parsing failed.
-  if (value_str == NULL) return false;
-
-  // Sets *value to the value of the flag.
-  return ParseInt32(Message() << "The value of flag --" << flag,
-                    value_str, value);
-}
-
-// Parses a string for a string flag, in the form of
-// "--flag=value".
-//
-// On success, stores the value of the flag in *value, and returns
-// true.  On failure, returns false without changing *value.
-bool ParseStringFlag(const char* str, const char* flag, String* value) {
-  // Gets the value of the flag as a string.
-  const char* const value_str = ParseFlagValue(str, flag, false);
-
-  // Aborts if the parsing failed.
-  if (value_str == NULL) return false;
-
-  // Sets *value to the value of the flag.
-  *value = value_str;
-  return true;
-}
-
-// Determines whether a string has a prefix that Google Test uses for its
-// flags, i.e., starts with GTEST_FLAG_PREFIX_ or GTEST_FLAG_PREFIX_DASH_.
-// If Google Test detects that a command line flag has its prefix but is not
-// recognized, it will print its help message. Flags starting with
-// GTEST_INTERNAL_PREFIX_ followed by "internal_" are considered Google Test
-// internal flags and do not trigger the help message.
-static bool HasGoogleTestFlagPrefix(const char* str) {
-  return (SkipPrefix("--", &str) ||
-          SkipPrefix("-", &str) ||
-          SkipPrefix("/", &str)) &&
-         !SkipPrefix(GTEST_FLAG_PREFIX_ "internal_", &str) &&
-         (SkipPrefix(GTEST_FLAG_PREFIX_, &str) ||
-          SkipPrefix(GTEST_FLAG_PREFIX_DASH_, &str));
-}
-
-// Prints a string containing code-encoded text.  The following escape
-// sequences can be used in the string to control the text color:
-//
-//   @@    prints a single '@' character.
-//   @R    changes the color to red.
-//   @G    changes the color to green.
-//   @Y    changes the color to yellow.
-//   @D    changes to the default terminal text color.
-//
-// TODO(wan at google.com): Write tests for this once we add stdout
-// capturing to Google Test.
-static void PrintColorEncoded(const char* str) {
-  GTestColor color = COLOR_DEFAULT;  // The current color.
-
-  // Conceptually, we split the string into segments divided by escape
-  // sequences.  Then we print one segment at a time.  At the end of
-  // each iteration, the str pointer advances to the beginning of the
-  // next segment.
-  for (;;) {
-    const char* p = strchr(str, '@');
-    if (p == NULL) {
-      ColoredPrintf(color, "%s", str);
-      return;
-    }
-
-    ColoredPrintf(color, "%s", String(str, p - str).c_str());
-
-    const char ch = p[1];
-    str = p + 2;
-    if (ch == '@') {
-      ColoredPrintf(color, "@");
-    } else if (ch == 'D') {
-      color = COLOR_DEFAULT;
-    } else if (ch == 'R') {
-      color = COLOR_RED;
-    } else if (ch == 'G') {
-      color = COLOR_GREEN;
-    } else if (ch == 'Y') {
-      color = COLOR_YELLOW;
-    } else {
-      --str;
-    }
-  }
-}
-
-static const char kColorEncodedHelpMessage[] =
-"This program contains tests written using " GTEST_NAME_ ". You can use the\n"
-"following command line flags to control its behavior:\n"
-"\n"
-"Test Selection:\n"
-"  @G--" GTEST_FLAG_PREFIX_ "list_tests at D\n"
-"      List the names of all tests instead of running them. The name of\n"
-"      TEST(Foo, Bar) is \"Foo.Bar\".\n"
-"  @G--" GTEST_FLAG_PREFIX_ "filter=@YPOSTIVE_PATTERNS"
-    "[@G- at YNEGATIVE_PATTERNS]@D\n"
-"      Run only the tests whose name matches one of the positive patterns but\n"
-"      none of the negative patterns. '?' matches any single character; '*'\n"
-"      matches any substring; ':' separates two patterns.\n"
-"  @G--" GTEST_FLAG_PREFIX_ "also_run_disabled_tests at D\n"
-"      Run all disabled tests too.\n"
-"\n"
-"Test Execution:\n"
-"  @G--" GTEST_FLAG_PREFIX_ "repeat=@Y[COUNT]@D\n"
-"      Run the tests repeatedly; use a negative count to repeat forever.\n"
-"  @G--" GTEST_FLAG_PREFIX_ "shuffle at D\n"
-"      Randomize tests' orders on every iteration.\n"
-"  @G--" GTEST_FLAG_PREFIX_ "random_seed=@Y[NUMBER]@D\n"
-"      Random number seed to use for shuffling test orders (between 1 and\n"
-"      99999, or 0 to use a seed based on the current time).\n"
-"\n"
-"Test Output:\n"
-"  @G--" GTEST_FLAG_PREFIX_ "color=@Y(@Gyes at Y|@Gno at Y|@Gauto at Y)@D\n"
-"      Enable/disable colored output. The default is @Gauto at D.\n"
-"  - at G-" GTEST_FLAG_PREFIX_ "print_time=0 at D\n"
-"      Don't print the elapsed time of each test.\n"
-"  @G--" GTEST_FLAG_PREFIX_ "output=xml at Y[@G:@YDIRECTORY_PATH at G"
-    GTEST_PATH_SEP_ "@Y|@G:@YFILE_PATH]@D\n"
-"      Generate an XML report in the given directory or with the given file\n"
-"      name. @YFILE_PATH at D defaults to @Gtest_details.xml at D.\n"
-#if GTEST_CAN_STREAM_RESULTS_
-"  @G--" GTEST_FLAG_PREFIX_ "stream_result_to=@YHOST at G:@YPORT at D\n"
-"      Stream test results to the given server.\n"
-#endif  // GTEST_CAN_STREAM_RESULTS_
-"\n"
-"Assertion Behavior:\n"
-#if GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS
-"  @G--" GTEST_FLAG_PREFIX_ "death_test_style=@Y(@Gfast at Y|@Gthreadsafe at Y)@D\n"
-"      Set the default death test style.\n"
-#endif  // GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS
-"  @G--" GTEST_FLAG_PREFIX_ "break_on_failure at D\n"
-"      Turn assertion failures into debugger break-points.\n"
-"  @G--" GTEST_FLAG_PREFIX_ "throw_on_failure at D\n"
-"      Turn assertion failures into C++ exceptions.\n"
-"  @G--" GTEST_FLAG_PREFIX_ "catch_exceptions=0 at D\n"
-"      Do not report exceptions as test failures. Instead, allow them\n"
-"      to crash the program or throw a pop-up (on Windows).\n"
-"\n"
-"Except for @G--" GTEST_FLAG_PREFIX_ "list_tests at D, you can alternatively set "
-    "the corresponding\n"
-"environment variable of a flag (all letters in upper-case). For example, to\n"
-"disable colored text output, you can either specify @G--" GTEST_FLAG_PREFIX_
-    "color=no at D or set\n"
-"the @G" GTEST_FLAG_PREFIX_UPPER_ "COLOR at D environment variable to @Gno at D.\n"
-"\n"
-"For more information, please read the " GTEST_NAME_ " documentation at\n"
-"@G" GTEST_PROJECT_URL_ "@D. If you find a bug in " GTEST_NAME_ "\n"
-"(not one in your own code or tests), please report it to\n"
-"@G<" GTEST_DEV_EMAIL_ ">@D.\n";
-
-// Parses the command line for Google Test flags, without initializing
-// other parts of Google Test.  The type parameter CharType can be
-// instantiated to either char or wchar_t.
-template <typename CharType>
-void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {
-  for (int i = 1; i < *argc; i++) {
-    const String arg_string = StreamableToString(argv[i]);
-    const char* const arg = arg_string.c_str();
-
-    using internal::ParseBoolFlag;
-    using internal::ParseInt32Flag;
-    using internal::ParseStringFlag;
-
-    // Do we see a Google Test flag?
-    if (ParseBoolFlag(arg, kAlsoRunDisabledTestsFlag,
-                      &GTEST_FLAG(also_run_disabled_tests)) ||
-        ParseBoolFlag(arg, kBreakOnFailureFlag,
-                      &GTEST_FLAG(break_on_failure)) ||
-        ParseBoolFlag(arg, kCatchExceptionsFlag,
-                      &GTEST_FLAG(catch_exceptions)) ||
-        ParseStringFlag(arg, kColorFlag, &GTEST_FLAG(color)) ||
-        ParseStringFlag(arg, kDeathTestStyleFlag,
-                        &GTEST_FLAG(death_test_style)) ||
-        ParseBoolFlag(arg, kDeathTestUseFork,
-                      &GTEST_FLAG(death_test_use_fork)) ||
-        ParseStringFlag(arg, kFilterFlag, &GTEST_FLAG(filter)) ||
-        ParseStringFlag(arg, kInternalRunDeathTestFlag,
-                        &GTEST_FLAG(internal_run_death_test)) ||
-        ParseBoolFlag(arg, kListTestsFlag, &GTEST_FLAG(list_tests)) ||
-        ParseStringFlag(arg, kOutputFlag, &GTEST_FLAG(output)) ||
-        ParseBoolFlag(arg, kPrintTimeFlag, &GTEST_FLAG(print_time)) ||
-        ParseInt32Flag(arg, kRandomSeedFlag, &GTEST_FLAG(random_seed)) ||
-        ParseInt32Flag(arg, kRepeatFlag, &GTEST_FLAG(repeat)) ||
-        ParseBoolFlag(arg, kShuffleFlag, &GTEST_FLAG(shuffle)) ||
-        ParseInt32Flag(arg, kStackTraceDepthFlag,
-                       &GTEST_FLAG(stack_trace_depth)) ||
-        ParseStringFlag(arg, kStreamResultToFlag,
-                        &GTEST_FLAG(stream_result_to)) ||
-        ParseBoolFlag(arg, kThrowOnFailureFlag,
-                      &GTEST_FLAG(throw_on_failure))
-        ) {
-      // Yes.  Shift the remainder of the argv list left by one.  Note
-      // that argv has (*argc + 1) elements, the last one always being
-      // NULL.  The following loop moves the trailing NULL element as
-      // well.
-      for (int j = i; j != *argc; j++) {
-        argv[j] = argv[j + 1];
-      }
-
-      // Decrements the argument count.
-      (*argc)--;
-
-      // We also need to decrement the iterator as we just removed
-      // an element.
-      i--;
-    } else if (arg_string == "--help" || arg_string == "-h" ||
-               arg_string == "-?" || arg_string == "/?" ||
-               HasGoogleTestFlagPrefix(arg)) {
-      // Both help flag and unrecognized Google Test flags (excluding
-      // internal ones) trigger help display.
-      g_help_flag = true;
-    }
-  }
-
-  if (g_help_flag) {
-    // We print the help here instead of in RUN_ALL_TESTS(), as the
-    // latter may not be called at all if the user is using Google
-    // Test with another testing framework.
-    PrintColorEncoded(kColorEncodedHelpMessage);
-  }
-}
-
-// Parses the command line for Google Test flags, without initializing
-// other parts of Google Test.
-void ParseGoogleTestFlagsOnly(int* argc, char** argv) {
-  ParseGoogleTestFlagsOnlyImpl(argc, argv);
-}
-void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv) {
-  ParseGoogleTestFlagsOnlyImpl(argc, argv);
-}
-
-// The internal implementation of InitGoogleTest().
-//
-// The type parameter CharType can be instantiated to either char or
-// wchar_t.
-template <typename CharType>
-void InitGoogleTestImpl(int* argc, CharType** argv) {
-  g_init_gtest_count++;
-
-  // We don't want to run the initialization code twice.
-  if (g_init_gtest_count != 1) return;
-
-  if (*argc <= 0) return;
-
-  internal::g_executable_path = internal::StreamableToString(argv[0]);
-
-#if GTEST_HAS_DEATH_TEST
-
-  g_argvs.clear();
-  for (int i = 0; i != *argc; i++) {
-    g_argvs.push_back(StreamableToString(argv[i]));
-  }
-
-#endif  // GTEST_HAS_DEATH_TEST
-
-  ParseGoogleTestFlagsOnly(argc, argv);
-  GetUnitTestImpl()->PostFlagParsingInit();
-}
-
-}  // namespace internal
-
-// Initializes Google Test.  This must be called before calling
-// RUN_ALL_TESTS().  In particular, it parses a command line for the
-// flags that Google Test recognizes.  Whenever a Google Test flag is
-// seen, it is removed from argv, and *argc is decremented.
-//
-// No value is returned.  Instead, the Google Test flag variables are
-// updated.
-//
-// Calling the function for the second time has no user-visible effect.
-void InitGoogleTest(int* argc, char** argv) {
-  internal::InitGoogleTestImpl(argc, argv);
-}
-
-// This overloaded version can be used in Windows programs compiled in
-// UNICODE mode.
-void InitGoogleTest(int* argc, wchar_t** argv) {
-  internal::InitGoogleTestImpl(argc, argv);
-}
-
-}  // namespace testing
diff --git a/bamtools/src/third_party/gtest-1.6.0/src/gtest_main.cc b/bamtools/src/third_party/gtest-1.6.0/src/gtest_main.cc
deleted file mode 100644
index a09bbe0..0000000
--- a/bamtools/src/third_party/gtest-1.6.0/src/gtest_main.cc
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#include <iostream>
-
-#include "gtest/gtest.h"
-
-GTEST_API_ int main(int argc, char **argv) {
-  std::cout << "Running main() from gtest_main.cc\n";
-
-  testing::InitGoogleTest(&argc, argv);
-  return RUN_ALL_TESTS();
-}
diff --git a/bamtools/src/third_party/jsoncpp/CMakeLists.txt b/bamtools/src/third_party/jsoncpp/CMakeLists.txt
deleted file mode 100644
index 8dc64e4..0000000
--- a/bamtools/src/third_party/jsoncpp/CMakeLists.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-# ==========================
-# BamTools CMakeLists.txt
-# (c) 2010 Derek Barnett
-#
-# src/third-party/jsoncpp
-# ==========================
-
-# add compiler definitions 
-add_definitions( -DBAMTOOLS_JSONCPP_LIBRARY ) # (for proper exporting of library symbols)
-add_definitions( -fPIC ) # (attempt to force PIC compiling on CentOS, not being set on shared libs by CMake)
-
-# create jsoncpp library
-add_library( jsoncpp STATIC
-             json_reader.cpp
-             json_value.cpp
-             json_writer.cpp
-           )
-
-# set jsoncpp library properties
-set_target_properties( jsoncpp PROPERTIES
-                       OUTPUT_NAME jsoncpp
-                       PREFIX "lib"
-                     )
diff --git a/bamtools/src/third_party/jsoncpp/LICENSE b/bamtools/src/third_party/jsoncpp/LICENSE
deleted file mode 100644
index ca2bfe1..0000000
--- a/bamtools/src/third_party/jsoncpp/LICENSE
+++ /dev/null
@@ -1,55 +0,0 @@
-The JsonCpp library's source code, including accompanying documentation, 
-tests and demonstration applications, are licensed under the following
-conditions...
-
-The author (Baptiste Lepilleur) explicitly disclaims copyright in all 
-jurisdictions which recognize such a disclaimer. In such jurisdictions, 
-this software is released into the Public Domain.
-
-In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
-2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
-released under the terms of the MIT License (see below).
-
-In jurisdictions which recognize Public Domain property, the user of this 
-software may choose to accept it either as 1) Public Domain, 2) under the 
-conditions of the MIT License (see below), or 3) under the terms of dual 
-Public Domain/MIT License conditions described here, as they choose.
-
-The MIT License is about as close to Public Domain as a license can get, and is
-described in clear, concise terms at:
-
-   http://en.wikipedia.org/wiki/MIT_License
-   
-The full text of the MIT License follows:
-
-========================================================================
-Copyright (c) 2007-2010 Baptiste Lepilleur
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use, copy,
-modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-========================================================================
-(END LICENSE TEXT)
-
-The MIT license is compatible with both the GPL and commercial
-software, affording one all of the rights of Public Domain with the
-minor nuisance of being required to keep the above copyright notice
-and license text in the source code. Note also that by accepting the
-Public Domain "license" you can re-license your copy using whatever
-license you like.
diff --git a/bamtools/src/third_party/jsoncpp/json.h b/bamtools/src/third_party/jsoncpp/json.h
deleted file mode 100644
index cac0a9b..0000000
--- a/bamtools/src/third_party/jsoncpp/json.h
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef JSON_JSON_H_INCLUDED
-# define JSON_JSON_H_INCLUDED
-
-//# include "autolink.h"
-# include "json_value.h"
-# include "json_reader.h"
-# include "json_writer.h"
-# include "json_features.h"
-
-#endif // JSON_JSON_H_INCLUDED
diff --git a/bamtools/src/third_party/jsoncpp/json_batchallocator.h b/bamtools/src/third_party/jsoncpp/json_batchallocator.h
deleted file mode 100644
index 173e2ed..0000000
--- a/bamtools/src/third_party/jsoncpp/json_batchallocator.h
+++ /dev/null
@@ -1,130 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef JSONCPP_BATCHALLOCATOR_H_INCLUDED
-# define JSONCPP_BATCHALLOCATOR_H_INCLUDED
-
-# include <stdlib.h>
-# include <assert.h>
-
-# ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
-
-namespace Json {
-
-/* Fast memory allocator.
- *
- * This memory allocator allocates memory for a batch of object (specified by
- * the page size, the number of object in each page).
- *
- * It does not allow the destruction of a single object. All the allocated objects
- * can be destroyed at once. The memory can be either released or reused for future
- * allocation.
- * 
- * The in-place new operator must be used to construct the object using the pointer
- * returned by allocate.
- */
-template<typename AllocatedType
-        ,const unsigned int objectPerAllocation>
-class BatchAllocator
-{
-public:
-   typedef AllocatedType Type;
-
-   BatchAllocator( unsigned int objectsPerPage = 255 )
-      : freeHead_( 0 )
-      , objectsPerPage_( objectsPerPage )
-   {
-//      printf( "Size: %d => %s\n", sizeof(AllocatedType), typeid(AllocatedType).name() );
-      assert( sizeof(AllocatedType) * objectPerAllocation >= sizeof(AllocatedType *) ); // We must be able to store a slist in the object free space.
-      assert( objectsPerPage >= 16 );
-      batches_ = allocateBatch( 0 );   // allocated a dummy page
-      currentBatch_ = batches_;
-   }
-
-   ~BatchAllocator()
-   {
-      for ( BatchInfo *batch = batches_; batch;  )
-      {
-         BatchInfo *nextBatch = batch->next_;
-         free( batch );
-         batch = nextBatch;
-      }
-   }
-
-   /// allocate space for an array of objectPerAllocation object.
-   /// @warning it is the responsability of the caller to call objects constructors.
-   AllocatedType *allocate()
-   {
-      if ( freeHead_ ) // returns node from free list.
-      {
-         AllocatedType *object = freeHead_;
-         freeHead_ = *(AllocatedType **)object;
-         return object;
-      }
-      if ( currentBatch_->used_ == currentBatch_->end_ )
-      {
-         currentBatch_ = currentBatch_->next_;
-         while ( currentBatch_  &&  currentBatch_->used_ == currentBatch_->end_ )
-            currentBatch_ = currentBatch_->next_;
-
-         if ( !currentBatch_  ) // no free batch found, allocate a new one
-         { 
-            currentBatch_ = allocateBatch( objectsPerPage_ );
-            currentBatch_->next_ = batches_; // insert at the head of the list
-            batches_ = currentBatch_;
-         }
-      }
-      AllocatedType *allocated = currentBatch_->used_;
-      currentBatch_->used_ += objectPerAllocation;
-      return allocated;
-   }
-
-   /// Release the object.
-   /// @warning it is the responsability of the caller to actually destruct the object.
-   void release( AllocatedType *object )
-   {
-      assert( object != 0 );
-      *(AllocatedType **)object = freeHead_;
-      freeHead_ = object;
-   }
-
-private:
-   struct BatchInfo
-   {
-      BatchInfo *next_;
-      AllocatedType *used_;
-      AllocatedType *end_;
-      AllocatedType buffer_[objectPerAllocation];
-   };
-
-   // disabled copy constructor and assignement operator.
-   BatchAllocator( const BatchAllocator & );
-   void operator =( const BatchAllocator &);
-
-   static BatchInfo *allocateBatch( unsigned int objectsPerPage )
-   {
-      const unsigned int mallocSize = sizeof(BatchInfo) - sizeof(AllocatedType)* objectPerAllocation
-                                + sizeof(AllocatedType) * objectPerAllocation * objectsPerPage;
-      BatchInfo *batch = static_cast<BatchInfo*>( malloc( mallocSize ) );
-      batch->next_ = 0;
-      batch->used_ = batch->buffer_;
-      batch->end_ = batch->buffer_ + objectsPerPage;
-      return batch;
-   }
-
-   BatchInfo *batches_;
-   BatchInfo *currentBatch_;
-   /// Head of a single linked list within the allocated space of freeed object
-   AllocatedType *freeHead_;
-   unsigned int objectsPerPage_;
-};
-
-
-} // namespace Json
-
-# endif // ifndef JSONCPP_DOC_INCLUDE_IMPLEMENTATION
-
-#endif // JSONCPP_BATCHALLOCATOR_H_INCLUDED
-
diff --git a/bamtools/src/third_party/jsoncpp/json_config.h b/bamtools/src/third_party/jsoncpp/json_config.h
deleted file mode 100644
index 4977f14..0000000
--- a/bamtools/src/third_party/jsoncpp/json_config.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef JSON_CONFIG_H_INCLUDED
-#define JSON_CONFIG_H_INCLUDED
-
-// Last Modified: Derek Barnett, 19 November 2010
-
-#include "shared/bamtools_global.h"
-#ifdef BAMTOOLS_JSONCPP_LIBRARY
-#  define JSON_API BAMTOOLS_LIBRARY_EXPORT
-#else
-#  define JSON_API BAMTOOLS_LIBRARY_IMPORT
-#endif
-
-#if defined(_MSC_VER)  &&  _MSC_VER <= 1200 // MSVC 6
-// Microsoft Visual Studio 6 only support conversion from __int64 to double
-// (no conversion from unsigned __int64).
-#  define JSON_USE_INT64_DOUBLE_CONVERSION 1
-#endif // if defined(_MSC_VER)  &&  _MSC_VER < 1200 // MSVC 6
-
-namespace Json {
-
-#if defined(JSON_NO_INT64)
-   typedef int Int;
-   typedef unsigned int UInt;
-#else // if defined(JSON_NO_INT64)
-   // For Microsoft Visual use specific types as long long is not supported
-#  if defined(_MSC_VER) // Microsoft Visual Studio
-     typedef __int64 Int;
-     typedef unsigned __int64 UInt;
-#  else // if defined(_MSC_VER) // Other platforms, use long long
-     typedef long long int Int;
-     typedef unsigned long long int UInt;
-#  endif // if defined(_MSC_VER)
-#endif // if defined(JSON_NO_INT64)
-
-} // end namespace Json
-
-#endif // JSON_CONFIG_H_INCLUDED
diff --git a/bamtools/src/third_party/jsoncpp/json_features.h b/bamtools/src/third_party/jsoncpp/json_features.h
deleted file mode 100644
index 05521dc..0000000
--- a/bamtools/src/third_party/jsoncpp/json_features.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef CPPTL_JSON_FEATURES_H_INCLUDED
-# define CPPTL_JSON_FEATURES_H_INCLUDED
-
-# include "json_forwards.h"
-
-namespace Json {
-
-   /** \brief Configuration passed to reader and writer.
-    * This configuration object can be used to force the Reader or Writer
-    * to behave in a standard conforming way.
-    */
-   class JSON_API Features
-   {
-   public:
-      /** \brief A configuration that allows all features and assumes all strings are UTF-8.
-       * - C & C++ comments are allowed
-       * - Root object can be any JSON value
-       * - Assumes Value strings are encoded in UTF-8
-       */
-      static Features all();
-
-      /** \brief A configuration that is strictly compatible with the JSON specification.
-       * - Comments are forbidden.
-       * - Root object must be either an array or an object value.
-       * - Assumes Value strings are encoded in UTF-8
-       */
-      static Features strictMode();
-
-      /** \brief Initialize the configuration like JsonConfig::allFeatures;
-       */
-      Features();
-
-      /// \c true if comments are allowed. Default: \c true.
-      bool allowComments_;
-
-      /// \c true if root must be either an array or an object value. Default: \c false.
-      bool strictRoot_;
-   };
-
-} // namespace Json
-
-#endif // CPPTL_JSON_FEATURES_H_INCLUDED
diff --git a/bamtools/src/third_party/jsoncpp/json_forwards.h b/bamtools/src/third_party/jsoncpp/json_forwards.h
deleted file mode 100644
index 792a87a..0000000
--- a/bamtools/src/third_party/jsoncpp/json_forwards.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef JSON_FORWARDS_H_INCLUDED
-# define JSON_FORWARDS_H_INCLUDED
-
-# include "json_config.h"
-
-namespace Json {
-
-   // writer.h
-   class FastWriter;
-   class StyledWriter;
-
-   // reader.h
-   class Reader;
-
-   // features.h
-   class Features;
-
-   // value.h
-   typedef unsigned int ArrayIndex;
-   class StaticString;
-   class Path;
-   class PathArgument;
-   class Value;
-   class ValueIteratorBase;
-   class ValueIterator;
-   class ValueConstIterator;
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
-   class ValueMapAllocator;
-   class ValueInternalLink;
-   class ValueInternalArray;
-   class ValueInternalMap;
-#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP
-
-} // namespace Json
-
-
-#endif // JSON_FORWARDS_H_INCLUDED
diff --git a/bamtools/src/third_party/jsoncpp/json_internalarray.inl b/bamtools/src/third_party/jsoncpp/json_internalarray.inl
deleted file mode 100644
index 66d838e..0000000
--- a/bamtools/src/third_party/jsoncpp/json_internalarray.inl
+++ /dev/null
@@ -1,453 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-// included by json_value.cpp
-// everything is within Json namespace
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// class ValueInternalArray
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-
-ValueArrayAllocator::~ValueArrayAllocator()
-{
-}
-
-// //////////////////////////////////////////////////////////////////
-// class DefaultValueArrayAllocator
-// //////////////////////////////////////////////////////////////////
-#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
-class DefaultValueArrayAllocator : public ValueArrayAllocator
-{
-public: // overridden from ValueArrayAllocator
-   virtual ~DefaultValueArrayAllocator()
-   {
-   }
-
-   virtual ValueInternalArray *newArray()
-   {
-      return new ValueInternalArray();
-   }
-
-   virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )
-   {
-      return new ValueInternalArray( other );
-   }
-
-   virtual void destructArray( ValueInternalArray *array )
-   {
-      delete array;
-   }
-
-   virtual void reallocateArrayPageIndex( Value **&indexes, 
-                                          ValueInternalArray::PageIndex &indexCount,
-                                          ValueInternalArray::PageIndex minNewIndexCount )
-   {
-      ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;
-      if ( minNewIndexCount > newIndexCount )
-         newIndexCount = minNewIndexCount;
-      void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );
-      if ( !newIndexes )
-         throw std::bad_alloc();
-      indexCount = newIndexCount;
-      indexes = static_cast<Value **>( newIndexes );
-   }
-   virtual void releaseArrayPageIndex( Value **indexes, 
-                                       ValueInternalArray::PageIndex indexCount )
-   {
-      if ( indexes )
-         free( indexes );
-   }
-
-   virtual Value *allocateArrayPage()
-   {
-      return static_cast<Value *>( malloc( sizeof(Value) * ValueInternalArray::itemsPerPage ) );
-   }
-
-   virtual void releaseArrayPage( Value *value )
-   {
-      if ( value )
-         free( value );
-   }
-};
-
-#else // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
-/// @todo make this thread-safe (lock when accessign batch allocator)
-class DefaultValueArrayAllocator : public ValueArrayAllocator
-{
-public: // overridden from ValueArrayAllocator
-   virtual ~DefaultValueArrayAllocator()
-   {
-   }
-
-   virtual ValueInternalArray *newArray()
-   {
-      ValueInternalArray *array = arraysAllocator_.allocate();
-      new (array) ValueInternalArray(); // placement new
-      return array;
-   }
-
-   virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )
-   {
-      ValueInternalArray *array = arraysAllocator_.allocate();
-      new (array) ValueInternalArray( other ); // placement new
-      return array;
-   }
-
-   virtual void destructArray( ValueInternalArray *array )
-   {
-      if ( array )
-      {
-         array->~ValueInternalArray();
-         arraysAllocator_.release( array );
-      }
-   }
-
-   virtual void reallocateArrayPageIndex( Value **&indexes, 
-                                          ValueInternalArray::PageIndex &indexCount,
-                                          ValueInternalArray::PageIndex minNewIndexCount )
-   {
-      ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;
-      if ( minNewIndexCount > newIndexCount )
-         newIndexCount = minNewIndexCount;
-      void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );
-      if ( !newIndexes )
-         throw std::bad_alloc();
-      indexCount = newIndexCount;
-      indexes = static_cast<Value **>( newIndexes );
-   }
-   virtual void releaseArrayPageIndex( Value **indexes, 
-                                       ValueInternalArray::PageIndex indexCount )
-   {
-      if ( indexes )
-         free( indexes );
-   }
-
-   virtual Value *allocateArrayPage()
-   {
-      return static_cast<Value *>( pagesAllocator_.allocate() );
-   }
-
-   virtual void releaseArrayPage( Value *value )
-   {
-      if ( value )
-         pagesAllocator_.release( value );
-   }
-private:
-   BatchAllocator<ValueInternalArray,1> arraysAllocator_;
-   BatchAllocator<Value,ValueInternalArray::itemsPerPage> pagesAllocator_;
-};
-#endif // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
-
-static ValueArrayAllocator *&arrayAllocator()
-{
-   static DefaultValueArrayAllocator defaultAllocator;
-   static ValueArrayAllocator *arrayAllocator = &defaultAllocator;
-   return arrayAllocator;
-}
-
-static struct DummyArrayAllocatorInitializer {
-   DummyArrayAllocatorInitializer() 
-   {
-      arrayAllocator();      // ensure arrayAllocator() statics are initialized before main().
-   }
-} dummyArrayAllocatorInitializer;
-
-// //////////////////////////////////////////////////////////////////
-// class ValueInternalArray
-// //////////////////////////////////////////////////////////////////
-bool 
-ValueInternalArray::equals( const IteratorState &x, 
-                            const IteratorState &other )
-{
-   return x.array_ == other.array_  
-          &&  x.currentItemIndex_ == other.currentItemIndex_  
-          &&  x.currentPageIndex_ == other.currentPageIndex_;
-}
-
-
-void 
-ValueInternalArray::increment( IteratorState &it )
-{
-   JSON_ASSERT_MESSAGE( it.array_  &&
-      (it.currentPageIndex_ - it.array_->pages_)*itemsPerPage + it.currentItemIndex_
-      != it.array_->size_,
-      "ValueInternalArray::increment(): moving iterator beyond end" );
-   ++(it.currentItemIndex_);
-   if ( it.currentItemIndex_ == itemsPerPage )
-   {
-      it.currentItemIndex_ = 0;
-      ++(it.currentPageIndex_);
-   }
-}
-
-
-void 
-ValueInternalArray::decrement( IteratorState &it )
-{
-   JSON_ASSERT_MESSAGE( it.array_  &&  it.currentPageIndex_ == it.array_->pages_ 
-                        &&  it.currentItemIndex_ == 0,
-      "ValueInternalArray::decrement(): moving iterator beyond end" );
-   if ( it.currentItemIndex_ == 0 )
-   {
-      it.currentItemIndex_ = itemsPerPage-1;
-      --(it.currentPageIndex_);
-   }
-   else
-   {
-      --(it.currentItemIndex_);
-   }
-}
-
-
-Value &
-ValueInternalArray::unsafeDereference( const IteratorState &it )
-{
-   return (*(it.currentPageIndex_))[it.currentItemIndex_];
-}
-
-
-Value &
-ValueInternalArray::dereference( const IteratorState &it )
-{
-   JSON_ASSERT_MESSAGE( it.array_  &&
-      (it.currentPageIndex_ - it.array_->pages_)*itemsPerPage + it.currentItemIndex_
-      < it.array_->size_,
-      "ValueInternalArray::dereference(): dereferencing invalid iterator" );
-   return unsafeDereference( it );
-}
-
-void 
-ValueInternalArray::makeBeginIterator( IteratorState &it ) const
-{
-   it.array_ = const_cast<ValueInternalArray *>( this );
-   it.currentItemIndex_ = 0;
-   it.currentPageIndex_ = pages_;
-}
-
-
-void 
-ValueInternalArray::makeIterator( IteratorState &it, ArrayIndex index ) const
-{
-   it.array_ = const_cast<ValueInternalArray *>( this );
-   it.currentItemIndex_ = index % itemsPerPage;
-   it.currentPageIndex_ = pages_ + index / itemsPerPage;
-}
-
-
-void 
-ValueInternalArray::makeEndIterator( IteratorState &it ) const
-{
-   makeIterator( it, size_ );
-}
-
-
-ValueInternalArray::ValueInternalArray()
-   : pages_( 0 )
-   , size_( 0 )
-   , pageCount_( 0 )
-{
-}
-
-
-ValueInternalArray::ValueInternalArray( const ValueInternalArray &other )
-   : pages_( 0 )
-   , pageCount_( 0 )
-   , size_( other.size_ )
-{
-   PageIndex minNewPages = other.size_ / itemsPerPage;
-   arrayAllocator()->reallocateArrayPageIndex( pages_, pageCount_, minNewPages );
-   JSON_ASSERT_MESSAGE( pageCount_ >= minNewPages, 
-                        "ValueInternalArray::reserve(): bad reallocation" );
-   IteratorState itOther;
-   other.makeBeginIterator( itOther );
-   Value *value;
-   for ( ArrayIndex index = 0; index < size_; ++index, increment(itOther) )
-   {
-      if ( index % itemsPerPage == 0 )
-      {
-         PageIndex pageIndex = index / itemsPerPage;
-         value = arrayAllocator()->allocateArrayPage();
-         pages_[pageIndex] = value;
-      }
-      new (value) Value( dereference( itOther ) );
-   }
-}
-
-
-ValueInternalArray &
-ValueInternalArray::operator =( const ValueInternalArray &other )
-{
-   ValueInternalArray temp( other );
-   swap( temp );
-   return *this;
-}
-
-
-ValueInternalArray::~ValueInternalArray()
-{
-   // destroy all constructed items
-   IteratorState it;
-   IteratorState itEnd;
-   makeBeginIterator( it);
-   makeEndIterator( itEnd );
-   for ( ; !equals(it,itEnd); increment(it) )
-   {
-      Value *value = &dereference(it);
-      value->~Value();
-   }
-   // release all pages
-   PageIndex lastPageIndex = size_ / itemsPerPage;
-   for ( PageIndex pageIndex = 0; pageIndex < lastPageIndex; ++pageIndex )
-      arrayAllocator()->releaseArrayPage( pages_[pageIndex] );
-   // release pages index
-   arrayAllocator()->releaseArrayPageIndex( pages_, pageCount_ );
-}
-
-
-void 
-ValueInternalArray::swap( ValueInternalArray &other )
-{
-   Value **tempPages = pages_;
-   pages_ = other.pages_;
-   other.pages_ = tempPages;
-   ArrayIndex tempSize = size_;
-   size_ = other.size_;
-   other.size_ = tempSize;
-   PageIndex tempPageCount = pageCount_;
-   pageCount_ = other.pageCount_;
-   other.pageCount_ = tempPageCount;
-}
-
-void 
-ValueInternalArray::clear()
-{
-   ValueInternalArray dummy;
-   swap( dummy );
-}
-
-
-void 
-ValueInternalArray::resize( ArrayIndex newSize )
-{
-   if ( newSize == 0 )
-      clear();
-   else if ( newSize < size_ )
-   {
-      IteratorState it;
-      IteratorState itEnd;
-      makeIterator( it, newSize );
-      makeIterator( itEnd, size_ );
-      for ( ; !equals(it,itEnd); increment(it) )
-      {
-         Value *value = &dereference(it);
-         value->~Value();
-      }
-      PageIndex pageIndex = (newSize + itemsPerPage - 1) / itemsPerPage;
-      PageIndex lastPageIndex = size_ / itemsPerPage;
-      for ( ; pageIndex < lastPageIndex; ++pageIndex )
-         arrayAllocator()->releaseArrayPage( pages_[pageIndex] );
-      size_ = newSize;
-   }
-   else if ( newSize > size_ )
-      resolveReference( newSize );
-}
-
-
-void 
-ValueInternalArray::makeIndexValid( ArrayIndex index )
-{
-   // Need to enlarge page index ?
-   if ( index >= pageCount_ * itemsPerPage )
-   {
-      PageIndex minNewPages = (index + 1) / itemsPerPage;
-      arrayAllocator()->reallocateArrayPageIndex( pages_, pageCount_, minNewPages );
-      JSON_ASSERT_MESSAGE( pageCount_ >= minNewPages, "ValueInternalArray::reserve(): bad reallocation" );
-   }
-
-   // Need to allocate new pages ?
-   ArrayIndex nextPageIndex = 
-      (size_ % itemsPerPage) != 0 ? size_ - (size_%itemsPerPage) + itemsPerPage
-                                  : size_;
-   if ( nextPageIndex <= index )
-   {
-      PageIndex pageIndex = nextPageIndex / itemsPerPage;
-      PageIndex pageToAllocate = (index - nextPageIndex) / itemsPerPage + 1;
-      for ( ; pageToAllocate-- > 0; ++pageIndex )
-         pages_[pageIndex] = arrayAllocator()->allocateArrayPage();
-   }
-
-   // Initialize all new entries
-   IteratorState it;
-   IteratorState itEnd;
-   makeIterator( it, size_ );
-   size_ = index + 1;
-   makeIterator( itEnd, size_ );
-   for ( ; !equals(it,itEnd); increment(it) )
-   {
-      Value *value = &dereference(it);
-      new (value) Value(); // Construct a default value using placement new
-   }
-}
-
-Value &
-ValueInternalArray::resolveReference( ArrayIndex index )
-{
-   if ( index >= size_ )
-      makeIndexValid( index );
-   return pages_[index/itemsPerPage][index%itemsPerPage];
-}
-
-Value *
-ValueInternalArray::find( ArrayIndex index ) const
-{
-   if ( index >= size_ )
-      return 0;
-   return &(pages_[index/itemsPerPage][index%itemsPerPage]);
-}
-
-ValueInternalArray::ArrayIndex 
-ValueInternalArray::size() const
-{
-   return size_;
-}
-
-int 
-ValueInternalArray::distance( const IteratorState &x, const IteratorState &y )
-{
-   return indexOf(y) - indexOf(x);
-}
-
-
-ValueInternalArray::ArrayIndex 
-ValueInternalArray::indexOf( const IteratorState &iterator )
-{
-   if ( !iterator.array_ )
-      return ArrayIndex(-1);
-   return ArrayIndex(
-      (iterator.currentPageIndex_ - iterator.array_->pages_) * itemsPerPage 
-      + iterator.currentItemIndex_ );
-}
-
-
-int 
-ValueInternalArray::compare( const ValueInternalArray &other ) const
-{
-   int sizeDiff( size_ - other.size_ );
-   if ( sizeDiff != 0 )
-      return sizeDiff;
-   
-   for ( ArrayIndex index =0; index < size_; ++index )
-   {
-      int diff = pages_[index/itemsPerPage][index%itemsPerPage].compare( 
-         other.pages_[index/itemsPerPage][index%itemsPerPage] );
-      if ( diff != 0 )
-         return diff;
-   }
-   return 0;
-}
diff --git a/bamtools/src/third_party/jsoncpp/json_internalmap.inl b/bamtools/src/third_party/jsoncpp/json_internalmap.inl
deleted file mode 100644
index d0dd62a..0000000
--- a/bamtools/src/third_party/jsoncpp/json_internalmap.inl
+++ /dev/null
@@ -1,612 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-// included by json_value.cpp
-// everything is within Json namespace
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// class ValueInternalMap
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-
-/** \internal MUST be safely initialized using memset( this, 0, sizeof(ValueInternalLink) );
-   * This optimization is used by the fast allocator.
-   */
-ValueInternalLink::ValueInternalLink()
-   : previous_( 0 )
-   , next_( 0 )
-{
-}
-
-ValueInternalLink::~ValueInternalLink()
-{ 
-   for ( int index =0; index < itemPerLink; ++index )
-   {
-      if ( !items_[index].isItemAvailable() )
-      {
-         if ( !items_[index].isMemberNameStatic() )
-            free( keys_[index] );
-      }
-      else
-         break;
-   }
-}
-
-
-
-ValueMapAllocator::~ValueMapAllocator()
-{
-}
-
-#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
-class DefaultValueMapAllocator : public ValueMapAllocator
-{
-public: // overridden from ValueMapAllocator
-   virtual ValueInternalMap *newMap()
-   {
-      return new ValueInternalMap();
-   }
-
-   virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )
-   {
-      return new ValueInternalMap( other );
-   }
-
-   virtual void destructMap( ValueInternalMap *map )
-   {
-      delete map;
-   }
-
-   virtual ValueInternalLink *allocateMapBuckets( unsigned int size )
-   {
-      return new ValueInternalLink[size];
-   }
-
-   virtual void releaseMapBuckets( ValueInternalLink *links )
-   {
-      delete [] links;
-   }
-
-   virtual ValueInternalLink *allocateMapLink()
-   {
-      return new ValueInternalLink();
-   }
-
-   virtual void releaseMapLink( ValueInternalLink *link )
-   {
-      delete link;
-   }
-};
-#else
-/// @todo make this thread-safe (lock when accessign batch allocator)
-class DefaultValueMapAllocator : public ValueMapAllocator
-{
-public: // overridden from ValueMapAllocator
-   virtual ValueInternalMap *newMap()
-   {
-      ValueInternalMap *map = mapsAllocator_.allocate();
-      new (map) ValueInternalMap(); // placement new
-      return map;
-   }
-
-   virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )
-   {
-      ValueInternalMap *map = mapsAllocator_.allocate();
-      new (map) ValueInternalMap( other ); // placement new
-      return map;
-   }
-
-   virtual void destructMap( ValueInternalMap *map )
-   {
-      if ( map )
-      {
-         map->~ValueInternalMap();
-         mapsAllocator_.release( map );
-      }
-   }
-
-   virtual ValueInternalLink *allocateMapBuckets( unsigned int size )
-   {
-      return new ValueInternalLink[size];
-   }
-
-   virtual void releaseMapBuckets( ValueInternalLink *links )
-   {
-      delete [] links;
-   }
-
-   virtual ValueInternalLink *allocateMapLink()
-   {
-      ValueInternalLink *link = linksAllocator_.allocate();
-      memset( link, 0, sizeof(ValueInternalLink) );
-      return link;
-   }
-
-   virtual void releaseMapLink( ValueInternalLink *link )
-   {
-      link->~ValueInternalLink();
-      linksAllocator_.release( link );
-   }
-private:
-   BatchAllocator<ValueInternalMap,1> mapsAllocator_;
-   BatchAllocator<ValueInternalLink,1> linksAllocator_;
-};
-#endif
-
-static ValueMapAllocator *&mapAllocator()
-{
-   static DefaultValueMapAllocator defaultAllocator;
-   static ValueMapAllocator *mapAllocator = &defaultAllocator;
-   return mapAllocator;
-}
-
-static struct DummyMapAllocatorInitializer {
-   DummyMapAllocatorInitializer() 
-   {
-      mapAllocator();      // ensure mapAllocator() statics are initialized before main().
-   }
-} dummyMapAllocatorInitializer;
-
-
-
-// h(K) = value * K >> w ; with w = 32 & K prime w.r.t. 2^32.
-
-/*
-use linked list hash map. 
-buckets array is a container.
-linked list element contains 6 key/values. (memory = (16+4) * 6 + 4 = 124)
-value have extra state: valid, available, deleted
-*/
-
-
-ValueInternalMap::ValueInternalMap()
-   : buckets_( 0 )
-   , tailLink_( 0 )
-   , bucketsSize_( 0 )
-   , itemCount_( 0 )
-{
-}
-
-
-ValueInternalMap::ValueInternalMap( const ValueInternalMap &other )
-   : buckets_( 0 )
-   , tailLink_( 0 )
-   , bucketsSize_( 0 )
-   , itemCount_( 0 )
-{
-   reserve( other.itemCount_ );
-   IteratorState it;
-   IteratorState itEnd;
-   other.makeBeginIterator( it );
-   other.makeEndIterator( itEnd );
-   for ( ; !equals(it,itEnd); increment(it) )
-   {
-      bool isStatic;
-      const char *memberName = key( it, isStatic );
-      const Value &aValue = value( it );
-      resolveReference(memberName, isStatic) = aValue;
-   }
-}
-
-
-ValueInternalMap &
-ValueInternalMap::operator =( const ValueInternalMap &other )
-{
-   ValueInternalMap dummy( other );
-   swap( dummy );
-   return *this;
-}
-
-
-ValueInternalMap::~ValueInternalMap()
-{
-   if ( buckets_ )
-   {
-      for ( BucketIndex bucketIndex =0; bucketIndex < bucketsSize_; ++bucketIndex )
-      {
-         ValueInternalLink *link = buckets_[bucketIndex].next_;
-         while ( link )
-         {
-            ValueInternalLink *linkToRelease = link;
-            link = link->next_;
-            mapAllocator()->releaseMapLink( linkToRelease );
-         }
-      }
-      mapAllocator()->releaseMapBuckets( buckets_ );
-   }
-}
-
-
-void 
-ValueInternalMap::swap( ValueInternalMap &other )
-{
-   ValueInternalLink *tempBuckets = buckets_;
-   buckets_ = other.buckets_;
-   other.buckets_ = tempBuckets;
-   ValueInternalLink *tempTailLink = tailLink_;
-   tailLink_ = other.tailLink_;
-   other.tailLink_ = tempTailLink;
-   BucketIndex tempBucketsSize = bucketsSize_;
-   bucketsSize_ = other.bucketsSize_;
-   other.bucketsSize_ = tempBucketsSize;
-   BucketIndex tempItemCount = itemCount_;
-   itemCount_ = other.itemCount_;
-   other.itemCount_ = tempItemCount;
-}
-
-
-void 
-ValueInternalMap::clear()
-{
-   ValueInternalMap dummy;
-   swap( dummy );
-}
-
-
-ValueInternalMap::BucketIndex 
-ValueInternalMap::size() const
-{
-   return itemCount_;
-}
-
-bool 
-ValueInternalMap::reserveDelta( BucketIndex growth )
-{
-   return reserve( itemCount_ + growth );
-}
-
-bool 
-ValueInternalMap::reserve( BucketIndex newItemCount )
-{
-   if ( !buckets_  &&  newItemCount > 0 )
-   {
-      buckets_ = mapAllocator()->allocateMapBuckets( 1 );
-      bucketsSize_ = 1;
-      tailLink_ = &buckets_[0];
-   }
-//   BucketIndex idealBucketCount = (newItemCount + ValueInternalLink::itemPerLink) / ValueInternalLink::itemPerLink;
-   return true;
-}
-
-
-const Value *
-ValueInternalMap::find( const char *key ) const
-{
-   if ( !bucketsSize_ )
-      return 0;
-   HashKey hashedKey = hash( key );
-   BucketIndex bucketIndex = hashedKey % bucketsSize_;
-   for ( const ValueInternalLink *current = &buckets_[bucketIndex]; 
-         current != 0; 
-         current = current->next_ )
-   {
-      for ( BucketIndex index=0; index < ValueInternalLink::itemPerLink; ++index )
-      {
-         if ( current->items_[index].isItemAvailable() )
-            return 0;
-         if ( strcmp( key, current->keys_[index] ) == 0 )
-            return &current->items_[index];
-      }
-   }
-   return 0;
-}
-
-
-Value *
-ValueInternalMap::find( const char *key )
-{
-   const ValueInternalMap *constThis = this;
-   return const_cast<Value *>( constThis->find( key ) );
-}
-
-
-Value &
-ValueInternalMap::resolveReference( const char *key,
-                                    bool isStatic )
-{
-   HashKey hashedKey = hash( key );
-   if ( bucketsSize_ )
-   {
-      BucketIndex bucketIndex = hashedKey % bucketsSize_;
-      ValueInternalLink **previous = 0;
-      BucketIndex index;
-      for ( ValueInternalLink *current = &buckets_[bucketIndex]; 
-            current != 0; 
-            previous = &current->next_, current = current->next_ )
-      {
-         for ( index=0; index < ValueInternalLink::itemPerLink; ++index )
-         {
-            if ( current->items_[index].isItemAvailable() )
-               return setNewItem( key, isStatic, current, index );
-            if ( strcmp( key, current->keys_[index] ) == 0 )
-               return current->items_[index];
-         }
-      }
-   }
-
-   reserveDelta( 1 );
-   return unsafeAdd( key, isStatic, hashedKey );
-}
-
-
-void 
-ValueInternalMap::remove( const char *key )
-{
-   HashKey hashedKey = hash( key );
-   if ( !bucketsSize_ )
-      return;
-   BucketIndex bucketIndex = hashedKey % bucketsSize_;
-   for ( ValueInternalLink *link = &buckets_[bucketIndex]; 
-         link != 0; 
-         link = link->next_ )
-   {
-      BucketIndex index;
-      for ( index =0; index < ValueInternalLink::itemPerLink; ++index )
-      {
-         if ( link->items_[index].isItemAvailable() )
-            return;
-         if ( strcmp( key, link->keys_[index] ) == 0 )
-         {
-            doActualRemove( link, index, bucketIndex );
-            return;
-         }
-      }
-   }
-}
-
-void 
-ValueInternalMap::doActualRemove( ValueInternalLink *link, 
-                                  BucketIndex index,
-                                  BucketIndex bucketIndex )
-{
-   // find last item of the bucket and swap it with the 'removed' one.
-   // set removed items flags to 'available'.
-   // if last page only contains 'available' items, then desallocate it (it's empty)
-   ValueInternalLink *&lastLink = getLastLinkInBucket( index );
-   BucketIndex lastItemIndex = 1; // a link can never be empty, so start at 1
-   for ( ;   
-         lastItemIndex < ValueInternalLink::itemPerLink; 
-         ++lastItemIndex ) // may be optimized with dicotomic search
-   {
-      if ( lastLink->items_[lastItemIndex].isItemAvailable() )
-         break;
-   }
-   
-   BucketIndex lastUsedIndex = lastItemIndex - 1;
-   Value *valueToDelete = &link->items_[index];
-   Value *valueToPreserve = &lastLink->items_[lastUsedIndex];
-   if ( valueToDelete != valueToPreserve )
-      valueToDelete->swap( *valueToPreserve );
-   if ( lastUsedIndex == 0 )  // page is now empty
-   {  // remove it from bucket linked list and delete it.
-      ValueInternalLink *linkPreviousToLast = lastLink->previous_;
-      if ( linkPreviousToLast != 0 )   // can not deleted bucket link.
-      {
-         mapAllocator()->releaseMapLink( lastLink );
-         linkPreviousToLast->next_ = 0;
-         lastLink = linkPreviousToLast;
-      }
-   }
-   else
-   {
-      Value dummy;
-      valueToPreserve->swap( dummy ); // restore deleted to default Value.
-      valueToPreserve->setItemUsed( false );
-   }
-   --itemCount_;
-}
-
-
-ValueInternalLink *&
-ValueInternalMap::getLastLinkInBucket( BucketIndex bucketIndex )
-{
-   if ( bucketIndex == bucketsSize_ - 1 )
-      return tailLink_;
-   ValueInternalLink *&previous = buckets_[bucketIndex+1].previous_;
-   if ( !previous )
-      previous = &buckets_[bucketIndex];
-   return previous;
-}
-
-
-Value &
-ValueInternalMap::setNewItem( const char *key, 
-                              bool isStatic,
-                              ValueInternalLink *link, 
-                              BucketIndex index )
-{
-   char *duplicatedKey = makeMemberName( key );
-   ++itemCount_;
-   link->keys_[index] = duplicatedKey;
-   link->items_[index].setItemUsed();
-   link->items_[index].setMemberNameIsStatic( isStatic );
-   return link->items_[index]; // items already default constructed.
-}
-
-
-Value &
-ValueInternalMap::unsafeAdd( const char *key, 
-                             bool isStatic, 
-                             HashKey hashedKey )
-{
-   JSON_ASSERT_MESSAGE( bucketsSize_ > 0, "ValueInternalMap::unsafeAdd(): internal logic error." );
-   BucketIndex bucketIndex = hashedKey % bucketsSize_;
-   ValueInternalLink *&previousLink = getLastLinkInBucket( bucketIndex );
-   ValueInternalLink *link = previousLink;
-   BucketIndex index;
-   for ( index =0; index < ValueInternalLink::itemPerLink; ++index )
-   {
-      if ( link->items_[index].isItemAvailable() )
-         break;
-   }
-   if ( index == ValueInternalLink::itemPerLink ) // need to add a new page
-   {
-      ValueInternalLink *newLink = mapAllocator()->allocateMapLink();
-      index = 0;
-      link->next_ = newLink;
-      previousLink = newLink;
-      link = newLink;
-   }
-   return setNewItem( key, isStatic, link, index );
-}
-
-
-ValueInternalMap::HashKey 
-ValueInternalMap::hash( const char *key ) const
-{
-   HashKey hash = 0;
-   while ( *key )
-      hash += *key++ * 37;
-   return hash;
-}
-
-
-int 
-ValueInternalMap::compare( const ValueInternalMap &other ) const
-{
-   int sizeDiff( itemCount_ - other.itemCount_ );
-   if ( sizeDiff != 0 )
-      return sizeDiff;
-   // Strict order guaranty is required. Compare all keys FIRST, then compare values.
-   IteratorState it;
-   IteratorState itEnd;
-   makeBeginIterator( it );
-   makeEndIterator( itEnd );
-   for ( ; !equals(it,itEnd); increment(it) )
-   {
-      if ( !other.find( key( it ) ) )
-         return 1;
-   }
-
-   // All keys are equals, let's compare values
-   makeBeginIterator( it );
-   for ( ; !equals(it,itEnd); increment(it) )
-   {
-      const Value *otherValue = other.find( key( it ) );
-      int valueDiff = value(it).compare( *otherValue );
-      if ( valueDiff != 0 )
-         return valueDiff;
-   }
-   return 0;
-}
-
-
-void 
-ValueInternalMap::makeBeginIterator( IteratorState &it ) const
-{
-   it.map_ = const_cast<ValueInternalMap *>( this );
-   it.bucketIndex_ = 0;
-   it.itemIndex_ = 0;
-   it.link_ = buckets_;
-}
-
-
-void 
-ValueInternalMap::makeEndIterator( IteratorState &it ) const
-{
-   it.map_ = const_cast<ValueInternalMap *>( this );
-   it.bucketIndex_ = bucketsSize_;
-   it.itemIndex_ = 0;
-   it.link_ = 0;
-}
-
-
-bool 
-ValueInternalMap::equals( const IteratorState &x, const IteratorState &other )
-{
-   return x.map_ == other.map_  
-          &&  x.bucketIndex_ == other.bucketIndex_  
-          &&  x.link_ == other.link_
-          &&  x.itemIndex_ == other.itemIndex_;
-}
-
-
-void 
-ValueInternalMap::incrementBucket( IteratorState &iterator )
-{
-   ++iterator.bucketIndex_;
-   JSON_ASSERT_MESSAGE( iterator.bucketIndex_ <= iterator.map_->bucketsSize_,
-      "ValueInternalMap::increment(): attempting to iterate beyond end." );
-   if ( iterator.bucketIndex_ == iterator.map_->bucketsSize_ )
-      iterator.link_ = 0;
-   else
-      iterator.link_ = &(iterator.map_->buckets_[iterator.bucketIndex_]);
-   iterator.itemIndex_ = 0;
-}
-
-
-void 
-ValueInternalMap::increment( IteratorState &iterator )
-{
-   JSON_ASSERT_MESSAGE( iterator.map_, "Attempting to iterator using invalid iterator." );
-   ++iterator.itemIndex_;
-   if ( iterator.itemIndex_ == ValueInternalLink::itemPerLink )
-   {
-      JSON_ASSERT_MESSAGE( iterator.link_ != 0,
-         "ValueInternalMap::increment(): attempting to iterate beyond end." );
-      iterator.link_ = iterator.link_->next_;
-      if ( iterator.link_ == 0 )
-         incrementBucket( iterator );
-   }
-   else if ( iterator.link_->items_[iterator.itemIndex_].isItemAvailable() )
-   {
-      incrementBucket( iterator );
-   }
-}
-
-
-void 
-ValueInternalMap::decrement( IteratorState &iterator )
-{
-   if ( iterator.itemIndex_ == 0 )
-   {
-      JSON_ASSERT_MESSAGE( iterator.map_, "Attempting to iterate using invalid iterator." );
-      if ( iterator.link_ == &iterator.map_->buckets_[iterator.bucketIndex_] )
-      {
-         JSON_ASSERT_MESSAGE( iterator.bucketIndex_ > 0, "Attempting to iterate beyond beginning." );
-         --(iterator.bucketIndex_);
-      }
-      iterator.link_ = iterator.link_->previous_;
-      iterator.itemIndex_ = ValueInternalLink::itemPerLink - 1;
-   }
-}
-
-
-const char *
-ValueInternalMap::key( const IteratorState &iterator )
-{
-   JSON_ASSERT_MESSAGE( iterator.link_, "Attempting to iterate using invalid iterator." );
-   return iterator.link_->keys_[iterator.itemIndex_];
-}
-
-const char *
-ValueInternalMap::key( const IteratorState &iterator, bool &isStatic )
-{
-   JSON_ASSERT_MESSAGE( iterator.link_, "Attempting to iterate using invalid iterator." );
-   isStatic = iterator.link_->items_[iterator.itemIndex_].isMemberNameStatic();
-   return iterator.link_->keys_[iterator.itemIndex_];
-}
-
-
-Value &
-ValueInternalMap::value( const IteratorState &iterator )
-{
-   JSON_ASSERT_MESSAGE( iterator.link_, "Attempting to iterate using invalid iterator." );
-   return iterator.link_->items_[iterator.itemIndex_];
-}
-
-
-int 
-ValueInternalMap::distance( const IteratorState &x, const IteratorState &y )
-{
-   int offset = 0;
-   IteratorState it = x;
-   while ( !equals( it, y ) )
-      increment( it );
-   return offset;
-}
diff --git a/bamtools/src/third_party/jsoncpp/json_reader.cpp b/bamtools/src/third_party/jsoncpp/json_reader.cpp
deleted file mode 100644
index 07561f2..0000000
--- a/bamtools/src/third_party/jsoncpp/json_reader.cpp
+++ /dev/null
@@ -1,870 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#include "json_reader.h"
-#include "json_value.h"
-#include "json_tool.h"
-#include <utility>
-#include <cstdio>
-#include <cassert>
-#include <cstring>
-#include <iostream>
-#include <stdexcept>
-
-#if _MSC_VER >= 1400 // VC++ 8.0
-#pragma warning( disable : 4996 )   // disable warning about strdup being deprecated.
-#endif
-
-namespace Json {
-
-// Implementation of class Features
-// ////////////////////////////////
-
-Features::Features()
-   : allowComments_( true )
-   , strictRoot_( false )
-{
-}
-
-
-Features 
-Features::all()
-{
-   return Features();
-}
-
-
-Features 
-Features::strictMode()
-{
-   Features features;
-   features.allowComments_ = false;
-   features.strictRoot_ = true;
-   return features;
-}
-
-// Implementation of class Reader
-// ////////////////////////////////
-
-
-static inline bool 
-in( Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4 )
-{
-   return c == c1  ||  c == c2  ||  c == c3  ||  c == c4;
-}
-
-static inline bool 
-in( Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4, Reader::Char c5 )
-{
-   return c == c1  ||  c == c2  ||  c == c3  ||  c == c4  ||  c == c5;
-}
-
-
-static bool 
-containsNewLine( Reader::Location begin, 
-                 Reader::Location end )
-{
-   for ( ;begin < end; ++begin )
-      if ( *begin == '\n'  ||  *begin == '\r' )
-         return true;
-   return false;
-}
-
-
-// Class Reader
-// //////////////////////////////////////////////////////////////////
-
-Reader::Reader()
-   : features_( Features::all() )
-{
-}
-
-
-Reader::Reader( const Features &features )
-   : features_( features )
-{
-}
-
-
-bool
-Reader::parse( const std::string &document, 
-               Value &root,
-               bool collectComments )
-{
-   document_ = document;
-   const char *begin = document_.c_str();
-   const char *end = begin + document_.length();
-   return parse( begin, end, root, collectComments );
-}
-
-
-bool
-Reader::parse( std::istream& sin,
-               Value &root,
-               bool collectComments )
-{
-   //std::istream_iterator<char> begin(sin);
-   //std::istream_iterator<char> end;
-   // Those would allow streamed input from a file, if parse() were a
-   // template function.
-
-   // Since std::string is reference-counted, this at least does not
-   // create an extra copy.
-   std::string doc;
-   std::getline(sin, doc, (char)EOF);
-   return parse( doc, root, collectComments );
-}
-
-bool 
-Reader::parse( const char *beginDoc, const char *endDoc, 
-               Value &root,
-               bool collectComments )
-{
-   if ( !features_.allowComments_ )
-   {
-      collectComments = false;
-   }
-
-   begin_ = beginDoc;
-   end_ = endDoc;
-   collectComments_ = collectComments;
-   current_ = begin_;
-   lastValueEnd_ = 0;
-   lastValue_ = 0;
-   commentsBefore_ = "";
-   errors_.clear();
-   while ( !nodes_.empty() )
-      nodes_.pop();
-   nodes_.push( &root );
-   
-   bool successful = readValue();
-   Token token;
-   skipCommentTokens( token );
-   if ( collectComments_  &&  !commentsBefore_.empty() )
-      root.setComment( commentsBefore_, commentAfter );
-   if ( features_.strictRoot_ )
-   {
-      if ( !root.isArray()  &&  !root.isObject() )
-      {
-         // Set error location to start of doc, ideally should be first token found in doc
-         token.type_ = tokenError;
-         token.start_ = beginDoc;
-         token.end_ = endDoc;
-         addError( "A valid JSON document must be either an array or an object value.",
-                   token );
-         return false;
-      }
-   }
-   return successful;
-}
-
-
-bool
-Reader::readValue()
-{
-   Token token;
-   skipCommentTokens( token );
-   bool successful = true;
-
-   if ( collectComments_  &&  !commentsBefore_.empty() )
-   {
-      currentValue().setComment( commentsBefore_, commentBefore );
-      commentsBefore_ = "";
-   }
-
-
-   switch ( token.type_ )
-   {
-   case tokenObjectBegin:
-      successful = readObject( token );
-      break;
-   case tokenArrayBegin:
-      successful = readArray( token );
-      break;
-   case tokenNumber:
-      successful = decodeNumber( token );
-      break;
-   case tokenString:
-      successful = decodeString( token );
-      break;
-   case tokenTrue:
-      currentValue() = true;
-      break;
-   case tokenFalse:
-      currentValue() = false;
-      break;
-   case tokenNull:
-      currentValue() = Value();
-      break;
-   default:
-      return addError( "Syntax error: value, object or array expected.", token );
-   }
-
-   if ( collectComments_ )
-   {
-      lastValueEnd_ = current_;
-      lastValue_ = &currentValue();
-   }
-
-   return successful;
-}
-
-
-void 
-Reader::skipCommentTokens( Token &token )
-{
-   if ( features_.allowComments_ )
-   {
-      do
-      {
-         readToken( token );
-      }
-      while ( token.type_ == tokenComment );
-   }
-   else
-   {
-      readToken( token );
-   }
-}
-
-
-bool 
-Reader::expectToken( TokenType type, Token &token, const char *message )
-{
-   readToken( token );
-   if ( token.type_ != type )
-      return addError( message, token );
-   return true;
-}
-
-
-bool 
-Reader::readToken( Token &token )
-{
-   skipSpaces();
-   token.start_ = current_;
-   Char c = getNextChar();
-   bool ok = true;
-   switch ( c )
-   {
-   case '{':
-      token.type_ = tokenObjectBegin;
-      break;
-   case '}':
-      token.type_ = tokenObjectEnd;
-      break;
-   case '[':
-      token.type_ = tokenArrayBegin;
-      break;
-   case ']':
-      token.type_ = tokenArrayEnd;
-      break;
-   case '"':
-      token.type_ = tokenString;
-      ok = readString();
-      break;
-   case '/':
-      token.type_ = tokenComment;
-      ok = readComment();
-      break;
-   case '0':
-   case '1':
-   case '2':
-   case '3':
-   case '4':
-   case '5':
-   case '6':
-   case '7':
-   case '8':
-   case '9':
-   case '-':
-      token.type_ = tokenNumber;
-      readNumber();
-      break;
-   case 't':
-      token.type_ = tokenTrue;
-      ok = match( "rue", 3 );
-      break;
-   case 'f':
-      token.type_ = tokenFalse;
-      ok = match( "alse", 4 );
-      break;
-   case 'n':
-      token.type_ = tokenNull;
-      ok = match( "ull", 3 );
-      break;
-   case ',':
-      token.type_ = tokenArraySeparator;
-      break;
-   case ':':
-      token.type_ = tokenMemberSeparator;
-      break;
-   case 0:
-      token.type_ = tokenEndOfStream;
-      break;
-   default:
-      ok = false;
-      break;
-   }
-   if ( !ok )
-      token.type_ = tokenError;
-   token.end_ = current_;
-   return true;
-}
-
-
-void 
-Reader::skipSpaces()
-{
-   while ( current_ != end_ )
-   {
-      Char c = *current_;
-      if ( c == ' '  ||  c == '\t'  ||  c == '\r'  ||  c == '\n' )
-         ++current_;
-      else
-         break;
-   }
-}
-
-
-bool 
-Reader::match( Location pattern, 
-               int patternLength )
-{
-   if ( end_ - current_ < patternLength )
-      return false;
-   int index = patternLength;
-   while ( index-- )
-      if ( current_[index] != pattern[index] )
-         return false;
-   current_ += patternLength;
-   return true;
-}
-
-
-bool
-Reader::readComment()
-{
-   Location commentBegin = current_ - 1;
-   Char c = getNextChar();
-   bool successful = false;
-   if ( c == '*' )
-      successful = readCStyleComment();
-   else if ( c == '/' )
-      successful = readCppStyleComment();
-   if ( !successful )
-      return false;
-
-   if ( collectComments_ )
-   {
-      CommentPlacement placement = commentBefore;
-      if ( lastValueEnd_  &&  !containsNewLine( lastValueEnd_, commentBegin ) )
-      {
-         if ( c != '*'  ||  !containsNewLine( commentBegin, current_ ) )
-            placement = commentAfterOnSameLine;
-      }
-
-      addComment( commentBegin, current_, placement );
-   }
-   return true;
-}
-
-
-void 
-Reader::addComment( Location begin, 
-                    Location end, 
-                    CommentPlacement placement )
-{
-   assert( collectComments_ );
-   if ( placement == commentAfterOnSameLine )
-   {
-      assert( lastValue_ != 0 );
-      lastValue_->setComment( std::string( begin, end ), placement );
-   }
-   else
-   {
-      if ( !commentsBefore_.empty() )
-         commentsBefore_ += "\n";
-      commentsBefore_ += std::string( begin, end );
-   }
-}
-
-
-bool 
-Reader::readCStyleComment()
-{
-   while ( current_ != end_ )
-   {
-      Char c = getNextChar();
-      if ( c == '*'  &&  *current_ == '/' )
-         break;
-   }
-   return getNextChar() == '/';
-}
-
-
-bool 
-Reader::readCppStyleComment()
-{
-   while ( current_ != end_ )
-   {
-      Char c = getNextChar();
-      if (  c == '\r'  ||  c == '\n' )
-         break;
-   }
-   return true;
-}
-
-
-void 
-Reader::readNumber()
-{
-   while ( current_ != end_ )
-   {
-      if ( !(*current_ >= '0'  &&  *current_ <= '9')  &&
-           !in( *current_, '.', 'e', 'E', '+', '-' ) )
-         break;
-      ++current_;
-   }
-}
-
-bool
-Reader::readString()
-{
-   Char c = 0;
-   while ( current_ != end_ )
-   {
-      c = getNextChar();
-      if ( c == '\\' )
-         getNextChar();
-      else if ( c == '"' )
-         break;
-   }
-   return c == '"';
-}
-
-
-bool 
-Reader::readObject( Token &tokenStart )
-{
-   Token tokenName;
-   std::string name;
-   currentValue() = Value( objectValue );
-   while ( readToken( tokenName ) )
-   {
-      bool initialTokenOk = true;
-      while ( tokenName.type_ == tokenComment  &&  initialTokenOk )
-         initialTokenOk = readToken( tokenName );
-      if  ( !initialTokenOk )
-         break;
-      if ( tokenName.type_ == tokenObjectEnd  &&  name.empty() )  // empty object
-         return true;
-      if ( tokenName.type_ != tokenString )
-         break;
-      
-      name = "";
-      if ( !decodeString( tokenName, name ) )
-         return recoverFromError( tokenObjectEnd );
-
-      Token colon;
-      if ( !readToken( colon ) ||  colon.type_ != tokenMemberSeparator )
-      {
-         return addErrorAndRecover( "Missing ':' after object member name", 
-                                    colon, 
-                                    tokenObjectEnd );
-      }
-      Value &value = currentValue()[ name ];
-      nodes_.push( &value );
-      bool ok = readValue();
-      nodes_.pop();
-      if ( !ok ) // error already set
-         return recoverFromError( tokenObjectEnd );
-
-      Token comma;
-      if ( !readToken( comma )
-            ||  ( comma.type_ != tokenObjectEnd  &&  
-                  comma.type_ != tokenArraySeparator &&
-		  comma.type_ != tokenComment ) )
-      {
-         return addErrorAndRecover( "Missing ',' or '}' in object declaration", 
-                                    comma, 
-                                    tokenObjectEnd );
-      }
-      bool finalizeTokenOk = true;
-      while ( comma.type_ == tokenComment &&
-              finalizeTokenOk )
-         finalizeTokenOk = readToken( comma );
-      if ( comma.type_ == tokenObjectEnd )
-         return true;
-   }
-   return addErrorAndRecover( "Missing '}' or object member name", 
-                              tokenName, 
-                              tokenObjectEnd );
-}
-
-
-bool 
-Reader::readArray( Token &tokenStart )
-{
-   currentValue() = Value( arrayValue );
-   skipSpaces();
-   if ( *current_ == ']' ) // empty array
-   {
-      Token endArray;
-      readToken( endArray );
-      return true;
-   }
-   int index = 0;
-   while ( true )
-   {
-      Value &value = currentValue()[ index++ ];
-      nodes_.push( &value );
-      bool ok = readValue();
-      nodes_.pop();
-      if ( !ok ) // error already set
-         return recoverFromError( tokenArrayEnd );
-
-      Token token;
-      // Accept Comment after last item in the array.
-      ok = readToken( token );
-      while ( token.type_ == tokenComment  &&  ok )
-      {
-         ok = readToken( token );
-      }
-      bool badTokenType = ( token.type_ == tokenArraySeparator  &&  
-                            token.type_ == tokenArrayEnd );
-      if ( !ok  ||  badTokenType )
-      {
-         return addErrorAndRecover( "Missing ',' or ']' in array declaration", 
-                                    token, 
-                                    tokenArrayEnd );
-      }
-      if ( token.type_ == tokenArrayEnd )
-         break;
-   }
-   return true;
-}
-
-
-bool 
-Reader::decodeNumber( Token &token )
-{
-   bool isDouble = false;
-   for ( Location inspect = token.start_; inspect != token.end_; ++inspect )
-   {
-      isDouble = isDouble  
-                 ||  in( *inspect, '.', 'e', 'E', '+' )  
-                 ||  ( *inspect == '-'  &&  inspect != token.start_ );
-   }
-   if ( isDouble )
-      return decodeDouble( token );
-   // Attempts to parse the number as an integer. If the number is
-   // larger than the maximum supported value of an integer then
-   // we decode the number as a double.
-   Location current = token.start_;
-   bool isNegative = *current == '-';
-   if ( isNegative )
-      ++current;
-   Value::UInt maxIntegerValue = isNegative ? Value::UInt(-Value::minInt) 
-                                            : Value::maxUInt;
-   Value::UInt threshold = maxIntegerValue / 10;
-   Value::UInt lastDigitThreshold = maxIntegerValue % 10;
-   assert( lastDigitThreshold >=0  &&  lastDigitThreshold <= 9 );
-   Value::UInt value = 0;
-   while ( current < token.end_ )
-   {
-      Char c = *current++;
-      if ( c < '0'  ||  c > '9' )
-         return addError( "'" + std::string( token.start_, token.end_ ) + "' is not a number.", token );
-      Value::UInt digit(c - '0');
-      if ( value >= threshold )
-      {
-         // If the current digit is not the last one, or if it is
-         // greater than the last digit of the maximum integer value,
-         // the parse the number as a double.
-         if ( current != token.end_  ||  digit > lastDigitThreshold )
-         {
-            return decodeDouble( token );
-         }
-      }
-      value = value * 10 + digit;
-   }
-   if ( isNegative )
-      currentValue() = -Value::Int( value );
-   else if ( value <= Value::UInt(Value::maxInt) )
-      currentValue() = Value::Int( value );
-   else
-      currentValue() = value;
-   return true;
-}
-
-
-bool 
-Reader::decodeDouble( Token &token )
-{
-   double value = 0;
-   const int bufferSize = 32;
-   int count;
-   int length = int(token.end_ - token.start_);
-   if ( length <= bufferSize )
-   {
-      Char buffer[bufferSize];
-      memcpy( buffer, token.start_, length );
-      buffer[length] = 0;
-      count = sscanf( buffer, "%lf", &value );
-   }
-   else
-   {
-      std::string buffer( token.start_, token.end_ );
-      count = sscanf( buffer.c_str(), "%lf", &value );
-   }
-
-   if ( count != 1 )
-      return addError( "'" + std::string( token.start_, token.end_ ) + "' is not a number.", token );
-   currentValue() = value;
-   return true;
-}
-
-
-bool 
-Reader::decodeString( Token &token )
-{
-   std::string decoded;
-   if ( !decodeString( token, decoded ) )
-      return false;
-   currentValue() = decoded;
-   return true;
-}
-
-
-bool 
-Reader::decodeString( Token &token, std::string &decoded )
-{
-   decoded.reserve( token.end_ - token.start_ - 2 );
-   Location current = token.start_ + 1; // skip '"'
-   Location end = token.end_ - 1;      // do not include '"'
-   while ( current != end )
-   {
-      Char c = *current++;
-      if ( c == '"' )
-         break;
-      else if ( c == '\\' )
-      {
-         if ( current == end )
-            return addError( "Empty escape sequence in string", token, current );
-         Char escape = *current++;
-         switch ( escape )
-         {
-         case '"': decoded += '"'; break;
-         case '/': decoded += '/'; break;
-         case '\\': decoded += '\\'; break;
-         case 'b': decoded += '\b'; break;
-         case 'f': decoded += '\f'; break;
-         case 'n': decoded += '\n'; break;
-         case 'r': decoded += '\r'; break;
-         case 't': decoded += '\t'; break;
-         case 'u':
-            {
-               unsigned int unicode;
-               if ( !decodeUnicodeCodePoint( token, current, end, unicode ) )
-                  return false;
-               decoded += codePointToUTF8(unicode);
-            }
-            break;
-         default:
-            return addError( "Bad escape sequence in string", token, current );
-         }
-      }
-      else
-      {
-         decoded += c;
-      }
-   }
-   return true;
-}
-
-bool
-Reader::decodeUnicodeCodePoint( Token &token, 
-                                     Location &current, 
-                                     Location end, 
-                                     unsigned int &unicode )
-{
-
-   if ( !decodeUnicodeEscapeSequence( token, current, end, unicode ) )
-      return false;
-   if (unicode >= 0xD800 && unicode <= 0xDBFF)
-   {
-      // surrogate pairs
-      if (end - current < 6)
-         return addError( "additional six characters expected to parse unicode surrogate pair.", token, current );
-      unsigned int surrogatePair;
-      if (*(current++) == '\\' && *(current++)== 'u')
-      {
-         if (decodeUnicodeEscapeSequence( token, current, end, surrogatePair ))
-         {
-            unicode = 0x10000 + ((unicode & 0x3FF) << 10) + (surrogatePair & 0x3FF);
-         } 
-         else
-            return false;
-      } 
-      else
-         return addError( "expecting another \\u token to begin the second half of a unicode surrogate pair", token, current );
-   }
-   return true;
-}
-
-bool 
-Reader::decodeUnicodeEscapeSequence( Token &token, 
-                                     Location &current, 
-                                     Location end, 
-                                     unsigned int &unicode )
-{
-   if ( end - current < 4 )
-      return addError( "Bad unicode escape sequence in string: four digits expected.", token, current );
-   unicode = 0;
-   for ( int index =0; index < 4; ++index )
-   {
-      Char c = *current++;
-      unicode *= 16;
-      if ( c >= '0'  &&  c <= '9' )
-         unicode += c - '0';
-      else if ( c >= 'a'  &&  c <= 'f' )
-         unicode += c - 'a' + 10;
-      else if ( c >= 'A'  &&  c <= 'F' )
-         unicode += c - 'A' + 10;
-      else
-         return addError( "Bad unicode escape sequence in string: hexadecimal digit expected.", token, current );
-   }
-   return true;
-}
-
-
-bool 
-Reader::addError( const std::string &message, 
-                  Token &token,
-                  Location extra )
-{
-   ErrorInfo info;
-   info.token_ = token;
-   info.message_ = message;
-   info.extra_ = extra;
-   errors_.push_back( info );
-   return false;
-}
-
-
-bool 
-Reader::recoverFromError( TokenType skipUntilToken )
-{
-   int errorCount = int(errors_.size());
-   Token skip;
-   while ( true )
-   {
-      if ( !readToken(skip) )
-         errors_.resize( errorCount ); // discard errors caused by recovery
-      if ( skip.type_ == skipUntilToken  ||  skip.type_ == tokenEndOfStream )
-         break;
-   }
-   errors_.resize( errorCount );
-   return false;
-}
-
-
-bool 
-Reader::addErrorAndRecover( const std::string &message, 
-                            Token &token,
-                            TokenType skipUntilToken )
-{
-   addError( message, token );
-   return recoverFromError( skipUntilToken );
-}
-
-
-Value &
-Reader::currentValue()
-{
-   return *(nodes_.top());
-}
-
-
-Reader::Char 
-Reader::getNextChar()
-{
-   if ( current_ == end_ )
-      return 0;
-   return *current_++;
-}
-
-
-void 
-Reader::getLocationLineAndColumn( Location location,
-                                  int &line,
-                                  int &column ) const
-{
-   Location current = begin_;
-   Location lastLineStart = current;
-   line = 0;
-   while ( current < location  &&  current != end_ )
-   {
-      Char c = *current++;
-      if ( c == '\r' )
-      {
-         if ( *current == '\n' )
-            ++current;
-         lastLineStart = current;
-         ++line;
-      }
-      else if ( c == '\n' )
-      {
-         lastLineStart = current;
-         ++line;
-      }
-   }
-   // column & line start at 1
-   column = int(location - lastLineStart) + 1;
-   ++line;
-}
-
-
-std::string
-Reader::getLocationLineAndColumn( Location location ) const
-{
-   int line, column;
-   getLocationLineAndColumn( location, line, column );
-   char buffer[18+16+16+1];
-   sprintf( buffer, "Line %d, Column %d", line, column );
-   return buffer;
-}
-
-
-std::string 
-Reader::getFormatedErrorMessages() const
-{
-   std::string formattedMessage;
-   for ( Errors::const_iterator itError = errors_.begin();
-         itError != errors_.end();
-         ++itError )
-   {
-      const ErrorInfo &error = *itError;
-      formattedMessage += "* " + getLocationLineAndColumn( error.token_.start_ ) + "\n";
-      formattedMessage += "  " + error.message_ + "\n";
-      if ( error.extra_ )
-         formattedMessage += "See " + getLocationLineAndColumn( error.extra_ ) + " for detail.\n";
-   }
-   return formattedMessage;
-}
-
-
-std::istream& operator>>( std::istream &sin, Value &root )
-{
-    Json::Reader reader;
-    bool ok = reader.parse(sin, root, true);
-    //JSON_ASSERT( ok );
-    if (!ok) throw std::runtime_error(reader.getFormatedErrorMessages());
-    return sin;
-}
-
-
-} // namespace Json
diff --git a/bamtools/src/third_party/jsoncpp/json_reader.h b/bamtools/src/third_party/jsoncpp/json_reader.h
deleted file mode 100644
index 4caa102..0000000
--- a/bamtools/src/third_party/jsoncpp/json_reader.h
+++ /dev/null
@@ -1,201 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef CPPTL_JSON_READER_H_INCLUDED
-# define CPPTL_JSON_READER_H_INCLUDED
-
-# include "json_features.h"
-# include "json_value.h"
-# include <deque>
-# include <stack>
-# include <string>
-# include <iostream>
-
-namespace Json {
-
-   /** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a Value.
-    *
-    */
-   class JSON_API Reader
-   {
-   public:
-      typedef char Char;
-      typedef const Char *Location;
-
-      /** \brief Constructs a Reader allowing all features
-       * for parsing.
-       */
-      Reader();
-
-      /** \brief Constructs a Reader allowing the specified feature set
-       * for parsing.
-       */
-      Reader( const Features &features );
-
-      /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a> document.
-       * \param document UTF-8 encoded string containing the document to read.
-       * \param root [out] Contains the root value of the document if it was
-       *             successfully parsed.
-       * \param collectComments \c true to collect comment and allow writing them back during
-       *                        serialization, \c false to discard comments.
-       *                        This parameter is ignored if Features::allowComments_
-       *                        is \c false.
-       * \return \c true if the document was successfully parsed, \c false if an error occurred.
-       */
-      bool parse( const std::string &document, 
-                  Value &root,
-                  bool collectComments = true );
-
-      /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a> document.
-       * \param document UTF-8 encoded string containing the document to read.
-       * \param root [out] Contains the root value of the document if it was
-       *             successfully parsed.
-       * \param collectComments \c true to collect comment and allow writing them back during
-       *                        serialization, \c false to discard comments.
-       *                        This parameter is ignored if Features::allowComments_
-       *                        is \c false.
-       * \return \c true if the document was successfully parsed, \c false if an error occurred.
-       */
-      bool parse( const char *beginDoc, const char *endDoc, 
-                  Value &root,
-                  bool collectComments = true );
-
-      /// \brief Parse from input stream.
-      /// \see Json::operator>>(std::istream&, Json::Value&).
-      bool parse( std::istream &is,
-                  Value &root,
-                  bool collectComments = true );
-
-      /** \brief Returns a user friendly string that list errors in the parsed document.
-       * \return Formatted error message with the list of errors with their location in 
-       *         the parsed document. An empty string is returned if no error occurred
-       *         during parsing.
-       */
-      std::string getFormatedErrorMessages() const;
-
-   private:
-      enum TokenType
-      {
-         tokenEndOfStream = 0,
-         tokenObjectBegin,
-         tokenObjectEnd,
-         tokenArrayBegin,
-         tokenArrayEnd,
-         tokenString,
-         tokenNumber,
-         tokenTrue,
-         tokenFalse,
-         tokenNull,
-         tokenArraySeparator,
-         tokenMemberSeparator,
-         tokenComment,
-         tokenError
-      };
-
-      class Token
-      {
-      public:
-         TokenType type_;
-         Location start_;
-         Location end_;
-      };
-
-      class ErrorInfo
-      {
-      public:
-         Token token_;
-         std::string message_;
-         Location extra_;
-      };
-
-      typedef std::deque<ErrorInfo> Errors;
-
-      bool expectToken( TokenType type, Token &token, const char *message );
-      bool readToken( Token &token );
-      void skipSpaces();
-      bool match( Location pattern, 
-                  int patternLength );
-      bool readComment();
-      bool readCStyleComment();
-      bool readCppStyleComment();
-      bool readString();
-      void readNumber();
-      bool readValue();
-      bool readObject( Token &token );
-      bool readArray( Token &token );
-      bool decodeNumber( Token &token );
-      bool decodeString( Token &token );
-      bool decodeString( Token &token, std::string &decoded );
-      bool decodeDouble( Token &token );
-      bool decodeUnicodeCodePoint( Token &token, 
-                                   Location &current, 
-                                   Location end, 
-                                   unsigned int &unicode );
-      bool decodeUnicodeEscapeSequence( Token &token, 
-                                        Location &current, 
-                                        Location end, 
-                                        unsigned int &unicode );
-      bool addError( const std::string &message, 
-                     Token &token,
-                     Location extra = 0 );
-      bool recoverFromError( TokenType skipUntilToken );
-      bool addErrorAndRecover( const std::string &message, 
-                               Token &token,
-                               TokenType skipUntilToken );
-      void skipUntilSpace();
-      Value &currentValue();
-      Char getNextChar();
-      void getLocationLineAndColumn( Location location,
-                                     int &line,
-                                     int &column ) const;
-      std::string getLocationLineAndColumn( Location location ) const;
-      void addComment( Location begin, 
-                       Location end, 
-                       CommentPlacement placement );
-      void skipCommentTokens( Token &token );
-   
-      typedef std::stack<Value *> Nodes;
-      Nodes nodes_;
-      Errors errors_;
-      std::string document_;
-      Location begin_;
-      Location end_;
-      Location current_;
-      Location lastValueEnd_;
-      Value *lastValue_;
-      std::string commentsBefore_;
-      Features features_;
-      bool collectComments_;
-   };
-
-   /** \brief Read from 'sin' into 'root'.
-
-    Always keep comments from the input JSON.
-
-    This can be used to read a file into a particular sub-object.
-    For example:
-    \code
-    Json::Value root;
-    cin >> root["dir"]["file"];
-    cout << root;
-    \endcode
-    Result:
-    \verbatim
-    {
-	"dir": {
-	    "file": {
-		// The input stream JSON would be nested here.
-	    }
-	}
-    }
-    \endverbatim
-    \throw std::exception on parse error.
-    \see Json::operator<<()
-   */
-   std::istream& operator>>( std::istream&, Value& );
-
-} // namespace Json
-
-#endif // CPPTL_JSON_READER_H_INCLUDED
diff --git a/bamtools/src/third_party/jsoncpp/json_tool.h b/bamtools/src/third_party/jsoncpp/json_tool.h
deleted file mode 100644
index c20639d..0000000
--- a/bamtools/src/third_party/jsoncpp/json_tool.h
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED
-# define LIB_JSONCPP_JSON_TOOL_H_INCLUDED
-
-/* This header provides common string manipulation support, such as UTF-8,
- * portable conversion from/to string...
- *
- * It is an internal header that must not be exposed.
- */
-
-namespace Json {
-
-/// Converts a unicode code-point to UTF-8.
-static inline std::string 
-codePointToUTF8(unsigned int cp)
-{
-   std::string result;
-   
-   // based on description from http://en.wikipedia.org/wiki/UTF-8
-
-   if (cp <= 0x7f) 
-   {
-      result.resize(1);
-      result[0] = static_cast<char>(cp);
-   } 
-   else if (cp <= 0x7FF) 
-   {
-      result.resize(2);
-      result[1] = static_cast<char>(0x80 | (0x3f & cp));
-      result[0] = static_cast<char>(0xC0 | (0x1f & (cp >> 6)));
-   } 
-   else if (cp <= 0xFFFF) 
-   {
-      result.resize(3);
-      result[2] = static_cast<char>(0x80 | (0x3f & cp));
-      result[1] = 0x80 | static_cast<char>((0x3f & (cp >> 6)));
-      result[0] = 0xE0 | static_cast<char>((0xf & (cp >> 12)));
-   }
-   else if (cp <= 0x10FFFF) 
-   {
-      result.resize(4);
-      result[3] = static_cast<char>(0x80 | (0x3f & cp));
-      result[2] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));
-      result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 12)));
-      result[0] = static_cast<char>(0xF0 | (0x7 & (cp >> 18)));
-   }
-
-   return result;
-}
-
-
-/// Returns true if ch is a control character (in range [0,32[).
-static inline bool 
-isControlCharacter(char ch)
-{
-   return ch > 0 && ch <= 0x1F;
-}
-
-
-enum { 
-   /// Constant that specify the size of the buffer that must be passed to uintToString.
-   uintToStringBufferSize = 3*sizeof(UInt)+1 
-};
-
-// Defines a char buffer for use with uintToString().
-typedef char UIntToStringBuffer[uintToStringBufferSize];
-
-
-/** Converts an unsigned integer to string.
- * @param value Unsigned interger to convert to string
- * @param current Input/Output string buffer. 
- *        Must have at least uintToStringBufferSize chars free.
- */
-static inline void 
-uintToString( UInt value, 
-              char *&current )
-{
-   *--current = 0;
-   do
-   {
-      *--current = char(value % 10) + '0';
-      value /= 10;
-   }
-   while ( value != 0 );
-}
-
-} // namespace Json {
-
-#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED
diff --git a/bamtools/src/third_party/jsoncpp/json_value.cpp b/bamtools/src/third_party/jsoncpp/json_value.cpp
deleted file mode 100644
index 69d0c78..0000000
--- a/bamtools/src/third_party/jsoncpp/json_value.cpp
+++ /dev/null
@@ -1,1701 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#include <iostream>
-#include "json_value.h"
-#include "json_writer.h"
-#include <utility>
-#include <stdexcept>
-#include <cstring>
-#include <cassert>
-#ifdef JSON_USE_CPPTL
-# include <cpptl/conststring.h>
-#endif
-#include <cstddef>    // size_t
-#ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
-# include "json_batchallocator.h"
-#endif // #ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
-
-#define JSON_ASSERT_UNREACHABLE assert( false )
-#define JSON_ASSERT( condition ) assert( condition );  // @todo <= change this into an exception throw
-#define JSON_ASSERT_MESSAGE( condition, message ) if (!( condition )) throw std::runtime_error( message );
-
-namespace Json {
-
-const Value Value::null;
-const Int Value::minInt = Int( ~(UInt(-1)/2) );
-const Int Value::maxInt = Int( UInt(-1)/2 );
-const UInt Value::maxUInt = UInt(-1);
-
-/// Unknown size marker
-enum { unknown = (unsigned)-1 };
-
-
-/** Duplicates the specified string value.
- * @param value Pointer to the string to duplicate. Must be zero-terminated if
- *              length is "unknown".
- * @param length Length of the value. if equals to unknown, then it will be
- *               computed using strlen(value).
- * @return Pointer on the duplicate instance of string.
- */
-static inline char *
-duplicateStringValue( const char *value, 
-                      unsigned int length = unknown )
-{
-   if ( length == unknown )
-      length = (unsigned int)strlen(value);
-   char *newString = static_cast<char *>( malloc( length + 1 ) );
-   memcpy( newString, value, length );
-   newString[length] = 0;
-   return newString;
-}
-
-
-/** Free the string duplicated by duplicateStringValue().
- */
-static inline void 
-releaseStringValue( char *value )
-{
-   if ( value )
-      free( value );
-}
-
-
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// ValueInternals...
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
-# include "json_internalarray.inl"
-# include "json_internalmap.inl"
-#endif // JSON_VALUE_USE_INTERNAL_MAP
-
-# include "json_valueiterator.inl"
-
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// class Value::CommentInfo
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-
-
-Value::CommentInfo::CommentInfo()
-   : comment_( 0 )
-{
-}
-
-Value::CommentInfo::~CommentInfo()
-{
-   if ( comment_ )
-      releaseStringValue( comment_ );
-}
-
-
-void 
-Value::CommentInfo::setComment( const char *text )
-{
-   if ( comment_ )
-      releaseStringValue( comment_ );
-   JSON_ASSERT( text );
-   JSON_ASSERT_MESSAGE( text[0]=='\0' || text[0]=='/', "Comments must start with /");
-   // It seems that /**/ style comments are acceptable as well.
-   comment_ = duplicateStringValue( text );
-}
-
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// class Value::CZString
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-# ifndef JSON_VALUE_USE_INTERNAL_MAP
-
-// Notes: index_ indicates if the string was allocated when
-// a string is stored.
-
-Value::CZString::CZString( ArrayIndex index )
-   : cstr_( 0 )
-   , index_( index )
-{
-}
-
-Value::CZString::CZString( const char *cstr, DuplicationPolicy allocate )
-   : cstr_( allocate == duplicate ? duplicateStringValue(cstr) 
-                                  : cstr )
-   , index_( allocate )
-{
-}
-
-Value::CZString::CZString( const CZString &other )
-: cstr_( other.index_ != noDuplication &&  other.cstr_ != 0
-                ?  duplicateStringValue( other.cstr_ )
-                : other.cstr_ )
-   , index_( other.cstr_ ? (other.index_ == noDuplication ? noDuplication : duplicate)
-                         : other.index_ )
-{
-}
-
-Value::CZString::~CZString()
-{
-   if ( cstr_  &&  index_ == duplicate )
-      releaseStringValue( const_cast<char *>( cstr_ ) );
-}
-
-void 
-Value::CZString::swap( CZString &other )
-{
-   std::swap( cstr_, other.cstr_ );
-   std::swap( index_, other.index_ );
-}
-
-Value::CZString &
-Value::CZString::operator =( const CZString &other )
-{
-   CZString temp( other );
-   swap( temp );
-   return *this;
-}
-
-bool 
-Value::CZString::operator<( const CZString &other ) const 
-{
-   if ( cstr_ )
-      return strcmp( cstr_, other.cstr_ ) < 0;
-   return index_ < other.index_;
-}
-
-bool 
-Value::CZString::operator==( const CZString &other ) const 
-{
-   if ( cstr_ )
-      return strcmp( cstr_, other.cstr_ ) == 0;
-   return index_ == other.index_;
-}
-
-
-ArrayIndex 
-Value::CZString::index() const
-{
-   return index_;
-}
-
-
-const char *
-Value::CZString::c_str() const
-{
-   return cstr_;
-}
-
-bool 
-Value::CZString::isStaticString() const
-{
-   return index_ == noDuplication;
-}
-
-#endif // ifndef JSON_VALUE_USE_INTERNAL_MAP
-
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// class Value::Value
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-
-/*! \internal Default constructor initialization must be equivalent to:
- * memset( this, 0, sizeof(Value) )
- * This optimization is used in ValueInternalMap fast allocator.
- */
-Value::Value( ValueType type )
-   : type_( type )
-   , allocated_( 0 )
-   , comments_( 0 )
-# ifdef JSON_VALUE_USE_INTERNAL_MAP
-   , itemIsUsed_( 0 )
-#endif
-{
-   switch ( type )
-   {
-   case nullValue:
-      break;
-   case intValue:
-   case uintValue:
-      value_.int_ = 0;
-      break;
-   case realValue:
-      value_.real_ = 0.0;
-      break;
-   case stringValue:
-      value_.string_ = 0;
-      break;
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-   case arrayValue:
-   case objectValue:
-      value_.map_ = new ObjectValues();
-      break;
-#else
-   case arrayValue:
-      value_.array_ = arrayAllocator()->newArray();
-      break;
-   case objectValue:
-      value_.map_ = mapAllocator()->newMap();
-      break;
-#endif
-   case booleanValue:
-      value_.bool_ = false;
-      break;
-   default:
-      JSON_ASSERT_UNREACHABLE;
-   }
-}
-
-
-#if !defined(JSON_NO_INT64)
-Value::Value( ArrayIndex value )
-   : type_( uintValue )
-   , comments_( 0 )
-# ifdef JSON_VALUE_USE_INTERNAL_MAP
-   , itemIsUsed_( 0 )
-#endif
-{
-   value_.uint_ = value;
-}
-
-Value::Value( int value )
-   : type_( intValue )
-   , comments_( 0 )
-# ifdef JSON_VALUE_USE_INTERNAL_MAP
-   , itemIsUsed_( 0 )
-#endif
-{
-   value_.int_ = value;
-}
-
-#endif // if !defined(JSON_NO_INT64)
-
-
-Value::Value( Int value )
-   : type_( intValue )
-   , comments_( 0 )
-# ifdef JSON_VALUE_USE_INTERNAL_MAP
-   , itemIsUsed_( 0 )
-#endif
-{
-   value_.int_ = value;
-}
-
-
-Value::Value( UInt value )
-   : type_( uintValue )
-   , comments_( 0 )
-# ifdef JSON_VALUE_USE_INTERNAL_MAP
-   , itemIsUsed_( 0 )
-#endif
-{
-   value_.uint_ = value;
-}
-
-Value::Value( double value )
-   : type_( realValue )
-   , comments_( 0 )
-# ifdef JSON_VALUE_USE_INTERNAL_MAP
-   , itemIsUsed_( 0 )
-#endif
-{
-   value_.real_ = value;
-}
-
-Value::Value( const char *value )
-   : type_( stringValue )
-   , allocated_( true )
-   , comments_( 0 )
-# ifdef JSON_VALUE_USE_INTERNAL_MAP
-   , itemIsUsed_( 0 )
-#endif
-{
-   value_.string_ = duplicateStringValue( value );
-}
-
-
-Value::Value( const char *beginValue, 
-              const char *endValue )
-   : type_( stringValue )
-   , allocated_( true )
-   , comments_( 0 )
-# ifdef JSON_VALUE_USE_INTERNAL_MAP
-   , itemIsUsed_( 0 )
-#endif
-{
-   value_.string_ = duplicateStringValue( beginValue, 
-                                          (unsigned int)(endValue - beginValue) );
-}
-
-
-Value::Value( const std::string &value )
-   : type_( stringValue )
-   , allocated_( true )
-   , comments_( 0 )
-# ifdef JSON_VALUE_USE_INTERNAL_MAP
-   , itemIsUsed_( 0 )
-#endif
-{
-   value_.string_ = duplicateStringValue( value.c_str(), 
-                                          (unsigned int)value.length() );
-
-}
-
-Value::Value( const StaticString &value )
-   : type_( stringValue )
-   , allocated_( false )
-   , comments_( 0 )
-# ifdef JSON_VALUE_USE_INTERNAL_MAP
-   , itemIsUsed_( 0 )
-#endif
-{
-   value_.string_ = const_cast<char *>( value.c_str() );
-}
-
-
-# ifdef JSON_USE_CPPTL
-Value::Value( const CppTL::ConstString &value )
-   : type_( stringValue )
-   , allocated_( true )
-   , comments_( 0 )
-# ifdef JSON_VALUE_USE_INTERNAL_MAP
-   , itemIsUsed_( 0 )
-#endif
-{
-   value_.string_ = duplicateStringValue( value, value.length() );
-}
-# endif
-
-Value::Value( bool value )
-   : type_( booleanValue )
-   , comments_( 0 )
-# ifdef JSON_VALUE_USE_INTERNAL_MAP
-   , itemIsUsed_( 0 )
-#endif
-{
-   value_.bool_ = value;
-}
-
-
-Value::Value( const Value &other )
-   : type_( other.type_ )
-   , comments_( 0 )
-# ifdef JSON_VALUE_USE_INTERNAL_MAP
-   , itemIsUsed_( 0 )
-#endif
-{
-   switch ( type_ )
-   {
-   case nullValue:
-   case intValue:
-   case uintValue:
-   case realValue:
-   case booleanValue:
-      value_ = other.value_;
-      break;
-   case stringValue:
-      if ( other.value_.string_ )
-      {
-         value_.string_ = duplicateStringValue( other.value_.string_ );
-         allocated_ = true;
-      }
-      else
-         value_.string_ = 0;
-      break;
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-   case arrayValue:
-   case objectValue:
-      value_.map_ = new ObjectValues( *other.value_.map_ );
-      break;
-#else
-   case arrayValue:
-      value_.array_ = arrayAllocator()->newArrayCopy( *other.value_.array_ );
-      break;
-   case objectValue:
-      value_.map_ = mapAllocator()->newMapCopy( *other.value_.map_ );
-      break;
-#endif
-   default:
-      JSON_ASSERT_UNREACHABLE;
-   }
-   if ( other.comments_ )
-   {
-      comments_ = new CommentInfo[numberOfCommentPlacement];
-      for ( int comment =0; comment < numberOfCommentPlacement; ++comment )
-      {
-         const CommentInfo &otherComment = other.comments_[comment];
-         if ( otherComment.comment_ )
-            comments_[comment].setComment( otherComment.comment_ );
-      }
-   }
-}
-
-
-Value::~Value()
-{
-   switch ( type_ )
-   {
-   case nullValue:
-   case intValue:
-   case uintValue:
-   case realValue:
-   case booleanValue:
-      break;
-   case stringValue:
-      if ( allocated_ )
-         releaseStringValue( value_.string_ );
-      break;
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-   case arrayValue:
-   case objectValue:
-      delete value_.map_;
-      break;
-#else
-   case arrayValue:
-      arrayAllocator()->destructArray( value_.array_ );
-      break;
-   case objectValue:
-      mapAllocator()->destructMap( value_.map_ );
-      break;
-#endif
-   default:
-      JSON_ASSERT_UNREACHABLE;
-   }
-
-   if ( comments_ )
-      delete[] comments_;
-}
-
-Value &
-Value::operator=( const Value &other )
-{
-   Value temp( other );
-   swap( temp );
-   return *this;
-}
-
-void 
-Value::swap( Value &other )
-{
-   ValueType temp = type_;
-   type_ = other.type_;
-   other.type_ = temp;
-   std::swap( value_, other.value_ );
-   int temp2 = allocated_;
-   allocated_ = other.allocated_;
-   other.allocated_ = temp2;
-}
-
-ValueType 
-Value::type() const
-{
-   return type_;
-}
-
-
-int 
-Value::compare( const Value &other )
-{
-   /*
-   int typeDelta = other.type_ - type_;
-   switch ( type_ )
-   {
-   case nullValue:
-
-      return other.type_ == type_;
-   case intValue:
-      if ( other.type_.isNumeric()
-   case uintValue:
-   case realValue:
-   case booleanValue:
-      break;
-   case stringValue,
-      break;
-   case arrayValue:
-      delete value_.array_;
-      break;
-   case objectValue:
-      delete value_.map_;
-   default:
-      JSON_ASSERT_UNREACHABLE;
-   }
-   */
-   return 0;  // unreachable
-}
-
-bool 
-Value::operator <( const Value &other ) const
-{
-   int typeDelta = type_ - other.type_;
-   if ( typeDelta )
-      return typeDelta < 0 ? true : false;
-   switch ( type_ )
-   {
-   case nullValue:
-      return false;
-   case intValue:
-      return value_.int_ < other.value_.int_;
-   case uintValue:
-      return value_.uint_ < other.value_.uint_;
-   case realValue:
-      return value_.real_ < other.value_.real_;
-   case booleanValue:
-      return value_.bool_ < other.value_.bool_;
-   case stringValue:
-      return ( value_.string_ == 0  &&  other.value_.string_ )
-             || ( other.value_.string_  
-                  &&  value_.string_  
-                  && strcmp( value_.string_, other.value_.string_ ) < 0 );
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-   case arrayValue:
-   case objectValue:
-      {
-         int delta = int( value_.map_->size() - other.value_.map_->size() );
-         if ( delta )
-            return delta < 0;
-         return (*value_.map_) < (*other.value_.map_);
-      }
-#else
-   case arrayValue:
-      return value_.array_->compare( *(other.value_.array_) ) < 0;
-   case objectValue:
-      return value_.map_->compare( *(other.value_.map_) ) < 0;
-#endif
-   default:
-      JSON_ASSERT_UNREACHABLE;
-   }
-   return 0;  // unreachable
-}
-
-bool 
-Value::operator <=( const Value &other ) const
-{
-   return !(other > *this);
-}
-
-bool 
-Value::operator >=( const Value &other ) const
-{
-   return !(*this < other);
-}
-
-bool 
-Value::operator >( const Value &other ) const
-{
-   return other < *this;
-}
-
-bool 
-Value::operator ==( const Value &other ) const
-{
-   //if ( type_ != other.type_ )
-   // GCC 2.95.3 says:
-   // attempt to take address of bit-field structure member `Json::Value::type_'
-   // Beats me, but a temp solves the problem.
-   int temp = other.type_;
-   if ( type_ != temp )
-      return false;
-   switch ( type_ )
-   {
-   case nullValue:
-      return true;
-   case intValue:
-      return value_.int_ == other.value_.int_;
-   case uintValue:
-      return value_.uint_ == other.value_.uint_;
-   case realValue:
-      return value_.real_ == other.value_.real_;
-   case booleanValue:
-      return value_.bool_ == other.value_.bool_;
-   case stringValue:
-      return ( value_.string_ == other.value_.string_ )
-             || ( other.value_.string_  
-                  &&  value_.string_  
-                  && strcmp( value_.string_, other.value_.string_ ) == 0 );
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-   case arrayValue:
-   case objectValue:
-      return value_.map_->size() == other.value_.map_->size()
-             && (*value_.map_) == (*other.value_.map_);
-#else
-   case arrayValue:
-      return value_.array_->compare( *(other.value_.array_) ) == 0;
-   case objectValue:
-      return value_.map_->compare( *(other.value_.map_) ) == 0;
-#endif
-   default:
-      JSON_ASSERT_UNREACHABLE;
-   }
-   return 0;  // unreachable
-}
-
-bool 
-Value::operator !=( const Value &other ) const
-{
-   return !( *this == other );
-}
-
-const char *
-Value::asCString() const
-{
-   JSON_ASSERT( type_ == stringValue );
-   return value_.string_;
-}
-
-
-std::string 
-Value::asString() const
-{
-   switch ( type_ )
-   {
-   case nullValue:
-      return "";
-   case stringValue:
-      return value_.string_ ? value_.string_ : "";
-   case booleanValue:
-      return value_.bool_ ? "true" : "false";
-   case intValue:
-   case uintValue:
-   case realValue:
-   case arrayValue:
-   case objectValue:
-      JSON_ASSERT_MESSAGE( false, "Type is not convertible to string" );
-   default:
-      JSON_ASSERT_UNREACHABLE;
-   }
-   return ""; // unreachable
-}
-
-# ifdef JSON_USE_CPPTL
-CppTL::ConstString 
-Value::asConstString() const
-{
-   return CppTL::ConstString( asString().c_str() );
-}
-# endif
-
-Value::Int 
-Value::asInt() const
-{
-   switch ( type_ )
-   {
-   case nullValue:
-      return 0;
-   case intValue:
-      return value_.int_;
-   case uintValue:
-      JSON_ASSERT_MESSAGE( value_.uint_ < (unsigned)maxInt, "integer out of signed integer range" );
-      return value_.uint_;
-   case realValue:
-      JSON_ASSERT_MESSAGE( value_.real_ >= minInt  &&  value_.real_ <= maxInt, "Real out of signed integer range" );
-      return Int( value_.real_ );
-   case booleanValue:
-      return value_.bool_ ? 1 : 0;
-   case stringValue:
-   case arrayValue:
-   case objectValue:
-      JSON_ASSERT_MESSAGE( false, "Type is not convertible to int" );
-   default:
-      JSON_ASSERT_UNREACHABLE;
-   }
-   return 0; // unreachable;
-}
-
-Value::UInt 
-Value::asUInt() const
-{
-   switch ( type_ )
-   {
-   case nullValue:
-      return 0;
-   case intValue:
-      JSON_ASSERT_MESSAGE( value_.int_ >= 0, "Negative integer can not be converted to unsigned integer" );
-      return value_.int_;
-   case uintValue:
-      return value_.uint_;
-   case realValue:
-      JSON_ASSERT_MESSAGE( value_.real_ >= 0  &&  value_.real_ <= maxUInt,  "Real out of unsigned integer range" );
-      return UInt( value_.real_ );
-   case booleanValue:
-      return value_.bool_ ? 1 : 0;
-   case stringValue:
-   case arrayValue:
-   case objectValue:
-      JSON_ASSERT_MESSAGE( false, "Type is not convertible to uint" );
-   default:
-      JSON_ASSERT_UNREACHABLE;
-   }
-   return 0; // unreachable;
-}
-
-double 
-Value::asDouble() const
-{
-   switch ( type_ )
-   {
-   case nullValue:
-      return 0.0;
-   case intValue:
-      return static_cast<double>( value_.int_ );
-   case uintValue:
-#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
-      return static_cast<double>( value_.uint_ );
-#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
-      return static_cast<double>( Int(value_.uint_/2) ) * 2 + Int(value_.uint_ & 1);
-#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
-   case realValue:
-      return value_.real_;
-   case booleanValue:
-      return value_.bool_ ? 1.0 : 0.0;
-   case stringValue:
-   case arrayValue:
-   case objectValue:
-      JSON_ASSERT_MESSAGE( false, "Type is not convertible to double" );
-   default:
-      JSON_ASSERT_UNREACHABLE;
-   }
-   return 0; // unreachable;
-}
-
-bool 
-Value::asBool() const
-{
-   switch ( type_ )
-   {
-   case nullValue:
-      return false;
-   case intValue:
-   case uintValue:
-      return value_.int_ != 0;
-   case realValue:
-      return value_.real_ != 0.0;
-   case booleanValue:
-      return value_.bool_;
-   case stringValue:
-      return value_.string_  &&  value_.string_[0] != 0;
-   case arrayValue:
-   case objectValue:
-      return value_.map_->size() != 0;
-   default:
-      JSON_ASSERT_UNREACHABLE;
-   }
-   return false; // unreachable;
-}
-
-
-bool 
-Value::isConvertibleTo( ValueType other ) const
-{
-   switch ( type_ )
-   {
-   case nullValue:
-      return true;
-   case intValue:
-      return ( other == nullValue  &&  value_.int_ == 0 )
-             || other == intValue
-             || ( other == uintValue  && value_.int_ >= 0 )
-             || other == realValue
-             || other == stringValue
-             || other == booleanValue;
-   case uintValue:
-      return ( other == nullValue  &&  value_.uint_ == 0 )
-             || ( other == intValue  && value_.uint_ <= (unsigned)maxInt )
-             || other == uintValue
-             || other == realValue
-             || other == stringValue
-             || other == booleanValue;
-   case realValue:
-      return ( other == nullValue  &&  value_.real_ == 0.0 )
-             || ( other == intValue  &&  value_.real_ >= minInt  &&  value_.real_ <= maxInt )
-             || ( other == uintValue  &&  value_.real_ >= 0  &&  value_.real_ <= maxUInt )
-             || other == realValue
-             || other == stringValue
-             || other == booleanValue;
-   case booleanValue:
-      return ( other == nullValue  &&  value_.bool_ == false )
-             || other == intValue
-             || other == uintValue
-             || other == realValue
-             || other == stringValue
-             || other == booleanValue;
-   case stringValue:
-      return other == stringValue
-             || ( other == nullValue  &&  (!value_.string_  ||  value_.string_[0] == 0) );
-   case arrayValue:
-      return other == arrayValue
-             ||  ( other == nullValue  &&  value_.map_->size() == 0 );
-   case objectValue:
-      return other == objectValue
-             ||  ( other == nullValue  &&  value_.map_->size() == 0 );
-   default:
-      JSON_ASSERT_UNREACHABLE;
-   }
-   return false; // unreachable;
-}
-
-
-/// Number of values in array or object
-ArrayIndex 
-Value::size() const
-{
-   switch ( type_ )
-   {
-   case nullValue:
-   case intValue:
-   case uintValue:
-   case realValue:
-   case booleanValue:
-   case stringValue:
-      return 0;
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-   case arrayValue:  // size of the array is highest index + 1
-      if ( !value_.map_->empty() )
-      {
-         ObjectValues::const_iterator itLast = value_.map_->end();
-         --itLast;
-         return (*itLast).first.index()+1;
-      }
-      return 0;
-   case objectValue:
-      return ArrayIndex( value_.map_->size() );
-#else
-   case arrayValue:
-      return Int( value_.array_->size() );
-   case objectValue:
-      return Int( value_.map_->size() );
-#endif
-   default:
-      JSON_ASSERT_UNREACHABLE;
-   }
-   return 0; // unreachable;
-}
-
-
-bool 
-Value::empty() const
-{
-   if ( isNull() || isArray() || isObject() )
-      return size() == 0u;
-   else
-      return false;
-}
-
-
-bool
-Value::operator!() const
-{
-   return isNull();
-}
-
-
-void 
-Value::clear()
-{
-   JSON_ASSERT( type_ == nullValue  ||  type_ == arrayValue  || type_ == objectValue );
-
-   switch ( type_ )
-   {
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-   case arrayValue:
-   case objectValue:
-      value_.map_->clear();
-      break;
-#else
-   case arrayValue:
-      value_.array_->clear();
-      break;
-   case objectValue:
-      value_.map_->clear();
-      break;
-#endif
-   default:
-      break;
-   }
-}
-
-void 
-Value::resize( ArrayIndex newSize )
-{
-   JSON_ASSERT( type_ == nullValue  ||  type_ == arrayValue );
-   if ( type_ == nullValue )
-      *this = Value( arrayValue );
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-   ArrayIndex oldSize = size();
-   if ( newSize == 0 )
-      clear();
-   else if ( newSize > oldSize )
-      (*this)[ newSize - 1 ];
-   else
-   {
-      for ( ArrayIndex index = newSize; index < oldSize; ++index )
-      {
-         value_.map_->erase( index );
-      }
-      assert( size() == newSize );
-   }
-#else
-   value_.array_->resize( newSize );
-#endif
-}
-
-
-Value &
-Value::operator[]( ArrayIndex index )
-{
-   JSON_ASSERT( type_ == nullValue  ||  type_ == arrayValue );
-   if ( type_ == nullValue )
-      *this = Value( arrayValue );
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-   CZString key( index );
-   ObjectValues::iterator it = value_.map_->lower_bound( key );
-   if ( it != value_.map_->end()  &&  (*it).first == key )
-      return (*it).second;
-
-   ObjectValues::value_type defaultValue( key, null );
-   it = value_.map_->insert( it, defaultValue );
-   return (*it).second;
-#else
-   return value_.array_->resolveReference( index );
-#endif
-}
-
-
-const Value &
-Value::operator[]( ArrayIndex index ) const
-{
-   JSON_ASSERT( type_ == nullValue  ||  type_ == arrayValue );
-   if ( type_ == nullValue )
-      return null;
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-   CZString key( index );
-   ObjectValues::const_iterator it = value_.map_->find( key );
-   if ( it == value_.map_->end() )
-      return null;
-   return (*it).second;
-#else
-   Value *value = value_.array_->find( index );
-   return value ? *value : null;
-#endif
-}
-
-
-Value &
-Value::operator[]( const char *key )
-{
-   return resolveReference( key, false );
-}
-
-
-Value &
-Value::resolveReference( const char *key, 
-                         bool isStatic )
-{
-   JSON_ASSERT( type_ == nullValue  ||  type_ == objectValue );
-   if ( type_ == nullValue )
-      *this = Value( objectValue );
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-   CZString actualKey( key, isStatic ? CZString::noDuplication 
-                                     : CZString::duplicateOnCopy );
-   ObjectValues::iterator it = value_.map_->lower_bound( actualKey );
-   if ( it != value_.map_->end()  &&  (*it).first == actualKey )
-      return (*it).second;
-
-   ObjectValues::value_type defaultValue( actualKey, null );
-   it = value_.map_->insert( it, defaultValue );
-   Value &value = (*it).second;
-   return value;
-#else
-   return value_.map_->resolveReference( key, isStatic );
-#endif
-}
-
-
-Value 
-Value::get( ArrayIndex index, 
-            const Value &defaultValue ) const
-{
-   const Value *value = &((*this)[index]);
-   return value == &null ? defaultValue : *value;
-}
-
-
-bool 
-Value::isValidIndex( ArrayIndex index ) const
-{
-   return index < size();
-}
-
-
-
-const Value &
-Value::operator[]( const char *key ) const
-{
-   JSON_ASSERT( type_ == nullValue  ||  type_ == objectValue );
-   if ( type_ == nullValue )
-      return null;
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-   CZString actualKey( key, CZString::noDuplication );
-   ObjectValues::const_iterator it = value_.map_->find( actualKey );
-   if ( it == value_.map_->end() )
-      return null;
-   return (*it).second;
-#else
-   const Value *value = value_.map_->find( key );
-   return value ? *value : null;
-#endif
-}
-
-
-Value &
-Value::operator[]( const std::string &key )
-{
-   return (*this)[ key.c_str() ];
-}
-
-
-const Value &
-Value::operator[]( const std::string &key ) const
-{
-   return (*this)[ key.c_str() ];
-}
-
-Value &
-Value::operator[]( const StaticString &key )
-{
-   return resolveReference( key, true );
-}
-
-
-# ifdef JSON_USE_CPPTL
-Value &
-Value::operator[]( const CppTL::ConstString &key )
-{
-   return (*this)[ key.c_str() ];
-}
-
-
-const Value &
-Value::operator[]( const CppTL::ConstString &key ) const
-{
-   return (*this)[ key.c_str() ];
-}
-# endif
-
-
-Value &
-Value::append( const Value &value )
-{
-   return (*this)[size()] = value;
-}
-
-
-Value 
-Value::get( const char *key, 
-            const Value &defaultValue ) const
-{
-   const Value *value = &((*this)[key]);
-   return value == &null ? defaultValue : *value;
-}
-
-
-Value 
-Value::get( const std::string &key,
-            const Value &defaultValue ) const
-{
-   return get( key.c_str(), defaultValue );
-}
-
-Value
-Value::removeMember( const char* key )
-{
-   JSON_ASSERT( type_ == nullValue  ||  type_ == objectValue );
-   if ( type_ == nullValue )
-      return null;
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-   CZString actualKey( key, CZString::noDuplication );
-   ObjectValues::iterator it = value_.map_->find( actualKey );
-   if ( it == value_.map_->end() )
-      return null;
-   Value old(it->second);
-   value_.map_->erase(it);
-   return old;
-#else
-   Value *value = value_.map_->find( key );
-   if (value){
-      Value old(*value);
-      value_.map_.remove( key );
-      return old;
-   } else {
-      return null;
-   }
-#endif
-}
-
-Value
-Value::removeMember( const std::string &key )
-{
-   return removeMember( key.c_str() );
-}
-
-# ifdef JSON_USE_CPPTL
-Value 
-Value::get( const CppTL::ConstString &key,
-            const Value &defaultValue ) const
-{
-   return get( key.c_str(), defaultValue );
-}
-# endif
-
-bool 
-Value::isMember( const char *key ) const
-{
-   const Value *value = &((*this)[key]);
-   return value != &null;
-}
-
-
-bool 
-Value::isMember( const std::string &key ) const
-{
-   return isMember( key.c_str() );
-}
-
-
-# ifdef JSON_USE_CPPTL
-bool 
-Value::isMember( const CppTL::ConstString &key ) const
-{
-   return isMember( key.c_str() );
-}
-#endif
-
-Value::Members 
-Value::getMemberNames() const
-{
-   JSON_ASSERT( type_ == nullValue  ||  type_ == objectValue );
-   if ( type_ == nullValue )
-       return Value::Members();
-   Members members;
-   members.reserve( value_.map_->size() );
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-   ObjectValues::const_iterator it = value_.map_->begin();
-   ObjectValues::const_iterator itEnd = value_.map_->end();
-   for ( ; it != itEnd; ++it )
-      members.push_back( std::string( (*it).first.c_str() ) );
-#else
-   ValueInternalMap::IteratorState it;
-   ValueInternalMap::IteratorState itEnd;
-   value_.map_->makeBeginIterator( it );
-   value_.map_->makeEndIterator( itEnd );
-   for ( ; !ValueInternalMap::equals( it, itEnd ); ValueInternalMap::increment(it) )
-      members.push_back( std::string( ValueInternalMap::key( it ) ) );
-#endif
-   return members;
-}
-//
-//# ifdef JSON_USE_CPPTL
-//EnumMemberNames
-//Value::enumMemberNames() const
-//{
-//   if ( type_ == objectValue )
-//   {
-//      return CppTL::Enum::any(  CppTL::Enum::transform(
-//         CppTL::Enum::keys( *(value_.map_), CppTL::Type<const CZString &>() ),
-//         MemberNamesTransform() ) );
-//   }
-//   return EnumMemberNames();
-//}
-//
-//
-//EnumValues 
-//Value::enumValues() const
-//{
-//   if ( type_ == objectValue  ||  type_ == arrayValue )
-//      return CppTL::Enum::anyValues( *(value_.map_), 
-//                                     CppTL::Type<const Value &>() );
-//   return EnumValues();
-//}
-//
-//# endif
-
-
-bool
-Value::isNull() const
-{
-   return type_ == nullValue;
-}
-
-
-bool 
-Value::isBool() const
-{
-   return type_ == booleanValue;
-}
-
-
-bool 
-Value::isInt() const
-{
-   return type_ == intValue;
-}
-
-
-bool 
-Value::isUInt() const
-{
-   return type_ == uintValue;
-}
-
-
-bool 
-Value::isIntegral() const
-{
-   return type_ == intValue  
-          ||  type_ == uintValue  
-          ||  type_ == booleanValue;
-}
-
-
-bool 
-Value::isDouble() const
-{
-   return type_ == realValue;
-}
-
-
-bool 
-Value::isNumeric() const
-{
-   return isIntegral() || isDouble();
-}
-
-
-bool 
-Value::isString() const
-{
-   return type_ == stringValue;
-}
-
-
-bool 
-Value::isArray() const
-{
-   return type_ == nullValue  ||  type_ == arrayValue;
-}
-
-
-bool 
-Value::isObject() const
-{
-   return type_ == nullValue  ||  type_ == objectValue;
-}
-
-
-void 
-Value::setComment( const char *comment,
-                   CommentPlacement placement )
-{
-   if ( !comments_ )
-      comments_ = new CommentInfo[numberOfCommentPlacement];
-   comments_[placement].setComment( comment );
-}
-
-
-void 
-Value::setComment( const std::string &comment,
-                   CommentPlacement placement )
-{
-   setComment( comment.c_str(), placement );
-}
-
-
-bool 
-Value::hasComment( CommentPlacement placement ) const
-{
-   return comments_ != 0  &&  comments_[placement].comment_ != 0;
-}
-
-std::string 
-Value::getComment( CommentPlacement placement ) const
-{
-   if ( hasComment(placement) )
-      return comments_[placement].comment_;
-   return "";
-}
-
-
-std::string 
-Value::toStyledString() const
-{
-   StyledWriter writer;
-   return writer.write( *this );
-}
-
-
-Value::const_iterator 
-Value::begin() const
-{
-   switch ( type_ )
-   {
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
-   case arrayValue:
-      if ( value_.array_ )
-      {
-         ValueInternalArray::IteratorState it;
-         value_.array_->makeBeginIterator( it );
-         return const_iterator( it );
-      }
-      break;
-   case objectValue:
-      if ( value_.map_ )
-      {
-         ValueInternalMap::IteratorState it;
-         value_.map_->makeBeginIterator( it );
-         return const_iterator( it );
-      }
-      break;
-#else
-   case arrayValue:
-   case objectValue:
-      if ( value_.map_ )
-         return const_iterator( value_.map_->begin() );
-      break;
-#endif
-   default:
-      break;
-   }
-   return const_iterator();
-}
-
-Value::const_iterator 
-Value::end() const
-{
-   switch ( type_ )
-   {
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
-   case arrayValue:
-      if ( value_.array_ )
-      {
-         ValueInternalArray::IteratorState it;
-         value_.array_->makeEndIterator( it );
-         return const_iterator( it );
-      }
-      break;
-   case objectValue:
-      if ( value_.map_ )
-      {
-         ValueInternalMap::IteratorState it;
-         value_.map_->makeEndIterator( it );
-         return const_iterator( it );
-      }
-      break;
-#else
-   case arrayValue:
-   case objectValue:
-      if ( value_.map_ )
-         return const_iterator( value_.map_->end() );
-      break;
-#endif
-   default:
-      break;
-   }
-   return const_iterator();
-}
-
-
-Value::iterator 
-Value::begin()
-{
-   switch ( type_ )
-   {
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
-   case arrayValue:
-      if ( value_.array_ )
-      {
-         ValueInternalArray::IteratorState it;
-         value_.array_->makeBeginIterator( it );
-         return iterator( it );
-      }
-      break;
-   case objectValue:
-      if ( value_.map_ )
-      {
-         ValueInternalMap::IteratorState it;
-         value_.map_->makeBeginIterator( it );
-         return iterator( it );
-      }
-      break;
-#else
-   case arrayValue:
-   case objectValue:
-      if ( value_.map_ )
-         return iterator( value_.map_->begin() );
-      break;
-#endif
-   default:
-      break;
-   }
-   return iterator();
-}
-
-Value::iterator 
-Value::end()
-{
-   switch ( type_ )
-   {
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
-   case arrayValue:
-      if ( value_.array_ )
-      {
-         ValueInternalArray::IteratorState it;
-         value_.array_->makeEndIterator( it );
-         return iterator( it );
-      }
-      break;
-   case objectValue:
-      if ( value_.map_ )
-      {
-         ValueInternalMap::IteratorState it;
-         value_.map_->makeEndIterator( it );
-         return iterator( it );
-      }
-      break;
-#else
-   case arrayValue:
-   case objectValue:
-      if ( value_.map_ )
-         return iterator( value_.map_->end() );
-      break;
-#endif
-   default:
-      break;
-   }
-   return iterator();
-}
-
-
-// class PathArgument
-// //////////////////////////////////////////////////////////////////
-
-PathArgument::PathArgument()
-   : kind_( kindNone )
-{
-}
-
-
-PathArgument::PathArgument( ArrayIndex index )
-   : index_( index )
-   , kind_( kindIndex )
-{
-}
-
-
-PathArgument::PathArgument( const char *key )
-   : key_( key )
-   , kind_( kindKey )
-{
-}
-
-
-PathArgument::PathArgument( const std::string &key )
-   : key_( key.c_str() )
-   , kind_( kindKey )
-{
-}
-
-// class Path
-// //////////////////////////////////////////////////////////////////
-
-Path::Path( const std::string &path,
-            const PathArgument &a1,
-            const PathArgument &a2,
-            const PathArgument &a3,
-            const PathArgument &a4,
-            const PathArgument &a5 )
-{
-   InArgs in;
-   in.push_back( &a1 );
-   in.push_back( &a2 );
-   in.push_back( &a3 );
-   in.push_back( &a4 );
-   in.push_back( &a5 );
-   makePath( path, in );
-}
-
-
-void 
-Path::makePath( const std::string &path,
-                const InArgs &in )
-{
-   const char *current = path.c_str();
-   const char *end = current + path.length();
-   InArgs::const_iterator itInArg = in.begin();
-   while ( current != end )
-   {
-      if ( *current == '[' )
-      {
-         ++current;
-         if ( *current == '%' )
-            addPathInArg( path, in, itInArg, PathArgument::kindIndex );
-         else
-         {
-            ArrayIndex index = 0;
-            for ( ; current != end && *current >= '0'  &&  *current <= '9'; ++current )
-               index = index * 10 + ArrayIndex(*current - '0');
-            args_.push_back( index );
-         }
-         if ( current == end  ||  *current++ != ']' )
-            invalidPath( path, int(current - path.c_str()) );
-      }
-      else if ( *current == '%' )
-      {
-         addPathInArg( path, in, itInArg, PathArgument::kindKey );
-         ++current;
-      }
-      else if ( *current == '.' )
-      {
-         ++current;
-      }
-      else
-      {
-         const char *beginName = current;
-         while ( current != end  &&  !strchr( "[.", *current ) )
-            ++current;
-         args_.push_back( std::string( beginName, current ) );
-      }
-   }
-}
-
-
-void 
-Path::addPathInArg( const std::string &path, 
-                    const InArgs &in, 
-                    InArgs::const_iterator &itInArg, 
-                    PathArgument::Kind kind )
-{
-   if ( itInArg == in.end() )
-   {
-      // Error: missing argument %d
-   }
-   else if ( (*itInArg)->kind_ != kind )
-   {
-      // Error: bad argument type
-   }
-   else
-   {
-      args_.push_back( **itInArg );
-   }
-}
-
-
-void 
-Path::invalidPath( const std::string &path, 
-                   int location )
-{
-   // Error: invalid path.
-}
-
-
-const Value &
-Path::resolve( const Value &root ) const
-{
-   const Value *node = &root;
-   for ( Args::const_iterator it = args_.begin(); it != args_.end(); ++it )
-   {
-      const PathArgument &arg = *it;
-      if ( arg.kind_ == PathArgument::kindIndex )
-      {
-         if ( !node->isArray()  ||  node->isValidIndex( arg.index_ ) )
-         {
-            // Error: unable to resolve path (array value expected at position...
-         }
-         node = &((*node)[arg.index_]);
-      }
-      else if ( arg.kind_ == PathArgument::kindKey )
-      {
-         if ( !node->isObject() )
-         {
-            // Error: unable to resolve path (object value expected at position...)
-         }
-         node = &((*node)[arg.key_]);
-         if ( node == &Value::null )
-         {
-            // Error: unable to resolve path (object has no member named '' at position...)
-         }
-      }
-   }
-   return *node;
-}
-
-
-Value 
-Path::resolve( const Value &root, 
-               const Value &defaultValue ) const
-{
-   const Value *node = &root;
-   for ( Args::const_iterator it = args_.begin(); it != args_.end(); ++it )
-   {
-      const PathArgument &arg = *it;
-      if ( arg.kind_ == PathArgument::kindIndex )
-      {
-         if ( !node->isArray()  ||  node->isValidIndex( arg.index_ ) )
-            return defaultValue;
-         node = &((*node)[arg.index_]);
-      }
-      else if ( arg.kind_ == PathArgument::kindKey )
-      {
-         if ( !node->isObject() )
-            return defaultValue;
-         node = &((*node)[arg.key_]);
-         if ( node == &Value::null )
-            return defaultValue;
-      }
-   }
-   return *node;
-}
-
-
-Value &
-Path::make( Value &root ) const
-{
-   Value *node = &root;
-   for ( Args::const_iterator it = args_.begin(); it != args_.end(); ++it )
-   {
-      const PathArgument &arg = *it;
-      if ( arg.kind_ == PathArgument::kindIndex )
-      {
-         if ( !node->isArray() )
-         {
-            // Error: node is not an array at position ...
-         }
-         node = &((*node)[arg.index_]);
-      }
-      else if ( arg.kind_ == PathArgument::kindKey )
-      {
-         if ( !node->isObject() )
-         {
-            // Error: node is not an object at position...
-         }
-         node = &((*node)[arg.key_]);
-      }
-   }
-   return *node;
-}
-
-
-} // namespace Json
diff --git a/bamtools/src/third_party/jsoncpp/json_value.h b/bamtools/src/third_party/jsoncpp/json_value.h
deleted file mode 100644
index 5c99471..0000000
--- a/bamtools/src/third_party/jsoncpp/json_value.h
+++ /dev/null
@@ -1,1059 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef CPPTL_JSON_H_INCLUDED
-# define CPPTL_JSON_H_INCLUDED
-
-# include "json_forwards.h"
-# include <string>
-# include <vector>
-
-# ifndef JSON_USE_CPPTL_SMALLMAP
-#  include <map>
-# else
-#  include <cpptl/smallmap.h>
-# endif
-# ifdef JSON_USE_CPPTL
-#  include <cpptl/forwards.h>
-# endif
-
-/** \brief JSON (JavaScript Object Notation).
- */
-namespace Json {
-
-   /** \brief Type of the value held by a Value object.
-    */
-   enum ValueType
-   {
-      nullValue = 0, ///< 'null' value
-      intValue,      ///< signed integer value
-      uintValue,     ///< unsigned integer value
-      realValue,     ///< double value
-      stringValue,   ///< UTF-8 string value
-      booleanValue,  ///< bool value
-      arrayValue,    ///< array value (ordered list)
-      objectValue    ///< object value (collection of name/value pairs).
-   };
-
-   enum CommentPlacement
-   {
-      commentBefore = 0,        ///< a comment placed on the line before a value
-      commentAfterOnSameLine,   ///< a comment just after a value on the same line
-      commentAfter,             ///< a comment on the line after a value (only make sense for root value)
-      numberOfCommentPlacement
-   };
-
-//# ifdef JSON_USE_CPPTL
-//   typedef CppTL::AnyEnumerator<const char *> EnumMemberNames;
-//   typedef CppTL::AnyEnumerator<const Value &> EnumValues;
-//# endif
-
-   /** \brief Lightweight wrapper to tag static string.
-    *
-    * Value constructor and objectValue member assignement takes advantage of the
-    * StaticString and avoid the cost of string duplication when storing the
-    * string or the member name.
-    *
-    * Example of usage:
-    * \code
-    * Json::Value aValue( StaticString("some text") );
-    * Json::Value object;
-    * static const StaticString code("code");
-    * object[code] = 1234;
-    * \endcode
-    */
-   class JSON_API StaticString
-   {
-   public:
-      explicit StaticString( const char *czstring )
-         : str_( czstring )
-      {
-      }
-
-      operator const char *() const
-      {
-         return str_;
-      }
-
-      const char *c_str() const
-      {
-         return str_;
-      }
-
-   private:
-      const char *str_;
-   };
-
-   /** \brief Represents a <a HREF="http://www.json.org">JSON</a> value.
-    *
-    * This class is a discriminated union wrapper that can represents a:
-    * - signed integer [range: Value::minInt - Value::maxInt]
-    * - unsigned integer (range: 0 - Value::maxUInt)
-    * - double
-    * - UTF-8 string
-    * - boolean
-    * - 'null'
-    * - an ordered list of Value
-    * - collection of name/value pairs (javascript object)
-    *
-    * The type of the held value is represented by a #ValueType and 
-    * can be obtained using type().
-    *
-    * values of an #objectValue or #arrayValue can be accessed using operator[]() methods. 
-    * Non const methods will automatically create the a #nullValue element 
-    * if it does not exist. 
-    * The sequence of an #arrayValue will be automatically resize and initialized 
-    * with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.
-    *
-    * The get() methods can be used to obtanis default value in the case the required element
-    * does not exist.
-    *
-    * It is possible to iterate over the list of a #objectValue values using 
-    * the getMemberNames() method.
-    */
-   class JSON_API Value 
-   {
-      friend class ValueIteratorBase;
-# ifdef JSON_VALUE_USE_INTERNAL_MAP
-      friend class ValueInternalLink;
-      friend class ValueInternalMap;
-# endif
-   public:
-      typedef std::vector<std::string> Members;
-      typedef ValueIterator iterator;
-      typedef ValueConstIterator const_iterator;
-      typedef Json::UInt UInt;
-      typedef Json::Int Int;
-      typedef Json::ArrayIndex ArrayIndex;
-
-      static const Value null;
-      static const Int minInt;
-      static const Int maxInt;
-      static const UInt maxUInt;
-
-   private:
-#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
-# ifndef JSON_VALUE_USE_INTERNAL_MAP
-      class CZString 
-      {
-      public:
-         enum DuplicationPolicy 
-         {
-            noDuplication = 0,
-            duplicate,
-            duplicateOnCopy
-         };
-         CZString( ArrayIndex index );
-         CZString( const char *cstr, DuplicationPolicy allocate );
-         CZString( const CZString &other );
-         ~CZString();
-         CZString &operator =( const CZString &other );
-         bool operator<( const CZString &other ) const;
-         bool operator==( const CZString &other ) const;
-         ArrayIndex index() const;
-         const char *c_str() const;
-         bool isStaticString() const;
-      private:
-         void swap( CZString &other );
-         const char *cstr_;
-         ArrayIndex index_;
-      };
-
-   public:
-#  ifndef JSON_USE_CPPTL_SMALLMAP
-      typedef std::map<CZString, Value> ObjectValues;
-#  else
-      typedef CppTL::SmallMap<CZString, Value> ObjectValues;
-#  endif // ifndef JSON_USE_CPPTL_SMALLMAP
-# endif // ifndef JSON_VALUE_USE_INTERNAL_MAP
-#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
-
-   public:
-      /** \brief Create a default Value of the given type.
-
-        This is a very useful constructor.
-        To create an empty array, pass arrayValue.
-        To create an empty object, pass objectValue.
-        Another Value can then be set to this one by assignment.
-	This is useful since clear() and resize() will not alter types.
-
-        Examples:
-	\code
-	Json::Value null_value; // null
-	Json::Value arr_value(Json::arrayValue); // []
-	Json::Value obj_value(Json::objectValue); // {}
-	\endcode
-      */
-      Value( ValueType type = nullValue );
-#if !defined(JSON_NO_INT64)
-      Value( int value );
-      Value( ArrayIndex value );
-#endif // if !defined(JSON_NO_INT64)
-      Value( Int value );
-      Value( UInt value );
-      Value( double value );
-      Value( const char *value );
-      Value( const char *beginValue, const char *endValue );
-      /** \brief Constructs a value from a static string.
-
-       * Like other value string constructor but do not duplicate the string for
-       * internal storage. The given string must remain alive after the call to this
-       * constructor.
-       * Example of usage:
-       * \code
-       * Json::Value aValue( StaticString("some text") );
-       * \endcode
-       */
-      Value( const StaticString &value );
-      Value( const std::string &value );
-# ifdef JSON_USE_CPPTL
-      Value( const CppTL::ConstString &value );
-# endif
-      Value( bool value );
-      Value( const Value &other );
-      ~Value();
-
-      Value &operator=( const Value &other );
-      /// Swap values.
-      /// \note Currently, comments are intentionally not swapped, for
-      /// both logic and efficiency.
-      void swap( Value &other );
-
-      ValueType type() const;
-
-      bool operator <( const Value &other ) const;
-      bool operator <=( const Value &other ) const;
-      bool operator >=( const Value &other ) const;
-      bool operator >( const Value &other ) const;
-
-      bool operator ==( const Value &other ) const;
-      bool operator !=( const Value &other ) const;
-
-      int compare( const Value &other );
-
-      const char *asCString() const;
-      std::string asString() const;
-# ifdef JSON_USE_CPPTL
-      CppTL::ConstString asConstString() const;
-# endif
-      Int asInt() const;
-      UInt asUInt() const;
-      double asDouble() const;
-      bool asBool() const;
-
-      bool isNull() const;
-      bool isBool() const;
-      bool isInt() const;
-      bool isUInt() const;
-      bool isIntegral() const;
-      bool isDouble() const;
-      bool isNumeric() const;
-      bool isString() const;
-      bool isArray() const;
-      bool isObject() const;
-
-      bool isConvertibleTo( ValueType other ) const;
-
-      /// Number of values in array or object
-      ArrayIndex size() const;
-
-      /// \brief Return true if empty array, empty object, or null;
-      /// otherwise, false.
-      bool empty() const;
-
-      /// Return isNull()
-      bool operator!() const;
-
-      /// Remove all object members and array elements.
-      /// \pre type() is arrayValue, objectValue, or nullValue
-      /// \post type() is unchanged
-      void clear();
-
-      /// Resize the array to size elements. 
-      /// New elements are initialized to null.
-      /// May only be called on nullValue or arrayValue.
-      /// \pre type() is arrayValue or nullValue
-      /// \post type() is arrayValue
-      void resize( ArrayIndex size );
-
-      /// Access an array element (zero based index ).
-      /// If the array contains less than index element, then null value are inserted
-      /// in the array so that its size is index+1.
-      /// (You may need to say 'value[0u]' to get your compiler to distinguish
-      ///  this from the operator[] which takes a string.)
-      Value &operator[]( ArrayIndex index );
-      /// Access an array element (zero based index )
-      /// (You may need to say 'value[0u]' to get your compiler to distinguish
-      ///  this from the operator[] which takes a string.)
-      const Value &operator[]( ArrayIndex index ) const;
-      /// If the array contains at least index+1 elements, returns the element value, 
-      /// otherwise returns defaultValue.
-      Value get( ArrayIndex index, 
-                 const Value &defaultValue ) const;
-      /// Return true if index < size().
-      bool isValidIndex( ArrayIndex index ) const;
-      /// \brief Append value to array at the end.
-      ///
-      /// Equivalent to jsonvalue[jsonvalue.size()] = value;
-      Value &append( const Value &value );
-
-      /// Access an object value by name, create a null member if it does not exist.
-      Value &operator[]( const char *key );
-      /// Access an object value by name, returns null if there is no member with that name.
-      const Value &operator[]( const char *key ) const;
-      /// Access an object value by name, create a null member if it does not exist.
-      Value &operator[]( const std::string &key );
-      /// Access an object value by name, returns null if there is no member with that name.
-      const Value &operator[]( const std::string &key ) const;
-      /** \brief Access an object value by name, create a null member if it does not exist.
-
-       * If the object as no entry for that name, then the member name used to store
-       * the new entry is not duplicated.
-       * Example of use:
-       * \code
-       * Json::Value object;
-       * static const StaticString code("code");
-       * object[code] = 1234;
-       * \endcode
-       */
-      Value &operator[]( const StaticString &key );
-# ifdef JSON_USE_CPPTL
-      /// Access an object value by name, create a null member if it does not exist.
-      Value &operator[]( const CppTL::ConstString &key );
-      /// Access an object value by name, returns null if there is no member with that name.
-      const Value &operator[]( const CppTL::ConstString &key ) const;
-# endif
-      /// Return the member named key if it exist, defaultValue otherwise.
-      Value get( const char *key, 
-                 const Value &defaultValue ) const;
-      /// Return the member named key if it exist, defaultValue otherwise.
-      Value get( const std::string &key,
-                 const Value &defaultValue ) const;
-# ifdef JSON_USE_CPPTL
-      /// Return the member named key if it exist, defaultValue otherwise.
-      Value get( const CppTL::ConstString &key,
-                 const Value &defaultValue ) const;
-# endif
-      /// \brief Remove and return the named member.  
-      ///
-      /// Do nothing if it did not exist.
-      /// \return the removed Value, or null.
-      /// \pre type() is objectValue or nullValue
-      /// \post type() is unchanged
-      Value removeMember( const char* key );
-      /// Same as removeMember(const char*)
-      Value removeMember( const std::string &key );
-
-      /// Return true if the object has a member named key.
-      bool isMember( const char *key ) const;
-      /// Return true if the object has a member named key.
-      bool isMember( const std::string &key ) const;
-# ifdef JSON_USE_CPPTL
-      /// Return true if the object has a member named key.
-      bool isMember( const CppTL::ConstString &key ) const;
-# endif
-
-      /// \brief Return a list of the member names.
-      ///
-      /// If null, return an empty list.
-      /// \pre type() is objectValue or nullValue
-      /// \post if type() was nullValue, it remains nullValue
-      Members getMemberNames() const;
-
-//# ifdef JSON_USE_CPPTL
-//      EnumMemberNames enumMemberNames() const;
-//      EnumValues enumValues() const;
-//# endif
-
-      /// Comments must be //... or /* ... */
-      void setComment( const char *comment,
-                       CommentPlacement placement );
-      /// Comments must be //... or /* ... */
-      void setComment( const std::string &comment,
-                       CommentPlacement placement );
-      bool hasComment( CommentPlacement placement ) const;
-      /// Include delimiters and embedded newlines.
-      std::string getComment( CommentPlacement placement ) const;
-
-      std::string toStyledString() const;
-
-      const_iterator begin() const;
-      const_iterator end() const;
-
-      iterator begin();
-      iterator end();
-
-   private:
-      Value &resolveReference( const char *key, 
-                               bool isStatic );
-
-# ifdef JSON_VALUE_USE_INTERNAL_MAP
-      inline bool isItemAvailable() const
-      {
-         return itemIsUsed_ == 0;
-      }
-
-      inline void setItemUsed( bool isUsed = true )
-      {
-         itemIsUsed_ = isUsed ? 1 : 0;
-      }
-
-      inline bool isMemberNameStatic() const
-      {
-         return memberNameIsStatic_ == 0;
-      }
-
-      inline void setMemberNameIsStatic( bool isStatic )
-      {
-         memberNameIsStatic_ = isStatic ? 1 : 0;
-      }
-# endif // # ifdef JSON_VALUE_USE_INTERNAL_MAP
-
-   private:
-      struct CommentInfo
-      {
-         CommentInfo();
-         ~CommentInfo();
-
-         void setComment( const char *text );
-
-         char *comment_;
-      };
-
-      //struct MemberNamesTransform
-      //{
-      //   typedef const char *result_type;
-      //   const char *operator()( const CZString &name ) const
-      //   {
-      //      return name.c_str();
-      //   }
-      //};
-
-      union ValueHolder
-      {
-         Int int_;
-         UInt uint_;
-         double real_;
-         bool bool_;
-         char *string_;
-# ifdef JSON_VALUE_USE_INTERNAL_MAP
-         ValueInternalArray *array_;
-         ValueInternalMap *map_;
-#else
-         ObjectValues *map_;
-# endif
-      } value_;
-      ValueType type_ : 8;
-      int allocated_ : 1;     // Notes: if declared as bool, bitfield is useless.
-# ifdef JSON_VALUE_USE_INTERNAL_MAP
-      unsigned int itemIsUsed_ : 1;      // used by the ValueInternalMap container.
-      int memberNameIsStatic_ : 1;       // used by the ValueInternalMap container.
-# endif
-      CommentInfo *comments_;
-   };
-
-
-   /** \brief Experimental and untested: represents an element of the "path" to access a node.
-    */
-   class PathArgument
-   {
-   public:
-      friend class Path;
-
-      PathArgument();
-      PathArgument( ArrayIndex index );
-      PathArgument( const char *key );
-      PathArgument( const std::string &key );
-
-   private:
-      enum Kind
-      {
-         kindNone = 0,
-         kindIndex,
-         kindKey
-      };
-      std::string key_;
-      ArrayIndex index_;
-      Kind kind_;
-   };
-
-   /** \brief Experimental and untested: represents a "path" to access a node.
-    *
-    * Syntax:
-    * - "." => root node
-    * - ".[n]" => elements at index 'n' of root node (an array value)
-    * - ".name" => member named 'name' of root node (an object value)
-    * - ".name1.name2.name3"
-    * - ".[0][1][2].name1[3]"
-    * - ".%" => member name is provided as parameter
-    * - ".[%]" => index is provied as parameter
-    */
-   class Path
-   {
-   public:
-      Path( const std::string &path,
-            const PathArgument &a1 = PathArgument(),
-            const PathArgument &a2 = PathArgument(),
-            const PathArgument &a3 = PathArgument(),
-            const PathArgument &a4 = PathArgument(),
-            const PathArgument &a5 = PathArgument() );
-
-      const Value &resolve( const Value &root ) const;
-      Value resolve( const Value &root, 
-                     const Value &defaultValue ) const;
-      /// Creates the "path" to access the specified node and returns a reference on the node.
-      Value &make( Value &root ) const;
-
-   private:
-      typedef std::vector<const PathArgument *> InArgs;
-      typedef std::vector<PathArgument> Args;
-
-      void makePath( const std::string &path,
-                     const InArgs &in );
-      void addPathInArg( const std::string &path, 
-                         const InArgs &in, 
-                         InArgs::const_iterator &itInArg, 
-                         PathArgument::Kind kind );
-      void invalidPath( const std::string &path, 
-                        int location );
-
-      Args args_;
-   };
-
-
-
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
-   /** \brief Allocator to customize Value internal map.
-    * Below is an example of a simple implementation (default implementation actually
-    * use memory pool for speed).
-    * \code
-      class DefaultValueMapAllocator : public ValueMapAllocator
-      {
-      public: // overridden from ValueMapAllocator
-         virtual ValueInternalMap *newMap()
-         {
-            return new ValueInternalMap();
-         }
-
-         virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )
-         {
-            return new ValueInternalMap( other );
-         }
-
-         virtual void destructMap( ValueInternalMap *map )
-         {
-            delete map;
-         }
-
-         virtual ValueInternalLink *allocateMapBuckets( unsigned int size )
-         {
-            return new ValueInternalLink[size];
-         }
-
-         virtual void releaseMapBuckets( ValueInternalLink *links )
-         {
-            delete [] links;
-         }
-
-         virtual ValueInternalLink *allocateMapLink()
-         {
-            return new ValueInternalLink();
-         }
-
-         virtual void releaseMapLink( ValueInternalLink *link )
-         {
-            delete link;
-         }
-      };
-    * \endcode
-    */ 
-   class JSON_API ValueMapAllocator
-   {
-   public:
-      virtual ~ValueMapAllocator();
-      virtual ValueInternalMap *newMap() = 0;
-      virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other ) = 0;
-      virtual void destructMap( ValueInternalMap *map ) = 0;
-      virtual ValueInternalLink *allocateMapBuckets( unsigned int size ) = 0;
-      virtual void releaseMapBuckets( ValueInternalLink *links ) = 0;
-      virtual ValueInternalLink *allocateMapLink() = 0;
-      virtual void releaseMapLink( ValueInternalLink *link ) = 0;
-   };
-
-   /** \brief ValueInternalMap hash-map bucket chain link (for internal use only).
-    * \internal previous_ & next_ allows for bidirectional traversal.
-    */
-   class JSON_API ValueInternalLink
-   {
-   public:
-      enum { itemPerLink = 6 };  // sizeof(ValueInternalLink) = 128 on 32 bits architecture.
-      enum InternalFlags { 
-         flagAvailable = 0,
-         flagUsed = 1
-      };
-
-      ValueInternalLink();
-
-      ~ValueInternalLink();
-
-      Value items_[itemPerLink];
-      char *keys_[itemPerLink];
-      ValueInternalLink *previous_;
-      ValueInternalLink *next_;
-   };
-
-
-   /** \brief A linked page based hash-table implementation used internally by Value.
-    * \internal ValueInternalMap is a tradional bucket based hash-table, with a linked
-    * list in each bucket to handle collision. There is an addional twist in that
-    * each node of the collision linked list is a page containing a fixed amount of
-    * value. This provides a better compromise between memory usage and speed.
-    * 
-    * Each bucket is made up of a chained list of ValueInternalLink. The last
-    * link of a given bucket can be found in the 'previous_' field of the following bucket.
-    * The last link of the last bucket is stored in tailLink_ as it has no following bucket.
-    * Only the last link of a bucket may contains 'available' item. The last link always
-    * contains at least one element unless is it the bucket one very first link.
-    */
-   class JSON_API ValueInternalMap
-   {
-      friend class ValueIteratorBase;
-      friend class Value;
-   public:
-      typedef unsigned int HashKey;
-      typedef unsigned int BucketIndex;
-
-# ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
-      struct IteratorState
-      {
-         IteratorState() 
-            : map_(0)
-            , link_(0)
-            , itemIndex_(0)
-            , bucketIndex_(0) 
-         {
-         }
-         ValueInternalMap *map_;
-         ValueInternalLink *link_;
-         BucketIndex itemIndex_;
-         BucketIndex bucketIndex_;
-      };
-# endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
-
-      ValueInternalMap();
-      ValueInternalMap( const ValueInternalMap &other );
-      ValueInternalMap &operator =( const ValueInternalMap &other );
-      ~ValueInternalMap();
-
-      void swap( ValueInternalMap &other );
-
-      BucketIndex size() const;
-
-      void clear();
-
-      bool reserveDelta( BucketIndex growth );
-
-      bool reserve( BucketIndex newItemCount );
-
-      const Value *find( const char *key ) const;
-
-      Value *find( const char *key );
-
-      Value &resolveReference( const char *key, 
-                               bool isStatic );
-
-      void remove( const char *key );
-
-      void doActualRemove( ValueInternalLink *link, 
-                           BucketIndex index,
-                           BucketIndex bucketIndex );
-
-      ValueInternalLink *&getLastLinkInBucket( BucketIndex bucketIndex );
-
-      Value &setNewItem( const char *key, 
-                         bool isStatic, 
-                         ValueInternalLink *link, 
-                         BucketIndex index );
-
-      Value &unsafeAdd( const char *key, 
-                        bool isStatic, 
-                        HashKey hashedKey );
-
-      HashKey hash( const char *key ) const;
-
-      int compare( const ValueInternalMap &other ) const;
-
-   private:
-      void makeBeginIterator( IteratorState &it ) const;
-      void makeEndIterator( IteratorState &it ) const;
-      static bool equals( const IteratorState &x, const IteratorState &other );
-      static void increment( IteratorState &iterator );
-      static void incrementBucket( IteratorState &iterator );
-      static void decrement( IteratorState &iterator );
-      static const char *key( const IteratorState &iterator );
-      static const char *key( const IteratorState &iterator, bool &isStatic );
-      static Value &value( const IteratorState &iterator );
-      static int distance( const IteratorState &x, const IteratorState &y );
-
-   private:
-      ValueInternalLink *buckets_;
-      ValueInternalLink *tailLink_;
-      BucketIndex bucketsSize_;
-      BucketIndex itemCount_;
-   };
-
-   /** \brief A simplified deque implementation used internally by Value.
-   * \internal
-   * It is based on a list of fixed "page", each page contains a fixed number of items.
-   * Instead of using a linked-list, a array of pointer is used for fast item look-up.
-   * Look-up for an element is as follow:
-   * - compute page index: pageIndex = itemIndex / itemsPerPage
-   * - look-up item in page: pages_[pageIndex][itemIndex % itemsPerPage]
-   *
-   * Insertion is amortized constant time (only the array containing the index of pointers
-   * need to be reallocated when items are appended).
-   */
-   class JSON_API ValueInternalArray
-   {
-      friend class Value;
-      friend class ValueIteratorBase;
-   public:
-      enum { itemsPerPage = 8 };    // should be a power of 2 for fast divide and modulo.
-      typedef Value::ArrayIndex ArrayIndex;
-      typedef unsigned int PageIndex;
-
-# ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
-      struct IteratorState // Must be a POD
-      {
-         IteratorState() 
-            : array_(0)
-            , currentPageIndex_(0)
-            , currentItemIndex_(0) 
-         {
-         }
-         ValueInternalArray *array_;
-         Value **currentPageIndex_;
-         unsigned int currentItemIndex_;
-      };
-# endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
-
-      ValueInternalArray();
-      ValueInternalArray( const ValueInternalArray &other );
-      ValueInternalArray &operator =( const ValueInternalArray &other );
-      ~ValueInternalArray();
-      void swap( ValueInternalArray &other );
-
-      void clear();
-      void resize( ArrayIndex newSize );
-
-      Value &resolveReference( ArrayIndex index );
-
-      Value *find( ArrayIndex index ) const;
-
-      ArrayIndex size() const;
-
-      int compare( const ValueInternalArray &other ) const;
-
-   private:
-      static bool equals( const IteratorState &x, const IteratorState &other );
-      static void increment( IteratorState &iterator );
-      static void decrement( IteratorState &iterator );
-      static Value &dereference( const IteratorState &iterator );
-      static Value &unsafeDereference( const IteratorState &iterator );
-      static int distance( const IteratorState &x, const IteratorState &y );
-      static ArrayIndex indexOf( const IteratorState &iterator );
-      void makeBeginIterator( IteratorState &it ) const;
-      void makeEndIterator( IteratorState &it ) const;
-      void makeIterator( IteratorState &it, ArrayIndex index ) const;
-
-      void makeIndexValid( ArrayIndex index );
-
-      Value **pages_;
-      ArrayIndex size_;
-      PageIndex pageCount_;
-   };
-
-   /** \brief Experimental: do not use. Allocator to customize Value internal array.
-    * Below is an example of a simple implementation (actual implementation use
-    * memory pool).
-      \code
-class DefaultValueArrayAllocator : public ValueArrayAllocator
-{
-public: // overridden from ValueArrayAllocator
-   virtual ~DefaultValueArrayAllocator()
-   {
-   }
-
-   virtual ValueInternalArray *newArray()
-   {
-      return new ValueInternalArray();
-   }
-
-   virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )
-   {
-      return new ValueInternalArray( other );
-   }
-
-   virtual void destruct( ValueInternalArray *array )
-   {
-      delete array;
-   }
-
-   virtual void reallocateArrayPageIndex( Value **&indexes, 
-                                          ValueInternalArray::PageIndex &indexCount,
-                                          ValueInternalArray::PageIndex minNewIndexCount )
-   {
-      ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;
-      if ( minNewIndexCount > newIndexCount )
-         newIndexCount = minNewIndexCount;
-      void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );
-      if ( !newIndexes )
-         throw std::bad_alloc();
-      indexCount = newIndexCount;
-      indexes = static_cast<Value **>( newIndexes );
-   }
-   virtual void releaseArrayPageIndex( Value **indexes, 
-                                       ValueInternalArray::PageIndex indexCount )
-   {
-      if ( indexes )
-         free( indexes );
-   }
-
-   virtual Value *allocateArrayPage()
-   {
-      return static_cast<Value *>( malloc( sizeof(Value) * ValueInternalArray::itemsPerPage ) );
-   }
-
-   virtual void releaseArrayPage( Value *value )
-   {
-      if ( value )
-         free( value );
-   }
-};
-      \endcode
-    */ 
-   class JSON_API ValueArrayAllocator
-   {
-   public:
-      virtual ~ValueArrayAllocator();
-      virtual ValueInternalArray *newArray() = 0;
-      virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other ) = 0;
-      virtual void destructArray( ValueInternalArray *array ) = 0;
-      /** \brief Reallocate array page index.
-       * Reallocates an array of pointer on each page.
-       * \param indexes [input] pointer on the current index. May be \c NULL.
-       *                [output] pointer on the new index of at least 
-       *                         \a minNewIndexCount pages. 
-       * \param indexCount [input] current number of pages in the index.
-       *                   [output] number of page the reallocated index can handle.
-       *                            \b MUST be >= \a minNewIndexCount.
-       * \param minNewIndexCount Minimum number of page the new index must be able to
-       *                         handle.
-       */
-      virtual void reallocateArrayPageIndex( Value **&indexes, 
-                                             ValueInternalArray::PageIndex &indexCount,
-                                             ValueInternalArray::PageIndex minNewIndexCount ) = 0;
-      virtual void releaseArrayPageIndex( Value **indexes, 
-                                          ValueInternalArray::PageIndex indexCount ) = 0;
-      virtual Value *allocateArrayPage() = 0;
-      virtual void releaseArrayPage( Value *value ) = 0;
-   };
-#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP
-
-
-   /** \brief base class for Value iterators.
-    *
-    */
-   class ValueIteratorBase
-   {
-   public:
-      typedef unsigned int size_t;
-      typedef int difference_type;
-      typedef ValueIteratorBase SelfType;
-
-      ValueIteratorBase();
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-      explicit ValueIteratorBase( const Value::ObjectValues::iterator &current );
-#else
-      ValueIteratorBase( const ValueInternalArray::IteratorState &state );
-      ValueIteratorBase( const ValueInternalMap::IteratorState &state );
-#endif
-
-      bool operator ==( const SelfType &other ) const
-      {
-         return isEqual( other );
-      }
-
-      bool operator !=( const SelfType &other ) const
-      {
-         return !isEqual( other );
-      }
-
-      difference_type operator -( const SelfType &other ) const
-      {
-         return computeDistance( other );
-      }
-
-      /// Return either the index or the member name of the referenced value as a Value.
-      Value key() const;
-
-      /// Return the index of the referenced Value. -1 if it is not an arrayValue.
-      UInt index() const;
-
-      /// Return the member name of the referenced Value. "" if it is not an objectValue.
-      const char *memberName() const;
-
-   protected:
-      Value &deref() const;
-
-      void increment();
-
-      void decrement();
-
-      difference_type computeDistance( const SelfType &other ) const;
-
-      bool isEqual( const SelfType &other ) const;
-
-      void copy( const SelfType &other );
-
-   private:
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-      Value::ObjectValues::iterator current_;
-      // Indicates that iterator is for a null value.
-      bool isNull_;
-#else
-      union
-      {
-         ValueInternalArray::IteratorState array_;
-         ValueInternalMap::IteratorState map_;
-      } iterator_;
-      bool isArray_;
-#endif
-   };
-
-   /** \brief const iterator for object and array value.
-    *
-    */
-   class ValueConstIterator : public ValueIteratorBase
-   {
-      friend class Value;
-   public:
-      typedef unsigned int size_t;
-      typedef int difference_type;
-      typedef const Value &reference;
-      typedef const Value *pointer;
-      typedef ValueConstIterator SelfType;
-
-      ValueConstIterator();
-   private:
-      /*! \internal Use by Value to create an iterator.
-       */
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-      explicit ValueConstIterator( const Value::ObjectValues::iterator &current );
-#else
-      ValueConstIterator( const ValueInternalArray::IteratorState &state );
-      ValueConstIterator( const ValueInternalMap::IteratorState &state );
-#endif
-   public:
-      SelfType &operator =( const ValueIteratorBase &other );
-
-      SelfType operator++( int )
-      {
-         SelfType temp( *this );
-         ++*this;
-         return temp;
-      }
-
-      SelfType operator--( int )
-      {
-         SelfType temp( *this );
-         --*this;
-         return temp;
-      }
-
-      SelfType &operator--()
-      {
-         decrement();
-         return *this;
-      }
-
-      SelfType &operator++()
-      {
-         increment();
-         return *this;
-      }
-
-      reference operator *() const
-      {
-         return deref();
-      }
-   };
-
-
-   /** \brief Iterator for object and array value.
-    */
-   class ValueIterator : public ValueIteratorBase
-   {
-      friend class Value;
-   public:
-      typedef unsigned int size_t;
-      typedef int difference_type;
-      typedef Value &reference;
-      typedef Value *pointer;
-      typedef ValueIterator SelfType;
-
-      ValueIterator();
-      ValueIterator( const ValueConstIterator &other );
-      ValueIterator( const ValueIterator &other );
-   private:
-      /*! \internal Use by Value to create an iterator.
-       */
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-      explicit ValueIterator( const Value::ObjectValues::iterator &current );
-#else
-      ValueIterator( const ValueInternalArray::IteratorState &state );
-      ValueIterator( const ValueInternalMap::IteratorState &state );
-#endif
-   public:
-
-      SelfType &operator =( const SelfType &other );
-
-      SelfType operator++( int )
-      {
-         SelfType temp( *this );
-         ++*this;
-         return temp;
-      }
-
-      SelfType operator--( int )
-      {
-         SelfType temp( *this );
-         --*this;
-         return temp;
-      }
-
-      SelfType &operator--()
-      {
-         decrement();
-         return *this;
-      }
-
-      SelfType &operator++()
-      {
-         increment();
-         return *this;
-      }
-
-      reference operator *() const
-      {
-         return deref();
-      }
-   };
-
-
-} // namespace Json
-
-
-#endif // CPPTL_JSON_H_INCLUDED
diff --git a/bamtools/src/third_party/jsoncpp/json_valueiterator.inl b/bamtools/src/third_party/jsoncpp/json_valueiterator.inl
deleted file mode 100644
index bd7c8d2..0000000
--- a/bamtools/src/third_party/jsoncpp/json_valueiterator.inl
+++ /dev/null
@@ -1,297 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-// included by json_value.cpp
-// everything is within Json namespace
-
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// class ValueIteratorBase
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-
-ValueIteratorBase::ValueIteratorBase()
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-   : current_()
-   , isNull_( true )
-{
-}
-#else
-   : isArray_( true )
-   , isNull_( true )
-{
-   iterator_.array_ = ValueInternalArray::IteratorState();
-}
-#endif
-
-
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-ValueIteratorBase::ValueIteratorBase( const Value::ObjectValues::iterator &current )
-   : current_( current )
-   , isNull_( false )
-{
-}
-#else
-ValueIteratorBase::ValueIteratorBase( const ValueInternalArray::IteratorState &state )
-   : isArray_( true )
-{
-   iterator_.array_ = state;
-}
-
-
-ValueIteratorBase::ValueIteratorBase( const ValueInternalMap::IteratorState &state )
-   : isArray_( false )
-{
-   iterator_.map_ = state;
-}
-#endif
-
-Value &
-ValueIteratorBase::deref() const
-{
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-   return current_->second;
-#else
-   if ( isArray_ )
-      return ValueInternalArray::dereference( iterator_.array_ );
-   return ValueInternalMap::value( iterator_.map_ );
-#endif
-}
-
-
-void 
-ValueIteratorBase::increment()
-{
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-   ++current_;
-#else
-   if ( isArray_ )
-      ValueInternalArray::increment( iterator_.array_ );
-   ValueInternalMap::increment( iterator_.map_ );
-#endif
-}
-
-
-void 
-ValueIteratorBase::decrement()
-{
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-   --current_;
-#else
-   if ( isArray_ )
-      ValueInternalArray::decrement( iterator_.array_ );
-   ValueInternalMap::decrement( iterator_.map_ );
-#endif
-}
-
-
-ValueIteratorBase::difference_type 
-ValueIteratorBase::computeDistance( const SelfType &other ) const
-{
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-# ifdef JSON_USE_CPPTL_SMALLMAP
-   return current_ - other.current_;
-# else
-   // Iterator for null value are initialized using the default
-   // constructor, which initialize current_ to the default
-   // std::map::iterator. As begin() and end() are two instance 
-   // of the default std::map::iterator, they can not be compared.
-   // To allow this, we handle this comparison specifically.
-   if ( isNull_  &&  other.isNull_ )
-   {
-      return 0;
-   }
-
-
-   // Usage of std::distance is not portable (does not compile with Sun Studio 12 RogueWave STL,
-   // which is the one used by default).
-   // Using a portable hand-made version for non random iterator instead:
-   //   return difference_type( std::distance( current_, other.current_ ) );
-   difference_type myDistance = 0;
-   for ( Value::ObjectValues::iterator it = current_; it != other.current_; ++it )
-   {
-      ++myDistance;
-   }
-   return myDistance;
-# endif
-#else
-   if ( isArray_ )
-      return ValueInternalArray::distance( iterator_.array_, other.iterator_.array_ );
-   return ValueInternalMap::distance( iterator_.map_, other.iterator_.map_ );
-#endif
-}
-
-
-bool 
-ValueIteratorBase::isEqual( const SelfType &other ) const
-{
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-   if ( isNull_ )
-   {
-      return other.isNull_;
-   }
-   return current_ == other.current_;
-#else
-   if ( isArray_ )
-      return ValueInternalArray::equals( iterator_.array_, other.iterator_.array_ );
-   return ValueInternalMap::equals( iterator_.map_, other.iterator_.map_ );
-#endif
-}
-
-
-void 
-ValueIteratorBase::copy( const SelfType &other )
-{
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-   current_ = other.current_;
-#else
-   if ( isArray_ )
-      iterator_.array_ = other.iterator_.array_;
-   iterator_.map_ = other.iterator_.map_;
-#endif
-}
-
-
-Value 
-ValueIteratorBase::key() const
-{
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-   const Value::CZString czstring = (*current_).first;
-   if ( czstring.c_str() )
-   {
-      if ( czstring.isStaticString() )
-         return Value( StaticString( czstring.c_str() ) );
-      return Value( czstring.c_str() );
-   }
-   return Value( czstring.index() );
-#else
-   if ( isArray_ )
-      return Value( ValueInternalArray::indexOf( iterator_.array_ ) );
-   bool isStatic;
-   const char *memberName = ValueInternalMap::key( iterator_.map_, isStatic );
-   if ( isStatic )
-      return Value( StaticString( memberName ) );
-   return Value( memberName );
-#endif
-}
-
-
-UInt 
-ValueIteratorBase::index() const
-{
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-   const Value::CZString czstring = (*current_).first;
-   if ( !czstring.c_str() )
-      return czstring.index();
-   return Value::UInt( -1 );
-#else
-   if ( isArray_ )
-      return Value::UInt( ValueInternalArray::indexOf( iterator_.array_ ) );
-   return Value::UInt( -1 );
-#endif
-}
-
-
-const char *
-ValueIteratorBase::memberName() const
-{
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-   const char *name = (*current_).first.c_str();
-   return name ? name : "";
-#else
-   if ( !isArray_ )
-      return ValueInternalMap::key( iterator_.map_ );
-   return "";
-#endif
-}
-
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// class ValueConstIterator
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-
-ValueConstIterator::ValueConstIterator()
-{
-}
-
-
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-ValueConstIterator::ValueConstIterator( const Value::ObjectValues::iterator &current )
-   : ValueIteratorBase( current )
-{
-}
-#else
-ValueConstIterator::ValueConstIterator( const ValueInternalArray::IteratorState &state )
-   : ValueIteratorBase( state )
-{
-}
-
-ValueConstIterator::ValueConstIterator( const ValueInternalMap::IteratorState &state )
-   : ValueIteratorBase( state )
-{
-}
-#endif
-
-ValueConstIterator &
-ValueConstIterator::operator =( const ValueIteratorBase &other )
-{
-   copy( other );
-   return *this;
-}
-
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// class ValueIterator
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-
-ValueIterator::ValueIterator()
-{
-}
-
-
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-ValueIterator::ValueIterator( const Value::ObjectValues::iterator &current )
-   : ValueIteratorBase( current )
-{
-}
-#else
-ValueIterator::ValueIterator( const ValueInternalArray::IteratorState &state )
-   : ValueIteratorBase( state )
-{
-}
-
-ValueIterator::ValueIterator( const ValueInternalMap::IteratorState &state )
-   : ValueIteratorBase( state )
-{
-}
-#endif
-
-ValueIterator::ValueIterator( const ValueConstIterator &other )
-   : ValueIteratorBase( other )
-{
-}
-
-ValueIterator::ValueIterator( const ValueIterator &other )
-   : ValueIteratorBase( other )
-{
-}
-
-ValueIterator &
-ValueIterator::operator =( const SelfType &other )
-{
-   copy( other );
-   return *this;
-}
diff --git a/bamtools/src/third_party/jsoncpp/json_writer.cpp b/bamtools/src/third_party/jsoncpp/json_writer.cpp
deleted file mode 100644
index 4e45496..0000000
--- a/bamtools/src/third_party/jsoncpp/json_writer.cpp
+++ /dev/null
@@ -1,819 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#include "json_writer.h"
-#include "json_tool.h"
-#include <utility>
-#include <assert.h>
-#include <stdio.h>
-#include <string.h>
-#include <iostream>
-#include <sstream>
-#include <iomanip>
-
-#if _MSC_VER >= 1400 // VC++ 8.0
-#pragma warning( disable : 4996 )   // disable warning about strdup being deprecated.
-#endif
-
-namespace Json {
-
-static bool containsControlCharacter( const char* str )
-{
-   while ( *str ) 
-   {
-      if ( isControlCharacter( *(str++) ) )
-         return true;
-   }
-   return false;
-}
-
-std::string valueToString( Int value )
-{
-   UIntToStringBuffer buffer;
-   char *current = buffer + sizeof(buffer);
-   bool isNegative = value < 0;
-   if ( isNegative )
-      value = -value;
-   uintToString( UInt(value), current );
-   if ( isNegative )
-      *--current = '-';
-   assert( current >= buffer );
-   return current;
-}
-
-
-std::string valueToString( UInt value )
-{
-   UIntToStringBuffer buffer;
-   char *current = buffer + sizeof(buffer);
-   uintToString( value, current );
-   assert( current >= buffer );
-   return current;
-}
-
-std::string valueToString( double value )
-{
-   char buffer[32];
-#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__) // Use secure version with visual studio 2005 to avoid warning. 
-   sprintf_s(buffer, sizeof(buffer), "%#.16g", value); 
-#else	
-   sprintf(buffer, "%#.16g", value); 
-#endif
-   char* ch = buffer + strlen(buffer) - 1;
-   if (*ch != '0') return buffer; // nothing to truncate, so save time
-   while(ch > buffer && *ch == '0'){
-     --ch;
-   }
-   char* last_nonzero = ch;
-   while(ch >= buffer){
-     switch(*ch){
-     case '0':
-     case '1':
-     case '2':
-     case '3':
-     case '4':
-     case '5':
-     case '6':
-     case '7':
-     case '8':
-     case '9':
-       --ch;
-       continue;
-     case '.':
-       // Truncate zeroes to save bytes in output, but keep one.
-       *(last_nonzero+2) = '\0';
-       return buffer;
-     default:
-       return buffer;
-     }
-   }
-   return buffer;
-}
-
-
-std::string valueToString( bool value )
-{
-   return value ? "true" : "false";
-}
-
-std::string valueToQuotedString( const char *value )
-{
-   // Not sure how to handle unicode...
-   if (strpbrk(value, "\"\\\b\f\n\r\t") == NULL && !containsControlCharacter( value ))
-      return std::string("\"") + value + "\"";
-   // We have to walk value and escape any special characters.
-   // Appending to std::string is not efficient, but this should be rare.
-   // (Note: forward slashes are *not* rare, but I am not escaping them.)
-   std::string::size_type maxsize = strlen(value)*2 + 3; // allescaped+quotes+NULL
-   std::string result;
-   result.reserve(maxsize); // to avoid lots of mallocs
-   result += "\"";
-   for (const char* c=value; *c != 0; ++c)
-   {
-      switch(*c)
-      {
-         case '\"':
-            result += "\\\"";
-            break;
-         case '\\':
-            result += "\\\\";
-            break;
-         case '\b':
-            result += "\\b";
-            break;
-         case '\f':
-            result += "\\f";
-            break;
-         case '\n':
-            result += "\\n";
-            break;
-         case '\r':
-            result += "\\r";
-            break;
-         case '\t':
-            result += "\\t";
-            break;
-         //case '/':
-            // Even though \/ is considered a legal escape in JSON, a bare
-            // slash is also legal, so I see no reason to escape it.
-            // (I hope I am not misunderstanding something.
-            // blep notes: actually escaping \/ may be useful in javascript to avoid </ 
-            // sequence.
-            // Should add a flag to allow this compatibility mode and prevent this 
-            // sequence from occurring.
-         default:
-            if ( isControlCharacter( *c ) )
-            {
-               std::ostringstream oss;
-               oss << "\\u" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << static_cast<int>(*c);
-               result += oss.str();
-            }
-            else
-            {
-               result += *c;
-            }
-            break;
-      }
-   }
-   result += "\"";
-   return result;
-}
-
-// Class Writer
-// //////////////////////////////////////////////////////////////////
-Writer::~Writer()
-{
-}
-
-
-// Class FastWriter
-// //////////////////////////////////////////////////////////////////
-
-FastWriter::FastWriter()
-   : yamlCompatiblityEnabled_( false )
-{
-}
-
-
-void 
-FastWriter::enableYAMLCompatibility()
-{
-   yamlCompatiblityEnabled_ = true;
-}
-
-
-std::string 
-FastWriter::write( const Value &root )
-{
-   document_ = "";
-   writeValue( root );
-   document_ += "\n";
-   return document_;
-}
-
-
-void 
-FastWriter::writeValue( const Value &value )
-{
-   switch ( value.type() )
-   {
-   case nullValue:
-      document_ += "null";
-      break;
-   case intValue:
-      document_ += valueToString( value.asInt() );
-      break;
-   case uintValue:
-      document_ += valueToString( value.asUInt() );
-      break;
-   case realValue:
-      document_ += valueToString( value.asDouble() );
-      break;
-   case stringValue:
-      document_ += valueToQuotedString( value.asCString() );
-      break;
-   case booleanValue:
-      document_ += valueToString( value.asBool() );
-      break;
-   case arrayValue:
-      {
-         document_ += "[";
-         int size = value.size();
-         for ( int index =0; index < size; ++index )
-         {
-            if ( index > 0 )
-               document_ += ",";
-            writeValue( value[index] );
-         }
-         document_ += "]";
-      }
-      break;
-   case objectValue:
-      {
-         Value::Members members( value.getMemberNames() );
-         document_ += "{";
-         for ( Value::Members::iterator it = members.begin(); 
-               it != members.end(); 
-               ++it )
-         {
-            const std::string &name = *it;
-            if ( it != members.begin() )
-               document_ += ",";
-            document_ += valueToQuotedString( name.c_str() );
-            document_ += yamlCompatiblityEnabled_ ? ": " 
-                                                  : ":";
-            writeValue( value[name] );
-         }
-         document_ += "}";
-      }
-      break;
-   }
-}
-
-
-// Class StyledWriter
-// //////////////////////////////////////////////////////////////////
-
-StyledWriter::StyledWriter()
-   : rightMargin_( 74 )
-   , indentSize_( 3 )
-{
-}
-
-
-std::string 
-StyledWriter::write( const Value &root )
-{
-   document_ = "";
-   addChildValues_ = false;
-   indentString_ = "";
-   writeCommentBeforeValue( root );
-   writeValue( root );
-   writeCommentAfterValueOnSameLine( root );
-   document_ += "\n";
-   return document_;
-}
-
-
-void 
-StyledWriter::writeValue( const Value &value )
-{
-   switch ( value.type() )
-   {
-   case nullValue:
-      pushValue( "null" );
-      break;
-   case intValue:
-      pushValue( valueToString( value.asInt() ) );
-      break;
-   case uintValue:
-      pushValue( valueToString( value.asUInt() ) );
-      break;
-   case realValue:
-      pushValue( valueToString( value.asDouble() ) );
-      break;
-   case stringValue:
-      pushValue( valueToQuotedString( value.asCString() ) );
-      break;
-   case booleanValue:
-      pushValue( valueToString( value.asBool() ) );
-      break;
-   case arrayValue:
-      writeArrayValue( value);
-      break;
-   case objectValue:
-      {
-         Value::Members members( value.getMemberNames() );
-         if ( members.empty() )
-            pushValue( "{}" );
-         else
-         {
-            writeWithIndent( "{" );
-            indent();
-            Value::Members::iterator it = members.begin();
-            while ( true )
-            {
-               const std::string &name = *it;
-               const Value &childValue = value[name];
-               writeCommentBeforeValue( childValue );
-               writeWithIndent( valueToQuotedString( name.c_str() ) );
-               document_ += " : ";
-               writeValue( childValue );
-               if ( ++it == members.end() )
-               {
-                  writeCommentAfterValueOnSameLine( childValue );
-                  break;
-               }
-               document_ += ",";
-               writeCommentAfterValueOnSameLine( childValue );
-            }
-            unindent();
-            writeWithIndent( "}" );
-         }
-      }
-      break;
-   }
-}
-
-
-void 
-StyledWriter::writeArrayValue( const Value &value )
-{
-   unsigned size = value.size();
-   if ( size == 0 )
-      pushValue( "[]" );
-   else
-   {
-      bool isArrayMultiLine = isMultineArray( value );
-      if ( isArrayMultiLine )
-      {
-         writeWithIndent( "[" );
-         indent();
-         bool hasChildValue = !childValues_.empty();
-         unsigned index =0;
-         while ( true )
-         {
-            const Value &childValue = value[index];
-            writeCommentBeforeValue( childValue );
-            if ( hasChildValue )
-               writeWithIndent( childValues_[index] );
-            else
-            {
-               writeIndent();
-               writeValue( childValue );
-            }
-            if ( ++index == size )
-            {
-               writeCommentAfterValueOnSameLine( childValue );
-               break;
-            }
-            document_ += ",";
-            writeCommentAfterValueOnSameLine( childValue );
-         }
-         unindent();
-         writeWithIndent( "]" );
-      }
-      else // output on a single line
-      {
-         assert( childValues_.size() == size );
-         document_ += "[ ";
-         for ( unsigned index =0; index < size; ++index )
-         {
-            if ( index > 0 )
-               document_ += ", ";
-            document_ += childValues_[index];
-         }
-         document_ += " ]";
-      }
-   }
-}
-
-
-bool 
-StyledWriter::isMultineArray( const Value &value )
-{
-   int size = value.size();
-   bool isMultiLine = size*3 >= rightMargin_ ;
-   childValues_.clear();
-   for ( int index =0; index < size  &&  !isMultiLine; ++index )
-   {
-      const Value &childValue = value[index];
-      isMultiLine = isMultiLine  ||
-                     ( (childValue.isArray()  ||  childValue.isObject())  &&  
-                        childValue.size() > 0 );
-   }
-   if ( !isMultiLine ) // check if line length > max line length
-   {
-      childValues_.reserve( size );
-      addChildValues_ = true;
-      int lineLength = 4 + (size-1)*2; // '[ ' + ', '*n + ' ]'
-      for ( int index =0; index < size  &&  !isMultiLine; ++index )
-      {
-         writeValue( value[index] );
-         lineLength += int( childValues_[index].length() );
-         isMultiLine = isMultiLine  &&  hasCommentForValue( value[index] );
-      }
-      addChildValues_ = false;
-      isMultiLine = isMultiLine  ||  lineLength >= rightMargin_;
-   }
-   return isMultiLine;
-}
-
-
-void 
-StyledWriter::pushValue( const std::string &value )
-{
-   if ( addChildValues_ )
-      childValues_.push_back( value );
-   else
-      document_ += value;
-}
-
-
-void 
-StyledWriter::writeIndent()
-{
-   if ( !document_.empty() )
-   {
-      char last = document_[document_.length()-1];
-      if ( last == ' ' )     // already indented
-         return;
-      if ( last != '\n' )    // Comments may add new-line
-         document_ += '\n';
-   }
-   document_ += indentString_;
-}
-
-
-void 
-StyledWriter::writeWithIndent( const std::string &value )
-{
-   writeIndent();
-   document_ += value;
-}
-
-
-void 
-StyledWriter::indent()
-{
-   indentString_ += std::string( indentSize_, ' ' );
-}
-
-
-void 
-StyledWriter::unindent()
-{
-   assert( int(indentString_.size()) >= indentSize_ );
-   indentString_.resize( indentString_.size() - indentSize_ );
-}
-
-
-void 
-StyledWriter::writeCommentBeforeValue( const Value &root )
-{
-   if ( !root.hasComment( commentBefore ) )
-      return;
-   document_ += normalizeEOL( root.getComment( commentBefore ) );
-   document_ += "\n";
-}
-
-
-void 
-StyledWriter::writeCommentAfterValueOnSameLine( const Value &root )
-{
-   if ( root.hasComment( commentAfterOnSameLine ) )
-      document_ += " " + normalizeEOL( root.getComment( commentAfterOnSameLine ) );
-
-   if ( root.hasComment( commentAfter ) )
-   {
-      document_ += "\n";
-      document_ += normalizeEOL( root.getComment( commentAfter ) );
-      document_ += "\n";
-   }
-}
-
-
-bool 
-StyledWriter::hasCommentForValue( const Value &value )
-{
-   return value.hasComment( commentBefore )
-          ||  value.hasComment( commentAfterOnSameLine )
-          ||  value.hasComment( commentAfter );
-}
-
-
-std::string 
-StyledWriter::normalizeEOL( const std::string &text )
-{
-   std::string normalized;
-   normalized.reserve( text.length() );
-   const char *begin = text.c_str();
-   const char *end = begin + text.length();
-   const char *current = begin;
-   while ( current != end )
-   {
-      char c = *current++;
-      if ( c == '\r' ) // mac or dos EOL
-      {
-         if ( *current == '\n' ) // convert dos EOL
-            ++current;
-         normalized += '\n';
-      }
-      else // handle unix EOL & other char
-         normalized += c;
-   }
-   return normalized;
-}
-
-
-// Class StyledStreamWriter
-// //////////////////////////////////////////////////////////////////
-
-StyledStreamWriter::StyledStreamWriter( std::string indentation )
-   : document_(NULL)
-   , rightMargin_( 74 )
-   , indentation_( indentation )
-{
-}
-
-
-void
-StyledStreamWriter::write( std::ostream &out, const Value &root )
-{
-   document_ = &out;
-   addChildValues_ = false;
-   indentString_ = "";
-   writeCommentBeforeValue( root );
-   writeValue( root );
-   writeCommentAfterValueOnSameLine( root );
-   *document_ << "\n";
-   document_ = NULL; // Forget the stream, for safety.
-}
-
-
-void 
-StyledStreamWriter::writeValue( const Value &value )
-{
-   switch ( value.type() )
-   {
-   case nullValue:
-      pushValue( "null" );
-      break;
-   case intValue:
-      pushValue( valueToString( value.asInt() ) );
-      break;
-   case uintValue:
-      pushValue( valueToString( value.asUInt() ) );
-      break;
-   case realValue:
-      pushValue( valueToString( value.asDouble() ) );
-      break;
-   case stringValue:
-      pushValue( valueToQuotedString( value.asCString() ) );
-      break;
-   case booleanValue:
-      pushValue( valueToString( value.asBool() ) );
-      break;
-   case arrayValue:
-      writeArrayValue( value);
-      break;
-   case objectValue:
-      {
-         Value::Members members( value.getMemberNames() );
-         if ( members.empty() )
-            pushValue( "{}" );
-         else
-         {
-            writeWithIndent( "{" );
-            indent();
-            Value::Members::iterator it = members.begin();
-            while ( true )
-            {
-               const std::string &name = *it;
-               const Value &childValue = value[name];
-               writeCommentBeforeValue( childValue );
-               writeWithIndent( valueToQuotedString( name.c_str() ) );
-               *document_ << " : ";
-               writeValue( childValue );
-               if ( ++it == members.end() )
-               {
-                  writeCommentAfterValueOnSameLine( childValue );
-                  break;
-               }
-               *document_ << ",";
-               writeCommentAfterValueOnSameLine( childValue );
-            }
-            unindent();
-            writeWithIndent( "}" );
-         }
-      }
-      break;
-   }
-}
-
-
-void 
-StyledStreamWriter::writeArrayValue( const Value &value )
-{
-   unsigned size = value.size();
-   if ( size == 0 )
-      pushValue( "[]" );
-   else
-   {
-      bool isArrayMultiLine = isMultineArray( value );
-      if ( isArrayMultiLine )
-      {
-         writeWithIndent( "[" );
-         indent();
-         bool hasChildValue = !childValues_.empty();
-         unsigned index =0;
-         while ( true )
-         {
-            const Value &childValue = value[index];
-            writeCommentBeforeValue( childValue );
-            if ( hasChildValue )
-               writeWithIndent( childValues_[index] );
-            else
-            {
-	       writeIndent();
-               writeValue( childValue );
-            }
-            if ( ++index == size )
-            {
-               writeCommentAfterValueOnSameLine( childValue );
-               break;
-            }
-            *document_ << ",";
-            writeCommentAfterValueOnSameLine( childValue );
-         }
-         unindent();
-         writeWithIndent( "]" );
-      }
-      else // output on a single line
-      {
-         assert( childValues_.size() == size );
-         *document_ << "[ ";
-         for ( unsigned index =0; index < size; ++index )
-         {
-            if ( index > 0 )
-               *document_ << ", ";
-            *document_ << childValues_[index];
-         }
-         *document_ << " ]";
-      }
-   }
-}
-
-
-bool 
-StyledStreamWriter::isMultineArray( const Value &value )
-{
-   int size = value.size();
-   bool isMultiLine = size*3 >= rightMargin_ ;
-   childValues_.clear();
-   for ( int index =0; index < size  &&  !isMultiLine; ++index )
-   {
-      const Value &childValue = value[index];
-      isMultiLine = isMultiLine  ||
-                     ( (childValue.isArray()  ||  childValue.isObject())  &&  
-                        childValue.size() > 0 );
-   }
-   if ( !isMultiLine ) // check if line length > max line length
-   {
-      childValues_.reserve( size );
-      addChildValues_ = true;
-      int lineLength = 4 + (size-1)*2; // '[ ' + ', '*n + ' ]'
-      for ( int index =0; index < size  &&  !isMultiLine; ++index )
-      {
-         writeValue( value[index] );
-         lineLength += int( childValues_[index].length() );
-         isMultiLine = isMultiLine  &&  hasCommentForValue( value[index] );
-      }
-      addChildValues_ = false;
-      isMultiLine = isMultiLine  ||  lineLength >= rightMargin_;
-   }
-   return isMultiLine;
-}
-
-
-void 
-StyledStreamWriter::pushValue( const std::string &value )
-{
-   if ( addChildValues_ )
-      childValues_.push_back( value );
-   else
-      *document_ << value;
-}
-
-
-void 
-StyledStreamWriter::writeIndent()
-{
-  /*
-    Some comments in this method would have been nice. ;-)
-
-   if ( !document_.empty() )
-   {
-      char last = document_[document_.length()-1];
-      if ( last == ' ' )     // already indented
-         return;
-      if ( last != '\n' )    // Comments may add new-line
-         *document_ << '\n';
-   }
-  */
-   *document_ << '\n' << indentString_;
-}
-
-
-void 
-StyledStreamWriter::writeWithIndent( const std::string &value )
-{
-   writeIndent();
-   *document_ << value;
-}
-
-
-void 
-StyledStreamWriter::indent()
-{
-   indentString_ += indentation_;
-}
-
-
-void 
-StyledStreamWriter::unindent()
-{
-   assert( indentString_.size() >= indentation_.size() );
-   indentString_.resize( indentString_.size() - indentation_.size() );
-}
-
-
-void 
-StyledStreamWriter::writeCommentBeforeValue( const Value &root )
-{
-   if ( !root.hasComment( commentBefore ) )
-      return;
-   *document_ << normalizeEOL( root.getComment( commentBefore ) );
-   *document_ << "\n";
-}
-
-
-void 
-StyledStreamWriter::writeCommentAfterValueOnSameLine( const Value &root )
-{
-   if ( root.hasComment( commentAfterOnSameLine ) )
-      *document_ << " " + normalizeEOL( root.getComment( commentAfterOnSameLine ) );
-
-   if ( root.hasComment( commentAfter ) )
-   {
-      *document_ << "\n";
-      *document_ << normalizeEOL( root.getComment( commentAfter ) );
-      *document_ << "\n";
-   }
-}
-
-
-bool 
-StyledStreamWriter::hasCommentForValue( const Value &value )
-{
-   return value.hasComment( commentBefore )
-          ||  value.hasComment( commentAfterOnSameLine )
-          ||  value.hasComment( commentAfter );
-}
-
-
-std::string 
-StyledStreamWriter::normalizeEOL( const std::string &text )
-{
-   std::string normalized;
-   normalized.reserve( text.length() );
-   const char *begin = text.c_str();
-   const char *end = begin + text.length();
-   const char *current = begin;
-   while ( current != end )
-   {
-      char c = *current++;
-      if ( c == '\r' ) // mac or dos EOL
-      {
-         if ( *current == '\n' ) // convert dos EOL
-            ++current;
-         normalized += '\n';
-      }
-      else // handle unix EOL & other char
-         normalized += c;
-   }
-   return normalized;
-}
-
-
-std::ostream& operator<<( std::ostream &sout, const Value &root )
-{
-   Json::StyledStreamWriter writer;
-   writer.write(sout, root);
-   return sout;
-}
-
-
-} // namespace Json
diff --git a/bamtools/src/third_party/jsoncpp/json_writer.h b/bamtools/src/third_party/jsoncpp/json_writer.h
deleted file mode 100644
index f01194d..0000000
--- a/bamtools/src/third_party/jsoncpp/json_writer.h
+++ /dev/null
@@ -1,179 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef JSON_WRITER_H_INCLUDED
-# define JSON_WRITER_H_INCLUDED
-
-# include "json_value.h"
-# include <vector>
-# include <string>
-# include <iostream>
-
-namespace Json {
-
-   class Value;
-
-   /** \brief Abstract class for writers.
-    */
-   class JSON_API Writer
-   {
-   public:
-      virtual ~Writer();
-
-      virtual std::string write( const Value &root ) = 0;
-   };
-
-   /** \brief Outputs a Value in <a HREF="http://www.json.org">JSON</a> format without formatting (not human friendly).
-    *
-    * The JSON document is written in a single line. It is not intended for 'human' consumption,
-    * but may be usefull to support feature such as RPC where bandwith is limited.
-    * \sa Reader, Value
-    */
-   class JSON_API FastWriter : public Writer
-   {
-   public:
-      FastWriter();
-      virtual ~FastWriter(){}
-
-      void enableYAMLCompatibility();
-
-   public: // overridden from Writer
-      virtual std::string write( const Value &root );
-
-   private:
-      void writeValue( const Value &value );
-
-      std::string document_;
-      bool yamlCompatiblityEnabled_;
-   };
-
-   /** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a human friendly way.
-    *
-    * The rules for line break and indent are as follow:
-    * - Object value:
-    *     - if empty then print {} without indent and line break
-    *     - if not empty the print '{', line break & indent, print one value per line
-    *       and then unindent and line break and print '}'.
-    * - Array value:
-    *     - if empty then print [] without indent and line break
-    *     - if the array contains no object value, empty array or some other value types,
-    *       and all the values fit on one lines, then print the array on a single line.
-    *     - otherwise, it the values do not fit on one line, or the array contains
-    *       object or non empty array, then print one value per line.
-    *
-    * If the Value have comments then they are outputed according to their #CommentPlacement.
-    *
-    * \sa Reader, Value, Value::setComment()
-    */
-   class JSON_API StyledWriter: public Writer
-   {
-   public:
-      StyledWriter();
-      virtual ~StyledWriter(){}
-
-   public: // overridden from Writer
-      /** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
-       * \param root Value to serialize.
-       * \return String containing the JSON document that represents the root value.
-       */
-      virtual std::string write( const Value &root );
-
-   private:
-      void writeValue( const Value &value );
-      void writeArrayValue( const Value &value );
-      bool isMultineArray( const Value &value );
-      void pushValue( const std::string &value );
-      void writeIndent();
-      void writeWithIndent( const std::string &value );
-      void indent();
-      void unindent();
-      void writeCommentBeforeValue( const Value &root );
-      void writeCommentAfterValueOnSameLine( const Value &root );
-      bool hasCommentForValue( const Value &value );
-      static std::string normalizeEOL( const std::string &text );
-
-      typedef std::vector<std::string> ChildValues;
-
-      ChildValues childValues_;
-      std::string document_;
-      std::string indentString_;
-      int rightMargin_;
-      int indentSize_;
-      bool addChildValues_;
-   };
-
-   /** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a human friendly way,
-        to a stream rather than to a string.
-    *
-    * The rules for line break and indent are as follow:
-    * - Object value:
-    *     - if empty then print {} without indent and line break
-    *     - if not empty the print '{', line break & indent, print one value per line
-    *       and then unindent and line break and print '}'.
-    * - Array value:
-    *     - if empty then print [] without indent and line break
-    *     - if the array contains no object value, empty array or some other value types,
-    *       and all the values fit on one lines, then print the array on a single line.
-    *     - otherwise, it the values do not fit on one line, or the array contains
-    *       object or non empty array, then print one value per line.
-    *
-    * If the Value have comments then they are outputed according to their #CommentPlacement.
-    *
-    * \param indentation Each level will be indented by this amount extra.
-    * \sa Reader, Value, Value::setComment()
-    */
-   class JSON_API StyledStreamWriter
-   {
-   public:
-      StyledStreamWriter( std::string indentation="\t" );
-      ~StyledStreamWriter(){}
-
-   public:
-      /** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
-       * \param out Stream to write to. (Can be ostringstream, e.g.)
-       * \param root Value to serialize.
-       * \note There is no point in deriving from Writer, since write() should not return a value.
-       */
-      void write( std::ostream &out, const Value &root );
-
-   private:
-      void writeValue( const Value &value );
-      void writeArrayValue( const Value &value );
-      bool isMultineArray( const Value &value );
-      void pushValue( const std::string &value );
-      void writeIndent();
-      void writeWithIndent( const std::string &value );
-      void indent();
-      void unindent();
-      void writeCommentBeforeValue( const Value &root );
-      void writeCommentAfterValueOnSameLine( const Value &root );
-      bool hasCommentForValue( const Value &value );
-      static std::string normalizeEOL( const std::string &text );
-
-      typedef std::vector<std::string> ChildValues;
-
-      ChildValues childValues_;
-      std::ostream* document_;
-      std::string indentString_;
-      int rightMargin_;
-      std::string indentation_;
-      bool addChildValues_;
-   };
-
-   std::string JSON_API valueToString( Int value );
-   std::string JSON_API valueToString( UInt value );
-   std::string JSON_API valueToString( double value );
-   std::string JSON_API valueToString( bool value );
-   std::string JSON_API valueToQuotedString( const char *value );
-
-   /// \brief Output using the StyledStreamWriter.
-   /// \see Json::operator>>()
-   std::ostream& operator<<( std::ostream&, const Value &root );
-
-} // namespace Json
-
-
-
-#endif // JSON_WRITER_H_INCLUDED
diff --git a/bamtools/src/toolkit/CMakeLists.txt b/bamtools/src/toolkit/CMakeLists.txt
deleted file mode 100644
index 33b0735..0000000
--- a/bamtools/src/toolkit/CMakeLists.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-# ==========================
-# BamTools CMakeLists.txt
-# (c) 2010 Derek Barnett
-#
-# src/toolkit
-# ==========================
-
-# set include path
-include_directories( ${BamTools_SOURCE_DIR}/src/api
-                     ${BamTools_SOURCE_DIR}/src/utils
-                     ${BamTools_SOURCE_DIR}/src/third_party
-                   )
-
-# compile main bamtools application
-add_executable( bamtools_cmd
-                bamtools_convert.cpp
-                bamtools_count.cpp
-                bamtools_coverage.cpp
-                bamtools_filter.cpp
-                bamtools_header.cpp
-                bamtools_index.cpp
-                bamtools_merge.cpp
-                bamtools_random.cpp
-                bamtools_resolve.cpp
-                bamtools_revert.cpp
-                bamtools_sort.cpp
-                bamtools_split.cpp
-                bamtools_stats.cpp
-                bamtools.cpp
-              )
-
-# set BamTools application properties
-set_target_properties( bamtools_cmd PROPERTIES
-                       VERSION  2.3.0
-                       OUTPUT_NAME "bamtools"
-                     )
-# make version info available in application
-configure_file( bamtools_version.h.in ${BamTools_SOURCE_DIR}/src/toolkit/bamtools_version.h )
-
-# define libraries to link
-target_link_libraries( bamtools_cmd BamTools BamTools-utils jsoncpp )
-
-# set application install destinations
-install( TARGETS bamtools_cmd DESTINATION "bin")
diff --git a/bamtools/src/toolkit/bamtools.cpp b/bamtools/src/toolkit/bamtools.cpp
deleted file mode 100644
index 29097d0..0000000
--- a/bamtools/src/toolkit/bamtools.cpp
+++ /dev/null
@@ -1,163 +0,0 @@
-// ***************************************************************************
-// bamtools.cpp (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 12 October 2012 (DB)
-// ---------------------------------------------------------------------------
-// Integrates a number of BamTools functionalities into a single executable.
-// ***************************************************************************
-
-#include "bamtools_convert.h"
-#include "bamtools_count.h"
-#include "bamtools_coverage.h"
-#include "bamtools_filter.h"
-#include "bamtools_header.h"
-#include "bamtools_index.h"
-#include "bamtools_merge.h"
-#include "bamtools_random.h"
-#include "bamtools_resolve.h"
-#include "bamtools_revert.h"
-#include "bamtools_sort.h"
-#include "bamtools_split.h"
-#include "bamtools_stats.h"
-#include "bamtools_version.h"
-#include <cstdio>
-#include <cstdlib>
-#include <iostream>
-#include <sstream>
-#include <string>
-using namespace BamTools;
-using namespace std;
-
-// bamtools subtool names
-static const string CONVERT  = "convert";
-static const string COUNT    = "count";
-static const string COVERAGE = "coverage";
-static const string FILTER   = "filter";
-static const string HEADER   = "header";
-static const string INDEX    = "index";
-static const string MERGE    = "merge";
-static const string RANDOM   = "random";
-static const string RESOLVE  = "resolve";
-static const string REVERT   = "revert";
-static const string SORT     = "sort";
-static const string SPLIT    = "split";
-static const string STATS    = "stats";
-
-// bamtools help/version constants
-static const string HELP          = "help";
-static const string LONG_HELP     = "--help";
-static const string SHORT_HELP    = "-h";
-static const string VERSION       = "version";
-static const string LONG_VERSION  = "--version";
-static const string SHORT_VERSION = "-v";
-
-// determine if string is a help constant
-static bool IsHelp(char* str) {
-    return ( str == HELP ||
-             str == LONG_HELP ||
-             str == SHORT_HELP );
-}
-
-// determine if string is a version constant
-static bool IsVersion(char* str) {
-    return ( str == VERSION ||
-             str == LONG_VERSION ||
-             str == SHORT_VERSION );
-}
-
-// subtool factory method
-AbstractTool* CreateTool(const string& arg) {
-  
-    // determine tool type based on arg
-    if ( arg == CONVERT )  return new ConvertTool;
-    if ( arg == COUNT )    return new CountTool;
-    if ( arg == COVERAGE ) return new CoverageTool;
-    if ( arg == FILTER )   return new FilterTool;
-    if ( arg == HEADER )   return new HeaderTool;
-    if ( arg == INDEX )    return new IndexTool;
-    if ( arg == MERGE )    return new MergeTool;
-    if ( arg == RANDOM )   return new RandomTool;
-    if ( arg == RESOLVE )  return new ResolveTool;
-    if ( arg == REVERT )   return new RevertTool;
-    if ( arg == SORT )     return new SortTool;
-    if ( arg == SPLIT )    return new SplitTool;
-    if ( arg == STATS )    return new StatsTool;
-
-    // unknown arg
-    return 0;
-}
-
-// print help info
-int Help(int argc, char* argv[]) {
-  
-    // check for 'bamtools help COMMAND' to print tool-specific help message
-    if (argc > 2) {
-        
-	// determine desired sub-tool
-        AbstractTool* tool = CreateTool( argv[2] );
-
-        // if tool known, print its help screen
-        if ( tool ) return tool->Help();
-    }
-
-    // print general BamTools help message
-    cerr << endl;
-    cerr << "usage: bamtools [--help] COMMAND [ARGS]" << endl;
-    cerr << endl;
-    cerr << "Available bamtools commands:" << endl;
-    cerr << "\tconvert         Converts between BAM and a number of other formats" << endl;
-    cerr << "\tcount           Prints number of alignments in BAM file(s)" << endl;
-    cerr << "\tcoverage        Prints coverage statistics from the input BAM file" << endl;    
-    cerr << "\tfilter          Filters BAM file(s) by user-specified criteria" << endl;
-    cerr << "\theader          Prints BAM header information" << endl;
-    cerr << "\tindex           Generates index for BAM file" << endl;
-    cerr << "\tmerge           Merge multiple BAM files into single file" << endl;
-    cerr << "\trandom          Select random alignments from existing BAM file(s), intended more as a testing tool." << endl;
-    cerr << "\tresolve         Resolves paired-end reads (marking the IsProperPair flag as needed)" << endl;
-    cerr << "\trevert          Removes duplicate marks and restores original base qualities" << endl;
-    cerr << "\tsort            Sorts the BAM file according to some criteria" << endl;
-    cerr << "\tsplit           Splits a BAM file on user-specified property, creating a new BAM output file for each value found" << endl;
-    cerr << "\tstats           Prints some basic statistics from input BAM file(s)" << endl;
-    cerr << endl;
-    cerr << "See 'bamtools help COMMAND' for more information on a specific command." << endl;
-    cerr << endl;
-    return EXIT_SUCCESS;
-}
-
-// print version info
-int Version(void) {
-
-    stringstream versionStream("");
-    versionStream << BAMTOOLS_VERSION_MAJOR << "."
-                  << BAMTOOLS_VERSION_MINOR << "."
-                  << BAMTOOLS_VERSION_BUILD;
-
-    cout << endl;
-    cout << "bamtools " << versionStream.str() << endl;
-    cout << "Part of BamTools API and toolkit" << endl;
-    cout << "Primary authors: Derek Barnett, Erik Garrison, Michael Stromberg" << endl;
-    cout << "(c) 2009-2012 Marth Lab, Biology Dept., Boston College" << endl;
-    cout << endl;
-    return EXIT_SUCCESS;
-}
-
-// toolkit entry point
-int main(int argc, char* argv[]) {
-
-    // just 'bamtools'
-    if ( (argc == 1) ) return Help(argc, argv);
-    
-    // 'bamtools help', 'bamtools --help', or 'bamtools -h'
-    if ( IsHelp(argv[1]) ) return Help(argc, argv); 
-    
-    // 'bamtools version', 'bamtools --version', or 'bamtools -v'
-    if ( IsVersion(argv[1]) ) return Version(); 
-        
-    // determine desired sub-tool, run if found
-    AbstractTool* tool = CreateTool( argv[1] );
-    if ( tool ) return tool->Run(argc, argv);
-
-    // no tool matched, show help
-    return Help(argc, argv);
-}
diff --git a/bamtools/src/toolkit/bamtools_convert.cpp b/bamtools/src/toolkit/bamtools_convert.cpp
deleted file mode 100644
index 54820e7..0000000
--- a/bamtools/src/toolkit/bamtools_convert.cpp
+++ /dev/null
@@ -1,919 +0,0 @@
-// ***************************************************************************
-// bamtools_convert.cpp (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 December 2012
-// ---------------------------------------------------------------------------
-// Converts between BAM and a number of other formats
-// ***************************************************************************
-
-#include "bamtools_convert.h"
-
-#include <api/BamConstants.h>
-#include <api/BamMultiReader.h>
-#include <utils/bamtools_fasta.h>
-#include <utils/bamtools_options.h>
-#include <utils/bamtools_pileup_engine.h>
-#include <utils/bamtools_utilities.h>
-using namespace BamTools;
-
-#include <fstream>
-#include <iostream>
-#include <sstream>
-#include <string>
-#include <vector>
-using namespace std;
-  
-namespace BamTools { 
-  
-// ---------------------------------------------
-// ConvertTool constants
-
-// supported conversion format command-line names
-static const string FORMAT_BED    = "bed";
-static const string FORMAT_FASTA  = "fasta";
-static const string FORMAT_FASTQ  = "fastq";
-static const string FORMAT_JSON   = "json";
-static const string FORMAT_SAM    = "sam";
-static const string FORMAT_PILEUP = "pileup";
-static const string FORMAT_YAML   = "yaml";
-
-// other constants
-static const unsigned int FASTA_LINE_MAX = 50;
-
-// ---------------------------------------------
-// ConvertPileupFormatVisitor declaration
-
-class ConvertPileupFormatVisitor : public PileupVisitor {
-
-    // ctor & dtor
-    public:
-        ConvertPileupFormatVisitor(const RefVector& references,
-                                   const string& fastaFilename,
-                                   const bool isPrintingMapQualities,
-                                   ostream* out);
-        ~ConvertPileupFormatVisitor(void);
-
-    // PileupVisitor interface implementation
-    public:
-        void Visit(const PileupPosition& pileupData);
-
-    // data members
-    private:
-        Fasta     m_fasta;
-        bool      m_hasFasta;
-        bool      m_isPrintingMapQualities;
-        ostream*  m_out;
-        RefVector m_references;
-};
-    
-} // namespace BamTools
-  
-// ---------------------------------------------
-// ConvertSettings implementation
-
-struct ConvertTool::ConvertSettings {
-
-    // flag
-    bool HasInput;
-    bool HasInputFilelist;
-    bool HasOutput;
-    bool HasFormat;
-    bool HasRegion;
-
-    // pileup flags
-    bool HasFastaFilename;
-    bool IsOmittingSamHeader;
-    bool IsPrintingPileupMapQualities;
-    
-    // options
-    vector<string> InputFiles;
-    string InputFilelist;
-    string OutputFilename;
-    string Format;
-    string Region;
-    
-    // pileup options
-    string FastaFilename;
-
-    // constructor
-    ConvertSettings(void)
-        : HasInput(false)
-        , HasInputFilelist(false)
-        , HasOutput(false)
-        , HasFormat(false)
-        , HasRegion(false)
-        , HasFastaFilename(false)
-        , IsOmittingSamHeader(false)
-        , IsPrintingPileupMapQualities(false)
-        , OutputFilename(Options::StandardOut())
-        , FastaFilename("")
-    { } 
-};    
-
-// ---------------------------------------------
-// ConvertToolPrivate implementation  
-  
-struct ConvertTool::ConvertToolPrivate {
-  
-    // ctor & dtor
-    public:
-        ConvertToolPrivate(ConvertTool::ConvertSettings* settings)
-            : m_settings(settings)
-            , m_out(cout.rdbuf())
-        { }
-
-        ~ConvertToolPrivate(void) { }
-    
-    // interface
-    public:
-        bool Run(void);
-        
-    // internal methods
-    private:
-        void PrintBed(const BamAlignment& a);
-        void PrintFasta(const BamAlignment& a);
-        void PrintFastq(const BamAlignment& a);
-        void PrintJson(const BamAlignment& a);
-        void PrintSam(const BamAlignment& a);
-        void PrintYaml(const BamAlignment& a);
-        
-        // special case - uses the PileupEngine
-        bool RunPileupConversion(BamMultiReader* reader);
-        
-    // data members
-    private: 
-        ConvertTool::ConvertSettings* m_settings;
-        RefVector m_references;
-        ostream m_out;
-};
-
-bool ConvertTool::ConvertToolPrivate::Run(void) {
- 
-    // ------------------------------------
-    // initialize conversion input/output
-        
-    // set to default input if none provided
-    if ( !m_settings->HasInput && !m_settings->HasInputFilelist )
-        m_settings->InputFiles.push_back(Options::StandardIn());
-    
-    // add files in the filelist to the input file list
-    if ( m_settings->HasInputFilelist ) {
-
-        ifstream filelist(m_settings->InputFilelist.c_str(), ios::in);
-        if ( !filelist.is_open() ) {
-            cerr << "bamtools convert ERROR: could not open input BAM file list... Aborting." << endl;
-            return false;
-        }
-
-        string line;
-        while ( getline(filelist, line) )
-            m_settings->InputFiles.push_back(line);
-    }
-
-    // open input files
-    BamMultiReader reader;
-    if ( !reader.Open(m_settings->InputFiles) ) {
-        cerr << "bamtools convert ERROR: could not open input BAM file(s)... Aborting." << endl;
-        return false;
-    }
-
-    // if input is not stdin & a region is provided, look for index files
-    if ( m_settings->HasInput && m_settings->HasRegion ) {
-        if ( !reader.LocateIndexes() ) {
-            cerr << "bamtools convert ERROR: could not locate index file(s)... Aborting." << endl;
-            return false;
-        }
-    }
-
-    // retrieve reference data
-    m_references = reader.GetReferenceData();
-
-    // set region if specified
-    BamRegion region;
-    if ( m_settings->HasRegion ) {
-        if ( Utilities::ParseRegionString(m_settings->Region, reader, region) ) {
-
-            if ( reader.HasIndexes() ) {
-                if ( !reader.SetRegion(region) ) {
-                    cerr << "bamtools convert ERROR: set region failed. Check that REGION describes a valid range" << endl;
-                    reader.Close();
-                    return false;
-                }
-            }
-
-        } else {
-            cerr << "bamtools convert ERROR: could not parse REGION: " << m_settings->Region << endl;
-            cerr << "Check that REGION is in valid format (see documentation) and that the coordinates are valid"
-                 << endl;
-            reader.Close();
-            return false;
-        }
-    }
-        
-    // if output file given
-    ofstream outFile;
-    if ( m_settings->HasOutput ) {
-      
-        // open output file stream
-        outFile.open(m_settings->OutputFilename.c_str());
-        if ( !outFile ) {
-            cerr << "bamtools convert ERROR: could not open " << m_settings->OutputFilename
-                 << " for output" << endl;
-            return false; 
-        }
-        
-        // set m_out to file's streambuf
-        m_out.rdbuf(outFile.rdbuf()); 
-    }
-    
-    // -------------------------------------
-    // do conversion based on format
-    
-     bool convertedOk = true;
-    
-    // pileup is special case
-    // conversion not done per alignment, like the other formats
-    if ( m_settings->Format == FORMAT_PILEUP )
-        convertedOk = RunPileupConversion(&reader);
-    
-    // all other formats
-    else {
-    
-        bool formatError = false;
-        
-        // set function pointer to proper conversion method
-        void (BamTools::ConvertTool::ConvertToolPrivate::*pFunction)(const BamAlignment&) = 0;
-        if      ( m_settings->Format == FORMAT_BED )   pFunction = &BamTools::ConvertTool::ConvertToolPrivate::PrintBed;
-        else if ( m_settings->Format == FORMAT_FASTA ) pFunction = &BamTools::ConvertTool::ConvertToolPrivate::PrintFasta;
-        else if ( m_settings->Format == FORMAT_FASTQ ) pFunction = &BamTools::ConvertTool::ConvertToolPrivate::PrintFastq;
-        else if ( m_settings->Format == FORMAT_JSON )  pFunction = &BamTools::ConvertTool::ConvertToolPrivate::PrintJson;
-        else if ( m_settings->Format == FORMAT_SAM )   pFunction = &BamTools::ConvertTool::ConvertToolPrivate::PrintSam;
-        else if ( m_settings->Format == FORMAT_YAML )  pFunction = &BamTools::ConvertTool::ConvertToolPrivate::PrintYaml;
-        else { 
-            cerr << "bamtools convert ERROR: unrecognized format: " << m_settings->Format << endl;
-            cerr << "Please see documentation for list of supported formats " << endl;
-            formatError = true;
-            convertedOk = false;
-        }
-        
-        // if format selected ok
-        if ( !formatError ) {
-        
-            // if SAM format & not omitting header, print SAM header first
-            if ( (m_settings->Format == FORMAT_SAM) && !m_settings->IsOmittingSamHeader ) 
-                m_out << reader.GetHeaderText();
-            
-            // iterate through file, doing conversion
-            BamAlignment a;
-            while ( reader.GetNextAlignment(a) )
-                (this->*pFunction)(a);
-            
-            // set flag for successful conversion
-            convertedOk = true;
-        }
-    }
-    
-    // ------------------------
-    // clean up & exit
-    reader.Close();
-    if ( m_settings->HasOutput )
-        outFile.close();
-    return convertedOk;   
-}
-
-// ----------------------------------------------------------
-// Conversion/output methods
-// ----------------------------------------------------------
-
-void ConvertTool::ConvertToolPrivate::PrintBed(const BamAlignment& a) { 
-  
-    // tab-delimited, 0-based half-open 
-    // (e.g. a 50-base read aligned to pos 10 could have BED coordinates (10, 60) instead of BAM coordinates (10, 59) )
-    // <chromName> <chromStart> <chromEnd> <readName> <score> <strand>
-
-    m_out << m_references.at(a.RefID).RefName << "\t"
-          << a.Position << "\t"
-          << a.GetEndPosition() << "\t"
-          << a.Name << "\t"
-          << a.MapQuality << "\t"
-          << (a.IsReverseStrand() ? "-" : "+") << endl;
-}
-
-// print BamAlignment in FASTA format
-// N.B. - uses QueryBases NOT AlignedBases
-void ConvertTool::ConvertToolPrivate::PrintFasta(const BamAlignment& a) { 
-    
-    // >BamAlignment.Name
-    // BamAlignment.QueryBases (up to FASTA_LINE_MAX bases per line)
-    // ...
-    //
-    // N.B. - QueryBases are reverse-complemented if aligned to reverse strand
-  
-    // print header
-    m_out << ">" << a.Name << endl;
-    
-    // handle reverse strand alignment - bases 
-    string sequence = a.QueryBases;
-    if ( a.IsReverseStrand() )
-        Utilities::ReverseComplement(sequence);
-    
-    // if sequence fits on single line
-    if ( sequence.length() <= FASTA_LINE_MAX )
-        m_out << sequence << endl;
-    
-    // else split over multiple lines
-    else {
-      
-        size_t position = 0;
-        size_t seqLength = sequence.length(); // handle reverse strand alignment - bases & qualitiesth();
-        
-        // write subsequences to each line
-        while ( position < (seqLength - FASTA_LINE_MAX) ) {
-            m_out << sequence.substr(position, FASTA_LINE_MAX) << endl;
-            position += FASTA_LINE_MAX;
-        }
-        
-        // write final subsequence
-        m_out << sequence.substr(position) << endl;
-    }
-}
-
-// print BamAlignment in FASTQ format
-// N.B. - uses QueryBases NOT AlignedBases
-void ConvertTool::ConvertToolPrivate::PrintFastq(const BamAlignment& a) { 
-  
-    // @BamAlignment.Name
-    // BamAlignment.QueryBases
-    // +
-    // BamAlignment.Qualities
-    //
-    // N.B. - QueryBases are reverse-complemented (& Qualities reversed) if aligned to reverse strand .
-    //        Name is appended "/1" or "/2" if paired-end, to reflect which mate this entry is.
-  
-    // handle paired-end alignments
-    string name = a.Name;
-    if ( a.IsPaired() )
-        name.append( (a.IsFirstMate() ? "/1" : "/2") );
-  
-    // handle reverse strand alignment - bases & qualities
-    string qualities = a.Qualities;
-    string sequence  = a.QueryBases;
-    if ( a.IsReverseStrand() ) {
-        Utilities::Reverse(qualities);
-        Utilities::ReverseComplement(sequence);
-    }
-  
-    // write to output stream
-    m_out << "@" << name << endl
-          << sequence    << endl
-          << "+"         << endl
-          << qualities   << endl;
-}
-
-// print BamAlignment in JSON format
-void ConvertTool::ConvertToolPrivate::PrintJson(const BamAlignment& a) {
-  
-    // write name & alignment flag
-    m_out << "{\"name\":\"" << a.Name << "\",\"alignmentFlag\":\"" << a.AlignmentFlag << "\",";
-    
-    // write reference name
-    if ( (a.RefID >= 0) && (a.RefID < (int)m_references.size()) ) 
-        m_out << "\"reference\":\"" << m_references[a.RefID].RefName << "\",";
-    
-    // write position & map quality
-    m_out << "\"position\":" << a.Position+1 << ",\"mapQuality\":" << a.MapQuality << ",";
-    
-    // write CIGAR
-    const vector<CigarOp>& cigarData = a.CigarData;
-    if ( !cigarData.empty() ) {
-        m_out << "\"cigar\":[";
-        vector<CigarOp>::const_iterator cigarBegin = cigarData.begin();
-        vector<CigarOp>::const_iterator cigarIter  = cigarBegin;
-        vector<CigarOp>::const_iterator cigarEnd   = cigarData.end();
-        for ( ; cigarIter != cigarEnd; ++cigarIter ) {
-            const CigarOp& op = (*cigarIter);
-            if (cigarIter != cigarBegin)
-                m_out << ",";
-            m_out << "\"" << op.Length << op.Type << "\"";
-        }
-        m_out << "],";
-    }
-    
-    // write mate reference name, mate position, & insert size
-    if ( a.IsPaired() && (a.MateRefID >= 0) && (a.MateRefID < (int)m_references.size()) ) {
-        m_out << "\"mate\":{"
-              << "\"reference\":\"" << m_references[a.MateRefID].RefName << "\","
-              << "\"position\":" << a.MatePosition+1
-              << ",\"insertSize\":" << a.InsertSize << "},";
-    }
-    
-    // write sequence
-    if ( !a.QueryBases.empty() ) 
-        m_out << "\"queryBases\":\"" << a.QueryBases << "\",";
-    
-    // write qualities
-    if ( !a.Qualities.empty() && a.Qualities.at(0) != (char)0xFF ) {
-        string::const_iterator s = a.Qualities.begin();
-        m_out << "\"qualities\":[" << static_cast<short>(*s) - 33;
-        ++s;
-        for ( ; s != a.Qualities.end(); ++s )
-            m_out << "," << static_cast<short>(*s) - 33;
-        m_out << "],";
-    }
-    
-    // write alignment's source BAM file
-    m_out << "\"filename\":\"" << a.Filename << "\",";
-
-    // write tag data
-    const char* tagData = a.TagData.c_str();
-    const size_t tagDataLength = a.TagData.length();
-    size_t index = 0;
-    if ( index < tagDataLength ) {
-
-        m_out << "\"tags\":{";
-        
-        while ( index < tagDataLength ) {
-
-            if ( index > 0 )
-                m_out << ",";
-            
-            // write tag name
-            m_out << "\"" << a.TagData.substr(index, 2) << "\":";
-            index += 2;
-            
-            // get data type
-            char type = a.TagData.at(index);
-            ++index;
-            switch ( type ) {
-                case (Constants::BAM_TAG_TYPE_ASCII) :
-                    m_out << "\"" << tagData[index] << "\"";
-                    ++index; 
-                    break;
-                
-                case (Constants::BAM_TAG_TYPE_INT8) :
-                    // force value into integer-type (instead of char value)
-                    m_out << static_cast<int16_t>(tagData[index]);
-                    ++index;
-                    break;
-
-                case (Constants::BAM_TAG_TYPE_UINT8) :
-                    // force value into integer-type (instead of char value)
-                    m_out << static_cast<uint16_t>(tagData[index]);
-                    ++index; 
-                    break;
-                
-                case (Constants::BAM_TAG_TYPE_INT16) :
-                    m_out << BamTools::UnpackSignedShort(&tagData[index]);
-                    index += sizeof(int16_t);
-                    break;
-
-                case (Constants::BAM_TAG_TYPE_UINT16) :
-                    m_out << BamTools::UnpackUnsignedShort(&tagData[index]);
-                    index += sizeof(uint16_t);
-                    break;
-                    
-                case (Constants::BAM_TAG_TYPE_INT32) :
-                    m_out << BamTools::UnpackSignedInt(&tagData[index]);
-                    index += sizeof(int32_t);
-                    break;
-
-                case (Constants::BAM_TAG_TYPE_UINT32) :
-                    m_out << BamTools::UnpackUnsignedInt(&tagData[index]);
-                    index += sizeof(uint32_t);
-                    break;
-
-                case (Constants::BAM_TAG_TYPE_FLOAT) :
-                    m_out << BamTools::UnpackFloat(&tagData[index]);
-                    index += sizeof(float);
-                    break;
-                
-                case (Constants::BAM_TAG_TYPE_HEX)    :
-                case (Constants::BAM_TAG_TYPE_STRING) :
-                    m_out << "\""; 
-                    while (tagData[index]) {
-                        if (tagData[index] == '\"')
-                            m_out << "\\\""; // escape for json
-                        else
-                            m_out << tagData[index];
-                        ++index;
-                    }
-                    m_out << "\""; 
-                    ++index; 
-                    break;      
-            }
-            
-            if ( tagData[index] == '\0') 
-                break;
-        }
-
-        m_out << "}";
-    }
-
-    m_out << "}" << endl;
-}
-
-// print BamAlignment in SAM format
-void ConvertTool::ConvertToolPrivate::PrintSam(const BamAlignment& a) {
-  
-    // tab-delimited
-    // <QNAME> <FLAG> <RNAME> <POS> <MAPQ> <CIGAR> <MRNM> <MPOS> <ISIZE> <SEQ> <QUAL> [ <TAG>:<VTYPE>:<VALUE> [...] ]
-  
-    // write name & alignment flag
-   m_out << a.Name << "\t" << a.AlignmentFlag << "\t";
-
-    // write reference name
-    if ( (a.RefID >= 0) && (a.RefID < (int)m_references.size()) ) 
-        m_out << m_references[a.RefID].RefName << "\t";
-    else 
-        m_out << "*\t";
-    
-    // write position & map quality
-    m_out << a.Position+1 << "\t" << a.MapQuality << "\t";
-    
-    // write CIGAR
-    const vector<CigarOp>& cigarData = a.CigarData;
-    if ( cigarData.empty() ) m_out << "*\t";
-    else {
-        vector<CigarOp>::const_iterator cigarIter = cigarData.begin();
-        vector<CigarOp>::const_iterator cigarEnd  = cigarData.end();
-        for ( ; cigarIter != cigarEnd; ++cigarIter ) {
-            const CigarOp& op = (*cigarIter);
-            m_out << op.Length << op.Type;
-        }
-        m_out << "\t";
-    }
-    
-    // write mate reference name, mate position, & insert size
-    if ( a.IsPaired() && (a.MateRefID >= 0) && (a.MateRefID < (int)m_references.size()) ) {
-        if ( a.MateRefID == a.RefID )
-            m_out << "=\t";
-        else
-           m_out << m_references[a.MateRefID].RefName << "\t";
-        m_out << a.MatePosition+1 << "\t" << a.InsertSize << "\t";
-    } 
-    else
-        m_out << "*\t0\t0\t";
-    
-    // write sequence
-    if ( a.QueryBases.empty() )
-        m_out << "*\t";
-    else
-        m_out << a.QueryBases << "\t";
-    
-    // write qualities
-    if ( a.Qualities.empty() || (a.Qualities.at(0) == (char)0xFF) )
-        m_out << "*";
-    else
-        m_out << a.Qualities;
-    
-    // write tag data
-    const char* tagData = a.TagData.c_str();
-    const size_t tagDataLength = a.TagData.length();
-    
-    size_t index = 0;
-    while ( index < tagDataLength ) {
-
-        // write tag name   
-        string tagName = a.TagData.substr(index, 2);
-        m_out << "\t" << tagName << ":";
-        index += 2;
-        
-        // get data type
-        char type = a.TagData.at(index);
-        ++index;
-        switch ( type ) {
-            case (Constants::BAM_TAG_TYPE_ASCII) :
-                m_out << "A:" << tagData[index];
-                ++index;
-                break;
-
-            case (Constants::BAM_TAG_TYPE_INT8) :
-                // force value into integer-type (instead of char value)
-                m_out << "i:" << static_cast<int16_t>(tagData[index]);
-                ++index;
-                break;
-
-            case (Constants::BAM_TAG_TYPE_UINT8) :
-                // force value into integer-type (instead of char value)
-                m_out << "i:" << static_cast<uint16_t>(tagData[index]);
-                ++index;
-                break;
-
-            case (Constants::BAM_TAG_TYPE_INT16) :
-                m_out << "i:" << BamTools::UnpackSignedShort(&tagData[index]);
-                index += sizeof(int16_t);
-                break;
-
-            case (Constants::BAM_TAG_TYPE_UINT16) :
-                m_out << "i:" << BamTools::UnpackUnsignedShort(&tagData[index]);
-                index += sizeof(uint16_t);
-                break;
-
-            case (Constants::BAM_TAG_TYPE_INT32) :
-                m_out << "i:" << BamTools::UnpackSignedInt(&tagData[index]);
-                index += sizeof(int32_t);
-                break;
-
-            case (Constants::BAM_TAG_TYPE_UINT32) :
-                m_out << "i:" << BamTools::UnpackUnsignedInt(&tagData[index]);
-                index += sizeof(uint32_t);
-                break;
-
-            case (Constants::BAM_TAG_TYPE_FLOAT) :
-                m_out << "f:" << BamTools::UnpackFloat(&tagData[index]);
-                index += sizeof(float);
-                break;
-
-            case (Constants::BAM_TAG_TYPE_HEX)    : // fall-through
-            case (Constants::BAM_TAG_TYPE_STRING) :
-                m_out << type << ":";
-                while (tagData[index]) {
-                    m_out << tagData[index];
-                    ++index;
-                }
-                ++index;
-                break;
-        }
-
-        if ( tagData[index] == '\0' )
-            break;
-    }
-
-    m_out << endl;
-}
-
-// Print BamAlignment in YAML format
-void ConvertTool::ConvertToolPrivate::PrintYaml(const BamAlignment& a) {
-
-    // write alignment name
-    m_out << "---" << endl;
-    m_out << a.Name << ":" << endl;
-
-    // write alignment data
-    m_out << "   " << "AlndBases: "     << a.AlignedBases << endl;
-    m_out << "   " << "Qualities: "     << a.Qualities << endl;
-    m_out << "   " << "Name: "          << a.Name << endl;
-    m_out << "   " << "Length: "        << a.Length << endl;
-    m_out << "   " << "TagData: "       << a.TagData << endl;
-    m_out << "   " << "RefID: "         << a.RefID << endl;
-    m_out << "   " << "RefName: "       << m_references[a.RefID].RefName << endl;
-    m_out << "   " << "Position: "      << a.Position << endl;
-    m_out << "   " << "Bin: "           << a.Bin << endl;
-    m_out << "   " << "MapQuality: "    << a.MapQuality << endl;
-    m_out << "   " << "AlignmentFlag: " << a.AlignmentFlag << endl;
-    m_out << "   " << "MateRefID: "     << a.MateRefID << endl;
-    m_out << "   " << "MatePosition: "  << a.MatePosition << endl;
-    m_out << "   " << "InsertSize: "    << a.InsertSize << endl;
-    m_out << "   " << "Filename: "      << a.Filename << endl;
-
-    // write Cigar data
-    const vector<CigarOp>& cigarData = a.CigarData;
-    if ( !cigarData.empty() ) {
-        m_out << "   " <<  "Cigar: ";
-        vector<CigarOp>::const_iterator cigarBegin = cigarData.begin();
-        vector<CigarOp>::const_iterator cigarIter  = cigarBegin;
-        vector<CigarOp>::const_iterator cigarEnd   = cigarData.end();
-        for ( ; cigarIter != cigarEnd; ++cigarIter ) {
-            const CigarOp& op = (*cigarIter);
-            m_out << op.Length << op.Type;
-        }
-        m_out << endl;
-    }
-}
-
-bool ConvertTool::ConvertToolPrivate::RunPileupConversion(BamMultiReader* reader) {
-  
-    // check for valid BamMultiReader
-    if ( reader == 0 ) return false;
-  
-    // set up our pileup format 'visitor'
-    ConvertPileupFormatVisitor* v = new ConvertPileupFormatVisitor(m_references, 
-                                                                   m_settings->FastaFilename,
-                                                                   m_settings->IsPrintingPileupMapQualities, 
-                                                                   &m_out);
-
-    // set up PileupEngine
-    PileupEngine pileup;
-    pileup.AddVisitor(v);
-    
-    // iterate through data
-    BamAlignment al;
-    while ( reader->GetNextAlignment(al) )
-        pileup.AddAlignment(al);
-    pileup.Flush();
-    
-    // clean up
-    delete v;
-    v = 0;
-    
-    // return success
-    return true;
-}       
-
-// ---------------------------------------------
-// ConvertTool implementation
-
-ConvertTool::ConvertTool(void)
-    : AbstractTool()
-    , m_settings(new ConvertSettings)
-    , m_impl(0)
-{
-    // set program details
-    Options::SetProgramInfo("bamtools convert", "converts BAM to a number of other formats",
-                            "-format <FORMAT> [-in <filename> -in <filename> ... | -list <filelist>] [-out <filename>] [-region <REGION>] [format-specific options]");
-    
-    // set up options 
-    OptionGroup* IO_Opts = Options::CreateOptionGroup("Input & Output");
-    Options::AddValueOption("-in",     "BAM filename", "the input BAM file(s)", "", m_settings->HasInput,   m_settings->InputFiles,     IO_Opts, Options::StandardIn());
-    Options::AddValueOption("-list",   "filename", "the input BAM file list, one line per file", "", m_settings->HasInputFilelist,  m_settings->InputFilelist, IO_Opts);
-    Options::AddValueOption("-out",    "BAM filename", "the output BAM file",   "", m_settings->HasOutput,  m_settings->OutputFilename, IO_Opts, Options::StandardOut());
-    Options::AddValueOption("-format", "FORMAT", "the output file format - see README for recognized formats", "", m_settings->HasFormat, m_settings->Format, IO_Opts);
-    Options::AddValueOption("-region", "REGION", "genomic region. Index file is recommended for better performance, and is used automatically if it exists. See \'bamtools help index\' for more details on creating one", "", m_settings->HasRegion, m_settings->Region, IO_Opts);
-    
-    OptionGroup* PileupOpts = Options::CreateOptionGroup("Pileup Options");
-    Options::AddValueOption("-fasta", "FASTA filename", "FASTA reference file", "", m_settings->HasFastaFilename, m_settings->FastaFilename, PileupOpts);
-    Options::AddOption("-mapqual", "print the mapping qualities", m_settings->IsPrintingPileupMapQualities, PileupOpts);
-    
-    OptionGroup* SamOpts = Options::CreateOptionGroup("SAM Options");
-    Options::AddOption("-noheader", "omit the SAM header from output", m_settings->IsOmittingSamHeader, SamOpts);
-}
-
-ConvertTool::~ConvertTool(void) {
-
-    delete m_settings;
-    m_settings = 0;
-    
-    delete m_impl;
-    m_impl = 0;
-}
-
-int ConvertTool::Help(void) {
-    Options::DisplayHelp();
-    return 0;
-}
-
-int ConvertTool::Run(int argc, char* argv[]) {
-  
-    // parse command line arguments
-    Options::Parse(argc, argv, 1);
-    
-    // initialize ConvertTool with settings
-    m_impl = new ConvertToolPrivate(m_settings);
-    
-    // run ConvertTool, return success/fail
-    if ( m_impl->Run() ) 
-        return 0;
-    else 
-        return 1;
-}
-
-// ---------------------------------------------
-// ConvertPileupFormatVisitor implementation
-
-ConvertPileupFormatVisitor::ConvertPileupFormatVisitor(const RefVector& references, 
-                                                       const string& fastaFilename,
-                                                       const bool isPrintingMapQualities,
-                                                       ostream* out)
-    : PileupVisitor()
-    , m_hasFasta(false)
-    , m_isPrintingMapQualities(isPrintingMapQualities)
-    , m_out(out)
-    , m_references(references)
-{ 
-    // set up Fasta reader if file is provided
-    if ( !fastaFilename.empty() ) {
-      
-        // check for FASTA index
-        string indexFilename = "";
-        if ( Utilities::FileExists(fastaFilename + ".fai") ) 
-            indexFilename = fastaFilename + ".fai";
-      
-        // open FASTA file
-        if ( m_fasta.Open(fastaFilename, indexFilename) ) 
-            m_hasFasta = true;
-    }
-}
-
-ConvertPileupFormatVisitor::~ConvertPileupFormatVisitor(void) { 
-    // be sure to close Fasta reader
-    if ( m_hasFasta ) {
-        m_fasta.Close();
-        m_hasFasta = false;
-    }
-}
-
-void ConvertPileupFormatVisitor::Visit(const PileupPosition& pileupData ) {
-  
-    // skip if no alignments at this position
-    if ( pileupData.PileupAlignments.empty() ) return;
-  
-    // retrieve reference name
-    const string& referenceName = m_references[pileupData.RefId].RefName;
-    const int& position   = pileupData.Position;
-    
-    // retrieve reference base from FASTA file, if one provided; otherwise default to 'N'
-    char referenceBase('N');
-    if ( m_hasFasta && (pileupData.Position < m_references[pileupData.RefId].RefLength) ) {
-        if ( !m_fasta.GetBase(pileupData.RefId, pileupData.Position, referenceBase ) ) {
-            cerr << "bamtools convert ERROR: pileup conversion - could not read reference base from FASTA file" << endl;
-            return;
-        }
-    }
-    
-    // get count of alleles at this position
-    const int numberAlleles = pileupData.PileupAlignments.size();
-    
-    // -----------------------------------------------------------
-    // build strings based on alleles at this positionInAlignment
-    
-    stringstream bases("");
-    stringstream baseQualities("");
-    stringstream mapQualities("");
-    
-    // iterate over alignments at this pileup position
-    vector<PileupAlignment>::const_iterator pileupIter = pileupData.PileupAlignments.begin();
-    vector<PileupAlignment>::const_iterator pileupEnd  = pileupData.PileupAlignments.end();
-    for ( ; pileupIter != pileupEnd; ++pileupIter ) {
-        const PileupAlignment pa = (*pileupIter);
-        const BamAlignment& ba = pa.Alignment;
-        
-        // if beginning of read segment
-        if ( pa.IsSegmentBegin )
-            bases << '^' << ( ((int)ba.MapQuality > 93) ? (char)126 : (char)((int)ba.MapQuality+33) );
-        
-        // if current base is not a DELETION
-        if ( !pa.IsCurrentDeletion ) {
-          
-            // get base at current position
-            char base = ba.QueryBases.at(pa.PositionInAlignment);
-            
-            // if base matches reference
-            if ( base == '=' || 
-                 toupper(base) == toupper(referenceBase) ||
-                 tolower(base) == tolower(referenceBase) ) 
-            {
-                base = ( ba.IsReverseStrand() ? ',' : '.' );
-            }
-            
-            // mismatches reference
-            else base = ( ba.IsReverseStrand() ? tolower(base) : toupper(base) );
-            
-            // store base
-            bases << base;
-          
-            // if next position contains insertion
-            if ( pa.IsNextInsertion ) {
-                bases << '+' << pa.InsertionLength;
-                for (int i = 1; i <= pa.InsertionLength; ++i) {
-                    char insertedBase = (char)ba.QueryBases.at(pa.PositionInAlignment + i);
-                    bases << (ba.IsReverseStrand() ? (char)tolower(insertedBase) : (char)toupper(insertedBase) );
-                }
-            }
-            
-            // if next position contains DELETION
-            else if ( pa.IsNextDeletion ) {
-                bases << '-' << pa.DeletionLength;
-                for (int i = 1; i <= pa.DeletionLength; ++i) {
-                    char deletedBase('N');
-                    if ( m_hasFasta && (pileupData.Position+i < m_references[pileupData.RefId].RefLength) ) {
-                        if ( !m_fasta.GetBase(pileupData.RefId, pileupData.Position+i, deletedBase ) ) {
-                            cerr << "bamtools convert ERROR: pileup conversion - could not read reference base from FASTA file" << endl;
-                            return;
-                        }
-                    }
-                    bases << (ba.IsReverseStrand() ? (char)tolower(deletedBase) : (char)toupper(deletedBase) );
-                }
-            }
-        }
-        
-        // otherwise, DELETION
-        else bases << '*';
-        
-        // if end of read segment
-        if ( pa.IsSegmentEnd )
-            bases << '$';
-        
-        // store current base quality
-        baseQualities << ba.Qualities.at(pa.PositionInAlignment);
-        
-        // save alignment map quality if desired
-        if ( m_isPrintingMapQualities )
-            mapQualities << ( ((int)ba.MapQuality > 93) ? (char)126 : (char)((int)ba.MapQuality+33) );
-    }
-    
-    // ----------------------
-    // print results 
-    
-    // tab-delimited
-    // <refName> <1-based pos> <refBase> <numberAlleles> <bases> <qualities> [mapQuals]
-    
-    const string TAB = "\t";
-    *m_out << referenceName       << TAB 
-           << position + 1        << TAB 
-           << referenceBase       << TAB 
-           << numberAlleles       << TAB 
-           << bases.str()         << TAB 
-           << baseQualities.str() << TAB
-           << mapQualities.str()  << endl;
-}
diff --git a/bamtools/src/toolkit/bamtools_convert.h b/bamtools/src/toolkit/bamtools_convert.h
deleted file mode 100644
index 9cc3b89..0000000
--- a/bamtools/src/toolkit/bamtools_convert.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// ***************************************************************************
-// bamtools_convert.h (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 9 July 2010
-// ---------------------------------------------------------------------------
-// Converts between BAM and a number of other formats
-// ***************************************************************************
-
-#ifndef BAMTOOLS_CONVERT_H
-#define BAMTOOLS_CONVERT_H
-
-#include "bamtools_tool.h"
-
-namespace BamTools { 
-  
-class ConvertTool : public AbstractTool {
-  
-    public:
-        ConvertTool(void);
-        ~ConvertTool(void);
-
-    public:
-        int Help(void);
-        int Run(int argc, char* argv[]); 
-        
-    private: 
-        struct ConvertSettings;
-        ConvertSettings* m_settings;
-        
-        struct ConvertToolPrivate;
-        ConvertToolPrivate* m_impl;
-};
-  
-} // namespace BamTools
-
-#endif // BAMTOOLS_CONVERT_H
diff --git a/bamtools/src/toolkit/bamtools_count.cpp b/bamtools/src/toolkit/bamtools_count.cpp
deleted file mode 100644
index 5a7c0a7..0000000
--- a/bamtools/src/toolkit/bamtools_count.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-// ***************************************************************************
-// bamtools_count.cpp (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 December 2012
-// ---------------------------------------------------------------------------
-// Prints alignment count for BAM file(s)
-// ***************************************************************************
-
-#include "bamtools_count.h"
-
-#include <api/BamAlgorithms.h>
-#include <api/BamMultiReader.h>
-#include <utils/bamtools_options.h>
-#include <utils/bamtools_utilities.h>
-using namespace BamTools;
-
-#include <fstream>
-#include <iostream>
-#include <string>
-#include <vector>
-using namespace std;
-
-// ---------------------------------------------  
-// CountSettings implementation
-
-struct CountTool::CountSettings {
-
-    // flags
-    bool HasInput;
-    bool HasInputFilelist;
-    bool HasRegion;
-
-    // filenames
-    vector<string> InputFiles;
-    string InputFilelist;
-    string Region;
-    
-    // constructor
-    CountSettings(void)
-        : HasInput(false)
-        , HasInputFilelist(false)
-        , HasRegion(false)
-    { }  
-}; 
-  
-// ---------------------------------------------
-// CountToolPrivate implementation
-
-struct CountTool::CountToolPrivate {
-
-    // ctor & dtro
-    public:
-        CountToolPrivate(CountTool::CountSettings* settings)
-            : m_settings(settings)
-        { }
-
-        ~CountToolPrivate(void) { }
-
-    // interface
-    public:
-        bool Run(void);
-
-    // data members
-    private:
-        CountTool::CountSettings* m_settings;
-};
-
-bool CountTool::CountToolPrivate::Run(void) {
-
-    // set to default input if none provided
-    if ( !m_settings->HasInput && !m_settings->HasInputFilelist )
-        m_settings->InputFiles.push_back(Options::StandardIn());
-
-    // add files in the filelist to the input file list
-    if ( m_settings->HasInputFilelist ) {
-
-        ifstream filelist(m_settings->InputFilelist.c_str(), ios::in);
-        if ( !filelist.is_open() ) {
-            cerr << "bamtools count ERROR: could not open input BAM file list... Aborting." << endl;
-            return false;
-        }
-
-        string line;
-        while ( getline(filelist, line) )
-            m_settings->InputFiles.push_back(line);
-    }
-
-    // open reader without index
-    BamMultiReader reader;
-    if ( !reader.Open(m_settings->InputFiles) ) {
-        cerr << "bamtools count ERROR: could not open input BAM file(s)... Aborting." << endl;
-        return false;
-    }
-
-    // alignment counter
-    BamAlignment al;
-    int alignmentCount(0);
-
-    // if no region specified, count entire file
-    if ( !m_settings->HasRegion ) {
-        while ( reader.GetNextAlignmentCore(al) )
-            ++alignmentCount;
-    }
-
-    // otherwise attempt to use region as constraint
-    else {
-
-        // if region string parses OK
-        BamRegion region;
-        if ( Utilities::ParseRegionString(m_settings->Region, reader, region) ) {
-
-            // attempt to find index files
-            reader.LocateIndexes();
-
-            // if index data available for all BAM files, we can use SetRegion
-            if ( reader.HasIndexes() ) {
-
-                // attempt to set region on reader
-                if ( !reader.SetRegion(region.LeftRefID, region.LeftPosition, region.RightRefID, region.RightPosition) ) {
-                    cerr << "bamtools count ERROR: set region failed. Check that REGION describes a valid range" << endl;
-                    reader.Close();
-                    return false;
-                }
-
-                // everything checks out, just iterate through specified region, counting alignments
-                while ( reader.GetNextAlignmentCore(al) )
-                    ++alignmentCount;
-            }
-
-            // no index data available, we have to iterate through until we
-            // find overlapping alignments
-            else {
-                while ( reader.GetNextAlignmentCore(al) ) {
-                    if ( (al.RefID >= region.LeftRefID)  && ( (al.Position + al.Length) >= region.LeftPosition ) &&
-                          (al.RefID <= region.RightRefID) && ( al.Position <= region.RightPosition) )
-                    {
-                        ++alignmentCount;
-                    }
-                }
-            }
-        }
-
-        // error parsing REGION string
-        else {
-            cerr << "bamtools count ERROR: could not parse REGION - " << m_settings->Region << endl;
-            cerr << "Check that REGION is in valid format (see documentation) and that the coordinates are valid"
-                 << endl;
-            reader.Close();
-            return false;
-        }
-    }
-
-    // print results
-    cout << alignmentCount << endl;
-
-    // clean up & exit
-    reader.Close();
-    return true;
-}
-
-// ---------------------------------------------
-// CountTool implementation
-
-CountTool::CountTool(void) 
-    : AbstractTool()
-    , m_settings(new CountSettings)
-    , m_impl(0)
-{ 
-    // set program details
-    Options::SetProgramInfo("bamtools count", "prints number of alignments in BAM file(s)",
-                            "[-in <filename> -in <filename> ... | -list <filelist>] [-region <REGION>]");
-    
-    // set up options 
-    OptionGroup* IO_Opts = Options::CreateOptionGroup("Input & Output");
-    Options::AddValueOption("-in",     "BAM filename", "the input BAM file(s)", "", m_settings->HasInput,  m_settings->InputFiles, IO_Opts, Options::StandardIn());
-    Options::AddValueOption("-list",   "filename", "the input BAM file list, one line per file", "", m_settings->HasInputFilelist,  m_settings->InputFilelist, IO_Opts);
-    Options::AddValueOption("-region", "REGION",
-                            "genomic region. Index file is recommended for better performance, and is used automatically if it exists. See \'bamtools help index\' for more details on creating one",
-                            "", m_settings->HasRegion, m_settings->Region, IO_Opts);
-}
-
-CountTool::~CountTool(void) { 
-
-    delete m_settings;
-    m_settings = 0;
-
-    delete m_impl;
-    m_impl = 0;
-}
-
-int CountTool::Help(void) { 
-    Options::DisplayHelp();
-    return 0;
-} 
-
-int CountTool::Run(int argc, char* argv[]) { 
-
-    // parse command line arguments
-    Options::Parse(argc, argv, 1);
-
-    // initialize CountTool with settings
-    m_impl = new CountToolPrivate(m_settings);
-
-    // run CountTool, return success/fail
-    if ( m_impl->Run() )
-        return 0;
-    else
-        return 1;
-}
diff --git a/bamtools/src/toolkit/bamtools_count.h b/bamtools/src/toolkit/bamtools_count.h
deleted file mode 100644
index 553f9b0..0000000
--- a/bamtools/src/toolkit/bamtools_count.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// ***************************************************************************
-// bamtools_count.h (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 7 April 2011
-// ---------------------------------------------------------------------------
-// Prints alignment count for BAM file(s)
-// ***************************************************************************
-
-#ifndef BAMTOOLS_COUNT_H
-#define BAMTOOLS_COUNT_H
-
-#include "bamtools_tool.h"
-
-namespace BamTools { 
-  
-class CountTool : public AbstractTool {
-  
-    public:
-        CountTool(void);
-        ~CountTool(void);
-
-    public:
-        int Help(void);
-        int Run(int argc, char* argv[]); 
-        
-    private: 
-        struct CountSettings;
-        CountSettings* m_settings;
-
-        struct CountToolPrivate;
-        CountToolPrivate* m_impl;
-};
-  
-} // namespace BamTools
-
-#endif // BAMTOOLS_COUNT_H
diff --git a/bamtools/src/toolkit/bamtools_coverage.cpp b/bamtools/src/toolkit/bamtools_coverage.cpp
deleted file mode 100644
index 6a4493d..0000000
--- a/bamtools/src/toolkit/bamtools_coverage.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-// ***************************************************************************
-// bamtools_coverage.cpp (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 24 July 2013
-// ---------------------------------------------------------------------------
-// Prints coverage data for a single BAM file 
-// ***************************************************************************
-
-#include "bamtools_coverage.h"
-
-#include <api/BamReader.h>
-#include <utils/bamtools_options.h>
-#include <utils/bamtools_pileup_engine.h>
-using namespace BamTools;
-
-#include <iostream>
-#include <fstream>
-#include <string>
-#include <vector>
-using namespace std;
-  
-namespace BamTools {
- 
-// ---------------------------------------------  
-// CoverageVisitor implementation 
-  
-class CoverageVisitor : public PileupVisitor {
-  
-    public:
-        CoverageVisitor(const RefVector& references, ostream* out)
-            : PileupVisitor()
-            , m_references(references)
-            , m_out(out)
-        { }
-        ~CoverageVisitor(void) { }
-  
-    // PileupVisitor interface implementation
-    public:
-	// prints coverage results ( tab-delimited )
-        void Visit(const PileupPosition& pileupData) {
-            *m_out << m_references[pileupData.RefId].RefName << "\t" 
-                   << pileupData.Position << "\t" 
-                   << pileupData.PileupAlignments.size() << endl;
-        }
-        
-    private:
-        RefVector m_references;
-        ostream*  m_out;
-};
-
-} // namespace BamTools
-
-// ---------------------------------------------  
-// CoverageSettings implementation
-
-struct CoverageTool::CoverageSettings {
-
-    // flags
-    bool HasInputFile;
-    bool HasOutputFile;
-
-    // filenames
-    string InputBamFilename;
-    string OutputFilename;
-    
-    // constructor
-    CoverageSettings(void)
-        : HasInputFile(false)
-        , HasOutputFile(false)
-        , InputBamFilename(Options::StandardIn())
-        , OutputFilename(Options::StandardOut())
-    { } 
-};  
-
-// ---------------------------------------------
-// CoverageToolPrivate implementation
-
-struct CoverageTool::CoverageToolPrivate {
-  
-    // ctor & dtor
-    public:
-        CoverageToolPrivate(CoverageTool::CoverageSettings* settings)
-            : m_settings(settings)
-            , m_out(cout.rdbuf())
-        { }
-
-        ~CoverageToolPrivate(void) { }
-    
-    // interface
-    public:
-        bool Run(void);
-        
-    // data members
-    private: 
-        CoverageTool::CoverageSettings* m_settings;
-        ostream m_out;
-        RefVector m_references;
-};  
-
-bool CoverageTool::CoverageToolPrivate::Run(void) {  
-  
-    // if output filename given
-    ofstream outFile;
-    if ( m_settings->HasOutputFile ) {
-      
-        // open output file stream
-        outFile.open(m_settings->OutputFilename.c_str());
-        if ( !outFile ) {
-            cerr << "bamtools coverage ERROR: could not open " << m_settings->OutputFilename
-                 << " for output" << endl;
-            return false; 
-        }
-        
-        // set m_out to file's streambuf
-        m_out.rdbuf(outFile.rdbuf()); 
-    } 
-    
-    //open our BAM reader
-    BamReader reader;
-    if ( !reader.Open(m_settings->InputBamFilename) ) {
-        cerr << "bamtools coverage ERROR: could not open input BAM file: " << m_settings->InputBamFilename << endl;
-        return false;
-    }
-
-    // retrieve references
-    m_references = reader.GetReferenceData();
-    
-    // set up our output 'visitor'
-    CoverageVisitor* cv = new CoverageVisitor(m_references, &m_out);
-    
-    // set up pileup engine with 'visitor'
-    PileupEngine pileup;
-    pileup.AddVisitor(cv);
-    
-    // process input data
-    BamAlignment al;    
-    while ( reader.GetNextAlignment(al) ) 
-        pileup.AddAlignment(al);
-    pileup.Flush();
-    
-    // clean up 
-    reader.Close();
-    if ( m_settings->HasOutputFile )
-        outFile.close();
-    delete cv;
-    cv = 0;
-    
-    // return success
-    return true;
-}
-
-// ---------------------------------------------
-// CoverageTool implementation
-
-CoverageTool::CoverageTool(void) 
-    : AbstractTool()
-    , m_settings(new CoverageSettings)
-    , m_impl(0)
-{ 
-    // set program details
-    Options::SetProgramInfo("bamtools coverage", "prints coverage data for a single BAM file", "[-in <filename>] [-out <filename>]");
-    
-    // set up options 
-    OptionGroup* IO_Opts = Options::CreateOptionGroup("Input & Output");
-    Options::AddValueOption("-in",  "BAM filename", "the input BAM file", "", m_settings->HasInputFile,  m_settings->InputBamFilename, IO_Opts, Options::StandardIn());
-    Options::AddValueOption("-out", "filename",     "the output file",    "", m_settings->HasOutputFile, m_settings->OutputFilename,   IO_Opts, Options::StandardOut());
-}
-
-CoverageTool::~CoverageTool(void) { 
-
-    delete m_settings;
-    m_settings = 0;
-    
-    delete m_impl;
-    m_impl = 0;
-}
-
-int CoverageTool::Help(void) { 
-    Options::DisplayHelp();
-    return 0;
-} 
-
-int CoverageTool::Run(int argc, char* argv[]) { 
-
-    // parse command line arguments
-    Options::Parse(argc, argv, 1);
-    
-    // initialize CoverageTool with settings
-    m_impl = new CoverageToolPrivate(m_settings);
-    
-    // run CoverageTool, return success/fail
-    if ( m_impl->Run() ) 
-        return 0;
-    else 
-        return 1;
-}  
diff --git a/bamtools/src/toolkit/bamtools_coverage.h b/bamtools/src/toolkit/bamtools_coverage.h
deleted file mode 100644
index a542ec2..0000000
--- a/bamtools/src/toolkit/bamtools_coverage.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// ***************************************************************************
-// bamtools_coverage.h (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 1 August 2010
-// ---------------------------------------------------------------------------
-// Prints coverage data for a single BAM file 
-// ***************************************************************************
-
-#ifndef BAMTOOLS_COVERAGE_H
-#define BAMTOOLS_COVERAGE_H
-
-#include "bamtools_tool.h"
-
-namespace BamTools {
-  
-class CoverageTool : public AbstractTool {
-  
-    public:
-        CoverageTool(void);
-        ~CoverageTool(void);
-  
-    public:
-        int Help(void);
-        int Run(int argc, char* argv[]); 
-        
-    private:  
-        struct CoverageSettings;
-        CoverageSettings* m_settings;
-        
-        struct CoverageToolPrivate;
-        CoverageToolPrivate* m_impl;
-};
-  
-} // namespace BamTools
-
-#endif // BAMTOOLS_COVERAGE_H
diff --git a/bamtools/src/toolkit/bamtools_filter.cpp b/bamtools/src/toolkit/bamtools_filter.cpp
deleted file mode 100644
index 2f17242..0000000
--- a/bamtools/src/toolkit/bamtools_filter.cpp
+++ /dev/null
@@ -1,955 +0,0 @@
-// ***************************************************************************
-// bamtools_filter.cpp (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 3 May 2013
-// ---------------------------------------------------------------------------
-// Filters BAM file(s) according to some user-specified criteria
-// ***************************************************************************
-
-#include "bamtools_filter.h"
-
-#include <api/BamMultiReader.h>
-#include <api/BamWriter.h>
-#include <utils/bamtools_filter_engine.h>
-#include <utils/bamtools_options.h>
-#include <utils/bamtools_utilities.h>
-using namespace BamTools;
-
-#include <jsoncpp/json.h>
-using namespace Json;
-
-#include <cstdio>
-#include <fstream>
-#include <iostream>
-#include <sstream>
-#include <string>
-#include <vector>
-using namespace std;
-  
-namespace BamTools {
-  
-// -------------------------------  
-// string literal constants  
-
-// property names
-const string ALIGNMENTFLAG_PROPERTY       = "alignmentFlag";
-const string CIGAR_PROPERTY               = "cigar";
-const string INSERTSIZE_PROPERTY          = "insertSize";
-const string ISDUPLICATE_PROPERTY         = "isDuplicate";
-const string ISFAILEDQC_PROPERTY          = "isFailedQC";
-const string ISFIRSTMATE_PROPERTY         = "isFirstMate";
-const string ISMAPPED_PROPERTY            = "isMapped";
-const string ISMATEMAPPED_PROPERTY        = "isMateMapped";
-const string ISMATEREVERSESTRAND_PROPERTY = "isMateReverseStrand";
-const string ISPAIRED_PROPERTY            = "isPaired";
-const string ISPRIMARYALIGNMENT_PROPERTY  = "isPrimaryAlignment";
-const string ISPROPERPAIR_PROPERTY        = "isProperPair";
-const string ISREVERSESTRAND_PROPERTY     = "isReverseStrand";
-const string ISSECONDMATE_PROPERTY        = "isSecondMate";
-const string ISSINGLETON_PROPERTY         = "isSingleton";
-const string LENGTH_PROPERTY              = "length";
-const string MAPQUALITY_PROPERTY          = "mapQuality";
-const string MATEPOSITION_PROPERTY        = "matePosition";
-const string MATEREFERENCE_PROPERTY       = "mateReference";
-const string NAME_PROPERTY                = "name";
-const string POSITION_PROPERTY            = "position";
-const string QUERYBASES_PROPERTY          = "queryBases";
-const string REFERENCE_PROPERTY           = "reference";
-const string TAG_PROPERTY                 = "tag";
-
-// boolalpha
-const string TRUE_STR  = "true";
-const string FALSE_STR = "false";
-    
-RefVector filterToolReferences;    
-    
-struct BamAlignmentChecker {
-    bool check(const PropertyFilter& filter, const BamAlignment& al) {
-      
-        bool keepAlignment = true;
-        const PropertyMap& properties = filter.Properties;
-        PropertyMap::const_iterator propertyIter = properties.begin();
-        PropertyMap::const_iterator propertyEnd  = properties.end();
-        for ( ; propertyIter != propertyEnd; ++propertyIter ) {
-          
-            // check alignment data field depending on propertyName
-            const string& propertyName = (*propertyIter).first;
-            const PropertyFilterValue& valueFilter = (*propertyIter).second;
-            
-            if      ( propertyName == ALIGNMENTFLAG_PROPERTY )  keepAlignment &= valueFilter.check(al.AlignmentFlag);
-            else if ( propertyName == CIGAR_PROPERTY ) {
-                stringstream cigarSs;
-                const vector<CigarOp>& cigarData = al.CigarData;
-                if ( !cigarData.empty() ) {
-                    vector<CigarOp>::const_iterator cigarBegin = cigarData.begin();
-                    vector<CigarOp>::const_iterator cigarIter = cigarBegin;
-                    vector<CigarOp>::const_iterator cigarEnd  = cigarData.end();
-                    for ( ; cigarIter != cigarEnd; ++cigarIter ) {
-                        const CigarOp& op = (*cigarIter);
-                        cigarSs << op.Length << op.Type;
-                    }
-                    keepAlignment &= valueFilter.check(cigarSs.str());
-                }
-            }
-            else if ( propertyName == INSERTSIZE_PROPERTY )           keepAlignment &= valueFilter.check(al.InsertSize);
-            else if ( propertyName == ISDUPLICATE_PROPERTY )          keepAlignment &= valueFilter.check(al.IsDuplicate());
-            else if ( propertyName == ISFAILEDQC_PROPERTY )           keepAlignment &= valueFilter.check(al.IsFailedQC());
-            else if ( propertyName == ISFIRSTMATE_PROPERTY )          keepAlignment &= valueFilter.check(al.IsFirstMate());
-            else if ( propertyName == ISMAPPED_PROPERTY )             keepAlignment &= valueFilter.check(al.IsMapped());
-            else if ( propertyName == ISMATEMAPPED_PROPERTY )         keepAlignment &= valueFilter.check(al.IsMateMapped());
-            else if ( propertyName == ISMATEREVERSESTRAND_PROPERTY )  keepAlignment &= valueFilter.check(al.IsMateReverseStrand());
-            else if ( propertyName == ISPAIRED_PROPERTY )             keepAlignment &= valueFilter.check(al.IsPaired());
-            else if ( propertyName == ISPRIMARYALIGNMENT_PROPERTY )   keepAlignment &= valueFilter.check(al.IsPrimaryAlignment());
-            else if ( propertyName == ISPROPERPAIR_PROPERTY )         keepAlignment &= valueFilter.check(al.IsProperPair());
-            else if ( propertyName == ISREVERSESTRAND_PROPERTY )      keepAlignment &= valueFilter.check(al.IsReverseStrand());
-            else if ( propertyName == ISSECONDMATE_PROPERTY )         keepAlignment &= valueFilter.check(al.IsSecondMate());
-            else if ( propertyName == ISSINGLETON_PROPERTY ) {
-                const bool isSingleton = al.IsPaired() && al.IsMapped() && !al.IsMateMapped();
-                keepAlignment &= valueFilter.check(isSingleton);
-            }
-            else if ( propertyName == LENGTH_PROPERTY )               keepAlignment &= valueFilter.check(al.Length);
-            else if ( propertyName == MAPQUALITY_PROPERTY )           keepAlignment &= valueFilter.check(al.MapQuality);
-            else if ( propertyName == MATEPOSITION_PROPERTY )         keepAlignment &= ( al.IsPaired() && al.IsMateMapped() && valueFilter.check(al.MateRefID) );
-            else if ( propertyName == MATEREFERENCE_PROPERTY ) {
-                if ( !al.IsPaired() || !al.IsMateMapped() ) return false;
-                BAMTOOLS_ASSERT_MESSAGE( (al.MateRefID>=0 && (al.MateRefID<(int)filterToolReferences.size())), "Invalid MateRefID");
-                const string& refName = filterToolReferences.at(al.MateRefID).RefName;
-                keepAlignment &= valueFilter.check(refName);
-            }
-            else if ( propertyName == NAME_PROPERTY )                 keepAlignment &= valueFilter.check(al.Name);
-            else if ( propertyName == POSITION_PROPERTY )             keepAlignment &= valueFilter.check(al.Position);
-            else if ( propertyName == QUERYBASES_PROPERTY )           keepAlignment &= valueFilter.check(al.QueryBases);
-            else if ( propertyName == REFERENCE_PROPERTY ) {
-                BAMTOOLS_ASSERT_MESSAGE( (al.RefID>=0 && (al.RefID<(int)filterToolReferences.size())), "Invalid RefID");
-                const string& refName = filterToolReferences.at(al.RefID).RefName;
-                keepAlignment &= valueFilter.check(refName);
-            }
-            else if ( propertyName == TAG_PROPERTY ) keepAlignment &= checkAlignmentTag(valueFilter, al);
-            else BAMTOOLS_ASSERT_UNREACHABLE;
-            
-            // if alignment fails at ANY point, just quit and return false
-            if ( !keepAlignment ) return false;
-        }
-      
-        BAMTOOLS_ASSERT_MESSAGE( keepAlignment, "Error in BamAlignmentChecker... keepAlignment should be true here");
-        return keepAlignment;
-    }
-    
-    bool checkAlignmentTag(const PropertyFilterValue& valueFilter, const BamAlignment& al) {
-     
-        // ensure filter contains string data
-        Variant entireTagFilter = valueFilter.Value;
-        if ( !entireTagFilter.is_type<string>() ) return false;
-
-        // localize string from variant
-        const string& entireTagFilterString = entireTagFilter.get<string>();
-
-        // ensure we have at least "XX:x"
-        if ( entireTagFilterString.length() < 4 ) return false;
-
-        // get tagName & lookup in alignment
-        // if found, set tagType to tag type character
-        // if not found, return false
-        const string& tagName = entireTagFilterString.substr(0,2);
-        char tagType = '\0';
-        if ( !al.GetTagType(tagName, tagType) ) return false;
-
-        // remove tagName & ":" from beginning tagFilter
-        string tagFilterString = entireTagFilterString.substr(3);
-
-        // switch on tag type to set tag query value & parse filter token
-        int8_t   asciiFilterValue,   asciiQueryValue;
-        int32_t  intFilterValue,    intQueryValue;
-        uint32_t uintFilterValue,   uintQueryValue;
-        float    realFilterValue,   realQueryValue;
-        string   stringFilterValue, stringQueryValue;
-
-        PropertyFilterValue tagFilter;
-        PropertyFilterValue::ValueCompareType compareType;
-        bool keepAlignment = false;
-        switch (tagType) {
-
-            // ASCII tag type
-            case 'A':
-                if ( al.GetTag(tagName, asciiQueryValue) ) {
-                    if ( FilterEngine<BamAlignmentChecker>::parseToken(tagFilterString, asciiFilterValue, compareType) ) {
-                        tagFilter.Value = asciiFilterValue;
-                        tagFilter.Type  = compareType;
-                        keepAlignment   = tagFilter.check(asciiQueryValue);
-                    }
-                }
-                break;
-
-            // signed int tag type
-            case 'c' :
-            case 's' :
-            case 'i' :
-                if ( al.GetTag(tagName, intQueryValue) ) {
-                    if ( FilterEngine<BamAlignmentChecker>::parseToken(tagFilterString, intFilterValue, compareType) ) {
-                        tagFilter.Value = intFilterValue;
-                        tagFilter.Type  = compareType;
-                        keepAlignment   = tagFilter.check(intQueryValue);
-                    }
-                }
-                break;
-
-            // unsigned int tag type
-            case 'C' :
-            case 'S' :
-            case 'I' :
-                if ( al.GetTag(tagName, uintQueryValue) ) {
-                    if ( FilterEngine<BamAlignmentChecker>::parseToken(tagFilterString, uintFilterValue, compareType) ) {
-                        tagFilter.Value = uintFilterValue;
-                        tagFilter.Type  = compareType;
-                        keepAlignment   = tagFilter.check(uintQueryValue);
-                    }
-                }
-                break;
-
-            // 'real' tag type
-            case 'f' :
-                if ( al.GetTag(tagName, realQueryValue) ) {
-                    if ( FilterEngine<BamAlignmentChecker>::parseToken(tagFilterString, realFilterValue, compareType) ) {
-                        tagFilter.Value = realFilterValue;
-                        tagFilter.Type  = compareType;
-                        keepAlignment   = tagFilter.check(realQueryValue);
-                    }
-                }
-                break;
-
-            // string tag type
-
-            case 'Z':
-            case 'H':
-                if ( al.GetTag(tagName, stringQueryValue) ) {
-                    if ( FilterEngine<BamAlignmentChecker>::parseToken(tagFilterString, stringFilterValue, compareType) ) {
-                        tagFilter.Value = stringFilterValue;
-                        tagFilter.Type  = compareType;
-                        keepAlignment   = tagFilter.check(stringQueryValue);
-                    }
-                }
-                break;
-
-            // unknown tag type
-            default :
-                keepAlignment = false;
-        }
-
-        return keepAlignment;
-    }
-};    
-    
-} // namespace BamTools
-  
-// ---------------------------------------------
-// FilterSettings implementation
-
-struct FilterTool::FilterSettings {
-
-    // ----------------------------------
-    // IO opts
-
-    // flags
-    bool HasInput;
-    bool HasInputFilelist;
-    bool HasOutput;
-    bool HasRegion;
-    bool HasScript;
-    bool IsForceCompression;
-
-    // filenames
-    vector<string> InputFiles;
-    string InputFilelist;
-    string OutputFilename;
-    string Region;
-    string ScriptFilename;
-
-    // -----------------------------------
-    // General filter opts
-
-    // flags
-    bool HasAlignmentFlagFilter;
-    bool HasInsertSizeFilter;
-    bool HasLengthFilter;
-    bool HasMapQualityFilter;
-    bool HasNameFilter;
-    bool HasQueryBasesFilter;
-    bool HasTagFilter; //(s)
-
-    // filters
-    string AlignmentFlagFilter;
-    string InsertSizeFilter;
-    string LengthFilter;
-    string MapQualityFilter;
-    string NameFilter;
-    string QueryBasesFilter;
-    string TagFilter;  // support multiple ?
-
-    // -----------------------------------
-    // AlignmentFlag filter opts
-
-    // flags
-    bool HasIsDuplicateFilter;
-    bool HasIsFailedQCFilter;
-    bool HasIsFirstMateFilter;
-    bool HasIsMappedFilter;
-    bool HasIsMateMappedFilter;
-    bool HasIsMateReverseStrandFilter;
-    bool HasIsPairedFilter;
-    bool HasIsPrimaryAlignmentFilter;
-    bool HasIsProperPairFilter;
-    bool HasIsReverseStrandFilter;
-    bool HasIsSecondMateFilter;
-    bool HasIsSingletonFilter;
-
-    // filters
-    string IsDuplicateFilter;
-    string IsFailedQCFilter;
-    string IsFirstMateFilter;
-    string IsMappedFilter;
-    string IsMateMappedFilter;
-    string IsMateReverseStrandFilter;
-    string IsPairedFilter;
-    string IsPrimaryAlignmentFilter;
-    string IsProperPairFilter;
-    string IsReverseStrandFilter;
-    string IsSecondMateFilter;
-    string IsSingletonFilter;
-
-    // ---------------------------------
-    // constructor
-
-    FilterSettings(void)
-        : HasInput(false)
-        , HasInputFilelist(false)
-        , HasOutput(false)
-        , HasRegion(false)
-        , HasScript(false)
-        , IsForceCompression(false)
-        , OutputFilename(Options::StandardOut())
-        , HasAlignmentFlagFilter(false)
-        , HasInsertSizeFilter(false)
-        , HasLengthFilter(false)
-        , HasMapQualityFilter(false)
-        , HasNameFilter(false)
-        , HasQueryBasesFilter(false)
-        , HasTagFilter(false)
-        , HasIsDuplicateFilter(false)
-        , HasIsFailedQCFilter(false)
-        , HasIsFirstMateFilter(false)
-        , HasIsMappedFilter(false)
-        , HasIsMateMappedFilter(false)
-        , HasIsMateReverseStrandFilter(false)
-        , HasIsPairedFilter(false)
-        , HasIsPrimaryAlignmentFilter(false)
-        , HasIsProperPairFilter(false)
-        , HasIsReverseStrandFilter(false)
-        , HasIsSecondMateFilter(false)
-        , HasIsSingletonFilter(false)
-        , IsDuplicateFilter(TRUE_STR)
-        , IsFailedQCFilter(TRUE_STR)
-        , IsFirstMateFilter(TRUE_STR)
-        , IsMappedFilter(TRUE_STR)
-        , IsMateMappedFilter(TRUE_STR)
-        , IsMateReverseStrandFilter(TRUE_STR)
-        , IsPairedFilter(TRUE_STR)
-        , IsPrimaryAlignmentFilter(TRUE_STR)
-        , IsProperPairFilter(TRUE_STR)
-        , IsReverseStrandFilter(TRUE_STR)
-        , IsSecondMateFilter(TRUE_STR)
-        , IsSingletonFilter(TRUE_STR)
-    { }
-};
-
-// ---------------------------------------------
-// FilterToolPrivate declaration
-
-class FilterTool::FilterToolPrivate {
-      
-    // ctor & dtor
-    public:
-        FilterToolPrivate(FilterTool::FilterSettings* settings);
-        ~FilterToolPrivate(void);  
-        
-    // 'public' interface
-    public:
-        bool Run(void);
-        
-    // internal methods
-    private:
-        bool AddPropertyTokensToFilter(const string& filterName, const map<string, string>& propertyTokens);
-        bool CheckAlignment(const BamAlignment& al);
-        const string GetScriptContents(void);
-        void InitProperties(void);
-        bool ParseCommandLine(void);
-        bool ParseFilterObject(const string& filterName, const Json::Value& filterObject);
-        bool ParseScript(void);
-        bool SetupFilters(void);
-        
-    // data members
-    private:
-        vector<string> m_propertyNames;
-        FilterTool::FilterSettings* m_settings;
-        FilterEngine<BamAlignmentChecker> m_filterEngine;
-};
- 
-// ---------------------------------------------
-// FilterToolPrivate implementation
-  
-// constructor  
-FilterTool::FilterToolPrivate::FilterToolPrivate(FilterTool::FilterSettings* settings)
-    : m_settings(settings)
-{ }  
-  
-// destructor
-FilterTool::FilterToolPrivate::~FilterToolPrivate(void) { }
-
-bool FilterTool::FilterToolPrivate::AddPropertyTokensToFilter(const string& filterName,
-                                                              const map<string,
-                                                              string>& propertyTokens)
-{
-    // dummy temp values for token parsing
-    bool boolValue;
-    int32_t int32Value;
-    uint16_t uint16Value;
-    uint32_t uint32Value;
-    string stringValue;
-    PropertyFilterValue::ValueCompareType type;
-  
-    // iterate over property token map
-    map<string, string>::const_iterator mapIter = propertyTokens.begin();
-    map<string, string>::const_iterator mapEnd  = propertyTokens.end();
-    for ( ; mapIter != mapEnd; ++mapIter ) {
-      
-        const string& propertyName = (*mapIter).first;
-        const string& token        = (*mapIter).second;
-        
-        // ------------------------------
-        // convert token to value & compare type 
-        // then add to filter engine
-        
-        // bool conversion
-        if ( propertyName == ISDUPLICATE_PROPERTY ||
-             propertyName == ISFAILEDQC_PROPERTY ||
-             propertyName == ISFIRSTMATE_PROPERTY ||
-             propertyName == ISMAPPED_PROPERTY ||
-             propertyName == ISMATEMAPPED_PROPERTY ||
-             propertyName == ISMATEREVERSESTRAND_PROPERTY ||
-             propertyName == ISPAIRED_PROPERTY ||
-             propertyName == ISPRIMARYALIGNMENT_PROPERTY ||
-             propertyName == ISPROPERPAIR_PROPERTY ||
-             propertyName == ISREVERSESTRAND_PROPERTY ||
-             propertyName == ISSECONDMATE_PROPERTY ||
-             propertyName == ISSINGLETON_PROPERTY
-           ) 
-        {
-            FilterEngine<BamAlignmentChecker>::parseToken(token, boolValue, type);
-            m_filterEngine.setProperty(filterName, propertyName, boolValue, type);
-        }
-        
-        // int32_t conversion
-        else if ( propertyName == INSERTSIZE_PROPERTY ||
-                  propertyName == LENGTH_PROPERTY ||
-                  propertyName == MATEPOSITION_PROPERTY ||
-                  propertyName == POSITION_PROPERTY 
-                ) 
-        {
-            FilterEngine<BamAlignmentChecker>::parseToken(token, int32Value, type);
-            m_filterEngine.setProperty(filterName, propertyName, int32Value, type);
-        }
-        
-        // uint16_t conversion
-        else if ( propertyName == MAPQUALITY_PROPERTY )
-        {
-            FilterEngine<BamAlignmentChecker>::parseToken(token, uint16Value, type);
-            m_filterEngine.setProperty(filterName, propertyName, uint16Value, type);
-        }
-        
-        // uint32_t conversion
-        else if ( propertyName == ALIGNMENTFLAG_PROPERTY )
-        {
-            FilterEngine<BamAlignmentChecker>::parseToken(token, uint32Value, type);
-            m_filterEngine.setProperty(filterName, propertyName, uint32Value, type);
-        }
-        
-        // string conversion
-        else if ( propertyName == CIGAR_PROPERTY || 
-                  propertyName == MATEREFERENCE_PROPERTY ||
-                  propertyName == NAME_PROPERTY ||
-                  propertyName == QUERYBASES_PROPERTY ||
-                  propertyName == REFERENCE_PROPERTY 
-                ) 
-        {
-            FilterEngine<BamAlignmentChecker>::parseToken(token, stringValue, type);
-            m_filterEngine.setProperty(filterName, propertyName, stringValue, type);
-        }
-      
-        else if ( propertyName == TAG_PROPERTY ) {
-            // this will be stored directly as the TAG:VALUE token
-            // (VALUE may contain compare ops, will be parsed out later)
-            m_filterEngine.setProperty(filterName, propertyName, token, PropertyFilterValue::EXACT);
-        }
-      
-        // else unknown property 
-        else {
-            cerr << "bamtools filter ERROR: unknown property - " << propertyName << endl;
-            return false;
-        }
-    }
-    return true;
-}
-
-bool FilterTool::FilterToolPrivate::CheckAlignment(const BamAlignment& al) {
-    return m_filterEngine.check(al);
-}
-
-const string FilterTool::FilterToolPrivate::GetScriptContents(void) {
-  
-    // open script for reading
-    FILE* inFile = fopen(m_settings->ScriptFilename.c_str(), "rb");
-    if ( !inFile ) {
-        cerr << "bamtools filter ERROR: could not open script: "
-             << m_settings->ScriptFilename << " for reading" << endl;
-        return string();
-    }
-    
-    // read in entire script contents  
-    char buffer[1024];
-    ostringstream docStream("");
-    while ( true ) {
-        
-        // peek ahead, make sure there is data available
-        char ch = fgetc(inFile);
-        ungetc(ch, inFile);
-        if( feof(inFile) )
-            break;
-        
-        // read next block of data
-        if ( fgets(buffer, 1024, inFile) == 0 ) {
-            cerr << "bamtools filter ERROR: could not read script contents" << endl;
-            return string();
-        }
-        
-        docStream << buffer;
-    }
-    
-    // close script file
-    fclose(inFile);
-    
-    // import buffer contents to document, return
-    return docStream.str();
-}
-
-void FilterTool::FilterToolPrivate::InitProperties(void) {
-  
-    // store property names in vector 
-    m_propertyNames.push_back(ALIGNMENTFLAG_PROPERTY);
-    m_propertyNames.push_back(CIGAR_PROPERTY);
-    m_propertyNames.push_back(INSERTSIZE_PROPERTY);
-    m_propertyNames.push_back(ISDUPLICATE_PROPERTY);
-    m_propertyNames.push_back(ISFAILEDQC_PROPERTY);
-    m_propertyNames.push_back(ISFIRSTMATE_PROPERTY);
-    m_propertyNames.push_back(ISMAPPED_PROPERTY);
-    m_propertyNames.push_back(ISMATEMAPPED_PROPERTY);
-    m_propertyNames.push_back(ISMATEREVERSESTRAND_PROPERTY);
-    m_propertyNames.push_back(ISPAIRED_PROPERTY);
-    m_propertyNames.push_back(ISPRIMARYALIGNMENT_PROPERTY);
-    m_propertyNames.push_back(ISPROPERPAIR_PROPERTY);
-    m_propertyNames.push_back(ISREVERSESTRAND_PROPERTY);
-    m_propertyNames.push_back(ISSECONDMATE_PROPERTY);
-    m_propertyNames.push_back(ISSINGLETON_PROPERTY);
-    m_propertyNames.push_back(LENGTH_PROPERTY);
-    m_propertyNames.push_back(MAPQUALITY_PROPERTY);
-    m_propertyNames.push_back(MATEPOSITION_PROPERTY);
-    m_propertyNames.push_back(MATEREFERENCE_PROPERTY);
-    m_propertyNames.push_back(NAME_PROPERTY);
-    m_propertyNames.push_back(POSITION_PROPERTY);
-    m_propertyNames.push_back(QUERYBASES_PROPERTY);
-    m_propertyNames.push_back(REFERENCE_PROPERTY);
-    m_propertyNames.push_back(TAG_PROPERTY);
-    
-    // add vector contents to FilterEngine<BamAlignmentChecker>
-    vector<string>::const_iterator propertyNameIter = m_propertyNames.begin();
-    vector<string>::const_iterator propertyNameEnd  = m_propertyNames.end();
-    for ( ; propertyNameIter != propertyNameEnd; ++propertyNameIter )
-        m_filterEngine.addProperty((*propertyNameIter));
-}
-
-bool FilterTool::FilterToolPrivate::ParseCommandLine(void) {
-  
-    // add a rule set to filter engine
-    const string CMD = "COMMAND_LINE";
-    m_filterEngine.addFilter(CMD);
-
-    // map property names to command line args
-    map<string, string> propertyTokens;
-    if ( m_settings->HasAlignmentFlagFilter )       propertyTokens.insert( make_pair(ALIGNMENTFLAG_PROPERTY,       m_settings->AlignmentFlagFilter) );
-    if ( m_settings->HasInsertSizeFilter )          propertyTokens.insert( make_pair(INSERTSIZE_PROPERTY,          m_settings->InsertSizeFilter) );
-    if ( m_settings->HasIsDuplicateFilter )         propertyTokens.insert( make_pair(ISDUPLICATE_PROPERTY,         m_settings->IsDuplicateFilter) );
-    if ( m_settings->HasIsFailedQCFilter )          propertyTokens.insert( make_pair(ISFAILEDQC_PROPERTY,          m_settings->IsFailedQCFilter) );
-    if ( m_settings->HasIsFirstMateFilter )         propertyTokens.insert( make_pair(ISFIRSTMATE_PROPERTY,         m_settings->IsFirstMateFilter) );
-    if ( m_settings->HasIsMappedFilter )            propertyTokens.insert( make_pair(ISMAPPED_PROPERTY,            m_settings->IsMappedFilter) );
-    if ( m_settings->HasIsMateMappedFilter )        propertyTokens.insert( make_pair(ISMATEMAPPED_PROPERTY,        m_settings->IsMateMappedFilter) );
-    if ( m_settings->HasIsMateReverseStrandFilter ) propertyTokens.insert( make_pair(ISMATEREVERSESTRAND_PROPERTY, m_settings->IsMateReverseStrandFilter) );
-    if ( m_settings->HasIsPairedFilter )            propertyTokens.insert( make_pair(ISPAIRED_PROPERTY,            m_settings->IsPairedFilter) );
-    if ( m_settings->HasIsPrimaryAlignmentFilter )  propertyTokens.insert( make_pair(ISPRIMARYALIGNMENT_PROPERTY,  m_settings->IsPrimaryAlignmentFilter) );
-    if ( m_settings->HasIsProperPairFilter )        propertyTokens.insert( make_pair(ISPROPERPAIR_PROPERTY,        m_settings->IsProperPairFilter) );
-    if ( m_settings->HasIsReverseStrandFilter )     propertyTokens.insert( make_pair(ISREVERSESTRAND_PROPERTY,     m_settings->IsReverseStrandFilter) );
-    if ( m_settings->HasIsSecondMateFilter )        propertyTokens.insert( make_pair(ISSECONDMATE_PROPERTY,        m_settings->IsSecondMateFilter) );
-    if ( m_settings->HasIsSingletonFilter )         propertyTokens.insert( make_pair(ISSINGLETON_PROPERTY,         m_settings->IsSingletonFilter) );
-    if ( m_settings->HasLengthFilter )              propertyTokens.insert( make_pair(LENGTH_PROPERTY,              m_settings->LengthFilter) );
-    if ( m_settings->HasMapQualityFilter )          propertyTokens.insert( make_pair(MAPQUALITY_PROPERTY,          m_settings->MapQualityFilter) );
-    if ( m_settings->HasNameFilter )                propertyTokens.insert( make_pair(NAME_PROPERTY,                m_settings->NameFilter) );
-    if ( m_settings->HasQueryBasesFilter )          propertyTokens.insert( make_pair(QUERYBASES_PROPERTY,          m_settings->QueryBasesFilter) );
-    if ( m_settings->HasTagFilter )                 propertyTokens.insert( make_pair(TAG_PROPERTY,                 m_settings->TagFilter) );
-    
-    // send add these properties to filter set "COMMAND_LINE"
-    return AddPropertyTokensToFilter(CMD, propertyTokens);
-}
-
-bool FilterTool::FilterToolPrivate::ParseFilterObject(const string& filterName, const Json::Value& filterObject) {
-  
-    // filter object parsing variables
-    Json::Value null(Json::nullValue);
-    Json::Value propertyValue;
-    
-    // store results
-    map<string, string> propertyTokens;
-    
-    // iterate over known properties
-    vector<string>::const_iterator propertyNameIter = m_propertyNames.begin();
-    vector<string>::const_iterator propertyNameEnd  = m_propertyNames.end();
-    for ( ; propertyNameIter != propertyNameEnd; ++propertyNameIter ) {
-        const string& propertyName = (*propertyNameIter);
-        
-        // if property defined in filter, add to token list
-        propertyValue = filterObject.get(propertyName, null);
-        if ( propertyValue != null ) 
-            propertyTokens.insert( make_pair(propertyName, propertyValue.asString()) );
-    }
-  
-    // add this filter to engin
-    m_filterEngine.addFilter(filterName);
-  
-    // add token list to this filter
-    return AddPropertyTokensToFilter(filterName, propertyTokens);
-}
-
-bool FilterTool::FilterToolPrivate::ParseScript(void) {
-  
-    // read in script contents from file
-    const string document = GetScriptContents();
-    
-    // set up JsonCPP reader and attempt to parse script
-    Json::Value root;
-    Json::Reader reader;
-    if ( !reader.parse(document, root) ) {
-        // use built-in error reporting mechanism to alert user what was wrong with the script
-        cerr  << "bamtools filter ERROR: failed to parse script - see error message(s) below" << endl
-              << reader.getFormatedErrorMessages();
-        return false;     
-    }
-
-    // initialize return status
-    bool success = true;
-    
-    // see if root object contains multiple filters
-    const Json::Value filters = root["filters"];
-    if ( !filters.isNull() ) {
-      
-        // iterate over any filters found
-        int filterIndex = 0;
-        Json::Value::const_iterator filtersIter = filters.begin();
-        Json::Value::const_iterator filtersEnd  = filters.end();
-        for ( ; filtersIter != filtersEnd; ++filtersIter, ++filterIndex ) {
-            Json::Value filter = (*filtersIter);
-            
-            // convert filter index to string
-            string filterName;
-            
-            // if id tag supplied
-            const Json::Value id = filter["id"];
-            if ( !id.isNull() ) 
-                filterName = id.asString();
-            
-            // use array index 
-            else {
-                stringstream convert;
-                convert << filterIndex;
-                filterName = convert.str();
-            }
-            
-            // create & parse filter 
-            success &= ParseFilterObject(filterName, filter);
-        }
-        
-        // see if user defined a "rule" for these filters
-        // otherwise, use filter engine's default rule behavior
-        string ruleString("");
-        const Json::Value rule = root["rule"];
-        if ( rule.isString() )
-            ruleString = rule.asString();
-        m_filterEngine.setRule(ruleString);
-          
-        // return success/fail
-        return success;
-    } 
-    
-    // otherwise, root is the only filter (just contains properties)
-    // create & parse filter named "ROOT"
-    else success = ParseFilterObject("ROOT", root);
-    
-    // return success/failure
-    return success;
-}
-
-bool FilterTool::FilterToolPrivate::Run(void) {
-    
-    // set to default input if none provided
-    if ( !m_settings->HasInput && !m_settings->HasInputFilelist )
-        m_settings->InputFiles.push_back(Options::StandardIn());
-
-    // add files in the filelist to the input file list
-    if ( m_settings->HasInputFilelist ) {
-
-        ifstream filelist(m_settings->InputFilelist.c_str(), ios::in);
-        if ( !filelist.is_open() ) {
-            cerr << "bamtools filter ERROR: could not open input BAM file list... Aborting." << endl;
-            return false;
-        }
-
-        string line;
-        while ( getline(filelist, line) )
-            m_settings->InputFiles.push_back(line);
-    }
-
-    // initialize defined properties & user-specified filters
-    // quit if failed
-    if ( !SetupFilters() )
-        return false;
-
-    // open reader without index
-    BamMultiReader reader;
-    if ( !reader.Open(m_settings->InputFiles) ) {
-        cerr << "bamtools filter ERROR: could not open input files for reading." << endl;
-        return false;
-    }
-
-    // retrieve reader header & reference data
-    const string headerText = reader.GetHeaderText();
-    filterToolReferences = reader.GetReferenceData();
-    
-    // determine compression mode for BamWriter
-    bool writeUncompressed = ( m_settings->OutputFilename == Options::StandardOut() &&
-                              !m_settings->IsForceCompression );
-    BamWriter::CompressionMode compressionMode = BamWriter::Compressed;
-    if ( writeUncompressed ) compressionMode = BamWriter::Uncompressed;
-
-    // open BamWriter
-    BamWriter writer;
-    writer.SetCompressionMode(compressionMode);
-    if ( !writer.Open(m_settings->OutputFilename, headerText, filterToolReferences) ) {
-        cerr << "bamtools filter ERROR: could not open " << m_settings->OutputFilename << " for writing." << endl;
-        reader.Close();
-        return false;
-    }
-
-    // if no region specified, filter entire file 
-    BamAlignment al;
-    if ( !m_settings->HasRegion ) {
-        while ( reader.GetNextAlignment(al) ) {
-            if ( CheckAlignment(al) ) 
-                writer.SaveAlignment(al);
-        }
-    }
-    
-    // otherwise attempt to use region as constraint
-    else {
-        
-        // if region string parses OK
-        BamRegion region;
-        if ( Utilities::ParseRegionString(m_settings->Region, reader, region) ) {
-
-            // attempt to find index files
-            reader.LocateIndexes();
-
-            // if index data available for all BAM files, we can use SetRegion
-            if ( reader.HasIndexes() ) {
-
-                // attempt to use SetRegion(), if failed report error
-                if ( !reader.SetRegion(region.LeftRefID, region.LeftPosition, region.RightRefID, region.RightPosition) ) {
-                    cerr << "bamtools filter ERROR: set region failed. Check that REGION describes a valid range" << endl;
-                    reader.Close();
-                    return false;
-                } 
-              
-                // everything checks out, just iterate through specified region, filtering alignments
-                while ( reader.GetNextAlignment(al) )
-                    if ( CheckAlignment(al) ) 
-                        writer.SaveAlignment(al);
-                }
-            
-            // no index data available, we have to iterate through until we
-            // find overlapping alignments
-            else {
-                while ( reader.GetNextAlignment(al) ) {
-                    if ( (al.RefID >= region.LeftRefID)  && ((al.Position + al.Length) >= region.LeftPosition) &&
-                         (al.RefID <= region.RightRefID) && ( al.Position <= region.RightPosition) ) 
-                    {
-                        if ( CheckAlignment(al) ) 
-                            writer.SaveAlignment(al);
-                    }
-                }
-            }
-        } 
-        
-        // error parsing REGION string
-        else {
-            cerr << "bamtools filter ERROR: could not parse REGION: " << m_settings->Region << endl;
-            cerr << "Check that REGION is in valid format (see documentation) and that the coordinates are valid"
-                 << endl;
-            reader.Close();
-            return false;
-        }
-    }
-
-    // clean up & exit
-    reader.Close();
-    writer.Close();
-    return true;
-}
-
-bool FilterTool::FilterToolPrivate::SetupFilters(void) {
-  
-    // set up filter engine with supported properties
-    InitProperties();
-    
-    // parse script for filter rules, if given
-    if ( m_settings->HasScript )
-        return ParseScript();
-    
-    // otherwise check command line for filters
-    else return ParseCommandLine();
-}
-
-// ---------------------------------------------
-// FilterTool implementation
-
-FilterTool::FilterTool(void)
-    : AbstractTool()
-    , m_settings(new FilterSettings)
-    , m_impl(0)
-{
-    // ----------------------------------
-    // set program details
-
-    const string usage = "[-in <filename> -in <filename> ... | -list <filelist>] "
-                         "[-out <filename> | [-forceCompression]] [-region <REGION>] "
-                         "[ [-script <filename] | [filterOptions] ]";
-
-    Options::SetProgramInfo("bamtools filter", "filters BAM file(s)", usage );
-
-    // ----------------------------------
-    // I/O options
-
-    OptionGroup* IO_Opts = Options::CreateOptionGroup("Input & Output");
-
-    const string inDesc     = "the input BAM file(s)";
-    const string listDesc   = "the input BAM file list, one line per file";
-    const string outDesc    = "the output BAM file";
-    const string regionDesc = "only read data from this genomic region (see documentation for more details)";
-    const string scriptDesc = "the filter script file (see documentation for more details)";
-    const string forceDesc  = "if results are sent to stdout (like when piping to another tool), "
-                              "default behavior is to leave output uncompressed. Use this flag to "
-                              "override and force compression";
-
-    Options::AddValueOption("-in",     "BAM filename", inDesc,     "", m_settings->HasInput,  m_settings->InputFiles,     IO_Opts, Options::StandardIn());
-    Options::AddValueOption("-list",   "filename",     listDesc,   "", m_settings->HasInputFilelist,  m_settings->InputFilelist, IO_Opts);
-    Options::AddValueOption("-out",    "BAM filename", outDesc,    "", m_settings->HasOutput, m_settings->OutputFilename, IO_Opts, Options::StandardOut());
-    Options::AddValueOption("-region", "REGION",       regionDesc, "", m_settings->HasRegion, m_settings->Region,         IO_Opts);
-    Options::AddValueOption("-script", "filename",     scriptDesc, "", m_settings->HasScript, m_settings->ScriptFilename, IO_Opts);
-    Options::AddOption("-forceCompression",forceDesc, m_settings->IsForceCompression, IO_Opts);
-
-    // ----------------------------------
-    // general filter options
-
-    OptionGroup* FilterOpts = Options::CreateOptionGroup("General Filters");
-
-    const string flagDesc    = "keep reads with this *exact* alignment flag (for more detailed queries, see below)";
-    const string insertDesc  = "keep reads with insert size that matches pattern";
-    const string lengthDesc  = "keep reads with length that matches pattern";
-    const string mapQualDesc = "keep reads with map quality that matches pattern";
-    const string nameDesc    = "keep reads with name that matches pattern";
-    const string queryDesc   = "keep reads with motif that matches pattern";
-    const string tagDesc     = "keep reads with this key=>value pair";
-
-    Options::AddValueOption("-alignmentFlag", "int",       flagDesc,    "", m_settings->HasAlignmentFlagFilter, m_settings->AlignmentFlagFilter, FilterOpts);
-    Options::AddValueOption("-insertSize",    "int",       insertDesc,  "", m_settings->HasInsertSizeFilter,    m_settings->InsertSizeFilter,    FilterOpts);
-    Options::AddValueOption("-length",        "int",       lengthDesc,  "", m_settings->HasLengthFilter,        m_settings->LengthFilter,        FilterOpts);
-    Options::AddValueOption("-mapQuality",    "[0-255]",   mapQualDesc, "", m_settings->HasMapQualityFilter,    m_settings->MapQualityFilter,    FilterOpts);
-    Options::AddValueOption("-name",          "string",    nameDesc,    "", m_settings->HasNameFilter,          m_settings->NameFilter,          FilterOpts);
-    Options::AddValueOption("-queryBases",    "string",    queryDesc,   "", m_settings->HasQueryBasesFilter,    m_settings->QueryBasesFilter,    FilterOpts);
-    Options::AddValueOption("-tag",           "TAG:VALUE", tagDesc,     "", m_settings->HasTagFilter,           m_settings->TagFilter,           FilterOpts);
-
-    // ----------------------------------
-    // alignment flag filter options
-
-    OptionGroup* AlignmentFlagOpts = Options::CreateOptionGroup("Alignment Flag Filters");
-
-    const string boolArg           = "true/false";
-    const string isDupDesc         = "keep only alignments that are marked as duplicate?";
-    const string isFailQcDesc      = "keep only alignments that failed QC?";
-    const string isFirstMateDesc   = "keep only alignments marked as first mate?";
-    const string isMappedDesc      = "keep only alignments that were mapped?";
-    const string isMateMappedDesc  = "keep only alignments with mates that mapped";
-    const string isMateReverseDesc = "keep only alignments with mate on reverese strand?";
-    const string isPairedDesc      = "keep only alignments that were sequenced as paired?";
-    const string isPrimaryDesc     = "keep only alignments marked as primary?";
-    const string isProperPairDesc  = "keep only alignments that passed PE resolution?";
-    const string isReverseDesc     = "keep only alignments on reverse strand?";
-    const string isSecondMateDesc  = "keep only alignments marked as second mate?";
-    const string isSingletonDesc   = "keep only singletons";
-
-    Options::AddValueOption("-isDuplicate",         boolArg, isDupDesc,         "", m_settings->HasIsDuplicateFilter,         m_settings->IsDuplicateFilter,         AlignmentFlagOpts, TRUE_STR);
-    Options::AddValueOption("-isFailedQC",          boolArg, isFailQcDesc,      "", m_settings->HasIsFailedQCFilter,          m_settings->IsFailedQCFilter,          AlignmentFlagOpts, TRUE_STR);
-    Options::AddValueOption("-isFirstMate",         boolArg, isFirstMateDesc,   "", m_settings->HasIsFirstMateFilter,         m_settings->IsFirstMateFilter,         AlignmentFlagOpts, TRUE_STR);
-    Options::AddValueOption("-isMapped",            boolArg, isMappedDesc,      "", m_settings->HasIsMappedFilter,            m_settings->IsMappedFilter,            AlignmentFlagOpts, TRUE_STR);
-    Options::AddValueOption("-isMateMapped",        boolArg, isMateMappedDesc,  "", m_settings->HasIsMateMappedFilter,        m_settings->IsMateMappedFilter,        AlignmentFlagOpts, TRUE_STR);
-    Options::AddValueOption("-isMateReverseStrand", boolArg, isMateReverseDesc, "", m_settings->HasIsMateReverseStrandFilter, m_settings->IsMateReverseStrandFilter, AlignmentFlagOpts, TRUE_STR);
-    Options::AddValueOption("-isPaired",            boolArg, isPairedDesc,      "", m_settings->HasIsPairedFilter,            m_settings->IsPairedFilter,            AlignmentFlagOpts, TRUE_STR);
-    Options::AddValueOption("-isPrimaryAlignment",  boolArg, isPrimaryDesc,     "", m_settings->HasIsPrimaryAlignmentFilter,  m_settings->IsPrimaryAlignmentFilter,  AlignmentFlagOpts, TRUE_STR);
-    Options::AddValueOption("-isProperPair",        boolArg, isProperPairDesc,  "", m_settings->HasIsProperPairFilter,        m_settings->IsProperPairFilter,        AlignmentFlagOpts, TRUE_STR);
-    Options::AddValueOption("-isReverseStrand",     boolArg, isReverseDesc,     "", m_settings->HasIsReverseStrandFilter,     m_settings->IsReverseStrandFilter,     AlignmentFlagOpts, TRUE_STR);
-    Options::AddValueOption("-isSecondMate",        boolArg, isSecondMateDesc,  "", m_settings->HasIsSecondMateFilter,        m_settings->IsSecondMateFilter,        AlignmentFlagOpts, TRUE_STR);
-    Options::AddValueOption("-isSingleton",         boolArg, isSingletonDesc,   "", m_settings->HasIsSingletonFilter,         m_settings->IsSingletonFilter,         AlignmentFlagOpts, TRUE_STR);
-}
-
-FilterTool::~FilterTool(void) {
-
-    delete m_settings;
-    m_settings = 0;
-
-    delete m_impl;
-    m_impl = 0;
-}
-
-int FilterTool::Help(void) {
-    Options::DisplayHelp();
-    return 0;
-}
-
-int FilterTool::Run(int argc, char* argv[]) {
-
-    // parse command line arguments
-    Options::Parse(argc, argv, 1);
-
-    // initialize FilterTool with settings
-    m_impl = new FilterToolPrivate(m_settings);
-
-    // run FilterTool, return success/fail
-    if ( m_impl->Run() )
-        return 0;
-    else
-        return 1;
-}
diff --git a/bamtools/src/toolkit/bamtools_filter.h b/bamtools/src/toolkit/bamtools_filter.h
deleted file mode 100644
index 7fa5f73..0000000
--- a/bamtools/src/toolkit/bamtools_filter.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// ***************************************************************************
-// bamtools_filter.h (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 28 August 2010
-// ---------------------------------------------------------------------------
-// Filters BAM file(s) according to some user-specified criteria
-// ***************************************************************************
-
-#ifndef BAMTOOLS_FILTER_H
-#define BAMTOOLS_FILTER_H
-
-#include "bamtools_tool.h"
-
-namespace BamTools {
-  
-class FilterTool : public AbstractTool {
-  
-    public:
-        FilterTool(void);
-        ~FilterTool(void);
-  
-    public:
-        int Help(void);
-        int Run(int argc, char* argv[]); 
-        
-    private:
-        struct FilterSettings;
-        FilterSettings* m_settings;
-        
-        struct FilterToolPrivate;
-        FilterToolPrivate* m_impl;
-};
-  
-} // namespace BamTools
-
-#endif // BAMTOOLS_FILTER_H
diff --git a/bamtools/src/toolkit/bamtools_header.cpp b/bamtools/src/toolkit/bamtools_header.cpp
deleted file mode 100644
index 534bb14..0000000
--- a/bamtools/src/toolkit/bamtools_header.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-// ***************************************************************************
-// bamtools_header.cpp (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 December 2012
-// ---------------------------------------------------------------------------
-// Prints the SAM-style header from a single BAM file ( or merged header from
-// multiple BAM files) to stdout
-// ***************************************************************************
-
-#include "bamtools_header.h"
-
-#include <api/BamMultiReader.h>
-#include <utils/bamtools_options.h>
-using namespace BamTools;
-
-#include <fstream>
-#include <iostream>
-#include <string>
-#include <vector>
-using namespace std;
-  
-// ---------------------------------------------
-// HeaderSettings implementation
-
-struct HeaderTool::HeaderSettings {
-
-    // flags
-    bool HasInput;
-    bool HasInputFilelist;
-
-    // filenames
-    vector<string> InputFiles;
-    string InputFilelist;
-    
-    // constructor
-    HeaderSettings(void)
-        : HasInput(false)
-        , HasInputFilelist(false)
-    { }
-};  
-
-struct HeaderTool::HeaderToolPrivate {
-
-    // ctor & dtor
-    public:
-        HeaderToolPrivate(HeaderTool::HeaderSettings* settings)
-            : m_settings(settings)
-        { }
-
-        ~HeaderToolPrivate(void) { }
-
-    // interface
-    public:
-        bool Run(void);
-
-    // data members
-    private:
-        HeaderTool::HeaderSettings* m_settings;
-};
-
-bool HeaderTool::HeaderToolPrivate::Run(void) {
-
-    // set to default input if none provided
-    if ( !m_settings->HasInput && !m_settings->HasInputFilelist )
-        m_settings->InputFiles.push_back(Options::StandardIn());
-
-    // add files in the filelist to the input file list
-    if ( m_settings->HasInputFilelist ) {
-
-        ifstream filelist(m_settings->InputFilelist.c_str(), ios::in);
-        if ( !filelist.is_open() ) {
-            cerr << "bamtools header ERROR: could not open input BAM file list... Aborting." << endl;
-            return false;
-        }
-
-        string line;
-        while ( getline(filelist, line) )
-            m_settings->InputFiles.push_back(line);
-    }
-
-    // attemp to open BAM files
-    BamMultiReader reader;
-    if ( !reader.Open(m_settings->InputFiles) ) {
-        cerr << "bamtools header ERROR: could not open BAM file(s) for reading... Aborting." << endl;
-        return false;
-    }
-
-    // dump (merged) header contents to stdout
-    cout << reader.GetHeaderText() << endl;
-
-    // clean up & exit
-    reader.Close();
-    return true;
-}
-
-// ---------------------------------------------
-// HeaderTool implementation
-
-HeaderTool::HeaderTool(void)
-    : AbstractTool()
-    , m_settings(new HeaderSettings)
-    , m_impl(0)
-{
-    // set program details
-    Options::SetProgramInfo("bamtools header", "prints header from BAM file(s)", "[-in <filename> -in <filename> ... | -list <filelist>]");
-    
-    // set up options 
-    OptionGroup* IO_Opts = Options::CreateOptionGroup("Input & Output");
-    Options::AddValueOption("-in", "BAM filename", "the input BAM file(s)", "", m_settings->HasInput, m_settings->InputFiles, IO_Opts, Options::StandardIn());
-    Options::AddValueOption("-list", "filename", "the input BAM file list, one line per file", "", m_settings->HasInputFilelist,  m_settings->InputFilelist, IO_Opts);
-}
-
-HeaderTool::~HeaderTool(void) {
-
-    delete m_settings;
-    m_settings = 0;
-
-    delete m_impl;
-    m_impl = 0;
-}
-
-int HeaderTool::Help(void) {
-    Options::DisplayHelp();
-    return 0;
-}
-
-int HeaderTool::Run(int argc, char* argv[]) {
-  
-    // parse command line arguments
-    Options::Parse(argc, argv, 1);
-  
-    // initialize HeaderTool with settings
-    m_impl = new HeaderToolPrivate(m_settings);
-
-    // run HeaderTool, return success/fail
-    if ( m_impl->Run() )
-        return 0;
-    else
-        return 1;
-}
diff --git a/bamtools/src/toolkit/bamtools_header.h b/bamtools/src/toolkit/bamtools_header.h
deleted file mode 100644
index 7e59d68..0000000
--- a/bamtools/src/toolkit/bamtools_header.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// ***************************************************************************
-// bamtools_header.h (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 7 April 2011
-// ---------------------------------------------------------------------------
-// Prints the SAM-style header from a single BAM file ( or merged header from
-// multiple BAM files) to stdout
-// ***************************************************************************
-
-#ifndef BAMTOOLS_HEADER_H
-#define BAMTOOLS_HEADER_H
-
-#include "bamtools_tool.h"
-
-namespace BamTools {
-  
-class HeaderTool : public AbstractTool {
-  
-    public:
-        HeaderTool(void);
-        ~HeaderTool(void);
-  
-    public:
-        int Help(void);
-        int Run(int argc, char* argv[]); 
-        
-    private:
-        struct HeaderSettings;
-        HeaderSettings* m_settings;
-
-        struct HeaderToolPrivate;
-        HeaderToolPrivate* m_impl;
-};
-  
-} // namespace BamTools
-
-#endif // BAMTOOLS_HEADER_H
diff --git a/bamtools/src/toolkit/bamtools_index.cpp b/bamtools/src/toolkit/bamtools_index.cpp
deleted file mode 100644
index ef0e765..0000000
--- a/bamtools/src/toolkit/bamtools_index.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-// ***************************************************************************
-// bamtools_index.cpp (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 7 April 2011
-// ---------------------------------------------------------------------------
-// Creates a BAM index file
-// ***************************************************************************
-
-#include "bamtools_index.h"
-
-#include <api/BamReader.h>
-#include <utils/bamtools_options.h>
-using namespace BamTools;
-
-#include <iostream>
-#include <string>
-using namespace std;
-
-// ---------------------------------------------
-// IndexSettings implementation
-
-struct IndexTool::IndexSettings {
-
-    // flags
-    bool HasInputBamFilename;
-    bool IsUsingBamtoolsIndex;
-
-    // filenames
-    string InputBamFilename;
-    
-    // constructor
-    IndexSettings(void)
-        : HasInputBamFilename(false)
-        , IsUsingBamtoolsIndex(false)
-        , InputBamFilename(Options::StandardIn())
-    { }
-};  
-
-// ---------------------------------------------
-// IndexToolPrivate implementation
-
-struct IndexTool::IndexToolPrivate {
-
-    // ctor & dtor
-    public:
-        IndexToolPrivate(IndexTool::IndexSettings* settings)
-            : m_settings(settings)
-        { }
-
-        ~IndexToolPrivate(void) { }
-
-    // interface
-    public:
-        bool Run(void);
-
-    // data members
-    private:
-        IndexTool::IndexSettings* m_settings;
-};
-
-bool IndexTool::IndexToolPrivate::Run(void) {
-
-    // open our BAM reader
-    BamReader reader;
-    if ( !reader.Open(m_settings->InputBamFilename) ) {
-        cerr << "bamtools index ERROR: could not open BAM file: "
-             << m_settings->InputBamFilename << endl;
-        return false;
-    }
-
-    // create index for BAM file
-    const BamIndex::IndexType type = ( m_settings->IsUsingBamtoolsIndex ? BamIndex::BAMTOOLS
-                                                                        : BamIndex::STANDARD );
-    reader.CreateIndex(type);
-
-    // clean & exit
-    reader.Close();
-    return true;
-}
-
-// ---------------------------------------------
-// IndexTool implementation
-
-IndexTool::IndexTool(void)
-    : AbstractTool()
-    , m_settings(new IndexSettings)
-    , m_impl(0)
-{
-    // set program details
-    Options::SetProgramInfo("bamtools index", "creates index for BAM file", "[-in <filename>] [-bti]");
-    
-    // set up options 
-    OptionGroup* IO_Opts = Options::CreateOptionGroup("Input & Output");
-    Options::AddValueOption("-in", "BAM filename", "the input BAM file", "", m_settings->HasInputBamFilename, m_settings->InputBamFilename, IO_Opts, Options::StandardIn());
-    Options::AddOption("-bti", "create (non-standard) BamTools index file (*.bti). Default behavior is to create standard BAM index (*.bai)", m_settings->IsUsingBamtoolsIndex, IO_Opts);
-}
-
-IndexTool::~IndexTool(void) {
-
-    delete m_settings;
-    m_settings = 0;
-
-    delete m_impl;
-    m_impl = 0;
-}
-
-int IndexTool::Help(void) {
-    Options::DisplayHelp();
-    return 0;
-}
-
-int IndexTool::Run(int argc, char* argv[]) {
-  
-    // parse command line arguments
-    Options::Parse(argc, argv, 1);
-    
-    // initialize IndexTool with settings
-    m_impl = new IndexToolPrivate(m_settings);
-
-    // run IndexTool, return success/fail
-    if ( m_impl->Run() )
-        return 0;
-    else
-        return 1;
-}
diff --git a/bamtools/src/toolkit/bamtools_index.h b/bamtools/src/toolkit/bamtools_index.h
deleted file mode 100644
index a670741..0000000
--- a/bamtools/src/toolkit/bamtools_index.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// ***************************************************************************
-// bamtools_index.h (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 7 April 2011
-// ---------------------------------------------------------------------------
-// Creates a BAM index file
-// ***************************************************************************
-
-#ifndef BAMTOOLS_INDEX_H
-#define BAMTOOLS_INDEX_H
-
-#include "bamtools_tool.h"
-
-namespace BamTools {
-  
-class IndexTool : public AbstractTool {
-  
-    public:
-        IndexTool(void);
-        ~IndexTool(void);
-  
-    public:
-        int Help(void);
-        int Run(int argc, char* argv[]); 
-        
-    private:
-        struct IndexSettings;
-        IndexSettings* m_settings;
-
-        struct IndexToolPrivate;
-        IndexToolPrivate* m_impl;
-};
-  
-} // namespace BamTools
-
-#endif // BAMTOOLS_INDEX_H
diff --git a/bamtools/src/toolkit/bamtools_merge.cpp b/bamtools/src/toolkit/bamtools_merge.cpp
deleted file mode 100644
index 6a33d12..0000000
--- a/bamtools/src/toolkit/bamtools_merge.cpp
+++ /dev/null
@@ -1,241 +0,0 @@
-// ***************************************************************************
-// bamtools_merge.cpp (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 December 2012
-// ---------------------------------------------------------------------------
-// Merges multiple BAM files into one
-// ***************************************************************************
-
-#include "bamtools_merge.h"
-
-#include <api/BamMultiReader.h>
-#include <api/BamWriter.h>
-#include <utils/bamtools_options.h>
-#include <utils/bamtools_utilities.h>
-using namespace BamTools;
-
-#include <fstream>
-#include <iostream>
-#include <string>
-#include <vector>
-using namespace std;
-
-// ---------------------------------------------
-// MergeSettings implementation
-
-struct MergeTool::MergeSettings {
-
-    // flags
-    bool HasInput;
-    bool HasInputFilelist;
-    bool HasOutput;
-    bool IsForceCompression;
-    bool HasRegion;
-    
-    // filenames
-    vector<string> InputFiles;
-    string InputFilelist;
-    
-    // other parameters
-    string OutputFilename;
-    string Region;
-    
-    // constructor
-    MergeSettings(void)
-        : HasInput(false)
-        , HasInputFilelist(false)
-        , HasOutput(false)
-        , IsForceCompression(false)
-        , HasRegion(false)
-        , OutputFilename(Options::StandardOut())
-    { }
-};  
-
-// ---------------------------------------------
-// MergeToolPrivate implementation
-
-struct MergeTool::MergeToolPrivate {
-
-    // ctor & dtor
-    public:
-        MergeToolPrivate(MergeTool::MergeSettings* settings)
-            : m_settings(settings)
-        { }
-
-        ~MergeToolPrivate(void) { }
-
-    // interface
-    public:
-        bool Run(void);
-
-    // data members
-    private:
-        MergeTool::MergeSettings* m_settings;
-};
-
-bool MergeTool::MergeToolPrivate::Run(void) {
-
-    // set to default input if none provided
-    if ( !m_settings->HasInput && !m_settings->HasInputFilelist )
-        m_settings->InputFiles.push_back(Options::StandardIn());
-
-    // add files in the filelist to the input file list
-    if ( m_settings->HasInputFilelist ) {
-
-        ifstream filelist(m_settings->InputFilelist.c_str(), ios::in);
-        if ( !filelist.is_open() ) {
-            cerr << "bamtools merge ERROR: could not open input BAM file list... Aborting." << endl;
-            return false;
-        }
-
-        string line;
-        while ( getline(filelist, line) )
-            m_settings->InputFiles.push_back(line);
-    }
-
-    // opens the BAM files (by default without checking for indexes)
-    BamMultiReader reader;
-    if ( !reader.Open(m_settings->InputFiles) ) {
-        cerr << "bamtools merge ERROR: could not open input BAM file(s)... Aborting." << endl;
-        return false;
-    }
-
-    // retrieve header & reference dictionary info
-    std::string mergedHeader = reader.GetHeaderText();
-    RefVector references = reader.GetReferenceData();
-
-    // determine compression mode for BamWriter
-    bool writeUncompressed = ( m_settings->OutputFilename == Options::StandardOut() &&
-                               !m_settings->IsForceCompression );
-    BamWriter::CompressionMode compressionMode = BamWriter::Compressed;
-    if ( writeUncompressed ) compressionMode = BamWriter::Uncompressed;
-
-    // open BamWriter
-    BamWriter writer;
-    writer.SetCompressionMode(compressionMode);
-    if ( !writer.Open(m_settings->OutputFilename, mergedHeader, references) ) {
-        cerr << "bamtools merge ERROR: could not open "
-             << m_settings->OutputFilename << " for writing." << endl;
-        reader.Close();
-        return false;
-    }
-
-    // if no region specified, store entire contents of file(s)
-    if ( !m_settings->HasRegion ) {
-        BamAlignment al;
-        while ( reader.GetNextAlignmentCore(al) )
-            writer.SaveAlignment(al);
-    }
-
-    // otherwise attempt to use region as constraint
-    else {
-
-        // if region string parses OK
-        BamRegion region;
-        if ( Utilities::ParseRegionString(m_settings->Region, reader, region) ) {
-
-            // attempt to find index files
-            reader.LocateIndexes();
-
-            // if index data available for all BAM files, we can use SetRegion
-            if ( reader.HasIndexes() ) {
-
-                // attempt to use SetRegion(), if failed report error
-                if ( !reader.SetRegion(region.LeftRefID,
-                                       region.LeftPosition,
-                                       region.RightRefID,
-                                       region.RightPosition) )
-                {
-                    cerr << "bamtools merge ERROR: set region failed. Check that REGION describes a valid range"
-                         << endl;
-                    reader.Close();
-                    return false;
-                }
-
-                // everything checks out, just iterate through specified region, storing alignments
-                BamAlignment al;
-                while ( reader.GetNextAlignmentCore(al) )
-                    writer.SaveAlignment(al);
-            }
-
-            // no index data available, we have to iterate through until we
-            // find overlapping alignments
-            else {
-                BamAlignment al;
-                while ( reader.GetNextAlignmentCore(al) ) {
-                    if ( (al.RefID >= region.LeftRefID)  && ( (al.Position + al.Length) >= region.LeftPosition ) &&
-                         (al.RefID <= region.RightRefID) && ( al.Position <= region.RightPosition) )
-                    {
-                        writer.SaveAlignment(al);
-                    }
-                }
-            }
-        }
-
-        // error parsing REGION string
-        else {
-            cerr << "bamtools merge ERROR: could not parse REGION - " << m_settings->Region << endl;
-            cerr << "Check that REGION is in valid format (see documentation) and that the coordinates are valid"
-                 << endl;
-            reader.Close();
-            writer.Close();
-            return false;
-        }
-    }
-
-    // clean & exit
-    reader.Close();
-    writer.Close();
-    return true;
-}
-
-// ---------------------------------------------
-// MergeTool implementation
-
-MergeTool::MergeTool(void)
-    : AbstractTool()
-    , m_settings(new MergeSettings)
-    , m_impl(0)
-{
-    // set program details
-    Options::SetProgramInfo("bamtools merge", "merges multiple BAM files into one",
-                            "[-in <filename> -in <filename> ... | -list <filelist>] [-out <filename> | [-forceCompression]] [-region <REGION>]");
-    
-    // set up options 
-    OptionGroup* IO_Opts = Options::CreateOptionGroup("Input & Output");
-    Options::AddValueOption("-in",  "BAM filename", "the input BAM file(s)", "", m_settings->HasInput,  m_settings->InputFiles,     IO_Opts);
-    Options::AddValueOption("-list",  "filename", "the input BAM file list, one line per file", "", m_settings->HasInputFilelist,  m_settings->InputFilelist, IO_Opts);
-    Options::AddValueOption("-out", "BAM filename", "the output BAM file",   "", m_settings->HasOutput, m_settings->OutputFilename, IO_Opts);
-    Options::AddOption("-forceCompression", "if results are sent to stdout (like when piping to another tool), default behavior is to leave output uncompressed. Use this flag to override and force compression", m_settings->IsForceCompression, IO_Opts);
-    Options::AddValueOption("-region", "REGION", "genomic region. See README for more details", "", m_settings->HasRegion, m_settings->Region, IO_Opts);
-}
-
-MergeTool::~MergeTool(void) {
-
-    delete m_settings;
-    m_settings = 0;
-
-    delete m_impl;
-    m_impl = 0;
-}
-
-int MergeTool::Help(void) {
-    Options::DisplayHelp();
-    return 0; 
-}
-
-int MergeTool::Run(int argc, char* argv[]) {
-  
-    // parse command line arguments
-    Options::Parse(argc, argv, 1);
-    
-    // initialize MergeTool with settings
-    m_impl = new MergeToolPrivate(m_settings);
-
-    // run MergeTool, return success/fail
-    if ( m_impl->Run() )
-        return 0;
-    else
-        return 1;
-}
diff --git a/bamtools/src/toolkit/bamtools_merge.h b/bamtools/src/toolkit/bamtools_merge.h
deleted file mode 100644
index cab851c..0000000
--- a/bamtools/src/toolkit/bamtools_merge.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// ***************************************************************************
-// bamtools_merge.h (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 7 April 2011
-// ---------------------------------------------------------------------------
-// Merges multiple BAM files into one
-// ***************************************************************************
-
-#ifndef BAMTOOLS_MERGE_H
-#define BAMTOOLS_MERGE_H
-
-#include "bamtools_tool.h"
-
-namespace BamTools {
-  
-class MergeTool : public AbstractTool {
-  
-    public:
-        MergeTool(void);
-        ~MergeTool(void);
-  
-    public:
-        int Help(void);
-        int Run(int argc, char* argv[]); 
-        
-    private:
-        struct MergeSettings;
-        MergeSettings* m_settings;
-
-        struct MergeToolPrivate;
-        MergeToolPrivate* m_impl;
-};
-  
-} // namespace BamTools
-
-#endif // BAMTOOLS_MERGE_H
diff --git a/bamtools/src/toolkit/bamtools_random.cpp b/bamtools/src/toolkit/bamtools_random.cpp
deleted file mode 100644
index 367ac58..0000000
--- a/bamtools/src/toolkit/bamtools_random.cpp
+++ /dev/null
@@ -1,285 +0,0 @@
-// ***************************************************************************
-// bamtools_random.cpp (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 24 July 2013 (DB)
-// ---------------------------------------------------------------------------
-// Grab a random subset of alignments (testing tool)
-// ***************************************************************************
-
-#include "bamtools_random.h"
-
-#include <api/BamMultiReader.h>
-#include <api/BamWriter.h>
-#include <utils/bamtools_options.h>
-#include <utils/bamtools_utilities.h>
-using namespace BamTools;
-
-#include <ctime>
-#include <cstdlib>
-#include <fstream>
-#include <iostream>
-#include <string>
-#include <vector>
-using namespace std;
-  
-namespace BamTools {
-  
-// define constants
-const unsigned int RANDOM_MAX_ALIGNMENT_COUNT = 10000;
-
-// utility methods for RandomTool
-int getRandomInt(const int& lowerBound, const int& upperBound) {
-    const int range = (upperBound - lowerBound) + 1;
-    return ( lowerBound + (int)(range * (double)rand()/((double)RAND_MAX + 1)) );
-}
-    
-} // namespace BamTools
-  
-// ---------------------------------------------  
-// RandomSettings implementation
-
-struct RandomTool::RandomSettings {
-
-    // flags
-    bool HasAlignmentCount;
-    bool HasInput;
-    bool HasInputFilelist;
-    bool HasOutput;
-    bool HasRandomNumberSeed;
-    bool HasRegion;
-    bool IsForceCompression;
-
-    // parameters
-    unsigned int AlignmentCount;
-    vector<string> InputFiles;
-    string InputFilelist;
-    string OutputFilename;
-    unsigned int RandomNumberSeed;
-    string Region;
-    
-    // constructor
-    RandomSettings(void)
-        : HasAlignmentCount(false)
-        , HasInput(false)
-        , HasInputFilelist(false)
-        , HasOutput(false)
-        , HasRandomNumberSeed(false)
-        , HasRegion(false)
-        , IsForceCompression(false)
-        , AlignmentCount(RANDOM_MAX_ALIGNMENT_COUNT)
-        , OutputFilename(Options::StandardOut())
-        , RandomNumberSeed(0)
-    { }  
-};  
-
-// ---------------------------------------------
-// RandomToolPrivate implementation
-
-struct RandomTool::RandomToolPrivate {
-
-    // ctor & dtor
-    public:
-        RandomToolPrivate(RandomTool::RandomSettings* settings)
-            : m_settings(settings)
-        { }
-
-        ~RandomToolPrivate(void) { }
-
-    // interface
-    public:
-        bool Run(void);
-
-    // data members
-    private:
-        RandomTool::RandomSettings* m_settings;
-};
-
-bool RandomTool::RandomToolPrivate::Run(void) {
-
-    // set to default stdin if no input files provided
-    if ( !m_settings->HasInput && !m_settings->HasInputFilelist )
-        m_settings->InputFiles.push_back(Options::StandardIn());
-
-    // add files in the filelist to the input file list
-    if ( m_settings->HasInputFilelist ) {
-
-        ifstream filelist(m_settings->InputFilelist.c_str(), ios::in);
-        if ( !filelist.is_open() ) {
-            cerr << "bamtools random ERROR: could not open input BAM file list... Aborting." << endl;
-            return false;
-        }
-
-        string line;
-        while ( getline(filelist, line) )
-            m_settings->InputFiles.push_back(line);
-    }
-
-    // open our reader
-    BamMultiReader reader;
-    if ( !reader.Open(m_settings->InputFiles) ) {
-        cerr << "bamtools random ERROR: could not open input BAM file(s)... Aborting." << endl;
-        return false;
-    }
-
-    // look up index files for all BAM files
-    reader.LocateIndexes();
-
-    // make sure index data is available
-    if ( !reader.HasIndexes() ) {
-        cerr << "bamtools random ERROR: could not load index data for all input BAM file(s)... Aborting." << endl;
-        reader.Close();
-        return false;
-    }
-
-    // get BamReader metadata
-    const string headerText = reader.GetHeaderText();
-    const RefVector references = reader.GetReferenceData();
-    if ( references.empty() ) {
-        cerr << "bamtools random ERROR: no reference data available... Aborting." << endl;
-        reader.Close();
-        return false;
-    }
-
-    // determine compression mode for BamWriter
-    bool writeUncompressed = ( m_settings->OutputFilename == Options::StandardOut() &&
-                              !m_settings->IsForceCompression );
-    BamWriter::CompressionMode compressionMode = BamWriter::Compressed;
-    if ( writeUncompressed ) compressionMode = BamWriter::Uncompressed;
-
-    // open BamWriter
-    BamWriter writer;
-    writer.SetCompressionMode(compressionMode);
-    if ( !writer.Open(m_settings->OutputFilename, headerText, references) ) {
-        cerr << "bamtools random ERROR: could not open " << m_settings->OutputFilename
-             << " for writing... Aborting." << endl;
-        reader.Close();
-        return false;
-    }
-
-    // if user specified a REGION constraint, attempt to parse REGION string
-    BamRegion region;
-    if ( m_settings->HasRegion && !Utilities::ParseRegionString(m_settings->Region, reader, region) ) {
-        cerr << "bamtools random ERROR: could not parse REGION: " << m_settings->Region << endl;
-        cerr << "Check that REGION is in valid format (see documentation) and that the coordinates are valid"
-             << endl;
-        reader.Close();
-        writer.Close();
-        return false;
-    }
-
-    // seed our random number generator
-    if ( m_settings->HasRandomNumberSeed )
-        srand( m_settings->RandomNumberSeed );
-    else
-        srand( time(NULL) );
-
-    // grab random alignments
-    BamAlignment al;
-    unsigned int i = 0;
-    while ( i < m_settings->AlignmentCount ) {
-
-        int randomRefId    = 0;
-        int randomPosition = 0;
-
-        // use REGION constraints to select random refId & position
-        if ( m_settings->HasRegion ) {
-
-            // select a random refId
-            randomRefId = getRandomInt(region.LeftRefID, region.RightRefID);
-
-            // select a random position based on randomRefId
-            const int lowerBoundPosition = ( (randomRefId == region.LeftRefID)
-                                             ? region.LeftPosition
-                                             : 0 );
-            const int upperBoundPosition = ( (randomRefId == region.RightRefID)
-                                             ? region.RightPosition
-                                             : (references.at(randomRefId).RefLength - 1) );
-            randomPosition = getRandomInt(lowerBoundPosition, upperBoundPosition);
-        }
-
-        // otherwise select from all possible random refId & position
-        else {
-
-            // select random refId
-            randomRefId = getRandomInt(0, (int)references.size() - 1);
-
-            // select random position based on randomRefId
-            const int lowerBoundPosition = 0;
-            const int upperBoundPosition = references.at(randomRefId).RefLength - 1;
-            randomPosition = getRandomInt(lowerBoundPosition, upperBoundPosition);
-        }
-
-        // if jump & read successful, save first alignment that overlaps random refId & position
-        if ( reader.Jump(randomRefId, randomPosition) ) {
-            while ( reader.GetNextAlignmentCore(al) ) {
-                if ( al.RefID == randomRefId && al.Position >= randomPosition ) {
-                    writer.SaveAlignment(al);
-                    ++i;
-                    break;
-                }
-            }
-        }
-    }
-
-    // cleanup & exit
-    reader.Close();
-    writer.Close();
-    return true;
-}
-
-// ---------------------------------------------
-// RandomTool implementation
-
-RandomTool::RandomTool(void) 
-    : AbstractTool()
-    , m_settings(new RandomSettings)
-    , m_impl(0)
-{ 
-    // set program details
-    Options::SetProgramInfo("bamtools random", "grab a random subset of alignments",
-                            "[-in <filename> -in <filename> ... | -list <filelist>] [-out <filename>] [-forceCompression] [-n] [-region <REGION>]");
-    
-    // set up options 
-    OptionGroup* IO_Opts = Options::CreateOptionGroup("Input & Output");
-    Options::AddValueOption("-in",     "BAM filename", "the input BAM file",                         "", m_settings->HasInput,          m_settings->InputFiles,     IO_Opts, Options::StandardIn());
-    Options::AddValueOption("-list",   "filename",     "the input BAM file list, one line per file", "", m_settings->HasInputFilelist,  m_settings->InputFilelist,  IO_Opts);
-    Options::AddValueOption("-out",    "BAM filename", "the output BAM file",                        "", m_settings->HasOutput,         m_settings->OutputFilename, IO_Opts, Options::StandardOut());
-    Options::AddValueOption("-region", "REGION",       "only pull random alignments from within this genomic region. Index file is recommended for better performance, and is used automatically if it exists. See \'bamtools help index\' for more details on creating one", "", m_settings->HasRegion, m_settings->Region, IO_Opts);
-    Options::AddOption("-forceCompression", "if results are sent to stdout (like when piping to another tool), default behavior is to leave output uncompressed. Use this flag to override and force compression", m_settings->IsForceCompression, IO_Opts);
-    
-    OptionGroup* SettingsOpts = Options::CreateOptionGroup("Settings");
-    Options::AddValueOption("-n", "count", "number of alignments to grab. Note - no duplicate checking is performed", "",
-                            m_settings->HasAlignmentCount, m_settings->AlignmentCount, SettingsOpts, RANDOM_MAX_ALIGNMENT_COUNT);
-    Options::AddValueOption("-seed", "unsigned integer", "random number generator seed (for repeatable results). Current time is used if no seed value is provided.", "",
-                            m_settings->HasRandomNumberSeed, m_settings->RandomNumberSeed, SettingsOpts);
-}
-
-RandomTool::~RandomTool(void) { 
-
-    delete m_settings;
-    m_settings = 0;
-
-    delete m_impl;
-    m_impl = 0;
-}
-
-int RandomTool::Help(void) { 
-    Options::DisplayHelp();
-    return 0;
-} 
-
-int RandomTool::Run(int argc, char* argv[]) { 
-
-    // parse command line arguments
-    Options::Parse(argc, argv, 1);
-
-    // initialize RandomTool with settings
-    m_impl = new RandomToolPrivate(m_settings);
-
-    // run RandomTool, return success/fail
-    if ( m_impl->Run() )
-        return 0;
-    else
-        return 1;
-}
diff --git a/bamtools/src/toolkit/bamtools_random.h b/bamtools/src/toolkit/bamtools_random.h
deleted file mode 100644
index ce70b86..0000000
--- a/bamtools/src/toolkit/bamtools_random.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// ***************************************************************************
-// bamtools_random.h (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 7 April 2010 (DB)
-// ---------------------------------------------------------------------------
-// Grab a random subset of alignments (testing tool)
-// ***************************************************************************
-
-#ifndef BAMTOOLS_RANDOM_H
-#define BAMTOOLS_RANDOM_H
-
-#include "bamtools_tool.h"
-
-namespace BamTools {
-  
-class RandomTool : public AbstractTool {
-  
-    public:
-        RandomTool(void);
-        ~RandomTool(void);
-  
-    public:
-        int Help(void);
-        int Run(int argc, char* argv[]); 
-        
-    private:
-        struct RandomSettings;
-        RandomSettings* m_settings;
-
-        struct RandomToolPrivate;
-        RandomToolPrivate* m_impl;
-};
-  
-} // namespace BamTools
-
-#endif // BAMTOOLS_RANDOM _H
diff --git a/bamtools/src/toolkit/bamtools_resolve.cpp b/bamtools/src/toolkit/bamtools_resolve.cpp
deleted file mode 100644
index 9e5fb84..0000000
--- a/bamtools/src/toolkit/bamtools_resolve.cpp
+++ /dev/null
@@ -1,1414 +0,0 @@
-// ***************************************************************************
-// bamtools_resolve.cpp (c) 2011
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 24 July 2013 (DB)
-// ---------------------------------------------------------------------------
-// Resolves paired-end reads (marking the IsProperPair flag as needed).
-// ***************************************************************************
-
-#include "bamtools_resolve.h"
-#include "bamtools_version.h"
-#include <api/BamReader.h>
-#include <api/BamWriter.h>
-#include <utils/bamtools_options.h>
-#include <utils/bamtools_utilities.h>
-using namespace BamTools;
-
-#include <algorithm>
-#include <cassert>
-#include <cctype>
-#include <cstdio>
-#include <cstdlib>
-#include <fstream>
-#include <iostream>
-#include <map>
-#include <sstream>
-#include <string>
-#include <utility>
-#include <vector>
-using namespace std;
-
-// --------------------------------------------------------------------------
-// general ResolveTool constants
-// --------------------------------------------------------------------------
-
-static const int      NUM_MODELS = 8;
-static const string   READ_GROUP_TAG = "RG";
-static const double   DEFAULT_CONFIDENCE_INTERVAL = 0.9973;
-static const uint16_t DEFAULT_MIN_MAPQUALITY = 1;
-static const double   DEFAULT_UNUSEDMODEL_THRESHOLD = 0.1;
-
-// --------------------------------------------------------------------------
-// stats file constants
-// --------------------------------------------------------------------------
-
-// basic char/string constants
-static const char COMMENT_CHAR     = '#';
-static const char OPEN_BRACE_CHAR  = '[';
-static const char CLOSE_BRACE_CHAR = ']';
-static const char EQUAL_CHAR       = '=';
-static const char TAB_CHAR         = '\t';
-
-static const string WHITESPACE_CHARS = " \t\n";
-static const string TRUE_KEYWORD     = "true";
-static const string FALSE_KEYWORD    = "false";
-
-// field counts
-static const size_t NUM_OPTIONS_FIELDS    = 2;
-static const size_t NUM_READGROUPS_FIELDS = 7;
-
-// header strings
-static const string INPUT_TOKEN      = "[Input]";
-static const string OPTIONS_TOKEN    = "[Options]";
-static const string READGROUPS_TOKEN = "[ReadGroups]";
-
-// option keywords
-static const string OPTION_CONFIDENCEINTERVAL   = "ConfidenceInterval";
-static const string OPTION_MINIMUMMAPQUALITY    = "MinimumMapQuality";
-static const string OPTION_UNUSEDMODELTHRESHOLD = "UnusedModelThreshold";
-static const string OPTION_FORCEMARKREADGROUPS  = "ForceMarkReadGroups";
-
-// other string constants
-static const string RG_FIELD_DESCRIPTION =
-    "#<name> <medianFL> <minFL> <maxFL> <topModelID> <nextTopModelID> <isAmbiguous?>";
-
-static const string MODEL_DESCRIPTION =
-    "# ------------- Model Types Description ---------------\n"
-    "#\n"
-    "#   ID     Position              Orientation           \n"
-    "#    1   mate1 < mate2   mate1:forward, mate2:forward  \n"
-    "#    2   mate1 < mate2   mate1:forward, mate2:reverse  \n"
-    "#    3   mate1 < mate2   mate1:reverse, mate2:forward  \n"
-    "#    4   mate1 < mate2   mate1:reverse, mate2:reverse  \n"
-    "#    5   mate2 < mate1   mate2:forward, mate1:forward  \n"
-    "#    6   mate2 < mate1   mate2:forward, mate1:reverse  \n"
-    "#    7   mate2 < mate1   mate2:reverse, mate1:forward  \n"
-    "#    8   mate2 < mate1   mate2:reverse, mate1:reverse  \n"
-    "# -----------------------------------------------------\n";
-
-// --------------------------------------------------------------------------
-// unique readname file constants
-// --------------------------------------------------------------------------
-
-static const string READNAME_FILE_SUFFIX = ".uniq_names.txt";
-static const string DEFAULT_READNAME_FILE = "bt_resolve_TEMP" + READNAME_FILE_SUFFIX;
-
-// --------------------------------------------------------------------------
-// ModelType implementation
-
-struct ModelType {
-
-    // data members
-    uint16_t ID;
-    vector<int32_t> FragmentLengths;
-
-    // ctor
-    ModelType(const uint16_t id)
-        : ID(id)
-    {
-        // preallocate space for 10K fragments per model type
-        FragmentLengths.reserve(10000);
-    }
-
-    // convenience access to internal fragment lengths vector
-    vector<int32_t>::iterator begin(void) { return FragmentLengths.begin(); }
-    vector<int32_t>::const_iterator begin(void) const { return FragmentLengths.begin(); }
-    void clear(void) { FragmentLengths.clear(); }
-    vector<int32_t>::iterator end(void) { return FragmentLengths.end(); }
-    vector<int32_t>::const_iterator end(void) const { return FragmentLengths.end(); }
-    void push_back(const int32_t& x) { FragmentLengths.push_back(x); }
-    size_t size(void) const { return FragmentLengths.size(); }
-
-    // constants
-    static const uint16_t DUMMY_ID;
-};
-
-const uint16_t ModelType::DUMMY_ID = 100;
-
-bool operator>(const ModelType& lhs, const ModelType& rhs) {
-    return lhs.size() > rhs.size();
-}
-
-uint16_t CalculateModelType(const BamAlignment& al) {
-
-    // localize alignment's mate positions & orientations for convenience
-    const int32_t m1_begin = ( al.IsFirstMate() ? al.Position : al.MatePosition );
-    const int32_t m2_begin = ( al.IsFirstMate() ? al.MatePosition : al.Position );
-    const bool m1_isReverseStrand = ( al.IsFirstMate() ? al.IsReverseStrand() : al.IsMateReverseStrand() );
-    const bool m2_isReverseStrand = ( al.IsFirstMate() ? al.IsMateReverseStrand() : al.IsReverseStrand() );
-
-    // determine 'model type'
-    if ( m1_begin < m2_begin ) {
-        if ( !m1_isReverseStrand && !m2_isReverseStrand ) return 0; // ID: 1
-        if ( !m1_isReverseStrand &&  m2_isReverseStrand ) return 1; // ID: 2
-        if (  m1_isReverseStrand && !m2_isReverseStrand ) return 2; // ID: 3
-        if (  m1_isReverseStrand &&  m2_isReverseStrand ) return 3; // ID: 4
-    } else {
-        if ( !m2_isReverseStrand && !m1_isReverseStrand ) return 4; // ID: 5
-        if ( !m2_isReverseStrand &&  m1_isReverseStrand ) return 5; // ID: 6
-        if (  m2_isReverseStrand && !m1_isReverseStrand ) return 6; // ID: 7
-        if (  m2_isReverseStrand &&  m1_isReverseStrand ) return 7; // ID: 8
-    }
-
-    // unknown model
-    return ModelType::DUMMY_ID;
-}
-
-// --------------------------------------------------------------------------
-// ReadGroupResolver implementation
-
-struct ReadGroupResolver {
-
-    // data members
-    int32_t MinFragmentLength;
-    int32_t MedianFragmentLength;
-    int32_t MaxFragmentLength;
-    uint16_t TopModelId;
-    uint16_t NextTopModelId;
-    bool IsAmbiguous;
-    bool HasData;
-    vector<ModelType> Models;
-    map<string, bool> ReadNames;
-
-    // ctor
-    ReadGroupResolver(void);
-
-    // resolving methods
-    bool IsValidInsertSize(const BamAlignment& al) const;
-    bool IsValidOrientation(const BamAlignment& al) const;
-
-    // select 2 best models based on observed data
-    void DetermineTopModels(const string& readGroupName);
-
-    // static settings
-    static double ConfidenceInterval;
-    static double UnusedModelThreshold;
-    static void SetConfidenceInterval(const double& ci);
-    static void SetUnusedModelThreshold(const double& umt);
-};
-
-double ReadGroupResolver::ConfidenceInterval   = DEFAULT_CONFIDENCE_INTERVAL;
-double ReadGroupResolver::UnusedModelThreshold = DEFAULT_UNUSEDMODEL_THRESHOLD;
-
-ReadGroupResolver::ReadGroupResolver(void)
-    : MinFragmentLength(0)
-    , MedianFragmentLength(0)
-    , MaxFragmentLength(0)
-    , TopModelId(ModelType::DUMMY_ID)
-    , NextTopModelId(ModelType::DUMMY_ID)
-    , IsAmbiguous(false)
-    , HasData(false)
-{
-    // pre-allocate space for 8 models
-    Models.reserve(NUM_MODELS);
-    for ( uint16_t i = 0; i < NUM_MODELS; ++i )
-        Models.push_back( ModelType(i+1) );
-}
-
-bool ReadGroupResolver::IsValidInsertSize(const BamAlignment& al) const {  
-    const int32_t absInsertSize = abs(al.InsertSize);
-    return ( absInsertSize >= MinFragmentLength &&
-             absInsertSize <= MaxFragmentLength );
-}
-
-bool ReadGroupResolver::IsValidOrientation(const BamAlignment& al) const {
-    const uint16_t currentModelId = CalculateModelType(al) + 1; // convert model type (array index) to ID number
-    return ( currentModelId == TopModelId || currentModelId == NextTopModelId );
-}
-
-void ReadGroupResolver::DetermineTopModels(const string& readGroupName) {
-
-    // sort models (from most common to least common)
-    sort( Models.begin(), Models.end(), std::greater<ModelType>() );
-
-    // store top 2 models for later
-    TopModelId     = Models[0].ID;
-    NextTopModelId = Models[1].ID;
-
-    // make sure that the 2 most common models are some threshold more common
-    // than the remaining models
-    const unsigned int activeModelCountSum = Models[0].size() + Models[1].size();
-    if ( activeModelCountSum == 0 ) return; // skip if no data in this read group
-    const unsigned int unusedModelCountSum = Models[2].size() + Models[3].size() +
-                                             Models[4].size() + Models[5].size() +
-                                             Models[6].size() + Models[7].size();    
-    const double unusedPercentage = (double)unusedModelCountSum / (double)activeModelCountSum;
-    if ( unusedPercentage > UnusedModelThreshold ) {
-        cerr << "WARNING: " << readGroupName << " does not have clearly defined 'top models'" << endl
-             << "         The fraction of alignments in bottom 6 models (" << unusedPercentage
-             << ") exceeds threshold: " << UnusedModelThreshold << endl;
-        IsAmbiguous = true;
-    }
-
-    // emit a warning if the best alignment models are non-standard
-    const bool isModel1Top = (TopModelId == 1) || (NextTopModelId == 1);
-    const bool isModel2Top = (TopModelId == 2) || (NextTopModelId == 2);
-    const bool isModel4Top = (TopModelId == 4) || (NextTopModelId == 4);
-    const bool isModel5Top = (TopModelId == 5) || (NextTopModelId == 5);
-    const bool isModel6Top = (TopModelId == 6) || (NextTopModelId == 6);
-    const bool isModel8Top = (TopModelId == 8) || (NextTopModelId == 8);
-
-    bool isMatePair  = ( isModel4Top && isModel5Top ? true : false );
-    bool isPairedEnd = ( isModel2Top && isModel6Top ? true : false );
-    bool isSolidPair = ( isModel1Top && isModel8Top ? true : false );
-
-    if ( !isMatePair && !isPairedEnd && !isSolidPair ) {
-        cerr << "WARNING: Found a non-standard alignment model configuration. " << endl
-             << "         Using alignment models " << TopModelId << " & " << NextTopModelId
-             << endl;
-    }
-
-    // store only the fragments from the best alignment models, then sort
-    vector<int32_t> fragments;
-    fragments.reserve( Models[0].size() + Models[1].size() );
-    fragments.insert( fragments.end(), Models[0].begin(), Models[0].end() );
-    fragments.insert( fragments.end(), Models[1].begin(), Models[1].end() );
-    sort ( fragments.begin(), fragments.end() );
-
-    // clear out Model fragment data, not needed anymore
-    Models.clear();
-
-    // skip if no fragments found for this read group
-    if ( fragments.empty() ) {
-        HasData = false;
-        return;
-    } else
-        HasData = true;
-
-    // calculate & store the min,median, & max fragment lengths
-    const unsigned int numFragmentLengths = fragments.size();
-    const double halfNonConfidenceInterval = (1.0 - ReadGroupResolver::ConfidenceInterval)/2.0;
-    const unsigned int minIndex    = (unsigned int)(numFragmentLengths * halfNonConfidenceInterval);
-    const unsigned int medianIndex = (unsigned int)(numFragmentLengths * 0.5);
-    const unsigned int maxIndex    = (unsigned int)(numFragmentLengths * (1.0-halfNonConfidenceInterval));
-
-    MinFragmentLength    = fragments[minIndex];
-    MedianFragmentLength = fragments[medianIndex];
-    MaxFragmentLength    = fragments[maxIndex];
-}
-
-void ReadGroupResolver::SetConfidenceInterval(const double& ci) {
-    ConfidenceInterval = ci;
-}
-
-void ReadGroupResolver::SetUnusedModelThreshold(const double& umt) {
-    UnusedModelThreshold = umt;
-}
-
-// --------------------------------------------------------------------------
-// ResolveSettings implementation
-
-struct ResolveTool::ResolveSettings {
-
-    // modes
-    bool IsMakeStats;
-    bool IsMarkPairs;
-    bool IsTwoPass;
-
-    // I/O flags
-    bool HasInputBamFile;
-    bool HasOutputBamFile;
-    bool HasStatsFile;
-    bool IsForceCompression;
-
-    // resolve option flags
-    bool HasConfidenceInterval;
-    bool HasForceMarkReadGroups;
-    bool HasMinimumMapQuality;
-    bool HasUnusedModelThreshold;
-
-    // I/O filenames
-    string InputBamFilename;
-    string OutputBamFilename;
-    string StatsFilename;
-    string ReadNamesFilename; //  ** N.B. - Only used internally, not set from cmdline **
-
-    // resolve options
-    double   ConfidenceInterval;
-    uint16_t MinimumMapQuality;
-    double   UnusedModelThreshold;
-
-    // constructor
-    ResolveSettings(void)
-        : IsMakeStats(false)
-        , IsMarkPairs(false)
-        , IsTwoPass(false)
-        , HasInputBamFile(false)
-        , HasOutputBamFile(false)
-        , HasStatsFile(false)
-        , IsForceCompression(false)
-        , HasConfidenceInterval(false)
-        , HasForceMarkReadGroups(false)
-        , HasMinimumMapQuality(false)
-        , HasUnusedModelThreshold(false)
-        , InputBamFilename(Options::StandardIn())
-        , OutputBamFilename(Options::StandardOut())
-        , StatsFilename("")
-        , ReadNamesFilename(DEFAULT_READNAME_FILE)
-        , ConfidenceInterval(DEFAULT_CONFIDENCE_INTERVAL)
-        , MinimumMapQuality(DEFAULT_MIN_MAPQUALITY)
-        , UnusedModelThreshold(DEFAULT_UNUSEDMODEL_THRESHOLD)
-    { }
-};
-
-// --------------------------------------------------------------------------
-// ReadNamesFileReader implementation
-
-struct ResolveTool::ReadNamesFileReader {
-
-    // ctor & dtor
-    ReadNamesFileReader(void) { }
-    ~ReadNamesFileReader(void) { Close(); }
-
-    // main reader interface
-    public:
-        void Close(void);
-        bool Open(const string& filename);
-        bool Read(map<string, ReadGroupResolver>& readGroups);
-
-    // data members
-    private:
-        ifstream m_stream;
-};
-
-void ResolveTool::ReadNamesFileReader::Close(void) {
-    if ( m_stream.is_open() )
-        m_stream.close();
-}
-
-bool ResolveTool::ReadNamesFileReader::Open(const string& filename) {
-
-    // make sure stream is fresh
-    Close();
-
-    // attempt to open filename, return status
-    m_stream.open(filename.c_str(), ifstream::in);
-    return m_stream.good();
-}
-
-bool ResolveTool::ReadNamesFileReader::Read(map<string, ReadGroupResolver>& readGroups) {
-
-    // up-front sanity check
-    if ( !m_stream.is_open() ) return false;
-
-    // parse read names file
-    string line;
-    vector<string> fields;
-    map<string, ReadGroupResolver>::iterator rgIter;
-    map<string, ReadGroupResolver>::iterator rgEnd = readGroups.end();
-    while ( getline(m_stream, line) ) {
-
-        // skip if empty line
-        if ( line.empty() ) continue;
-
-        // split line on '\t'
-        fields = Utilities::Split(line, TAB_CHAR);
-        if ( fields.size() != 2 ) continue;
-
-        // look up resolver for read group
-        rgIter = readGroups.find( fields[0] );
-        if ( rgIter == rgEnd ) return false;
-        ReadGroupResolver& resolver = (*rgIter).second;
-
-        // store read name with resolver
-        resolver.ReadNames.insert( make_pair<string,bool>(fields[1], true) ) ;
-    }
-
-    // if here, return success
-    return true;
-}
-
-// --------------------------------------------------------------------------
-// ReadNamesFileWriter implementation
-
-struct ResolveTool::ReadNamesFileWriter {
-
-    // ctor & dtor
-    ReadNamesFileWriter(void) { }
-    ~ReadNamesFileWriter(void) { Close(); }
-
-    // main reader interface
-    public:
-        void Close(void);
-        bool Open(const string& filename);
-        void Write(const string& readGroupName, const string& readName);
-
-    // data members
-    private:
-        ofstream m_stream;
-};
-
-void ResolveTool::ReadNamesFileWriter::Close(void) {
-    if ( m_stream.is_open() )
-        m_stream.close();
-}
-
-bool ResolveTool::ReadNamesFileWriter::Open(const string& filename) {
-
-    // make sure stream is fresh
-    Close();
-
-    // attempt to open filename, return status
-    m_stream.open(filename.c_str(), ofstream::out);
-    return m_stream.good();
-}
-
-void ResolveTool::ReadNamesFileWriter::Write(const string& readGroupName,
-                                             const string& readName)
-{
-    m_stream << readGroupName << TAB_CHAR << readName << endl;
-}
-
-// --------------------------------------------------------------------------
-// StatsFileReader implementation
-
-struct ResolveTool::StatsFileReader {
-
-    // ctor & dtor
-    public:
-        StatsFileReader(void) { }
-        ~StatsFileReader(void) { Close(); }
-
-    // main reader interface
-    public:
-        void Close(void);
-        bool Open(const string& filename);
-        bool Read(ResolveTool::ResolveSettings* settings,
-                  map<string, ReadGroupResolver>& readGroups);
-
-    // internal methods
-    private:
-        bool IsComment(const string& line) const;
-        bool IsWhitespace(const string& line) const;
-        bool ParseInputLine(const string& line);
-        bool ParseOptionLine(const string& line, ResolveTool::ResolveSettings* settings);
-        bool ParseReadGroupLine(const string& line, map<string, ReadGroupResolver>& readGroups);
-        string SkipCommentsAndWhitespace(void);
-
-    // data members
-    private:
-        ifstream m_stream;
-
-        enum State { None = 0
-                   , InInput
-                   , InOptions
-                   , InReadGroups };
-};
-
-void ResolveTool::StatsFileReader::Close(void) {
-    if ( m_stream.is_open() )
-        m_stream.close();
-}
-
-bool ResolveTool::StatsFileReader::IsComment(const string& line) const {
-    assert( !line.empty() );
-    return ( line.at(0) == COMMENT_CHAR );
-}
-
-bool ResolveTool::StatsFileReader::IsWhitespace(const string& line) const {
-    if ( line.empty() )
-        return true;
-    return ( isspace(line.at(0)) );
-}
-
-bool ResolveTool::StatsFileReader::Open(const string& filename) {
-
-    // make sure stream is fresh
-    Close();
-
-    // attempt to open filename, return status
-    m_stream.open(filename.c_str(), ifstream::in);
-    return m_stream.good();
-}
-
-bool ResolveTool::StatsFileReader::ParseInputLine(const string& /*line*/) {
-    // input lines are ignored (for now at least), tool will use input from command line
-    return true;
-}
-
-bool ResolveTool::StatsFileReader::ParseOptionLine(const string& line,
-                                                   ResolveTool::ResolveSettings* settings)
-{
-    // split line into option, value
-    vector<string> fields = Utilities::Split(line, EQUAL_CHAR);
-    if ( fields.size() != NUM_OPTIONS_FIELDS )
-        return false;
-    const string& option = fields.at(0);
-    stringstream value(fields.at(1));
-
-    // -----------------------------------
-    // handle option based on keyword
-
-    // ConfidenceInterval
-    if ( option == OPTION_CONFIDENCEINTERVAL ) {
-        value >> settings->ConfidenceInterval;
-        settings->HasConfidenceInterval = true;
-        return true;
-    }
-
-    // ForceMarkReadGroups
-    if ( option == OPTION_FORCEMARKREADGROUPS ) {
-        value >> settings->HasForceMarkReadGroups;
-        return true;
-    }
-
-    // MinimumMapQuality
-    if ( option == OPTION_MINIMUMMAPQUALITY ) {
-        value >> settings->MinimumMapQuality;
-        settings->HasMinimumMapQuality = true;
-        return true;
-    }
-
-    // UnusedModelThreshold
-    if ( option == OPTION_UNUSEDMODELTHRESHOLD ) {
-        value >> settings->UnusedModelThreshold;
-        settings->HasUnusedModelThreshold = true;
-        return true;
-    }
-
-    // otherwise unknown option
-    cerr << "bamtools resolve ERROR - unrecognized option: " << option << " in stats file" << endl;
-    return false;
-}
-
-bool ResolveTool::StatsFileReader::ParseReadGroupLine(const string& line,
-                                                      map<string, ReadGroupResolver>& readGroups)
-{
-    // split read group data in to fields
-    vector<string> fields = Utilities::Split(line, WHITESPACE_CHARS);
-    if ( fields.size() != NUM_READGROUPS_FIELDS ) return false;
-
-    // retrieve RG name
-    const string& name = fields.at(0);
-
-    // populate RG's 'resolver' data
-    ReadGroupResolver resolver;
-
-    stringstream dataStream;
-    dataStream.str(fields.at(1));
-    dataStream >> resolver.MedianFragmentLength;
-    dataStream.clear();
-
-    dataStream.str(fields.at(2));
-    dataStream >> resolver.MinFragmentLength;
-    dataStream.clear();
-
-    dataStream.str(fields.at(3));
-    dataStream >> resolver.MaxFragmentLength;
-    dataStream.clear();
-
-    dataStream.str(fields.at(4));
-    dataStream >> resolver.TopModelId;
-    dataStream.clear();
-
-    dataStream.str(fields.at(5));
-    dataStream >> resolver.NextTopModelId;
-    dataStream.clear();
-
-    resolver.IsAmbiguous = ( fields.at(6) == TRUE_KEYWORD );
-
-    // store RG entry and return success
-    readGroups.insert( make_pair<string, ReadGroupResolver>(name, resolver) );
-    return true;
-}
-
-bool ResolveTool::StatsFileReader::Read(ResolveTool::ResolveSettings* settings,
-                                        map<string, ReadGroupResolver>& readGroups)
-{
-    // up-front sanity checks
-    if ( !m_stream.is_open() || settings == 0 )
-        return false;
-
-    // clear out read group data
-    readGroups.clear();
-
-    // initialize state
-    State currentState = StatsFileReader::None;
-
-    // read stats file
-    string line = SkipCommentsAndWhitespace();
-    while ( !line.empty() ) {
-
-        bool foundError = false;
-
-        // switch state on keyword found
-        if ( Utilities::StartsWith(line, INPUT_TOKEN) )
-            currentState = StatsFileReader::InInput;
-        else if ( Utilities::StartsWith(line, OPTIONS_TOKEN) )
-            currentState = StatsFileReader::InOptions;
-        else if ( Utilities::StartsWith(line, READGROUPS_TOKEN) )
-            currentState = StatsFileReader::InReadGroups;
-
-        // otherwise parse data line, depending on state
-        else {
-            if ( currentState == StatsFileReader::InInput )
-                foundError = !ParseInputLine(line);
-            else if ( currentState == StatsFileReader::InOptions )
-                foundError = !ParseOptionLine(line, settings);
-            else if ( currentState == StatsFileReader::InReadGroups )
-                foundError = !ParseReadGroupLine(line, readGroups);
-            else
-                foundError = true;
-        }
-
-        // break out if error found
-        if ( foundError )
-            return false;
-
-        // get next line
-        line = SkipCommentsAndWhitespace();
-    }
-
-    // if here, return success
-    return true;
-}
-
-string ResolveTool::StatsFileReader::SkipCommentsAndWhitespace(void) {
-    string line;
-    do {
-        if ( m_stream.eof() )
-            return string();
-        getline(m_stream, line);
-    } while ( IsWhitespace(line) || IsComment(line) );
-    return line;
-}
-
-// --------------------------------------------------------------------------
-// StatsFileReader implementation
-
-struct ResolveTool::StatsFileWriter {
-
-    // ctor & dtor
-    public:
-        StatsFileWriter(void) { }
-        ~StatsFileWriter(void) { Close(); }
-
-    // main reader interface
-    public:
-        void Close(void);
-        bool Open(const string& filename);
-        bool Write(ResolveTool::ResolveSettings* settings,
-                   const map<string, ReadGroupResolver>& readGroups);
-
-    // internal methods
-    private:
-        void WriteHeader(void);
-        void WriteInput(ResolveTool::ResolveSettings* settings);
-        void WriteOptions(ResolveTool::ResolveSettings* settings);
-        void WriteReadGroups(const map<string, ReadGroupResolver>& readGroups);
-
-    // data members
-    private:
-        ofstream m_stream;
-};
-
-void ResolveTool::StatsFileWriter::Close(void) {
-    if ( m_stream.is_open() )
-        m_stream.close();
-}
-
-bool ResolveTool::StatsFileWriter::Open(const string& filename) {
-
-    // make sure stream is fresh
-    Close();
-
-    // attempt to open filename, return status
-    m_stream.open(filename.c_str(), ofstream::out);
-    return m_stream.good();
-}
-
-bool ResolveTool::StatsFileWriter::Write(ResolveTool::ResolveSettings* settings,
-                                         const map<string, ReadGroupResolver>& readGroups)
-{
-    // return failure if file not open
-    if ( !m_stream.is_open() )
-        return false;
-
-    // write stats file elements
-    WriteHeader();
-    WriteInput(settings);
-    WriteOptions(settings);
-    WriteReadGroups(readGroups);
-
-    // return success
-    return true;
-}
-
-void ResolveTool::StatsFileWriter::WriteHeader(void) {
-
-    // stringify current bamtools version
-    stringstream versionStream("");
-    versionStream << "v"
-                  << BAMTOOLS_VERSION_MAJOR << "."
-                  << BAMTOOLS_VERSION_MINOR << "."
-                  << BAMTOOLS_VERSION_BUILD;
-
-    // # bamtools resolve (vX.Y.Z)
-    // #
-    // # MODEL DESCRIPTION - see above for actual text
-    // \n
-
-    m_stream << COMMENT_CHAR << " bamtools resolve (" << versionStream.str() << ")" << endl
-             << COMMENT_CHAR << endl
-             << MODEL_DESCRIPTION
-             << endl;
-}
-
-void ResolveTool::StatsFileWriter::WriteInput(ResolveTool::ResolveSettings* settings) {
-
-    // [Input]
-    // filename
-    // \n
-
-    m_stream << INPUT_TOKEN << endl
-             << settings->InputBamFilename << endl
-             << endl;
-}
-
-void ResolveTool::StatsFileWriter::WriteOptions(ResolveTool::ResolveSettings* settings) {
-
-    // [Options]
-    // ConfidenceInterval=<double>
-    // ForceMarkReadGroups=<true|false>
-    // MinimumMapQuality=<uint16_t>
-    // UnusedModelThreshold=<double>
-    // \n
-
-    m_stream << OPTIONS_TOKEN << endl
-             << OPTION_CONFIDENCEINTERVAL   << EQUAL_CHAR << settings->ConfidenceInterval << endl
-             << OPTION_FORCEMARKREADGROUPS  << EQUAL_CHAR << boolalpha << settings->HasForceMarkReadGroups << endl
-             << OPTION_MINIMUMMAPQUALITY    << EQUAL_CHAR << settings->MinimumMapQuality << endl
-             << OPTION_UNUSEDMODELTHRESHOLD << EQUAL_CHAR << settings->UnusedModelThreshold << endl
-             << endl;
-}
-
-void ResolveTool::StatsFileWriter::WriteReadGroups(const map<string, ReadGroupResolver>& readGroups) {
-
-    // [ReadGroups]
-    // #<name> <medianFL> <minFL> <maxFL> <topModelID> <nextTopModelID> <isAmbiguous?>
-    m_stream << READGROUPS_TOKEN << endl
-             << RG_FIELD_DESCRIPTION << endl;
-
-    // iterate over read groups
-    map<string, ReadGroupResolver>::const_iterator rgIter = readGroups.begin();
-    map<string, ReadGroupResolver>::const_iterator rgEnd  = readGroups.end();
-    for ( ; rgIter != rgEnd; ++rgIter ) {
-        const string& name = (*rgIter).first;
-        const ReadGroupResolver& resolver = (*rgIter).second;
-
-        // skip if read group has no data
-        if ( !resolver.HasData )
-            continue;
-
-        // write read group data
-        m_stream << name << TAB_CHAR
-                 << resolver.MedianFragmentLength << TAB_CHAR
-                 << resolver.MinFragmentLength << TAB_CHAR
-                 << resolver.MaxFragmentLength << TAB_CHAR
-                 << resolver.TopModelId << TAB_CHAR
-                 << resolver.NextTopModelId << TAB_CHAR
-                 << boolalpha << resolver.IsAmbiguous
-                 << endl;
-    }
-
-    // extra newline at end
-    m_stream << endl;
-}
-
-// --------------------------------------------------------------------------
-// ResolveToolPrivate implementation
-
-struct ResolveTool::ResolveToolPrivate {
-
-    // ctor & dtor
-    public:
-        ResolveToolPrivate(ResolveTool::ResolveSettings* settings)
-            : m_settings(settings)
-        { }
-        ~ResolveToolPrivate(void) { }
-
-    // 'public' interface
-    public:
-        bool Run(void);
-
-    // internal methods
-    private:
-        bool CheckSettings(vector<string>& errors);
-        bool MakeStats(void);
-        void ParseHeader(const SamHeader& header);
-        bool ReadStatsFile(void);
-        void ResolveAlignment(BamAlignment& al);
-        bool ResolvePairs(void);
-        bool WriteStatsFile(void);
-
-    // data members
-    private:
-        ResolveTool::ResolveSettings* m_settings;
-        map<string, ReadGroupResolver> m_readGroups;
-};
-
-bool ResolveTool::ResolveToolPrivate::CheckSettings(vector<string>& errors) {
-
-    // ensure clean slate
-    errors.clear();
-
-    // if MakeStats mode
-    if ( m_settings->IsMakeStats ) {
-
-        // ensure mutex mode
-        if ( m_settings->IsMarkPairs )
-            errors.push_back("Cannot run in both -makeStats & -markPairs modes. Please select ONE.");
-        if ( m_settings->IsTwoPass )
-            errors.push_back("Cannot run in both -makeStats & -twoPass modes. Please select ONE.");
-
-        // error if output BAM options supplied
-        if ( m_settings->HasOutputBamFile )
-            errors.push_back("Cannot use -out (output BAM file) in -makeStats mode.");
-        if ( m_settings->IsForceCompression )
-            errors.push_back("Cannot use -forceCompression. No output BAM file is being generated.");
-
-        // make sure required stats file supplied
-        if ( !m_settings->HasStatsFile )
-            errors.push_back("Ouptut stats filename required for -makeStats mode. Please specify one using -stats option.");
-
-        // check for UseStats options
-        if ( m_settings->HasForceMarkReadGroups )
-            errors.push_back("Cannot use -forceMarkReadGroups. -markPairs options are DISABLED in -makeStats mode.");
-    }
-
-    // if MarkPairs mode
-    else if ( m_settings->IsMarkPairs ) {
-
-        // ensure mutex mode
-        if ( m_settings->IsMakeStats )
-            errors.push_back("Cannot run in both -makeStats & -markPairs modes. Please select ONE.");
-        if ( m_settings->IsTwoPass )
-            errors.push_back("Cannot run in both -markPairs & -twoPass modes. Please select ONE.");
-
-        // make sure required stats file supplied
-        if ( !m_settings->HasStatsFile )
-            errors.push_back("Input stats filename required for -markPairs mode. Please specify one using -stats option.");
-
-        // check for MakeStats options
-        if ( m_settings->HasConfidenceInterval )
-            errors.push_back("Cannot use -ci. -makeStats options are DISABLED is -markPairs mode.");
-    }
-
-    // if TwoPass mode
-    else if ( m_settings->IsTwoPass ) {
-
-        // ensure mutex mode
-        if ( m_settings->IsMakeStats )
-            errors.push_back("Cannot run in both -makeStats & -twoPass modes. Please select ONE.");
-        if ( m_settings->IsMarkPairs )
-            errors.push_back("Cannot run in both -markPairs & -twoPass modes. Please select ONE.");
-
-        // make sure input is file not stdin
-        if ( !m_settings->HasInputBamFile || m_settings->InputBamFilename == Options::StandardIn() )
-            errors.push_back("Cannot run -twoPass mode with BAM data from stdin. Please specify existing file using -in option.");
-    }
-
-    // no mode selected
-    else
-        errors.push_back("No resolve mode specified. Please select ONE of the following: -makeStats, -markPairs, or -twoPass. See help for more info.");
-
-    // boundary checks on values
-    if ( m_settings->HasConfidenceInterval ) {
-        if ( m_settings->ConfidenceInterval < 0.0 || m_settings->ConfidenceInterval > 1.0 )
-            errors.push_back("Invalid confidence interval. Must be between 0 and 1");
-    }
-    if ( m_settings->HasMinimumMapQuality ) {
-        if ( m_settings->MinimumMapQuality >= 256 )
-            errors.push_back("Invalid minimum map quality. Must be between 0 and 255");
-    }
-    if ( m_settings->HasUnusedModelThreshold ) {
-        if ( m_settings->UnusedModelThreshold < 0.0 || m_settings->UnusedModelThreshold > 1.0 )
-            errors.push_back("Invalid unused model threshold. Must be between 0 and 1");
-    }
-
-    // return success if no errors found
-    return ( errors.empty() );
-}
-
-bool ResolveTool::ResolveToolPrivate::MakeStats(void) {
-
-    // pull resolver settings from command-line settings
-    ReadGroupResolver::SetConfidenceInterval(m_settings->ConfidenceInterval);
-    ReadGroupResolver::SetUnusedModelThreshold(m_settings->UnusedModelThreshold);
-
-    // open our BAM reader
-    BamReader bamReader;
-    if ( !bamReader.Open(m_settings->InputBamFilename) ) {
-        cerr << "bamtools resolve ERROR: could not open input BAM file: "
-             << m_settings->InputBamFilename << endl;
-        return false;
-    }
-
-    // retrieve header & parse for read groups
-    const SamHeader& header = bamReader.GetHeader();
-    ParseHeader(header);
-
-    // open ReadNamesFileWriter
-    ResolveTool::ReadNamesFileWriter readNamesWriter;
-    if ( !readNamesWriter.Open(m_settings->ReadNamesFilename) ) {
-        cerr << "bamtools resolve ERROR: could not open (temp) output read names file: "
-             << m_settings->ReadNamesFilename << endl;
-        bamReader.Close();
-        return false;
-    }
-
-    // read through BAM file
-    BamAlignment al;
-    string readGroup("");
-    map<string, ReadGroupResolver>::iterator rgIter;
-    map<string, bool>::iterator readNameIter;
-    while ( bamReader.GetNextAlignmentCore(al) ) {
-
-        // skip if alignment is not paired, mapped, nor mate is mapped
-        if ( !al.IsPaired() || !al.IsMapped() || !al.IsMateMapped() )
-            continue;
-
-        // skip if alignment & mate not on same reference sequence
-        if ( al.RefID != al.MateRefID ) continue;
-
-        // flesh out the char data, so we can retrieve its read group ID
-        al.BuildCharData();
-
-        // get read group from alignment (OK if empty)
-        readGroup.clear();
-        al.GetTag(READ_GROUP_TAG, readGroup);
-
-        // look up resolver for read group
-        rgIter = m_readGroups.find(readGroup);
-        if ( rgIter == m_readGroups.end() )  {
-            cerr << "bamtools resolve ERROR - unable to calculate stats, unknown read group encountered: "
-                 << readGroup << endl;
-            bamReader.Close();
-            return false;
-        }
-        ReadGroupResolver& resolver = (*rgIter).second;
-
-        // determine unique-ness of current alignment
-        const bool isCurrentMateUnique = ( al.MapQuality >= m_settings->MinimumMapQuality );
-
-        // look up read name
-        readNameIter = resolver.ReadNames.find(al.Name);
-
-        // if read name found (current alignment's mate already parsed)
-        if ( readNameIter != resolver.ReadNames.end() ) {
-
-            // if both unique mates are unique, store read name & insert size for later
-            const bool isStoredMateUnique  = (*readNameIter).second;
-            if ( isCurrentMateUnique && isStoredMateUnique ) {
-
-                // save read name in temp file as candidates for later pair marking
-                readNamesWriter.Write(readGroup, al.Name);
-
-                // determine model type & store fragment length for stats calculation
-                const uint16_t currentModelType = CalculateModelType(al);
-                assert( currentModelType != ModelType::DUMMY_ID );
-                resolver.Models[currentModelType].push_back( abs(al.InsertSize) );
-            }
-
-            // unique or not, remove read name from map
-            resolver.ReadNames.erase(readNameIter);
-        }
-
-        // if read name not found, store new entry
-        else resolver.ReadNames.insert( make_pair<string, bool>(al.Name, isCurrentMateUnique) );
-    }
-
-    // close files
-    readNamesWriter.Close();
-    bamReader.Close();
-
-    // iterate back through read groups
-    map<string, ReadGroupResolver>::iterator rgEnd  = m_readGroups.end();
-    for ( rgIter = m_readGroups.begin(); rgIter != rgEnd; ++rgIter ) {
-        const string& name = (*rgIter).first;
-        ReadGroupResolver& resolver = (*rgIter).second;
-
-        // calculate acceptable orientation & insert sizes for this read group
-        resolver.DetermineTopModels(name);
-
-        // clear out left over read names
-        // (these have mates that did not pass filters or were already removed as non-unique)
-        resolver.ReadNames.clear();
-    }
-
-    // if we get here, return success
-    return true;
-}
-
-void ResolveTool::ResolveToolPrivate::ParseHeader(const SamHeader& header) {
-
-    // iterate over header read groups, creating a 'resolver' for each
-    SamReadGroupConstIterator rgIter = header.ReadGroups.ConstBegin();
-    SamReadGroupConstIterator rgEnd  = header.ReadGroups.ConstEnd();
-    for ( ; rgIter != rgEnd; ++rgIter ) {
-        const SamReadGroup& rg = (*rgIter);
-        m_readGroups.insert( make_pair<string, ReadGroupResolver>(rg.ID, ReadGroupResolver()) );
-    }
-}
-
-bool ResolveTool::ResolveToolPrivate::ReadStatsFile(void) {
-
-    // skip if no filename provided
-    if ( m_settings->StatsFilename.empty() )
-        return false;
-
-    // attempt to open stats file
-    ResolveTool::StatsFileReader statsReader;
-    if ( !statsReader.Open(m_settings->StatsFilename) ) {
-        cerr << "bamtools resolve ERROR - could not open stats file: "
-             << m_settings->StatsFilename << " for reading" << endl;
-        return false;
-    }
-
-    // attempt to read stats data
-    if ( !statsReader.Read(m_settings, m_readGroups) ) {
-        cerr << "bamtools resolve ERROR - could not parse stats file: "
-             << m_settings->StatsFilename << " for data" << endl;
-        return false;
-    }
-
-    // return success
-    return true;
-}
-
-void ResolveTool::ResolveToolPrivate::ResolveAlignment(BamAlignment& al) {
-
-    // clear proper-pair flag
-    al.SetIsProperPair(false);
-
-    // quit check if alignment is not from paired-end read
-    if ( !al.IsPaired() ) return;
-
-    // quit check if either alignment or its mate are unmapped
-    if ( !al.IsMapped() || !al.IsMateMapped() ) return;
-
-    // quit check if alignment & its mate are on differenct references
-    if ( al.RefID != al.MateRefID ) return;
-
-    // quit check if map quality less than cutoff
-    if ( al.MapQuality < m_settings->MinimumMapQuality ) return;
-
-    // get read group from alignment
-    // empty string if not found, this is OK - we handle empty read group case
-    string readGroupName("");
-    al.GetTag(READ_GROUP_TAG, readGroupName);
-
-    // look up read group's 'resolver'
-    map<string, ReadGroupResolver>::iterator rgIter = m_readGroups.find(readGroupName);
-    if ( rgIter == m_readGroups.end() ) {
-        cerr << "bamtools resolve ERROR - read group found that was not in header: "
-             << readGroupName << endl;
-        exit(1);
-    }
-    const ReadGroupResolver& resolver = (*rgIter).second;
-
-    // quit check if pairs are not in proper orientation (can differ for each RG)
-    if ( !resolver.IsValidOrientation(al) ) return;
-
-    // quit check if pairs are not within "reasonable" distance (can differ for each RG)
-    if ( !resolver.IsValidInsertSize(al) ) return;
-
-    // quit check if alignment is not a "candidate proper pair"
-    map<string, bool>::const_iterator readNameIter;
-    readNameIter = resolver.ReadNames.find(al.Name);
-    if ( readNameIter == resolver.ReadNames.end() )
-        return;
-
-    // if we get here, alignment is OK - set 'proper pair' flag
-    al.SetIsProperPair(true);
-}
-
-bool ResolveTool::ResolveToolPrivate::ResolvePairs(void) {
-
-    // open file containing read names of candidate proper pairs
-    ResolveTool::ReadNamesFileReader readNamesReader;
-    if ( !readNamesReader.Open(m_settings->ReadNamesFilename) ) {
-        cerr << "bamtools resolve ERROR: could not open (temp) inputput read names file: "
-             << m_settings->ReadNamesFilename << endl;
-        return false;
-    }
-
-    // parse read names (matching with corresponding read groups)
-    if ( !readNamesReader.Read(m_readGroups) ) {
-        cerr << "bamtools resolve ERROR: could not read candidate read names from file: "
-             << m_settings->ReadNamesFilename << endl;
-        readNamesReader.Close();
-        return false;
-    }
-
-    // close read name file reader & delete temp file
-    readNamesReader.Close();
-    if ( remove(m_settings->ReadNamesFilename.c_str()) != 0 ) {
-        cerr << "bamtools resolve WARNING: could not delete temp file: "
-             << m_settings->ReadNamesFilename << endl;
-    }
-
-    // open our BAM reader
-    BamReader reader;
-    if ( !reader.Open(m_settings->InputBamFilename) ) {
-        cerr << "bamtools resolve ERROR: could not open input BAM file: "
-             << m_settings->InputBamFilename << endl;
-        return false;
-    }
-
-    // retrieve header & reference dictionary info
-    const SamHeader& header = reader.GetHeader();
-    const RefVector& references = reader.GetReferenceData();
-
-    // determine compression mode for BamWriter
-    bool writeUncompressed = ( m_settings->OutputBamFilename == Options::StandardOut() &&
-                               !m_settings->IsForceCompression );
-    BamWriter::CompressionMode compressionMode = BamWriter::Compressed;
-    if ( writeUncompressed ) compressionMode = BamWriter::Uncompressed;
-
-    // open BamWriter
-    BamWriter writer;
-    writer.SetCompressionMode(compressionMode);
-    if ( !writer.Open(m_settings->OutputBamFilename, header, references) ) {
-        cerr << "bamtools resolve ERROR: could not open "
-             << m_settings->OutputBamFilename << " for writing." << endl;
-        reader.Close();
-        return false;
-    }
-
-    // plow through alignments, setting/clearing 'proper pair' flag
-    // and writing to new output BAM file
-    BamAlignment al;
-    while ( reader.GetNextAlignment(al) ) {
-        ResolveAlignment(al);
-        writer.SaveAlignment(al);
-    }
-
-    // clean up & return success
-    reader.Close();
-    writer.Close();
-    return true;
-}
-
-bool ResolveTool::ResolveToolPrivate::Run(void) {
-
-    // verify that command line settings are acceptable
-    vector<string> errors;
-    if ( !CheckSettings(errors) ) {
-        cerr << "bamtools resolve ERROR - invalid settings: " << endl;
-        vector<string>::const_iterator errorIter = errors.begin();
-        vector<string>::const_iterator errorEnd  = errors.end();
-        for ( ; errorIter != errorEnd; ++errorIter )
-            cerr << (*errorIter) << endl;
-        return false;
-    }
-
-    // initialize read group map with default (empty name) read group
-    m_readGroups.insert( make_pair<string, ReadGroupResolver>("", ReadGroupResolver()) );
-
-    // init readname filename
-    // uses (adjusted) stats filename if provided (req'd for makeStats, markPairs modes; optional for twoPass)
-    // else keep default filename
-    if ( m_settings->HasStatsFile )
-        m_settings->ReadNamesFilename = m_settings->StatsFilename + READNAME_FILE_SUFFIX;
-
-    // -makeStats mode
-    if ( m_settings->IsMakeStats ) {
-
-        // generate stats data
-        if ( !MakeStats() ) {
-            cerr << "bamtools resolve ERROR - could not generate stats" << endl;
-            return false;
-        }
-
-        // write stats to file
-        if ( !WriteStatsFile() ) {
-            cerr << "bamtools resolve ERROR - could not write stats file: "
-                 << m_settings->StatsFilename << endl;
-            return false;
-        }
-    }
-
-    // -markPairs mode
-    else if ( m_settings->IsMarkPairs ) {
-
-        // read stats from file
-        if ( !ReadStatsFile() ) {
-            cerr << "bamtools resolve ERROR - could not read stats file: "
-                 << m_settings->StatsFilename << endl;
-            return false;
-        }
-
-        // do paired-end resolution
-        if ( !ResolvePairs() ) {
-            cerr << "bamtools resolve ERROR - could not resolve pairs" << endl;
-            return false;
-        }
-    }
-
-    // -twoPass mode
-    else {
-
-        // generate stats data
-        if ( !MakeStats() ) {
-            cerr << "bamtools resolve ERROR - could not generate stats" << endl;
-            return false;
-        }
-
-        // if stats file requested
-        if ( m_settings->HasStatsFile ) {
-
-            // write stats to file
-            // emit warning if write fails, but paired-end resolution should be allowed to proceed
-            if ( !WriteStatsFile() )
-                cerr << "bamtools resolve WARNING - could not write stats file: "
-                     << m_settings->StatsFilename << endl;
-        }
-
-        // do paired-end resolution
-        if ( !ResolvePairs() ) {
-            cerr << "bamtools resolve ERROR - could not resolve pairs" << endl;
-            return false;
-        }
-    }
-
-    // return success
-    return true;
-}
-
-bool ResolveTool::ResolveToolPrivate::WriteStatsFile(void) {
-
-    // skip if no filename provided
-    if ( m_settings->StatsFilename.empty() )
-        return false;
-
-    // attempt to open stats file
-    ResolveTool::StatsFileWriter statsWriter;
-    if ( !statsWriter.Open(m_settings->StatsFilename) ) {
-        cerr << "bamtools resolve ERROR - could not open stats file: "
-             << m_settings->StatsFilename << " for writing" << endl;
-        return false;
-    }
-
-    // attempt to write stats data
-    if ( !statsWriter.Write(m_settings, m_readGroups) ) {
-        cerr << "bamtools resolve ERROR - could not write stats file: "
-             << m_settings->StatsFilename << " for data" << endl;
-        return false;
-    }
-
-    // return success
-    return true;
-}
-
-// --------------------------------------------------------------------------
-// ResolveTool implementation
-
-ResolveTool::ResolveTool(void)
-    : AbstractTool()
-    , m_settings(new ResolveSettings)
-    , m_impl(0)
-{
-    // set description texts
-    const string programDescription = "resolves paired-end reads (marking the IsProperPair flag as needed)";
-    const string programUsage = "<mode> [options] [-in <filename>] [-out <filename> | [-forceCompression] ] [-stats <filename>]";
-    const string inputBamDescription = "the input BAM file(s)";
-    const string outputBamDescription = "the output BAM file";
-    const string statsFileDescription = "input/output stats file, depending on selected mode (see below). "
-            "This file is human-readable, storing fragment length data generated per read group, as well as "
-            "the options used to configure the -makeStats mode";
-    const string forceCompressionDescription = "if results are sent to stdout (like when piping to another tool), "
-            "default behavior is to leave output uncompressed."
-            "Use this flag to override and force compression. This feature is disabled in -makeStats mode.";
-    const string makeStatsDescription = "generates a fragment-length stats file from the input BAM. "
-            "Data is written to file specified using the -stats option. "
-            "MarkPairs Mode Settings are DISABLED.";
-    const string markPairsDescription = "generates an output BAM with alignments marked with proper-pair status. "
-            "Stats data is read from file specified using the -stats option. "
-            "MakeStats Mode Settings are DISABLED";
-    const string twoPassDescription = "combines the -makeStats & -markPairs modes into a single command. "
-            "However, due to the two-pass nature of paired-end resolution, piping BAM data via stdin is DISABLED. "
-            "You must supply an explicit input BAM file. Output BAM may be piped to stdout, however, if desired. "
-            "All MakeStats & MarkPairs Mode Settings are available. "
-            "The intermediate stats file is not necessary, but if the -stats options is used, then one will be generated. "
-            "You may find this useful for documentation purposes.";
-    const string minMapQualDescription = "minimum map quality. Used in -makeStats mode as a heuristic for determining a mate's "
-            "uniqueness. Used in -markPairs mode as a filter for marking candidate proper pairs.";
-    const string confidenceIntervalDescription = "confidence interval. Set min/max fragment lengths such that we capture "
-            "this fraction of pairs";
-    const string unusedModelThresholdDescription = "unused model threshold. The resolve tool considers 8 possible orientation models "
-            "for pairs. The top 2 are selected for later use when actually marking alignments. This value determines the "
-            "cutoff for marking a read group as ambiguous. Meaning that if the ratio of the number of alignments from bottom 6 models "
-            "to the top 2 is greater than this threshold, then the read group is flagged as ambiguous. By default, NO alignments "
-            "from ambiguous read groups will be marked as proper pairs. You may override this behavior with the -force option "
-            "in -markPairs mode";
-    const string forceMarkDescription = "forces all read groups to be marked according to their top 2 'orientation models'. "
-            "When generating stats, the 2 (out of 8 possible) models with the most observations are chosen as the top models for each read group. "
-            "If the remaining 6 models account for more than some threshold ([default=10%], see -umt), then the read group is marked as ambiguous. "
-            "The default behavior is that for an ambiguous read group, NONE of its alignments are marked as proper-pairs. "
-            "By setting this option, a read group's ambiguity flag will be ignored, and all of its alignments will be compared to the top 2 models.";
-
-    // set program details
-    Options::SetProgramInfo("bamtools resolve", programDescription, programUsage);
-
-    // set up I/O options
-    OptionGroup* IO_Opts = Options::CreateOptionGroup("Input & Output");
-    Options::AddValueOption("-in",  "BAM filename", inputBamDescription, "",
-                            m_settings->HasInputBamFile, m_settings->InputBamFilename,
-                            IO_Opts, Options::StandardIn());
-    Options::AddValueOption("-out", "BAM filename", outputBamDescription, "",
-                            m_settings->HasOutputBamFile, m_settings->OutputBamFilename,
-                            IO_Opts, Options::StandardOut());
-    Options::AddValueOption("-stats", "STATS filename", statsFileDescription, "",
-                            m_settings->HasStatsFile, m_settings->StatsFilename, IO_Opts);
-    Options::AddOption("-forceCompression", forceCompressionDescription,
-                       m_settings->IsForceCompression, IO_Opts);
-
-    OptionGroup* ModeOpts = Options::CreateOptionGroup("Resolve Modes (must select ONE of the following)");
-    Options::AddOption("-makeStats", makeStatsDescription, m_settings->IsMakeStats, ModeOpts);
-    Options::AddOption("-markPairs", markPairsDescription, m_settings->IsMarkPairs, ModeOpts);
-    Options::AddOption("-twoPass",   twoPassDescription,   m_settings->IsTwoPass,   ModeOpts);
-
-    OptionGroup* GeneralOpts = Options::CreateOptionGroup("General Resolve Options (available in all modes)");
-    Options::AddValueOption("-minMQ", "unsigned short", minMapQualDescription, "",
-                            m_settings->HasMinimumMapQuality, m_settings->MinimumMapQuality, GeneralOpts);
-
-    OptionGroup* MakeStatsOpts = Options::CreateOptionGroup("MakeStats Mode Options (disabled in -markPairs mode)");
-    Options::AddValueOption("-ci", "double", confidenceIntervalDescription, "",
-                            m_settings->HasConfidenceInterval, m_settings->ConfidenceInterval, MakeStatsOpts);
-    Options::AddValueOption("-umt", "double", unusedModelThresholdDescription, "",
-                            m_settings->HasUnusedModelThreshold, m_settings->UnusedModelThreshold, MakeStatsOpts);
-
-    OptionGroup* MarkPairsOpts = Options::CreateOptionGroup("MarkPairs Mode Options (disabled in -makeStats mode)");
-    Options::AddOption("-force", forceMarkDescription, m_settings->HasForceMarkReadGroups, MarkPairsOpts);
-}
-
-ResolveTool::~ResolveTool(void) {
-
-    delete m_settings;
-    m_settings = 0;
-
-    delete m_impl;
-    m_impl = 0;
-}
-
-int ResolveTool::Help(void) {
-    Options::DisplayHelp();
-    return 0;
-}
-
-int ResolveTool::Run(int argc, char* argv[]) {
-
-    // parse command line arguments
-    Options::Parse(argc, argv, 1);
-
-    // initialize ResolveTool
-    m_impl = new ResolveToolPrivate(m_settings);
-
-    // run ResolveTool, return success/failure
-    if ( m_impl->Run() )
-        return 0;
-    else
-        return 1;
-}
diff --git a/bamtools/src/toolkit/bamtools_resolve.h b/bamtools/src/toolkit/bamtools_resolve.h
deleted file mode 100644
index f90dec0..0000000
--- a/bamtools/src/toolkit/bamtools_resolve.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// ***************************************************************************
-// bamtools_resolve.h (c) 2011 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 23 June 2011
-// ---------------------------------------------------------------------------
-// Resolves paired-end reads (marking the IsProperPair flag as needed).
-// ***************************************************************************
-
-#ifndef BAMTOOLS_RESOLVE_H
-#define BAMTOOLS_RESOLVE_H
-
-#include "bamtools_tool.h"
-
-namespace BamTools {
-
-class ResolveTool : public AbstractTool {
-
-    public:
-        ResolveTool(void);
-        ~ResolveTool(void);
-
-    public:
-        int Help(void);
-        int Run(int argc, char* argv[]);
-
-    private:
-        struct ResolveSettings;
-        ResolveSettings* m_settings;
-
-        struct ResolveToolPrivate;
-        ResolveToolPrivate* m_impl;
-
-        struct ReadNamesFileReader;
-        struct ReadNamesFileWriter;
-        struct StatsFileReader;
-        struct StatsFileWriter;
-};
-
-} // namespace BamTools
-
-#endif // BAMTOOLS_RESOLVE_H
diff --git a/bamtools/src/toolkit/bamtools_revert.cpp b/bamtools/src/toolkit/bamtools_revert.cpp
deleted file mode 100644
index ba0debe..0000000
--- a/bamtools/src/toolkit/bamtools_revert.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
-// ***************************************************************************
-// bamtools_revert.cpp (c) 2010 Derek Barnett, Alistair Ward
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 7 April 2011
-// ---------------------------------------------------------------------------
-// Removes duplicate marks and restores original base qualities
-// ***************************************************************************
-
-#include "bamtools_revert.h"
-
-#include <api/BamReader.h>
-#include <api/BamWriter.h>
-#include <utils/bamtools_options.h>
-#include <utils/bamtools_utilities.h>
-using namespace BamTools;
-
-#include <iostream>
-#include <string>
-using namespace std;
-
-namespace BamTools {
-
-static const string OQ_TAG = "OQ";
-
-} // namespace BamTools;
-
-// ---------------------------------------------
-// RevertSettings implementation
-
-struct RevertTool::RevertSettings {
-
-    // flags
-    bool HasInput;
-    bool HasOutput;
-    bool IsForceCompression;
-    bool IsKeepDuplicateFlag;
-    bool IsKeepQualities;
-
-    // filenames
-    string InputFilename;
-    string OutputFilename;
-    
-    // constructor
-    RevertSettings(void)
-        : HasInput(false)
-        , HasOutput(false)
-        , IsForceCompression(false)
-        , IsKeepDuplicateFlag(false)
-        , IsKeepQualities(false)
-        , InputFilename(Options::StandardIn())
-        , OutputFilename(Options::StandardOut())
-    { }
-};  
-
-// ---------------------------------------------
-// RevertToolPrivate implementation
-
-struct RevertTool::RevertToolPrivate {
-  
-    // ctor & dtor
-    public:
-        RevertToolPrivate(RevertTool::RevertSettings* settings)
-            : m_settings(settings)
-        { }
-        ~RevertToolPrivate(void) { }
-  
-    // 'public' interface
-    public:
-        bool Run(void);
-        
-    // internal methods
-    private:
-        void RevertAlignment(BamAlignment& al);
-        
-    // data members
-    private:
-        RevertTool::RevertSettings* m_settings;
-};
-
-// 'reverts' a BAM alignment
-// default behavior (for now) is:
-//   1 - replace Qualities with OQ contents
-//   2 - clear IsDuplicate flag
-// can override default behavior using command line options
-void RevertTool::RevertToolPrivate::RevertAlignment(BamAlignment& al) {
-
-    // replace Qualities with OQ contents, if requested
-    if ( !m_settings->IsKeepQualities ) {
-        string originalQualities;
-        if ( al.GetTag(OQ_TAG, originalQualities) ) {
-            al.Qualities = originalQualities;
-            al.RemoveTag(OQ_TAG);
-        }
-    }
-
-    // clear duplicate flag, if requested
-    if ( !m_settings->IsKeepDuplicateFlag )
-        al.SetIsDuplicate(false);
-}
-
-bool RevertTool::RevertToolPrivate::Run(void) {
-  
-    // opens the BAM file without checking for indexes
-    BamReader reader;
-    if ( !reader.Open(m_settings->InputFilename) ) {
-        cerr << "bamtools revert ERROR: could not open " << m_settings->InputFilename
-             << " for reading... Aborting." << endl;
-        return false;
-    }
-
-    // get BAM file metadata
-    const string& headerText = reader.GetHeaderText();
-    const RefVector& references = reader.GetReferenceData();
-    
-    // determine compression mode for BamWriter
-    bool writeUncompressed = ( m_settings->OutputFilename == Options::StandardOut() &&
-                              !m_settings->IsForceCompression );
-    BamWriter::CompressionMode compressionMode = BamWriter::Compressed;
-    if ( writeUncompressed ) compressionMode = BamWriter::Uncompressed;
-
-    // open BamWriter
-    BamWriter writer;
-    writer.SetCompressionMode(compressionMode);
-    if ( !writer.Open(m_settings->OutputFilename, headerText, references) ) {
-        cerr << "bamtools revert ERROR: could not open " << m_settings->OutputFilename
-             << " for writing... Aborting." << endl;
-        reader.Close();
-        return false;
-    }
-
-    // plow through file, reverting alignments
-    BamAlignment al;
-    while ( reader.GetNextAlignment(al) ) {
-        RevertAlignment(al);
-        writer.SaveAlignment(al);
-    }
-    
-    // clean and exit
-    reader.Close();
-    writer.Close();
-    return true; 
-}
-
-// ---------------------------------------------
-// RevertTool implementation
-
-RevertTool::RevertTool(void)
-    : AbstractTool()
-    , m_settings(new RevertSettings)
-    , m_impl(0)
-{
-    // set program details
-    Options::SetProgramInfo("bamtools revert", "removes duplicate marks and restores original (non-recalibrated) base qualities", "[-in <filename> -in <filename> ...] [-out <filename> | [-forceCompression]] [revertOptions]");
-    
-    // set up options 
-    OptionGroup* IO_Opts = Options::CreateOptionGroup("Input & Output");
-    Options::AddValueOption("-in",  "BAM filename", "the input BAM file",  "", m_settings->HasInput,  m_settings->InputFilename,  IO_Opts, Options::StandardIn());
-    Options::AddValueOption("-out", "BAM filename", "the output BAM file", "", m_settings->HasOutput, m_settings->OutputFilename, IO_Opts, Options::StandardOut());
-    Options::AddOption("-forceCompression", "if results are sent to stdout (like when piping to another tool), default behavior is to leave output uncompressed. Use this flag to override and force compression", m_settings->IsForceCompression, IO_Opts);
-
-    OptionGroup* RevertOpts = Options::CreateOptionGroup("Revert Options");
-    Options::AddOption("-keepDuplicate", "keep duplicates marked", m_settings->IsKeepDuplicateFlag, RevertOpts);
-    Options::AddOption("-keepQualities", "keep base qualities (do not replace with OQ contents)", m_settings->IsKeepQualities, RevertOpts);
-}
-
-RevertTool::~RevertTool(void) {
-
-    delete m_settings;
-    m_settings = 0;
-    
-    delete m_impl;
-    m_impl = 0;
-}
-
-int RevertTool::Help(void) {
-    Options::DisplayHelp();
-    return 0;
-}
-
-int RevertTool::Run(int argc, char* argv[]) {
-  
-    // parse command line arguments
-    Options::Parse(argc, argv, 1);
-
-    // intialize RevertTool with settings
-    m_impl = new RevertToolPrivate(m_settings);
-    
-    // run RevertTool, return success/fail
-    if ( m_impl->Run() )
-        return 0;
-    else
-        return 1;
-}
diff --git a/bamtools/src/toolkit/bamtools_revert.h b/bamtools/src/toolkit/bamtools_revert.h
deleted file mode 100644
index 7aa270d..0000000
--- a/bamtools/src/toolkit/bamtools_revert.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// ***************************************************************************
-// bamtools_revert.h (c) 2010 Derek Barnett, Alistair Ward
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 7 April 2011
-// ---------------------------------------------------------------------------
-// Removes duplicate marks and restores original base qualities
-// ***************************************************************************
-
-#ifndef BAMTOOLS_REVERT_H
-#define BAMTOOLS_REVERT_H
-
-#include "bamtools_tool.h"
-
-namespace BamTools {
-  
-class RevertTool : public AbstractTool {
-  
-    public:
-        RevertTool(void);
-        ~RevertTool(void);
-  
-    public:
-        int Help(void);
-        int Run(int argc, char* argv[]); 
-        
-    private:
-        struct RevertSettings;
-        RevertSettings* m_settings;
-        
-        struct RevertToolPrivate;
-        RevertToolPrivate* m_impl;
-};
-  
-} // namespace BamTools
-
-#endif // BAMTOOLS_REVERT_H
diff --git a/bamtools/src/toolkit/bamtools_sort.cpp b/bamtools/src/toolkit/bamtools_sort.cpp
deleted file mode 100644
index e268bee..0000000
--- a/bamtools/src/toolkit/bamtools_sort.cpp
+++ /dev/null
@@ -1,375 +0,0 @@
-// ***************************************************************************
-// bamtools_sort.cpp (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 27 March 2012 (DB)
-// ---------------------------------------------------------------------------
-// Sorts an input BAM file
-// ***************************************************************************
-
-#include "bamtools_sort.h"
-
-#include <api/SamConstants.h>
-#include <api/BamMultiReader.h>
-#include <api/BamWriter.h>
-#include <api/algorithms/Sort.h>
-#include <utils/bamtools_options.h>
-using namespace BamTools;
-using namespace BamTools::Algorithms;
-
-#include <cstdio>
-#include <algorithm>
-#include <iostream>
-#include <sstream>
-#include <string>
-#include <vector>
-using namespace std;
-
-namespace BamTools {
-  
-// defaults
-//
-// ** These defaults should be tweaked & 'optimized' per testing ** //
-//
-//    I say 'optimized' because each system will naturally perform
-//    differently.  We will attempt to determine a sensible
-//    compromise that should perform well on average.
-const unsigned int SORT_DEFAULT_MAX_BUFFER_COUNT  = 500000;  // max numberOfAlignments for buffer
-const unsigned int SORT_DEFAULT_MAX_BUFFER_MEMORY = 1024;    // Mb
-    
-} // namespace BamTools
-
-// ---------------------------------------------
-// SortSettings implementation
-
-struct SortTool::SortSettings {
-
-    // flags
-    bool HasInputBamFilename;
-    bool HasMaxBufferCount;
-    bool HasMaxBufferMemory;
-    bool HasOutputBamFilename;
-    bool IsSortingByName;
-
-    // filenames
-    string InputBamFilename;
-    string OutputBamFilename;
-
-    // parameters
-    unsigned int MaxBufferCount;
-    unsigned int MaxBufferMemory;
-
-    // constructor
-    SortSettings(void)
-        : HasInputBamFilename(false)
-        , HasMaxBufferCount(false)
-        , HasMaxBufferMemory(false)
-        , HasOutputBamFilename(false)
-        , IsSortingByName(false)
-        , InputBamFilename(Options::StandardIn())
-        , OutputBamFilename(Options::StandardOut())
-        , MaxBufferCount(SORT_DEFAULT_MAX_BUFFER_COUNT)
-        , MaxBufferMemory(SORT_DEFAULT_MAX_BUFFER_MEMORY)
-    { }
-};
-
-// ---------------------------------------------
-// SortToolPrivate implementation
-
-class SortTool::SortToolPrivate {
-      
-    // ctor & dtor
-    public:
-        SortToolPrivate(SortTool::SortSettings* settings);
-        ~SortToolPrivate(void) { }
-        
-    // 'public' interface
-    public:
-        bool Run(void);
-        
-    // internal methods
-    private:
-        bool CreateSortedTempFile(vector<BamAlignment>& buffer);
-        bool GenerateSortedRuns(void);
-        bool MergeSortedRuns(void);
-        bool WriteTempFile(const vector<BamAlignment>& buffer, const string& tempFilename);
-        void SortBuffer(vector<BamAlignment>& buffer);
-        
-    // data members
-    private:
-        SortTool::SortSettings* m_settings;
-        string m_tempFilenameStub;
-        int m_numberOfRuns;
-        string m_headerText;
-        RefVector m_references;
-        vector<string> m_tempFilenames;
-};
-
-// constructor
-SortTool::SortToolPrivate::SortToolPrivate(SortTool::SortSettings* settings) 
-    : m_settings(settings)
-    , m_numberOfRuns(0) 
-{ 
-    // set filename stub depending on inputfile path
-    // that way multiple sort runs don't trip on each other's temp files
-    if ( m_settings) {
-        size_t extensionFound = m_settings->InputBamFilename.find(".bam");
-        if ( extensionFound != string::npos )
-            m_tempFilenameStub = m_settings->InputBamFilename.substr(0,extensionFound);
-        m_tempFilenameStub.append(".sort.temp.");
-    }
-}
-
-// generates mutiple sorted temp BAM files from single unsorted BAM file
-bool SortTool::SortToolPrivate::GenerateSortedRuns(void) {
-    
-    // open input BAM file
-    BamReader reader;
-    if ( !reader.Open(m_settings->InputBamFilename) ) {
-        cerr << "bamtools sort ERROR: could not open " << m_settings->InputBamFilename
-             << " for reading... Aborting." << endl;
-        return false;
-    }
-    
-    // get basic data that will be shared by all temp/output files 
-    SamHeader header = reader.GetHeader();
-    if ( !header.HasVersion() )
-        header.Version = Constants::SAM_CURRENT_VERSION;
-    header.SortOrder = ( m_settings->IsSortingByName
-                       ? Constants::SAM_HD_SORTORDER_QUERYNAME
-                       : Constants::SAM_HD_SORTORDER_COORDINATE );
-    m_headerText = header.ToString();
-    m_references = reader.GetReferenceData();
-    
-    // set up alignments buffer
-    BamAlignment al;
-    vector<BamAlignment> buffer;
-    buffer.reserve( (size_t)(m_settings->MaxBufferCount*1.1) );
-    bool bufferFull = false;
-
-    // if sorting by name, we need to generate full char data
-    // so can't use GetNextAlignmentCore()
-    if ( m_settings->IsSortingByName ) {
-
-        // iterate through file
-        while ( reader.GetNextAlignment(al)) {
-
-            // check buffer's usage
-            bufferFull = ( buffer.size() >= m_settings->MaxBufferCount );
-
-            // store alignments until buffer is "full"
-            if ( !bufferFull )
-                buffer.push_back(al);
-
-            // if buffer is "full"
-            else {
-                // so create a sorted temp file with current buffer contents
-                // then push "al" into fresh buffer
-                CreateSortedTempFile(buffer);
-                buffer.push_back(al);
-            }
-        }
-    }
-
-    // sorting by position, can take advantage of GNACore() speedup
-    else {
-
-        // iterate through file
-        while ( reader.GetNextAlignmentCore(al) ) {
-
-            // check buffer's usage
-            bufferFull = ( buffer.size() >= m_settings->MaxBufferCount );
-
-            // store alignments until buffer is "full"
-            if ( !bufferFull )
-                buffer.push_back(al);
-
-            // if buffer is "full"
-            else {
-                // create a sorted temp file with current buffer contents
-                // then push "al" into fresh buffer
-                CreateSortedTempFile(buffer);
-                buffer.push_back(al);
-            }
-        }
-    }
-
-    // handle any leftover buffer contents
-    if ( !buffer.empty() )
-        CreateSortedTempFile(buffer);
-    
-    // close reader & return success
-    reader.Close();
-    return true;
-}
-
-bool SortTool::SortToolPrivate::CreateSortedTempFile(vector<BamAlignment>& buffer) {
- 
-    // do sorting
-    SortBuffer(buffer);
-  
-    // write sorted contents to temp file, store success/fail
-    stringstream tempStr;
-    tempStr << m_tempFilenameStub << m_numberOfRuns;
-    bool success = WriteTempFile( buffer, tempStr.str() );
-    
-    // save temp filename for merging later
-    m_tempFilenames.push_back(tempStr.str());
-    
-    // clear buffer contents & update run counter
-    buffer.clear();
-    ++m_numberOfRuns;
-    
-    // return success/fail of writing to temp file
-    // TODO: a failure returned here is not actually caught and handled anywhere
-    return success;
-}
-
-// merges sorted temp BAM files into single sorted output BAM file
-bool SortTool::SortToolPrivate::MergeSortedRuns(void) {
-  
-    // open up multi reader for all of our temp files
-    // this might get broken up if we do a multi-pass system later ??
-    BamMultiReader multiReader;
-    if ( !multiReader.Open(m_tempFilenames) ) {
-        cerr << "bamtools sort ERROR: could not open BamMultiReader for merging temp files... Aborting."
-             << endl;
-        return false;
-    }
-
-    // open writer for our completely sorted output BAM file
-    BamWriter mergedWriter;
-    if ( !mergedWriter.Open(m_settings->OutputBamFilename, m_headerText, m_references) ) {
-        cerr << "bamtools sort ERROR: could not open " << m_settings->OutputBamFilename
-             << " for writing... Aborting." << endl;
-        multiReader.Close();
-        return false;
-    }
-    
-    // while data available in temp files
-    BamAlignment al;
-    while ( multiReader.GetNextAlignmentCore(al) )
-        mergedWriter.SaveAlignment(al);
-  
-    // close files
-    multiReader.Close();
-    mergedWriter.Close();
-    
-    // delete all temp files
-    vector<string>::const_iterator tempIter = m_tempFilenames.begin();
-    vector<string>::const_iterator tempEnd  = m_tempFilenames.end();
-    for ( ; tempIter != tempEnd; ++tempIter ) {
-        const string& tempFilename = (*tempIter);
-        remove(tempFilename.c_str());
-    }
-  
-    // return success
-    return true;
-}
-
-bool SortTool::SortToolPrivate::Run(void) {
- 
-    // this does a single pass, chunking up the input file into smaller sorted temp files, 
-    // then write out using BamMultiReader to handle merging
-    
-    if ( GenerateSortedRuns() )
-        return MergeSortedRuns();
-    else 
-        return false;
-} 
-    
-void SortTool::SortToolPrivate::SortBuffer(vector<BamAlignment>& buffer) {
- 
-    // ** add further custom sort options later ?? **
-    
-    // sort buffer by desired method
-    if ( m_settings->IsSortingByName )
-        std::stable_sort( buffer.begin(), buffer.end(), Sort::ByName() );
-    else
-        std::stable_sort( buffer.begin(), buffer.end(), Sort::ByPosition() );
-}
-    
-bool SortTool::SortToolPrivate::WriteTempFile(const vector<BamAlignment>& buffer,
-                                              const string& tempFilename)
-{
-    // open temp file for writing
-    BamWriter tempWriter;
-    if ( !tempWriter.Open(tempFilename, m_headerText, m_references) ) {
-        cerr << "bamtools sort ERROR: could not open " << tempFilename
-             << " for writing." << endl;
-        return false;
-    }
-  
-    // write data
-    vector<BamAlignment>::const_iterator buffIter = buffer.begin();
-    vector<BamAlignment>::const_iterator buffEnd  = buffer.end();
-    for ( ; buffIter != buffEnd; ++buffIter )  {
-        const BamAlignment& al = (*buffIter);
-        tempWriter.SaveAlignment(al);
-    }
-  
-    // close temp file & return success
-    tempWriter.Close();
-    return true;
-}
-
-// ---------------------------------------------
-// SortTool implementation
-
-SortTool::SortTool(void)
-    : AbstractTool()
-    , m_settings(new SortSettings)
-    , m_impl(0)
-{
-    // set program details
-    Options::SetProgramInfo("bamtools sort", "sorts a BAM file", "[-in <filename>] [-out <filename>] [sortOptions]");
-
-    // set up options
-    OptionGroup* IO_Opts = Options::CreateOptionGroup("Input & Output");
-    Options::AddValueOption("-in",  "BAM filename", "the input BAM file",  "",
-                            m_settings->HasInputBamFilename,  m_settings->InputBamFilename,
-                            IO_Opts, Options::StandardIn());
-    Options::AddValueOption("-out", "BAM filename", "the output BAM file", "",
-                            m_settings->HasOutputBamFilename, m_settings->OutputBamFilename,
-                            IO_Opts, Options::StandardOut());
-
-    OptionGroup* SortOpts = Options::CreateOptionGroup("Sorting Methods");
-    Options::AddOption("-byname", "sort by alignment name", m_settings->IsSortingByName, SortOpts);
-
-    OptionGroup* MemOpts = Options::CreateOptionGroup("Memory Settings");
-    Options::AddValueOption("-n",   "count", "max number of alignments per tempfile", "",
-                            m_settings->HasMaxBufferCount,  m_settings->MaxBufferCount,
-                            MemOpts, SORT_DEFAULT_MAX_BUFFER_COUNT);
-    Options::AddValueOption("-mem", "Mb", "max memory to use", "",
-                            m_settings->HasMaxBufferMemory, m_settings->MaxBufferMemory,
-                            MemOpts, SORT_DEFAULT_MAX_BUFFER_MEMORY);
-}
-
-SortTool::~SortTool(void) {
-
-    delete m_settings;
-    m_settings = 0;
-
-    delete m_impl;
-    m_impl = 0;
-}
-
-int SortTool::Help(void) {
-    Options::DisplayHelp();
-    return 0;
-}
-
-int SortTool::Run(int argc, char* argv[]) {
-
-    // parse command line arguments
-    Options::Parse(argc, argv, 1);
-
-    // initialize SortTool with settings
-    m_impl = new SortToolPrivate(m_settings);
-
-    // run SortTool, return success/fail
-    if ( m_impl->Run() )
-        return 0;
-    else
-        return 1;
-}
diff --git a/bamtools/src/toolkit/bamtools_sort.h b/bamtools/src/toolkit/bamtools_sort.h
deleted file mode 100644
index d746f5e..0000000
--- a/bamtools/src/toolkit/bamtools_sort.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// ***************************************************************************
-// bamtools_sort.h (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 7 April 2011 (DB)
-// ---------------------------------------------------------------------------
-// Sorts a BAM file
-// ***************************************************************************
-
-#ifndef BAMTOOLS_SORT_H
-#define BAMTOOLS_SORT_H
-
-#include "bamtools_tool.h"
-
-namespace BamTools {
-  
-class SortTool : public AbstractTool {
-  
-    public:
-        SortTool(void);
-        ~SortTool(void);
-  
-    public:
-        int Help(void);
-        int Run(int argc, char* argv[]); 
-        
-    private:
-        struct SortSettings;
-        SortSettings* m_settings;
-        
-        struct SortToolPrivate;
-        SortToolPrivate* m_impl;
-};
-  
-} // namespace BamTools
-
-#endif // BAMTOOLS_SORT_H
diff --git a/bamtools/src/toolkit/bamtools_split.cpp b/bamtools/src/toolkit/bamtools_split.cpp
deleted file mode 100644
index 6425e95..0000000
--- a/bamtools/src/toolkit/bamtools_split.cpp
+++ /dev/null
@@ -1,600 +0,0 @@
-// ***************************************************************************
-// bamtools_split.cpp (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 24 July 2013 (DB)
-// ---------------------------------------------------------------------------
-// Splits a BAM file on user-specified property, creating a new BAM output
-// file for each value found
-// ***************************************************************************
-
-#include "bamtools_split.h"
-
-#include <api/BamConstants.h>
-#include <api/BamReader.h>
-#include <api/BamWriter.h>
-#include <utils/bamtools_options.h>
-#include <utils/bamtools_variant.h>
-using namespace BamTools;
-
-#include <ctime>
-#include <iostream>
-#include <map>
-#include <sstream>
-#include <string>
-#include <vector>
-using namespace std;
-
-namespace BamTools {
-  
-// string constants
-static const string SPLIT_MAPPED_TOKEN    = ".MAPPED";
-static const string SPLIT_UNMAPPED_TOKEN  = ".UNMAPPED";
-static const string SPLIT_PAIRED_TOKEN    = ".PAIRED_END";
-static const string SPLIT_SINGLE_TOKEN    = ".SINGLE_END";
-static const string SPLIT_REFERENCE_TOKEN = ".REF_";
-static const string SPLIT_TAG_TOKEN       = ".TAG_";
-
-string GetTimestampString(void) {
-
-    // get human readable timestamp
-    time_t currentTime;
-    time(&currentTime);
-    stringstream timeStream("");
-    timeStream << ctime(&currentTime);
-
-    // convert whitespace to '_'
-    string timeString = timeStream.str();
-    size_t found = timeString.find(" ");
-    while (found != string::npos) {
-        timeString.replace(found, 1, "_");
-        found = timeString.find(" ", found+1);
-    }
-    return timeString;
-}
-
-// remove copy of filename without extension
-// (so /path/to/file.txt becomes /path/to/file )
-string RemoveFilenameExtension(const string& filename) {
-    size_t found = filename.rfind(".");
-    return filename.substr(0, found);
-}
-    
-} // namespace BamTools
-
-// ---------------------------------------------
-// SplitSettings implementation
-
-struct SplitTool::SplitSettings {
-
-    // flags
-    bool HasInputFilename;
-    bool HasCustomOutputStub;
-    bool HasCustomRefPrefix;
-    bool HasCustomTagPrefix;
-    bool IsSplittingMapped;
-    bool IsSplittingPaired;
-    bool IsSplittingReference;
-    bool IsSplittingTag;
-    
-    // string args
-    string CustomOutputStub;
-    string CustomRefPrefix;
-    string CustomTagPrefix;
-    string InputFilename;
-    string TagToSplit;
-    
-    // constructor
-    SplitSettings(void)
-        : HasInputFilename(false)
-        , HasCustomOutputStub(false)
-        , HasCustomRefPrefix(false)
-        , HasCustomTagPrefix(false)
-        , IsSplittingMapped(false)
-        , IsSplittingPaired(false)
-        , IsSplittingReference(false)
-        , IsSplittingTag(false)
-        , CustomOutputStub("")
-        , CustomRefPrefix("")
-        , CustomTagPrefix("")
-        , InputFilename(Options::StandardIn())
-        , TagToSplit("")
-    { } 
-};  
-
-// ---------------------------------------------
-// SplitToolPrivate declaration
-
-class SplitTool::SplitToolPrivate {
-      
-    // ctor & dtor
-    public:
-        SplitToolPrivate(SplitTool::SplitSettings* settings)
-            : m_settings(settings)
-        { }
-
-        ~SplitToolPrivate(void) {
-            m_reader.Close();
-        }
-        
-    // 'public' interface
-    public:
-        bool Run(void);
-        
-    // internal methods
-    private:
-        // close & delete BamWriters in map
-        template<typename T>
-        void CloseWriters(map<T, BamWriter*>& writers);
-        // calculate output stub based on IO args given
-        void DetermineOutputFilenameStub(void);
-        // open our BamReader
-        bool OpenReader(void);
-        // split alignments in BAM file based on isMapped property
-        bool SplitMapped(void);
-        // split alignments in BAM file based on isPaired property
-        bool SplitPaired(void);
-        // split alignments in BAM file based on refID property
-        bool SplitReference(void);
-        // finds first alignment and calls corresponding SplitTagImpl<> 
-        // depending on tag type
-        bool SplitTag(void);
-        // templated split tag implementation 
-        // handle the various types that are possible for tags
-        template<typename T>
-        bool SplitTagImpl(BamAlignment& al);    
-        
-    // data members
-    private:
-        SplitTool::SplitSettings* m_settings;
-        string m_outputFilenameStub;
-        BamReader m_reader;
-        string m_header;
-        RefVector m_references;
-};
-
-void SplitTool::SplitToolPrivate::DetermineOutputFilenameStub(void) {
-  
-    // if user supplied output filename stub, use that
-    if ( m_settings->HasCustomOutputStub ) 
-        m_outputFilenameStub = m_settings->CustomOutputStub;
-    
-    // else if user supplied input BAM filename, use that (minus ".bam" extension) as stub
-    else if ( m_settings->HasInputFilename )
-        m_outputFilenameStub = RemoveFilenameExtension(m_settings->InputFilename);
-        
-    // otherwise, user did not specify -stub, and input is coming from STDIN
-    // generate stub from timestamp
-    else m_outputFilenameStub = GetTimestampString();      
-}
-
-bool SplitTool::SplitToolPrivate::OpenReader(void) {
-
-    // attempt to open BAM file
-    if ( !m_reader.Open(m_settings->InputFilename) ) {
-        cerr << "bamtools split ERROR: could not open BAM file: " << m_settings->InputFilename << endl;
-        return false;
-    }
-
-    // save file 'metadata' & return success
-    m_header     = m_reader.GetHeaderText();
-    m_references = m_reader.GetReferenceData();
-    return true;
-}
-
-bool SplitTool::SplitToolPrivate::Run(void) {
-  
-    // determine output stub
-    DetermineOutputFilenameStub();
-
-    // open up BamReader
-    if ( !OpenReader() )
-        return false;
-    
-    // determine split type from settings
-    if ( m_settings->IsSplittingMapped )    return SplitMapped();
-    if ( m_settings->IsSplittingPaired )    return SplitPaired();
-    if ( m_settings->IsSplittingReference ) return SplitReference();
-    if ( m_settings->IsSplittingTag )       return SplitTag();
-
-    // if we get here, no property was specified 
-    cerr << "bamtools split ERROR: no property given to split on... " << endl
-         << "Please use -mapped, -paired, -reference, or -tag TAG to specifiy desired split behavior." << endl;
-    return false;
-}    
-
-bool SplitTool::SplitToolPrivate::SplitMapped(void) {
-    
-    // set up splitting data structure
-    map<bool, BamWriter*> outputFiles;
-    map<bool, BamWriter*>::iterator writerIter;
-    
-    // iterate through alignments
-    BamAlignment al;
-    BamWriter* writer;
-    bool isCurrentAlignmentMapped;
-    while ( m_reader.GetNextAlignment(al) ) {
-      
-        // see if bool value exists
-        isCurrentAlignmentMapped = al.IsMapped();
-        writerIter = outputFiles.find(isCurrentAlignmentMapped);
-          
-        // if no writer associated with this value
-        if ( writerIter == outputFiles.end() ) {
-        
-            // open new BamWriter
-            const string outputFilename = m_outputFilenameStub + ( isCurrentAlignmentMapped
-                                                                  ? SPLIT_MAPPED_TOKEN
-                                                                  : SPLIT_UNMAPPED_TOKEN ) + ".bam";
-            writer = new BamWriter;
-            if ( !writer->Open(outputFilename, m_header, m_references) ) {
-                cerr << "bamtools split ERROR: could not open " << outputFilename
-                     << " for writing." << endl;
-                return false;
-            }
-          
-            // store in map
-            outputFiles.insert( make_pair(isCurrentAlignmentMapped, writer) );
-        } 
-        
-        // else grab corresponding writer
-        else writer = (*writerIter).second;
-        
-        // store alignment in proper BAM output file 
-        if ( writer )
-            writer->SaveAlignment(al);
-    }
-    
-    // clean up BamWriters 
-    CloseWriters(outputFiles);
-    
-    // return success
-    return true;
-}
-
-bool SplitTool::SplitToolPrivate::SplitPaired(void) {
-  
-    // set up splitting data structure
-    map<bool, BamWriter*> outputFiles;
-    map<bool, BamWriter*>::iterator writerIter;
-    
-    // iterate through alignments
-    BamAlignment al;
-    BamWriter* writer;
-    bool isCurrentAlignmentPaired;
-    while ( m_reader.GetNextAlignment(al) ) {
-      
-        // see if bool value exists
-        isCurrentAlignmentPaired = al.IsPaired();
-        writerIter = outputFiles.find(isCurrentAlignmentPaired);
-          
-        // if no writer associated with this value
-        if ( writerIter == outputFiles.end() ) {
-        
-            // open new BamWriter
-            const string outputFilename = m_outputFilenameStub + ( isCurrentAlignmentPaired
-                                                                  ? SPLIT_PAIRED_TOKEN
-                                                                  : SPLIT_SINGLE_TOKEN ) + ".bam";
-            writer = new BamWriter;
-            if ( !writer->Open(outputFilename, m_header, m_references) ) {
-                cerr << "bamtool split ERROR: could not open " << outputFilename
-                     << " for writing." << endl;
-                return false;
-            }
-          
-            // store in map
-            outputFiles.insert( make_pair(isCurrentAlignmentPaired, writer) );
-        } 
-        
-        // else grab corresponding writer
-        else writer = (*writerIter).second;
-        
-        // store alignment in proper BAM output file 
-        if ( writer ) 
-            writer->SaveAlignment(al);
-    }
-    
-    // clean up BamWriters 
-    CloseWriters(outputFiles);
-    
-    // return success
-    return true;  
-}
-
-bool SplitTool::SplitToolPrivate::SplitReference(void) {
-  
-    // set up splitting data structure
-    map<int32_t, BamWriter*> outputFiles;
-    map<int32_t, BamWriter*>::iterator writerIter;
-    
-    // determine reference prefix
-    string refPrefix = SPLIT_REFERENCE_TOKEN;
-    if ( m_settings->HasCustomRefPrefix )
-        refPrefix = m_settings->CustomRefPrefix;
-
-    // make sure prefix starts with '.'
-    const size_t dotFound = refPrefix.find('.');
-    if ( dotFound != 0 )
-        refPrefix = string(".") + refPrefix;
-
-    // iterate through alignments
-    BamAlignment al;
-    BamWriter* writer;
-    int32_t currentRefId;
-    while ( m_reader.GetNextAlignment(al) ) {
-      
-        // see if bool value exists
-        currentRefId = al.RefID;
-        writerIter = outputFiles.find(currentRefId);
-          
-        // if no writer associated with this value
-        if ( writerIter == outputFiles.end() ) {
-        
-            // fetch reference name for ID
-            string refName;
-            if ( currentRefId == -1 )
-                refName = "unmapped";
-            else
-                refName = m_references.at(currentRefId).RefName;
-
-            // construct new output filename
-            const string outputFilename = m_outputFilenameStub + refPrefix + refName + ".bam";
-
-            // open new BamWriter
-            writer = new BamWriter;
-            if ( !writer->Open(outputFilename, m_header, m_references) ) {
-                cerr << "bamtools split ERROR: could not open " << outputFilename
-                     << " for writing." << endl;
-                return false;
-            }
-
-            // store in map
-            outputFiles.insert( make_pair(currentRefId, writer) );
-        } 
-        
-        // else grab corresponding writer
-        else writer = (*writerIter).second;
-        
-        // store alignment in proper BAM output file 
-        if ( writer ) 
-            writer->SaveAlignment(al);
-    }
-    
-    // clean up BamWriters 
-    CloseWriters(outputFiles);
-    
-    // return success
-    return true;
-}
-
-// finds first alignment and calls corresponding SplitTagImpl<>() depending on tag type
-bool SplitTool::SplitToolPrivate::SplitTag(void) {  
-  
-    // iterate through alignments, until we hit TAG
-    BamAlignment al;
-    while ( m_reader.GetNextAlignment(al) ) {
-      
-        // look for tag in this alignment and get tag type
-        char tagType(0);
-        if ( !al.GetTagType(m_settings->TagToSplit, tagType) )
-            continue;
-        
-        // request split method based on tag type
-        // pass it the current alignment found
-        switch ( tagType ) {
-          
-            case (Constants::BAM_TAG_TYPE_INT8)  :
-            case (Constants::BAM_TAG_TYPE_INT16) :
-            case (Constants::BAM_TAG_TYPE_INT32) :
-                return SplitTagImpl<int32_t>(al);
-                
-            case (Constants::BAM_TAG_TYPE_UINT8)  :
-            case (Constants::BAM_TAG_TYPE_UINT16) :
-            case (Constants::BAM_TAG_TYPE_UINT32) :
-                return SplitTagImpl<uint32_t>(al);
-              
-            case (Constants::BAM_TAG_TYPE_FLOAT)  :
-                return SplitTagImpl<float>(al);
-            
-            case (Constants::BAM_TAG_TYPE_ASCII)  :
-            case (Constants::BAM_TAG_TYPE_STRING) :
-            case (Constants::BAM_TAG_TYPE_HEX)    :
-                return SplitTagImpl<string>(al);
-
-            case (Constants::BAM_TAG_TYPE_ARRAY) :
-                cerr << "bamtools split ERROR: array tag types are not supported" << endl;
-                return false;
-          
-            default:
-                cerr << "bamtools split ERROR: unknown tag type encountered: " << tagType << endl;
-                return false;
-        }
-    }
-    
-    // tag not found, but that's not an error - return success
-    return true;
-}
-
-// --------------------------------------------------------------------------------
-// template method implementation
-// *Technical Note* - use of template methods declared & defined in ".cpp" file
-//                    goes against normal practices, but works here because these
-//                    are purely internal (no one can call from outside this file)
-
-// close BamWriters & delete pointers
-template<typename T>
-void SplitTool::SplitToolPrivate::CloseWriters(map<T, BamWriter*>& writers) {
-  
-    typedef map<T, BamWriter*> WriterMap;
-    typedef typename WriterMap::iterator WriterMapIterator;
-  
-    // iterate over writers
-    WriterMapIterator writerIter = writers.begin();
-    WriterMapIterator writerEnd  = writers.end();
-    for ( ; writerIter != writerEnd; ++writerIter ) {
-        BamWriter* writer = (*writerIter).second;
-        if ( writer == 0 ) continue;
-
-        // close BamWriter
-        writer->Close();
-
-        // destroy BamWriter
-        delete writer;
-        writer = 0;
-    }
-
-    // clear the container (destroying the items doesn't remove them)
-    writers.clear();
-}
-
-// handle the various types that are possible for tags
-template<typename T>
-bool SplitTool::SplitToolPrivate::SplitTagImpl(BamAlignment& al) {
-  
-    typedef T TagValueType;
-    typedef map<TagValueType, BamWriter*> WriterMap;
-    typedef typename WriterMap::iterator WriterMapIterator;
-  
-    // set up splitting data structure
-    WriterMap outputFiles;
-    WriterMapIterator writerIter;
-
-    // determine tag prefix
-    string tagPrefix = SPLIT_TAG_TOKEN;
-    if ( m_settings->HasCustomTagPrefix )
-        tagPrefix = m_settings->CustomTagPrefix;
-
-    // make sure prefix starts with '.'
-    const size_t dotFound = tagPrefix.find('.');
-    if ( dotFound != 0 )
-        tagPrefix = string(".") + tagPrefix;
-
-    // local variables
-    const string tag = m_settings->TagToSplit;
-    BamWriter* writer;
-    stringstream outputFilenameStream("");
-    TagValueType currentValue;
-    
-    // retrieve first alignment tag value
-    if ( al.GetTag(tag, currentValue) ) {
-      
-        // open new BamWriter, save first alignment
-        outputFilenameStream << m_outputFilenameStub << tagPrefix << tag << "_" << currentValue << ".bam";
-        writer = new BamWriter;
-        if ( !writer->Open(outputFilenameStream.str(), m_header, m_references) ) {
-            cerr << "bamtools split ERROR: could not open " << outputFilenameStream.str()
-                 << " for writing." << endl;
-            return false;
-        }
-        writer->SaveAlignment(al);
-        
-        // store in map
-        outputFiles.insert( make_pair(currentValue, writer) );
-        
-        // reset stream
-        outputFilenameStream.str("");
-    }
-    
-    // iterate through remaining alignments
-    while ( m_reader.GetNextAlignment(al) ) {
-      
-        // skip if this alignment doesn't have TAG 
-        if ( !al.GetTag(tag, currentValue) ) continue;
-        
-        // look up tag value in map
-        writerIter = outputFiles.find(currentValue);
-          
-        // if no writer associated with this value
-        if ( writerIter == outputFiles.end() ) {
-        
-            // open new BamWriter
-            outputFilenameStream << m_outputFilenameStub << tagPrefix << tag << "_" << currentValue << ".bam";
-            writer = new BamWriter;
-            if ( !writer->Open(outputFilenameStream.str(), m_header, m_references) ) {
-                cerr << "bamtool split ERROR: could not open " << outputFilenameStream.str()
-                     << " for writing." << endl;
-                return false;
-            }
-
-            // store in map
-            outputFiles.insert( make_pair(currentValue, writer) );
-            
-            // reset stream
-            outputFilenameStream.str("");
-        } 
-        
-        // else grab corresponding writer
-        else writer = (*writerIter).second;
-        
-        // store alignment in proper BAM output file 
-        if ( writer ) 
-            writer->SaveAlignment(al);
-    }
-    
-    // clean up BamWriters  
-    CloseWriters(outputFiles);
-    
-    // return success
-    return true;  
-}
-
-// ---------------------------------------------
-// SplitTool implementation
-
-SplitTool::SplitTool(void)
-    : AbstractTool()
-    , m_settings(new SplitSettings)
-    , m_impl(0)
-{
-    // set program details
-    const string name = "bamtools split";
-    const string description = "splits a BAM file on user-specified property, creating a new BAM output file for each value found";
-    const string args = "[-in <filename>] [-stub <filename stub>] < -mapped | -paired | -reference [-refPrefix <prefix>] | -tag <TAG> > ";
-    Options::SetProgramInfo(name, description, args);
-    
-    // set up options 
-    OptionGroup* IO_Opts = Options::CreateOptionGroup("Input & Output");
-    Options::AddValueOption("-in",   "BAM filename",  "the input BAM file",  "", m_settings->HasInputFilename,  m_settings->InputFilename,  IO_Opts, Options::StandardIn());
-    Options::AddValueOption("-refPrefix", "string", "custom prefix for splitting by references. Currently files end with REF_<refName>.bam. This option allows you to replace \"REF_\" with a prefix of your choosing.", "",
-                            m_settings->HasCustomRefPrefix, m_settings->CustomRefPrefix, IO_Opts);
-    Options::AddValueOption("-tagPrefix", "string", "custom prefix for splitting by tags. Current files end with TAG_<tagname>_<tagvalue>.bam. This option allows you to replace \"TAG_\" with a prefix of your choosing.", "",
-                            m_settings->HasCustomTagPrefix, m_settings->CustomTagPrefix, IO_Opts);
-    Options::AddValueOption("-stub", "filename stub", "prefix stub for output BAM files (default behavior is to use input filename, without .bam extension, as stub). If input is stdin and no stub provided, a timestamp is generated as the stub.", "",
-                            m_settings->HasCustomOutputStub, m_settings->CustomOutputStub, IO_Opts);
-    
-    OptionGroup* SplitOpts = Options::CreateOptionGroup("Split Options");
-    Options::AddOption("-mapped",    "split mapped/unmapped alignments",       m_settings->IsSplittingMapped,    SplitOpts);
-    Options::AddOption("-paired",    "split single-end/paired-end alignments", m_settings->IsSplittingPaired,    SplitOpts);
-    Options::AddOption("-reference", "split alignments by reference",          m_settings->IsSplittingReference, SplitOpts);
-    Options::AddValueOption("-tag", "tag name", "splits alignments based on all values of TAG encountered (i.e. -tag RG creates a BAM file for each read group in original BAM file)", "", 
-                            m_settings->IsSplittingTag, m_settings->TagToSplit, SplitOpts);
-}
-
-SplitTool::~SplitTool(void) {
-    
-    delete m_settings;
-    m_settings = 0;
-    
-    delete m_impl;
-    m_impl = 0;
-}
-
-int SplitTool::Help(void) {
-    Options::DisplayHelp();
-    return 0;
-}
-
-int SplitTool::Run(int argc, char* argv[]) {
-  
-    // parse command line arguments
-    Options::Parse(argc, argv, 1);
-    
-    // initialize SplitTool with settings
-    m_impl = new SplitToolPrivate(m_settings);
-    
-    // run SplitTool, return success/fail
-    if ( m_impl->Run() ) 
-        return 0;
-    else 
-        return 1;
-}
diff --git a/bamtools/src/toolkit/bamtools_split.h b/bamtools/src/toolkit/bamtools_split.h
deleted file mode 100644
index a294f4f..0000000
--- a/bamtools/src/toolkit/bamtools_split.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// ***************************************************************************
-// bamtools_split.h (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 7 April 2011 (DB)
-// ---------------------------------------------------------------------------
-// Splits a BAM file on user-specified property, creating a new BAM output
-// file for each value found
-// ***************************************************************************
-
-#ifndef BAMTOOLS_SPLIT_H
-#define BAMTOOLS_SPLIT_H
-
-#include "bamtools_tool.h"
-
-namespace BamTools {
-  
-class SplitTool : public AbstractTool {
-  
-    public:
-        SplitTool(void);
-        ~SplitTool(void);
-  
-    public:
-        int Help(void);
-        int Run(int argc, char* argv[]); 
-        
-    private:
-        struct SplitSettings;
-        SplitSettings* m_settings;
-        
-        struct SplitToolPrivate;
-        SplitToolPrivate* m_impl;
-};
-  
-} // namespace BamTools
-
-#endif // BAMTOOLS_SPLIT_H
diff --git a/bamtools/src/toolkit/bamtools_stats.cpp b/bamtools/src/toolkit/bamtools_stats.cpp
deleted file mode 100644
index 0035913..0000000
--- a/bamtools/src/toolkit/bamtools_stats.cpp
+++ /dev/null
@@ -1,307 +0,0 @@
-// ***************************************************************************
-// bamtools_cpp (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 December 2012
-// ---------------------------------------------------------------------------
-// Prints general alignment statistics for BAM file(s).
-// ***************************************************************************
-
-#include "bamtools_stats.h"
-
-#include <api/BamMultiReader.h>
-#include <utils/bamtools_options.h>
-using namespace BamTools;
-
-#include <cmath>
-#include <algorithm>
-#include <fstream>
-#include <functional>
-#include <iostream>
-#include <numeric>
-#include <string>
-#include <vector>
-using namespace std;
-
-// ---------------------------------------------
-// StatsSettings implementation
-
-struct StatsTool::StatsSettings {
-
-    // flags
-    bool HasInput;
-    bool HasInputFilelist;
-    bool IsShowingInsertSizeSummary;
-
-    // filenames
-    vector<string> InputFiles;
-    string InputFilelist;
-    
-    // constructor
-    StatsSettings(void)
-        : HasInput(false)
-        , HasInputFilelist(false)
-        , IsShowingInsertSizeSummary(false)
-    { }
-};  
-
-// ---------------------------------------------
-// StatsToolPrivate implementation
-
-struct StatsTool::StatsToolPrivate {
-  
-    // ctor & dtor
-    public:
-        StatsToolPrivate(StatsTool::StatsSettings* _settings);
-        ~StatsToolPrivate(void) { }
-  
-    // 'public' interface
-    public:
-        bool Run(void);
-        
-    // internal methods
-    private:
-        bool CalculateMedian(vector<int>& data, double& median); 
-        void PrintStats(void);
-        void ProcessAlignment(const BamAlignment& al);
-        
-    // data members
-    private:
-        StatsTool::StatsSettings* m_settings;
-        unsigned int m_numReads;
-        unsigned int m_numPaired;
-        unsigned int m_numProperPair;
-        unsigned int m_numMapped;
-        unsigned int m_numBothMatesMapped;
-        unsigned int m_numForwardStrand;
-        unsigned int m_numReverseStrand;
-        unsigned int m_numFirstMate;
-        unsigned int m_numSecondMate;
-        unsigned int m_numSingletons;
-        unsigned int m_numFailedQC;
-        unsigned int m_numDuplicates;
-        vector<int> m_insertSizes;
-};
-
-StatsTool::StatsToolPrivate::StatsToolPrivate(StatsTool::StatsSettings* settings)
-    : m_settings(settings)
-    , m_numReads(0)
-    , m_numPaired(0)
-    , m_numProperPair(0)
-    , m_numMapped(0)
-    , m_numBothMatesMapped(0)
-    , m_numForwardStrand(0)
-    , m_numReverseStrand(0)
-    , m_numFirstMate(0)
-    , m_numSecondMate(0)
-    , m_numSingletons(0)
-    , m_numFailedQC(0)
-    , m_numDuplicates(0)
-{ 
-    m_insertSizes.reserve(100000);
-}
-
-// median is of type double because in the case of even number of data elements,
-// we need to return the average of middle 2 elements
-bool StatsTool::StatsToolPrivate::CalculateMedian(vector<int>& data, double& median) { 
-  
-    // skip if data empty
-    if ( data.empty() )
-        return false;
-
-    // find middle element
-    size_t middleIndex = data.size() / 2;
-    vector<int>::iterator target = data.begin() + middleIndex;
-    nth_element(data.begin(), target, data.end());
-    
-    // odd number of elements
-    if ( (data.size() % 2) != 0) {
-        median = (double)(*target);
-        return true;
-    }
-    
-    // even number of elements
-    else {
-        double rightTarget = (double)(*target);
-        vector<int>::iterator leftTarget = target - 1;
-        nth_element(data.begin(), leftTarget, data.end());
-        median = (double)((rightTarget+*leftTarget)/2.0);
-        return true;
-    }
-}
-
-// print BAM file alignment stats
-void StatsTool::StatsToolPrivate::PrintStats(void) {
-  
-    cout << endl;
-    cout << "**********************************************" << endl;
-    cout << "Stats for BAM file(s): " << endl;
-    cout << "**********************************************" << endl;
-    cout << endl;
-    cout << "Total reads:       " << m_numReads << endl;
-    cout << "Mapped reads:      " << m_numMapped << "\t(" << ((float)m_numMapped/m_numReads)*100 << "%)" << endl;
-    cout << "Forward strand:    " << m_numForwardStrand << "\t(" << ((float)m_numForwardStrand/m_numReads)*100 << "%)" << endl;
-    cout << "Reverse strand:    " << m_numReverseStrand << "\t(" << ((float)m_numReverseStrand/m_numReads)*100 << "%)" << endl;
-    cout << "Failed QC:         " << m_numFailedQC << "\t(" << ((float)m_numFailedQC/m_numReads)*100 << "%)" << endl;
-    cout << "Duplicates:        " << m_numDuplicates << "\t(" << ((float)m_numDuplicates/m_numReads)*100 << "%)" << endl;
-    cout << "Paired-end reads:  " << m_numPaired << "\t(" << ((float)m_numPaired/m_numReads)*100 << "%)" << endl;
-    
-    if ( m_numPaired != 0 ) {
-        cout << "'Proper-pairs':    " << m_numProperPair << "\t(" << ((float)m_numProperPair/m_numPaired)*100 << "%)" << endl;
-        cout << "Both pairs mapped: " << m_numBothMatesMapped << "\t(" << ((float)m_numBothMatesMapped/m_numPaired)*100 << "%)" << endl;
-        cout << "Read 1:            " << m_numFirstMate << endl;
-        cout << "Read 2:            " << m_numSecondMate << endl;
-        cout << "Singletons:        " << m_numSingletons << "\t(" << ((float)m_numSingletons/m_numPaired)*100 << "%)" << endl;
-    }
-    
-    if ( m_settings->IsShowingInsertSizeSummary ) {
-      
-        double avgInsertSize = 0.0;
-        if ( !m_insertSizes.empty() ) {
-            avgInsertSize = ( accumulate(m_insertSizes.begin(), m_insertSizes.end(), 0.0) / (double)m_insertSizes.size() );
-            cout << "Average insert size (absolute value): " << avgInsertSize << endl;
-        }
-        
-        double medianInsertSize = 0.0;
-        if ( CalculateMedian(m_insertSizes, medianInsertSize) )
-            cout << "Median insert size (absolute value): " << medianInsertSize << endl;
-    }
-    cout << endl;
-}
-
-// use current input alignment to update BAM file alignment stats
-void StatsTool::StatsToolPrivate::ProcessAlignment(const BamAlignment& al) {
-  
-    // increment total alignment counter
-    ++m_numReads;
-    
-    // incrememt counters for pairing-independent flags
-    if ( al.IsDuplicate() ) ++m_numDuplicates;
-    if ( al.IsFailedQC()  ) ++m_numFailedQC;
-    if ( al.IsMapped()    ) ++m_numMapped;
-    
-    // increment strand counters
-    if ( al.IsReverseStrand() ) 
-        ++m_numReverseStrand;
-    else 
-        ++m_numForwardStrand;
-    
-    // if alignment is paired-end
-    if ( al.IsPaired() ) {
-      
-        // increment PE counter
-        ++m_numPaired;
-      
-        // increment first mate/second mate counters
-        if ( al.IsFirstMate()  ) ++m_numFirstMate;
-        if ( al.IsSecondMate() ) ++m_numSecondMate;
-        
-        // if alignment is mapped, check mate status
-        if ( al.IsMapped() ) {
-            // if mate mapped
-            if ( al.IsMateMapped() ) 
-                ++m_numBothMatesMapped;
-            // else singleton
-            else 
-                ++m_numSingletons;
-        }
-        
-        // check for explicit proper pair flag
-        if ( al.IsProperPair() )
-            ++m_numProperPair;
-        
-        // store insert size for first mate 
-        if ( m_settings->IsShowingInsertSizeSummary && al.IsFirstMate() && (al.InsertSize != 0) ) {
-            int insertSize = abs(al.InsertSize);
-            m_insertSizes.push_back( insertSize );
-        }
-    }
-}
-
-bool StatsTool::StatsToolPrivate::Run() {
-  
-    // set to default input if none provided
-    if ( !m_settings->HasInput && !m_settings->HasInputFilelist )
-        m_settings->InputFiles.push_back(Options::StandardIn());
-
-    // add files in the filelist to the input file list
-    if ( m_settings->HasInputFilelist ) {
-
-        ifstream filelist(m_settings->InputFilelist.c_str(), ios::in);
-        if ( !filelist.is_open() ) {
-            cerr << "bamtools stats ERROR: could not open input BAM file list... Aborting." << endl;
-            return false;
-        }
-
-        string line;
-        while ( getline(filelist, line) )
-            m_settings->InputFiles.push_back(line);
-    }
-
-    // open the BAM files
-    BamMultiReader reader;
-    if ( !reader.Open(m_settings->InputFiles) ) {
-        cerr << "bamtools stats ERROR: could not open input BAM file(s)... Aborting." << endl;
-        reader.Close();
-        return false;
-    }
-    
-    // plow through alignments, keeping track of stats
-    BamAlignment al;
-    while ( reader.GetNextAlignmentCore(al) )
-        ProcessAlignment(al);
-    reader.Close();
-    
-    // print stats & exit
-    PrintStats();
-    return true; 
-}
-
-// ---------------------------------------------
-// StatsTool implementation
-
-StatsTool::StatsTool(void)
-    : AbstractTool()
-    , m_settings(new StatsSettings)
-    , m_impl(0)
-{
-    // set program details
-    Options::SetProgramInfo("bamtools stats", "prints general alignment statistics", "[-in <filename> -in <filename> ... | -list <filelist>] [statsOptions]");
-    
-    // set up options 
-    OptionGroup* IO_Opts = Options::CreateOptionGroup("Input & Output");
-    Options::AddValueOption("-in", "BAM filename", "the input BAM file", "", m_settings->HasInput,  m_settings->InputFiles,  IO_Opts, Options::StandardIn());
-    Options::AddValueOption("-list",  "filename", "the input BAM file list, one line per file", "", m_settings->HasInputFilelist,  m_settings->InputFilelist, IO_Opts);
-    
-    OptionGroup* AdditionalOpts = Options::CreateOptionGroup("Additional Stats");
-    Options::AddOption("-insert", "summarize insert size data", m_settings->IsShowingInsertSizeSummary, AdditionalOpts);
-}
-
-StatsTool::~StatsTool(void) {
-
-    delete m_settings;
-    m_settings = 0;
-    
-    delete m_impl;
-    m_impl = 0;
-}
-
-int StatsTool::Help(void) {
-    Options::DisplayHelp();
-    return 0;
-}
-
-int StatsTool::Run(int argc, char* argv[]) {
-  
-    // parse command line arguments
-    Options::Parse(argc, argv, 1);
-    
-    // initialize StatsTool with settings
-    m_impl = new StatsToolPrivate(m_settings);
-    
-    // run StatsTool, return success/fail
-    if ( m_impl->Run() )
-        return 0;
-    else
-        return 1;
-}
diff --git a/bamtools/src/toolkit/bamtools_stats.h b/bamtools/src/toolkit/bamtools_stats.h
deleted file mode 100644
index 29cc998..0000000
--- a/bamtools/src/toolkit/bamtools_stats.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// ***************************************************************************
-// bamtools_stats.h (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 7 April 2011
-// ---------------------------------------------------------------------------
-// Prints general statistics for a single BAM file
-// ***************************************************************************
-
-#ifndef BAMTOOLS_STATS_H
-#define BAMTOOLS_STATS_H
-
-#include "bamtools_tool.h"
-
-namespace BamTools {
-  
-class StatsTool : public AbstractTool {
-  
-    public:
-        StatsTool(void);
-        ~StatsTool(void);
-  
-    public:
-        int Help(void);
-        int Run(int argc, char* argv[]); 
-        
-    private:
-        struct StatsSettings;
-        StatsSettings* m_settings;
-        
-        struct StatsToolPrivate;
-        StatsToolPrivate* m_impl;
-};
-  
-} // namespace BamTools
-
-#endif // BAMTOOLS_STATS_H
diff --git a/bamtools/src/toolkit/bamtools_tool.h b/bamtools/src/toolkit/bamtools_tool.h
deleted file mode 100644
index f14d460..0000000
--- a/bamtools/src/toolkit/bamtools_tool.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// ***************************************************************************
-// bamtools_tool.h (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 2 June 2010
-// ---------------------------------------------------------------------------
-// Base class for all other BamTools sub-tools
-// All derived classes must provide Help() and Run() methods
-// ***************************************************************************
-
-#ifndef BAMTOOLS_ABSTRACTTOOL_H
-#define BAMTOOLS_ABSTRACTTOOL_H
-
-#include <string>
-
-namespace BamTools { 
-  
-class AbstractTool {
-  
-    public:
-        AbstractTool(void) { }
-        virtual ~AbstractTool(void) { }
-
-    public:
-        virtual int Help(void) =0;
-        virtual int Run(int argc, char* argv[]) =0; 
-
-    // derived classes should also provide:
-    // static std::string Description(void);
-    // static std::String Name(void);
-};
-  
-} // namespace BamTools
-
-#endif // BAMTOOLS_ABSTRACTTOOL_H
diff --git a/bamtools/src/toolkit/bamtools_version.h.in b/bamtools/src/toolkit/bamtools_version.h.in
deleted file mode 100644
index 325314c..0000000
--- a/bamtools/src/toolkit/bamtools_version.h.in
+++ /dev/null
@@ -1,20 +0,0 @@
-// ***************************************************************************
-// bamtools_version.h.in (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 19 November 2010 (DB)
-// ---------------------------------------------------------------------------
-// Provides version information for the BamTools toolkit.
-// ***************************************************************************
-
-#ifndef BAMTOOLS_VERSION_H
-#define BAMTOOLS_VERSION_H
-
-// CMake uses this file as a template to generate "bamtools_version.h".
-// These constants are defined to match the variables set in the build system. 
-#define BAMTOOLS_VERSION_MAJOR @BamTools_VERSION_MAJOR@
-#define BAMTOOLS_VERSION_MINOR @BamTools_VERSION_MINOR@
-#define BAMTOOLS_VERSION_BUILD @BamTools_VERSION_BUILD@
-
-#endif // BAMTOOLS_VERSION_H
-
diff --git a/bamtools/src/utils/CMakeLists.txt b/bamtools/src/utils/CMakeLists.txt
deleted file mode 100644
index 1c33f4b..0000000
--- a/bamtools/src/utils/CMakeLists.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-# ==========================
-# BamTools CMakeLists.txt
-# (c) 2010 Derek Barnett
-#
-# src/utils/
-# ==========================
-
-# list include paths
-include_directories( ${BamTools_SOURCE_DIR}/src/api )
-
-# add compiler definitions 
-add_definitions( -DBAMTOOLS_UTILS_LIBRARY ) # (for proper exporting of library symbols)
-add_definitions( -fPIC ) # (attempt to force PIC compiling on CentOS, not being set on shared libs by CMake)
-
-# create BamTools utils library
-add_library( BamTools-utils STATIC
-             bamtools_fasta.cpp
-             bamtools_options.cpp
-             bamtools_pileup_engine.cpp
-             bamtools_utilities.cpp
-           )
-
-# link BamTools-utils library with BamTools automatically
-target_link_libraries( BamTools-utils BamTools )
-
-# set BamTools library properties
-set_target_properties( BamTools-utils PROPERTIES
-                       OUTPUT_NAME bamtools-utils
-                       PREFIX "lib"
-                     )
diff --git a/bamtools/src/utils/bamtools_fasta.cpp b/bamtools/src/utils/bamtools_fasta.cpp
deleted file mode 100644
index 680f62b..0000000
--- a/bamtools/src/utils/bamtools_fasta.cpp
+++ /dev/null
@@ -1,623 +0,0 @@
-// ***************************************************************************
-// bamtools_fasta.cpp (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 9 March 2012 (DB)
-// ---------------------------------------------------------------------------
-// Provides FASTA reading/indexing functionality.
-// ***************************************************************************
-
-#include "utils/bamtools_fasta.h"
-using namespace BamTools;
-
-#include <cstdio>
-#include <cstdlib>
-#include <cstring>
-#include <fstream>
-#include <iostream>
-#include <sstream>
-#include <vector>
-using namespace std;
-
-struct Fasta::FastaPrivate {
-  
-    struct FastaIndexData {
-        string  Name;
-        int32_t Length;
-        int64_t Offset;
-        int32_t LineLength;
-        int32_t ByteLength; // LineLength + newline character(s) - varies on OS where file was generated
-    };
-  
-    // data members
-    FILE* Stream;
-    bool IsOpen;
-    
-    FILE* IndexStream;
-    bool HasIndex;
-    bool IsIndexOpen;
-  
-    vector<FastaIndexData> Index;
-    
-    // ctor
-    FastaPrivate(void);
-    ~FastaPrivate(void);
-    
-    // 'public' API methods
-    bool Close(void);
-    bool CreateIndex(const string& indexFilename);
-    bool GetBase(const int& refId, const int& position, char& base);
-    bool GetSequence(const int& refId, const int& start, const int& stop, string& sequence);
-    bool Open(const string& filename, const string& indexFilename);
-    
-    // internal methods
-    private:
-        void Chomp(char* sequence);
-        bool GetNameFromHeader(const string& header, string& name);
-        bool GetNextHeader(string& header);
-        bool GetNextSequence(string& sequence);
-        bool LoadIndexData(void);
-        bool Rewind(void);
-        bool WriteIndexData(void);
-};
-
-Fasta::FastaPrivate::FastaPrivate(void) 
-    : IsOpen(false)
-    , HasIndex(false)
-    , IsIndexOpen(false)
-{ }
-
-Fasta::FastaPrivate::~FastaPrivate(void) {
-    Close();
-}
-
-// remove any trailing newlines
-void Fasta::FastaPrivate::Chomp(char* sequence) {
-  
-    static const int CHAR_LF = 10;
-    static const int CHAR_CR = 13;
-  
-    size_t seqLength = strlen(sequence);
-    if ( seqLength == 0 ) return;
-    --seqLength; // ignore null terminator
-  
-    while ( sequence[seqLength] == CHAR_LF || 
-            sequence[seqLength] == CHAR_CR 
-          ) 
-    {
-        sequence[seqLength] = 0;
-        --seqLength;
-        if (seqLength < 0) 
-            break;
-    }
-}
-
-bool Fasta::FastaPrivate::Close(void) {
- 
-    // close fasta file
-    if ( IsOpen ) {
-        fclose(Stream);
-        IsOpen = false;
-    }
-
-    // close index file
-    if ( HasIndex && IsIndexOpen ) {
-        fclose(IndexStream);
-        HasIndex = false;
-        IsIndexOpen = false;
-    }
-  
-    // return success
-    return true;
-}
-
-bool Fasta::FastaPrivate::CreateIndex(const string& indexFilename) {
-  
-    // check that file is open
-    if ( !IsOpen ) {
-        cerr << "FASTA error : cannot create index, FASTA file not open" << endl;
-        return false;
-    }
-  
-    // rewind FASTA file
-    if ( !Rewind() ) {
-        cerr << "FASTA error : could not rewind FASTA file" << endl;
-        return false;
-    }
-    
-    // clear out prior index data
-    Index.clear();
-    
-    // -------------------------------------------
-    // calculate lineLength & byteLength
-    
-    int lineLength = 0;
-    int byteLength = 0;
-    
-    // skip over header
-    char buffer[1024];
-    if ( fgets(buffer, 1024, Stream) == 0 ) {
-        cerr << "FASTA error : could not read from file" << endl;
-        return false;
-    }
-    if ( feof(Stream) ) return false;
-    if ( buffer[0] != '>' ) { 
-        cerr << "FASTA error : expected header ('>'), instead : " << buffer[0] << endl;
-        return false;
-    }
-  
-    // read in first line of sequence  
-    char c = fgetc(Stream);
-    while ( (c >= 0) && (c != '\n') ) {
-        ++byteLength;
-        if (isgraph(c)) ++lineLength;
-        c = fgetc(Stream);
-    }
-    ++byteLength; // store newline
-    
-    // rewind FASTA file
-    if ( !Rewind() ) {
-        cerr << "FASTA error : could not rewind FASTA file" << endl;
-        return false;
-    }
-    
-    // iterate through fasta entries
-    int currentId   = 0;
-    string header   = "";
-    string sequence = "";
-    while ( GetNextHeader(header) ) {
-        
-        // ---------------------------
-        // build index entry data
-        FastaIndexData data;
-        
-        // store file offset of beginning of DNA sequence (after header)
-        data.Offset = ftello(Stream);
-        
-        // parse header, store sequence name in data.Name
-        if ( !GetNameFromHeader(header, data.Name) ) {
-            cerr << "FASTA error : could not parse read name from FASTA header" << endl;
-            return false;
-        }
-        
-        // retrieve FASTA sequence
-        if ( !GetNextSequence(sequence) ) {
-            cerr << "FASTA error : could not read in next sequence from FASTA file" << endl;
-            return false;
-        }
-        
-        // store sequence length & line/byte lengths
-        data.Length = sequence.length();
-        data.LineLength = lineLength;
-        data.ByteLength = byteLength;
-        
-        // store index entry
-        Index.push_back(data);
-        
-        // update ref Id
-        ++currentId;
-    }
-    
-    // open index file
-    if ( !indexFilename.empty() ) {
-        IndexStream = fopen(indexFilename.c_str(), "wb");
-        if ( !IndexStream ) {
-            cerr << "FASTA error : Could not open " << indexFilename << " for writing." << endl;
-            return false;
-        }
-        IsIndexOpen = true;
-    }
-    
-    // write index data
-    if ( !WriteIndexData() ) return false;
-    HasIndex = true;
-    
-    // close index file
-    fclose(IndexStream);
-    IsIndexOpen = false;
-    
-    // return succes status
-    return true;
-}
-
-bool Fasta::FastaPrivate::GetBase(const int& refId, const int& position, char& base) {
-  
-    // make sure FASTA file is open
-    if ( !IsOpen ) {
-        cerr << "FASTA error : file not open for reading" << endl;
-        return false;
-    }
-  
-    // use index if available
-    if ( HasIndex && !Index.empty() ) {
-        
-        // validate reference id 
-        if ( (refId < 0) || (refId >= (int)Index.size()) ) {
-            cerr << "FASTA error: invalid refId specified: " << refId << endl;
-            return false;
-        }
-        
-        // retrieve reference index data
-        const FastaIndexData& referenceData = Index.at(refId);
-        
-        // validate position 
-        if ( (position < 0) || (position > referenceData.Length) ) {
-            cerr << "FASTA error: invalid position specified: " << position << endl;
-            return false;
-        }
-
-        // calculate seek position & attempt jump
-        const int64_t lines = position / referenceData.LineLength;
-        const int64_t lineOffset = position % referenceData.LineLength;
-        const int64_t seekTo = referenceData.Offset + (lines*referenceData.ByteLength) + lineOffset;
-        if ( fseek64(Stream, seekTo, SEEK_SET) != 0 ) {
-            cerr << "FASTA error : could not seek in file" << endl;
-            return false;
-        }
-        
-        // set base & return success
-        base = getc(Stream);
-        return true;
-    }
-    
-    // else plow through sequentially
-    else {
-      
-        // rewind FASTA file
-        if ( !Rewind() ) {
-            cerr << "FASTA error : could not rewind FASTA file" << endl;
-            return false;
-        }
-        
-        // iterate through fasta entries
-        int currentId = 0;
-        string header = "";
-        string sequence = "";
-        
-        // get first entry
-        GetNextHeader(header);
-        GetNextSequence(sequence);
-        
-        while ( currentId != refId ) {
-            GetNextHeader(header);
-            GetNextSequence(sequence);
-            ++currentId;
-        }
-        
-        // get desired base from sequence 
-        // TODO: error reporting on invalid position
-        if ( currentId == refId && (sequence.length() >= (size_t)position) ) {          
-            base = sequence.at(position);
-            return true;
-        }
-      
-        // could not get sequence
-        return false;
-    }
- 
-    // return success
-    return true;
-}
-
-bool Fasta::FastaPrivate::GetNameFromHeader(const string& header, string& name) {
-
-    // get rid of the leading greater than sign
-    string s = header.substr(1);
-
-    // extract the first non-whitespace segment
-    char* pName = (char*)s.data();
-    unsigned int nameLen = (unsigned int)s.size();
-
-    unsigned int start = 0;
-    while ( (pName[start] == 32) || (pName[start] == 9) || (pName[start] == 10) || (pName[start] == 13) ) {
-        start++;
-        if ( start == nameLen ) 
-            break;
-    }
-
-    unsigned int stop  = start;
-    if ( stop < nameLen ) {
-        while( (pName[stop] != 32) && (pName[stop] != 9) && (pName[stop] != 10) && (pName[stop] != 13) ) {
-            stop++;
-            if ( stop == nameLen ) 
-                break;
-        }
-    }
-
-    if ( start == stop ) {
-        cerr << "FASTA error : could not parse read name from FASTA header" << endl;
-        return false;
-    }
-
-    name = s.substr(start, stop - start).c_str();
-    return true;
-}
-
-bool Fasta::FastaPrivate::GetNextHeader(string& header) {
-  
-    // validate input stream
-    if ( !IsOpen || feof(Stream) ) 
-        return false;
-    
-    // read in header line
-    char buffer[1024];
-    if ( fgets(buffer, 1024, Stream) == 0 ) {
-        cerr << "FASTA error : could not read from file" << endl;
-        return false;
-    }
-    
-    // make sure it's a FASTA header
-    if ( buffer[0] != '>' ) { 
-        cerr << "FASTA error : expected header ('>'), instead : " << buffer[0] << endl;
-        return false;
-    }
-  
-    // import buffer contents to header string
-    stringstream headerBuffer("");
-    headerBuffer << buffer;
-    header = headerBuffer.str();
-  
-    // return success
-    return true;
-}
-
-bool Fasta::FastaPrivate::GetNextSequence(string& sequence) {
-  
-    // validate input stream
-    if ( !IsOpen || feof(Stream) ) 
-        return false;
-    
-    // read in sequence  
-    char buffer[1024];
-    ostringstream seqBuffer("");
-    while(true) {
-        
-        char ch = fgetc(Stream);
-        ungetc(ch, Stream);
-        if( (ch == '>') || feof(Stream) ) 
-              break;       
-        
-        if ( fgets(buffer, 1024, Stream) == 0 ) {
-            cerr << "FASTA error : could not read from file" << endl;
-            return false;
-        }
-        
-        Chomp(buffer);
-        seqBuffer << buffer;
-    }
-    
-    // import buffer contents to sequence string
-    sequence = seqBuffer.str();
-  
-    // return success
-    return true;
-}
-
-bool Fasta::FastaPrivate::GetSequence(const int& refId, const int& start, const int& stop, string& sequence) {
- 
-    // make sure FASTA file is open
-    if ( !IsOpen ) {
-        cerr << "FASTA error : file not open for reading" << endl;
-        return false;
-    }
-  
-    // use index if available
-    if ( HasIndex && !Index.empty() ) {
-      
-        // validate reference id 
-        if ( (refId < 0) || (refId >= (int)Index.size()) ) {
-            cerr << "FASTA error: invalid refId specified: " << refId << endl;
-            return false;
-        }
-        
-        // retrieve reference index data
-        const FastaIndexData& referenceData = Index.at(refId);
-        
-        // validate stop position 
-        if ( (start < 0) || (start > stop) || (stop > referenceData.Length) ) {
-            cerr << "FASTA error: invalid start/stop positions specified: " << start << ", " << stop << endl;
-            return false;
-        }
-        
-        // seek to beginning of sequence data
-        if ( fseeko(Stream, referenceData.Offset, SEEK_SET) != 0 ) {
-            cerr << "FASTA error : could not sek in file" << endl;
-            return false;
-        }
-      
-        // retrieve full sequence
-        string fullSequence = "";
-        if ( !GetNextSequence(fullSequence) ) {
-            cerr << "FASTA error : could not retrieve sequence from FASTA file" << endl;
-            return false;
-        }
-        
-        // set sub-sequence & return success
-        const int seqLength = (stop - start) + 1;
-        sequence = fullSequence.substr(start, seqLength);
-        return true;
-    }
-    
-    // else plow through sequentially
-    else {
-      
-        // rewind FASTA file
-        if ( !Rewind() ) {
-            cerr << "FASTA error : could not rewind FASTA file" << endl;
-            return false;
-        }
-     
-        // iterate through fasta entries
-        int currentId = 0;
-        string header = "";
-        string fullSequence = "";
-        
-        // get first entry
-        GetNextHeader(header);
-        GetNextSequence(fullSequence);
-        
-        while ( currentId != refId ) {
-            GetNextHeader(header);
-            GetNextSequence(fullSequence);
-            ++currentId;
-        }
-        
-        // get desired substring from sequence
-        // TODO: error reporting on invalid start/stop positions
-        if ( currentId == refId && (fullSequence.length() >= (size_t)stop) ) {          
-            const int seqLength = (stop - start) + 1;
-            sequence = fullSequence.substr(start, seqLength);
-            return true;
-        }
-      
-        // could not get sequence
-        return false;
-    }
-  
-    // return success
-    return true;
-}
-
-bool Fasta::FastaPrivate::LoadIndexData(void) {
-  
-    // skip if no index file available
-    if ( !IsIndexOpen ) return false; 
-  
-    // clear any prior index data
-    Index.clear();
-  
-    char buffer[1024];
-    stringstream indexBuffer;
-    while ( true ) {
-      
-        char c = fgetc(IndexStream);
-        if ( (c == '\n') || feof(IndexStream) ) break;
-        ungetc(c, IndexStream);
-      
-        // clear index buffer
-        indexBuffer.str("");
-        
-        // read line from index file
-        if ( fgets(buffer, 1024, IndexStream) == 0 ) {
-            cerr << "FASTA LoadIndexData() error : could not read from index file" << endl;
-            HasIndex = false;
-            return false;
-        }
-      
-        // store line in indexBuffer
-        indexBuffer << buffer;
-        
-        // retrieve fasta index data from line
-        FastaIndexData data;
-        indexBuffer >> data.Name;
-        indexBuffer >> data.Length;
-        indexBuffer >> data.Offset;
-        indexBuffer >> data.LineLength;
-        indexBuffer >> data.ByteLength;
-        
-        // store index entry
-        Index.push_back(data);
-    }
-    
-    return true;
-}
-
-bool Fasta::FastaPrivate::Open(const string& filename, const string& indexFilename) {
- 
-    bool success = true;
-  
-    // open FASTA filename
-    Stream = fopen(filename.c_str(), "rb");
-    if ( !Stream ) {
-        cerr << "FASTA error: Could not open " << filename << " for reading" << endl;
-        return false;
-    }
-    IsOpen = true;
-    success &= IsOpen;
-    
-    // open index file if it exists
-    if ( !indexFilename.empty() ) {
-        IndexStream = fopen(indexFilename.c_str(), "rb");
-        if ( !IndexStream ) {
-            cerr << "FASTA error : Could not open " << indexFilename << " for reading." << endl;
-            return false;
-        }
-        IsIndexOpen = true;
-        success &= IsIndexOpen;
-        
-        // attempt to load index data
-        HasIndex = LoadIndexData();
-        success &= HasIndex;
-    }
-    
-    // return success status
-    return success;
-}
-
-bool Fasta::FastaPrivate::Rewind(void) {
-    if ( !IsOpen ) return false;
-    return ( fseeko(Stream, 0, SEEK_SET) == 0 );
-}
-
-bool Fasta::FastaPrivate::WriteIndexData(void) {
- 
-    // skip if no index file available
-    if ( !IsIndexOpen ) return false; 
-  
-    // iterate over index entries
-    bool success = true;
-    stringstream indexBuffer;
-    vector<FastaIndexData>::const_iterator indexIter = Index.begin();
-    vector<FastaIndexData>::const_iterator indexEnd  = Index.end();
-    for ( ; indexIter != indexEnd; ++indexIter ) {
-      
-        // clear stream
-        indexBuffer.str("");
-      
-        // write data to stream
-        const FastaIndexData& data = (*indexIter);
-        indexBuffer << data.Name << "\t"
-                    << data.Length << "\t"
-                    << data.Offset << "\t"
-                    << data.LineLength << "\t"
-                    << data.ByteLength << endl;
-                    
-        // write stream to file
-        success &= ( fputs(indexBuffer.str().c_str(), IndexStream) >= 0 );
-    }
-  
-    // return success status
-    return success;
-}
-
-// --------------------------------
-// Fasta implementation
-
-Fasta::Fasta(void) {
-    d = new FastaPrivate;
-}
-
-Fasta::~Fasta(void) {
-    delete d;
-    d = 0;
-}
-
-bool Fasta::Close(void) { 
-    return d->Close();
-}
-
-bool Fasta::CreateIndex(const string& indexFilename) {
-    return d->CreateIndex(indexFilename);
-}
-
-bool Fasta::GetBase(const int& refId, const int& position, char& base) {
-    return d->GetBase(refId, position, base);
-}
-
-bool Fasta::GetSequence(const int& refId, const int& start, const int& stop, string& sequence) {
-    return d->GetSequence(refId, start, stop, sequence);
-}
-
-bool Fasta::Open(const string& filename, const string& indexFilename) {
-    return d->Open(filename, indexFilename);
-}
diff --git a/bamtools/src/utils/bamtools_fasta.h b/bamtools/src/utils/bamtools_fasta.h
deleted file mode 100644
index c339943..0000000
--- a/bamtools/src/utils/bamtools_fasta.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// ***************************************************************************
-// bamtools_fasta.h (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011
-// ---------------------------------------------------------------------------
-// Provides FASTA reading/indexing functionality.
-// ***************************************************************************
-
-#ifndef BAMTOOLS_FASTA_H
-#define BAMTOOLS_FASTA_H
-
-#include "utils/utils_global.h"
-#include <string>
-
-namespace BamTools {
-
-class UTILS_EXPORT Fasta {
-  
-    // ctor & dtor
-    public:
-        Fasta(void);
-        ~Fasta(void);
-        
-    // file-handling methods
-    public:
-        bool Close(void);
-        bool Open(const std::string& filename, const std::string& indexFilename = "");
-        
-    // sequence access methods
-    public:
-        bool GetBase(const int& refID, const int& position, char& base);
-        bool GetSequence(const int& refId, const int& start, const int& stop, std::string& sequence);
-        
-    // index-handling methods
-    public:
-        bool CreateIndex(const std::string& indexFilename);
-
-    // internal implementation
-    private:
-        struct FastaPrivate;
-        FastaPrivate* d;
-};
-  
-} // BAMTOOLS_FASTA_H
-  
-#endif // BAMTOOLS_FASTA_H
diff --git a/bamtools/src/utils/bamtools_filter_engine.h b/bamtools/src/utils/bamtools_filter_engine.h
deleted file mode 100644
index 9fb2f59..0000000
--- a/bamtools/src/utils/bamtools_filter_engine.h
+++ /dev/null
@@ -1,552 +0,0 @@
-// ***************************************************************************
-// bamtools_filter_engine.h (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 3 May 2013
-// ---------------------------------------------------------------------------
-// Provides a generic filter engine based on filter-sets of properties,
-// with possible "rules" (compound logical expressions) to create more complex
-// queries on a data set.
-//
-// FilterEngine consists, most importantly, of :
-//
-//     a list of possible properties (each tagged whether it has been 'enabled' as a filter)
-//     a map of filterName => propertySet
-//     queue for compound rule expression (i.e. "(filter1 AND filter2) OR !filter3" )
-//     
-// Each propertySet is a list of properties enabled for this particular filter object
-//
-//     Implemented as a map of propertyNames to propertyFilterValue
-//     ( "property1" => pfv1 
-//       "property2" => pfv2 
-//       "property4" => pfv4
-//       etc. )  
-//
-//     Any properties that are 'possible', via FilterEngine::addProperty(), but not enabled 
-//     via FilterEngine::setProperty() (in our example, say "property3"), evaluate to true 
-//     for any query.  Meaning that if a property is not set on this filter, we don't care 
-//     about it here, so it passes though OK.
-//
-// A propertyFilterValue contains a value and comparison type
-//
-//    ( pfv1: Value = 50,    Type = GREATER_THAN_EQUAL
-//      pfv2: Value = "foo", Type = STARTS_WITH
-//      pfv4: Value = "bar", Type = CONTAINS
-//      etc. )  
-//
-//    This allows for more complex queries (than simple isEqual?) against a variety of data types.
-// 
-// ***************************************************************************
-
-#ifndef BAMTOOLS_FILTER_ENGINE_H
-#define BAMTOOLS_FILTER_ENGINE_H
-
-#include "utils/utils_global.h"
-#include "utils/bamtools_filter_properties.h"
-#include "utils/bamtools_filter_ruleparser.h"
-#include "utils/bamtools_utilities.h"
-
-#include <algorithm>
-#include <iostream>
-#include <map>
-#include <queue>
-#include <sstream>
-#include <stack>
-#include <string>
-#include <utility>
-#include <vector>
-
-namespace BamTools {
-
-struct UTILS_EXPORT FilterCompareType {
-    enum Type { AND = 0
-              , NOT
-              , OR
-    };
-};
-  
-// -----------------------------------------------------------
-// FilterEngine
-  
-template <typename FilterChecker>
-class UTILS_EXPORT FilterEngine {
-  
-    // ctor & dtor
-    public:
-        FilterEngine(void) 
-            : m_ruleString("")
-            , m_isRuleQueueGenerated(false)
-            , m_defaultCompareType(FilterCompareType::OR)
-            , AND_OPERATOR("&")
-            , OR_OPERATOR("|")
-            , NOT_OPERATOR("!")
-        { }
-        
-        ~FilterEngine(void) { }
-  
-    // 'filter set' methods
-    public:
-        // creates a new filter set, returns true if created, false if error or already exists
-        bool addFilter(const std::string& filterName);       
-        
-        // return list of current filter names
-        const std::vector<std::string> filterNames(void);    
-  
-    // 'property' methods
-    public:
-      
-        // add a new known property (& type) to engine
-        bool addProperty(const std::string& propertyName);
-  
-        // sets property filter (value, type) for propertyName, on a particular filter set 
-        // setProperty("filter1", "mapQuality", 50, GREATER_THAN_EQUAL)
-        template<typename T>
-        bool setProperty(const std::string& filterName, 
-                         const std::string& propertyName, 
-                         const T& value,
-                         const PropertyFilterValue::ValueCompareType& type = PropertyFilterValue::EXACT);
-        
-        // returns list of all properties known by FilterEngine  ( any created using addProperty() )
-        const std::vector<std::string> allPropertyNames(void);
-        
-        // returns list of property names that are 'enabled' ( only those touched by setProperty() )
-        const std::vector<std::string> enabledPropertyNames(void);  
-  
-     // 'rule' methods
-    public:   
-        
-        // sets comparison operator between filters if no rule string given
-        // default is to do an OR on each filter
-        void setDefaultCompareType(const FilterCompareType::Type& type = FilterCompareType::OR);
-
-        // sets rule string for building expression queue
-        // if empty, creates 
-        void setRule(const std::string& ruleString = "");
-        
-    // token parsing (for property filter generation)
-    public:
-        template<typename T>
-        static bool parseToken(const std::string& token, T& value, PropertyFilterValue::ValueCompareType& type);
-        
-    // query evaluation
-    public:
-        // returns true if query passes all filters in FilterEngine
-        template<typename T>
-        bool check(const T& query);
-
-    // internal rule-handling methods
-    private:
-        void buildDefaultRuleString(void);
-        void buildRuleQueue(void);
-        template<typename T>
-        bool evaluateFilterRules(const T& query);
-        
-    // data members
-    private:
-        // all 'filter sets'
-        FilterMap m_filters;
-        
-        // all known properties
-        std::vector<Property> m_properties; 
-        
-        // infix expression of filter-set comparison rules 
-        std::string m_ruleString;
-        
-        // postfix expression of tokens (filterNames) and operators (as strings)
-        // if this is empty, uses m_compareType to build default expression queue
-        std::queue<std::string> m_ruleQueue;
-        
-        // flag to test if the rule expression queue has been generated
-        bool m_isRuleQueueGenerated;
-        
-        // 'default' comparison operator between filters if no rule string given
-        // if this is changed, m_ruleString is used to build new m_ruleQueue
-        FilterCompareType::Type m_defaultCompareType;
-        
-        // client-specified checking type ( provides method: bool check(PropertyFilter, T object) )
-        FilterChecker m_checker;
-        
-        // token-parsing constants
-        static const int NOT_CHAR          = (int)'!';
-        static const int EQUAL_CHAR        = (int)'=';
-        static const int GREATER_THAN_CHAR = (int)'>';
-        static const int LESS_THAN_CHAR    = (int)'<';
-        static const int WILDCARD_CHAR     = (int)'*';
-        
-        // filter evaluation constants
-        const std::string AND_OPERATOR;
-        const std::string OR_OPERATOR;
-        const std::string NOT_OPERATOR;
-};
-
-// creates a new filter set, returns true if created, false if error or already exists
-template<typename FilterChecker>
-inline bool FilterEngine<FilterChecker>::addFilter(const std::string& filterName) {
-    return (m_filters.insert(std::make_pair(filterName, PropertyFilter()))).second;
-}
-
-// add a new known property & type to engine
-template<typename FilterChecker>
-inline bool FilterEngine<FilterChecker>::addProperty(const std::string& propertyName) {
-    const std::vector<std::string> propertyNames = allPropertyNames();
-    bool found = std::binary_search( propertyNames.begin(), propertyNames.end(), propertyName );
-    if ( found ) return false;
-    m_properties.push_back( Property(propertyName) );
-    std::sort( m_properties.begin(), m_properties.end() );
-    return true;
-}
-
-// returns list of all properties known by FilterEngine 
-// ( any that were created using addProperty() )
-template<typename FilterChecker>
-inline const std::vector<std::string> FilterEngine<FilterChecker>::allPropertyNames(void) {
-    // set up stringlist
-    std::vector<std::string> names;
-    names.reserve(m_properties.size());
-    // iterate through all properties, appending to stringlist
-    std::vector<Property>::const_iterator propIter = m_properties.begin();
-    std::vector<Property>::const_iterator propEnd  = m_properties.end();
-    for ( ; propIter != propEnd; ++propIter )
-        names.push_back( (*propIter).Name );  
-    // return stringlist
-    return names;
-}
-
-// builds a default rule string based on m_defaultCompareType
-// used if user supplied an explicit rule string
-template<typename FilterChecker>
-inline void FilterEngine<FilterChecker>::buildDefaultRuleString(void) {
-  
-    // set up temp string stream 
-    std::stringstream ruleStream("");
-  
-    // get first filterName
-    FilterMap::const_iterator mapIter = m_filters.begin();
-    ruleStream << (*mapIter).first;
-    
-    // if there are more filters present
-    // iterate over remaining filters, appending compare operator and filter name
-    if ( m_filters.size() > 1 ) {        
-        for ( ++mapIter ; mapIter != m_filters.end(); ++mapIter )
-            ruleStream << ( (m_defaultCompareType == FilterCompareType::AND) ? " & " : " | " ) 
-                       << (*mapIter).first;
-    }
-
-    // set m_ruleString from temp stream
-    m_ruleString = ruleStream.str();
-}
-
-// build expression queue based on ruleString
-template<typename FilterChecker>
-inline void FilterEngine<FilterChecker>::buildRuleQueue(void) {
-  
-    // skip if no filters present
-    if ( m_filters.empty() ) return;
-  
-    // clear out any prior expression queue data
-    while ( !m_ruleQueue.empty() )
-        m_ruleQueue.pop();
-  
-    // create a rule string, if not provided
-    if ( m_ruleString.empty() ) 
-        buildDefaultRuleString();
-    
-    // initialize RuleParser, run, and retrieve results
-    RuleParser ruleParser(m_ruleString);
-    ruleParser.parse();
-    m_ruleQueue = ruleParser.results();
-    
-    // set flag if rule queue contains any values
-    m_isRuleQueueGenerated = (!m_ruleQueue.empty());    
-}
-
-// returns whether query value passes filter engine rules
-template<class FilterChecker> template<typename T>
-bool FilterEngine<FilterChecker>::check(const T& query) {
-  
-    // return result of querying against filter rules
-    return evaluateFilterRules(query);
-}
-
-// returns list of property names that are 'enabled' ( only those touched by setProperty() )
-template<typename FilterChecker>
-inline const std::vector<std::string> FilterEngine<FilterChecker>::enabledPropertyNames(void) {
-    // initialize stringlist
-    std::vector<std::string> names;
-    names.reserve(m_properties.size());
-    // iterate over all properties, appending if enabled
-    std::vector<Property>::const_iterator propIter = m_properties.begin();
-    std::vector<Property>::const_iterator propEnd  = m_properties.end();
-    for ( ; propIter != propEnd; ++propIter )
-        if ( (*propIter).IsEnabled ) 
-            names.push_back( (*propIter).Name );    
-    // return stringlist
-    return names;
-}
-
-// evaluates postfix rule queue - with each filter as an operand, AND|OR|NOT as operators
-template<class FilterChecker> template<typename T>
-bool FilterEngine<FilterChecker>::evaluateFilterRules(const T& query) {
-  
-    // build ruleQueue if not done before
-    if ( !m_isRuleQueueGenerated ) 
-        buildRuleQueue();
-    
-    std::stack<bool> resultStack;
-    FilterMap::const_iterator filterIter;
-    std::queue<std::string> ruleQueueCopy = m_ruleQueue;
-    while ( !ruleQueueCopy.empty() ) {
-        const std::string& token = ruleQueueCopy.front();
-        
-        // token is NOT_OPERATOR
-        if ( token == FilterEngine<FilterChecker>::NOT_OPERATOR ) {
-            BAMTOOLS_ASSERT_MESSAGE( !resultStack.empty(), "Empty result stack - cannot apply operator: !" );
-            resultStack.top() = !resultStack.top();
-        }
-        
-        // token is AND_OPERATOR
-        else if ( token == FilterEngine<FilterChecker>::AND_OPERATOR ) {
-            BAMTOOLS_ASSERT_MESSAGE( resultStack.size() >= 2 , "Not enough operands - cannot apply operator: &" );
-            bool topResult = resultStack.top();
-            resultStack.pop();
-            resultStack.top() &= topResult;
-        }
-        
-        // token is OR_OPERATOR
-        else if ( token == FilterEngine<FilterChecker>::OR_OPERATOR ) {
-            BAMTOOLS_ASSERT_MESSAGE( resultStack.size() >= 2 , "Not enough operands - cannot apply operator: |" );
-            bool topResult = resultStack.top();
-            resultStack.pop();
-            resultStack.top() |= topResult;
-        }
-        
-        // token is an operand 
-        else {
-            // look up PropertyFilter that matches this token 
-            filterIter = m_filters.find(token);
-            BAMTOOLS_ASSERT_MESSAGE( (filterIter != m_filters.end() ), "Filter mentioned in rule, not found in FilterEngine" );
-            const PropertyFilter& filter = (*filterIter).second;
-            bool result = m_checker.check(filter, query);
-            resultStack.push( result );
-        }
-        
-        // pop token from ruleQueue
-        ruleQueueCopy.pop();
-    }
-    
-    // return last result
-    BAMTOOLS_ASSERT_MESSAGE( resultStack.size() == 1, "Result stack should only have one value remaining - cannot return result" );
-    return resultStack.top();
-}
-
-// return list of current filter names
-template<typename FilterChecker>
-inline const std::vector<std::string> FilterEngine<FilterChecker>::filterNames(void) {
-    // initialize stringlist
-    std::vector<std::string> names;
-    names.reserve(m_filters.size());
-    // iterate over all filters, appending filter name
-    FilterMap::const_iterator mapIter = m_filters.begin();
-    FilterMap::const_iterator mapEnd  = m_filters.end();
-    for ( ; mapIter != mapEnd; ++mapIter )
-        names.push_back( (*mapIter).first ); 
-    // return stringlist
-    return names;
-}
-
-// parse a filterValue token string that may contain comparison qualifiers (">50", "*SRR", etc.)
-template<class FilterChecker> template<typename T>
-bool FilterEngine<FilterChecker>::parseToken(const std::string& token, T& value, PropertyFilterValue::ValueCompareType& type) {
-    
-    // skip if token is empty
-    if ( token.empty() ) return false;
-    
-    // will store token after special chars are removed
-    std::string strippedToken;
-    
-    // if only single character
-    if ( token.length() == 1 ) {
-        strippedToken = token;
-        type = PropertyFilterValue::EXACT;
-    } 
-    
-    // more than one character, check for special chars
-    else {
-        const int firstChar = (int)token.at(0);
-        switch ( firstChar ) {
-          
-            case ( FilterEngine<FilterChecker>::NOT_CHAR ) :
-                strippedToken = token.substr(1);       
-                type = PropertyFilterValue::NOT;
-                break;
-                
-            case ( FilterEngine<FilterChecker>::GREATER_THAN_CHAR ) :
-                
-                // check for '>=' case
-                if ( token.at(1) == FilterEngine<FilterChecker>::EQUAL_CHAR ) {
-                    if ( token.length() == 2 ) return false;
-                    strippedToken = token.substr(2);
-                    type = PropertyFilterValue::GREATER_THAN_EQUAL;
-                } 
-                
-                // otherwise only '>'
-                else {
-                    strippedToken = token.substr(1);
-                    type = PropertyFilterValue::GREATER_THAN;
-                }
-                
-                break;
-                
-            case ( FilterEngine<FilterChecker>::LESS_THAN_CHAR ) : 
-         
-                // check for '<=' case
-                if ( token.at(1) == FilterEngine<FilterChecker>::EQUAL_CHAR ) {
-                    if ( token.length() == 2 ) return false;
-                    strippedToken = token.substr(2);
-                    type = PropertyFilterValue::LESS_THAN_EQUAL;
-                } 
-                
-                // otherwise only '<'
-                else {
-                    strippedToken = token.substr(1);
-                    type = PropertyFilterValue::LESS_THAN;
-                }
-                
-                break;
-                
-            case ( FilterEngine<FilterChecker>::WILDCARD_CHAR ) : 
-              
-                // check for *str* case (CONTAINS)
-                if ( token.at( token.length() - 1 ) == FilterEngine<FilterChecker>::WILDCARD_CHAR ) {
-                    if ( token.length() == 2 ) return false;
-                    strippedToken = token.substr(1, token.length() - 2);
-                    type = PropertyFilterValue::CONTAINS;
-                }
-                
-                // otherwise *str case (ENDS_WITH)
-                else {
-                    strippedToken = token.substr(1);
-                    type = PropertyFilterValue::ENDS_WITH;
-                }
-                
-                break;
-               
-            default :
-                // check for str* case (STARTS_WITH)
-                if ( token.at( token.length() - 1 ) == FilterEngine<FilterChecker>::WILDCARD_CHAR ) {
-                    if ( token.length() == 2 ) return false;
-                    strippedToken = token.substr(0, token.length() - 1);
-                    type = PropertyFilterValue::STARTS_WITH;
-                }
-                
-                // otherwise EXACT
-                else {
-                    strippedToken = token;
-                    type = PropertyFilterValue::EXACT;
-                }
-                
-                break;
-        }
-    }
-    
-    // convert stripped token to value
-    std::stringstream stream(strippedToken);
-    if ( strippedToken == "true" || strippedToken == "false" )
-        stream >> std::boolalpha >> value;
-    else 
-        stream >> value;
-    
-    // check for valid CompareType on type T
-    Variant variantCheck = value;
-    
-    // if T is not string AND CompareType is for string values, return false
-    if ( !variantCheck.is_type<std::string>() ) {
-        if ( type == PropertyFilterValue::CONTAINS || 
-             type == PropertyFilterValue::ENDS_WITH || 
-             type == PropertyFilterValue::STARTS_WITH )          
-            
-          return false;
-    }
-    
-    // return success
-    return true;
-}
-
-// sets comparison operator between filters if no rule string given
-// default is to do an OR on each filter
-template<typename FilterChecker>
-inline void FilterEngine<FilterChecker>::setDefaultCompareType(const FilterCompareType::Type& type) {
-    // check for supported compare type
-    if ( type == FilterCompareType::AND || type == FilterCompareType::OR ) {
-        // if not the current compare type
-        if ( m_defaultCompareType != type ) {
-            m_defaultCompareType = type;
-            buildRuleQueue();
-        }
-    }
-}
-
-// sets property filter (value, type) for propertyName, on a particular filter set 
-// setProperty("filter1", "mapQuality", 50, GREATER_THAN_EQUAL)
-template<class FilterChecker> template<typename T>
-bool FilterEngine<FilterChecker>::setProperty(const std::string& filterName, 
-                                              const std::string& propertyName, 
-                                              const T& value,
-                                              const PropertyFilterValue::ValueCompareType& type)
-{
-    // lookup filter by name, return false if not found
-    FilterMap::iterator filterIter = m_filters.find(filterName);
-    if ( filterIter == m_filters.end() ) return false;
-      
-    // lookup property for filter, add new PropertyFilterValue if not found, modify if already exists
-    PropertyFilter& filter = (*filterIter).second;
-    PropertyMap::iterator propertyIter = filter.Properties.find(propertyName);
-    
-    bool success;
-    
-    // property not found for this filter, create new entry
-    if ( propertyIter == filter.Properties.end() )
-        success = (filter.Properties.insert(std::make_pair(propertyName, PropertyFilterValue(value, type)))).second;
-    
-    // property already exists, modify
-    else {
-        PropertyFilterValue& filterValue = (*propertyIter).second;
-        filterValue.Value = value;
-        filterValue.Type  = type;
-        success = true;
-    }
-    
-    // if error so far, return false
-    if ( !success ) return false;
-    
-    // --------------------------------------------
-    // otherwise, set Property.IsEnabled to true
-    
-    // lookup property
-    std::vector<Property>::iterator knownPropertyIter = std::find( m_properties.begin(), m_properties.end(), propertyName);
-    
-    // if not found, create a new (enabled) entry (& re-sort list)
-    if ( knownPropertyIter == m_properties.end() ) {
-        m_properties.push_back( Property(propertyName, true) );
-        std::sort( m_properties.begin(), m_properties.end() );
-    } 
-    
-    // property already known, set as enabled
-    else (*knownPropertyIter).IsEnabled = true;
-
-    // return success
-    return true;
-}
-
-// sets user-specified rule string & signals update of rule-expression queue
-template<typename FilterChecker>
-inline void FilterEngine<FilterChecker>::setRule(const std::string& ruleString) {
-    if ( m_ruleString != ruleString) {
-        m_ruleString = ruleString;
-        buildRuleQueue();
-    }
-}
-
-} // namespace BamTools
-
-#endif // BAMTOOLS_FILTER_ENGINE_H
diff --git a/bamtools/src/utils/bamtools_filter_properties.h b/bamtools/src/utils/bamtools_filter_properties.h
deleted file mode 100644
index a69f31d..0000000
--- a/bamtools/src/utils/bamtools_filter_properties.h
+++ /dev/null
@@ -1,195 +0,0 @@
-// ***************************************************************************
-// bamtools_filter_properties.h (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011
-// ---------------------------------------------------------------------------
-// Provides support data structures & methods for FilterEngine
-//
-// The FilterEngine consists, most importantly, of :
-//
-//     a list of possible properties (each tagged whether it has been 'enabled' as a filter)
-//     a map of filterName => propertySet
-//     queue for compound rule expression (i.e. "(filter1 AND filter2) OR !filter3" )
-//     
-// Each propertySet is a list of properties enabled for this particular filter object
-//
-//     Implemented as a map of propertyNames to propertyFilterValue
-//     ( "property1" => pfv1 
-//       "property2" => pfv2 
-//       "property4" => pfv4
-//       etc. )  
-//
-//     Any properties that are 'possible', via FilterEngine::addProperty(), but not enabled 
-//     via FilterEngine::setProperty() (in our example, say "property3"), evaluate to true 
-//     for any query.  Meaning that if a property is not set on this filter, we don't care 
-//     about it here, so it passes though OK.
-//
-// A propertyFilterValue contains a value and comparison type
-//
-//    ( pfv1: Value = 50,    Type = GREATER_THAN_EQUAL
-//      pfv2: Value = "foo", Type = STARTS_WITH
-//      pfv4: Value = "bar", Type = CONTAINS
-//      etc. )  
-//
-//    This allows for more complex queries (than simple isEqual?) against a variety of data types.
-//
-// ***************************************************************************
-
-#ifndef BAMTOOLS_FILTER_PROPERTIES_H
-#define BAMTOOLS_FILTER_PROPERTIES_H
-
-#include "utils/utils_global.h"
-#include "utils/bamtools_utilities.h"
-#include "utils/bamtools_variant.h"
-#include <iostream>
-#include <map>
-#include <string>
-
-namespace BamTools {
-
-// ----------------------------------------------------------
-// PropertyFilterValue
-  
-struct UTILS_EXPORT PropertyFilterValue {
-  
-    // define valid ValueCompareTypes
-    enum ValueCompareType { CONTAINS = 0
-                          , ENDS_WITH
-                          , EXACT
-                          , GREATER_THAN
-                          , GREATER_THAN_EQUAL
-                          , LESS_THAN
-                          , LESS_THAN_EQUAL
-                          , NOT
-                          , STARTS_WITH
-                          };
-                   
-    // ctor
-    PropertyFilterValue(const Variant& value = Variant(),
-                        const ValueCompareType& type = PropertyFilterValue::EXACT)
-        : Value(value)
-        , Type(type)
-    { }
-          
-    // filter check methods      
-    template<typename T>
-    bool check(const T& query) const;
-    bool check(const std::string& query) const;
-             
-    // data members
-    Variant Value;
-    ValueCompareType Type;
-};
-
-// checks a query against a filter (value, compare type)
-template<typename T>
-bool PropertyFilterValue::check(const T& query) const {
-  
-    // ensure filter value & query are same type
-    if ( !Value.is_type<T>() ) { 
-        std::cerr << "Cannot compare different types!" << std::endl;
-        return false;
-    }
-    
-    // string matching
-    if ( Value.is_type<std::string>() ) {
-        std::cerr << "Cannot compare different types - query is a string!" << std::endl;
-        return false;
-    } 
-    
-    // numeric matching based on our filter type
-    switch ( Type ) {
-        case ( PropertyFilterValue::EXACT)              : return ( query == Value.get<T>() );
-        case ( PropertyFilterValue::GREATER_THAN)       : return ( query >  Value.get<T>() ); 
-        case ( PropertyFilterValue::GREATER_THAN_EQUAL) : return ( query >= Value.get<T>() ); 
-        case ( PropertyFilterValue::LESS_THAN)          : return ( query <  Value.get<T>() );
-        case ( PropertyFilterValue::LESS_THAN_EQUAL)    : return ( query <= Value.get<T>() );
-        case ( PropertyFilterValue::NOT)                : return ( query != Value.get<T>() );
-        default : BAMTOOLS_ASSERT_UNREACHABLE;
-    }
-    return false;
-}
-
-// checks a string query against filter (value, compare type)
-inline
-bool PropertyFilterValue::check(const std::string& query) const {
-  
-    // ensure filter value & query are same type
-    if ( !Value.is_type<std::string>() ) {
-        std::cerr << "Cannot compare different types!" << std::endl;
-        return false;
-    }
-  
-    // localize string version of our filter value
-    const std::string& valueString = Value.get<std::string>();
-    
-    // string matching based on our filter type
-    switch ( Type ) {
-        case ( PropertyFilterValue::CONTAINS)           : return ( query.find(valueString) != std::string::npos );
-        case ( PropertyFilterValue::ENDS_WITH)          : return ( query.find(valueString) == (query.length() - valueString.length()) ); 
-        case ( PropertyFilterValue::EXACT)              : return ( query == valueString );
-        case ( PropertyFilterValue::GREATER_THAN)       : return ( query >  valueString ); 
-        case ( PropertyFilterValue::GREATER_THAN_EQUAL) : return ( query >= valueString ); 
-        case ( PropertyFilterValue::LESS_THAN)          : return ( query <  valueString );
-        case ( PropertyFilterValue::LESS_THAN_EQUAL)    : return ( query <= valueString );
-        case ( PropertyFilterValue::NOT)                : return ( query != valueString );
-        case ( PropertyFilterValue::STARTS_WITH)        : return ( query.find(valueString) == 0 );
-        default : BAMTOOLS_ASSERT_UNREACHABLE;
-    }
-    return false;
-}
-
-inline
-const std::string toString(const PropertyFilterValue::ValueCompareType& type) {
-  
-    switch ( type ) {
-        case ( PropertyFilterValue::CONTAINS )           : return std::string( "CONTAINS");
-        case ( PropertyFilterValue::ENDS_WITH )          : return std::string( "ENDS_WITH");
-        case ( PropertyFilterValue::EXACT )              : return std::string( "EXACT");
-        case ( PropertyFilterValue::GREATER_THAN )       : return std::string( "GREATER_THAN");
-        case ( PropertyFilterValue::GREATER_THAN_EQUAL ) : return std::string( "GREATER_THAN_EQUAL");
-        case ( PropertyFilterValue::LESS_THAN )          : return std::string( "LESS_THAN");
-        case ( PropertyFilterValue::LESS_THAN_EQUAL )    : return std::string( "LESS_THAN_EQUAL");
-        case ( PropertyFilterValue::NOT )                : return std::string( "NOT");
-        case ( PropertyFilterValue::STARTS_WITH )        : return std::string( "STARTS_WITH");
-        default : BAMTOOLS_ASSERT_UNREACHABLE;
-    }
-    return std::string();
-}
-
-// property name => property filter value 
-// ('name' => ('SSR', STARTS_WITH), 'mapQuality' => (50, GREATER_THAN_EQUAL), etc...)
-typedef std::map<std::string, PropertyFilterValue> PropertyMap;
-
-// ----------------------------------------------------------
-// PropertyFilter
-
-struct UTILS_EXPORT PropertyFilter {
-    // data members
-    PropertyMap Properties;
-};
-
-// filter name => properties  
-// ('filter1' => properties1, 'filter2' => properties2, etc...)
-typedef std::map<std::string, PropertyFilter> FilterMap;
-  
-// ----------------------------------------------------------
-// Property
-  
-// used to store properties known to engine & keep track of enabled state
-struct UTILS_EXPORT Property {
-    std::string Name;
-    bool IsEnabled;
-    Property(const std::string& name, bool isEnabled = false) 
-        : Name(name)
-        , IsEnabled(isEnabled) 
-    { }
-};
-
-inline bool operator<  (const Property& lhs, const Property& rhs) { return lhs.Name <  rhs.Name; }
-inline bool operator== (const Property& lhs, const Property& rhs) { return lhs.Name == rhs.Name; }
-
-} // namespace BamTools
-
-#endif // BAMTOOLS_FILTER_PROPERTIES_H
diff --git a/bamtools/src/utils/bamtools_filter_ruleparser.h b/bamtools/src/utils/bamtools_filter_ruleparser.h
deleted file mode 100644
index f3079eb..0000000
--- a/bamtools/src/utils/bamtools_filter_ruleparser.h
+++ /dev/null
@@ -1,319 +0,0 @@
-// ***************************************************************************
-// bamtools_filter_ruleparser.h (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011
-// ---------------------------------------------------------------------------
-// Provides a compound rule parser for FilterEngine.
-// ***************************************************************************
-
-#ifndef BAMTOOLS_FILTER_RULEPARSER_H
-#define BAMTOOLS_FILTER_RULEPARSER_H
-
-#include "utils/bamtools_utilities.h"
-#include <queue>
-#include <stack>
-#include <string>
-
-namespace BamTools {
-
-// -------------------------------------------
-// char constants  
-  
-const char LEFT_PARENTHESIS_CHAR  = '(';
-const char RIGHT_PARENTHESIS_CHAR = ')';
-const char AND_OPERATOR_CHAR      = '&';
-const char OR_OPERATOR_CHAR       = '|';
-const char NOT_OPERATOR_CHAR      = '!';
-const char SPACE_CHAR             = ' ';
-  
-// -------------------------------------------
-// RuleToken implementation
-  
-struct RuleToken {
-  
-    // enums
-    enum RuleTokenType { OPERAND = 0
-                       , AND_OPERATOR
-                       , OR_OPERATOR
-                       , NOT_OPERATOR
-                       , LEFT_PARENTHESIS
-                       , RIGHT_PARENTHESIS
-                       };
-    
-    // data members
-    RuleTokenType Type;
-    std::string Value;
-};
-
-inline int priority(const RuleToken& token) {
-    switch ( token.Type ) {
-        case ( RuleToken::NOT_OPERATOR )      : return 3;
-        case ( RuleToken::AND_OPERATOR )      : return 2;
-        case ( RuleToken::OR_OPERATOR  )      : return 1;
-        case ( RuleToken::LEFT_PARENTHESIS )  : return 0;
-        case ( RuleToken::RIGHT_PARENTHESIS ) : return 0;
-        default:
-            BAMTOOLS_ASSERT_UNREACHABLE;
-            return -1;
-    } 
-}
-
-inline bool isRightAssociative(const RuleToken& token) {
-    return (token.Type == RuleToken::NOT_OPERATOR || 
-            token.Type == RuleToken::LEFT_PARENTHESIS);
-}
-
-inline bool isLeftAssociative(const RuleToken& token) {
-    return !isRightAssociative(token);
-}
-
-inline bool isLeftParenthesis(const RuleToken& token) {
-    return ( token.Type == RuleToken::LEFT_PARENTHESIS );
-}
-
-inline bool isRightParenthesis(const RuleToken& token) {
-    return ( token.Type == RuleToken::RIGHT_PARENTHESIS );
-}
-
-inline bool isOperand(const RuleToken& token) {
-    return ( token.Type == RuleToken::OPERAND );
-}
-
-inline bool isOperator(const RuleToken& token) {
-    return ( token.Type == RuleToken::AND_OPERATOR ||
-             token.Type == RuleToken::OR_OPERATOR  ||
-             token.Type == RuleToken::NOT_OPERATOR);
-}
-  
-// -------------------------------------------
-// RuleParser implementation  
-  
-class RuleParser {
-
-    // ctor & dtor
-    public:
-        RuleParser(const std::string& ruleString)
-            : m_ruleString(ruleString)
-        { 
-            // initialize char markers
-            m_begin = (char*)m_ruleString.c_str();
-            m_end   = m_begin + m_ruleString.length();
-            ignoreQuotes();
-        }
-        
-        ~RuleParser(void) { }
-  
-    // public interface
-    public:
-        void parse(void);
-        std::queue<std::string> results(void) const { return m_ruleQueue; }
-
-    // internal methods
-    private:
-        char getNextChar(void);
-        void ignoreQuotes(void);
-        bool readToken(RuleToken& token);
-        void skipSpaces(void);
-      
-    // data members
-    private:
-        std::string m_ruleString;
-        char* m_begin;
-        char* m_current;
-        char* m_end;
-        
-        std::queue<std::string> m_ruleQueue;
-        std::stack<RuleToken> m_operatorStack;
-};
-
-inline
-char RuleParser::getNextChar(void) {
-   if ( m_current == m_end ) return 0;
-   return *m_current++;
-}
-
-inline
-void RuleParser::ignoreQuotes(void) {
-    if ( *m_begin == '\"' ) ++m_begin;
-    if ( *m_end   == '\"' ) --m_end;
-}
-
-inline
-void RuleParser::parse(void) {
-  
-    // clear out any prior data
-    while ( !m_ruleQueue.empty() ) 
-        m_ruleQueue.pop();
-    
-    // skip if no rule to parse
-    if ( m_ruleString.empty() ) return;
-  
-    // start at beginning of ruleString
-    m_current = m_begin;
-    
-    // iterate through tokens in rule string
-    RuleToken token;
-    while ( readToken(token) ) {
-      
-        if ( token.Value.empty() ) break;
-      
-        // if token is an operand
-        if ( isOperand(token) )
-            m_ruleQueue.push(token.Value);
-
-        // if token is an operator 
-        else if ( isOperator(token) ) {
-
-            // pop any operators at top of stack with higher priority
-            while ( !m_operatorStack.empty() ) {
-                const RuleToken& opToken = m_operatorStack.top();
-                if ( (isLeftAssociative(token) && (priority(token) <= priority(opToken))) ||
-                     (isRightAssociative(token) && (priority(token) < priority(opToken))) 
-                    )
-                {
-                    m_ruleQueue.push(opToken.Value);
-                    m_operatorStack.pop();
-                }
-                else break;
-            }
-            
-            // push current operator token onto stack
-            m_operatorStack.push(token);
-        }
-        
-        // if token is left parenthesis
-        else if ( isLeftParenthesis(token) )
-            m_operatorStack.push(token);
-        
-        // if token is right parenthesis
-        else if ( isRightParenthesis(token) ) {
-          
-            bool foundLeftParenthesis = false;
-          
-            // push operators into rule queue until left parenthesis found
-            while ( !m_operatorStack.empty() && !foundLeftParenthesis ) {
-                const RuleToken& opToken = m_operatorStack.top();
-                if ( !isLeftParenthesis(opToken) )
-                    m_ruleQueue.push(opToken.Value);
-                else 
-                    foundLeftParenthesis = true;
-                m_operatorStack.pop();
-            }
-          
-            // no left parenthesis found, error
-            BAMTOOLS_ASSERT_MESSAGE( foundLeftParenthesis, "ERROR: Mismatched parenthesis in rule string.1");
-        }
-        
-        // error: unknown operand
-        else BAMTOOLS_ASSERT_UNREACHABLE;
-    }    
-    
-    // while there are still operators on stack
-    while ( !m_operatorStack.empty() ) {
-        const RuleToken& token = m_operatorStack.top();
-        BAMTOOLS_ASSERT_MESSAGE( (!isLeftParenthesis(token) && !isRightParenthesis(token)), "ERROR: Mismatched parenthesis in rule string.2");
-        m_ruleQueue.push(token.Value);
-        m_operatorStack.pop();
-    }
-}
-
-inline
-bool RuleParser::readToken(RuleToken& token) {
-  
-    // skip any preceding whitespace
-    skipSpaces();
-    if ( m_current == m_end ) return false;
-
-    // clear out prior token value
-    token.Value.clear();
-    
-    // read chars while still in token
-    char c = 1;
-    bool keepReading = true;
-    bool inOperandString = false;
-    while ( keepReading && (c != 0) ) {
-      
-      // get next char
-      c = getNextChar();
-      switch (c) {
-        
-          // current char is '('
-          case ( LEFT_PARENTHESIS_CHAR ) :
-              token.Type = RuleToken::LEFT_PARENTHESIS;
-              token.Value.append(1, LEFT_PARENTHESIS_CHAR);
-              keepReading = false;
-              break;
-              
-          // current char is ')'
-          case ( RIGHT_PARENTHESIS_CHAR ) :
-              if ( inOperandString )
-                  --m_current;
-              else {
-                  token.Type = RuleToken::RIGHT_PARENTHESIS;
-                  token.Value.append(1, RIGHT_PARENTHESIS_CHAR);
-              }
-              keepReading = false;
-              break;
-        
-          // current char is '&'
-          case ( AND_OPERATOR_CHAR ) :
-              if ( inOperandString ) 
-                  --m_current;
-              else {
-                  token.Type = RuleToken::AND_OPERATOR;
-                  token.Value.append(1, AND_OPERATOR_CHAR);
-              }
-              keepReading = false;
-              break;
-              
-          // current char is '|' 
-          case ( OR_OPERATOR_CHAR ) :
-              if ( inOperandString )
-                  --m_current;
-              else {  
-                  token.Type = RuleToken::OR_OPERATOR;
-                  token.Value.append(1, OR_OPERATOR_CHAR);
-              }
-              keepReading = false;
-              break;
-              
-          // current char is '!'
-          case ( NOT_OPERATOR_CHAR ) :
-              token.Type = RuleToken::NOT_OPERATOR;
-              token.Value.append(1, NOT_OPERATOR_CHAR);
-              keepReading = false;
-              break;
-              
-          // current char is ' '
-          case ( SPACE_CHAR ) : 
-              keepReading = false;
-              break;
-            
-          // current char is a true value token
-          default:
-              if ( c != 0 ) {
-                  token.Type = RuleToken::OPERAND;
-                  token.Value.append(1, c);
-                  inOperandString = true;
-                  keepReading = true;
-              }
-        }         
-    }
-      
-    return true;
-}
-
-inline
-void RuleParser::skipSpaces(void) {
-    while ( m_current != m_end ) {
-        const char c = *m_current;
-        if ( c == ' ' || c == '\t' || c == '\r' || c == '\n')
-            ++m_current;
-        else break;
-    }
-}
-
-} // namespace BamTools
-
-#endif // BAMTOOLS_FILTER_RULEPARSER_H
diff --git a/bamtools/src/utils/bamtools_options.cpp b/bamtools/src/utils/bamtools_options.cpp
deleted file mode 100644
index 565c90e..0000000
--- a/bamtools/src/utils/bamtools_options.cpp
+++ /dev/null
@@ -1,287 +0,0 @@
-// ***************************************************************************
-// bamtools_options.cpp (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011
-// ---------------------------------------------------------------------------
-// Parses command line arguments and creates a help menu
-// ---------------------------------------------------------------------------
-// Modified from:
-// The Mosaik suite's command line parser class: COptions
-// (c) 2006 - 2009 Michael Str�mberg
-// Marth Lab, Department of Biology, Boston College
-// Re-licensed under MIT License with author's permission.
-//
-// * Modified slightly to fit BamTools, otherwise code is same. 
-// *  (BamTools namespace, added stdin/stdout) (DB)
-// ***************************************************************************
-
-#include "utils/bamtools_options.h"
-using namespace BamTools;
-
-#include <cstdio>
-#include <cstdlib>
-#include <cstring>
-#include <iomanip>
-#include <sstream>
-using namespace std;
-
-string Options::m_programName;                   // the program name
-string Options::m_description;                   // the main description
-string Options::m_exampleArguments;              // the example arguments
-vector<OptionGroup> Options::m_optionGroups;     // stores the option groups
-map<string, OptionValue> Options::m_optionsMap;  // stores the options in a map
-const string Options::m_stdin  = "stdin";        // string representation of stdin
-const string Options::m_stdout = "stdout";       // string representation of stdout
-
-// adds a simple option to the parser
-void Options::AddOption(const string& argument,
-                        const string& optionDescription,
-                        bool& foundArgument,
-                        OptionGroup* group)
-{
-    Option o;
-    o.Argument    = argument;
-    o.Description = optionDescription;
-    o.StoreValue  = false;
-    group->Options.push_back(o);
-
-    OptionValue ov;
-    ov.pFoundArgument = &foundArgument;
-    ov.StoreValue     = false;
-
-    m_optionsMap[argument] = ov;
-}
-
-// creates an option group
-OptionGroup* Options::CreateOptionGroup(const string& groupName) {
-    OptionGroup og;
-    og.Name = groupName;
-    m_optionGroups.push_back(og);
-    return &m_optionGroups[m_optionGroups.size() - 1];
-}
-
-// displays the help menu
-void Options::DisplayHelp(void) {
-
-    // initialize
-    char argumentBuffer[ARGUMENT_LENGTH + 1];
-    ostringstream sb;
-
-    char indentBuffer[MAX_LINE_LENGTH - DESC_LENGTH + 1];
-    memset(indentBuffer, ' ', MAX_LINE_LENGTH - DESC_LENGTH);
-    indentBuffer[MAX_LINE_LENGTH - DESC_LENGTH] = 0;
-
-    // display the menu
-    printf("Description: %s.\n\n", m_description.c_str());
-    printf("Usage: ");
-    printf("%s", m_programName.c_str());
-    printf(" %s\n\n", m_exampleArguments.c_str());
-
-    vector<Option>::const_iterator      optionIter;
-    vector<OptionGroup>::const_iterator groupIter;
-    for (groupIter = m_optionGroups.begin(); groupIter != m_optionGroups.end(); ++groupIter) {
-        
-        printf("%s:\n", groupIter->Name.c_str());
-
-        for (optionIter = groupIter->Options.begin(); optionIter != groupIter->Options.end(); ++optionIter) {
-
-            if (optionIter->StoreValue) 
-                snprintf(argumentBuffer, ARGUMENT_LENGTH + 1, "  %s <%s>", optionIter->Argument.c_str(), optionIter->ValueDescription.c_str());
-            else 
-                snprintf(argumentBuffer, ARGUMENT_LENGTH + 1, "  %s", optionIter->Argument.c_str());
-            printf("%-35s ", argumentBuffer);
-
-            string description = optionIter->Description;
-
-            // handle default values
-            if (optionIter->HasDefaultValue) {
-                
-                sb.str("");
-                sb << description << " [";
-
-                if (optionIter->DefaultValue.is_type<unsigned int>()) {
-                    sb << (unsigned int)optionIter->DefaultValue;
-                } else if (optionIter->DefaultValue.is_type<unsigned char>()) {
-                    sb << (unsigned short)(unsigned char)optionIter->DefaultValue;
-                } else if (optionIter->DefaultValue.is_type<float>()) {
-                    sb << std::fixed << std::setprecision(2) << (float)optionIter->DefaultValue;
-                } else if (optionIter->DefaultValue.is_type<double>()) {
-                    sb << std::fixed << std::setprecision(4) << (double)optionIter->DefaultValue;
-                } else if (optionIter->DefaultValue.is_type<std::string>()) {
-                    const std::string stringValue = optionIter->DefaultValue;
-                    sb << stringValue;
-                } else {
-                    printf("ERROR: Found an unsupported data type for argument %s when casting the default value.\n",
-                           optionIter->Argument.c_str());
-                    exit(1);
-                }
-
-                sb << "]";
-                description = sb.str(); 
-            }
-
-            if ( description.size() <= DESC_LENGTH_FIRST_ROW ) {
-                printf("%s\n", description.c_str());
-            } else {
-
-                // handle the first row
-                const char* pDescription = description.data();
-                unsigned int cutIndex = DESC_LENGTH_FIRST_ROW;
-                while(pDescription[cutIndex] != ' ') 
-                    cutIndex--;
-                printf("%s\n", description.substr(0, cutIndex).c_str());
-                description = description.substr(cutIndex + 1);
-
-                // handle subsequent rows
-                while(description.size() > DESC_LENGTH) {
-                    pDescription = description.data();
-                    cutIndex = DESC_LENGTH;
-                    while(pDescription[cutIndex] != ' ') 
-                        cutIndex--;
-                    printf("%s%s\n", indentBuffer, description.substr(0, cutIndex).c_str());
-                    description = description.substr(cutIndex + 1);
-                }
-
-                // handle last row
-                printf("%s%s\n", indentBuffer, description.c_str());
-            }                       
-        }
-
-        printf("\n");
-    }
-
-    printf("Help:\n"); 
-    printf("  --help, -h                        shows this help text\n");
-    exit(1);
-}
-
-// parses the command line
-void Options::Parse(int argc, char* argv[], int offset) {
-
-    // initialize
-    map<string, OptionValue>::const_iterator ovMapIter;
-    map<string, OptionValue>::const_iterator checkMapIter;
-    const int LAST_INDEX = argc - 1;
-    ostringstream errorBuilder;
-    bool foundError = false;
-    char* end_ptr = NULL;
-    const string ERROR_SPACER(7, ' ');
-
-    // check if we should show the help menu
-    bool showHelpMenu = false;
-    if (argc > 1) {
-        for (int i = 1; i < argc; i++) {
-            const std::string argument = argv[i];
-            if ( (argument == "-h") || (argument == "--help") || (argument == "help") ) 
-                showHelpMenu = true;
-        }
-    } else showHelpMenu = true;
-
-    if (showHelpMenu) 
-        DisplayHelp();
-
-    // check each argument
-    for (int i = offset+1; i < argc; i++) {
-      
-        const string argument = argv[i];
-        ovMapIter = m_optionsMap.find(argument);
-
-        if (ovMapIter == m_optionsMap.end()) {
-            errorBuilder << ERROR_SPACER << "An unrecognized argument was found: " << argument << std::endl;
-            foundError = true;
-        } else {
-
-            *ovMapIter->second.pFoundArgument = true;
-
-            // grab the value
-            if (ovMapIter->second.StoreValue) {
-
-                if (i < LAST_INDEX) {
-
-                    // check if the next argument is really a command line option
-                    const string val = argv[i + 1]; 
-                    checkMapIter = m_optionsMap.find(val);
-
-                    if (checkMapIter == m_optionsMap.end()) {
-                        
-                        ++i;
-                        
-                        if (ovMapIter->second.VariantValue.is_type<unsigned int>()) {
-                            const unsigned int uint32 = (unsigned int)strtoul(val.c_str(), &end_ptr, 10);
-                            unsigned int* varValue = (unsigned int*)ovMapIter->second.pValue;
-                            *varValue = uint32;
-                        } else if (ovMapIter->second.VariantValue.is_type<unsigned char>()) {
-                            const unsigned char uint8 = (unsigned char)strtoul(val.c_str(), &end_ptr, 10);
-                            unsigned char* varValue = (unsigned char*)ovMapIter->second.pValue;
-                            *varValue = uint8;
-                        } else if (ovMapIter->second.VariantValue.is_type<uint64_t>()) {
-                            const uint64_t uint64 = strtoui64(val.c_str(), &end_ptr, 10);
-                            uint64_t* varValue = (uint64_t*)ovMapIter->second.pValue;
-                            *varValue = uint64;
-                        } else if (ovMapIter->second.VariantValue.is_type<double>()) {
-                            const double d = strtod(val.c_str(), &end_ptr);
-                            double* varValue = (double*)ovMapIter->second.pValue;
-                            *varValue = d;
-                        } else if (ovMapIter->second.VariantValue.is_type<float>()) {
-                            const float f = (float)strtod(val.c_str(), &end_ptr);
-                            float* varValue = (float*)ovMapIter->second.pValue;
-                            *varValue = f;
-                        } else if (ovMapIter->second.VariantValue.is_type<string>()) {
-                            string* pStringValue = (string*)ovMapIter->second.pValue;
-                            *pStringValue = val;
-                        } else if (ovMapIter->second.VariantValue.is_type<vector<string> >()) {
-                            vector<string>* pVectorValue = (vector<string>*)ovMapIter->second.pValue;
-                            pVectorValue->push_back(val);
-                        } else {
-                            printf("ERROR: Found an unsupported data type for argument %s when parsing the arguments.\n",
-                                   argument.c_str());
-                            exit(1);
-                        }
-                    } else {
-                        errorBuilder << ERROR_SPACER << "The argument (" << argument
-                                     << ") expects a value, but none was found." << endl;
-                        foundError = true;
-                    }
-                } else {
-                    errorBuilder << ERROR_SPACER << "The argument (" << argument
-                                 << ") expects a value, but none was found." << endl;
-                    foundError = true;
-                }
-            }
-        }
-    }
-
-    // check if we missed any required parameters
-    for (ovMapIter = m_optionsMap.begin(); ovMapIter != m_optionsMap.end(); ++ovMapIter) {
-        if (ovMapIter->second.IsRequired && !*ovMapIter->second.pFoundArgument) {
-            errorBuilder << ERROR_SPACER << ovMapIter->second.ValueTypeDescription
-                         << " was not specified. Please use the " << ovMapIter->first << " parameter." << endl;
-            foundError = true;
-        }
-    }
-
-    // print the errors if any were found
-    if (foundError) {
-        printf("ERROR: Some problems were encountered when parsing the command line options:\n");
-        printf("%s\n", errorBuilder.str().c_str());
-        printf("For a complete list of command line options, type \"%s help %s\"\n", argv[0], argv[1]);
-        exit(1);
-    }
-}
-
-// sets the program info
-void Options::SetProgramInfo(const string& programName,
-                             const string& description,
-                             const string& arguments)
-{
-    m_programName      = programName;
-    m_description      = description;
-    m_exampleArguments = arguments;
-}
-
-// return string representations of stdin
-const string& Options::StandardIn(void) { return m_stdin; }
-
-// return string representations of stdout
-const string& Options::StandardOut(void) { return m_stdout; }
diff --git a/bamtools/src/utils/bamtools_options.h b/bamtools/src/utils/bamtools_options.h
deleted file mode 100644
index 2afe129..0000000
--- a/bamtools/src/utils/bamtools_options.h
+++ /dev/null
@@ -1,213 +0,0 @@
-// ***************************************************************************
-// bamtools_options.h (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011
-// ---------------------------------------------------------------------------
-// Parses command line arguments and creates a help menu
-// ---------------------------------------------------------------------------
-// Modified from:
-// The Mosaik suite's command line parser class: COptions
-// (c) 2006 - 2009 Michael Str�mberg
-// Marth Lab, Department of Biology, Boston College
-// Re-licensed under MIT License with author's permission.
-//
-// * Modified slightly to fit BamTools, otherwise code is same. 
-// *  (BamTools namespace, added stdin/stdout) (DB)
-// ***************************************************************************
-
-#ifndef BAMTOOLS_OPTIONS_H
-#define BAMTOOLS_OPTIONS_H
-
-#include "utils/bamtools_variant.h"
-#include "utils/utils_global.h"
-
-#include <map>
-#include <string>
-#include <vector>
-
-#ifndef WIN32
-    #include <stdint.h>
-#endif
-
-namespace BamTools {
-
-#define ARGUMENT_LENGTH       35
-#define DESC_LENGTH_FIRST_ROW 30
-#define DESC_LENGTH           42
-#define MAX_LINE_LENGTH       78
-
-#ifdef WIN32
-  #define snprintf _snprintf
-  typedef __int64          int64_t;
-  typedef unsigned __int64 uint64_t;
-  #define strtoui64 _strtoui64
-#else
-  #define strtoui64 strtoull
-#endif
-
-struct UTILS_EXPORT Option {
-  
-    // data members
-    std::string Argument;
-    std::string ValueDescription;
-    std::string Description;
-    bool StoreValue;
-    bool HasDefaultValue;
-    Variant DefaultValue;
-
-    // constructor
-    Option(void)
-        : StoreValue(true)
-        , HasDefaultValue(false)
-    { }
-};
-
-struct UTILS_EXPORT OptionValue {
-  
-    // data members
-    bool* pFoundArgument;
-    void* pValue;
-    std::string ValueTypeDescription;
-    bool UseVector;
-    bool StoreValue;
-    bool IsRequired;
-    Variant VariantValue;
-
-    // constructor
-    OptionValue(void)
-        : pFoundArgument(NULL)
-        , pValue(NULL)
-        , UseVector(false)
-        , StoreValue(true)
-        , IsRequired(false)
-    { } 
-};
-
-struct UTILS_EXPORT OptionGroup {
-    std::string Name;
-    std::vector<Option> Options;
-};
-
-class UTILS_EXPORT Options {
-  
-    // add option/argument rules
-    public:
-        // adds a simple option to the parser
-        static void AddOption(const std::string& argument, 
-                       const std::string& optionDescription, 
-                       bool& foundArgument, 
-                       OptionGroup* group);
-                       
-        // adds a value option to the parser
-        template<typename T>
-        static void AddValueOption(const std::string& argument, 
-                            const std::string& valueDescription, 
-                            const std::string& optionDescription, 
-                            const std::string& valueTypeDescription, 
-                            bool& foundArgument, 
-                            T& val, 
-                            OptionGroup* group);
-                            
-        // adds a value option to the parser (with a default value)
-        template<typename T, typename D>
-        static void AddValueOption(const std::string& argument, 
-                            const std::string& valueDescription, 
-                            const std::string& optionDescription, 
-                            const std::string& valueTypeDescription, 
-                            bool& foundArgument, 
-                            T& val, 
-                            OptionGroup* group, 
-                            D& defaultValue);
-       
-    // other API methods
-    public:
-        // creates an option group
-        static OptionGroup* CreateOptionGroup(const std::string& groupName);    
-        // displays the help menu
-        static void DisplayHelp(void);
-        // parses the command line
-        static void Parse(int argc, char* argv[], int offset = 0);
-        // sets the program info
-        static void SetProgramInfo(const std::string& programName,
-                                   const std::string& description,
-                                   const std::string& arguments);
-        // returns string representation of stdin
-        static const std::string& StandardIn(void);
-        // returns string representation of stdout
-        static const std::string& StandardOut(void);
-        
-    // static data members
-    private:
-        // the program name
-        static std::string m_programName;
-        // the main description
-        static std::string m_description;
-        // the example arguments
-        static std::string m_exampleArguments;
-        // stores the option groups
-        static std::vector<OptionGroup> m_optionGroups;
-        // stores the options in a map
-        static std::map<std::string, OptionValue> m_optionsMap;
-        // string representation of stdin
-        static const std::string m_stdin;
-        // string representation of stdout
-        static const std::string m_stdout;
-};
-
-// adds a value option to the parser
-template<typename T>
-void Options::AddValueOption(const std::string& argument, 
-                             const std::string& valueDescription, 
-                             const std::string& optionDescription, 
-                             const std::string& valueTypeDescription, 
-                             bool& foundArgument, 
-                             T& val, 
-                             OptionGroup* group) 
-{
-        Option o;
-        o.Argument         = argument;
-        o.ValueDescription = valueDescription;
-        o.Description      = optionDescription;
-        group->Options.push_back(o);
-
-        OptionValue ov;
-        ov.pFoundArgument       = &foundArgument;
-        ov.pValue               = (void*)&val;
-        ov.VariantValue         = val;
-        ov.IsRequired           = (valueTypeDescription.empty() ? false : true);
-        ov.ValueTypeDescription = valueTypeDescription;
-        m_optionsMap[argument] = ov;
-}
-
-// adds a value option to the parser (with a default value)
-template<typename T, typename D>
-void Options::AddValueOption(const std::string& argument, 
-                             const std::string& valueDescription, 
-                             const std::string& optionDescription, 
-                             const std::string& valueTypeDescription, 
-                             bool& foundArgument, 
-                             T& val, 
-                             OptionGroup* group, 
-                             D& defaultValue) 
-{
-        Option o;
-        o.Argument         = argument;
-        o.ValueDescription = valueDescription;
-        o.Description      = optionDescription;
-        o.DefaultValue     = defaultValue;
-        o.HasDefaultValue  = true;
-        group->Options.push_back(o);
-
-        OptionValue ov;
-        ov.pFoundArgument       = &foundArgument;
-        ov.pValue               = (void*)&val;
-        ov.VariantValue         = val;
-        ov.IsRequired           = (valueTypeDescription.empty() ? false : true);
-        ov.ValueTypeDescription = valueTypeDescription;
-        m_optionsMap[argument] = ov;
-}
-
-} // namespace BamTools
-
-#endif // BAMTOOLS_OPTIONS_H
diff --git a/bamtools/src/utils/bamtools_pileup_engine.cpp b/bamtools/src/utils/bamtools_pileup_engine.cpp
deleted file mode 100644
index c499b28..0000000
--- a/bamtools/src/utils/bamtools_pileup_engine.cpp
+++ /dev/null
@@ -1,346 +0,0 @@
-// ***************************************************************************
-// bamtools_pileup_engine.cpp (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 9 March 2012 (DB)
-// ---------------------------------------------------------------------------
-// Provides pileup at position functionality for various tools.
-// ***************************************************************************
-
-#include "utils/bamtools_pileup_engine.h"
-using namespace BamTools;
-
-#include <iostream>
-using namespace std;
-
-// ---------------------------------------------
-// PileupEnginePrivate implementation
-
-struct PileupEngine::PileupEnginePrivate {
-  
-    // data members
-    int CurrentId;
-    int CurrentPosition;
-    vector<BamAlignment> CurrentAlignments;
-    PileupPosition CurrentPileupData;
-    
-    bool IsFirstAlignment;
-    vector<PileupVisitor*> Visitors;
-  
-    // ctor & dtor
-    PileupEnginePrivate(void)
-        : CurrentId(-1)
-        , CurrentPosition(-1)
-        , IsFirstAlignment(true)
-    { }
-    ~PileupEnginePrivate(void) { }
-    
-    // 'public' methods
-    bool AddAlignment(const BamAlignment& al);
-    void Flush(void);
-    
-    // internal methods
-    private:
-        void ApplyVisitors(void);
-        void ClearOldData(void);
-        void CreatePileupData(void);
-        void ParseAlignmentCigar(const BamAlignment& al);
-};
-
-bool PileupEngine::PileupEnginePrivate::AddAlignment(const BamAlignment& al) {
-  
-    // if first time
-    if ( IsFirstAlignment ) {
-      
-        // set initial markers 
-        CurrentId       = al.RefID;
-        CurrentPosition = al.Position;
-        
-        // store first entry
-        CurrentAlignments.clear();
-        CurrentAlignments.push_back(al);
-        
-        // set flag & return
-        IsFirstAlignment = false;
-        return true;
-    }
-  
-    // if same reference
-    if ( al.RefID == CurrentId ) {
-      
-        // if same position, store and move on
-        if ( al.Position == CurrentPosition )
-            CurrentAlignments.push_back(al);
-        
-        // if less than CurrentPosition - sorting error => ABORT
-        else if ( al.Position < CurrentPosition ) {
-            cerr << "Pileup::Run() : Data not sorted correctly!" << endl;
-            return false;
-        }
-        
-        // else print pileup data until 'catching up' to CurrentPosition
-        else {
-            while ( al.Position > CurrentPosition ) {
-                ApplyVisitors();
-                ++CurrentPosition;
-            }
-            CurrentAlignments.push_back(al);
-        }
-    } 
-
-    // if reference ID less than CurrentId - sorting error => ABORT
-    else if ( al.RefID < CurrentId ) {
-        cerr << "Pileup::Run() : Data not sorted correctly!" << endl;
-        return false;
-    }
-
-    // else moved forward onto next reference
-    else {
-        
-        // print any remaining pileup data from previous reference
-        while ( !CurrentAlignments.empty() ) {
-            ApplyVisitors();
-            ++CurrentPosition;
-        }
-        
-        // store first entry on this new reference, update markers
-        CurrentAlignments.clear();
-        CurrentAlignments.push_back(al);
-        CurrentId = al.RefID;
-        CurrentPosition = al.Position;
-    }
-  
-    return true;
-}
-
-void PileupEngine::PileupEnginePrivate::ApplyVisitors(void) {
-  
-    // parse CIGAR data in BamAlignments to build up current pileup data
-    CreatePileupData();
-  
-    // apply all visitors to current alignment set
-    vector<PileupVisitor*>::const_iterator visitorIter = Visitors.begin();
-    vector<PileupVisitor*>::const_iterator visitorEnd  = Visitors.end();
-    for ( ; visitorIter != visitorEnd; ++visitorIter ) 
-        (*visitorIter)->Visit(CurrentPileupData);
-}
-
-void PileupEngine::PileupEnginePrivate::ClearOldData(void) {
- 
-    // remove any alignments that end before our CurrentPosition
-    // N.B. - BAM positions are 0-based, half-open. GetEndPosition() returns a 1-based position,
-    //        while our CurrentPosition is 0-based. For example, an alignment with 'endPosition' of
-    //        100 does not overlap a 'CurrentPosition' of 100, and should be discarded.
-
-    size_t i = 0;
-    size_t j = 0;
-    const size_t numAlignments = CurrentAlignments.size();
-    while ( i < numAlignments ) {
-
-        // skip over alignment if its (1-based) endPosition is <= to (0-based) CurrentPosition
-        // i.e. this entry will not be saved upon vector resize
-        const int endPosition = CurrentAlignments[i].GetEndPosition();
-        if ( endPosition <= CurrentPosition ) {
-            ++i;
-            continue;
-        }
-
-        // otherwise alignment ends after CurrentPosition
-        // move it towards vector beginning, at index j
-        if ( i != j )
-            CurrentAlignments[j] = CurrentAlignments[i];
-
-        // increment our indices
-        ++i;
-        ++j;
-    }
-
-    // 'squeeze' vector to size j, discarding all remaining alignments in the container
-    CurrentAlignments.resize(j);
-}
-
-void PileupEngine::PileupEnginePrivate::CreatePileupData(void) {
-  
-    // remove any non-overlapping alignments
-    ClearOldData();
-  
-    // set pileup refId, position to current markers
-    CurrentPileupData.RefId = CurrentId;
-    CurrentPileupData.Position = CurrentPosition;
-    CurrentPileupData.PileupAlignments.clear();
-    
-    // parse CIGAR data in remaining alignments 
-    vector<BamAlignment>::const_iterator alIter = CurrentAlignments.begin();
-    vector<BamAlignment>::const_iterator alEnd  = CurrentAlignments.end(); 
-    for ( ; alIter != alEnd; ++alIter )
-        ParseAlignmentCigar( (*alIter) );
-}
-
-void PileupEngine::PileupEnginePrivate::Flush(void) {
-    while ( !CurrentAlignments.empty() ) {
-        ApplyVisitors();
-        ++CurrentPosition;
-    }
-}
-
-void PileupEngine::PileupEnginePrivate::ParseAlignmentCigar(const BamAlignment& al) {
-  
-    // skip if unmapped
-    if ( !al.IsMapped() ) return;
-    
-    // intialize local variables
-    int  genomePosition      = al.Position;
-    int  positionInAlignment = 0;
-    bool isNewReadSegment    = true;
-    bool saveAlignment       = true;    
-    PileupAlignment pileupAlignment(al);
-    
-    // iterate over CIGAR operations
-    const int numCigarOps = (const int)al.CigarData.size();
-    for (int i = 0; i < numCigarOps; ++i ) { 
-        const CigarOp& op = al.CigarData.at(i);
-      
-        // if op is MATCH
-        if ( op.Type == 'M' ) {
-          
-            // if match op overlaps current position
-            if ( genomePosition + (int)op.Length > CurrentPosition ) {
-              
-                // set pileup data
-                pileupAlignment.IsCurrentDeletion   = false;
-                pileupAlignment.IsNextDeletion      = false;
-                pileupAlignment.IsNextInsertion     = false;
-                pileupAlignment.PositionInAlignment = positionInAlignment + (CurrentPosition - genomePosition);
-                
-                // check for beginning of read segment
-                if ( genomePosition == CurrentPosition && isNewReadSegment ) 
-                    pileupAlignment.IsSegmentBegin = true;
-                
-                // if we're at the end of a match operation
-                if ( genomePosition + (int)op.Length - 1 == CurrentPosition ) {
-                    
-                    // if not last operation
-                    if ( i < numCigarOps - 1 ) {
-                        
-                        // check next CIGAR op
-                        const CigarOp& nextOp = al.CigarData.at(i+1);
-                        
-                        // if next CIGAR op is DELETION
-                        if ( nextOp.Type == 'D') {
-                            pileupAlignment.IsNextDeletion = true;
-                            pileupAlignment.DeletionLength = nextOp.Length;
-                        }
-                        
-                        // if next CIGAR op is INSERTION
-                        else if ( nextOp.Type == 'I' ) {
-                            pileupAlignment.IsNextInsertion = true;
-                            pileupAlignment.InsertionLength = nextOp.Length;
-                        }
-                            
-                        // if next CIGAR op is either DELETION or INSERTION
-                        if ( nextOp.Type == 'D' || nextOp.Type == 'I' ) {
-
-                            // if there is a CIGAR op after the DEL/INS
-                            if ( i < numCigarOps - 2 ) {
-                                const CigarOp& nextNextOp = al.CigarData.at(i+2);
-                                
-                                // if next CIGAR op is clipping or ref_skip
-                                if ( nextNextOp.Type == 'S' || 
-                                     nextNextOp.Type == 'N' ||
-                                     nextNextOp.Type == 'H' )
-                                    pileupAlignment.IsSegmentEnd = true;
-                            } 
-                            else {
-                                pileupAlignment.IsSegmentEnd = true;
-                                
-                                // if next CIGAR op is clipping or ref_skip
-                                if ( nextOp.Type == 'S' || 
-                                     nextOp.Type == 'N' ||
-                                     nextOp.Type == 'H' )
-                                    pileupAlignment.IsSegmentEnd = true;
-                            }
-                        }
-                        
-                        // otherwise
-                        else { 
-                        
-                            // if next CIGAR op is clipping or ref_skip
-                            if ( nextOp.Type == 'S' || 
-                                 nextOp.Type == 'N' ||
-                                 nextOp.Type == 'H' )
-                                pileupAlignment.IsSegmentEnd = true;
-                        }
-                    }
-                    
-                    // else this is last operation
-                    else pileupAlignment.IsSegmentEnd = true;
-                }
-            }
-          
-            // increment markers
-            genomePosition      += op.Length;
-            positionInAlignment += op.Length;
-        } 
-        
-        // if op is DELETION
-        else if ( op.Type == 'D' ) {
-          
-            // if deletion op overlaps current position
-            if ( genomePosition + (int)op.Length > CurrentPosition ) {
-              
-                // set pileup data
-                pileupAlignment.IsCurrentDeletion   = true;
-                pileupAlignment.IsNextDeletion      = false;
-                pileupAlignment.IsNextInsertion     = true;
-                pileupAlignment.PositionInAlignment = positionInAlignment + (CurrentPosition - genomePosition);
-            }
-            
-            // increment marker
-            genomePosition += op.Length;
-        }
-
-        // if op is REF_SKIP
-        else if ( op.Type == 'N' ) {
-            genomePosition += op.Length;
-        }
-        
-        // if op is INSERTION or SOFT_CLIP
-        else if ( op.Type == 'I' || op.Type == 'S' ) {
-            positionInAlignment += op.Length;
-        }
-        
-        // checl for beginning of new read segment
-        if ( op.Type == 'N' ||
-             op.Type == 'S' ||
-             op.Type == 'H' )
-            isNewReadSegment = true;
-        else 
-            isNewReadSegment = false;
-      
-        // if we've moved beyond current position
-        if ( genomePosition > CurrentPosition ) {
-            if ( op.Type == 'N' ) saveAlignment = false; // ignore alignment if REF_SKIP
-            break;
-        }
-    }
-
-    // save pileup position if flag is true
-    if ( saveAlignment )
-        CurrentPileupData.PileupAlignments.push_back( pileupAlignment );
-}
-
-// ---------------------------------------------
-// PileupEngine implementation
-
-PileupEngine::PileupEngine(void)
-    : d( new PileupEnginePrivate )
-{ }
-
-PileupEngine::~PileupEngine(void) {
-    delete d;
-    d = 0;
-}
-
-bool PileupEngine::AddAlignment(const BamAlignment& al) { return d->AddAlignment(al); }
-void PileupEngine::AddVisitor(PileupVisitor* visitor) { d->Visitors.push_back(visitor); }
-void PileupEngine::Flush(void) { d->Flush(); }
diff --git a/bamtools/src/utils/bamtools_pileup_engine.h b/bamtools/src/utils/bamtools_pileup_engine.h
deleted file mode 100644
index eeca56c..0000000
--- a/bamtools/src/utils/bamtools_pileup_engine.h
+++ /dev/null
@@ -1,95 +0,0 @@
-// ***************************************************************************
-// bamtools_pileup_engine.h (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011
-// ---------------------------------------------------------------------------
-// Provides pileup at position functionality for various tools.
-// ***************************************************************************
-
-#ifndef BAMTOOLS_PILEUP_ENGINE_H
-#define BAMTOOLS_PILEUP_ENGINE_H
-
-#include "utils/utils_global.h"
-
-#include <api/BamAlignment.h>
-#include <vector>
-
-namespace BamTools {
-
-// contains auxiliary data about a single BamAlignment
-// at current position considered
-struct UTILS_EXPORT PileupAlignment {
-  
-    // data members
-    BamAlignment Alignment;
-    int32_t PositionInAlignment;
-    bool IsCurrentDeletion;
-    bool IsNextDeletion;
-    bool IsNextInsertion;
-    int DeletionLength;
-    int InsertionLength;
-    bool IsSegmentBegin;
-    bool IsSegmentEnd;
-    
-    // ctor
-    PileupAlignment(const BamAlignment& al)
-        : Alignment(al)
-        , PositionInAlignment(-1)
-        , IsCurrentDeletion(false)
-        , IsNextDeletion(false)
-        , IsNextInsertion(false)
-        , DeletionLength(0)
-        , InsertionLength(0)
-        , IsSegmentBegin(false)
-        , IsSegmentEnd(false)
-    { }
-};
-  
-// contains all data at a position
-struct UTILS_EXPORT PileupPosition {
-  
-    // data members
-    int RefId;
-    int Position;
-    std::vector<PileupAlignment> PileupAlignments;
-
-    // ctor
-    PileupPosition(const int& refId = 0,
-                   const int& position = 0, 
-                   const std::vector<PileupAlignment>& alignments = std::vector<PileupAlignment>())
-        : RefId(refId)
-        , Position(position)
-        , PileupAlignments(alignments)
-    { }
-};
-  
-class UTILS_EXPORT PileupVisitor {
-  
-    public:
-        PileupVisitor(void) { }
-        virtual ~PileupVisitor(void) { }
-  
-    public:
-        virtual void Visit(const PileupPosition& pileupData) =0;
-};
-
-class UTILS_EXPORT PileupEngine {
-  
-    public:
-        PileupEngine(void);
-        ~PileupEngine(void);
-        
-    public:
-        bool AddAlignment(const BamAlignment& al);
-        void AddVisitor(PileupVisitor* visitor);
-        void Flush(void);
-        
-    private:
-        struct PileupEnginePrivate;
-        PileupEnginePrivate* d;
-};
-
-} // namespace BamTools
-
-#endif // BAMTOOLS_PILEUP_ENGINE_H
diff --git a/bamtools/src/utils/bamtools_utilities.cpp b/bamtools/src/utils/bamtools_utilities.cpp
deleted file mode 100644
index c7c45ec..0000000
--- a/bamtools/src/utils/bamtools_utilities.cpp
+++ /dev/null
@@ -1,333 +0,0 @@
-// ***************************************************************************
-// bamtools_utilities.cpp (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 8 October 2011
-// ---------------------------------------------------------------------------
-// Provides general utilities used by BamTools sub-tools.
-// ***************************************************************************
-
-#include <api/BamMultiReader.h>
-#include <api/BamReader.h>
-#include <utils/bamtools_utilities.h>
-using namespace BamTools;
-
-#include <algorithm>
-#include <cstdlib>
-#include <cstring>
-#include <fstream>
-#include <iostream>
-#include <sstream>
-using namespace std;
-
-namespace BamTools {
-  
-const char REVCOMP_LOOKUP[] = {'T',  0,  'G', 'H',
-                                0,   0,  'C', 'D',
-                                0,   0,   0,   0,
-                               'K', 'N',  0,   0,
-                                0,  'Y', 'W', 'A',
-                               'A', 'B', 'S', 'X',
-                               'R',  0 };
-  
-} // namespace BamTools 
-  
-// returns true if 'source' contains 'pattern'
-bool Utilities::Contains(const string& source, const string& pattern) {
-    return ( source.find(pattern) != string::npos );
-}
-
-// returns true if 'source' contains 'c'
-bool Utilities::Contains(const std::string &source, const char c) {
-    return ( source.find(c) != string::npos );
-}
-
-// returns true if 'source' ends with 'pattern'
-bool Utilities::EndsWith(const string& source, const string& pattern) {
-    return ( source.find(pattern) == (source.length() - pattern.length()) );
-}
-
-// returns true if 'source' ends with 'c'
-bool Utilities::EndsWith(const std::string& source, const char c) {
-    return ( source.find(c) == (source.length() - 1) );
-}
-
-// check if a file exists
-bool Utilities::FileExists(const string& filename) {
-    ifstream f(filename.c_str(), ifstream::in);
-    return !f.fail();
-}
-
-// Parses a region string, does validation (valid ID's, positions), stores in Region struct
-// Returns success (true/false)
-bool Utilities::ParseRegionString(const string& regionString,
-                                  const BamReader& reader,
-                                  BamRegion& region)
-{
-    // -------------------------------
-    // parse region string
-  
-    // check first for empty string
-    if ( regionString.empty() ) 
-        return false;   
-    
-    // non-empty string, look for a colom
-    size_t foundFirstColon = regionString.find(':');
-    
-    // store chrom strings, and numeric positions
-    string startChrom;
-    string stopChrom;
-    int startPos;
-    int stopPos;
-    
-    // no colon found
-    // going to use entire contents of requested chromosome 
-    // just store entire region string as startChrom name
-    // use BamReader methods to check if its valid for current BAM file
-    if ( foundFirstColon == string::npos ) {
-        startChrom = regionString;
-        startPos   = 0;
-        stopChrom  = regionString;
-        stopPos    = 0;
-    }
-    
-    // colon found, so we at least have some sort of startPos requested
-    else {
-      
-        // store start chrom from beginning to first colon
-        startChrom = regionString.substr(0,foundFirstColon);
-        
-        // look for ".." after the colon
-        size_t foundRangeDots = regionString.find("..", foundFirstColon+1);
-        
-        // no dots found
-        // so we have a startPos but no range
-        // store contents before colon as startChrom, after as startPos
-        if ( foundRangeDots == string::npos ) {
-            startPos   = atoi( regionString.substr(foundFirstColon+1).c_str() ); 
-            stopChrom  = startChrom;
-            stopPos    = -1;
-        } 
-        
-        // ".." found, so we have some sort of range selected
-        else {
-          
-            // store startPos between first colon and range dots ".."
-            startPos = atoi( regionString.substr(foundFirstColon+1, foundRangeDots-foundFirstColon-1).c_str() );
-          
-            // look for second colon
-            size_t foundSecondColon = regionString.find(':', foundRangeDots+1);
-            
-            // no second colon found
-            // so we have a "standard" chrom:start..stop input format (on single chrom)
-            if ( foundSecondColon == string::npos ) {
-                stopChrom  = startChrom;
-                stopPos    = atoi( regionString.substr(foundRangeDots+2).c_str() );
-            }
-            
-            // second colon found
-            // so we have a range requested across 2 chrom's
-            else {
-                stopChrom  = regionString.substr(foundRangeDots+2, foundSecondColon-(foundRangeDots+2));
-                stopPos    = atoi( regionString.substr(foundSecondColon+1).c_str() );
-            }
-        }
-    }
-
-    // -------------------------------
-    // validate reference IDs & genomic positions
-    
-    const RefVector references = reader.GetReferenceData();
-    
-    // if startRefID not found, return false
-    int startRefID = reader.GetReferenceID(startChrom);
-    if ( startRefID == -1 ) return false;
-    
-    // startPos cannot be greater than or equal to reference length
-    const RefData& startReference = references.at(startRefID);
-    if ( startPos >= startReference.RefLength ) return false;
-    
-    // if stopRefID not found, return false
-    int stopRefID = reader.GetReferenceID(stopChrom);
-    if ( stopRefID == -1 ) return false;
-    
-    // stopPosition cannot be larger than reference length
-    const RefData& stopReference = references.at(stopRefID);
-    if ( stopPos > stopReference.RefLength ) return false;
-    
-    // if no stopPosition specified, set to reference end
-    if ( stopPos == -1 ) stopPos = stopReference.RefLength;  
-    
-    // -------------------------------
-    // set up Region struct & return
-    
-    region.LeftRefID     = startRefID;
-    region.LeftPosition  = startPos;
-    region.RightRefID    = stopRefID;;
-    region.RightPosition = stopPos;
-    return true;
-}
-
-// Same as ParseRegionString() above, but accepts a BamMultiReader
-bool Utilities::ParseRegionString(const string& regionString,
-                                  const BamMultiReader& reader,
-                                  BamRegion& region)
-{
-    // -------------------------------
-    // parse region string
-  
-    // check first for empty string
-    if ( regionString.empty() ) 
-        return false;   
-    
-    // non-empty string, look for a colom
-    size_t foundFirstColon = regionString.find(':');
-    
-    // store chrom strings, and numeric positions
-    string startChrom;
-    string stopChrom;
-    int startPos;
-    int stopPos;
-    
-    // no colon found
-    // going to use entire contents of requested chromosome 
-    // just store entire region string as startChrom name
-    // use BamReader methods to check if its valid for current BAM file
-    if ( foundFirstColon == string::npos ) {
-        startChrom = regionString;
-        startPos   = 0;
-        stopChrom  = regionString;
-        stopPos    = -1;
-    }
-    
-    // colon found, so we at least have some sort of startPos requested
-    else {
-      
-        // store start chrom from beginning to first colon
-        startChrom = regionString.substr(0,foundFirstColon);
-        
-        // look for ".." after the colon
-        size_t foundRangeDots = regionString.find("..", foundFirstColon+1);
-        
-        // no dots found
-        // so we have a startPos but no range
-        // store contents before colon as startChrom, after as startPos
-        if ( foundRangeDots == string::npos ) {
-            startPos   = atoi( regionString.substr(foundFirstColon+1).c_str() ); 
-            stopChrom  = startChrom;
-            stopPos    = -1;
-        } 
-        
-        // ".." found, so we have some sort of range selected
-        else {
-          
-            // store startPos between first colon and range dots ".."
-            startPos = atoi( regionString.substr(foundFirstColon+1, foundRangeDots-foundFirstColon-1).c_str() );
-          
-            // look for second colon
-            size_t foundSecondColon = regionString.find(':', foundRangeDots+1);
-            
-            // no second colon found
-            // so we have a "standard" chrom:start..stop input format (on single chrom)
-            if ( foundSecondColon == string::npos ) {
-                stopChrom  = startChrom;
-                stopPos    = atoi( regionString.substr(foundRangeDots+2).c_str() );
-            }
-            
-            // second colon found
-            // so we have a range requested across 2 chrom's
-            else {
-                stopChrom  = regionString.substr(foundRangeDots+2, foundSecondColon-(foundRangeDots+2));
-                stopPos    = atoi( regionString.substr(foundSecondColon+1).c_str() );
-            }
-        }
-    }
-
-    // -------------------------------
-    // validate reference IDs & genomic positions
-
-    const RefVector references = reader.GetReferenceData();
-
-    // if startRefID not found, return false
-    int startRefID = reader.GetReferenceID(startChrom);
-    if ( startRefID == -1 ) return false;
-
-    // startPos cannot be greater than or equal to reference length
-    const RefData& startReference = references.at(startRefID);
-    if ( startPos >= startReference.RefLength ) return false;
-
-    // if stopRefID not found, return false
-    int stopRefID = reader.GetReferenceID(stopChrom);
-    if ( stopRefID == -1 ) return false;
-
-    // stopPosition cannot be larger than reference length
-    const RefData& stopReference = references.at(stopRefID);
-    if ( stopPos > stopReference.RefLength ) return false;
-
-    // if no stopPosition specified, set to reference end
-    if ( stopPos == -1 ) stopPos = stopReference.RefLength;
-
-    // -------------------------------
-    // set up Region struct & return
-
-    region.LeftRefID     = startRefID;
-    region.LeftPosition  = startPos;
-    region.RightRefID    = stopRefID;;
-    region.RightPosition = stopPos;
-    return true;
-}
-
-void Utilities::Reverse(string& sequence) {
-    reverse(sequence.begin(), sequence.end());
-}
-
-void Utilities::ReverseComplement(string& sequence) {
-    
-    // do complement, in-place
-    size_t seqLength = sequence.length();
-    for ( size_t i = 0; i < seqLength; ++i )
-        sequence.replace(i, 1, 1, REVCOMP_LOOKUP[(int)sequence.at(i) - 65]);
-    
-    // reverse it
-    Reverse(sequence);
-}
-
-vector<string> Utilities::Split(const string& source, const char delim) {
-
-    stringstream ss(source);
-    string field;
-    vector<string> fields;
-
-    while ( getline(ss, field, delim) )
-        fields.push_back(field);
-    return fields;
-}
-
-vector<string> Utilities::Split(const string& source, const string& delims) {
-
-    vector<string> fields;
-
-    char* tok;
-    char* cchars = new char[source.size()+1];
-    char* cstr = &cchars[0];
-    strcpy(cstr, source.c_str());
-    tok = strtok(cstr, delims.c_str());
-    while (tok != NULL) {
-        fields.push_back(tok);
-        tok = strtok(NULL, delims.c_str());
-    }
-
-    delete[] cchars;
-
-    return fields;
-}
-
-// returns true if 'source' starts with 'pattern'
-bool Utilities::StartsWith(const string& source, const string& pattern) {
-    return ( source.find(pattern) == 0 );
-}
-
-// returns true if 'source' starts with 'c'
-bool Utilities::StartsWith(const std::string &source, const char c) {
-    return ( source.find(c) == 0 );
-}
diff --git a/bamtools/src/utils/bamtools_utilities.h b/bamtools/src/utils/bamtools_utilities.h
deleted file mode 100644
index 9c1f7c9..0000000
--- a/bamtools/src/utils/bamtools_utilities.h
+++ /dev/null
@@ -1,65 +0,0 @@
-// ***************************************************************************
-// bamtools_utilities.h (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 7 October 2011
-// ---------------------------------------------------------------------------
-// Provides general utilities used by BamTools sub-tools.
-// ***************************************************************************
-
-#ifndef BAMTOOLS_UTILITIES_H
-#define BAMTOOLS_UTILITIES_H
-
-#include <api/BamAux.h>
-#include <utils/utils_global.h>
-#include <string>
-#include <vector>
-
-#define BAMTOOLS_ASSERT_UNREACHABLE BT_ASSERT_UNREACHABLE
-#define BAMTOOLS_ASSERT_MESSAGE( condition, message ) BT_ASSERT_X( condition, message )
-
-namespace BamTools {
-
-class BamReader;
-class BamMultiReader;
-
-class UTILS_EXPORT Utilities {
-  
-    public: 
-        // returns true if 'source' contains 'pattern' or 'c'
-        static bool Contains(const std::string& source, const std::string& pattern);
-        static bool Contains(const std::string& source, const char c);
-
-        // returns true if 'source' ends with 'pattern' or 'c'
-        static bool EndsWith(const std::string& source, const std::string& pattern);
-        static bool EndsWith(const std::string& source, const char c);
-
-        // check if a file exists
-        static bool FileExists(const std::string& fname);
-        
-        // Parses a region string, uses reader to do validation (valid ID's, positions), stores in Region struct
-        // Returns success (true/false)
-        static bool ParseRegionString(const std::string& regionString,
-                                      const BamReader& reader,
-                                      BamRegion& region);
-        // Same as above, but accepts a BamMultiReader
-        static bool ParseRegionString(const std::string& regionString,
-                                      const BamMultiReader& reader,
-                                      BamRegion& region);
-
-        // sequence utilities
-        static void Reverse(std::string& sequence);
-        static void ReverseComplement(std::string& sequence);
-
-        // split string on delimiter character (or string of allowed delimiters)
-        static std::vector<std::string> Split(const std::string& source, const char delim);
-        static std::vector<std::string> Split(const std::string& source, const std::string& delims);
-
-        // returns true if 'source' starts with 'pattern' or 'c'
-        static bool StartsWith(const std::string& source, const std::string& pattern);
-        static bool StartsWith(const std::string &source, const char c);
-};
-
-} // namespace BamTools
-  
-#endif // BAMTOOLS_UTILITIES_H
diff --git a/bamtools/src/utils/bamtools_variant.h b/bamtools/src/utils/bamtools_variant.h
deleted file mode 100644
index 4c477fb..0000000
--- a/bamtools/src/utils/bamtools_variant.h
+++ /dev/null
@@ -1,128 +0,0 @@
-// ***************************************************************************
-// bamtools_variant.h (c) 2010 Derek Barnett, Erik Garrison
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 10 October 2011
-// ---------------------------------------------------------------------------
-// Provides a template-based variant type
-// ---------------------------------------------------------------------------
-// Modified from:
-// variant_t - An Improved Variant Type Based on Member Templates
-// (c) 2000 Fernando Cacciola
-// Dr. Dobb's (http://www.ddj.com/cpp/184401293)
-//
-// * Modified to be in BamTools namespace, otherwise code is same. (DB)
-// ***************************************************************************
-
-#ifndef BAMTOOLS_VARIANT_H
-#define BAMTOOLS_VARIANT_H
-
-#include "utils/utils_global.h"
-#include <stdexcept>
-#include <string>
-#include <typeinfo>
-
-namespace BamTools {
-
-class UTILS_EXPORT Variant {
-  
-    public:
-        Variant(void) : data(NULL) { }
-        
-        Variant(const Variant& other) { 
-            if ( other.data != NULL ) 
-                other.data->AddRef();
-            data = other.data;
-        }
-
-        ~Variant(void) { 
-            if ( data != NULL ) 
-                data->Release();
-        }
-
-        // NOTE: This code takes care of self-assignment.
-        // DO NOT CHANGE THE ORDER of the statements.
-        Variant& operator= (const Variant& rhs) {
-            if ( rhs.data != NULL ) 
-                rhs.data->AddRef();
-            if ( data != NULL ) 
-                data->Release();
-            data = rhs.data;
-            return *this;
-        }
-
-        // This member template constructor allows you to
-        // instance a variant_t object with a value of any type.
-        template<typename T>
-        Variant(T v) 
-            : data(new Impl<T>(v)) 
-        { 
-            data->AddRef(); 
-        }
-
-        // This generic conversion operator let you retrieve
-        // the value held. To avoid template specialization conflicts,
-        // it returns an instance of type T, which will be a COPY
-        // of the value contained.
-        template<typename T> 
-        operator T() const { 
-            return CastFromBase<T>(data)->data;
-        }
-
-        // This forms returns a REFERENCE and not a COPY, which
-        // will be significant in some cases.
-        template<typename T> 
-        const T& get(void) const { 
-            return CastFromBase<T>(data)->data; 
-        }
-
-        template<typename T> 
-        bool is_type(void) const { 
-            return typeid(*data)==typeid(Impl<T>); 
-        }
-
-        template<typename T> 
-        bool is_type(T v) const { 
-            return typeid(*data)==typeid(v); 
-        }
-
-    private:
-        struct ImplBase {
-                
-            ImplBase() : refs(0) { }
-            virtual ~ImplBase(void) { }
-                
-            void AddRef(void) { ++refs; }
-            void Release(void) { 
-                --refs;
-                if ( refs == 0 ) delete this;
-            }
-                
-            size_t refs;
-        };
-
-        template<typename T>
-        struct Impl : ImplBase {
-            Impl(T v) : data(v) { }
-            ~Impl(void) { }
-            T data;
-        };
-
-        // The following method is static because it doesn't
-        // operate on variant_t instances.
-        template<typename T> 
-        static Impl<T>* CastFromBase(ImplBase* v) {
-            // This upcast will fail if T is other than the T used
-            // with the constructor of variant_t.
-            Impl<T>* p = dynamic_cast< Impl<T>* > (v);
-            if ( p == NULL ) 
-                throw std::invalid_argument( typeid(T).name() + std::string(" is not a valid type") );
-            return p;
-        }
-
-        ImplBase* data;
-};
-
-} // namespace BamTools
-
-#endif // BAMTOOLS_VARIANT_H
diff --git a/bamtools/src/utils/utils_global.h b/bamtools/src/utils/utils_global.h
deleted file mode 100644
index c793e8c..0000000
--- a/bamtools/src/utils/utils_global.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// ***************************************************************************
-// utils_global.h (c) 2010 Derek Barnett
-// Marth Lab, Department of Biology, Boston College
-// ---------------------------------------------------------------------------
-// Last modified: 19 November 2010 (DB)
-// ---------------------------------------------------------------------------
-// Provides macros for exporting & importing BamTools-utils library symbols
-// ***************************************************************************
-
-#ifndef UTILS_GLOBAL_H
-#define UTILS_GLOBAL_H
-
-#include "shared/bamtools_global.h"
-
-#ifdef BAMTOOLS_UTILS_LIBRARY
-#  define UTILS_EXPORT BAMTOOLS_LIBRARY_EXPORT
-#else
-#  define UTILS_EXPORT BAMTOOLS_LIBRARY_IMPORT
-#endif
-
-#endif // UTILS_GLOBAL_H
diff --git a/intervaltree/.gitignore b/intervaltree/.gitignore
deleted file mode 100644
index 7ffcca6..0000000
--- a/intervaltree/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-interval_tree_test
diff --git a/intervaltree/IntervalTree.h b/intervaltree/IntervalTree.h
deleted file mode 100644
index 52bceb5..0000000
--- a/intervaltree/IntervalTree.h
+++ /dev/null
@@ -1,215 +0,0 @@
-#ifndef __INTERVAL_TREE_H
-#define __INTERVAL_TREE_H
-
-#include <vector>
-#include <algorithm>
-#include <iostream>
-
-using namespace std;
-
-
-template <class T>
-class Interval {
-public:
-    int start;
-    int stop;
-    T value;
-    Interval(int s, int e, const T& v)
-        : start(s)
-        , stop(e)
-        , value(v)
-    { }
-};
-
-template <class T>
-int intervalStart(const Interval<T>& i) {
-    return i.start;
-}
-
-template <class T>
-int intervalStop(const Interval<T>& i) {
-    return i.stop;
-}
-
-template <class T>
-ostream& operator<<(ostream& out, Interval<T>& i) {
-    out << "Interval(" << i.start << ", " << i.stop << "): " << i.value;
-    return out;
-}
-
-template <class T>
-class IntervalStartSorter {
-public:
-    bool operator() (const Interval<T>& a, const Interval<T>& b) {
-        return a.start < b.start;
-    }
-};
-
-template <class T>
-class IntervalTree {
-
-public:
-    vector<Interval<T> > intervals;
-    IntervalTree<T>* left;
-    IntervalTree<T>* right;
-    int center;
-
-    IntervalTree<T>(void)
-        : left(NULL)
-        , right(NULL)
-        , center(0)
-    { }
-
-    IntervalTree<T>(const IntervalTree<T>& other) {
-        center = other.center;
-        intervals = other.intervals;
-        if (other.left) {
-            left = (IntervalTree<T>*) malloc(sizeof(IntervalTree<T>));
-            *left = *other.left;
-        } else {
-            left = NULL;
-        }
-        if (other.right) {
-            right = new IntervalTree<T>();
-            *right = *other.right;
-        } else {
-            right = NULL;
-        }
-    }
-
-    IntervalTree<T>& operator=(const IntervalTree<T>& other) {
-        center = other.center;
-        intervals = other.intervals;
-        if (other.left) {
-            left = new IntervalTree<T>();
-            *left = *other.left;
-        } else {
-            left = NULL;
-        }
-        if (other.right) {
-            right = new IntervalTree<T>();
-            *right = *other.right;
-        } else {
-            right = NULL;
-        }
-	return *this;
-    }
-
-    IntervalTree<T>(
-            vector<Interval<T> >& ivals,
-            unsigned int depth = 16,
-            unsigned int minbucket = 64,
-            int leftextent = 0,
-            int rightextent = 0,
-            unsigned int maxbucket = 512
-            )
-        : left(NULL)
-        , right(NULL)
-    {
-
-        --depth;
-        if (depth == 0 || (ivals.size() < minbucket && ivals.size() < maxbucket)) {
-            intervals = ivals;
-        } else {
-            if (leftextent == 0 && rightextent == 0) {
-                // sort intervals by start
-                IntervalStartSorter<T> intervalStartSorter;
-                sort(ivals.begin(), ivals.end(), intervalStartSorter);
-            }
-
-            int leftp = 0;
-            int rightp = 0;
-            int centerp = 0;
-            
-            if (leftextent || rightextent) {
-                leftp = leftextent;
-                rightp = rightextent;
-            } else {
-                leftp = ivals.front().start;
-                vector<int> stops;
-                stops.resize(ivals.size());
-                transform(ivals.begin(), ivals.end(), stops.begin(), intervalStop<T>);
-                rightp = *max_element(stops.begin(), stops.end());
-            }
-
-            //centerp = ( leftp + rightp ) / 2;
-            centerp = ivals.at(ivals.size() / 2).start;
-            center = centerp;
-
-            vector<Interval<T> > lefts;
-            vector<Interval<T> > rights;
-
-            for (typename vector<Interval<T> >::iterator i = ivals.begin(); i != ivals.end(); ++i) {
-                Interval<T>& interval = *i;
-                if (interval.stop < center) {
-                    lefts.push_back(interval);
-                } else if (interval.start > center) {
-                    rights.push_back(interval);
-                } else {
-                    intervals.push_back(interval);
-                }
-            }
-
-            if (!lefts.empty()) {
-                left = new IntervalTree<T>(lefts, depth, minbucket, leftp, centerp);
-            }
-            if (!rights.empty()) {
-                right = new IntervalTree<T>(rights, depth, minbucket, centerp, rightp);
-            }
-        }
-    }
-
-    void findOverlapping(int start, int stop, vector<Interval<T> >& overlapping) {
-        if (!intervals.empty() && ! (stop < intervals.front().start)) {
-            for (typename vector<Interval<T> >::iterator i = intervals.begin(); i != intervals.end(); ++i) {
-                Interval<T>& interval = *i;
-                if (interval.stop >= start && interval.start <= stop) {
-                    overlapping.push_back(interval);
-                }
-            }
-        }
-
-        if (left && start <= center) {
-            left->findOverlapping(start, stop, overlapping);
-        }
-
-        if (right && stop >= center) {
-            right->findOverlapping(start, stop, overlapping);
-        }
-
-    }
-
-    void findContained(int start, int stop, vector<Interval<T> >& contained) {
-        if (!intervals.empty() && ! (stop < intervals.front().start)) {
-            for (typename vector<Interval<T> >::iterator i = intervals.begin(); i != intervals.end(); ++i) {
-                Interval<T>& interval = *i;
-                if (interval.start >= start && interval.stop <= stop) {
-                    contained.push_back(interval);
-                }
-            }
-        }
-
-        if (left && start <= center) {
-            left->findContained(start, stop, contained);
-        }
-
-        if (right && stop >= center) {
-            right->findContained(start, stop, contained);
-        }
-
-    }
-
-    ~IntervalTree(void) {
-        // traverse the left and right
-        // delete them all the way down
-        if (left) {
-            delete left;
-        }
-        if (right) {
-            delete right;
-        }
-    }
-
-};
-
-#endif
diff --git a/intervaltree/LICENSE b/intervaltree/LICENSE
deleted file mode 100644
index be6b5b5..0000000
--- a/intervaltree/LICENSE
+++ /dev/null
@@ -1,19 +0,0 @@
-Copyright (c) 2011 Erik Garrison
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/intervaltree/Makefile b/intervaltree/Makefile
deleted file mode 100644
index 83de0a8..0000000
--- a/intervaltree/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-interval_tree_test: interval_tree_test.cpp IntervalTree.h
-	g++ -Wall interval_tree_test.cpp -o interval_tree_test -std=c++0x
-
-.PHONY: clean
-
-clean:
-	rm interval_tree_test
diff --git a/intervaltree/README b/intervaltree/README
deleted file mode 100644
index 28a1e6c..0000000
--- a/intervaltree/README
+++ /dev/null
@@ -1,41 +0,0 @@
-Overview:
-
-An interval tree can be used to efficiently find a set of numeric
-intervals overlapping or containing another interval.
-
-This library provides a basic implementation of an interval tree using
-C++ templates, allowing the insertion of arbitrary types into the
-tree.
-
-
-Usage:
-
-Add #include "IntervalTree.h" to the source files in which you will
-use the interval tree.
-
-To make an IntervalTree to contain objects of class T, use:
-
-   vector<Interval<T> > intervals;
-   T a, b, c;
-   intervals.push_back(Interval<T>(2, 10, a));
-   intervals.push_back(Interval<T>(3, 4, b));
-   intervals.push_back(Interval<T>(20, 100, c));
-   IntervalTree<T> tree;
-   tree = IntervalTree<T>(intervals);
-
-Now, it's possible to query the tree and obtain a set of intervals
-which are contained within the start and stop coordinates.
-
-    vector<Interval<T> > results;
-    tree.findContained(start, stop, results);
-    cout << "found " << results.size()
-         << " overlapping intervals" << endl;
-
-The function IntervalTree::findOverlapping provides a method to find
-all those intervals which are contained or partially overlap the
-interval (start, stop).
-
-
-Author: Erik Garrison <erik.garrison at gmail.com>
-
-License: MIT
diff --git a/intervaltree/interval_tree_test.cpp b/intervaltree/interval_tree_test.cpp
deleted file mode 100644
index d600677..0000000
--- a/intervaltree/interval_tree_test.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-#include <iostream>
-#include <thread>
-#include <chrono>
-#include <random>
-#include <time.h>
-#include <assert.h>
-#include "IntervalTree.h"
-
-using namespace std;
-
-int randInt(int floor, int ceiling) {
-    int range = ceiling - floor;
-    return floor + range * ((double) rand() / (double) (RAND_MAX + 1.0));
-}
-
-template<class T>
-Interval<T> randomInterval(int maxStart, int maxLength, int maxStop, const T& value) {
-    int start = randInt(0, maxStart);
-    int stop = min(randInt(start, start + maxLength), maxStop);
-    return Interval<T>(start, stop, value);
-}
-
-int main() {
-
-    srand((unsigned)time(NULL));
-
-    vector<Interval<bool> > intervals;
-    vector<Interval<bool> > queries;
-
-    // generate a test set of target intervals
-    for (int i = 0; i < 10000; ++i) {
-        intervals.push_back(randomInterval(100000, 1000, 100000 + 1, true));
-    }
-    // and queries
-    for (int i = 0; i < 5000; ++i) {
-        queries.push_back(randomInterval(100000, 1000, 100000 + 1, true));
-    }
-
-    typedef chrono::high_resolution_clock Clock;
-    typedef chrono::milliseconds milliseconds;
-
-    // using brute-force search
-    vector<int> bruteforcecounts;
-    Clock::time_point t0 = Clock::now();
-    for (vector<Interval<bool> >::iterator q = queries.begin(); q != queries.end(); ++q) {
-        vector<Interval<bool> > results;
-        for (vector<Interval<bool> >::iterator i = intervals.begin(); i != intervals.end(); ++i) {
-            if (i->start >= q->start && i->stop <= q->stop) {
-                results.push_back(*i);
-            }
-        }
-        bruteforcecounts.push_back(results.size());
-    }
-    Clock::time_point t1 = Clock::now();
-    milliseconds ms = chrono::duration_cast<milliseconds>(t1 - t0);
-    cout << "brute force:\t" << ms.count() << "ms" << endl;
-
-    // using the interval tree
-    //IntervalTree<bool> tree(intervals);
-    IntervalTree<bool> tree;
-    tree = IntervalTree<bool>(intervals);
-    vector<int> treecounts;
-    t0 = Clock::now();
-    for (vector<Interval<bool> >::iterator q = queries.begin(); q != queries.end(); ++q) {
-        vector<Interval<bool> > results;
-        tree.findContained(q->start, q->stop, results);
-        treecounts.push_back(results.size());
-    }
-    t1 = Clock::now();
-    ms = std::chrono::duration_cast<milliseconds>(t1 - t0);
-    cout << "interval tree:\t" << ms.count() << "ms" << endl;
-
-    // check that the same number of results are returned
-    vector<int>::iterator b = bruteforcecounts.begin();
-    for (vector<int>::iterator t = treecounts.begin(); t != treecounts.end(); ++t, ++b) {
-        assert(*b == *t);
-    }
-
-    return 0;
-}
-
diff --git a/src/Allele.cpp b/src/Allele.cpp
index 94c21d7..b4a7a97 100644
--- a/src/Allele.cpp
+++ b/src/Allele.cpp
@@ -422,7 +422,8 @@ ostream &operator<<(ostream &out, Allele &allele) {
             //<< ":" << allele.referenceSequence
             << ":" << allele.repeatRightBoundary
             << ":" << allele.cigar
-            << ":" << allele.quality;
+            << ":" << allele.lnmapQuality
+            << ":" << allele.lnquality;
         out.precision(prec);
     } else {
         out << allele.typeStr() 
diff --git a/src/AlleleParser.cpp b/src/AlleleParser.cpp
index a301dac..3d9b6dd 100644
--- a/src/AlleleParser.cpp
+++ b/src/AlleleParser.cpp
@@ -1118,6 +1118,9 @@ void AlleleParser::updateHaplotypeBasisAlleles(long int pos, int referenceLength
                 }
 
             }
+        } else {
+            ERROR("Could not set haplotype-basis VCF file to target region");
+            exit(1);
         }
         // set the rightmost haplotype position to trigger the next update
         rightmostHaplotypeBasisAllelePosition = pos + referenceLength + CACHED_BASIS_HAPLOTYPE_WINDOW;
diff --git a/src/Ewens.cpp b/src/Ewens.cpp
index 499f2dc..7616bd2 100644
--- a/src/Ewens.cpp
+++ b/src/Ewens.cpp
@@ -10,7 +10,7 @@ long double alleleFrequencyProbability(const map<int, int>& alleleFrequencyCount
         int frequency = f->first;
         int count = f->second;
         M += frequency * count;
-        p *= (double) pow((double) theta, (double) count) / (double) pow((double) frequency, (double) count) * factorial(count);
+        p *= (double) pow((double) theta, (double) count) / ((double) pow((double) frequency, (double) count) * factorial(count));
     }
 
     long double thetaH = 1;
@@ -39,7 +39,7 @@ long double __alleleFrequencyProbabilityln(const map<int, int>& alleleFrequencyC
         int frequency = f->first;
         int count = f->second;
         M += frequency * count;
-        p += powln(thetaln, count) - powln(log(frequency), count) + factorialln(count);
+        p += powln(thetaln, count) - (powln(log(frequency), count) + factorialln(count));
     }
 
     long double thetaH = 0;
diff --git a/src/version_git.h b/src/version_git.h
index ab1ff04..e9dbe54 100644
--- a/src/version_git.h
+++ b/src/version_git.h
@@ -1,4 +1,4 @@
 #ifndef VERSION_GIT_H
 #define VERSION_GIT_H
-#define VERSION_GIT "v0.9.10-11-g90b7027-dirty"
+#define VERSION_GIT "v0.9.13-5-ga830efd-dirty"
 #endif /* VERSION_GIT_H */
diff --git a/src/version_release.txt b/src/version_release.txt
index aa2e3b5..6fbaf06 100644
--- a/src/version_release.txt
+++ b/src/version_release.txt
@@ -1,5 +1,5 @@
-# This file was auto-generated by running "make setversion VERSION=v9.9.11"
-# on Thu Jan 16 18:29:42 EST 2014 .
+# This file was auto-generated by running "make setversion VERSION=v0.9.14"
+# on Mon Mar  3 09:43:15 EST 2014 .
 # Please do not edit or commit this file manually.
 #
-v9.9.11
+v0.9.14
diff --git a/vcflib/.gitignore b/vcflib/.gitignore
deleted file mode 100644
index 403542a..0000000
--- a/vcflib/.gitignore
+++ /dev/null
@@ -1,107 +0,0 @@
-*~
-.Rhistory
-.*swp
-.nfs*
-*.o
-BedReader.cpp
-Fasta.cpp
-Fasta.h
-Makefile.bad
-Multinomial.cpp
-Multinomial.h
-Pilot1
-Pilot2
-VCF.h
-VariantFilter.h
-b.vcf
-bugs/
-callgrind.out.7143
-f
-freebayes.chr20.integrated.nogeno.20101123.vcf
-glorder
-glorder.cpp
-glorder.py
-glorder.pyc
-gmon.out
-multimaptest.cpp
-pooled.sqlite
-pooled.sqlite3
-shunt
-shunt.c
-t.bed
-test.db
-test.vcf
-test.vcf.gz
-test.vcf.gz.tbi
-test/
-vcf2tsv
-vcfaddinfo
-vcfaddtag.cpp
-vcfafpath
-vcfallelicprimitives
-vcfaltcount
-vcfannotate
-vcfannotategenotypes
-vcfbreakmulti
-vcfcheck
-vcfclassify
-vcfcleancomplex
-vcfcommonsamples
-vcfcountalleles
-vcfcreatemulti
-vcfdistance
-vcfecho
-vcfentropy
-vcffilter
-vcffixup
-vcffixup.cpp.bak
-vcfflatten
-vcfgeno2haplo
-vcfgenotypecompare
-vcfgenotypes
-vcfglxgt
-vcfhaplotyecompare.cpp
-vcfhetcount
-vcfhethomratio
-vcfintersect
-vcfkeepfields
-vcfkeepgeno
-vcfkeepinfo
-vcfkeepsamples
-vcflength
-vcfmultiwaywwwindexfilter
-vcfnogeno
-vcfnogeno.cpp
-vcfnumalt
-vcfoverlay
-vcfparallel
-vcfparsealts
-vcfphylo.cpp
-vcfplotaltdiscrepancy.r.loess
-vcfplottstv.r
-vcfprimers
-vcfrandom
-vcfrandomsample
-vcfremap
-vcfremoveaberrantgenotypes
-vcfremovesamples
-vcfroc
-vcfsamplediff
-vcfsamplenames
-vcfsitesummarize
-vcfsom
-vcfsplit.cpp
-vcfstats
-vcfstreamsort
-vcfuniqalleles
-#vcfcountalleles.cpp#
-.vcfplotaltdiscrepancy.r.swo
-.vcfstats.cpp.swn
-.vcfstats.cpp.swo
-a.out
-vcfuniq
-vcfcat
-vcfevenregions
-vcfgenosummarize
-vcfgenosamplenames
-vcf2fasta
diff --git a/vcflib/.gitmodules b/vcflib/.gitmodules
deleted file mode 100644
index e3606fc..0000000
--- a/vcflib/.gitmodules
+++ /dev/null
@@ -1,21 +0,0 @@
-[submodule "tabixpp"]
-	path = tabixpp
-	url = git://github.com/ekg/tabixpp.git
-[submodule "smithwaterman"]
-	path = smithwaterman
-	url = git://github.com/ekg/smithwaterman.git
-[submodule "multichoose"]
-	path = multichoose
-	url = git://github.com/ekg/multichoose.git
-[submodule "fastahack"]
-	path = fastahack
-	url = git://github.com/ekg/fastahack.git
-[submodule "intervaltree"]
-	path = intervaltree
-	url = git://github.com/ekg/intervaltree.git
-[submodule "fsom"]
-	path = fsom
-	url = git://github.com/ekg/fsom.git
-[submodule "filevercmp"]
-	path = filevercmp
-	url = https://github.com/ekg/filevercmp.git
diff --git a/vcflib/LICENSE b/vcflib/LICENSE
deleted file mode 100644
index 0708937..0000000
--- a/vcflib/LICENSE
+++ /dev/null
@@ -1,19 +0,0 @@
-Copyright (c) 2012 Erik Garrison
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/vcflib/Makefile b/vcflib/Makefile
deleted file mode 100644
index 2c7ff6a..0000000
--- a/vcflib/Makefile
+++ /dev/null
@@ -1,154 +0,0 @@
-#OBJ_DIR = ./
-HEADERS = src/Variant.h \
-		  src/split.h \
-		  src/join.h
-SOURCES = src/Variant.cpp \
-		  src/split.cpp
-OBJECTS= $(SOURCES:.cpp=.o)
-
-# TODO
-#vcfstats.cpp
-
-BIN_SOURCES = src/vcfecho.cpp \
-			  src/vcfaltcount.cpp \
-			  src/vcfhetcount.cpp \
-			  src/vcfhethomratio.cpp \
-			  src/vcffilter.cpp \
-			  src/vcf2tsv.cpp \
-			  src/vcfgenotypes.cpp \
-			  src/vcfannotategenotypes.cpp \
-			  src/vcfcommonsamples.cpp \
-			  src/vcfremovesamples.cpp \
-			  src/vcfkeepsamples.cpp \
-			  src/vcfsamplenames.cpp \
-			  src/vcfgenotypecompare.cpp \
-			  src/vcffixup.cpp \
-			  src/vcfclassify.cpp \
-			  src/vcfsamplediff.cpp \
-			  src/vcfremoveaberrantgenotypes.cpp \
-			  src/vcfrandom.cpp \
-			  src/vcfparsealts.cpp \
-			  src/vcfstats.cpp \
-			  src/vcfflatten.cpp \
-			  src/vcfprimers.cpp \
-			  src/vcfnumalt.cpp \
-			  src/vcfcleancomplex.cpp \
-			  src/vcfintersect.cpp \
-			  src/vcfannotate.cpp \
-			  src/vcfallelicprimitives.cpp \
-			  src/vcfoverlay.cpp \
-			  src/vcfaddinfo.cpp \
-			  src/vcfkeepinfo.cpp \
-			  src/vcfkeepgeno.cpp \
-			  src/vcfafpath.cpp \
-			  src/vcfcountalleles.cpp \
-			  src/vcflength.cpp \
-			  src/vcfdistance.cpp \
-			  src/vcfrandomsample.cpp \
-			  src/vcfentropy.cpp \
-			  src/vcfglxgt.cpp \
-			  src/vcfroc.cpp \
-			  src/vcfsom.cpp \
-			  src/vcfcheck.cpp \
-			  src/vcfstreamsort.cpp \
-			  src/vcfuniq.cpp \
-			  src/vcfuniqalleles.cpp \
-			  src/vcfremap.cpp \
-			  src/vcf2fasta.cpp \
-			  src/vcfsitesummarize.cpp \
-			  src/vcfbreakmulti.cpp \
-			  src/vcfcreatemulti.cpp \
-			  src/vcfevenregions.cpp \
-			  src/vcfcat.cpp \
-			  src/vcfgenosummarize.cpp \
-			  src/vcfgenosamplenames.cpp \
-			  src/vcfgeno2haplo.cpp \
-			  src/vcfleftalign.cpp \
-			  src/vcfcombine.cpp \
-			  src/vcfgeno2alleles.cpp \
-
-#BINS = $(BIN_SOURCES:.cpp=)
-BINS = $(addprefix bin/,$(notdir $(BIN_SOURCES:.cpp=)))
-SHORTBINS = $(notdir $(BIN_SOURCES:.cpp=))
-
-TABIX = tabixpp/tabix.o
-
-FASTAHACK = fastahack/Fasta.o
-
-SMITHWATERMAN = smithwaterman/SmithWatermanGotoh.o 
-
-REPEATS = smithwaterman/Repeats.o
-
-INDELALLELE = smithwaterman/IndelAllele.o
-
-DISORDER = smithwaterman/disorder.c
-
-LEFTALIGN = smithwaterman/LeftAlign.o
-
-FSOM = fsom/fsom.o
-
-FILEVERCMP = filevercmp/filevercmp.o
-
-INCLUDES = -I. -L. -Ltabixpp/ -ltabix -lz -lm
-
-all: $(OBJECTS) $(BINS)
-
-CXX = g++
-CXXFLAGS = -O3 -D_FILE_OFFSET_BITS=64
-#CXXFLAGS = -O2
-#CXXFLAGS = -pedantic -Wall -Wshadow -Wpointer-arith -Wcast-qual
-
-SSW = src/ssw.o src/ssw_cpp.o
-
-ssw.o: src/ssw.h
-ssw_cpp.o:src/ssw_cpp.h
-
-openmp:
-	$(MAKE) CXXFLAGS="$(CXXFLAGS) -fopenmp -D HAS_OPENMP"
-
-profiling:
-	$(MAKE) CXXFLAGS="$(CXXFLAGS) -g" all
-
-gprof:
-	$(MAKE) CXXFLAGS="$(CXXFLAGS) -pg" all
-
-$(OBJECTS): $(SOURCES) $(HEADERS) $(TABIX)
-	$(CXX) -c -o $@ src/$(*F).cpp $(INCLUDES) $(LDFLAGS) $(CXXFLAGS)
-
-$(TABIX):
-	cd tabixpp && $(MAKE)
-
-$(SMITHWATERMAN):
-	cd smithwaterman && $(MAKE)
-
-$(DISORDER): $(SMITHWATERMAN)
-
-$(REPEATS): $(SMITHWATERMAN)
-
-$(LEFTALIGN): $(SMITHWATERMAN)
-
-$(INDELALLELE): $(SMITHWATERMAN)
-
-$(FASTAHACK):
-	cd fastahack && $(MAKE)
-
-$(FSOM):
-	cd fsom && $(CXX) $(CXXFLAGS) -c fsom.c -lm
-
-$(FILEVERCMP):
-	cd filevercmp && make
-
-$(SHORTBINS):
-	$(MAKE) bin/$@
-
-$(BINS): $(BIN_SOURCES) $(OBJECTS) $(SMITHWATERMAN) $(FASTAHACK) $(DISORDER) $(LEFTALIGN) $(INDELALLELE) $(SSW) $(FSOM) $(FILEVERCMP)
-	$(CXX) $(OBJECTS) $(SMITHWATERMAN) $(REPEATS) $(DISORDER) $(LEFTALIGN) $(INDELALLELE) $(SSW) $(FASTAHACK) $(FSOM) $(FILEVERCMP) tabixpp/tabix.o tabixpp/bgzf.o src/$(notdir $@).cpp -o $@ $(INCLUDES) $(LDFLAGS) $(CXXFLAGS)
-
-clean:
-	rm -f $(BINS) $(OBJECTS)
-	rm -f ssw_cpp.o ssw.o
-	cd tabixpp && make clean
-	cd smithwaterman && make clean
-	cd fastahack && make clean
-
-.PHONY: clean all
diff --git a/vcflib/README.md b/vcflib/README.md
deleted file mode 100644
index b96d15d..0000000
--- a/vcflib/README.md
+++ /dev/null
@@ -1,639 +0,0 @@
-# vcflib
-### a C++ library for parsing and manipulating VCF files.
-
-#### author: Erik Garrison <erik.garrison at bc.edu>
-
-#### license: MIT
-
----
-
-## overview
-
-The [Variant Call Format (VCF)](http://www.1000genomes.org/wiki/Analysis/Variant%20Call%20Format/vcf-variant-call-format-version-41)
-is a flat-file, tab-delimited textual format
-intended to concisely describe reference-indexed variations between individuals. 
-VCF provides a common interchange format for the description of variation in individuals and populations of samples,
-and has become the _defacto_ standard reporting format for a wide array of genomic variant detectors.
-
-vcflib provides methods to manipulate and interpret sequence variation as it can be described by VCF.
-It is both:
-
- * an API for parsing and operating on records of genomic variation as it can be described by the VCF format,
- * and a collection of command-line utilities for executing complex manipulations on VCF files.
-
-The API itself provides a quick and extremely permissive method to read and write VCF files.
-Extensions and applications of the library provided in the included utilities (*.cpp) comprise the vast bulk of the library's utility for most users.
-
-## usage
-
-vcflib provides a variety of functions for VCF manipulation:
-
-### comparison
-
- * Generate **haplotype-aware intersections** ([vcfintersect](#vcfintersect) -i), **unions** (vcfintersect -u), and **complements** (vcfintersect -v -i).
- * **Overlay-merge** multiple VCF files together, using provided order as precedence ([vcfoverlay](#vcfoverlay)).
- * **Combine** multiple VCF files together, handling samples when alternate allele descriptions are identical ([vcfcombine](#vcfcombine)).
- * **Validate** the integrity and identity of the VCF by verifying that the VCF record's REF matches a given reference file ([vcfcheck](#vcfcheck)).
-
-### format conversion
-
- * Convert a VCF file into a per-allele or per-genotype **tab-separated (.tsv)** file ([vcf2tsv](#vcf2tsv)).
- * Store a VCF file in an **SQLite3** database (vcf2sqlite.py).
- * Make a **BED file** from the intervals in a VCF file (vcf2bed.py).
-
-### filtering and subsetting
-
- * **Filter** variants and genotypes using arbitrary expressions based on values in the INFO and sample fields ([vcffilter](#vcffilter)).
- * **Randomly sample** a subset of records from a VCF file, given a rate ([vcfrandomsample](#vcfrandomsample)).
- * **Select variants** of a certain type (vcfsnps, vcfbiallelic, vcfindels, vcfcomplex, etc.)
-
-### annotation
-
- * **Annotate** one VCF file with fields from the INFO column of another, based on position ([vcfaddinfo](#vcfaddinfo), [vcfintersect](#vcfintersect)).
- * Incorporate annotations or targets provided by a *BED* file ([vcfannotate](#vcfannotate), [vcfintersect](#vcfintersect)).
- * Examine **genotype correspondence** between two VCF files by annotating samples in one file with genotypes from another ([vcfannotategenotypes](#vcfannotategenotypes)).
- * Annotate variants with the **distance** to the nearest variant ([vcfdistance](#vcfdistance)).
- * Count the number of alternate alleles represented in samples at each variant record ([vcfaltcount](#vcfaltcount)).
- * **Subset INFO fields** to decrease file size and processing time ([vcfkeepinfo](#vcfkeepinfo)).
- * Lighten up VCF files by keeping only a **subset of per-sample information** ([vcfkeepgeno](#vcfkeepgeno)).
-
-### samples
-
- * Quickly obtain the **list of samples** in a given VCF file ([vcfsamplenames](#vcfsamplenames)).
- * **Remove samples** from a VCF file ([vcfkeepsamples](#vcfkeepsamples), [vcfremovesamples](#vcfremovesamples)).
-
-### ordering
-
- * **Sort variants** by genome coordinate ([vcfstreamsort](#vcfstreamsort)).
- * **Remove duplicate** variants in vcfstreamsort'ed files according to their REF and ALT fields ([vcfuniq](#vcfuniq)).
-
-### variant representation
-
- * **Break multiallelic** records into multiple records ([vcfbreakmulti](#vcfbreakmulti)), retaining allele-specific INFO fields.
- * **Combine overlapping biallelic** records into a single record ([vcfcreatemulti](#vcfcreatemulti)).
- * **Decompose complex variants** into a canonical SNP and indel representation ([vcfallelicprimitives](#vcfallelicprimitives)), generating phased genotypes for available samples.
- * **Reconstitute complex variants** provided a phased VCF with samples ([vcfgeno2haplo](#vcfgeno2haplo)).
- * **Left-align indel and complex variants** ([vcfleftalign](#vcfleftalign)).
-
-### genotype manipulation
-
- * **Set genotypes** in a VCF file provided genotype likelihoods in the GL field ([vcfglxgt](#vcfglxgt)).
- * Establish putative **somatic variants** using reported differences between germline and somatic samples ([vcfsamplediff](#vcfsamplediff)).
- * Remove samples for which the reported genotype (GT) and observation counts disagree (AO, RO) ([vcfremoveaberrantgenotypes](#vcfremoveaberrantgenotypes)).
-
-### interpretation and classification of variants
-
- * Obtain aggregate **statistics** about VCF files ([vcfstats](#vcfstats)).
- * Print the **receiver-operating characteristic (ROC)** of one VCF given a truth set ([vcfroc](#vcfroc)).
- * Annotate VCF records with the **Shannon entropy** of flanking sequence ([vcfentropy](#vcfentropy)).
- * Calculate the heterozygosity rate ([vcfhetcount](#vcfhetcount)).
- * Generate potential **primers** from VCF records ([vcfprimers](#vcfprimers)), to check for genome uniqueness.
- * Convert the numerical represenation of genotypes provided by the GT field to a **human-readable genotype format** ([vcfgenotypes](#vcfgenotypes)).
- * Observe how different alignment parameters, including context and entropy-dependent ones, influence **variant classification and interpretation** ([vcfremap](#vcfremap)).
- * **Classify variants** by annotations in the INFO field using a self-organizing map ([vcfsom](#vcfsom)); **re-estimate their quality** given known variants.
-
-
-A number of "helper" perl and python scripts (e.g. vcf2bed.py, vcfbiallelic) further extend functionality.
-
-In practice, users are encouraged to drive the utilities in the library in a streaming fashion, using pipes, to fully utilize resources on multi-core systems during interactive work.  Piping provides a convenient method to interface with other libraries (vcf-tools, BedTools, GATK, htslib, bcftools, freebayes) which interface via VCF files, allowing the composition of an immense variety of processing functions.
-
-## development
-
-See src/vcfecho.cpp for basic usage.  src/Variant.h and src/Variant.cpp describe methods available in the API.
-vcflib is incorporated into several projects, such as [freebayes](https://github.com/ekg/freebayes), which may provide a point of reference for prospective developers.
-Additionally, developers should be aware of that vcflib contains submodules (git repositories) comprising its dependencies (outside of lzib and a *nix environment).
-
-
-## installing
-
-vcflib includes submodules, so to obtain vcflib you have to use:
-
-    % git clone --recursive git://github.com/ekg/vcflib.git
-
-or
-
-    % git clone --recursive https://github.com/ekg/vcflib.git
-
-To build, use Make:
-
-    % cd vcflib
-    % make
-
-Executables are built into the ./bin directory in the repository.
-A number of shell, perl, python, and R scripts already reside there.
-This makes installation easy, as users can add vcflib/bin to their path, or copy the contained executables to a directory already in their path.
-
-
-## executables
-
-### vcf2tsv
-    
-    usage: vcf2tsv [-n null_string] [-g] [vcf file]
-    Converts stdin or given VCF file to tab-delimited format, using null string to replace empty values in the table.
-    Specifying -g will output one line per sample with genotype information.
-    
-### vcfaddinfo
-    
-    usage: vcfaddinfo <vcf file> <vcf file>
-    Adds info fields from the second file which are not present in the first vcf file.
-    
-    
-### vcfafpath
-
-Uses allele frequencies in the AF info column to estimate phylogeny at multiallelic sites.
-
-
-### vcfallelicprimitives
-    
-    usage: vcfallelicprimitives [options] [file]
-    
-    options:
-        -m, --use-mnps          Retain MNPs as separate events (default: false)
-        -t, --tag-parsed FLAG   Tag records which are split apart of a complex allele
-                                with this flag
-    
-    If multiple alleleic primitives (gaps or mismatches) are specified in
-    a single VCF record, split the record into multiple lines, but drop all
-    INFO fields.  "Pure" MNPs are split into multiple SNPs unless the -m
-    flag is provided.  Genotypes are phased where complex alleles have been
-    decomposed, provided genotypes in the input.
-
-    
-### vcfaltcount
-    
-Counts the number of alternate alleles in the record.
-    
-    
-### vcfannotate
-    
-    usage: vcfannotate [options] [<vcf file>]
-
-    options:
-        -b, --bed   use annotations provided by this BED file
-        -k, --key   use this INFO field key for the annotations
-        -d, --default  use this INFO field key for records without annotations
-
-    Intersect the records in the VCF file with targets provided in a BED file.
-    Intersections are done on the reference sequences in the VCF file.
-    If no VCF filename is specified on the command line (last argument) the VCF
-    read from stdin.
-
-    
-### vcfannotategenotypes
-    
-    usage: vcfannotategenotypes <annotation-tag> <vcf file> <vcf file>
-
-    annotates genotypes in the first file with genotypes in the second adding the
-    genotype as another flag to each sample filed in the first file.
-    annotation-tag is the name of the sample flag which is added to store the
-    annotation.  also adds a 'has\_variant' flag for sites where the second file has
-    a variant.
-    
-    
-### vcfbreakmulti
-    
-    usage: vcfbreakmulti [options] [file]
-    
-    If multiple alleles are specified in a single record, break the record into
-    multiple lines, preserving allele-specific INFO fields.
-    
-    
-### vcfcheck
-    
-    usage: vcfcheck [options] <vcf file>
-    
-    options: -f, --fasta-reference  FASTA reference file to use to obtain
-                                    primer sequences
-    
-    Verifies that the VCF REF field matches the reference as described.
-    
-    
-    
-### vcfcleancomplex
-    
-Removes reference-matching sequence from complex alleles and adjusts records to
-reflect positional change.
-    
-    
-### vcfcombine
-
-Combines VCF files positionally, combining samples when sites and alleles are identical.
-Any number of VCF files may be combined.  The INFO field and other columns are taken from
-one of the files which are combined when records in multiple files match.  Alleles must
-have identical ordering to be combined into one record.  If they do not, multiple records
-will be emitted.
-
-
-### vcfcommonsamples
-    
-    usage: vcfcommonsamples <vcf file> <vcf file> outputs each record in the
-    first file, removing samples not present in the second
-    
-    
-### vcfcountalleles
-    
-Counts the total number of alleles in the input.
-
-
-### vcfcreatemulti
-
-If overlapping alleles are represented across multiple records, merge them into a single record.
-    
-### vcfdistance
-    
-Adds a value to each VCF record indicating the distance to the nearest variant
-in the file.
-    
-    
-### vcfentropy
-    
-    usage: vcfentropy [options] <vcf file>
-    
-    options: -f, --fasta-reference  FASTA reference file to use to obtain
-primer sequences -w, --window-size      Size of the window over which to
-calculate entropy
-    
-    Anotates the output VCF file with, for each record, EntropyLeft,
-EntropyRight, EntropyCenter, which are the entropies of the sequence of the
-given window size to the left, right, and center  of the record.
-    
-    
-    
-### vcffilter
-    
-    usage: vcffilter [options] <vcf file>
-
-    options:
-        -f, --info-filter     specifies a filter to apply to the info fields of records,
-                              removes alleles which do not pass the filter
-        -g, --genotype-filter specifies a filter to apply to the genotype fields of records
-        -s, --filter-sites    filter entire records, not just alleles
-        -t, --tag-pass        tag vcf records as positively filtered with this tag, print all records
-        -F, --tag-fail        tag vcf records as negatively filtered with this tag, print all records
-        -A, --append-filter   append the existing filter tag, don't just replace it
-        -a, --allele-tag      apply -t on a per-allele basis.  adds or sets the corresponding INFO field tag
-        -v, --invert          inverts the filter, e.g. grep -v
-        -o, --or              use logical OR instead of AND to combine filters
-        -r, --region          specify a region on which to target the filtering, requires a BGZF
-                              compressed file which has been indexed with tabix.  any number of
-                              regions may be specified.
-
-    Filter the specified vcf file using the set of filters.
-    Filters are specified in the form "<ID> <operator> <value>:
-     -f "DP > 10"  # for info fields
-     -g "GT = 1|1" # for genotype fields
-     -f "CpG"  # for 'flag' fields
-
-    Operators can be any of: =, !, <, >, |, &
-
-    Any number of filters may be specified.  They are combined via logical AND
-    unless --or is specified on the command line.  Obtain logical negation through
-    the use of parentheses, e.g. ! "( DP = 10 )"
-
-    For convenience, you can specify "QUAL" to refer to the quality of the site, even
-    though it does not appear in the INFO fields.
-
-    
-### vcffixup
-
-Count the allele frequencies across alleles present in each record in the 
-VCF file.  (Similar to vcftools --freq.)
-
-Uses genotypes from the VCF file to correct AC (alternate allele count), AF
-(alternate allele frequency), NS (number of called), in the VCF records.  For
-example:
-
-    % vcfkeepsamples file.vcf NA12878 | vcffixup - | vcffilter -f "AC > 0"
-
-Would downsample file.vcf to only NA12878, removing sites for which the sample
-was not called as polymorphic.
-    
-    
-### vcfflatten
-    
-    usage: vcfflatten [file]
-    
-    Removes multi-allelic sites by picking the most common alternate.  Requires
-    allele frequency specification 'AF' and use of 'G' and 'A' to specify the
-    fields which vary according to the Allele or Genotype. VCF file may be
-    specified on the command line or piped as stdin.
-    
-    
-### vcfgeno2haplo
-    
-    usage: vcfgeno2haplo [options] [<vcf file>]
-    
-    options:
-        -w, --window-size N       compare records up to this many bp away (default 30)
-        -r, --reference FILE      FASTA reference file, required with -i and -u
-    
-    Convert genotype-based phased alleles within --window-size into haplotype alleles.
-    
-    
-    
-### vcfgenotypecompare
-    
-    usage: vcfgenotypecompare <other-genotype-tag> <vcf file>
-    adds statistics to the INFO field of the vcf file describing the
-    amount of discrepancy between the genotypes (GT) in the vcf file and the
-    genotypes reported in the <other-genotype-tag>.  use this after
-    vcfannotategenotypes to get correspondence statistics for two vcfs.
-    
-    
-### vcfgenotypes
-    
-Converts numerical representation of genotypes (standard in GT field) to the
-alleles provided in the call's ALT/REF fields.
-    
-    
-### vcfglxgt
-    
-    usage: vcfglxgt [options] <vcf file>
-    
-    options:
-        -n, --fix-null-genotypes   only apply to null and partly-null genotypes
-    
-    Set genotypes using the maximum genotype likelihood for each sample.
-    
-    
-    
-### vcfhetcount
-    
-Count the number of heterozygotes in the input VCF.
-    
-    
-### vcfhethomratio
-    
-Provides the ratio between heterozygotes and homozygotes.
-
-    
-### vcfintersect
-    
-    usage: vcfintersect [options] [<vcf file>]
-    
-    options:
-        -b, --bed FILE            use intervals provided by this BED file
-        -v, --invert              invert the selection, printing only records which would
-                                    not have been printed out
-        -i, --intersect-vcf FILE  use this VCF for set intersection generation
-        -u, --union-vcf FILE      use this VCF for set union generation
-        -w, --window-size N       compare records up to this many bp away (default 30)
-        -r, --reference FILE      FASTA reference file, required with -i and -u
-        -l, --loci                output whole loci when one alternate allele matches
-        -m, --ref-match           intersect on the basis of record REF string
-        -t, --tag TAG             attach TAG to each record's info field if it would intersect
-        -V, --tag-value VAL       use this value to indicate that the allele is passing
-                                  '.' will be used otherwise.  default: 'PASS'
-        -M, --merge-from FROM-TAG
-        -T, --merge-to   TO-TAG   merge from FROM-TAG used in the -i file, setting TO-TAG
-                                  in the current file.
-    
-    For bed-vcf intersection, alleles which fall into the targets are retained.
-    
-    For vcf-vcf intersection and union, unify on equivalent alleles within window-size bp
-    as determined by haplotype comparison alleles.
-    
-    
-### vcfkeepgeno
-    
-    usage: vcfkeepgeno <vcf file> [FIELD1] [FIELD2] ...
-    outputs each record in the vcf file, removing FORMAT fields not listed
-    on the command line from sample specifications in the output
-    
-    
-### vcfkeepinfo
-    
-    usage: vcfkeepinfo <vcf file> [FIELD1] [FIELD2] ...
-    outputs each record in the vcf file, removing INFO fields not listed on the command line
-    
-    
-### vcfkeepsamples
-    
-    usage: vcfkeepsamples <vcf file> [SAMPLE1] [SAMPLE2] ...
-    outputs each record in the vcf file, removing samples not listed on the command line
-    
-    
-### vcfleftalign
-
-Left-align indels and complex variants in the input using a pairwise ref/alt
-alignment followed by a heuristic, iterative left realignment process that
-shifts indel representations to their absolute leftmost (5') extent.  This is
-the same procedure used in the internal left alignment in freebayes, and can be
-used when preparing VCF files for input to freebayes to decrease positional
-representation differences between the input alleles and left-realigned
-alignments.
-
-    usage: vcfleftalign [options] [file]
-
-    options:
-        -r, --reference FILE  Use this reference as a basis for realignment.
-        -w, --window N        Use a window of this many bp when left aligning (150).
-
-    Left-aligns variants in the specified input file or stdin.  Window size is determined
-    dynamically according to the entropy of the regions flanking the indel.  These must have
-    entropy > 1 bit/bp, or be shorter than ~5kb.
-
-
-### vcflength
-    
-Adds the length of the variant record (in [-/+]) relative to the reference allele to each VCF record.
-    
-    
-### vcfnumalt
-    
-Annotates the VCF stream on stdin with the number of alternate alleles at the site.
-    
-    
-### vcfoverlay
-    
-    usage: vcfoverlay [options] [<vcf file> ...]
-    
-    options:
-        -h, --help       this dialog
-    
-    Overlays records in the input vcf files in the order in which they appear.
-    
-    
-### vcfparsealts
-    
-Demonstration of alternate allele parsing method.  This method uses pairwise
-alignment of REF and ALTs to determine component allelic primitives for each
-alternate allele.
-
-Use `vcfallelicprimitives` to decompose records while preserving format.
-    
-    
-### vcfprimers
-    
-    usage: vcfprimers [options] <vcf file>
-    
-    options:
-        -f, --fasta-reference  FASTA reference file to use to obtain primer sequences
-        -l, --primer-length    The length of the primer sequences on each side of the variant
-    
-    For each VCF record, extract the flanking sequences, and write them to stdout as FASTA
-    records suitable for alignment.  This tool is intended for use in designing validation
-    experiments.  Primers extracted which would flank all of the alleles at multi-allelic
-    sites.  The name of the FASTA "reads" indicates the VCF record which they apply to.
-    The form is >CHROM_POS_LEFT for the 3' primer and >CHROM_POS_RIGHT for the 5' primer,
-    for example:
-    
-    >20_233255_LEFT
-    CCATTGTATATATAGACCATAATTTCTTTATCCAATCATCTGTTGATGGA
-    >20_233255_RIGHT
-    ACTCAGTTGATTCCATACCTTTGCCATCATGAATCATGTTGTAATAAACA
-    
-    
-    
-### vcfrandomsample
-    
-    usage: vcfrandomsample [options] [<vcf file>]
-    
-    options:
-        -r, --rate RATE      base sampling probability per locus
-        -s, --scale-by KEY   scale sampling likelihood by this Float info field
-        -p, --random-seed N  use this random seed
-    
-    Randomly sample sites from an input VCF file, which may be provided as stdin.
-    Scale the sampling probability by the field specified in KEY.  This may be
-    used to provide uniform sampling across allele frequencies, for instance.
-    
-    
-### vcfremap
-    
-    usage: vcfremap [options] [<vcf file>]
-    
-    options:
-        -w, --ref-window-size N      align using this many bases flanking each side of the reference allele
-        -s, --alt-window-size N      align using this many flanking bases from the reference around each alternate allele
-        -r, --reference FILE         FASTA reference file, required with -i and -u
-        -m, --match-score N          match score for SW algorithm
-        -x, --mismatch-score N       mismatch score for SW algorithm
-        -o, --gap-open-penalty N     gap open penalty for SW algorithm
-        -e, --gap-extend-penalty N   gap extension penalty for SW algorithm
-        -z, --entropy-gap-open       use entropy scaling for the gap open penalty
-        -R, --repeat-gap-extend N    penalize non-repeat-unit gaps in repeat sequence
-        -a, --adjust-vcf TAG         supply a new cigar as TAG in the output VCF
-    
-    For each alternate allele, attempt to realign against the reference with lowered gap open penalty.
-    If realignment is possible, adjust the cigar and reference/alternate alleles.
-    
-    
-### vcfremoveaberrantgenotypes
-    
-Strips genotypes which are homozygous but have observations implying
-heterozygosity.  Requires RA (reference allele observation) and AA (alternate
-allele observation) for each genotype.
-    
-    
-### vcfremovesamples
-    
-    usage: vcfremovesamples <vcf file> [SAMPLE1] [SAMPLE2] ...
-    outputs each record in the vcf file, removing samples listed on the command line
-    
-    
-### vcfroc
-    
-    usage: vcfroc [options] [<vcf file>]
-    
-    options:
-        -t, --truth-vcf FILE      use this VCF as ground truth for ROC generation
-        -w, --window-size N       compare records up to this many bp away (default 30)
-        -r, --reference FILE      FASTA reference file
-    
-    Generates a pseudo-ROC curve using sensitivity and specificity estimated against
-    a putative truth set.  Thresholding is provided by successive QUAL cutoffs.
-    
-    
-### vcfsamplediff
-    
-    usage: vcfsamplediff <tag> <sample> <sample> [ <sample> ... ] <vcf file>
-    tags each record where the listed sample genotypes differ with <tag>
-    The first sample is assumed to be germline, the second somatic.
-    Each record is tagged with <tag>={germline,somatic,loh} to specify the type of
-    variant given the genotype difference between the two samples.
-    
-    
-### vcfsamplenames
-    
-Prints the names of the samples in the VCF file.
-
-    
-### vcfsom
-    
-    usage: vcfsom [options] [vcf file]
-    
-    training: 
-        vcfsom -s output.som -f "AF DP ABP" training.vcf
-    
-    application: 
-        vcfsom -a output.som -f "AF DP ABP" test.vcf >results.vcf
-    
-    vcfsomtrains and/or applies a self-organizing map to the input VCF data
-    on stdin, adding two columns for the x and y coordinates of the winning
-    neuron in the network and an optional euclidean distance from a given
-    node (--center).
-    
-    If a map is provided via --apply,  map will be applied to input without
-    training.  Automated filtering to an estimated FP rate is 
-    
-    options:
-    
-        -h, --help             this dialog
-    
-    training:
-    
-        -f, --fields "FIELD ..."  INFO fields to provide to the SOM
-        -a, --apply FILE       apply the saved map to input data to FILE
-        -s, --save  FILE       train on input data and save the map to FILE
-        -t, --print-training-results
-                               print results of SOM on training input
-                               (you can also just use --apply on the same input)
-        -x, --width X          width in columns of the output array
-        -y, --height Y         height in columns of the output array
-        -i, --iterations N     number of training iterations or epochs
-        -d, --debug            print timing information
-    
-    recalibration:
-    
-        -c, --center X,Y       annotate with euclidean distance from center
-        -p, --paint-true VCF   use VCF file to annotate true variants (multiple)
-        -f, --paint-false VCF  use VCF file to annotate false variants (multiple)
-        -R, --paint-tag TAG    provide estimated FDR% in TAG in variant INFO
-        -N, --false-negative   replace FDR% (false detection) with FNR% (false negative)
-    
-    
-### vcfstats
-    
-    usage: vcfstats [options] <vcf file>
-    
-        -r, --region          specify a region on which to target the stats, requires a BGZF
-                              compressed file which has been indexed with tabix.  any number of
-                              regions may be specified.
-        -a, --add-info        add the statistics intermediate information to the VCF file,
-                              writing out VCF records instead of summary statistics
-        -l, --no-length-frequency    don't out the indel and mnp length-frequency spectra
-        -m, --match-score N          match score for SW algorithm
-        -x, --mismatch-score N       mismatch score for SW algorithm
-        -o, --gap-open-penalty N     gap open penalty for SW algorithm
-        -e, --gap-extend-penalty N   gap extension penalty for SW algorithm
-    
-    Prints statistics about variants in the input VCF file.
-    
-    
-### vcfstreamsort
-    
-Reads VCF on stdin and guarantees that the positional order is correct provided out-of-order
-variants are no more than 100 positions in the VCF file apart.
-
-
-### vcfuniq
-
-Like GNU uniq, but for VCF records.  Remove records which have the same positon, ref, and alt
-as the previous record.
-
-
-### vcfuniqalleles
-
-For each record, remove any duplicate alternate alleles that may have resulted from merging
-separate VCF files.
diff --git a/vcflib/bin/plot_roc.r b/vcflib/bin/plot_roc.r
deleted file mode 100755
index 5a99615..0000000
--- a/vcflib/bin/plot_roc.r
+++ /dev/null
@@ -1,153 +0,0 @@
-#!/usr/bin/Rscript
-
-
-
-
-require(plyr)
-require(ggplot2)
-require(pracma)
-require(grid)
-
-argv <- commandArgs(trailingOnly = TRUE)
-
-prefix <- gsub("\\s","", argv[1])
-print(prefix)
-truthset <- argv[2]
-print(truthset)
-results <- argv[3]
-print(results)
-xmin <- as.numeric(argv[4])
-xmax <- as.numeric(argv[5])
-ymin <- as.numeric(argv[6])
-ymax <- as.numeric(argv[7])
-
-roc <- read.delim(results)
-
-bests <- ddply(roc, .(set), function(x) { data.frame(best_snps=with(x, min(false_negative_snps + false_positive_snps)), best_snp_threshold=min(subset(x, (false_negative_snps + false_positive_snps) == with(x, min(false_negative_snps + false_positive_snps)))$threshold ), best_indels=with(x, min(false_negative_indels + false_positive_indels)), best_indel_threshold=min(subset(x, (false_negative_indels + false_positive_indels) == with(x, min(false_negative_indels + false_positive_indels)))$th [...]
-
-write.table(bests, paste(prefix, ".bests.tsv", sep=""), row.names=FALSE, quote=FALSE, sep="\t")
-
-#abs(trapz(c(1, roc$complexfpr), c(1, roc$complextpr)))
-
-true_snps <- with(subset(roc, set==truthset), max(num_snps))
-true_indels <- with(subset(roc, set==truthset), max(num_indels))
-
-# get ROC AUC
-auc <- ddply(roc, .(set),
-      function(x) {
-        data.frame(
-                   snp_auc=ifelse(true_snps>0,
-                     with(x,
-                          abs(trapz(c(1,
-                                      false_positive_snps/(false_positive_snps+ max(false_negative_snps + num_snps - false_positive_snps))),
-                                    c(max(1- false_negative_snps/true_snps),
-                                      1- false_negative_snps/true_snps)))),
-                     0),
-                   indel_auc=ifelse(true_indels>0,
-                     with(x,
-                          abs(trapz(c(1,
-                                      false_positive_indels/(false_positive_indels+ max(false_negative_indels + num_indels - false_positive_indels))),
-                                    c(max(1- false_negative_indels/true_indels),
-                                      1- false_negative_indels/true_indels)))),
-                     0)
-                   )
-      }
-      )
-
-write.table(auc, paste(prefix, ".auc.tsv", sep=""), row.names=FALSE, quote=FALSE, sep="\t")
-
-
-rocsnps <- ddply(roc, .(set),
-      function(x) {
-        data.frame(
-                   FPR=
-                     with(x,
-                          c(1,
-                            false_positive_snps/(false_positive_snps+ max(false_negative_snps + num_snps - false_positive_snps)))),
-                   TPR=
-                      with(x,
-                          c(max(1- false_negative_snps/true_snps),
-                            1- false_negative_snps/true_snps)),
-                   type=as.factor("snps")
-                   )
-          }
-      )
-
-rocindels <- ddply(roc, .(set),
-      function(x) {
-        data.frame(
-                   FPR=
-                     with(x,
-                          c(1,
-                            false_positive_indels/(false_positive_indels+ max(false_negative_indels + num_indels - false_positive_indels)))),
-                   TPR=
-                      with(x,
-                          c(max(1- false_negative_indels/true_indels),
-                            1- false_negative_indels/true_indels)),
-                   type=as.factor("indels")
-                   )
-          }
-      )
-
-
-if (FALSE) {
-if (true_snps>0) {
-  ggplot(subset(roc, set != truthset),
-         aes(false_positive_snps/(false_positive_snps+with(subset(roc, set==set), max(false_negative_snps + num_snps - false_positive_snps))),
-             1- false_negative_snps/with(subset(roc, set==set), max(false_negative_snps + num_snps - false_positive_snps)),
-             group=set,
-             color=set)) + scale_x_continuous("false positive rate") + scale_y_continuous("true positive rate") + geom_path() + theme_bw()
-            + coord_cartesian(xlim=c(xmin,xmax), ylim=c(ymin,ymax))
-  ggsave(paste(prefix, ".snps.png", sep=""), height=6, width=9)
-}
-
-if (true_indels>0) {
-  ggplot(subset(roc, set != truthset),
-         aes(false_positive_indels/(false_positive_indels+with(subset(roc, set==set), max(false_negative_indels + num_indels - false_positive_indels))),
-             1- false_negative_indels/with(subset(roc, set==set), max(false_negative_indels + num_indels - false_positive_indels)),
-             group=set,
-             color=set)) + scale_x_continuous("false positive rate") + scale_y_continuous("true positive rate") + geom_path() + theme_bw()
-            + coord_cartesian(xlim=c(xmin,xmax), ylim=c(ymin,ymax))
-  ggsave(paste(prefix, ".indels.png", sep=""), height=6, width=9)
-}
-}
-
-
-# new versions
-if (true_snps>0) {
-  ggplot(subset(rocsnps, set != truthset),
-         aes(FPR,
-             TPR,
-             group=set,
-             color=set)) + scale_x_continuous("false positive rate") + scale_y_continuous("true positive rate") + geom_path() + theme_bw() + coord_cartesian(xlim=c(xmin,xmax), ylim=c(ymin,ymax))
-  ggsave(paste(prefix, ".snps.png", sep=""), height=6, width=9)
-}
-
-if (true_indels>0) {
-  ggplot(subset(rocindels, set != truthset),
-         aes(FPR,
-             TPR,
-             group=set,
-             color=set)) + scale_x_continuous("false positive rate") + scale_y_continuous("true positive rate") + geom_path() + theme_bw() + coord_cartesian(xlim=c(xmin,xmax), ylim=c(ymin,ymax))
-  ggsave(paste(prefix, ".indels.png", sep=""), height=6, width=9)
-}
-
-if (true_indels>0 && true_snps>0) {
-
-(
-  ggplot(subset(rbind(rocsnps,rocindels), set != truthset),
-         aes(FPR,
-             TPR,
-             group=set,
-             color=set))
-    + scale_x_continuous("false positive rate")
-    + scale_y_continuous("true positive rate")
-    + geom_path()
-    + theme_bw()
-    + coord_cartesian(xlim=c(xmin,xmax), ylim=c(ymin,ymax))
-    + facet_grid(type ~ .)
-    + theme(panel.margin = unit(1, "lines")) 
-)
-  ggsave(paste(prefix, ".both.png", sep=""), height=5, width=5)
-
-}
diff --git a/vcflib/bin/vcf2sqlite.py b/vcflib/bin/vcf2sqlite.py
deleted file mode 100755
index f0170b0..0000000
--- a/vcflib/bin/vcf2sqlite.py
+++ /dev/null
@@ -1,130 +0,0 @@
-#!/usr/bin/python
-
-import sys
-import re
-import sqlite3
-
-if len(sys.argv) < 2:
-    print "usage", sys.argv[0], " [dbname]"
-    print "reads VCF on stdin, and writes output to a sqlite3 db [dbname]"
-    exit(1)
-
-dbname = sys.argv[1]
-
-# parse the header
-# into a mapping from tag -> type
-
-infotypes = {}
-infonumbers = {}
-
-for line in sys.stdin:
-    if line.startswith('##INFO'):
-        #<ID=XRS,Number=1,Type=Float,
-        i = re.search("ID=(.*?),", line)
-        n = re.search("Number=(.*?),", line)
-        t = re.search("Type=(.*?),", line)
-        if i and n and t:
-            id = i.groups()[0]
-            number = n.groups()[0]
-            if number == "A":
-                number = -1
-            elif number == "G" or int(number) > 1:
-                # unclear how to deal with these
-                continue
-            else:
-                number = int(number)
-            typestr = t.groups()[0]
-            infotypes[id] = typestr
-            infonumbers[id] = number
-        else:
-            continue
-    elif line.startswith('##'):
-        continue
-    else:
-        break # header line, sample names etc.
-
-# write the table schema
-
-infotype_to_sqltype = {}
-infotype_to_sqltype["Flag"] = "boolean"
-infotype_to_sqltype["Integer"] = "integer"
-infotype_to_sqltype["Float"] = "real"
-infotype_to_sqltype["String"] = "text"
-
-tablecmd = """create table alleles"""
-specs = ["CHROM text",
-        "POS integer",
-        "ID text",
-        "REF text",
-        "ALT text",
-        "QUAL real",
-        "FILTER text"]
-
-sorted_fields = sorted(infotypes.keys())
-for field in sorted_fields:
-    infotype = infotypes[field]
-    sqltype = infotype_to_sqltype[infotype]
-    field = field.replace(".", "_") # escape periods, which are not allowed
-    specs.append(field + " " + sqltype)
-
-tablecmd += " (" + ", ".join(specs) + ")"
-
-conn = sqlite3.connect(dbname)
-conn.execute(tablecmd)
-
-# for each record
-# parse the record
-# for each allele
-
-for line in sys.stdin:
-    fields = line.split('\t')
-    chrom, pos, id, ref, alts, qual, filter, info = fields[:8]
-    alts = alts.split(",")
-    altindex = 0
-    chrom = "\'" + chrom + "\'"
-    id = "\'" + id + "\'"
-    ref = "\'" + ref + "\'"
-    filter = "\'" + filter + "\'"
-    for alt in alts:
-        alt = "\'" + alt + "\'"
-        info_values = {}
-        for pair in info.split(";"):
-            if pair.find("=") is not -1:
-                pair = pair.split("=")
-                key = pair[0]
-                value = pair[1]
-                if not infonumbers.has_key(key):
-                    continue
-                if infonumbers[key] == -1:
-                    values = value.split(",")
-                    value = values[altindex]
-                info_values[key] = value
-            else:
-               # boolean flag
-                info_values[pair] = "1"
-        ordered_insertion = []
-        for field in sorted_fields:
-            value = "null"
-            if info_values.has_key(field):
-                value = info_values[field]
-                if infotypes[field] == "String":
-                    value = "\'" + value + "\'"
-            else:
-                # missing flag means "false" for that flag
-                if infotypes[field] == "Flag":
-                    value = "0"
-            ordered_insertion.append(value)
-        cmd = "insert into alleles values (" \
-            + ", ".join([chrom, pos, id, ref, alt, qual, filter]) \
-            + ", " \
-            + ", ".join(ordered_insertion) + ")"
-        conn.execute(cmd)
-        altindex += 1
-
-conn.commit()
-
-# TODO ignoring samples (for now)
-
-# add indexes everywhere?
-
-conn.close()
diff --git a/vcflib/bin/vcf_strip_extra_headers b/vcflib/bin/vcf_strip_extra_headers
deleted file mode 100755
index c8b05e6..0000000
--- a/vcflib/bin/vcf_strip_extra_headers
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/perl
-
-my $seen_non_header = 0;
-
-while (<STDIN>) {
-    if (! $seen_non_header) {
-        if (/^#/) {
-        } else {
-            $seen_non_header = 1;
-        }
-        print;
-    } else {
-        if (! /^#/) {
-            print;
-        }
-    }
-
-}
diff --git a/vcflib/bin/vcfbiallelic b/vcflib/bin/vcfbiallelic
deleted file mode 100755
index 7761fec..0000000
--- a/vcflib/bin/vcfbiallelic
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/perl
-#
-
-while (<STDIN>) {
-    if ($_ =~ /^#/) {
-        print;
-    } else {
-        $_ =~ /^(.+?)\t(.+?)\t(.+?)\t(.+?)\t(.+?)\t/;
-        $chrom = $1;
-        $pos = $2;
-        $tag = $3;
-        $ref = $4;
-        $alt = $5;
-        if ($alt =~ /,/) {
-            # remove anything which isn't biallelic
-        } else {
-            print;
-        }
-    }
-}
diff --git a/vcflib/bin/vcfclearid b/vcflib/bin/vcfclearid
deleted file mode 100755
index f428682..0000000
--- a/vcflib/bin/vcfclearid
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/python
-#
-
-import sys
-
-for line in sys.stdin:
-    if line.startswith("#"):
-        print line.strip()
-    else:
-        fields = line.strip().split("\t")
-        fields[2] = "."
-        print "\t".join(fields)
diff --git a/vcflib/bin/vcfclearinfo b/vcflib/bin/vcfclearinfo
deleted file mode 100755
index a0512fd..0000000
--- a/vcflib/bin/vcfclearinfo
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/python
-#
-
-import sys
-
-for line in sys.stdin:
-    if line.startswith("#"):
-        print line.strip()
-    else:
-        fields = line.strip().split("\t")
-        fields[7] = "."
-        print "\t".join(fields)
diff --git a/vcflib/bin/vcfcomplex b/vcflib/bin/vcfcomplex
deleted file mode 100755
index e074123..0000000
--- a/vcflib/bin/vcfcomplex
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/perl
-#
-
-while (<STDIN>) {
-    if ($_ =~ /^#/) {
-        print;
-    } else {
-        $_ =~ /^(.+?)\t(.+?)\t(.+?)\t(.+?)\t(.+?)\t/;
-        $chrom = $1;
-        $pos = $2;
-        $tag = $3;
-        $ref = $4;
-        $alts = $5;
-	$hasindel = 0;
-	@alts = split(/,/, $alts);
-	$snp = 1;
-	foreach $alt (@alts) {
-	    if (length($ref) > 1 || length($alt) != length($ref)) {
-		$snp = 0;
-	    }
-        }
-	if (!$snp) {
-	    print;
-	}
-    }
-}
diff --git a/vcflib/bin/vcfgtcompare.sh b/vcflib/bin/vcfgtcompare.sh
deleted file mode 100755
index d563313..0000000
--- a/vcflib/bin/vcfgtcompare.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-
-if [ $# != 3 ];
-then
-    echo "usage: $0 [annotation] [fileA] [fileB]"
-    echo "annotates records in the first file with genotypes and sites from the second"
-    exit
-fi
-
-annotation=$1
-fileA=$2
-fileB=$3
-
-vcfcommonsamples $fileA $fileB \
- | vcfannotategenotypes $annotation - $fileB \
- | vcfgenotypecompare $annotation -
diff --git a/vcflib/bin/vcfindelproximity b/vcflib/bin/vcfindelproximity
deleted file mode 100755
index 982ba81..0000000
--- a/vcflib/bin/vcfindelproximity
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/usr/bin/perl
-#
-
-
-
-# for line in the vcf
-# stuff the line into a queue
-# when you reach an indel
-# record the position
-# pop lines from the back of the queue until we are at the current position
-#
-
-my @lines;
-
-my $prox = $ARGV[0];
-
-my $lastchrom = "";
-my $indelpos = 0;
-
-while (<STDIN>) {
-
-    if ($_ =~ /^#/) {
-        print $_;
-        next;
-    }
-
-    $_ =~ /^(.+?)\t(.+?)\t(.+?)\t(.+?)\t(.+?)\t/;
-    my $chrom = $1;
-    my $pos = $2;
-    my $tag = $3;
-    my $ref = $4;
-    my $alt = $5;
-    #print "chrom: $chrom, pos: $pos, ref: $ref, alt: $alt\n";
-
-    # if new chrom, print out everything from last one
-    if ($lastchrom == "") {
-        $lastchrom = $chrom;
-    }
-
-    if ($chrom != $lastchrom) {
-        while ($lines) {
-            print pop(@lines);
-        }
-    }
-
-    unshift(@lines, $_);
-
-    my $diff = length($ref) - length($alt);
-
-    if ($diff != 0) {
-        # insertion
-        if ($indelpos == 0) {
-            $indelpos = $pos;
-        }
-        $nextindelpos = $pos;
-        #print "last $indelpos next $nextindelpos\n";
-        while (@lines) {
-            my $line = pop(@lines);
-            $line =~ /^(.+?)\t(.+?)\t(.+?)\t(.+?)\t(.+?)\t/;
-            my $c = $1;
-            my $p = $2;
-            my $t = $3;
-            my $r = $4;
-            my $a = $5;
-            # print indels
-            if (length($r) - length($a) != 0) {
-                print $line;
-            } else {
-            # print other events which are more than prox away from indels
-                if (abs($indelpos - $p) >= $prox and abs($nextindelpos - $p) >= $prox) {
-                    print $line;
-                }
-            }
-        }
-        $indelpos = $pos;
-    }
-}
-
-# flush lines end of file
-while ($lines) {
-    print pop(@lines);
-}
diff --git a/vcflib/bin/vcfindels b/vcflib/bin/vcfindels
deleted file mode 100755
index 9c2b188..0000000
--- a/vcflib/bin/vcfindels
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/perl
-#
-
-while (<STDIN>) {
-    if ($_ =~ /^#/) {
-        print;
-    } else {
-        $_ =~ /^(.+?)\t(.+?)\t(.+?)\t(.+?)\t(.+?)\t/;
-        $chrom = $1;
-        $pos = $2;
-        $tag = $3;
-        $ref = $4;
-        $alts = $5;
-        $hasindel = 0;
-        @alts = split(/,/, $alts);
-        $snp = 1;
-        foreach $alt (@alts) {
-            if (length($ref) > 1 || length($alt) != length($ref)) {
-                $snp = 0;
-            }
-        }
-        if (!$snp) {
-            print;
-        }
-    }
-}
diff --git a/vcflib/bin/vcfmultiallelic b/vcflib/bin/vcfmultiallelic
deleted file mode 100755
index 47f3dce..0000000
--- a/vcflib/bin/vcfmultiallelic
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/perl
-#
-
-while (<STDIN>) {
-    if ($_ =~ /^#/) {
-        print;
-    } else {
-        $_ =~ /^(.+?)\t(.+?)\t(.+?)\t(.+?)\t(.+?)\t/;
-        $chrom = $1;
-        $pos = $2;
-        $tag = $3;
-        $ref = $4;
-        $alt = $5;
-        if ($alt =~ /,/) {
-            print;
-        } else {
-            # remove anything which isn't multiallelic
-        }
-    }
-}
diff --git a/vcflib/bin/vcfmultiway b/vcflib/bin/vcfmultiway
deleted file mode 100755
index 9536a65..0000000
--- a/vcflib/bin/vcfmultiway
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/bash
-
-reference=$1
-shift
-
-echo comparing $@
-
-for fileA in $@;
-do
-    for fileB in $@;
-    do
-	if [ "$fileA" = "$fileB" ]
-	then
-	    vcfstats $fileA >$(basename $fileA).stats.txt
-	else
-	    vcfintersect -r $reference -i $fileA $fileB | vcfstats >$(basename $fileA).common.$(basename $fileB).stats.txt
-	    vcfintersect -r $reference -v -i $fileB $fileA | vcfstats >$(basename $fileA).unique.$(basename $fileB).stats.txt
-	fi
-    done
-done
diff --git a/vcflib/bin/vcfmultiwayscripts b/vcflib/bin/vcfmultiwayscripts
deleted file mode 100755
index 8373805..0000000
--- a/vcflib/bin/vcfmultiwayscripts
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/bash
-
-reference=$1
-outdir=$2
-scriptsdir=$3
-shift
-shift
-shift
-
-mkdir -p $outdir
-mkdir -p $scriptsdir
-
-echo comparing $@
-
-for fileA in $@;
-do
-    fileA=$(pwd)/$fileA
-    for fileB in $@;
-    do
-	fileB=$(pwd)/$fileB
-	echo $fileA vs $fileB
-	if [ "$fileA" = "$fileB" ]
-	then
-	    echo "vcfstats $fileA >$outdir/$(basename $fileA).stats" >$scriptsdir/$(basename $fileA).sh
-	else
-	    echo "vcfintersect -r $reference -i $fileA $fileB | vcfstats >$outdir/$(basename $fileA).common.$(basename $fileB).stats" >$scriptsdir/$(basename $fileA).common.$(basename $fileB).sh
-	    echo "vcfintersect -r $reference -v -i $fileB $fileA | vcfstats >$outdir/$(basename $fileA).unique.$(basename $fileB).stats" >$scriptsdir/$(basename $fileA).unique.$(basename $fileB).sh
-	fi
-    done
-done
diff --git a/vcflib/bin/vcfnobiallelicsnps b/vcflib/bin/vcfnobiallelicsnps
deleted file mode 100755
index 7de8440..0000000
--- a/vcflib/bin/vcfnobiallelicsnps
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/perl
-#
-
-while (<STDIN>) {
-    if ($_ =~ /^#/) {
-        print;
-    } else {
-        $_ =~ /^(.+?)\t(.+?)\t(.+?)\t(.+?)\t(.+?)\t/;
-        $chrom = $1;
-        $pos = $2;
-        $tag = $3;
-        $ref = $4;
-        $alts = $5;
-        $hasnonsnp = 0;
-        @alts = split(/,/, $alts);
-        foreach $alt (@alts) {
-            if (!(length($alt)==1 && length($alt) == length($ref))) {
-                $hasnonsnp = 1;
-            }
-        }
-        if ($hasnonsnp || scalar(@alts) > 1) {
-            print;
-        }
-    }
-}
diff --git a/vcflib/bin/vcfnoindels b/vcflib/bin/vcfnoindels
deleted file mode 100755
index c2051ac..0000000
--- a/vcflib/bin/vcfnoindels
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/perl
-#
-
-while (<STDIN>) {
-    if ($_ =~ /^#/) {
-        print;
-    } else {
-        $_ =~ /^(.+?)\t(.+?)\t(.+?)\t(.+?)\t(.+?)\t/;
-        $chrom = $1;
-        $pos = $2;
-        $tag = $3;
-        $ref = $4;
-        $alts = $5;
-	$hasindel = 0;
-	@alts = split(/,/, $alts);
-	foreach $alt (@alts) {
-	    if (length($alt ) != length($ref)) {
-		$hasindel = 1;
-	    }
-        }
-	if (! $hasindel) {
-	    print;
-	}
-    }
-}
diff --git a/vcflib/bin/vcfnosnps b/vcflib/bin/vcfnosnps
deleted file mode 100755
index 19ee084..0000000
--- a/vcflib/bin/vcfnosnps
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/perl
-#
-
-while (<STDIN>) {
-    if ($_ =~ /^#/) {
-        print;
-    } else {
-        $_ =~ /^(.+?)\t(.+?)\t(.+?)\t(.+?)\t(.+?)\t/;
-        $chrom = $1;
-        $pos = $2;
-        $tag = $3;
-        $ref = $4;
-        $alts = $5;
-        $hasnonsnp = 0;
-        @alts = split(/,/, $alts);
-        foreach $alt (@alts) {
-            if (!(length($alt)==1 && length($alt) == length($ref))) {
-                $hasnonsnp = 1;
-            }
-        }
-        if ($hasnonsnp) {
-            print;
-        }
-    }
-}
diff --git a/vcflib/bin/vcfnulldotslashdot b/vcflib/bin/vcfnulldotslashdot
deleted file mode 100755
index 9951a34..0000000
--- a/vcflib/bin/vcfnulldotslashdot
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/usr/bin/python
-
-import sys
-import math
-
-def bincoeff(n,k): return math.factorial(n) / (math.factorial(n-k)*math.factorial(k))
-def multcoeff(n,k): return bincoeff(n+k-1,k)
-
-for line in sys.stdin:
-    if line.startswith("#"):
-        print line.strip()
-        continue
-    fields = line.strip().split("\t")
-    alleles = len(fields[4].split(","))+1
-    # assume that we have GT:GL
-    # how many genotypes?  assume diploid
-    flatgls = ",".join(map(str,[0]*multcoeff(alleles,2)))
-    for i in range(9, len(fields)):
-        if fields[i] == ".":
-            fields[i] = "./.:" + flatgls
-    print "\t".join(fields)
-    
diff --git a/vcflib/bin/vcfplotaltdiscrepancy.r b/vcflib/bin/vcfplotaltdiscrepancy.r
deleted file mode 100755
index 8717987..0000000
--- a/vcflib/bin/vcfplotaltdiscrepancy.r
+++ /dev/null
@@ -1,511 +0,0 @@
-#!/usr/bin/Rscript
-
-# helper functions
-
-nan.to.zero <- function(n) {
-    if (is.nan(n)) return(0) else return(n)
-}
-
-
-# get the input VCF tabular format, assert that sites must have AC > 0
-vcf <- subset(read.table(pipe('cat /dev/stdin'), header=T), AC > 0)
-
-filename <- commandArgs(TRUE)[1]
-tag <- commandArgs(TRUE)[2]
-
-tag.genotypes_count <- paste(tag, '.genotypes.alternate_count', sep='')
-tag.genotypes_alternate_count <- paste(tag, '.genotypes.alternate_count', sep='')
-tag.non_reference_discrepancy_count <- paste(tag, '.site.non_reference_discrepancy.count', sep='')
-tag.non_reference_discrepancy_normalizer <- paste(tag, '.site.non_reference_discrepancy.normalizer', sep='')
-tag.non_reference_sensitivity_count <- paste(tag, '.site.non_reference_sensitivity.count', sep='')
-tag.non_reference_sensitivity_normalizer <- paste(tag, '.site.non_reference_sensitivity.normalizer', sep='')
-tag.alternate_positive_discrepancy <- paste(tag, '.site.alternate_positive_discrepancy', sep='')
-tag.alternate_negative_discrepancy <- paste(tag, '.site.alternate_negative_discrepancy', sep='')
-tag.has_variant <- paste(tag, '.has_variant', sep='')
-
-vcf.numberOfSites <- length(vcf[, tag.genotypes_alternate_count])
-vcf.totalAltAlleles <- sum(vcf[, tag.genotypes_alternate_count])
-vcf.positiveDiscrepancy <- sum(vcf[, tag.alternate_positive_discrepancy]) / sum(vcf[, tag.genotypes_alternate_count])
-vcf.negativeDiscrepancy <- sum(vcf[, tag.alternate_negative_discrepancy]) / sum(vcf[, tag.genotypes_alternate_count])
-vcf.sitesTruePositive <- mean(vcf[, tag.has_variant])
-
-min_sites <- 5  # number of sites required for "simple plotting"
-
-#library(ggplot2)
-#vcf2 <- data.frame(QUAL=vcf$QUAL, AC=vcf$AC, has_variant=vcf[, tag.has_variant])
-#qplot(AC, has_variant, group=AC, geom="boxplot", data=subset(vcf2, AC <= 20))
-#ggsave(paste(filename, '.', tag, '.PD.vs.AC.boxplot.ac_lt_20.pdf', sep=''))
-
-
-cat('number of sites', vcf.numberOfSites, '\n')
-cat('total alternate alleles', vcf.totalAltAlleles, '\n')
-cat('positive discrepancy', vcf.positiveDiscrepancy, '\n')
-cat('negative discrepancy', vcf.negativeDiscrepancy, '\n')
-
-#x <- cbind(tapply(vcf, as.list(seq(0,max(vcf$AC))),
-#    function(x) {
-#        sum(x[, tag.alternate_positive_discrepancy]) / sum(x[, tag.genotypes_alternate_count])
-#    }))
-
-byac <- data.frame(ac=as.vector(seq(1,max(vcf$AC)))) #, fdr=as.vector(x))
-
-
-byac$fdr <- as.vector(cbind(by(byac$ac, byac$ac,
-    function(x) {
-        s <- subset(vcf, AC == x)
-        return(nan.to.zero(sum(s[, tag.alternate_positive_discrepancy]) / sum(s[, tag.genotypes_alternate_count])))
-    })))
-
-# false detection count
-byac$fpc <- as.vector(cbind(by(byac$ac, byac$ac,
-    function(x) {
-        s <- subset(vcf, AC == x)
-        return(sum(s[, tag.alternate_positive_discrepancy]))
-    })))
-
-byac$alleles <- as.vector(cbind(by(byac$ac, byac$ac,
-    function(x) {
-        s <- subset(vcf, AC == x)
-        return(sum(s[, tag.genotypes_alternate_count]))
-    })))
-
-byac$sites <- as.vector(cbind(by(byac$ac, byac$ac,
-    function(x) {
-        s <- subset(vcf, AC == x)
-        return(length(s$AC))
-    })))
-
-# count true positive sites
-byac$site_tpc <- as.vector(cbind(by(byac$ac, byac$ac,
-    function(x) {
-        s <- subset(vcf, AC == x)
-        return(sum(s[, tag.has_variant]))
-    })))
-
-# fpc == false detection count
-byac$site_fpc <- byac$sites - byac$site_tpc
-# site detection fpr is 1 - true positive rate
-byac$site_fpr <- 1 - ( byac$site_tpc / byac$sites )
-
-summary(byac)
-
-#print(byac$sites)
-#print(byac$site_tpc)
-#print(byac$site_fpc)
-#print(byac$site_fpr)
-
-#byac$site_fpr_gt0 <- as.vector(cbind(tapply(byac$ac, byac$ac, function(i) { 
-#    s <- subset(byac, ac == i, select=c(site_fpr, sites))
-#if (s$sites >= min_sites) {
-#    return(s$site_fpr)
-#} else {
-#    return(NA)
-#}
-#})))
-
-#byac$site_fprlt <- as.vector(cbind(tapply(byac$ac, byac$ac, function(i) mean(subset(byac, ac <= i, select=site_fpr)))))
-byac$site_fprlt <- as.vector(cbind(tapply(byac$ac, byac$ac, function(i) { 
-    s <- subset(byac, ac <= i, select=c(site_fpc, sites))
-    return(sum(s$site_fpc) / sum(s$sites))
-})))
-
-#byac$site_fprgt <- as.vector(cbind(tapply(byac$ac, byac$ac, function(i) mean(subset(byac, ac >= i, select=site_fpr)))))
-byac$site_fprgt <- as.vector(cbind(tapply(byac$ac, byac$ac, function(i) { 
-    s <- subset(byac, ac >= i, select=c(site_fpc, sites))
-    return(sum(s$site_fpc) / sum(s$sites))
-})))
-
-byac$cfa <- as.vector(cbind(tapply(byac$ac, byac$ac, function(i) sum(subset(byac, ac <= i, select=alleles)) / sum(byac$alleles))))
-
-byac$cfs <- as.vector(cbind(tapply(byac$ac, byac$ac, function(i) sum(subset(byac, ac <= i, select=sites)) / length(vcf$AC))))
-
-# inappropriate collapse via averaging of fdr
-#byac$alternate_pdlt <- as.vector(cbind(tapply(byac$ac, byac$ac, function(i) mean(subset(byac, ac <= i, select=fdr)))))
-
-byac$alternate_pdr <- as.vector(cbind(tapply(byac$ac, byac$ac, function(i) { 
-    s <- subset(byac, ac == i, select=c(fpc, alleles))
-    return(sum(s$fpc) / sum(s$alleles))
-})))
-
-# use this one
-byac$alternate_pdlt <- as.vector(cbind(tapply(byac$ac, byac$ac, function(i) { 
-    s <- subset(byac, ac <= i, select=c(fpc, alleles))
-    return(sum(s$fpc) / sum(s$alleles))
-})))
-
-#byac$alternate_pdgt <- as.vector(cbind(tapply(byac$ac, byac$ac, function(i) mean(subset(byac, ac >= i, select=fdr)))))
-byac$alternate_pdgt <- as.vector(cbind(tapply(byac$ac, byac$ac, function(i) { 
-    s <- subset(byac, ac >= i, select=c(fpc, alleles))
-    return(sum(s$fpc) / sum(s$alleles))
-})))
-
-byac$nrs <- as.vector(cbind(by(byac$ac, byac$ac,
-    function(x) {
-        s <- subset(vcf, AC == x)
-        return(nan.to.zero(sum(s[, tag.non_reference_sensitivity_count]) / sum(s[, tag.non_reference_sensitivity_normalizer])))
-    })))
-
-byac$nrd <- as.vector(cbind(by(byac$ac, byac$ac,
-    function(x) {
-        s <- subset(vcf, AC == x)
-        return(nan.to.zero(sum(s[, tag.non_reference_discrepancy_count]) / sum(s[, tag.non_reference_discrepancy_normalizer])))
-    })))
-
-byac$nrslt <- as.vector(cbind(tapply(byac$ac, byac$ac, function(i) {
-    s <- subset(vcf, AC <= i, select=c(tag.non_reference_sensitivity_count, tag.non_reference_sensitivity_normalizer))
-    return(nan.to.zero(sum(s[, tag.non_reference_sensitivity_count]) / sum(s[, tag.non_reference_sensitivity_normalizer])))
-})))
-
-byac$nrdlt <- as.vector(cbind(tapply(byac$ac, byac$ac, function(i) { 
-    s <- subset(vcf, AC <= i, select=c(tag.non_reference_discrepancy_count, tag.non_reference_discrepancy_normalizer))
-    return(nan.to.zero(sum(s[, tag.non_reference_discrepancy_count]) / sum(s[, tag.non_reference_discrepancy_normalizer])))
-})))
-
-byac_gtsites <- subset(byac, sites >= min_sites)
-
-
-if (FALSE) {
-pdf(paste(filename, '.', tag, '.PD.vs.AC.smooth.pdf', sep=''))
-par(cex=0.75)
-par(mar=c(5,4,4,5) + 0.1)
-plot(byac$cfa, ylim=c(0,1.0),
-    xlab='alternate allele count (AC)', xaxt='n',
-    ylab='', yaxt='n', type='l', col='red')
-axis(2, at=seq(0,1,0.1), labels=seq(0,1,0.1))
-axis(1, at=seq(0,max(byac$ac),10), labels=seq(0,max(byac$ac),10), cex=0.75)
-grid(lty=5)
-par(new=T)
-title(paste(filename, 'positive discrepancy versus', tag, '(smoothed)'))
-par(new=T)
-countTicks <- seq(0,1,0.1) * vcf.numberOfSites
-axis(4, at=seq(0,1,0.1), labels=round(countTicks))
-mtext("number of sites", side=4, line=3, cex=0.75)
-par(new=T)
-#plot(byac$alternate_pdlt, ylim=c(0,1.0), xlab='', xaxt='n', ylab='', yaxt='n', type='l', col='green')
-plot(byac$site_fpr, ylim=c(0,1.0), xlab='', xaxt='n', ylab='', yaxt='n')
-par(new=T)
-lines(byac$ac, predict(loess(byac$alternate_pdr ~ byac$ac, span=0.5)), col="green")
-par(new=T)
-plot(byac$cfa, ylim=c(0,1.0), xlab='', xaxt='n', ylab='', yaxt='n', type='l', col='red')
-par(new=T)
-plot(byac$cfs, ylim=c(0,1.0), xlab='', xaxt='n', ylab='', yaxt='n', type='l', col='purple')
-par(new=T)
-lines(byac$ac, predict(loess(byac$site_fpr ~ byac$ac, span=0.5)), col="blue")
-par(new=T)
-lines(byac$ac, predict(loess(byac$nrs ~ byac$ac, span=0.5)), col="magenta")
-par(new=T)
-lines(byac$ac, predict(loess(byac$nrd ~ byac$ac, span=0.5)), col="brown")
-par(new=T, cex=0.65)
-mtext(paste("alternate genotype PD: ", round(vcf.positiveDiscrepancy, digits=4), ", site PD: ", round(1 - vcf.sitesTruePositive, digits=4), sep=''))
-par(new=T, cex=0.65)
-legend('topleft', c('cumulative fraction of alt alleles', 'cumulative fraction of sites', 'alt genotypes PD', 'site PD', 'non-ref sensitivity', 'non-ref discrepancy', 'site PD at AC'),
-    fill=c('red', 'purple', 'green', 'blue', 'magenta', 'brown', 'black'))
-garbage <- dev.off()
-}
-
-
-
-pdf(paste(filename, '.', tag, '.PD.vs.AC.cumulative.pdf', sep=''))
-par(cex=0.75)
-par(mar=c(5,4,4,5) + 0.1)
-plot(byac$cfa, ylim=c(0,1.0), 
-    xlab='alternate allele count (AC)', xaxt='n',
-    ylab='', yaxt='n', type='l', col='red')
-axis(2, at=seq(0,1,0.1), labels=seq(0,1,0.1))
-axis(1, at=seq(0,max(byac$ac),10), labels=seq(0,max(byac$ac),10), cex=0.75)
-grid(lty=5)
-par(new=T)
-title(paste(filename, 'positive discrepancy versus', tag, '(cumulative)'))
-par(new=T)
-countTicks <- seq(0,1,0.1) * vcf.numberOfSites
-axis(4, at=seq(0,1,0.1), labels=round(countTicks))
-mtext("number of sites", side=4, line=3, cex=0.75)
-par(new=T)
-#plot(byac_gtsites$ac, byac_gtsites$site_fpr, ylim=c(0,1.0), xlab='', xaxt='n', ylab='', yaxt='n')
-plot(byac$site_fpr, ylim=c(0,1.0),  xlab='', xaxt='n', ylab='', yaxt='n')
-par(new=T)
-plot(byac$alternate_pdlt, ylim=c(0,1.0),  xlab='', xaxt='n', ylab='', yaxt='n', type='l', col='green')
-par(new=T)
-plot(byac$cfa, ylim=c(0,1.0),  xlab='', xaxt='n', ylab='', yaxt='n', type='l', col='red')
-par(new=T)
-plot(byac$cfs, ylim=c(0,1.0),  xlab='', xaxt='n', ylab='', yaxt='n', type='l', col='purple')
-par(new=T)
-plot(byac$site_fprlt, ylim=c(0,1.0),  xlab='', xaxt='n', ylab='', yaxt='n', type='l', col='blue')
-par(new=T)
-plot(byac$nrslt, ylim=c(0,1.0),  xlab='', xaxt='n', ylab='', yaxt='n', type='l', col='magenta')
-par(new=T)
-plot(byac$nrdlt, ylim=c(0,1.0),  xlab='', xaxt='n', ylab='', yaxt='n', type='l', col='brown')
-par(new=T, cex=0.65)
-mtext(paste("alternate genotype PD: ", round(vcf.positiveDiscrepancy, digits=4), ", site PD: ", round(1 - vcf.sitesTruePositive, digits=4), sep=''))
-par(new=T, cex=0.65)
-legend('topleft', c('cumulative fraction of alt alleles', 'cumulative fraction of sites', 'alt genotypes PD', 'site PD', 'non-ref sensitivity', 'non-ref discrepancy', 'site PD at AC'),
-    fill=c('red', 'purple', 'green', 'blue', 'magenta', 'brown', 'black'))
-garbage <- dev.off()
-
-
-
-pdf(paste(filename, '.', tag, '.PD.vs.AC.cumulative.simple.pdf', sep=''))
-par(cex=0.75)
-par(mar=c(5,4,4,5) + 0.1)
-plot(byac$cfs, ylim=c(0,1.0), xlim=c(0,max(vcf$AC)),
-    xlab='alternate allele count (AC)', xaxt='n',
-    ylab='', yaxt='n', type='l', col='purple')
-axis(2, at=seq(0,1,0.1), labels=seq(0,1,0.1))
-axis(1, at=seq(0,max(byac$ac),10), labels=seq(0,max(byac$ac),10), cex=0.75)
-grid(lty=5)
-par(new=T)
-title(paste(filename, 'positive discrepancy versus', tag, '(cumulative)'))
-par(new=T)
-countTicks <- seq(0,1,0.1) * vcf.numberOfSites
-axis(4, at=seq(0,1,0.1), labels=round(countTicks))
-mtext("number of sites", side=4, line=3, cex=0.75)
-par(new=T)
-plot(byac$site_fprlt, ylim=c(0,1.0), xlim=c(0,max(vcf$AC)), xlab='', xaxt='n', ylab='', yaxt='n', type='l', col='blue')
-par(new=T)
-plot(byac_gtsites$ac, byac_gtsites$site_fpr, ylim=c(0,1.0), xlim=c(0,max(vcf$AC)),   xlab='', xaxt='n', ylab='', yaxt='n')
-par(new=T, cex=0.65)
-mtext(paste("site PD: ", round(1 - vcf.sitesTruePositive, digits=4), sep=''))
-par(new=T, cex=0.65)
-legend('topleft', c('cumulative fraction of sites', 'cumulative site PD', paste('site PD at AC (>=', min_sites, 'sites)')),
-    fill=c('purple', 'blue', 'black'))
-garbage <- dev.off()
-
-
-
-
-pdf(paste(filename, '.', tag, '.PD.vs.AC.instantaneous.ac_lt_20.pdf', sep=''))
-#par(cex=0.75)
-par(mar=c(5,4,4,5) + 0.1)
-plot(byac$sites, ylim=c(0,max(byac$sites)), xlim=c(0,20),
-    xlab='alternate allele count (AC)', xaxt='n',
-    ylab='number of sites', type='l', pch=19, col='blue')
-#axis(2, at=seq(0,1,0.1), labels=seq(0,1,0.1))
-#countTicks <- round(seq(0,1,0.1) * max(byac$sites))
-#axis(2, at=countTicks, labels=countTicks)
-par(new=T)
-axis(1, at=seq(0,max(byac$ac),1), labels=seq(0,max(byac$ac),1))
-grid(lty=5)
-par(new=T)
-plot(byac$sites, ylim=c(0,max(byac$sites)), xlim=c(0,20), type='o', pch=19, col='blue', xlab='', xaxt='n', ylab='', yaxt='n')
-par(new=T)
-title(paste(filename, 'positive discrepancy versus', tag, '(instantaneous)'))
-par(new=T)
-mtext("number of sites", side=2, line=3) #, cex=0.75)
-#par(new=T)
-#plot(byac$site_fprlt, ylim=c(0,1.0), xlim=c(0,20),  xlab='', xaxt='n', ylab='', yaxt='n', type='l', col='blue')
-par(new=T)
-plot(byac_gtsites$ac, byac_gtsites$site_tpc, ylim=c(0,max(byac$sites)), xlim=c(0,20), xlab='', xaxt='n', ylab='', yaxt='n', col='red', pch=19, type='o')
-par(new=T) #, cex=0.65)
-mtext(paste("site PD: ", round(1 - vcf.sitesTruePositive, digits=4), sep=''))
-par(new=T) #, cex=0.65)
-#legend('topright', c('number of sites', 'site PD count'),
-#    fill=c('blue', 'red'))
-garbage <- dev.off()
-
-# stratifying by QUAL
-
-if (FALSE) {
-
-
-x <- cbind(by(vcf, vcf$QUAL,
-    function(x) {
-        sum(x[, tag.alternate_positive_discrepancy]) / sum(x[, tag.genotypes_alternate_count])
-    }))
-
-byqual <- data.frame(qual=as.numeric(rownames(x)), fdr=as.vector(x))
-
-# false detection count
-byqual$fpc <- as.vector(cbind(by(vcf, vcf$QUAL,
-    function(i) { sum(i[, tag.alternate_positive_discrepancy]) } )))
-
-byqual$alleles <- as.vector(cbind(by(vcf, vcf$QUAL,
-    function(i) {
-        sum(i[, tag.genotypes_alternate_count])
-    })))
-
-byqual$sites <- as.vector(cbind(by(vcf$QUAL, vcf$QUAL, function(i) length(i))))
-
-# count true positive sites
-byqual$site_tpc <- as.vector(cbind(by(vcf[, tag.has_variant], vcf$QUAL, function(i) sum(i))))
-# fpc == false detection count
-byqual$site_fpc <- byqual$sites - byqual$site_tpc
-# site detection fpr is 1 - true positive rate
-byqual$site_fpr <- 1 - ( byqual$site_tpc / byqual$sites )
-
-#byqual$site_fpr_gt0 <- as.vector(cbind(tapply(byqual$ac, byqual$ac, function(i) { 
-#    s <- subset(byqual, ac == i, select=c(site_fpr, sites))
-#if (s$sites >= min_sites) {
-#    return(s$site_fpr)
-#} else {
-#    return(NA)
-#}
-#})))
-
-#byqual$site_fprlt <- as.vector(cbind(tapply(byqual$qual, byqual$qual, function(i) mean(subset(byqual, qual <= i, select=site_fpr)))))
-byqual$site_fprlt <- as.vector(cbind(tapply(byqual$qual, byqual$qual, function(i) { 
-    s <- subset(byqual, qual <= i, select=c(site_fpc, sites))
-    return(sum(s$site_fpc) / sum(s$sites))
-})))
-
-#byqual$site_fprgt <- as.vector(cbind(tapply(byqual$qual, byqual$qual, function(i) mean(subset(byqual, qual >= i, select=site_fpr)))))
-byqual$site_fprgt <- as.vector(cbind(tapply(byqual$qual, byqual$qual, function(i) { 
-    s <- subset(byqual, qual >= i, select=c(site_fpc, sites))
-    return(sum(s$site_fpc) / sum(s$sites))
-})))
-
-byqual$cfa <- as.vector(cbind(tapply(byqual$qual, byqual$qual, function(i) sum(subset(byqual, qual <= i, select=alleles)) / sum(byqual$alleles))))
-
-byqual$cfs <- as.vector(cbind(tapply(byqual$qual, byqual$qual, function(i) sum(subset(byqual, qual <= i, select=sites)) / length(vcf$QUAL))))
-
-# inappropriate collapse via averaging of fdr
-#byqual$alternate_pdlt <- as.vector(cbind(tapply(byqual$qual, byqual$qual, function(i) mean(subset(byqual, qual <= i, select=fdr)))))
-
-byqual$alternate_pdr <- as.vector(cbind(tapply(byqual$qual, byqual$qual, function(i) { 
-    s <- subset(byqual, qual == i, select=c(fpc, alleles))
-    return(sum(s$fpc) / sum(s$alleles))
-})))
-
-# use this one
-byqual$alternate_pdlt <- as.vector(cbind(tapply(byqual$qual, byqual$qual, function(i) { 
-    s <- subset(byqual, qual <= i, select=c(fpc, alleles))
-    return(sum(s$fpc) / sum(s$alleles))
-})))
-
-#byqual$alternate_pdgt <- as.vector(cbind(tapply(byqual$qual, byqual$qual, function(i) mean(subset(byqual, qual >= i, select=fdr)))))
-byqual$alternate_pdgt <- as.vector(cbind(tapply(byqual$qual, byqual$qual, function(i) { 
-    s <- subset(byqual, qual >= i, select=c(fpc, alleles))
-    return(sum(s$fpc) / sum(s$alleles))
-})))
-
-nan.to.zero <- function(n) {
-    if (is.nan(n)) return(0) else return(n)
-}
-
-byqual$nrs <- as.vector(cbind(by(vcf, vcf$QUAL, function(i) {
-    return(nan.to.zero(sum(i[, tag.non_reference_sensitivity_count]) / sum(i[, tag.non_reference_sensitivity_normalizer])))
-})))
-
-byqual$nrd <- as.vector(cbind(by(vcf, vcf$QUAL, function(i) { 
-    return(nan.to.zero(sum(i[, tag.non_reference_discrepancy_count]) / sum(i[, tag.non_reference_discrepancy_normalizer])))
-})))
-
-byqual$nrslt <- as.vector(cbind(tapply(byqual$qual, byqual$qual, function(i) {
-    s <- subset(vcf, QUAL <= i, select=c(tag.non_reference_sensitivity_count, tag.non_reference_sensitivity_normalizer))
-    return(nan.to.zero(sum(s[, tag.non_reference_sensitivity_count]) / sum(s[, tag.non_reference_sensitivity_normalizer])))
-})))
-
-byqual$nrdlt <- as.vector(cbind(tapply(byqual$qual, byqual$qual, function(i) { 
-    s <- subset(vcf, QUAL <= i, select=c(tag.non_reference_discrepancy_count, tag.non_reference_discrepancy_normalizer))
-    return(nan.to.zero(sum(s[, tag.non_reference_discrepancy_count]) / sum(s[, tag.non_reference_discrepancy_normalizer])))
-})))
-
-byqual_gt10 <- subset(byqual, sites >= min_sites)
-
-
-if (FALSE) {
-pdf(paste(filename, '.', tag, '.PD.vs.QUAL.smooth.pdf', sep=''))
-par(cex=0.75)
-par(mar=c(5,4,4,5) + 0.1)
-plot(byqual$cfa, ylim=c(0,1.0),
-    xlab='QUAL', xaxt='n',
-    ylab='', yaxt='n', type='l', col='red')
-axis(2, at=seq(0,1,0.1), labels=seq(0,1,0.1))
-axis(1, at=seq(0,max(byqual$qual),10), labels=seq(0,max(byqual$qual),10), cex=0.75)
-grid(lty=5)
-par(new=T)
-title(paste(filename, 'positive discrepancy versus', tag, '(smoothed)'))
-par(new=T)
-countTicks <- seq(0,1,0.1) * vcf.numberOfSites
-axis(4, at=seq(0,1,0.1), labels=round(countTicks))
-mtext("number of sites", side=4, line=3, cex=0.75)
-par(new=T)
-#plot(byqual$alternate_pdlt, ylim=c(0,1.0), xlab='', xaxt='n', ylab='', yaxt='n', type='l', col='green')
-plot(byqual$site_fpr, ylim=c(0,1.0), xlab='', xaxt='n', ylab='', yaxt='n')
-par(new=T)
-lines(byqual$qual, predict(loess(byqual$alternate_pdr ~ byqual$qual, span=0.5)), col="green")
-par(new=T)
-plot(byqual$cfa, ylim=c(0,1.0), xlab='', xaxt='n', ylab='', yaxt='n', type='l', col='red')
-par(new=T)
-plot(byqual$cfs, ylim=c(0,1.0), xlab='', xaxt='n', ylab='', yaxt='n', type='l', col='purple')
-par(new=T)
-lines(byqual$qual, predict(loess(byqual$site_fpr ~ byqual$qual, span=0.5)), col="blue")
-par(new=T)
-lines(byqual$qual, predict(loess(byqual$nrs ~ byqual$qual, span=0.5)), col="magenta")
-par(new=T)
-lines(byqual$qual, predict(loess(byqual$nrd ~ byqual$qual, span=0.5)), col="brown")
-par(new=T, cex=0.65)
-mtext(paste("alternate genotype PD: ", round(vcf.positiveDiscrepancy, digits=4), ", site PD: ", round(1 - vcf.sitesTruePositive, digits=4), sep=''))
-par(new=T, cex=0.65)
-legend('topleft', c('cumulative fraction of alt alleles', 'cumulative fraction of sites', 'alt genotypes PD', 'site PD', 'non-ref sensitivity', 'non-ref discrepancy', 'site PD at QUAL'),
-    fill=c('red', 'purple', 'green', 'blue', 'magenta', 'brown', 'black'))
-garbage <- dev.off()
-}
-
-
-
-pdf(paste(filename, '.', tag, '.PD.vs.QUAL.cumulative.pdf', sep=''))
-par(cex=0.75)
-par(mar=c(5,4,4,5) + 0.1)
-plot(byqual$cfa, ylim=c(0,1.0),
-    xlab='QUAL', xaxt='n',
-    ylab='', yaxt='n', type='l', col='red')
-axis(2, at=seq(0,1,0.1), labels=seq(0,1,0.1))
-axis(1, at=seq(0,max(byqual$qual),10), labels=seq(0,max(byqual$qual),10), cex=0.75)
-grid(lty=5)
-par(new=T)
-title(paste(filename, 'positive discrepancy versus', tag, '(cumulative)'))
-par(new=T)
-countTicks <- seq(0,1,0.1) * vcf.numberOfSites
-axis(4, at=seq(0,1,0.1), labels=round(countTicks))
-mtext("number of sites", side=4, line=3, cex=0.75)
-par(new=T)
-plot(byqual_gt10$qual, byqual_gt10$site_fpr, ylim=c(0,1.0), xlab='', xaxt='n', ylab='', yaxt='n')
-#plot(byqual$site_fpr, ylim=c(0,1.0), xlab='', xaxt='n', ylab='', yaxt='n')
-par(new=T)
-plot(byqual$alternate_pdlt, ylim=c(0,1.0), xlab='', xaxt='n', ylab='', yaxt='n', type='l', col='green')
-par(new=T)
-plot(byqual$cfa, ylim=c(0,1.0), xlab='', xaxt='n', ylab='', yaxt='n', type='l', col='red')
-par(new=T)
-plot(byqual$cfs, ylim=c(0,1.0), xlab='', xaxt='n', ylab='', yaxt='n', type='l', col='purple')
-par(new=T)
-plot(byqual$site_fprlt, ylim=c(0,1.0), xlab='', xaxt='n', ylab='', yaxt='n', type='l', col='blue')
-par(new=T)
-plot(byqual$nrslt, ylim=c(0,1.0), xlab='', xaxt='n', ylab='', yaxt='n', type='l', col='magenta')
-par(new=T)
-plot(byqual$nrdlt, ylim=c(0,1.0), xlab='', xaxt='n', ylab='', yaxt='n', type='l', col='brown')
-par(new=T, cex=0.65)
-mtext(paste("alternate genotype PD: ", round(vcf.positiveDiscrepancy, digits=4), ", site PD: ", round(1 - vcf.sitesTruePositive, digits=4), sep=''))
-par(new=T, cex=0.65)
-legend('topleft', c('cumulative fraction of alt alleles', 'cumulative fraction of sites', 'alt genotypes PD', 'site PD', 'non-ref sensitivity', 'non-ref discrepancy', 'site PD at QUAL (>= 10 sites)'),
-    fill=c('red', 'purple', 'green', 'blue', 'magenta', 'brown', 'black'))
-garbage <- dev.off()
-
-
-
-pdf(paste(filename, '.', tag, '.PD.vs.QUAL.cumulative.simple.pdf', sep=''))
-par(cex=0.75)
-par(mar=c(5,4,4,5) + 0.1)
-plot(byqual$cfs, ylim=c(0,1.0),
-    xlab='QUAL', xaxt='n',
-    ylab='', yaxt='n', type='l', col='purple')
-axis(2, at=seq(0,1,0.1), labels=seq(0,1,0.1))
-axis(1, at=seq(0,max(byqual$qual),10), labels=seq(0,max(byqual$qual),10), cex=0.75)
-grid(lty=5)
-par(new=T)
-title(paste(filename, 'positive discrepancy versus', tag, '(cumulative)'))
-par(new=T)
-countTicks <- seq(0,1,0.1) * vcf.numberOfSites
-axis(4, at=seq(0,1,0.1), labels=round(countTicks))
-mtext("number of sites", side=4, line=3, cex=0.75)
-par(new=T)
-plot(byqual$site_fprlt, ylim=c(0,1.0), xlab='', xaxt='n', ylab='', yaxt='n', type='l', col='blue')
-par(new=T)
-plot(byqual_gt10$qual, byqual_gt10$site_fpr, ylim=c(0,1.0), xlab='', xaxt='n', ylab='', yaxt='n')
-par(new=T, cex=0.65)
-mtext(paste("site PD: ", round(1 - vcf.sitesTruePositive, digits=4), sep=''))
-par(new=T, cex=0.65)
-legend('topleft', c('cumulative fraction of sites', 'site PD', 'site PD at QUAL (>= 10 sites)'),
-    fill=c('purple', 'blue', 'black'))
-garbage <- dev.off()
-
-}
diff --git a/vcflib/bin/vcfplotaltdiscrepancy.sh b/vcflib/bin/vcfplotaltdiscrepancy.sh
deleted file mode 100755
index 0817895..0000000
--- a/vcflib/bin/vcfplotaltdiscrepancy.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/bash
-
-filename=$1
-tag=$2
-
-vcf2tsv \
-    | tsvsplit \
-        QUAL \
-        AC \
-        $tag.has_variant \
-    | tf2binary \
-    | vcfplotsitediscrepancy.r $filename $tag
diff --git a/vcflib/bin/vcfplotsitediscrepancy.r b/vcflib/bin/vcfplotsitediscrepancy.r
deleted file mode 100755
index d4f4ecb..0000000
--- a/vcflib/bin/vcfplotsitediscrepancy.r
+++ /dev/null
@@ -1,99 +0,0 @@
-#!/usr/bin/Rscript --vanilla --slave
-
-# get the input VCF tabular format, assert that sites must have AC > 0
-vcf <- subset(read.table(pipe('cat /dev/stdin'), header=T), AC > 0)
-
-filename <- commandArgs(TRUE)[1]
-tag <- commandArgs(TRUE)[2]
-
-tag.has_variant <- paste(tag, '.has_variant', sep='')
-
-vcf.numberOfSites <- length(vcf$AC)
-vcf.sitesTruePositive <- mean(vcf[, tag.has_variant])
-
-# false detection count
-x <- cbind(by(vcf$AC, vcf$AC, function(i) length(i)))
-
-byac <- data.frame(ac=as.numeric(rownames(x)), sites=as.vector(x))
-
-# count true positive sites
-byac$site_tpc <- as.vector(cbind(by(vcf[, tag.has_variant], vcf$AC, function(i) sum(i))))
-# fpc == false detection count
-byac$site_fpc <- byac$sites - byac$site_tpc
-# site detection fpr is 1 - true positive rate
-byac$site_fpr <- 1 - ( byac$site_tpc / byac$sites )
-
-#byac$site_fprlt <- as.vector(cbind(tapply(byac$ac, byac$ac, function(i) mean(subset(byac, ac <= i, select=site_fpr)))))
-byac$site_fprlt <- as.vector(cbind(tapply(byac$ac, byac$ac, function(i) { 
-    s <- subset(byac, ac <= i, select=c(site_fpc, sites))
-    return(sum(s$site_fpc) / sum(s$sites))
-})))
-
-#byac$site_fprgt <- as.vector(cbind(tapply(byac$ac, byac$ac, function(i) mean(subset(byac, ac >= i, select=site_fpr)))))
-byac$site_fprgt <- as.vector(cbind(tapply(byac$ac, byac$ac, function(i) { 
-    s <- subset(byac, ac >= i, select=c(site_fpc, sites))
-    return(sum(s$site_fpc) / sum(s$sites))
-})))
-
-byac$cfs <- as.vector(cbind(tapply(byac$ac, byac$ac, function(i) sum(subset(byac, ac <= i, select=sites)) / length(vcf$AC))))
-
-
-pdf(paste(filename, '.', tag, '.site_FDR.vs.AC.smooth.pdf', sep=''))
-par(cex=0.75)
-par(mar=c(5,4,4,5) + 0.1)
-plot(byac$cfs, ylim=c(0,1.0),
-    xlab='alternate allele count (AC)', xaxt='n',
-    ylab='false discovery rate (FDR)', yaxt='n', type='l', col='red')
-axis(2, at=seq(0,1,0.1), labels=seq(0,1,0.1))
-axis(1, at=seq(0,max(byac$ac),10), labels=seq(0,max(byac$ac),10), cex=0.75)
-grid(lty=5)
-par(new=T)
-title(paste(filename, 'putative site false discovery rate versus', tag, '(smoothed)'))
-par(new=T)
-countTicks <- seq(0,1,0.1) * vcf.numberOfSites
-axis(4, at=seq(0,1,0.1), labels=round(countTicks))
-par(col='red')
-mtext("number of sites", side=4, line=3, cex=0.75)
-par(col='black')
-par(new=T)
-plot(byac$site_fpr, ylim=c(0,1.0), xlab='', xaxt='n', ylab='', yaxt='n')
-par(new=T)
-lines(byac$ac, predict(loess(byac$site_fpr ~ byac$ac, span=0.5)), col="blue")
-par(new=T, cex=0.65)
-mtext(paste("site FDR: ", round(1 - vcf.sitesTruePositive, digits=4), sep=''))
-par(new=T, cex=0.65)
-legend('topleft', c('cumulative sites', 'site FDR (loess smoothed)', 'FDR at AC'),
-    fill=c('red', 'blue', 'black'))
-garbage <- dev.off()
-
-
-
-pdf(paste(filename, '.', tag, '.site_FDR.vs.AC.cumulative.pdf', sep=''))
-par(cex=0.75)
-par(mar=c(5,4,4,5) + 0.1)
-plot(byac$cfs, ylim=c(0,1.0),
-    xlab='alternate allele count (AC)', xaxt='n',
-    ylab='false discovery rate (FDR)', yaxt='n', type='l', col='red')
-axis(2, at=seq(0,1,0.1), labels=seq(0,1,0.1))
-axis(1, at=seq(0,max(byac$ac),10), labels=seq(0,max(byac$ac),10), cex=0.75)
-grid(lty=5)
-par(new=T)
-title(paste(filename, 'putative false discovery rate versus', tag, '(cumulative)'))
-par(new=T)
-countTicks <- seq(0,1,0.1) * vcf.numberOfSites
-axis(4, at=seq(0,1,0.1), labels=round(countTicks))
-par(col='red')
-mtext("number of sites", side=4, line=3, cex=0.75)
-par(col='black')
-par(new=T)
-plot(byac$site_fpr, ylim=c(0,1.0), xlab='', xaxt='n', ylab='', yaxt='n')
-par(new=T)
-plot(byac$site_fprgt, ylim=c(0,1.0), xlab='', xaxt='n', ylab='', yaxt='n', type='l', col='green')
-par(new=T)
-plot(byac$site_fprlt, ylim=c(0,1.0), xlab='', xaxt='n', ylab='', yaxt='n', type='l', col='blue')
-par(new=T, cex=0.65)
-mtext(paste("site FDR: ", round(1 - vcf.sitesTruePositive, digits=4), sep=''))
-par(new=T, cex=0.65)
-legend('topleft', c('cumulative sites', 'site FDR <= AC', 'site FDR >= AC', 'FDR at AC'),
-    fill=c('red', 'blue', 'green', 'black'))
-garbage <- dev.off()
diff --git a/vcflib/bin/vcfplottstv.sh b/vcflib/bin/vcfplottstv.sh
deleted file mode 100755
index 835b5ef..0000000
--- a/vcflib/bin/vcfplottstv.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/bash
-
-filename=$1
-title=$2
-
-vcf2tsv \
-    | tsvsplit \
-        QUAL \
-        AC \
-        AF \
-        TS \
-    | tf2binary \
-    | vcfplottstv.r $filename $title
diff --git a/vcflib/bin/vcfprintaltdiscrepancy.r b/vcflib/bin/vcfprintaltdiscrepancy.r
deleted file mode 100755
index ef33502..0000000
--- a/vcflib/bin/vcfprintaltdiscrepancy.r
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/Rscript --vanilla --slave
-
-# get the input VCF tabular format, assert that sites must have AC > 0
-vcf <- subset(read.table(pipe('cat /dev/stdin'), header=T), AC > 0)
-
-tag <- commandArgs(TRUE)[1]
-
-tag.genotypes_alternate_count <- paste(tag, '.genotypes.alternate_count', sep='')
-tag.non_reference_discrepancy_count <- paste(tag, '.site.non_reference_discrepancy.count', sep='')
-tag.non_reference_discrepancy_normalizer <- paste(tag, '.site.non_reference_discrepancy.normalizer', sep='')
-tag.non_reference_sensitivity_count <- paste(tag, '.site.non_reference_sensitivity.count', sep='')
-tag.non_reference_sensitivity_normalizer <- paste(tag, '.site.non_reference_sensitivity.normalizer', sep='')
-tag.alternate_positive_discrepancy <- paste(tag, '.site.alternate_positive_discrepancy', sep='')
-tag.alternate_negative_discrepancy <- paste(tag, '.site.alternate_negative_discrepancy', sep='')
-tag.has_variant <- paste(tag, '.has_variant', sep='')
-
-vcf.numberOfSites <- length(vcf[, tag.genotypes_alternate_count])
-vcf.totalAltAlleles <- sum(vcf[, tag.genotypes_alternate_count])
-vcf.positiveDiscrepancy <- sum(vcf[, tag.alternate_positive_discrepancy]) / sum(vcf[, tag.genotypes_alternate_count])
-vcf.negativeDiscrepancy <- sum(vcf[, tag.alternate_negative_discrepancy]) / sum(vcf[, tag.genotypes_alternate_count])
-vcf.sitesTruePositive <- sum(vcf[, tag.has_variant]) / nrow(vcf)
-
-cat('number of sites', vcf.numberOfSites, '\n')
-cat('total alternate alleles', vcf.totalAltAlleles, '\n')
-cat('positive discrepancy', vcf.positiveDiscrepancy, '\n')
-cat('negative discrepancy', vcf.negativeDiscrepancy, '\n')
-
-x <- cbind(by(vcf, vcf$AC,
-    function(x) {
-        sum(x[, tag.alternate_positive_discrepancy]) / sum(x[, tag.genotypes_alternate_count])
-    }))
-
-byac <- data.frame(ac=as.numeric(rownames(x)), fdr=as.vector(x))
-
-print(byac)
-
-
diff --git a/vcflib/bin/vcfprintaltdiscrepancy.sh b/vcflib/bin/vcfprintaltdiscrepancy.sh
deleted file mode 100755
index 1df0a65..0000000
--- a/vcflib/bin/vcfprintaltdiscrepancy.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/bash
-
-tag=$1
-
-vcf2tsv \
-    | tsvsplit \
-        QUAL \
-        AC \
-        $tag.has_variant \
-        $tag.site.alternate_negative_discrepancy \
-        $tag.site.alternate_positive_discrepancy \
-        $tag.genotypes.alternate_count \
-        $tag.site.non_reference_sensitivity.count \
-        $tag.site.non_reference_sensitivity.normalizer \
-        $tag.site.non_reference_discrepancy.count \
-        $tag.site.non_reference_discrepancy.normalizer \
-    | tf2binary \
-    | vcfprintaltdiscrepancy.r $tag
diff --git a/vcflib/bin/vcfqualfilter b/vcflib/bin/vcfqualfilter
deleted file mode 100755
index 8fe970f..0000000
--- a/vcflib/bin/vcfqualfilter
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/bin/perl
-#
-#
-
-use Getopt::Long;
-my $cutoff = -1;
-my $max = -1;
-my $indel = 0;
-my $snp = 0;
-$result = GetOptions ("c|cutoff=i" => \$cutoff,
-                      "m|max=i" => \$max,
-                      "i|indel=i"   => \$indel,
-                      "s|snp=i"  => \$snp);
-
-
-while (<STDIN>) {
-    if ($_ =~ /^#/) {
-        print $_;
-        next;
-    }
-
-    if ($_ =~ /^(.*?\t){6}(.*?)\t/) {
-        $qual = $1;
-    }
-    if ($cutoff ne -1 and $qual >= $cutoff and ($max eq -1 or $qual <= $max)) {
-        print $_;
-    } elsif ($snp and $_ =~ "SNP" and $qual >= $snp) {
-        print $_;
-    } elsif ($indel and $_ =~ "INS\|DEL" and $qual >= $indel) {
-        print $_;
-    }
-}
diff --git a/vcflib/bin/vcfregionreduce b/vcflib/bin/vcfregionreduce
deleted file mode 100755
index fde0938..0000000
--- a/vcflib/bin/vcfregionreduce
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-
-if [ $# -ne 2 ];
-then
-    echo "Usage: $0 [region file] [directory]"
-    echo
-    echo "Generates \`basename directory\`.vcf.gz, which is the concatenation"
-    echo "of files in the directory named [directory]/[region1].vcf.gz,"
-    echo "[directory]/[region2].vcf.gz, etc. in the order in which they"
-    echo "occur in the region file."
-    echo
-    echo "A tabix index is subsequently generated."
-    exit 1
-fi
-
-regionfile=$1
-mergedir=$2
-mergename=$(basename $mergedir)
-vcfgenotypes=$mergename.vcf.gz
-#vcfsites=$mergename.sites.vcf.gz
-
-firstfile=$mergedir/$(head -1 $regionfile).vcf.gz
-files=$(for region in $(cat $regionfile); do echo $mergedir/$region.vcf.gz; done)
-
-( zcat $firstfile | head -1000 | grep ^#
-for file in $files
-do
-    zcat $file | grep -v "^#"
-done ) | ( bgzip >$vcfgenotypes && tabix -p vcf $vcfgenotypes )
diff --git a/vcflib/bin/vcfregionreduce_and_cut b/vcflib/bin/vcfregionreduce_and_cut
deleted file mode 100755
index f15dc2c..0000000
--- a/vcflib/bin/vcfregionreduce_and_cut
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/bash
-
-if [ $# -ne 2 ];
-then
-    echo "Usage: $0 [region file] [directory]"
-    echo
-    echo "Generates \`basename directory\`.vcf.gz and \`basename directory\`.sites.vcf.gz"
-    echo "which are the concatenation of files in the directory named [directory]/[region1].vcf.gz,"
-    echo "[directory]/[region2].vcf.gz, etc. in the order in which they occur in the region file."
-    echo
-    echo "Tabix indexes are simultaneously generated."
-    exit 1
-fi
-
-regionfile=$1
-mergedir=$2
-mergename=$(basename $mergedir)
-vcfgenotypes=$mergename.vcf.gz
-vcfsites=$mergename.sites.vcf.gz
-
-regions=$(cat $regionfile)
-
-firstfile=$mergedir/$(echo $regions | cut -f 1 -d\  ).vcf.gz
-files=$(for region in $regions; do echo $mergedir/$region.vcf.gz; done)
-
-( zcat $firstfile | head -1000 | grep ^#
-for file in $files
-do
-    zcat $file | grep -v "^#"
-done ) | uniq | pee \
-        "bgzip >$vcfgenotypes && tabix -p vcf $vcfgenotypes" \
-        "cut -f -8 | bgzip >$vcfsites && tabix -p vcf $vcfsites"
diff --git a/vcflib/bin/vcfregionreduce_pipe b/vcflib/bin/vcfregionreduce_pipe
deleted file mode 100755
index 8a21782..0000000
--- a/vcflib/bin/vcfregionreduce_pipe
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-
-if [ $# -ne 2 ];
-then
-    echo "Usage: $0 [region file] [directory]"
-    echo
-    echo "Generates \`basename directory\`.vcf.gz, which is the concatenation"
-    echo "of files in the directory named [directory]/[region1].vcf.gz,"
-    echo "[directory]/[region2].vcf.gz, etc. in the order in which they"
-    echo "occur in the region file."
-    echo
-    echo "A tabix index is subsequently generated."
-    exit 1
-fi
-
-regionfile=$1
-mergedir=$2
-mergename=$(basename $mergedir)
-vcfgenotypes=$mergename.vcf.gz
-#vcfsites=$mergename.sites.vcf.gz
-
-firstfile=$mergedir/$(head -1 $regionfile).vcf.gz
-files=$(for region in $(cat $regionfile); do echo $mergedir/$region.vcf.gz; done)
-
-zcat $firstfile | head -1000 | grep ^#
-for file in $files
-do
-    zcat $file | grep -v "^#"
-done
diff --git a/vcflib/bin/vcfregionreduce_uncompressed b/vcflib/bin/vcfregionreduce_uncompressed
deleted file mode 100755
index 41c7528..0000000
--- a/vcflib/bin/vcfregionreduce_uncompressed
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-
-if [ $# -ne 2 ];
-then
-    echo "Usage: $0 [region file] [directory]"
-    echo
-    echo "Generates \`basename directory\`.vcf.gz, which is the concatenation"
-    echo "of files in the directory named [directory]/[region1].vcf.gz,"
-    echo "[directory]/[region2].vcf.gz, etc. in the order in which they"
-    echo "occur in the region file."
-    echo
-    echo "A tabix index is subsequently generated."
-    exit 1
-fi
-
-regionfile=$1
-mergedir=$2
-mergename=$(basename $mergedir)
-vcfgenotypes=$mergename.vcf.gz
-#vcfsites=$mergename.sites.vcf.gz
-
-firstfile=$mergedir/$(head -1 $regionfile).vcf
-files=$(for region in $(cat $regionfile); do echo $mergedir/$region.vcf; done)
-
-( cat $firstfile | head -1000 | grep ^#
-for file in $files
-do
-    cat $file | grep -v "^#"
-done ) | ( bgzip >$vcfgenotypes && tabix -p vcf $vcfgenotypes )
diff --git a/vcflib/bin/vcfsnps b/vcflib/bin/vcfsnps
deleted file mode 100755
index b2b8b79..0000000
--- a/vcflib/bin/vcfsnps
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/perl
-#
-
-while (<STDIN>) {
-    if ($_ =~ /^#/) {
-        print;
-    } else {
-        $_ =~ /^(.+?)\t(.+?)\t(.+?)\t(.+?)\t(.+?)\t/;
-        $chrom = $1;
-        $pos = $2;
-        $tag = $3;
-        $ref = $4;
-        $alts = $5;
-        $hasindel = 0;
-        @alts = split(/,/, $alts);
-        $snp = 1;
-        foreach $alt (@alts) {
-            if (length($ref) > 1 || length($alt) != length($ref)) {
-                $snp = 0;
-            }
-        }
-        if ($snp) {
-            print;
-        }
-    }
-}
diff --git a/vcflib/bin/vcfsort b/vcflib/bin/vcfsort
deleted file mode 100755
index def75ee..0000000
--- a/vcflib/bin/vcfsort
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-head -1000 $1 | grep "^#"; cat $@ | grep -v "^#" | sort -k1,1d -k2,2n
diff --git a/vcflib/bin/vcfvarstats b/vcflib/bin/vcfvarstats
deleted file mode 100755
index 1f645f7..0000000
--- a/vcflib/bin/vcfvarstats
+++ /dev/null
@@ -1,225 +0,0 @@
-#!/usr/bin/perl
-#
-
-use IPC::Open2;
-
-sub revcomplement {
-    $revcom = reverse shift;
-    $revcom =~ tr/ACGTacgt/TGCAtgca/;
-    return $revcom;
-}
-
-$reference = $ARGV[0];
-
-if ($reference) {
-    $pid = open2(\*FASTAHACK_OUT, \*FASTAHACK_IN, "fastahack -c $reference");
-}
-
-#print FASTAHACK_IN "1:10000\n";
-#$result = <FASTAHACK_OUT>;
-#print $result;
-
-
-#open(VCF, $file);
-
-$ts = 0;
-$tv = 0;
-$cpg = 0;
-$total = 0;
-$snp = 0;
-$mnp = 0;
-$mnplen = 0;
-%mnp = ();
-$ins = 0;
-$inslen = 0;
-%ins = ();
-$del = 0;
-$dellen = 0;
-%del = ();
-
-%dint = (); # di-nucleotide distribution
-
-while (<STDIN>) {
-    if ($_ =~ /^#/) {
-        next;
-    } else {
-        $_ =~ /^(.+?)\t(.+?)\t(.+?)\t(.+?)\t(.+?)\t/;
-        $chrom = $1;
-        $pos = $2;
-        $tag = $3;
-        $ref = $4;
-        $alt = $5;
-        #print "chrom: $chrom, pos: $pos, ref: $ref, alt: $alt\n";
-    }
-
-    $diff = length($ref) - length($alt);
-
-    $is_snp = 0;
-    if ($_ =~ /SNP/) {
-        $is_snp = 1;
-        $snp += 1;
-        # get di-nt's
-        if ($reference) {
-            if ($_ =~ /^(\d+)\t(\d+)/) {
-                $seq = $1;
-                $start = $2;
-                $end = $2 + 1;
-                print FASTAHACK_IN "$seq:$start..$end\n";
-                $dibp = <FASTAHACK_OUT>;
-                chomp $dibp;
-                $dint{$dibp} += 1;
-            }
-        }
-    } elsif ($diff eq 0 and length($ref) eq 1) {
-        $snp += 1;
-        $is_snp = 1;
-    } elsif ($diff eq 0 and length($ref) gt 1) {
-        $mnp += 1;
-        $mnplen += length($ref);
-        $mnp{length($ref)} += 1;
-    }
-    if ($is_snp) {
-        if ((($ref eq "A" and $alt eq "G") or ($ref eq "G" and $alt eq "A"))
-                or
-            (($ref eq "C" and $alt eq "T") or ($ref eq "T" and $alt eq "C"))) {
-            $ts += 1;
-        } else {
-            $tv += 1;
-        }
-        if ($_ =~ /CpG/) { $cpg += 1; }
-    }
-
-    if ($diff lt 0) {
-        $len = abs($diff);
-        $ins += 1;
-        $inslen += $len;
-        $ins{$len} += 1;
-    }
-
-    if ($diff gt 0) {
-        $len = abs($diff);
-        $del += 1;
-        $dellen += $len;
-        $del{$len} += 1;
-    }
-    #elsif (length($ref) > 1 and $diff eq 0) {
-    #    print $_ . "\n";
-    #    $mnp += 1;
-    #    $mnplen += length($ref);
-    #    $mnp{length($ref)} += 1;
-    #}
-
-    $total += 1;
-}
-
-if ($total == 0) {
-    die "no VCF records read on stdin\n";
-}
-
-print "total variants:\t$total" . "\n";
-print "\n";
-if ($snp > 0) {
-    print "total snps:\t$snp\n";
-    print "transitions:\t$ts\n";
-    print "transversions:\t$tv\n";
-    if ($tv > 0) {
-        print "ts/tv ratio:\t" . ($ts / $tv) . "\n";
-    }
-    print "CpG sites:\t$cpg\n";
-    if ($cpg > 0) {
-        print "CpG/total snps:\t" . ($cpg / $snp) . "\n";
-    }
-}
-
-if (($ins + $del) > 0) {
-    print "\n";
-    print "total indels:\t" . ($ins + $del) . "\n";
-    print "insertions:\t$ins\t$inslen bp\n";
-    print "deletions:\t$del\t$dellen bp\n";
-
-    $max = 0;
-    while ( my ($size, $count) = each(%ins) ) {
-        if ($size > $max) { $max = $size; }
-    }
-    while ( my ($size, $count) = each(%del) ) {
-        if ($size > $max) { $max = $size; }
-    }
-
-    print "\n";
-
-    if ($inslen > 0 and $dellen > 0) {
-        $indel_length_ratio = $inslen / $dellen;
-        print "ins/del length ratio:\t$indel_length_ratio\n";
-        print "\n";
-        print "indel size frequency distribution\n";
-        print "size\tins\tdel\tins/del\tcurr/prev\n";
-
-        $last_delcount = 0;
-        $last_inscount = 0;
-        $last_ratio_del = 0;
-        $last_ratio_ins = 0;
-        for (1 .. $max) {
-            $inscount = $ins{$_};
-            $delcount = $del{$_};
-            if ($last_delcount != 0) {
-                $last_ratio_del = $delcount / $last_delcount;
-            }
-            if ($last_inscount != 0) {
-                $last_ratio_ins = $inscount / $last_inscount;
-            }
-            $last_delcount = $delcount;
-            $last_inscount = $inscount;
-            if ($inscount > 0 and $delcount > 0) {
-                $ratio = $inscount / $delcount;
-            } else {
-                $ratio = "";
-            }
-            print "$_\t$inscount\t$delcount\t"
-            . sprintf("%.3f", $ratio);
-            if ($last_ratio_ins != 0 or $last_ratio_del != 0) {
-                print "\t";
-                if ($last_ratio_ins != 0) {
-                    print sprintf("%.3f", $last_ratio_ins);
-                }
-                print "\t";
-                if ($last_ratio_del != 0) {
-                    print sprintf("%.3f", $last_ratio_del);
-                }
-                print "\n";
-            } else {
-                print "\n";
-            }
-        }
-        # FIXME
-        #print "\t\t\t\t" . sprintf("%.3f", $even_odd_ratio_sum_ins / $ins)
-        # . "\t" . sprintf("%.3f", $even_odd_ratio_sum_del / $del);
-    }
-}
-
-if ($mnplen > 0) {
-    print "\n";
-    print "total mnps:\t$mnp\n";
-    print "mnps length:\t$mnplen\n";
-    print "mnp size distribution\n";
-    $max = 0;
-    while ( my ($size, $count) = each(%mnp) ) {
-        if ($size > $max) { $max = $size; }
-    }
-    print "size\tcount\n";
-    for (2 .. $max) {
-        print $_ . "\t" . $mnp{$_} . "\n";
-    }
-}
-
-if ($reference) {
-
-    print "\n";
-
-    print "di-nucleotide distribution for SNPs\n";
-    print "di-nt\tcount\tcount/(total snps / 16)\n";
-    while ( my ($dibp, $count) = each(%dint) ) {
-        print "$dibp\t$count\t" . ($count / ($snp / 16)) . "\n";
-    }
-
-}
-
diff --git a/vcflib/fastahack/.gitignore b/vcflib/fastahack/.gitignore
deleted file mode 100644
index 9c2ec17..0000000
--- a/vcflib/fastahack/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-*.o
-fastahack
\ No newline at end of file
diff --git a/vcflib/fastahack/Fasta.cpp b/vcflib/fastahack/Fasta.cpp
deleted file mode 100644
index 96ab114..0000000
--- a/vcflib/fastahack/Fasta.cpp
+++ /dev/null
@@ -1,317 +0,0 @@
-// ***************************************************************************
-// FastaIndex.cpp (c) 2010 Erik Garrison <erik.garrison at bc.edu>
-// Marth Lab, Department of Biology, Boston College
-// All rights reserved.
-// ---------------------------------------------------------------------------
-// Last modified: 9 February 2010 (EG)
-// ---------------------------------------------------------------------------
-
-#include "Fasta.h"
-
-FastaIndexEntry::FastaIndexEntry(string name, int length, long long offset, int line_blen, int line_len)
-    : name(name)
-    , length(length)
-    , offset(offset)
-    , line_blen(line_blen)
-    , line_len(line_len)
-{}
-
-FastaIndexEntry::FastaIndexEntry(void) // empty constructor
-{ clear(); }
-
-FastaIndexEntry::~FastaIndexEntry(void)
-{}
-
-void FastaIndexEntry::clear(void)
-{
-    name = "";
-    length = 0;
-    offset = -1;  // no real offset will ever be below 0, so this allows us to
-                  // check if we have already recorded a real offset
-    line_blen = 0;
-    line_len = 0;
-}
-
-ostream& operator<<(ostream& output, const FastaIndexEntry& e) {
-    // just write the first component of the name, for compliance with other tools
-    output << split(e.name, ' ').at(0) << "\t" << e.length << "\t" << e.offset << "\t" <<
-        e.line_blen << "\t" << e.line_len;
-    return output;  // for multiple << operators.
-}
-
-FastaIndex::FastaIndex(void) 
-{}
-
-void FastaIndex::readIndexFile(string fname) {
-    string line;
-    long long linenum = 0;
-    indexFile.open(fname.c_str(), ifstream::in);
-    if (indexFile.is_open()) {
-        while (getline (indexFile, line)) {
-            ++linenum;
-            // the fai format defined in samtools is tab-delimited, every line being:
-            // fai->name[i], (int)x.len, (long long)x.offset, (int)x.line_blen, (int)x.line_len
-            vector<string> fields = split(line, '\t');
-            if (fields.size() == 5) {  // if we don't get enough fields then there is a problem with the file
-                // note that fields[0] is the sequence name
-                char* end;
-                string name = split(fields[0], " \t").at(0);  // key by first token of name
-                sequenceNames.push_back(name);
-                this->insert(make_pair(name, FastaIndexEntry(fields[0], atoi(fields[1].c_str()),
-                                                    strtoll(fields[2].c_str(), &end, 10),
-                                                    atoi(fields[3].c_str()),
-                                                    atoi(fields[4].c_str()))));
-            } else {
-                cerr << "Warning: malformed fasta index file " << fname << 
-                    "does not have enough fields @ line " << linenum << endl;
-                cerr << line << endl;
-                exit(1);
-            }
-        }
-    } else {
-        cerr << "could not open index file " << fname << endl;
-        exit(1);
-    }
-}
-
-// for consistency this should be a class method
-bool fastaIndexEntryCompare ( FastaIndexEntry a, FastaIndexEntry b) { return (a.offset<b.offset); }
-
-ostream& operator<<(ostream& output, FastaIndex& fastaIndex) {
-    vector<FastaIndexEntry> sortedIndex;
-    for(vector<string>::const_iterator it = fastaIndex.sequenceNames.begin(); it != fastaIndex.sequenceNames.end(); ++it)
-    {
-        sortedIndex.push_back(fastaIndex[*it]);
-    }
-    sort(sortedIndex.begin(), sortedIndex.end(), fastaIndexEntryCompare);
-    for( vector<FastaIndexEntry>::iterator fit = sortedIndex.begin(); fit != sortedIndex.end(); ++fit) {
-        output << *fit << endl;
-    }
-}
-
-void FastaIndex::indexReference(string refname) {
-    // overview:
-    //  for line in the reference fasta file
-    //  track byte offset from the start of the file
-    //  if line is a fasta header, take the name and dump the last sequnece to the index
-    //  if line is a sequence, add it to the current sequence
-    //cerr << "indexing fasta reference " << refname << endl;
-    string line;
-    FastaIndexEntry entry;  // an entry buffer used in processing
-    entry.clear();
-    int line_length = 0;
-    long long offset = 0;  // byte offset from start of file
-    long long line_number = 0; // current line number
-    bool mismatchedLineLengths = false; // flag to indicate if our line length changes mid-file
-                                        // this will be used to raise an error
-                                        // if we have a line length change at
-                                        // any line other than the last line in
-                                        // the sequence
-    bool emptyLine = false;  // flag to catch empty lines, which we allow for
-                             // index generation only on the last line of the sequence
-    ifstream refFile;
-    refFile.open(refname.c_str());
-    if (refFile.is_open()) {
-        while (getline(refFile, line)) {
-            ++line_number;
-            line_length = line.length();
-            if (line[0] == ';') {
-                // fasta comment, skip
-            } else if (line[0] == '+') {
-                // fastq quality header
-                getline(refFile, line);
-                line_length = line.length();
-                offset += line_length + 1;
-                // get and don't handle the quality line
-                getline(refFile, line);
-                line_length = line.length();
-            } else if (line[0] == '>' || line[0] == '@') { // fasta /fastq header
-                // if we aren't on the first entry, push the last sequence into the index
-                if (entry.name != "") {
-                    mismatchedLineLengths = false; // reset line length error tracker for every new sequence
-                    emptyLine = false;
-                    flushEntryToIndex(entry);
-                    entry.clear();
-                }
-                entry.name = line.substr(1, line_length - 1);
-            } else { // we assume we have found a sequence line
-                if (entry.offset == -1) // NB initially the offset is -1
-                    entry.offset = offset;
-                entry.length += line_length;
-                if (entry.line_len) {
-                    //entry.line_len = entry.line_len ? entry.line_len : line_length + 1;
-                    if (mismatchedLineLengths || emptyLine) {
-                        if (line_length == 0) {
-                            emptyLine = true; // flag empty lines, raise error only if this is embedded in the sequence
-                        } else {
-                            if (emptyLine) {
-                                cerr << "ERROR: embedded newline";
-                            } else {
-                                cerr << "ERROR: mismatched line lengths";
-                            }
-                            cerr << " at line " << line_number << " within sequence " << entry.name <<
-                                endl << "File not suitable for fasta index generation." << endl;
-                            exit(1);
-                        }
-                    }
-                    // this flag is set here and checked on the next line
-                    // because we may have reached the end of the sequence, in
-                    // which case a mismatched line length is OK
-                    if (entry.line_len != line_length + 1) {
-                        mismatchedLineLengths = true;
-                        if (line_length == 0) {
-                            emptyLine = true; // flag empty lines, raise error only if this is embedded in the sequence
-                        }
-                    }
-                } else {
-                    entry.line_len = line_length + 1; // first line
-                }
-                entry.line_blen = entry.line_len - 1;
-            }
-            offset += line_length + 1;
-        }
-        // we've hit the end of the fasta file!
-        // flush the last entry
-        flushEntryToIndex(entry);
-    } else {
-        cerr << "could not open reference file " << refname << " for indexing!" << endl;
-        exit(1);
-    }
-}
-
-void FastaIndex::flushEntryToIndex(FastaIndexEntry& entry) {
-    string name = split(entry.name, " \t").at(0);  // key by first token of name
-    sequenceNames.push_back(name);
-    this->insert(make_pair(name, FastaIndexEntry(entry.name, entry.length,
-                        entry.offset, entry.line_blen,
-                        entry.line_len)));
-
-}
-
-void FastaIndex::writeIndexFile(string fname) {
-    //cerr << "writing fasta index file " << fname << endl;
-    ofstream file;
-    file.open(fname.c_str()); 
-    if (file.is_open()) {
-        file << *this;
-    } else { 
-        cerr << "could not open index file " << fname << " for writing!" << endl;
-        exit(1);
-    }
-}
-
-FastaIndex::~FastaIndex(void) {
-    indexFile.close();
-}
-
-FastaIndexEntry FastaIndex::entry(string name) {
-    FastaIndex::iterator e = this->find(name);
-    if (e == this->end()) {
-        cerr << "unable to find FASTA index entry for '" << name << "'" << endl;
-        exit(1);
-    } else {
-        return e->second;
-    }
-}
-
-string FastaIndex::indexFileExtension() { return ".fai"; }
-
-/*
-FastaReference::FastaReference(string reffilename) {
-}
-*/
-
-void FastaReference::open(string reffilename) {
-    filename = reffilename;
-    if (!(file = fopen(filename.c_str(), "r"))) {
-        cerr << "could not open " << filename << endl;
-        exit(1);
-    }
-    index = new FastaIndex();
-    struct stat stFileInfo; 
-    string indexFileName = filename + index->indexFileExtension(); 
-    // if we can find an index file, use it
-    if(stat(indexFileName.c_str(), &stFileInfo) == 0) { 
-        index->readIndexFile(indexFileName);
-    } else { // otherwise, read the reference and generate the index file in the cwd
-        cerr << "index file " << indexFileName << " not found, generating..." << endl;
-        index->indexReference(filename);
-        index->writeIndexFile(indexFileName);
-    }
-}
-
-FastaReference::~FastaReference(void) {
-    fclose(file);
-    delete index;
-}
-
-string FastaReference::getSequence(string seqname) {
-    FastaIndexEntry entry = index->entry(seqname);
-    int newlines_in_sequence = entry.length / entry.line_blen;
-    int seqlen = newlines_in_sequence  + entry.length;
-    char* seq = (char*) calloc (seqlen + 1, sizeof(char));
-    fseek64(file, entry.offset, SEEK_SET);
-    fread(seq, sizeof(char), seqlen, file);
-    seq[seqlen] = '\0';
-    char* pbegin = seq;
-    char* pend = seq + (seqlen/sizeof(char));
-    pend = remove(pbegin, pend, '\n');
-    pend = remove(pbegin, pend, '\0');
-    string s = seq;
-    free(seq);
-    s.resize((pend - pbegin)/sizeof(char));
-    return s;
-}
-
-// TODO cleanup; odd function.  use a map
-string FastaReference::sequenceNameStartingWith(string seqnameStart) {
-    try {
-        return (*index)[seqnameStart].name;
-    } catch (exception& e) {
-        cerr << e.what() << ": unable to find index entry for " << seqnameStart << endl;
-        exit(1);
-    }
-}
-
-string FastaReference::getTargetSubSequence(FastaRegion& target) {
-    if (target.startPos == -1) {
-        return getSequence(target.startSeq);
-    } else {
-        return getSubSequence(target.startSeq, target.startPos - 1, target.length());
-    }
-}
-
-string FastaReference::getSubSequence(string seqname, int start, int length) {
-    FastaIndexEntry entry = index->entry(seqname);
-    length = min(length, entry.length - start);
-    if (start < 0 || length < 1) {
-        //cerr << "Empty sequence" << endl;
-        return "";
-    }
-    // we have to handle newlines
-    // approach: count newlines before start
-    //           count newlines by end of read
-    //             subtracting newlines before start find count of embedded newlines
-    int newlines_before = start > 0 ? (start - 1) / entry.line_blen : 0;
-    int newlines_by_end = (start + length - 1) / entry.line_blen;
-    int newlines_inside = newlines_by_end - newlines_before;
-    int seqlen = length + newlines_inside;
-    char* seq = (char*) calloc (seqlen + 1, sizeof(char));
-    fseek64(file, (off_t) (entry.offset + newlines_before + start), SEEK_SET);
-    fread(seq, sizeof(char), (off_t) seqlen, file);
-    seq[seqlen] = '\0';
-    char* pbegin = seq;
-    char* pend = seq + (seqlen/sizeof(char));
-    pend = remove(pbegin, pend, '\n');
-    pend = remove(pbegin, pend, '\0');
-    string s = seq;
-    free(seq);
-    s.resize((pend - pbegin)/sizeof(char));
-    return s;
-}
-
-long unsigned int FastaReference::sequenceLength(string seqname) {
-    FastaIndexEntry entry = index->entry(seqname);
-    return entry.length;
-}
-
diff --git a/vcflib/fastahack/Fasta.h b/vcflib/fastahack/Fasta.h
deleted file mode 100644
index d3f8eda..0000000
--- a/vcflib/fastahack/Fasta.h
+++ /dev/null
@@ -1,82 +0,0 @@
-// ***************************************************************************
-// FastaIndex.h (c) 2010 Erik Garrison <erik.garrison at bc.edu>
-// Marth Lab, Department of Biology, Boston College
-// All rights reserved.
-// ---------------------------------------------------------------------------
-// Last modified: 5 February 2010 (EG)
-// ---------------------------------------------------------------------------
-
-#ifndef _FASTA_H
-#define _FASTA_H
-
-#include <map>
-#include <iostream>
-#include <fstream>
-#include <vector>
-#include <stdint.h>
-#include <stdio.h>
-#include <algorithm>
-#include "LargeFileSupport.h"
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include "split.h"
-#include <stdlib.h>
-#include <ctype.h>
-#include <unistd.h>
-#include "Region.h"
-
-using namespace std;
-
-class FastaIndexEntry {
-    friend ostream& operator<<(ostream& output, const FastaIndexEntry& e);
-    public:
-        FastaIndexEntry(string name, int length, long long offset, int line_blen, int line_len);
-        FastaIndexEntry(void);
-        ~FastaIndexEntry(void);
-        string name;  // sequence name
-        int length;  // length of sequence
-        long long offset;  // bytes offset of sequence from start of file
-        int line_blen;  // line length in bytes, sequence characters
-        int line_len;  // line length including newline
-        void clear(void);
-};
-
-class FastaIndex : public map<string, FastaIndexEntry> {
-    friend ostream& operator<<(ostream& output, FastaIndex& i);
-    public:
-        FastaIndex(void);
-        ~FastaIndex(void);
-        vector<string> sequenceNames;
-        map<string, unsigned int> sequenceID;
-        void indexReference(string refName);
-        void readIndexFile(string fname);
-        void writeIndexFile(string fname);
-        ifstream indexFile;
-        FastaIndexEntry entry(string key);
-        void flushEntryToIndex(FastaIndexEntry& entry);
-        string indexFileExtension(void);
-};
-
-class FastaReference {
-    public:
-        void open(string reffilename);
-        bool usingmmap;
-        string filename;
-        FastaReference(void) : usingmmap(false) { }
-        ~FastaReference(void);
-        FILE* file;
-        void* filemm;
-        size_t filesize;
-        FastaIndex* index;
-        vector<FastaIndexEntry> findSequencesStartingWith(string seqnameStart);
-        string getSequence(string seqname);
-        // potentially useful for performance, investigate
-        // void getSequence(string seqname, string& sequence);
-        string getSubSequence(string seqname, int start, int length);
-        string getTargetSubSequence(FastaRegion& target);
-        string sequenceNameStartingWith(string seqnameStart);
-        unsigned int getSequenceID(string seqname);
-        long unsigned int sequenceLength(string seqname);
-};
-
-#endif
diff --git a/vcflib/fastahack/FastaHack.cpp b/vcflib/fastahack/FastaHack.cpp
deleted file mode 100644
index 07cc445..0000000
--- a/vcflib/fastahack/FastaHack.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-#include "Fasta.h"
-#include <stdlib.h>
-#include <getopt.h>
-#include "disorder.h"
-#include "Region.h"
-
-void printSummary() {
-    cerr << "usage: fastahack [options] <fasta reference>" << endl
-         << endl
-         << "options:" << endl 
-         << "    -i, --index          generate fasta index <fasta reference>.fai" << endl
-         << "    -r, --region REGION  print the specified region" << endl
-         << "    -c, --stdin          read a stream of line-delimited region specifiers on stdin" << endl
-         << "                         and print the corresponding sequence for each on stdout" << endl
-         << "    -e, --entropy        print the shannon entropy of the specified region" << endl
-         << "    -d, --dump           print the fasta file in the form 'seq_name <tab> sequence'" << endl
-         << endl
-         << "REGION is of the form <seq>, <seq>:<start>[sep]<end>, <seq1>:<start>[sep]<seq2>:<end>" << endl
-         << "where start and end are 1-based, and the region includes the end position." << endl
-         << "[sep] is \"-\" or \"..\"" << endl
-         << endl
-         << "Specifying a sequence name alone will return the entire sequence, specifying" << endl
-         << "range will return that range, and specifying a single coordinate pair, e.g." << endl
-         << "<seq>:<start> will return just that base." << endl
-         << endl
-         << "author: Erik Garrison <erik.garrison at bc.edu>" << endl;
-}
-
-
-int main (int argc, char** argv) {
-
-    string command;
-    string fastaFileName;
-    string seqname;
-    string longseqname;
-    long long start;
-    long long length;
-    bool dump = false;
-
-    bool buildIndex = false;  // flag to force index building
-    bool printEntropy = false;  // entropy printing
-    bool readRegionsFromStdin = false;
-    //bool printLength = false;
-    string region;
-
-    int c;
-
-    while (true) {
-        static struct option long_options[] =
-        {
-            /* These options set a flag. */
-            //{"verbose", no_argument,       &verbose_flag, 1},
-            //{"brief",   no_argument,       &verbose_flag, 0},
-            {"help", no_argument, 0, 'h'},
-            {"index",  no_argument, 0, 'i'},
-            //{"length",  no_argument, &printLength, true},
-            {"entropy", no_argument, 0, 'e'},
-            {"region", required_argument, 0, 'r'},
-            {"stdin", no_argument, 0, 'c'},
-            {0, 0, 0, 0}
-        };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "hciedr:",
-                         long_options, &option_index);
-
-      /* Detect the end of the options. */
-          if (c == -1)
-            break;
- 
-          switch (c)
-            {
-            case 0:
-            /* If this option set a flag, do nothing else now. */
-            if (long_options[option_index].flag != 0)
-              break;
-            printf ("option %s", long_options[option_index].name);
-            if (optarg)
-              printf (" with arg %s", optarg);
-            printf ("\n");
-            break;
-
-          case 'e':
-            printEntropy = true;
-            break;
-
-          case 'c':
-            readRegionsFromStdin = true;
-            break;
- 
-          case 'i':
-            buildIndex = true;
-            break;
- 
-          case 'r':
-            region = optarg;
-            break;
-
-            case 'd':
-                dump = true;
-                break;
-
-          case 'h':
-            printSummary();
-            exit(0);
-            break;
- 
-          case '?':
-            /* getopt_long already printed an error message. */
-            printSummary();
-            exit(1);
-            break;
- 
-          default:
-            abort ();
-          }
-      }
-
-    /* Print any remaining command line arguments (not options). */
-    if (optind < argc) {
-        //cerr << "fasta file: " << argv[optind] << endl;
-        fastaFileName = argv[optind];
-    } else {
-        cerr << "please specify a fasta file" << endl;
-        printSummary();
-        exit(1);
-    }
-
-    if (buildIndex) {
-        FastaIndex* fai = new FastaIndex();
-        //cerr << "generating fasta index file for " << fastaFileName << endl;
-        fai->indexReference(fastaFileName);
-        fai->writeIndexFile((string) fastaFileName + fai->indexFileExtension());
-    }
-    
-    string sequence;  // holds sequence so we can optionally process it
-
-    FastaReference fr;
-    fr.open(fastaFileName);
-
-    if (dump) {
-        for (vector<string>::iterator s = fr.index->sequenceNames.begin(); s != fr.index->sequenceNames.end(); ++s) {
-            cout << *s << "\t" << fr.getSequence(*s) << endl;
-        }
-        return 0;
-    }
-
-    if (region != "") {
-        FastaRegion target(region);
-        sequence = fr.getTargetSubSequence(target);
-    }
-
-    if (readRegionsFromStdin) {
-        string regionstr;
-        while (getline(cin, regionstr)) {
-            FastaRegion target(regionstr);
-            if (target.startPos == -1) {
-                cout << fr.getSequence(target.startSeq) << endl;
-            } else {
-                cout << fr.getSubSequence(target.startSeq, target.startPos - 1, target.length()) << endl;
-            }
-        }
-    } else {
-        if (sequence != "") {
-            if (printEntropy) {
-                if (sequence.size() > 0) {
-                    cout << shannon_H((char*) sequence.c_str(), sequence.size()) << endl;
-                } else {
-                    cerr << "please specify a region or sequence for which to calculate the shannon entropy" << endl;
-                }
-            } else {  // if no statistical processing is requested, just print the sequence
-                cout << sequence << endl;
-            }
-        }
-    }
-
-    return 0;
-}
diff --git a/vcflib/fastahack/LargeFileSupport.h b/vcflib/fastahack/LargeFileSupport.h
deleted file mode 100644
index 733e8cf..0000000
--- a/vcflib/fastahack/LargeFileSupport.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#pragma once
-
-#define _FILE_OFFSET_BITS 64
-#ifdef WIN32
-#define ftell64(a)     _ftelli64(a)
-#define fseek64(a,b,c) _fseeki64(a,b,c)
-typedef __int64 off_type;
-#elif defined(__APPLE__)
-#define ftell64(a)     ftello(a)
-#define fseek64(a,b,c) fseeko(a,b,c)
-typedef off_t off_type;
-#else
-#define ftell64(a)     ftello(a)
-#define fseek64(a,b,c) fseeko(a,b,c)
-typedef __off64_t off_type;
-#endif
diff --git a/vcflib/fastahack/Makefile b/vcflib/fastahack/Makefile
deleted file mode 100644
index b0d847e..0000000
--- a/vcflib/fastahack/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-CXX=g++
-CFLAGS=-O3 -D_FILE_OFFSET_BITS=64
-
-fastahack: Fasta.o FastaHack.cpp split.o disorder.o
-	$(CXX) $(CFLAGS) Fasta.o FastaHack.cpp split.o disorder.o -o fastahack
-
-Fasta.o: Fasta.h Fasta.cpp
-	$(CXX) $(CFLAGS) -c Fasta.cpp
-
-split.o: split.h split.cpp
-	$(CXX) $(CFLAGS) -c split.cpp
-
-disorder.o: disorder.c disorder.h
-	$(CXX) $(CFLAGS) -c disorder.c
-
-clean:
-	rm -f fastahack *.o
-
-.PHONY: clean
diff --git a/vcflib/fastahack/README b/vcflib/fastahack/README
deleted file mode 100644
index 5ccba37..0000000
--- a/vcflib/fastahack/README
+++ /dev/null
@@ -1,63 +0,0 @@
-fastahack --- *fast* FASTA file indexing, subsequence and sequence extraction
-
-Author: Erik Garrison <erik.garrison at bc.edu>, Marth Lab, Boston College
-Date:   May 7, 2010
-
-
-Overview:
-
-fastahack is a small application for indexing and extracting sequences and
-subsequences from FASTA files.  The included Fasta.cpp library provides a FASTA
-reader and indexer that can be embedded into applications which would benefit
-from directly reading subsequences from FASTA files.  The library automatically
-handles index file generation and use.
-
-
-Features:
-
- - FASTA index (.fai) generation for FASTA files
- - Sequence extraction
- - Subsequence extraction
- - Sequence statistics (TODO: currently only length is provided)
-
-Sequence and subsequence extraction use fseek64 to provide fastest-possible
-extraction without RAM-intensive file loading operations.  This makes fastahack
-a useful tool for bioinformaticists who need to quickly extract many
-subsequences from a reference FASTA sequence.
-
-
-Notes:
-
-The index files generated by this system should be numerically equivalent to
-those generated by samtools (http://samtools.sourceforge.net/).  However, while
-samtools truncates sequence names in the index file, fastahack provides them
-completely.
-
-To simplify use, sequences can be addressed by first whitespace-separated
-field; e.g. "8 SN(Homo sapiens) GA(HG18) URI(NC_000008.9)" can be addressed
-simply as "8", provided "8" is a unique first-field name in the FASTA file.
-Thus, to extract 20bp starting at position 323202 in chromosome 8 from the
-human reference:
-
-  % fastahack subsequence h.sapiens.fasta 8 323202 20
-  ACATTGTAATAGATCTCAGA
-
-Usage information is provided by running fastahack with no arguments:
-
-  % fastahack
-  usage: fastahack <command> [options]
-  actions:
-      index <fasta reference>
-      sequence <fasta reference> <sequence name>
-      subsequence <fasta reference> <sequence name> <0-based start> <length>
-      stats <fasta reference> <sequence name>  (returns sequence length)
-
-
-Limitations:
-
-fastahack will only generate indexes for FASTA files in which the sequences
-have self-consistent line lengths.  Trailing whitespace is allowed at the end
-of sequences, but not embedded within the sequence.  These limitations are
-necessitated by the complexity of indexing sequences whose lines change in
-length--- the use of indexes is frustrated by such inconsistencies; each change
-in line length would require a new entry in the index file.
diff --git a/vcflib/fastahack/Region.h b/vcflib/fastahack/Region.h
deleted file mode 100644
index cd5fb57..0000000
--- a/vcflib/fastahack/Region.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef FASTA_REGION_H
-#define FASTA_REGION_H
-
-#include <string>
-#include <stdlib.h>
-
-using namespace std;
-
-class FastaRegion {
-public:
-    string startSeq;
-    int startPos;
-    int stopPos;
-
-    FastaRegion(string& region) {
-        startPos = -1;
-        stopPos = -1;
-        size_t foundFirstColon = region.find(":");
-        // we only have a single string, use the whole sequence as the target
-        if (foundFirstColon == string::npos) {
-            startSeq = region;
-        } else {
-            startSeq = region.substr(0, foundFirstColon);
-            size_t foundRangeDots = region.find("..", foundFirstColon);
-	    size_t foundRangeDash = region.find("-", foundFirstColon);
-            if (foundRangeDots == string::npos && foundRangeDash == string::npos) {
-                startPos = atoi(region.substr(foundFirstColon + 1).c_str());
-                stopPos = startPos; // just print one base if we don't give an end
-            } else {
-		if (foundRangeDash == string::npos) {
-		    startPos = atoi(region.substr(foundFirstColon + 1, foundRangeDots - foundRangeDots - 1).c_str());
-		    stopPos = atoi(region.substr(foundRangeDots + 2).c_str()); // to the start of this chromosome
-		} else {
-		    startPos = atoi(region.substr(foundFirstColon + 1, foundRangeDash - foundRangeDash - 1).c_str());
-		    stopPos = atoi(region.substr(foundRangeDash + 1).c_str()); // to the start of this chromosome
-		}
-            }
-        }
-    }
-
-    int length(void) {
-        if (stopPos > 0) {
-            return stopPos - startPos + 1;
-        } else {
-            return 1;
-        }
-    }
-
-};
-
-#endif
diff --git a/vcflib/fastahack/disorder.c b/vcflib/fastahack/disorder.c
deleted file mode 100644
index a5f7c35..0000000
--- a/vcflib/fastahack/disorder.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/***************************************************************************
- *  libdisorder: A Library for Measuring Byte Stream Entropy
- *  Copyright (C) 2010 Michael E. Locasto
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the:
- *       Free Software Foundation, Inc.
- *       59 Temple Place, Suite 330
- *       Boston, MA  02111-1307  USA
- *
- * $Id$
- **************************************************************************/
-
-#include <math.h> //for log2()
-#include <stdio.h> //for NULL
-#include "disorder.h"
-
-#if defined(__FreeBSD__)
-#define        log2(x) (log((x)) * (1./M_LN2))
-#endif
-
-/** Frequecies for each byte */
-static int m_token_freqs[LIBDO_MAX_BYTES]; //frequency of each token in sample
-static float m_token_probs[LIBDO_MAX_BYTES]; //P(each token appearing)
-static int m_num_tokens = 0; //actual number of `seen' tokens, max 256 
-static float m_maxent = 0.0;
-static float m_ratio = 0.0;
-static int LIBDISORDER_INITIALIZED = 0;
-
-static void
-initialize_lib()
-{
-  int i = 0;
-  if(1==LIBDISORDER_INITIALIZED)
-    return;
-
-  m_num_tokens = 0;
-
-  for(i=0;i<LIBDO_MAX_BYTES;i++)
-  {
-    m_token_freqs[i]=0;
-    m_token_probs[i]=0.0;
-  }
-
-  LIBDISORDER_INITIALIZED = 1;
-}
-
-/**
- * Set m_num_tokens by iterating over m_token_freq[] and maintaining
- * a counter of each position that does not hold the value of zero.
- */
-static void
-count_num_tokens()
-{
-  int i = 0;
-  int counter = 0;
-  for(i=0;i<LIBDO_MAX_BYTES;i++)
-  {
-    if(0!=m_token_freqs[i])
-    {
-      counter++;
-    }
-  }
-  m_num_tokens = counter;
-  return;
-}
-
-/**
- * Sum frequencies for each token (i.e., byte values 0 through 255)
- * We assume the `length' parameter is correct.
- *
- * This function is available only to functions in this file.
- */
-static void
-get_token_frequencies(char* buf, 
-		      long long length)
-{
-  int i=0;
-  char* itr=NULL;
-  unsigned char c=0;
-
-  itr = buf;
-
-  //reset number of tokens
-  m_num_tokens = 0;
-
-  //make sure freqency and probability arrays are cleared
-  for(i=0;i<LIBDO_MAX_BYTES;i++)
-  {
-    m_token_freqs[i] = 0;
-    m_token_probs[i] = 0.0;
-  }
-
-  for(i=0;i<length;i++)
-  {
-    c = (unsigned char)*itr;
-    //assert(0<=c<LIBDO_MAX_BYTES);
-    m_token_freqs[c]++;
-    itr++;
-  }
-}
-
-/**
- * Return entropy (in bits) of this buffer of bytes. We assume that the
- * `length' parameter is correct. This implementation is a translation
- * of the PHP code found here:
- *
- *    http://onlamp.com/pub/a/php/2005/01/06/entropy.html
- *
- * with a helpful hint on the `foreach' statement from here:
- *
- *    http://php.net/manual/en/control-structures.foreach.php
- */
-float
-shannon_H(char* buf, 
-	  long long length)
-{
-  int i = 0;
-  float bits = 0.0;
-  char* itr=NULL; //values of itr should be zero to 255
-  unsigned char token;
-  int num_events = 0; //`length' parameter
-  float freq = 0.0; //loop variable for holding freq from m_token_freq[]
-  float entropy = 0.0; //running entropy sum
-
-  if(NULL==buf || 0==length)
-    return 0.0;
-
-  if(0==LIBDISORDER_INITIALIZED)
-    initialize_lib();
-
-  itr = buf;
-  m_maxent = 0.0;
-  m_ratio = 0.0;
-  num_events = length;
-  get_token_frequencies(itr, num_events); //modifies m_token_freqs[]
-  //set m_num_tokens by counting unique m_token_freqs entries
-  count_num_tokens(); 
-
-  if(m_num_tokens>LIBDO_MAX_BYTES)
-  {
-    //report error somehow?
-    return 0.0;
-  }
-
-  //iterate through whole m_token_freq array, but only count
-  //spots that have a registered token (i.e., freq>0)
-  for(i=0;i<LIBDO_MAX_BYTES;i++)
-  {
-    if(0!=m_token_freqs[i])
-    {
-      token = i;
-      freq = ((float)m_token_freqs[token]); 
-      m_token_probs[token] = (freq / ((float)num_events));
-      entropy += m_token_probs[token] * log2(m_token_probs[token]);
-    }
-  }
-
-  bits = -1.0 * entropy;
-  m_maxent = log2(m_num_tokens);
-  m_ratio = bits / m_maxent;
-
-  return bits;
-}
-
-int 
-get_num_tokens()
-{
-  return m_num_tokens;
-}
-
-float 
-get_max_entropy()
-{
-  return m_maxent;
-}
-
-float 
-get_entropy_ratio()
-{
-  return m_ratio;
-}
diff --git a/vcflib/fastahack/disorder.h b/vcflib/fastahack/disorder.h
deleted file mode 100644
index 3458774..0000000
--- a/vcflib/fastahack/disorder.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/***************************************************************************
- *  libdisorder: A Library for Measuring Byte Stream Entropy
- *  Copyright (C) 2010 Michael E. Locasto
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the:
- *       Free Software Foundation, Inc.
- *       59 Temple Place, Suite 330
- *       Boston, MA  02111-1307  USA
- *
- * $Id$
- **************************************************************************/
-
-#ifndef __DISORDER_H_
-#define __DISORDER_H_
-
-/** Max number of bytes (i.e., tokens) */
-#define LIBDO_MAX_BYTES      256
-
-/** A convienance value for clients of this library. Feel free to change
- * if you plan to use a larger buffer. You can also safely ignore it, as
- * libdisorder does not use this value internally; it relies on the
- * client-supplied `length' parameter.
- *
- * NB: Might become deprecated because it is potentially misleading and
- * has zero relationship to any library internal state.
- */
-#define LIBDO_BUFFER_LEN   16384
-
-/** 
- * Given a pointer to an array of bytes, return a float indicating the
- * level of entropy in bits (a number between zero and eight),
- * assuming a space of 256 possible byte values. The second argument
- * indicates the number of bytes in the sequence. If this sequence
- * runs into unallocated memory, this function should fail with a
- * SIGSEGV.
- */
-float    shannon_H(char*, long long);
-
-/** Report the number of (unique) tokens seen. This is _not_ the
-    number of individual events seen. For example, if the library sees
-    the string `aaab', the number of events is 4 and the number of
-    tokens is 2. */
-int      get_num_tokens(void);
-
-/** Returns maximum entropy for byte distributions log2(256)=8 bits*/
-float    get_max_entropy(void);
-
-/** Returns the ratio of entropy to maxentropy */
-float    get_entropy_ratio(void);
-
-#endif
diff --git a/vcflib/fastahack/libdisorder.LICENSE b/vcflib/fastahack/libdisorder.LICENSE
deleted file mode 100644
index 8bbcff9..0000000
--- a/vcflib/fastahack/libdisorder.LICENSE
+++ /dev/null
@@ -1,339 +0,0 @@
-		    GNU GENERAL PUBLIC LICENSE
-		       Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-			    Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users.  This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it.  (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.)  You can apply it to
-your programs, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
-  To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
-  For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have.  You must make sure that they, too, receive or can get the
-source code.  And you must show them these terms so they know their
-rights.
-
-  We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
-  Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software.  If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
-  Finally, any free program is threatened constantly by software
-patents.  We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary.  To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.
-

-		    GNU GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License.  The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language.  (Hereinafter, translation is included without limitation in
-the term "modification".)  Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
-  1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
-  2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) You must cause the modified files to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    b) You must cause any work that you distribute or publish, that in
-    whole or in part contains or is derived from the Program or any
-    part thereof, to be licensed as a whole at no charge to all third
-    parties under the terms of this License.
-
-    c) If the modified program normally reads commands interactively
-    when run, you must cause it, when started running for such
-    interactive use in the most ordinary way, to print or display an
-    announcement including an appropriate copyright notice and a
-    notice that there is no warranty (or else, saying that you provide
-    a warranty) and that users may redistribute the program under
-    these conditions, and telling the user how to view a copy of this
-    License.  (Exception: if the Program itself is interactive but
-    does not normally print such an announcement, your work based on
-    the Program is not required to print an announcement.)
-

-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
-    a) Accompany it with the complete corresponding machine-readable
-    source code, which must be distributed under the terms of Sections
-    1 and 2 above on a medium customarily used for software interchange; or,
-
-    b) Accompany it with a written offer, valid for at least three
-    years, to give any third party, for a charge no more than your
-    cost of physically performing source distribution, a complete
-    machine-readable copy of the corresponding source code, to be
-    distributed under the terms of Sections 1 and 2 above on a medium
-    customarily used for software interchange; or,
-
-    c) Accompany it with the information you received as to the offer
-    to distribute corresponding source code.  (This alternative is
-    allowed only for noncommercial distribution and only if you
-    received the program in object code or executable form with such
-    an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it.  For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable.  However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-

-  4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License.  Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
-  5. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Program or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
-  6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
-  7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-

-  8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-  9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time.  Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation.  If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
-  10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission.  For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this.  Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
-			    NO WARRANTY
-
-  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
-  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
-		     END OF TERMS AND CONDITIONS
-

-	    How to Apply These Terms to Your New Programs
-
-  If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
-  To do so, attach the following notices to the program.  It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the program's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
-    Gnomovision version 69, Copyright (C) year name of author
-    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-    This is free software, and you are welcome to redistribute it
-    under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License.  Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
-  `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
-  <signature of Ty Coon>, 1 April 1989
-  Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs.  If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library.  If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/vcflib/fastahack/split.cpp b/vcflib/fastahack/split.cpp
deleted file mode 100644
index 5f1dc4e..0000000
--- a/vcflib/fastahack/split.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-#include "split.h"
-
-std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) {
-    std::stringstream ss(s);
-    std::string item;
-    while(std::getline(ss, item, delim)) {
-        elems.push_back(item);
-    }
-    return elems;
-}
-
-std::vector<std::string> split(const std::string &s, char delim) {
-    std::vector<std::string> elems;
-    return split(s, delim, elems);
-}
-
-std::vector<std::string> &split(const std::string &s, const std::string& delims, std::vector<std::string> &elems) {
-    char* tok;
-    char cchars [s.size()+1];
-    char* cstr = &cchars[0];
-    strcpy(cstr, s.c_str());
-    tok = strtok(cstr, delims.c_str());
-    while (tok != NULL) {
-        elems.push_back(tok);
-        tok = strtok(NULL, delims.c_str());
-    }
-    return elems;
-}
-
-std::vector<std::string> split(const std::string &s, const std::string& delims) {
-    std::vector<std::string> elems;
-    return split(s, delims, elems);
-}
diff --git a/vcflib/fastahack/split.h b/vcflib/fastahack/split.h
deleted file mode 100644
index bd5525d..0000000
--- a/vcflib/fastahack/split.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef __SPLIT_H
-#define __SPLIT_H
-
-// functions to split a string by a specific delimiter
-#include <string>
-#include <vector>
-#include <sstream>
-#include <string.h>
-
-// thanks to Evan Teran, http://stackoverflow.com/questions/236129/how-to-split-a-string/236803#236803
-
-// split a string on a single delimiter character (delim)
-std::vector<std::string>& split(const std::string &s, char delim, std::vector<std::string> &elems);
-std::vector<std::string>  split(const std::string &s, char delim);
-
-// split a string on any character found in the string of delimiters (delims)
-std::vector<std::string>& split(const std::string &s, const std::string& delims, std::vector<std::string> &elems);
-std::vector<std::string>  split(const std::string &s, const std::string& delims);
-
-#endif
diff --git a/vcflib/fastahack/tests/correct.fasta b/vcflib/fastahack/tests/correct.fasta
deleted file mode 100644
index 99af0c0..0000000
--- a/vcflib/fastahack/tests/correct.fasta
+++ /dev/null
@@ -1,30 +0,0 @@
->1
-TAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAAC
-CCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCAACCCTAACCCTAACCCTAACCCTAACCCTAA
-CCCTAACCCCTAACCCTAACCCTAACCCTAACCCTAACCTAACCCTAACCCTAACCCTAACCCTAACCCT
-AACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAAACCCTAAACCCTAACCCTAACCCTAACCCTA
-ACCCTAACCCCAACCCCAACCCCAACCCCAACCCCAACCCCAACCCTAACCCCTAACCCTAACCCTAACC
-CTACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCCTAACCCCTAACCCTAACCCTAACCCTA
-ACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAACCCTAACCCTCGCGGTACCCTCAGCCGGCCCG
-CCCGCCCGGGTCTGACCTGAGGAGAACTGTGCTCCGCCTTCAGAGTACCACCGAAATCTGTGCAGAGGAC
-AACGCAGCTCCGCCCTCGCGGTGCTCTCCGGGTCTGTGCTGAGGAGAACGCAACTCCGCCGGCGCAGGCG
->2
-TAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAAC
-CCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCAACCCTAACCCTAACCCTAACCCTAACCCTAA
-CCCTAACCCCTAACCCTAACCCTAACCCTAACCCTAACCTAACCCTAACCCTAACCCTAACCCTAACCCT
-AACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAAACCCTAAACCCTAACCCTAACCCTAACCCTA
-ACCCTAACCCCAACCCCAACCCCAACCCCAACCCCAACCCCAACCCTAACCCCTAACCCTAACCCTAACC
-CTACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCCTAACCCCTAACCCTAACCCTAACCCTA
-ACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAACCCTAACCCTCGCGGTACCCTCAGCCGGCCCG
-CCCGCCCGGGTCTGACCTGAGGAGAACTGTGCTCCGCCTTCAGAGTACCACCGAAATCTGTGCAGAGGAC
-AACGCAGCTCCGCCCTCGCGGTGCTCTCCGGGTCTGTGCTGAGGAGAACGCAAC
->3
-TAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAAC
-CCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCAACCCTAACCCTAACCCTAACCCTAACCCTAA
-CCCTAACCCCTAACCCTAACCCTAACCCTAACCCTAACCTAACCCTAACCCTAACCCTAACCCTAACCCT
-AACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAAACCCTAAACCCTAACCCTAACCCTAACCCTA
-CTACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCCTAACCCCTAACCCTAACCCTAACCCTA
-ACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAACCCTAACCCTCGCGGTACCCTCAGCCGGCCCG
-CCCGCCCGGGTCTGACCTGAGGAGAACTGTGCTCCGCCTTCAGAGTACCACCGAAATCTGTGCAGAGGAC
-AACGCAGCTCCGCCCTCGCGGTGCTCTCCGGGTCTGTGCTGAGGAGAACGCAACTCCGCCGGCGCAGGCG
-ACCCTAACCCCAACCCCAACCCCAACCCCAACCCCAACCCCAACCCTAACCCCTAACCCTAACCCT
diff --git a/vcflib/fastahack/tests/embedded_newline.fasta b/vcflib/fastahack/tests/embedded_newline.fasta
deleted file mode 100644
index 26b21e7..0000000
--- a/vcflib/fastahack/tests/embedded_newline.fasta
+++ /dev/null
@@ -1,35 +0,0 @@
->1
-TAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAAC
-CCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCAACCCTAACCCTAACCCTAACCCTAACCCTAA
-CCCTAACCCCTAACCCTAACCCTAACCCTAACCCTAACCTAACCCTAACCCTAACCCTAACCCTAACCCT
-AACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAAACCCTAAACCCTAACCCTAACCCTAACCCTA
-ACCCTAACCCCAACCCCAACCCCAACCCCAACCCCAACCCCAACCCTAACCCCTAACCCTAACCCTAACC
-CTACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCCTAACCCCTAACCCTAACCCTAACCCTA
-ACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAACCCTAACCCTCGCGGTACCCTCAGCCGGCCCG
-CCCGCCCGGGTCTGACCTGAGGAGAACTGTGCTCCGCCTTCAGAGTACCACCGAAATCTGTGCAGAGGAC
-AACGCAGCTCCGCCCTCGCGGTGCTCTCCGGGTCTGTGCTGAGGAGAACGCAACTCCGCCGGCGCAGGCG
-
-
-
->2
-TAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAAC
-CCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCAACCCTAACCCTAACCCTAACCCTAACCCTAA
-CCCTAACCCCTAACCCTAACCCTAACCCTAACCCTAACCTAACCCTAACCCTAACCCTAACCCTAACCCT
-AACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAAACCCTAAACCCTAACCCTAACCCTAACCCTA
-
-ACCCTAACCCCAACCCCAACCCCAACCCCAACCCCAACCCCAACCCTAACCCCTAACCCTAACCCTAACC
-CTACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCCTAACCCCTAACCCTAACCCTAACCCTA
-ACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAACCCTAACCCTCGCGGTACCCTCAGCCGGCCCG
-CCCGCCCGGGTCTGACCTGAGGAGAACTGTGCTCCGCCTTCAGAGTACCACCGAAATCTGTGCAGAGGAC
-AACGCAGCTCCGCCCTCGCGGTGCTCTCCGGGTCTGTGCTGAGGAGAACGCAAC
-
->3
-TAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAAC
-CCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCAACCCTAACCCTAACCCTAACCCTAACCCTAA
-CCCTAACCCCTAACCCTAACCCTAACCCTAACCCTAACCTAACCCTAACCCTAACCCTAACCCTAACCCT
-AACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAAACCCTAAACCCTAACCCTAACCCTAACCCTA
-CTACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCCTAACCCCTAACCCTAACCCTAACCCTA
-ACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAACCCTAACCCTCGCGGTACCCTCAGCCGGCCCG
-CCCGCCCGGGTCTGACCTGAGGAGAACTGTGCTCCGCCTTCAGAGTACCACCGAAATCTGTGCAGAGGAC
-AACGCAGCTCCGCCCTCGCGGTGCTCTCCGGGTCTGTGCTGAGGAGAACGCAACTCCGCCGGCGCAGGCG
-ACCCTAACCCCAACCCCAACCCCAACCCCAACCCCAACCCCAACCCTAACCCCTAACCCTAACCCT
diff --git a/vcflib/fastahack/tests/mismatched_lines.fasta b/vcflib/fastahack/tests/mismatched_lines.fasta
deleted file mode 100644
index 56a7020..0000000
--- a/vcflib/fastahack/tests/mismatched_lines.fasta
+++ /dev/null
@@ -1,30 +0,0 @@
->1
-TAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAAC
-CCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCAACCCTAACCCTAACCCTAACCCTAACCCTAA
-CCCTAACCCCTAACCCTAACCCTAACCCTAACCCTAACCTAACCCTAACCCTAACCCTAACCCTAACCCT
-AACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAAACCCTAAACCCTAACCCTAACCCTAACCCTA
-ACCCTAACCCCAACCCCAACCCCAACCCCAACCCCAACCCCAACCCTAACCCCTAACCCTAACCCTAACC
-CTACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCCTAACCCCTAACCCTAACCCTAACCCTA
-ACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAACCCTAACCCTCGCGGTACCCTCAGCCGGCCCG
-CCCGCCCGGGTCTGACCTGAGGAGAACTGTGCTCCGCCTTCAGAGTACCACCGAAATCTGTGCAGAGGAC
-AACGCAGCTCCGCCCTCGCGGTGCTCTCCGGGTCTGTGCTGAGGAGAACGCAACTCCGCCGGCGCAGGCG
->2
-TAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAAC
-CCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCAACCCTAACCCTAACCCTAACCCTAACCCTAA
-CCCTAACCCCTAACCCTAACCCTAACCCTAACCCTAACCTAACCCTAACCCTAACCCTAACCCTAACCCT
-AACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAAACCCTAAACCCTAACCCTAACCCTAACCCTA
-ACCCTAACCCCAACCCCAACCCCAACCCCAACCCCAACCCCAACCCTAACCCCTAACCCTAACCCTAACC
-CTACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCCTAACCCCTAACCCTAACCCTAACCCTA
-ACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAACCCTAACCCTCGCGGTACCCTCAGCCGGCCCG
-CCCGCCCGGGTCTGACCTGAGGAGAACTGTGCTCCGCCTTCAGAGTACCACCGAAATCTGTGCAGAGGAC
-AACGCAGCTCCGCCCTCGCGGTGCTCTCCGGGTCTGTGCTGAGGAGAACGCAAC
->3
-TAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAAC
-CCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCAACCCTAACCCTAACCCTAACCCTAACCCTAA
-CCCTAACCCCTAACCCTAACCCTAACCCTAACCCTAACCTAACCCTAACCCTAACCCTAACCCTAACCCT
-AACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAAACCCTAAACCCTAACCCTAACCCTAACCCTA
-ACCCTAACCCCAACCCCAACCCCAACCCCAACCCCAACCCCAACCCTAACCCCTAACCCTAACCCT
-CTACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCCTAACCCCTAACCCTAACCCTAACCCTA
-ACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAACCCTAACCCTCGCGGTACCCTCAGCCGGCCCG
-CCCGCCCGGGTCTGACCTGAGGAGAACTGTGCTCCGCCTTCAGAGTACCACCGAAATCTGTGCAGAGGAC
-AACGCAGCTCCGCCCTCGCGGTGCTCTCCGGGTCTGTGCTGAGGAGAACGCAACTCCGCCGGCGCAGGCG
diff --git a/vcflib/fastahack/tests/trailing_newlines.fasta b/vcflib/fastahack/tests/trailing_newlines.fasta
deleted file mode 100644
index 377513f..0000000
--- a/vcflib/fastahack/tests/trailing_newlines.fasta
+++ /dev/null
@@ -1,34 +0,0 @@
->1
-TAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAAC
-CCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCAACCCTAACCCTAACCCTAACCCTAACCCTAA
-CCCTAACCCCTAACCCTAACCCTAACCCTAACCCTAACCTAACCCTAACCCTAACCCTAACCCTAACCCT
-AACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAAACCCTAAACCCTAACCCTAACCCTAACCCTA
-ACCCTAACCCCAACCCCAACCCCAACCCCAACCCCAACCCCAACCCTAACCCCTAACCCTAACCCTAACC
-CTACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCCTAACCCCTAACCCTAACCCTAACCCTA
-ACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAACCCTAACCCTCGCGGTACCCTCAGCCGGCCCG
-CCCGCCCGGGTCTGACCTGAGGAGAACTGTGCTCCGCCTTCAGAGTACCACCGAAATCTGTGCAGAGGAC
-AACGCAGCTCCGCCCTCGCGGTGCTCTCCGGGTCTGTGCTGAGGAGAACGCAACTCCGCCGGCGCAGGCG
-
-
-
->2
-TAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAAC
-CCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCAACCCTAACCCTAACCCTAACCCTAACCCTAA
-CCCTAACCCCTAACCCTAACCCTAACCCTAACCCTAACCTAACCCTAACCCTAACCCTAACCCTAACCCT
-AACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAAACCCTAAACCCTAACCCTAACCCTAACCCTA
-ACCCTAACCCCAACCCCAACCCCAACCCCAACCCCAACCCCAACCCTAACCCCTAACCCTAACCCTAACC
-CTACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCCTAACCCCTAACCCTAACCCTAACCCTA
-ACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAACCCTAACCCTCGCGGTACCCTCAGCCGGCCCG
-CCCGCCCGGGTCTGACCTGAGGAGAACTGTGCTCCGCCTTCAGAGTACCACCGAAATCTGTGCAGAGGAC
-AACGCAGCTCCGCCCTCGCGGTGCTCTCCGGGTCTGTGCTGAGGAGAACGCAAC
-
->3
-TAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAAC
-CCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCAACCCTAACCCTAACCCTAACCCTAACCCTAA
-CCCTAACCCCTAACCCTAACCCTAACCCTAACCCTAACCTAACCCTAACCCTAACCCTAACCCTAACCCT
-AACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAAACCCTAAACCCTAACCCTAACCCTAACCCTA
-CTACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCCTAACCCCTAACCCTAACCCTAACCCTA
-ACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAACCCTAACCCTCGCGGTACCCTCAGCCGGCCCG
-CCCGCCCGGGTCTGACCTGAGGAGAACTGTGCTCCGCCTTCAGAGTACCACCGAAATCTGTGCAGAGGAC
-AACGCAGCTCCGCCCTCGCGGTGCTCTCCGGGTCTGTGCTGAGGAGAACGCAACTCCGCCGGCGCAGGCG
-ACCCTAACCCCAACCCCAACCCCAACCCCAACCCCAACCCCAACCCTAACCCCTAACCCTAACCCT
diff --git a/vcflib/filevercmp/Makefile b/vcflib/filevercmp/Makefile
deleted file mode 100644
index 1740538..0000000
--- a/vcflib/filevercmp/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-all: filevercmp
-
-clean:
-	rm -f filevercmp
-	rm -f filevercmp.o
-
-.PHONY: all clean
-
-filevercmp.o: filevercmp.c main.c filevercmp.h
-	gcc -c filevercmp.c
-
-filevercmp: filevercmp.o
-	gcc -o filevercmp main.c filevercmp.o
diff --git a/vcflib/filevercmp/README.md b/vcflib/filevercmp/README.md
deleted file mode 100644
index ab7a9ce..0000000
--- a/vcflib/filevercmp/README.md
+++ /dev/null
@@ -1,39 +0,0 @@
-Compare version strings:
-
-This function compares strings S1 and S2:
-
-1. By PREFIX in the same way as strcmp.
-2. Then by VERSION (most similarly to version compare of Debian's dpkg).
-  Leading zeros in version numbers are ignored.
-3. If both (PREFIX and  VERSION) are equal, strcmp function is used for
-  comparison. So this function can return 0 if (and only if) strings S1
-  and S2 are identical.
-
-It returns number >0 for S1 > S2, 0 for S1 == S2 and number <0 for S1 < S2.
-
-This function compares strings, in a way that if VER1 and VER2 are version
-numbers and PREFIX and SUFFIX (SUFFIX defined as `(\.[A-Za-z~][A-Za-z0-9~]*)*)`
-are strings then VER1 < VER2 implies filevercmp (PREFIX VER1 SUFFIX,
-PREFIX VER2 SUFFIX) < 0.
-
-This function is intended to be a replacement for strverscmp.
-
-*fine print*
-
-
-    Copyright (C) 1995 Ian Jackson <iwj10 at cus.cam.ac.uk>
-    Copyright (C) 2001 Anthony Towns <aj at azure.humbug.org.au>
-    Copyright (C) 2008-2009 Free Software Foundation, Inc.
-
-    This program is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
diff --git a/vcflib/filevercmp/filevercmp.c b/vcflib/filevercmp/filevercmp.c
deleted file mode 100644
index f9d9c04..0000000
--- a/vcflib/filevercmp/filevercmp.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
-   Copyright (C) 1995 Ian Jackson <iwj10 at cus.cam.ac.uk>
-   Copyright (C) 2001 Anthony Towns <aj at azure.humbug.org.au>
-   Copyright (C) 2008-2009 Free Software Foundation, Inc.
-
-   This program is free software: you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation, either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
-
-#include "filevercmp.h"
-
-#include <sys/types.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <string.h>
-#include <limits.h>
-#include <ctype.h>
-
-/* Match a file suffix defined by this regular expression:
-   /(\.[A-Za-z~][A-Za-z0-9~]*)*$/
-   Scan the string *STR and return a pointer to the matching suffix, or
-   NULL if not found.  Upon return, *STR points to terminating NUL.  */
-static const char *
-match_suffix (const char **str)
-{
-  const char *match = NULL;
-  bool read_alpha = false;
-  while (**str)
-    {
-      if (read_alpha)
-        {
-          read_alpha = false;
-          if (!isalpha (**str) && '~' != **str)
-            match = NULL;
-        }
-      else if ('.' == **str)
-        {
-          read_alpha = true;
-          if (!match)
-            match = *str;
-        }
-      else if (!isalnum (**str) && '~' != **str)
-        match = NULL;
-      (*str)++;
-    }
-  return match;
-}
-
-/* verrevcmp helper function */
-static inline int
-order (unsigned char c)
-{
-  if (isdigit (c))
-    return 0;
-  else if (isalpha (c))
-    return c;
-  else if (c == '~')
-    return -1;
-  else
-    return (int) c + UCHAR_MAX + 1;
-}
-
-/* slightly modified verrevcmp function from dpkg
-   S1, S2 - compared string
-   S1_LEN, S2_LEN - length of strings to be scanned
-
-   This implements the algorithm for comparison of version strings
-   specified by Debian and now widely adopted.  The detailed
-   specification can be found in the Debian Policy Manual in the
-   section on the `Version' control field.  This version of the code
-   implements that from s5.6.12 of Debian Policy v3.8.0.1
-   http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version */
-static int
-verrevcmp (const char *s1, size_t s1_len, const char *s2, size_t s2_len)
-{
-  size_t s1_pos = 0;
-  size_t s2_pos = 0;
-  while (s1_pos < s1_len || s2_pos < s2_len)
-    {
-      int first_diff = 0;
-      while ((s1_pos < s1_len && !isdigit (s1[s1_pos]))
-	     || (s2_pos < s2_len && !isdigit (s2[s2_pos])))
-	{
-	  int s1_c = (s1_pos == s1_len) ? 0 : order (s1[s1_pos]);
-	  int s2_c = (s2_pos == s2_len) ? 0 : order (s2[s2_pos]);
-	  if (s1_c != s2_c)
-	    return s1_c - s2_c;
-	  s1_pos++;
-	  s2_pos++;
-	}
-      while (s1[s1_pos] == '0')
-	s1_pos++;
-      while (s2[s2_pos] == '0')
-	s2_pos++;
-      while (isdigit (s1[s1_pos]) && isdigit (s2[s2_pos]))
-	{
-	  if (!first_diff)
-	    first_diff = s1[s1_pos] - s2[s2_pos];
-	  s1_pos++;
-	  s2_pos++;
-	}
-      if (isdigit (s1[s1_pos]))
-	return 1;
-      if (isdigit (s2[s2_pos]))
-	return -1;
-      if (first_diff)
-	return first_diff;
-    }
-  return 0;
-}
-
-/* Compare version strings S1 and S2.
-   See filevercmp.h for function description.  */
-int
-filevercmp (const char *s1, const char *s2)
-{
-  const char *s1_pos;
-  const char *s2_pos;
-  const char *s1_suffix, *s2_suffix;
-  size_t s1_len, s2_len;
-  int result;
-
-  /* easy comparison to see if strings are identical */
-  int simple_cmp = strcmp (s1, s2);
-  if (simple_cmp == 0)
-    return 0;
-
-  /* special handle for "", "." and ".." */
-  if (!*s1)
-    return -1;
-  if (!*s2)
-    return 1;
-  if (0 == strcmp (".", s1))
-    return -1;
-  if (0 == strcmp (".", s2))
-    return 1;
-  if (0 == strcmp ("..", s1))
-    return -1;
-  if (0 == strcmp ("..", s2))
-    return 1;
-
-  /* special handle for other hidden files */
-  if (*s1 == '.' && *s2 != '.')
-    return -1;
-  if (*s1 != '.' && *s2 == '.')
-    return 1;
-  if (*s1 == '.' && *s2 == '.')
-    {
-      s1++;
-      s2++;
-    }
-
-  /* "cut" file suffixes */
-  s1_pos = s1;
-  s2_pos = s2;
-  s1_suffix = match_suffix (&s1_pos);
-  s2_suffix = match_suffix (&s2_pos);
-  s1_len = (s1_suffix ? s1_suffix : s1_pos) - s1;
-  s2_len = (s2_suffix ? s2_suffix : s2_pos) - s2;
-
-  /* restore file suffixes if strings are identical after "cut" */
-  if ((s1_suffix || s2_suffix) && (s1_len == s2_len)
-      && 0 == strncmp (s1, s2, s1_len))
-    {
-      s1_len = s1_pos - s1;
-      s2_len = s2_pos - s2;
-    }
-
-  result = verrevcmp (s1, s1_len, s2, s2_len);
-  return result == 0 ? simple_cmp : result;
-}
diff --git a/vcflib/filevercmp/filevercmp.h b/vcflib/filevercmp/filevercmp.h
deleted file mode 100644
index f3d78f0..0000000
--- a/vcflib/filevercmp/filevercmp.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
-   Copyright (C) 1995 Ian Jackson <iwj10 at cus.cam.ac.uk>
-   Copyright (C) 2001 Anthony Towns <aj at azure.humbug.org.au>
-   Copyright (C) 2008-2009 Free Software Foundation, Inc.
-
-   This program is free software: you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation, either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
-
-#ifndef FILEVERCMP_H
-#define FILEVERCMP_H
-
-/* Compare version strings:
-
-   This function compares strings S1 and S2:
-   1) By PREFIX in the same way as strcmp.
-   2) Then by VERSION (most similarly to version compare of Debian's dpkg).
-      Leading zeros in version numbers are ignored.
-   3) If both (PREFIX and  VERSION) are equal, strcmp function is used for
-      comparison. So this function can return 0 if (and only if) strings S1
-      and S2 are identical.
-
-   It returns number >0 for S1 > S2, 0 for S1 == S2 and number <0 for S1 < S2.
-
-   This function compares strings, in a way that if VER1 and VER2 are version
-   numbers and PREFIX and SUFFIX (SUFFIX defined as (\.[A-Za-z~][A-Za-z0-9~]*)*)
-   are strings then VER1 < VER2 implies filevercmp (PREFIX VER1 SUFFIX,
-   PREFIX VER2 SUFFIX) < 0.
-
-   This function is intended to be a replacement for strverscmp. */
-int filevercmp (const char *s1, const char *s2);
-
-#endif /* FILEVERCMP_H */
diff --git a/vcflib/filevercmp/main.c b/vcflib/filevercmp/main.c
deleted file mode 100644
index 32ecfdd..0000000
--- a/vcflib/filevercmp/main.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include "filevercmp.h"
-#include <stdio.h>
-
-
-int main(int argc, char** argv) {
-    if (argc != 3) {
-        printf("usage: %s [a] [b]\n", argv[0]);
-        printf("shows version-string comparison of strings a and b\n", argv[0]);
-        printf("for instance, chr1 < chr10, 1 < 10, abca < bcac\n");
-        return 1;
-    }
-    int c = filevercmp(argv[1], argv[2]);
-    printf("%s < %s = %i\n", argv[1], argv[2], c);
-    return 0;
-}
diff --git a/vcflib/fsom/Makefile b/vcflib/fsom/Makefile
deleted file mode 100644
index 3c81734..0000000
--- a/vcflib/fsom/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-all:
-	g++ -w -O3 -pipe -fomit-frame-pointer -ffast-math fsom.c split.cpp main.cpp -o fsom -lm
-clean:
-	rm -f *.o fsom
-
diff --git a/vcflib/fsom/README b/vcflib/fsom/README
deleted file mode 100644
index e69de29..0000000
diff --git a/vcflib/fsom/convert.h b/vcflib/fsom/convert.h
deleted file mode 100644
index 399bcea..0000000
--- a/vcflib/fsom/convert.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef __CONVERT_H
-#define __CONVERT_H
-
-#include <sstream>
-
-// converts the string into the specified type, setting r to the converted
-// value and returning true/false on success or failure
-template<typename T>
-bool convert(const std::string& s, T& r) {
-    std::istringstream iss(s);
-    iss >> r;
-    return iss.eof() ? true : false;
-}
-
-template<typename T>
-std::string convert(const T& r) {
-    std::ostringstream iss;
-    iss << r;
-    return iss.str();
-}
-
-#endif
diff --git a/vcflib/fsom/example.c b/vcflib/fsom/example.c
deleted file mode 100644
index 9ce1036..0000000
--- a/vcflib/fsom/example.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * =====================================================================================
- *
- *       Filename:  example.c
- *
- *    Description:  Examle file to benchmark fsom library.
- *
- *        Version:  0.1
- *       Revision:  none
- *       Compiler:  gcc
- *
- *         Author:  BlackLight (http://0x00.ath.cx), <blacklight at autistici.org>
- *    Contributor:  evilsocket (http://www.evilsocket.net), <evilsocket at gmail.com>
- *        Licence:  GNU GPL v.3
- *        Company:  DO WHAT YOU WANT CAUSE A PIRATE IS FREE, YOU ARE A PIRATE!
- *
- * =====================================================================================
- */
-#include	"fsom.h"
-
-#include	<alloca.h>
-#include	<stdio.h>
-#include 	<sys/time.h>
-
-static unsigned long prev_uticks = 0;
-
-static unsigned long get_uticks(){
-    struct timeval ts;
-    gettimeofday(&ts,0);
-    return ((ts.tv_sec * 1000000) + ts.tv_usec);
-}
-
-static void start_timer(){
-	prev_uticks = get_uticks();
-}
-
-static void print_timing( const char *msg ){
-	#define MS_DELTA (1000.0)
-	#define SS_DELTA (MS_DELTA * 1000.0)
-	#define MM_DELTA (SS_DELTA * 60.0)
-	#define HH_DELTA (MM_DELTA * 60.0)
-
-	double ticks = get_uticks() - prev_uticks;
-
-	if( ticks < MS_DELTA ){
-	   printf( "%s\t : %lf us\n", msg, ticks );
-	}
-	else if( ticks < SS_DELTA ){
-	   printf( "%s\t : %lf ms\n", msg, ticks / MS_DELTA );
-	}
-	else if( ticks < MM_DELTA ){
-	   printf( "%s\t : %lf s\n", msg, ticks / SS_DELTA );
-	}
-	else if( ticks < HH_DELTA ){
-	   printf( "%s\t : %lf m\n", msg, ticks / MM_DELTA );
-	}
-	else{
-	   printf( "%s\t : %lf h\n", msg, ticks / HH_DELTA );
-	}
-
-	start_timer();
-}
-
-#define 	VECTORS 		10
-#define 	INPUTS 		    20
-#define 	OUT_ROWS 		20
-#define 	OUT_COLS 		20
-#define 	TRAIN_STEPS 	100
-
-int
-main ( int argc, char *argv[] )
-{
-	size_t i, j, x, y;
-	double step = 0.0;
-	double **data = NULL;
-	som_network_t *net = NULL;
-
-	data = (double **) alloca ( INPUTS * sizeof ( double* ));
-
-	for ( i=0, step = 0.0; i < INPUTS; ++i, step += 0.1 )
-	{
-		data[i] = (double *) alloca ( VECTORS * sizeof ( double ));
-
-		for ( j=0; j < VECTORS; ++j )
-		{
-                        data[i][j] = step;
-		}
-	}
-
-	start_timer();
-
-	net = som_network_new ( INPUTS, OUT_ROWS, OUT_COLS );
-
-	if ( !net )
-	{
-		printf( "ERROR: som_network_new failed.\n" );
-		return 1;
-	}
-
-	print_timing( "Network Creation" );
-
-	som_init_weights ( net, data, INPUTS );
-	som_train ( net, data, VECTORS, TRAIN_STEPS );
-
-	print_timing( "Network Training" );
-
-	for ( i=0; i < INPUTS; ++i )
-	{
-		som_set_inputs ( net, data[i] );
-		som_get_best_neuron_coordinates ( net, &x, &y );
-		printf ( "best coordinates [%u]: %u,%u\n", i, x, y );
-	}
-
-	print_timing( "Input Recognition" );
-
-	som_network_destroy ( net );
-
-	print_timing( "Network Destruction" );
-
-	return 0;
-}			
diff --git a/vcflib/fsom/fsom.c b/vcflib/fsom/fsom.c
deleted file mode 100644
index aaf7379..0000000
--- a/vcflib/fsom/fsom.c
+++ /dev/null
@@ -1,988 +0,0 @@
-/*
- * =====================================================================================
- *
- *       Filename:  fsom.c
- *
- *    Description:  Manage a self-organizing map (SOM) as a neural network
- *
- *        Version:  0.1
- *        Created:  15/10/2010 13:53:31
- *       Revision:  none
- *       Compiler:  gcc
- *
- *         Author:  BlackLight (http://0x00.ath.cx), <blacklight at autistici.org>
- *    Contributor:  evilsocket (http://www.evilsocket.net), <evilsocket at gmail.com>
- *        Licence:  GNU GPL v.3
- *        Company:  DO WHAT YOU WANT CAUSE A PIRATE IS FREE, YOU ARE A PIRATE!
- *
- * =====================================================================================
- */
-
-#include	"fsom.h"
-
-#include	<float.h>
-#include	<limits.h>
-#include	<math.h>
-#include	<memory.h>
-#include	<stdio.h>
-#include	<stdlib.h>
-
-#ifndef 	M_E
-#define 	M_E		2.7182818284590452354
-#endif
-
-/**
- * \brief  Create a new synapsis between two neurons
- * \param  input_neuron 		Input neuron for the synapsis
- * \param  output_neuron 	Output neuron for the synapsis
- * \param  weight 			Weight of the synapsis (set it to 0 for a random value between 0 and 1)
- * \return A pointer representing the new synapsis
- */
-
-static som_synapsis_t*
-som_synapsis_new ( som_neuron_t *input_neuron, som_neuron_t *output_neuron, double weight )
-{
-	som_synapsis_t  *synapsis = NULL;
-
-	if ( !( synapsis = ( som_synapsis_t* ) malloc ( sizeof ( som_synapsis_t ))))
-	{
-		return NULL;
-	}
-
-	synapsis->neuron_in  = input_neuron;
-	synapsis->neuron_out = output_neuron;
-
-	if ( weight == 0.0 )
-	{
-		synapsis->weight = (double) rand() / (double) UINT_MAX;
-	} else {
-		synapsis->weight = weight;
-	}
-
-	if ( !( input_neuron->synapses = ( som_synapsis_t** ) realloc ( input_neuron->synapses, (++( input_neuron->synapses_count )) * sizeof ( som_synapsis_t ))))
-	{
-		free ( synapsis );
-		return NULL;
-	}
-	
-	if ( !( output_neuron->synapses = ( som_synapsis_t** ) realloc ( output_neuron->synapses, (++( output_neuron->synapses_count )) * sizeof ( som_synapsis_t ))))
-	{
-		free ( synapsis );
-		return NULL;
-	}
-
-	input_neuron->synapses[ input_neuron->synapses_count - 1 ] = synapsis;
-	output_neuron->synapses[ output_neuron->synapses_count - 1 ] = synapsis;
-	return synapsis;
-}		/* -----  end of function som_synapsis_new  ----- */
-
-
-/**
- * \brief  Create a new neuron
- * \return The new neuron
- */
-#define som_neuron_new() ( som_neuron_t *)calloc( 1, sizeof ( som_neuron_t ) )
-/* -----  end of macro som_neuron_new  ----- */
-
-/**
- * \brief  Deallocate a neuron
- * \param  neuron 	Neuron to be deallocated
- */
-#define som_neuron_destroy( neuron ) if( neuron ){ free(neuron); neuron = NULL; }
-/* -----  end of macro som_neuron_destroy  ----- */
-
-/**
- * \brief  Create a new input layer
- * \param  neurons_count 	Number of neurons in the new input layer
- * \return The new layer
- */
-
-static som_input_layer_t*
-som_input_layer_new ( size_t neurons_count )
-{
-	size_t i = 0,
-		  j = 0;
-
-	som_input_layer_t *layer = NULL;
-
-	if ( !( layer = ( som_input_layer_t* ) malloc ( sizeof ( som_input_layer_t ))))
-	{
-		return NULL;
-	}
-
-	layer->neurons_count = neurons_count;
-
-	if ( !( layer->neurons = ( som_neuron_t** ) malloc ( neurons_count * sizeof ( som_neuron_t* ))))
-	{
-		free ( layer );
-		return NULL;
-	}
-	
-	for ( i=0; i < neurons_count; ++i )
-	{
-		if ( !( layer->neurons[i] = som_neuron_new() ))
-		{
-			for ( j=0; j < i; ++j )
-			{
-				som_neuron_destroy ( layer->neurons[j] );
-			}
-
-			free ( layer->neurons );
-			free ( layer );
-			return NULL;
-		}
-	}
-
-	return layer;
-}		/* -----  end of function som_input_layer_new  ----- */
-
-/**
- * \brief  Create a new output layer
- * \param  neurons_rows 	Number of rows in the matrix of output neurons
- * \param  neurons_cols 	Number of cols in the matrix of output neurons
- * \return The new layer
- */
-
-static som_output_layer_t*
-som_output_layer_new ( size_t neurons_rows, size_t neurons_cols )
-{
-	size_t i = 0,
-		  j = 0,
-		  k = 0,
-		  l = 0;
-
-	som_output_layer_t *layer = NULL;
-
-	if ( !( layer = ( som_output_layer_t* ) malloc ( sizeof ( som_output_layer_t ))))
-	{
-		return NULL;
-	}
-
-	layer->neurons_rows = neurons_rows;
-	layer->neurons_cols = neurons_cols;
-
-	if ( !( layer->neurons = ( som_neuron_t*** ) malloc ( neurons_rows * neurons_cols * sizeof ( som_neuron_t** ))))
-	{
-		free ( layer );
-		return NULL;
-	}
-
-	for ( i=0; i < neurons_rows; ++i )
-	{
-		if ( !( layer->neurons[i] = ( som_neuron_t** ) malloc ( neurons_cols * sizeof ( som_neuron_t* ))))
-		{
-			for ( j=0; j < i; ++j )
-			{
-				free ( layer->neurons[j] );
-				layer->neurons[j] = NULL;
-			}
-
-			free ( layer->neurons );
-			free ( layer );
-			return NULL;
-		}
-	}
-
-	for ( i=0; i < neurons_rows; ++i )
-	{
-		for ( j=0; j < neurons_cols; ++j )
-		{
-			if ( !( layer->neurons[i][j] = som_neuron_new() ))
-			{
-				for ( k=0; k < i; ++k )
-				{
-					for ( l=0; l < j; ++l )
-					{
-						som_neuron_destroy ( layer->neurons[k][l] );
-					}
-
-					free ( layer->neurons[k] );
-					layer->neurons[k] = NULL;
-				}
-
-				free ( layer->neurons );
-				return NULL;
-			}
-		}
-	}
-
-	return layer;
-}		/* -----  end of function som_output_layer_new  ----- */
-
-/**
- * \brief  Connect two layers of a neural SOM
- * \param  input_layer 	Reference to the input layer
- * \param  output_layer 	Reference to the output layer
- */
-
-static void
-som_connect_layers ( som_input_layer_t **input_layer, som_output_layer_t **output_layer )
-{
-	size_t i = 0,
-		  j = 0,
-		  k = 0;
-
-	for ( i=0; i < (*output_layer)->neurons_rows; ++i )
-	{
-		for ( j=0; j < (*output_layer)->neurons_cols; ++j )
-		{
-			for ( k=0; k < (*input_layer)->neurons_count; ++k )
-			{
-				if ( !( som_synapsis_new ( (*input_layer)->neurons[k], (*output_layer)->neurons[i][j], 0.0 )))
-				{
-					return;
-				}
-			}
-		}
-	}
-}		/* -----  end of function som_connect_layers  ----- */
-
-/**
- * \brief  Initialize a new SOM neural network
- * \param  input_neurons 		Number of neurons in the input layer
- * \param  output_neurons_rows 	Number of rows of neurons in the output layer
- * \param  output_neurons_cols 	Number of cols of neurons in the output layer
- * \return The new SOM neural network
- */
-
-som_network_t*
-som_network_new ( size_t input_neurons, size_t output_neurons_rows, size_t output_neurons_cols )
-{
-	som_network_t *net = NULL;
-	srand ( time ( NULL ));
-
-	if ( !( net = ( som_network_t* ) calloc ( 1, sizeof ( som_network_t ))))
-	{
-		return NULL;
-	}
-
-	if ( !( net->input_layer = som_input_layer_new ( input_neurons )))
-	{
-		free ( net );
-		return NULL;
-	}
-
-	if ( !( net->output_layer = som_output_layer_new ( output_neurons_rows, output_neurons_cols )))
-	{
-		free ( net->input_layer );
-		free ( net );
-		return NULL;
-	}
-
-	net->T_learning_param = 0.0;
-	net->serialization_time = ( time_t ) 0;
-	som_connect_layers ( &( net->input_layer ), &( net->output_layer ));
-	return net;
-}		/* -----  end of function som_network_new  ----- */
-
-/**
- * \brief  Deallocate an input layer
- * \param  net 	Network whose input layer should be deallocated
- */
-
-static void
-som_input_layer_destroy ( som_network_t *net )
-{
-	size_t i = 0,
-		  j = 0,
-		  k = 0;
-
-	if ( !( net->input_layer ))
-	{
-		return;
-	}
-
-	for ( i=0; i < net->input_layer->neurons_count; ++i )
-	{
-		for ( j=0; j < net->input_layer->neurons[i]->synapses_count; ++j )
-		{
-			if ( (int) j < 0 )
-			{
-				break;
-			}
-
-			if ( net->input_layer->neurons[i]->synapses )
-			{
-				if ( net->input_layer->neurons[i]->synapses[j] )
-				{
-					if ( net->input_layer->neurons[i]->synapses[j]->neuron_out )
-					{
-						/* net->input_layer->neurons[i]->synapses[j]->neuron_out->synapses[k]->neuron_in = NULL; */
-
-						for ( k=0; k < net->input_layer->neurons[i]->synapses[j]->neuron_out->synapses_count; ++k )
-						{
-							if ( net->input_layer->neurons[i]->synapses[j]->neuron_out->synapses[k] )
-							{
-								net->input_layer->neurons[i]->synapses[j]->neuron_out->synapses[k]->neuron_in = NULL;
-								net->input_layer->neurons[i]->synapses[j]->neuron_out->synapses[k] = NULL;
-							}
-						}
-					}
-
-					free ( net->input_layer->neurons[i]->synapses[j] );
-					net->input_layer->neurons[i]->synapses[j] = NULL;
-				}
-
-				free ( net->input_layer->neurons[i]->synapses );
-				net->input_layer->neurons[i]->synapses = NULL;
-			}
-		}
-
-		som_neuron_destroy ( net->input_layer->neurons[i] );
-	}
-
-	free ( net->input_layer->neurons );
-	net->input_layer->neurons = NULL;
-
-	free ( net->input_layer );
-	net->input_layer = NULL;
-}		/* -----  end of function som_input_layer_destroy  ----- */
-
-/**
- * \brief  Deallocate an output layer
- * \param  net 	Network whose output layer should be deallocated
- */
-
-static void
-som_output_layer_destroy ( som_network_t *net )
-{
-	size_t i = 0,
-		  j = 0,
-		  k = 0;
-
-	if ( !( net->output_layer ))
-	{
-		return;
-	}
-
-	for ( i=0; i < net->output_layer->neurons_rows; ++i )
-	{
-		for ( j=0; j < net->output_layer->neurons_cols; ++j )
-		{
-			for ( k=0; k < net->output_layer->neurons[i][j]->synapses_count; ++k )
-			{
-				if ( net->output_layer->neurons[i][j]->synapses )
-				{
-					if ( net->output_layer->neurons[i][j]->synapses[k] )
-					{
-						free ( net->output_layer->neurons[i][j]->synapses[k] );
-						net->output_layer->neurons[i][j]->synapses[k] = NULL;
-					}
-
-					free ( net->output_layer->neurons[i][j]->synapses );
-					net->output_layer->neurons[i][j]->synapses = NULL;
-				}
-			}
-
-			som_neuron_destroy ( net->output_layer->neurons[i][j] );
-		}
-
-		free ( net->output_layer->neurons[i] );
-		net->output_layer->neurons[i] = NULL;
-	}
-
-	free ( net->output_layer->neurons );
-	net->output_layer->neurons = NULL;
-
-	free ( net->output_layer );
-	net->output_layer = NULL;
-}		/* -----  end of function som_output_layer_destroy  ----- */
-
-/**
- * \brief  Deallocate a SOM neural network
- * \param  net 	Network to be deallocated
- */
-
-void
-som_network_destroy ( som_network_t *net )
-{
-	if ( !net )
-	{
-		return;
-	}
-
-	som_input_layer_destroy  ( net );
-	som_output_layer_destroy ( net );
-	free ( net );
-	net = NULL;
-}		/* -----  end of function som_network_destroy  ----- */
-
-/**
- * \brief  Set a vector as input for the network
- * \param  net 	SOM neural network
- * \param  data 	Vector to be passed as input for the network
- */
-
-void
-som_set_inputs ( som_network_t *net, double *data )
-{
-	size_t i = 0;
-
-	for ( i=0; i < net->input_layer->neurons_count; ++i )
-	{
-		net->input_layer->neurons[i]->input = data[i];
-	}
-}		/* -----  end of function som_set_inputs  ----- */
-
-/**
- * \brief  Get the coordinates of the output neuron closest to the current input data
- * \param  net 	SOM neural network
- * \param  x 		Reference to the X coordinate of the best output neuron
- * \param  y 		Reference to the Y coordinate of the best output neuron
- * \return The value of the module ||X-W|| (squared euclidean distance) for the best neuron
- */
-
-double
-som_get_best_neuron_coordinates ( som_network_t *net, size_t *x, size_t *y )
-{
-	size_t i = 0,
-		   j = 0,
-		   k = 0;
-
-	double mod 		 = 0.0,
-	    best_dist = DBL_MAX;
-
-	som_neuron_t *neuron;
-
-	for ( i=0; i < net->output_layer->neurons_rows; ++i )
-	{
-		for ( j=0; j < net->output_layer->neurons_cols; ++j )
-		{
-			mod    = 0.0;
-			neuron = net->output_layer->neurons[i][j];
-
-			for ( k=0; k < neuron->synapses_count; ++k )
-			{
-				mod += pow( net->input_layer->neurons[k]->input - neuron->synapses[k]->weight, 2 );
-			}
-
-			if ( mod < best_dist )
-			{
-				best_dist = mod;
-				*x = i;
-				*y = j;
-			}
-		}
-	}
-
-	return mod;
-}		/* -----  end of function som_get_best_neuron_coordinates  ----- */
-
-/**
- * \brief  Get the n-th approximated step of the analytic continuation of the Lambert W-function of a real number x (see "Numerical Evaluation of the Lambert W Function and Application to Generation of Generalized Gaussian Noise With Exponent 1/2" from Chapeau-Blondeau and Monir, IEEE Transactions on Signal Processing, vol.50, no.9, Sep.2002)
- * \param  x 	Input variable of which we're going to compute W[-1](x)
- * \return W[-1](x)
- */
-
-static double
-lambert_W1_function ( som_network_t *net, double x )
-{
-	int j = 0,
-		k = 0;
-
-	double p = 0.0,
-		   res = 0.0,
-		   k_plus = 0,
-		   k_less = 0;
-
-	p = - sqrt ( 2 * ( M_E * x + 1 ));
-
-	net->mus[0]    = -1;
-	net->mus[1]    = 1;
-	net->alphas[0] = 2;
-	net->alphas[1] = -1;
-	for ( k=2; k < TAYLOR_LAMBERT_LAST_ELEMENT; ++k )
-	{
-		net->alphas[k] = 0.0;
-
-		for ( j=2; j < k; ++j )
-		{
-			net->alphas[k] += net->mus[j] * net->mus[ k - j + 1 ];
-		}
-		
-		k_plus = k + 1;
-		k_less = k - 1;
-
-		net->mus[k] = (k_less / k_plus) *
-					  ( (net->mus[k-2] / 2.0) + ( net->alphas[k-2] / 4.0) ) -
-					  ( net->alphas[k] / 2.0 ) -
-					  ( net->mus[(int)k_less] / k_plus );
-
-		res += ( net->mus[k] * pow ( p, k ) );
-	}
-
-	return res;
-}		/* -----  end of function lambert_W1_function  ----- */
-
-/**
- * \brief  Get the learning rate of a step of the learning process in function of the current iteration number
- * \param  net 	SOM neural network
- * \param  t 		Iteration number
- * \param  M 		Maximum value for the learning rate (in [0:1])
- * \param  N 		Iteration number after which the function equals the "cutoff" value (0.01), i.e. the learning rate becomes almost meaningless
- * \return Learning rate
- */
-
-static double
-som_learning_rate ( som_network_t* net, size_t t, double M, size_t N )
-{
-	double value = 0.0,
-		  T = 0.0,
-		  K = 0.0,
-		  W = 0.0,
-		  W_arg = 0.0;
-
-	if ( net->T_learning_param == 0.0 )
-	{
-		K = ( M * (double) N * M_E ) / 0.01;
-		W_arg = -((double) N ) / K;
-		W = lambert_W1_function ( net, W_arg );
-		T = K * exp ( W );
-		net->T_learning_param = T;
-	} else {
-		T = net->T_learning_param;
-	}
-
-	value = M * ( (double) t / T) * exp ( 1 - ( (double) t / T ));
-	return value;
-}		/* -----  end of function som_learning_rate  ----- */
-
-/**
- * \brief  Get the learning rate of a step of the learning process in function of the current iteration number once T_learning_param is set
- * \param  net 	SOM neural network
- * \param  t 		Iteration number
- * \param  M 		Maximum value for the learning rate (in [0:1])
- * \param  N 		Iteration number after which the function equals the "cutoff" value (0.01), i.e. the learning rate becomes almost meaningless
- * \return Learning rate
- */
-
-INLINE double
-som_learning_rate_fast ( som_network_t* net, size_t t, double M, size_t N )
-{
-	double inv_lrate = (double) t / net->T_learning_param;
-	return M * inv_lrate * exp ( 1 - inv_lrate );
-}		/* -----  end of function som_learning_rate  ----- */
-
-/**
- * \brief  Training iteration for the network given a single input data set
- * \param  net 	SOM neural network
- * \param  data 	Input data
- * \param  iter 	Iteration number
- */
-
-static void
-som_train_iteration ( som_network_t *net, double *data, size_t iter )
-{
-	size_t x = 0,
-		  y = 0,
-		  i = 0,
-		  j = 0,
-		  k = 0,
-		  dist = 0,
-		  dist_i;
-
-	double l_rate = 0.0,
-		   inv_dist;
-
-	l_rate = som_learning_rate_fast ( net, iter, 0.8, 200 );
-	som_set_inputs ( net, data );
-	som_get_best_neuron_coordinates ( net, &x, &y );
-
-	som_neuron_t *neuron;
-	for ( i=0; i < net->output_layer->neurons_rows; ++i )
-	{
-		dist_i = abs( x - i );
-		for ( j=0; j < net->output_layer->neurons_cols; ++j )
-		{
-			dist     = pow( dist_i + abs ( y - j ), 4 );
-			inv_dist = (1.0 / ((double) dist + 1)) * l_rate;
-			neuron   = net->output_layer->neurons[i][j];
-			for ( k=0; k < net->input_layer->neurons_count; ++k )
-			{
-				neuron->synapses[k]->weight += inv_dist * ( net->input_layer->neurons[k]->input - neuron->synapses[k]->weight );
-			}
-		}
-	}
-}		/* -----  end of function som_train_loop  ----- */
-
-/**
- * \brief  Initialize the synaptical weights of the network using the algorithm proposed in "Improving the Self-Organization Feature Map Algorithm Using an Efficient Initialization Scheme", by Su, Liu and Chang, on "Tamkang Journal of Science and Engineering", vol.5, no.1, pp.35-48, 2002
- * \param  net 	SOM neural network
- * \param  data 	Input data set
- * \param  n_data 	Number of vectors in the input set
- */
-
-void
-som_init_weights ( som_network_t *net, double **data, size_t n_data )
-{
-	size_t i = 0,
-		  j = 0,
-		  k = 0,
-		  out_rows = 0,
-		  out_cols = 0,
-		  in_size  = 0,
-		  max_i = 0,
-		  max_j = 0,
-		  medium_i = 0,
-		  medium_j = 0;
-
-	double dist = 0.0,
-		  max_dist = 0.0;
-
-	double *avg_data = NULL;
-
-	if ( !( avg_data = (double*) malloc ( net->input_layer->neurons_count * sizeof ( double ))))
-	{
-		return;
-	}
-
-	/* Find the couple of data sets with the maximum distance */
-	for ( i=0; i < n_data; ++i )
-	{
-		for ( j=0; j < n_data; ++j )
-		{
-			if ( i != j )
-			{
-				dist = 0.0;
-
-				for ( k=0; k < net->input_layer->neurons_count; ++k )
-				{
-					dist += fabs ( data[i][k] - data[j][k] );
-				}
-
-				if ( dist > max_dist )
-				{
-					max_dist = dist;
-					max_i = i;
-					max_j = j;
-				}
-			}
-		}
-	}
-
-	/* Compute the avg_data vector as the vector containing the average values of (data[max_i], data[max_j]) */
-	double *max_i_row = data[max_i],
-	       *max_j_row = data[max_j];
-	for ( i=0; i < net->input_layer->neurons_count; ++i )
-	{
-		avg_data[i] = fabs ( max_i_row[i] + max_j_row[i] ) / 2.0;
-	}
-
-	/* Initialize the upper-right and bottom-left vertex of the output matrix with these values */
-	som_neuron_t *ur_neuron = net->output_layer->neurons[0][ net->output_layer->neurons_cols - 1 ],
-				 *bl_neuron = net->output_layer->neurons[ net->output_layer->neurons_rows - 1 ][0];
-	for ( i=0; i < net->input_layer->neurons_count; ++i )
-	{
-		ur_neuron->synapses[i]->weight = max_i_row[i];
-		bl_neuron->synapses[i]->weight = max_j_row[i];
-	}
-
-	/* Find the vector having the maximum distance from the maximum distance vectors */
-	max_dist = DBL_MAX;
-
-	for ( i=0; i < n_data; ++i )
-	{
-		if ( i != max_i && i != max_j )
-		{
-			dist = 0.0;
-
-			for ( k=0; k < net->input_layer->neurons_count; ++k )
-			{
-				dist += fabs ( data[i][k] - avg_data[i] );
-
-				if ( dist < max_dist )
-				{
-					max_dist = dist;
-					medium_i = i;
-				}
-			}
-		}
-	}
-	
-	double *med_i_row = data[medium_i];
-
-	/* Initialize the upper-left corner with the values of this vector */
-	som_neuron_t *ul_neuron = net->output_layer->neurons[0][0];
-	for ( i=0; i < net->input_layer->neurons_count; ++i )
-	{
-		ul_neuron->synapses[i]->weight = med_i_row[i];
-	}
-
-	/* avg_data contains the average values of the 3 vectors computed above */
-	for ( i=0; i < net->input_layer->neurons_count; ++i )
-	{
-		avg_data[i] = fabs ( max_i_row[i] + max_j_row[i] + med_i_row[i] ) / 3.0;
-	}
-
-	/* Find the vector having the maximum distance from the 3 vectors above */
-	max_dist = DBL_MAX;
-
-	for ( i=0; i < n_data; ++i )
-	{
-		if ( i != max_i && i != max_j && i != medium_i )
-		{
-			dist = 0.0;
-
-			for ( k=0; k < net->input_layer->neurons_count; ++k )
-			{
-				dist += fabs ( data[i][k] - avg_data[i] );
-
-				if ( dist < max_dist )
-				{
-					max_dist = dist;
-					medium_j = i;
-				}
-			}
-		}
-	}
-	
-	double *med_j_row = data[medium_j];
-
-	/* Initialize the bottom-right corner with the values of this vector */
-	som_neuron_t *br_neuron = net->output_layer->neurons[ net->output_layer->neurons_rows - 1 ][ net->output_layer->neurons_cols - 1 ];
-	for ( i=0; i < net->input_layer->neurons_count; ++i )
-	{
-		br_neuron->synapses[i]->weight = med_j_row[i];
-	}
-
-	/* Initialize the weights on the 4 edges */
-	out_rows = net->output_layer->neurons_rows;
-	out_cols = net->output_layer->neurons_cols;
-	in_size  = net->input_layer->neurons_count;
-
-	som_neuron_t **edges = net->output_layer->neurons[0];
-	size_t		   last_out_col = out_cols - 1,
-				   span_cols;
-	double		   a, b;
-	for ( j=1; j < out_cols - 1; ++j )
-	{
-		span_cols = out_cols - j;
-		a		  = ( (double)(j - 1) / last_out_col );
-		b		  = ( (double)span_cols / (double)last_out_col );
-		for ( k=0; k < in_size; ++k )
-		{
-			edges[j]->synapses[k]->weight =
-				a * edges[ last_out_col ]->synapses[k]->weight +
-				b * ul_neuron->synapses[k]->weight;
-		}
-	}
-
-	size_t		 last_out_row = out_rows - 1;
-	som_neuron_t *j_neuron,
-				 *br_edge = net->output_layer->neurons[ last_out_row  ][ last_out_col ],
-				 *bl_edge = net->output_layer->neurons[ last_out_row ][0];
-	for ( j=1; j < out_cols - 1; ++j )
-	{
-		j_neuron  = net->output_layer->neurons[last_out_row][j];
-		a		  = (double)(j - 1)		   / (double)last_out_col;
-		b		  = (double)(out_cols - j) / (double)last_out_col;
-
-		for ( k=0; k < in_size; ++k )
-		{
-			j_neuron->synapses[k]->weight = a * br_edge->synapses[k]->weight + b * bl_edge->synapses[k]->weight;
-		}
-	}
-
-	som_neuron_t *i_neuron,
-				 *tl_edge = net->output_layer->neurons[0][0];
-	for ( i=1; i < out_rows - 1; ++i )
-	{
-		i_neuron = net->output_layer->neurons[i][0];
-		a		 = ( ((double) i - 1) / (double) last_out_row );
-		b		 = ( (double) ( out_rows - i ) /  (double)last_out_row);
-		for ( k=0; k < in_size; ++k )
-		{
-			i_neuron->synapses[k]->weight = a * bl_edge->synapses[k]->weight + b * tl_edge->synapses[k]->weight;
-		}
-	}
-
-	som_neuron_t *tr_edge = net->output_layer->neurons[0][ last_out_col ];
-	for ( i=1; i < out_rows - 1; ++i )
-	{
-		i_neuron = net->output_layer->neurons[i][ last_out_col ];
-		a		 = ( ((double) i - 1) / ((double) last_out_row ));
-		b		 = ( (double) ( out_rows - i ) / ((double) last_out_row ));
-		for ( k=0; k < in_size; ++k )
-		{
-			i_neuron->synapses[k]->weight = a * br_edge->synapses[k]->weight + b * tr_edge->synapses[k]->weight;
-		}
-	}
-
-	/* Initialize the weights in the middle of the matrix */
-	som_neuron_t *ij_neuron;
-	double		  sqr_index = (double) last_out_row  * (double) last_out_col,
-				  prev_i,
-				  prev_j,
-				  prev_out_rows,
-				  prev_out_cols,
-				  c,
-				  d;
-	for ( i=1; i < out_rows - 1; ++i )
-	{
-		prev_i 		  = i - 1;
-		prev_out_rows = out_rows - i;
-		for ( j=1; j < out_cols - 1; ++j )
-		{
-			prev_j	  	  = j - 1;
-			ij_neuron 	  = net->output_layer->neurons[i][j];
-			prev_out_cols = out_cols - j;
-			a		  	  = ( prev_j * prev_i ) / sqr_index;
-			b	   	  	  = ( prev_j * prev_out_rows ) / sqr_index;
-			c		  	  = ( prev_out_cols * prev_i ) / sqr_index;
-			d		 	  = ( prev_out_cols * prev_out_rows ) / sqr_index;
-			for ( k=0; k < in_size; ++k )
-			{
-				ij_neuron->synapses[k]->weight =
-					a *
-					br_edge->synapses[k]->weight +
-					b *
-					tr_edge->synapses[k]->weight +
-					c *
-					bl_edge->synapses[k]->weight +
-					d *
-					tl_edge->synapses[k]->weight;
-			}
-		}
-	}
-	free(avg_data); // cleanup
-}		/* -----  end of function som_init_weights  ----- */
-
-/**
- * \brief  Train the self-organizing map through a data set
- * \param  net 	SOM neural network
- * \param  data 	Data set (set of input vectors)
- * \param  n_data 	Number of input vectors in data
- * \param  iter 	Number of iterations
- */
-
-void
-som_train ( som_network_t *net, double **data, size_t n_data, size_t iter )
-{
-	size_t n = 0,
-		  k = 0,
-		  x = 0,
-		  y = 0;
-		
-	som_learning_rate( net, iter, 0.8, 200 );
-
-	for ( n=0; n < n_data; ++n )
-	{
-		for ( k=1; k <= iter; ++k )
-		{
-			som_train_iteration ( net, data[n], k );
-
-			if ( som_get_best_neuron_coordinates ( net, &x, &y ) == 0.0 )
-				break;
-		}
-	}
-}		/* -----  end of function som_train  ----- */
-
-/**
- * \brief  Serialize a neural network on a binary file
- * \param  net 	SOM network to be serialized
- * \param  fname 	Output file name
- */
-
-void
-som_serialize ( som_network_t *net, const char *fname )
-{
-	FILE *fp = NULL;
-	size_t i = 0,
-		  j = 0,
-		  k = 0;
-	
-	if ( !( fp = fopen ( fname, "w" )))
-	{
-		return;
-	}
-
-	net->serialization_time = time ( NULL );
-	fwrite ( &(net->serialization_time), sizeof ( time_t ), 1, fp );
-	fwrite ( &(net->T_learning_param), sizeof ( double ), 1, fp );
-	fwrite ( &(net->input_layer->neurons_count), sizeof ( size_t ), 1, fp );
-	fwrite ( &(net->output_layer->neurons_rows), sizeof ( size_t ), 1, fp );
-	fwrite ( &(net->output_layer->neurons_cols), sizeof ( size_t ), 1, fp );
-
-	for ( i=0; i < net->output_layer->neurons_rows; ++i )
-	{
-		for ( j=0; j < net->output_layer->neurons_cols; ++j )
-		{
-			for ( k=0; k < net->output_layer->neurons[i][j]->synapses_count; ++k )
-			{
-				fwrite ( &(net->output_layer->neurons[i][j]->synapses[k]->weight), sizeof ( double ), 1, fp );
-			}
-		}
-	}
-
-	fclose ( fp );
-}		/* -----  end of function som_serialize  ----- */
-
-/**
- * \brief  Initialize a SOM neural network from a serialized one on a file
- * \param  fname 	Binary file containing the network
- * \return The initialized network in case of success, NULL otherwise
- */
-
-som_network_t*
-som_deserialize ( const char* fname )
-{
-	som_network_t *net = NULL;
-	FILE *fp = NULL;
-	double weight = 0.0;
-	size_t i = 0,
-		  j = 0,
-		  k = 0,
-		  input_neurons = 0,
-		  output_neurons_rows = 0,
-		  output_neurons_cols = 0;
-
-	if ( !( fp = fopen ( fname, "r" )))
-	{
-		return NULL;
-	}
-
-	if ( !( net = ( som_network_t* ) calloc ( 1, sizeof ( som_network_t ))))
-	{
-		return NULL;
-	}
-
-	fread ( &(net->serialization_time), sizeof ( time_t ), 1, fp );
-	fread ( &(net->T_learning_param ), sizeof ( double ), 1, fp );
-	fread ( &input_neurons, sizeof ( size_t ), 1, fp );
-	fread ( &output_neurons_rows, sizeof ( size_t ), 1, fp );
-	fread ( &output_neurons_cols, sizeof ( size_t ), 1, fp );
-
-	if ( !( net->input_layer = som_input_layer_new ( input_neurons )))
-	{
-		free ( net );
-		return NULL;
-	}
-
-	if ( !( net->output_layer = som_output_layer_new ( output_neurons_rows, output_neurons_cols )))
-	{
-		free ( net->input_layer );
-		free ( net );
-		return NULL;
-	}
-
-	for ( i=0; i < output_neurons_rows; ++i )
-	{
-		for ( j=0; j < output_neurons_cols; ++j )
-		{
-			for ( k=0; k < input_neurons; ++k )
-			{
-				fread ( &weight, sizeof ( double ), 1, fp );
-
-				if ( !( som_synapsis_new ( net->input_layer->neurons[k], net->output_layer->neurons[i][j], weight )))
-				{
-					som_input_layer_destroy ( net );
-					som_output_layer_destroy ( net );
-					return NULL;
-				}
-			}
-		}
-	}
-
-	return net;
-}		/* -----  end of function som_deserialize  ----- */
-
diff --git a/vcflib/fsom/fsom.h b/vcflib/fsom/fsom.h
deleted file mode 100644
index 6f68112..0000000
--- a/vcflib/fsom/fsom.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * =====================================================================================
- *
- *       Filename:  neural_som.h
- *
- *    Description:  Header file for neural_som mini-library
- *
- *        Version:  0.1
- *        Created:  15/10/2010 15:31:50
- *       Revision:  none
- *       Compiler:  gcc
- *
- *         Author:  BlackLight (http://0x00.ath.cx), <blacklight at autistici.org>
- *    Contributor:  evilsocket (http://www.evilsocket.net), <evilsocket at gmail.com>
- *        Licence:  GNU GPL v.3
- *        Company:  DO WHAT YOU WANT CAUSE A PIRATE IS FREE, YOU ARE A PIRATE!
- *
- * =====================================================================================
- */
-
-#ifndef 	__NEURAL_SOM_H
-#define 	__NEURAL_SOM_H
-
-#include	<stddef.h>
-#include	<time.h>
-
-#define TAYLOR_LAMBERT_ELEMENTS 	1001
-#define TAYLOR_LAMBERT_LAST_ELEMENT 1000
-
-#ifndef INLINE
-#	define INLINE __inline__ __attribute__((always_inline))
-#endif
-
-typedef struct  {
-	double                 output;
-	double                 input;
-
-	struct som_synapsis_s  **synapses;
-	size_t                 synapses_count;
-} som_neuron_t
-__attribute__ ((aligned));;
-
-typedef struct som_synapsis_s  {
-	som_neuron_t    *neuron_in;
-	som_neuron_t    *neuron_out;
-	double          weight;
-} som_synapsis_t
-__attribute__ ((aligned));
-
-typedef struct  {
-	som_neuron_t    **neurons;
-	size_t          neurons_count;
-} som_input_layer_t
-__attribute__ ((aligned));
-
-typedef struct  {
-	som_neuron_t    ***neurons;
-	size_t          neurons_rows;
-	size_t          neurons_cols;
-} som_output_layer_t
-__attribute__ ((aligned));
-
-#ifdef __APPLE__
-typedef struct somename {
-#else
-typedef struct {
-#endif
-	som_input_layer_t   *input_layer;
-	som_output_layer_t  *output_layer;
-	double              T_learning_param;
-	time_t              serialization_time;
-	double				alphas[TAYLOR_LAMBERT_ELEMENTS];
-	double			    mus[TAYLOR_LAMBERT_ELEMENTS];
-} som_network_t
-__attribute__ ((aligned));
-
-void                 som_network_destroy ( som_network_t* );
-void                 som_set_inputs ( som_network_t*, double* );
-void                 som_train ( som_network_t*, double**, size_t, size_t );
-void                 som_serialize ( som_network_t*, const char* );
-void                 som_init_weights ( som_network_t*, double**, size_t );
-double               som_get_best_neuron_coordinates ( som_network_t*, size_t*, size_t* );
-som_network_t*       som_deserialize ( const char* );
-som_network_t*       som_network_new ( size_t, size_t, size_t );
-
-#endif
-
diff --git a/vcflib/fsom/main.cpp b/vcflib/fsom/main.cpp
deleted file mode 100644
index 63a8074..0000000
--- a/vcflib/fsom/main.cpp
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * =====================================================================================
- *
- *       Filename:  example.c
- *
- *    Description:  Examle file to benchmark fsom library.
- *
- *        Version:  0.1
- *       Revision:  none
- *       Compiler:  gcc
- *
- *         Author:  BlackLight (http://0x00.ath.cx), <blacklight at autistici.org>
- *    Contributor:  evilsocket (http://www.evilsocket.net), <evilsocket at gmail.com>
- *        Licence:  GNU GPL v.3
- *        Company:  DO WHAT YOU WANT CAUSE A PIRATE IS FREE, YOU ARE A PIRATE!
- *
- * =====================================================================================
- */
-#include "fsom.h"
-
-#include "convert.h"
-#include "split.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/time.h>
-#include <getopt.h>
-#include <iostream>
-#include <sstream>
-#include <fstream>
-#include <vector>
-
-using namespace std;
-
-static unsigned long prev_uticks = 0;
-
-static unsigned long get_uticks(){
-    struct timeval ts;
-    gettimeofday(&ts,0);
-    return ((ts.tv_sec * 1000000) + ts.tv_usec);
-}
-
-static void start_timer(){
-    prev_uticks = get_uticks();
-}
-
-static void print_timing( const char *msg ){
-#define MS_DELTA (1000.0)
-#define SS_DELTA (MS_DELTA * 1000.0)
-#define MM_DELTA (SS_DELTA * 60.0)
-#define HH_DELTA (MM_DELTA * 60.0)
-
-    double ticks = get_uticks() - prev_uticks;
-
-    if( ticks < MS_DELTA ){
-	fprintf(stderr, "%s\t : %lf us\n", msg, ticks );
-    }
-    else if( ticks < SS_DELTA ){
-	fprintf(stderr, "%s\t : %lf ms\n", msg, ticks / MS_DELTA );
-    }
-    else if( ticks < MM_DELTA ){
-	fprintf(stderr, "%s\t : %lf s\n", msg, ticks / SS_DELTA );
-    }
-    else if( ticks < HH_DELTA ){
-	fprintf(stderr, "%s\t : %lf m\n", msg, ticks / MM_DELTA );
-    }
-    else{
-	fprintf(stderr, "%s\t : %lf h\n", msg, ticks / HH_DELTA );
-    }
-
-    start_timer();
-}
-
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [options]" << endl
-         << endl
-         << "Trains and applies a self-organizing map to the input tab-separated data on" << endl
-	 << "stdin, adding two columns for the x and y coordinates of the winning neuron" << endl
-	 << "in the network." << endl
-	 << endl
-	 << "If a map is provided, training will be skipped and the map will be applied to" << endl
-	 << "the input.  Maps may be saved for later use." << endl
-	 << endl
-         << "options:" << endl
-         << "    -h, --help          this dialog" << endl
-	 << "    -a, --apply FILE    apply the saved map to input data to FILE" << endl
-	 << "    -s, --save  FILE    train on input data and save the map to FILE" << endl
-         << "    -x, --width X       width in columns of the output array" << endl
-         << "    -y, --height Y      height in columns of the output array" << endl
-         << "    -i, --iterations N  number of training iterations or epochs" << endl;
-}
-
-
-int main(int argc, char** argv) {   
-
-    int width = 100;
-    int height = 100;
-    int num_dimensions = 2;
-    int iterations = 1000;
-    string save_file;
-    string load_file;
-
-    int c;
-
-    if (argc == 1) {
-        printSummary(argv);
-        exit(1);
-    }
-
-    while (true) {
-        static struct option long_options[] =
-        {  
-            /* These options set a flag. */
-            //{"verbose", no_argument,       &verbose_flag, 1},
-            {"help", no_argument, 0, 'h'},
-            {"iterations", required_argument, 0, 'i'},
-            {"width", required_argument, 0, 'x'},
-            {"height", required_argument, 0, 'y'},
-	    {"apply", required_argument, 0, 'a'},
-	    {"save", required_argument, 0, 's'},
-            {0, 0, 0, 0}
-        };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "hi:x:y:a:s:",
-                         long_options, &option_index);
-
-        if (c == -1)
-            break;
-
-        string field;
-
-        switch (c)
-        {
-
-            case 'x':
-                if (!convert(optarg, width)) {
-                    cerr << "could not parse --width, -x" << endl;
-                    exit(1);
-                }
-                break;
-
-            case 'y':
-                if (!convert(optarg, height)) {
-                    cerr << "could not parse --height, -y" << endl;
-                    exit(1);
-                }
-                break;
-
-            case 'i':
-                if (!convert(optarg, iterations)) {
-                    cerr << "could not parse --iterations, -i" << endl;
-                    exit(1);
-                }
-                break;
-
-            case 'a':
-                load_file = optarg;
-                break;
-
-            case 's':
-                save_file = optarg;
-                break;
-
-            case 'h':
-                printSummary(argv);
-                exit(0);
-                break;
-
-            default:
-                break;
-        }
-    }
-
-    size_t i, j;
-    som_network_t *net = NULL;
-    vector<string> inputs;
-    vector<vector<double> > data;
-
-
-    string line;
-    stringstream ss;
-
-    /*
-    if (!load_file.empty()) { // apply
-	while (getline(cin, line)) {
-	    vector<double> record;
-	    vector<string> items;
-	    split(line, '\t', items);
-	    int ti;
-	    vector<string>::iterator j = items.begin();
-	    for (; j != items.end(); ++j) {
-		convert(*j, ti);
-		record.push_back(ti);
-	    }
-	    som_set_inputs(net, &record[0]);
-	    som_get_best_neuron_coordinates(net, &x, &y);
-	    cout << x << "\t" << y << "\t" << line << endl;
-	}
-	return 0; // done with application
-    } else { // get data
-    */
-    while (getline(cin, line)) {
-	inputs.push_back(line);
-	vector<double> record;
-	vector<string> items;
-	split(line, '\t', items);
-	double td;
-	vector<string>::iterator j = items.begin();
-	for (; j != items.end(); ++j) {
-	    convert(*j, td);
-	    record.push_back(td);
-	}
-	data.push_back(record);
-    }
-    //}
-
-    vector<double*> dataptrs (data.size());
-    for (unsigned i=0, e=dataptrs.size(); i<e; ++i) {
-	dataptrs[i] = &(data[i][0]); // assuming !thing[i].empty()
-    }
-
-    start_timer();
-
-    if (!load_file.empty()) {
-	cerr << "Loading ... "  << endl;
-	if (! (net = som_deserialize(load_file.c_str()))) {
-	    cerr << "could not load SOM from " << load_file << endl;
-	    return 1;
-	}
-    } else {
-
-	net = som_network_new(data[0].size(), height, width);
-	
-	if ( !net )	{
-	    printf( "ERROR: som_network_new failed.\n" );
-	    return 1;
-	}
-    }
-
-    print_timing( "Network Creation" );
-
-    if (!save_file.empty()) {
-	cerr << "Training using " << data.size() << " input vectors" << endl;
-	som_init_weights ( net, &dataptrs[0], data.size() );
-	som_train ( net, &dataptrs[0], data.size(), iterations );
-    }
-
-    print_timing( "Network Training" );
-
-    for ( i=0; i < data.size(); ++i ) {
-	som_set_inputs ( net, dataptrs[i] );
-	size_t x=0, y=0;
-	som_get_best_neuron_coordinates ( net, &x, &y );
-	//printf ( "best coordinates [%u]: %u,%u\n", i, x, y );
-	cout << x << "\t" << y << "\t" << inputs[i] << endl;
-    }
-
-    print_timing( "Input Recognition" );
-
-    if (!save_file.empty()) {
-	som_serialize(net, save_file.c_str());
-    }
-
-    som_network_destroy ( net );
-
-    print_timing( "Network Destruction" );
-
-    return 0;
-}			
diff --git a/vcflib/fsom/split.cpp b/vcflib/fsom/split.cpp
deleted file mode 100644
index 5f1dc4e..0000000
--- a/vcflib/fsom/split.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-#include "split.h"
-
-std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) {
-    std::stringstream ss(s);
-    std::string item;
-    while(std::getline(ss, item, delim)) {
-        elems.push_back(item);
-    }
-    return elems;
-}
-
-std::vector<std::string> split(const std::string &s, char delim) {
-    std::vector<std::string> elems;
-    return split(s, delim, elems);
-}
-
-std::vector<std::string> &split(const std::string &s, const std::string& delims, std::vector<std::string> &elems) {
-    char* tok;
-    char cchars [s.size()+1];
-    char* cstr = &cchars[0];
-    strcpy(cstr, s.c_str());
-    tok = strtok(cstr, delims.c_str());
-    while (tok != NULL) {
-        elems.push_back(tok);
-        tok = strtok(NULL, delims.c_str());
-    }
-    return elems;
-}
-
-std::vector<std::string> split(const std::string &s, const std::string& delims) {
-    std::vector<std::string> elems;
-    return split(s, delims, elems);
-}
diff --git a/vcflib/fsom/split.h b/vcflib/fsom/split.h
deleted file mode 100644
index bd5525d..0000000
--- a/vcflib/fsom/split.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef __SPLIT_H
-#define __SPLIT_H
-
-// functions to split a string by a specific delimiter
-#include <string>
-#include <vector>
-#include <sstream>
-#include <string.h>
-
-// thanks to Evan Teran, http://stackoverflow.com/questions/236129/how-to-split-a-string/236803#236803
-
-// split a string on a single delimiter character (delim)
-std::vector<std::string>& split(const std::string &s, char delim, std::vector<std::string> &elems);
-std::vector<std::string>  split(const std::string &s, char delim);
-
-// split a string on any character found in the string of delimiters (delims)
-std::vector<std::string>& split(const std::string &s, const std::string& delims, std::vector<std::string> &elems);
-std::vector<std::string>  split(const std::string &s, const std::string& delims);
-
-#endif
diff --git a/vcflib/intervaltree/.gitignore b/vcflib/intervaltree/.gitignore
deleted file mode 100644
index 7ffcca6..0000000
--- a/vcflib/intervaltree/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-interval_tree_test
diff --git a/vcflib/intervaltree/IntervalTree.h b/vcflib/intervaltree/IntervalTree.h
deleted file mode 100644
index 4ff8de3..0000000
--- a/vcflib/intervaltree/IntervalTree.h
+++ /dev/null
@@ -1,214 +0,0 @@
-#ifndef __INTERVAL_TREE_H
-#define __INTERVAL_TREE_H
-
-#include <vector>
-#include <algorithm>
-#include <iostream>
-
-using namespace std;
-
-
-template <class T>
-class Interval {
-public:
-    int start;
-    int stop;
-    T value;
-    Interval(int s, int e, const T& v)
-        : start(s)
-        , stop(e)
-        , value(v)
-    { }
-};
-
-template <class T>
-int intervalStart(const Interval<T>& i) {
-    return i.start;
-}
-
-template <class T>
-int intervalStop(const Interval<T>& i) {
-    return i.stop;
-}
-
-template <class T>
-ostream& operator<<(ostream& out, Interval<T>& i) {
-    out << "Interval(" << i.start << ", " << i.stop << "): " << i.value;
-    return out;
-}
-
-template <class T>
-class IntervalStartSorter {
-public:
-    bool operator() (const Interval<T>& a, const Interval<T>& b) {
-        return a.start < b.start;
-    }
-};
-
-template <class T>
-class IntervalTree {
-
-public:
-    vector<Interval<T> > intervals;
-    IntervalTree<T>* left;
-    IntervalTree<T>* right;
-    int center;
-
-    IntervalTree<T>(void)
-        : left(NULL)
-        , right(NULL)
-        , center(0)
-    { }
-
-    IntervalTree<T>(const IntervalTree<T>& other) {
-        center = other.center;
-        intervals = other.intervals;
-        if (other.left) {
-            left = (IntervalTree<T>*) malloc(sizeof(IntervalTree<T>));
-            *left = *other.left;
-        } else {
-            left = NULL;
-        }
-        if (other.right) {
-            right = new IntervalTree<T>();
-            *right = *other.right;
-        } else {
-            right = NULL;
-        }
-    }
-
-    IntervalTree<T>& operator=(const IntervalTree<T>& other) {
-        center = other.center;
-        intervals = other.intervals;
-        if (other.left) {
-            left = new IntervalTree<T>();
-            *left = *other.left;
-        } else {
-            left = NULL;
-        }
-        if (other.right) {
-            right = new IntervalTree<T>();
-            *right = *other.right;
-        } else {
-            right = NULL;
-        }
-    }
-
-    IntervalTree<T>(
-            vector<Interval<T> >& ivals,
-            int depth = 16,
-            int minbucket = 64,
-            int leftextent = 0,
-            int rightextent = 0,
-            int maxbucket = 512
-            )
-        : left(NULL)
-        , right(NULL)
-    {
-
-        --depth;
-        if (depth == 0 || ivals.size() < minbucket && ivals.size() < maxbucket) {
-            intervals = ivals;
-        } else {
-            if (leftextent == 0 && rightextent == 0) {
-                // sort intervals by start
-                IntervalStartSorter<T> intervalStartSorter;
-                sort(ivals.begin(), ivals.end(), intervalStartSorter);
-            }
-
-            int leftp = 0;
-            int rightp = 0;
-            int centerp = 0;
-            
-            if (leftextent || rightextent) {
-                leftp = leftextent;
-                rightp = rightextent;
-            } else {
-                leftp = ivals.front().start;
-                vector<int> stops;
-                stops.resize(ivals.size());
-                transform(ivals.begin(), ivals.end(), stops.begin(), intervalStop<T>);
-                rightp = *max_element(stops.begin(), stops.end());
-            }
-
-            //centerp = ( leftp + rightp ) / 2;
-            centerp = ivals.at(ivals.size() / 2).start;
-            center = centerp;
-
-            vector<Interval<T> > lefts;
-            vector<Interval<T> > rights;
-
-            for (typename vector<Interval<T> >::iterator i = ivals.begin(); i != ivals.end(); ++i) {
-                Interval<T>& interval = *i;
-                if (interval.stop < center) {
-                    lefts.push_back(interval);
-                } else if (interval.start > center) {
-                    rights.push_back(interval);
-                } else {
-                    intervals.push_back(interval);
-                }
-            }
-
-            if (!lefts.empty()) {
-                left = new IntervalTree<T>(lefts, depth, minbucket, leftp, centerp);
-            }
-            if (!rights.empty()) {
-                right = new IntervalTree<T>(rights, depth, minbucket, centerp, rightp);
-            }
-        }
-    }
-
-    void findOverlapping(int start, int stop, vector<Interval<T> >& overlapping) {
-        if (!intervals.empty() && ! (stop < intervals.front().start)) {
-            for (typename vector<Interval<T> >::iterator i = intervals.begin(); i != intervals.end(); ++i) {
-                Interval<T>& interval = *i;
-                if (interval.stop >= start && interval.start <= stop) {
-                    overlapping.push_back(interval);
-                }
-            }
-        }
-
-        if (left && start <= center) {
-            left->findOverlapping(start, stop, overlapping);
-        }
-
-        if (right && stop >= center) {
-            right->findOverlapping(start, stop, overlapping);
-        }
-
-    }
-
-    void findContained(int start, int stop, vector<Interval<T> >& contained) {
-        if (!intervals.empty() && ! (stop < intervals.front().start)) {
-            for (typename vector<Interval<T> >::iterator i = intervals.begin(); i != intervals.end(); ++i) {
-                Interval<T>& interval = *i;
-                if (interval.start >= start && interval.stop <= stop) {
-                    contained.push_back(interval);
-                }
-            }
-        }
-
-        if (left && start <= center) {
-            left->findContained(start, stop, contained);
-        }
-
-        if (right && stop >= center) {
-            right->findContained(start, stop, contained);
-        }
-
-    }
-
-    ~IntervalTree(void) {
-        // traverse the left and right
-        // delete them all the way down
-        if (left) {
-            delete left;
-        }
-        if (right) {
-            delete right;
-        }
-    }
-
-};
-
-#endif
diff --git a/vcflib/intervaltree/Makefile b/vcflib/intervaltree/Makefile
deleted file mode 100644
index c23b3ef..0000000
--- a/vcflib/intervaltree/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-interval_tree_test: interval_tree_test.cpp IntervalTree.h
-	g++ interval_tree_test.cpp -o interval_tree_test -std=c++0x
-
-.PHONY: clean
-
-clean:
-	rm interval_tree_test
diff --git a/vcflib/intervaltree/interval_tree_test.cpp b/vcflib/intervaltree/interval_tree_test.cpp
deleted file mode 100644
index d600677..0000000
--- a/vcflib/intervaltree/interval_tree_test.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-#include <iostream>
-#include <thread>
-#include <chrono>
-#include <random>
-#include <time.h>
-#include <assert.h>
-#include "IntervalTree.h"
-
-using namespace std;
-
-int randInt(int floor, int ceiling) {
-    int range = ceiling - floor;
-    return floor + range * ((double) rand() / (double) (RAND_MAX + 1.0));
-}
-
-template<class T>
-Interval<T> randomInterval(int maxStart, int maxLength, int maxStop, const T& value) {
-    int start = randInt(0, maxStart);
-    int stop = min(randInt(start, start + maxLength), maxStop);
-    return Interval<T>(start, stop, value);
-}
-
-int main() {
-
-    srand((unsigned)time(NULL));
-
-    vector<Interval<bool> > intervals;
-    vector<Interval<bool> > queries;
-
-    // generate a test set of target intervals
-    for (int i = 0; i < 10000; ++i) {
-        intervals.push_back(randomInterval(100000, 1000, 100000 + 1, true));
-    }
-    // and queries
-    for (int i = 0; i < 5000; ++i) {
-        queries.push_back(randomInterval(100000, 1000, 100000 + 1, true));
-    }
-
-    typedef chrono::high_resolution_clock Clock;
-    typedef chrono::milliseconds milliseconds;
-
-    // using brute-force search
-    vector<int> bruteforcecounts;
-    Clock::time_point t0 = Clock::now();
-    for (vector<Interval<bool> >::iterator q = queries.begin(); q != queries.end(); ++q) {
-        vector<Interval<bool> > results;
-        for (vector<Interval<bool> >::iterator i = intervals.begin(); i != intervals.end(); ++i) {
-            if (i->start >= q->start && i->stop <= q->stop) {
-                results.push_back(*i);
-            }
-        }
-        bruteforcecounts.push_back(results.size());
-    }
-    Clock::time_point t1 = Clock::now();
-    milliseconds ms = chrono::duration_cast<milliseconds>(t1 - t0);
-    cout << "brute force:\t" << ms.count() << "ms" << endl;
-
-    // using the interval tree
-    //IntervalTree<bool> tree(intervals);
-    IntervalTree<bool> tree;
-    tree = IntervalTree<bool>(intervals);
-    vector<int> treecounts;
-    t0 = Clock::now();
-    for (vector<Interval<bool> >::iterator q = queries.begin(); q != queries.end(); ++q) {
-        vector<Interval<bool> > results;
-        tree.findContained(q->start, q->stop, results);
-        treecounts.push_back(results.size());
-    }
-    t1 = Clock::now();
-    ms = std::chrono::duration_cast<milliseconds>(t1 - t0);
-    cout << "interval tree:\t" << ms.count() << "ms" << endl;
-
-    // check that the same number of results are returned
-    vector<int>::iterator b = bruteforcecounts.begin();
-    for (vector<int>::iterator t = treecounts.begin(); t != treecounts.end(); ++t, ++b) {
-        assert(*b == *t);
-    }
-
-    return 0;
-}
-
diff --git a/vcflib/multichoose/.gitignore b/vcflib/multichoose/.gitignore
deleted file mode 100644
index b24a058..0000000
--- a/vcflib/multichoose/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-multichoose
-cmultichoose
-tad
-.*swp
-*.pyc
diff --git a/vcflib/multichoose/Makefile b/vcflib/multichoose/Makefile
deleted file mode 100644
index 04e6cab..0000000
--- a/vcflib/multichoose/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-all: multichoose multipermute
-
-#multichoose_recursive: multichoose_recursive.cpp
-#	g++ multichoose_recursive.cpp -o multichoose_recursive
-
-multichoose: multichoose.cpp multichoose.h
-	g++ multichoose.cpp -o multichoose
-
-multipermute: multipermute.cpp multipermute.h
-	g++ multipermute.cpp -o multipermute
-
-cmultichoose: multichoose.c
-	gcc multichoose.c -o cmultichoose
-
-clean:
-	rm cmultichoose
-	rm multichoose
diff --git a/vcflib/multichoose/README b/vcflib/multichoose/README
deleted file mode 100644
index 605eeb4..0000000
--- a/vcflib/multichoose/README
+++ /dev/null
@@ -1,40 +0,0 @@
-Multiset combinations, n multichoose k
-
-Erik Garrison <erik.garrison at bc.edu>
-
-multichoose.cpp --
-
-This is a small C++ library/program which contains a generic function to
-generate multisets for vectors of any type of object.  You can test out the
-program using strings input from the command line by typing:
-
-    % make
-
-Running:
-
-    % ./multichoose
-
-Prints usage information:
-
-    usage: 
-    ./multichoose <k> <item1> <item2> ... <itemN>  ~ n multichoose k
-
-Example usage:
-
-    % ./multichoose 2 a t g c
-    a a 
-    a t 
-    a g 
-    a c 
-    t t 
-    t g 
-    t c 
-    g g 
-    g c 
-    c c 
-
-This example lists all the possible *unordered' genotypes at a given genetic
-loci of which there are two copies (e.g. chromosomes).  'k' (2 in this case)
-could be understood as the expected ploidy of the given locus.  Applying
-multiset permutations to each of the results would generate all possible
-ordered multisets.
diff --git a/vcflib/multichoose/multichoose.c b/vcflib/multichoose/multichoose.c
deleted file mode 100644
index e29b540..0000000
--- a/vcflib/multichoose/multichoose.c
+++ /dev/null
@@ -1,53 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-
-
-int main(int argc, char** argv){
-
-    int *a, *b;
-    char **m;
-    int i,j,j_1,k,n,r;
-
-    if (argc<3) {
-        printf("usage: ./multi_erik k item_1 ... item_n\n");
-        return 0;
-    }
-    n = atoi(argv[1]);
-    r = argc - 2;
-
-    m = malloc(r * sizeof(char*));
-    a = malloc(n * sizeof(int));
-    b = malloc(n * sizeof(int));
-
-    for (i=2;i<argc;i++)
-        m[i-1] = argv[i];
-
-    for (i=1;i<=n;i++) {
-        a[i] = 1; b[i] = r;
-    }
-
-    j=n;
-    while(1){
-        // emit multiset combination
-        for(i=1;i<=n;i++)
-            printf("%s ", m[a[i]]);
-        printf("\n");
-        j=n;
-        while(a[j]==b[j])j--;
-        if (j<=0) break;
-        j_1=j;
-        while(j_1<=n){
-            a[j_1]=a[j_1]+1;
-            k=j_1;
-            while(k<n) {
-                a[k+1]=a[k];
-                k++;
-            }
-            k++;
-            j_1=k;
-        }
-    }
-
-    return 0;
-}
-
diff --git a/vcflib/multichoose/multichoose.cpp b/vcflib/multichoose/multichoose.cpp
deleted file mode 100644
index 455e7e6..0000000
--- a/vcflib/multichoose/multichoose.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/* 
-
-multichoose.cpp  -- n multichoose k for generic vectors
-
-author: Erik Garrison <erik.garrison at bc.edu>
-last revised: 2010-04-16
-
-Copyright (c) 2010 by Erik Garrison
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
- */
-
-#include <iostream>
-#include <vector>
-#include <list>
-#include <stdlib.h>
-#include "multichoose.h"
-
-
-using namespace std;
-
-
-int main(int argc, char** argv) { 
-    if (argc < 3) {
-        cerr << "usage: " << endl
-             << argv[0] << " <k> <item1> <item2> ... <itemN>  ~ n multichoose k" << endl;
-        return 1;
-    }
-
-    int k = atoi(argv[1]);
-    vector<string> items;
-    for (int i = 2; i < argc; ++i) {
-        items.push_back(string(argv[i]));
-    }
-
-    vector< vector<string> > results = multichoose(k, items);
-
-    for (vector< vector<string> >::const_iterator i = results.begin(); i != results.end(); ++i) {
-        for (vector<string>::const_iterator j = i->begin(); j != i->end(); ++j) {
-            cout << *j << " ";
-        }
-        cout << endl;
-    }
-
-    return 0; 
-}
diff --git a/vcflib/multichoose/multichoose.h b/vcflib/multichoose/multichoose.h
deleted file mode 100644
index 51acb24..0000000
--- a/vcflib/multichoose/multichoose.h
+++ /dev/null
@@ -1,79 +0,0 @@
-#ifndef __MULTICHOOSE_H
-#define __MULTICHOOSE_H
-
-/* 
-
-multichoose.h  -- n multichoose k for generic vectors
-
-author: Erik Garrison <erik.garrison at bc.edu>
-last revised: 2010-04-16
-
-Copyright (c) 2010 by Erik Garrison
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-*/
-
-
-// provides multiset combinations out of the std::vector of objects
-template <class T>
-std::vector< std::vector<T> > multichoose(int k, std::vector<T>& objects) {
-
-    std::vector< std::vector<T> > choices;
-
-    int j,j_1,q,r;
-
-    r = objects.size() - 1;
-
-    // combination indexes
-    std::vector<T*> a, b;
-
-    for (int i=0;i<k;i++) {
-        a.push_back(&objects[0]); b.push_back(&objects[r]);
-    }
-
-    j=k;
-    while(1){
-        std::vector<T> multiset;
-        for(int i=0;i<k;i++)
-            multiset.push_back(*a[i]);
-        choices.push_back(multiset);
-        j=k;
-        do { j--; } while(a[j]==b[j]);
-        if (j<0) break;
-        j_1=j;
-        while(j_1<=k-1){
-            a[j_1]=a[j_1]+1;
-            q=j_1;
-            while(q<k-1) {
-                a[q+1]=a[q];
-                q++;
-            }
-            q++;
-            j_1=q;
-        }
-    }
-    
-    return choices;
-}
-
-#endif
diff --git a/vcflib/multichoose/multichoose.py b/vcflib/multichoose/multichoose.py
deleted file mode 100644
index 62ae7ba..0000000
--- a/vcflib/multichoose/multichoose.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# encoding: utf-8
-
-"""
-
-multichoose.py  -- non-recursive n multichoose k for python lists
-
-author: Erik Garrison <erik.garrison at bc.edu>
-last revised: 2010-04-30
-
-Copyright (c) 2010 by Erik Garrison
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-"""
-
-def multichoose(k, objects):
-    """n multichoose k multisets from the list of objects.  n is the size of
-    the objects."""
-    j,j_1,q = k,k,k  # init here for scoping
-    r = len(objects) - 1
-    a = [0 for i in range(k)] # initial multiset indexes
-    while True:
-        yield [objects[a[i]] for i in range(0,k)]  # emit result
-        j = k - 1
-        while j >= 0 and a[j] == r: j -= 1
-        if j < 0: break  # check for end condition
-        j_1 = j
-        while j_1 <= k - 1:
-            a[j_1] = a[j_1] + 1 # increment
-            q = j_1
-            while q < k - 1:
-                a[q+1] = a[q] # shift left
-                q += 1
-            q += 1
-            j_1 = q
-
diff --git a/vcflib/multichoose/multipermute.cpp b/vcflib/multichoose/multipermute.cpp
deleted file mode 100644
index fc26a25..0000000
--- a/vcflib/multichoose/multipermute.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/* 
-
-multipermute.cpp  -- multiset permutations for generic vectors
-
-author: Erik Garrison <erik.garrison at bc.edu>
-last revised: 2010-06-02
-
-Copyright (c) 2010 by Erik Garrison
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-*/
-
-
-#include <iostream>
-#include <vector>
-#include <list>
-#include <stdlib.h>
-#include "multipermute.h"
-
-
-using namespace std;
-
-
-int main(int argc, char** argv) { 
-    if (argc < 3) {
-        cerr << "usage: " << endl
-             << argv[0] << " [multiset, items delimited by space]  ~ multiset permutations of " << endl;
-        return 1;
-    }
-
-    vector<string> items;
-    for (int i = 1; i < argc; ++i) {
-        items.push_back(string(argv[i]));
-    }
-
-    vector< vector<string> > results = multipermute(items);
-
-    for (vector< vector<string> >::const_iterator i = results.begin(); i != results.end(); ++i) {
-        for (vector<string>::const_iterator j = i->begin(); j != i->end(); ++j) {
-            cout << *j << " ";
-        }
-        cout << endl;
-    }
-
-    return 0; 
-}
diff --git a/vcflib/multichoose/multipermute.h b/vcflib/multichoose/multipermute.h
deleted file mode 100644
index 6c270a3..0000000
--- a/vcflib/multichoose/multipermute.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/* 
-
-multipermute.h  -- multiset permutations for generic vectors
-
-Follows 'Algorithm 1' from "Loopless Generation of Multiset Permutations using
-a Constant Number of Variables by Prefix Shifts."  Aaron Williams, 2009
-
-author: Erik Garrison <erik.garrison at bc.edu>
-last revised: 2010-04-16
-
-Copyright (c) 2010 by Erik Garrison
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-*/
-
-
-#include <vector>
-#include <algorithm>
-
-template <class T>
-class ListElement { 
-
-public:
-    T value;
-    ListElement<T>* next;
-
-    ListElement<T>() { }
-
-    ListElement<T>(T val, ListElement<T>* n) {
-        value = val;
-        next = n;
-    }
-
-    ListElement<T>* nth(int n) {
-        ListElement<T>* o = this;
-        int i = 0;
-        while (i < n && o->next != NULL) {
-            o = o->next;
-            ++i;
-        }
-        return o;
-    }
-
-    ~ListElement<T>() {
-        if (next != NULL) {
-            delete next;
-        }
-    }
-
-};
-
-template <class T>
-ListElement<T>* list_init(std::vector<T>& multiset) {
-    std::sort(multiset.begin(), multiset.end()); // ensures proper non-increasing order
-    typename std::vector<T>::const_iterator item = multiset.begin();
-    ListElement<T>* h = new ListElement<T>(*item, NULL);
-    ++item;
-    while (item != multiset.end()) {
-        h = new ListElement<T>(*item, h);
-        ++item;
-    }
-    return h;
-}
-
-template <class T>
-std::vector<T> linked_list_to_vector(ListElement<T>* h) {
-    ListElement<T>* o = h;
-    std::vector<T> l;
-    while (o != NULL) {
-        l.push_back(o->value);
-        o = o->next;
-    }
-    return l;
-}
-
-// provides multiset permutations out of the std::vector multiset
-template <class T>
-std::vector< std::vector<T> > multipermute(std::vector<T>& multiset) {
-
-    std::vector< std::vector<T> > results;
-
-    ListElement<T>* h = list_init(multiset);
-    ListElement<T>* i = h->nth(multiset.size() - 2);
-    ListElement<T>* j = h->nth(multiset.size() - 1);
-    ListElement<T>* s;
-    ListElement<T>* t;
-
-    results.push_back(linked_list_to_vector(h));
-
-    while (j->next != NULL || j->value < h->value) {
-        if (j->next != NULL && i->value >= j->next->value) {
-            s = j;
-        } else {
-            s = i;
-        }
-        t = s->next;
-        s->next = t->next;
-        t->next = h;
-        if (t->value < h->value) {
-            i = t;
-        }
-        j = i->next;
-        h = t;
-        results.push_back(linked_list_to_vector(h));
-    }
-
-    delete h;
-
-    return results;
-
-}
-
diff --git a/vcflib/multichoose/multipermute.py b/vcflib/multichoose/multipermute.py
deleted file mode 100644
index 10f7ccc..0000000
--- a/vcflib/multichoose/multipermute.py
+++ /dev/null
@@ -1,98 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-# multipermute.py - permutations of a multiset
-# Erik Garrison <erik.garrison at bc.edu> 2010
-
-"""
-This module encodes functions to generate the permutations of a multiset
-following this algorithm:
-
-Algorithm 1 
-Visits the permutations of multiset E. The permutations are stored
-in a singly-linked list pointed to by head pointer h. Each node in the linked
-list has a value field v and a next field n. The init(E) call creates a
-singly-linked list storing the elements of E in non-increasing order with h, i,
-and j pointing to its first, second-last, and last nodes, respectively. The
-null pointer is given by φ. Note: If E is empty, then init(E) should exit.
-Also, if E contains only one element, then init(E) does not need to provide a
-value for i.
-
-[h, i, j] ← init(E) 
-visit(h) 
-while j.n ≠ φ orj.v <h.v do
-    if j.n ≠    φ and i.v ≥ j.n.v then 
-        s←j
-    else
-        s←i 
-    end if
-    t←s.n 
-    s.n ← t.n 
-    t.n ← h 
-    if t.v < h.v then
-        i←t 
-    end if
-    j←i.n 
-    h←t 
-    visit(h)
-end while
-
-... from "Loopless Generation of Multiset Permutations using a Constant Number
-of Variables by Prefix Shifts."  Aaron Williams, 2009
-"""
-
-class ListElement:
-    def __init__(self, value, next):
-        self.value = value
-        self.next = next
-    def nth(self, n):
-        o = self
-        i = 0
-        while i < n and o.next is not None:
-            o = o.next
-            i += 1
-        return o
-
-def init(multiset):
-    multiset.sort() # ensures proper non-increasing order
-    h = ListElement(multiset[0], None)
-    for item in multiset[1:]:
-        h = ListElement(item, h)
-    return h, h.nth(len(multiset) - 2), h.nth(len(multiset) - 1)
-
-def visit(h):
-    """Converts our bespoke linked list to a python list."""
-    o = h
-    l = []
-    while o is not None:
-        l.append(o.value)
-        o = o.next
-    return l
-
-def permutations(multiset):
-    """Generator providing all multiset permutations of a multiset."""
-    h, i, j = init(multiset)
-    yield visit(h)
-    while j.next is not None or j.value < h.value:
-        if j.next is not None and i.value >= j.next.value:
-            s = j
-        else:
-            s = i
-        t = s.next
-        s.next = t.next
-        t.next = h
-        if t.value < h.value:
-            i = t
-        j = i.next
-        h = t
-        yield visit(h)
-
-if __name__ == '__main__':
-    import sys
-    multiset = sys.argv[1:]
-    if multiset != []:
-        for permutation in permutations(multiset):
-            for item in permutation:
-                print item,
-            print
-    else:
-        print "usage", sys.argv[0], "<multiset>"
diff --git a/vcflib/samples/sample.vcf b/vcflib/samples/sample.vcf
deleted file mode 100644
index e8dd794..0000000
--- a/vcflib/samples/sample.vcf
+++ /dev/null
@@ -1,31 +0,0 @@
-##fileformat=VCFv4.0
-##fileDate=20090805
-##source=myImputationProgramV3.1
-##reference=1000GenomesPilot-NCBI36
-##phasing=partial
-##INFO=<ID=NS,Number=1,Type=Integer,Description="Number of Samples With Data">
-##INFO=<ID=AN,Number=1,Type=Integer,Description="Total number of alleles in called genotypes">
-##INFO=<ID=AC,Number=.,Type=Integer,Description="Allele count in genotypes, for each ALT allele, in the same order as listed">
-##INFO=<ID=DP,Number=1,Type=Integer,Description="Total Depth">
-##INFO=<ID=AF,Number=.,Type=Float,Description="Allele Frequency">
-##INFO=<ID=AA,Number=1,Type=String,Description="Ancestral Allele">
-##INFO=<ID=DB,Number=0,Type=Flag,Description="dbSNP membership, build 129">
-##INFO=<ID=H2,Number=0,Type=Flag,Description="HapMap2 membership">
-##FILTER=<ID=q10,Description="Quality below 10">
-##FILTER=<ID=s50,Description="Less than 50% of samples have data">
-##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype">
-##FORMAT=<ID=GQ,Number=1,Type=Integer,Description="Genotype Quality">
-##FORMAT=<ID=DP,Number=1,Type=Integer,Description="Read Depth">
-##FORMAT=<ID=HQ,Number=2,Type=Integer,Description="Haplotype Quality">
-##ALT=<ID=DEL:ME:ALU,Description="Deletion of ALU element">
-##ALT=<ID=CNV,Description="Copy number variable region">
-#CHROM	POS	ID	REF	ALT	QUAL	FILTER	INFO	FORMAT	NA00001	NA00002	NA00003
-19	111	.	A	C	9.6	.	.	GT:HQ	0|0:10,10	0|0:10,10	0/1:3,3
-19	112	.	A	G	10	.	.	GT:HQ	0|0:10,10	0|0:10,10	0/1:3,3
-20	14370	rs6054257	G	A	29	PASS	NS=3;DP=14;AF=0.5;DB;H2	GT:GQ:DP:HQ	0|0:48:1:51,51	1|0:48:8:51,51	1/1:43:5:.,.
-20	17330	.	T	A	3	q10	NS=3;DP=11;AF=0.017	GT:GQ:DP:HQ	0|0:49:3:58,50	0|1:3:5:65,3	0/0:41:3:.,.
-20	1110696	rs6040355	A	G,T	67	PASS	NS=2;DP=10;AF=0.333,0.667;AA=T;DB	GT:GQ:DP:HQ	1|2:21:6:23,27	2|1:2:0:18,2	2/2:35:4:.,.
-20	1230237	.	T	.	47	PASS	NS=3;DP=13;AA=T	GT:GQ:DP:HQ	0|0:54:.:56,60	0|0:48:4:51,51	0/0:61:2:.,.
-20	1234567	microsat1	G	GA,GAC	50	PASS	NS=3;DP=9;AA=G;AN=6;AC=3,1	GT:GQ:DP	0/1:.:4	0/2:17:2	1/1:40:3
-20	1235237	.	T	.	.	.	.	GT	0/0	0|0	./.
-X	10	rsTest	AC	A,ATG	10	PASS	.	GT	0	0/1	0|2
diff --git a/vcflib/smithwaterman/.gitignore b/vcflib/smithwaterman/.gitignore
deleted file mode 100644
index e36f800..0000000
--- a/vcflib/smithwaterman/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-.*.swp
-*.o
-smithwaterman
diff --git a/vcflib/smithwaterman/BandedSmithWaterman.cpp b/vcflib/smithwaterman/BandedSmithWaterman.cpp
deleted file mode 100644
index a961f7c..0000000
--- a/vcflib/smithwaterman/BandedSmithWaterman.cpp
+++ /dev/null
@@ -1,670 +0,0 @@
-#include "BandedSmithWaterman.h"
-
-// define our static constants
-const float CBandedSmithWaterman::FLOAT_NEGATIVE_INFINITY = (float)-1e+30;
-
-const DirectionType CBandedSmithWaterman::Directions_STOP     = 0;
-const DirectionType CBandedSmithWaterman::Directions_LEFT     = 1;
-const DirectionType CBandedSmithWaterman::Directions_DIAGONAL = 2;
-const DirectionType CBandedSmithWaterman::Directions_UP       = 3;
-
-const PositionType CBandedSmithWaterman::Position_REF_AND_QUERY_ZERO    = 0;
-const PositionType CBandedSmithWaterman::Position_REF_ZERO              = 1;
-const PositionType CBandedSmithWaterman::Position_QUERY_ZERO            = 2;
-const PositionType CBandedSmithWaterman::Position_REF_AND_QUERO_NONZERO = 3;
-
-// constructor
-CBandedSmithWaterman::CBandedSmithWaterman(float matchScore, float mismatchScore, float gapOpenPenalty, float gapExtendPenalty, unsigned int bandWidth) 
-: mCurrentMatrixSize(0)
-, mCurrentAnchorSize(0)
-, mCurrentAQSumSize(0)
-, mBandwidth(bandWidth)
-, mPointers(NULL)
-, mMatchScore(matchScore)
-, mMismatchScore(mismatchScore)
-, mGapOpenPenalty(gapOpenPenalty)
-, mGapExtendPenalty(gapExtendPenalty)
-, mAnchorGapScores(NULL)
-, mBestScores(NULL)
-, mReversedAnchor(NULL)
-, mReversedQuery(NULL)
-, mUseHomoPolymerGapOpenPenalty(false)
-{
-	CreateScoringMatrix();
-
-	//if((bandWidth % 2) != 1) {
-		//printf("ERROR: The bandwidth must be an odd number.\n");
-		//exit(1);
-	//}
-
-	try {
-		mBestScores	 = new float[bandWidth + 2];
-		mAnchorGapScores = new float[bandWidth + 2];
-	} catch(bad_alloc) {
-		printf("ERROR: Unable to allocate enough memory for the banded Smith-Waterman algorithm.\n");
-		exit(1);
-	}
-}
-
-// destructor
-CBandedSmithWaterman::~CBandedSmithWaterman(void) {
-	if(mPointers)              delete [] mPointers;
-	if(mAnchorGapScores)       delete [] mAnchorGapScores;
-	if(mBestScores)            delete [] mBestScores;
-	if(mReversedAnchor)        delete [] mReversedAnchor;
-	if(mReversedQuery)         delete [] mReversedQuery;
-}
-
-// aligns the query sequence to the anchor using the Smith Waterman Gotoh algorithm
-void CBandedSmithWaterman::Align(unsigned int& referenceAl, string& cigarAl, const string& s1, const string& s2, pair< pair<unsigned int, unsigned int>, pair<unsigned int, unsigned int> >& hr) {
-
-
-	
-	unsigned int rowStart = min(hr.first.first, (unsigned int)hr.second.first);
-	hr.first.first    -= rowStart;
-	hr.second.first   -= rowStart;
-	
-	//bool isLegalBandWidth = (s2.length() - hr.QueryBegin) > (mBandwidth / 2);
-	//     isLegalBandWidth = isLegalBandWidth && ((s1.length() - hr.Begin) > (mBandwidth / 2));
-
-
-
-	// check the lengths of the input sequences
-	//if( (s1.length() <= 0) || (s2.length() <= 0) || (s1.length() < s2.length()) ) {
-	//	printf("ERROR: An unexpected sequence length was encountered during pairwise alignment.\n");
-	//	printf("Sequence lengths are listed as following:\n");
-	//	printf("1. Reference length: %u\n2. Query length: %u\n", s1.length(), s2.length());
-		//printf("3. Hash region in reference:%4u-%4u\n", hr.Begin + rowStart, hr.End);
-		//printf("4. Hash region in query:    %4u-%4u\n", hr.QueryBegin + rowStart, hr.QueryEnd);
-	//	exit(1);
-	//}
-
-	
-	// determine the hash region type
-	unsigned int rowOffset;
-	unsigned int columnOffset;
-	PositionType positionType;
-
-	if(hr.first.first == 0) {
-		if(hr.second.first == 0) {
-			rowOffset    = 1;
-			columnOffset = (mBandwidth / 2) + 1;
-			positionType = Position_REF_AND_QUERY_ZERO;
-		} else {
-			rowOffset    = 1 - hr.second.first;
-			columnOffset = (mBandwidth / 2) + 1 + hr.second.first;
-			positionType = Position_REF_ZERO;
-		}
-	} else {
-		if(hr.second.first == 0) {
-			rowOffset    = 1;
-			columnOffset = (mBandwidth / 2) + 1 - hr.first.first;
-			positionType = Position_QUERY_ZERO;
-		} else {
-			rowOffset    = 1 - hr.second.first;
-			columnOffset = (mBandwidth / 2) + 1 + hr.second.first - hr.first.first;
-			positionType = Position_REF_AND_QUERO_NONZERO;
-		}
-	}
-
-	// =========================
-	// Reinitialize the matrices
-	// =========================
-	
-	ReinitializeMatrices(positionType, s1.length(), s2.length(), hr);
-
-	// =======================================
-	// Banded Smith-Waterman forward algorithm
-	// =======================================
-
-	unsigned int bestColumn	= 0;
-	unsigned int bestRow	= 0;
-	float bestScore         = FLOAT_NEGATIVE_INFINITY;
-	float currentQueryGapScore;
-
-	// rowNum and column indicate the row and column numbers in the Smith-Waterman matrix respectively
-	unsigned int rowNum    = hr.second.first;
-	unsigned int columnNum = hr.first.first;
-
-	// indicates how many rows including blank elements in the Banded SmithWaterman
-	int numBlankElements = (mBandwidth / 2) - columnNum;
-
-	//cout << numBlankElements << endl;
-	// upper triangle matrix in Banded Smith-Waterman
-	for( ; numBlankElements > 0; numBlankElements--, rowNum++){
-		// in the upper triangle matrix, we always start at the 0th column
-		columnNum = 0;
-
-		// columnEnd indicates how many columns which should be dealt with in the current row
-		unsigned int columnEnd = min((mBandwidth - numBlankElements), ((unsigned int) s1.length() - columnNum + 1) );
-		currentQueryGapScore = FLOAT_NEGATIVE_INFINITY;
-		for( unsigned int j = 0; j < columnEnd; j++){
-			float score = CalculateScore(s1, s2, rowNum, columnNum, currentQueryGapScore, rowOffset, columnOffset);
-			//cout << s1[columnNum] << s2[rowNum] << score << endl;
-			UpdateBestScore(bestRow, bestColumn, bestScore, rowNum, columnNum, score);
-			columnNum++;
-		}
-
-		// replace the columnNum to the middle column in the Smith-Waterman matrix
-		columnNum = columnNum - (mBandwidth / 2);
-	}
-	// complete matrix in Banded Smith-Waterman
-	unsigned int completeNum = min((s1.length() - columnNum - (mBandwidth / 2)), (s2.length() - rowNum));
-	//cout << completeNum << endl;
-	for(unsigned int i = 0; i < completeNum; i++, rowNum++){
-		columnNum = columnNum - (mBandwidth / 2);
-
-		// there are mBandwidth columns which should be dealt with in each row
-		currentQueryGapScore = FLOAT_NEGATIVE_INFINITY;
-
-		for(unsigned int j = 0; j < mBandwidth; j++){
-			float score = CalculateScore(s1, s2, rowNum, columnNum, currentQueryGapScore, rowOffset, columnOffset);
-			UpdateBestScore(bestRow, bestColumn, bestScore, rowNum, columnNum, score);
-			//cout << s1[columnNum] << s2[rowNum] << score << endl;
-			columnNum++;
-		}
-
-		// replace the columnNum to the middle column in the Smith-Waterman matrix
-		// because mBandwidth is an odd number, everytime the following equation shifts a column (pluses 1).
-		columnNum = columnNum - (mBandwidth / 2);
-	}
-	
-	// lower triangle matrix
-	numBlankElements = min(mBandwidth, ((unsigned int) s2.length() - rowNum));
-	columnNum = columnNum - (mBandwidth / 2);
-	for(unsigned int i = 0; numBlankElements > 0; i++, rowNum++, numBlankElements--) {
-
-		mBestScores[ mBandwidth - i ] = FLOAT_NEGATIVE_INFINITY;;
-		// columnEnd indicates how many columns which should be dealt with
-		currentQueryGapScore = FLOAT_NEGATIVE_INFINITY;
-
-		for( unsigned int j = columnNum; j < s1.length(); j++){
-			float score = CalculateScore(s1, s2, rowNum, columnNum, currentQueryGapScore, rowOffset, columnOffset);
-			UpdateBestScore(bestRow, bestColumn, bestScore, rowNum, columnNum, score);
-			//cout << s1[columnNum] << s2[rowNum] << score << endl;
-			columnNum++;
-		}
-
-		// replace the columnNum to the middle column in the Smith-Waterman matrix
-		columnNum = columnNum - mBandwidth + i + 2;
-	}
-
-	// =========================================
-	// Banded Smith-Waterman backtrace algorithm
-	// =========================================
-
-	Traceback(referenceAl, cigarAl, s1, s2, bestRow, bestColumn, rowOffset, columnOffset);
-
-}
-
-// calculates the score during the forward algorithm
-float CBandedSmithWaterman::CalculateScore(const string& s1, const string& s2, const unsigned int rowNum, const unsigned int columnNum, float& currentQueryGapScore, const unsigned int rowOffset, const unsigned int columnOffset) {
-
-	// initialize
-	const unsigned int row      = rowNum + rowOffset;
-	const unsigned int column   = columnOffset - rowNum + columnNum;
-	const unsigned int position = row * (mBandwidth + 2) + column;
-
-	// retrieve the similarity scores
-	const float similarityScore      = mScoringMatrix[s1[columnNum] - 'A'][s2[rowNum] - 'A'];
-	const float totalSimilarityScore = mBestScores[column] + similarityScore;
-
-	// ================================
-	// open a gap in the query sequence
-	// ================================
-
-	float queryGapExtendScore = currentQueryGapScore - mGapExtendPenalty;
-	float queryGapOpenScore   = mBestScores[column - 1] - mGapOpenPenalty;
-
-	// compute the homo-polymer gap score if enabled
-	if(mUseHomoPolymerGapOpenPenalty)
-		if((rowNum > 1) && (s2[rowNum] == s2[rowNum - 1]))
-			queryGapOpenScore = mBestScores[column - 1] - mHomoPolymerGapOpenPenalty;
-
-	if(queryGapExtendScore > queryGapOpenScore) {
-		currentQueryGapScore = queryGapExtendScore;
-		mPointers[position].mSizeOfHorizontalGaps = mPointers[position - 1].mSizeOfHorizontalGaps + 1;
-	} else currentQueryGapScore = queryGapOpenScore;
-
-
-	// ====================================
-	// open a gap in the reference sequence
-	// ====================================
-
-	
-	float anchorGapExtendScore = mAnchorGapScores[column + 1] - mGapExtendPenalty;
-	float anchorGapOpenScore   = mBestScores[column + 1] - mGapOpenPenalty;
-
-	// compute the homo-polymer gap score if enabled	
-	if(mUseHomoPolymerGapOpenPenalty)
-		if((columnNum > 1) && (s1[columnNum] == s1[columnNum - 1]))
-			anchorGapOpenScore = mBestScores[column + 1] - mHomoPolymerGapOpenPenalty;
-
-	if(anchorGapExtendScore > anchorGapOpenScore) {
-		mAnchorGapScores[column] = anchorGapExtendScore;
-		mPointers[position].mSizeOfVerticalGaps = mPointers[position - mBandwidth - 1].mSizeOfVerticalGaps + 1;
-	} else mAnchorGapScores[column] = anchorGapOpenScore;
-
-	// ======================================
-	// calculate the best score and direction
-	// ======================================
-
-	//mBestScores[column] = MaxFloats(totalSimilarityScore, mAnchorGapScores[column], currentQueryGapScore);
-	mBestScores[column] = MaxFloats(totalSimilarityScore, currentQueryGapScore, mAnchorGapScores[column]);
-
-	// determine the traceback direction
-	// diagonal (445364713) > stop (238960195) > up (214378647) > left (166504495)
-	if(mBestScores[column] == 0)                            mPointers[position].Direction = Directions_STOP;
-	else if(mBestScores[column] == totalSimilarityScore)    mPointers[position].Direction = Directions_UP;
-	else if(mBestScores[column] == currentQueryGapScore)   mPointers[position].Direction = Directions_LEFT;
-	else                                                    mPointers[position].Direction = Directions_DIAGONAL;
-
-	return mBestScores[column];
-}
-
-// corrects the homopolymer gap order for forward alignments
-void CBandedSmithWaterman::CorrectHomopolymerGapOrder(const unsigned int numBases, const unsigned int numMismatches) {
-
-
-	// this is only required for alignments with mismatches
-	//if(al.NumMismatches == 0) return;
-	if ( numMismatches == 0 ) return;
-
-	// localize the alignment data
-	//char* pReference = al.Reference.Data();
-	//char* pQuery     = al.Query.Data();
-	//const unsigned int numBases = al.Reference.Length();
-	char* pReference = mReversedAnchor;
-	char* pQuery     = mReversedQuery;
-
-	// initialize
-	bool hasReferenceGap = false, hasQueryGap = false;
-	char* pNonGapSeq = NULL;
-	char* pGapSeq    = NULL;
-	char nonGapBase  = 'J';
-
-	// identify gapped regions
-	for(unsigned int i = 0; i < numBases; i++) {
-
-		// check if the current position is gapped
-		hasReferenceGap = false;
-		hasQueryGap     = false;
-
-		if(pReference[i] == GAP) {
-			hasReferenceGap = true;
-			pNonGapSeq      = pQuery;
-			pGapSeq         = pReference;
-			nonGapBase      = pQuery[i];
-		}
-
-		if(pQuery[i] == GAP) {
-			hasQueryGap = true;
-			pNonGapSeq  = pReference;
-			pGapSeq     = pQuery;
-			nonGapBase  = pReference[i];
-		}
-
-		// continue if we don't have any gaps
-		if(!hasReferenceGap && !hasQueryGap) continue;
-
-		// sanity check
-		if(hasReferenceGap && hasQueryGap) {
-			printf("ERROR: Found a gap in both the reference sequence and query sequence.\n");
-			exit(1);
-		}
-
-		// find the non-gapped length (forward)
-		unsigned short numGappedBases = 0;
-		unsigned short nonGapLength   = 0;
-		unsigned short testPos = i;
-		while(testPos < numBases) {
-
-			const char gs  = pGapSeq[testPos];
-			const char ngs = pNonGapSeq[testPos];
-
-			bool isPartofHomopolymer = false;
-			if(((gs == nonGapBase) || (gs == GAP)) && (ngs == nonGapBase)) isPartofHomopolymer = true;
-			if(!isPartofHomopolymer) break;
-
-			if(gs == GAP) numGappedBases++;
-			else nonGapLength++;
-			testPos++;
-		}
-
-		// fix the gap order
-		if(numGappedBases != 0) {
-			char* pCurrentSequence = pGapSeq + i;
-			memset(pCurrentSequence, nonGapBase, nonGapLength);
-			pCurrentSequence += nonGapLength;
-			memset(pCurrentSequence, GAP, numGappedBases);
-		}
-
-		// increment
-		i += numGappedBases + nonGapLength - 1;
-	}
-}
-
-// creates a simple scoring matrix to align the nucleotides and the ambiguity code N
-void CBandedSmithWaterman::CreateScoringMatrix(void) {
-
-	unsigned int nIndex = 13;
-	unsigned int xIndex = 23;
-
-	// define the N score to be 1/4 of the span between mismatch and match
-	//const short nScore = mMismatchScore + (short)(((mMatchScore - mMismatchScore) / 4.0) + 0.5);
-
-	// calculate the scoring matrix
-	for(unsigned char i = 0; i < MOSAIK_NUM_NUCLEOTIDES; i++) {
-		for(unsigned char j = 0; j < MOSAIK_NUM_NUCLEOTIDES; j++) {
-
-			// N.B. matching N to everything (while conceptually correct) leads to some
-			// bad alignments, lets make N be a mismatch instead.
-
-			// add the matches or mismatches to the hashtable (N is a mismatch)
-			if((i == nIndex) || (j == nIndex)) mScoringMatrix[i][j] = mMismatchScore;
-			else if((i == xIndex) || (j == xIndex)) mScoringMatrix[i][j] = mMismatchScore;
-			else if(i == j) mScoringMatrix[i][j] = mMatchScore;
-			else mScoringMatrix[i][j] = mMismatchScore;
-		}
-	}
-
-	// add ambiguity codes
-	mScoringMatrix['M' - 'A']['A' - 'A'] = mMatchScore;	// M - A
-	mScoringMatrix['A' - 'A']['M' - 'A'] = mMatchScore;
-	// add ambiguity codes
-	mScoringMatrix['M' - 'A']['A' - 'A'] = mMatchScore;	// M - A
-	mScoringMatrix['A' - 'A']['M' - 'A'] = mMatchScore;
-	mScoringMatrix['M' - 'A']['C' - 'A'] = mMatchScore; // M - C
-	mScoringMatrix['C' - 'A']['M' - 'A'] = mMatchScore;
-
-	mScoringMatrix['R' - 'A']['A' - 'A'] = mMatchScore;	// R - A
-	mScoringMatrix['A' - 'A']['R' - 'A'] = mMatchScore;
-	mScoringMatrix['R' - 'A']['G' - 'A'] = mMatchScore; // R - G
-	mScoringMatrix['G' - 'A']['R' - 'A'] = mMatchScore;
-
-	mScoringMatrix['W' - 'A']['A' - 'A'] = mMatchScore;	// W - A
-	mScoringMatrix['A' - 'A']['W' - 'A'] = mMatchScore;
-	mScoringMatrix['W' - 'A']['T' - 'A'] = mMatchScore; // W - T
-	mScoringMatrix['T' - 'A']['W' - 'A'] = mMatchScore;
-
-	mScoringMatrix['S' - 'A']['C' - 'A'] = mMatchScore;	// S - C
-	mScoringMatrix['C' - 'A']['S' - 'A'] = mMatchScore;
-	mScoringMatrix['S' - 'A']['G' - 'A'] = mMatchScore; // S - G
-	mScoringMatrix['G' - 'A']['S' - 'A'] = mMatchScore;
-
-	mScoringMatrix['Y' - 'A']['C' - 'A'] = mMatchScore;	// Y - C
-	mScoringMatrix['C' - 'A']['Y' - 'A'] = mMatchScore;
-	mScoringMatrix['Y' - 'A']['T' - 'A'] = mMatchScore; // Y - T
-	mScoringMatrix['T' - 'A']['Y' - 'A'] = mMatchScore;
-
-	mScoringMatrix['K' - 'A']['G' - 'A'] = mMatchScore;	// K - G
-	mScoringMatrix['G' - 'A']['K' - 'A'] = mMatchScore;
-	mScoringMatrix['K' - 'A']['T' - 'A'] = mMatchScore; // K - T
-	mScoringMatrix['T' - 'A']['K' - 'A'] = mMatchScore;
-
-	mScoringMatrix['V' - 'A']['A' - 'A'] = mMatchScore;	// V - A
-	mScoringMatrix['A' - 'A']['V' - 'A'] = mMatchScore;
-	mScoringMatrix['V' - 'A']['C' - 'A'] = mMatchScore; // V - C
-	mScoringMatrix['C' - 'A']['V' - 'A'] = mMatchScore;
-	mScoringMatrix['V' - 'A']['G' - 'A'] = mMatchScore; // V - G
-	mScoringMatrix['G' - 'A']['V' - 'A'] = mMatchScore;
-
-	mScoringMatrix['H' - 'A']['A' - 'A'] = mMatchScore;	// H - A
-	mScoringMatrix['A' - 'A']['H' - 'A'] = mMatchScore;
-	mScoringMatrix['H' - 'A']['C' - 'A'] = mMatchScore; // H - C
-	mScoringMatrix['C' - 'A']['H' - 'A'] = mMatchScore;
-	mScoringMatrix['H' - 'A']['T' - 'A'] = mMatchScore; // H - T
-	mScoringMatrix['T' - 'A']['H' - 'A'] = mMatchScore;
-
-	mScoringMatrix['D' - 'A']['A' - 'A'] = mMatchScore;	// D - A
-	mScoringMatrix['A' - 'A']['D' - 'A'] = mMatchScore;
-	mScoringMatrix['D' - 'A']['G' - 'A'] = mMatchScore; // D - G
-	mScoringMatrix['G' - 'A']['D' - 'A'] = mMatchScore;
-	mScoringMatrix['D' - 'A']['T' - 'A'] = mMatchScore; // D - T
-	mScoringMatrix['T' - 'A']['D' - 'A'] = mMatchScore;
-
-	mScoringMatrix['B' - 'A']['C' - 'A'] = mMatchScore;	// B - C
-	mScoringMatrix['C' - 'A']['B' - 'A'] = mMatchScore;
-	mScoringMatrix['B' - 'A']['G' - 'A'] = mMatchScore; // B - G
-	mScoringMatrix['G' - 'A']['B' - 'A'] = mMatchScore;
-	mScoringMatrix['B' - 'A']['T' - 'A'] = mMatchScore; // B - T
-	mScoringMatrix['T' - 'A']['B' - 'A'] = mMatchScore;
-}
-
-// enables homo-polymer scoring
-void CBandedSmithWaterman::EnableHomoPolymerGapPenalty(float hpGapOpenPenalty) {
-	mUseHomoPolymerGapOpenPenalty = true;
-	mHomoPolymerGapOpenPenalty    = hpGapOpenPenalty;
-}
-
-// reinitializes the matrices
-void CBandedSmithWaterman::ReinitializeMatrices(const PositionType& positionType, const unsigned int& s1Length, const unsigned int& s2Length, const pair< pair<unsigned int, unsigned int>, pair<unsigned int, unsigned int> > hr) {
-
-/*
-	try {
-		mBestScores	 = new float[mBandwidth + 2];
-		mAnchorGapScores = new float[mBandwidth + 2];
-	} catch(bad_alloc) {
-		printf("ERROR: Unable to allocate enough memory for the banded Smith-Waterman algorithm.\n");
-		exit(1);
-	}
-*/
-
-	const unsigned int numColumns = mBandwidth + 2;
-	unsigned int numRows = 0;
-
-	switch(positionType) {
-		case Position_REF_AND_QUERY_ZERO:
-			numRows = s2Length + 1;
-			break;
-		case Position_REF_ZERO:
-			numRows = s2Length - hr.second.first + 2;
-			break;
-		case Position_QUERY_ZERO:
-			numRows = min(s2Length + 1, s1Length - hr.first.first + 2);
-			break;
-		case Position_REF_AND_QUERO_NONZERO:
-			numRows = min(s1Length - hr.first.first + 2, s2Length - hr.second.first + 2);
-			break;
-	}
-
-	// update the size of the backtrace matrix
-	if((numColumns * numRows) > mCurrentMatrixSize) {
-
-		mCurrentMatrixSize = numColumns * numRows;
-		if(mPointers) delete [] mPointers;
-
-		try {
-			mPointers = new ElementInfo[mCurrentMatrixSize];
-		} catch(bad_alloc) {
-			printf("ERROR: Unable to allocate enough memory for the banded Smith-Waterman algorithm.\n");
-			exit(1);
-		}
-	}
-
-	// initialize our backtrace matrix
-	ElementInfo defaultElement;
-	defaultElement.Direction = Directions_STOP;
-	defaultElement.mSizeOfHorizontalGaps = 1;
-	defaultElement.mSizeOfVerticalGaps   = 1;
-
-	uninitialized_fill(mPointers, mPointers + mCurrentMatrixSize, defaultElement);
-
-	// update the sequence character arrays
-	if((s1Length + s2Length) > mCurrentAQSumSize) {
-
-		mCurrentAQSumSize = s1Length + s2Length;
-		if(mReversedAnchor)	delete [] mReversedAnchor;
-		if(mReversedQuery)	delete [] mReversedQuery;
-
-		try {
-			mReversedAnchor	= new char[mCurrentAQSumSize + 1]; // reversed sequence #1
-			mReversedQuery	= new char[mCurrentAQSumSize + 1]; // reversed sequence #2
-		} catch(bad_alloc) {
-			printf("ERROR: Unable to allocate enough memory for the banded Smith-Waterman algorithm.\n");
-			exit(1);
-		}
-	}
-
-	// initialize the gap score and score vectors
-	uninitialized_fill(mAnchorGapScores, mAnchorGapScores + mBandwidth + 2, FLOAT_NEGATIVE_INFINITY);
-	memset((char*)mBestScores, 0, SIZEOF_FLOAT * (mBandwidth + 2));
-	mBestScores[0]              = FLOAT_NEGATIVE_INFINITY;
-	mBestScores[mBandwidth + 1] = FLOAT_NEGATIVE_INFINITY;
-}
-
-// performs the backtrace algorithm
-void CBandedSmithWaterman::Traceback(unsigned int& referenceAl, string& cigarAl, const string& s1, const string& s2, unsigned int bestRow, unsigned int bestColumn, const unsigned int rowOffset, const unsigned int columnOffset){
-
-
-	unsigned int currentRow		 = bestRow;
-	unsigned int currentColumn	 = bestColumn;
-	unsigned int currentPosition = ((currentRow + rowOffset) * (mBandwidth + 2)) + (columnOffset - currentRow + currentColumn);
-
-
-	// record the numbers of row and column before the current row and column
-	unsigned int previousRow	= bestRow;
-	unsigned int previousColumn	= bestColumn;
-
-	unsigned int gappedAnchorLen = 0;
-	unsigned int gappedQueryLen  = 0;
-	unsigned int numMismatches   = 0;
-
-	bool keepProcessing = true;
-	while(keepProcessing) {
-		unsigned int nVerticalGap = 0;
-		unsigned int nHorizontalGap = 0;
-		switch(mPointers[currentPosition].Direction){
-			case Directions_DIAGONAL:
-				nVerticalGap = mPointers[currentPosition].mSizeOfVerticalGaps;
-				for(unsigned int i = 0; i < nVerticalGap; i++){
-					mReversedAnchor[gappedAnchorLen++] = GAP;
-					mReversedQuery[gappedQueryLen++]   = s2[currentRow];
-
-					numMismatches++;
-
-					previousRow = currentRow;
-					previousColumn = currentColumn;
-
-					currentRow--;
-				}
-				break;
-
-			case Directions_STOP:
-				keepProcessing = false;
-				//mReversedAnchor[gappedAnchorLen+1]='\0';
-				//mReversedQuery [gappedQueryLen+1]='\0';
-				break;
-
-			case Directions_UP:
-
-				mReversedAnchor[gappedAnchorLen++] = s1[currentColumn];
-				mReversedQuery[gappedQueryLen++]   = s2[currentRow];
-
-				if(s1[currentColumn] != s2[currentRow]) numMismatches++;
-				previousRow = currentRow;
-				previousColumn = currentColumn;
-
-				currentRow--;
-				currentColumn--;
-				break;
-
-			case Directions_LEFT:
-				nHorizontalGap =  mPointers[currentPosition].mSizeOfHorizontalGaps;
-				for(unsigned int i = 0; i < nHorizontalGap; i++){
-
-					mReversedAnchor[gappedAnchorLen++] = s1[currentColumn];
-					mReversedQuery[gappedQueryLen++]   = GAP;
-
-					numMismatches++;
-
-					previousRow = currentRow;
-					previousColumn = currentColumn;
-
-
-					currentColumn--;
-				}
-				break;
-		}
-		currentPosition = ((currentRow + rowOffset) * (mBandwidth + 2)) + (columnOffset - currentRow + currentColumn);
-	}
-
-	// correct the reference and query sequence order
-	mReversedAnchor[gappedAnchorLen] = 0;
-	mReversedQuery [gappedQueryLen] = 0;
-	reverse(mReversedAnchor, mReversedAnchor + gappedAnchorLen);
-	reverse(mReversedQuery,  mReversedQuery  + gappedQueryLen);
-
-	//alignment.Reference = mReversedAnchor;
-	//alignment.Query     = mReversedQuery;
-
-	// assign the alignment endpoints
-	//alignment.ReferenceBegin = previousColumn;
-	//alignment.ReferenceEnd   = bestColumn;
-	referenceAl  = previousColumn;
-	/*  
-	if(alignment.IsReverseComplement){
-		alignment.QueryBegin = s2.length() - bestRow - 1; 
-		alignment.QueryEnd   = s2.length() - previousRow - 1;
-	} else {
-		alignment.QueryBegin = previousRow; 
-		alignment.QueryEnd   = bestRow;
-	}
-	*/
-	
-	//alignment.QueryLength	= alignment.QueryEnd - alignment.QueryBegin + 1;
-	//alignment.NumMismatches = numMismatches;
-
-	const unsigned int alLength = strlen(mReversedAnchor);
-	unsigned int m = 0, d = 0, i = 0;
-	bool dashRegion = false;
-	ostringstream oCigar;
-
-	if ( previousRow != 0 )
-		oCigar << previousRow << 'S';
-
-	for ( unsigned int j = 0; j < alLength; j++ ) {
-		// m
-		if ( ( mReversedAnchor[j] != GAP ) && ( mReversedQuery[j] != GAP ) ) {
-			if ( dashRegion ) {
-				if ( d != 0 ) oCigar << d << 'D';
-				else          oCigar << i << 'I';
-			}
-			dashRegion = false;
-			m++;
-			d = 0;
-			i = 0;
-		}
-		// I or D
-		else {
-			if ( !dashRegion )
-				oCigar << m << 'M';
-			dashRegion = true;
-			m = 0;
-			if ( mReversedAnchor[j] == GAP ) {
-				if ( d != 0 ) oCigar << d << 'D';
-				i++;
-				d = 0;
-			}
-			else {
-				if ( i != 0 ) oCigar << i << 'I';
-				d++;
-				i = 0;
-			}
-		}
-	}
-	
-	if      ( m != 0 ) oCigar << m << 'M';
-	else if ( d != 0 ) oCigar << d << 'D';
-	else if ( i != 0 ) oCigar << i << 'I';
-
-	if ( ( bestRow + 1 ) != s2.length() )
-		oCigar << s2.length() - bestRow - 1 << 'S';
-
-	cigarAl = oCigar.str();
-	
-
-	// correct the homopolymer gap order
-	CorrectHomopolymerGapOrder(alLength, numMismatches);
-
-}
diff --git a/vcflib/smithwaterman/BandedSmithWaterman.h b/vcflib/smithwaterman/BandedSmithWaterman.h
deleted file mode 100644
index ca78ac2..0000000
--- a/vcflib/smithwaterman/BandedSmithWaterman.h
+++ /dev/null
@@ -1,111 +0,0 @@
-#pragma once
-
-#include <iostream>
-#include <algorithm>
-#include <memory>
-//#include "Alignment.h"
-#include "Mosaik.h"
-//#include "HashRegion.h"
-#include <string.h>
-#include <stdio.h>
-#include <sstream>
-#include <string>
-
-using namespace std;
-
-#define MOSAIK_NUM_NUCLEOTIDES 26
-#define GAP '-'
-
-typedef unsigned char DirectionType;
-typedef unsigned char PositionType;
-
-struct ElementInfo {
-	unsigned int Direction             : 2;
-	unsigned int mSizeOfVerticalGaps   : 15;
-	unsigned int mSizeOfHorizontalGaps : 15;
-};
-
-class CBandedSmithWaterman {
-public:
-	// constructor
-	CBandedSmithWaterman(float matchScore, float mismatchScore, float gapOpenPenalty, float gapExtendPenalty, unsigned int bandWidth);
-	// destructor
-	~CBandedSmithWaterman(void);
-	// aligns the query sequence to the anchor using the Smith Waterman Gotoh algorithm
-	void Align(unsigned int& referenceAl, string& stringAl, const string& s1, const string& s2, pair< pair<unsigned int, unsigned int>, pair<unsigned int, unsigned int> >& hr);
-	// enables homo-polymer scoring
-	void EnableHomoPolymerGapPenalty(float hpGapOpenPenalty);
-private:
-	// calculates the score during the forward algorithm
-	float CalculateScore(const string& s1, const string& s2, const unsigned int rowNum, const unsigned int columnNum, float& currentQueryGapScore, const unsigned int rowOffset, const unsigned int columnOffset);
-	// creates a simple scoring matrix to align the nucleotides and the ambiguity code N
-	void CreateScoringMatrix(void);
-	// corrects the homopolymer gap order for forward alignments
-	void CorrectHomopolymerGapOrder(const unsigned int numBases, const unsigned int numMismatches);
-	// returns the maximum floating point number
-	static inline float MaxFloats(const float& a, const float& b, const float& c);
-	// reinitializes the matrices
-	void ReinitializeMatrices(const PositionType& positionType, const unsigned int& s1Length, const unsigned int& s2Length, const pair< pair<unsigned int, unsigned int>, pair<unsigned int, unsigned int> > hr);
-	// performs the backtrace algorithm
-	void Traceback(unsigned int& referenceAl, string& stringAl, const string& s1, const string& s2, unsigned int bestRow, unsigned int bestColumn, const unsigned int rowOffset, const unsigned int columnOffset);
-	// updates the best score during the forward algorithm
-	inline void UpdateBestScore(unsigned int& bestRow, unsigned int& bestColumn, float& bestScore, const unsigned int rowNum, const unsigned int columnNum, const float score);
-	// our simple scoring matrix
-	float mScoringMatrix[MOSAIK_NUM_NUCLEOTIDES][MOSAIK_NUM_NUCLEOTIDES];
-	// keep track of maximum initialized sizes
-	unsigned int mCurrentMatrixSize;
-	unsigned int mCurrentAnchorSize;
-	unsigned int mCurrentAQSumSize;
-	unsigned int mBandwidth;
-	// define our backtrace directions
-	const static DirectionType Directions_STOP;
-	const static DirectionType Directions_LEFT;
-	const static DirectionType Directions_DIAGONAL;
-	const static DirectionType Directions_UP;
-	// store the backtrace pointers
-	ElementInfo* mPointers;
-	// define our position types
-	const static PositionType Position_REF_AND_QUERY_ZERO;
-	const static PositionType Position_REF_ZERO;
-	const static PositionType Position_QUERY_ZERO;
-	const static PositionType Position_REF_AND_QUERO_NONZERO;
-	// define scoring constants
-	const float mMatchScore;
-	const float mMismatchScore;
-	const float mGapOpenPenalty;
-	const float mGapExtendPenalty;
-	// score if xi aligns to a gap after yi
-	float* mAnchorGapScores;
-	// best score of alignment x1...xi to y1...yi
-	float* mBestScores;
-	// our reversed alignment
-	char* mReversedAnchor;
-	char* mReversedQuery;
-	// define static constants
-	static const float FLOAT_NEGATIVE_INFINITY;
-	// toggles the use of the homo-polymer gap open penalty
-	bool mUseHomoPolymerGapOpenPenalty;
-	float mHomoPolymerGapOpenPenalty;
-};
-
-// returns the maximum floating point number
-inline float CBandedSmithWaterman::MaxFloats(const float& a, const float& b, const float& c) {
-	float max = 0.0f;
-	if(a > max) max = a;
-	if(b > max) max = b;
-	if(c > max) max = c;
-	return max;
-}
-
-// updates the best score during the forward algorithm
-inline void CBandedSmithWaterman::UpdateBestScore(unsigned int& bestRow, unsigned int& bestColumn, float& bestScore, const unsigned int rowNum, const unsigned int columnNum, const float score) {
-
-	//const unsigned int row    = rowNum + rowOffset;
-	//const unsigned int column = columnOffset - rowNum + columnNum;
-
-	if(score > bestScore) {
-		bestRow    = rowNum;
-		bestColumn = columnNum;
-		bestScore  = score;
-	}
-}
diff --git a/vcflib/smithwaterman/IndelAllele.cpp b/vcflib/smithwaterman/IndelAllele.cpp
deleted file mode 100644
index 80b5fac..0000000
--- a/vcflib/smithwaterman/IndelAllele.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-#include "IndelAllele.h"
-
-using namespace std;
-
-
-bool IndelAllele::homopolymer(void) {
-    string::iterator s = sequence.begin();
-    char c = *s++;
-    while (s != sequence.end()) {
-        if (c != *s++) return false;
-    }
-    return true;
-}
-
-int IndelAllele::readLength(void) {
-    if (insertion) {
-	return length;
-    } else {
-	return 0;
-    }
-}
-
-int IndelAllele::referenceLength(void) {
-    if (insertion) {
-	return 0;
-    } else {
-	return length;
-    }
-}
-
-bool homopolymer(string sequence) {
-    string::iterator s = sequence.begin();
-    char c = *s++;
-    while (s != sequence.end()) {
-        if (c != *s++) return false;
-    }
-    return true;
-}
-
-ostream& operator<<(ostream& out, const IndelAllele& indel) {
-    string t = indel.insertion ? "i" : "d";
-    out << t <<  ":" << indel.position << ":" << indel.readPosition << ":" << indel.length << ":" << indel.sequence;
-    return out;
-}
-
-bool operator==(const IndelAllele& a, const IndelAllele& b) {
-    return (a.insertion == b.insertion
-            && a.length == b.length
-            && a.position == b.position
-            && a.sequence == b.sequence);
-}
-
-bool operator!=(const IndelAllele& a, const IndelAllele& b) {
-    return !(a==b);
-}
-
-bool operator<(const IndelAllele& a, const IndelAllele& b) {
-    ostringstream as, bs;
-    as << a;
-    bs << b;
-    return as.str() < bs.str();
-}
diff --git a/vcflib/smithwaterman/IndelAllele.h b/vcflib/smithwaterman/IndelAllele.h
deleted file mode 100644
index 247c01f..0000000
--- a/vcflib/smithwaterman/IndelAllele.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef __INDEL_ALLELE_H
-#define __INDEL_ALLELE_H
-
-#include <string>
-#include <iostream>
-#include <sstream>
-
-using namespace std;
-
-class IndelAllele {
-    friend ostream& operator<<(ostream&, const IndelAllele&);
-    friend bool operator==(const IndelAllele&, const IndelAllele&);
-    friend bool operator!=(const IndelAllele&, const IndelAllele&);
-    friend bool operator<(const IndelAllele&, const IndelAllele&);
-public:
-    bool insertion;
-    int length;
-    int referenceLength(void);
-    int readLength(void);
-    int position;
-    int readPosition;
-    string sequence;
-
-    bool homopolymer(void);
-
-    IndelAllele(bool i, int l, int p, int rp, string s)
-        : insertion(i), length(l), position(p), readPosition(rp), sequence(s)
-    { }
-};
-
-bool homopolymer(string sequence);
-ostream& operator<<(ostream& out, const IndelAllele& indel);
-bool operator==(const IndelAllele& a, const IndelAllele& b);
-bool operator!=(const IndelAllele& a, const IndelAllele& b);
-bool operator<(const IndelAllele& a, const IndelAllele& b);
-
-#endif
diff --git a/vcflib/smithwaterman/LeftAlign.cpp b/vcflib/smithwaterman/LeftAlign.cpp
deleted file mode 100644
index 3e526aa..0000000
--- a/vcflib/smithwaterman/LeftAlign.cpp
+++ /dev/null
@@ -1,853 +0,0 @@
-#include "LeftAlign.h"
-
-//bool debug;
-#define VERBOSE_DEBUG
-
-// Attempts to left-realign all the indels represented by the alignment cigar.
-//
-// This is done by shifting all indels as far left as they can go without
-// mismatch, then merging neighboring indels of the same class.  leftAlign
-// updates the alignment cigar with changes, and returns true if realignment
-// changed the alignment cigar.
-//
-// To left-align, we move multi-base indels left by their own length as long as
-// the preceding bases match the inserted or deleted sequence.  After this
-// step, we handle multi-base homopolymer indels by shifting them one base to
-// the left until they mismatch the reference.
-//
-// To merge neighboring indels, we iterate through the set of left-stabilized
-// indels.  For each indel we add a new cigar element to the new cigar.  If a
-// deletion follows a deletion, or an insertion occurs at the same place as
-// another insertion, we merge the events by extending the previous cigar
-// element.
-//
-// In practice, we must call this function until the alignment is stabilized.
-//
-bool leftAlign(string& querySequence, string& cigar, string& baseReferenceSequence, int& offset, bool debug) {
-
-    debug = false;
-
-    string referenceSequence = baseReferenceSequence.substr(offset);
-
-    int arsOffset = 0; // pointer to insertion point in aligned reference sequence
-    string alignedReferenceSequence, alignedQuerySequence;
-    if (debug) alignedReferenceSequence = referenceSequence;
-    if (debug) alignedQuerySequence = querySequence;
-    int aabOffset = 0;
-
-    // store information about the indels
-    vector<IndelAllele> indels;
-
-    int rp = 0;  // read position, 0-based relative to read
-    int sp = 0;  // sequence position
-
-    string softBegin;
-    string softEnd;
-
-    string cigarbefore = cigar;
-
-    vector<pair<int, string> > cigarData = splitCIGAR(cigar);
-    for (vector<pair<int, string> >::const_iterator c = cigarData.begin();
-        c != cigarData.end(); ++c) {
-        unsigned int l = c->first;
-        string t = c->second;
-	if (debug) cerr << l << t << " " << sp << " " << rp << endl;
-        if (t == "M") { // match or mismatch
-            sp += l;
-            rp += l;
-        } else if (t == "D") { // deletion
-            indels.push_back(IndelAllele(false, l, sp, rp, referenceSequence.substr(sp, l)));
-            if (debug) { cerr << indels.back() << endl;  alignedQuerySequence.insert(rp + aabOffset, string(l, '-')); }
-            aabOffset += l;
-            sp += l;  // update reference sequence position
-        } else if (t == "I") { // insertion
-            indels.push_back(IndelAllele(true, l, sp, rp, querySequence.substr(rp, l)));
-            if (debug) { cerr << indels.back() << endl; alignedReferenceSequence.insert(sp + softBegin.size() + arsOffset, string(l, '-')); }
-            arsOffset += l;
-            rp += l;
-        } else if (t == "S") { // soft clip, clipped sequence present in the read not matching the reference
-            // remove these bases from the refseq and read seq, but don't modify the alignment sequence
-            if (rp == 0) {
-                alignedReferenceSequence = string(l, '*') + alignedReferenceSequence;
-		//indels.push_back(IndelAllele(true, l, sp, rp, querySequence.substr(rp, l)));
-                softBegin = querySequence.substr(0, l);
-            } else {
-                alignedReferenceSequence = alignedReferenceSequence + string(l, '*');
-		//indels.push_back(IndelAllele(true, l, sp, rp, querySequence.substr(rp, l)));
-                softEnd = querySequence.substr(querySequence.size() - l, l);
-            }
-            rp += l;
-        } else if (t == "H") { // hard clip on the read, clipped sequence is not present in the read
-        } else if (t == "N") { // skipped region in the reference not present in read, aka splice
-            sp += l;
-        }
-    }
-
-
-    if (debug) cerr << "| " << cigarbefore << endl
-		    << "| " << alignedReferenceSequence << endl
-		    << "| " << alignedQuerySequence << endl;
-
-    // if no indels, return the alignment
-    if (indels.empty()) { return false; }
-
-    if (debug) {
-	for (vector<IndelAllele>::iterator a = indels.begin(); a != indels.end(); ++a) cerr << *a << " ";
-	cerr << endl;
-    }
-
-    // for each indel, from left to right
-    //     while the indel sequence repeated to the left and we're not matched up with the left-previous indel
-    //         move the indel left
-
-    vector<IndelAllele>::iterator previous = indels.begin();
-    for (vector<IndelAllele>::iterator id = indels.begin(); id != indels.end(); ++id) {
-
-        // left shift by repeats
-        //
-        // from 1 base to the length of the indel, attempt to shift left
-        // if the move would cause no change in alignment optimality (no
-        // introduction of mismatches, and by definition no change in gap
-        // length), move to the new position.
-        // in practice this moves the indel left when we reach the size of
-        // the repeat unit.
-        //
-        int steppos, readsteppos;
-        IndelAllele& indel = *id;
-        int i = 1;
-
-        while (i <= indel.length) {
-
-            int steppos = indel.position - i;
-            int readsteppos = indel.readPosition - i;
-
-            if (debug) {
-                if (steppos >= 0 && readsteppos >= 0) {
-                    cerr << "refseq flank " << referenceSequence.substr(steppos, indel.length) << endl;
-                    cerr << "qryseq flank " << querySequence.substr(readsteppos, indel.length) << endl;
-                    cerr << "indelseq     " << indel.sequence << endl;
-                }
-            }
-
-            while (steppos >= 0 && readsteppos >= 0
-                   && indel.sequence == referenceSequence.substr(steppos, indel.length)
-                   && indel.sequence == querySequence.substr(readsteppos, indel.length)
-                   && (id == indels.begin()
-                       || (previous->insertion && steppos >= previous->position)
-                       || (!previous->insertion && steppos >= previous->position + previous->length))) {
-                LEFTALIGN_DEBUG((indel.insertion ? "insertion " : "deletion ") << indel << " shifting " << i << "bp left" << endl);
-                indel.position -= i;
-                indel.readPosition -= i;
-                steppos = indel.position - i;
-                readsteppos = indel.readPosition - i;
-            }
-            do {
-                ++i;
-            } while (i <= indel.length && indel.length % i != 0);
-        }
-
-
-
-        // left shift indels with exchangeable flanking sequence
-        //
-        // for example:
-        //
-        //    GTTACGTT           GTTACGTT
-        //    GT-----T   ---->   G-----TT
-        //
-        // GTGTGACGTGT           GTGTGACGTGT
-        // GTGTG-----T   ---->   GTG-----TGT
-        //
-        // GTGTG-----T           GTG-----TGT
-        // GTGTGACGTGT   ---->   GTGTGACGTGT
-        //
-        //
-
-        steppos = indel.position - 1;
-        readsteppos = indel.readPosition - 1;
-        while (steppos >= 0 && readsteppos >= 0
-               && querySequence.at(readsteppos) == referenceSequence.at(steppos)
-	       && referenceSequence.size() > steppos + indel.length
-	       && indel.sequence.at((int) indel.sequence.size() - 1) == referenceSequence.at(steppos + indel.length) // are the exchanged bases going to match wrt. the reference?
-               && querySequence.at(readsteppos) == indel.sequence.at((int) indel.sequence.size() - 1)
-               && (id == indels.begin()
-                   || (previous->insertion && indel.position - 1 >= previous->position)
-                   || (!previous->insertion && indel.position - 1 >= previous->position + previous->length))) {
-            if (debug) cerr << (indel.insertion ? "insertion " : "deletion ") << indel << " exchanging bases " << 1 << "bp left" << endl;
-            indel.sequence = indel.sequence.at(indel.sequence.size() - 1) + indel.sequence.substr(0, indel.sequence.size() - 1);
-            indel.position -= 1;
-            indel.readPosition -= 1;
-	    if (debug) cerr << indel << endl;
-            steppos = indel.position - 1;
-            readsteppos = indel.readPosition - 1;
-	    //if (debug && steppos && readsteppos) cerr << querySequence.at(readsteppos) << " ==? " << referenceSequence.at(steppos) << endl;
-	    //if (debug && steppos && readsteppos) cerr << indel.sequence.at((int) indel.sequence.size() - 1) << " ==? " << referenceSequence.at(steppos + indel.length) << endl;
-        }
-        // tracks previous indel, so we don't run into it with the next shift
-        previous = id;
-    }
-
-    if (debug) {
-	for (vector<IndelAllele>::iterator a = indels.begin(); a != indels.end(); ++a) cerr << *a << " ";
-	cerr << endl;
-    }
-
-    if (debug) cerr << "bring together floating indels" << endl;
-
-    // bring together floating indels
-    // from left to right
-    // check if we could merge with the next indel
-    // if so, adjust so that we will merge in the next step
-    if (indels.size() > 1) {
-        previous = indels.begin();
-        for (vector<IndelAllele>::iterator id = (indels.begin() + 1); id != indels.end(); ++id) {
-            IndelAllele& indel = *id;
-            // parsimony: could we shift right and merge with the previous indel?
-            // if so, do it
-            int prev_end_ref = previous->insertion ? previous->position : previous->position + previous->length;
-            int prev_end_read = !previous->insertion ? previous->readPosition : previous->readPosition + previous->length;
-            if (previous->insertion == indel.insertion
-                    && ((previous->insertion
-                        && (previous->position < indel.position
-                        && previous->readPosition < indel.readPosition))
-                        ||
-                        (!previous->insertion
-                        && (previous->position + previous->length < indel.position)
-                        && (previous->readPosition < indel.readPosition)
-                        ))) {
-                if (previous->homopolymer()) {
-                    string seq = referenceSequence.substr(prev_end_ref, indel.position - prev_end_ref);
-                    string readseq = querySequence.substr(prev_end_read, indel.position - prev_end_ref);
-                    if (debug) cerr << "seq: " << seq << endl << "readseq: " << readseq << endl;
-                    if (previous->sequence.at(0) == seq.at(0)
-                            && homopolymer(seq)
-                            && homopolymer(readseq)) {
-                        if (debug) cerr << "moving " << *previous << " right to " 
-					<< (indel.insertion ? indel.position : indel.position - previous->length) << endl;
-                        previous->position = indel.insertion ? indel.position : indel.position - previous->length;
-			previous->readPosition = !indel.insertion ? indel.readPosition : indel.readPosition - previous->readLength(); // should this be readLength?
-                    }
-                }
-		/*
-                else {
-                    int pos = previous->position;
-		    int readpos = previous->readPosition;
-                    while (pos < (int) referenceSequence.length() &&
-                            ((previous->insertion && pos + previous->length <= indel.position)
-                            ||
-                            (!previous->insertion && pos + previous->length < indel.position))
-			   && previous->sequence == referenceSequence.substr(pos + previous->length, previous->length)
-			   && previous->sequence == querySequence.substr(readpos + previous->length, previous->length)
-			) {
-                        pos += previous->length;
-			readpos += previous->length;
-                    }
-		    string seq = previous->sequence;
-                    if (pos > previous->position) {
-			// wobble bases right to left as far as we can go
-			int steppos = previous->position + seq.size();
-			int readsteppos = previous->readPosition + seq.size();
-
-			while (querySequence.at(readsteppos) == referenceSequence.at(steppos)
-			       && querySequence.at(readsteppos) == seq.at(0)
-			       && (id == indels.begin()
-				   || (indel.insertion && pos + seq.size() - 1 <= indel.position)
-				   || (!previous->insertion && indel.position - 1 >= pos + previous->length))) {
-			    seq = seq.substr(1) + seq.at(0);
-			    ++pos;
-			    ++readpos;
-			    steppos = pos + 1;
-			    readsteppos = readpos + 1;
-			}
-
-			if (((previous->insertion && pos + previous->length == indel.position)
-			     ||
-			     (!previous->insertion && pos == indel.position - previous->length))
-			    ) {
-			    if (debug) cerr << "right-merging tandem repeat: moving " << *previous << " right to " << pos << endl;
-			    previous->position = pos;
-			    previous->readPosition = readpos;
-			    previous->sequence = seq;
-			}
-                    }
-                }
-		*/
-            }
-            previous = id;
-        }
-    }
-
-    if (debug) {
-	for (vector<IndelAllele>::iterator a = indels.begin(); a != indels.end(); ++a) cerr << *a << " ";
-	cerr << endl;
-    }
-
-
-    if (debug) cerr << "bring in indels at ends of read" << endl;
-
-    // try to "bring in" repeat indels at the end, for maximum parsimony
-    //
-    // e.g.
-    //
-    // AGAAAGAAAGAAAAAGAAAAAGAACCAAGAAGAAAA
-    // AGAAAG------AAAGAAAAAGAACCAAGAAGAAAA
-    //
-    //     has no information which distinguishes it from:
-    //
-    // AGAAAGAAAAAGAAAAAGAACCAAGAAGAAAA
-    // AGAAAG--AAAGAAAAAGAACCAAGAAGAAAA
-    //
-    // here we take the parsimonious explanation
-
-    if (!indels.empty()) {
-	// deal with the first indel
-	// the first deletion ... or the biggest deletion
-	vector<IndelAllele>::iterator a = indels.begin();
-	vector<IndelAllele>::iterator del = indels.begin();
-	for (; a != indels.end(); ++a) {
-	    //if (!a->insertion && a->length > biggestDel->length) biggestDel = a;
-	    if (!a->insertion && a->length) del = a;
-	if (!del->insertion) {
-	    //if (!indel.insertion) { // only handle deletions like this for now
-	    //if (!indel.insertion && !(indels.size() > 1 && indel.readPosition == indels.at(1).readPosition)) { // only handle deletions like this for now
-	    int insertedBpBefore = 0;
-	    int deletedBpBefore = 0;
-	    for (vector<IndelAllele>::iterator i = indels.begin(); i != del; ++i) {
-		if (i->insertion) insertedBpBefore += i->length;
-		else deletedBpBefore += i->length;
-	    }
-	    IndelAllele& indel = *del;
-	    int minsize = indel.length;
-	    int flankingLength = indel.readPosition;
-	    if (debug) cerr << indel << endl;
-	    string flanking = querySequence.substr(0, flankingLength);
-	    if (debug) cerr << flanking << endl;
-
-	    size_t p = referenceSequence.substr(0, indel.position + indel.length).rfind(flanking);
-	    if (p == string::npos) {
-		if (debug) cerr << "flanking not found" << endl;
-	    } else {
-		if (debug) {
-		    cerr << "flanking is at " << p << endl;
-		    cerr << "minsize would be " << (indel.position + indel.length) - ((int) p + flankingLength) << endl;
-		}
-		minsize = (indel.position + indel.length) - ((int) p + flankingLength);
-	    }
-
-	    if (debug) cerr << minsize << endl;
-
-	    if (minsize >= 0 && minsize < indel.length) {
-
-		int softdiff = softBegin.size();
-		if (!softBegin.empty()) { // remove soft clips if we can
-		    if (flankingLength < softBegin.size()) {
-			softBegin = softBegin.substr(0, flankingLength - softBegin.size());
-			softdiff -= softBegin.size();
-		    } else {
-			softBegin.clear();
-		    }
-		}
-
-		// the new read position == the current read position
-		// the new reference position == the flanking length size
-		// the positional offset of the reference sequence == the new position of the deletion - the flanking length
-
-		int diff = indel.length - minsize - softdiff  + deletedBpBefore - insertedBpBefore;
-		//int querydiff = indel.length - minsize - softBegin.size() - insertedBpBefore + deletedBpBefore;
-		if (debug) cerr << "adjusting " << indel.length <<" " << minsize << "  " << softdiff << " " << diff << endl;
-		offset += diff;
-		///
-		indel.length = minsize;
-		indel.sequence = indel.sequence.substr(indel.sequence.size() - minsize);
-		indel.position = flankingLength;
-		indel.readPosition = indel.position; // if we have removed all the sequence before, this should be ==
-		referenceSequence = referenceSequence.substr(diff);
-
-		for (vector<IndelAllele>::iterator i = indels.begin(); i != indels.end(); ++i) {
-		    if (i < del) {
-			i->length = 0; // remove
-		    } else if (i > del) {
-			i->position -= diff;
-		    }
-		}
-	    }
-	    if (debug) cerr << indel << endl;
-
-	    // now, do the same for the reverse
-	    if (indel.length > 0) {
-		int minsize = indel.length + 1;
-		int flankingLength = querySequence.size() - indel.readPosition + indel.readLength();
-		string flanking = querySequence.substr(indel.readPosition + indel.readLength(), flankingLength);
-		int indelRefEnd = indel.position + indel.referenceLength();
-
-		size_t p = referenceSequence.find(flanking, indel.position);
-		if (p == string::npos) {
-		    if (debug)
-			cerr << "flanking not found" << endl;
-		} else {
-		    if (debug) {
-			cerr << "flanking is at " << p << endl;
-			cerr << "minsize would be " << (int) p - indel.position << endl;
-		    }
-		    minsize = (int) p - indel.position;
-		}
-
-		if (debug) cerr << "minsize " << minsize << endl;
-		if (minsize >= 0 && minsize <= indel.length) {
-		    //referenceSequence = referenceSequence.substr(0, referenceSequence.size() - (indel.length - minsize));
-		    if (debug) cerr << "adjusting " << indel << endl;
-		    indel.length = minsize;
-		    indel.sequence = indel.sequence.substr(0, minsize);
-		    //cerr << indel << endl;
-		    if (!softEnd.empty()) { // remove soft clips if we can
-			if (flankingLength < softEnd.size()) {
-			    softEnd = softEnd.substr(flankingLength - softEnd.size());
-			} else {
-			    softEnd.clear();
-			}
-		    }
-		    for (vector<IndelAllele>::iterator i = indels.begin(); i != indels.end(); ++i) {
-			if (i > del) {
-			    i->length = 0; // remove
-			}
-		    }
-		}
-	    }
-	}
-	}
-    }
-
-    if (debug) {
-	for (vector<IndelAllele>::iterator a = indels.begin(); a != indels.end(); ++a) cerr << *a << " ";
-	cerr << endl;
-    }
-
-    if (debug) cerr << "parsing indels" << endl;
-
-    // if soft clipping can be reduced by adjusting the tailing indels in the read, do it
-    // TODO
-
-    /*
-    int numEmptyIndels = 0;
-
-    if (!indels.empty()) {
-	vector<IndelAllele>::iterator a = indels.begin();
-	while (a != indels.end()) {
-	    if (debug) cerr << "parsing " << *a << endl;
-	    if (!(a->length > 0 && a->position >= 0)) {
-		++numEmptyIndels;
-	    }
-	    ++a;
-	}
-    }
-    */
-
-    for (vector<IndelAllele>::iterator i = indels.begin(); i != indels.end(); ++i) {
-	if (i->length == 0) continue;
-	if (i->insertion) {
-	    if (querySequence.substr(i->readPosition, i->readLength()) != i->sequence) {
-		cerr << "failure: " << *i << " should be " << querySequence.substr(i->readPosition, i->readLength()) << endl;
-		cerr << baseReferenceSequence << endl;
-		cerr << querySequence << endl;
-		throw 1;
-	    }
-	} else {
-	    if (referenceSequence.substr(i->position, i->length) != i->sequence) {
-		cerr << "failure: " << *i << " should be " << referenceSequence.substr(i->position, i->length) << endl;
-		cerr << baseReferenceSequence << endl;
-		cerr << querySequence << endl;
-		throw 1;
-	    }
-	}
-    }
-
-    if (indels.size() > 1) {
-        vector<IndelAllele>::iterator id = indels.begin();
-	while ((id + 1) != indels.end()) {
-	    if (debug) {
-		cerr << "indels: ";
-		for (vector<IndelAllele>::iterator a = indels.begin(); a != indels.end(); ++a) cerr << *a << " ";
-		cerr << endl;
-		//for (vector<IndelAllele>::iterator a = newIndels.begin(); a != newIndels.end(); ++a) cerr << *a << " ";
-		//cerr << endl;
-	    }
-
-	    // get the indels to try to merge
-	    while (id->length == 0 && (id + 1) != indels.end()) ++id;
-	    vector<IndelAllele>::iterator idn = (id + 1);
-	    while (idn != indels.end() && idn->length == 0) ++idn;
-	    if (idn == indels.end()) break;
-
-            IndelAllele& indel = *idn;
-	    IndelAllele& last = *id;
-	    if (debug) cerr << "trying " << last << " against " << indel << endl;
-
-	    int lastend = last.insertion ? last.position : (last.position + last.length);
-	    if (indel.position == lastend) {
-		if (debug) cerr << "indel.position " << indel.position << " lastend " << lastend << endl;
-		if (indel.insertion == last.insertion) {
-		    last.length += indel.length;
-		    last.sequence += indel.sequence;
-		    indel.length = 0;
-		    indel.sequence.clear();
-		    id = idn;
-		} else if (last.length && indel.length) { // if the end of the previous == the start of the current, cut it off of both the ins and the del
-		    if (debug) cerr << "Merging " << last << " " << indel << endl;
-		    int matchsize = 1;
-		    int biggestmatchsize = 0;
-
-		    while (matchsize <= last.sequence.size() && matchsize <= indel.sequence.size()) {
-			if (last.sequence.substr(last.sequence.size() - matchsize) == indel.sequence.substr(0, matchsize)) {
-			    biggestmatchsize = matchsize;
-			}
-			++matchsize;
-		    }
-		    if (debug) cerr << "biggestmatchsize " << biggestmatchsize << endl;
-
-		    last.sequence = last.sequence.substr(0, last.sequence.size() - biggestmatchsize);
-		    last.length -= biggestmatchsize;
-		    indel.sequence = indel.sequence.substr(biggestmatchsize);
-		    indel.length -= biggestmatchsize;
-		    if (indel.insertion) indel.readPosition += biggestmatchsize;
-		    else indel.position += biggestmatchsize;
-
-		    if (indel.length > 0) {
-			id = idn;
-		    }
-		}
-	    } else {
-		if (last.insertion != indel.insertion) {
-		    if (debug) cerr << "merging by overlap " << last << " " << indel << endl;
-		    // see if we can slide the sequence in between these two indels together
-		    string lastOverlapSeq;
-		    string indelOverlapSeq;
-
-		    if (last.insertion) {
-			lastOverlapSeq =
-			    last.sequence
-			    + querySequence.substr(last.readPosition + last.readLength(),
-						   indel.readPosition - (last.readPosition + last.readLength()));
-			indelOverlapSeq =
-			    referenceSequence.substr(last.position + last.referenceLength(),
-						     indel.position - (last.position + last.referenceLength()))
-			    + indel.sequence;
-		    } else {
-			lastOverlapSeq =
-			    last.sequence
-			    + referenceSequence.substr(last.position + last.referenceLength(),
-						       indel.position - (last.position + last.referenceLength()));
-			indelOverlapSeq =
-			    querySequence.substr(last.readPosition + last.readLength(),
-						 indel.readPosition - (last.readPosition + last.readLength()))
-			    + indel.sequence;
-		    }
-
-		    if (debug) {
-			if (!last.insertion) {
-			    if (last.insertion) cerr << string(last.length, '-');
-			    cerr << lastOverlapSeq;
-			    if (indel.insertion) cerr << string(indel.length, '-');
-			    cerr << endl;
-			    if (!last.insertion) cerr << string(last.length, '-');
-			    cerr << indelOverlapSeq;
-			    if (!indel.insertion) cerr << string(indel.length, '-');
-			    cerr << endl;
-			} else {
-			    if (last.insertion) cerr << string(last.length, '-');
-			    cerr << indelOverlapSeq;
-			    if (indel.insertion) cerr << string(indel.length, '-');
-			    cerr << endl;
-			    if (!last.insertion) cerr << string(last.length, '-');
-			    cerr << lastOverlapSeq;
-			    if (!indel.insertion) cerr << string(indel.length, '-');
-			    cerr << endl;
-			}
-		    }
-
-
-		    int dist = min(last.length, indel.length);
-		    int matchingInBetween = indel.position - (last.position + last.referenceLength());
-		    int previousMatchingInBetween = matchingInBetween;
-		    //int matchingInBetween = indel.position - last.position;
-		    if (debug) cerr << "matchingInBetween " << matchingInBetween << endl;
-		    if (debug) cerr << "dist " << dist << endl;
-		    int mindist = matchingInBetween - dist;
-		    if (lastOverlapSeq == indelOverlapSeq) {
-			matchingInBetween = lastOverlapSeq.size();
-		    } else {
-			// TODO change to use string::find()
-			for (int i = dist; i > 0; --i) {
-			    if (debug) cerr << "lastoverlap: "
-					    << lastOverlapSeq.substr(lastOverlapSeq.size() - previousMatchingInBetween - i)
-					    << " thisoverlap: "
-					    << indelOverlapSeq.substr(0, i + previousMatchingInBetween) << endl;
-			    if (lastOverlapSeq.substr(lastOverlapSeq.size() - previousMatchingInBetween - i)
-				== indelOverlapSeq.substr(0, i + previousMatchingInBetween)) {
-				matchingInBetween = previousMatchingInBetween + i;
-				break;
-			    }
-			}
-		    }
-		    //cerr << last << " " << indel << endl;
-		    if (matchingInBetween > 0 && matchingInBetween > previousMatchingInBetween) {
-			if (debug) cerr << "matching " << matchingInBetween  << "bp between " << last << " " << indel
-				        << " was matching " << previousMatchingInBetween << endl;
-			int diff = matchingInBetween - previousMatchingInBetween;
-			last.length -= diff;
-			last.sequence = last.sequence.substr(0, last.length);
-			indel.length -= diff;
-			indel.sequence = indel.sequence.substr(diff);
-			if (!indel.insertion) indel.position += diff;
-			else indel.readPosition += diff;
-			if (debug) cerr << last << " " << indel << endl;
-		    }// else if (matchingInBetween == 0 || matchingInBetween == indel.position - last.position) {
-			//if (!newIndels.empty()) newIndels.pop_back();
-		    //} //else { newIndels.push_back(indel); }
-		    id = idn;
-		    //newIndels.push_back(indel);
-		} else {
-		    id = idn;
-		    //newIndels.push_back(indel);
-		}
-	    }
-	}
-    }
-
-    vector<IndelAllele> newIndels;
-    for (vector<IndelAllele>::iterator i = indels.begin(); i != indels.end(); ++i) {
-	if (!i->insertion && i->position == 0) { offset += i->length;
-	} else if (i->length > 0) newIndels.push_back(*i); // remove dels at front
-    }
-
-    // for each indel
-    //     if ( we're matched up to the previous insertion (or deletion) 
-    //          and it's also an insertion or deletion )
-    //         merge the indels
-    //
-    // and simultaneously reconstruct the cigar
-    //
-    // if there are spurious deletions at the start and end of the read, remove them
-    // if there are spurious insertions after soft-clipped bases, make them soft clips
-
-    vector<pair<int, string> > newCigar;
-
-    if (!softBegin.empty()) {
-	newCigar.push_back(make_pair(softBegin.size(), "S"));
-    }
-
-    if (newIndels.empty()) {
-
-	int remainingReadBp = querySequence.size() - softEnd.size() - softBegin.size();
-	newCigar.push_back(make_pair(remainingReadBp, "M"));
-
-	if (!softEnd.empty()) {
-	    newCigar.push_back(make_pair(softEnd.size(), "S"));
-	}
-
-	cigar = joinCIGAR(newCigar);
-
-	// check if we're realigned
-	if (cigar == cigarbefore) {
-	    return false;
-	} else {
-	    return true;
-	}
-    }
-
-    vector<IndelAllele>::iterator id = newIndels.begin();
-    vector<IndelAllele>::iterator last = id++;
-
-    if (last->position > 0) {
-	newCigar.push_back(make_pair(last->position, "M"));
-	newCigar.push_back(make_pair(last->length, (last->insertion ? "I" : "D")));
-    } else if (last->position == 0) { // discard floating indels
-	if (last->insertion) newCigar.push_back(make_pair(last->length, "S"));
-	else  newCigar.push_back(make_pair(last->length, "D"));
-    } else {
-	cerr << "negative indel position " << *last << endl;
-    }
-
-    int lastend = last->insertion ? last->position : (last->position + last->length);
-    LEFTALIGN_DEBUG(*last << ",");
-
-    for (; id != newIndels.end(); ++id) {
-	IndelAllele& indel = *id;
-	if (indel.length == 0) continue; // remove 0-length indels
-	if (debug) cerr << indel << " " << *last << endl;
-	LEFTALIGN_DEBUG(indel << ",");
-	if ((id + 1) == newIndels.end()
-	    && (indel.insertion && indel.position == referenceSequence.size()
-		|| (!indel.insertion && indel.position + indel.length == referenceSequence.size()))
-	    ) {
-	    if (indel.insertion) {
-		if (!newCigar.empty() && newCigar.back().second == "S") {
-		    newCigar.back().first += indel.length;
-		} else {
-		    newCigar.push_back(make_pair(indel.length, "S"));
-		}
-	    }
-	} else if (indel.position < lastend) {
-	    cerr << "impossibility?: indel realigned left of another indel" << endl;
-	    return false;
-	} else if (indel.position == lastend) {
-	    // how?
-	    if (indel.insertion == last->insertion) {
-		pair<int, string>& op = newCigar.back();
-		op.first += indel.length;
-	    } else {
-		newCigar.push_back(make_pair(indel.length, (indel.insertion ? "I" : "D")));
-	    }
-        } else if (indel.position > lastend) {  // also catches differential indels, but with the same position
-	    if (!newCigar.empty() && newCigar.back().second == "M") newCigar.back().first += indel.position - lastend;
-	    else newCigar.push_back(make_pair(indel.position - lastend, "M"));
-            newCigar.push_back(make_pair(indel.length, (indel.insertion ? "I" : "D")));
-        }
-
-	last = id;
-	lastend = last->insertion ? last->position : (last->position + last->length);
-
-	if (debug) {
-	    for (vector<pair<int, string> >::iterator c = newCigar.begin(); c != newCigar.end(); ++c)
-		cerr << c->first << c->second;
-	    cerr << endl;
-	}
-
-    }
-
-    int remainingReadBp = querySequence.size() - (last->readPosition + last->readLength()) - softEnd.size();
-    if (remainingReadBp > 0) {
-	if (debug) cerr << "bp remaining = " << remainingReadBp << endl;
-	if (newCigar.back().second == "M") newCigar.back().first += remainingReadBp;
-	else newCigar.push_back(make_pair(remainingReadBp, "M"));
-    }
-
-    if (newCigar.back().second == "D") newCigar.pop_back(); // remove trailing deletions
-
-    if (!softEnd.empty()) {
-	if (newCigar.back().second == "S") newCigar.back().first += softEnd.size();
-	else newCigar.push_back(make_pair(softEnd.size(), "S"));
-    }
-
-    LEFTALIGN_DEBUG(endl);
-
-    cigar = joinCIGAR(newCigar);
-
-    LEFTALIGN_DEBUG(cigar << endl);
-
-    // check if we're realigned
-    if (cigar == cigarbefore) {
-        return false;
-    } else {
-        return true;
-    }
-
-}
-
-int countMismatches(string& querySequence, string& cigar, string referenceSequence) {
-
-    int mismatches = 0;
-    int sp = 0;
-    int rp = 0;
-    vector<pair<int, string> > cigarData = splitCIGAR(cigar);
-    for (vector<pair<int, string> >::const_iterator c = cigarData.begin();
-        c != cigarData.end(); ++c) {
-        unsigned int l = c->first;
-        string t = c->second;
-        if (t == "M") { // match or mismatch
-            for (int i = 0; i < l; ++i) {
-                if (querySequence.at(rp) != referenceSequence.at(sp))
-                    ++mismatches;
-                ++sp;
-                ++rp;
-            }
-        } else if (t == "D") { // deletion
-            sp += l;  // update reference sequence position
-        } else if (t == "I") { // insertion
-            rp += l;  // update read position
-        } else if (t == "S") { // soft clip, clipped sequence present in the read not matching the reference
-            rp += l;
-        } else if (t == "H") { // hard clip on the read, clipped sequence is not present in the read
-        } else if (t == "N") { // skipped region in the reference not present in read, aka splice
-            sp += l;
-        }
-    }
-
-    return mismatches;
-
-}
-
-// Iteratively left-aligns the indels in the alignment until we have a stable
-// realignment.  Returns true on realignment success or non-realignment.
-// Returns false if we exceed the maximum number of realignment iterations.
-//
-bool stablyLeftAlign(string querySequence, string& cigar, string referenceSequence, int& offset, int maxiterations, bool debug) {
-
-    if (!leftAlign(querySequence, cigar, referenceSequence, offset)) {
-
-        LEFTALIGN_DEBUG("did not realign" << endl);
-        return true;
-
-    } else {
-
-        while (leftAlign(querySequence, cigar, referenceSequence, offset) && --maxiterations > 0) {
-            LEFTALIGN_DEBUG("realigning ..." << endl);
-        }
-
-        if (maxiterations <= 0) {
-            return false;
-        } else {
-            return true;
-        }
-    }
-}
-
-string mergeCIGAR(const string& c1, const string& c2) {
-    vector<pair<int, string> > cigar1 = splitCIGAR(c1);
-    vector<pair<int, string> > cigar2 = splitCIGAR(c2);
-    // check if the middle elements are the same
-    if (cigar1.back().second == cigar2.front().second) {
-        cigar1.back().first += cigar2.front().first;
-        cigar2.erase(cigar2.begin());
-    }
-    for (vector<pair<int, string> >::iterator c = cigar2.begin(); c != cigar2.end(); ++c) {
-        cigar1.push_back(*c);
-    }
-    return joinCIGAR(cigar1);
-}
-
-vector<pair<int, string> > splitCIGAR(const string& cigarStr) {
-    vector<pair<int, string> > cigar;
-    string number;
-    string type;
-    // strings go [Number][Type] ...
-    for (string::const_iterator s = cigarStr.begin(); s != cigarStr.end(); ++s) {
-        char c = *s;
-        if (isdigit(c)) {
-            if (type.empty()) {
-                number += c;
-            } else {
-                // signal for next token, push back the last pair, clean up
-                cigar.push_back(make_pair(atoi(number.c_str()), type));
-                number.clear();
-                type.clear();
-                number += c;
-            }
-        } else {
-            type += c;
-        }
-    }
-    if (!number.empty() && !type.empty()) {
-        cigar.push_back(make_pair(atoi(number.c_str()), type));
-    }
-    return cigar;
-}
-
-string joinCIGAR(const vector<pair<int, string> >& cigar) {
-    string cigarStr;
-    for (vector<pair<int, string> >::const_iterator c = cigar.begin(); c != cigar.end(); ++c) {
-        if (c->first) {
-            cigarStr += convert(c->first) + c->second;
-        }
-    }
-    return cigarStr;
-}
diff --git a/vcflib/smithwaterman/LeftAlign.h b/vcflib/smithwaterman/LeftAlign.h
deleted file mode 100644
index 7fb796e..0000000
--- a/vcflib/smithwaterman/LeftAlign.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef __LEFTALIGN_H
-#define __LEFTALIGN_H
-
-#include <algorithm>
-#include <map>
-#include <vector>
-#include <list>
-#include <utility>
-#include <sstream>
-
-#include "IndelAllele.h"
-#include "convert.h"
-
-#ifdef VERBOSE_DEBUG
-#define LEFTALIGN_DEBUG(msg) \
-    if (debug) { cerr << msg; }
-#else
-#define LEFTALIGN_DEBUG(msg)
-#endif
-
-using namespace std;
-
-bool leftAlign(string& alternateQuery, string& cigar, string& referenceSequence, int& offset, bool debug = false);
-bool stablyLeftAlign(string alternateQuery, string& cigar, string referenceSequence, int& offset, int maxiterations = 20, bool debug = false);
-int countMismatches(string& alternateQuery, string& cigar, string& referenceSequence);
-
-string mergeCIGAR(const string& c1, const string& c2);
-vector<pair<int, string> > splitCIGAR(const string& cigarStr);
-string joinCIGAR(const vector<pair<int, string> >& cigar);
-
-
-#endif
diff --git a/vcflib/smithwaterman/Makefile b/vcflib/smithwaterman/Makefile
deleted file mode 100644
index 01f5063..0000000
--- a/vcflib/smithwaterman/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-# =========================================
-# MOSAIK Banded Smith-Waterman Makefile
-# (c) 2009 Michael Stromberg & Wan-Ping Lee
-# =========================================
-
-# ----------------------------------
-# define our source and object files
-# ----------------------------------
-SOURCES= smithwaterman.cpp BandedSmithWaterman.cpp SmithWatermanGotoh.cpp Repeats.cpp disorder.c LeftAlign.cpp IndelAllele.cpp
-OBJECTS= $(SOURCES:.cpp=.o) disorder.o
-
-# ----------------
-# compiler options
-# ----------------
-
-CFLAGS=-Wall -O3
-LDFLAGS=-Wl,-s
-#CFLAGS=-g
-PROGRAM=smithwaterman
-LIBS=
-
-all: $(PROGRAM)
-
-.PHONY: all
-
-$(PROGRAM): $(OBJECTS)
-	@echo "  * linking $(PROGRAM)"
-	@$(CXX) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(LIBS)
-
-.PHONY: clean
-
-clean:
-	@echo "Cleaning up."
-	@rm -f *.o $(PROGRAM) *~
diff --git a/vcflib/smithwaterman/Mosaik.h b/vcflib/smithwaterman/Mosaik.h
deleted file mode 100644
index 24d70d0..0000000
--- a/vcflib/smithwaterman/Mosaik.h
+++ /dev/null
@@ -1,73 +0,0 @@
-#pragma once
-
-#ifndef WIN32
-//#include "SafeFunctions.h"
-#endif
-
-// ==============
-// MOSAIK version
-// ==============
-
-#define MOSAIK_VERSION_DATE "2009-02-11"
-
-// adopt a major.minor.build version number [1].[1].[3]
-const unsigned char  MOSAIK_MAJOR_VERSION = 0;
-const unsigned char  MOSAIK_MINOR_VERSION = 9;
-const unsigned short MOSAIK_BUILD_VERSION = 899;
-
-// ================================
-// Platform specific variable sizes
-// ================================
-
-// Windows Vista 32-bit
-// Fedora Core 7 32-bit
-// Fedora Core 6 64-bit
-// Itanium2      64-bit
-#define SIZEOF_CHAR          1
-#define SIZEOF_WCHAR         2
-#define SIZEOF_SHORT         2
-#define SIZEOF_INT           4
-#define SIZEOF_FLOAT         4
-#define SIZEOF_DOUBLE        8
-#define SIZEOF_UINT64        8
-#define MOSAIK_LITTLE_ENDIAN 1
-
-#ifdef WIN32
-typedef signed long long    int64_t;
-typedef unsigned long long uint64_t;
-#endif
-
-#define NEGATIVE_ONE_INT     0xffffffff
-#define NEGATIVE_TWO_INT     0xfffffffe
-#define NEGATIVE_THREE_INT   0xfffffffd
-#define NEGATIVE_FOUR_INT    0xfffffffc
-#define MAX_SHORT            0xffff
-
-// ==========================
-// Platform specific file I/O 
-// ==========================
-
-#ifdef WIN32
-const char OS_DIRECTORY_SEPARATOR = '\\';
-#else
-const char OS_DIRECTORY_SEPARATOR = '/';
-#endif
-
-#define DIRECTORY_NAME_LENGTH    255
-
-// ====================================
-// Enable unit test diagnostic messages
-// ====================================
-
-#ifdef UNITTEST
-#define SILENTMODE if(0)
-#else
-#define SILENTMODE
-#endif
-
-// =================
-// Aligner constants
-// =================
-
-const double HASH_REGION_EXTENSION_PERCENT     = 0.025;
-const unsigned char REFERENCE_SEQUENCE_QUALITY = 40;
diff --git a/vcflib/smithwaterman/Repeats.cpp b/vcflib/smithwaterman/Repeats.cpp
deleted file mode 100644
index 289e7c7..0000000
--- a/vcflib/smithwaterman/Repeats.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-#include "Repeats.h"
-
-map<string, int> repeatCounts(long int position, const string& sequence, int maxsize) {
-    map<string, int> counts;
-    for (int i = 1; i <= maxsize; ++i) {
-        // subseq here i bases
-        string seq = sequence.substr(position, i);
-        // go left.
-
-        int j = position - i;
-        int leftsteps = 0;
-        while (j >= 0 && seq == sequence.substr(j, i)) {
-            j -= i;
-            ++leftsteps;
-        }
-
-        // go right.
-        j = position;
-
-        int rightsteps = 0;
-        while (j + i <= sequence.size() && seq == sequence.substr(j, i)) {
-            j += i;
-            ++rightsteps;
-        }
-        // if we went left and right a non-zero number of times, 
-        if (leftsteps + rightsteps > 1) {
-            counts[seq] = leftsteps + rightsteps;
-        }
-    }
-
-    // filter out redundant repeat information
-    if (counts.size() > 1) {
-        map<string, int> filteredcounts;
-        map<string, int>::iterator c = counts.begin();
-        string prev = c->first;
-        filteredcounts[prev] = c->second;  // shortest sequence
-        ++c;
-        for (; c != counts.end(); ++c) {
-            int i = 0;
-            string seq = c->first;
-            while (i + prev.length() <= seq.length() && seq.substr(i, prev.length()) == prev) {
-                i += prev.length();
-            }
-            if (i < seq.length()) {
-                filteredcounts[seq] = c->second;
-                prev = seq;
-            }
-        }
-        return filteredcounts;
-    } else {
-        return counts;
-    }
-}
-
-bool isRepeatUnit(const string& seq, const string& unit) {
-
-    if (seq.size() % unit.size() != 0) {
-	return false;
-    } else {
-	int maxrepeats = seq.size() / unit.size();
-	for (int i = 0; i < maxrepeats; ++i) {
-	    if (seq.substr(i * unit.size(), unit.size()) != unit) {
-		return false;
-	    }
-	}
-	return true;
-    }
-
-}
diff --git a/vcflib/smithwaterman/Repeats.h b/vcflib/smithwaterman/Repeats.h
deleted file mode 100644
index 2efc0ea..0000000
--- a/vcflib/smithwaterman/Repeats.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <iostream>
-#include <string>
-#include <map>
-
-using namespace std;
-
-map<string, int> repeatCounts(long int pos, const string& seq, int maxsize);
-bool isRepeatUnit(const string& seq, const string& unit);
diff --git a/vcflib/smithwaterman/SWMain.cpp b/vcflib/smithwaterman/SWMain.cpp
deleted file mode 100644
index 6ef3421..0000000
--- a/vcflib/smithwaterman/SWMain.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-#include <iostream>
-#include <string.h>
-//#include "Alignment.h"
-//#include "Benchmark.h"
-//#include "HashRegion.h"
-#include "SmithWatermanGotoh.h"
-#include "BandedSmithWaterman.h"
-
-using namespace std;
-
-int main(int argc, char* argv[]) {
-/*
-	printf("------------------------------------------------------------------------------\n");
-	printf("Banded Smith-Waterman Algorithm (worst case)\n");
-	printf("Michael Stromberg & Wan-Ping Lee  Marth Lab, Boston College Biology Department\n");
-	printf("------------------------------------------------------------------------------\n\n");
-*/
-	// this version simulates the worst case of only a fragment hashing to the
-	// reference sequence. Basically a non-centered diagonal in the Smith-Waterman
-	// dynamic programming matrix.
-
-	// here we simulate a region on the reference that occurs between position 4001
-	// and position 4136. During hashing, only the first 20 bases in the query 
-	// matched perfectly.
-
-	// define the start and end coordinates of the entire reference region
-	//const unsigned int start = 4001;
-	//const unsigned int end   = 4136;
-
-	//const unsigned int testStart = atoi(argv[1]);
-	//const unsigned int testEnd = atoi(argv[2]);
-	//const unsigned int testQueryStart = atoi(argv[3]);
-	//const unsigned int testQueryEnd = atoi(argv[4]);
-	
-	//cout << endl<< "=====================================================" << endl;
-	//cout << testStart << "\t" << testQueryStart << endl;
-	
-	// define the 20 b:q
-	// ases that matched perfectly
-	//HashRegion hr;
-	
-	//=====================================================
-	// defind the hash region
-	// first.first:   reference begin
-	// first.second:  reference end
-	// second.first:  query begin
-	// second.second: query end
-	//=====================================================
-	
-	pair< pair<unsigned int, unsigned int>, pair<unsigned int, unsigned int> > hr;
-	hr.first.first   = 5;
-	hr.first.second  = 13;
-	hr.second.first  = 0;
-	hr.second.second = 8;
-
-	//=====================================================
-
-	// for 76 bp reads, we expect as much as 12 mismatches - however this does not
-	// translate to a bandwidth of 12 * 2 + 1 since most of these will be
-	// substitution errors
-	const unsigned char bandwidth = 11;
-
-	// initialize
-	const char* pReference = "ATGGCGGGGATCGGGACACTCGCCGGTGCGGGTACCCTA";
-	const char* pQuery     =      "GGGGATCGGGACACTCGCTCTCCGGTGCGGGTA";
-	
-	const unsigned int referenceLen = strlen(pReference);
-	const unsigned int queryLen     = strlen(pQuery);
-
-	// ==============================================================================================
-	// benchmarking reference on koi.bc.edu when NUM_ITERATIONS = 38000 on 76 bp read (1 try):
-	// CPU time: 23.920 s, wall time: 24.012 s (1582.6 alignments/s)
-	// ==============================================================================================
-	//const unsigned int NUM_ITERATIONS = 38000;
-	//unsigned int NUM_ITERATIONS = 1;
-
-	// create a new Smith-Waterman alignment object
-	CSmithWatermanGotoh sw(10.0f, -9.0f, 15.0f, 6.66f);
-	CBandedSmithWaterman bsw(10.0f, -9.0f, 15.0f, 6.66f, bandwidth);
-
-	// start timing the algorithm
-	//CBenchmark bench;
-	//bench.Start();
-
-	// perform NUM_ITERATIONS alignments
-	//Alignment bswAl;
-	//Alignment swAl;
-	//   referenceBegin, referenceEnd
-	unsigned int referenceSW, referenceBSW;
-	string cigarSW, cigarBSW;
-	//for(unsigned int i = 0; i < NUM_ITERATIONS; i++) {
-	  sw.Align(referenceSW, cigarSW, pReference, referenceLen, pQuery, queryLen);
-	  bsw.Align(referenceBSW, cigarBSW, pReference, referenceLen, pQuery, queryLen, hr);
-	//}
-
-	// stop timing the algorithm
-	//bench.Stop();
-	
-	// calculate the alignments per second
-	//double elapsedWallTime = bench.GetElapsedWallTime();
-	//double alignmentsPerSecond = (double)NUM_ITERATIONS / elapsedWallTime;
-	
-	// show our results
-	//printf("%d\t%d\n", al.ReferenceBegin,al.QueryBegin);
-
-	printf("Smith-Waterman\n");
-	printf("reference:    %s %3u\n", cigarSW.c_str(), referenceSW);
-	printf("Banded Smith-Waterman\n");
-	printf("reference:    %s %3u\n", cigarBSW.c_str(), referenceBSW);
-	/*  
-	printf("Smith-Waterman\n");
-	printf("reference:    %s %3u %3u\n", swAl.Reference.CData(), swAl.ReferenceBegin, swAl.ReferenceEnd);
-        printf("query:        %s %3u %3u\n", swAl.Query.CData(), swAl.QueryBegin, swAl.QueryEnd);
-        printf("mismatches:   %u\n", swAl.NumMismatches);
-	printf("\n");	
-	printf("Banded Smith-Waterman\n");
-	printf("reference:    %s %3u %3u\n", bswAl.Reference.CData(), bswAl.ReferenceBegin, bswAl.ReferenceEnd);
-        printf("query:        %s %3u %3u\n", bswAl.Query.CData(), bswAl.QueryBegin, bswAl.QueryEnd);
-        printf("mismatches:   %u\n", bswAl.NumMismatches);
-	*/
-	//printf("alignments/s: %.1f\n\n", alignmentsPerSecond);
-
-	//bench.DisplayTime("BandedSmithWaterman");
-
-	return 0;
-}
diff --git a/vcflib/smithwaterman/SmithWatermanGotoh.cpp b/vcflib/smithwaterman/SmithWatermanGotoh.cpp
deleted file mode 100644
index 1050f1a..0000000
--- a/vcflib/smithwaterman/SmithWatermanGotoh.cpp
+++ /dev/null
@@ -1,741 +0,0 @@
-#include "SmithWatermanGotoh.h"
-
-const float CSmithWatermanGotoh::FLOAT_NEGATIVE_INFINITY = (float)-1e+30;
-
-const char CSmithWatermanGotoh::Directions_STOP     = 0;
-const char CSmithWatermanGotoh::Directions_LEFT     = 1;
-const char CSmithWatermanGotoh::Directions_DIAGONAL = 2;
-const char CSmithWatermanGotoh::Directions_UP       = 3;
-
-const int CSmithWatermanGotoh::repeat_size_max      = 12;
-
-CSmithWatermanGotoh::CSmithWatermanGotoh(float matchScore, float mismatchScore, float gapOpenPenalty, float gapExtendPenalty) 
-    : mCurrentMatrixSize(0)
-    , mCurrentAnchorSize(0)
-    , mCurrentQuerySize(0)
-    , mCurrentAQSumSize(0)
-    , mMatchScore(matchScore)
-    , mMismatchScore(mismatchScore)
-    , mGapOpenPenalty(gapOpenPenalty)
-    , mGapExtendPenalty(gapExtendPenalty)
-    , mPointers(NULL)
-    , mSizesOfVerticalGaps(NULL)
-    , mSizesOfHorizontalGaps(NULL)
-    , mQueryGapScores(NULL)
-    , mBestScores(NULL)
-    , mReversedAnchor(NULL)
-    , mReversedQuery(NULL)
-    , mUseHomoPolymerGapOpenPenalty(false)
-    , mUseEntropyGapOpenPenalty(false)
-    , mUseRepeatGapExtensionPenalty(false)
-{
-    CreateScoringMatrix();
-}
-
-CSmithWatermanGotoh::~CSmithWatermanGotoh(void) {
-    if(mPointers)              delete [] mPointers;
-    if(mSizesOfVerticalGaps)   delete [] mSizesOfVerticalGaps;
-    if(mSizesOfHorizontalGaps) delete [] mSizesOfHorizontalGaps;
-    if(mQueryGapScores)        delete [] mQueryGapScores;
-    if(mBestScores)            delete [] mBestScores;
-    if(mReversedAnchor)        delete [] mReversedAnchor;
-    if(mReversedQuery)         delete [] mReversedQuery;
-}
-
-// aligns the query sequence to the reference using the Smith Waterman Gotoh algorithm
-void CSmithWatermanGotoh::Align(unsigned int& referenceAl, string& cigarAl, const string& s1, const string& s2) {
-
-    if((s1.length() == 0) || (s2.length() == 0)) {
-	cout << "ERROR: Found a read with a zero length." << endl;
-	exit(1);
-    }
-
-    unsigned int referenceLen      = s1.length() + 1;
-    unsigned int queryLen          = s2.length() + 1;
-    unsigned int sequenceSumLength = s1.length() + s2.length();
-
-    // reinitialize our matrices
-
-    if((referenceLen * queryLen) > mCurrentMatrixSize) {
-
-	// calculate the new matrix size
-	mCurrentMatrixSize = referenceLen * queryLen;
-
-	// delete the old arrays
-	if(mPointers)              delete [] mPointers;
-	if(mSizesOfVerticalGaps)   delete [] mSizesOfVerticalGaps;
-	if(mSizesOfHorizontalGaps) delete [] mSizesOfHorizontalGaps;
-
-	try {
-
-	    // initialize the arrays
-	    mPointers              = new char[mCurrentMatrixSize];
-	    mSizesOfVerticalGaps   = new short[mCurrentMatrixSize];
-	    mSizesOfHorizontalGaps = new short[mCurrentMatrixSize];
-
-	} catch(bad_alloc) {
-	    cout << "ERROR: Unable to allocate enough memory for the Smith-Waterman algorithm." << endl;
-	    exit(1);
-	}
-    }
-
-    // initialize the traceback matrix to STOP
-    memset((char*)mPointers, 0, SIZEOF_CHAR * queryLen);
-    for(unsigned int i = 1; i < referenceLen; i++) mPointers[i * queryLen] = 0;
-
-    // initialize the gap matrices to 1
-    uninitialized_fill(mSizesOfVerticalGaps, mSizesOfVerticalGaps + mCurrentMatrixSize, 1);
-    uninitialized_fill(mSizesOfHorizontalGaps, mSizesOfHorizontalGaps + mCurrentMatrixSize, 1);
-
-
-    // initialize our repeat counts if they are needed
-    vector<map<string, int> > referenceRepeats;
-    vector<map<string, int> > queryRepeats;
-    int queryBeginRepeatBases = 0;
-    int queryEndRepeatBases = 0;
-    if (mUseRepeatGapExtensionPenalty) {
-	for (unsigned int i = 0; i < queryLen; ++i)
-	    queryRepeats.push_back(repeatCounts(i, s2, repeat_size_max));
-	for (unsigned int i = 0; i < referenceLen; ++i)
-	    referenceRepeats.push_back(repeatCounts(i, s1, repeat_size_max));
-
-	// keep only the biggest repeat
-	vector<map<string, int> >::iterator q = queryRepeats.begin();
-	for (; q != queryRepeats.end(); ++q) {
-	    map<string, int>::iterator biggest = q->begin();
-	    map<string, int>::iterator z = q->begin();
-	    for (; z != q->end(); ++z)
-		if (z->first.size() > biggest->first.size()) biggest = z;
-	    z = q->begin();
-	    while (z != q->end()) {
-		if (z != biggest)
-		    q->erase(z++);
-		else ++z;
-	    }
-	}
-
-	q = referenceRepeats.begin();
-	for (; q != referenceRepeats.end(); ++q) {
-	    map<string, int>::iterator biggest = q->begin();
-	    map<string, int>::iterator z = q->begin();
-	    for (; z != q->end(); ++z)
-		if (z->first.size() > biggest->first.size()) biggest = z;
-	    z = q->begin();
-	    while (z != q->end()) {
-		if (z != biggest)
-		    q->erase(z++);
-		else ++z;
-	    }
-	}
-
-	// remove repeat information from ends of queries
-	// this results in the addition of spurious flanking deletions in repeats
-	map<string, int>& qrend = queryRepeats.at(queryRepeats.size() - 2);
-	if (!qrend.empty()) {
-	    int queryEndRepeatBases = qrend.begin()->first.size() * qrend.begin()->second;
-	    for (int i = 0; i < queryEndRepeatBases; ++i)
-		queryRepeats.at(queryRepeats.size() - 2 - i).clear();
-	}
-
-	map<string, int>& qrbegin = queryRepeats.front();
-	if (!qrbegin.empty()) {
-	    int queryBeginRepeatBases = qrbegin.begin()->first.size() * qrbegin.begin()->second;
-	    for (int i = 0; i < queryBeginRepeatBases; ++i)
-		queryRepeats.at(i).clear();
-	}
-
-    }
-
-    int entropyWindowSize = 8;
-    vector<float> referenceEntropies;
-    vector<float> queryEntropies;
-    if (mUseEntropyGapOpenPenalty) {
-	for (unsigned int i = 0; i < queryLen; ++i)
-	    queryEntropies.push_back(
-		shannon_H((char*) &s2[max(0, min((int) i - entropyWindowSize / 2, (int) queryLen - entropyWindowSize - 1))],
-			  entropyWindowSize));
-	for (unsigned int i = 0; i < referenceLen; ++i)
-	    referenceEntropies.push_back(
-		shannon_H((char*) &s1[max(0, min((int) i - entropyWindowSize / 2, (int) referenceLen - entropyWindowSize - 1))],
-			  entropyWindowSize));
-    }
-
-    // normalize entropies
-    /*
-    float qsum = 0;
-    float qnorm = 0;
-    float qmax = 0;
-    for (vector<float>::iterator q = queryEntropies.begin(); q != queryEntropies.end(); ++q) {
-	qsum += *q;
-	if (*q > qmax) qmax = *q;
-    }
-    qnorm = qsum / queryEntropies.size();
-    for (vector<float>::iterator q = queryEntropies.begin(); q != queryEntropies.end(); ++q)
-	*q = *q / qsum + qmax;
-
-    float rsum = 0;
-    float rnorm = 0;
-    float rmax = 0;
-    for (vector<float>::iterator r = referenceEntropies.begin(); r != referenceEntropies.end(); ++r) {
-	rsum += *r;
-	if (*r > rmax) rmax = *r;
-    }
-    rnorm = rsum / referenceEntropies.size();
-    for (vector<float>::iterator r = referenceEntropies.begin(); r != referenceEntropies.end(); ++r)
-	*r = *r / rsum + rmax;
-    */
-
-    //
-    // construct
-    //
-
-    // reinitialize our query-dependent arrays
-    if(s2.length() > mCurrentQuerySize) {
-
-	// calculate the new query array size
-	mCurrentQuerySize = s2.length();
-
-	// delete the old arrays
-	if(mQueryGapScores) delete [] mQueryGapScores;
-	if(mBestScores)     delete [] mBestScores;
-
-	// initialize the arrays
-	try {
-
-	    mQueryGapScores = new float[mCurrentQuerySize + 1];
-	    mBestScores     = new float[mCurrentQuerySize + 1];
-
-	} catch(bad_alloc) {
-	    cout << "ERROR: Unable to allocate enough memory for the Smith-Waterman algorithm." << endl;
-	    exit(1);
-	}
-    }
-
-    // reinitialize our reference+query-dependent arrays
-    if(sequenceSumLength > mCurrentAQSumSize) {
-
-	// calculate the new reference array size
-	mCurrentAQSumSize = sequenceSumLength;
-
-	// delete the old arrays
-	if(mReversedAnchor) delete [] mReversedAnchor;
-	if(mReversedQuery)  delete [] mReversedQuery;
-
-	// initialize the arrays
-	try {
-
-	    mReversedAnchor = new char[mCurrentAQSumSize + 1];	// reversed sequence #1
-	    mReversedQuery  = new char[mCurrentAQSumSize + 1];	// reversed sequence #2
-
-	} catch(bad_alloc) {
-	    cout << "ERROR: Unable to allocate enough memory for the Smith-Waterman algorithm." << endl;
-	    exit(1);
-	}
-    }
-
-    // initialize the gap score and score vectors
-    uninitialized_fill(mQueryGapScores, mQueryGapScores + queryLen, FLOAT_NEGATIVE_INFINITY);
-    memset((char*)mBestScores, 0, SIZEOF_FLOAT * queryLen);
-
-    float similarityScore, totalSimilarityScore, bestScoreDiagonal;
-    float queryGapExtendScore, queryGapOpenScore;
-    float referenceGapExtendScore, referenceGapOpenScore, currentAnchorGapScore;
-
-    unsigned int BestColumn = 0;
-    unsigned int BestRow    = 0;
-    float BestScore         = FLOAT_NEGATIVE_INFINITY;
-
-    for(unsigned int i = 1, k = queryLen; i < referenceLen; i++, k += queryLen) {
-
-	currentAnchorGapScore = FLOAT_NEGATIVE_INFINITY;
-	bestScoreDiagonal = mBestScores[0];
-
-	for(unsigned int j = 1, l = k + 1; j < queryLen; j++, l++) {
-
-	    // calculate our similarity score
-	    similarityScore = mScoringMatrix[s1[i - 1] - 'A'][s2[j - 1] - 'A'];
-
-	    // fill the matrices
-	    totalSimilarityScore = bestScoreDiagonal + similarityScore;
-	    
-	    //cerr << "i: " << i << ", j: " << j << ", totalSimilarityScore: " << totalSimilarityScore << endl;
-
-	    queryGapExtendScore = mQueryGapScores[j] - mGapExtendPenalty;
-	    queryGapOpenScore   = mBestScores[j] - mGapOpenPenalty;
-	    
-	    // compute the homo-polymer gap score if enabled
-	    if(mUseHomoPolymerGapOpenPenalty)
-		if((j > 1) && (s2[j - 1] == s2[j - 2]))
-		    queryGapOpenScore = mBestScores[j] - mHomoPolymerGapOpenPenalty;
-	    
-	    // compute the entropy gap score if enabled
-	    if (mUseEntropyGapOpenPenalty) {
-		queryGapOpenScore = 
-		    mBestScores[j] - mGapOpenPenalty 
-		    * max(queryEntropies.at(j), referenceEntropies.at(i))
-		    * mEntropyGapOpenPenalty;
-	    }
-
-	    int gaplen = mSizesOfVerticalGaps[l - queryLen] + 1;
-
-	    if (mUseRepeatGapExtensionPenalty) {
-		map<string, int>& repeats = queryRepeats[j];
-		// does the sequence which would be inserted or deleted in this gap match the repeat structure which it is embedded in?
-		if (!repeats.empty()) {
-
-		    const pair<string, int>& repeat = *repeats.begin();
-		    int repeatsize = repeat.first.size();
-		    if (gaplen != repeatsize && gaplen % repeatsize != 0) {
-			gaplen = gaplen / repeatsize + repeatsize;
-		    }
-
-		    if ((repeat.first.size() * repeat.second) > 3 && gaplen + i < s1.length()) {
-			string gapseq = string(&s1[i], gaplen);
-			if (gapseq == repeat.first || isRepeatUnit(gapseq, repeat.first)) {
-			    queryGapExtendScore = mQueryGapScores[j]
-				+ mRepeatGapExtensionPenalty / (float) gaplen;
-				//    mMaxRepeatGapExtensionPenalty)
-			} else {
-			    queryGapExtendScore = mQueryGapScores[j] - mGapExtendPenalty;
-			}
-		    }
-		} else {
-		    queryGapExtendScore = mQueryGapScores[j] - mGapExtendPenalty;
-		}
-	    }
-		  
-	    if(queryGapExtendScore > queryGapOpenScore) {
-		mQueryGapScores[j] = queryGapExtendScore;
-		mSizesOfVerticalGaps[l] = gaplen;
-	    } else mQueryGapScores[j] = queryGapOpenScore;
-	    
-	    referenceGapExtendScore = currentAnchorGapScore - mGapExtendPenalty;
-	    referenceGapOpenScore   = mBestScores[j - 1] - mGapOpenPenalty;
-		  
-	    // compute the homo-polymer gap score if enabled
-	    if(mUseHomoPolymerGapOpenPenalty)
-		if((i > 1) && (s1[i - 1] == s1[i - 2]))
-		    referenceGapOpenScore = mBestScores[j - 1] - mHomoPolymerGapOpenPenalty;
-		  
-	    // compute the entropy gap score if enabled
-	    if (mUseEntropyGapOpenPenalty) {
-		referenceGapOpenScore = 
-		    mBestScores[j - 1] - mGapOpenPenalty 
-		    * max(queryEntropies.at(j), referenceEntropies.at(i))
-		    * mEntropyGapOpenPenalty;
-	    }
-
-	    gaplen = mSizesOfHorizontalGaps[l - 1] + 1;
-
-	    if (mUseRepeatGapExtensionPenalty) {
-		map<string, int>& repeats = referenceRepeats[i];
-		// does the sequence which would be inserted or deleted in this gap match the repeat structure which it is embedded in?
-		if (!repeats.empty()) {
-
-		    const pair<string, int>& repeat = *repeats.begin();
-		    int repeatsize = repeat.first.size();
-		    if (gaplen != repeatsize && gaplen % repeatsize != 0) {
-			gaplen = gaplen / repeatsize + repeatsize;
-		    }
-
-		    if ((repeat.first.size() * repeat.second) > 3 && gaplen + j < s2.length()) {
-			string gapseq = string(&s2[j], gaplen);
-			if (gapseq == repeat.first || isRepeatUnit(gapseq, repeat.first)) {
-			    referenceGapExtendScore = currentAnchorGapScore
-				+ mRepeatGapExtensionPenalty / (float) gaplen;
-				//mMaxRepeatGapExtensionPenalty)
-			} else {
-			    referenceGapExtendScore = currentAnchorGapScore - mGapExtendPenalty;
-			}
-		    }
-		} else {
-		    referenceGapExtendScore = currentAnchorGapScore - mGapExtendPenalty;
-		}
-	    }
-
-	    if(referenceGapExtendScore > referenceGapOpenScore) {
-		currentAnchorGapScore = referenceGapExtendScore;
-		mSizesOfHorizontalGaps[l] = gaplen;
-	    } else currentAnchorGapScore = referenceGapOpenScore;
-		  
-	    bestScoreDiagonal = mBestScores[j];
-	    mBestScores[j] = MaxFloats(totalSimilarityScore, mQueryGapScores[j], currentAnchorGapScore);
-		  
-		  
-	    // determine the traceback direction
-	    // diagonal (445364713) > stop (238960195) > up (214378647) > left (166504495)
-	    if(mBestScores[j] == 0)                         mPointers[l] = Directions_STOP;
-	    else if(mBestScores[j] == totalSimilarityScore) mPointers[l] = Directions_DIAGONAL;
-	    else if(mBestScores[j] == mQueryGapScores[j])   mPointers[l] = Directions_UP;
-	    else                                            mPointers[l] = Directions_LEFT;
-		  
-	    // set the traceback start at the current cell i, j and score
-	    if(mBestScores[j] > BestScore) {
-		BestRow    = i;
-		BestColumn = j;
-		BestScore  = mBestScores[j];
-	    }
-	}
-    }
-
-    //
-    // traceback
-    //
-
-    // aligned sequences
-    int gappedAnchorLen  = 0;   // length of sequence #1 after alignment
-    int gappedQueryLen   = 0;   // length of sequence #2 after alignment
-    int numMismatches    = 0;   // the mismatched nucleotide count
-
-    char c1, c2;
-
-    int ci = BestRow;
-    int cj = BestColumn;
-    int ck = ci * queryLen;
-
-    // traceback flag
-    bool keepProcessing = true;
-
-    while(keepProcessing) {
-	//cerr << ci << " " << cj << " " << ck << "  ... " << gappedAnchorLen << " " << gappedQueryLen <<  endl;
-
-	// diagonal (445364713) > stop (238960195) > up (214378647) > left (166504495)
-	switch(mPointers[ck + cj]) {
-
-	case Directions_DIAGONAL:
-	    c1 = s1[--ci];
-	    c2 = s2[--cj];
-	    ck -= queryLen;
-
-	    mReversedAnchor[gappedAnchorLen++] = c1;
-	    mReversedQuery[gappedQueryLen++]   = c2;
-
-	    // increment our mismatch counter
-	    if(mScoringMatrix[c1 - 'A'][c2 - 'A'] == mMismatchScore) numMismatches++;	
-	    break;
-
-	case Directions_STOP:
-	    keepProcessing = false;
-	    break;
-
-	case Directions_UP:
-	    for(unsigned int l = 0, len = mSizesOfVerticalGaps[ck + cj]; l < len; l++) {
-		if (ci <= 0) {
-		    keepProcessing = false;
-		    break;
-		}
-		mReversedAnchor[gappedAnchorLen++] = s1[--ci];
-		mReversedQuery[gappedQueryLen++]   = GAP;
-		ck -= queryLen;
-		numMismatches++;
-	    }
-	    break;
-
-	case Directions_LEFT:
-	    for(unsigned int l = 0, len = mSizesOfHorizontalGaps[ck + cj]; l < len; l++) {
-		if (cj <= 0) {
-		    keepProcessing = false;
-		    break;
-		}
-		mReversedAnchor[gappedAnchorLen++] = GAP;
-		mReversedQuery[gappedQueryLen++]   = s2[--cj];
-		numMismatches++;
-	    }
-	    break;
-	}
-    }
-
-    // define the reference and query sequences
-    mReversedAnchor[gappedAnchorLen] = 0;
-    mReversedQuery[gappedQueryLen]   = 0;
-
-    // catch sequences with different lengths
-    if(gappedAnchorLen != gappedQueryLen) {
-	cout << "ERROR: The aligned sequences have different lengths after Smith-Waterman-Gotoh algorithm." << endl;
-	exit(1);
-    }
-
-    // reverse the strings and assign them to our alignment structure
-    reverse(mReversedAnchor, mReversedAnchor + gappedAnchorLen);
-    reverse(mReversedQuery,  mReversedQuery  + gappedQueryLen);
-
-    //alignment.Reference = mReversedAnchor;
-    //alignment.Query     = mReversedQuery;
-
-    // set the reference endpoints
-    //alignment.ReferenceBegin = ci;
-    //alignment.ReferenceEnd   = BestRow - 1;
-    referenceAl = ci;
-
-    // set the query endpoints
-    /*  
-	if(alignment.IsReverseComplement) {
-	alignment.QueryBegin = s2Length - BestColumn;
-	alignment.QueryEnd   = s2Length - cj - 1;
-	// alignment.QueryLength= alignment.QueryBegin - alignment.QueryEnd + 1;
-	} else {
-	alignment.QueryBegin = cj;
-	alignment.QueryEnd   = BestColumn - 1;
-	// alignment.QueryLength= alignment.QueryEnd - alignment.QueryBegin + 1;
-	}
-    */
-
-    // set the query length and number of mismatches
-    //alignment.QueryLength = alignment.QueryEnd - alignment.QueryBegin + 1;
-    //alignment.NumMismatches  = numMismatches;
-
-    unsigned int alLength = strlen(mReversedAnchor);
-    unsigned int m = 0, d = 0, i = 0;
-    bool dashRegion = false;
-    ostringstream oCigar (ostringstream::out);
-    int insertedBases = 0;
-
-    if ( cj != 0 ) {
-	if ( cj > 0 ) {
-	    oCigar << cj << 'S';
-	} else { // how do we get negative cj's?
-	    referenceAl -= cj;
-	    alLength += cj;
-	}
-    }
-	
-    for ( unsigned int j = 0; j < alLength; j++ ) {
-	// m
-	if ( ( mReversedAnchor[j] != GAP ) && ( mReversedQuery[j] != GAP ) ) {
-	    if ( dashRegion ) {
-		if ( d != 0 ) oCigar << d << 'D';
-		else          { oCigar << i << 'I'; insertedBases += i; }
-	    }
-	    dashRegion = false;
-	    m++;
-	    d = 0;
-	    i = 0;
-	}
-	else {
-	    if ( !dashRegion && m )
-		oCigar << m << 'M';
-	    dashRegion = true;
-	    m = 0;
-	    if ( mReversedAnchor[j] == GAP ) {
-		if ( d != 0 ) oCigar << d << 'D';
-		i++;
-		d = 0;
-	    }
-	    else {
-		if ( i != 0) { oCigar << i << 'I'; insertedBases += i; }
-		d++;
-		i = 0;
-	    }
-	}
-    }
-    if      ( m != 0 ) oCigar << m << 'M';
-    else if ( d != 0 ) oCigar << d << 'D';
-    else if ( i != 0 ) oCigar << i << 'I';
-
-    if ( BestColumn != s2.length() )
-	oCigar << s2.length() - BestColumn << 'S';
-
-    cigarAl = oCigar.str();
-
-    // fix the gap order
-    CorrectHomopolymerGapOrder(alLength, numMismatches);
-
-    if (mUseEntropyGapOpenPenalty || mUseRepeatGapExtensionPenalty) {
-	int offset = 0;
-	string oldCigar;
-	try {
-	    oldCigar = cigarAl;
-	    stablyLeftAlign(s2, cigarAl, s1.substr(referenceAl, alLength - insertedBases), offset);
-	} catch (...) {
-	    cerr << "an exception occurred when left-aligning " << s1 << " " << s2 << endl;
-	    cigarAl = oldCigar; // undo the failed left-realignment attempt
-	    offset = 0;
-	}
-	referenceAl += offset;
-    }
-
-}
-
-// creates a simple scoring matrix to align the nucleotides and the ambiguity code N
-void CSmithWatermanGotoh::CreateScoringMatrix(void) {
-
-    unsigned int nIndex = 13;
-    unsigned int xIndex = 23;
-
-    // define the N score to be 1/4 of the span between mismatch and match
-    //const short nScore = mMismatchScore + (short)(((mMatchScore - mMismatchScore) / 4.0) + 0.5);
-
-    // calculate the scoring matrix
-    for(unsigned char i = 0; i < MOSAIK_NUM_NUCLEOTIDES; i++) {
-	for(unsigned char j = 0; j < MOSAIK_NUM_NUCLEOTIDES; j++) {
-
-	    // N.B. matching N to everything (while conceptually correct) leads to some
-	    // bad alignments, lets make N be a mismatch instead.
-
-	    // add the matches or mismatches to the hashtable (N is a mismatch)
-	    if((i == nIndex) || (j == nIndex)) mScoringMatrix[i][j] = mMismatchScore;
-	    else if((i == xIndex) || (j == xIndex)) mScoringMatrix[i][j] = mMismatchScore;
-	    else if(i == j) mScoringMatrix[i][j] = mMatchScore;
-	    else mScoringMatrix[i][j] = mMismatchScore;
-	}
-    }
-
-    // add ambiguity codes
-    mScoringMatrix['M' - 'A']['A' - 'A'] = mMatchScore;	// M - A
-    mScoringMatrix['A' - 'A']['M' - 'A'] = mMatchScore;
-    mScoringMatrix['M' - 'A']['C' - 'A'] = mMatchScore; // M - C
-    mScoringMatrix['C' - 'A']['M' - 'A'] = mMatchScore;
-
-    mScoringMatrix['R' - 'A']['A' - 'A'] = mMatchScore;	// R - A
-    mScoringMatrix['A' - 'A']['R' - 'A'] = mMatchScore;
-    mScoringMatrix['R' - 'A']['G' - 'A'] = mMatchScore; // R - G
-    mScoringMatrix['G' - 'A']['R' - 'A'] = mMatchScore;
-
-    mScoringMatrix['W' - 'A']['A' - 'A'] = mMatchScore;	// W - A
-    mScoringMatrix['A' - 'A']['W' - 'A'] = mMatchScore;
-    mScoringMatrix['W' - 'A']['T' - 'A'] = mMatchScore; // W - T
-    mScoringMatrix['T' - 'A']['W' - 'A'] = mMatchScore;
-
-    mScoringMatrix['S' - 'A']['C' - 'A'] = mMatchScore;	// S - C
-    mScoringMatrix['C' - 'A']['S' - 'A'] = mMatchScore;
-    mScoringMatrix['S' - 'A']['G' - 'A'] = mMatchScore; // S - G
-    mScoringMatrix['G' - 'A']['S' - 'A'] = mMatchScore;
-
-    mScoringMatrix['Y' - 'A']['C' - 'A'] = mMatchScore;	// Y - C
-    mScoringMatrix['C' - 'A']['Y' - 'A'] = mMatchScore;
-    mScoringMatrix['Y' - 'A']['T' - 'A'] = mMatchScore; // Y - T
-    mScoringMatrix['T' - 'A']['Y' - 'A'] = mMatchScore;
-
-    mScoringMatrix['K' - 'A']['G' - 'A'] = mMatchScore;	// K - G
-    mScoringMatrix['G' - 'A']['K' - 'A'] = mMatchScore;
-    mScoringMatrix['K' - 'A']['T' - 'A'] = mMatchScore; // K - T
-    mScoringMatrix['T' - 'A']['K' - 'A'] = mMatchScore;
-
-    mScoringMatrix['V' - 'A']['A' - 'A'] = mMatchScore;	// V - A
-    mScoringMatrix['A' - 'A']['V' - 'A'] = mMatchScore;
-    mScoringMatrix['V' - 'A']['C' - 'A'] = mMatchScore; // V - C
-    mScoringMatrix['C' - 'A']['V' - 'A'] = mMatchScore;
-    mScoringMatrix['V' - 'A']['G' - 'A'] = mMatchScore; // V - G
-    mScoringMatrix['G' - 'A']['V' - 'A'] = mMatchScore;
-
-    mScoringMatrix['H' - 'A']['A' - 'A'] = mMatchScore;	// H - A
-    mScoringMatrix['A' - 'A']['H' - 'A'] = mMatchScore;
-    mScoringMatrix['H' - 'A']['C' - 'A'] = mMatchScore; // H - C
-    mScoringMatrix['C' - 'A']['H' - 'A'] = mMatchScore;
-    mScoringMatrix['H' - 'A']['T' - 'A'] = mMatchScore; // H - T
-    mScoringMatrix['T' - 'A']['H' - 'A'] = mMatchScore;
-
-    mScoringMatrix['D' - 'A']['A' - 'A'] = mMatchScore;	// D - A
-    mScoringMatrix['A' - 'A']['D' - 'A'] = mMatchScore;
-    mScoringMatrix['D' - 'A']['G' - 'A'] = mMatchScore; // D - G
-    mScoringMatrix['G' - 'A']['D' - 'A'] = mMatchScore;
-    mScoringMatrix['D' - 'A']['T' - 'A'] = mMatchScore; // D - T
-    mScoringMatrix['T' - 'A']['D' - 'A'] = mMatchScore;
-
-    mScoringMatrix['B' - 'A']['C' - 'A'] = mMatchScore;	// B - C
-    mScoringMatrix['C' - 'A']['B' - 'A'] = mMatchScore;
-    mScoringMatrix['B' - 'A']['G' - 'A'] = mMatchScore; // B - G
-    mScoringMatrix['G' - 'A']['B' - 'A'] = mMatchScore;
-    mScoringMatrix['B' - 'A']['T' - 'A'] = mMatchScore; // B - T
-    mScoringMatrix['T' - 'A']['B' - 'A'] = mMatchScore;
-}
-
-// enables homo-polymer scoring
-void CSmithWatermanGotoh::EnableHomoPolymerGapPenalty(float hpGapOpenPenalty) {
-    mUseHomoPolymerGapOpenPenalty = true;
-    mHomoPolymerGapOpenPenalty    = hpGapOpenPenalty;
-}
-
-// enables entropy-based gap open penalty
-void CSmithWatermanGotoh::EnableEntropyGapPenalty(float enGapOpenPenalty) {
-    mUseEntropyGapOpenPenalty = true;
-    mEntropyGapOpenPenalty    = enGapOpenPenalty;
-}
-
-// enables repeat-aware gap extension penalty
-void CSmithWatermanGotoh::EnableRepeatGapExtensionPenalty(float rGapExtensionPenalty, float rMaxGapRepeatExtensionPenaltyFactor) {
-    mUseRepeatGapExtensionPenalty = true;
-    mRepeatGapExtensionPenalty    = rGapExtensionPenalty;
-    mMaxRepeatGapExtensionPenalty = rMaxGapRepeatExtensionPenaltyFactor * rGapExtensionPenalty;
-}
-
-// corrects the homopolymer gap order for forward alignments
-void CSmithWatermanGotoh::CorrectHomopolymerGapOrder(const unsigned int numBases, const unsigned int numMismatches) {
-
-    // this is only required for alignments with mismatches
-    //if(al.NumMismatches == 0) return;
-    if ( numMismatches == 0 ) return;
-
-    // localize the alignment data
-    //char* pReference = al.Reference.Data();
-    //char* pQuery     = al.Query.Data();
-    //const unsigned int numBases = al.Reference.Length();
-    char* pReference = mReversedAnchor;
-    char* pQuery     = mReversedQuery;
-
-    // initialize
-    bool hasReferenceGap = false, hasQueryGap = false;
-    char* pNonGapSeq = NULL;
-    char* pGapSeq    = NULL;
-    char nonGapBase  = 'J';
-
-    // identify gapped regions
-    for(unsigned int i = 0; i < numBases; i++) {
-
-	// check if the current position is gapped
-	hasReferenceGap = false;
-	hasQueryGap     = false;
-
-	if(pReference[i] == GAP) {
-	    hasReferenceGap = true;
-	    pNonGapSeq      = pQuery;
-	    pGapSeq         = pReference;
-	    nonGapBase      = pQuery[i];
-	}
-
-	if(pQuery[i] == GAP) {
-	    hasQueryGap = true;
-	    pNonGapSeq  = pReference;
-	    pGapSeq     = pQuery;
-	    nonGapBase  = pReference[i];
-	}
-
-	// continue if we don't have any gaps
-	if(!hasReferenceGap && !hasQueryGap) continue;
-
-	// sanity check
-	if(hasReferenceGap && hasQueryGap) {
-	    printf("ERROR: Found a gap in both the reference sequence and query sequence.\n");
-	    exit(1);
-	}
-
-	// find the non-gapped length (forward)
-	unsigned short numGappedBases = 0;
-	unsigned short nonGapLength   = 0;
-	unsigned short testPos = i;
-	while(testPos < numBases) {
-
-	    const char gs  = pGapSeq[testPos];
-	    const char ngs = pNonGapSeq[testPos];
-
-	    bool isPartofHomopolymer = false;
-	    if(((gs == nonGapBase) || (gs == GAP)) && (ngs == nonGapBase)) isPartofHomopolymer = true;
-	    if(!isPartofHomopolymer) break;
-
-	    if(gs == GAP) numGappedBases++;
-	    else nonGapLength++;
-	    testPos++;
-	}
-
-	// fix the gap order
-	if(numGappedBases != 0) {
-	    char* pCurrentSequence = pGapSeq + i;
-	    memset(pCurrentSequence, nonGapBase, nonGapLength);
-	    pCurrentSequence += nonGapLength;
-	    memset(pCurrentSequence, GAP, numGappedBases);
-	}
-
-	// increment
-	i += numGappedBases + nonGapLength - 1;
-    }
-}
diff --git a/vcflib/smithwaterman/SmithWatermanGotoh.h b/vcflib/smithwaterman/SmithWatermanGotoh.h
deleted file mode 100644
index 2379847..0000000
--- a/vcflib/smithwaterman/SmithWatermanGotoh.h
+++ /dev/null
@@ -1,101 +0,0 @@
-#pragma once
-
-#include <iostream>
-#include <algorithm>
-#include <memory>
-//#include "Alignment.h"
-#include "Mosaik.h"
-#include <stdio.h>
-#include <string.h>
-#include <sstream>
-#include <string>
-#include "disorder.h"
-#include "Repeats.h"
-#include "LeftAlign.h"
-
-using namespace std;
-
-#define MOSAIK_NUM_NUCLEOTIDES 26
-#define GAP '-'
-
-class CSmithWatermanGotoh {
-public:
-    // constructor
-    CSmithWatermanGotoh(float matchScore, float mismatchScore, float gapOpenPenalty, float gapExtendPenalty);
-    // destructor
-    ~CSmithWatermanGotoh(void);
-    // aligns the query sequence to the reference using the Smith Waterman Gotoh algorithm
-    void Align(unsigned int& referenceAl, string& cigarAl, const string& s1, const string& s2);
-    // enables homo-polymer scoring
-    void EnableHomoPolymerGapPenalty(float hpGapOpenPenalty);
-    // enables non-repeat gap open penalty
-    void EnableEntropyGapPenalty(float enGapOpenPenalty);
-    // enables repeat gap extension penalty
-    void EnableRepeatGapExtensionPenalty(float rGapExtensionPenalty, float rMaxGapRepeatExtensionPenaltyFactor = 10);
-private:
-    // creates a simple scoring matrix to align the nucleotides and the ambiguity code N
-    void CreateScoringMatrix(void);
-    // corrects the homopolymer gap order for forward alignments
-    void CorrectHomopolymerGapOrder(const unsigned int numBases, const unsigned int numMismatches);
-    // returns the maximum floating point number
-    static inline float MaxFloats(const float& a, const float& b, const float& c);
-    // our simple scoring matrix
-    float mScoringMatrix[MOSAIK_NUM_NUCLEOTIDES][MOSAIK_NUM_NUCLEOTIDES];
-    // keep track of maximum initialized sizes
-    unsigned int mCurrentMatrixSize;
-    unsigned int mCurrentAnchorSize;
-    unsigned int mCurrentQuerySize;
-    unsigned int mCurrentAQSumSize;
-    // define our traceback directions
-    // N.B. This used to be defined as an enum, but gcc doesn't like being told
-    // which storage class to use
-    const static char Directions_STOP;
-    const static char Directions_LEFT;
-    const static char Directions_DIAGONAL;
-    const static char Directions_UP;
-    // repeat structure determination
-    const static int repeat_size_max;
-    // define scoring constants
-    const float mMatchScore;
-    const float mMismatchScore;
-    const float mGapOpenPenalty;
-    const float mGapExtendPenalty;
-    // store the backtrace pointers
-    char* mPointers;
-    // store the vertical gap sizes - assuming gaps are not longer than 32768 bases long
-    short* mSizesOfVerticalGaps;
-    // store the horizontal gap sizes - assuming gaps are not longer than 32768 bases long
-    short* mSizesOfHorizontalGaps;	
-    // score if xi aligns to a gap after yi
-    float* mQueryGapScores;
-    // best score of alignment x1...xi to y1...yi
-    float* mBestScores;
-    // our reversed alignment
-    char* mReversedAnchor;
-    char* mReversedQuery;
-    // define static constants
-    static const float FLOAT_NEGATIVE_INFINITY;
-    // toggles the use of the homo-polymer gap open penalty
-    bool mUseHomoPolymerGapOpenPenalty;
-    // specifies the homo-polymer gap open penalty
-    float mHomoPolymerGapOpenPenalty;
-    // toggles the use of the entropy gap open penalty
-    bool mUseEntropyGapOpenPenalty;
-    // specifies the entropy gap open penalty (multiplier)
-    float mEntropyGapOpenPenalty;
-    // toggles the use of the repeat gap extension penalty
-    bool mUseRepeatGapExtensionPenalty;
-    // specifies the repeat gap extension penalty
-    float mRepeatGapExtensionPenalty;
-    // specifies the max repeat gap extension penalty
-    float mMaxRepeatGapExtensionPenalty;
-};
-
-// returns the maximum floating point number
-inline float CSmithWatermanGotoh::MaxFloats(const float& a, const float& b, const float& c) {
-    float max = 0.0f;
-    if(a > max) max = a;
-    if(b > max) max = b;
-    if(c > max) max = c;
-    return max;
-}
diff --git a/vcflib/smithwaterman/convert.h b/vcflib/smithwaterman/convert.h
deleted file mode 100644
index 399bcea..0000000
--- a/vcflib/smithwaterman/convert.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef __CONVERT_H
-#define __CONVERT_H
-
-#include <sstream>
-
-// converts the string into the specified type, setting r to the converted
-// value and returning true/false on success or failure
-template<typename T>
-bool convert(const std::string& s, T& r) {
-    std::istringstream iss(s);
-    iss >> r;
-    return iss.eof() ? true : false;
-}
-
-template<typename T>
-std::string convert(const T& r) {
-    std::ostringstream iss;
-    iss << r;
-    return iss.str();
-}
-
-#endif
diff --git a/vcflib/smithwaterman/disorder.c b/vcflib/smithwaterman/disorder.c
deleted file mode 100644
index a5f7c35..0000000
--- a/vcflib/smithwaterman/disorder.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/***************************************************************************
- *  libdisorder: A Library for Measuring Byte Stream Entropy
- *  Copyright (C) 2010 Michael E. Locasto
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the:
- *       Free Software Foundation, Inc.
- *       59 Temple Place, Suite 330
- *       Boston, MA  02111-1307  USA
- *
- * $Id$
- **************************************************************************/
-
-#include <math.h> //for log2()
-#include <stdio.h> //for NULL
-#include "disorder.h"
-
-#if defined(__FreeBSD__)
-#define        log2(x) (log((x)) * (1./M_LN2))
-#endif
-
-/** Frequecies for each byte */
-static int m_token_freqs[LIBDO_MAX_BYTES]; //frequency of each token in sample
-static float m_token_probs[LIBDO_MAX_BYTES]; //P(each token appearing)
-static int m_num_tokens = 0; //actual number of `seen' tokens, max 256 
-static float m_maxent = 0.0;
-static float m_ratio = 0.0;
-static int LIBDISORDER_INITIALIZED = 0;
-
-static void
-initialize_lib()
-{
-  int i = 0;
-  if(1==LIBDISORDER_INITIALIZED)
-    return;
-
-  m_num_tokens = 0;
-
-  for(i=0;i<LIBDO_MAX_BYTES;i++)
-  {
-    m_token_freqs[i]=0;
-    m_token_probs[i]=0.0;
-  }
-
-  LIBDISORDER_INITIALIZED = 1;
-}
-
-/**
- * Set m_num_tokens by iterating over m_token_freq[] and maintaining
- * a counter of each position that does not hold the value of zero.
- */
-static void
-count_num_tokens()
-{
-  int i = 0;
-  int counter = 0;
-  for(i=0;i<LIBDO_MAX_BYTES;i++)
-  {
-    if(0!=m_token_freqs[i])
-    {
-      counter++;
-    }
-  }
-  m_num_tokens = counter;
-  return;
-}
-
-/**
- * Sum frequencies for each token (i.e., byte values 0 through 255)
- * We assume the `length' parameter is correct.
- *
- * This function is available only to functions in this file.
- */
-static void
-get_token_frequencies(char* buf, 
-		      long long length)
-{
-  int i=0;
-  char* itr=NULL;
-  unsigned char c=0;
-
-  itr = buf;
-
-  //reset number of tokens
-  m_num_tokens = 0;
-
-  //make sure freqency and probability arrays are cleared
-  for(i=0;i<LIBDO_MAX_BYTES;i++)
-  {
-    m_token_freqs[i] = 0;
-    m_token_probs[i] = 0.0;
-  }
-
-  for(i=0;i<length;i++)
-  {
-    c = (unsigned char)*itr;
-    //assert(0<=c<LIBDO_MAX_BYTES);
-    m_token_freqs[c]++;
-    itr++;
-  }
-}
-
-/**
- * Return entropy (in bits) of this buffer of bytes. We assume that the
- * `length' parameter is correct. This implementation is a translation
- * of the PHP code found here:
- *
- *    http://onlamp.com/pub/a/php/2005/01/06/entropy.html
- *
- * with a helpful hint on the `foreach' statement from here:
- *
- *    http://php.net/manual/en/control-structures.foreach.php
- */
-float
-shannon_H(char* buf, 
-	  long long length)
-{
-  int i = 0;
-  float bits = 0.0;
-  char* itr=NULL; //values of itr should be zero to 255
-  unsigned char token;
-  int num_events = 0; //`length' parameter
-  float freq = 0.0; //loop variable for holding freq from m_token_freq[]
-  float entropy = 0.0; //running entropy sum
-
-  if(NULL==buf || 0==length)
-    return 0.0;
-
-  if(0==LIBDISORDER_INITIALIZED)
-    initialize_lib();
-
-  itr = buf;
-  m_maxent = 0.0;
-  m_ratio = 0.0;
-  num_events = length;
-  get_token_frequencies(itr, num_events); //modifies m_token_freqs[]
-  //set m_num_tokens by counting unique m_token_freqs entries
-  count_num_tokens(); 
-
-  if(m_num_tokens>LIBDO_MAX_BYTES)
-  {
-    //report error somehow?
-    return 0.0;
-  }
-
-  //iterate through whole m_token_freq array, but only count
-  //spots that have a registered token (i.e., freq>0)
-  for(i=0;i<LIBDO_MAX_BYTES;i++)
-  {
-    if(0!=m_token_freqs[i])
-    {
-      token = i;
-      freq = ((float)m_token_freqs[token]); 
-      m_token_probs[token] = (freq / ((float)num_events));
-      entropy += m_token_probs[token] * log2(m_token_probs[token]);
-    }
-  }
-
-  bits = -1.0 * entropy;
-  m_maxent = log2(m_num_tokens);
-  m_ratio = bits / m_maxent;
-
-  return bits;
-}
-
-int 
-get_num_tokens()
-{
-  return m_num_tokens;
-}
-
-float 
-get_max_entropy()
-{
-  return m_maxent;
-}
-
-float 
-get_entropy_ratio()
-{
-  return m_ratio;
-}
diff --git a/vcflib/smithwaterman/disorder.h b/vcflib/smithwaterman/disorder.h
deleted file mode 100644
index 3458774..0000000
--- a/vcflib/smithwaterman/disorder.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/***************************************************************************
- *  libdisorder: A Library for Measuring Byte Stream Entropy
- *  Copyright (C) 2010 Michael E. Locasto
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the:
- *       Free Software Foundation, Inc.
- *       59 Temple Place, Suite 330
- *       Boston, MA  02111-1307  USA
- *
- * $Id$
- **************************************************************************/
-
-#ifndef __DISORDER_H_
-#define __DISORDER_H_
-
-/** Max number of bytes (i.e., tokens) */
-#define LIBDO_MAX_BYTES      256
-
-/** A convienance value for clients of this library. Feel free to change
- * if you plan to use a larger buffer. You can also safely ignore it, as
- * libdisorder does not use this value internally; it relies on the
- * client-supplied `length' parameter.
- *
- * NB: Might become deprecated because it is potentially misleading and
- * has zero relationship to any library internal state.
- */
-#define LIBDO_BUFFER_LEN   16384
-
-/** 
- * Given a pointer to an array of bytes, return a float indicating the
- * level of entropy in bits (a number between zero and eight),
- * assuming a space of 256 possible byte values. The second argument
- * indicates the number of bytes in the sequence. If this sequence
- * runs into unallocated memory, this function should fail with a
- * SIGSEGV.
- */
-float    shannon_H(char*, long long);
-
-/** Report the number of (unique) tokens seen. This is _not_ the
-    number of individual events seen. For example, if the library sees
-    the string `aaab', the number of events is 4 and the number of
-    tokens is 2. */
-int      get_num_tokens(void);
-
-/** Returns maximum entropy for byte distributions log2(256)=8 bits*/
-float    get_max_entropy(void);
-
-/** Returns the ratio of entropy to maxentropy */
-float    get_entropy_ratio(void);
-
-#endif
diff --git a/vcflib/smithwaterman/examples.txt b/vcflib/smithwaterman/examples.txt
deleted file mode 100644
index aefe062..0000000
--- a/vcflib/smithwaterman/examples.txt
+++ /dev/null
@@ -1,76 +0,0 @@
-TCTGTGACCTCAAAGCCCAACTGTGCATACACAAGCATACACACACACACACACACACACACACACACACACACATACACACACA TCTGTGACCTCAAAGCCCAACTGTGCATACACAAGCATACACACACACACACACACA 
-AAAGGCTGGGGACCACTGATCTAAATACACCAATAAAAAGAAAAAGATTGTAAGATTGGATTTTAAAAGACCTGACTCTATACTGACCACAAAAAAAAACCCTCACT AAAGGCTGGGGACCACTGATCTAAATACACCAATAAAAAGAAAAAGATTGTAAGATTGGATTTTAAAAGACCTGACTCTATACTGACCACAAAAAAAACC 
-TGTGACCTCAAAGCCCAACTGTGCATACACAAGCATACACACACACACACACACACACACACACACACACACATACACA TGTGACCTCAAAGCCCAACTGTGCATACACAAGCATACACACACACACGCACACACACACATACACACAC 
-ATTTTTTAAATCAGGAATAACTTAGACCAGGGTGAACAAACTACTGCTGTCAGGGCAAATCCAGCCCATAGCCTGCTTTTGGAAATAAATTTGTATTAGAACACACACACACACACACACACACACACACACACACACACATACACACATACACACAAATATATCTTCACTAATGTTCTTTTTTTCTTGTTTTTC GGTGAACAAACTACTGCTGTCAGGGCAAATCCAGCCCATAGCCTGCTTTTGGAAATAAATTTGTATTAGAACACACACACACACACACACACATACACACATACACACAAAT 
-ATGCATGCCTCTCTCTCTCTCTCTGTCGCTCTCTCTCTCTCTCTCTCTCTCTCTCT ATGCATGCCTCTCTCTCTCTCTCTCGCTCTCTCTCTCTCTCTCTCT 
-ACACCAGCTGGGGTGTGTGTGTGTGTGTGTGTGTGTGCGTGTGTGTGTGTGTGTGTGATTCTCGTGCCT GGGGGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGATTCTCGTGC 
-GCCTGGGCAACATAGTGAGACCTTGTCTCTACAAATAGTTAAAAAAAAAAAAAAAATTAGCCAGGTGTGGTGGTGCACACATGT GCCTGGGCAACATAGTGAGACCTTGTCTCTACAAATAGTTAAAAAAAAAAAAAATTAGCCAGGTGTGGTGGTGCACACATGT 
-TTTTCTTTTCTTTTCTTTTCTTTTTTTTTTTTTTTTTGAGATGGAATTTCACTCTTGTTGCCCAGGCTGGAGTGCAATGGTGTGATCTCGGCTCACGGCAACCTCCG TTTTCTTTTTTTTTTTGAGATGGAATTTCACTCTTGTTGCCCAGGCCGGAGTGCAATGGTGTGCTCTCGGCTCCCGGCAACCTCCG
-AGTAATGGAAATACTGTTTATCATCATTAGAGTTGGGTGTATACTACTACATTACTCTCTCTCTCTCTCTATATATATATATATATATATATATATTTTTTTTT AGTAATGGAAATACTGTTTATCATCATTAGAGTTGGGTGTATACTACTACATTACTCTCTCTCTCTCTCTCTCTATATATATATATATATATTTTTTTTT
-AGCCTGGGCGACAGGGCGAGACTCCGTCTCAAATAATAATAATAATAATAATAATAATAATAATAATAATAATAAAATAAAATAAAATAAAATAAAAATACAAAAAT AGCCTGGGCGACAGGGCGAGACTCCGTCTCAAATAATAATAATAATAATAATAATAATAATAAAATAAAATAAAATAAAATAAAAATACAAAAAT 
-CATACACACACACACACACACACACACACACACACACACACACACACACACACCTCATGTAGTGAACTTAATAAATTTAATCTGCAGCTCTGATGATTTCCTTAAGG CATACACACACACACACACACATACACACACACACACACACACACCTCATGTAGTGAACTTAATAAATTTAATCTGCAGCTCTGATGATTTCCTTAAGG 
-GGGAGGCTGAGGCAGGAGGATCACACCACTGCACTTTAGCCTGAATACTGAGTAACAAAGCAAAACCCTGTCTCTCTTAAAAAAAAAATTGGGGGGAAGGACAAGTCTTTTTTCTTTTCTTTTCTTTTCTTTTCTTTTTTTTTTTTTTTTTGAGATGGAATTTCACTCTTGTTGCCCAGGCTGGAGTGCAATGGTGTGATC AGTAACAAAGCAAAACCCTGTCTCTCTTAAAAAAAAAATTGGGGGGAAGGACAAGTCTTTTTTCTTTTCTTTTCTTTTCTTTTCTTTTCTTTTTTTTTTTGTGATGGAATT 
-ATTTTTTAAATCAGGAATAACTTAGACCAGGGTGAACAAACTACTGCTGTCAGGGCAAATCCAGCCCATAGCCTGCTTTTGGAAATAAATTTGTATTAGAACACACACACACACACACACACACACACACACACACACACATACACACATACACACAAATATATCTTCACTAATGTTCTTTTTTTCTTGTTTTTC GGTGAACAAACTACTGCTGTCAGGGCAAATCCAGCCCATAGCCTGCTTTTGGAAATAAATTTGTATTAGAACACACACACACACACACACACATACACACATACACACAAAT 
-CATACACACACACACACACACACACACACACACACACACACACACACACACACCTCATGTAGTGAACTTAATAAATTTAATCTGCAGCTCTGATGATTTCCTTAAGGC CATACACACACACACACACACATACACACACACACACACACACACCTCATGTAGTGAACTTAATAAATTTAATCTGCAGCTCTGATGATTTCCTTAAGGC 
-TATACAGATTACTTTTATAGCTGATGAGGCAAGTCCTTCTATCATTGTTTCAAAGATTCCATGGCTTTTACTGAACATTTTCTTTTTTCTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTGAGACGGAGTTTC TTTTCTTTTTTCTTTTTTTTTTTTTGAGACGGAGTTTC 
-GAGAGAGGCGCGCGCGCGCGTGCGCACGCACACACACACACACACACACATAACTAATATATATAAATACATATATATGTGGGTATATATTATTTATTTATG GAGAGAGGCGCGCGCGCGCGCGCGCACACACACACACACACACACACATAACTAATATATATAAATACATATATATGTGGGTATATATTATTTATTTATG 
-TATATGTATATATATGTGTGTATATATATGTATATATATGTGTGTATATATATGTGTATATATATGTGTGTGTGTGTGTGTGTGTGTGTATATATATATATATATATATATATCAGTTTGCCCTTGCTGGATAACAAA TATATGTATATATATGTGTGTATATATATGTATATATATGTGTGTATATATATGTGTATATATGTGTGTGTGTGTGTATATATATATCAGTTTGCCCTTG 
-AGCAAACACCTATTGTGCATTTTCTTTTCTTTCTTTCTTTCTTTCTTTTTTTTTTTTGAGACGGAGTTTCGCTCTTGTTGTCCAGGCTAGAGTACGATGG AGCAAACACCTATTGTGCATTTTCTTTTCCTTCTTTCTTTCTTTTTTTTTTTTTTTGAGACGGAGTTTCGCTCTTGTTGTCCAGTCTAGAGTCAGTGG 
-GATTTTGGTATATTGGTCTTACATTTTTTCACTTTGCTGAACTCATTTATTAGTTCTAATTCATGGGGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTCTGTGTGTGTGTGTGTCTGTGTGTT GATTTTGGTATATTGGTCTTACATTTTTTCACTTTGCTGAACTCATTTATTAGTTCTAATTCATGGGGTGTGTGTGTGTGTGTGTGTGTGTCTGTGTGTG 
-CCAGCCTGGGCGACAGAGTGAGACTCCATCTCAAAACAAACAAACAAACAAACAAACAAACAAACAACTCCACTAAGACTTTTGGGACAACCTGTACCTACCTGACCTGCCTTTCCATCTTTAATGCTCTTCT CCAGCCTGGGCGACAGAGTGAGACTCCATCTCAAAACAAACAAACAAACAAACAAACAAACAACTCCACTAAGACTTTTGGGACAACCTGTACCTATCT 
-TATATGTATATATATGTGTGTATATATATGTATATATATGTGTGTATATATATGTGTATATATATGTGTGTGTGTGTGTGTGTGTGTGTATATATATATATATATATATATATCAGTTTGCCCTTGCTGGATAACAAA TATATGTATATATATGTGTGTATATATATGTATATATATGTGTGTATATATATGTGTATATATGTGTGTGTGTGTGTATATATATATCAGTTTGCCCTTG 
-TAATATATATAATATCTAATATATATAATATCTAATATATATAATATATATATAGAGAGAGAGAGAGAGCGAGAGAGAGAGAGAGAGGGAGAGACGGAGTTTCGCTCTTGTTGCCCAGACTGGAGTGCAATGGCGCGATCTC AATATATATATAGAGAGAGAGAGAGCGAGAGAGAGAGAGAGAGAGGGAGAGACGGAGTTTCGCTCTTGTTGCCCAGACTGGAGTGCAATGGCGCGATCTC 
-GAGAAAGAAACTATTTAGCATTGTGGCTTTCATAATTTCTTTCTTTCTTTTTTTTTTTTTTTTTGAAGCAGAGTCTAGCTCTGTCGCCCAGGCTGGAAAGCAGTGGTGCAAACTC TTAGCATTGTGGCTTTCATAATTTCTTTCTTTTTTTTTTTTTTTTTTTTTAAGCAGAGTCTAGCTCTGTCCCCCCGGCTGGAAAGCAGTGGTGCAACCTC 
-GGTGACAGAGCAAGACTCCATCTCTCTCTCTCTCTCTCTCTCTCTATATATATATATATATATATACATATATATATGTATATATATGTATATATATGTGTATATATGTGTATATATATGTATATATGTGTATATATATAT GTGACAGAGCAAGACTCCATCTCTCTCTCTCTCTCTCTCTCTATATATATATATATACACACATATATATATGTATATATATGTATATATATATGTGTAT 
-GAGAGAGGCGCGCGCGCGCGTGCGCACGCACACACACACACACACACACATAACTAATATATATAAATACATATATATGTGGGTATATATTATTTATTTATG GAGAGAGGCGCGCGCGCGCGCGCGCACACACACACACACACACACACATAACTAATATATATAAATACATATATATGTGGGTATATATTATTTATTTATG 
-ATTTTTTAAATCAGGAATAACTTAGACCAGGGTGAACAAACTACTGCTGTCAGGGCAAATCCAGCCCATAGCCTGCTTTTGGAAATAAATTTGTATTAGAACACACACACACACACACACACACACACACACACACACACATACACACATACACACAAATATATCTTCACTAATGTTCTTTTTTTCTTGTTTTTC GGTGAACAAACTACTGCTGTCAGGGCAAATCCAGCCCATAGCCTGCTTTTGGAAATAAATTTGTATTAGAACACACACACACACACACACACATACACACATACACACAAAT 
-TTTTCTTTTCTTTTCTTTTTTTTTTTTTTTTTGAGATGGAATTTCACTCTTGTTGCCCAGGCTGGAGTGCAATGGTGTGATCTCGGCTCACGGCAACCTCCGCCTCC TTTTCTTTTTTTTTTTGAGATGGAATTTCACTCTTGTTGCCCAGGCCGGAGTGCAATGGTGTGCTCTCGGCTCCCGGCAACCTCCGCCTCT 
-GAGCCGAGATCGTGCCACTGCACTCCAGCCTGGGTGACAGAGCGAGACTCTGTCTCAAAAACAAAAAACAAGCAAACAAAAAAACAAAAAAAAACAAAAAATCCCCAGCA ATCGTGCCACTGCACTCCAGCCTGGGTGACAGAGCGAGACTCTGTCTCAAAAACAAAAAACAAGCAAACAAAAAGCAAAAAAAACAAAAAACCCCCAGCA 
-GAGCCGAGATCGTGCCACTGCACTCCAGCCTGGGTGACAGAGCGAGACTCTGTCTCAAAAACAAAAAACAAGCAAACAAAAAAACAAAAAAAAACAAAAAATCCCCAGCA ATCGTGCCACTGCACTCCAGCCTGGGTGACAGAGCGAGACTCTGTCTCAAAAACAAAAAACAAGCAAACAAAAAGCAAAAAAAACAAAAAACCCCCAGCA 
-TAATATATATAATATCTAATATATATAATATCTAATATATATAATATATATATAGAGAGAGAGAGAGAGCGAGAGAGAGAGAGAGAGGGAGAGACGGAGTTTCGCTCTTGTTGCCCAGACTGGAGTG AATATATATATAGAGAGAGAGAGAGCGAGAGAGAGAGAGAGAGAGGGAGAGACGGAGTTTCGCTCTTGTTGCCCAGACTGGAGTG 
-AAACCCCATCTCTGCTACAAATACAAATACAAATAATAATAATAATAATAATAATAATAATAATAATAATAATAATAATAGCCAGGCATGC AAACCCCATCTCTGCTACAAATACAAATACAAATAATAATAATAATAATAATAATAATAATAATAATAATAATAGCCAGGCATGC 
-TATATAATATCTAATATATATAATATATATATAGAGAGAGAGAGAGAGCGAGAGAGAGAGAGAGAGGGAGAGACGGAGTTTCGCTCTTGTTGCCCAGACTGGAGTGC TATATAATATCTAATATATATAATATATATATATAGAGAGAGAGAGCGAGAGAGAGAGAGAGAGGGAGAGA 
-AGAGGCAGTAGATTTAGGGACCACTCAACCTAGTGAGACACCAGCTGGGGTGTGTGTGTGTGTGTGTGTGTGTGCGTGTGTGTGTGTGTGTGTGATTCTCGTGCCTC TAGATTTAGGGAGCACTCAACCTAGTGAGACACCAGCTGGGGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGATT 
-ACACCAGCTGGGGTGTGTGTGTGTGTGTGTGTGTGTGCGTGTGTGTGTGTGTGTGTGATTCTCGTGCCTC GGGGGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGATTCTCGTGC 
-CAAGGCTCCAAAATTTTCAGATGAAATGTACAGAAAGAATACAATCTCATTTTAATAGTTTTTTTTTTTTTTAAAAAGGTCCTTGACCAATTCCCCAAGGTCCAT CAAGGCTCCAAAATTTTCAGATGAAATGTACAGAAAGAATACAATCTCATTTTAATAGTTTTTTTTTTTTAAAAAAGGTCCTTGACCAATTCCCCAAGGT 
-AAACCCCATCTCTGCTACAAATACAAATACAAATAATAATAATAATAATAATAATAATAATAATAATAATAATAATAATAGCCAGGCATGC AAACCCCATCTCTGCTACAAATACAAATACAAATAATAATAATAATAATAATAATAATAATAATAATAATAATAGCCAGGCATGC 
-TACTTCATATGTTCCACGCTCTGGTTGTTTTGTGGGGAGCAAAAGAGAAGTTCCCATTTCTGTTTATGTTAGAAACAAAACAAGACAAAAAACAAATTAACAAGCAAATACATACTGATTATAAAATAATGTGATGTGAAGAAAAAAACTGCTAAGAAAGAATAATGAGGT TTCCCATTTCTGTTTATGTTAAAAACAAAACAAAACAAGACAAAAAACAAATTAACAAGCAAATACATACTGATTATAAAATAATGTGATGTGAAGAAAA
-GGTTGTTTTGTGGGGAGCAAAAGAGAAGTTCCCATTTCTGTTTATGTTAGAAACAAAACAAGACAAAAAACAAATTAACAAGCAAATACATACTGATTATAAAATAATGTGATGTGAAGAAAAAAACTGCTAAGAAAGAATAATGAGGTAGGAGGGGGCTACTTGAGATCAGGTGGTCACGCTGAGAGTTGA TTAAAAACAAAACGAAACAAGACAAAAAACAAATTAACAAGCAAATACATACTGATTATAAAATAATGTGATGTGAAGAAAAAAACTGCTAAGAAAGAAT
-TTAGAAACAAAACAAGACAAAAAACAAATTAACAAGCAAATACATACTGATTATAAAATAATGTGATGTGAAGAAAAAAACTGCTAAGAAAGAAT TTAAAAACAAAACGAAACAAGACAAAAAACAAATTAACAAGCAAATACATACTGATTATAAAATAATGTGATGTGAAGAAAAAAACTGCTAAGAAAGAAT 
-ACCTTGAATATGAACACTCTAAATGCTCCACTTAAGAGGCACAGAGTAGCAAGTTGGAAAAGAAAAGAAAAGAAAAGAAAAGAAAACTCATCTGTCTGCAG ACCTTGAATATGAACACTCTAAATGCTCCACTTAAGAGGCACAGAGTAGCAAGTTGGAAAAGAAAAGAAAAGAAAAGAAAACAAAACAAAACTCATCTGT 
-TTTTCTTTTCTTTTCTTTTCTTTTCTTTTTTTTTTTTTTTTTGAGATGGAATTTCACTCTTGTTGCCCAGGCTGGAGTGCAATGGTGTGATCTCGGCTCACGGCAAC TTTTCTTTTTTTTTTTGAGATGGAATTTCACTCTTGTTGCCCAGGCCGGAGTGCAATGGTGTGCTCTCGGCTCCCGGCAAC 
-AGAAAGAAAGAAAAAGAAAAAGAACCAAGAAGAAAAAATAATCACCGGAGATTCCTCCCCTCCCCTAGAGCTAACTAGGCTAACATTTTGGTATATATCTTTCCAG AGAAAGAAAGAAAAAGAACCAAGAAGAAAAAATAATCACCGGAGATTCCTCCCCTCCCCTAGAGCTGACTAGGCTAACATTTTGGTATATATCTTTCCAG 
-GACCTTTCTATATATGGTTTTACAATCGGATCAATCGAGATCCCCTCCCCTCCTTAGAGGCCACTAATAAAAAAGAAGAACCAAGAAAAAGAAAAAGAAAGA GACCTTTCTATATATGGTTTTACAATCGGATCAATCGAGATCCCCTCCCCTCCTTAGAGGCCACTAATAAAAAAGAAGAACCAAGAAAAAGAAAAAGA
-AGAAAGAAAGAAAAAGAAAAAGAACCAAGAAGAAAAAATAATCACCGGAGATTCCTCCCCTCCCCTAGAGCTAACTAGGCTAACATTTTGGTATATATCTTTCCAG AGAAAGAAAGAAAAAGAACCAAGAAGAAAAAATAATCACCGGAGATTCCTCCCCTCCCCTAGAGCTGACTAGGCTAACATTTTGGTATATATCTTTCCAG 
-ATTTTTTAAATCAGGAATAACTTAGACCAGGGTGAACAAACTACTGCTGTCAGGGCAAATCCAGCCCATAGCCTGCTTTTGGAAATAAATTTGTATTAGAACACACACACACACACACACACACACACACACACACACACATACACACATACACACAAATATATCTTCACTAATGTTCTTTTTTTCTTGTTTTTC GGTGAACAAACTACTGCTGTCAGGGCAAATCCAGCCCATAGCCTGCTTTTGGAAATAAATTTGTATTAGAACACACACACACACACACACACATACACACATACACACAAAT 
-GGTTGTTTTGTGGGGAGCAAAAGAGAAGTTCCCATTTCTGTTTATGTTAGAAACAAAACAAGACAAAAAACAAATTAACAAGCAAATACATACTGATTATAAAATAATGTGATGTGAAGAAAAAAACTGCTAAGAAAGAATAATGAGGTAGGAGGGGGCTACTTGAGATCAGGTGGTCACGCTGAGAGTTGA TTAAAAACAAAACGAAACAAGACAAAAAACAAATTAACAAGCAAATACATACTGATTATAAAATAATGTGATGTGAAGAAAAAAACTGCTAAGAAAGAAT 
-TAAGAAAGAATCGTCAAAAAAAGAAGTGTAGTGTAATAAAATATTAGTCATACATAAACGAACAATTAAACAAAAAACAGAACAAAGCACACACACACACACA TAAGAAAGAATCGTCAAAAAAAGAAGTGTAGTGTAATAAAATATTAGTCATACATAAACGAACAATTAAACAAAAAACAGAACAAAGCACACACACACACACA
-TAATATATATAATATCTAATATATATAATATCTAATATATATAATATATATATAGAGAGAGAGAGAGAGCGAGAGAGAGAGAGAGAGGGAGAGACGGAGTTTCGCTCTTGTTGCCCAGACTGGAGTGCAATGGCGCGATCTC AATATATATATAGAGAGAGAGAGAGCGAGAGAGAGAGAGAGAGAGGGAGAGACGGAGTTTCGCTCTTGTTGCCCAGACTGGAGTGCAATGGCGCGATCTC 
-AAAGAAAGAAAAGAAAGAAAGAAAGAAAGAAAGAAAGAAAGAAAGAAAGAAAGAAAGAAAAAGAAAAAGAACCAAGAAGAAAAAATAATCACCGGAGATTCCTCCCCTCCCCTAGAGCTAACTAGGCTAACATTTTGGTATATATCTTTCCAGTCCGGATCCTGTGTGACTGAGTGTGTATATGCATATGTATTATTTTCAAC AAGAAAGAAAGAAAAAGAACCAAGAAGAAAAAATAATCACCCGAGATTCCTCCCCTCCCCTAGAGCTAACTAGGCTAACATTTTGGTATATATCTTTCCA 
-GAATGCACATTTGGTCCTTCATTAACTCATTTACTCACAATTTTTTTTTTTTTTTTTTTTTTGAGACGGAGTTTCACTCTTGTCGCCCAGGCTGGAGTGCAATGGTGTGA ACAATTTTTTTTTTTTTTTTTTTGAGACGGAGTTTCACTCTTGTCGCCCAGGCTGGAGTGCAATGGTGTGA 
-CCACTGCACTCCAGCCTGGGCGACAGGGCGAGACTCCGTCTCAAATAATAATAATAATAATAATAATAATAATAATAATAATAATAAAATAAAATAAAA CCACTGCACTCCAGCCTGGGCGACAGGGCGAGACTCCGTCTCAAATAATAATAATAATAATAATAATAATAATAAAATAAAATAAAATAAAATAAAA 
-ATTCCAATACTATTCAATTGTTCCACAGCACAGAAAAGAAAAAATTCTAAATTCTTTCTATGGAACAAAAAAATCATCAATGACACCTGACCAAAGATGGCACACACACACACACACACACACACACACACACACACACACTACAGTCCAACCCCACTAATGAATACAAAAATCCTAACACTAGCA GGGACACACACACACACACACACACACACACACTACAGTCCAACCCCACTAATGAATACAAAAATCCTAACACTAGCA
-GGCAGGAGAATTGCTTGAACCCAGGGGGCAGAGGTGGCAGTGAGCCGGGATCATGCCACTTCACTCCAGCCTGGGTGAAAGAGCAAAACTCTGTCTCAAAAAAAAAAAAAAAAAAAGACAGCTGCAACAAATGTCAAGTTCTGTGTGTTTTCTTTTCTTTTCTTTTTTTTCTATTTAATTAATTTATT AAAAAAAAAAAAAAAAAGACAGCTGCAACAAATGTCAAGTTCTGTGTGTTTTCTTTTCTTTTCTTTTTTTTCTATTTAATTAATTTATT
-GGCAGGAGAATTGCTTGAACCCAGGGGGCAGAGGTGGCAGTGAGCCGGGATCATGCCACTTCACTCCAGCCTGGGTGAAAGAGCAAAACTCTGTCTCAAAAAAAAAAAAAAAAAAAGACAGCTGCAACAAATGTCAAGTTCTGTGTGTTTTCTTTTCTTTTCTTTTTTTTCTATTTAATTAATTTATT CAAAAAAAAAAAAAAAAAGACAGCTGCAACAAATGTCAAGTTCTGTGTGTTTTCTTTTCTTTTCTTTTTTTTCTATTTAATTAATTTATT
-ATTGCTTGAGCCCAGGAGTTCAGGGCTGCAATGAGCTATGATCATGCCACTGCACTCCAGCCTGGGCAACAGAGTGAGATCCTGTCTCTAAAATATGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTATGTGTGTGTGTCTGTACATATACGTATATATATATGTGTGTATATATACAT AATATGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTATGTGTGTGTGTCTGTACATATACGTATATATATATGTGTGTATATATACAT
-GCCCACCACGCTGCAGATGAATATGCCACAATGTCAACAGTGTTTAGGCTCATATATATATATATATATATATATATATATATATATATATATATATATATTTTAAGACAGTCTTGCTCTGTCACCC TCTCATATATATATATATATATATATATATTTTAAGACAGTCTTGCTCTGTCACCC
-GCCCACCACGCTGCAGATGAATATGCCACAATGTCAACAGTGTTTAGGCTCATATATATATATATATATATATATATATATATATATATATATATATATATTTTAAGACAGTCTTGCTCTGTCACCC TATATATATATATATATATATATATATATATATATTGAGACAGTCTCGCTCTGTCACCC 
-ATTCCAATACTATTCAATTGTTCCACAGCACAGAAAAGAAAAAATTCTAAATTCTTTCTATGGAACAAAAAAATCATCAATGACACCTGACCAAAGATGGCACACACACACACACACACACACACACACACACACACACACTACAGTCCAACCCCACTAATGAATACAAAAATCCTAACACTAGCA GGGACACACACACACACACACACACACACACACTACAGTCCAACCCCACTAATGAATACAAAAATCCTAACACTAGCA 
-GCCCACCACGCTGCAGATGAATATGCCACAATGTCAACAGTGTTTAGGCTCATATATATATATATATATATATATATATATATATATATATATATATATATTTTAAGACAGTCTTGCTCTGTCACCC TATATATATATATATATATATATATATATATATATTGAGACAGTCTCGCTCTGTCACCC 
-CACAAGAACTGCAATTCCTAGGCAACTGCTAGTGCTGTGCTGGGCTCAGAGGCAGTAGATTTAGGGACCACTCAACCTAGTGAGACACCAGCTGGGGTGTGTGTGTGTGTGTGTGTGTGTGCGTGTGTGTGTGTGTGTGTGATTCTCGTGCCTCAGCCTCCCAAGTAGCTGGTGATGGCAGTGGCAGCCCATCTGGAGTGGACGCTGCCATCAAGCCAGCTGCAGCAGGGAGGGACAGCTGGGGCTGCACAT GGTCAGAGAGAGTATATAGAGAGAGCACACACCAGAGAGAGACACGCTGGGGGGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGATTCTCGTGC 
-CGCCTGTAGTCTCAGCTATTAATATTTGGGAGGCTGAGGCAGGAGGATCACACCACTGCACTTTAGCCTGAATACTGAGTAACAAAGCAAAACCCTGTCTCTCTTAAAAAAAAAATTGGGGGGAAGGACAAGTCTTTTTTCTTTTCTTTTCTTTTCTTTTCTTTTTTTTTTTTTTTTTGAGATGGAATTTCACTCTTGTTGCCCAGGCTGGAGTGCAATGGTGTGATCTCGGCTCACGGCAACCTCCGCCTCCTGGGTTCAAGCAATTCTGCTTCAGCCTCCCGAGTGGCTGGGATTATAGT CTCTTAAAAAAAAAATTGGGGGGAAGGACAAGTCTTTTTTCTTTTCTTTTCTTTTCTTTTCTTTTCTTTTTTTTTTTGGGTTGGAATTTTACTCTTGTTG 
-CTCGGCTCACTGCAAGCTCCACCTCCCGGGTTCACGCCATTCTCCTGCCTCAGTCTCCCAAGTAGCTGGGACTACAGGTGCCCACCACCACGTCTGGCTAATTTTTTTGTATTTTTAGTAGAGATGGGGATTCACCGTGTTAGCCAGGATGGTCTCGATCTCCTGACTTTGTGATCCACCCGCCTCAGCCTCCCAAAGCCTCCTTCACTTTTCTTTATTAGCCTCAACCCCATGATTCACCACTCCAAGTACTCCCTTGCCAGCATCCTCAAATCCCAATACCATTTTTAAAATTTTTTAA ATTTTTTTGTATTTTTAGTAGAGATGGGGATTCACCGTGTTAGCCAGGATGGTCTCGATCTCCTGACTTTGTGATCCGCCCGCCTCAGCCTCCCAAAGCC 
-TTGGGGGGAAGGACAAGTCTTTTTTCTTTTCTTTTCTTTTCTTTTCTTTTTTTTTTTTTTTTTGAGATGGAATTTCACTCTTGTTGCCCAGGCTGGAGTGCAATG TTCTTTTTTTTTTTGAGATGGAATTTCACTCTTGTTGCCCAGGCCGGAGTGCAATG 
-GGAGGCAGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGTGACAGAGCAAGACTCCATCTCTCTCTCTCTCTCTCTCTCTCTATATATATATATATATATATACATATATATATGTATATATATGTATATATATGTGTATATATGTGTATATATATGTATATATGTGTATATATATATGTAT CCTGTGTGACAGAGCAAGACTCCATCTCTCTCTCTCTCTCTCTCTCTCTATATATATATATATATATACATATATATATATATGTATATATATGTATATA
-TAATTTACAACAACACGTAAGTTGTTACTCTGTAAACCCTTGCCTCCCCCCCACCCCCCACCCAATTGGGTCTTTTTTTTTTTTCTCTCTCTCCATGCTTCTGCAGTGACTCTTAAGTAGCATTTTTAAAAACTTC CCACCCCCCACCCAATTGGGTCTTTTTTTTTTTTCTCTCTCTCCATGCTTCTGCAGTGACTCTTAAGTAGCATTTTTTAAAACTTCTATTTATTTTAAAA
-GTTCACACTTTTGGCCATACCCAGGGTCAGCCATGAAGATTGTTCTCAGAATGTTTTCTTTCTTCCTTCCTTTCTCTTTCTTTTCTTTCTTTCTTCCTTTCTTTCTTTCCTTTCTTTTTCTTTCTTCTCTTTCTTTTTTTCTTTTCTTCTTTCTCTCTCTTTCTTTCTCTCTCTCTCTCTCCTTCCTTCCTTCCTTCT ATGTTTTCTTTCTTCCTTCCTTTCTCTTTCTTTTCTTTCTTTCTTCCTTTCTTTCTTTCCTTTCTTTTTCTTTCTTCTCTTTCTTTCTTTTTTCTTTTCT
-GTTCACACTTTTGGCCATACCCAGGGTCAGCCATGAAGATTGTTCTCAGAATGTTTTCTTTCTTCCTTCCTTTCTCTTTCTTTTCTTTCTTTCTTCCTTTCTTTCTTTCCTTTCTTTTTCTTTCTTCTCTTTCTTTTTTTCTTTTCTTCTTTCTCTCTCTTTCTTTCTCTCTCTCTCTCTCCTTCCTTCCTTCCTTCT ATGTTTTCTTTCTTCCTTCCTTTCTCTTTCTTTTCTTTCTTTCTTCCTTTCTTTCTTTCCTTTCTTTTTCTTTCTTCTCTTTCTTTCTTTTTTCTTTTCT
-GGAGGCAGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGTGACAGAGCAAGACTCCATCTCTCTCTCTCTCTCTCTCTCTCTATATATATATATATATATATACATATATATATGTATATATATGTATATATATGTGTATATATGTGTATATATATGTATATATGTGTATATATATATGTAT CCTGTGTGACAGAGCAAGACTCCATCTCTCTCTCTCTCTCTCTCTCTCTATATATATATATATATATACATATATATATATATGTATATATATGTATATA
-CTCCCACTGGGGTAATCCATCTTTTCTTTTAATTATTTTCCTTTTGAGATATATTAAAAATGCAAAAAAAAAAATTTTTATTTTTTTGAGACGGAGTCTCGCTCTATCACCTAGGCTGGAGTGCAGTGGCATGATCTTGGCTCACTGCAACCTCCGCCTCCTGGGTTCAACTGATTCTCCTGCCTCAGCCTCCTGAATAG ATATTAAAAATGCAAAAAAAAATTTTTTTTATTTTTTTGAGACGGAGTCTCGCTCTATCGCCTAGGCTGGAGTGCAGTGGCATGATCTTGGCTCACTGCA
-GGCAGGAGAATTGCTTGAACCCAGGGGGCAGAGGTGGCAGTGAGCCGGGATCATGCCACTTCACTCCAGCCTGGGTGAAAGAGCAAAACTCTGTCTCAAAAAAAAAAAAAAAAAAAGACAGCTGCAACAAATGTCAAGTTCTGTGTGTTTTCTTTTCTTTTCTTTTTTTTCTATTTAATTAATTTATT CAAAAAAAAAAAAAAAAAGACAGCTGCAACAAATGTCAAGTTCTGTGTGTTTTCTTTTCTTTTCTTTTTTTTCTATTTAATTAATTTATT
-CAAGATCGTGCCGCTGCACTCCAGCCCAGGTGACAGAGCGAGACTTCATCTCAAAAAAAAAAAGGGCGCCAAACATCTACTGTGTACCCACAAAAATTAAAATTATAAAAAGACGGCATCAGCAATCCCAGGAGGTGATGTGTCCCTGGTTGGTGTACCTCAGGAGTTGCTGCATTTGCCTCACATCACCATGTGAGATAA CAAAAAAAAAAAAGGGCGCCAAACATCTACTGTGTACCCACAAAAATTAAAATTATAAAAAGACGGCATCAGCAATCCCAGGAGGTGATGTGTCCCTGGT
-CCTCTTAGGTGGTCACATCCTAGAGAGGGGGAAATTACATCAGAAAAGGACCAATGCCAAATTACAGCAACAAAGGGAAAGTAATCCTGGAAGCTGATTTAAGCTATGTGACTGTGTCTTCAATTAAAATATTCAGTCCCTTCCCCTCCCCCTCCCCCTCCCTTCCGTCTCCCTCTGTTGCTGAGGCTGGACTG CCAATGCCAAATTACAGCAACAAAGGGAAAGTAATCCTGGAAGCTGATTTAAGCTATGTGACTGTGTCTTCAATTAAAATATTCAGTCCCTCCCCCTCCC
-CCAAGTGACCCTTTCACCTCAGCTTCCCAAGTAGCTGGGATTACAGGTGCACACCAACTGTGCTTTGCAGTTTTGTTTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTGTATTTTGTTTTTTTTACAAGCCCACAACATCATAGC TCCTCAGCGTCCCAAGTAGCTGGGAGTAGAGATGCACACCAACTGTGCTTTGCAGTTTTGTTTGTGTGTGTGTGTGTGTGTGTGTGTGTATTTTGTTTTT
-CAAGATTTGCCACTGCACTCCAGCCTGGGTGACAGAGTGAGACTGTATCTCAAAAAAAAAAAATAAATAAATAAAGAGAATAAGGCATTTGATATAGTTTCTTTGCATAACAAAATACAAATAAAACCACATTCTATTTCATCTAAACACTTTCTCCCAAGTCATTCTCTCTTAGCCTCA GGACAGGGGGAGACTGTATCTCAAAAAAAAAAAAAAAATAAATAAAGAGAATAAGGCATTTGATATAGTTTCTTTGCATAACAAAATACAAATAAAACCA
-GATCATGCCACTGCACTCCAGCCTGGGCAAAAGAGCGAGACTCTGTCTCAAAAAAAAAAAAAAAATCCAGAAAGAATTGGCACACCTATGTTGTTAAGTTTTCCAATCCAAGAATACTGTATTCCTTATCATTTTT AAAAAAAAAAAAAAATCCAGAAAGAATTGGCACCCTTTTGTTGTAAAGTTTTCCATTCCAAGAAAACTGGATTCCTTCTTTTTTTTTTCTTTTTGTTTCT
-TCCCTCCCTTCCTCCCTTTCTCTCCCTCTCCCTCTCTTTCTTTCTCTCTCTCTCTTTCTCCCCTTCTTTCTTTCTTTCTCTCTCTCTTTTTCTTTCTTTCTTTCTTTCTTTC TCCCTCCCTTCCTCCCTTTCTCTCCCTCTCCCTCTCTTTCTTTCTCTCTCTCTCTTTCTCCCCTTCTTTTTTTCTCTCTCTCTCTTTTTTTTTCTTTCTC
diff --git a/vcflib/smithwaterman/libdisorder.LICENSE b/vcflib/smithwaterman/libdisorder.LICENSE
deleted file mode 100644
index 8bbcff9..0000000
--- a/vcflib/smithwaterman/libdisorder.LICENSE
+++ /dev/null
@@ -1,339 +0,0 @@
-		    GNU GENERAL PUBLIC LICENSE
-		       Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-			    Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users.  This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it.  (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.)  You can apply it to
-your programs, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
-  To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
-  For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have.  You must make sure that they, too, receive or can get the
-source code.  And you must show them these terms so they know their
-rights.
-
-  We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
-  Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software.  If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
-  Finally, any free program is threatened constantly by software
-patents.  We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary.  To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.
-

-		    GNU GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License.  The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language.  (Hereinafter, translation is included without limitation in
-the term "modification".)  Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
-  1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
-  2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) You must cause the modified files to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    b) You must cause any work that you distribute or publish, that in
-    whole or in part contains or is derived from the Program or any
-    part thereof, to be licensed as a whole at no charge to all third
-    parties under the terms of this License.
-
-    c) If the modified program normally reads commands interactively
-    when run, you must cause it, when started running for such
-    interactive use in the most ordinary way, to print or display an
-    announcement including an appropriate copyright notice and a
-    notice that there is no warranty (or else, saying that you provide
-    a warranty) and that users may redistribute the program under
-    these conditions, and telling the user how to view a copy of this
-    License.  (Exception: if the Program itself is interactive but
-    does not normally print such an announcement, your work based on
-    the Program is not required to print an announcement.)
-

-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
-    a) Accompany it with the complete corresponding machine-readable
-    source code, which must be distributed under the terms of Sections
-    1 and 2 above on a medium customarily used for software interchange; or,
-
-    b) Accompany it with a written offer, valid for at least three
-    years, to give any third party, for a charge no more than your
-    cost of physically performing source distribution, a complete
-    machine-readable copy of the corresponding source code, to be
-    distributed under the terms of Sections 1 and 2 above on a medium
-    customarily used for software interchange; or,
-
-    c) Accompany it with the information you received as to the offer
-    to distribute corresponding source code.  (This alternative is
-    allowed only for noncommercial distribution and only if you
-    received the program in object code or executable form with such
-    an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it.  For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable.  However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-

-  4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License.  Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
-  5. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Program or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
-  6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
-  7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-

-  8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-  9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time.  Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation.  If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
-  10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission.  For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this.  Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
-			    NO WARRANTY
-
-  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
-  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
-		     END OF TERMS AND CONDITIONS
-

-	    How to Apply These Terms to Your New Programs
-
-  If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
-  To do so, attach the following notices to the program.  It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the program's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
-    Gnomovision version 69, Copyright (C) year name of author
-    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-    This is free software, and you are welcome to redistribute it
-    under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License.  Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
-  `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
-  <signature of Ty Coon>, 1 April 1989
-  Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs.  If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library.  If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/vcflib/smithwaterman/smithwaterman.cpp b/vcflib/smithwaterman/smithwaterman.cpp
deleted file mode 100644
index 489dc1c..0000000
--- a/vcflib/smithwaterman/smithwaterman.cpp
+++ /dev/null
@@ -1,246 +0,0 @@
-#include <iostream>
-#include <string.h>
-#include <string>
-#include <sstream>
-#include <getopt.h>
-#include <utility>
-#include <vector>
-#include <stdlib.h>
-#include "SmithWatermanGotoh.h"
-#include "BandedSmithWaterman.h"
-
-using namespace std;
-
-void printSummary(void) {
-    cerr << "usage: smithwaterman [options] <reference sequence> <query sequence>" << endl
-         << endl
-         << "options:" << endl 
-         << "    -m, --match-score         the match score (default 10.0)" << endl
-         << "    -n, --mismatch-score      the mismatch score (default -9.0)" << endl
-         << "    -g, --gap-open-penalty    the gap open penalty (default 15.0)" << endl
-	 << "    -z, --entropy-gap-open-penalty  enable entropy scaling of the gap open penalty" << endl
-         << "    -e, --gap-extend-penalty  the gap extend penalty (default 6.66)" << endl
-	 << "    -r, --repeat-gap-extend-penalty  use repeat information when generating gap extension penalties" << endl
-         << "    -b, --bandwidth           bandwidth to use (default 0, or non-banded algorithm)" << endl
-         << "    -p, --print-alignment     print out the alignment" << endl
-         << endl
-         << "When called with literal reference and query sequences, smithwaterman" << endl
-         << "prints the cigar match positional string and the match position for the" << endl
-         << "query sequence against the reference sequence." << endl;
-}
-
-
-int main (int argc, char** argv) {
-
-    int c;
-
-    string reference;
-    string query;
-
-    int bandwidth = 0;
-
-    float matchScore = 10.0f;
-    float mismatchScore = -9.0f;
-    float gapOpenPenalty = 15.0f;
-    float gapExtendPenalty = 6.66f;
-    float entropyGapOpenPenalty = 0.0f;
-    bool useRepeatGapExtendPenalty = false;
-    float repeatGapExtendPenalty = 1.0f;
-    
-    bool print_alignment = false;
-
-    while (true) {
-        static struct option long_options[] =
-        {
-            {"help", no_argument, 0, 'h'},
-            {"match-score",  required_argument, 0, 'm'},
-            {"mismatch-score",  required_argument, 0, 'n'},
-            {"gap-open-penalty",  required_argument, 0, 'g'},
-            {"entropy-gap-open-penalty",  required_argument, 0, 'z'},
-            {"gap-extend-penalty",  required_argument, 0, 'e'},
-            {"repeat-gap-extend-penalty",  required_argument, 0, 'r'},
-            {"print-alignment",  required_argument, 0, 'p'},
-            {"bandwidth", required_argument, 0, 'b'},
-            {0, 0, 0, 0}
-        };
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "hpzm:n:g:r:e:b:r:",
-                         long_options, &option_index);
-
-          if (c == -1)
-            break;
- 
-          switch (c)
-            {
-            case 0:
-            /* If this option set a flag, do nothing else now. */
-            if (long_options[option_index].flag != 0)
-              break;
-            printf ("option %s", long_options[option_index].name);
-            if (optarg)
-              printf (" with arg %s", optarg);
-            printf ("\n");
-            break;
-
-          case 'm':
-            matchScore = atof(optarg);
-            break;
- 
-          case 'n':
-            mismatchScore = atof(optarg);
-            break;
- 
-          case 'g':
-            gapOpenPenalty = atof(optarg);
-            break;
-
-	  case 'z':
- 	    entropyGapOpenPenalty = 1;
-	    break;
- 
-	  case 'r':
-	    useRepeatGapExtendPenalty = true;
-	    repeatGapExtendPenalty = atof(optarg);
-	    break;
- 
-          case 'e':
-            gapExtendPenalty = atof(optarg);
-            break;
-
-          case 'b':
-            bandwidth = atoi(optarg);
-            break;
-
-          case 'p':
-            print_alignment = true;
-            break;
- 
-          case 'h':
-            printSummary();
-            exit(0);
-            break;
- 
-          case '?':
-            /* getopt_long already printed an error message. */
-            printSummary();
-            exit(1);
-            break;
- 
-          default:
-            abort ();
-          }
-      }
-
-    /* Print any remaining command line arguments (not options). */
-    if (optind == argc - 2) {
-        //cerr << "fasta file: " << argv[optind] << endl;
-        reference = string(argv[optind]);
-        ++optind;
-        query = string(argv[optind]);
-    } else {
-        cerr << "please specify a reference and query sequence" << endl
-             << "execute " << argv[0] << " --help for command-line usage" << endl;
-        exit(1);
-    }
-
-	// initialize
-	
-	unsigned int referencePos;
-	string cigar;
-
-	// create a new Smith-Waterman alignment object
-    if (bandwidth > 0) {
-        pair< pair<unsigned int, unsigned int>, pair<unsigned int, unsigned int> > hr;
-        hr.first.first   = 2;
-        hr.first.second  = 18;
-        hr.second.first  = 1;
-        hr.second.second = 17;
-        CBandedSmithWaterman bsw(matchScore, mismatchScore, gapOpenPenalty, gapExtendPenalty, bandwidth);
-        bsw.Align(referencePos, cigar, reference, query, hr);
-    } else {
-        CSmithWatermanGotoh sw(matchScore, mismatchScore, gapOpenPenalty, gapExtendPenalty);
-	if (useRepeatGapExtendPenalty)
-	    sw.EnableRepeatGapExtensionPenalty(repeatGapExtendPenalty);
-	if (entropyGapOpenPenalty > 0)
-	    sw.EnableEntropyGapPenalty(entropyGapOpenPenalty);
-        sw.Align(referencePos, cigar, reference, query);
-    }
-
-    printf("%s %3u\n", cigar.c_str(), referencePos);
-
-    // optionally print out the alignment
-    if (print_alignment) {
-        int alignmentLength = 0;
-        int len;
-        string slen;
-        vector<pair<int, char> > cigarData;
-        for (string::iterator c = cigar.begin(); c != cigar.end(); ++c) {
-            switch (*c) {
-                case 'I':
-                    len = atoi(slen.c_str());
-                    slen.clear();
-                    cigarData.push_back(make_pair(len, *c));
-                    break;
-                case 'D':
-                    len = atoi(slen.c_str());
-                    alignmentLength += len;
-                    slen.clear();
-                    cigarData.push_back(make_pair(len, *c));
-                    break;
-                case 'M':
-                    len = atoi(slen.c_str());
-                    alignmentLength += len;
-                    slen.clear();
-                    cigarData.push_back(make_pair(len, *c));
-                    break;
-                case 'S':
-                    len = atoi(slen.c_str());
-                    slen.clear();
-                    cigarData.push_back(make_pair(len, *c));
-                    break;
-                default:
-                    len = 0;
-                    slen += *c;
-                    break;
-            }
-        }
-
-        string gapped_ref = string(reference).substr(referencePos, alignmentLength);
-        string gapped_query = string(query);
-
-        int refpos = 0;
-        int readpos = 0;
-        for (vector<pair<int, char> >::iterator c = cigarData.begin(); c != cigarData.end(); ++c) {
-            int len = c->first;
-            switch (c->second) {
-                case 'I':
-                    gapped_ref.insert(refpos, string(len, '-'));
-                    readpos += len;
-		    refpos += len;
-                    break;
-                case 'D':
-                    gapped_query.insert(readpos, string(len, '-'));
-                    refpos += len;
-		    readpos += len;
-                    break;
-                case 'M':
-		    readpos += len;
-		    refpos += len;
-		    break;
-                case 'S':
-                    readpos += len;
-		    gapped_ref.insert(refpos, string(len, '*'));
-		    refpos += len;
-                    break;
-                default:
-                    break;
-            }
-        }
-
-        cout << gapped_ref << endl << gapped_query << endl;
-    }
-
-	return 0;
-
-}
diff --git a/vcflib/src/BedReader.h b/vcflib/src/BedReader.h
deleted file mode 100644
index 9deee16..0000000
--- a/vcflib/src/BedReader.h
+++ /dev/null
@@ -1,176 +0,0 @@
-#ifndef BEDREADER_H
-#define BEDREADER_H
-
-#include <iostream>
-#include <fstream>
-#include <string>
-#include <vector>
-#include <deque>
-#include <map>
-#include <iterator>
-#include <algorithm>
-#include "intervaltree/IntervalTree.h"
-#include "split.h"
-
-using namespace std;
-
-string strip(string const& str, char const* separators = " \t") {
-    string::size_type const first = str.find_first_not_of(separators);
-    return (first == string::npos) ? string()
-        : str.substr(first, str.find_last_not_of(separators) - first + 1);
-}
-
-void parseRegion(
-    string& region,
-    string& startSeq,
-    int& startPos,
-    int& stopPos) {
-
-    size_t foundFirstColon = region.find(":");
-
-    // we only have a single string, use the whole sequence as the target
-    if (foundFirstColon == string::npos) {
-        startSeq = region;
-        startPos = 0;
-        stopPos = -1;
-    } else {
-        startSeq = region.substr(0, foundFirstColon);
-        string sep = "..";
-        size_t foundRangeSep = region.find(sep, foundFirstColon);
-        if (foundRangeSep == string::npos) {
-            sep = "-";
-            foundRangeSep = region.find("-", foundFirstColon);
-        }
-        if (foundRangeSep == string::npos) {
-            startPos = atoi(region.substr(foundFirstColon + 1).c_str());
-            // differ from bamtools in this regard, in that we process only
-            // the specified position if a range isn't given
-            stopPos = startPos + 1;
-        } else {
-            startPos = atoi(region.substr(foundFirstColon + 1, foundRangeSep - foundFirstColon).c_str());
-            // if we have range sep specified, but no second number, read to the end of sequence
-            if (foundRangeSep + sep.size() != region.size()) {
-                stopPos = atoi(region.substr(foundRangeSep + sep.size()).c_str()); // end-exclusive, bed-format
-            } else {
-                //stopPos = reference.sequenceLength(startSeq);
-                stopPos = -1;
-            }
-        }
-    }
-}
-
-// stores the posiitional information of a bed target entry
-class BedTarget {
-
-public:
-
-    string seq;  // sequence name
-    int left;    // left position
-    int right;   // right position, adjusted to 0-base
-    string desc; // descriptive information, target name typically
-
-    BedTarget(string s) {
-        parseRegion(s, seq, left, right); 
-    }
-
-    BedTarget(string s, int l, int r, string d = "")
-        : seq(s)
-        , left(l)
-        , right(r)
-        , desc(d)
-    { }
-
-};
-
-
-class BedReader {
-
-    bool _isOpen;
-    ifstream file;
-
-public:
-
-    bool isOpen(void) { return _isOpen; }
-
-    vector<BedTarget> targets;
-    map<string, IntervalTree<BedTarget*> > intervals; // intervals by reference sequence
-
-    vector<BedTarget> entries(void) {
-
-        vector<BedTarget> entries;
-
-        if (!isOpen()) {
-            cerr << "bed targets file is not open" << endl;
-            exit(1);
-        }
-
-        string line;
-        while (std::getline(file, line)) {
-            vector<string> fields = split(line, " \t");
-            BedTarget entry(strip(fields[0]),
-                            atoi(strip(fields[1]).c_str()),
-                            atoi(strip(fields[2]).c_str()),
-                            (fields.size() >= 4) ? strip(fields[3]) : "");
-            entries.push_back(entry);
-        }
-
-        return entries;
-
-    }
-
-    vector<BedTarget*> targetsContained(BedTarget& target) {
-        vector<Interval<BedTarget*> > results;
-        intervals[target.seq].findContained(target.left, target.right, results);
-        vector<BedTarget*> contained;
-        for (vector<Interval<BedTarget*> >::iterator r = results.begin(); r != results.end(); ++r) {
-            contained.push_back(r->value);
-        }
-        return contained;
-    }
-
-    vector<BedTarget*> targetsOverlapping(BedTarget& target) {
-        vector<Interval<BedTarget*> > results;
-        intervals[target.seq].findOverlapping(target.left, target.right, results);
-        vector<BedTarget*> overlapping;
-        for (vector<Interval<BedTarget*> >::iterator r = results.begin(); r != results.end(); ++r) {
-            overlapping.push_back(r->value);
-        }
-        return overlapping;
-    }
-
-BedReader(void)
-	: _isOpen(false)
-    { }
-
-BedReader(string& fname)
-	: _isOpen(false) {
-        open(fname);
-    }
-
-    void addTargets(vector<BedTarget>& targets) {
-        map<string, vector<Interval<BedTarget*> > > intervalsBySeq;
-        for (vector<BedTarget>::iterator t = targets.begin(); t != targets.end(); ++t) {
-            intervalsBySeq[t->seq].push_back(Interval<BedTarget*>(1 + t->left, t->right, &*t));
-        }
-        for (map<string, vector<Interval<BedTarget*> > >::iterator s = intervalsBySeq.begin(); s != intervalsBySeq.end(); ++s) {
-            intervals[s->first] = IntervalTree<BedTarget*>(s->second);
-        }
-    }
-
-    void open(const string& fname) {
-        file.open(fname.c_str());
-        _isOpen = true;
-        targets = entries();
-        map<string, vector<Interval<BedTarget*> > > intervalsBySeq;
-        for (vector<BedTarget>::iterator t = targets.begin(); t != targets.end(); ++t) {
-            intervalsBySeq[t->seq].push_back(Interval<BedTarget*>(1 + t->left, t->right, &*t));
-        }
-        for (map<string, vector<Interval<BedTarget*> > >::iterator s = intervalsBySeq.begin(); s != intervalsBySeq.end(); ++s) {
-            intervals[s->first] = IntervalTree<BedTarget*>(s->second);
-        }
-    }
-
-};
-
-#endif
-
diff --git a/vcflib/src/Variant.cpp b/vcflib/src/Variant.cpp
deleted file mode 100644
index 850c63d..0000000
--- a/vcflib/src/Variant.cpp
+++ /dev/null
@@ -1,2199 +0,0 @@
-#include "Variant.h"
-
-namespace vcf {
-
-void Variant::parse(string& line, bool parseSamples) {
-
-    // clean up potentially variable data structures
-    info.clear();
-    infoFlags.clear();
-    format.clear();
-    alt.clear();
-    alleles.clear();
-
-    // #CHROM  POS     ID      REF     ALT     QUAL    FILTER  INFO    FORMAT [SAMPLE1 .. SAMPLEN]
-    vector<string> fields = split(line, '\t');
-    if (fields.size() < 7) {
-        cerr << "broken VCF record (less than 7 fields)" << endl
-             << line << endl;
-        exit(1);
-    }
-
-    sequenceName = fields.at(0);
-    char* end; // dummy variable for strtoll
-    position = strtoll(fields.at(1).c_str(), &end, 10);
-    id = fields.at(2);
-    ref = fields.at(3);
-    alt = split(fields.at(4), ","); // a comma-separated list of alternate alleles
-
-    // make a list of all (ref + alts) alleles, allele[0] = ref, alleles[1:] = alts
-    // add the ref allele ([0]), resize for the alt alleles, and then add the alt alleles
-    alleles.push_back(ref);
-    alleles.resize(alt.size()+1);
-    std::copy(alt.begin(), alt.end(), alleles.begin()+1);
-
-    // set up reverse lookup of allele index
-    altAlleleIndexes.clear();
-    int n = 0;
-    for (vector<string>::iterator a = alt.begin();
-            a != alt.end(); ++a, ++n) {
-        altAlleleIndexes[*a] = n;
-    }
-
-    convert(fields.at(5), quality);
-    filter = fields.at(6);
-    if (fields.size() > 7) {
-        vector<string> infofields = split(fields.at(7), ';');
-        for (vector<string>::iterator f = infofields.begin(); f != infofields.end(); ++f) {
-            if (*f == ".") {
-                continue;
-            }
-            vector<string> kv = split(*f, '=');
-            if (kv.size() == 2) {
-                split(kv.at(1), ',', info[kv.at(0)]);
-            } else if (kv.size() == 1) {
-                infoFlags[kv.at(0)] = true;
-            }
-        }
-    }
-    // check if we have samples specified
-    // and that we are supposed to parse them
-    if (parseSamples && fields.size() > 8) {
-        format = split(fields.at(8), ':');
-        // if the format changed, we have to rebuild the samples
-        if (fields.at(8) != lastFormat) {
-            samples.clear();
-            lastFormat = fields.at(8);
-        }
-        vector<string>::iterator sampleName = sampleNames.begin();
-        vector<string>::iterator sample = fields.begin() + 9;
-        for (; sample != fields.end() && sampleName != sampleNames.end(); ++sample, ++sampleName) {
-            string& name = *sampleName;
-            if (*sample == "." || *sample == "./.") {
-                samples.erase(name);
-                continue;
-            }
-            vector<string> samplefields = split(*sample, ':');
-            vector<string>::iterator i = samplefields.begin();
-            if (samplefields.size() != format.size()) {
-                // ignore this case... malformed (or 'null') sample specs are caught above
-                // /*
-                // cerr << "inconsistent number of fields for sample " << name << endl
-                //      << "format is " << join(format, ":") << endl
-                //      << "sample is " << *sample << endl;
-                // exit(1);
-                // *
-            }
-            else {
-                for (vector<string>::iterator f = format.begin(); f != format.end(); ++f) {
-                    samples[name][*f] = split(*i, ','); ++i;
-                }
-            }
-        }
-        if (sampleName != sampleNames.end()) {
-            cerr << "error: more sample names in header than sample fields" << endl;
-            cerr << "samples: " << join(sampleNames, " ") << endl;
-            cerr << "line: " << line << endl;
-            exit(1);
-        }
-        if (sample != fields.end()) {
-            cerr << "error: more sample fields than samples listed in header" << endl;
-            cerr << "samples: " << join(sampleNames, " ") << endl;
-            cerr << "line: " << line << endl;
-            exit(1);
-        }
-    } else if (!parseSamples) {
-        originalLine = line;
-    }
-
-    //return true; // we should be catching exceptions...
-}
-
-void Variant::setVariantCallFile(VariantCallFile& v) {
-    sampleNames = v.sampleNames;
-    outputSampleNames = v.sampleNames;
-    vcf = &v;
-}
-
-void Variant::setVariantCallFile(VariantCallFile* v) {
-    sampleNames = v->sampleNames;
-    outputSampleNames = v->sampleNames;
-    vcf = v;
-}
-
-ostream& operator<<(ostream& out, VariantFieldType type) {
-    switch (type) {
-        case FIELD_INTEGER:
-            out << "integer";
-            break;
-        case FIELD_FLOAT:
-            out << "float";
-            break;
-        case FIELD_BOOL:
-            out << "bool";
-            break;
-        case FIELD_STRING:
-            out << "string";
-            break;
-        default:
-            out << "unknown";
-            break;
-    }
-    return out;
-}
-
-VariantFieldType typeStrToVariantFieldType(string& typeStr) {
-    if (typeStr == "Integer") {
-        return FIELD_INTEGER;
-    } else if (typeStr == "Float") {
-        return FIELD_FLOAT;
-    } else if (typeStr == "Flag") {
-        return FIELD_BOOL;
-    } else if (typeStr == "String") {
-        return FIELD_STRING;
-    } else {
-        return FIELD_UNKNOWN;
-    }
-}
-
-VariantFieldType Variant::infoType(string& key) {
-    map<string, VariantFieldType>::iterator s = vcf->infoTypes.find(key);
-    if (s == vcf->infoTypes.end()) {
-        if (key == "QUAL") { // hack to use QUAL as an "info" field
-            return FIELD_INTEGER;
-        }
-        cerr << "no info field " << key << endl;
-        exit(1);
-    } else {
-        return s->second;
-    }
-}
-
-    VariantFieldType Variant::formatType(string& key) {
-        map<string, VariantFieldType>::iterator s = vcf->formatTypes.find(key);
-        if (s == vcf->formatTypes.end()) {
-            cerr << "no format field " << key << endl;
-            exit(1);
-        } else {
-            return s->second;
-        }
-    }
-
-    bool Variant::getInfoValueBool(string& key, int index) {
-        map<string, VariantFieldType>::iterator s = vcf->infoTypes.find(key);
-        if (s == vcf->infoTypes.end()) {
-            cerr << "no info field " << key << endl;
-            exit(1);
-        } else {
-            int count = vcf->infoCounts[key];
-            // XXX TODO, fix for Genotype variants...
-            if (count != ALLELE_NUMBER) {
-                index = 0;
-            }
-            if (index == INDEX_NONE) {
-                if (count != 1) {
-                    cerr << "no field index supplied and field count != 1" << endl;
-                    exit(1);
-                } else {
-                    index = 0;
-                }
-            }
-            VariantFieldType type = s->second;
-            if (type == FIELD_BOOL) {
-                map<string, bool>::iterator b = infoFlags.find(key);
-                if (b == infoFlags.end())
-                    return false;
-                else
-                    return true;
-            } else {
-                cerr << "not flag type " << key << endl;
-            }
-        }
-    }
-
-    string Variant::getInfoValueString(string& key, int index) {
-        map<string, VariantFieldType>::iterator s = vcf->infoTypes.find(key);
-        if (s == vcf->infoTypes.end()) {
-            cerr << "no info field " << key << endl;
-            exit(1);
-        } else {
-            int count = vcf->infoCounts[key];
-            // XXX TODO, fix for Genotype variants...
-            if (count != ALLELE_NUMBER) {
-                index = 0;
-            }
-            if (index == INDEX_NONE) {
-                if (count != 1) {
-                    cerr << "no field index supplied and field count != 1" << endl;
-                    exit(1);
-                } else {
-                    index = 0;
-                }
-            }
-            VariantFieldType type = s->second;
-            if (type == FIELD_STRING) {
-                map<string, vector<string> >::iterator b = info.find(key);
-                if (b == info.end())
-                    return "";
-                return b->second.at(index);
-            } else {
-                cerr << "not string type " << key << endl;
-                return "";
-            }
-        }
-    }
-
-    double Variant::getInfoValueFloat(string& key, int index) {
-        map<string, VariantFieldType>::iterator s = vcf->infoTypes.find(key);
-        if (s == vcf->infoTypes.end()) {
-            if (key == "QUAL") {
-                return quality;
-            }
-            cerr << "no info field " << key << endl;
-            exit(1);
-        } else {
-            int count = vcf->infoCounts[key];
-            // XXX TODO, fix for Genotype variants...
-            if (count != ALLELE_NUMBER) {
-                index = 0;
-            }
-            if (index == INDEX_NONE) {
-                if (count != 1) {
-                    cerr << "no field index supplied and field count != 1" << endl;
-                    exit(1);
-                } else {
-                    index = 0;
-                }
-            }
-            VariantFieldType type = s->second;
-            if (type == FIELD_FLOAT || type == FIELD_INTEGER) {
-                map<string, vector<string> >::iterator b = info.find(key);
-                if (b == info.end())
-                    return false;
-                double r;
-                if (!convert(b->second.at(index), r)) {
-                    cerr << "could not convert field " << key << "=" << b->second.at(index) << " to " << type << endl;
-                    exit(1);
-                }
-                return r;
-            } else {
-                cerr << "unsupported type for variant record " << type << endl;
-                exit(1);
-            }
-        }
-    }
-
-    int Variant::getNumSamples(void) {
-        return sampleNames.size();
-    }
-
-    int Variant::getNumValidGenotypes(void) {
-        int valid_genotypes = 0;
-        map<string, map<string, vector<string> > >::const_iterator s     = samples.begin();
-        map<string, map<string, vector<string> > >::const_iterator sEnd  = samples.end();
-        for (; s != sEnd; ++s) {
-            map<string, vector<string> > sample_info = s->second;
-            if (sample_info["GT"].front() != "./.") {
-                valid_genotypes++;
-            }
-        }
-        return valid_genotypes;
-    }
-
-    bool Variant::getSampleValueBool(string& key, string& sample, int index) {
-        map<string, VariantFieldType>::iterator s = vcf->formatTypes.find(key);
-        if (s == vcf->infoTypes.end()) {
-            cerr << "no info field " << key << endl;
-            exit(1);
-        } else {
-            int count = vcf->formatCounts[key];
-            // XXX TODO, fix for Genotype variants...
-            if (count != ALLELE_NUMBER) {
-                index = 0;
-            }
-            if (index == INDEX_NONE) {
-                if (count != 1) {
-                    cerr << "no field index supplied and field count != 1" << endl;
-                    exit(1);
-                } else {
-                    index = 0;
-                }
-            }
-            VariantFieldType type = s->second;
-            map<string, vector<string> >& sampleData = samples[sample];
-            if (type == FIELD_BOOL) {
-                map<string, vector<string> >::iterator b = sampleData.find(key);
-                if (b == sampleData.end())
-                    return false;
-                else
-                    return true;
-            } else {
-                cerr << "not bool type " << key << endl;
-            }
-        }
-    }
-
-    string Variant::getSampleValueString(string& key, string& sample, int index) {
-        map<string, VariantFieldType>::iterator s = vcf->formatTypes.find(key);
-        if (s == vcf->infoTypes.end()) {
-            cerr << "no info field " << key << endl;
-            exit(1);
-        } else {
-            int count = vcf->formatCounts[key];
-            // XXX TODO, fix for Genotype variants...
-            if (count != ALLELE_NUMBER) {
-                index = 0;
-            }
-            if (index == INDEX_NONE) {
-                if (count != 1) {
-                    cerr << "no field index supplied and field count != 1" << endl;
-                    exit(1);
-                } else {
-                    index = 0;
-                }
-            }
-            VariantFieldType type = s->second;
-            map<string, vector<string> >& sampleData = samples[sample];
-            if (type == FIELD_STRING) {
-                map<string, vector<string> >::iterator b = sampleData.find(key);
-                if (b == sampleData.end()) {
-                    return "";
-                } else {
-                    return b->second.at(index);
-                }
-            } else {
-                cerr << "not string type " << key << endl;
-            }
-        }
-    }
-
-    double Variant::getSampleValueFloat(string& key, string& sample, int index) {
-        map<string, VariantFieldType>::iterator s = vcf->formatTypes.find(key);
-        if (s == vcf->infoTypes.end()) {
-            cerr << "no info field " << key << endl;
-            exit(1);
-        } else {
-            // XXX TODO wrap this with a function call
-            int count = vcf->formatCounts[key];
-            // XXX TODO, fix for Genotype variants...
-            if (count != ALLELE_NUMBER) {
-                index = 0;
-            }
-            if (index == INDEX_NONE) {
-                if (count != 1) {
-                    cerr << "no field index supplied and field count != 1" << endl;
-                    exit(1);
-                } else {
-                    index = 0;
-                }
-            }
-            VariantFieldType type = s->second;
-            map<string, vector<string> >& sampleData = samples[sample];
-            if (type == FIELD_FLOAT || type == FIELD_INTEGER) {
-                map<string, vector<string> >::iterator b = sampleData.find(key);
-                if (b == sampleData.end())
-                    return false;
-                double r;
-                if (!convert(b->second.at(index), r)) {
-                    cerr << "could not convert field " << key << "=" << b->second.at(index) << " to " << type << endl;
-                    exit(1);
-                }
-                return r;
-            } else {
-                cerr << "unsupported type for sample " << type << endl;
-            }
-        }
-    }
-
-    bool Variant::getValueBool(string& key, string& sample, int index) {
-        if (sample.empty()) { // an empty sample name means
-            return getInfoValueBool(key, index);
-        } else {
-            return getSampleValueBool(key, sample, index);
-        }
-    }
-
-    double Variant::getValueFloat(string& key, string& sample, int index) {
-        if (sample.empty()) { // an empty sample name means
-            return getInfoValueFloat(key, index);
-        } else {
-            return getSampleValueFloat(key, sample, index);
-        }
-    }
-
-    string Variant::getValueString(string& key, string& sample, int index) {
-        if (sample.empty()) { // an empty sample name means
-            return getInfoValueString(key, index);
-        } else {
-            return getSampleValueString(key, sample, index);
-        }
-    }
-
-    int Variant::getAltAlleleIndex(string& allele) {
-        map<string, int>::iterator f = altAlleleIndexes.find(allele);
-        if (f == altAlleleIndexes.end()) {
-            cerr << "no such allele \'" << allele << "\' in record " << sequenceName << ":" << position << endl;
-            exit(1);
-        } else {
-            return f->second;
-        }
-    }
-
-    void Variant::addFilter(string& tag) {
-        if (filter == "" || filter == ".")
-            filter = tag;
-        else
-            filter += "," + tag;
-    }
-
-    void Variant::addFormatField(string& key) {
-        bool hasTag = false;
-        for (vector<string>::iterator t = format.begin(); t != format.end(); ++t) {
-            if (*t == key) {
-                hasTag = true;
-                break;
-            }
-        }
-        if (!hasTag) {
-            format.push_back(key);
-        }
-    }
-
-    void Variant::printAlt(ostream& out) {
-        for (vector<string>::iterator i = alt.begin(); i != alt.end(); ++i) {
-            out << *i;
-            // add a comma for all but the last alternate allele
-            if (i != (alt.end() - 1)) out << ",";
-        }
-    }
-
-    void Variant::printAlleles(ostream& out) {
-        for (vector<string>::iterator i = alleles.begin(); i != alleles.end(); ++i) {
-            out << *i;
-            // add a comma for all but the last alternate allele
-            if (i != (alleles.end() - 1)) out << ",";
-        }
-    }
-
-    ostream& operator<<(ostream& out, Variant& var) {
-        // ensure there are no empty fields
-        if (var.sequenceName.empty()) var.sequenceName = ".";
-        if (var.id.empty()) var.id = ".";
-        if (var.ref.empty()) var.ref = ".";
-        if (var.alt.empty()) var.alt.push_back(".");
-        if (var.filter.empty()) var.filter = ".";
-
-        out << var.sequenceName << "\t"
-            << var.position << "\t"
-            << var.id << "\t"
-            << var.ref << "\t";
-        // report the list of alternate alleles.
-        var.printAlt(out);
-        out << "\t"
-            << var.quality << "\t"
-            << var.filter << "\t";
-        if (var.info.empty() && var.infoFlags.empty()) {
-            out << ".";
-        } else {
-            for (map<string, vector<string> >::iterator i = var.info.begin(); i != var.info.end(); ++i) {
-                if (!i->second.empty()) {
-                    out << ((i == var.info.begin()) ? "" : ";") << i->first << "=" << join(i->second, ",");
-                }
-            }
-            for (map<string, bool>::iterator i = var.infoFlags.begin(); i != var.infoFlags.end(); ++i) {
-                if (i == var.infoFlags.end()) {
-                    out << "";
-                } else if (i == var.infoFlags.begin() && var.info.empty()) {
-                    out << "";
-                } else {
-                    out << ";";
-                }
-                out << i->first;
-            }
-        }
-        if (!var.format.empty()) {
-            out << "\t";
-            for (vector<string>::iterator f = var.format.begin(); f != var.format.end(); ++f) {
-                out << ((f == var.format.begin()) ? "" : ":") << *f;
-            }
-            for (vector<string>::iterator s = var.outputSampleNames.begin(); s != var.outputSampleNames.end(); ++s) {
-                out << "\t";
-                map<string, map<string, vector<string> > >::iterator sampleItr = var.samples.find(*s);
-                if (sampleItr == var.samples.end()) {
-                    out << ".";
-                } else {
-                    map<string, vector<string> >& sample = sampleItr->second;
-                    if (sample.size() == 0) {
-                        out << ".";
-                    } else {
-                        for (vector<string>::iterator f = var.format.begin(); f != var.format.end(); ++f) {
-                            map<string, vector<string> >::iterator g = sample.find(*f);
-                            out << ((f == var.format.begin()) ? "" : ":");
-                            if (g != sample.end() && !g->second.empty()) {
-                                out << join(g->second, ",");
-                            } else {
-                                out << ".";
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        return out;
-    }
-
-    void Variant::setOutputSampleNames(vector<string>& samplesToOutput) {
-        outputSampleNames = samplesToOutput;
-    }
-
-
-// shunting yard algorithm
-    void infixToPrefix(queue<RuleToken> tokens, queue<RuleToken>& prefixtokens) {
-        stack<RuleToken> ops;
-        while (!tokens.empty()) {
-            RuleToken& token = tokens.front();
-            if (isOperator(token)) {
-                //cerr << "found operator " << token.value << endl;
-                while (ops.size() > 0 && isOperator(ops.top())
-                       && (   (isLeftAssociative(token)  && priority(token) <= priority(ops.top()))
-                              || (isRightAssociative(token) && priority(token) <  priority(ops.top())))) {
-                    prefixtokens.push(ops.top());
-                    ops.pop();
-                }
-                ops.push(token);
-            } else if (isLeftParenthesis(token)) {
-                //cerr << "found paran " << token.value << endl;
-                ops.push(token);
-            } else if (isRightParenthesis(token)) {
-                //cerr << "found paran " << token.value << endl;
-                while (ops.size() > 0 && !isLeftParenthesis(ops.top())) {
-                    prefixtokens.push(ops.top());
-                    ops.pop();
-                }
-                if (ops.size() == 0) {
-                    cerr << "error: mismatched parentheses" << endl;
-                    exit(1);
-                }
-                if (isLeftParenthesis(ops.top())) {
-                    ops.pop();
-                }
-            } else {
-                //cerr << "found operand " << token.value << endl;
-                prefixtokens.push(token);
-            }
-            tokens.pop();
-        }
-        while (ops.size() > 0) {
-            if (isRightParenthesis(ops.top()) || isLeftParenthesis(ops.top())) {
-                cerr << "error: mismatched parentheses" << endl;
-                exit(1);
-            }
-            prefixtokens.push(ops.top());
-            ops.pop();
-        }
-    }
-
-    RuleToken::RuleToken(string tokenstr, map<string, VariantFieldType>& variables) {
-        isVariable = false;
-        if (tokenstr == "!") {
-            type = RuleToken::NOT_OPERATOR;
-        } else if (tokenstr == "&") {
-            type = RuleToken::AND_OPERATOR;
-        } else if (tokenstr == "|") {
-            type = RuleToken::OR_OPERATOR;
-        } else if (tokenstr == "+") {
-            type = RuleToken::ADD_OPERATOR;
-        } else if (tokenstr == "-") {
-            type = RuleToken::SUBTRACT_OPERATOR;
-        } else if (tokenstr == "*") {
-            type = RuleToken::MULTIPLY_OPERATOR;
-        } else if (tokenstr == "/") {
-            type = RuleToken::DIVIDE_OPERATOR;
-        } else if (tokenstr == "=") {
-            type = RuleToken::EQUAL_OPERATOR;
-        } else if (tokenstr == ">") {
-            type = RuleToken::GREATER_THAN_OPERATOR;
-        } else if (tokenstr == "<") {
-            type = RuleToken::LESS_THAN_OPERATOR;
-        } else if (tokenstr == "(") {
-            type = RuleToken::LEFT_PARENTHESIS;
-        } else if (tokenstr == ")") {
-            type = RuleToken::RIGHT_PARENTHESIS;
-        } else { // operand
-            type = RuleToken::OPERAND;
-            if (variables.find(tokenstr) == variables.end()) {
-                if (convert(tokenstr, number)) {
-                    type = RuleToken::NUMBER;
-                } else if (tokenstr == "QUAL") {
-                    isVariable = true;
-                } else {
-                    type = RuleToken::STRING_VARIABLE;
-                }
-            } else {
-                isVariable = true;
-            }
-        }
-        value = tokenstr;
-    }
-
-
-    void tokenizeFilterSpec(string& filterspec, queue<RuleToken>& tokens, map<string, VariantFieldType>& variables) {
-        string lastToken = "";
-        bool inToken = false;
-        for (unsigned int i = 0; i <  filterspec.size(); ++i) {
-            char c = filterspec.at(i);
-            if (c == ' ' || c == '\n') {
-                inToken = false;
-                if (!inToken && lastToken.size() > 0) {
-                    tokens.push(RuleToken(lastToken, variables));
-                    lastToken = "";
-                }
-            } else if (!inToken && (isOperatorChar(c) || isParanChar(c))) {
-                inToken = false;
-                if (lastToken.size() > 0) {
-                    tokens.push(RuleToken(lastToken, variables));
-                    lastToken = "";
-                }
-                tokens.push(RuleToken(filterspec.substr(i,1), variables));
-            } else {
-                inToken = true;
-                lastToken += c;
-            }
-        }
-        // get the last token
-        if (inToken) {
-            tokens.push(RuleToken(lastToken, variables));
-        }
-    }
-
-// class which evaluates filter expressions
-// allow filters to be defined using boolean infix expressions e.g.:
-//
-// "GQ > 10 & (DP < 3 | DP > 5) & SAMPLE = NA12878"
-// or
-// "GT = 1/1 | GT = 0/0"
-//
-// on initialization, tokenizes the input sequence, and converts it from infix to postfix
-// on call to 
-//
-
-
-    VariantFilter::VariantFilter(string filterspec, VariantFilterType filtertype, map<string, VariantFieldType>& variables) {
-        type = filtertype;
-        spec = filterspec;
-        tokenizeFilterSpec(filterspec, tokens, variables);
-        infixToPrefix(tokens, rules);
-        /*while (!rules.empty()) {
-          cerr << " " << rules.front().value << ((isNumeric(rules.front())) ? "f" : "");
-          rules.pop();
-          }
-        */
-        //cerr << endl;
-        //cerr << join(" ", tokens) << endl;
-    }
-
-// all alts pass
-    bool VariantFilter::passes(Variant& var, string& sample) {
-        for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-            string& allele = *a;
-            if (!passes(var, sample, allele)) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    bool VariantFilter::passes(Variant& var, string& sample, string& allele) {
-        // to evaluate a rpn boolean queue with embedded numbers and variables
-        // make a result stack, use float to allow comparison of floating point
-        // numbers, booleans, and integers
-        stack<RuleToken> results;
-        queue<RuleToken> rulesCopy = rules; // copy
-
-        int index;
-        if (allele.empty()) {
-            index = 0; // apply to the whole record
-        } else {
-            // apply to a specific allele
-            index = var.getAltAlleleIndex(allele);
-        }
-
-        while (!rulesCopy.empty()) {
-            RuleToken token = rulesCopy.front();
-            rulesCopy.pop();
-        // pop operands from the front of the queue and push them onto the stack
-        if (isOperand(token)) {
-            //cout << "is operand: " << token.value << endl;
-            // if the token is variable, i.e. not evaluated in this context, we
-            // must evaluate it before pushing it onto the stack
-            if (token.isVariable) {
-                //cout << "is variable" << endl;
-                // look up the variable using the Variant, depending on our filter type
-                //cout << "token.value " << token.value << endl;
-                VariantFieldType vtype;
-                if (sample.empty()) { // means we are record-specific
-                    vtype = var.infoType(token.value);
-                } else {
-                    vtype = var.formatType(token.value);
-                    //cout << "type = " << type << endl;
-                }
-                //cout << "type: " << type << endl;
-
-                if (vtype == FIELD_INTEGER || vtype == FIELD_FLOAT) {
-                    token.type = RuleToken::NUMERIC_VARIABLE;
-                    token.number = var.getValueFloat(token.value, sample, index);
-                    //cerr << "number: " << token.number << endl;
-                } else if (vtype == FIELD_BOOL) {
-                    token.type = RuleToken::BOOLEAN_VARIABLE;
-                    token.state = var.getValueBool(token.value, sample, index);
-                    //cerr << "state: " << token.state << endl;
-                } else if (vtype == FIELD_STRING) {
-                    //cout << "token.value = " << token.value << endl;
-                    token.type = RuleToken::STRING_VARIABLE;
-                    token.str = var.getValueString(token.value, sample, index);
-                } else if (isString(token)) {
-                    token.type = RuleToken::STRING_VARIABLE;
-                    token.str = var.getValueString(token.value, sample, index);
-                    //cerr << "string: " << token.str << endl;
-                }
-            } else {
-                double f;
-                string s;
-                //cerr << "parsing operand" << endl;
-                if (convert(token.value, f)) {
-                    token.type = RuleToken::NUMERIC_VARIABLE;
-                    token.number = f;
-                    //cerr << "number: " << token.number << endl;
-                } else if (convert(token.value, s)) {
-                    token.type = RuleToken::STRING_VARIABLE;
-                    token.str = s;
-                    //cerr << "string: " << token.str << endl;
-                } else {
-                    cerr << "could not parse non-variable operand " << token.value << endl;
-                    exit(1);
-                }
-            }
-            results.push(token);
-        } 
-        // apply operators to the first n elements on the stack and push the result back onto the stack
-        else if (isOperator(token)) {
-            //cerr << "is operator: " << token.value << endl;
-            RuleToken a, b, r;
-            // is it a not-operator?
-            switch (token.type) {
-                case ( RuleToken::NOT_OPERATOR ):
-                    a = results.top();
-                    results.pop();
-                    if (!isBoolean(a)) {
-                        cerr << "cannot negate a non-boolean" << endl;
-                    } else {
-                        a.state = !a.state;
-                        results.push(a);
-                    }
-                    break;
-
-                case ( RuleToken::EQUAL_OPERATOR ):
-                    a = results.top(); results.pop();
-                    b = results.top(); results.pop();
-                    if (a.type == b.type) {
-                        switch (a.type) {
-                            case (RuleToken::STRING_VARIABLE):
-                                r.state = (a.str == b.str);
-                                break;
-                            case (RuleToken::NUMERIC_VARIABLE):
-                                r.state = (a.number == b.number);
-                                break;
-                            case (RuleToken::BOOLEAN_VARIABLE):
-                                r.state = (a.state == b.state);
-                                break;
-                            default:
-                                cerr << "should not get here" << endl; exit(1);
-                                break;
-                        }
-                    } else if (a.type == RuleToken::STRING_VARIABLE && b.type == RuleToken::NUMERIC_VARIABLE) {
-                        r.state = (convert(b.number) == a.str);
-                    } else if (b.type == RuleToken::STRING_VARIABLE && a.type == RuleToken::NUMERIC_VARIABLE) {
-                        r.state = (convert(a.number) == b.str);
-                    }
-                    results.push(r);
-                    break;
-
-                case ( RuleToken::GREATER_THAN_OPERATOR ):
-                    a = results.top(); results.pop();
-                    b = results.top(); results.pop();
-                    if (a.type == b.type && a.type == RuleToken::NUMERIC_VARIABLE) {
-                        r.state = (b.number > a.number);
-                    } else {
-                        cerr << "cannot compare (>) objects of dissimilar types" << endl;
-                        cerr << a.type << " " << b.type << endl;
-                        exit(1);
-                    }
-                    results.push(r);
-                    break;
-
-                case ( RuleToken::LESS_THAN_OPERATOR ):
-                    a = results.top(); results.pop();
-                    b = results.top(); results.pop();
-                    if (a.type == b.type && a.type == RuleToken::NUMERIC_VARIABLE) {
-                        r.state = (b.number < a.number);
-                    } else {
-                        cerr << "cannot compare (<) objects of dissimilar types" << endl;
-                        cerr << a.type << " " << b.type << endl;
-                        exit(1);
-                    }
-                    results.push(r);
-                    break;
-
-                case ( RuleToken::ADD_OPERATOR ):
-                    a = results.top(); results.pop();
-                    b = results.top(); results.pop();
-                    if (a.type == b.type && a.type == RuleToken::NUMERIC_VARIABLE) {
-                        r.number = (b.number + a.number);
-                        r.type = RuleToken::NUMERIC_VARIABLE;
-                    } else {
-                        cerr << "cannot add objects of dissimilar types" << endl;
-                        cerr << a.type << " " << b.type << endl;
-                        exit(1);
-                    }
-                    results.push(r);
-                    break;
-
-                case ( RuleToken::SUBTRACT_OPERATOR ):
-                    a = results.top(); results.pop();
-                    b = results.top(); results.pop();
-                    if (a.type == b.type && a.type == RuleToken::NUMERIC_VARIABLE) {
-                        r.number = (b.number - a.number);
-                        r.type = RuleToken::NUMERIC_VARIABLE;
-                    } else {
-                        cerr << "cannot subtract objects of dissimilar types" << endl;
-                        cerr << a.type << " " << b.type << endl;
-                        exit(1);
-                    }
-                    results.push(r);
-                    break;
-
-                case ( RuleToken::MULTIPLY_OPERATOR ):
-                    a = results.top(); results.pop();
-                    b = results.top(); results.pop();
-                    if (a.type == b.type && a.type == RuleToken::NUMERIC_VARIABLE) {
-                        r.number = (b.number * a.number);
-                        r.type = RuleToken::NUMERIC_VARIABLE;
-                    } else {
-                        cerr << "cannot multiply objects of dissimilar types" << endl;
-                        cerr << a.type << " " << b.type << endl;
-                        exit(1);
-                    }
-                    results.push(r);
-                    break;
-
-                case ( RuleToken::DIVIDE_OPERATOR):
-                    a = results.top(); results.pop();
-                    b = results.top(); results.pop();
-                    if (a.type == b.type && a.type == RuleToken::NUMERIC_VARIABLE) {
-                        r.number = (b.number / a.number);
-                        r.type = RuleToken::NUMERIC_VARIABLE;
-                    } else {
-                        cerr << "cannot divide objects of dissimilar types" << endl;
-                        cerr << a.type << " " << b.type << endl;
-                        exit(1);
-                    }
-                    results.push(r);
-                    break;
-
-                case ( RuleToken::AND_OPERATOR ):
-                case ( RuleToken::OR_OPERATOR ):
-                    a = results.top(); results.pop();
-                    b = results.top(); results.pop();
-                    if (a.type == b.type && a.type == RuleToken::BOOLEAN_VARIABLE) {
-                        if (token.type == RuleToken::AND_OPERATOR) {
-                            r.state = (a.state && b.state);
-                        } else {
-                            r.state = (a.state || b.state);
-                        }
-                    } else {
-                        cerr << "cannot compare (& or |) objects of dissimilar types" << endl;
-                        exit(1);
-                    }
-                    results.push(r);
-                    break;
-                default:
-                    cerr << "should not get here!" << endl; exit(1);
-                    break;
-            }
-        }
-    }
-    // at the end you should have only one value on the stack, return it as a boolean
-    if (results.size() == 1) {
-        if (isBoolean(results.top())) {
-            return results.top().state;
-        } else {
-            cerr << "error, non-boolean value left on stack" << endl;
-            //cerr << results.top().value << endl;
-            exit(1);
-        }
-    } else if (results.size() > 1) {
-        cerr << "more than one value left on results stack!" << endl;
-        while (!results.empty()) {
-            cerr << results.top().value << endl;
-            results.pop();
-        }
-        exit(1);
-    } else {
-        cerr << "results stack empty" << endl;
-        exit(1);
-    }
-}
-
-void VariantFilter::removeFilteredGenotypes(Variant& var) {
-
-    for (vector<string>::iterator s = var.sampleNames.begin(); s != var.sampleNames.end(); ++s) {
-        string& name = *s;
-        if (!passes(var, name)) {
-            var.samples.erase(name);
-        }
-    }
-}
-
-/*
-bool VariantCallFile::openVCF(string& filename) {
-    file.open(filename.c_str(), ifstream::in);
-    if (!file.is_open()) {
-        cerr << "could not open " << filename << endl;
-        return false;
-    } else {
-        return parseHeader();
-    }
-}
-
-bool VariantCallFile::openVCF(ifstream& stream) {
-    file = stream;
-    if (!file.is_open()) {
-        cerr << "provided file is not open" << endl;
-        return false;
-    } else {
-        return parseHeader();
-    }
-}
-*/
-
-void VariantCallFile::updateSamples(vector<string>& newSamples) {
-    sampleNames = newSamples;
-    // regenerate the last line of the header
-    vector<string> headerLines = split(header, '\n');
-    vector<string> colnames = split(headerLines.at(headerLines.size() - 1), '\t'); // get the last, update the samples
-    vector<string> newcolnames;
-    newcolnames.resize(9 + sampleNames.size());
-    copy(colnames.begin(), colnames.begin() + 9, newcolnames.begin());
-    copy(sampleNames.begin(), sampleNames.end(), newcolnames.begin() + 9);
-    headerLines.at(headerLines.size() - 1) = join(newcolnames, "\t");
-    header = join(headerLines, "\n");
-}
-
-// non-destructive version of above
-string VariantCallFile::headerWithSampleNames(vector<string>& newSamples) {
-    // regenerate the last line of the header
-    if (newSamples.empty()) return header;
-    vector<string> headerLines = split(header, '\n');
-    vector<string> colnames = split(headerLines.at(headerLines.size() - 1), '\t'); // get the last, update the samples
-    vector<string> newcolnames;
-    newcolnames.resize(9 + newSamples.size());
-    copy(colnames.begin(), colnames.begin() + 9, newcolnames.begin());
-    copy(newSamples.begin(), newSamples.end(), newcolnames.begin() + 9);
-    headerLines.at(headerLines.size() - 1) = join(newcolnames, "\t");
-    return join(headerLines, "\n");
-}
-
-// TODO cleanup, store header lines instead of bulk header
-void VariantCallFile::addHeaderLine(string line) {
-    vector<string> headerLines = split(header, '\n');
-    headerLines.insert(headerLines.end() - 1, line);
-    header = join(unique(headerLines), "\n");
-}
-
-// helper to addHeaderLine
-vector<string>& unique(vector<string>& strings) {
-    set<string> uniq;
-    vector<string> res;
-    for (vector<string>::const_iterator s = strings.begin(); s != strings.end(); ++s) {
-        if (uniq.find(*s) == uniq.end()) {
-            res.push_back(*s);
-            uniq.insert(*s);
-        }
-    }
-    strings = res;
-    return strings;
-}
-
-vector<string> VariantCallFile::infoIds(void) {
-    vector<string> tags;
-    vector<string> headerLines = split(header, '\n');
-    for (vector<string>::iterator s = headerLines.begin(); s != headerLines.end(); ++s) {
-        string& line = *s;
-        if (line.find("##INFO") == 0) {
-            size_t pos = line.find("ID=");
-            if (pos != string::npos) {
-                pos += 3;
-                size_t tagend = line.find(",", pos);
-                if (tagend != string::npos) {
-                    tags.push_back(line.substr(pos, tagend - pos));
-                }
-            }
-        }
-    }
-    return tags;
-}
-
-vector<string> VariantCallFile::formatIds(void) {
-    vector<string> tags;
-    vector<string> headerLines = split(header, '\n');
-    for (vector<string>::iterator s = headerLines.begin(); s != headerLines.end(); ++s) {
-        string& line = *s;
-        if (line.find("##FORMAT") == 0) {
-            size_t pos = line.find("ID=");
-            if (pos != string::npos) {
-                pos += 3;
-                size_t tagend = line.find(",", pos);
-                if (tagend != string::npos) {
-                    tags.push_back(line.substr(pos, tagend - pos));
-                }
-            }
-        }
-    }
-    return tags;
-}
-
-void VariantCallFile::removeInfoHeaderLine(string tag) {
-    vector<string> headerLines = split(header, '\n');
-    vector<string> newHeader;
-    string id = "ID=" + tag + ",";
-    for (vector<string>::iterator s = headerLines.begin(); s != headerLines.end(); ++s) {
-        string& line = *s;
-        if (line.find("##INFO") == 0) {
-            if (line.find(id) == string::npos) {
-                newHeader.push_back(line);
-            }
-        } else {
-            newHeader.push_back(line);
-        }
-    }
-    header = join(newHeader, "\n");
-}
-
-void VariantCallFile::removeGenoHeaderLine(string tag) {
-    vector<string> headerLines = split(header, '\n');
-    vector<string> newHeader;
-    string id = "ID=" + tag + ",";
-    for (vector<string>::iterator s = headerLines.begin(); s != headerLines.end(); ++s) {
-        string& headerLine = *s;
-        if (headerLine.find("##FORMAT") == 0) {
-            if (headerLine.find(id) == string::npos) {
-                newHeader.push_back(headerLine);
-            }
-        } else {
-            newHeader.push_back(headerLine);
-        }
-    }
-    header = join(newHeader, "\n");
-}
-
-bool VariantCallFile::parseHeader(void) {
-
-    string headerStr = "";
-
-    if (usingTabix) {
-        tabixFile->getHeader(headerStr);
-        if (headerStr.empty()) {
-            cerr << "error: no VCF header" << endl;
-            exit(1);
-        }
-        tabixFile->getNextLine(line);
-        firstRecord = true;
-    } else {
-        while (std::getline(*file, line)) {
-            if (line.substr(0,1) == "#") {
-                headerStr += line + '\n';
-            } else {
-                // done with header
-                if (headerStr.empty()) {
-                    cerr << "error: no VCF header" << endl;
-                    exit(1);
-                }
-                firstRecord = true;
-                break;
-            }
-        }
-    }
-
-    return parseHeader(headerStr);
-
-}
-
-bool VariantCallFile::parseHeader(string& hs) {
-
-    if (hs.substr(hs.size() - 1, 1) == "\n") {
-	hs.erase(hs.size() - 1, 1); // remove trailing newline
-    }
-    header = hs; // stores the header in the object instance
-
-    vector<string> headerLines = split(header, "\n");
-    for (vector<string>::iterator h = headerLines.begin(); h != headerLines.end(); ++h) {
-        string headerLine = *h;
-        if (headerLine.substr(0,2) == "##") {
-            // meta-information headerLines
-            // TODO parse into map from info/format key to type
-            // ##INFO=<ID=DP,Number=1,Type=Integer,Description="Total Depth">
-            // ##FORMAT=<ID=CB,Number=1,Type=String,Description="Called by S(Sanger), M(UMich), B(BI)">
-            size_t found = headerLine.find_first_of("=");
-            string entryType = headerLine.substr(2, found - 2);
-            // handle reference here, no "<" and ">" given
-                //} else if (entryType == "reference") {
-            size_t dataStart = headerLine.find_first_of("<");
-            size_t dataEnd = headerLine.find_first_of(">");
-            if (dataStart != string::npos && dataEnd != string::npos) {
-                string entryData = headerLine.substr(dataStart + 1, dataEnd - dataStart - 1);
-                // XXX bad; this will break if anyone ever moves the order
-                // of the fields around to include a "long form" string
-                // including either a = or , in the first or second field
-                if (entryType == "INFO" || entryType == "FORMAT") {
-                    vector<string> fields = split(entryData, "=,");
-                    if (fields[0] != "ID") {
-                        cerr << "header parse error at:" << endl
-                             << "fields[0] != \"ID\"" << endl
-                             << headerLine << endl;
-                        exit(1);
-                    }
-                    string id = fields[1];
-                    if (fields[2] != "Number") {
-                        cerr << "header parse error at:" << endl
-                             << "fields[2] != \"Number\"" << endl
-                             << headerLine << endl;
-                        exit(1);
-                    }
-                    int number;
-                    string numberstr = fields[3].c_str();
-                    // XXX TODO VCF has variable numbers of fields...
-                    if (numberstr == "A") {
-                        number = ALLELE_NUMBER;
-                    } else if (numberstr == "G") {
-                        number = GENOTYPE_NUMBER;
-                    } else if (numberstr == ".") {
-                        number = 1;
-                    } else {
-                        convert(numberstr, number);
-                    }
-                    if (fields[4] != "Type") {
-                        cerr << "header parse error at:" << endl
-                             << "fields[4] != \"Type\"" << endl
-                             << headerLine << endl;
-                        exit(1);
-                    }
-                    VariantFieldType type = typeStrToVariantFieldType(fields[5]);
-                    if (entryType == "INFO") {
-                        infoCounts[id] = number;
-                        infoTypes[id] = type;
-                        //cerr << id << " == " << type << endl;
-                    } else if (entryType == "FORMAT") {
-                        //cout << "found format field " << id << " with type " << type << endl;
-                        formatCounts[id] = number;
-                        formatTypes[id] = type;
-                    }
-                }
-            }
-        } else if (headerLine.substr(0,1) == "#") {
-            // field name headerLine
-            vector<string> fields = split(headerLine, '\t');
-            if (fields.size() > 8) {
-                sampleNames.resize(fields.size() - 9);
-                copy(fields.begin() + 9, fields.end(), sampleNames.begin());
-            }
-        }
-    }
-
-    return true;
-}
-
-bool VariantCallFile::getNextVariant(Variant& var) {
-        if (firstRecord && !justSetRegion) {
-            if (!line.empty()) {
-                var.parse(line, parseSamples);
-                firstRecord = false;
-                _done = false;
-                return true;
-            } else {
-                return false;
-            }
-        }
-        if (usingTabix) {
-            if (justSetRegion && !line.empty()) {
-                if (firstRecord) {
-                    firstRecord = false;
-                }
-                var.parse(line, parseSamples);
-                line.clear();
-                justSetRegion = false;
-                _done = false;
-                return true;
-            } else if (tabixFile->getNextLine(line)) {
-                var.parse(line, parseSamples);
-                _done = false;
-                return true;
-            } else {
-                _done = true;
-                return false;
-            }
-        } else {
-            if (std::getline(*file, line)) {
-                var.parse(line, parseSamples);
-                _done = false;
-                return true;
-            } else {
-                _done = true;
-                return false;
-            }
-        }
-}
-
-bool VariantCallFile::setRegion(string seq, long int start, long int end) {
-    stringstream regionstr;
-    if (end) {
-        regionstr << seq << ":" << start << "-" << end;
-    } else {
-        regionstr << seq << ":" << start;
-    }
-    setRegion(regionstr.str());
-}
-
-bool VariantCallFile::setRegion(string region) {
-    if (!usingTabix) {
-        cerr << "cannot setRegion on a non-tabix indexed file" << endl;
-        exit(1);
-    }
-    size_t dots = region.find("..");
-    // convert between bamtools/freebayes style region string and tabix/samtools style
-    if (dots != string::npos) {
-        region.replace(dots, 2, "-");
-    }
-    if (tabixFile->setRegion(region)) {
-        if (tabixFile->getNextLine(line)) {
-	    justSetRegion = true;
-            return true;
-        } else {
-            return false;
-        }
-    } else {
-        return false;
-    }
-}
-
-
-// genotype manipulation
-
-/*
-map<string, int> decomposeGenotype(string& genotype) {
-    string splitter = "/";
-    if (genotype.find("|") != string::npos) {
-        splitter = "|";
-    }
-    vector<string> haps = split(genotype, splitter);
-    map<string, int> decomposed;
-    for (vector<string>::iterator h = haps.begin(); h != haps.end(); ++h) {
-        ++decomposed[*h];
-    }
-    return decomposed;
-}
-*/
-
-map<int, int> decomposeGenotype(const string& genotype) {
-    string splitter = "/";
-    if (genotype.find("|") != string::npos) {
-        splitter = "|";
-    }
-    vector<string> haps = split(genotype, splitter);
-    map<int, int> decomposed;
-    for (vector<string>::iterator h = haps.begin(); h != haps.end(); ++h) {
-        int alt;
-        if (*h == ".") {
-            ++decomposed[NULL_ALLELE];
-        } else {
-            convert(*h, alt);
-            ++decomposed[alt];
-        }
-    }
-    return decomposed;
-}
-
-vector<int> decomposePhasedGenotype(const string& genotype) {
-    string splitter = "/";
-    if (genotype.find("|") != string::npos) {
-        splitter = "|";
-    }
-    vector<string> haps = split(genotype, splitter);
-    if (haps.size() > 1 && splitter == "/") {
-        cerr << "could not find '|' in genotype, cannot decomposePhasedGenotype on unphased genotypes" << endl;
-        exit(1);
-    }
-    vector<int> decomposed;
-    for (vector<string>::iterator h = haps.begin(); h != haps.end(); ++h) {
-        int alt;
-        if (*h == ".") {
-            decomposed.push_back(NULL_ALLELE);
-        } else {
-            convert(*h, alt);
-            decomposed.push_back(alt);
-        }
-    }
-    return decomposed;
-}
-
-string genotypeToString(const map<int, int>& genotype) {
-    vector<int> s;
-    for (map<int, int>::const_iterator g = genotype.begin(); g != genotype.end(); ++g) {
-        int a = g->first;
-        int c = g->second;
-        for (int i = 0; i < c; ++i) s.push_back(a);
-    }
-    sort(s.begin(), s.end());
-    vector<string> r;
-    for (vector<int>::iterator i = s.begin(); i != s.end(); ++i) {
-        if (*i == NULL_ALLELE) r.push_back(".");
-        else r.push_back(convert(*i));
-    }
-    return join(r, "/"); // TODO adjust for phased/unphased
-}
-
-bool isHet(const map<int, int>& genotype) {
-    return genotype.size() > 1;
-}
-
-bool isHom(const map<int, int>& genotype) {
-    return genotype.size() == 1;
-}
-
-bool hasNonRef(const map<int, int>& genotype) {
-    for (map<int, int>::const_iterator g = genotype.begin(); g != genotype.end(); ++g) {
-        if (g->first != 0) {
-            return true;
-        }
-    }
-    return false;
-}
-
-bool isHomRef(const map<int, int>& genotype) {
-    return isHom(genotype) && !hasNonRef(genotype);
-}
-
-bool isHomNonRef(const map<int, int>& genotype) {
-    return isHom(genotype) && hasNonRef(genotype);
-}
-
-bool isNull(const map<int, int>& genotype) {
-    return genotype.find(NULL_ALLELE) != genotype.end();
-}
-
-int ploidy(const map<int, int>& genotype) {
-    int i = 0;
-    for (map<int, int>::const_iterator g = genotype.begin(); g != genotype.end(); ++g) {
-        i += g->second;
-    }
-    return i;
-}
-
-// generates cigar from allele parsed by parsedAlternates
-string varCigar(vector<VariantAllele>& vav, bool xForMismatch) {
-    string cigar;
-    pair<int, string> element;
-    for (vector<VariantAllele>::iterator v = vav.begin(); v != vav.end(); ++v) {
-        VariantAllele& va = *v;
-        if (va.ref != va.alt) {
-            if (element.second == "M") {
-                cigar += convert(element.first) + element.second;
-                element.second = ""; element.first = 0;
-            }
-            if (va.ref.size() == va.alt.size()) {
-                cigar += convert(va.ref.size()) + (xForMismatch ? "X" : "M");
-            } else if (va.ref.size() > va.alt.size()) {
-                cigar += convert(va.ref.size() - va.alt.size()) + "D";
-            } else {
-                cigar += convert(va.alt.size() - va.ref.size()) + "I";
-            }
-        } else {
-            if (element.second == "M") {
-                element.first += va.ref.size();
-            } else {
-                element = make_pair(va.ref.size(), "M");
-            }
-        }
-    }
-    if (element.second == "M") {
-        cigar += convert(element.first) + element.second;
-    }
-    element.second = ""; element.first = 0;
-    return cigar;
-}
-
-map<string, vector<VariantAllele> > Variant::parsedAlternates(bool includePreviousBaseForIndels,
-                                                              bool useMNPs,
-                                                              bool useEntropy,
-                                                              float matchScore,
-                                                              float mismatchScore,
-                                                              float gapOpenPenalty,
-                                                              float gapExtendPenalty,
-                                                              float repeatGapExtendPenalty,
-                                                              string flankingRefLeft,
-                                                              string flankingRefRight) {
-
-    map<string, vector<VariantAllele> > variantAlleles;
-
-    // add the reference allele
-    variantAlleles[ref].push_back(VariantAllele(ref, ref, position));
-
-    // single SNP case, no ambiguity possible, no need to spend a lot of
-    // compute aligning ref and alt fields
-    if (alt.size() == 1 && ref.size() == 1 && alt.front().size() == 1) {
-        variantAlleles[alt.front()].push_back(VariantAllele(ref, alt.front(), position));
-        return variantAlleles;
-    }
-
-    // padding is used to ensure a stable alignment of the alternates to the reference
-    // without having to go back and look at the full reference sequence
-    int paddingLen = max(10, (int) (ref.size()));  // dynamically determine optimum padding length
-    for (vector<string>::iterator a = alt.begin(); a != alt.end(); ++a) {
-        string& alternate = *a;
-        paddingLen = max(paddingLen, (int) (alternate.size()));
-    }
-    char padChar = 'Z';
-    char anchorChar = 'Q';
-    string padding(paddingLen, padChar);
-
-    // this 'anchored' string is done for stability
-    // the assumption is that there should be a positional match in the first base
-    // this is true for VCF 4.1, and standard best practices
-    // using the anchor char ensures this without other kinds of realignment
-    string reference_M;
-    if (flankingRefLeft.empty() && flankingRefRight.empty()) {
-        reference_M = padding + ref + padding;
-        reference_M[paddingLen] = anchorChar;
-    } else {
-        reference_M = flankingRefLeft + ref + flankingRefRight;
-        paddingLen = flankingRefLeft.size();
-    }
-
-    // passed to sw.Align
-    unsigned int referencePos;
-
-    string cigar;
-
-    for (vector<string>::iterator a = alt.begin(); a != alt.end(); ++a) {
-
-        string& alternate = *a;
-        vector<VariantAllele>& variants = variantAlleles[alternate];
-        string alternateQuery_M;
-        if (flankingRefLeft.empty() && flankingRefRight.empty()) {
-            alternateQuery_M = padding + alternate + padding;
-            alternateQuery_M[paddingLen] = anchorChar;
-        } else {
-            alternateQuery_M = flankingRefLeft + alternate + flankingRefRight;
-        }
-        //const unsigned int alternateLen = alternate.size();
-
-        if (true) {
-            CSmithWatermanGotoh sw(matchScore, mismatchScore, gapOpenPenalty, gapExtendPenalty);
-            if (useEntropy) sw.EnableEntropyGapPenalty(1);
-            if (repeatGapExtendPenalty != 0) sw.EnableRepeatGapExtensionPenalty(repeatGapExtendPenalty);
-            sw.Align(referencePos, cigar, reference_M, alternateQuery_M);
-        } else {  // disabled for now
-            StripedSmithWaterman::Aligner aligner;
-            StripedSmithWaterman::Filter sswFilter;
-            StripedSmithWaterman::Alignment alignment;
-            aligner.Align(alternateQuery_M.c_str(), reference_M.c_str(), reference_M.size(), sswFilter, &alignment);
-            cigar = alignment.cigar_string;
-        }
-
-        // left-realign the alignment...
-
-        vector<pair<int, string> > cigarData = splitCigar(cigar);
-
-        if (cigarData.front().second != "M" || cigarData.back().second != "M"
-            || cigarData.front().first < paddingLen || cigarData.back().first < paddingLen) {
-            cerr << "parsedAlternates: alignment does not start with match over padded sequence" << endl;
-            cerr << cigar << endl;
-            cerr << reference_M << endl;
-            cerr << alternateQuery_M << endl;
-            exit(1);
-        } else {
-            cigarData.front().first -= paddingLen;
-            cigarData.back().first -= paddingLen;;
-        }
-        //cigarData = cleanCigar(cigarData);
-        cigar = joinCigar(cigarData);
-
-        int altpos = 0;
-        int refpos = 0;
-
-        for (vector<pair<int, string> >::iterator e = cigarData.begin(); e != cigarData.end(); ++e) {
-
-            int len = e->first;
-            string type = e->second;
-
-            switch (type.at(0)) {
-            case 'I':
-                if (includePreviousBaseForIndels) {
-                    variants.push_back(VariantAllele(ref.substr(refpos - 1, 1),
-                                                     alternate.substr(altpos - 1, len + 1),
-                                                     refpos + position - 1));
-                } else {
-                    variants.push_back(VariantAllele("", alternate.substr(altpos, len), refpos + position));
-                }
-                altpos += len;
-                break;
-            case 'D':
-                if (includePreviousBaseForIndels) {
-                    variants.push_back(VariantAllele(ref.substr(refpos - 1, len + 1),
-                                                     alternate.substr(altpos - 1, 1),
-                                                     refpos + position - 1));
-                } else {
-                    variants.push_back(VariantAllele(ref.substr(refpos, len), "", refpos + position));
-                }
-                refpos += len;
-                break;
-            case 'M':
-                {
-                    for (int i = 0; i < len; ++i) {
-                        variants.push_back(VariantAllele(ref.substr(refpos + i, 1),
-                                                         alternate.substr(altpos + i, 1),
-                                                         refpos + i + position));
-                    }
-                }
-                refpos += len;
-                altpos += len;
-                break;
-            case 'S':
-                refpos += len;
-                altpos += len;
-                break;
-            default:
-                break;
-            }
-
-            // deal with MNP representation
-            if (useMNPs) {
-                vector<VariantAllele> adjustedVariants;
-                for (vector<VariantAllele>::iterator v = variants.begin(); v != variants.end(); ++v) {
-                    if (adjustedVariants.empty()) {
-                        adjustedVariants.push_back(*v);
-                    } else {
-                        if (adjustedVariants.back().ref.size() == adjustedVariants.back().alt.size()
-                            && adjustedVariants.back().ref != adjustedVariants.back().alt
-                            && v->ref.size() == v->alt.size()
-                            && v->ref != v->alt) {
-                            adjustedVariants.back().ref += v->ref;
-                            adjustedVariants.back().alt += v->alt;
-                        } else {
-                            adjustedVariants.push_back(*v);
-                        }
-                    }
-                }
-                variants = adjustedVariants;
-            }
-        }
-    }
-
-    return variantAlleles;
-}
-
-map<string, vector<VariantAllele> > Variant::flatAlternates(void) {
-    map<string, vector<VariantAllele> > variantAlleles;
-    for (vector<string>::iterator a = alt.begin(); a != alt.end(); ++a) {
-        string& alternate = *a;
-        vector<VariantAllele>& variants = variantAlleles[alternate];
-        variants.push_back(VariantAllele(ref, alternate, position));
-    }
-    return variantAlleles;
-}
-
-set<string> Variant::altSet(void) {
-    set<string> altset(alt.begin(), alt.end());
-    return altset;
-}
-
-ostream& operator<<(ostream& out, VariantAllele& var) {
-    out << var.position << " " << var.ref << " -> " << var.alt;
-    return out;
-}
-
-bool operator<(const VariantAllele& a, const VariantAllele& b) {
-    return a.repr < b.repr;
-}
-
-map<pair<int, int>, int> Variant::getGenotypeIndexesDiploid(void) {
-
-    map<pair<int, int>, int> genotypeIndexes;
-    //map<int, map<Genotype*, int> > vcfGenotypeOrder;
-    vector<int> indexes;
-    for (int i = 0; i < alleles.size(); ++i) {
-        indexes.push_back(i);
-    }
-    int ploidy = 2; // ONLY diploid
-    vector<vector<int> > genotypes = multichoose(ploidy, indexes);
-    for (vector<vector<int> >::iterator g = genotypes.begin(); g != genotypes.end(); ++g) {
-        sort(g->begin(), g->end());  // enforce e.g. 0/1, 0/2, 1/2 ordering over reverse
-        // XXX this does not handle non-diploid!!!!
-        int j = g->front();
-        int k = g->back();
-        genotypeIndexes[make_pair(j, k)] = (k * (k + 1) / 2) + j;
-    }
-    return genotypeIndexes;
-
-}
-
-void Variant::updateAlleleIndexes(void) {
-    // adjust the allele index
-    altAlleleIndexes.clear();
-    int m = 0;
-    for (vector<string>::iterator a = alt.begin();
-            a != alt.end(); ++a, ++m) {
-        altAlleleIndexes[*a] = m;
-    }
-}
-
-// TODO only works on "A"llele variant fields
-void Variant::removeAlt(string& altAllele) {
-
-    int altIndex = getAltAlleleIndex(altAllele);  // this is the alt-relative index, 0-based
-
-    for (map<string, int>::iterator c = vcf->infoCounts.begin(); c != vcf->infoCounts.end(); ++c) {
-        int count = c->second;
-        if (count == ALLELE_NUMBER) {
-            string key = c->first;
-            map<string, vector<string> >::iterator v = info.find(key);
-            if (v != info.end()) {
-                vector<string>& vals = v->second;
-                vector<string> tokeep;
-                int i = 0;
-                for (vector<string>::iterator a = vals.begin(); a != vals.end(); ++a, ++i) {
-                    if (i != altIndex) {
-                        tokeep.push_back(*a);
-                    }
-                }
-                vals = tokeep;
-            }
-        }
-    }
-
-    for (map<string, int>::iterator c = vcf->formatCounts.begin(); c != vcf->formatCounts.end(); ++c) {
-        int count = c->second;
-        if (count == ALLELE_NUMBER) {
-            string key = c->first;
-            for (map<string, map<string, vector<string> > >::iterator s = samples.begin();
-                 s != samples.end(); ++s) {
-                map<string, vector<string> >& sample = s->second;
-                map<string, vector<string> >::iterator v = sample.find(key);
-                if (v != sample.end()) {
-                    vector<string>& vals = v->second;
-                    vector<string> tokeep;
-                    int i = 0;
-                    for (vector<string>::iterator a = vals.begin(); a != vals.end(); ++a, ++i) {
-                        if (i != altIndex) {
-                            tokeep.push_back(*a);
-                        }
-                    }
-                    vals = tokeep;
-                }
-            }
-        }
-    }
-
-    int altSpecIndex = altIndex + 1; // this is the genotype-spec index, ref=0, 1-based for alts
-
-    vector<string> newalt;
-    map<int, int> alleleIndexMapping;
-    // setup the new alt string
-    alleleIndexMapping[0] = 0; // reference allele remains the same
-    alleleIndexMapping[NULL_ALLELE] = NULL_ALLELE; // null allele remains the same
-    int i = 1; // current index
-    int j = 1; // new index
-    for (vector<string>::iterator a = alt.begin(); a != alt.end(); ++a, ++i) {
-        if (i != altSpecIndex) {
-            newalt.push_back(*a);
-            // get the mapping between new and old allele indexes
-            alleleIndexMapping[i] = j;
-            ++j;
-        } else {
-            alleleIndexMapping[i] = NULL_ALLELE;
-        }
-    }
-
-    // fix the sample genotypes, removing reference to the old allele
-    map<string, int> samplePloidy;
-    for (map<string, map<string, vector<string> > >::iterator s = samples.begin(); s != samples.end(); ++s) {
-        map<string, vector<string> >& sample = s->second;
-        if (sample.find("GT") != sample.end()) {
-            string& gt = sample["GT"].front();
-            string splitter = "/";
-            if (gt.find("|") != string::npos) {
-                splitter = "|";
-            }
-            samplePloidy[s->first] = split(gt, splitter).size();
-            map<int, int> genotype = decomposeGenotype(sample["GT"].front());
-            map<int, int> newGenotype;
-            for (map<int, int>::iterator g = genotype.begin(); g != genotype.end(); ++g) {
-                newGenotype[alleleIndexMapping[g->first]] += g->second;
-            }
-            sample["GT"].clear();
-            sample["GT"].push_back(genotypeToString(newGenotype));
-        }
-    }
-
-    set<int> ploidies;
-    for (map<string, int>::iterator p = samplePloidy.begin(); p != samplePloidy.end(); ++p) {
-        ploidies.insert(p->second);
-    }
-
-    // fix the sample genotype likelihoods, removing reference to the old allele
-    // which GL fields should we remove?
-    vector<int> toRemove;
-    toRemove.push_back(altSpecIndex);
-    map<int, map<int, int> > glMappingByPloidy;
-    for (set<int>::iterator p = ploidies.begin(); p != ploidies.end(); ++p) {
-        glMappingByPloidy[*p] = glReorder(*p, alt.size() + 1, alleleIndexMapping, toRemove);
-    }
-
-    for (map<string, map<string, vector<string> > >::iterator s = samples.begin(); s != samples.end(); ++s) {
-        map<string, vector<string> >& sample = s->second;
-        map<string, vector<string> >::iterator glsit = sample.find("GL");
-        if (glsit != sample.end()) {
-            vector<string>& gls = glsit->second; // should be split already
-            map<int, string> newgls;
-            map<int, int>& newOrder = glMappingByPloidy[samplePloidy[s->first]];
-            int i = 0;
-            for (vector<string>::iterator g = gls.begin(); g != gls.end(); ++g, ++i) {
-                int j = newOrder[i];
-                if (j != -1) {
-                    newgls[i] = *g;
-                }
-            }
-            // update the gls
-            gls.clear();
-            for (map<int, string>::iterator g = newgls.begin(); g != newgls.end(); ++g) {
-                gls.push_back(g->second);
-            }
-        }
-    }
-
-    // reset the alt
-    alt = newalt;
-
-    // and the alleles
-    alleles.clear();
-    alleles.push_back(ref);
-    alleles.insert(alleles.end(), alt.begin(), alt.end());
-
-    updateAlleleIndexes();
-
-}
-
-// union of lines in headers of input files
-string unionInfoHeaderLines(string& s1, string& s2) {
-    vector<string> lines1 = split(s1, "\n");
-    vector<string> lines2 = split(s2, "\n");
-    vector<string> result;
-    set<string> l2;
-    string lastHeaderLine; // this one needs to be at the end
-    for (vector<string>::iterator s = lines2.begin(); s != lines2.end(); ++s) {
-        if (s->substr(0,6) == "##INFO") {
-            l2.insert(*s);
-        }
-    }
-    for (vector<string>::iterator s = lines1.begin(); s != lines1.end(); ++s) {
-        if (l2.count(*s)) {
-            l2.erase(*s);
-        }
-        if (s->substr(0,6) == "#CHROM") {
-            lastHeaderLine = *s;
-        } else {
-            result.push_back(*s);
-        }
-    }
-    for (set<string>::iterator s = l2.begin(); s != l2.end(); ++s) {
-        result.push_back(*s);
-    }
-    if (lastHeaderLine.empty()) {
-        cerr << "could not find CHROM POS ... header line" << endl;
-        exit(1);
-    }
-    result.push_back(lastHeaderLine);
-    return join(result, "\n");
-}
-
-string mergeCigar(const string& c1, const string& c2) {
-    vector<pair<int, string> > cigar1 = splitCigar(c1);
-    vector<pair<int, string> > cigar2 = splitCigar(c2);
-    // check if the middle elements are the same
-    if (cigar1.back().second == cigar2.front().second) {
-        cigar1.back().first += cigar2.front().first;
-        cigar2.erase(cigar2.begin());
-    }
-    for (vector<pair<int, string> >::iterator c = cigar2.begin(); c != cigar2.end(); ++c) {
-        cigar1.push_back(*c);
-    }
-    return joinCigar(cigar1);
-}
-
-vector<pair<int, string> > splitCigar(const string& cigarStr) {
-    vector<pair<int, string> > cigar;
-    string number;
-    string type;
-    // strings go [Number][Type] ...
-    for (string::const_iterator s = cigarStr.begin(); s != cigarStr.end(); ++s) {
-        char c = *s;
-        if (isdigit(c)) {
-            if (type.empty()) {
-                number += c;
-            } else {
-                // signal for next token, push back the last pair, clean up
-                cigar.push_back(make_pair(atoi(number.c_str()), type));
-                number.clear();
-                type.clear();
-                number += c;
-            }
-        } else {
-            type += c;
-        }
-    }
-    if (!number.empty() && !type.empty()) {
-        cigar.push_back(make_pair(atoi(number.c_str()), type));
-    }
-    return cigar;
-}
-
-list<pair<int, string> > splitCigarList(const string& cigarStr) {
-    list<pair<int, string> > cigar;
-    string number;
-    string type;
-    // strings go [Number][Type] ...
-    for (string::const_iterator s = cigarStr.begin(); s != cigarStr.end(); ++s) {
-        char c = *s;
-        if (isdigit(c)) {
-            if (type.empty()) {
-                number += c;
-            } else {
-                // signal for next token, push back the last pair, clean up
-                cigar.push_back(make_pair(atoi(number.c_str()), type));
-                number.clear();
-                type.clear();
-                number += c;
-            }
-        } else {
-            type += c;
-        }
-    }
-    if (!number.empty() && !type.empty()) {
-        cigar.push_back(make_pair(atoi(number.c_str()), type));
-    }
-    return cigar;
-}
-
-vector<pair<int, string> > cleanCigar(const vector<pair<int, string> >& cigar) {
-    vector<pair<int, string> > cigarClean;
-    for (vector<pair<int, string> >::const_iterator c = cigar.begin(); c != cigar.end(); ++c) {
-        if (c->first > 0) {
-            cigarClean.push_back(*c);
-        }
-    }
-    return cigarClean;
-}
-
-string joinCigar(const vector<pair<int, string> >& cigar) {
-    string cigarStr;
-    for (vector<pair<int, string> >::const_iterator c = cigar.begin(); c != cigar.end(); ++c) {
-        if (c->first) {
-            cigarStr += convert(c->first) + c->second;
-        }
-    }
-    return cigarStr;
-}
-
-string joinCigar(const vector<pair<int, char> >& cigar) {
-    string cigarStr;
-    for (vector<pair<int, char> >::const_iterator c = cigar.begin(); c != cigar.end(); ++c) {
-        if (c->first) {
-            cigarStr += convert(c->first) + string(1, c->second);
-        }
-    }
-    return cigarStr;
-}
-
-string joinCigarList(const list<pair<int, string> >& cigar) {
-    string cigarStr;
-    for (list<pair<int, string> >::const_iterator c = cigar.begin(); c != cigar.end(); ++c) {
-        cigarStr += convert(c->first) + c->second;
-    }
-    return cigarStr;
-}
-
-int cigarRefLen(const vector<pair<int, char> >& cigar) {
-    int len = 0;
-    for (vector<pair<int, char> >::const_iterator c = cigar.begin(); c != cigar.end(); ++c) {
-        if (c->second == 'M' || c->second == 'D' || c->second == 'X') {
-            len += c->first;
-        }
-    }
-    return len;
-}
-
-int cigarRefLen(const vector<pair<int, string> >& cigar) {
-    int len = 0;
-    for (vector<pair<int, string> >::const_iterator c = cigar.begin(); c != cigar.end(); ++c) {
-        if (c->second == "M" || c->second == "D" || c->second == "X") {
-            len += c->first;
-        }
-    }
-    return len;
-}
-
-bool isEmptyCigarElement(const pair<int, string>& elem) {
-    return elem.first == 0;
-}
-
-list<list<int> > _glorder(int ploidy, int alts) {
-    if (ploidy == 1) {
-        list<list<int> > results;
-        for (int n = 0; n < alts; ++n) {
-            list<int> v;
-            v.push_back(n);
-            results.push_back(v);
-        }
-        return results;
-    } else {
-        list<list<int> > results;
-        for (int n = 0; n < alts; ++n) {
-            list<list<int> > x = _glorder(ploidy - 1, alts);
-            for (list<list<int> >::iterator v = x.begin(); v != x.end(); ++v) {
-                if (v->front() <= n) {
-                    v->push_front(n);
-                    results.push_back(*v);
-                }
-            }
-        }
-        return results;
-    }
-}
-
-// genotype likelihood-ordering of genotypes, where each genotype is a
-// list of integers (as written in the GT field)
-list<list<int> > glorder(int ploidy, int alts) {
-    list<list<int> > results = _glorder(ploidy, alts);
-    for (list<list<int> >::iterator v = results.begin(); v != results.end(); ++v) {
-        v->reverse();
-    }
-    return results;
-}
-
-// which genotype likelihoods would include this alternate allele
-list<int> glsWithAlt(int alt, int ploidy, int numalts) {
-    list<int> gls;
-    list<list<int> > orderedGenotypes = glorder(ploidy, numalts);
-    int i = 0;
-    for (list<list<int> >::iterator v = orderedGenotypes.begin(); v != orderedGenotypes.end(); ++v, ++i) {
-        for (list<int>::iterator q = v->begin(); q != v->end(); ++q) {
-            if (*q == alt) {
-                gls.push_back(i);
-                break;
-            }
-        }
-    }
-    return gls;
-}
-
-// describes the mapping between the old gl ordering and and a new
-// one in which the GLs including the old alt have been removed
-// a map to -1 means "remove"
-map<int, int> glReorder(int ploidy, int numalts, map<int, int>& alleleIndexMapping, vector<int>& altsToRemove) {
-    map<int, int> mapping;
-    list<list<int> > orderedGenotypes = glorder(ploidy, numalts);
-    for (list<list<int> >::iterator v = orderedGenotypes.begin(); v != orderedGenotypes.end(); ++v) {
-        for (list<int>::iterator n = v->begin(); n != v->end(); ++n) {
-            *n = alleleIndexMapping[*n];
-        }
-    }
-    list<list<int> > newOrderedGenotypes = glorder(ploidy, numalts - altsToRemove.size());
-    map<list<int>, int> newOrderedGenotypesMapping;
-    int i = 0;
-    // mapping is wrong...
-    for (list<list<int> >::iterator v = newOrderedGenotypes.begin(); v != newOrderedGenotypes.end(); ++v, ++i) {
-        newOrderedGenotypesMapping[*v] = i;
-    }
-    i = 0;
-    for (list<list<int> >::iterator v = orderedGenotypes.begin(); v != orderedGenotypes.end(); ++v, ++i) {
-        map<list<int>, int>::iterator m = newOrderedGenotypesMapping.find(*v);
-        if (m != newOrderedGenotypesMapping.end()) {
-            //cout << "new gl order of " << i << " is " << m->second << endl;
-            mapping[i] = m->second;
-        } else {
-            //cout << i << " will be removed" << endl;
-            mapping[i] = -1;
-        }
-    }
-    return mapping;
-}
-
-string Variant::getGenotype(string& sample) {
-    map<string, map<string, vector<string> > >::iterator s = samples.find(sample);
-    if (s != samples.end()) {
-        map<string, vector<string> >::iterator f = s->second.find("GT");
-        if (f != s->second.end()) {
-            return f->second.front();
-        }
-    }
-    return "";
-}
-
-bool Variant::isPhased(void) {
-    for (map<string, map<string, vector<string> > >::iterator s = samples.begin(); s != samples.end(); ++s) {
-        map<string, vector<string> >& sample = s->second;
-        map<string, vector<string> >::iterator g = sample.find("GT");
-        if (g != sample.end()) {
-            string gt = g->second.front();
-            if (gt.size() > 1 && gt.find("|") == string::npos) {
-                return false;
-            }
-        }
-    }
-    return true;
-}
-
-long Variant::zeroBasedPosition(void) {
-    return position - 1;
-}
-
-string Variant::vrepr(void) {
-    return sequenceName + "\t" + convert(position) + "\t" + join(alleles, ",");
-}
-
-// TODO
-/*
-vector<Variant*> Variant::matchingHaplotypes() {
-
-    int haplotypeStart = var.position;
-    int haplotypeEnd = var.position + var.ref.size();
-
-    for (vector<Variant*>::iterator v = overlapping.begin(); v != overlapping.end(); ++v) {
-        haplotypeStart = min((*v)->position, (long int) haplotypeStart);
-        haplotypeEnd = max((*v)->position + (*v)->ref.size(), (long unsigned int) haplotypeEnd);
-    }
-
-    // for everything overlapping and the current variant, construct the local haplotype within the bounds
-    // if there is an exact match, the allele in the current VCF does intersect
-
-    string referenceHaplotype = reference.getSubSequence(var.sequenceName, haplotypeStart - 1, haplotypeEnd - haplotypeStart);
-    map<string, vector<pair<Variant*, int> > > haplotypes; // map to variant and alt index
-
-    for (vector<Variant*>::iterator v = overlapping.begin(); v != overlapping.end(); ++v) {
-        Variant& variant = **v;
-        int altindex = 0;
-        for (vector<string>::iterator a = variant.alt.begin(); a != variant.alt.end(); ++a, ++altindex) {
-            string haplotype = referenceHaplotype;
-            // get the relative start and end coordinates for the variant alternate allele
-            int relativeStart = variant.position - haplotypeStart;
-            haplotype.replace(relativeStart, variant.ref.size(), *a);
-            haplotypes[haplotype].push_back(make_pair(*v, altindex));
-        }
-    }
-
-    Variant originalVar = var;
-
-    // determine the non-intersecting alts
-    vector<string> altsToRemove;
-    vector<int> altIndexesToRemove;
-    for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-        string haplotype = referenceHaplotype;
-        int relativeStart = var.position - haplotypeStart;
-        haplotype.replace(relativeStart, var.ref.size(), *a);
-        map<string, vector<pair<Variant*, int> > >::iterator h = haplotypes.find(haplotype);
-        if ((intersecting && !invert && h == haplotypes.end())
-            || (intersecting && invert && h != haplotypes.end())
-            || (unioning && h != haplotypes.end())) {
-            if (tag.empty() && mergeToTag.empty()) {
-                altsToRemove.push_back(*a);
-            } else {
-                if (!tag.empty()) {
-                    var.info[tag].push_back(".");
-                }
-                if (!mergeToTag.empty()) {
-                    var.info[mergeToTag].push_back(".");
-                }
-            }
-        } else {
-            if (!tag.empty()) {
-                var.info[tag].push_back(tagValue);
-            }
-            // NB: just take the first value for the mergeFromTag
-            if (!mergeToTag.empty()) {
-                Variant* v = h->second.front().first;
-                int index = h->second.front().second;
-                if (v->info.find(mergeFromTag) != v->info.end()) {
-                    // now you have to find the exact allele...
-                    string& otherValue = v->info[mergeFromTag].at(index);
-                    var.info[mergeToTag].push_back(otherValue);
-                } else if (mergeFromTag == "QUAL") {
-                    var.info[mergeToTag].push_back(convert(v->quality));
-                } else {
-                    var.info[mergeToTag].push_back(".");
-                }
-            }
-        }
-    }
-
-    // remove the non-overlapping (intersecting) or overlapping (unioning) alts
-    if (intersecting && loci && altsToRemove.size() != var.alt.size()) {
-        // we have a match in loci mode, so we should output the whole loci, not just the matching sequence
-    } else {
-        for (vector<string>::iterator a = altsToRemove.begin(); a != altsToRemove.end(); ++a) {
-            var.removeAlt(*a);
-        }
-    }
-
-    if (unioning) {
-
-        // somehow sort the records and combine them?
-        map<long int, vector<Variant*> > variants;
-        for (vector<Variant*>::iterator o = overlapping.begin(); o != overlapping.end(); ++o) {
-            if ((*o)->position <= var.position && // check ensures proper ordering of variants on output
-                outputVariants.find(*o) == outputVariants.end()) {
-                outputVariants.insert(*o);
-                variants[(*o)->position].push_back(*o);
-            }
-        }
-        // add in the current variant, if it has alts left
-        if (!var.alt.empty()) {
-            vector<Variant*>& vars = variants[var.position];
-            int numalts = 0;
-            for (vector<Variant*>::iterator v = vars.begin(); v != vars.end(); ++v) {
-                numalts += (*v)->alt.size();
-            }
-            if (numalts + var.alt.size() == originalVar.alt.size()) {
-                variants[var.position].clear();
-                variants[var.position].push_back(&originalVar);
-            } else {
-                variants[var.position].push_back(&var);
-            }
-        }
-
-        for (map<long int, vector<Variant*> >::iterator v = variants.begin(); v != variants.end(); ++v) {
-            for (vector<Variant*>::iterator o = v->second.begin(); o != v->second.end(); ++o) {
-                cout << **o << endl;
-                lastOutputPosition = max(lastOutputPosition, (*o)->position);
-            }
-        }
-    } else {
-        // if any alts remain, output the variant record
-        if (!var.alt.empty()) {
-            cout << var << endl;
-            lastOutputPosition = max(lastOutputPosition, var.position);
-        }
-    }
-
-}
-*/
-
-} // end namespace vcf
diff --git a/vcflib/src/Variant.h b/vcflib/src/Variant.h
deleted file mode 100644
index 403eb3b..0000000
--- a/vcflib/src/Variant.h
+++ /dev/null
@@ -1,495 +0,0 @@
-#ifndef __VARIANT_H
-#define __VARIANT_H
-
-#include <vector>
-#include <list>
-#include <map>
-#include <string>
-#include <iostream>
-#include <fstream>
-#include <utility>
-#include <stdlib.h>
-#include <assert.h>
-#include <stack>
-#include <queue>
-#include <set>
-#include "split.h"
-#include "join.h"
-#include "tabixpp/tabix.hpp"
-#include "smithwaterman/SmithWatermanGotoh.h"
-#include "smithwaterman/disorder.h"
-#include "ssw_cpp.h"
-#include "convert.h"
-#include "multichoose/multichoose.h"
-extern "C" {
-    #include "filevercmp/filevercmp.h"
-}
-
-using namespace std;
-
-namespace vcf {
-
-class Variant;
-
-enum VariantFieldType { FIELD_FLOAT = 0
-                      , FIELD_INTEGER
-                      , FIELD_BOOL
-                      , FIELD_STRING
-                      , FIELD_UNKNOWN
-                      };
-
-enum VariantFieldNumber { ALLELE_NUMBER = -2
-                        , GENOTYPE_NUMBER = -1
-                        };
-
-const int INDEX_NONE = -1;
-const int NULL_ALLELE = -1;
-
-VariantFieldType typeStrToFieldType(string& typeStr);
-ostream& operator<<(ostream& out, VariantFieldType type);
-
-typedef map<string, map<string, vector<string> > > Samples;
-typedef vector<pair<int, string> > Cigar;
-
-class VariantCallFile {
-
-public:
-
-    istream* file;
-    Tabix* tabixFile;
-
-    bool usingTabix;
-
-    string header;
-    string line; // the current line
-    string fileformat;
-    string fileDate;
-    string source;
-    string reference;
-    string phasing;
-    map<string, VariantFieldType> infoTypes;
-    map<string, int> infoCounts;
-    map<string, VariantFieldType> formatTypes;
-    map<string, int> formatCounts;
-    vector<string> sampleNames;
-    bool parseSamples;
-    bool _done;
-
-    void updateSamples(vector<string>& newSampleNames);
-    string headerWithSampleNames(vector<string>& newSamples); // non-destructive, for output
-    void addHeaderLine(string line);
-    void removeInfoHeaderLine(string line);
-    void removeGenoHeaderLine(string line);
-    vector<string> infoIds(void);
-    vector<string> formatIds(void);
-
-    bool open(string& filename) {
-        vector<string> filenameParts = split(filename, ".");
-        if (filenameParts.back() == "gz" || filenameParts.back() == "bgz") {
-            return openTabix(filename);
-        } else {
-            return openFile(filename);
-        }
-    }
-
-    bool openFile(string& filename) {
-        file = &_file;
-        _file.open(filename.c_str(), ifstream::in);
-        parsedHeader = parseHeader();
-        return parsedHeader;
-    }
-
-    bool openTabix(string& filename) {
-        usingTabix = true;
-        tabixFile = new Tabix(filename);
-        parsedHeader = parseHeader();
-        return parsedHeader;
-    }
-
-    bool open(istream& stream) {
-        file = &stream;
-        parsedHeader = parseHeader();
-        return parsedHeader;
-    }
-
-    bool open(ifstream& stream) {
-        file = &stream;
-        parsedHeader = parseHeader();
-        return parsedHeader;
-    }
-
-    bool openForOutput(string& headerStr) {
-        parsedHeader = parseHeader(headerStr);
-        return parsedHeader;
-    }
-
-VariantCallFile(void) : usingTabix(false), parseSamples(true), justSetRegion(false), parsedHeader(false) { }
-    ~VariantCallFile(void) {
-        if (usingTabix) {
-            delete tabixFile;
-        }
-    }
-
-    bool is_open(void) { return parsedHeader; }
-
-    bool eof(void) { return _file.eof(); }
-
-    bool done(void) { return _done; }
-
-    bool parseHeader(string& headerStr);
-
-    bool parseHeader(void);
-
-    bool getNextVariant(Variant& var);
-
-    bool setRegion(string region);
-    bool setRegion(string seq, long int start, long int end = 0);
-
-private:
-    bool firstRecord;
-    bool justSetRegion;
-    bool usingFile;
-    ifstream _file;
-    bool parsedHeader;
-
-};
-
-class VariantAllele {
-    friend ostream& operator<<(ostream& out, VariantAllele& var);
-    friend bool operator<(const VariantAllele& a, const VariantAllele& b);
-public:
-    string ref;
-    string alt;
-    string repr;
-    long position;
-    VariantAllele(string r, string a, long p)
-        : ref(r), alt(a), position(p)
-    {
-        stringstream s;
-        s << position << ":" << ref << "/" << alt;
-        repr = s.str();
-    }
-};
-
-class Variant {
-
-    friend ostream& operator<<(ostream& out, Variant& var);
-    
-public:
-
-    string sequenceName;
-    long position;
-    long zeroBasedPosition(void);
-    string id;
-    string ref;
-    vector<string> alt;      // a list of all the alternate alleles present at this locus
-    vector<string> alleles;  // a list all alleles (ref + alt) at this locus
-                             // the indicies are organized such that the genotype codes (0,1,2,.etc.)
-                             // correspond to the correct offest into the allelese vector.
-                             // that is, alleles[0] = ref, alleles[1] = first alternate allele, etc.
-    string vrepr(void);  // a comparable record of the variantion described by the record
-    set<string> altSet(void);  // set of alleles, rather than vector of them
-    map<string, int> altAlleleIndexes;  // reverse lookup for alleles
-    map<string, vector<VariantAllele> > parsedAlternates(bool includePreviousBaseForIndels = false,
-                                                         bool useMNPs = false,
-                                                         bool useEntropy = false,
-                                                         float matchScore = 10.0f,
-                                                         float mismatchScore = -9.0f,
-                                                         float gapOpenPenalty = 15.0f,
-                                                         float gapExtendPenalty = 6.66f,
-                                                         float repeatGapExtendPenalty = 0.0f,
-                                                         string flankingRefLeft = "",
-                                                         string flankingRefRight = "");
-    // the same output format as parsedAlternates, without parsing
-    map<string, vector<VariantAllele> > flatAlternates(void);
-
-    map<string, string> extendedAlternates(long int newPosition, long int length);
-
-    string originalLine; // the literal of the record, as read
-    // TODO
-    // the ordering of genotypes for the likelihoods is given by: F(j/k) = (k*(k+1)/2)+j
-    // vector<pair<int, int> > genotypes;  // indexes into the alleles, ordered as per the spec
-    string filter;
-    double quality;
-    VariantFieldType infoType(string& key);
-    map<string, vector<string> > info;  // vector<string> allows for lists by Genotypes or Alternates
-    map<string, bool> infoFlags;
-    VariantFieldType formatType(string& key);
-    vector<string> format;
-    map<string, map<string, vector<string> > > samples;  // vector<string> allows for lists by Genotypes or Alternates
-    vector<string> sampleNames;
-    vector<string> outputSampleNames;
-    VariantCallFile* vcf;
-
-    //void addInfoInt(string& tag, int value);
-    //void addInfoFloat(string& tag, double value);
-    //void addInfoString(string& tag, string& value);
-
-    void removeAlt(string& altallele);
-
-public:
-
-    Variant() { }
-
-    Variant(VariantCallFile& v)
-        : sampleNames(v.sampleNames)
-        , outputSampleNames(v.sampleNames)
-        , vcf(&v)
-    { }
-
-    void setVariantCallFile(VariantCallFile& v);
-    void setVariantCallFile(VariantCallFile* v);
-
-    void parse(string& line, bool parseSamples = true);
-    void addFilter(string& tag);
-    bool getValueBool(string& key, string& sample, int index = INDEX_NONE);
-    double getValueFloat(string& key, string& sample, int index = INDEX_NONE);
-    string getValueString(string& key, string& sample, int index = INDEX_NONE);
-    bool getSampleValueBool(string& key, string& sample, int index = INDEX_NONE);
-    double getSampleValueFloat(string& key, string& sample, int index = INDEX_NONE);
-    string getSampleValueString(string& key, string& sample, int index = INDEX_NONE);
-    bool getInfoValueBool(string& key, int index = INDEX_NONE);
-    double getInfoValueFloat(string& key, int index = INDEX_NONE);
-    string getInfoValueString(string& key, int index = INDEX_NONE);
-    void printAlt(ostream& out);      // print a comma-sep list of alternate alleles to an ostream
-    void printAlleles(ostream& out);  // print a comma-sep list of *all* alleles to an ostream
-    int getAltAlleleIndex(string& allele);
-    void updateAlleleIndexes(void);
-    void addFormatField(string& key);
-    void setOutputSampleNames(vector<string>& outputSamples);
-    map<pair<int, int>, int> getGenotypeIndexesDiploid(void);
-    int getNumSamples(void);
-    int getNumValidGenotypes(void);
-    string getGenotype(string& sample);
-    bool isPhased(void);
-    // TODO
-    //void setInfoField(string& key, string& val);
-
-private:
-
-    string lastFormat;
-
-};
-
-
-// from BamTools
-// RuleToken implementation
-
-class RuleToken {
-
-public:
-
-    // enums
-    enum RuleTokenType { OPERAND = 0
-                       , NUMBER
-                       , BOOLEAN_VARIABLE
-                       , NUMERIC_VARIABLE
-                       , STRING_VARIABLE
-                       , AND_OPERATOR
-                       , OR_OPERATOR
-                       , ADD_OPERATOR
-                       , SUBTRACT_OPERATOR
-                       , MULTIPLY_OPERATOR
-                       , DIVIDE_OPERATOR
-                       , NOT_OPERATOR
-                       , EQUAL_OPERATOR
-                       , GREATER_THAN_OPERATOR
-                       , LESS_THAN_OPERATOR
-                       , LEFT_PARENTHESIS
-                       , RIGHT_PARENTHESIS
-                       };
-
-    // constructor
-    RuleToken(string token, map<string, VariantFieldType>& variables);
-    RuleToken(void) 
-        : type(BOOLEAN_VARIABLE)
-        , state(false)
-    { }
-
-    // data members
-    RuleTokenType type;
-    string value;
-
-    double number;
-    string str;
-    bool state;
-
-    bool isVariable; // if this is a variable
-    //bool isEvaluated; // when we evaluate variables
-
-    RuleToken apply(RuleToken& other);
-
-};
-
-inline int priority(const RuleToken& token) {
-    switch ( token.type ) {
-        case ( RuleToken::MULTIPLY_OPERATOR )     : return 8;
-        case ( RuleToken::DIVIDE_OPERATOR )       : return 8;
-        case ( RuleToken::ADD_OPERATOR )          : return 7;
-        case ( RuleToken::SUBTRACT_OPERATOR )     : return 7;
-        case ( RuleToken::NOT_OPERATOR )          : return 6;
-        case ( RuleToken::EQUAL_OPERATOR )        : return 5;
-        case ( RuleToken::GREATER_THAN_OPERATOR ) : return 5;
-        case ( RuleToken::LESS_THAN_OPERATOR )    : return 5;
-        case ( RuleToken::AND_OPERATOR )          : return 4;
-        case ( RuleToken::OR_OPERATOR )           : return 3;
-        case ( RuleToken::LEFT_PARENTHESIS )      : return 0;
-        case ( RuleToken::RIGHT_PARENTHESIS )     : return 0;
-        default: cerr << "invalid token type" << endl; exit(1);
-    }
-}
-
-inline bool isRightAssociative(const RuleToken& token) {
-    return (token.type == RuleToken::NOT_OPERATOR ||
-            token.type == RuleToken::LEFT_PARENTHESIS);
-}
-
-inline bool isLeftAssociative(const RuleToken& token) {
-    return !isRightAssociative(token);
-}
-
-inline bool isLeftParenthesis(const RuleToken& token) {
-    return ( token.type == RuleToken::LEFT_PARENTHESIS );
-}
-
-inline bool isRightParenthesis(const RuleToken& token) {
-    return ( token.type == RuleToken::RIGHT_PARENTHESIS );
-}
-
-inline bool isOperand(const RuleToken& token) {
-    return ( token.type == RuleToken::OPERAND || 
-             token.type == RuleToken::NUMBER ||
-             token.type == RuleToken::NUMERIC_VARIABLE ||
-             token.type == RuleToken::STRING_VARIABLE ||
-             token.type == RuleToken::BOOLEAN_VARIABLE
-           );
-}
-
-inline bool isOperator(const RuleToken& token) {
-    return ( token.type == RuleToken::AND_OPERATOR ||
-             token.type == RuleToken::OR_OPERATOR  ||
-             token.type == RuleToken::NOT_OPERATOR ||
-             token.type == RuleToken::EQUAL_OPERATOR ||
-             token.type == RuleToken::GREATER_THAN_OPERATOR ||
-             token.type == RuleToken::LESS_THAN_OPERATOR ||
-             token.type == RuleToken::MULTIPLY_OPERATOR ||
-             token.type == RuleToken::DIVIDE_OPERATOR ||
-             token.type == RuleToken::ADD_OPERATOR ||
-             token.type == RuleToken::SUBTRACT_OPERATOR
-             );
-}
-
-inline bool isOperatorChar(const char& c) {
-    return (c == '!' ||
-            c == '&' ||
-            c == '|' ||
-            c == '=' ||
-            c == '>' ||
-            c == '<' ||
-            c == '*' ||
-            c == '/' ||
-            c == '+' ||
-            c == '-');
-}
-
-inline bool isParanChar(const char& c) {
-    return (c == '(' || c == ')');
-}
-
-inline bool isNumeric(const RuleToken& token) {
-    return token.type == RuleToken::NUMERIC_VARIABLE;
-}
-
-inline bool isString(const RuleToken& token) {
-    return token.type == RuleToken::STRING_VARIABLE;
-}
-
-inline bool isBoolean(const RuleToken& token) {
-    return token.type == RuleToken::BOOLEAN_VARIABLE;
-}
-
-inline bool isVariable(const RuleToken& token) {
-    return isNumeric(token) || isString(token) || isBoolean(token);
-}
-
-void tokenizeFilterSpec(string& filterspec, stack<RuleToken>& tokens, map<string, VariantFieldType>& variables);
-
-
-class VariantFilter {
-
-public:
-
-    enum VariantFilterType { SAMPLE = 0,
-                             RECORD };
-
-    string spec;
-    queue<RuleToken> tokens; // tokens, infix notation
-    queue<RuleToken> rules;  // tokens, prefix notation
-    VariantFilterType type;
-    VariantFilter(string filterspec, VariantFilterType filtertype, map<string, VariantFieldType>& variables);
-    bool passes(Variant& var, string& sample); // all alts pass
-    bool passes(Variant& var, string& sample, string& allele);
-    void removeFilteredGenotypes(Variant& var);
-
-};
-
-
-// genotype manipulation
-
-// TODO
-//map<string, int> decomposeGenotype(string& genotype);
-
-vector<int> decomposePhasedGenotype(const string& genotype);
-map<int, int> decomposeGenotype(const string& genotype);
-
-string genotypeToString(const map<int, int>& genotype);
-
-bool isHet(const map<int, int>& genotype);
-
-bool isHom(const map<int, int>& genotype);
-
-bool hasNonRef(const map<int, int>& genotype);
-
-bool isHomRef(const map<int, int>& genotype);
-
-bool isHomNonRef(const map<int, int>& genotype);
-
-bool isNull(const map<int, int>& genotype);
-
-int ploidy(const map<int, int>& genotype);
-
-string unionInfoHeaderLines(string& s1, string& s2);
-
-// genotype likelihood ordering
-
-list<list<int> > glorder(int ploidy, int alleles);
-list<list<int> > _glorder(int ploidy, int alleles);
-list<int> glsWithAlt(int alt, int ploidy, int numalts);
-map<int, int> glReorder(int ploidy, int numalts, map<int, int>& alleleIndexMapping, vector<int>& altsToRemove);
-
-vector<string>& unique(vector<string>& strings);
-
-string varCigar(vector<VariantAllele>& vav, bool xForMismatch = false);
-string mergeCigar(const string& c1, const string& c2);
-vector<pair<int, string> > splitCigar(const string& cigarStr);
-list<pair<int, string> > splitCigarList(const string& cigarStr);
-int cigarRefLen(const vector<pair<int, char> >& cigar);
-int cigarRefLen(const vector<pair<int, string> >& cigar);
-vector<pair<int, string> > cleanCigar(const vector<pair<int, string> >& cigar);
-string joinCigar(const vector<pair<int, string> >& cigar);
-string joinCigar(const vector<pair<int, char> >& cigar);
-string joinCigarList(const list<pair<int, string> >& cigar);
-bool isEmptyCigarElement(const pair<int, string>& elem);
-
-// for sorting, generating maps ordered by chromosome name
-class ChromNameCompare {
-public:
-    bool operator()(const string& a, const string& b) {
-        return (filevercmp(a.c_str(), b.c_str()) < 0);
-    }
-};
-
-
-} // end namespace VCF
-
-#endif
diff --git a/vcflib/src/convert.h b/vcflib/src/convert.h
deleted file mode 100644
index d73d518..0000000
--- a/vcflib/src/convert.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef __CONVERT_H
-#define __CONVERT_H
-
-#include <sstream>
-
-// converts the string into the specified type, setting r to the converted
-// value and returning true/false on success or failure
-template<typename T>
-bool convert(const std::string& s, T& r) {
-    std::istringstream iss(s);
-    iss >> r;
-    return iss.eof() ? true : false;
-}
-
-template<typename T>
-std::string convert(const T& r) {
-    std::ostringstream oss;
-    oss << r;
-    return oss.str();
-}
-
-#endif
diff --git a/vcflib/src/join.h b/vcflib/src/join.h
deleted file mode 100644
index c46a75f..0000000
--- a/vcflib/src/join.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef __JOIN_H
-#define __JOIN_H
-
-// functions to split a string by a specific delimiter
-#include <string>
-#include <vector>
-#include <sstream>
-#include <string.h>
-
-// join a vector of elements by a delimiter object.  ostream<< must be defined
-// for both class S and T and an ostream, as it is e.g. in the case of strings
-// and character arrays
-template<class S, class T>
-std::string join(std::vector<T>& elems, S& delim) {
-    std::stringstream ss;
-    typename std::vector<T>::iterator e = elems.begin();
-    ss << *e++;
-    for (; e != elems.end(); ++e) {
-        ss << delim << *e;
-    }
-    return ss.str();
-}
-
-// same for lists
-template<class S, class T>
-std::string join(std::list<T>& elems, S& delim) {
-    std::stringstream ss;
-    typename std::list<T>::iterator e = elems.begin();
-    ss << *e++;
-    for (; e != elems.end(); ++e) {
-        ss << delim << *e;
-    }
-    return ss.str();
-}
-
-#endif
diff --git a/vcflib/src/mt19937ar.h b/vcflib/src/mt19937ar.h
deleted file mode 100644
index 3f239e1..0000000
--- a/vcflib/src/mt19937ar.h
+++ /dev/null
@@ -1,192 +0,0 @@
-/* 
-   A C-program for MT19937, with initialization improved 2002/1/26.
-   Coded by Takuji Nishimura and Makoto Matsumoto.
-
-   Before using, initialize the state by using init_genrand(seed)  
-   or init_by_array(init_key, key_length).
-
-   Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
-   All rights reserved.                          
-
-   Redistribution and use in source and binary forms, with or without
-   modification, are permitted provided that the following conditions
-   are met:
-
-     1. Redistributions of source code must retain the above copyright
-        notice, this list of conditions and the following disclaimer.
-
-     2. Redistributions in binary form must reproduce the above copyright
-        notice, this list of conditions and the following disclaimer in the
-        documentation and/or other materials provided with the distribution.
-
-     3. The names of its contributors may not be used to endorse or promote 
-        products derived from this software without specific prior written 
-        permission.
-
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-   Any feedback is very welcome.
-   http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
-   email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
-*/
-
-#include <stdio.h>
-
-/* Period parameters */  
-#define N 624
-#define M 397
-#define MATRIX_A 0x9908b0dfUL   /* constant vector a */
-#define UPPER_MASK 0x80000000UL /* most significant w-r bits */
-#define LOWER_MASK 0x7fffffffUL /* least significant r bits */
-
-static unsigned long mt[N]; /* the array for the state vector  */
-static int mti=N+1; /* mti==N+1 means mt[N] is not initialized */
-
-/* initializes mt[N] with a seed */
-void init_genrand(unsigned long s)
-{
-    mt[0]= s & 0xffffffffUL;
-    for (mti=1; mti<N; mti++) {
-        mt[mti] = 
-	    (1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti); 
-        /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
-        /* In the previous versions, MSBs of the seed affect   */
-        /* only MSBs of the array mt[].                        */
-        /* 2002/01/09 modified by Makoto Matsumoto             */
-        mt[mti] &= 0xffffffffUL;
-        /* for >32 bit machines */
-    }
-}
-
-/* initialize by an array with array-length */
-/* init_key is the array for initializing keys */
-/* key_length is its length */
-/* slight change for C++, 2004/2/26 */
-void init_by_array(unsigned long init_key[], int key_length)
-{
-    int i, j, k;
-    init_genrand(19650218UL);
-    i=1; j=0;
-    k = (N>key_length ? N : key_length);
-    for (; k; k--) {
-        mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1664525UL))
-          + init_key[j] + j; /* non linear */
-        mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
-        i++; j++;
-        if (i>=N) { mt[0] = mt[N-1]; i=1; }
-        if (j>=key_length) j=0;
-    }
-    for (k=N-1; k; k--) {
-        mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941UL))
-          - i; /* non linear */
-        mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
-        i++;
-        if (i>=N) { mt[0] = mt[N-1]; i=1; }
-    }
-
-    mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */ 
-}
-
-/* generates a random number on [0,0xffffffff]-interval */
-unsigned long genrand_int32(void)
-{
-    unsigned long y;
-    static unsigned long mag01[2]={0x0UL, MATRIX_A};
-    /* mag01[x] = x * MATRIX_A  for x=0,1 */
-
-    if (mti >= N) { /* generate N words at one time */
-        int kk;
-
-        if (mti == N+1)   /* if init_genrand() has not been called, */
-            init_genrand(5489UL); /* a default initial seed is used */
-
-        for (kk=0;kk<N-M;kk++) {
-            y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
-            mt[kk] = mt[kk+M] ^ (y >> 1) ^ mag01[y & 0x1UL];
-        }
-        for (;kk<N-1;kk++) {
-            y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
-            mt[kk] = mt[kk+(M-N)] ^ (y >> 1) ^ mag01[y & 0x1UL];
-        }
-        y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK);
-        mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1UL];
-
-        mti = 0;
-    }
-  
-    y = mt[mti++];
-
-    /* Tempering */
-    y ^= (y >> 11);
-    y ^= (y << 7) & 0x9d2c5680UL;
-    y ^= (y << 15) & 0xefc60000UL;
-    y ^= (y >> 18);
-
-    return y;
-}
-
-/* generates a random number on [0,0x7fffffff]-interval */
-long genrand_int31(void)
-{
-    return (long)(genrand_int32()>>1);
-}
-
-/* generates a random number on [0,1]-real-interval */
-double genrand_real1(void)
-{
-    return genrand_int32()*(1.0/4294967295.0); 
-    /* divided by 2^32-1 */ 
-}
-
-/* generates a random number on [0,1)-real-interval */
-double genrand_real2(void)
-{
-    return genrand_int32()*(1.0/4294967296.0); 
-    /* divided by 2^32 */
-}
-
-/* generates a random number on (0,1)-real-interval */
-double genrand_real3(void)
-{
-    return (((double)genrand_int32()) + 0.5)*(1.0/4294967296.0); 
-    /* divided by 2^32 */
-}
-
-/* generates a random number on [0,1) with 53-bit resolution*/
-double genrand_res53(void) 
-{ 
-    unsigned long a=genrand_int32()>>5, b=genrand_int32()>>6; 
-    return(a*67108864.0+b)*(1.0/9007199254740992.0); 
-} 
-/* These real versions are due to Isaku Wada, 2002/01/09 added */
-
-/*
-int main(void)
-{
-    int i;
-    unsigned long init[4]={0x123, 0x234, 0x345, 0x456}, length=4;
-    init_by_array(init, length);
-    printf("1000 outputs of genrand_int32()\n");
-    for (i=0; i<1000; i++) {
-      printf("%10lu ", genrand_int32());
-      if (i%5==4) printf("\n");
-    }
-    printf("\n1000 outputs of genrand_real2()\n");
-    for (i=0; i<1000; i++) {
-      printf("%10.8f ", genrand_real2());
-      if (i%5==4) printf("\n");
-    }
-    return 0;
-}
-*/
diff --git a/vcflib/src/split.cpp b/vcflib/src/split.cpp
deleted file mode 100644
index 831dfcd..0000000
--- a/vcflib/src/split.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#include "split.h"
-
-
-std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) {
-    std::string delims = std::string(1, delim);
-    tokenize(s, elems, delims);
-    return elems;
-}
-
-std::vector<std::string> split(const std::string &s, char delim) {
-    std::vector<std::string> elems;
-    return split(s, delim, elems);
-}
-
-std::vector<std::string> &split(const std::string &s, const std::string& delims, std::vector<std::string> &elems) {
-    tokenize(s, elems, delims);
-    return elems;
-}
-
-std::vector<std::string> split(const std::string &s, const std::string& delims) {
-    std::vector<std::string> elems;
-    return split(s, delims, elems);
-}
diff --git a/vcflib/src/split.h b/vcflib/src/split.h
deleted file mode 100644
index e10ba78..0000000
--- a/vcflib/src/split.h
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef __SPLIT_H
-#define __SPLIT_H
-
-// functions to split a string by a specific delimiter
-#include <string>
-#include <vector>
-#include <sstream>
-#include <string.h>
-
-// thanks to Evan Teran, http://stackoverflow.com/questions/236129/how-to-split-a-string/236803#236803
-
-// split a string on a single delimiter character (delim)
-std::vector<std::string>& split(const std::string &s, char delim, std::vector<std::string> &elems);
-std::vector<std::string>  split(const std::string &s, char delim);
-
-// split a string on any character found in the string of delimiters (delims)
-std::vector<std::string>& split(const std::string &s, const std::string& delims, std::vector<std::string> &elems);
-std::vector<std::string>  split(const std::string &s, const std::string& delims);
-
-// from Marius, http://stackoverflow.com/a/1493195/238609
-template < class ContainerT >
-void tokenize(const std::string& str, ContainerT& tokens,
-              const std::string& delimiters = " ", const bool trimEmpty = false)
-{
-
-    std::string::size_type pos, lastPos = 0;
-    while(true)
-    {
-	pos = str.find_first_of(delimiters, lastPos);
-	if(pos == std::string::npos)
-	{
-
-	    pos = str.length();
-
-	    if(pos != lastPos || !trimEmpty) {
-		tokens.push_back(typename ContainerT::value_type(str.data()+lastPos, (typename ContainerT::value_type::size_type)pos-lastPos));
-	    }
-
-	    break;
-	}
-	else
-	{
-	    if(pos != lastPos || !trimEmpty) {
-		tokens.push_back(typename ContainerT::value_type(str.data()+lastPos, (typename ContainerT::value_type::size_type)pos-lastPos));
-	    }
-	}
-
-	lastPos = pos + 1;
-    }
-};
-
-
-#endif
diff --git a/vcflib/src/ssw.c b/vcflib/src/ssw.c
deleted file mode 100644
index 69646f1..0000000
--- a/vcflib/src/ssw.c
+++ /dev/null
@@ -1,834 +0,0 @@
-/*
- *  ssw.c
- *
- *  Created by Mengyao Zhao on 6/22/10.
- *  Copyright 2010 Boston College. All rights reserved.
- *	Version 0.1.4
- *	Last revision by Mengyao Zhao on 07/31/12.
- *
- */
-
-#include <emmintrin.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-#include "ssw.h"
-
-#ifdef __GNUC__
-#define LIKELY(x) __builtin_expect((x),1)
-#define UNLIKELY(x) __builtin_expect((x),0)
-#else
-#define LIKELY(x) (x)
-#define UNLIKELY(x) (x)
-#endif
-
-/* Convert the coordinate in the scoring matrix into the coordinate in one line of the band. */
-#define set_u(u, w, i, j) { int x=(i)-(w); x=x>0?x:0; (u)=(j)-x+1; }
-
-/* Convert the coordinate in the direction matrix into the coordinate in one line of the band. */
-#define set_d(u, w, i, j, p) { int x=(i)-(w); x=x>0?x:0; x=(j)-x; (u)=x*3+p; }
-
-/*! @function
-  @abstract  Round an integer to the next closest power-2 integer.
-  @param  x  integer to be rounded (in place)
-  @discussion x will be modified.
- */
-#define kroundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x))
-
-typedef struct {
-	uint16_t score;
-	int32_t ref;	 //0-based position 
-	int32_t read;    //alignment ending position on read, 0-based 
-} alignment_end;
-
-typedef struct {
-	uint32_t* seq;
-	int32_t length;
-} cigar;
-
-struct _profile{
-	__m128i* profile_byte;	// 0: none
-	__m128i* profile_word;	// 0: none
-	const int8_t* read;
-	const int8_t* mat;
-	int32_t readLen;
-	int32_t n;
-	uint8_t bias;
-};
-
-/* Generate query profile rearrange query sequence & calculate the weight of match/mismatch. */
-__m128i* qP_byte (const int8_t* read_num,
-				  const int8_t* mat,
-				  const int32_t readLen,
-				  const int32_t n,	/* the edge length of the squre matrix mat */
-				  uint8_t bias) {
- 
-	int32_t segLen = (readLen + 15) / 16; /* Split the 128 bit register into 16 pieces. 
-								     Each piece is 8 bit. Split the read into 16 segments. 
-								     Calculat 16 segments in parallel.
-								   */
-	__m128i* vProfile = (__m128i*)malloc(n * segLen * sizeof(__m128i));
-	int8_t* t = (int8_t*)vProfile;
-	int32_t nt, i, j, segNum;
-	
-	/* Generate query profile rearrange query sequence & calculate the weight of match/mismatch */
-	for (nt = 0; LIKELY(nt < n); nt ++) {
-		for (i = 0; i < segLen; i ++) {
-			j = i; 
-			for (segNum = 0; LIKELY(segNum < 16) ; segNum ++) {
-				*t++ = j>= readLen ? bias : mat[nt * n + read_num[j]] + bias;
-				j += segLen;
-			}
-		}
-	}
-	return vProfile;
-}
-
-/* Striped Smith-Waterman
-   Record the highest score of each reference position. 
-   Return the alignment score and ending position of the best alignment, 2nd best alignment, etc. 
-   Gap begin and gap extension are different. 
-   wight_match > 0, all other weights < 0.
-   The returned positions are 0-based.
- */ 
-alignment_end* sw_sse2_byte (const int8_t* ref,
-							 int8_t ref_dir,	// 0: forward ref; 1: reverse ref
-							 int32_t refLen,
-							 int32_t readLen, 
-							 const uint8_t weight_gapO, /* will be used as - */
-							 const uint8_t weight_gapE, /* will be used as - */
-							 __m128i* vProfile,
-							 uint8_t terminate,	/* the best alignment score: used to terminate 
-												   the matrix calculation when locating the 
-												   alignment beginning point. If this score 
-												   is set to 0, it will not be used */
-	 						 uint8_t bias,  /* Shift 0 point to a positive value. */
-							 int32_t maskLen) {  
-      
-#define max16(m, vm) (vm) = _mm_max_epu8((vm), _mm_srli_si128((vm), 8)); \
-					  (vm) = _mm_max_epu8((vm), _mm_srli_si128((vm), 4)); \
-					  (vm) = _mm_max_epu8((vm), _mm_srli_si128((vm), 2)); \
-					  (vm) = _mm_max_epu8((vm), _mm_srli_si128((vm), 1)); \
-					  (m) = _mm_extract_epi16((vm), 0)
-
-	uint8_t max = 0;		                     /* the max alignment score */
-	int32_t end_read = readLen - 1;
-	int32_t end_ref = -1; /* 0_based best alignment ending point; Initialized as isn't aligned -1. */
-	int32_t segLen = (readLen + 15) / 16; /* number of segment */
-	
-	/* array to record the largest score of each reference position */
-	uint8_t* maxColumn = (uint8_t*) calloc(refLen, 1); 
-	
-	/* array to record the alignment read ending position of the largest score of each reference position */
-	int32_t* end_read_column = (int32_t*) calloc(refLen, sizeof(int32_t));
-	
-	/* Define 16 byte 0 vector. */
-	__m128i vZero = _mm_set1_epi32(0);
-
-	__m128i* pvHStore = (__m128i*) calloc(segLen, sizeof(__m128i));
-	__m128i* pvHLoad = (__m128i*) calloc(segLen, sizeof(__m128i));
-	__m128i* pvE = (__m128i*) calloc(segLen, sizeof(__m128i));
-	__m128i* pvHmax = (__m128i*) calloc(segLen, sizeof(__m128i));
-
-	int32_t i, j;
-	/* 16 byte insertion begin vector */
-	__m128i vGapO = _mm_set1_epi8(weight_gapO);
-	
-	/* 16 byte insertion extension vector */
-	__m128i vGapE = _mm_set1_epi8(weight_gapE);	
-	
-	/* 16 byte bias vector */
-	__m128i vBias = _mm_set1_epi8(bias);	
-
-	__m128i vMaxScore = vZero; /* Trace the highest score of the whole SW matrix. */
-	__m128i vMaxMark = vZero; /* Trace the highest score till the previous column. */	
-	__m128i vTemp;
-	int32_t edge, begin = 0, end = refLen, step = 1; 
-//	int32_t distance = readLen * 2 / 3;
-//	int32_t distance = readLen / 2;
-//	int32_t distance = readLen;
-
-	/* outer loop to process the reference sequence */
-	if (ref_dir == 1) {
-		begin = refLen - 1;
-		end = -1;
-		step = -1;
-	}
-	for (i = begin; LIKELY(i != end); i += step) {
-		int32_t cmp;
-		__m128i e = vZero, vF = vZero, vMaxColumn = vZero; /* Initialize F value to 0. 
-							   Any errors to vH values will be corrected in the Lazy_F loop. 
-							 */
-//		max16(maxColumn[i], vMaxColumn);
-//		fprintf(stderr, "middle[%d]: %d\n", i, maxColumn[i]);
-
-		__m128i vH = pvHStore[segLen - 1];
-		vH = _mm_slli_si128 (vH, 1); /* Shift the 128-bit value in vH left by 1 byte. */
-		__m128i* vP = vProfile + ref[i] * segLen; /* Right part of the vProfile */
-
-		/* Swap the 2 H buffers. */
-		__m128i* pv = pvHLoad;
-		pvHLoad = pvHStore;
-		pvHStore = pv;
-		
-		/* inner loop to process the query sequence */
-		for (j = 0; LIKELY(j < segLen); ++j) {
-			vH = _mm_adds_epu8(vH, _mm_load_si128(vP + j));
-			vH = _mm_subs_epu8(vH, vBias); /* vH will be always > 0 */
-	//	max16(maxColumn[i], vH);
-	//	fprintf(stderr, "H[%d]: %d\n", i, maxColumn[i]);
-//	int8_t* t;
-//	int32_t ti;
-//for (t = (int8_t*)&vH, ti = 0; ti < 16; ++ti) fprintf(stderr, "%d\t", *t++);
-
-			/* Get max from vH, vE and vF. */
-			e = _mm_load_si128(pvE + j);
-			vH = _mm_max_epu8(vH, e);
-			vH = _mm_max_epu8(vH, vF);
-			vMaxColumn = _mm_max_epu8(vMaxColumn, vH);
-			
-	//	max16(maxColumn[i], vMaxColumn);
-	//	fprintf(stderr, "middle[%d]: %d\n", i, maxColumn[i]);
-//	for (t = (int8_t*)&vMaxColumn, ti = 0; ti < 16; ++ti) fprintf(stderr, "%d\t", *t++);
-
-			/* Save vH values. */
-			_mm_store_si128(pvHStore + j, vH);
-
-			/* Update vE value. */
-			vH = _mm_subs_epu8(vH, vGapO); /* saturation arithmetic, result >= 0 */
-			e = _mm_subs_epu8(e, vGapE);
-			e = _mm_max_epu8(e, vH);
-			_mm_store_si128(pvE + j, e);
-			
-			/* Update vF value. */
-			vF = _mm_subs_epu8(vF, vGapE);
-			vF = _mm_max_epu8(vF, vH);
-			
-			/* Load the next vH. */
-			vH = _mm_load_si128(pvHLoad + j);
-		}
-
-		/* Lazy_F loop: has been revised to disallow adjecent insertion and then deletion, so don't update E(i, j), learn from SWPS3 */
-        /* reset pointers to the start of the saved data */
-        j = 0;
-        vH = _mm_load_si128 (pvHStore + j);
-
-        /*  the computed vF value is for the given column.  since */
-        /*  we are at the end, we need to shift the vF value over */
-        /*  to the next column. */
-        vF = _mm_slli_si128 (vF, 1);
-        vTemp = _mm_subs_epu8 (vH, vGapO);
-		vTemp = _mm_subs_epu8 (vF, vTemp);
-		vTemp = _mm_cmpeq_epi8 (vTemp, vZero);
-		cmp  = _mm_movemask_epi8 (vTemp);
-
-        while (cmp != 0xffff) 
-        {
-            vH = _mm_max_epu8 (vH, vF);
-			vMaxColumn = _mm_max_epu8(vMaxColumn, vH);
-            _mm_store_si128 (pvHStore + j, vH);
-            vF = _mm_subs_epu8 (vF, vGapE);
-            j++;
-            if (j >= segLen)
-            {
-                j = 0;
-                vF = _mm_slli_si128 (vF, 1);
-            }
-            vH = _mm_load_si128 (pvHStore + j);
-
-            vTemp = _mm_subs_epu8 (vH, vGapO);
-            vTemp = _mm_subs_epu8 (vF, vTemp);
-            vTemp = _mm_cmpeq_epi8 (vTemp, vZero);
-            cmp  = _mm_movemask_epi8 (vTemp);
-        }
-
-		vMaxScore = _mm_max_epu8(vMaxScore, vMaxColumn);
-		vTemp = _mm_cmpeq_epi8(vMaxMark, vMaxScore);
-		cmp = _mm_movemask_epi8(vTemp);
-		if (cmp != 0xffff) {
-			uint8_t temp; 
-			vMaxMark = vMaxScore;
-			max16(temp, vMaxScore);
-			vMaxScore = vMaxMark;
-			
-			if (LIKELY(temp > max)) {
-				max = temp;
-				if (max + bias >= 255) break;	//overflow
-				end_ref = i;
-			
-				/* Store the column with the highest alignment score in order to trace the alignment ending position on read. */
-				for (j = 0; LIKELY(j < segLen); ++j) pvHmax[j] = pvHStore[j];
-			}
-		}
-
-		/* Record the max score of current column. */	
-		max16(maxColumn[i], vMaxColumn);
-//		fprintf(stderr, "maxColumn[%d]: %d\n", i, maxColumn[i]);
-		if (maxColumn[i] == terminate) break;
-	}
-	
-	/* Trace the alignment ending position on read. */
-	uint8_t *t = (uint8_t*)pvHmax;
-	int32_t column_len = segLen * 16;
-	for (i = 0; LIKELY(i < column_len); ++i, ++t) {
-		int32_t temp;
-		if (*t == max) {
-			temp = i / 16 + i % 16 * segLen;
-			if (temp < end_read) end_read = temp;
-		}
-	}
-
-	free(pvHmax);
-	free(pvE);
-	free(pvHLoad);
-	free(pvHStore); 	
-
-	/* Find the most possible 2nd best alignment. */
-	alignment_end* bests = (alignment_end*) calloc(2, sizeof(alignment_end));
-	bests[0].score = max + bias >= 255 ? 255 : max;
-	bests[0].ref = end_ref;
-	bests[0].read = end_read;
-	
-	bests[1].score = 0;
-	bests[1].ref = 0;
-	bests[1].read = 0;
-
-	edge = (end_ref - maskLen) > 0 ? (end_ref - maskLen) : 0;
-	for (i = 0; i < edge; i ++) {
-//			fprintf (stderr, "maxColumn[%d]: %d\n", i, maxColumn[i]); 
-		if (maxColumn[i] > bests[1].score) {
-			bests[1].score = maxColumn[i];
-			bests[1].ref = i;
-		}
-	}
-	edge = (end_ref + maskLen) > refLen ? refLen : (end_ref + maskLen);
-	for (i = edge + 1; i < refLen; i ++) {
-//			fprintf (stderr, "refLen: %d\tmaxColumn[%d]: %d\n", refLen, i, maxColumn[i]); 
-		if (maxColumn[i] > bests[1].score) {
-			bests[1].score = maxColumn[i];
-			bests[1].ref = i;
-		}
-	}
-	
-	free(maxColumn);
-	free(end_read_column);
-	return bests;
-}
-
-__m128i* qP_word (const int8_t* read_num,
-				  const int8_t* mat,
-				  const int32_t readLen,
-				  const int32_t n) { 
-					
-	int32_t segLen = (readLen + 7) / 8; 
-	__m128i* vProfile = (__m128i*)malloc(n * segLen * sizeof(__m128i));
-	int16_t* t = (int16_t*)vProfile;
-	int32_t nt, i, j;
-	int32_t segNum;
-	
-	/* Generate query profile rearrange query sequence & calculate the weight of match/mismatch */
-	for (nt = 0; LIKELY(nt < n); nt ++) {
-		for (i = 0; i < segLen; i ++) {
-			j = i; 
-			for (segNum = 0; LIKELY(segNum < 8) ; segNum ++) {
-				*t++ = j>= readLen ? 0 : mat[nt * n + read_num[j]];
-				j += segLen;
-			}
-		}
-	}
-	return vProfile;
-}
-
-alignment_end* sw_sse2_word (const int8_t* ref, 
-							 int8_t ref_dir,	// 0: forward ref; 1: reverse ref
-							 int32_t refLen,
-							 int32_t readLen, 
-							 const uint8_t weight_gapO, /* will be used as - */
-							 const uint8_t weight_gapE, /* will be used as - */
-						     __m128i* vProfile,
-							 uint16_t terminate, 
-							 int32_t maskLen) { 
-
-#define max8(m, vm) (vm) = _mm_max_epi16((vm), _mm_srli_si128((vm), 8)); \
-					(vm) = _mm_max_epi16((vm), _mm_srli_si128((vm), 4)); \
-					(vm) = _mm_max_epi16((vm), _mm_srli_si128((vm), 2)); \
-					(m) = _mm_extract_epi16((vm), 0)
-	
-	uint16_t max = 0;		                     /* the max alignment score */
-	int32_t end_read = readLen - 1;
-	int32_t end_ref = 0; /* 1_based best alignment ending point; Initialized as isn't aligned - 0. */
-	int32_t segLen = (readLen + 7) / 8; /* number of segment */
-	
-	/* array to record the largest score of each reference position */
-	uint16_t* maxColumn = (uint16_t*) calloc(refLen, 2); 
-	
-	/* array to record the alignment read ending position of the largest score of each reference position */
-	int32_t* end_read_column = (int32_t*) calloc(refLen, sizeof(int32_t));
-	
-	/* Define 16 byte 0 vector. */
-	__m128i vZero = _mm_set1_epi32(0);
-
-	__m128i* pvHStore = (__m128i*) calloc(segLen, sizeof(__m128i));
-	__m128i* pvHLoad = (__m128i*) calloc(segLen, sizeof(__m128i));
-	__m128i* pvE = (__m128i*) calloc(segLen, sizeof(__m128i));
-	__m128i* pvHmax = (__m128i*) calloc(segLen, sizeof(__m128i));
-
-	int32_t i, j, k;
-	/* 16 byte insertion begin vector */
-	__m128i vGapO = _mm_set1_epi16(weight_gapO);
-	
-	/* 16 byte insertion extension vector */
-	__m128i vGapE = _mm_set1_epi16(weight_gapE);	
-
-	/* 16 byte bias vector */
-	__m128i vMaxScore = vZero; /* Trace the highest score of the whole SW matrix. */
-	__m128i vMaxMark = vZero; /* Trace the highest score till the previous column. */	
-	__m128i vTemp;
-	int32_t edge, begin = 0, end = refLen, step = 1;
-
-	/* outer loop to process the reference sequence */
-	if (ref_dir == 1) {
-		begin = refLen - 1;
-		end = -1;
-		step = -1;
-	}
-	for (i = begin; LIKELY(i != end); i += step) {
-		int32_t cmp;
-		__m128i e = vZero, vF = vZero; /* Initialize F value to 0. 
-							   Any errors to vH values will be corrected in the Lazy_F loop. 
-							 */
-		__m128i vH = pvHStore[segLen - 1];
-		vH = _mm_slli_si128 (vH, 2); /* Shift the 128-bit value in vH left by 2 byte. */
-		
-		/* Swap the 2 H buffers. */
-		__m128i* pv = pvHLoad;
-		
-		__m128i vMaxColumn = vZero; /* vMaxColumn is used to record the max values of column i. */
-		
-		__m128i* vP = vProfile + ref[i] * segLen; /* Right part of the vProfile */
-		pvHLoad = pvHStore;
-		pvHStore = pv;
-		
-		/* inner loop to process the query sequence */
-		for (j = 0; LIKELY(j < segLen); j ++) {
-			vH = _mm_adds_epi16(vH, _mm_load_si128(vP + j));
-
-			/* Get max from vH, vE and vF. */
-			e = _mm_load_si128(pvE + j);
-			vH = _mm_max_epi16(vH, e);
-			vH = _mm_max_epi16(vH, vF);
-			vMaxColumn = _mm_max_epi16(vMaxColumn, vH);
-			
-			/* Save vH values. */
-			_mm_store_si128(pvHStore + j, vH);
-
-			/* Update vE value. */
-			vH = _mm_subs_epu16(vH, vGapO); /* saturation arithmetic, result >= 0 */
-			e = _mm_subs_epu16(e, vGapE);
-			e = _mm_max_epi16(e, vH);
-			_mm_store_si128(pvE + j, e);
-
-			/* Update vF value. */
-			vF = _mm_subs_epu16(vF, vGapE);
-			vF = _mm_max_epi16(vF, vH);
-			
-			/* Load the next vH. */
-			vH = _mm_load_si128(pvHLoad + j);
-		}
-
-		/* Lazy_F loop: has been revised to disallow adjecent insertion and then deletion, so don't update E(i, j), learn from SWPS3 */
-		for (k = 0; LIKELY(k < 8); ++k) {
-			vF = _mm_slli_si128 (vF, 2);
-			for (j = 0; LIKELY(j < segLen); ++j) {
-				vH = _mm_load_si128(pvHStore + j);
-				vH = _mm_max_epi16(vH, vF);
-				_mm_store_si128(pvHStore + j, vH);
-				vH = _mm_subs_epu16(vH, vGapO);
-				vF = _mm_subs_epu16(vF, vGapE);
-				if (UNLIKELY(! _mm_movemask_epi8(_mm_cmpgt_epi16(vF, vH)))) goto end;
-			}
-		}
-
-end:	
-		vMaxScore = _mm_max_epi16(vMaxScore, vMaxColumn);	
-		vTemp = _mm_cmpeq_epi16(vMaxMark, vMaxScore);
-		cmp = _mm_movemask_epi8(vTemp);
-		if (cmp != 0xffff) {
-			uint16_t temp; 
-			vMaxMark = vMaxScore;
-			max8(temp, vMaxScore);
-			vMaxScore = vMaxMark;
-			
-			if (LIKELY(temp > max)) {
-				max = temp;
-				end_ref = i;
-				for (j = 0; LIKELY(j < segLen); ++j) pvHmax[j] = pvHStore[j];
-			}
-		}
-		
-		/* Record the max score of current column. */	
-		max8(maxColumn[i], vMaxColumn);
-		if (maxColumn[i] == terminate) break;
-	} 	
-
-	/* Trace the alignment ending position on read. */
-	uint16_t *t = (uint16_t*)pvHmax;
-	int32_t column_len = segLen * 8;
-	for (i = 0; LIKELY(i < column_len); ++i, ++t) {
-		int32_t temp;
-		if (*t == max) {
-			temp = i / 8 + i % 8 * segLen;
-			if (temp < end_read) end_read = temp;
-		}
-	}
-
-	free(pvHmax);
-	free(pvE);
-	free(pvHLoad);
-	free(pvHStore); 
-	
-	/* Find the most possible 2nd best alignment. */
-	alignment_end* bests = (alignment_end*) calloc(2, sizeof(alignment_end));
-	bests[0].score = max;
-	bests[0].ref = end_ref;
-	bests[0].read = end_read;
-	
-	bests[1].score = 0;
-	bests[1].ref = 0;
-	bests[1].read = 0;
-
-	edge = (end_ref - maskLen) > 0 ? (end_ref - maskLen) : 0;
-	for (i = 0; i < edge; i ++) {
-		if (maxColumn[i] > bests[1].score) { 
-			bests[1].score = maxColumn[i];
-			bests[1].ref = i;
-		}
-	}
-	edge = (end_ref + maskLen) > refLen ? refLen : (end_ref + maskLen);
-	for (i = edge; i < refLen; i ++) {
-		if (maxColumn[i] > bests[1].score) {
-			bests[1].score = maxColumn[i];
-			bests[1].ref = i;
-		}
-	}
-	
-	free(maxColumn);
-	free(end_read_column);
-	return bests;
-}
-
-cigar* banded_sw (const int8_t* ref,
-				 const int8_t* read, 
-				 int32_t refLen, 
-				 int32_t readLen,
-				 int32_t score,
-				 const uint32_t weight_gapO,  /* will be used as - */
-				 const uint32_t weight_gapE,  /* will be used as - */
-				 int32_t band_width,
-				 const int8_t* mat,	/* pointer to the weight matrix */
-				 int32_t n) {	
-
-	uint32_t *c = (uint32_t*)malloc(16 * sizeof(uint32_t)), *c1;
-	int32_t i, j, e, f, temp1, temp2, s = 16, s1 = 8, s2 = 1024, l, max = 0;
-	int32_t width, width_d, *h_b, *e_b, *h_c;
-	int8_t *direction, *direction_line;
-	cigar* result = (cigar*)malloc(sizeof(cigar));
-	h_b = (int32_t*)malloc(s1 * sizeof(int32_t)); 
-	e_b = (int32_t*)malloc(s1 * sizeof(int32_t)); 
-	h_c = (int32_t*)malloc(s1 * sizeof(int32_t)); 
-	direction = (int8_t*)malloc(s2 * sizeof(int8_t));
-
-	do {
-		width = band_width * 2 + 3, width_d = band_width * 2 + 1;
-		while (width >= s1) {
-			++s1;
-			kroundup32(s1);
-			h_b = (int32_t*)realloc(h_b, s1 * sizeof(int32_t)); 
-			e_b = (int32_t*)realloc(e_b, s1 * sizeof(int32_t)); 
-			h_c = (int32_t*)realloc(h_c, s1 * sizeof(int32_t)); 
-		}
-		while (width_d * readLen * 3 >= s2) {
-			++s2;
-			kroundup32(s2);
-			if (s2 < 0) {
-				fprintf(stderr, "Alignment score and position are not consensus.\n");
-				exit(1);
-			}
-			direction = (int8_t*)realloc(direction, s2 * sizeof(int8_t)); 
-		}
-		direction_line = direction;
-		for (j = 1; LIKELY(j < width - 1); j ++) h_b[j] = 0;
-		for (i = 0; LIKELY(i < readLen); i ++) {
-			int32_t beg = 0, end = refLen - 1, u = 0, edge;
-			j = i - band_width;	beg = beg > j ? beg : j; // band start
-			j = i + band_width; end = end < j ? end : j; // band end
-			edge = end + 1 < width - 1 ? end + 1 : width - 1;
-			f = h_b[0] = e_b[0] = h_b[edge] = e_b[edge] = h_c[0] = 0;
-			direction_line = direction + width_d * i * 3;
-
-			for (j = beg; LIKELY(j <= end); j ++) {
-				int32_t b, e1, f1, d, de, df, dh;
-				set_u(u, band_width, i, j);	set_u(e, band_width, i - 1, j); 
-				set_u(b, band_width, i, j - 1); set_u(d, band_width, i - 1, j - 1);
-				set_d(de, band_width, i, j, 0);
-				set_d(df, band_width, i, j, 1);
-				set_d(dh, band_width, i, j, 2);
-
-				temp1 = i == 0 ? -weight_gapO : h_b[e] - weight_gapO;
-				temp2 = i == 0 ? -weight_gapE : e_b[e] - weight_gapE;
-				e_b[u] = temp1 > temp2 ? temp1 : temp2;
-				direction_line[de] = temp1 > temp2 ? 3 : 2;
-		
-				temp1 = h_c[b] - weight_gapO;
-				temp2 = f - weight_gapE;
-				f = temp1 > temp2 ? temp1 : temp2;
-				direction_line[df] = temp1 > temp2 ? 5 : 4;
-				
-				e1 = e_b[u] > 0 ? e_b[u] : 0;
-				f1 = f > 0 ? f : 0;
-				temp1 = e1 > f1 ? e1 : f1;
-				temp2 = h_b[d] + mat[ref[j] * n + read[i]];
-				h_c[u] = temp1 > temp2 ? temp1 : temp2;
-		
-				if (h_c[u] > max) max = h_c[u];
-		
-				if (temp1 <= temp2) direction_line[dh] = 1;
-				else direction_line[dh] = e1 > f1 ? direction_line[de] : direction_line[df];
-			}
-			for (j = 1; j <= u; j ++) h_b[j] = h_c[j];
-		}
-		band_width *= 2;
-	} while (LIKELY(max < score));
-	band_width /= 2;
-
-	// trace back
-	i = readLen - 1;
-	j = refLen - 1;
-	e = 0;	// Count the number of M, D or I.
-	l = 0;	// record length of current cigar
-	f = max = 0; // M
-	temp2 = 2;	// h
-	while (LIKELY(i > 0)) {
-		set_d(temp1, band_width, i, j, temp2);
-		switch (direction_line[temp1]) {
-			case 1: 
-				--i;
-				--j;
-				temp2 = 2;
-				direction_line -= width_d * 3;
-				f = 0;	// M
-				break;
-			case 2:
-			 	--i;
-				temp2 = 0;	// e
-				direction_line -= width_d * 3;
-				f = 1;	// I
-				break;		
-			case 3:
-				--i;
-				temp2 = 2;
-				direction_line -= width_d * 3;
-				f = 1;	// I
-				break;
-			case 4:
-				--j;
-				temp2 = 1;
-				f = 2;	// D
-				break;
-			case 5:
-				--j;
-				temp2 = 2;
-				f = 2;	// D
-				break;
-			default: 
-				fprintf(stderr, "Trace back error: %d.\n", direction_line[temp1 - 1]);
-				return 0;
-		}
-		if (f == max) ++e;
-		else {
-			++l;
-			while (l >= s) {
-				++s;
-				kroundup32(s);
-				c = (uint32_t*)realloc(c, s * sizeof(uint32_t));
-			}
-			c[l - 1] = e<<4|max;
-			max = f;
-			e = 1;
-		}
-	}
-	if (f == 0) {
-		++l;
-		while (l >= s) {
-			++s;
-			kroundup32(s);
-			c = (uint32_t*)realloc(c, s * sizeof(uint32_t));
-		}
-		c[l - 1] = (e+1)<<4;
-	}else {
-		l += 2;
-		while (l >= s) {
-			++s;
-			kroundup32(s);
-			c = (uint32_t*)realloc(c, s * sizeof(uint32_t));
-		}
-		c[l - 2] = e<<4|f;
-		c[l - 1] = 16;	// 1M
-	}
-
-	// reverse cigar
-	c1 = (uint32_t*)malloc(l * sizeof(uint32_t));
-	s = 0;
-	e = l - 1;
-	while (LIKELY(s <= e)) {			
-		c1[s] = c[e];		
-		c1[e] = c[s];		
-		++ s;					
-		-- e;						
-	}								
-	result->seq = c1;
-	result->length = l;
-
-	free(direction);
-	free(h_c);
-	free(e_b);
-	free(h_b);
-	free(c);
-	return result;
-}
-
-int8_t* seq_reverse(const int8_t* seq, int32_t end)	/* end is 0-based alignment ending position */	
-{									
-	int8_t* reverse = (int8_t*)calloc(end + 1, sizeof(int8_t));	
-	int32_t start = 0;
-	while (LIKELY(start <= end)) {			
-		reverse[start] = seq[end];		
-		reverse[end] = seq[start];		
-		++ start;					
-		-- end;						
-	}								
-	return reverse;					
-}
-		
-s_profile* ssw_init (const int8_t* read, const int32_t readLen, const int8_t* mat, const int32_t n, const int8_t score_size) {
-	s_profile* p = (s_profile*)calloc(1, sizeof(struct _profile));
-	p->profile_byte = 0;
-	p->profile_word = 0;
-	p->bias = 0;
-	
-	if (score_size == 0 || score_size == 2) {
-		/* Find the bias to use in the substitution matrix */
-		int32_t bias = 0, i;
-		for (i = 0; i < n*n; i++) if (mat[i] < bias) bias = mat[i];
-		bias = abs(bias);
-
-		p->bias = bias;
-		p->profile_byte = qP_byte (read, mat, readLen, n, bias);
-	}
-	if (score_size == 1 || score_size == 2) p->profile_word = qP_word (read, mat, readLen, n);
-	p->read = read;
-	p->mat = mat;
-	p->readLen = readLen;
-	p->n = n;
-	return p;
-}
-
-void init_destroy (s_profile* p) {
-	free(p->profile_byte);
-	free(p->profile_word);
-	free(p);
-}
-
-s_align* ssw_align (const s_profile* prof, 
-					const int8_t* ref, 
-				  	int32_t refLen, 
-				  	const uint8_t weight_gapO, 
-				  	const uint8_t weight_gapE, 
-					const uint8_t flag,	//  (from high to low) bit 5: return the best alignment beginning position; 6: if (ref_end1 - ref_begin1 <= filterd) && (read_end1 - read_begin1 <= filterd), return cigar; 7: if max score >= filters, return cigar; 8: always return cigar; if 6 & 7 are both setted, only return cigar when both filter fulfilled
-					const uint16_t filters,
-					const int32_t filterd,
-					const int32_t maskLen) {
-
-	alignment_end* bests = 0, *bests_reverse = 0;
-	__m128i* vP = 0;
-	int32_t word = 0, band_width = 0, readLen = prof->readLen;
-	int8_t* read_reverse = 0;
-	cigar* path;
-	s_align* r = (s_align*)calloc(1, sizeof(s_align));
-	r->ref_begin1 = -1;
-	r->read_begin1 = -1;
-	r->cigar = 0;
-	r->cigarLen = 0;
-	if (maskLen < 15) {
-		fprintf(stderr, "When maskLen < 15, the function ssw_align doesn't return 2nd best alignment information.\n");
-	}
-
-	// Find the alignment scores and ending positions
-	if (prof->profile_byte) {
-		bests = sw_sse2_byte(ref, 0, refLen, readLen, weight_gapO, weight_gapE, prof->profile_byte, -1, prof->bias, maskLen);
-		if (prof->profile_word && bests[0].score == 255) {
-			free(bests);
-			bests = sw_sse2_word(ref, 0, refLen, readLen, weight_gapO, weight_gapE, prof->profile_word, -1, maskLen);
-			word = 1;
-		} else if (bests[0].score == 255) {
-			fprintf(stderr, "Please set 2 to the score_size parameter of the function ssw_init, otherwise the alignment results will be incorrect.\n");
-			return 0;
-		}
-	}else if (prof->profile_word) {
-		bests = sw_sse2_word(ref, 0, refLen, readLen, weight_gapO, weight_gapE, prof->profile_word, -1, maskLen);
-		word = 1;
-	}else {
-		fprintf(stderr, "Please call the function ssw_init before ssw_align.\n");
-		return 0;
-	}
-	r->score1 = bests[0].score;
-	r->ref_end1 = bests[0].ref;
-	r->read_end1 = bests[0].read;
-	if (maskLen >= 15) {
-		r->score2 = bests[1].score;
-		r->ref_end2 = bests[1].ref;
-	} else {
-		r->score2 = 0;
-		r->ref_end2 = -1;
-	}
-	free(bests);
-	if (flag == 0 || (flag == 2 && r->score1 < filters)) goto end;
-
-	// Find the beginning position of the best alignment.
-	read_reverse = seq_reverse(prof->read, r->read_end1);
-	if (word == 0) {
-		vP = qP_byte(read_reverse, prof->mat, r->read_end1 + 1, prof->n, prof->bias);
-		bests_reverse = sw_sse2_byte(ref, 1, r->ref_end1 + 1, r->read_end1 + 1, weight_gapO, weight_gapE, vP, r->score1, prof->bias, maskLen);
-	} else {
-		vP = qP_word(read_reverse, prof->mat, r->read_end1 + 1, prof->n);
-		bests_reverse = sw_sse2_word(ref, 1, r->ref_end1 + 1, r->read_end1 + 1, weight_gapO, weight_gapE, vP, r->score1, maskLen);
-	}
-	free(vP);
-	free(read_reverse);
-	r->ref_begin1 = bests_reverse[0].ref;
-	r->read_begin1 = r->read_end1 - bests_reverse[0].read;
-	free(bests_reverse);
-	if ((7&flag) == 0 || ((2&flag) != 0 && r->score1 < filters) || ((4&flag) != 0 && (r->ref_end1 - r->ref_begin1 > filterd || r->read_end1 - r->read_begin1 > filterd))) goto end;
-
-	// Generate cigar.
-	refLen = r->ref_end1 - r->ref_begin1 + 1;
-	readLen = r->read_end1 - r->read_begin1 + 1;
-	band_width = abs(refLen - readLen) + 1;
-	path = banded_sw(ref + r->ref_begin1, prof->read + r->read_begin1, refLen, readLen, r->score1, weight_gapO, weight_gapE, band_width, prof->mat, prof->n);
-	if (path == 0) r = 0;
-	else {
-		r->cigar = path->seq;
-		r->cigarLen = path->length;
-		free(path);
-	}
-	
-end: 
-	return r;
-}
-
-void align_destroy (s_align* a) {
-	free(a->cigar);
-	free(a);
-}
diff --git a/vcflib/src/ssw.h b/vcflib/src/ssw.h
deleted file mode 100644
index 3cb45c8..0000000
--- a/vcflib/src/ssw.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- *  ssw.h
- *
- *  Created by Mengyao Zhao on 6/22/10.
- *  Copyright 2010 Boston College. All rights reserved.
- *	Version 0.1.4
- *	Last revision by Mengyao Zhao on 07/31/12.
- *
- */
-
-#ifndef SSW_H
-#define SSW_H
-
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-#include <emmintrin.h>
-
-/*!	@typedef	structure of the query profile	*/
-struct _profile;
-typedef struct _profile s_profile;
-
-/*!	@typedef	structure of the alignment result
-	@field	score1	the best alignment score
-	@field	score2	sub-optimal alignment score
-	@field	ref_begin1	0-based best alignment beginning position on reference;	ref_begin1 = -1 when the best alignment beginning 
-						position is not available
-	@field	ref_end1	0-based best alignment ending position on reference
-	@field	read_begin1	0-based best alignment beginning position on read; read_begin1 = -1 when the best alignment beginning 
-						position is not available
-	@field	read_end1	0-based best alignment ending position on read
-	@field	read_end2	0-based sub-optimal alignment ending position on read
-	@field	cigar	best alignment cigar; stored the same as that in BAM format, high 28 bits: length, low 4 bits: M/I/D (0/1/2); 
-					cigar = 0 when the best alignment path is not available
-	@field	cigarLen	length of the cigar string; cigarLen = 0 when the best alignment path is not available
-*/
-typedef struct {
-	uint16_t score1;	
-	uint16_t score2;	
-	int32_t ref_begin1;	
-	int32_t ref_end1;	
-	int32_t	read_begin1;	
-	int32_t read_end1;	
-	int32_t ref_end2;
-	uint32_t* cigar;	
-	int32_t cigarLen;	
-} s_align;
-
-#ifdef __cplusplus
-extern "C" {
-#endif	// __cplusplus
-
-/*!	@function	Create the query profile using the query sequence.
-	@param	read	pointer to the query sequence; the query sequence needs to be numbers
-	@param	readLen	length of the query sequence
-	@param	mat	pointer to the substitution matrix; mat needs to be corresponding to the read sequence
-	@param	n	the square root of the number of elements in mat (mat has n*n elements)
-	@param	score_size	estimated Smith-Waterman score; if your estimated best alignment score is surely < 255 please set 0; if 
-						your estimated best alignment score >= 255, please set 1; if you don't know, please set 2 
-	@return	pointer to the query profile structure
-	@note	example for parameter read and mat:
-			If the query sequence is: ACGTATC, the sequence that read points to can be: 1234142
-			Then if the penalty for match is 2 and for mismatch is -2, the substitution matrix of parameter mat will be:
-			//A  C  G  T  
-			  2 -2 -2 -2 //A
-			 -2  2 -2 -2 //C
-			 -2 -2  2 -2 //G
-			 -2 -2 -2  2 //T
-			mat is the pointer to the array {2, -2, -2, -2, -2, 2, -2, -2, -2, -2, 2, -2, -2, -2, -2, 2}
-*/
-s_profile* ssw_init (const int8_t* read, const int32_t readLen, const int8_t* mat, const int32_t n, const int8_t score_size);
-
-/*!	@function	Release the memory allocated by function ssw_init.
-	@param	p	pointer to the query profile structure	
-*/
-void init_destroy (s_profile* p);
-
-// @function	ssw alignment.
-/*!	@function	Do Striped Smith-Waterman alignment.
-	@param	prof	pointer to the query profile structure
-	@param	ref	pointer to the target sequence; the target sequence needs to be numbers and corresponding to the mat parameter of
-				function ssw_init
-	@param	refLen	length of the target sequence
-	@param	weight_gapO	the absolute value of gap open penalty  
-	@param	weight_gapE	the absolute value of gap extension penalty
-	@param	flag	bitwise FLAG; (from high to low) bit 5: when setted as 1, function ssw_align will return the best alignment 
-					beginning position; bit 6: when setted as 1, if (ref_end1 - ref_begin1 < filterd && read_end1 - read_begin1 
-					< filterd), (whatever bit 5 is setted) the function will return the best alignment beginning position and 
-					cigar; bit 7: when setted as 1, if the best alignment score >= filters, (whatever bit 5 is setted) the function
-  					will return the best alignment beginning position and cigar; bit 8: when setted as 1, (whatever bit 5, 6 or 7 is
- 					setted) the function will always return the best alignment beginning position and cigar
-	@param	filters	score filter: when bit 7 of flag is setted as 1 and bit 8 is setted as 0, filters will be used (Please check the
- 					decription of the flag parameter for detailed usage.)
-	@param	filterd	distance filter: when bit 6 of flag is setted as 1 and bit 8 is setted as 0, filterd will be used (Please check 
-					the decription of the flag parameter for detailed usage.)
-	@param	maskLen	The distance between the optimal and suboptimal alignment ending position >= maskLen. We suggest to use 
-					readLen/2, if you don't have special concerns. Note: maskLen has to be >= 15, otherwise this function will NOT 
-					return the suboptimal alignment information. Detailed description of maskLen: After locating the optimal
-					alignment ending position, the suboptimal alignment score can be heuristically found by checking the second 
-					largest score in the array that contains the maximal score of each column of the SW matrix. In order to avoid 
-					picking the scores that belong to the alignments sharing the partial best alignment, SSW C library masks the 
-					reference loci nearby (mask length = maskLen) the best alignment ending position and locates the second largest 
-					score from the unmasked elements.
-	@return	pointer to the alignment result structure 
-	@note	Whatever the parameter flag is setted, this function will at least return the optimal and sub-optimal alignment score,
-			and the optimal alignment ending positions on target and query sequences. If both bit 6 and 7 of the flag are setted
-			while bit 8 is not, the function will return cigar only when both criteria are fulfilled. All returned positions are 
-			0-based coordinate.  	
-*/
-s_align* ssw_align (const s_profile* prof, 
-					const int8_t* ref, 
-					int32_t refLen, 
-					const uint8_t weight_gapO, 
-					const uint8_t weight_gapE, 
-					const uint8_t flag,	
-					const uint16_t filters,
-					const int32_t filterd,
-					const int32_t maskLen);
-
-/*!	@function	Release the memory allocated by function ssw_align.
-	@param	a	pointer to the alignment result structure
-*/
-void align_destroy (s_align* a);
-
-#ifdef __cplusplus
-}
-#endif	// __cplusplus
-
-#endif	// SSW_H
diff --git a/vcflib/src/ssw_cpp.cpp b/vcflib/src/ssw_cpp.cpp
deleted file mode 100644
index ea260de..0000000
--- a/vcflib/src/ssw_cpp.cpp
+++ /dev/null
@@ -1,399 +0,0 @@
-#include "ssw_cpp.h"
-
-#include <sstream>
-
-extern "C" {
-#include "ssw.h"
-}
-
-namespace {
-
-static int8_t kBaseTranslation[128] = {
-    4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4, 
-    4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4, 
-    4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,
-    4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4, 
-  //   A     C            G
-    4, 0, 4, 1,  4, 4, 4, 2,  4, 4, 4, 4,  4, 4, 4, 4, 
-  //             T
-    4, 4, 4, 4,  3, 0, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4, 
-  //   a     c            g
-    4, 0, 4, 1,  4, 4, 4, 2,  4, 4, 4, 4,  4, 4, 4, 4, 
-  //             t
-    4, 4, 4, 4,  3, 0, 4, 4,  4, 4, 4, 4,  4, 4, 4, 4 
-};
-
-void BuildSwScoreMatrix(const uint8_t& match_score, 
-                        const uint8_t& mismatch_penalty,
-			int8_t* matrix) {
-
-  // The score matrix looks like
-  //                 // A,  C,  G,  T,  N
-  //  score_matrix_ = { 2, -2, -2, -2,  0, // A
-  //                   -2,  2, -2, -2,  0, // C
-  //                   -2, -2,  2, -2,  0, // G
-  //                   -2, -2, -2,  2,  0, // T
-  //                    0,  0,  0,  0,  0};// N
-
-  int id = 0;
-  for (int i = 0; i < 4; ++i) {
-    for (int j = 0; j < 4; ++j) {
-      matrix[id] = ((i == j) ? match_score : static_cast<int8_t>(-mismatch_penalty));
-      ++id;
-    }
-    matrix[id] = 0;
-    ++id;
-  }
-
-  for (int i = 0; i < 5; ++i)
-    matrix[id++] = 0;
-    
-}
-
-void ConvertAlignment(const s_align& s_al, 
-                      const int& query_len, 
-                      StripedSmithWaterman::Alignment* al) {
-  al->sw_score           = s_al.score1;
-  al->sw_score_next_best = s_al.score2;
-  al->ref_begin          = s_al.ref_begin1;
-  al->ref_end            = s_al.ref_end1;
-  al->query_begin        = s_al.read_begin1;
-  al->query_end          = s_al.read_end1;
-  al->ref_end_next_best  = s_al.ref_end2;
-
-  al->cigar.clear();
-  al->cigar_string.clear();
-  
-  if (s_al.cigarLen > 0) {
-    std::ostringstream cigar_string;
-    if (al->query_begin > 0) {
-      uint32_t cigar = (al->query_begin << 4) | 0x0004;
-      al->cigar.push_back(cigar);
-      cigar_string << al->query_begin << 'S';
-    }
-
-    for (int i = 0; i < s_al.cigarLen; ++i) {
-      al->cigar.push_back(s_al.cigar[i]);
-      cigar_string << (s_al.cigar[i] >> 4);
-      uint8_t op = s_al.cigar[i] & 0x000f;
-      switch(op) {
-        case 0: cigar_string << 'M'; break;
-        case 1: cigar_string << 'I'; break;
-        case 2: cigar_string << 'D'; break;
-      }
-    }
-
-    int end = query_len - al->query_end - 1;
-    if (end > 0) {
-      uint32_t cigar = (end << 4) | 0x0004;
-      al->cigar.push_back(cigar);
-      cigar_string << end << 'S';
-    }
-
-    al->cigar_string = cigar_string.str();
-  } // end if
-}
-
-int CalculateNumberMismatch(
-    const StripedSmithWaterman::Alignment& al,
-    const int8_t* matrix,
-    int8_t const *ref,
-    int8_t const *query) {
-  
-  ref   += al.ref_begin;
-  query += al.query_begin;
-  int mismatch_length = 0;
-  for (unsigned int i = 0; i < al.cigar.size(); ++i) {
-    int32_t op = al.cigar[i] & 0x0000000f;
-    int32_t length = (al.cigar[i] >> 4) & 0x0fffffff;
-    if (op == 0) { // M
-      for (int j = 0; j < length; ++j) {
-        if (matrix[*ref] != matrix[*query]) ++mismatch_length;
-	++ref;
-	++query;
-      }
-    } else if (op == 1) { // I
-      query += length;
-      mismatch_length += length;
-    } else if (op == 2) { // D
-      ref += length;
-      mismatch_length += length;
-    }
-  }
-
-  return mismatch_length;
-}
-
-void SetFlag(const StripedSmithWaterman::Filter& filter, uint8_t* flag) {
-  if (filter.report_begin_position) *flag |= 0x08;
-  if (filter.report_cigar) *flag |= 0x0f;
-}
-
-} // namespace
-
-
-
-namespace StripedSmithWaterman {
-
-Aligner::Aligner(void)
-    : score_matrix_(NULL)
-    , score_matrix_size_(5)
-    , translation_matrix_(NULL)
-    , default_matrix_(false)
-    , matrix_built_(false)
-    , match_score_(2)
-    , mismatch_penalty_(2)
-    , gap_opening_penalty_(3)
-    , gap_extending_penalty_(1)
-    , translated_reference_(NULL)
-    , reference_length_(0)
-{
-  BuildDefaultMatrix();
-}
-
-Aligner::Aligner(
-    const uint8_t& match_score,
-    const uint8_t& mismatch_penalty,
-    const uint8_t& gap_opening_penalty,
-    const uint8_t& gap_extending_penalty)
-
-    : score_matrix_(NULL)
-    , score_matrix_size_(5)
-    , translation_matrix_(NULL)
-    , default_matrix_(false)
-    , matrix_built_(false)
-    , match_score_(match_score)
-    , mismatch_penalty_(mismatch_penalty)
-    , gap_opening_penalty_(gap_opening_penalty)
-    , gap_extending_penalty_(gap_extending_penalty)
-    , translated_reference_(NULL)
-    , reference_length_(0)
-{
-  BuildDefaultMatrix();
-}
-
-Aligner::Aligner(const int8_t* score_matrix,
-                 const int&    score_matrix_size,
-	         const int8_t* translation_matrix,
-		 const int&    translation_matrix_size)
-    
-    : score_matrix_(NULL)
-    , score_matrix_size_(score_matrix_size)
-    , translation_matrix_(NULL)
-    , default_matrix_(true)
-    , matrix_built_(false)
-    , match_score_(2)
-    , mismatch_penalty_(2)
-    , gap_opening_penalty_(3)
-    , gap_extending_penalty_(1)
-    , translated_reference_(NULL)
-    , reference_length_(0)
-{
-  score_matrix_ = new int8_t[score_matrix_size_ * score_matrix_size_];
-  memcpy(score_matrix_, score_matrix, sizeof(int8_t) * score_matrix_size_ * score_matrix_size_);
-  translation_matrix_ = new int8_t[translation_matrix_size];
-  memcpy(translation_matrix_, translation_matrix, sizeof(int8_t) * translation_matrix_size);
-  matrix_built_ = true;
-}
-
-
-Aligner::~Aligner(void){
-  Clear();
-}
-
-int Aligner::SetReferenceSequence(const char* seq, const int& length) {
-  
-  int len = 0;
-  if (matrix_built_) {
-    // calculate the valid length
-    int calculated_ref_length = static_cast<int>(strlen(seq));
-    int valid_length = (calculated_ref_length > length) 
-                       ? length : calculated_ref_length;
-    // delete the current buffer
-    CleanReferenceSequence();
-    // allocate a new buffer
-    translated_reference_ = new int8_t[valid_length];
-  
-    len = TranslateBase(seq, valid_length, translated_reference_);
-  } else {
-    // nothing
-  }
-
-  reference_length_ = len;
-  return len;
-
-
-}
-
-int Aligner::TranslateBase(const char* bases, const int& length, 
-    int8_t* translated) const {
-
-  char* ptr = (char*)bases;
-  int len = 0;
-  for (int i = 0; i < length; ++i) {
-    translated[i] = translation_matrix_[(int) *ptr];
-    ++ptr;
-    ++len;
-  }
-
-  return len;
-}
-
-
-bool Aligner::Align(const char* query, const Filter& filter, 
-                    Alignment* alignment) const
-{
-  if (!matrix_built_) return false;
-  if (reference_length_ == 0) return false;
-
-  int query_len = strlen(query);
-  if (query_len == 0) return false;
-  int8_t* translated_query = new int8_t[query_len];
-  TranslateBase(query, query_len, translated_query);
-
-  const int8_t score_size = 2;
-  s_profile* profile = ssw_init(translated_query, query_len, score_matrix_, 
-                                score_matrix_size_, score_size);
-
-  uint8_t flag = 0;
-  SetFlag(filter, &flag);
-  s_align* s_al = ssw_align(profile, translated_reference_, reference_length_,
-                                 static_cast<int>(gap_opening_penalty_), 
-				 static_cast<int>(gap_extending_penalty_),
-				 flag, filter.score_filter, filter.distance_filter, query_len);
-  
-  alignment->Clear();
-  ConvertAlignment(*s_al, query_len, alignment);
-  alignment->mismatches = CalculateNumberMismatch(*alignment, score_matrix_, translated_reference_, translated_query);
-
-
-  // Free memory
-  if (query_len > 1) delete [] translated_query;
-  else delete translated_query;
-  align_destroy(s_al);
-  init_destroy(profile);
-
-  return true;
-}
-
-
-bool Aligner::Align(const char* query, const char* ref, const int& ref_len,
-                    const Filter& filter, Alignment* alignment) const
-{
-  if (!matrix_built_) return false;
-  
-  int query_len = strlen(query);
-  if (query_len == 0) return false;
-  int8_t* translated_query = new int8_t[query_len];
-  TranslateBase(query, query_len, translated_query);
-
-  // calculate the valid length
-  int calculated_ref_length = static_cast<int>(strlen(ref));
-  int valid_ref_len = (calculated_ref_length > ref_len) 
-                      ? ref_len : calculated_ref_length;
-  int8_t* translated_ref = new int8_t[valid_ref_len];
-  TranslateBase(ref, valid_ref_len, translated_ref);
-
-
-  const int8_t score_size = 2;
-  s_profile* profile = ssw_init(translated_query, query_len, score_matrix_, 
-                                score_matrix_size_, score_size);
-
-  uint8_t flag = 0;
-  SetFlag(filter, &flag);
-  s_align* s_al = ssw_align(profile, translated_ref, valid_ref_len,
-                                 static_cast<int>(gap_opening_penalty_), 
-				 static_cast<int>(gap_extending_penalty_),
-				 flag, filter.score_filter, filter.distance_filter, query_len);
-  
-  alignment->Clear();
-  ConvertAlignment(*s_al, query_len, alignment);
-  alignment->mismatches = CalculateNumberMismatch(*alignment, score_matrix_, translated_ref, translated_query);
-
-  // Free memory
-  if (query_len > 1) delete [] translated_query;
-  else delete translated_query;
-  if (valid_ref_len > 1) delete [] translated_ref;
-  else delete translated_ref;
-  align_destroy(s_al);
-  init_destroy(profile);
-
-  return true;
-}
-
-void Aligner::Clear(void) {
-  if (score_matrix_) delete [] score_matrix_;
-  score_matrix_ = NULL;
-
-  if (!default_matrix_ && translation_matrix_) 
-    delete [] translation_matrix_;
-  translation_matrix_ = NULL;
-
-  CleanReferenceSequence();
-
-  default_matrix_ = false;
-  matrix_built_   = false;
-}
-
-void Aligner::SetAllDefault(void) {
-  score_matrix_size_     = 5;
-  default_matrix_        = false;
-  matrix_built_          = false;
-  match_score_           = 2;
-  mismatch_penalty_      = 2;
-  gap_opening_penalty_   = 3;
-  gap_extending_penalty_ = 1;
-  reference_length_      = 0;
-}
-
-bool Aligner::ReBuild(void) {
-  if (matrix_built_) return false;
-
-  SetAllDefault();
-  BuildDefaultMatrix();
-
-  return true;
-}
-
-bool Aligner::ReBuild(
-    const uint8_t& match_score,
-    const uint8_t& mismatch_penalty,
-    const uint8_t& gap_opening_penalty,
-    const uint8_t& gap_extending_penalty) {
-  if (matrix_built_) return false;
-
-  SetAllDefault();
-
-  match_score_           = match_score;
-  mismatch_penalty_      = mismatch_penalty;
-  gap_opening_penalty_   = gap_opening_penalty;
-  gap_extending_penalty_ = gap_extending_penalty;
-
-  BuildDefaultMatrix();
-
-  return true;
-}
-
-bool Aligner::ReBuild(
-    const int8_t* score_matrix,
-    const int&    score_matrix_size,
-    const int8_t* translation_matrix,
-    const int&    translation_matrix_size) {
-
-  score_matrix_ = new int8_t[score_matrix_size_ * score_matrix_size_];
-  memcpy(score_matrix_, score_matrix, sizeof(int8_t) * score_matrix_size_ * score_matrix_size_);
-  translation_matrix_ = new int8_t[translation_matrix_size];
-  memcpy(translation_matrix_, translation_matrix, sizeof(int8_t) * translation_matrix_size);
-  matrix_built_ = true;
-
-  return true;
-}
-
-void Aligner::BuildDefaultMatrix(void) {
-  score_matrix_ = new int8_t[score_matrix_size_ * score_matrix_size_];
-  BuildSwScoreMatrix(match_score_, mismatch_penalty_, score_matrix_);
-  translation_matrix_ = kBaseTranslation;
-  matrix_built_   = true;
-  default_matrix_ = true;
-}
-} // namespace StripedSmithWaterman
diff --git a/vcflib/src/ssw_cpp.h b/vcflib/src/ssw_cpp.h
deleted file mode 100644
index fb10f4f..0000000
--- a/vcflib/src/ssw_cpp.h
+++ /dev/null
@@ -1,216 +0,0 @@
-#ifndef COMPLETE_STRIPED_SMITH_WATERMAN_CPP_H_
-#define COMPLETE_STRIPED_SMITH_WATERMAN_CPP_H_
-
-#include <stdint.h>
-#include <string>
-#include <vector>
-
-namespace StripedSmithWaterman {
-
-struct Alignment {
-  uint16_t sw_score;           // The best alignment score 
-  uint16_t sw_score_next_best; // The next best alignment score
-  int32_t  ref_begin;          // Reference begin position of the best alignment
-  int32_t  ref_end;            // Reference end position of the best alignment
-  int32_t  query_begin;        // Query begin position of the best alignment
-  int32_t  query_end;          // Query end position of the best alignment
-  int32_t  ref_end_next_best;  // Reference end position of the next best alignment
-  int32_t  mismatches;         // Number of mismatches of the alignment
-  std::string cigar_string;    // Cigar string of the best alignment
-  std::vector<uint32_t> cigar; // Cigar stored in the BAM format
-                               //   high 28 bits: length
-			       //   low 4 bits: M/I/D/S/X (0/1/2/4/8);
-  void Clear() {
-    sw_score           = 0;
-    sw_score_next_best = 0;
-    ref_begin          = 0;
-    ref_end            = 0;
-    query_begin        = 0;
-    query_end          = 0;
-    ref_end_next_best  = 0;
-    mismatches         = 0;
-    cigar_string.clear();
-    cigar.clear();
-  };
-};
-
-struct Filter {
-  // NOTE: No matter the filter, those five fields will be given anyway.
-  //       sw_score; sw_score_next_best; ref_end; query_end; ref_end_next_best.
-  
-  bool report_begin_position;    // Give ref_begin and query_begin. 
-                                 //   If it is not set, ref_begin and query_begin are -1.
-  bool report_cigar;             // Give cigar_string and cigar.
-                                 //   report_begin_position is automatically TRUE.
-  
-  // When *report_cigar* is true and alignment passes these two filters,
-  //   cigar_string and cigar will be given.
-  uint16_t score_filter;         // score >= score_filter
-  uint16_t distance_filter;      // ((ref_end - ref_begin) < distance_filter) &&
-                                 // ((query_end - read_begin) < distance_filter)
-
-  Filter()
-    : report_begin_position(true)
-    , report_cigar(true)
-    , score_filter(0)
-    , distance_filter(32767)
-  {};
-};
-
-class Aligner {
- public:
-  // =========
-  // @function Construct an Aligner on default values.
-  //             The function will build the {A.C,G,T,N} aligner.
-  //             If you target for other character aligners, then please
-  //             use the other constructor and pass the corresponding matrix in.
-  // =========
-  Aligner(void);
-  
-  // =========
-  // @function Construct an Aligner by assigning scores.
-  //             The function will build the {A.C,G,T,N} aligner.
-  //             If you target for other character aligners, then please
-  //             use the other constructor and pass the corresponding matrix in.
-  // =========
-  Aligner(const uint8_t& match_score,
-          const uint8_t& mismatch_penalty,
-	  const uint8_t& gap_opening_penalty,
-	  const uint8_t& gap_extending_penalty);
-  
-  // =========
-  // @function Construct an Aligner by the specific matrixs.
-  // =========
-  Aligner(const int8_t* score_matrix, 
-          const int&    score_matrix_size,
-          const int8_t* translation_matrix,
-	  const int&    translation_matrix_size);
-  
-  ~Aligner(void);
-
-  // =========
-  // @function Build the reference sequence and thus make 
-  //             Align(const char* query, s_align* alignment) function;
-  //             otherwise the reference should be given when aligning.
-  //           [NOTICE] If there exists a sequence, that one will be deleted 
-  //                    and replaced.
-  // @param    seq    The reference bases;
-  //                  [NOTICE] It is not necessary null terminated.
-  // @param    length The length of bases will be be built.
-  // @return   The length of the built bases.
-  // =========
-  int SetReferenceSequence(const char* seq, const int& length);
-
-  void CleanReferenceSequence(void);
-
-  // =========
-  // @function Set penalties for opening and extending gaps
-  //           [NOTICE] The defaults are 3 and 1 respectively.
-  // =========
-  void SetGapPenalty(const uint8_t& opening, const uint8_t& extending) {
-    gap_opening_penalty_ = opening;
-    gap_extending_penalty_ = extending;
-  };
-
-  void SetMismatchPenalty(const uint8_t& match, const uint8_t& mismatch) {
-    match_score_ = match;
-    mismatch_penalty_ = mismatch;
-  };
-
-  // =========
-  // @function Align the query againt the reference that is set by 
-  //             SetReferenceSequence.
-  // @param    query     The query sequence.
-  // @param    filter    The filter for the alignment.
-  // @param    alignment The container contains the result.
-  // @return   True: succeed; false: fail.
-  // =========
-  bool Align(const char* query, const Filter& filter, Alignment* alignment) const;
-
-  // =========
-  // @function Align the query againt the reference.
-  //           [NOTICE] The reference won't replace the reference 
-  //                      set by SetReferenceSequence.
-  // @param    query     The query sequence.
-  // @param    ref       The reference sequence.
-  //                     [NOTICE] It is not necessary null terminated.
-  // @param    ref_len   The length of the reference sequence.
-  // @param    filter    The filter for the alignment.
-  // @param    alignment The container contains the result.
-  // @return   True: succeed; false: fail.
-  // =========
-  bool Align(const char* query, const char* ref, const int& ref_len, 
-             const Filter& filter, Alignment* alignment) const;
-
-  // @function Clear up all containers and thus the aligner is disabled.
-  //             To rebuild the aligner please use Build functions.
-  void Clear(void);
-
-  // =========
-  // @function Rebuild the aligner's ability on default values.
-  //           [NOTICE] If the aligner is not cleaned, rebuilding will fail.
-  // @return   True: succeed; false: fail.
-  // =========
-  bool ReBuild(void);
-
-  // =========
-  // @function Rebuild the aligner's ability by the specific matrixs.
-  //           [NOTICE] If the aligner is not cleaned, rebuilding will fail.
-  // @return   True: succeed; false: fail.
-  // =========
-  bool ReBuild(
-          const uint8_t& match_score,
-          const uint8_t& mismatch_penalty,
-	  const uint8_t& gap_opening_penalty,
-	  const uint8_t& gap_extending_penalty);
-  
-  // =========
-  // @function Construct an Aligner by the specific matrixs.
-  //           [NOTICE] If the aligner is not cleaned, rebuilding will fail.
-  // @return   True: succeed; false: fail.
-  // =========
-  bool ReBuild(
-          const int8_t* score_matrix, 
-          const int&    score_matrix_size,
-          const int8_t* translation_matrix,
-	  const int&    translation_matrix_size);
-  
- private:
-  int8_t* score_matrix_;
-  int     score_matrix_size_;
-  int8_t* translation_matrix_;
-  bool    default_matrix_;
-  bool    matrix_built_;
-
-  uint8_t match_score_;           // default: 2
-  uint8_t mismatch_penalty_;      // default: 2
-  uint8_t gap_opening_penalty_;   // default: 3
-  uint8_t gap_extending_penalty_; // default: 1
-
-  int8_t* translated_reference_;
-  int32_t reference_length_;
-
-  int TranslateBase(const char* bases, const int& length, int8_t* translated) const;
-  void SetAllDefault(void);
-  void BuildDefaultMatrix(void);
-  
-  Aligner& operator= (const Aligner&);
-  Aligner (const Aligner&); 
-}; // class Aligner
-
-
-// ================
-// inline functions
-// ================
-inline void Aligner::CleanReferenceSequence(void) {
-  if (reference_length_ == 0) return;
-  
-  // delete the current buffer
-  if (reference_length_ > 1) delete [] translated_reference_;
-  else delete translated_reference_;
-  
-  reference_length_ = 0;
-}
-} // namespace StripedSmithWaterman
-
-#endif // COMPLETE_STRIPED_SMITH_WATERMAN_CPP_H_
diff --git a/vcflib/src/vcf2fasta.cpp b/vcflib/src/vcf2fasta.cpp
deleted file mode 100644
index 88de80a..0000000
--- a/vcflib/src/vcf2fasta.cpp
+++ /dev/null
@@ -1,264 +0,0 @@
-#include "Variant.h"
-#include "convert.h"
-#include "join.h"
-#include "split.h"
-#include <set>
-#include <getopt.h>
-#include "fastahack/Fasta.h"
-#include <iostream>
-#include <fstream>
-
-using namespace std;
-using namespace vcf;
-
-#define ALLELE_NULL -1
-
-
-class SampleFastaFile {
-
-public:
-
-    ofstream fastafile;
-    long int pos;
-    string linebuffer;
-    string filename;
-    string seqname;
-    int linewidth;
-
-    void write(string sequence) {
-        linebuffer += sequence;
-        while (linebuffer.length() > linewidth) {
-            fastafile << linebuffer.substr(0, linewidth) << endl;
-            linebuffer = linebuffer.substr(linewidth);
-        }
-    }
-
-    SampleFastaFile(void) { }
-
-    void open(string& m_filename, string& m_seqname, int m_linewidth = 80) {
-        filename = m_filename;
-        seqname = m_seqname;
-        pos = 0;
-        linewidth = m_linewidth;
-        if (fastafile.is_open()) fastafile.close();
-        fastafile.open(filename.c_str());
-        if (!fastafile.is_open()) {
-            cerr << "could not open " << filename << " for writing, exiting" << endl;
-            exit(1);
-        }
-        fastafile << ">" << seqname << endl;
-    }
-
-    ~SampleFastaFile(void) {
-        if (fastafile.is_open()) {
-            write(""); // flush
-            fastafile << linebuffer << endl;
-            fastafile.close();
-        }
-    }
-
-};
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [options] [file]" << endl
-         << endl
-         << "options:" << endl
-         << "    -f, --reference REF     Use this reference when decomposing samples." << endl
-         << "    -p, --prefix PREFIX     Affix this output prefix to each file, none by default" << endl
-         << "    -P, --default-ploidy N  Set a default ploidy for samples which do not have information in the first record (2)." << endl
-         << endl
-         << "Outputs sample_seq:N.fa for each sample, reference sequence, and chromosomal copy N in [0,1... ploidy]." << endl;
-        //<< "Impossible regions of haplotypes are noted with an error message.  The corresponding" << endl
-        //<< "regions of the output FASTA files will be marked as N." << endl
-    exit(0);
-}
-
-map<string, int>& getPloidies(Variant& var, map<string, int>& ploidies, int defaultPloidy=2) {
-    for (vector<string>::iterator s = var.sampleNames.begin(); s != var.sampleNames.end(); ++s) {
-        int p = ploidy(decomposeGenotype(var.getGenotype(*s)));
-        if (p == 0) ploidies[*s] = defaultPloidy;
-        else        ploidies[*s] = p;
-    }
-    return ploidies;
-}
-
-void closeOutputs(map<string, map<int, SampleFastaFile*> >& outputs) {
-    for (map<string, map<int, SampleFastaFile*> >::iterator f = outputs.begin(); f != outputs.end(); ++f) {
-        for (map<int, SampleFastaFile*>::iterator s = f->second.begin(); s != f->second.end(); ++s) {
-            delete s->second;
-        }
-    }
-}
-
-void initOutputs(map<string, map<int, SampleFastaFile*> >& outputs, vector<string>& sampleNames, string& seqName, map<string, int>& ploidies, string& prefix) {
-    closeOutputs(outputs);
-    for (vector<string>::iterator s = sampleNames.begin(); s != sampleNames.end(); ++s) {
-        map<int, SampleFastaFile*>& outs = outputs[*s];
-        int p = ploidies[*s];
-        for (int i = 0; i < p; ++i) {
-            string name = prefix + *s + "_" + seqName + ":" + convert(i) + ".fasta";
-            if (!outs[i]) {
-                SampleFastaFile* fp = new SampleFastaFile;
-                outs[i] = fp;
-            }
-            SampleFastaFile& f = *outs[i];
-            f.open(name, seqName);
-        }
-    }
-}
-
-void vcf2fasta(VariantCallFile& variantFile, FastaReference& reference, string& outputPrefix, int defaultPloidy) {
-    string lastSeq;
-    long int lastPos=0, lastEnd=0;
-    map<string, map<int, SampleFastaFile*> > outputs;
-    Variant var(variantFile);
-    map<string, int> lastPloidies;
-    while (variantFile.getNextVariant(var)) {
-        if (!var.isPhased()) {
-            cerr << "variant " << var.sequenceName << ":" << var.position << " is not phased, cannot convert to fasta" << endl;
-            exit(1);
-        }
-        map<string, int> ploidies;
-        getPloidies(var, ploidies, defaultPloidy);
-        if (var.sequenceName != lastSeq || lastSeq.empty()) {
-            if (!lastSeq.empty()) {
-                string ref5prime = reference.getSubSequence(lastSeq, lastEnd, reference.sequenceLength(lastSeq)-lastEnd);
-                for (map<string, map<int, SampleFastaFile*> >::iterator s = outputs.begin(); s != outputs.end(); ++s) {
-                    map<int, SampleFastaFile*>& f = s->second;
-                    for (map<int, SampleFastaFile*>::iterator o = f.begin(); o != f.end(); ++o) {
-                        o->second->write(ref5prime);
-                    }
-                }
-            }
-            initOutputs(outputs, var.sampleNames, var.sequenceName, ploidies, outputPrefix);
-            lastSeq = var.sequenceName;
-            lastPos = 0;
-        } else if (!lastPloidies.empty() && lastPloidies != ploidies) {
-            cerr << "cannot handle mid-sequence change of ploidy" << endl;
-            // in principle it should be possible...
-            // it's a matter of representation, GFASTA anyone?
-            exit(1);
-        }
-        lastPloidies = ploidies;
-        if (var.position < lastEnd) {
-            cerr << var.position << " vs " << lastEnd << endl;
-            cerr << "overlapping or out-of-order variants at " << var.sequenceName << ":" << var.position << endl;
-            exit(1);
-        }
-        // get reference sequences implied by last->current variant
-        string ref5prime;
-        if (var.position - 1 - lastEnd > 0) {
-            ref5prime = reference.getSubSequence(var.sequenceName, lastEnd, var.position - 1 - lastEnd);
-        }
-        // write alt/ref seqs for current variant based on phased genotypes
-        for (vector<string>::iterator s = var.sampleNames.begin(); s != var.sampleNames.end(); ++s) {
-            string& sample = *s;
-            vector<int> gt = decomposePhasedGenotype(var.getGenotype(sample));
-            // assume no-call == ref?
-            if (gt.empty()) {
-                cerr << "empty genotype for sample " << *s << " at " << var.sequenceName << ":" << var.position << endl;
-                exit(1);
-            }
-            int i = 0;
-            for (vector<int>::iterator g = gt.begin(); g != gt.end(); ++g, ++i) {
-                outputs[sample].at(i)->write(ref5prime+var.alleles.at(*g));
-            }
-        }
-        lastPos = var.position - 1;
-        lastEnd = lastPos + var.ref.size();
-    }
-    // write last sequences
-    {
-        string ref5prime = reference.getSubSequence(lastSeq, lastEnd, reference.sequenceLength(lastSeq)-lastEnd);
-        for (map<string, map<int, SampleFastaFile*> >::iterator s = outputs.begin(); s != outputs.end(); ++s) {
-            map<int, SampleFastaFile*>& f = s->second;
-            for (map<int, SampleFastaFile*>::iterator o = f.begin(); o != f.end(); ++o) {
-                o->second->write(ref5prime);
-            }
-        }
-    }
-    closeOutputs(outputs);
-    // outputs are closed by ~SampleFastaFile
-}
-
-int main(int argc, char** argv) {
-
-    VariantCallFile variantFile;
-    string fastaFileName;
-    int defaultPloidy;
-    string outputPrefix;
-
-    int c;
-    while (true) {
-        static struct option long_options[] =
-            {
-                /* These options set a flag. */
-                //{"verbose", no_argument,       &verbose_flag, 1},
-                {"help", no_argument, 0, 'h'},
-                {"reference", required_argument, 0, 'f'},
-                {"prefix", required_argument, 0, 'p'},
-                {"default-ploidy", required_argument, 0, 'P'},
-                {0, 0, 0, 0}
-            };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "hmf:p:P:",
-                         long_options, &option_index);
-
-        if (c == -1)
-            break;
-
-        switch (c) {
-
-	    case 'f':
-            fastaFileName = optarg;
-            break;
-
-        case 'h':
-            printSummary(argv);
-            break;
-
-	    case 'p':
-            outputPrefix = optarg;
-            break;
-
-        case 'P':
-            defaultPloidy = atoi(optarg);
-            break;
-
-        case '?':
-            printSummary(argv);
-            exit(1);
-            break;
-
-        default:
-            abort ();
-        }
-    }
-
-    FastaReference reference;
-    if (fastaFileName.empty()) {
-        cerr << "a reference is required for haplotype allele generation" << endl;
-        printSummary(argv);
-        exit(1);
-    }
-    reference.open(fastaFileName);
-
-    if (optind < argc) {
-        string filename = argv[optind];
-        variantFile.open(filename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    vcf2fasta(variantFile, reference, outputPrefix, defaultPloidy);
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcf2tsv.cpp b/vcflib/src/vcf2tsv.cpp
deleted file mode 100644
index 9a1e2dd..0000000
--- a/vcflib/src/vcf2tsv.cpp
+++ /dev/null
@@ -1,241 +0,0 @@
-#include "Variant.h"
-#include <getopt.h>
-
-using namespace std;
-using namespace vcf;
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [-n null_string] [-g]" << " [vcf file]" << endl
-         << "Converts stdin or given VCF file to tab-delimited format, using null string to replace empty values in the table." << endl
-         << "Specifying -g will output one line per sample with genotype information." << endl;
-    exit(1);
-}
-
-
-int main(int argc, char** argv) {
-
-    string nullval;
-    bool genotypes = false;
-
-    int c;
-    while (true) {
-        static struct option long_options[] =
-        {
-            /* These options set a flag. */
-            //{"verbose", no_argument,       &verbose_flag, 1},
-            {"help", no_argument, 0, 'h'},
-            {"null-value", required_argument, 0, 'n'},
-            {"genotypes", no_argument, 0, 'g'},
-            {0, 0, 0, 0}
-        };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "hn:g",
-                         long_options, &option_index);
-
-        if (c == -1)
-            break;
-
-        switch (c) {
-
-	    case 'n':
-	        nullval = optarg;
-            break;
-
-        case 'g':
-            genotypes = true;
-            break;
-
-        case 'h':
-            printSummary(argv);
-            break;
-            
-        case '?':
-            printSummary(argv);
-            exit(1);
-            break;
-                
-        default:
-            abort ();
-        }
-    }
-
-    VariantCallFile variantFile;
-    bool usingstdin = false;
-    string inputFilename;
-    if (optind == argc - 1) {
-        inputFilename = argv[optind];
-        variantFile.open(inputFilename);
-    } else {
-        if (!variantFile.open(std::cin)) {
-            if (argc == 1) {
-                printSummary(argv);
-            } else {
-                cerr << "could not open stdin for reading as VCF" << endl;
-                exit(1);
-            }
-        }
-        usingstdin = true;
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-    // obtain all possible field names
-    vector<string> infofields;
-    vector<string> infoflags;
-
-    for (map<string, VariantFieldType>::iterator i = variantFile.infoTypes.begin(); i != variantFile.infoTypes.end(); ++i) {
-        if (i->second == FIELD_BOOL) {
-            infoflags.push_back(i->first);
-        } else {
-            infofields.push_back(i->first);
-        }
-    }
-
-    vector<string> formatfields;
-    if (genotypes) {
-        for (map<string, VariantFieldType>::iterator f = variantFile.formatTypes.begin(); f != variantFile.formatTypes.end(); ++f) {
-            formatfields.push_back(f->first);
-        }
-    }
-
-    // write header
-
-    // defaults
-    cout << "CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER";
-    
-    // configurable info field
-    for (vector<string>::iterator i = infofields.begin(); i != infofields.end(); ++i) {
-        cout << "\t" << *i;
-    }
-    for (vector<string>::iterator i = infoflags.begin(); i != infoflags.end(); ++i) {
-        cout << "\t" << *i;
-    }
-    
-    if (genotypes) {
-        cout << "\t" << "SAMPLE";
-        for (vector<string>::iterator f = formatfields.begin(); f != formatfields.end(); ++f) {
-            cout << "\t" << *f;
-        }
-    }
-    cout << endl;
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-
-        if (!genotypes) {
-
-            int altindex = 0;
-            for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a, ++altindex) {
-
-                string& altallele = *a;
-
-                cout << var.sequenceName << "\t"
-                     << var.position << "\t"
-                     << var.id << "\t"
-                     << var.ref << "\t"
-                     << altallele << "\t"
-                     << var.quality << "\t"
-                     << var.filter;
-
-                for (vector<string>::iterator i = infofields.begin(); i != infofields.end(); ++i) {
-                    vector<string> value;
-                    string& name = *i;
-                    map<string, vector<string> >::iterator f = var.info.find(name);
-                    if (f != var.info.end()) {
-                        value = f->second;
-                        if (value.size() == 1) {
-                            cout << "\t" << value.front();
-                        } else if (value.size() == var.alt.size()) {
-                            cout << "\t" << value.at(altindex);
-                        } else {
-                            cout << "\t" << nullval; // null
-                        }
-                    } else {
-                        cout << "\t" << nullval; // null
-                    }
-                }
-
-                for (vector<string>::iterator i = infoflags.begin(); i != infoflags.end(); ++i) {
-                    string value;
-                    string& name = *i;
-                    map<string, bool>::iterator f = var.infoFlags.find(name);
-                    cout << "\t";
-                    if (f != var.infoFlags.end()) {
-                        cout << 1;
-                    } else {
-                        cout << 0;
-                    }
-                }
-
-                cout << endl;
-
-            }
-        } else {
-
-            stringstream o;
-
-            // per-genotype output
-            o << var.sequenceName << "\t"
-              << var.position << "\t"
-              << var.id << "\t"
-              << var.ref << "\t"
-              << join(var.alt, ",") << "\t"
-              << var.quality << "\t"
-              << var.filter;
-            
-            for (vector<string>::iterator i = infofields.begin(); i != infofields.end(); ++i) {
-                vector<string> value;
-                string& name = *i;
-                map<string, vector<string> >::iterator f = var.info.find(name);
-                if (f != var.info.end()) {
-                    value = f->second;
-                    if (value.size() == 1) {
-                        o << "\t" << value.front();
-                    } else if (value.size() == var.alt.size()) {
-                        o << "\t" << join(value, ",");
-                    } else {
-                        o << "\t" << nullval; // null
-                    }
-                } else {
-                    o << "\t" << nullval; // null
-                }
-            }
-
-            for (vector<string>::iterator i = infoflags.begin(); i != infoflags.end(); ++i) {
-                string value;
-                string& name = *i;
-                map<string, bool>::iterator f = var.infoFlags.find(name);
-                o << "\t";
-                if (f != var.infoFlags.end()) {
-                    o << 1;
-                } else {
-                    o << 0;
-                }
-            }
-            
-            string siteinfo = o.str();
-
-            for (map<string, map<string, vector<string> > >::iterator s = var.samples.begin(); s != var.samples.end(); ++s) {
-                cout << siteinfo;
-                const string& sampleName = s->first;
-                cout << "\t" << sampleName;
-                map<string, vector<string> >& sample = s->second;
-                for (vector<string>::iterator f = formatfields.begin(); f != formatfields.end(); ++f) {
-                    if (sample.find(*f) != sample.end()) {
-                        cout << "\t" << join(sample[*f], ",");
-                    } else {
-                        cout << "\t" << nullval;
-                    }
-                }
-                cout << endl;
-            }
-        }
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfaddinfo.cpp b/vcflib/src/vcfaddinfo.cpp
deleted file mode 100644
index cff66d6..0000000
--- a/vcflib/src/vcfaddinfo.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include <string>
-#include <iostream>
-#include <set>
-
-using namespace std;
-using namespace vcf;
-
-// adds non-overlapping info fields from varB to varA
-void addInfo(Variant& varA, Variant& varB) {
-    for (map<string, vector<string> >::iterator i = varB.info.begin(); i != varB.info.end(); ++i) {
-        if (varA.info.find(i->first) == varA.info.end()) {
-            varA.info[i->first] = i->second;
-        }
-    }
-}
-
-int main(int argc, char** argv) {
-
-    if (argc != 3) {
-        cerr << "usage: " << argv[0] << " <vcf file> <vcf file>" << endl
-             << "Adds info fields from the second file which are not present in the first vcf file." << endl;
-        return 1;
-    }
-
-    string filenameA = argv[1];
-    string filenameB = argv[2];
-
-    if (filenameA == filenameB) {
-        cerr << "it won't help to add info data from the same file!" << endl;
-        return 1;
-    }
-
-    VariantCallFile variantFileA;
-    if (filenameA == "-") {
-        variantFileA.open(std::cin);
-    } else {
-        variantFileA.open(filenameA);
-    }
-
-    VariantCallFile variantFileB;
-    if (filenameB == "-") {
-        variantFileB.open(std::cin);
-    } else {
-        variantFileB.open(filenameB);
-    }
-
-    if (!variantFileA.is_open() || !variantFileB.is_open()) {
-        return 1;
-    }
-
-    Variant varA(variantFileA);
-    Variant varB(variantFileB);
-
-    // while the first file doesn't match the second positionally,
-    // step forward, annotating each genotype record with an empty genotype
-    // when the two match, iterate through the genotypes from the first file
-    // and get the genotypes reported in the second file
-    
-    variantFileA.getNextVariant(varA);
-    variantFileB.getNextVariant(varB);
-    
-    variantFileA.header = unionInfoHeaderLines(variantFileA.header, variantFileB.header);
-    
-    cout << variantFileA.header << endl;
-
-    do {
-
-        while (!variantFileB.done()
-               && (varB.sequenceName < varA.sequenceName
-                   || (varB.sequenceName == varA.sequenceName && varB.position < varA.position))
-            ) {
-            variantFileB.getNextVariant(varB);
-        }
-
-        while (!variantFileA.done()
-               && (varA.sequenceName < varB.sequenceName
-                   || (varA.sequenceName == varB.sequenceName && varA.position < varB.position))
-            ) {
-            cout << varA << endl;
-            variantFileA.getNextVariant(varA);
-        }
-
-        while (!variantFileB.done()
-               && (varB.sequenceName < varA.sequenceName
-                   || (varB.sequenceName == varA.sequenceName && varB.position < varA.position))
-            ) {
-            variantFileB.getNextVariant(varB);
-        }
-
-        while (!variantFileA.done() && varA.sequenceName == varB.sequenceName && varA.position == varB.position) {
-            addInfo(varA, varB);
-            cout << varA << endl;
-            variantFileA.getNextVariant(varA);
-            variantFileB.getNextVariant(varB);
-        }
-        
-    } while (!variantFileA.done() && !variantFileB.done());
-
-    if (!variantFileA.done()) {
-        cout << varA << endl;
-        while (variantFileA.getNextVariant(varA)) {
-            cout << varA << endl;
-        }
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfafpath.cpp b/vcflib/src/vcfafpath.cpp
deleted file mode 100644
index e87ab80..0000000
--- a/vcflib/src/vcfafpath.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-#include "Variant.h"
-#include <algorithm>
-#include <vector>
-#include <map>
-
-using namespace std;
-using namespace vcf;
-
-int main(int argc, char** argv) {
-
-    VariantCallFile variantFile;
-
-    if (argc > 1) {
-        string filename = argv[1];
-        variantFile.open(filename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    //cout << variantFile.header << endl;
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-        //cout << var << endl;
-        double afref = 1;
-        map<double, vector<string> > allelesByAf;
-        vector<double> afd;
-        vector<string>& afstr = var.info["AF"];
-        for (vector<string>::iterator af = afstr.begin(); af != afstr.end(); ++af) {
-            double r; convert(*af, r);
-            afd.push_back(r);
-        }
-        vector<double>::iterator af = afd.begin();
-        for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a, ++af) {
-            afref -= *af;
-            allelesByAf[*af].push_back(*a);
-        }
-        cout << var.ref;
-        for (map<double, vector<string> >::reverse_iterator a = allelesByAf.rbegin(); a != allelesByAf.rend(); ++a) {
-            cout << " -> " << join(a->second, ", ");
-        }
-        cout << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfallelicprimitives.cpp b/vcflib/src/vcfallelicprimitives.cpp
deleted file mode 100644
index 3754a2e..0000000
--- a/vcflib/src/vcfallelicprimitives.cpp
+++ /dev/null
@@ -1,341 +0,0 @@
-#include "Variant.h"
-#include "convert.h"
-#include "join.h"
-#include "split.h"
-#include <set>
-#include <getopt.h>
-
-using namespace std;
-using namespace vcf;
-
-#define ALLELE_NULL -1
-
-double convertStrDbl(const string& s) {
-    double r;
-    convert(s, r);
-    return r;
-}
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [options] [file]" << endl
-         << endl
-         << "options:" << endl
-         << "    -m, --use-mnps          Retain MNPs as separate events (default: false)." << endl
-         << "    -t, --tag-parsed FLAG   Tag records which are split apart of a complex allele with this flag." << endl
-         << "    -L, --max-length LEN    Do not manipulate records in which either the ALT or" << endl
-         << "                            REF is longer than LEN (default: 200)." << endl
-         << endl
-         << "If multiple alleleic primitives (gaps or mismatches) are specified in" << endl
-         << "a single VCF record, split the record into multiple lines, but drop all" << endl
-         << "INFO fields.  Does not handle genotypes (yet).  MNPs are split into" << endl
-         << "multiple SNPs unless the -m flag is provided.  Records generated by splits have th" << endl;
-    exit(0);
-}
-
-int main(int argc, char** argv) {
-
-    bool includePreviousBaseForIndels = true;
-    bool useMNPs = false;
-    string parseFlag;
-    int maxLength = 200;
-
-    VariantCallFile variantFile;
-
-    int c;
-    while (true) {
-        static struct option long_options[] =
-            {
-                /* These options set a flag. */
-                //{"verbose", no_argument,       &verbose_flag, 1},
-                {"help", no_argument, 0, 'h'},
-                {"use-mnps", no_argument, 0, 'm'},
-                {"max-length", required_argument, 0, 'L'},
-                {"tag-parsed", required_argument, 0, 't'},
-                {0, 0, 0, 0}
-            };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "hmt:L:",
-                         long_options, &option_index);
-
-        if (c == -1)
-            break;
-
-        switch (c) {
-
-	    case 'm':
-            useMNPs = true;
-            break;
-
-        case 'h':
-            printSummary(argv);
-            break;
-
-	    case 't':
-            parseFlag = optarg;
-            break;
-
-        case 'L':
-            maxLength = atoi(optarg);
-            break;
-
-        case '?':
-            printSummary(argv);
-            exit(1);
-            break;
-
-        default:
-            abort ();
-        }
-    }
-
-    if (optind < argc) {
-        string filename = argv[optind];
-        variantFile.open(filename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    variantFile.addHeaderLine("##INFO=<ID=TYPE,Number=A,Type=String,Description=\"The type of allele, either snp, mnp, ins, del, or complex.\">");
-    variantFile.addHeaderLine("##INFO=<ID=LEN,Number=A,Type=Integer,Description=\"allele length\">");
-    if (!parseFlag.empty()) {
-        variantFile.addHeaderLine("##INFO=<ID="+parseFlag+",Number=0,Type=Flag,Description=\"The allele was parsed using vcfallelicprimitives.\">");
-    }
-    cout << variantFile.header << endl;
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-
-
-        // we can't decompose *1* bp events, these are already in simplest-form whether SNPs or indels
-        // we also don't handle anything larger than maxLength bp
-        if (var.alt.size() == 1 
-            && (   var.alt.front().size() == 1
-                || var.ref.size() == 1
-                || var.alt.front().size() > maxLength
-                || var.ref.size() > maxLength
-                )) {
-            // nothing to do
-            cout << var << endl;
-            continue;
-        }
-
-        // for each parsedalternate, get the position
-        // build a new vcf record for that position
-        // unless we are already at the position !
-        // take everything which is unique to that allele (records) and append it to the new record
-        // then handle genotypes; determine the mapping between alleleic primitives and convert to phased haplotypes
-        // this means taking all the parsedAlternates and, for each one, generating a pattern of allele indecies corresponding to it
-
-        map<string, vector<VariantAllele> > varAlleles = var.parsedAlternates(includePreviousBaseForIndels, useMNPs);
-        set<VariantAllele> alleles;
-
-        // collect unique alleles
-        for (map<string, vector<VariantAllele> >::iterator a = varAlleles.begin(); a != varAlleles.end(); ++a) {
-            for (vector<VariantAllele>::iterator va = a->second.begin(); va != a->second.end(); ++va) {
-                alleles.insert(*va);
-            }
-        }
-
-        int altcount = 0;
-        for (set<VariantAllele>::iterator a = alleles.begin(); a != alleles.end(); ++a) {
-            if (a->ref != a->alt) {
-                ++altcount;
-            }
-        }
-
-        if (altcount == 1 && var.alt.size() == 1 && var.alt.front().size() == 1) { // if biallelic SNP
-            cout << var << endl;
-            continue;
-        }
-
-        // collect variant allele indexed membership
-        map<string, vector<int> > variantAlleleIndexes; // from serialized VariantAllele to indexes
-        for (map<string, vector<VariantAllele> >::iterator a = varAlleles.begin(); a != varAlleles.end(); ++a) {
-            int index = var.altAlleleIndexes[a->first] + 1; // make non-relative
-            for (vector<VariantAllele>::iterator va = a->second.begin(); va != a->second.end(); ++va) {
-                variantAlleleIndexes[va->repr].push_back(index);
-            }
-        }
-
-        map<VariantAllele, double> alleleFrequencies;
-        map<VariantAllele, int> alleleCounts;
-
-        bool hasAf = false;
-        if (var.info.find("AF") != var.info.end()) {
-            hasAf = true;
-            for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-                vector<VariantAllele>& vars = varAlleles[*a];
-                for (vector<VariantAllele>::iterator va = vars.begin(); va != vars.end(); ++va) {
-                    double freq;
-                    convert(var.info["AF"].at(var.altAlleleIndexes[*a]), freq);
-                    alleleFrequencies[*va] += freq;
-                }
-            }
-        }
-
-        bool hasAc = false;
-        if (var.info.find("AC") != var.info.end()) {
-            hasAc = true;
-            for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-                vector<VariantAllele>& vars = varAlleles[*a];
-                for (vector<VariantAllele>::iterator va = vars.begin(); va != vars.end(); ++va) {
-                    int freq;
-                    try {
-                        convert(var.info["AC"].at(var.altAlleleIndexes[*a]), freq);
-                        alleleCounts[*va] += freq;
-                    } catch (...) {
-                        /*
-                        cerr << "AC does not have the right number of fields for allele "
-                             << *a << " which would be at index " << var.altAlleleIndexes[*a] << endl;
-                        */
-                    }
-                }
-            }
-        }
-
-        // from old allele index to a new series across the unpacked positions
-        map<int, map<long unsigned int, int> > unpackedAlleleIndexes;
-
-        map<long unsigned int, Variant> variants;
-        //vector<Variant> variants;
-        for (set<VariantAllele>::iterator a = alleles.begin(); a != alleles.end(); ++a) {
-            if (a->ref == a->alt) {
-                // ref allele
-                continue;
-            }
-            string type;
-            int len = 0;
-            if (a->ref.at(0) == a->alt.at(0)) { // well-behaved indels
-                if (a->ref.size() > a->alt.size()) {
-                    type = "del";
-                    len = a->ref.size() - a->alt.size();
-                } else if (a->ref.size() < a->alt.size()) {
-                    len = a->alt.size() - a->ref.size();
-                    type = "ins";
-                }
-            } else {
-                if (a->ref.size() == a->alt.size()) {
-                    len = a->ref.size();
-                    if (a->ref.size() == 1) {
-                        type = "snp";
-                    } else {
-                        type = "mnp";
-                    }
-                } else {
-                    len = abs((int) a->ref.size() - (int) a->alt.size());
-                    type = "complex";
-                }
-            }
-
-            if (variants.find(a->position) == variants.end()) {
-                Variant newvar(variantFile);
-                variants[a->position] = newvar;
-            }
-
-            Variant& v = variants[a->position]; // guaranteed to exist
-
-            if (!parseFlag.empty()) {
-                v.infoFlags[parseFlag] = true;
-            }
-            v.quality = var.quality;
-            v.filter = var.filter;
-            v.id = ".";
-            //v.format = var.format;
-            vector<string> gtonlyformat;
-            gtonlyformat.push_back("GT");
-            v.format = gtonlyformat;
-            v.info["TYPE"].push_back(type);
-            v.info["LEN"].push_back(convert(len));
-            if (hasAf) {
-                v.info["AF"].push_back(convert(alleleFrequencies[*a]));
-            }
-            if (hasAc) {
-                v.info["AC"].push_back(convert(alleleCounts[*a]));
-            }
-
-            v.sequenceName = var.sequenceName;
-            v.position = a->position; // ... by definition, this should be == if the variant was found
-            if (v.ref.size() < a->ref.size()) {
-                for (vector<string>::iterator va = v.alt.begin(); va != v.alt.end(); ++va) {
-                    *va += a->ref.substr(v.ref.size());
-                }
-                v.ref = a->ref;
-            }
-            v.alt.push_back(a->alt);
-
-            int alleleIndex = v.alt.size();
-            vector<int>& originalIndexes = variantAlleleIndexes[a->repr];
-            for (vector<int>::iterator i = originalIndexes.begin(); i != originalIndexes.end(); ++i) {
-                unpackedAlleleIndexes[*i][v.position] = alleleIndex;
-            }
-            // add null allele
-            unpackedAlleleIndexes[ALLELE_NULL][v.position] = ALLELE_NULL;
-
-        }
-
-        // genotypes
-        for (vector<string>::iterator s = var.sampleNames.begin(); s != var.sampleNames.end(); ++s) {
-            string& sampleName = *s;
-            if (var.samples.find(sampleName) == var.samples.end()) {
-                continue;
-            }
-            map<string, vector<string> >& sample = var.samples[sampleName];
-            if (sample.find("GT") == sample.end()) {
-                continue;
-            }
-            string& genotype = sample["GT"].front();
-            vector<string> genotypeStrs = split(genotype, "|/");
-            vector<int> genotypeIndexes;
-            for (vector<string>::iterator s = genotypeStrs.begin(); s != genotypeStrs.end(); ++s) {
-                int i;
-                if (!convert(*s, i)) {
-                    genotypeIndexes.push_back(ALLELE_NULL);
-                } else {
-                    genotypeIndexes.push_back(i);
-                }
-            }
-            map<long unsigned int, vector<int> > positionIndexes;
-            for (vector<int>::iterator g = genotypeIndexes.begin(); g != genotypeIndexes.end(); ++g) {
-                int oldIndex = *g;
-                for (map<long unsigned int, Variant>::iterator v = variants.begin(); v != variants.end(); ++v) {
-                    const long unsigned int& p = v->first;
-                    if (oldIndex == 0) { // reference
-                        positionIndexes[p].push_back(0);
-                    } else {
-                        positionIndexes[p].push_back(unpackedAlleleIndexes[oldIndex][p]);
-                    }
-                }
-            }
-            for (map<long unsigned int, Variant>::iterator v = variants.begin(); v != variants.end(); ++v) {
-                Variant& variant = v->second;
-                vector<int>& gtints = positionIndexes[v->first];
-                vector<string> gtstrs;
-                for (vector<int>::iterator i = gtints.begin(); i != gtints.end(); ++i) {
-                    if (*i != ALLELE_NULL) {
-                        gtstrs.push_back(convert(*i));
-                    } else {
-                        gtstrs.push_back(".");
-                    }
-                }
-                string genotype = join(gtstrs, "|");
-                variant.samples[sampleName]["GT"].clear();
-                variant.samples[sampleName]["GT"].push_back(genotype);
-            }
-        }
-
-        //for (vector<Variant>::iterator v = variants.begin(); v != variants.end(); ++v) {
-        for (map<long unsigned int, Variant>::iterator v = variants.begin(); v != variants.end(); ++v) {
-            cout << v->second << endl;
-        }
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfaltcount.cpp b/vcflib/src/vcfaltcount.cpp
deleted file mode 100644
index 756b5fc..0000000
--- a/vcflib/src/vcfaltcount.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include <string>
-#include <iostream>
-
-using namespace std;
-using namespace vcf;
-
-
-int main(int argc, char** argv) {
-
-    if (argc != 2) {
-        cerr << "usage: " << argv[0] << " <vcf file>" << endl
-             << "count the number of alternate alleles in all records in the vcf file" << endl;
-        return 1;
-    }
-
-    string filename = argv[1];
-
-    VariantCallFile variantFile;
-    variantFile.open(filename);
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    unsigned int alternateAlleleCount = 0;
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-        //cout << var << endl;
-        for (map<string, map<string, vector<string> > >::iterator s = var.samples.begin(); s != var.samples.end(); ++s) {
-            //string& name = s->first;
-            map<string, vector<string> >& sample = s->second;
-            string& genotype = sample["GT"].front();
-            vector<string> gt = split(genotype, "|/");
-            int alt = 0;
-            for (vector<string>::iterator g = gt.begin(); g != gt.end(); ++g) {
-                if (*g != "0")
-                    ++alt;
-            }
-            alternateAlleleCount += alt;
-        }
-    }
-
-    cout << alternateAlleleCount << endl;
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfannotate.cpp b/vcflib/src/vcfannotate.cpp
deleted file mode 100644
index 3499083..0000000
--- a/vcflib/src/vcfannotate.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-#include "Variant.h"
-#include "BedReader.h"
-#include <getopt.h>
-
-using namespace std;
-using namespace vcf;
-
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [options] [<vcf file>]" << endl
-         << endl
-         << "options:" << endl 
-         << "    -b, --bed   use annotations provided by this BED file" << endl
-         << "    -k, --key   use this INFO field key for the annotations" << endl
-         << "    -d, --default  use this INFO field key for records without annotations" << endl
-         << endl
-         << "Intersect the records in the VCF file with targets provided in a BED file." << endl
-         << "Intersections are done on the reference sequences in the VCF file." << endl
-         << "If no VCF filename is specified on the command line (last argument) the VCF" << endl
-         << "read from stdin." << endl;
-    exit(0);
-}
-
-int main(int argc, char** argv) {
-
-    string bedFileName;
-    string annotationInfoKey;
-    string defaultAnnotationValue;
-
-    if (argc == 1)
-        printSummary(argv);
-
-    int c;
-    while (true) {
-        static struct option long_options[] =
-        {
-            /* These options set a flag. */
-            //{"verbose", no_argument,       &verbose_flag, 1},
-            {"help", no_argument, 0, 'h'},
-            {"bed",  required_argument, 0, 'b'},
-            {"key",  required_argument, 0, 'k'},
-            {"default",  required_argument, 0, 'd'},
-            {0, 0, 0, 0}
-        };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "hb:k:d:",
-                         long_options, &option_index);
-
-        if (c == -1)
-            break;
-
-        switch (c) {
-            case 'b':
-                bedFileName = string(optarg);
-                break;
-
-            case 'k':
-                annotationInfoKey = string(optarg);
-                break;
-
-            case 'd':
-                defaultAnnotationValue = string(optarg);
-                break;
-
-            case 'h':
-                printSummary(argv);
-                break;
-
-            case '?':
-                printSummary(argv);
-                exit(1);
-                break;
-
-            default:
-                abort ();
-        }
-    }
-
-    if (bedFileName.empty()) {
-        cerr << "a BED file is required when intersecting" << endl;
-        exit(1);
-    }
-
-    BedReader bed(bedFileName);
-
-    VariantCallFile variantFile;
-    string inputFilename;
-    if (optind == argc - 1) {
-        inputFilename = argv[optind];
-        variantFile.open(inputFilename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        cout << "could not open VCF file" << endl;
-        return 1;
-    }
-
-    string line = "##INFO=<ID=" + annotationInfoKey + ",Number=1,Type=String,Description=\"Annotation from "
-        + bedFileName + " delimited by ':'\">";
-    variantFile.addHeaderLine(line);
-
-    cout << variantFile.header << endl;
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-        BedTarget record(var.sequenceName, var.position, var.position + var.ref.size() - 1, "");
-        vector<BedTarget*> overlaps = bed.targetsOverlapping(record);
-        vector<string> annotations;
-        if (!overlaps.empty()) {
-            for (vector<BedTarget*>::iterator t = overlaps.begin(); t != overlaps.end(); ++t) {
-                annotations.push_back((*t)->desc);
-            }
-            var.info[annotationInfoKey].push_back(join(annotations, ":"));
-        } else if (!defaultAnnotationValue.empty()) {
-            var.info[annotationInfoKey].push_back(defaultAnnotationValue);
-        }
-        cout << var << endl;
-    }
-
-    return 0;
-
-}
diff --git a/vcflib/src/vcfannotategenotypes.cpp b/vcflib/src/vcfannotategenotypes.cpp
deleted file mode 100644
index 6109616..0000000
--- a/vcflib/src/vcfannotategenotypes.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include <string>
-#include <list>
-#include <iostream>
-
-using namespace std;
-using namespace vcf;
-
-void annotateWithBlankGenotypes(Variant& var, string& annotationTag) {
-
-    var.addFormatField(annotationTag);
-
-    map<string, map<string, vector<string> > >::iterator s     = var.samples.begin(); 
-    map<string, map<string, vector<string> > >::iterator sEnd  = var.samples.end();
-
-    for (; s != sEnd; ++s) {
-        map<string, vector<string> >& sample = s->second;
-        sample[annotationTag].clear(); // means "no genotype" genotype
-        sample[annotationTag].push_back("./."); // means "no genotype" genotype
-    }
-}
-
-void annotateWithGenotypes(Variant& varA, Variant& varB, string& annotationTag) {
-
-    varA.addFormatField(annotationTag);
-
-    map<string, map<string, vector<string> > >::iterator s     = varA.samples.begin(); 
-    map<string, map<string, vector<string> > >::iterator sEnd  = varA.samples.end();
-
-    map<string, int> varAAlleleInts;
-    int i = 1;
-    for (vector<string>::iterator a = varA.alt.begin(); a != varA.alt.end(); ++a, ++i) {
-        varAAlleleInts[*a] = i;
-    }
-
-    map<int, int> varBconvertToVarA; // maps alleles in the second file to allele numbers for the first
-    varBconvertToVarA[0] = 0; // reference == reference!
-    i = 1;
-    for (vector<string>::iterator a = varB.alt.begin(); a != varB.alt.end(); ++a, ++i) {
-        map<string, int>::iterator ita = varAAlleleInts.find(*a);
-        if (ita != varAAlleleInts.end()) {
-            varBconvertToVarA[i] = ita->second;
-        }
-    }
-
-    for (; s != sEnd; ++s) {
-        map<string, vector<string> >& sample = s->second;
-        const string& name = s->first;
-        map<string, map<string, vector<string> > >::iterator o = varB.samples.find(name);
-        sample[annotationTag].clear();
-        if (o == varB.samples.end()) {
-            sample[annotationTag].push_back("./."); // means "no genotype"
-        } else {
-            map<string, vector<string> >& other = o->second;
-            string& otherGenotype = other["GT"].front();
-            // XXX this must compare the genotypes in the two files
-            map<int, int> gtB = decomposeGenotype(otherGenotype);
-            map<int, int> gtnew;
-            for (map<int, int>::iterator g = gtB.begin(); g != gtB.end(); ++g) {
-                map<int, int>::iterator f = varBconvertToVarA.find(g->first);
-                if (f != varBconvertToVarA.end()) {
-                    gtnew[f->second] += g->second;
-                } else {
-                    gtnew[-1] += g->second;
-                }
-            }
-            sample[annotationTag].push_back(genotypeToString(gtnew));
-        }
-    }
-}
-
-int main(int argc, char** argv) {
-
-    if (argc != 4) {
-        cerr << "usage: " << argv[0] << " <annotation-tag> <vcf file> <vcf file>" << endl
-             << "annotates genotypes in the first file with genotypes in the second" << endl
-             << "adding the genotype as another flag to each sample filed in the first file." << endl
-             << "annotation-tag is the name of the sample flag which is added to store the annotation." << endl
-             << "also adds a 'has_variant' flag for sites where the second file has a variant." << endl;
-        return 1;
-    }
-
-    string annotag = argv[1];
-    string filenameA = argv[2];
-    string filenameB = argv[3];
-
-    if (filenameA == filenameB) {
-        cerr << "it won't help to annotate samples with their own genotypes!" << endl;
-        return 1;
-    }
-
-    VariantCallFile variantFileA;
-    if (filenameA == "-") {
-        variantFileA.open(std::cin);
-    } else {
-        variantFileA.open(filenameA);
-    }
-
-    VariantCallFile variantFileB;
-    if (filenameB == "-") {
-        variantFileB.open(std::cin);
-    } else {
-        variantFileB.open(filenameB);
-    }
-
-    if (!variantFileA.is_open() || !variantFileB.is_open()) {
-        return 1;
-    }
-
-    Variant varA(variantFileA);
-    Variant varB(variantFileB);
-
-    // while the first file doesn't match the second positionally,
-    // step forward, annotating each genotype record with an empty genotype
-    // when the two match, iterate through the genotypes from the first file
-    // and get the genotypes reported in the second file
-    
-    variantFileA.getNextVariant(varA);
-    variantFileB.getNextVariant(varB);
-
-    string line = "##INFO=<ID=" + annotag + ".has_variant,Number=0,Type=Flag,Description=\"True if "
-        + annotag + " has a called alternate among samples under comparison.\">";
-    variantFileA.addHeaderLine(line);
-    line = "##FORMAT=<ID=" + annotag + ",Number=1,Type=String,Description=\"Genotype from "
-        + annotag + ".\">";
-    variantFileA.addHeaderLine(line);
-
-    cout << variantFileA.header << endl;
-
-    do {
-
-        // this is broken.  to do it right, it'll be necessary to get reference ids from the fasta reference used to make the alignments...
-        if (!variantFileB.done()
-            && (varB.sequenceName != varA.sequenceName
-                || (varB.sequenceName == varA.sequenceName && varB.position < varA.position))
-            ) {
-            variantFileB.getNextVariant(varB);
-        }
-
-        if (!variantFileA.done()
-            && (varA.sequenceName != varB.sequenceName
-                || (varA.sequenceName == varB.sequenceName && varA.position < varB.position))
-            ) {
-            cout << varA << endl;
-            variantFileA.getNextVariant(varA);
-        }
-
-        vector<Variant> varsA;
-        vector<Variant> varsB;
-
-        bool hasMultipleAlts = false;
-
-        long int thisPosition = 0;
-        string thisSequenceName;
-        if (varA.position == varB.position
-            && varA.sequenceName == varB.sequenceName) {
-            thisPosition = varA.position;
-            thisSequenceName = varA.sequenceName;
-        }
-        while (!variantFileA.done()
-               && !variantFileB.done()
-               && thisPosition == varA.position
-               && thisSequenceName == varA.sequenceName
-               && varA.sequenceName == varB.sequenceName
-               && varA.position == varB.position) {
-            // accumulate all the alts at the current position
-            varsA.push_back(varA);
-            varsB.push_back(varB);
-            if (varA.alt.size() > 1 || varB.alt.size() > 1)
-                hasMultipleAlts = true;
-            variantFileA.getNextVariant(varA);
-            variantFileB.getNextVariant(varB);
-        }
-
-        // multiple lines per position
-        if (!hasMultipleAlts && (varsA.size() > 1 || varsB.size() > 1)) {
-
-            map<pair<string, string>, Variant> varsAParsed;
-            map<pair<string, string>, Variant> varsBParsed;	
-            for (vector<Variant>::iterator v = varsA.begin(); v != varsA.end(); ++v) {
-                varsAParsed[make_pair(v->ref, v->alt.front())] = *v;
-            }
-            for (vector<Variant>::iterator v = varsB.begin(); v != varsB.end(); ++v) {
-                varsBParsed[make_pair(v->ref, v->alt.front())] = *v;
-            }
-	    
-            for (map<pair<string, string>, Variant>::iterator vs = varsAParsed.begin(); vs != varsAParsed.end(); ++vs) {
-                Variant& varA = vs->second;
-                if (varsBParsed.find(make_pair(varA.ref, varA.alt.front())) != varsBParsed.end()) {
-                    Variant& varB = varsBParsed[make_pair(varA.ref, varA.alt.front())]; // TODO cleanup
-                    annotateWithGenotypes(varA, varB, annotag);
-                    varA.infoFlags[annotag + ".has_variant"] = true;
-                } else {
-                    annotateWithBlankGenotypes(varA, annotag);
-                }
-                cout << varA << endl;
-            }
-
-        } else if (!varsA.empty() && !varsB.empty()) { // one line per multi-allelic
-            Variant& varA = varsA.front();
-            Variant& varB = varsB.front();
-            annotateWithGenotypes(varA, varB, annotag);
-            // XXX TODO, and also allow for records with multiple alts
-            // XXX assume that if the other file has a corresponding record, some kind of variation was detected at the same site
-            varA.infoFlags[annotag + ".has_variant"] = true;
-            cout << varA << endl;
-        }
-        
-    } while (!variantFileA.done() && !variantFileB.done());
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfbreakmulti.cpp b/vcflib/src/vcfbreakmulti.cpp
deleted file mode 100644
index f462111..0000000
--- a/vcflib/src/vcfbreakmulti.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-#include "Variant.h"
-#include "convert.h"
-#include <set>
-#include <getopt.h>
-
-using namespace std;
-using namespace vcf;
-
-
-double convertStrDbl(const string& s) {
-    double r;
-    convert(s, r);
-    return r;
-}
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [options] [file]" << endl
-	 << endl
-	 << "If multiple alleles are specified in a single record, break the record into" << endl
-	 << "multiple lines, preserving allele-specific INFO fields." << endl;
-    exit(0);
-}
-
-int main(int argc, char** argv) {
-
-    bool includePreviousBaseForIndels = true;
-    bool useMNPs = false;
-
-    VariantCallFile variantFile;
-
-    int c;
-    while (true) {
-        static struct option long_options[] =
-        {
-            /* These options set a flag. */
-            //{"verbose", no_argument,       &verbose_flag, 1},
-            {"help", no_argument, 0, 'h'},
-            {0, 0, 0, 0}
-        };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "h",
-                         long_options, &option_index);
-
-        if (c == -1)
-            break;
-
-        switch (c) {
-
-            case 'h':
-                printSummary(argv);
-                break;
-
-            case '?':
-                printSummary(argv);
-                exit(1);
-                break;
-
-            default:
-                abort ();
-        }
-    }
-
-    if (optind < argc) {
-        string filename = argv[optind];
-        variantFile.open(filename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    cout << variantFile.header << endl;
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-
-        int numalt = var.alt.size();
-
-        if (numalt == 1) {
-            cout << var << endl;
-            continue;
-        }
-
-        vector<Variant> variants;
-        for (int i = 0; i < numalt; ++i) {
-            variants.push_back(var);
-        }
-
-        for (int i = 0; i < numalt; ++i) {
-            Variant& v = variants.at(i);
-            vector<string> altsToRemove;
-            for (int j = 0; j < numalt; ++j) {
-                if (j != i) {
-                    altsToRemove.push_back(var.alt.at(j));
-                }
-            }
-            for (vector<string>::iterator a = altsToRemove.begin(); a != altsToRemove.end(); ++a) {
-                v.removeAlt(*a);
-            }
-        }
-
-        for (vector<Variant>::iterator v = variants.begin(); v != variants.end(); ++v) {
-            cout << *v << endl;
-        }
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfcat.cpp b/vcflib/src/vcfcat.cpp
deleted file mode 100644
index cf40921..0000000
--- a/vcflib/src/vcfcat.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "Variant.h"
-
-using namespace std;
-using namespace vcf;
-
-int main(int argc, char** argv) {
-
-    if (argc == 1) {
-        cout << "usage: " << argv[0] << " [file1] [file2] ... [fileN]" << endl
-             << "Concatenates VCF files." << endl;
-        return 0;
-    } else {
-        for (int i = 1; i < argc; ++i) {
-            VariantCallFile variantFile;
-            string filename = argv[i];
-            variantFile.open(filename);
-            if (!variantFile.is_open()) {
-                cerr << "could not open " << argv[i] << endl;
-                return 1;
-            }
-            if (i == 1) {
-                cout << variantFile.header << endl;
-            }
-            Variant var(variantFile);
-            while (variantFile.getNextVariant(var)) {
-                cout << var << endl;
-            }
-        }
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfcheck.cpp b/vcflib/src/vcfcheck.cpp
deleted file mode 100644
index d370ae1..0000000
--- a/vcflib/src/vcfcheck.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include "fastahack/Fasta.h"
-#include <getopt.h>
-
-using namespace std;
-using namespace vcf;
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [options] <vcf file>" << endl
-         << endl
-         << "options:" << endl 
-         << "    -f, --fasta-reference  FASTA reference file to use to obtain primer sequences" << endl
-         << "    -x, --exclude-failures If a record fails, don't print it.  Otherwise do." << endl
-         << "    -k, --keep-failures    Print if the record fails, otherwise not." << endl
-         << endl
-         << "Verifies that the VCF REF field matches the reference as described." << endl
-         << endl;
-    exit(0);
-}
-
-
-int main(int argc, char** argv) {
-
-    int c;
-    string fastaRef;
-    bool keepFailures = false;
-    bool excludeFailures = false;
-
-    if (argc == 1)
-        printSummary(argv);
-
-    while (true) {
-        static struct option long_options[] =
-            {
-                /* These options set a flag. */
-                //{"verbose", no_argument,       &verbose_flag, 1},
-                {"help", no_argument, 0, 'h'},
-                {"fasta-reference",  required_argument, 0, 'f'},
-                {"exclude-failures",  no_argument, 0, 'x'},
-                {"keep-failures",  no_argument, 0, 'k'},
-                //{"length",  no_argument, &printLength, true},
-                {0, 0, 0, 0}
-            };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "hxkf:",
-                         long_options, &option_index);
-
-        /* Detect the end of the options. */
-        if (c == -1)
-            break;
- 
-        switch (c)
-        {
-        case 0:
-            /* If this option set a flag, do nothing else now. */
-            if (long_options[option_index].flag != 0)
-                break;
-            printf ("option %s", long_options[option_index].name);
-            if (optarg)
-                printf (" with arg %s", optarg);
-            printf ("\n");
-            break;
-
-        case 'f':
-            fastaRef = optarg;
-            break;
-
-        case 'x':
-            excludeFailures = true;
-            break;
-
-        case 'k':
-            keepFailures = true;
-            break;
- 
-        case 'h':
-            printSummary(argv);
-            exit(0);
-            break;
-
-        case '?':
-            /* getopt_long already printed an error message. */
-            printSummary(argv);
-            exit(1);
-            break;
- 
-        default:
-            abort ();
-        }
-    }
-
-    if (fastaRef.empty()) {
-        cerr << "a FASTA reference sequence must be specified" << endl;
-        exit(1);
-    }
-
-    FastaReference ref;
-    ref.open(fastaRef);
-
-    VariantCallFile variantFile;
-    string inputFilename;
-    if (optind == argc - 1) {
-        inputFilename = argv[optind];
-        variantFile.open(inputFilename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    if (keepFailures || excludeFailures) {
-        cout << variantFile.header << endl;
-    }
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-        int refstart = var.position - 1; // convert to 0-based
-        string matchedRef = ref.getSubSequence(var.sequenceName, refstart, var.ref.size());
-        if (var.ref != matchedRef) {
-            if (keepFailures) {
-                cout << var << endl;
-            } else if (!excludeFailures) {
-                cout << "mismatched reference " << var.ref << " should be " << matchedRef << " at "
-                     << var.sequenceName << ":" << var.position << endl;
-            }
-        } else if (excludeFailures) {
-            cout << var << endl;
-        }
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfclassify.cpp b/vcflib/src/vcfclassify.cpp
deleted file mode 100644
index 42624ee..0000000
--- a/vcflib/src/vcfclassify.cpp
+++ /dev/null
@@ -1,162 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include <string>
-#include <sstream>
-#include <iostream>
-
-using namespace std;
-using namespace vcf;
-
-bool isTransition(string& ref, string& alt) {
-    if (((ref == "A" && alt == "G") || (ref == "G" && alt == "A")) ||
-        ((ref == "C" && alt == "T") || (ref == "T" && alt == "C"))) {
-        return true;
-    } else {
-        return false;
-    }
-}
-
-bool hasTransition(Variant& var) {
-    string& ref = var.ref;
-    for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-        string& alt = *a;
-        if (isTransition(ref, alt)) {
-            return true;
-        }
-    }
-    return false;
-}
-
-bool hasTransversion(Variant& var) {
-    string& ref = var.ref;
-    for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-        string& alt = *a;
-        if (!isTransition(ref, alt)) {
-            return true;
-        }
-    }
-    return false;
-}
-
-bool hasInsertion(Variant& var) {
-    string& ref = var.ref;
-    for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-        string& alt = *a;
-        if (ref.size() < alt.size()) {
-            return true;
-        }
-    }
-    return false;
-}
-
-bool hasDeletion(Variant& var) {
-    string& ref = var.ref;
-    for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-        string& alt = *a;
-        if (ref.size() > alt.size()) {
-            return true;
-        }
-    }
-    return false;
-}
-
-bool hasMNP(Variant& var) {
-    string& ref = var.ref;
-    for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-        string& alt = *a;
-        if (ref.size() > 1 && alt.size() == ref.size()) {
-            return true;
-        }
-    }
-    return false;
-}
-
-bool hasSNP(Variant& var) {
-    string& ref = var.ref;
-    for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-        string& alt = *a;
-        if (ref.size() == 1 && alt.size() == 1) {
-            return true;
-        }
-    }
-    return false;
-}
-
-int main(int argc, char** argv) {
-
-    if (argc != 2) {
-        cerr << "usage: " << argv[0] << " <vcf file>" << endl
-             << "outputs a VCF stream each variant is tagged by allele class: snp, ts/tv, indel, mnp" << endl;
-        return 1;
-    }
-
-    string filename = argv[1];
-
-    VariantCallFile variantFile;
-    if (filename == "-") {
-        variantFile.open(std::cin);
-    } else {
-        variantFile.open(filename);
-    }
-
-    if (!variantFile.is_open()) {
-        cerr << "could not open " << filename << endl;
-        return 1;
-    }
-
-    Variant var(variantFile);
-
-    string line;
-    line = "##INFO=<ID=SNP,Number=0,Type=Flag,Description=\"SNP allele\">";
-    variantFile.addHeaderLine(line);
-    line = "##INFO=<ID=TS,Number=0,Type=Flag,Description=\"transition SNP\">";
-    variantFile.addHeaderLine(line);
-    line = "##INFO=<ID=TV,Number=0,Type=Flag,Description=\"transversion SNP\">";
-    variantFile.addHeaderLine(line);
-    line = "##INFO=<ID=INS,Number=0,Type=Flag,Description=\"insertion allele\">";
-    variantFile.addHeaderLine(line);
-    line = "##INFO=<ID=DEL,Number=0,Type=Flag,Description=\"deletion allele\">";
-    variantFile.addHeaderLine(line);
-    line = "##INFO=<ID=MNP,Number=0,Type=Flag,Description=\"MNP allele\">";
-    variantFile.addHeaderLine(line);
-    // TODO handle lengths at poly-allelic sites
-    //line = "##INFO=<ID=LEN,Number=1,Type=Integer,Description=\"allele length\">";
-    //variantFile.addHeaderLine(line);
-
-    // write the new header
-    cout << variantFile.header << endl;
- 
-
-    while (variantFile.getNextVariant(var)) {
-
-        if (hasSNP(var)) {
-            var.infoFlags["SNP"] = true;
-        }
-
-        if (hasTransition(var)) {
-            var.infoFlags["TS"] = true;
-        }
-
-        if (hasTransversion(var)) {
-            var.infoFlags["TV"] = true;
-        }
-
-        if (hasInsertion(var)) {
-            var.infoFlags["INS"] = true;
-        }
-
-        if (hasDeletion(var)) {
-            var.infoFlags["DEL"] = true;
-        }
-
-        if (hasMNP(var)) {
-            var.infoFlags["MNP"] = true;
-        }
-
-        cout << var << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfcleancomplex.cpp b/vcflib/src/vcfcleancomplex.cpp
deleted file mode 100644
index c0b3c71..0000000
--- a/vcflib/src/vcfcleancomplex.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include <string>
-#include <sstream>
-#include <iostream>
-
-using namespace std;
-using namespace vcf;
-
-
-int main(int argc, char** argv) {
-
-    if (argc != 2) {
-        cerr << "usage: " << argv[0] << " <vcf file>" << endl
-             << "outputs a VCF stream in which 'long' non-complex"
-             << "alleles have their position corrected." << endl
-             << "assumes that VCF records can't overlap 5'->3'" << endl;
-        return 1;
-    }
-
-    string filename = argv[1];
-
-    VariantCallFile variantFile;
-    if (filename == "-") {
-        variantFile.open(std::cin);
-    } else {
-        variantFile.open(filename);
-    }
-
-    if (!variantFile.is_open()) {
-        cerr << "could not open " << filename << endl;
-        return 1;
-    }
-
-    Variant var(variantFile);
-
-    // write the new header
-    cout << variantFile.header << endl;
- 
-    // print the records, filtering is done via the setting of varA's output sample names
-    while (variantFile.getNextVariant(var)) {
-        // if we just have one parsed alternate (non-complex case)
-        map<string, vector<VariantAllele> > parsedAlts = var.parsedAlternates(true, true); // use mnps, and previous for indels
-        // but the alt string is long
-        //cerr << var.alt.size() << " " << parsedAlts.size() << endl;
-        if (var.alt.size() == 1 && parsedAlts.size() > 1) {
-            string& alternate = var.alt.front();
-            vector<VariantAllele>& vs = parsedAlts[alternate];
-            vector<VariantAllele> valleles;
-            for (vector<VariantAllele>::iterator a = vs.begin(); a != vs.end(); ++a) {
-                if (a->ref != a->alt) {
-                    valleles.push_back(*a);
-                }
-            }
-            if (valleles.size() == 1) {
-                // do we have extra sequence hanging around?
-                VariantAllele& varallele = valleles.front();
-                if (vs.front().ref == vs.front().alt) {
-                    var.position = varallele.position;
-                    var.ref = var.ref.substr(vs.front().ref.size(), varallele.ref.size());
-                    var.alt.front() = varallele.alt;
-                }
-            }
-        }
-        cout << var << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfcombine.cpp b/vcflib/src/vcfcombine.cpp
deleted file mode 100644
index 27dbc80..0000000
--- a/vcflib/src/vcfcombine.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-#include "Variant.h"
-#include <getopt.h>
-
-
-using namespace std;
-using namespace vcf;
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [vcf file] [vcf file] ..." << endl
-         << endl
-         << "Combines VCF files positionally, combining samples when sites and alleles are identical." << endl
-         << "Any number of VCF files may be combined.  The INFO field and other columns are taken from" << endl
-         << "one of the files which are combined when records in multiple files match.  Alleles must" << endl
-         << "have identical ordering to be combined into one record.  If they do not, multiple records" << endl
-         << "will be emitted." << endl
-         << endl
-         << "options:" << endl
-         << "    -h --help           This text." << endl
-         << "    -r --region REGION  A region specifier of the form chrN:x-y to bound the merge" << endl;
-    exit(1);
-}
-
-int main(int argc, char** argv) {
-
-    if (argc < 2) {
-        printSummary(argv);
-    }
-
-    string region;
-
-    int c;
-    while (true) {
-        static struct option long_options[] =
-        {
-            /* These options set a flag. */
-            //{"verbose", no_argument,       &verbose_flag, 1},
-            {"help", no_argument, 0, 'h'},
-            {"region", required_argument, 0, 'r'},
-            {0, 0, 0, 0}
-        };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "hr:",
-                         long_options, &option_index);
-
-        if (c == -1)
-            break;
-
-        switch (c) {
-
-        case 'h':
-            printSummary(argv);
-            break;
-
-        case 'r':
-            region = optarg;
-            break;
-            
-        case '?':
-            printSummary(argv);
-            exit(1);
-            break;
-                
-        default:
-            abort ();
-        }
-    }
-
-    vector<string> sampleNames;
-    string randomHeader;
-    VariantCallFile* vcf;
-
-    // structure to track ordered variants
-    //ChromNameCompare chromCompare;
-
-    typedef 
-        map<vector<string>, // alts
-            map<VariantCallFile*, Variant*> >
-        Position;
-
-    typedef
-        map<long int, Position>
-        ChromVariants;
-
-    typedef
-        map<string, // chrom
-            ChromVariants,
-            ChromNameCompare>
-        VariantsByChromPosAltFile;
-
-    VariantsByChromPosAltFile  variantsByChromPosAltFile;
-
-    VariantCallFile* firstVCF = NULL;
-    for (int i = optind; i != argc; ++i) {
-        string inputFilename = argv[i];
-        vcf = new VariantCallFile;
-        vcf->open(inputFilename);
-        if (!region.empty()) {
-            if (!vcf->setRegion(region)) {
-                cerr << "could not set region on " << inputFilename << endl;
-                delete vcf;
-                continue;
-            }
-        }
-        if (vcf->is_open()) {
-            Variant* var = new Variant(*vcf);
-            if (vcf->getNextVariant(*var)) {
-                variantsByChromPosAltFile[var->sequenceName][var->position][var->alt][vcf] = var;
-                sampleNames.insert(sampleNames.end(), vcf->sampleNames.begin(), vcf->sampleNames.end());
-                // the first file is tracked for header generation
-            }
-            if (firstVCF == NULL) firstVCF = vcf;
-        }
-    }
-
-    // get sorted, unique samples in all files
-    sort(sampleNames.begin(), sampleNames.end());
-    sampleNames.erase(unique(sampleNames.begin(), sampleNames.end()), sampleNames.end());
-
-    // now that we've accumulated the sample information we can generate the combined header
-    VariantCallFile outputCallFile;
-    string header = firstVCF->headerWithSampleNames(sampleNames);
-    outputCallFile.openForOutput(header);
-
-    cout << outputCallFile.header << endl;
-
-    while (!variantsByChromPosAltFile.empty()) {
-        // get lowest variant(s)
-        // if they have identical alts and position, combine
-        // otherwise just output, but with the same sample names
-
-        ChromVariants& chrom = variantsByChromPosAltFile.begin()->second;
-        if (chrom.empty()) {
-            variantsByChromPosAltFile.erase(variantsByChromPosAltFile.begin());
-            continue;
-        }
-        
-        Position& pos = chrom.begin()->second;
-        Position::iterator s = pos.begin();
-        for ( ; s != pos.end(); ++s) {
-            Variant variant(outputCallFile);
-            map<VariantCallFile*, Variant*>& vars = s->second;
-            map<VariantCallFile*, Variant*>::iterator v = vars.begin();
-            for ( ; v != vars.end(); ++v) {
-                VariantCallFile* vcf = v->first;
-                Variant* var = v->second;
-                //if (variant.info.empty()) {
-                if (v == vars.begin()) { // set these using the first matching variant
-                    variant.sequenceName = var->sequenceName;
-                    variant.position = var->position;
-                    variant.id = var->id;
-                    variant.ref = var->ref;
-                    variant.alt = var->alt;
-                    variant.filter = var->filter;
-                    variant.quality = var->quality;
-                    variant.info = var->info;
-                    variant.format = var->format;
-                }
-                // add samples to output variant
-                for (Samples::iterator sample = var->samples.begin(); sample != var->samples.end(); ++sample) {
-                    variant.samples[sample->first] = sample->second;
-                }
-                if (vcf->getNextVariant(*var)) {
-                    variantsByChromPosAltFile[var->sequenceName][var->position][var->alt][vcf] = var;
-                }
-            }
-            // what was this chck for?
-            //if (!variant.info.empty())
-            cout << variant << endl;
-        }
-        // pop the last position
-        chrom.erase(chrom.begin());
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfcommonsamples.cpp b/vcflib/src/vcfcommonsamples.cpp
deleted file mode 100644
index ee594cb..0000000
--- a/vcflib/src/vcfcommonsamples.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include <string>
-#include <iostream>
-
-using namespace std;
-using namespace vcf;
-
-template<class T>
-vector<T> intersection(vector<T>& a, vector<T>& b) {
-    map<T, bool> inA;
-    map<T, bool> inAB;
-    for (typename vector<T>::iterator i = a.begin(); i != a.end(); ++i) {
-        inA[*i] = true;
-    }
-    for (typename vector<T>::iterator i = b.begin(); i != b.end(); ++i) {
-        if (inA.find(*i) != inA.end()) {
-            inAB[*i] = true;
-        }
-    }
-    vector<T> aIb;
-    for (typename map<T, bool>::iterator i = inAB.begin(); i != inAB.end(); ++i) {
-        aIb.push_back(i->first);
-    }
-    return aIb;
-}
-
-int main(int argc, char** argv) {
-
-    if (argc != 3) {
-        cerr << "usage: " << argv[0] << " <vcf file> <vcf file>" << endl
-             << "outputs each record in the first file, removing samples not present in the second" << endl;
-        return 1;
-    }
-
-    string filenameA = argv[1];
-    string filenameB = argv[2];
-
-    if (filenameA == filenameB) {
-        cerr << "you're just spinning your wheels matching the samples in "
-            << filenameA << " to the samples in " << filenameB << endl;
-        return 1;
-    }
-
-    VariantCallFile variantFileA;
-    if (filenameA == "-") {
-        variantFileA.open(std::cin);
-    } else {
-        variantFileA.open(filenameA);
-    }
-
-    VariantCallFile variantFileB;
-    if (filenameB == "-") {
-        variantFileB.open(std::cin);
-    } else {
-        variantFileB.open(filenameB);
-    }
-
-    if (!variantFileA.is_open() || !variantFileB.is_open()) {
-        return 1;
-    }
-
-    Variant varA(variantFileA);
-    Variant varB(variantFileB);
-
-    vector<string> commonSamples = intersection(variantFileA.sampleNames, variantFileB.sampleNames);
-
-    // update sample list in header
-    variantFileA.updateSamples(commonSamples);
-
-    // and restrict the output sample names in the variant to those we are keeping
-    varA.setOutputSampleNames(commonSamples);
- 
-    // write the new header
-    cout << variantFileA.header << endl;
- 
-    // print the records, filtering is done via the setting of varA's output sample names
-    while (variantFileA.getNextVariant(varA)) {
-        cout << varA << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfcountalleles.cpp b/vcflib/src/vcfcountalleles.cpp
deleted file mode 100644
index 9ce6aae..0000000
--- a/vcflib/src/vcfcountalleles.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-#include "Variant.h"
-
-using namespace std;
-using namespace vcf;
-
-int main(int argc, char** argv) {
-
-    VariantCallFile variantFile;
-
-    if (argc > 1) {
-        string filename = argv[1];
-        variantFile.open(filename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    int uniqueAlleles = 0;
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-        uniqueAlleles += var.alleles.size();
-    }
-
-    cout << uniqueAlleles << endl;
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfcreatemulti.cpp b/vcflib/src/vcfcreatemulti.cpp
deleted file mode 100644
index 78ba959..0000000
--- a/vcflib/src/vcfcreatemulti.cpp
+++ /dev/null
@@ -1,195 +0,0 @@
-#include "Variant.h"
-#include "convert.h"
-#include <set>
-#include <sstream>
-#include <getopt.h>
-
-using namespace std;
-using namespace vcf;
-
-
-double convertStrDbl(const string& s) {
-    double r;
-    convert(s, r);
-    return r;
-}
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [options] [file]" << endl
-         << endl
-         << "If overlapping alleles are represented across multiple records, merge" << endl
-         << "them into a single record.  Currently only for indels." << endl;
-    exit(0);
-}
-
-Variant createMultiallelic(vector<Variant>& vars) {
-
-    if (vars.size() == 1) {
-        return vars.front();
-    }
-
-    int maxpos = vars.front().position + vars.front().ref.size();
-    for (vector<Variant>::iterator v = vars.begin(); v != vars.end(); ++v) {
-        //cerr << *v << endl;
-        if (maxpos < v->position + v->ref.size()) {
-            maxpos = v->position + v->ref.size();
-        }
-    }
-
-    int numalt = vars.size();
-    //cerr << "gots overlapping vars " << vars.front().position << "-" << vars.back().position << endl;
-
-    // get REF
-    // use start position to extend all other alleles
-    int start = vars.front().position;
-    string ref = vars.front().ref;
-
-    for (vector<Variant>::iterator v = vars.begin() + 1; v != vars.end(); ++v) {
-        int sdiff = (v->position + v->ref.size()) - (start + ref.size());
-        int pdiff = (start + ref.size()) - v->position;
-        if (sdiff > 0) {
-            ref.append(v->ref.substr(pdiff, sdiff));
-        }
-    }
-
-    //cerr << "ref would be " << ref << " for vars from "
-    //     << vars.front().position << " to " << vars.back().position << endl;
-
-    Variant var = vars.front();
-    var.alt.clear();
-    var.ref = ref;
-
-    for (vector<Variant>::iterator v = vars.begin(); v != vars.end(); ++v) {
-        // add alternates and splice them into the reference
-        int p5diff = v->position - var.position;
-        int p3diff = (var.position + var.ref.size()) - (v->position + v->ref.size());
-        string before;
-        string after;
-        if (p5diff > 0) {
-            before = var.ref.substr(0, p5diff);
-        }
-        if (p3diff > 0 && p3diff < var.ref.size()) {
-            after = var.ref.substr(var.ref.size() - p3diff);
-        }
-        if (p5diff || p3diff) {
-            for (vector<string>::iterator a = v->alt.begin(); a != v->alt.end(); ++a) {
-                var.alt.push_back(before);
-                string& alt = var.alt.back();
-                alt.append(*a);
-                alt.append(after);
-            }
-        } else {
-            for (vector<string>::iterator a = v->alt.begin(); a != v->alt.end(); ++a) {
-                var.alt.push_back(*a);
-            }
-        }
-    }
-
-    stringstream s;
-    s << vars.front().position << "-" << vars.back().position;
-    var.info["combined"].push_back(s.str());
-
-    return var;
-
-}
-
-int main(int argc, char** argv) {
-
-    VariantCallFile variantFile;
-
-    int c;
-    while (true) {
-        static struct option long_options[] =
-        {
-            /* These options set a flag. */
-            //{"verbose", no_argument,       &verbose_flag, 1},
-            {"help", no_argument, 0, 'h'},
-            {0, 0, 0, 0}
-        };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "h",
-                         long_options, &option_index);
-
-        if (c == -1)
-            break;
-
-        switch (c) {
-
-            case 'h':
-                printSummary(argv);
-                break;
-
-            case '?':
-                printSummary(argv);
-                exit(1);
-                break;
-
-            default:
-                abort ();
-        }
-    }
-
-    if (optind < argc) {
-        string filename = argv[optind];
-        variantFile.open(filename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    variantFile.addHeaderLine("##INFO=<ID=combined,Number=1,Type=String,Description=\"Range of overlapping variants which were combined into this one using vcfcreatemulti.\">");
-
-    cout << variantFile.header << endl;
-
-    bool first = true;
-    bool already = false;
-    Variant var(variantFile);
-    vector<Variant> vars;
-    string lastSeq;
-
-    while (variantFile.getNextVariant(var)) {
-
-        if (lastSeq.empty()) {
-            lastSeq = var.sequenceName;
-        }
-
-        if (vars.empty()) {
-            vars.push_back(var);
-            continue;
-        } else {
-            int maxpos = vars.front().position + vars.front().ref.size();
-            for (vector<Variant>::iterator v = vars.begin(); v != vars.end(); ++v) {
-                if (maxpos < v->position + v->ref.size()) {
-                    maxpos = v->position + v->ref.size();
-                }
-            }
-            if (var.sequenceName != lastSeq) {
-                Variant result = createMultiallelic(vars);
-                cout << result << endl;
-                vars.clear();
-                lastSeq = var.sequenceName;
-                vars.push_back(var);
-            } else if (var.position < maxpos) {
-                vars.push_back(var);
-            } else {
-                Variant result = createMultiallelic(vars);
-                cout << result << endl;
-                vars.clear();
-                vars.push_back(var);
-            }
-        }
-
-    }
-
-    Variant result = createMultiallelic(vars);
-    cout << result << endl;
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfdistance.cpp b/vcflib/src/vcfdistance.cpp
deleted file mode 100644
index 818caef..0000000
--- a/vcflib/src/vcfdistance.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include <string>
-#include <iostream>
-
-using namespace std;
-using namespace vcf;
-
-int main(int argc, char** argv) {
-
-    if (argc > 1) {
-        cerr << "usage: " << argv[0] << " <[vcf file]" << endl
-             << "adds a tag (BasesToNextVariant) to each variant record which indicates" << endl
-             << "the distance to the nearest variant" << endl;
-        return 1;
-    }
-
-    VariantCallFile variantFile;
-    variantFile.open(std::cin);
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    Variant varA(variantFile);
-    Variant varB(variantFile);
-    Variant varC(variantFile);
-
-    vector<Variant*> vars;
-    vars.push_back(&varA);
-    vars.push_back(&varB);
-    vars.push_back(&varC);
-    
-    for (vector<Variant*>::iterator v = vars.begin(); v != vars.end(); ++v) {
-        variantFile.getNextVariant(**v);
-    }
-
-    string tag = "BasesToClosestVariant";
-    string line = "##INFO=<ID=" + tag + ",Number=1,Type=Integer,Description=\"" \
-        + "Number of bases to the closest variant in the file.\">";
-    variantFile.addHeaderLine(line);
-
-    cout << variantFile.header << endl;
-
-    // get the first distances
-    if (vars.at(0)->sequenceName == vars.at(1)->sequenceName) {
-        vars.at(0)->info[tag].push_back(convert(vars.at(1)->position - vars.at(0)->position));
-    }
-
-    while (variantFile.getNextVariant(*vars.back())) {
-
-        if (vars.at(1)->sequenceName == vars.at(0)->sequenceName &&
-            vars.at(1)->sequenceName == vars.at(2)->sequenceName) {
-            vars.at(1)->info[tag].push_back(convert(min(vars.at(1)->position - vars.at(0)->position,
-                                                        vars.at(2)->position - vars.at(1)->position)));
-        } else if (vars.at(1)->sequenceName == vars.at(0)->sequenceName) {
-            vars.at(1)->info[tag].push_back(convert(vars.at(1)->position - vars.at(0)->position));
-        } else if (vars.at(2)->sequenceName == vars.at(1)->sequenceName) {
-            vars.at(1)->info[tag].push_back(convert(vars.at(2)->position - vars.at(1)->position));
-        } else {
-            // don't add the tag
-        }
-        cout << *vars.front() << endl;
-        // rotate
-        Variant* v = vars.at(0);
-        vars.at(0) = vars.at(1);
-        vars.at(1) = vars.at(2);
-        vars.at(2) = v;
-
-    }
-
-    // assign the last distances
-    
-    if (vars.at(0)->sequenceName == vars.at(1)->sequenceName) {
-        vars.at(0)->info[tag].push_back(convert(vars.at(1)->position - vars.at(0)->position));
-        cout << *vars.at(0) << endl;
-	
-        vars.at(1)->info[tag].push_back(convert(vars.at(1)->position - vars.at(0)->position));
-        cout << *vars.at(1) << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfecho.cpp b/vcflib/src/vcfecho.cpp
deleted file mode 100644
index b850440..0000000
--- a/vcflib/src/vcfecho.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "Variant.h"
-
-using namespace std;
-using namespace vcf;
-
-int main(int argc, char** argv) {
-
-    VariantCallFile variantFile;
-
-    if (argc > 1) {
-        string filename = argv[1];
-        variantFile.open(filename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    cout << variantFile.header << endl;
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-        cout << var << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfentropy.cpp b/vcflib/src/vcfentropy.cpp
deleted file mode 100644
index 81b9238..0000000
--- a/vcflib/src/vcfentropy.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include "fastahack/Fasta.h"
-#include <getopt.h>
-
-using namespace std;
-using namespace vcf;
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [options] <vcf file>" << endl
-         << endl
-         << "options:" << endl 
-         << "    -f, --fasta-reference  FASTA reference file to use to obtain primer sequences" << endl
-         << "    -w, --window-size      Size of the window over which to calculate entropy" << endl
-         << endl
-	 << "Anotates the output VCF file with, for each record, EntropyLeft, EntropyRight," << endl
-	 << "EntropyCenter, which are the entropies of the sequence of the given window size to the" << endl
-	 << "left, right, and center  of the record." << endl
-         << endl;
-    exit(0);
-}
-
-
-int main(int argc, char** argv) {
-
-    int c;
-    string fastaRef;
-    int windowSize = 0;
-
-    if (argc == 1)
-        printSummary(argv);
-
-    while (true) {
-        static struct option long_options[] =
-        {
-            /* These options set a flag. */
-            //{"verbose", no_argument,       &verbose_flag, 1},
-            {"help", no_argument, 0, 'h'},
-            {"fasta-reference",  required_argument, 0, 'f'},
-            {"window-size", required_argument, 0, 'w'},
-            //{"length",  no_argument, &printLength, true},
-            {0, 0, 0, 0}
-        };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "hf:w:",
-                         long_options, &option_index);
-
-      /* Detect the end of the options. */
-          if (c == -1)
-            break;
- 
-          switch (c)
-            {
-            case 0:
-            /* If this option set a flag, do nothing else now. */
-            if (long_options[option_index].flag != 0)
-              break;
-            printf ("option %s", long_options[option_index].name);
-            if (optarg)
-              printf (" with arg %s", optarg);
-            printf ("\n");
-            break;
-
-          case 'f':
-            fastaRef = optarg;
-            break;
-
-          case 'w':
-            windowSize = atoi(optarg);
-            break;
- 
-          case 'h':
-            printSummary(argv);
-            exit(0);
-            break;
-
-          case '?':
-            /* getopt_long already printed an error message. */
-            printSummary(argv);
-            exit(1);
-            break;
- 
-          default:
-            abort ();
-          }
-      }
-
-    if (windowSize == 0) {
-        cerr << "a window size must be specified" << endl;
-        exit(1);
-    }
-    if (fastaRef.empty()) {
-        cerr << "a FASTA reference sequence must be specified" << endl;
-        exit(1);
-    }
-
-    FastaReference ref;
-    ref.open(fastaRef);
-
-    VariantCallFile variantFile;
-    string inputFilename;
-    if (optind == argc - 1) {
-        inputFilename = argv[optind];
-        variantFile.open(inputFilename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    variantFile.addHeaderLine("##INFO=<ID=EntropyLeft,Number=1,Type=Float,Description=\"Entropy of left-flanking sequence of "+ convert(windowSize) +"bp\">");
-    variantFile.addHeaderLine("##INFO=<ID=EntropyCenter,Number=1,Type=Float,Description=\"Entropy of centered sequence of "+ convert(windowSize) +"bp\">");
-    variantFile.addHeaderLine("##INFO=<ID=EntropyRight,Number=1,Type=Float,Description=\"Entropy of right-flanking sequence of "+ convert(windowSize) +"bp\">");
-
-    cout << variantFile.header << endl;
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-        // get the ref start and end positions
-        int refstart = var.position - 1; // convert to 0-based
-        int refend = var.position + var.ref.size() - 1;
-        string leftseq = ref.getSubSequence(var.sequenceName, refstart - windowSize, windowSize);
-        string rightseq = ref.getSubSequence(var.sequenceName, refend, windowSize);
-	string centerseq = ref.getSubSequence(var.sequenceName, refstart - windowSize/2, windowSize);
-	double entropyLeft = shannon_H((char*) &leftseq[0], windowSize);
-	double entropyRight = shannon_H((char*) &rightseq[0], windowSize);
-	double entropyCenter = shannon_H((char*) &centerseq[0], windowSize);
-	var.info["EntropyLeft"].push_back(convert(entropyLeft));
-	var.info["EntropyRight"].push_back(convert(entropyRight));
-	var.info["EntropyCenter"].push_back(convert(entropyCenter));
-
-        cout << var << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfevenregions.cpp b/vcflib/src/vcfevenregions.cpp
deleted file mode 100644
index 5888c98..0000000
--- a/vcflib/src/vcfevenregions.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include "fastahack/Fasta.h"
-#include <getopt.h>
-#include <cmath>
-
-using namespace std;
-using namespace vcf;
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [options] <vcf file>" << endl
-         << endl
-         << "options:" << endl 
-         << "    -f, --fasta-reference REF    FASTA reference file to use to obtain primer sequences." << endl
-         << "    -n, --number-of-regions N    The number of desired regions." << endl
-         << "    -p, --number-of-positions N  The number of positions per region." << endl
-         << "    -o, --offset N               Add an offset to region positioning, to avoid boundary" << endl
-         << "                                 related artifacts in downstream processing." << endl
-         << "    -l, --overlap N              The number of sites to overlap between regions.  Default 0." << endl
-         << "    -s, --separator SEQ          Specify string to use to separate region output.  Default '-'" << endl
-         << endl
-         << "Generates a list of regions, e.g. chr20:10..30 using the variant" << endl
-         << "density information provided in the VCF file to ensure that the regions have" << endl
-         << "even numbers of variants.  This can be use to reduce the variance in runtime" << endl
-         << "when dividing variant detection or genotyping by genomic coordinates." << endl;
-    exit(0);
-}
-
-
-struct Region {
-    long int start;
-    long int end;
-    int positions;
-    Region() : start(0), end(0), positions(0) { }
-    Region(long int s, long int e)
-        : start(s), end(e), positions(0) { }
-};
-
-
-int main(int argc, char** argv) {
-
-    int c;
-    string fastaRef;
-    bool keepFailures = false;
-    bool excludeFailures = false;
-    int number_of_regions = 1;
-    int number_of_positions = 0;
-    int offset = 0;
-    int overlap = 0;
-    string regionSplitSeq = "-";
-
-    if (argc == 1)
-        printSummary(argv);
-
-    while (true) {
-        static struct option long_options[] =
-            {
-                /* These options set a flag. */
-                //{"verbose", no_argument,       &verbose_flag, 1},
-                {"help", no_argument, 0, 'h'},
-                {"fasta-reference",  required_argument, 0, 'f'},
-                {"number-of-regions",  required_argument, 0, 'n'},
-                {"number-of-positions",  required_argument, 0, 'p'},
-                {"offset",  required_argument, 0, 'o'},
-                {"overlap",  required_argument, 0, 'l'},
-                {"separator",  required_argument, 0, 's'},
-                //{"length",  no_argument, &printLength, true},
-                {0, 0, 0, 0}
-            };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "hf:n:o:l:s:p:",
-                         long_options, &option_index);
-
-        /* Detect the end of the options. */
-        if (c == -1)
-            break;
- 
-        switch (c)
-        {
-        case 0:
-            /* If this option set a flag, do nothing else now. */
-            if (long_options[option_index].flag != 0)
-                break;
-            printf ("option %s", long_options[option_index].name);
-            if (optarg)
-                printf (" with arg %s", optarg);
-            printf ("\n");
-            break;
-
-        case 'f':
-            fastaRef = optarg;
-            break;
-
-        case 'n':
-            number_of_regions = atoi(optarg);
-            break;
-
-        case 'p':
-            number_of_positions = atoi(optarg);
-            break;
-
-        case 'o':
-            offset = atoi(optarg);
-            break;
-
-        case 'l':
-            overlap = atoi(optarg);
-            break;
-
-        case 's':
-            regionSplitSeq = optarg;
-            break;
- 
-        case 'h':
-            printSummary(argv);
-            exit(0);
-            break;
-
-        case '?':
-            /* getopt_long already printed an error message. */
-            printSummary(argv);
-            exit(1);
-            break;
- 
-        default:
-            abort ();
-        }
-    }
-
-    if (fastaRef.empty()) {
-        cerr << "a FASTA reference sequence must be specified" << endl;
-        exit(1);
-    }
-
-    FastaReference ref;
-    ref.open(fastaRef);
-
-    VariantCallFile variantFile;
-    string inputFilename;
-    if (optind == argc - 1) {
-        inputFilename = argv[optind];
-        variantFile.open(inputFilename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    map<string, vector<Region> > positions_by_chrom;
-    int total_positions = 0;
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-        int refstart = var.position - 1; // convert to 0-based
-        positions_by_chrom[var.sequenceName].push_back(Region(refstart + offset, refstart + offset + var.ref.size()));
-        ++total_positions;
-    }
-
-    int positions_per_region;
-    if (number_of_positions) {
-        if (number_of_positions - overlap < 0) {
-            cerr << "overlap is greater than the number of positions per region!" << endl;
-            exit(1);
-        } else {
-            positions_per_region = number_of_positions - overlap;
-        }
-    } else {
-        positions_per_region = ceil((double) total_positions / (double) number_of_regions);
-    }
-    //cerr << positions_per_region << "=" << total_positions << "/" << number_of_regions << "+" << overlap << endl;
-
-    // todo, update routine to allow overlaps
-
-    for (map<string, vector<Region> >::iterator s = positions_by_chrom.begin();
-         s != positions_by_chrom.end(); ++s) {
-        //pair<long int, long int> current_region;
-        Region current_region;
-        for (vector<Region>::iterator p = s->second.begin(); p != s->second.end(); ++p) {
-            if (current_region.positions < positions_per_region + overlap) {
-                current_region.end = p->end;
-                current_region.positions++;
-            } else {
-                cout << s->first << ":" << current_region.start << regionSplitSeq << current_region.end << endl;
-                vector<Region>::iterator l = max(s->second.begin(), p-overlap-1);
-                current_region.start = l->end;
-                current_region.end = p->end;
-                current_region.positions = overlap + 1;
-            }
-        }
-        // get refseq size, use as end coordinate for last region in target
-        current_region.end = ref.sequenceLength(s->first);
-        cout << s->first << ":" << current_region.start << regionSplitSeq << current_region.end << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcffilter.cpp b/vcflib/src/vcffilter.cpp
deleted file mode 100644
index 984596a..0000000
--- a/vcflib/src/vcffilter.cpp
+++ /dev/null
@@ -1,389 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include <getopt.h>
-
-using namespace std;
-using namespace vcf;
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [options] <vcf file>" << endl
-         << endl
-         << "options:" << endl 
-         << "    -f, --info-filter     specifies a filter to apply to the info fields of records," << endl
-         << "                          removes alleles which do not pass the filter" << endl
-         << "    -g, --genotype-filter specifies a filter to apply to the genotype fields of records" << endl
-         << "    -s, --filter-sites    filter entire records, not just alleles" << endl
-         << "    -t, --tag-pass        tag vcf records as positively filtered with this tag, print all records" << endl
-         << "    -F, --tag-fail        tag vcf records as negatively filtered with this tag, print all records" << endl
-         << "    -A, --append-filter   append the existing filter tag, don't just replace it" << endl
-         << "    -a, --allele-tag      apply -t on a per-allele basis.  adds or sets the corresponding INFO field tag" << endl
-         << "    -v, --invert          inverts the filter, e.g. grep -v" << endl
-         << "    -o, --or              use logical OR instead of AND to combine filters" << endl
-         << "    -r, --region          specify a region on which to target the filtering, requires a BGZF" << endl
-         << "                          compressed file which has been indexed with tabix.  any number of" << endl
-         << "                          regions may be specified." << endl
-         << endl
-         << "Filter the specified vcf file using the set of filters." << endl
-         << "Filters are specified in the form \"<ID> <operator> <value>:" << endl
-         << " -f \"DP > 10\"  # for info fields" << endl
-         << " -g \"GT = 1|1\" # for genotype fields" << endl
-         << " -f \"CpG\"  # for 'flag' fields" << endl
-         << endl
-         << "Operators can be any of: =, !, <, >, |, &" << endl
-         << endl
-         << "Any number of filters may be specified.  They are combined via logical AND" << endl
-         << "unless --or is specified on the command line.  Obtain logical negation through" << endl
-         << "the use of parentheses, e.g. ! \"( DP = 10 )\"" << endl
-         << endl
-         << "For convenience, you can specify \"QUAL\" to refer to the quality of the site, even" << endl
-         << "though it does not appear in the INFO fields." << endl
-         << endl;
-    exit(0);
-}
-
-bool passesFilters(Variant& var, vector<VariantFilter>& filters, bool logicalOr, string alt = "") {
-    for (vector<VariantFilter>::iterator f = filters.begin(); f != filters.end(); ++f) {
-        string s = "";
-        if (logicalOr) {
-            if (alt.empty()) {
-                if (f->passes(var, s)) return true;
-            } else {
-                if (f->passes(var, s, alt)) return true;
-            }
-        } else {
-            if (alt.empty()) {
-                if (!f->passes(var, s)) return false;
-            } else {
-                if (!f->passes(var, s, alt)) return false;
-            }
-        }
-    }
-    if (logicalOr)
-        return false;
-    else
-        return true;
-}
-
-
-int main(int argc, char** argv) {
-
-    int c;
-    bool invert = false;
-    bool logicalOr = false;
-    bool filterSites = false;
-    vector<string> infofilterStrs;
-    vector<VariantFilter> infofilters;
-    vector<string> genofilterStrs;
-    vector<VariantFilter> genofilters;
-    string tagPass = "";
-    string tagFail = "";
-    string filterSpec;
-    string alleleTag;
-    vector<string> regions;
-    bool replaceFilter = true;
-
-    if (argc == 1)
-        printSummary(argv);
-
-    while (true) {
-        static struct option long_options[] =
-            {
-                /* These options set a flag. */
-                //{"verbose", no_argument,       &verbose_flag, 1},
-                {"help", no_argument, 0, 'h'},
-                {"filter-sites", no_argument, 0, 's'},
-                {"info-filter",  required_argument, 0, 'f'},
-                {"genotype-filter",  required_argument, 0, 'g'},
-                {"tag-pass", required_argument, 0, 't'},
-                {"tag-pass", required_argument, 0, 'F'},
-                {"append-filter", no_argument, 0, 'A'},
-                {"allele-tag", required_argument, 0, 'a'},
-                {"invert", no_argument, 0, 'v'},
-                {"or", no_argument, 0, 'o'},
-                {"region", required_argument, 0, 'r'},
-                //{"length",  no_argument, &printLength, true},
-                {0, 0, 0, 0}
-            };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "hvAsof:g:t:F:r:a:",
-                         long_options, &option_index);
-
-        /* Detect the end of the options. */
-        if (c == -1)
-            break;
- 
-        switch (c)
-        {
-        case 0:
-            /* If this option set a flag, do nothing else now. */
-            if (long_options[option_index].flag != 0)
-                break;
-            printf ("option %s", long_options[option_index].name);
-            if (optarg)
-                printf (" with arg %s", optarg);
-            printf ("\n");
-            break;
-
-        case 'f':
-            filterSpec += " " + string(optarg);
-            infofilterStrs.push_back(string(optarg));
-            break;
-
-        case 's':
-            filterSites = true;
-            break;
-
-        case 'a':
-            alleleTag = optarg;
-            break;
- 
-        case 'g':
-            filterSpec += " genotypes filtered with: " + string(optarg);
-            genofilterStrs.push_back(string(optarg));
-            break;
- 
-        case 't':
-            tagPass = optarg;
-            break;
- 
-        case 'F':
-            tagFail = optarg;
-            break;
- 
-        case 'A':
-            replaceFilter = false;
-            break;
-
-        case 'h':
-            printSummary(argv);
-            exit(0);
-            break;
-
-        case 'v':
-            invert = true;
-            break;
-
-        case 'o':
-            logicalOr = true;
-            break;
-
-        case 'r':
-            regions.push_back(optarg);
-            break;
-          
-        case '?':
-            /* getopt_long already printed an error message. */
-            printSummary(argv);
-            exit(1);
-            break;
- 
-        default:
-            abort ();
-        }
-    }
-
-    filterSpec = filterSpec.substr(1); // strip leading " "
-
-    VariantCallFile variantFile;
-    string inputFilename;
-    if (optind == argc - 1) {
-        inputFilename = argv[optind];
-        variantFile.open(inputFilename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    for (vector<string>::iterator f = infofilterStrs.begin(); f != infofilterStrs.end(); ++f) {
-        infofilters.push_back(VariantFilter(*f, VariantFilter::RECORD, variantFile.infoTypes));
-    }
-
-    for (vector<string>::iterator f = genofilterStrs.begin(); f != genofilterStrs.end(); ++f) {
-        genofilters.push_back(VariantFilter(*f, VariantFilter::SAMPLE, variantFile.formatTypes));
-    }
-
-    vector<string> headerlines = split(variantFile.header, "\n");
-    variantFile.header.clear();
-    for (vector<string>::iterator l = headerlines.begin(); l != headerlines.end(); ++l) {
-        if (!filterSpec.empty() && (l->find("INFO") != string::npos || l + 1 == headerlines.end())) {
-            variantFile.header += "##filter=\"" + filterSpec + "\"\n";
-            filterSpec.clear();
-        }
-        variantFile.header += *l + ((l + 1 == headerlines.end()) ? "" : "\n");
-    }
-
-    if (!tagPass.empty()) {
-        variantFile.addHeaderLine("##FILTER=<ID="+ tagPass +",Description=\"Record passes the filters: " + filterSpec + ".\">");
-    }
-
-    if (!tagFail.empty()) {
-        variantFile.addHeaderLine("##FILTER=<ID="+ tagFail +",Description=\"Record fails the filters: " + filterSpec + ".\">");
-    }
-
-    if (!alleleTag.empty()) {
-        if (tagFail.empty()) {
-            tagFail = "";
-        }
-        if (tagPass.empty()) {
-            tagPass = "PASS";
-        }
-        variantFile.addHeaderLine("##INFO=<ID="+ alleleTag +",Number=A,Type=String,Description=\"" + tagPass + " if this allele passes the filters, " + tagFail + " if not, filters are: " + filterSpec + ".\">");
-    }
-
-    cout << variantFile.header << endl;
-
-    /*
-      if (genofilters.empty()) {
-      variantFile.parseSamples = false;
-      }
-    */
-
-    if (filterSites) {
-        variantFile.parseSamples = false;
-    }
-
-    Variant var(variantFile);
-
-    vector<string>::iterator regionItr = regions.begin();
-
-    do {
-
-        if (!inputFilename.empty() && !regions.empty()) {
-            string regionStr = *regionItr++;
-            variantFile.setRegion(regionStr);
-        }
-
-        while (variantFile.getNextVariant(var)) {
-            if (!genofilters.empty()) {
-                for (vector<VariantFilter>::iterator f = genofilters.begin(); f != genofilters.end(); ++f) {
-                    f->removeFilteredGenotypes(var);
-                }
-            }
-            if (!infofilters.empty()) {
-                if (filterSites) {
-                    bool passes = passesFilters(var, infofilters, logicalOr);
-                    if (invert) {
-                        passes = !passes;
-                    }
-                    if (passes) {
-                        if (!tagPass.empty()) {
-                            if (alleleTag.empty()) {
-                                if (replaceFilter) {
-                                    var.filter.clear();
-                                    var.addFilter(tagPass);
-                                } else {
-                                    var.addFilter(tagPass);
-                                }
-                            } else {
-                                var.info[alleleTag].clear();
-                                for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-                                    var.info[alleleTag].push_back(tagPass);
-                                }
-                            }
-                        } else {
-                            if (!var.originalLine.empty()) {
-                                cout << var.originalLine << endl;
-                            } else {
-                                cout << var << endl;
-                            }
-                        }
-                    } else {
-                        if (!tagFail.empty()) {
-                            if (alleleTag.empty()) {
-                                if (replaceFilter) {
-                                    var.filter.clear();
-                                    var.addFilter(tagFail);
-                                } else {
-                                    var.addFilter(tagFail);
-                                }
-                            } else {
-                                var.info[alleleTag].clear();
-                                for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-                                    var.info[alleleTag].push_back(tagFail);
-                                }
-                            }
-                        }
-                    }
-                    if (passes && !tagPass.empty()) {
-                        cout << var << endl;
-                    } else if (!tagFail.empty()) {
-                        cout << var << endl;
-                    }
-                } else { // filter out alleles which pass
-                    // removes the failing alleles
-                    vector<string> failingAlts;
-                    vector<string> passingAlts;
-                    vector<bool> passes;
-                    for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-                        if (!passesFilters(var, infofilters, logicalOr, *a)) {
-                            failingAlts.push_back(*a);
-                            passes.push_back(false);
-                        } else {
-                            passingAlts.push_back(*a);
-                            passes.push_back(true);
-                        }
-                    }
-                    if (tagPass.empty()) { // if there is no specified tag, just remove the failing alts
-                        if (failingAlts.size() < var.alt.size()) {
-                            for (vector<string>::iterator a = failingAlts.begin(); a != failingAlts.end(); ++a) {
-                                var.removeAlt(*a);
-                            }
-                            cout << var << endl;
-                        }
-                    } else { // otherwise, apply the tag
-                        if (alleleTag.empty()) {
-                            if (!passingAlts.empty()) {
-                                if (replaceFilter) {
-                                    var.filter.clear();
-                                    var.addFilter(tagPass);
-                                } else {
-                                    var.addFilter(tagPass);
-                                }
-                            } else {
-                                if (replaceFilter) {
-                                    var.filter.clear();
-                                    if (!tagFail.empty()) {
-                                        var.addFilter(tagFail);
-                                    }
-                                } else {
-                                    if (!tagFail.empty()) {
-                                        var.addFilter(tagFail);
-                                    }
-                                }
-                            }
-                        } else {
-                            var.info[alleleTag].clear();
-                            for (vector<bool>::iterator p = passes.begin(); p != passes.end(); ++p) {
-                                if (*p) {
-                                    var.info[alleleTag].push_back(tagPass);
-                                } else {
-                                    var.info[alleleTag].push_back(tagFail);
-                                }
-                            }
-                        }
-                        // TODO
-                        // here, if we don't use genotype filters, we shouldn't re-print the samples
-                        // we haven't done anything to this part of the input.
-                        cout << var << endl;
-                    }
-                }
-            } else {
-                if (genofilters.empty()) {
-                    cout << variantFile.line << endl;
-                } else {
-                    cout << var << endl;
-                }
-            }
-        }
-
-    } while (regionItr != regions.end());
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcffixup.cpp b/vcflib/src/vcffixup.cpp
deleted file mode 100644
index 1da3a34..0000000
--- a/vcflib/src/vcffixup.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include <string>
-#include <sstream>
-#include <iostream>
-
-using namespace std;
-using namespace vcf;
-
-int countAlts(Variant& var, int alleleIndex) {
-    int alts = 0;
-    for (map<string, map<string, vector<string> > >::iterator s = var.samples.begin(); s != var.samples.end(); ++s) {
-        map<string, vector<string> >& sample = s->second;
-        map<string, vector<string> >::iterator gt = sample.find("GT");
-        if (gt != sample.end()) {
-            map<int, int> genotype = decomposeGenotype(gt->second.front());
-            for (map<int, int>::iterator g = genotype.begin(); g != genotype.end(); ++g) {
-                if (g->first == alleleIndex) {
-                    alts += g->second;
-                }
-            }
-        }
-    }
-    return alts;
-}
-
-int countAlleles(Variant& var) {
-    int alleles = 0;
-    for (map<string, map<string, vector<string> > >::iterator s = var.samples.begin(); s != var.samples.end(); ++s) {
-        map<string, vector<string> >& sample = s->second;
-        map<string, vector<string> >::iterator gt = sample.find("GT");
-        if (gt != sample.end()) {
-            map<int, int> genotype = decomposeGenotype(gt->second.front());
-            for (map<int, int>::iterator g = genotype.begin(); g != genotype.end(); ++g) {
-		if (g->first != NULL_ALLELE) {
-		    alleles += g->second;
-		}
-            }
-        }
-    }
-    return alleles;
-}
-
-int main(int argc, char** argv) {
-
-    if (argc != 2) {
-        cerr << "usage: " << argv[0] << " <vcf file>" << endl
-             << "outputs a VCF stream where AC and NS have been generated for each record using sample genotypes" << endl;
-        return 1;
-    }
-
-    string filename = argv[1];
-
-    VariantCallFile variantFile;
-    if (filename == "-") {
-        variantFile.open(std::cin);
-    } else {
-        variantFile.open(filename);
-    }
-
-    if (!variantFile.is_open()) {
-        cerr << "could not open " << filename << endl;
-        return 1;
-    }
-
-    Variant var(variantFile);
-
-    // remove header lines we're going to add
-    variantFile.removeInfoHeaderLine("AC");
-    variantFile.removeInfoHeaderLine("AF");
-    variantFile.removeInfoHeaderLine("NS");
-    variantFile.removeInfoHeaderLine("AN");
-
-    // and add them back, so as not to duplicate them if they are already there
-    variantFile.addHeaderLine("##INFO=<ID=AC,Number=A,Type=Integer,Description=\"Total number of alternate alleles in called genotypes\">");
-    variantFile.addHeaderLine("##INFO=<ID=AF,Number=A,Type=Float,Description=\"Estimated allele frequency in the range (0,1]\">");
-    variantFile.addHeaderLine("##INFO=<ID=NS,Number=1,Type=Integer,Description=\"Number of samples with data\">");
-    variantFile.addHeaderLine("##INFO=<ID=AN,Number=1,Type=Integer,Description=\"Total number of alleles in called genotypes\">");
-
-    // write the new header
-    cout << variantFile.header << endl;
- 
-    // print the records, filtering is done via the setting of varA's output sample names
-    while (variantFile.getNextVariant(var)) {
-        stringstream ns;
-        ns << var.samples.size();
-        var.info["NS"].clear();
-        var.info["NS"].push_back(ns.str());
-
-        var.info["AC"].clear();
-        var.info["AF"].clear();
-	var.info["AN"].clear();
-
-        int allelecount = countAlleles(var);
-	stringstream an;
-	an << allelecount;
-	var.info["AN"].push_back(an.str());
-
-        for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-            string& allele = *a;
-            int altcount = countAlts(var, var.getAltAlleleIndex(allele) + 1);
-            stringstream ac;
-            ac << altcount;
-            var.info["AC"].push_back(ac.str());
-            stringstream af;
-            af << (double) altcount / (double) allelecount;
-            var.info["AF"].push_back(af.str());
-        }
-        cout << var << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfflatten.cpp b/vcflib/src/vcfflatten.cpp
deleted file mode 100644
index f528360..0000000
--- a/vcflib/src/vcfflatten.cpp
+++ /dev/null
@@ -1,178 +0,0 @@
-#include "Variant.h"
-#include "convert.h"
-
-using namespace std;
-using namespace vcf;
-
-
-double convertStrDbl(const string& s) {
-    double r;
-    convert(s, r);
-    return r;
-}
-
-int main(int argc, char** argv) {
-
-    int maxAlleles = 2;
-
-    VariantCallFile variantFile;
-
-    if (argc > 1) {
-        string filename = argv[1];
-        if (filename == "--help" || filename == "-h") {
-            cerr << "usage: vcfflatten [file]" << endl
-                 << endl
-                 << "Removes multi-allelic sites by picking the most common alternate.  Requires" << endl
-                 << "allele frequency specification 'AF' and use of 'G' and 'A' to specify the" << endl
-                 << "fields which vary according to the Allele or Genotype. VCF file may be" << endl
-                 << "specified on the command line or piped as stdin." << endl;
-            exit(1);
-        }
-        variantFile.open(filename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    cout << variantFile.header << endl;
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-        // count the number of alternates
-        // if we have more than N, strip the lowest-frequency ones
-        if (var.alleles.size() > maxAlleles) {
-
-            multimap<double, string> alleleFrequencies;
-
-            vector<string>& freqsstr = var.info["AF"];
-            vector<double> freqs;
-            freqs.resize(freqsstr.size());
-            transform(freqsstr.begin(), freqsstr.end(), freqs.begin(), convertStrDbl);
-
-            vector<double>::iterator f = freqs.begin();
-            for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a, ++f) {
-                alleleFrequencies.insert(pair<double, string>(*f, *a));
-            }
-
-            // pick the highest frequency alternate
-            string bestalt = alleleFrequencies.rbegin()->second;
-            // and get its index
-            int bestaltIndex = var.getAltAlleleIndex(bestalt);
-            int bestaltGenotypeIndex = bestaltIndex + 1; // per VCF spec
-
-            // keep the RR, RA, and AA alleles for this alternate
-            // generate the genotype index table for this variant
-            map<pair<int, int>, int> genotypeIndexes = var.getGenotypeIndexesDiploid();
-
-            // now get the genotype indexes we want to keep
-            vector<int> alleleIndexes;
-            alleleIndexes.push_back(0); 
-            alleleIndexes.push_back(bestaltGenotypeIndex);
-
-            // add the reference allele index for generating genotype indexes
-            int ploidy = 2;
-            vector<vector<int> > genotypesToKeep = multichoose(ploidy, alleleIndexes);
-            map<int, bool> genotypeIndexesToKeep;
-            for (vector<vector<int> >::iterator k = genotypesToKeep.begin(); k != genotypesToKeep.end(); ++k) {
-                pair<int, int> genotype = make_pair(k->front(), k->back()); // vectors are guaranteed to be diploid per multichoose
-                genotypeIndexesToKeep[genotypeIndexes[genotype]] = true;
-            }
-            // we are diploid, so there should be exactly 3 genotypes
-            assert(genotypeIndexesToKeep.size() == 3);
-
-            // get the fields which have genotype order "G"
-            // for all the infocounts
-            // find the ones which are == GENOTYPE_NUMBER or ALLELE_NUMBER
-            //     and fix em up
-            for (map<string, int>::iterator c = variantFile.infoCounts.begin(); c != variantFile.infoCounts.end(); ++c) {
-                int count = c->second;
-                if (count == GENOTYPE_NUMBER) {
-                    string key = c->first;
-                    map<string, vector<string> >::iterator v = var.info.find(key);
-                    if (v != var.info.end()) {
-                        vector<string>& vals = v->second;
-                        vector<string> tokeep;
-                        int i = 0;
-                        for (vector<string>::iterator g = vals.begin(); g != vals.end(); ++g, ++i) {
-                            if (genotypeIndexesToKeep.find(i) != genotypeIndexesToKeep.end()) {
-                                tokeep.push_back(*g);
-                            }
-                        }
-                        vals = tokeep;
-                    }
-                } else if (count == ALLELE_NUMBER) {
-                    string key = c->first;
-                    map<string, vector<string> >::iterator v = var.info.find(key);
-                    if (v != var.info.end()) {
-                        vector<string>& vals = v->second;
-                        vector<string> tokeep;
-                        int i = 0;
-                        for (vector<string>::iterator a = vals.begin(); a != vals.end(); ++a, ++i) {
-                            if (i == bestaltIndex) {
-                                tokeep.push_back(*a);
-                            }
-                        }
-                        vals = tokeep;
-                    }
-                }
-            }
-            //
-            // for all the formatcounts
-            // find the ones which are == GENOTYPE_NUMBER or ALLELE_NUMBER
-            //     for each sample, remove the new irrelevant values
-
-            // for each sample
-            //   remove info fields which now refer to nothing
-            for (map<string, int>::iterator c = variantFile.formatCounts.begin(); c != variantFile.formatCounts.end(); ++c) {
-                int count = c->second;
-                if (count == GENOTYPE_NUMBER) {
-                    string key = c->first;
-                    for (map<string, map<string, vector<string> > >::iterator s = var.samples.begin(); s != var.samples.end(); ++s) {
-                        map<string, vector<string> >& sample = s->second;
-                        map<string, vector<string> >::iterator v = sample.find(key);
-                        if (v != sample.end()) {
-                            vector<string>& vals = v->second;
-                            vector<string> tokeep;
-                            int i = 0;
-                            for (vector<string>::iterator g = vals.begin(); g != vals.end(); ++g, ++i) {
-                                if (genotypeIndexesToKeep.find(i) != genotypeIndexesToKeep.end()) {
-                                    tokeep.push_back(*g);
-                                }
-                            }
-                            vals = tokeep;
-                        }
-                    }
-                } else if (count == ALLELE_NUMBER) {
-                    string key = c->first;
-                    for (map<string, map<string, vector<string> > >::iterator s = var.samples.begin(); s != var.samples.end(); ++s) {
-                        map<string, vector<string> >& sample = s->second;
-                        map<string, vector<string> >::iterator v = sample.find(key);
-                        if (v != sample.end()) {
-                            vector<string>& vals = v->second;
-                            vector<string> tokeep;
-                            int i = 0;
-                            for (vector<string>::iterator a = vals.begin(); a != vals.end(); ++a, ++i) {
-                                if (i == bestaltIndex) {
-                                    tokeep.push_back(*a);
-                                }
-                            }
-                            vals = tokeep;
-                        }
-                    }
-                }
-            }
-
-            var.alt.clear();
-            var.alt.push_back(bestalt);
-
-        }
-        cout << var << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfgeno2alleles.cpp b/vcflib/src/vcfgeno2alleles.cpp
deleted file mode 100644
index 9fd66f2..0000000
--- a/vcflib/src/vcfgeno2alleles.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include <string>
-#include <iostream>
-
-using namespace std;
-using namespace vcf;
-
-
-int main(int argc, char** argv) {
-
-    if (argc > 1) {
-        cerr << "usage: " << argv[0] << " <[vcf file]" << endl
-             << "modifies the genotypes field to provide the literal alleles rather than indexes" << endl;
-        return 1;
-    }
-
-    VariantCallFile variantFile;
-
-    variantFile.open(std::cin);
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    cout << variantFile.header << endl;
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-        map<string, map<string, vector<string> > >::iterator s     = var.samples.begin(); 
-        map<string, map<string, vector<string> > >::iterator sEnd  = var.samples.end();
-        
-        for (; s != sEnd; ++s) {
-            map<string, vector<string> >& sample = s->second;
-            vector<string>& gtstrs = sample["GT"];
-            string& genotype = gtstrs.front();
-            vector<string> gt = split(genotype, "|/");
-            
-            // report the sample and it's genotype
-            stringstream o;
-            for (vector<string>::iterator g = gt.begin(); g != gt.end(); ++g) {
-                int index = atoi(g->c_str());
-                o << var.alleles[index];
-                if (g != (gt.end()-1)) o << "/";
-            }
-            gtstrs.clear();
-            gtstrs.push_back(o.str());
-        }
-        cout << var << endl;
-    }
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfgeno2haplo.cpp b/vcflib/src/vcfgeno2haplo.cpp
deleted file mode 100644
index f821c2d..0000000
--- a/vcflib/src/vcfgeno2haplo.cpp
+++ /dev/null
@@ -1,391 +0,0 @@
-#include "Variant.h"
-#include <getopt.h>
-#include "fastahack/Fasta.h"
-#include <algorithm>
-#include <list>
-#include <set>
-
-using namespace std;
-using namespace vcf;
-
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [options] [<vcf file>]" << endl
-         << endl
-         << "options:" << endl 
-         << "    -r, --reference FILE    FASTA reference file, required with -i and -u" << endl
-         << "    -w, --window-size N     Merge variants at most this many bp apart (default 30)" << endl
-         << "    -o, --only-variants     Don't output the entire haplotype, just concatenate" << endl
-         << "                            REF/ALT strings (delimited by \":\")" << endl
-         << endl
-         << "Convert genotype-based phased alleles within --window-size into haplotype alleles." << endl
-         << "Will break haplotype construction when encountering non-phased genotypes on input." << endl
-         << endl;
-    exit(0);
-}
-
-bool isPhased(Variant& var) {
-    for (map<string, map<string, vector<string> > >::iterator s = var.samples.begin(); s != var.samples.end(); ++s) {
-        map<string, vector<string> >& sample = s->second;
-        map<string, vector<string> >::iterator g = sample.find("GT");
-        if (g != sample.end()) {
-            string gt = g->second.front();
-            if (gt.size() > 1 && gt.find("|") == string::npos) {
-                return false;
-            }
-        }
-    }
-    return true;
-}
-
-int main(int argc, char** argv) {
-
-    string vcfFileName;
-    string fastaFileName;
-    int windowsize = 30;
-    bool onlyVariants = false;
-
-    if (argc == 1)
-        printSummary(argv);
-
-    int c;
-    while (true) {
-        static struct option long_options[] =
-            {
-                /* These options set a flag. */
-                //{"verbose", no_argument,       &verbose_flag, 1},
-                {"help", no_argument, 0, 'h'},
-                {"window-size", required_argument, 0, 'w'},
-                {"reference", required_argument, 0, 'r'},
-                {"only-variants", no_argument, 0, 'o'},
-                {0, 0, 0, 0}
-            };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "how:r:",
-                         long_options, &option_index);
-
-        if (c == -1)
-            break;
-
-        switch (c) {
-
-        case 'o':
-            onlyVariants = true;
-            break;
-
-	    case 'w':
-            windowsize = atoi(optarg);
-            break;
-
-	    case 'r':
-            fastaFileName = string(optarg);
-            break;
-
-        case 'h':
-            printSummary(argv);
-            break;
-
-        case '?':
-            printSummary(argv);
-            exit(1);
-            break;
-
-        default:
-            abort ();
-        }
-    }
-
-    VariantCallFile variantFile;
-    string inputFilename;
-    if (optind == argc - 1) {
-        inputFilename = argv[optind];
-        variantFile.open(inputFilename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        cerr << "could not open VCF file" << endl;
-        exit(1);
-    }
-
-    FastaReference reference;
-    if (fastaFileName.empty()) {
-        cerr << "a reference is required for haplotype allele generation" << endl;
-        exit(1);
-    }
-    reference.open(fastaFileName);
-
-    // pattern
-    // when variants are within windowSize from each other, build up local haplotypes
-    // establish all the haplotypes which exist within the window using genotypes+allele#+position map
-    // generate a haplotype allele string for each unique haplotype
-    // for completeness retain phasing information in the genotypes
-    // write a new VCF record in which there are haplotype alleles and correctly described genotypes for each sample
-    // if the variants are outside of the windowSize, just write out the record
-
-    Variant var(variantFile);
-    Variant outputVar(variantFile);
-
-    cout << variantFile.header << endl;
-
-    // get the first distances
-    vector<Variant> cluster;
-
-    while (variantFile.getNextVariant(var) || !cluster.empty()) {
-
-        bool haplotypeCluster = false;
-
-        if (variantFile.done()) {
-            if (cluster.size() >= 1) {
-                haplotypeCluster = true;
-            } else {
-                cout << cluster.front() << endl;
-                cluster.clear();
-            }
-        } else if (isPhased(var)) {
-            if (cluster.empty()
-                || cluster.back().sequenceName == var.sequenceName
-                && var.position - cluster.back().position + cluster.back().ref.size() - 1 <= windowsize) {
-                cluster.push_back(var);
-            } else {
-                if (cluster.size() == 1) {
-                    cout << cluster.front() << endl;
-                    cluster.clear();
-                    if (!variantFile.done()) {
-                        cluster.push_back(var);
-                    }
-                } else {
-                    haplotypeCluster = true;
-                }
-            }
-        } else { // not phased
-            if (cluster.empty()) {
-                cout << var << endl;
-            } else if (cluster.size() == 1) {
-                cout << cluster.front() << endl;
-                cout << var << endl;
-            } else {
-                haplotypeCluster = true;
-            }
-        }
-
-        // we need to deal with the current cluster, as our next var is outside of bounds
-        // process the last cluster if it's more than 1 var
-        if (haplotypeCluster) {
-            /*            cerr << "cluster: ";
-            for (vector<Variant>::iterator v = cluster.begin(); v != cluster.end(); ++v) {
-                cerr << " " << v->position;
-            }
-            cerr << endl;
-            */
-
-            // generate haplotype alleles and genotypes!
-            // get the reference sequence across the haplotype in question
-            string referenceHaplotype = reference.getSubSequence(cluster.front().sequenceName,
-                                                                 cluster.front().position - 1,
-                                                                 cluster.back().position
-                                                                 + cluster.back().ref.size() - cluster.front().position);
-
-            // establish what haplotypes there are by parsing the (phased) genotypes across the samples over these records
-            map<string, vector<vector<int> > > sampleHaplotypes;
-            for (vector<string>::iterator s = var.sampleNames.begin(); s != var.sampleNames.end(); ++s) {
-                // build the haplotype using the genotype fields in the variant cluster
-                // only build haplotypes for samples with complete information
-                string& sampleName = *s;
-                vector<vector<int> >& haplotypes = sampleHaplotypes[sampleName];
-		
-                bool completeCoverage = true;
-                // ensure complete genotype coverage over the haplotype cluster
-                for (vector<Variant>::iterator v = cluster.begin(); v != cluster.end(); ++v) {
-                    if (v->samples.find(sampleName) == v->samples.end()
-                        || v->samples[sampleName].find("GT") == v->samples[sampleName].end()) {
-                        completeCoverage = false;
-                        break;
-                    }
-                }
-                if (!completeCoverage) {
-                    continue; // skip samples without complete coverage
-                }
-		
-                // what's the ploidy?
-                {
-                    string& gt = cluster.front().samples[sampleName]["GT"].front();
-                    vector<string> gtspec = split(gt, "|");
-                    for (vector<string>::iterator g = gtspec.begin(); g != gtspec.end(); ++g) {
-                        vector<int> haplotype;
-                        haplotypes.push_back(haplotype);
-                    }
-                }
-		
-                for (vector<Variant>::iterator v = cluster.begin(); v != cluster.end(); ++v) {
-                    string& gt = v->samples[sampleName]["GT"].front();
-                    vector<string> gtspec = split(gt, "|");
-                    vector<string>::iterator g = gtspec.begin();
-                    for (vector<vector<int> >::iterator h = haplotypes.begin(); h != haplotypes.end(); ++h, ++g) {
-                        int j;
-                        convert(*g, j);
-                        h->push_back(j);
-                    }
-                }
-            }
-
-            set<vector<int> > uniqueHaplotypes;
-            for (map<string, vector<vector<int> > >::iterator hs = sampleHaplotypes.begin();
-                 hs != sampleHaplotypes.end(); ++hs) {
-                vector<vector<int> >& haps = hs->second;
-                for (vector<vector<int> >::iterator h = haps.begin(); h != haps.end(); ++h) {
-                    uniqueHaplotypes.insert(*h);
-                }
-            }
-	    
-            // write new haplotypes
-            map<vector<int>, string> haplotypeSeqs;
-            map<vector<int>, int> haplotypeIndexes;
-            map<int, string> alleles;
-	    
-            int impossibleHaplotypes = 0;
-
-            // always include the reference haplotype as 0
-            // when we come to it in the haplotypes, we'll ignore it
-            int alleleIndex = 1;
-            for (set<vector<int> >::iterator u = uniqueHaplotypes.begin(); u != uniqueHaplotypes.end(); ++u) {
-
-                /*
-                for (vector<int>::const_iterator z = u->begin(); z != u->end(); ++z) {
-                    cerr << *z;
-                }
-                cerr << endl;
-                */
-
-                string haplotype;
-                if (!onlyVariants) {
-                    haplotype = referenceHaplotype;
-                }
-                bool isreference = true;
-                bool impossibleHaplotype = false;
-                int referenceInsertOffset = 0;
-                int j = 0; // index into variant cluster
-                int lastpos = 0;
-                int lastrefend = 0;
-                for (vector<int>::const_iterator z = u->begin(); z != u->end(); ++z, ++j) {
-                    int i = *z;
-                    Variant& vartoInsert = cluster.at(j);
-                    if (i == 0) {
-                        if (onlyVariants) {
-                            if (!haplotype.empty()) haplotype.append(":");
-                            haplotype.append(vartoInsert.ref);
-                        }
-                    }
-                    if (i != 0) {
-                        isreference = false;
-                        string& alternate = vartoInsert.alleles.at(i);
-                        if (vartoInsert.position < lastrefend) {
-                            cerr << "impossible haplotype, overlapping alleles at " << vartoInsert.sequenceName << ":" << vartoInsert.position << endl;
-                            impossibleHaplotype = true;
-                            break;
-                        } else {
-                            //cerr << vartoInsert.position << " " << cluster.front().position + referenceInsertOffset << endl;
-                            //cerr << "replacing " << vartoInsert.ref << " at " << vartoInsert.position - cluster.front().position + referenceInsertOffset << " with " << alternate << endl;
-                            if (onlyVariants) {
-                                if (!haplotype.empty()) haplotype.append(":");
-                                haplotype.append(alternate);
-                            } else {
-                                haplotype.replace(vartoInsert.position - cluster.front().position + referenceInsertOffset,
-                                                  vartoInsert.ref.size(), alternate);
-                                if (alternate.size() != vartoInsert.ref.size()) {
-                                    referenceInsertOffset += alternate.size() - vartoInsert.ref.size();
-                                }
-                                lastpos = vartoInsert.position;
-                                lastrefend = vartoInsert.position + vartoInsert.ref.size();
-                            }
-                        }
-                    }
-                }
-		
-                if (impossibleHaplotype) {
-                    ++impossibleHaplotypes;
-                    haplotypeIndexes[*u] = -1; // indicates impossible haplotype
-                    impossibleHaplotype = false;
-                } else if (isreference) {
-                    alleles[0] = haplotype;
-                    haplotypeIndexes[*u] = 0;
-                } else {
-                    alleles[alleleIndex] = haplotype;
-                    haplotypeIndexes[*u] = alleleIndex;
-                    ++alleleIndex;
-                }
-                haplotypeSeqs[*u] = haplotype;
-                // if there's not a reference allele, add it
-                if (alleles.find(0) == alleles.end()) {
-                    alleles[0] = referenceHaplotype;
-                    // nb, there is no reference haplotype among
-                    // the samples, so we don't have to add it to
-                    // the haplotypeIndexes
-                }
-            }
-
-            if (onlyVariants) {
-                string newRef;
-                for (vector<Variant>::iterator v = cluster.begin(); v != cluster.end(); ++v) {
-                    if (!newRef.empty()) newRef.append(":");
-                    newRef.append(v->ref);
-                }
-                outputVar.ref = newRef;
-            } else {
-                outputVar.ref = alleles[0];
-            }
-            outputVar.alt.clear();
-            for (int i = 1; i < alleleIndex; ++i) {
-                outputVar.alt.push_back(alleles[i]);
-            }
-	    
-            outputVar.sequenceName = cluster.front().sequenceName;
-            outputVar.position = cluster.front().position;
-            outputVar.filter = ".";
-            outputVar.id = ".";
-            outputVar.info = cluster.front().info;
-            outputVar.samples.clear();
-            outputVar.format = cluster.front().format;
-	    
-            // now the genotypes
-            for (vector<string>::iterator s = var.sampleNames.begin(); s != var.sampleNames.end(); ++s) {
-                string& sampleName = *s;
-                vector<string> gt;
-                vector<vector<int> > & hs = sampleHaplotypes[sampleName];
-                for (vector<vector<int> >::iterator h = hs.begin(); h != hs.end(); ++h) {
-                    int hi = haplotypeIndexes[*h];
-                    if (hi != -1) {
-                        gt.push_back(convert(hi));
-                    } else {
-                        // nonexistent or impossible haplotype
-                        gt.push_back(".");
-                    }
-                }
-                if (gt.size() != 0) {
-                    outputVar.samples[sampleName]["GT"].push_back(join(gt, "|"));
-                }
-            }
-            if (cluster.size() - impossibleHaplotypes < 2) {
-                for (vector<Variant>::iterator v = cluster.begin(); v != cluster.end(); ++v) {
-                    cout << *v << endl;
-                }
-            } else {
-                if (!outputVar.alt.empty()) {
-                    cout << outputVar << endl;
-                } else {
-                    cerr << "no alternate alleles remain at " << outputVar.sequenceName << ":" << outputVar.position << " after haplotype validation" << endl;
-                }
-            }
-            cluster.clear();
-            if (!variantFile.done()) cluster.push_back(var);
-        }
-    }
-
-    exit(0);  // why?
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfgenosamplenames.cpp b/vcflib/src/vcfgenosamplenames.cpp
deleted file mode 100644
index 32e065a..0000000
--- a/vcflib/src/vcfgenosamplenames.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "Variant.h"
-
-using namespace std;
-using namespace vcf;
-
-int main(int argc, char** argv) {
-
-    VariantCallFile variantFile;
-
-    if (argc > 1) {
-        string filename = argv[1];
-        variantFile.open(filename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    variantFile.addHeaderLine("##FORMAT=<ID=SN,Number=1,Type=String,Description=\"The name of the sample.\">");
-
-    cout << variantFile.header << endl;
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-        var.format.push_back("SN");
-        for (map<string, map<string, vector<string> > >::iterator s = var.samples.begin();
-             s != var.samples.end(); ++s) {
-            s->second["SN"].clear();
-            s->second["SN"].push_back(s->first);
-        }
-        cout << var << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfgenosummarize.cpp b/vcflib/src/vcfgenosummarize.cpp
deleted file mode 100644
index 526bca1..0000000
--- a/vcflib/src/vcfgenosummarize.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include <string>
-#include <sstream>
-#include <iostream>
-#include <getopt.h>
-
-using namespace std;
-using namespace vcf;
-
-
-int main(int argc, char** argv) {
-
-    if (argc > 1 && (argv[1] == "-h" || argv[1] == "--help")) {
-        cerr << "usage: " << argv[0] << " <[input file] >[output vcf]" << endl
-             << "Adds summary statistics to each record summarizing qualities reported in" << endl
-             << "called genotypes.  Uses:" << endl
-             << "RO (reference observation count), QR (quality sum reference observations)" << endl
-             << "AO (alternate observation count), QA (quality sum alternate observations)" << endl;
-        return 1;
-    }
-
-    VariantCallFile variantFile;
-    if (argc == 1) {
-        variantFile.open(std::cin);
-    } else {
-        string filename = argv[argc-1];
-        variantFile.open(filename);
-        if (!variantFile.is_open()) {
-            cerr << "could not open " << filename << endl;
-            return 1;
-        }
-    }
-
-    Variant var(variantFile);
-
-    variantFile.removeInfoHeaderLine("AQR");
-    variantFile.addHeaderLine("##INFO=<ID=AQR,Number=1,Type=Float,Description=\"Mean reference observation quality calculated by RO and QR in called samples.\">");
-    variantFile.removeInfoHeaderLine("AQA");
-    variantFile.addHeaderLine("##INFO=<ID=AQA,Number=A,Type=Float,Description=\"Mean alternate observation quality calculated by AO and QA in called samples.\">");
-    variantFile.removeInfoHeaderLine("QR");
-    variantFile.addHeaderLine("##INFO=<ID=QR,Number=1,Type=Float,Description=\"Quality sum of reference observations calculated by QR in called samples.\">");
-    variantFile.removeInfoHeaderLine("QA");
-    variantFile.addHeaderLine("##INFO=<ID=QA,Number=A,Type=Float,Description=\"Quality sum of alternate observations calculated by QA in called samples.\">");
-    variantFile.removeInfoHeaderLine("RQA");
-    variantFile.addHeaderLine("##INFO=<ID=RQA,Number=A,Type=Float,Description=\"Ratio of mean alternate observation quality to mean reference observation quality (MQA/MQR).\">");
-
-    // write the new header
-    cout << variantFile.header << endl;
- 
-    // print the records, filtering is done via the setting of varA's output sample names
-    while (variantFile.getNextVariant(var)) {
-        int refobs = 0;
-        int refqual = 0;
-        vector<int> altobs(var.alt.size(), 0);
-        vector<int> altqual(var.alt.size(), 0);
-        for (map<string, map<string, vector<string> > >::iterator s = var.samples.begin();
-             s != var.samples.end(); ++s) {
-            map<string, vector<string> >& sample = s->second;
-            int x;
-            if (sample.find("RO") != sample.end()) {
-                convert(sample["RO"].front(), x);
-                refobs += x;
-                if (sample.find("QR") != sample.end()) {
-                    convert(sample["QR"].front(), x);
-                    refqual += x;
-                }
-            }
-            if (sample.find("AO") != sample.end()) {
-                vector<string>& aos = sample["AO"];
-                for (int i = 0; i != var.alt.size(); ++i) {
-                    convert(aos[i], x);
-                    altobs[i] += x;
-                }
-                if (sample.find("QA") != sample.end()) {
-                    vector<string>& qas = sample["QA"];
-                    for (int i = 0; i != var.alt.size(); ++i) {
-                        convert(qas[i], x);
-                        altqual[i] += x;
-                    }
-                }
-            }
-        }
-        var.info["QR"].push_back(convert(refqual));
-        if (refobs == 0 || refqual == 0) {
-            var.info["AQR"].push_back(convert(0));
-        } else {
-            var.info["AQR"].push_back(convert((double)refqual/(double)refobs));
-        }
-
-        for (int i = 0; i != var.alt.size(); ++i) {
-            var.info["QA"].push_back(convert(altqual[i]));
-            var.info["AQA"].push_back(convert((double)altqual[i]/(double)altobs[i]));
-            if (refobs == 0 || refqual == 0) {
-                var.info["RQA"].push_back(convert(1));
-            } else {
-                var.info["RQA"].push_back(convert(((double)altqual[i]/(double)altobs[i]) / 
-                                                  ((double)refqual/(double)refobs)));
-            }
-        }
-        cout << var << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfgenotypecompare.cpp b/vcflib/src/vcfgenotypecompare.cpp
deleted file mode 100644
index c81043f..0000000
--- a/vcflib/src/vcfgenotypecompare.cpp
+++ /dev/null
@@ -1,327 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include <string>
-#include <iostream>
-#include <sstream>
-
-using namespace std;
-using namespace vcf;
-
-// TODO fix this for multi-allelic!!!!
-string genotypeSpec(map<int, int>& genotype) {
-    string gtspec;
-    if (isNull(genotype)) {
-        gtspec = "NN";
-    } else if (isHom(genotype)) {
-        if (hasNonRef(genotype)) {
-            gtspec = "AA";
-        } else {
-            gtspec = "RR";
-        }
-    } else {
-        gtspec = "AR";
-    }
-    return gtspec;
-}
-
-int main(int argc, char** argv) {
-
-    if (argc != 3) {
-        cerr << "usage: " << argv[0] << " <other-genotype-tag> <vcf file>" << endl
-             << "adds statistics to the INFO field of the vcf file describing the" << endl
-             << "amount of discrepancy between the genotypes (GT) in the vcf file and the" << endl
-             << "genotypes reported in the <other-genotype-tag>.  use this after" << endl
-             << "vcfannotategenotypes to get correspondence statistics for two vcfs." << endl;
-        return 1;
-    }
-
-    string otherGenoTag = argv[1];
-    string filename = argv[2];
-
-    VariantCallFile variantFile;
-    if (filename == "-") {
-        variantFile.open(std::cin);
-    } else {
-        variantFile.open(filename);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    vector<string> specs;
-
-    specs.push_back("AA_AA");
-    specs.push_back("AA_AR");
-    specs.push_back("AA_RR");
-    specs.push_back("AA_NN");
-
-    specs.push_back("AR_AA");
-    specs.push_back("AR_AR");
-    specs.push_back("AR_RR");
-    specs.push_back("AR_NN");
-
-    specs.push_back("RR_AA");
-    specs.push_back("RR_AR");
-    specs.push_back("RR_RR");
-    specs.push_back("RR_NN");
-
-    specs.push_back("NN_AA");
-    specs.push_back("NN_AR");
-    specs.push_back("NN_RR");
-    specs.push_back("NN_NN");
-
-
-    for (vector<string>::iterator spec = specs.begin(); spec != specs.end(); ++spec) {
-        string line = "##INFO=<ID=" + otherGenoTag + ".genotypes." + *spec
-            + ",Number=1,Type=Integer,Description=\"Number of genotypes with "
-            + *spec + " relationship with " + otherGenoTag + "\">";
-        variantFile.addHeaderLine(line);
-    }
-
-    string line;
-
-    line = "##INFO=<ID=" + otherGenoTag + ".genotypes.count,Number=1,Type=Integer,Description=\"Count of genotypes under comparison.\">";
-    variantFile.addHeaderLine(line);
-
-    line = "##INFO=<ID=" + otherGenoTag + ".genotypes.alternate_count,Number=1,Type=Integer,Description=\"Count of alternate genotypes in the first file.\">";
-    variantFile.addHeaderLine(line);
-
-    line = "##INFO=<ID=" + otherGenoTag
-        + ".site.alternate_positive_discrepancy,Number=1,Type=Integer,Description=\"Estimated positive discrepancy rate of "
-        + otherGenoTag + " genotypes, where positive discrepancies are all cases where an alternate allele is called GT "
-        + " but none is represented in " + otherGenoTag + " or " + otherGenoTag + " is null/no-call\">";
-    variantFile.addHeaderLine(line);
-
-    line = "##INFO=<ID=" + otherGenoTag
-        + ".site.alternate_negative_discrepancy,Number=1,Type=Integer,Description=\"Estimated negative discrepancy rate of "
-        + otherGenoTag + " genotypes, where negative discrepancies are all cases where no alternate allele is called in "
-        + " GT but an alternate is represented in " + otherGenoTag + ", including no-calls or partly null genotypes\">";
-    variantFile.addHeaderLine(line);
-
-    line = "##INFO=<ID=" + otherGenoTag
-        + ".site.alternate_null_discrepancy,Number=1,Type=Integer,Description=\"Estimated null discrepancy rate of "
-        + otherGenoTag + " genotypes, where null discrepancies are all cases where GT is specified and contains an alternate but "
-        + otherGenoTag + " is null.  Cases where GT is null or partly null are excluded.\">";
-    variantFile.addHeaderLine(line);
-
-    line = "##INFO=<ID=" + otherGenoTag
-        + ".site.call_discrepancy,Number=1,Type=Integer,Description=\"Estimated call discrepancy rate of "
-        + otherGenoTag + " genotypes (het->hom, hom->het) between " + otherGenoTag + " and GT\">";
-    variantFile.addHeaderLine(line);
-
-    line = "##INFO=<ID=" + otherGenoTag
-        + ".site.call_concordance,Number=1,Type=Integer,Description=\"Estimated call concorndance rate of "
-        + otherGenoTag + " genotypes between " + otherGenoTag + " and GT\">";
-    variantFile.addHeaderLine(line);
-
-    line = "##INFO=<ID=" + otherGenoTag
-        + ".site.non_reference_discrepancy,Number=1,Type=Float,Description=\"Estimated non-reference discrepancy relative to "
-        + otherGenoTag + " genotypes,\">";
-    variantFile.addHeaderLine(line);
-
-    line = "##INFO=<ID=" + otherGenoTag
-        + ".site.non_reference_discrepancy.count,Number=1,Type=Int,Description=\"non-reference discrepancy normalizer relative to "
-        + otherGenoTag + " genotypes,\">";
-    variantFile.addHeaderLine(line);
-
-    line = "##INFO=<ID=" + otherGenoTag
-        + ".site.non_reference_discrepancy.normalizer,Number=1,Type=Int,Description=\"non-reference discrepancy count relative to "
-        + otherGenoTag + " genotypes,\">";
-    variantFile.addHeaderLine(line);
-
-    line = "##INFO=<ID=" + otherGenoTag
-        + ".site.non_reference_sensitivity,Number=1,Type=Float,Description=\"Estimated non-reference sensitivity relative to "
-        + otherGenoTag + " genotypes,\">";
-    variantFile.addHeaderLine(line);
-
-    line = "##INFO=<ID=" + otherGenoTag
-        + ".site.non_reference_sensitivity.count,Number=1,Type=Int,Description=\"non-reference sensitivity normalizer relative to "
-        + otherGenoTag + " genotypes,\">";
-    variantFile.addHeaderLine(line);
-
-    line = "##INFO=<ID=" + otherGenoTag
-        + ".site.non_reference_sensitivity.normalizer,Number=1,Type=Int,Description=\"non-reference sensitivity count relative to "
-        + otherGenoTag + " genotypes,\">";
-    variantFile.addHeaderLine(line);
-
-    cout << variantFile.header << endl;
-
-    Variant var(variantFile);
-
-    while (variantFile.getNextVariant(var)) {
-
-	//cout << "next: " << var << endl;
-        // for each sample, check GT against <other-genotype-tag>
-        // tally stats, and append to info
-        map<string, map<string, vector<string> > >::iterator s     = var.samples.begin();
-        map<string, map<string, vector<string> > >::iterator sEnd  = var.samples.end();
-
-        map<string, int> genotypeComparisonCounts;
-        int gtCount = var.samples.size();
-        int gtAltCount = 0; // number of alternate-containing genotypes in the first file
-        int pdCount = 0; // positive discrepancy count
-        int ndCount = 0; // negative discrepancy count
-        int nnCount = 0; // null discrepancy count
-        int cdCount = 0; // call discrepancy count
-        int ccCount = 0; // call concordance count
-        int nrdCount = 0; // non-reference discrepancy count
-        int nrdNormalizer = 0; // divisor for nrd rate
-        int nrsCount = 0; // non-reference sensitivity count
-        int nrsNormalizer = 0; // divisor for nrs rate
-
-        for (; s != sEnd; ++s) {
-            map<string, vector<string> >& sample = s->second;
-            const string& name = s->first;
-
-            // decompose genotypes into counts of strings
-            // to facilitate comparison
-
-	    string gtA;
-	    if (sample.find("GT") == sample.end()) {
-		gtA = "./.";
-	    } else {
-		gtA = sample["GT"].front();
-	    }
-
-	    string gtB;
-	    if (sample.find(otherGenoTag) == sample.end()) {
-		gtB = "./.";
-	    } else {
-		gtB = sample[otherGenoTag].front();
-	    }
-
-
-            map<int, int> genotypeA = decomposeGenotype(gtA);
-            map<int, int> genotypeB = decomposeGenotype(gtB);
-
-            string gtspecA = genotypeSpec(genotypeA);
-            string gtspecB = genotypeSpec(genotypeB);
-            //cout << gtA << " " << gtB << endl;
-            //cout << gtspecA << " " << gtspecB << endl;
-            ++genotypeComparisonCounts[gtspecA + "_" + gtspecB];
-
-            if (hasNonRef(genotypeA)) {
-                ++gtAltCount;
-            }
-
-            if (genotypeA != genotypeB) {
-                if (isNull(genotypeA)) {
-                    // TODO handle this somehow, maybe via a different flag?
-                    if (!isNull(genotypeB)) {
-                        ++nnCount;  // null discrepancy, the second set makes a call, this one does not
-                    }
-                } else if (hasNonRef(genotypeA)) {
-                    if (!isNull(genotypeB) && hasNonRef(genotypeB)) { // they cannot be the same, but they both represent an alternate
-                        ++cdCount;  // the calls are discrepant
-                    } else { // the other call does not have an alternate
-                        ++pdCount;
-                        // it is also null
-                        if (isNull(genotypeB)) {
-                            ++nnCount;
-                        }
-                    }
-                } else { // the current genotype has no non-ref alternate
-                    if (!isNull(genotypeB) && hasNonRef(genotypeB)) {
-                        ++ndCount;
-                    }
-                    if (isNull(genotypeB)) {
-                        ++nnCount;
-                    }
-                }
-            } else {
-                if (!isNull(genotypeA)) {
-                    ++ccCount;
-                }
-            }
-
-
-            if (!(isNull(genotypeA) || isNull(genotypeB))
-                    && !(isHomRef(genotypeA) && isHomRef(genotypeB))) {
-                ++nrdNormalizer;
-                if (genotypeA != genotypeB) {
-                    ++nrdCount;
-                }
-            }
-
-            if (!(isNull(genotypeB) || isHomRef(genotypeB))) {
-                ++nrsNormalizer;
-                if (!(isNull(genotypeA) || isHomRef(genotypeA))) {
-                    ++nrsCount;
-                }
-            }
-
-        }
-
-        for (map<string, int>::iterator g = genotypeComparisonCounts.begin();
-                g != genotypeComparisonCounts.end(); ++g) {
-            stringstream c;
-            c << g->second;
-            vector<string>& t = var.info[otherGenoTag + ".genotypes." + g->first];
-            t.clear(); t.push_back(c.str());
-        }
-
-        stringstream gtc;
-        gtc << gtCount;
-        var.info[otherGenoTag + ".genotypes.count"].push_back(gtc.str());
-
-        stringstream gtac;
-        gtac << gtAltCount;
-        var.info[otherGenoTag + ".genotypes.alternate_count"].push_back(gtac.str());
-
-        stringstream pd;
-        pd << pdCount;
-        var.info[otherGenoTag + ".site.alternate_positive_discrepancy"].push_back(pd.str());
-
-        stringstream nd;
-        nd << ndCount;
-        var.info[otherGenoTag + ".site.alternate_negative_discrepancy"].push_back(nd.str());
-
-        stringstream nn;
-        nn << nnCount;
-        var.info[otherGenoTag + ".site.alternate_null_discrepancy"].push_back(nn.str());
-
-        stringstream cd;
-        cd << cdCount;
-        var.info[otherGenoTag + ".site.call_discrepancy"].push_back(cd.str());
-
-        stringstream cc;
-        cc << ccCount;
-        var.info[otherGenoTag + ".site.call_concordance"].push_back(cc.str());
-
-        stringstream nrdc;
-        nrdc << nrdCount;
-        var.info[otherGenoTag + ".site.non_reference_discrepancy.count"].push_back(nrdc.str());
-
-        stringstream nrdn;
-        nrdn << nrdNormalizer;
-        var.info[otherGenoTag + ".site.non_reference_discrepancy.normalizer"].push_back(nrdn.str());
-
-        if (nrdNormalizer > 0) {
-            stringstream nrd;
-            nrd << (double) nrdCount / (double) nrdNormalizer;
-            var.info[otherGenoTag + ".site.non_reference_discrepancy"].push_back(nrd.str());
-        }
-
-        stringstream nrsc;
-        nrsc << nrsCount;
-        var.info[otherGenoTag + ".site.non_reference_sensitivity.count"].push_back(nrsc.str());
-
-        stringstream nrsn;
-        nrsn << nrsNormalizer;
-        var.info[otherGenoTag + ".site.non_reference_sensitivity.normalizer"].push_back(nrsn.str());
-
-        if (nrsNormalizer > 0) {
-            stringstream nrs;
-            nrs << (double) nrsCount / (double) nrsNormalizer;
-            var.info[otherGenoTag + ".site.non_reference_sensitivity"].push_back(nrs.str());
-        }
-
-        cout << var << endl;
-
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfgenotypes.cpp b/vcflib/src/vcfgenotypes.cpp
deleted file mode 100644
index 12faef7..0000000
--- a/vcflib/src/vcfgenotypes.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include <string>
-#include <iostream>
-
-using namespace std;
-using namespace vcf;
-
-
-int main(int argc, char** argv) {
-
-    if (argc != 2) {
-        cerr << "usage: " << argv[0] << " <vcf file>" << endl
-             << "report the genotypes for each sample, for each variant in the vcf file" << endl;
-        return 1;
-    }
-
-    string filename = argv[1];
-
-    VariantCallFile variantFile;
-
-    if (filename == "-") {
-        variantFile.open(std::cin);
-    } else {
-        variantFile.open(filename);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-        map<string, map<string, vector<string> > >::iterator s     = var.samples.begin(); 
-        map<string, map<string, vector<string> > >::iterator sEnd  = var.samples.end();
-        
-        cout << var.sequenceName << "\t"
-             << var.position     << "\t"
-             << var.ref          << "\t";
-        var.printAlt(cout);     cout << "\t"; 
-        var.printAlleles(cout); cout << "\t"; 
-        
-        for (; s != sEnd; ++s) {
-            map<string, vector<string> >& sample = s->second;
-            string& genotype = sample["GT"].front(); // XXX assumes we can only have one GT value
-            vector<string> gt = split(genotype, "|/");
-            
-            // report the sample and it's genotype
-            cout << s->first << ":";
-            for (vector<string>::iterator g = gt.begin(); g != gt.end(); ++g) {
-                int index = atoi(g->c_str());
-                cout << var.alleles[index];
-                if (g != (gt.end()-1)) cout << "/";
-            }
-            cout << "\t";
-        }
-        cout << endl;
-    }
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfglxgt.cpp b/vcflib/src/vcfglxgt.cpp
deleted file mode 100644
index 5909bdc..0000000
--- a/vcflib/src/vcfglxgt.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include <getopt.h>
-
-using namespace std;
-using namespace vcf;
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [options] <vcf file>" << endl
-         << endl
-         << "options:" << endl 
-         << "    -n, --fix-null-genotypes   only apply to null and partly-null genotypes" << endl
-         << endl
-         << "Set genotypes using the maximum genotype likelihood for each sample." << endl
-         << endl;
-    exit(0);
-}
-
-
-int main(int argc, char** argv) {
-
-    bool fixNull = false;
-    int c;
-
-    while (true) {
-        static struct option long_options[] =
-        {
-            /* These options set a flag. */
-            //{"verbose", no_argument,       &verbose_flag, 1},
-            {"help", no_argument, 0, 'h'},
-            {"fix-null-genotypes",  no_argument, 0, 'n'},
-            //{"length",  no_argument, &printLength, true},
-            {0, 0, 0, 0}
-        };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "hn",
-                         long_options, &option_index);
-
-      /* Detect the end of the options. */
-          if (c == -1)
-            break;
- 
-          switch (c)
-            {
-            case 0:
-            /* If this option set a flag, do nothing else now. */
-            if (long_options[option_index].flag != 0)
-              break;
-            printf ("option %s", long_options[option_index].name);
-            if (optarg)
-              printf (" with arg %s", optarg);
-            printf ("\n");
-            break;
-
-          case 'n':
-	      fixNull = true;
-	      break;
- 
-          case 'h':
-            printSummary(argv);
-            exit(0);
-            break;
-
-          case '?':
-            /* getopt_long already printed an error message. */
-            printSummary(argv);
-            exit(1);
-            break;
- 
-          default:
-            abort ();
-          }
-      }
-
-    VariantCallFile variantFile;
-    string inputFilename;
-    if (optind == argc - 1) {
-        inputFilename = argv[optind];
-        variantFile.open(inputFilename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    cout << variantFile.header << endl;
-
-    map<pair<int, int>, list<list<int> > > glOrderCache;
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-        if (find(var.format.begin(), var.format.end(), "GL") == var.format.end()) {
-            cout << var << endl;
-            continue;
-        }
-        if (find(var.format.begin(), var.format.end(), "GT") == var.format.end()) {
-            var.format.push_back("GT");
-            reverse(var.format.begin(), var.format.end());
-        }
-        for (map<string, map<string, vector<string> > >::iterator s = var.samples.begin();
-             s != var.samples.end(); ++s) {
-            map<string, vector<string> >& sample = s->second;
-            map<string, vector<string> >::iterator g = sample.find("GT");
-            map<string, vector<string> >::iterator l = sample.find("GL");
-            if (l != sample.end()) {
-                if (g == sample.end()) {
-                    sample["GT"].push_back("./.");
-                    g = sample.find("GT");
-                }
-
-                string& gt = g->second.front();
-                // if we are fixing null but the genotype is fully specified, continue
-                if (fixNull && gt.find(".") == string::npos) continue;
-                string splitter = "/";
-                if (gt.find("|") != string::npos) splitter = "|";
-                int samplePloidy = split(gt, splitter).size();
-                int numAlleles = var.alt.size() + 1; // including reference
-
-                // get the gt GL ordering
-                pair<int, int> pa = make_pair(samplePloidy, numAlleles);
-                map<pair<int, int>, list<list<int> > >::iterator order = glOrderCache.find(pa);
-                if (order == glOrderCache.end()) {
-                    glOrderCache[pa] = glorder(samplePloidy, numAlleles);
-                }
-                list<list<int> >& glOrdering = glOrderCache[pa];
-
-                // find the gl max
-                vector<string>& gls = l->second;
-                vector<string>::iterator p = gls.begin();
-                double maxGl;
-                convert(*p, maxGl); ++p;
-                int i = 1, maxindex = 0;
-                for (; p != gls.end(); ++p, ++i) {
-                    double cgl;
-                    convert(*p, cgl);
-                    if (cgl > maxGl) {
-                        maxGl = cgl;
-                        maxindex = i; // prefers == gls in order of listing
-                    }
-                }
-		
-                // determine which genotype it represents
-                // modify, if the GT is part-null
-                vector<string>& gtv = g->second;
-                list<list<int> >::iterator b = glOrdering.begin();
-                advance(b, maxindex);
-                /*
-                  cout << "changing sample " << s->first << " gt from " << gt << " to " << join(*b, "/")
-                  << " gls are ";
-                  int q = 0;
-                  for (list<list<int> >::iterator i = glOrdering.begin(); i != glOrdering.end(); ++i, ++q) {
-                  cout << join(*i, "/") << ":" << sample["GL"].at(q) << ", ";
-                  }
-                  cout << endl;
-                */
-
-                gtv.clear();
-                gtv.push_back(join(*b, "/"));
-            }
-        }
-        cout << var << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfhetcount.cpp b/vcflib/src/vcfhetcount.cpp
deleted file mode 100644
index 98ab44d..0000000
--- a/vcflib/src/vcfhetcount.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include <string>
-#include <iostream>
-
-using namespace std;
-using namespace vcf;
-
-
-int main(int argc, char** argv) {
-
-    if (argc != 2) {
-        cerr << "usage: " << argv[0] << " <vcf file>" << endl
-             << "count the number of alternate alleles in heterozygous genotypes in all records in the vcf file" << endl
-             << "outputs a count for each individual in the file" << endl;
-        return 1;
-    }
-
-    string filename = argv[1];
-
-    VariantCallFile variantFile;
-    variantFile.open(filename);
-    if (!variantFile.is_open()) {
-        cerr << "could not open " << filename << endl;
-        return 1;
-    }
-
-    unsigned int hetAlleleCount = 0;
-    map<string, unsigned int> hetCounts;
-    for (vector<string>::iterator s = variantFile.sampleNames.begin(); s != variantFile.sampleNames.end(); ++s) {
-        hetCounts[*s] = 0;
-    }
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-        //cout << var << endl;
-        for (map<string, map<string, vector<string> > >::iterator s = var.samples.begin(); s != var.samples.end(); ++s) {
-            string name = s->first;
-            map<string, vector<string> >& sample = s->second;
-            string& genotype = sample["GT"].front();
-            vector<string> gt = split(genotype, "|/");
-            int alt = 0;
-            for (vector<string>::iterator g = gt.begin(); g != gt.end(); ++g) {
-                if (*g != "0")
-                    ++alt;
-            }
-            if (alt != gt.size()) {
-                hetCounts[name] += alt;
-                //hetAlleleCount += alt;
-            }
-        }
-    }
-
-    //cout << hetAlleleCount << endl;
-    for (vector<string>::iterator s = variantFile.sampleNames.begin(); s != variantFile.sampleNames.end(); ++s) {
-        cout << (s == variantFile.sampleNames.begin() ? "" : "\t") << *s;
-    }
-    cout << endl;
-    for (vector<string>::iterator s = variantFile.sampleNames.begin(); s != variantFile.sampleNames.end(); ++s) {
-        cout << (s == variantFile.sampleNames.begin() ? "" : "\t") << hetCounts[*s];
-    }
-    cout << endl;
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfhethomratio.cpp b/vcflib/src/vcfhethomratio.cpp
deleted file mode 100644
index 10e39f8..0000000
--- a/vcflib/src/vcfhethomratio.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include <string>
-#include <iostream>
-
-using namespace std;
-using namespace vcf;
-
-
-int main(int argc, char** argv) {
-
-    if (argc != 2) {
-        cerr << "usage: " << argv[0] << " <vcf file>" << endl
-             << "outputs the het/hom ratio for each individual in the file" << endl;
-        return 1;
-    }
-
-    string filename = argv[1];
-
-    VariantCallFile variantFile;
-    if (filename == "-") {
-        variantFile.open(std::cin);
-    } else {
-        variantFile.open(filename);
-    }
-    if (!variantFile.is_open()) {
-        cerr << "could not open " << filename << endl;
-        return 1;
-    }
-
-    map<string, unsigned int> hetCounts;
-    map<string, unsigned int> homCounts;
-    for (vector<string>::iterator s = variantFile.sampleNames.begin(); s != variantFile.sampleNames.end(); ++s) {
-        hetCounts[*s] = 0;
-        homCounts[*s] = 0;
-    }
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-        //cout << var << endl;
-        for (map<string, map<string, vector<string> > >::iterator s = var.samples.begin(); s != var.samples.end(); ++s) {
-            string name = s->first;
-            map<string, vector<string> >& sample = s->second;
-            string& gt = sample["GT"].front();
-            map<int, int> genotype = decomposeGenotype(gt);
-            if (isHet(genotype)) {
-                ++hetCounts[name];
-            } else if (isHomNonRef(genotype)) {
-                ++homCounts[name];
-            }
-        }
-    }
-
-    for (vector<string>::iterator s = variantFile.sampleNames.begin(); s != variantFile.sampleNames.end(); ++s) {
-        cout << (s == variantFile.sampleNames.begin() ? "" : "\t") << *s;
-    }
-    cout << endl;
-    for (vector<string>::iterator s = variantFile.sampleNames.begin(); s != variantFile.sampleNames.end(); ++s) {
-        cout << (s == variantFile.sampleNames.begin() ? "" : "\t") << (double) hetCounts[*s] / (double) homCounts[*s];
-    }
-    cout << endl;
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfintersect.cpp b/vcflib/src/vcfintersect.cpp
deleted file mode 100644
index 58f3bd1..0000000
--- a/vcflib/src/vcfintersect.cpp
+++ /dev/null
@@ -1,569 +0,0 @@
-#include "Variant.h"
-#include "BedReader.h"
-#include "intervaltree/IntervalTree.h"
-#include <getopt.h>
-#include "fastahack/Fasta.h"
-#include <algorithm>
-#include <list>
-#include <set>
-
-using namespace std;
-using namespace vcf;
-
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [options] [<vcf file>]" << endl
-         << endl
-         << "options:" << endl 
-         << "    -b, --bed FILE            use intervals provided by this BED file" << endl
-         << "    -R, --region REGION       use 1-based tabix-style region (e.g. chrZ:10-20), multiples allowed" << endl
-         << "    -S, --start-only          don't use the reference length information in the record to determine" << endl
-         << "                              overlap status, just use the start posiion" << endl
-         << "    -v, --invert              invert the selection, printing only records which would" << endl
-         << "                                not have been printed out" << endl
-         << "    -i, --intersect-vcf FILE  use this VCF for set intersection generation" << endl
-         << "    -u, --union-vcf FILE      use this VCF for set union generation" << endl
-         << "    -w, --window-size N       compare records up to this many bp away (default 30)" << endl
-         << "    -r, --reference FILE      FASTA reference file, required with -i and -u" << endl
-         << "    -l, --loci                output whole loci when one alternate allele matches" << endl
-         << "    -m, --ref-match           intersect on the basis of record REF string" << endl
-         << "    -t, --tag TAG             attach TAG to each record's info field if it would intersect" << endl
-         << "    -V, --tag-value VAL       use this value to indicate that the allele is passing" << endl
-         << "                              '.' will be used otherwise.  default: 'PASS'" << endl
-         << "    -M, --merge-from FROM-TAG" << endl
-         << "    -T, --merge-to   TO-TAG   merge from FROM-TAG used in the -i file, setting TO-TAG" << endl
-         << "                              in the current file." << endl
-         << endl
-         << "For bed-vcf intersection, alleles which fall into the targets are retained." << endl
-         << endl
-         << "For vcf-vcf intersection and union, unify on equivalent alleles within window-size bp" << endl
-         << "as determined by haplotype comparison alleles." << endl;
-	//<< "Intersect the records in the VCF file with targets provided in a BED file." << endl
-	//<< "Intersections are done on the reference sequences in the VCF file." << endl
-	//<< "If no VCF filename is specified on the command line (last argument) the VCF" << endl
-	//<< "read from stdin." << endl;
-    exit(0);
-}
-
-
-int main(int argc, char** argv) {
-
-    string bedFileName;
-    string vcfFileName;
-    string fastaFileName;
-    bool intersecting = false;
-    bool unioning = false;
-    bool invert = false;
-    bool contained = true;
-    bool overlapping = false;
-    bool startPositionOnly = false;
-    int windowsize = 30;
-    bool loci = false;
-    bool refmatch = false;
-    string tag;
-    string tagValue = "PASS";
-    string mergeFromTag;
-    string mergeToTag;
-    vector<BedTarget> regions;
-
-    if (argc == 1)
-        printSummary(argv);
-
-    int c;
-    while (true) {
-        static struct option long_options[] =
-            {
-                /* These options set a flag. */
-                //{"verbose", no_argument,       &verbose_flag, 1},
-                {"help", no_argument, 0, 'h'},
-                {"bed",  required_argument, 0, 'b'},
-                {"region",  required_argument, 0, 'R'},
-                {"invert",  no_argument, 0, 'v'},
-                {"intersect-vcf", required_argument, 0, 'i'},
-                {"union-vcf", required_argument, 0, 'u'},
-                {"contained",  no_argument, 0, 'c'},
-                {"overlapping", no_argument, 0, 'o'},
-                {"window-size", required_argument, 0, 'w'},
-                {"reference", required_argument, 0, 'r'},
-                {"loci", no_argument, 0, 'l'},
-                {"ref-match", no_argument, 0, 'm'},
-                {"tag", required_argument, 0, 't'},
-                {"tag-value", required_argument, 0, 'V'},
-                {"merge-from", required_argument, 0, 'M'},
-                {"merge-to", required_argument, 0, 'T'},
-                {"start-only", no_argument, 0, 'S'},
-                {0, 0, 0, 0}
-            };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "hvcSlmob:i:u:w:r:t:V:M:T:R:",
-                         long_options, &option_index);
-
-        if (c == -1)
-            break;
-
-        switch (c) {
-
-	    case 'w':
-            windowsize = atoi(optarg);
-            break;
-
-        case 'b':
-            bedFileName = string(optarg);
-            break;
-
-        case 'i':
-            intersecting = true;
-            vcfFileName = string(optarg);
-            break;
-
-        case 'u':
-            unioning = true;
-            vcfFileName = string(optarg);
-            break;
-
-	    case 'r':
-            fastaFileName = string(optarg);
-            break;
-
-        case 'v':
-            invert = true;
-            break;
-
-        case 'c':
-            contained = true;
-            break;
-
-        case 'o':
-            overlapping = true;
-            break;
-
-	    case 'l':
-	        loci = true;
-	        break;
-
-	    case 'm':
-	        refmatch = true;
-	        break;
-
-	    case 't':
-	        tag = optarg;
-            break;
-
-        case 'R':
-            regions.push_back(BedTarget(optarg));
-            regions.back().left -= 1;
-            break;
-
-        case 'S':
-            startPositionOnly = true;
-            break;
-
-	    case 'V':
-            tagValue = optarg;
-            break;
-
-	    case 'M':
-            mergeFromTag = optarg;
-            break;
-
-	    case 'T':
-            mergeToTag = optarg;
-            break;
-
-        case 'h':
-            printSummary(argv);
-            break;
-
-        case '?':
-            printSummary(argv);
-            exit(1);
-            break;
-
-        default:
-            abort ();
-        }
-    }
-
-
-    VariantCallFile variantFile;
-    bool usingstdin = false;
-    string inputFilename;
-    if (optind == argc - 1) {
-        inputFilename = argv[optind];
-        variantFile.open(inputFilename);
-    } else {
-        variantFile.open(std::cin);
-        usingstdin = true;
-    }
-
-    if (!variantFile.is_open()) {
-        cerr << "could not open VCF file" << endl;
-        exit(1);
-    }
-
-
-    bool usingBED = false;
-    if (!bedFileName.empty()) {
-        usingBED = true;
-    }
-    
-    if (usingBED || !regions.empty()) {
-        variantFile.parseSamples = false;
-    }
-
-    // it runs much faster to do this first.  then downstream processes don't block!
-
-    if (!tag.empty()) {
-        variantFile.addHeaderLine("##INFO=<ID="+ tag +",Number=A,Type=String,Description=\"" + tagValue + " if this allele intersects with one in " + vcfFileName  +  ", '.' if not.\">");
-    }
-
-    if (!mergeToTag.empty()) {
-        if (mergeFromTag.empty()) {
-            cerr << "must specify a tag to merge from" << endl;
-            exit(1);
-        }
-        // todo...
-        // adjust to pick up flags from the other file to determine what it is we're merging
-        // otherwise, here be hacks
-        variantFile.addHeaderLine("##INFO=<ID="+ mergeToTag +",Number=A,Type=String,Description=\"The value of " + mergeFromTag + " in " + vcfFileName  +  " '.' if the tag does not exist for the given allele in the other file, or if there is no corresponding allele.\">");
-    }
-
-    cout << variantFile.header << endl;
-
-
-    BedReader bed;
-    if (usingBED) {
-        bed.open(bedFileName);
-    }
-    if (!regions.empty()) {
-        // add to the bed
-        bed.addTargets(regions);
-        usingBED = true;
-    }
-
-    VariantCallFile otherVariantFile;
-    if (!vcfFileName.empty()) {
-        if (vcfFileName == "-") {
-            if (usingstdin) {
-                cerr << "cannot open both VCF file streams from stdin" << endl;
-                exit(1);
-            } else {
-                otherVariantFile.open(std::cin);
-            }
-        } else {
-            otherVariantFile.open(vcfFileName);
-        }
-        if (!otherVariantFile.is_open()) {
-            cerr << "could not open VCF file " << vcfFileName << endl;
-            exit(1);
-        }
-    }
-
-    FastaReference reference;
-    if (unioning || intersecting) {
-        if (fastaFileName.empty()) {
-            cerr << "a reference is required for haplotype-based intersection and unioniong" << endl;
-            exit(1);
-        }
-        reference.open(fastaFileName);
-    }
-
-    if (!unioning && !intersecting) {
-        variantFile.parseSamples = false; // faster, as when we are
-        // only bed-intersecting we
-        // can do position-only
-        // output and don't have to
-        // manipulate specific
-        // alleles
-    }
-
-    // read the VCF file for union or intersection into an interval tree
-    // indexed using some proximity window
-
-    map<string, IntervalTree<Variant*> > variantIntervals;
-    map<string, list<Variant> > otherVariants;
-    map<string, vector<Interval<Variant*> > > otherVariantIntervals;
-
-    if (unioning || intersecting) {
-
-        Variant ovar(otherVariantFile);
-        while (otherVariantFile.getNextVariant(ovar)) {
-            long int left = ovar.position;
-            long int right = left + ovar.ref.size(); // this should be 1-past the end
-            otherVariants[ovar.sequenceName].push_back(ovar);
-            Variant* v = &otherVariants[ovar.sequenceName].back();
-            otherVariantIntervals[ovar.sequenceName].push_back(Interval<Variant*>(left, right, v));
-        }
-	
-        for (map<string, vector<Interval<Variant*> > >::iterator j = otherVariantIntervals.begin(); j != otherVariantIntervals.end(); ++j) {
-            variantIntervals[j->first] = IntervalTree<Variant*>(j->second);
-        }
-
-    }
-
-    set<Variant*> outputVariants;
-
-    long int lastOutputPosition = 0;
-    string lastSequenceName;
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-
-        if (lastSequenceName.empty()) {
-            lastSequenceName = var.sequenceName;
-        } else if (lastSequenceName != var.sequenceName) {
-            if (unioning) {
-                vector<Interval<Variant*> > previousRecords;
-                long int lastSeqLength = reference.sequenceLength(lastSequenceName);
-                variantIntervals[lastSequenceName].findContained(lastOutputPosition, lastSeqLength, previousRecords);
-                for (vector<Interval<Variant*> >::iterator r = previousRecords.begin(); r != previousRecords.end(); ++r) {
-                    Variant* v = r->value;
-                    if (outputVariants.find(v) == outputVariants.end()) {
-                        outputVariants.insert(v);
-                        cout << *v << endl; // Q: does this output everything in correct order?.... A: No.
-                    }
-                }
-                lastSequenceName = var.sequenceName;
-                lastOutputPosition = 0;
-            }
-        }
-
-        if (usingBED) {
-            vector<BedTarget*> overlaps;
-            if (startPositionOnly) {
-                // only intersect if start position (not end) is in target
-                BedTarget record(var.sequenceName, var.position, var.position, "");
-                overlaps = bed.targetsOverlapping(record);
-            } else {
-                // default behavior
-                BedTarget record(var.sequenceName, var.position, var.position + var.ref.size() - 1, "");
-                overlaps = bed.targetsOverlapping(record);
-            }
-
-            if (!invert && !overlaps.empty()) {
-                cout << variantFile.line << endl;
-            } else if (invert && overlaps.empty()) {
-                cout << variantFile.line << endl;
-            }
-
-        } else if (unioning || intersecting) {
-
-            // TODO check overlaps with union/intersection
-            // hmm... for unioning, you might need to step through the original VCF records
-            // but the idea is to exclude the haplotype-based duplicates
-
-            vector<Interval<Variant*> > results;
-
-            variantIntervals[var.sequenceName].findContained(var.position - windowsize, var.position + var.ref.size() + windowsize, results);
-
-            vector<Variant*> overlapping;
-
-            for (vector<Interval<Variant*> >::iterator r = results.begin(); r != results.end(); ++r) {
-                overlapping.push_back(r->value);
-            }
-
-
-            if (unioning) {
-
-                // unioning strategy
-
-                // write out all the records from the last file
-                // between the last one printed out and the first
-                // one we're about to print out
-
-                vector<Interval<Variant*> > previousRecords;
-
-                variantIntervals[var.sequenceName].findOverlapping(lastOutputPosition, var.position - windowsize, previousRecords);
-
-                map<long int, vector<Variant*> > variants;
-
-                for (vector<Interval<Variant*> >::iterator r = previousRecords.begin(); r != previousRecords.end(); ++r) {
-                    Variant* v = r->value;
-                    if (outputVariants.find(v) == outputVariants.end()) {
-                        outputVariants.insert(v);
-                        variants[v->position].push_back(v);
-                    }
-                }
-
-                for (map<long int, vector<Variant*> >::iterator v = variants.begin(); v != variants.end(); ++v) {
-                    for (vector<Variant*>::iterator o = v->second.begin(); o != v->second.end(); ++o) {
-                        cout << **o << endl;
-                        lastOutputPosition = max(lastOutputPosition, (*o)->position);
-                    }
-                }
-
-                // TODO find the duplicates for the other file
-            }
-
-
-            if (overlapping.empty()) {
-
-                if (unioning || (intersecting && invert)) {
-                    cout << var << endl;
-                    lastOutputPosition = max(lastOutputPosition, var.position);
-                } else if (intersecting && (!tag.empty() || !mergeToTag.empty())) {
-                    for (int i = 0; i < var.alt.size(); ++i) {
-                        if (!tag.empty()) {
-                            var.info[tag].push_back(".");
-                        }
-                        if (!mergeToTag.empty()) {
-                            var.info[mergeToTag].push_back(".");
-                        }
-                    }
-                    cout << var << endl;
-                    lastOutputPosition = max(lastOutputPosition, var.position);
-                }
-
-            } else {
-
-                // get the min and max of the overlaps
-
-                int haplotypeStart = var.position;
-                int haplotypeEnd = var.position + var.ref.size();
-
-                for (vector<Variant*>::iterator v = overlapping.begin(); v != overlapping.end(); ++v) {
-                    haplotypeStart = min((*v)->position, (long int) haplotypeStart);
-                    haplotypeEnd = max((*v)->position + (*v)->ref.size(), (long unsigned int) haplotypeEnd);
-                }
-
-                // for everything overlapping and the current variant, construct the local haplotype within the bounds
-                // if there is an exact match, the allele in the current VCF does intersect
-
-                string referenceHaplotype = reference.getSubSequence(var.sequenceName, haplotypeStart - 1, haplotypeEnd - haplotypeStart);
-                map<string, vector<pair<Variant*, int> > > haplotypes; // map to variant and alt index
-
-                for (vector<Variant*>::iterator v = overlapping.begin(); v != overlapping.end(); ++v) {
-                    Variant& variant = **v;
-                    int altindex = 0;
-                    for (vector<string>::iterator a = variant.alt.begin(); a != variant.alt.end(); ++a, ++altindex) {
-                        string haplotype = referenceHaplotype;
-                        // get the relative start and end coordinates for the variant alternate allele
-                        int relativeStart = variant.position - haplotypeStart;
-                        haplotype.replace(relativeStart, variant.ref.size(), *a);
-                        haplotypes[haplotype].push_back(make_pair(*v, altindex));
-                    }
-                }
-
-                Variant originalVar = var;
-
-                // determine the non-intersecting alts
-                vector<string> altsToRemove;
-                vector<int> altIndexesToRemove;
-                for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-                    string haplotype = referenceHaplotype;
-                    int relativeStart = var.position - haplotypeStart;
-                    haplotype.replace(relativeStart, var.ref.size(), *a);
-                    map<string, vector<pair<Variant*, int> > >::iterator h = haplotypes.find(haplotype);
-                    if ((intersecting && !invert && h == haplotypes.end())
-                        || (intersecting && invert && h != haplotypes.end())
-                        || (unioning && h != haplotypes.end())) {
-                        if (tag.empty() && mergeToTag.empty()) {
-                            altsToRemove.push_back(*a);
-                        } else {
-                            if (!tag.empty()) {
-                                var.info[tag].push_back(".");
-                            }
-                            if (!mergeToTag.empty()) {
-                                var.info[mergeToTag].push_back(".");
-                            }
-                        }
-                    } else {
-                        if (!tag.empty()) {
-                            var.info[tag].push_back(tagValue);
-                        }
-                        // NB: just take the first value for the mergeFromTag
-                        if (!mergeToTag.empty()) {
-                            Variant* v = h->second.front().first;
-                            int index = h->second.front().second;
-                            if (v->info.find(mergeFromTag) != v->info.end()) {
-                                // now you have to find the exact allele...
-                                string& otherValue = v->info[mergeFromTag].at(index);
-                                var.info[mergeToTag].push_back(otherValue);
-                            } else if (mergeFromTag == "QUAL") {
-                                var.info[mergeToTag].push_back(convert(v->quality));
-                            } else {
-                                var.info[mergeToTag].push_back(".");
-                            }
-                        }
-                    }
-                }
-
-                // remove the non-overlapping (intersecting) or overlapping (unioning) alts
-                if (intersecting && loci && altsToRemove.size() != var.alt.size()) {
-                    // we have a match in loci mode, so we should output the whole loci, not just the matching sequence
-                } else {
-                    for (vector<string>::iterator a = altsToRemove.begin(); a != altsToRemove.end(); ++a) {
-                        var.removeAlt(*a);
-                    }
-                }
-
-                if (unioning) {
-
-                    // somehow sort the records and combine them?
-                    map<long int, vector<Variant*> > variants;
-                    for (vector<Variant*>::iterator o = overlapping.begin(); o != overlapping.end(); ++o) {
-                        if ((*o)->position <= var.position && // check ensures proper ordering of variants on output
-                            outputVariants.find(*o) == outputVariants.end()) {
-                            outputVariants.insert(*o);
-                            variants[(*o)->position].push_back(*o);
-                        }
-                    }
-                    // add in the current variant, if it has alts left
-                    if (!var.alt.empty()) {
-                        vector<Variant*>& vars = variants[var.position];
-                        int numalts = 0;
-                        for (vector<Variant*>::iterator v = vars.begin(); v != vars.end(); ++v) {
-                            numalts += (*v)->alt.size();
-                        }
-                        if (numalts + var.alt.size() == originalVar.alt.size()) {
-                            variants[var.position].clear();
-                            variants[var.position].push_back(&originalVar);
-                        } else {
-                            variants[var.position].push_back(&var);
-                        }
-                    }
-
-                    for (map<long int, vector<Variant*> >::iterator v = variants.begin(); v != variants.end(); ++v) {
-                        for (vector<Variant*>::iterator o = v->second.begin(); o != v->second.end(); ++o) {
-                            cout << **o << endl;
-                            lastOutputPosition = max(lastOutputPosition, (*o)->position);
-                        }
-                    }
-                } else {
-                    // if any alts remain, output the variant record
-                    if (!var.alt.empty()) {
-                        cout << var << endl;
-                        lastOutputPosition = max(lastOutputPosition, var.position);
-                    }
-                }
-
-            }
-
-        }
-
-    }
-
-
-    // if unioning, and any variants remain, output them
-    if (unioning) {
-        for (map<string, list<Variant> >::iterator chrom = otherVariants.find(lastSequenceName);
-             chrom != otherVariants.end();
-             ++chrom) {
-            for (list<Variant>::iterator v = chrom->second.begin(); v != chrom->second.end(); ++v) {
-                Variant* variant = &*v;
-                if (outputVariants.find(variant) == outputVariants.end()) {
-                    outputVariants.insert(variant);
-                    cout << *variant << endl;
-                    // TODO guarantee sorting
-                }
-            }
-        }
-    }
-
-    exit(0);  // why?
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfkeepgeno.cpp b/vcflib/src/vcfkeepgeno.cpp
deleted file mode 100644
index 87ab0af..0000000
--- a/vcflib/src/vcfkeepgeno.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include <string>
-#include <iostream>
-#include <set>
-
-using namespace std;
-using namespace vcf;
-
-
-int main(int argc, char** argv) {
-
-    if (argc < 3) {
-        cerr << "usage: " << argv[0] << " <vcf file> [FIELD1] [FIELD2] ..." << endl
-             << "outputs each record in the vcf file, removing FORMAT fields not listed"
-	     << "on the command line from sample specifications in the output"
-	     << endl;
-        return 1;
-    }
-
-    string filename = argv[1];
-
-    vector<string> newFormat;
-    set<string> fieldsToKeep;
-    for (int i = 2; i < argc; ++i) {
-        fieldsToKeep.insert(argv[i]);
-	newFormat.push_back(argv[i]);
-    }
-
-    VariantCallFile variantFile;
-    if (filename == "-") {
-        variantFile.open(std::cin);
-    } else {
-        variantFile.open(filename);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    Variant var(variantFile);
-
-    vector<string> formatIds = variantFile.formatIds();
-    for (vector<string>::iterator i = formatIds.begin(); i != formatIds.end(); ++i) {
-	if (!fieldsToKeep.count(*i)) {
-	    variantFile.removeGenoHeaderLine(*i);
-	}
-    }
-
-    // write the header
-    cout << variantFile.header << endl;
- 
-    // print the records, filtering is done via the setting of varA's output sample names
-    while (variantFile.getNextVariant(var)) {
-	var.format = newFormat;
-        cout << var << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfkeepinfo.cpp b/vcflib/src/vcfkeepinfo.cpp
deleted file mode 100644
index 8696db7..0000000
--- a/vcflib/src/vcfkeepinfo.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include <string>
-#include <iostream>
-#include <set>
-
-using namespace std;
-using namespace vcf;
-
-int main(int argc, char** argv) {
-
-    if (argc < 3) {
-        cerr << "usage: " << argv[0] << " <vcf file> [FIELD1] [FIELD2] ..." << endl
-             << "outputs each record in the vcf file, removing INFO fields not listed on the command line" << endl;
-        return 1;
-    }
-
-    string filename = argv[1];
-
-    set<string> fieldsToKeep;
-    for (int i = 2; i < argc; ++i) {
-        fieldsToKeep.insert(argv[i]);
-    }
-
-    VariantCallFile variantFile;
-    if (filename == "-") {
-        variantFile.open(std::cin);
-    } else {
-        variantFile.open(filename);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    Variant var(variantFile);
-
-    vector<string> fieldsToErase;
-    vector<string> infoIds = variantFile.infoIds();
-    for (vector<string>::iterator i = infoIds.begin(); i != infoIds.end(); ++i) {
-        if (!fieldsToKeep.count(*i)) {
-            fieldsToErase.push_back(*i);
-            variantFile.removeInfoHeaderLine(*i);
-        }
-    }
-
-    // write the header
-    cout << variantFile.header << endl;
- 
-    // print the records, filtering is done via the setting of varA's output sample names
-    while (variantFile.getNextVariant(var)) {
-        for (vector<string>::iterator f = fieldsToErase.begin(); f != fieldsToErase.end(); ++f) {
-            var.info.erase(*f);
-            var.infoFlags.erase(*f);
-        }
-        cout << var << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfkeepsamples.cpp b/vcflib/src/vcfkeepsamples.cpp
deleted file mode 100644
index 935c8a1..0000000
--- a/vcflib/src/vcfkeepsamples.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include <string>
-#include <iostream>
-
-using namespace std;
-using namespace vcf;
-
-int main(int argc, char** argv) {
-
-    if (argc < 3) {
-        cerr << "usage: " << argv[0] << " <vcf file> [SAMPLE1] [SAMPLE2] ..." << endl
-             << "outputs each record in the vcf file, removing samples not listed on the command line" << endl;
-        return 1;
-    }
-
-    string filename = argv[1];
-
-    vector<string> samplesToKeep;
-    for (int i = 2; i < argc; ++i) {
-        samplesToKeep.push_back(argv[i]);
-    }
-
-    VariantCallFile variantFile;
-    if (filename == "-") {
-        variantFile.open(std::cin);
-    } else {
-        variantFile.open(filename);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    Variant var(variantFile);
-
-    // update sample list in header
-    variantFile.updateSamples(samplesToKeep);
-
-    // and restrict the output sample names in the variant to those we are keeping
-    var.setOutputSampleNames(samplesToKeep);
-    
-    // write the new header
-    cout << variantFile.header << endl;
- 
-    // print the records, filtering is done via the setting of varA's output sample names
-    while (variantFile.getNextVariant(var)) {
-        cout << var << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfleftalign.cpp b/vcflib/src/vcfleftalign.cpp
deleted file mode 100644
index 7d05b79..0000000
--- a/vcflib/src/vcfleftalign.cpp
+++ /dev/null
@@ -1,779 +0,0 @@
-#include "Variant.h"
-#include "convert.h"
-#include "join.h"
-#include "split.h"
-#include "fastahack/Fasta.h"
-#include <set>
-#include <vector>
-#include <getopt.h>
-#include <cmath>
-
-using namespace std;
-using namespace vcf;
-
-
-// Attempts to left-realign all the indels represented by the alignment cigar.
-//
-// This is done by shifting all indels as far left as they can go without
-// mismatch, then merging neighboring indels of the same class.  leftAlign
-// updates the alignment cigar with changes, and returns true if realignment
-// changed the alignment cigar.
-//
-// To left-align, we move multi-base indels left by their own length as long as
-// the preceding bases match the inserted or deleted sequence.  After this
-// step, we handle multi-base homopolymer indels by shifting them one base to
-// the left until they mismatch the reference.
-//
-// To merge neighboring indels, we iterate through the set of left-stabilized
-// indels.  For each indel we add a new cigar element to the new cigar.  If a
-// deletion follows a deletion, or an insertion occurs at the same place as
-// another insertion, we merge the events by extending the previous cigar
-// element.
-//
-// In practice, we must call this function until the alignment is stabilized.
-
-#define VCFLEFTALIGN_DEBUG(msg) \
-    if (false) { cerr << msg; }
-
-class VCFIndelAllele {
-    friend ostream& operator<<(ostream&, const VCFIndelAllele&);
-    friend bool operator==(const VCFIndelAllele&, const VCFIndelAllele&);
-    friend bool operator!=(const VCFIndelAllele&, const VCFIndelAllele&);
-    friend bool operator<(const VCFIndelAllele&, const VCFIndelAllele&);
-public:
-    bool insertion;
-    int length;
-    int position;
-    int readPosition;
-    string sequence;
-
-    bool homopolymer(void);
-
-    VCFIndelAllele(bool i, int l, int p, int rp, string s)
-        : insertion(i), length(l), position(p), readPosition(rp), sequence(s)
-        { }
-};
-
-bool FBhomopolymer(string sequence);
-ostream& operator<<(ostream& out, const VCFIndelAllele& indel);
-bool operator==(const VCFIndelAllele& a, const VCFIndelAllele& b);
-bool operator!=(const VCFIndelAllele& a, const VCFIndelAllele& b);
-bool operator<(const VCFIndelAllele& a, const VCFIndelAllele& b);
-
-bool VCFIndelAllele::homopolymer(void) {
-    string::iterator s = sequence.begin();
-    char c = *s++;
-    while (s != sequence.end()) {
-        if (c != *s++) return false;
-    }
-    return true;
-}
-
-bool FBhomopolymer(string sequence) {
-    string::iterator s = sequence.begin();
-    char c = *s++;
-    while (s != sequence.end()) {
-        if (c != *s++) return false;
-    }
-    return true;
-}
-
-ostream& operator<<(ostream& out, const VCFIndelAllele& indel) {
-    string t = indel.insertion ? "i" : "d";
-    out << t <<  ":" << indel.position << ":" << indel.readPosition << ":" << indel.sequence;
-    return out;
-}
-
-bool operator==(const VCFIndelAllele& a, const VCFIndelAllele& b) {
-    return (a.insertion == b.insertion
-            && a.length == b.length
-            && a.position == b.position
-            && a.sequence == b.sequence);
-}
-
-bool operator!=(const VCFIndelAllele& a, const VCFIndelAllele& b) {
-    return !(a==b);
-}
-
-bool operator<(const VCFIndelAllele& a, const VCFIndelAllele& b) {
-    ostringstream as, bs;
-    as << a;
-    bs << b;
-    return as.str() < bs.str();
-}
-
-
-class AltAlignment {
-public:
-    unsigned int pos;
-    string seq;
-    vector<pair<int, string> > cigar;
-    AltAlignment(unsigned int& p,
-                 string& s,
-                 string& c) {
-        pos = p;
-        seq = s;
-        cigar = splitCigar(c);
-    }
-};
-
-double entropy(const string& st) {
-    vector<char> stvec(st.begin(), st.end());
-    set<char> alphabet(stvec.begin(), stvec.end());
-    vector<double> freqs;
-    for (set<char>::iterator c = alphabet.begin(); c != alphabet.end(); ++c) {
-        int ctr = 0;
-        for (vector<char>::iterator s = stvec.begin(); s != stvec.end(); ++s) {
-            if (*s == *c) {
-                ++ctr;
-            }
-        }
-        freqs.push_back((double)ctr / (double)stvec.size());
-    }
-    double ent = 0;
-    double ln2 = log(2);
-    for (vector<double>::iterator f = freqs.begin(); f != freqs.end(); ++f) {
-        ent += *f * log(*f)/ln2;
-    }
-    ent = -ent;
-    return ent;
-}
-
-void getAlignment(Variant& var, FastaReference& reference, string& ref, vector<AltAlignment>& alignments, int window) {
-    
-    // default alignment params
-    float matchScore = 10.0f;
-    float mismatchScore = -9.0f;
-    float gapOpenPenalty = 25.0f;
-    float gapExtendPenalty = 3.33f;
-
-    // establish reference sequence
-    string pad = string(window/2, 'Z');
-    string leftFlank = reference.getSubSequence(var.sequenceName, var.zeroBasedPosition() - window/2, window/2);
-    string rightFlank = reference.getSubSequence(var.sequenceName, var.zeroBasedPosition() + var.ref.size(), window/2);
-    ref = pad + leftFlank + var.ref + rightFlank + pad;
-
-    // and iterate through the alternates, generating alignments
-    for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-        string alt = pad + leftFlank + *a + rightFlank + pad;
-        CSmithWatermanGotoh sw(matchScore, mismatchScore, gapOpenPenalty, gapExtendPenalty);
-        unsigned int referencePos;
-        string cigar;
-        sw.Align(referencePos, cigar, ref, alt);
-        alignments.push_back(AltAlignment(referencePos, alt, cigar));
-    }
-}
-
-
-bool stablyLeftAlign(string& alternateSequence, string referenceSequence, int maxiterations = 50, bool debug = false);
-int countMismatches(string& alternateSequence, string referenceSequence);
-
-bool leftAlign(string& alternateSequence, Cigar& cigar, string& referenceSequence, bool debug = false) {
-
-    int arsOffset = 0; // pointer to insertion point in aligned reference sequence
-    string alignedReferenceSequence = referenceSequence;
-    int aabOffset = 0;
-    string alignmentAlignedBases = alternateSequence;
-
-    // store information about the indels
-    vector<VCFIndelAllele> indels;
-
-    int rp = 0;  // read position, 0-based relative to read
-    int sp = 0;  // sequence position
-
-    string softBegin;
-    string softEnd;
-
-    stringstream cigar_before, cigar_after;
-    for (vector<pair<int, string> >::const_iterator c = cigar.begin();
-        c != cigar.end(); ++c) {
-        unsigned int l = c->first;
-        char t = c->second.at(0);
-
-        cigar_before << l << t;
-        if (t == 'M') { // match or mismatch
-            sp += l;
-            rp += l;
-        } else if (t == 'D') { // deletion
-            indels.push_back(VCFIndelAllele(false, l, sp, rp, referenceSequence.substr(sp, l)));
-            alignmentAlignedBases.insert(rp + aabOffset, string(l, '-'));
-            aabOffset += l;
-            sp += l;  // update reference sequence position
-        } else if (t == 'I') { // insertion
-            indels.push_back(VCFIndelAllele(true, l, sp, rp, alternateSequence.substr(rp, l)));
-            alignedReferenceSequence.insert(sp + softBegin.size() + arsOffset, string(l, '-'));
-            arsOffset += l;
-            rp += l;
-        } else if (t == 'S') { // soft clip, clipped sequence present in the read not matching the reference
-            // remove these bases from the refseq and read seq, but don't modify the alignment sequence
-            if (rp == 0) {
-                alignedReferenceSequence = string(l, '*') + alignedReferenceSequence;
-                softBegin = alignmentAlignedBases.substr(0, l);
-            } else {
-                alignedReferenceSequence = alignedReferenceSequence + string(l, '*');
-                softEnd = alignmentAlignedBases.substr(alignmentAlignedBases.size() - l, l);
-            }
-            rp += l;
-        } else if (t == 'H') { // hard clip on the read, clipped sequence is not present in the read
-        } else if (t == 'N') { // skipped region in the reference not present in read, aka splice
-            sp += l;
-        }
-    }
-
-
-    int alignedLength = sp;
-
-    VCFLEFTALIGN_DEBUG("| " << cigar_before.str() << endl
-       << "| " << alignedReferenceSequence << endl
-       << "| " << alignmentAlignedBases << endl);
-
-    // if no indels, return the alignment
-    if (indels.empty()) { return false; }
-
-    // for each indel, from left to right
-    //     while the indel sequence repeated to the left and we're not matched up with the left-previous indel
-    //         move the indel left
-
-    vector<VCFIndelAllele>::iterator previous = indels.begin();
-    for (vector<VCFIndelAllele>::iterator id = indels.begin(); id != indels.end(); ++id) {
-
-        // left shift by repeats
-        //
-        // from 1 base to the length of the indel, attempt to shift left
-        // if the move would cause no change in alignment optimality (no
-        // introduction of mismatches, and by definition no change in gap
-        // length), move to the new position.
-        // in practice this moves the indel left when we reach the size of
-        // the repeat unit.
-        //
-        int steppos, readsteppos;
-        VCFIndelAllele& indel = *id;
-        int i = 1;
-        while (i <= indel.length) {
-
-            int steppos = indel.position - i;
-            int readsteppos = indel.readPosition - i;
-
-#ifdef VERBOSE_DEBUG
-            if (debug) {
-                if (steppos >= 0 && readsteppos >= 0) {
-                    cerr << referenceSequence.substr(steppos, indel.length) << endl;
-                    cerr << alternateSequence.substr(readsteppos, indel.length) << endl;
-                    cerr << indel.sequence << endl;
-                }
-            }
-#endif
-            while (steppos >= 0 && readsteppos >= 0
-                   && indel.sequence == referenceSequence.substr(steppos, indel.length)
-                   && indel.sequence == alternateSequence.substr(readsteppos, indel.length)
-                   && (id == indels.begin()
-                       || (previous->insertion && steppos >= previous->position)
-                       || (!previous->insertion && steppos >= previous->position + previous->length))) {
-                VCFLEFTALIGN_DEBUG((indel.insertion ? "insertion " : "deletion ") << indel << " shifting " << i << "bp left" << endl);
-                indel.position -= i;
-                indel.readPosition -= i;
-                steppos = indel.position - i;
-                readsteppos = indel.readPosition - i;
-            }
-            do {
-                ++i;
-            } while (i <= indel.length && indel.length % i != 0);
-        }
-
-        // left shift indels with exchangeable flanking sequence
-        //
-        // for example:
-        //
-        //    GTTACGTT           GTTACGTT
-        //    GT-----T   ---->   G-----TT
-        //
-        // GTGTGACGTGT           GTGTGACGTGT
-        // GTGTG-----T   ---->   GTG-----TGT
-        //
-        // GTGTG-----T           GTG-----TGT
-        // GTGTGACGTGT   ---->   GTGTGACGTGT
-        //
-        //
-        steppos = indel.position - 1;
-        readsteppos = indel.readPosition - 1;
-        while (steppos >= 0 && readsteppos >= 0
-               && alternateSequence.at(readsteppos) == referenceSequence.at(steppos)
-               && alternateSequence.at(readsteppos) == indel.sequence.at(indel.sequence.size() - 1)
-               && (id == indels.begin()
-                   || (previous->insertion && indel.position - 1 >= previous->position)
-                   || (!previous->insertion && indel.position - 1 >= previous->position + previous->length))) {
-            VCFLEFTALIGN_DEBUG((indel.insertion ? "insertion " : "deletion ") << indel << " exchanging bases " << 1 << "bp left" << endl);
-            indel.sequence = indel.sequence.at(indel.sequence.size() - 1) + indel.sequence.substr(0, indel.sequence.size() - 1);
-            indel.position -= 1;
-            indel.readPosition -= 1;
-            steppos = indel.position - 1;
-            readsteppos = indel.readPosition - 1;
-        }
-        // tracks previous indel, so we don't run into it with the next shift
-        previous = id;
-    }
-
-    // bring together floating indels
-    // from left to right
-    // check if we could merge with the next indel
-    // if so, adjust so that we will merge in the next step
-    if (indels.size() > 1) {
-        previous = indels.begin();
-        for (vector<VCFIndelAllele>::iterator id = (indels.begin() + 1); id != indels.end(); ++id) {
-            VCFIndelAllele& indel = *id;
-            // parsimony: could we shift right and merge with the previous indel?
-            // if so, do it
-            int prev_end_ref = previous->insertion ? previous->position : previous->position + previous->length;
-            int prev_end_read = !previous->insertion ? previous->readPosition : previous->readPosition + previous->length;
-            if (previous->insertion == indel.insertion
-                    && ((previous->insertion
-                        && (previous->position < indel.position
-                        && previous->readPosition + previous->readPosition < indel.readPosition))
-                        ||
-                        (!previous->insertion
-                        && (previous->position + previous->length < indel.position)
-                        && (previous->readPosition < indel.readPosition)
-                        ))) {
-                if (previous->homopolymer()) {
-                    string seq = referenceSequence.substr(prev_end_ref, indel.position - prev_end_ref);
-                    string readseq = alternateSequence.substr(prev_end_read, indel.position - prev_end_ref);
-                    VCFLEFTALIGN_DEBUG("seq: " << seq << endl << "readseq: " << readseq << endl);
-                    if (previous->sequence.at(0) == seq.at(0)
-                            && FBhomopolymer(seq)
-                            && FBhomopolymer(readseq)) {
-                        VCFLEFTALIGN_DEBUG("moving " << *previous << " right to " 
-                                << (indel.insertion ? indel.position : indel.position - previous->length) << endl);
-                        previous->position = indel.insertion ? indel.position : indel.position - previous->length;
-                    }
-                } 
-                else {
-                    int pos = previous->position;
-                    while (pos < (int) referenceSequence.length() &&
-                            ((previous->insertion && pos + previous->length <= indel.position)
-                            ||
-                            (!previous->insertion && pos + previous->length < indel.position))
-                            && previous->sequence 
-                                == referenceSequence.substr(pos + previous->length, previous->length)) {
-                        pos += previous->length;
-                    }
-                    if (pos < previous->position &&
-                        ((previous->insertion && pos + previous->length == indel.position)
-                        ||
-                        (!previous->insertion && pos == indel.position - previous->length))
-                       ) {
-                        VCFLEFTALIGN_DEBUG("right-merging tandem repeat: moving " << *previous << " right to " << pos << endl);
-                        previous->position = pos;
-                    }
-                }
-            }
-            previous = id;
-        }
-    }
-
-    // for each indel
-    //     if ( we're matched up to the previous insertion (or deletion) 
-    //          and it's also an insertion or deletion )
-    //         merge the indels
-    //
-    // and simultaneously reconstruct the cigar
-
-    Cigar newCigar;
-
-    if (!softBegin.empty()) {
-        newCigar.push_back(make_pair(softBegin.size(), "S"));
-    }
-
-    vector<VCFIndelAllele>::iterator id = indels.begin();
-    VCFIndelAllele last = *id++;
-    if (last.position > 0) {
-        newCigar.push_back(make_pair(last.position, "M"));
-        newCigar.push_back(make_pair(last.length, (last.insertion ? "I" : "D")));
-    } else {
-        newCigar.push_back(make_pair(last.length, (last.insertion ? "I" : "D")));
-    }
-    int lastend = last.insertion ? last.position : (last.position + last.length);
-    VCFLEFTALIGN_DEBUG(last << ",");
-
-    for (; id != indels.end(); ++id) {
-        VCFIndelAllele& indel = *id;
-        VCFLEFTALIGN_DEBUG(indel << ",");
-        if (indel.position < lastend) {
-            cerr << "impossibility?: indel realigned left of another indel" << endl
-                 << referenceSequence << endl << alternateSequence << endl;
-            exit(1);
-        } else if (indel.position == lastend && indel.insertion == last.insertion) {
-            pair<int, string>& op = newCigar.back();
-            op.first += indel.length;
-        } else if (indel.position >= lastend) {  // also catches differential indels, but with the same position
-            newCigar.push_back(make_pair(indel.position - lastend, "M"));
-            newCigar.push_back(make_pair(indel.length, (indel.insertion ? "I" : "D")));
-        }
-        last = *id;
-        lastend = last.insertion ? last.position : (last.position + last.length);
-    }
-    
-    if (lastend < alignedLength) {
-        newCigar.push_back(make_pair(alignedLength - lastend, "M"));
-    }
-
-    if (!softEnd.empty()) {
-        newCigar.push_back(make_pair(softEnd.size(), "S"));
-    }
-
-    VCFLEFTALIGN_DEBUG(endl);
-
-    cigar = newCigar;
-
-    for (vector<pair<int, string> >::const_iterator c = cigar.begin();
-        c != cigar.end(); ++c) {
-        unsigned int l = c->first;
-        char t = c->second.at(0);
-        cigar_after << l << t;
-    }
-
-    //cerr << cigar_before.str() << " changes to " << cigar_after.str() << endl;
-    VCFLEFTALIGN_DEBUG(cigar_after.str() << endl);
-
-    // check if we're realigned
-    if (cigar_after.str() == cigar_before.str()) {
-        return false;
-    } else {
-        return true;
-    }
-
-}
-
-// Iteratively left-aligns the indels in the alignment until we have a stable
-// realignment.  Returns true on realignment success or non-realignment.
-// Returns false if we exceed the maximum number of realignment iterations.
-//
-bool stablyLeftAlign(string& alternateSequence, string referenceSequence, Cigar& cigar, int maxiterations, bool debug) {
-
-    if (!leftAlign(alternateSequence, cigar, referenceSequence, debug)) {
-
-        return true;
-
-    } else {
-
-        bool result = true;
-        while ((result = leftAlign(alternateSequence, cigar, referenceSequence, debug)) && --maxiterations > 0) { 
-        }
-
-        if (maxiterations <= 0) {
-            return false;
-        } else {
-            return true;
-        }
-
-    }
-
-}
-
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [options] [file]" << endl
-         << endl
-         << "options:" << endl
-         << "    -r, --reference FILE  Use this reference as a basis for realignment." << endl
-         << "    -w, --window N        Use a window of this many bp when left aligning (150)." << endl
-         << endl
-         << "Left-aligns variants in the specified input file or stdin.  Window size is determined" << endl
-         << "dynamically according to the entropy of the regions flanking the indel.  These must have" << endl
-         << "entropy > 1 bit/bp, or be shorter than ~5kb." << endl;
-    exit(0);
-}
-
-int main(int argc, char** argv) {
-
-    int window = 150;
-    VariantCallFile variantFile;
-    string fastaFileName;
-
-    int c;
-    while (true) {
-        static struct option long_options[] =
-            {
-                /* These options set a flag. */
-                //{"verbose", no_argument,       &verbose_flag, 1},
-                {"help", no_argument, 0, 'h'},
-                {"reference", required_argument, 0, 'r'},
-                {"window", required_argument, 0, 'w'},
-                {0, 0, 0, 0}
-            };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "hw:r:",
-                         long_options, &option_index);
-
-        if (c == -1)
-            break;
-
-        switch (c) {
-
-	    case 'r':
-            fastaFileName = optarg;
-            break;
-
-	    case 'w':
-            window = atoi(optarg);
-            break;
-
-        case '?':
-            printSummary(argv);
-            exit(1);
-            break;
-
-        case 'h':
-            printSummary(argv);
-            break;
-
-        default:
-            abort ();
-        }
-    }
-
-    if (optind < argc) {
-        string filename = argv[optind];
-        variantFile.open(filename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        cerr << "could not open VCF file" << endl;
-        exit(1);
-    }
-
-    FastaReference fastaReference;
-    if (fastaFileName.empty()) {
-        cerr << "a reference is required" << endl;
-        exit(1);
-    } else {
-        fastaReference.open(fastaFileName);
-    }
-
-    /*
-    variantFile.addHeaderLine("##INFO=<ID=TYPE,Number=A,Type=String,Description=\"The type of allele, either snp, mnp, ins, del, or complex.\">");
-    variantFile.addHeaderLine("##INFO=<ID=LEN,Number=A,Type=Integer,Description=\"allele length\">");
-    if (!parseFlag.empty()) {
-        variantFile.addHeaderLine("##INFO=<ID="+parseFlag+",Number=0,Type=Flag,Description=\"The allele was parsed using vcfallelicprimitives.\">");
-    }
-    */
-    cout << variantFile.header << endl;
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-
-        // if there is no indel, there is nothing to realign
-        bool hasIndel = false;
-        for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-            if (a->size() != var.ref.size()) {
-                hasIndel = true;
-                break;
-            }
-        }
-        if (!hasIndel) {
-            cout << var << endl;
-            continue;
-        }
-
-        vector<AltAlignment> alignments;
-        string ref;
-
-        // determine window size to prevent mismapping with SW algorithm
-        int currentWindow = window;
-        int scale = 2;
-        if (var.ref.size()*scale > currentWindow) currentWindow = var.ref.size()*scale;
-        for (vector<string>::iterator a = var.alleles.begin(); a != var.alleles.end(); ++a) {
-            if (a->size()*scale > currentWindow) {
-                currentWindow = a->size()*scale;
-            }
-        }
-
-        // while the entropy of either flank is < some target entropy (~1 is fine), increase the flank sizes
-        while (currentWindow < 2000) { // limit to one step > than this
-            string refTarget = fastaReference.getSubSequence(var.sequenceName, var.position - 1 - currentWindow/2, currentWindow);
-            if (entropy(refTarget.substr(0, refTarget.size()/2)) < 1 ||
-                entropy(refTarget.substr(refTarget.size()/2)) < 1) {
-                currentWindow *= scale;
-            } else {
-                break;
-            }
-        }
-
-        // do the alignments
-        getAlignment(var, fastaReference, ref, alignments, currentWindow);
-
-        // stably left align the alignments
-        for (vector<AltAlignment>::iterator a = alignments.begin(); a != alignments.end(); ++a) {
-            Cigar cigarBefore = a->cigar;
-            //cerr << a->seq << endl;
-            //cerr << "before : " << a->pos << " " << joinCigar(a->cigar) << endl;
-            stablyLeftAlign(a->seq, ref, a->cigar, 20, false);
-            //cerr << "after  : " << a->pos << " " << joinCigar(a->cigar) << endl;
-        }
-        //cout << var << endl;
-
-        // transform the mappings
-        // chop off leading matching bases
-        // find the range of bp in the alleles
-        // make the new ref allele
-        // make the new alt alleles
-        // emit the var
-
-        long int newPosition = var.position+currentWindow/2;
-        long int newEndPosition = var.position-currentWindow/2;
-        // check for no-indel case
-        int newLength = var.ref.size();
-        bool giveUp = false;
-        for (vector<AltAlignment>::iterator a = alignments.begin(); a != alignments.end() && !giveUp; ++a) {
-            // get the first mismatching position
-            Cigar::iterator c = a->cigar.begin();
-
-            int rp = 0;
-            int sp = 0;
-            bool hitMismatch = false;
-
-            int matchingBpAtStart = 0;
-            int matchingBpAtEnd = 0;
-            // will be set to true if the first reference position match is broken by a SNP, not an indel
-            bool leadingSNP = false;
-
-            while (c != a->cigar.end()) {
-                char op = c->second[0];
-                if (c == a->cigar.begin()) {
-                    if (op != 'M') {
-                        cerr << "alignment does not start on matched sequence" << endl;
-                        cerr << var << endl;
-                        exit(1);
-                    }
-                    int i = 0;
-                    for ( ; i < c->first; ++i) {
-                        if (ref[i] != a->seq[i]) {
-                            leadingSNP = true;
-                            break;
-                        }
-                    }
-                    matchingBpAtStart = i;
-                }
-                if (!leadingSNP && c == (a->cigar.begin()+1)) {
-                    // if the first thing we run into is an indel, step back, per VCF spec
-                    if (op == 'D' || op == 'I') {
-                        --matchingBpAtStart;
-                    }
-                }
-                if (c == (a->cigar.end()-1)) {
-                    if (op != 'M') {
-                        // soft clip at end
-                        // it'll be hard to interpret this
-                        // the alignments sometimes generate this
-                        // best thing to do is to move on
-                        //cerr << "alignment does not end on matched sequence" << endl;
-                        //cout << var << endl;
-                        //exit(1);
-                        giveUp = true;
-                        break;
-                    }
-                    int i = 0;
-                    for ( ; i < c->first; ++i) {
-                        if (ref[ref.size()-1-i] != a->seq[a->seq.size()-1-i]) {
-                            break;
-                        }
-                    }
-                    matchingBpAtEnd = i;
-                }
-                ++c;
-            }
-
-            int altMismatchLength = a->seq.size() - matchingBpAtEnd - matchingBpAtStart;
-            int refMismatchLength = (var.ref.size() + currentWindow) - matchingBpAtEnd - matchingBpAtStart;
-            //cerr << "alt mismatch length " << altMismatchLength << endl
-            //     << "ref mismatch length " << refMismatchLength << endl;
-            long int newStart = var.position - currentWindow/2 + matchingBpAtStart;
-            long int newEnd = newStart + refMismatchLength;
-            //cerr << "ref should run from " << newStart << " to " << newStart + refMismatchLength << endl;
-            newPosition = min(newStart, newPosition);
-            newEndPosition = max(newEnd, newEndPosition);
-            //cerr << newPosition << " " << newEndPosition << endl;
-            //if (newRefSize < refMismatchLength) newRefSize = refMismatchLength;
-        }
-
-        // the alignment failed for some reason, continue
-        if (giveUp) {
-            cout << var << endl;
-            continue;
-        }
-
-        //cerr << "new ref start " << newPosition << " and end " << newEndPosition << " was " << var.position << "," << var.position + var.ref.size() << endl;
-        int newRefSize = newEndPosition - newPosition;
-        string newRef = fastaReference.getSubSequence(var.sequenceName, newPosition-1, newRefSize);
-        // get the number of bp to strip from the alts
-        int stripFromStart = currentWindow/2 - (var.position - newPosition);
-        int stripFromEnd = (currentWindow + newRefSize) - (stripFromStart + newRefSize) + (var.ref.size() - newRefSize);
-
-        //cerr << "strip from start " << stripFromStart << endl;
-        //cerr << "strip from end " << stripFromEnd << endl;
-
-        vector<string> newAlt;
-        vector<string>::iterator l = var.alt.begin();
-        bool failedAlt = false;
-        for (vector<AltAlignment>::iterator a = alignments.begin(); a != alignments.end();
-             ++a, ++l) {
-            int diff = newRef.size() - l->size();
-            string alt = a->seq.substr(stripFromStart, a->seq.size() - (stripFromEnd + stripFromStart));
-            newAlt.push_back(alt);
-            if (alt.empty()) failedAlt = true;
-        }
-
-        // check the before/after haplotypes
-        bool brokenRealignment = false;
-        if (!newRef.empty() && !failedAlt) {
-            int slop = 50; // 50 extra bp!
-            int haplotypeStart = min(var.position, newPosition) - slop;
-            int haplotypeEnd = max(var.position + var.ref.size(), newPosition + newRef.size()) + slop;
-            string referenceHaplotype = fastaReference.getSubSequence(var.sequenceName, haplotypeStart - 1,
-                                                                      haplotypeEnd - haplotypeStart);
-            vector<string>::iterator o = var.alt.begin();
-            vector<string>::iterator n = newAlt.begin();
-            for ( ; o != var.alt.end() ; ++o, ++n) {
-                // map the haplotypes
-                string oldHaplotype = referenceHaplotype;
-                string newHaplotype = referenceHaplotype;
-                oldHaplotype.replace(var.position - haplotypeStart, var.ref.size(), *o);
-                newHaplotype.replace(newPosition - haplotypeStart, newRef.size(), *n);
-                if (oldHaplotype != newHaplotype) {
-                    cerr << "broken left alignment!" << endl
-                         << "old " << oldHaplotype << endl
-                         << "new " << newHaplotype << endl;
-                    cerr << "was: " << var << endl;
-                    brokenRealignment = true;
-                }
-            }
-        }
-
-        // *if* everything is OK, update the variant
-        if (!brokenRealignment && !newRef.empty() && !failedAlt) {
-            var.ref = newRef;
-            var.alt = newAlt;
-            var.position = newPosition;
-        }
-
-        cout << var << endl;
-
-        // for each parsedalternate, get the position
-        // build a new vcf record for that position
-        // unless we are already at the position !
-        // take everything which is unique to that allele (records) and append it to the new record
-        // then handle genotypes; determine the mapping between alleleic primitives and convert to phased haplotypes
-        // this means taking all the parsedAlternates and, for each one, generating a pattern of allele indecies corresponding to it
-
-        
-
-        //for (vector<Variant>::iterator v = variants.begin(); v != variants.end(); ++v) {
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcflength.cpp b/vcflib/src/vcflength.cpp
deleted file mode 100644
index 09bd883..0000000
--- a/vcflib/src/vcflength.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "Variant.h"
-#include "convert.h"
-#include <vector>
-
-using namespace std;
-using namespace vcf;
-
-int main(int argc, char** argv) {
-
-    VariantCallFile variantFile;
-
-    if (argc > 1) {
-        string filename = argv[1];
-        variantFile.open(filename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    variantFile.addHeaderLine("##INFO=<ID=length,Number=A,Type=Integer,Description=\"length(ALT) - length(REF) for each ALT\">");
-    cout << variantFile.header << endl;
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-        vector<string>& lengths = var.info["length"];
-        lengths.clear();
-        for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-            lengths.push_back(convert((int) a->size() - (int) var.ref.size()));
-        }
-        cout << var << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfnumalt.cpp b/vcflib/src/vcfnumalt.cpp
deleted file mode 100644
index a7c66cb..0000000
--- a/vcflib/src/vcfnumalt.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include <string>
-#include <sstream>
-#include <iostream>
-
-using namespace std;
-using namespace vcf;
-
-int main(int argc, char** argv) {
-
-    if (argc != 2) {
-        cerr << "usage: " << argv[0] << " <vcf file>" << endl
-             << "outputs a VCF stream where NUMALT has been generated for each record using sample genotypes" << endl;
-        return 1;
-    }
-
-    string filename = argv[1];
-
-    VariantCallFile variantFile;
-    if (filename == "-") {
-        variantFile.open(std::cin);
-    } else {
-        variantFile.open(filename);
-    }
-
-    if (!variantFile.is_open()) {
-        cerr << "could not open " << filename << endl;
-        return 1;
-    }
-
-    Variant var(variantFile);
-
-    // remove header lines we're going to add
-    variantFile.removeInfoHeaderLine("NUMALT");
-
-    // and add them back, so as not to duplicate them if they are already there
-    variantFile.addHeaderLine("##INFO=<ID=NUMALT,Number=1,Type=Integer,Description=\"Total number of segregating alternate alleles at the loci\">");
-
-    // write the new header
-    cout << variantFile.header << endl;
- 
-    // print the records, filtering is done via the setting of varA's output sample names
-    while (variantFile.getNextVariant(var)) {
-        stringstream na;
-        na << var.alt.size();
-        var.info["NUMALT"].clear();
-        var.info["NUMALT"].push_back(na.str());
-        cout << var << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfoverlay.cpp b/vcflib/src/vcfoverlay.cpp
deleted file mode 100644
index 1d2d1b3..0000000
--- a/vcflib/src/vcfoverlay.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-#include "Variant.h"
-#include <getopt.h>
-
-using namespace std;
-using namespace vcf;
-
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [options] [<vcf file> ...]" << endl
-         << endl
-         << "options:" << endl 
-         << "    -h, --help       this dialog" << endl
-         << endl
-         << "Overlays records in the input vcf files in the order in which they appear." << endl;
-    exit(0);
-}
-
-int main(int argc, char** argv) {
-
-    if (argc == 1)
-        printSummary(argv);
-
-    int c;
-    while (true) {
-        static struct option long_options[] =
-            {
-                {"help", no_argument, 0, 'h'},
-                {0, 0, 0, 0}
-            };
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "h",
-                         long_options, &option_index);
-
-        if (c == -1)
-            break;
-
-        switch (c) {
-            case 'h':
-                printSummary(argv);
-                break;
-
-            case '?':
-                printSummary(argv);
-                exit(1);
-                break;
-
-            default:
-                abort ();
-        }
-    }
-
-    // idea here is to shadow-merge
-    // records from the VCF files, which are provided in order of desired merge
-
-    map<int, pair<VariantCallFile*, Variant > > variantFiles;
-    map<string, map<long int, map<int, string> > > linesByPrecedence;
-    int i = optind;
-
-    if (optind < argc - 1) {
-	while (i < argc) {
-	    int index = i++;
-	    VariantCallFile*& variantFile = variantFiles[index].first;
-	    Variant& var = variantFiles[index].second;
-	    string inputFilename = argv[optind++];
-	    variantFile = new VariantCallFile;
-	    variantFile->open(inputFilename);
-	    var.setVariantCallFile(variantFile);
-	    if (!variantFile->is_open()) {
-		cout << "could not open VCF file" << endl;
-		exit(1);
-	    } else {
-		if (variantFile->getNextVariant(var)) {
-		    linesByPrecedence[var.sequenceName][var.position][index] = variantFile->line;
-		}
-	    }
-	}
-    } else {
-        cerr << "no input files specified" << endl;
-        exit(1);
-    }
-
-    cout << variantFiles.begin()->second.first->header << endl;
-
-    while (!linesByPrecedence.empty()) {
-        // get the lowest entry in the buffer of observed lines
-        // print the first line
-        // get the next variant from that file, put it back into the map
-        const string& lowestChrom = linesByPrecedence.begin()->first;
-        const long int lowestPosition = linesByPrecedence.begin()->second.begin()->first;
-        map<int, string>& lowestLine = linesByPrecedence.begin()->second.begin()->second;
-        cout << lowestLine.begin()->second << endl;
-        
-	for (map<int, string>::iterator g = lowestLine.begin(); g != lowestLine.end(); ++g) {
-	    int index = g->first;
-	    VariantCallFile& variantFile = *variantFiles[index].first;
-	    Variant& var = variantFiles[index].second;
-	    if (!variantFile.getNextVariant(var)) {
-		variantFiles.erase(index);
-	    } else {
-		linesByPrecedence[var.sequenceName][var.position][index] = variantFile.line;
-	    }
-	}
-	
-        linesByPrecedence[lowestChrom].erase(lowestPosition);
-        if (linesByPrecedence[lowestChrom].empty()) {
-            linesByPrecedence.erase(lowestChrom);
-        }
-    }
-
-    // flush the rest of the variant records if there are any
-
-    return 0;
-}
-
diff --git a/vcflib/src/vcfparsealts.cpp b/vcflib/src/vcfparsealts.cpp
deleted file mode 100644
index 5b4e508..0000000
--- a/vcflib/src/vcfparsealts.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-#include "Variant.h"
-
-using namespace std;
-using namespace vcf;
-
-int main(int argc, char** argv) {
-
-    VariantCallFile variantFile;
-
-    if (argc > 1) {
-        string filename = argv[1];
-        variantFile.open(filename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    cout << variantFile.header << endl;
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-        map<string, vector<VariantAllele> > variants = var.parsedAlternates();
-	cout << var << endl;
-        for (map<string, vector<VariantAllele> >::iterator va = variants.begin(); va != variants.end(); ++va) {
-            cout << " ( " << va->first << " :: ";
-            vector<VariantAllele>& vars = va->second;
-            vector<VariantAllele>::iterator g = vars.begin();
-            for (; g != vars.end(); ++g) {
-                cout << *g << "; ";
-            }
-            cout << " ) ";
-        }
-        cout << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfprimers.cpp b/vcflib/src/vcfprimers.cpp
deleted file mode 100644
index 2a5c46a..0000000
--- a/vcflib/src/vcfprimers.cpp
+++ /dev/null
@@ -1,140 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include "fastahack/Fasta.h"
-#include <getopt.h>
-
-using namespace std;
-using namespace vcf;
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [options] <vcf file>" << endl
-         << endl
-         << "options:" << endl 
-         << "    -f, --fasta-reference  FASTA reference file to use to obtain primer sequences" << endl
-         << "    -l, --primer-length    The length of the primer sequences on each side of the variant" << endl
-         << endl
-         << "For each VCF record, extract the flanking sequences, and write them to stdout as FASTA" << endl
-         << "records suitable for alignment.  This tool is intended for use in designing validation" << endl
-         << "experiments.  Primers extracted which would flank all of the alleles at multi-allelic" << endl
-         << "sites.  The name of the FASTA \"reads\" indicates the VCF record which they apply to." << endl
-         << "The form is >CHROM_POS_LEFT for the 3' primer and >CHROM_POS_RIGHT for the 5' primer," << endl
-         << "for example:" << endl
-         << endl
-         << ">20_233255_LEFT" << endl
-         << "CCATTGTATATATAGACCATAATTTCTTTATCCAATCATCTGTTGATGGA" << endl
-         << ">20_233255_RIGHT" << endl
-         << "ACTCAGTTGATTCCATACCTTTGCCATCATGAATCATGTTGTAATAAACA" << endl
-         << endl;
-    exit(0);
-}
-
-
-int main(int argc, char** argv) {
-
-    int c;
-    string fastaRef;
-    int primerLength = 0;
-
-    if (argc == 1)
-        printSummary(argv);
-
-    while (true) {
-        static struct option long_options[] =
-        {
-            /* These options set a flag. */
-            //{"verbose", no_argument,       &verbose_flag, 1},
-            {"help", no_argument, 0, 'h'},
-            {"fasta-reference",  required_argument, 0, 'f'},
-            {"primer-length", required_argument, 0, 'l'},
-            //{"length",  no_argument, &printLength, true},
-            {0, 0, 0, 0}
-        };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "hf:l:",
-                         long_options, &option_index);
-
-      /* Detect the end of the options. */
-          if (c == -1)
-            break;
- 
-          switch (c)
-            {
-            case 0:
-            /* If this option set a flag, do nothing else now. */
-            if (long_options[option_index].flag != 0)
-              break;
-            printf ("option %s", long_options[option_index].name);
-            if (optarg)
-              printf (" with arg %s", optarg);
-            printf ("\n");
-            break;
-
-          case 'f':
-            fastaRef = optarg;
-            break;
-
-          case 'l':
-            primerLength = atoi(optarg);
-            break;
- 
-          case 'h':
-            printSummary(argv);
-            exit(0);
-            break;
-
-          case '?':
-            /* getopt_long already printed an error message. */
-            printSummary(argv);
-            exit(1);
-            break;
- 
-          default:
-            abort ();
-          }
-      }
-
-    if (primerLength == 0) {
-        cerr << "a primer length must be specified" << endl;
-        exit(1);
-    }
-    if (fastaRef.empty()) {
-        cerr << "a FASTA reference sequence must be specified" << endl;
-        exit(1);
-    }
-
-    FastaReference ref;
-    ref.open(fastaRef);
-
-    VariantCallFile variantFile;
-    string inputFilename;
-    if (optind == argc - 1) {
-        inputFilename = argv[optind];
-        variantFile.open(inputFilename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-        // get the ref start and end positions
-        int refstart = var.position - 1; // convert to 0-based
-        int refend = var.position + var.ref.size() - 1;
-        string leftprimer = ref.getSubSequence(var.sequenceName, refstart - primerLength, primerLength);
-        string rightprimer = ref.getSubSequence(var.sequenceName, refend, primerLength);
-        //cout << var << endl;
-        cout << ">" << var.sequenceName << "_" << var.position << "_LEFT" << endl
-             << leftprimer << endl
-             << ">" << var.sequenceName << "_" << var.position << "_RIGHT" << endl
-             << rightprimer << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfrandom.cpp b/vcflib/src/vcfrandom.cpp
deleted file mode 100644
index debab84..0000000
--- a/vcflib/src/vcfrandom.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-#include <sstream>
-#include <stdlib.h>
-#include <time.h>
-#include "Variant.h"
-#include <cmath>
-
-using namespace std;
-using namespace vcf;
-
-int main(int argc, char** argv) {
-
-    VariantCallFile variantFile;
-
-    stringstream headerss;
-    headerss << "##fileformat=VCFv4.0" << endl
-             << "##source=vcfrandom" << endl
-             << "##reference=/d2/data/references/build_37/human_reference_v37.fa" << endl
-             << "##phasing=none" << endl
-             << "##INFO=<ID=NS,Number=1,Type=Integer,Description=\"Number of samples with data\">" << endl
-             << "##INFO=<ID=DP,Number=1,Type=Integer,Description=\"Total read depth at the locus\">" << endl
-             << "##INFO=<ID=AC,Number=1,Type=Integer,Description=\"Total number of alternate alleles in called genotypes\">" << endl
-             << "##INFO=<ID=AN,Number=1,Type=Integer,Description=\"Total number of alleles in called genotypes\">" << endl
-             << "##INFO=<ID=AF,Number=1,Type=Float,Description=\"Estimated allele frequency in the range (0,1]\">" << endl
-             << "##FORMAT=<ID=GT,Number=1,Type=String,Description=\"Genotype\">" << endl
-             << "##FORMAT=<ID=GQ,Number=1,Type=Integer,Description=\"Genotype Quality, the Phred-scaled marginal (or unconditional) probability of the called genotype\">" << endl
-             << "##FORMAT=<ID=DP,Number=1,Type=Integer,Description=\"Read Depth\">" << endl
-             << "#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tbill";
-
-    string header = headerss.str();
-    variantFile.openForOutput(header);
-
-    cout << variantFile.header << endl;
-
-    srand(time(NULL));
-
-    vector<string> atgc;
-    atgc.push_back("A");
-    atgc.push_back("T");
-    atgc.push_back("G");
-    atgc.push_back("C");
-
-    for (int i = 1; i < 10; ++i) {
-        Variant var(variantFile);
-        var.sequenceName = "one";
-        var.id = ".";
-        var.filter = ".";
-        var.ref = atgc.at(rand() % 4);
-        var.quality = 100;
-        stringstream s;
-        s << rand() % 100;
-        var.info["DP"].push_back(s.str());
-        var.format.push_back("GT");
-        var.format.push_back("DP");
-        var.position = i;
-        for (vector<string>::iterator s = var.sampleNames.begin(); s != var.sampleNames.end(); ++s) {
-            string& name = *s;
-            var.alt.clear();
-            var.alt.push_back(atgc.at(rand() % 4));
-            var.alt.push_back(atgc.at(rand() % 4));
-            var.samples[name]["GT"].push_back("0/1");
-            stringstream dp;
-            dp << floor(rand() % 100);
-            var.samples[name]["DP"].push_back(dp.str());
-        }
-        cout << var << endl;
-    }
-
-    return 0;
-
-}
diff --git a/vcflib/src/vcfrandomsample.cpp b/vcflib/src/vcfrandomsample.cpp
deleted file mode 100644
index 3cc565b..0000000
--- a/vcflib/src/vcfrandomsample.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-#include "Variant.h"
-#include "BedReader.h"
-#include <getopt.h>
-#include "mt19937ar.h"
-#include <sstream>
-#include <iostream>
-#include "convert.h"
-
-using namespace std;
-using namespace vcf;
-
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [options] [<vcf file>]" << endl
-         << endl
-         << "options:" << endl 
-         << "    -r, --rate RATE          base sampling probability per locus" << endl
-         << "    -s, --scale-by KEY       scale sampling likelihood by this Float info field" << endl
-         << "    -p, --random-seed N      use this random seed (by default read from /dev/random)" << endl
-         << "    -q, --pseudorandom-seed  use a pseudorandom seed (by default read from /dev/random)" << endl
-         << endl
-         << "Randomly sample sites from an input VCF file, which may be provided as stdin." << endl
-         << "Scale the sampling probability by the field specified in KEY.  This may be" << endl
-         << "used to provide uniform sampling across allele frequencies, for instance." << endl;
-    exit(0);
-}
-
-int main(int argc, char** argv) {
-
-    double rate = 1.0;
-    int seed = 0;
-    bool useprng = false;
-    string scaleByKey;
-
-    if (argc == 1)
-        printSummary(argv);
-
-    int c;
-    while (true) {
-        static struct option long_options[] =
-            {
-                {"help", no_argument, 0, 'h'},
-                {"rate",  required_argument, 0, 'r'},
-                {"scale-by",  required_argument, 0, 's'},
-                {"random-seed",  required_argument, 0, 'p'},
-                {"pseudorandom-seed",  required_argument, 0, 'q'},
-                {0, 0, 0, 0}
-            };
-
-        int option_index = 0;
-        c = getopt_long (argc, argv, "hqr:s:p:",
-                         long_options, &option_index);
-
-        if (c == -1)
-            break;
-
-        switch (c) {
-        case 'r':
-            rate = atof(optarg);
-            break;
-
-        case 's':
-            scaleByKey = optarg;
-            break;
-
-        case 'p':
-            seed = atoi(optarg);
-            break;
-
-        case 'q':
-            useprng = true;
-            break;
-
-        case 'h':
-            printSummary(argv);
-            break;
-
-        case '?':
-            printSummary(argv);
-            exit(1);
-            break;
-
-        default:
-            abort ();
-        }
-    }
-
-    VariantCallFile variantFile;
-    string inputFilename;
-    if (optind == argc - 1) {
-        inputFilename = argv[optind];
-        variantFile.open(inputFilename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        cout << "could not open VCF file" << endl;
-        return 1;
-    }
-
-    // seed prng with random bits from /dev/random
-    if (!seed) {
-        fstream random;
-        if (useprng) {
-            random.open("/dev/urandom", fstream::in);
-        } else {
-            random.open("/dev/random", fstream::in);
-        }
-        random.get((char*) &seed, sizeof(int));
-        random.close();
-    }
-
-    init_genrand(seed);
-
-    vector<string> args;
-    for (int i = 0; i < argc; ++i) {
-        args.push_back(argv[i]);
-    }
-
-    stringstream liness;
-    liness << "##sampling=\"random sampling using "
-           << join(args, " ")
-           << " using random seed "
-           << seed << "\"";
-    variantFile.addHeaderLine(liness.str());
-
-    cout << variantFile.header << endl;
-    
-    // check that we can use the scaling key
-    if (!scaleByKey.empty()) {
-        if (variantFile.infoTypes.find(scaleByKey) == variantFile.infoTypes.end()) {
-            cerr << "could not find info key " << scaleByKey << endl;
-            exit(1);
-        } else {
-            if (variantFile.infoTypes[scaleByKey] != FIELD_FLOAT) {
-                cerr << "cannot use " << scaleByKey << " as a scaling factor, as it is not of type Float" << endl;
-                exit(1);
-            }
-        }
-    }
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-        double randN = genrand_real1();
-        if (!scaleByKey.empty()) {
-            if (var.info.find(scaleByKey) != var.info.end()) {
-                double val;
-
-                // hack, sum the values of interest if we have multiple values
-                // really, this is only suitable for AF stuff
-                vector<string>& vals = var.info[scaleByKey];
-                for (vector<string>::iterator b = vals.begin(); b != vals.end(); ++b) {
-                    double f;
-                    convert(*b, f);
-                    val += f;
-                }
-                val /= vals.size();
-
-                if (val > 1) {
-                    cerr << "cannot scale by " << scaleByKey << "=" << val << " as it is > 1" << endl;
-                    exit(1);
-                }
-                randN *= val;
-            }
-        }
-        if (randN < rate) {
-            cout << var << endl;
-        }
-    }
-
-    return 0;
-
-}
diff --git a/vcflib/src/vcfremap.cpp b/vcflib/src/vcfremap.cpp
deleted file mode 100644
index 82c9997..0000000
--- a/vcflib/src/vcfremap.cpp
+++ /dev/null
@@ -1,350 +0,0 @@
-#include "Variant.h"
-#include "BedReader.h"
-#include "intervaltree/IntervalTree.h"
-#include <getopt.h>
-#include "fastahack/Fasta.h"
-#include <algorithm>
-#include <list>
-#include <set>
-
-using namespace std;
-using namespace vcf;
-
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [options] [<vcf file>]" << endl
-         << endl
-         << "options:" << endl 
-         << "    -w, --ref-window-size N      align using this many bases flanking each side of the reference allele" << endl
-         << "    -s, --alt-window-size N      align using this many flanking bases from the reference around each alternate allele" << endl
-         << "    -r, --reference FILE         FASTA reference file, required with -i and -u" << endl
-         << "    -m, --match-score N          match score for SW algorithm" << endl
-         << "    -x, --mismatch-score N       mismatch score for SW algorithm" << endl
-         << "    -o, --gap-open-penalty N     gap open penalty for SW algorithm" << endl
-         << "    -e, --gap-extend-penalty N   gap extension penalty for SW algorithm" << endl
-         << "    -z, --entropy-gap-open       use entropy scaling for the gap open penalty" << endl
-         << "    -R, --repeat-gap-extend N    penalize non-repeat-unit gaps in repeat sequence" << endl
-         << "    -a, --adjust-vcf TAG         supply a new cigar as TAG in the output VCF" << endl
-         << endl
-         << "For each alternate allele, attempt to realign against the reference with lowered gap open penalty." << endl
-         << "If realignment is possible, adjust the cigar and reference/alternate alleles." << endl;
-    exit(0);
-}
-
-int main(int argc, char** argv) {
-
-    string vcfFileName;
-    string fastaFileName;
-    int windowsize = 100;
-    bool includePreviousBaseForIndels = false;
-    bool useMNPs = true;
-    int altwindowsize = 50;
-
-    // constants for SmithWaterman algorithm
-    float matchScore = 10.0f;
-    float mismatchScore = -9.0f;
-    float gapOpenPenalty = 15.0f;
-    float gapExtendPenalty = 6.66f;
-
-    bool useEntropy = false;
-    bool useRepeatGapExtendPenalty = false;
-    float repeatGapExtendPenalty = 1;
-
-    bool adjustVcf = false;
-    string adjustedTag = "remappedCIGAR";
-
-    if (argc == 1)
-        printSummary(argv);
-
-    int c;
-    while (true) {
-        static struct option long_options[] =
-            {
-                /* These options set a flag. */
-                //{"verbose", no_argument,       &verbose_flag, 1},
-                {"help", no_argument, 0, 'h'},
-                {"ref-window-size", required_argument, 0, 'w'},
-                {"reference", required_argument, 0, 'r'},
-                {"match-score", required_argument, 0, 'm'},
-                {"mismatch-score", required_argument, 0, 'x'},
-                {"gap-open-penalty", required_argument, 0, 'o'},
-                {"gap-extend-penalty", required_argument, 0, 'e'},
-                {"alt-window-size", required_argument, 0, 's'},
-                {"entropy-gap-open", no_argument, 0, 'z'},
-                {"repeat-gap-extend", no_argument, 0, 'R'},
-                {"adjust-vcf", required_argument, 0, 'a'},
-                {0, 0, 0, 0}
-            };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "hza:w:r:m:x:o:e:s:R:",
-                         long_options, &option_index);
-
-        if (c == -1)
-            break;
-
-        switch (c) {
-
-	    case 'w':
-            windowsize = atoi(optarg);
-            break;
-
-	    case 'a':
-	        adjustVcf = true;
-            adjustedTag = optarg;
-            break;
-
-	    case 'r':
-            fastaFileName = string(optarg);
-            break;
-
-        case 'h':
-            printSummary(argv);
-            break;
-
-	    case 'm':
-            matchScore = atof(optarg);
-	        break;
-
-	    case 'x':
-            mismatchScore = atof(optarg);
-	        break;
-
-	    case 'o':
-            gapOpenPenalty = atof(optarg);
-	        break;
-
-	    case 'e':
-            gapExtendPenalty = atof(optarg);
-	        break;
-
-	    case 's':
-            altwindowsize = atoi(optarg);
-            break;
-
-	    case 'z':
-            useEntropy = true;
-            break;
-
-	    case 'R':
-            useRepeatGapExtendPenalty = true;
-            repeatGapExtendPenalty = atof(optarg);
-            break;
-
-        case '?':
-            printSummary(argv);
-            exit(1);
-            break;
-
-        default:
-            abort ();
-        }
-    }
-
-    VariantCallFile variantFile;
-    string inputFilename;
-    if (optind == argc - 1) {
-        inputFilename = argv[optind];
-        variantFile.open(inputFilename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        cerr << "could not open VCF file" << endl;
-        exit(1);
-    }
-
-    FastaReference freference;
-    if (fastaFileName.empty()) {
-        cerr << "a reference is required" << endl;
-        exit(1);
-    } else {
-        freference.open(fastaFileName);
-    }
-    
-    if (adjustVcf) {
-        vector<string> commandline;
-        for (int i = 0; i < argc; ++i)
-            commandline.push_back(argv[i]);
-        variantFile.addHeaderLine("##INFO=<ID=" + adjustedTag + ",Number=A,Type=String,Description=\"CIGAR when remapped using"+ join(commandline, " ") +"\">");
-    }
-
-    cout << variantFile.header << endl;
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-        //if (!adjustVcf) {
-	    cout << endl;
-	    cout << var << endl;
-	    //}
-        map<string, vector<VariantAllele> > variantAlleles;
-        vector<vector<pair<int, char> > > cigars;
-        vector<int> positionDiffs;
-        for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-            //if (!adjustVcf) cout << endl;
-            cout << endl;
-
-            // try to remap locally
-
-            string reference = freference.getSubSequence(var.sequenceName, var.position - 1 - windowsize, windowsize * 2 + var.ref.size());
-	    
-            // passed to sw align
-            unsigned int referencePos;
-            string cigar;
-
-            string& alternate = *a;
-
-            vector<VariantAllele>& variants = variantAlleles[alternate];
-
-            string alternateQuery = reference.substr(windowsize - altwindowsize, altwindowsize) + alternate + reference.substr(reference.size() - windowsize, altwindowsize);
-
-            //cout << "REF:\t" << reference << endl;
-            //cout << "ALT:\t" << string(windowsize - altwindowsize, ' ') << alternateQuery << endl;
-	    
-            CSmithWatermanGotoh sw(matchScore, mismatchScore, gapOpenPenalty, gapExtendPenalty);
-            if (useEntropy) sw.EnableEntropyGapPenalty(1);
-            if (useRepeatGapExtendPenalty) sw.EnableRepeatGapExtensionPenalty(repeatGapExtendPenalty);
-            sw.Align(referencePos, cigar, reference, alternateQuery);
-
-            int altpos = 0;
-            int refpos = 0;
-            int len;
-            string slen;
-            vector<pair<int, char> > cigarData;
-
-            string ref = reference.substr(referencePos);
-            positionDiffs.push_back(referencePos); // TODO this... is borked
-
-            stringstream refss;
-            stringstream altss;
-
-            if (!adjustVcf) cout << cigar << endl;
-            cout << cigar << endl;
-            for (string::iterator c = cigar.begin(); c != cigar.end(); ++c) {
-                switch (*c) {
-                case 'I':
-                    len = atoi(slen.c_str());
-                    slen.clear();
-                    if (altpos < altwindowsize) {
-                        cigarData.push_back(make_pair(len, 'M'));
-                    } else {
-                        cigarData.push_back(make_pair(len, *c));
-                    }
-                    altss << alternateQuery.substr(altpos, len);
-                    refss << string(len, '-');
-                    altpos += len;
-                    break;
-                case 'D':
-                    len = atoi(slen.c_str());
-                    slen.clear();
-                    if (altpos < altwindowsize) {
-                    } else {
-                        cigarData.push_back(make_pair(len, *c));
-                    }
-                    refss << ref.substr(refpos, len);
-                    altss << string(len, '-');
-                    refpos += len;
-                    break;
-                case 'M':
-                    len = atoi(slen.c_str());
-                    slen.clear();
-                    {
-                        for (int i = 0; i < len; ++i) {
-                            if (ref.at(refpos + i) == alternateQuery.at(altpos + i)) {
-                                if (!cigarData.empty() && cigarData.back().second == 'M') {
-                                    cigarData.back().first++;
-                                } else {
-                                    cigarData.push_back(make_pair(1, 'M'));
-                                }
-                            } else {
-                                if (!cigarData.empty() && cigarData.back().second == 'X') {
-                                    cigarData.back().first++;
-                                } else {
-                                    cigarData.push_back(make_pair(1, 'X'));
-                                }
-                            }
-                        }
-                    }
-                    refss << ref.substr(refpos, len);
-                    altss << alternateQuery.substr(altpos, len);
-                    refpos += len;
-                    altpos += len;
-                    break;
-                case 'S':
-                    len = atoi(slen.c_str());
-                    slen.clear();
-                    cigarData.push_back(make_pair(len, *c));
-                    refss << ref.substr(refpos, len);
-                    //altss << alternateQuery.substr(altpos, len); // TODO deal with soft clipping, weird behavior
-                    refpos += len;
-                    altpos += len;
-                    break;
-                default:
-                    len = 0;
-                    slen += *c;
-                    break;
-                }
-            }
-
-            if (!adjustVcf) {
-                cout << "ref:\t" << refss.str() << endl;
-                cout << "alt:\t" << altss.str() << endl;
-            } else {
-                cout << "ref:\t" << refss.str() << endl;
-                cout << "alt:\t" << altss.str() << endl;
-                cigars.push_back(cigarData);
-            }
-
-        }
-
-        if (adjustVcf) {
-            int substart = cigars.front().front().first;
-            int subend = cigars.front().back().first;
-
-            // find the min and max match
-            for (vector<vector<pair<int, char> > >::iterator c = cigars.begin(); c != cigars.end(); ++c) {
-                if (c->front().second == 'M' && c->front().first <= substart) {
-                    substart = c->front().first;
-                    if (c->size() > 1 && c->at(1).second != 'X') {
-                        --substart;
-                    }
-                }
-                if (c->back().second == 'M' && c->back().first <= subend) {
-                    subend = c->back().first;
-                }
-            }
-	    
-            // adjust the cigars and get the new reference length
-            int reflen = 0;
-            for (vector<vector<pair<int, char> > >::iterator c = cigars.begin(); c != cigars.end(); ++c) {
-                c->front().first -= substart;
-                c->back().first -= subend;
-                int crf = cigarRefLen(*c);
-                if (crf > reflen)
-                    reflen = crf;
-                var.info[adjustedTag].push_back(joinCigar(*c));
-            }
-
-            // find the lowest positional difference
-            int pdiff = 0;
-            for (vector<int>::iterator d = positionDiffs.begin(); d != positionDiffs.end(); ++d) {
-                if (*d + altwindowsize < pdiff)
-                    pdiff = *d + altwindowsize;
-            }
-
-            // adjust the reference string
-            var.position += pdiff;
-
-            // adjust the variant position
-            var.ref = freference.getSubSequence(var.sequenceName, var.position - 1, reflen);
-
-            cout << var << endl;
-        }
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfremoveaberrantgenotypes.cpp b/vcflib/src/vcfremoveaberrantgenotypes.cpp
deleted file mode 100644
index 75ebc32..0000000
--- a/vcflib/src/vcfremoveaberrantgenotypes.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include <string>
-#include <sstream>
-#include <iostream>
-
-using namespace std;
-using namespace vcf;
-
-void stripAberrant(Variant& var) {
-    map<string, map<string, vector<string> > >::iterator s = var.samples.begin();
-    while (s != var.samples.end()) {
-        map<string, vector<string> >& sample = s->second;
-        map<int, int> genotype = decomposeGenotype(sample["GT"].front());
-        int refobs = 0;
-        convert(sample["RO"].front(), refobs);
-        if (isHomNonRef(genotype) && refobs > 0) {
-            var.samples.erase(s);
-        } else if (isHomRef(genotype)) {
-            for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-                int alleleIndex = var.altAlleleIndexes[*a];
-                int altobs = 0;
-                convert(sample["AO"].at(alleleIndex), altobs);
-                if (altobs > 0) {
-                    var.samples.erase(s);
-                    break;
-                }
-            }
-        }
-        ++s;
-    }
-}
-
-int main(int argc, char** argv) {
-
-    if (argc != 2) {
-        cerr << "usage: " << argv[0] << " <vcf file>" << endl
-             << "strips samples which are homozygous but have observations implying heterozygosity" << endl;
-        return 1;
-    }
-
-    string filename = argv[1];
-
-    VariantCallFile variantFile;
-    if (filename == "-") {
-        variantFile.open(std::cin);
-    } else {
-        variantFile.open(filename);
-    }
-
-    if (!variantFile.is_open()) {
-        cerr << "could not open " << filename << endl;
-        return 1;
-    }
-
-    Variant var(variantFile);
-
-    // TODO check if AC is present
-    // ensure that AC is listed as an info field
-    string line = "##filter=\"removed homozygous genotypes which have observations implying heterozygosity\">";
-    variantFile.addHeaderLine(line);
-
-    // write the new header
-    cout << variantFile.header << endl;
- 
-    // print the records, filtering is done via the setting of varA's output sample names
-    while (variantFile.getNextVariant(var)) {
-        stripAberrant(var);
-        cout << var << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfremovesamples.cpp b/vcflib/src/vcfremovesamples.cpp
deleted file mode 100644
index b4b31df..0000000
--- a/vcflib/src/vcfremovesamples.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include <string>
-#include <iostream>
-
-using namespace std;
-using namespace vcf;
-
-// remove elements in a from b
-template<class T>
-vector<T> removeElems(vector<T>& a, vector<T>& b) {
-    map<T, bool> inA;
-    map<T, bool> inAB;
-    for (typename vector<T>::iterator i = a.begin(); i != a.end(); ++i) {
-        inA[*i] = true;
-    }
-    for (typename vector<T>::iterator i = b.begin(); i != b.end(); ++i) {
-        if (inA.find(*i) == inA.end()) {
-            inAB[*i] = true;
-        }
-    }
-    vector<T> aNb;
-    for (typename map<T, bool>::iterator i = inAB.begin(); i != inAB.end(); ++i) {
-        aNb.push_back(i->first);
-    }
-    return aNb;
-}
-
-int main(int argc, char** argv) {
-
-    if (argc < 3) {
-        cerr << "usage: " << argv[0] << " <vcf file> [SAMPLE1] [SAMPLE2] ..." << endl
-             << "outputs each record in the vcf file, removing samples listed on the command line" << endl;
-        return 1;
-    }
-
-    string filename = argv[1];
-
-    vector<string> samplesToRemove;
-    for (int i = 2; i < argc; ++i) {
-        samplesToRemove.push_back(argv[i]);
-    }
-
-    VariantCallFile variantFile;
-    if (filename == "-") {
-        variantFile.open(std::cin);
-    } else {
-        variantFile.open(filename);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    Variant var(variantFile);
-
-    vector<string> samplesToKeep = removeElems(samplesToRemove, variantFile.sampleNames);
-
-    // update sample list in header
-    variantFile.updateSamples(samplesToKeep);
-
-    // and restrict the output sample names in the variant to those we are keeping
-    var.setOutputSampleNames(samplesToKeep);
-    
-    // write the new header
-    cout << variantFile.header << endl;
- 
-    // print the records, filtering is done via the setting of varA's output sample names
-    while (variantFile.getNextVariant(var)) {
-        cout << var << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfroc.cpp b/vcflib/src/vcfroc.cpp
deleted file mode 100644
index c8d5dc7..0000000
--- a/vcflib/src/vcfroc.cpp
+++ /dev/null
@@ -1,469 +0,0 @@
-#include "Variant.h"
-#include "BedReader.h"
-#include "intervaltree/IntervalTree.h"
-#include <getopt.h>
-#include "fastahack/Fasta.h"
-#include <algorithm>
-#include <list>
-#include <set>
-
-using namespace std;
-using namespace vcf;
-
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [options] [<vcf file>]" << endl
-         << endl
-         << "options:" << endl 
-         << "    -t, --truth-vcf FILE      use this VCF as ground truth for ROC generation" << endl
-         << "    -w, --window-size N       compare records up to this many bp away (default 30)" << endl
-         << "    -c, --complex             directly compare complex alleles, don't parse into primitives" << endl
-         << "    -r, --reference FILE      FASTA reference file" << endl
-         << endl
-         << "Generates a pseudo-ROC curve using sensitivity and specificity estimated against" << endl
-         << "a putative truth set.  Thresholding is provided by successive QUAL cutoffs." << endl;
-    exit(0);
-}
-
-void buildVariantIntervalTree(VariantCallFile& variantFile,
-                              map<string, IntervalTree<Variant*> >& variantIntervals,
-                              list<Variant>& variants) {
-
-    map<string, vector<Interval<Variant*> > > rawVariantIntervals;
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-        long int left = var.position;
-        long int right = left + var.ref.size(); // this should be 1-past the end
-        variants.push_back(var);
-        Variant* v = &variants.back();
-        rawVariantIntervals[var.sequenceName].push_back(Interval<Variant*>(left, right, v));
-    }
-	
-    for (map<string, vector<Interval<Variant*> > >::iterator j = rawVariantIntervals.begin(); j != rawVariantIntervals.end(); ++j) {
-        variantIntervals[j->first] = IntervalTree<Variant*>(j->second);
-    }
-}
-
-
-void intersectVariant(Variant& var,
-                      map<string, IntervalTree<Variant*> >& variantIntervals,
-                      vector<string*>& commonAlleles,
-                      vector<string*>& uniqueAlleles,
-                      FastaReference& reference,
-                      int windowsize = 50) {
-
-    vector<Interval<Variant*> > results;
-
-    variantIntervals[var.sequenceName].findContained(var.position - windowsize, var.position + var.ref.size() + windowsize, results);
-
-    vector<Variant*> overlapping;
-
-    for (vector<Interval<Variant*> >::iterator r = results.begin(); r != results.end(); ++r) {
-        overlapping.push_back(r->value);
-    }
-
-
-    if (overlapping.empty()) {
-        for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-            uniqueAlleles.push_back(&*a);
-        }
-    } else {
-
-        // get the min and max of the overlaps
-
-        int haplotypeStart = var.position;
-        int haplotypeEnd = var.position + var.ref.size();
-
-        for (vector<Variant*>::iterator v = overlapping.begin(); v != overlapping.end(); ++v) {
-            haplotypeStart = min((*v)->position, (long int) haplotypeStart);
-            haplotypeEnd = max((*v)->position + (*v)->ref.size(), (long unsigned int) haplotypeEnd);
-        }
-
-        // for everything overlapping and the current variant, construct the local haplotype within the bounds
-        // if there is an exact match, the allele in the current VCF does intersect
-
-        string referenceHaplotype = reference.getSubSequence(var.sequenceName, haplotypeStart - 1, haplotypeEnd - haplotypeStart);
-        map<string, vector<pair<Variant*, int> > > haplotypes; // map to variant and alt index
-
-        for (vector<Variant*>::iterator v = overlapping.begin(); v != overlapping.end(); ++v) {
-            Variant& variant = **v;
-            int altindex = 0;
-            for (vector<string>::iterator a = variant.alt.begin(); a != variant.alt.end(); ++a, ++altindex) {
-                string haplotype = referenceHaplotype;
-                // get the relative start and end coordinates for the variant alternate allele
-                int relativeStart = variant.position - haplotypeStart;
-                haplotype.replace(relativeStart, variant.ref.size(), *a);
-                haplotypes[haplotype].push_back(make_pair(*v, altindex));
-            }
-        }
-
-
-        // determine the non-intersecting alts
-        for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-            string haplotype = referenceHaplotype;
-            int relativeStart = var.position - haplotypeStart;
-            haplotype.replace(relativeStart, var.ref.size(), *a);
-            map<string, vector<pair<Variant*, int> > >::iterator h = haplotypes.find(haplotype);
-            if (h == haplotypes.end()) {
-                uniqueAlleles.push_back(&*a);
-            } else {
-                commonAlleles.push_back(&*a);
-            }
-        }
-
-    }
-}
-
-
-int main(int argc, char** argv) {
-
-    string truthVcfFileName;
-    string fastaFileName;
-    bool complex = false;
-    int windowsize = 30;
-
-    if (argc == 1)
-        printSummary(argv);
-
-    int c;
-    while (true) {
-        static struct option long_options[] =
-            {
-                /* These options set a flag. */
-                //{"verbose", no_argument,       &verbose_flag, 1},
-                {"help", no_argument, 0, 'h'},
-                {"window-size", required_argument, 0, 'w'},
-                {"reference", required_argument, 0, 'r'},
-                {"complex", required_argument, 0, 'c'},
-                {"truth-vcf", required_argument, 0, 't'},
-                {0, 0, 0, 0}
-            };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "hcw:r:t:",
-                         long_options, &option_index);
-
-        if (c == -1)
-            break;
-
-        switch (c) {
-
-	    case 'w':
-            windowsize = atoi(optarg);
-            break;
-
-	    case 'r':
-            fastaFileName = string(optarg);
-            break;
-
-	    case 't':
-	        truthVcfFileName = optarg;
-            break;
-
-        case 'c':
-            complex = true;
-            break;
-
-        case 'h':
-            printSummary(argv);
-            break;
-
-        case '?':
-            printSummary(argv);
-            exit(1);
-            break;
-
-        default:
-            abort ();
-        }
-    }
-
-    VariantCallFile variantFile;
-    bool usingstdin = false;
-    string inputFilename;
-    if (optind == argc - 1) {
-        inputFilename = argv[optind];
-        variantFile.open(inputFilename);
-    } else {
-        variantFile.open(std::cin);
-        usingstdin = true;
-    }
-
-    if (!variantFile.is_open()) {
-        cerr << "could not open VCF file" << endl;
-        exit(1);
-    }
-
-    VariantCallFile truthVariantFile;
-    if (!truthVcfFileName.empty()) {
-        if (truthVcfFileName == "-") {
-            if (usingstdin) {
-                cerr << "cannot open both VCF file streams from stdin" << endl;
-                exit(1);
-            } else {
-                truthVariantFile.open(std::cin);
-            }
-        } else {
-            truthVariantFile.open(truthVcfFileName);
-        }
-        if (!truthVariantFile.is_open()) {
-            cerr << "could not open VCF file " << truthVcfFileName << endl;
-            exit(1);
-        }
-    }
-
-    FastaReference reference;
-    if (fastaFileName.empty()) {
-        cerr << "a reference is required for the haplotype-based intersection used by vcfroc" << endl;
-        exit(1);
-    }
-    reference.open(fastaFileName);
-
-    // read the VCF file for union or intersection into an interval tree
-    // indexed using some proximity window
-
-    map<string, IntervalTree<Variant*> > truthVariantIntervals;
-    list<Variant> truthVariants;
-    buildVariantIntervalTree(truthVariantFile, truthVariantIntervals, truthVariants);
-
-    map<string, IntervalTree<Variant*> > testVariantIntervals;
-    list<Variant> testVariants;
-    buildVariantIntervalTree(variantFile, testVariantIntervals, testVariants);
-
-    map<long double, vector<VariantAllele*> > falseNegativeAllelesAtCutoff;  // false negative after this cutoff
-    map<long double, vector<VariantAllele*> > falsePositiveAllelesAtCutoff;  // false positive until this cutoff
-    list<VariantAllele*> allFalsePositiveAlleles;
-    map<long double, vector<VariantAllele*> > allelesAtCutoff;
-    //map<long double, vector<VariantAllele*> > totalAllelesAtCutoff;
-    map<Variant*, map<string, vector<VariantAllele> > > parsedAlleles;
-    map<long double, vector<Variant*> > callsByCutoff;
-
-    // replicate this method, where Q is for each unique Q in the set
-    //vcfintersect -r $reference -v -i $results.$Q.vcf $answers_primitives | vcfstats >false_negatives.$Q.stats
-    //vcfintersect -r $reference -v -i $answers_primitives $results.$Q.vcf | vcfstats >false_positives.$Q.stats
-
-    for (list<Variant>::iterator v = testVariants.begin(); v != testVariants.end(); ++v) {
-        // TODO allow different cutoffs
-        callsByCutoff[v->quality].push_back(&*v);
-    }
-
-    // add false negatives at any cutoff
-    for (list<Variant>::iterator v = truthVariants.begin(); v != truthVariants.end(); ++v) {
-        Variant& variant = *v;
-        vector<string*> commonAlleles;
-        vector<string*> uniqueAlleles;
-        intersectVariant(variant, testVariantIntervals,
-                         commonAlleles, uniqueAlleles, reference);
-        if (complex) {
-            parsedAlleles[&*v] = variant.flatAlternates();
-        } else {
-            parsedAlleles[&*v] = variant.parsedAlternates();
-        }
-        // unique alleles are false negatives regardless of cutoff
-        for (vector<string*>::iterator a = uniqueAlleles.begin(); a != uniqueAlleles.end(); ++a) {
-            vector<VariantAllele>& alleles = parsedAlleles[&*v][**a];
-            for (vector<VariantAllele>::iterator va = alleles.begin(); va != alleles.end(); ++va) {
-                if (va->ref != va->alt) { 		// use only non-reference alleles
-                    // false negatives at threshold 0 XXX --- may not apply if threshold is generalized
-                    falseNegativeAllelesAtCutoff[-1].push_back(&*va);
-                }
-            }
-        }
-    }
-
-    for (map<long double, vector<Variant*> >::iterator q = callsByCutoff.begin(); q != callsByCutoff.end(); ++q) {
-        long double threshold = q->first;
-        vector<Variant*>& variants = q->second;
-        for (vector<Variant*>::iterator v = variants.begin(); v != variants.end(); ++v) {
-            Variant& variant = **v;
-            vector<string*> commonAlleles;
-            vector<string*> uniqueAlleles;
-            intersectVariant(variant, truthVariantIntervals,
-                             commonAlleles, uniqueAlleles, reference);
-            if (complex) {
-                parsedAlleles[*v] = variant.flatAlternates();
-            } else {
-                parsedAlleles[*v] = variant.parsedAlternates();
-            }
-
-            map<string, vector<VariantAllele> >& parsedAlts = parsedAlleles[*v];
-            // push VariantAllele*'s into the FN and FP alleles at cutoff vectors
-            for (vector<string*>::iterator a = commonAlleles.begin(); a != commonAlleles.end(); ++a) {
-                vector<VariantAllele>& alleles = parsedAlleles[*v][**a];
-                for (vector<VariantAllele>::iterator va = alleles.begin(); va != alleles.end(); ++va) {
-                    if (va->ref != va->alt) { 		// use only non-reference alleles
-                        allelesAtCutoff[threshold].push_back(&*va);
-                        falseNegativeAllelesAtCutoff[threshold].push_back(&*va);
-                    }
-                }
-            }
-            for (vector<string*>::iterator a = uniqueAlleles.begin(); a != uniqueAlleles.end(); ++a) {
-                vector<VariantAllele>& alleles = parsedAlts[**a];
-                for (vector<VariantAllele>::iterator va = alleles.begin(); va != alleles.end(); ++va) {
-                    if (va->ref != va->alt) { 		// use only non-reference alleles
-                        allelesAtCutoff[threshold].push_back(&*va);
-                        allFalsePositiveAlleles.push_back(&*va);
-                        falsePositiveAllelesAtCutoff[threshold].push_back(&*va);
-                    }
-                }
-            }
-        }
-    }
-
-
-    // output results
-    int totalSNPs = 0;
-    int falsePositiveSNPs = 0;
-    int falseNegativeSNPs = 0;
-    int totalIndels = 0;
-    int falsePositiveIndels = 0;
-    int falseNegativeIndels = 0;
-    int totalComplex = 0;
-    int falsePositiveComplex = 0;
-    int falseNegativeComplex = 0;
-
-    // write header
-    
-    cout << "threshold" << "\t"
-         << "num_snps" << "\t"
-         << "false_positive_snps" << "\t"
-         << "false_negative_snps" << "\t"
-         << "num_indels" << "\t"
-         << "false_positive_indels" << "\t"
-         << "false_negative_indels" << "\t"
-         << "num_complex" << "\t"
-         << "false_positive_complex" << "\t"
-         << "false_negative_complex" << endl;
-
-    // count total alleles in set
-    for (map<long double, vector<VariantAllele*> >::iterator a = allelesAtCutoff.begin(); a != allelesAtCutoff.end(); ++a) {
-        vector<VariantAllele*>& alleles = a->second;
-        for (vector<VariantAllele*>::iterator va = alleles.begin(); va != alleles.end(); ++va) {
-            VariantAllele& allele = **va;
-            if (allele.ref.size() == 1 && allele.ref.size() == allele.alt.size()) {
-                ++totalSNPs;
-            } else if (allele.ref.size() != allele.alt.size()) {
-                if (allele.ref.size() == 1 || allele.alt.size() == 1) {
-                    ++totalIndels;
-                } else {
-                    ++totalComplex;
-                }
-            } else {
-                ++totalComplex;
-            }
-        }
-    }
-
-    // tally total false positives
-    for (list<VariantAllele*>::iterator va = allFalsePositiveAlleles.begin(); va != allFalsePositiveAlleles.end(); ++va) {
-        VariantAllele& allele = **va;
-        if (allele.ref.size() == 1 && allele.ref.size() == allele.alt.size()) {
-            ++falsePositiveSNPs;
-        } else if (allele.ref.size() != allele.alt.size()) {
-            if (allele.ref.size() == 1 || allele.alt.size() == 1) {
-                ++falsePositiveIndels;
-            } else {
-                ++falsePositiveComplex;
-            }
-        } else {
-            ++falsePositiveComplex;
-        }
-    }
-
-    // get categorical false negatives
-    vector<VariantAllele*>& categoricalFalseNegatives = falseNegativeAllelesAtCutoff[-1];
-    for (vector<VariantAllele*>::iterator va = categoricalFalseNegatives.begin(); va != categoricalFalseNegatives.end(); ++va) {
-        VariantAllele& allele = **va;
-        if (allele.ref.size() == 1 && allele.ref.size() == allele.alt.size()) {
-            assert(allele.ref.size() == 1);
-            ++falseNegativeSNPs;
-        } else if (allele.ref.size() != allele.alt.size()) {
-            if (allele.ref.size() == 1 || allele.alt.size() == 1) {
-                ++falseNegativeIndels;
-            } else {
-                ++falseNegativeComplex;
-            }
-        } else {
-            ++falseNegativeComplex;
-        }
-    }
-    cout << -1 << "\t"
-         << totalSNPs << "\t"
-         << falsePositiveSNPs << "\t"
-         << falseNegativeSNPs << "\t"
-         << totalIndels << "\t"
-         << falsePositiveIndels << "\t"
-         << falseNegativeIndels << "\t"
-         << totalComplex << "\t"
-         << falsePositiveComplex << "\t"
-         << falseNegativeComplex << endl;
-
-    for (map<long double, vector<VariantAllele*> >::iterator a = allelesAtCutoff.begin(); a != allelesAtCutoff.end(); ++a) {
-        vector<VariantAllele*>& alleles = a->second;
-        long double threshold = a->first;
-        for (vector<VariantAllele*>::iterator va = alleles.begin(); va != alleles.end(); ++va) {
-            VariantAllele& allele = **va;
-            if (allele.ref.size() == 1 && allele.ref.size() == allele.alt.size()) {
-                assert(allele.ref.size() == 1);
-                --totalSNPs;
-            } else if (allele.ref.size() != allele.alt.size()) {
-                if (allele.ref.size() == 1 || allele.alt.size() == 1) {
-                    --totalIndels;
-                } else {
-                    --totalComplex;
-                }
-            } else {
-                --totalComplex;
-            }   
-        }
-        vector<VariantAllele*>& falseNegatives = falseNegativeAllelesAtCutoff[threshold];
-        for (vector<VariantAllele*>::iterator va = falseNegatives.begin(); va != falseNegatives.end(); ++va) {
-            VariantAllele& allele = **va;
-            if (allele.ref.size() == 1 && allele.ref.size() == allele.alt.size()) {
-                assert(allele.ref.size() == 1);
-                ++falseNegativeSNPs;
-            } else if (allele.ref.size() != allele.alt.size()) {
-                if (allele.ref.size() == 1 || allele.alt.size() == 1) {
-                    ++falseNegativeIndels;
-                } else {
-                    ++falseNegativeComplex;
-                }
-            } else {
-                ++falseNegativeComplex;
-            }
-        }
-        vector<VariantAllele*>& falsePositives = falsePositiveAllelesAtCutoff[threshold];
-        for (vector<VariantAllele*>::iterator va = falsePositives.begin(); va != falsePositives.end(); ++va) {
-            VariantAllele& allele = **va;
-            if (allele.ref.size() == 1 && allele.ref.size() == allele.alt.size()) {
-                assert(allele.ref.size() == 1);
-                --falsePositiveSNPs;
-            } else if (allele.ref.size() != allele.alt.size()) {
-                if (allele.ref.size() == 1 || allele.alt.size() == 1) {
-                    --falsePositiveIndels;
-                } else {
-                    --falsePositiveComplex;
-                }
-            } else {
-                --falsePositiveComplex;
-            }
-        }
-        cout << threshold << "\t"
-             << totalSNPs << "\t"
-             << falsePositiveSNPs << "\t"
-             << falseNegativeSNPs << "\t"
-             << totalIndels << "\t"
-             << falsePositiveIndels << "\t"
-             << falseNegativeIndels << "\t"
-             << totalComplex << "\t"
-             << falsePositiveComplex << "\t"
-             << falseNegativeComplex << endl;
-
-    }
-    
-    exit(0);  // why?
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfsamplediff.cpp b/vcflib/src/vcfsamplediff.cpp
deleted file mode 100644
index 6b9914c..0000000
--- a/vcflib/src/vcfsamplediff.cpp
+++ /dev/null
@@ -1,200 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include <string>
-#include <sstream>
-#include <iostream>
-#include <getopt.h>
-
-using namespace std;
-using namespace vcf;
-
-bool samplesDiffer(vector<string>& samples, Variant& var) {
-
-    string genotype;
-
-    for (vector<string>::iterator s = samples.begin(); s != samples.end(); ++s) {
-        string& sampleName = *s;
-        map<string, map<string, vector<string> > >::iterator f = var.samples.find(sampleName);
-        if (f != var.samples.end()) {
-            map<string, vector<string> >& sample = f->second;
-            map<string, vector<string> >::iterator gt = sample.find("GT");
-            if (gt != sample.end()) {
-                string& thisGenotype = gt->second.front();
-                if (genotype.empty()) {
-                    genotype = thisGenotype;
-                } else {
-                    if (genotype != thisGenotype) {
-                        return true;
-                    }
-                }
-            }
-        }
-    }
-
-    return false;
-
-}
-
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [options] <tag> <sample> <sample> [ <sample> ... ] <vcf file>" << endl
-         << "Tags each record where the listed sample genotypes differ with <tag>." << endl
-         << "The first sample is assumed to be germline, the second somatic." << endl
-         << "Each record is tagged with <tag>={germline,somatic,loh} to specify the type of" << endl
-         << "variant given the genotype difference between the two samples." << endl
-         << endl
-         << "options:" << endl
-         << "    -s --strict     Require that no observations in the germline support the somatic alternate." << endl
-         << endl;
-}
-
-
-int main(int argc, char** argv) {
-
-    if (argc < 5) {
-        printSummary(argv);
-        exit(0);
-    }
-
-    bool strict = false;
-    int c;
-
-    while (true) {
-        static struct option long_options[] =
-            {
-                /* These options set a flag. */
-                //{"verbose", no_argument,       &verbose_flag, 1},
-                {"help", no_argument, 0, 'h'},
-                {"strict",  no_argument, 0, 's'},
-                //{"length",  no_argument, &printLength, true},
-                {0, 0, 0, 0}
-            };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "hs",
-                         long_options, &option_index);
-
-        /* Detect the end of the options. */
-        if (c == -1)
-            break;
- 
-        switch (c)
-        {
-        case 0:
-            /* If this option set a flag, do nothing else now. */
-            if (long_options[option_index].flag != 0)
-                break;
-            printf ("option %s", long_options[option_index].name);
-            if (optarg)
-                printf (" with arg %s", optarg);
-            printf ("\n");
-            break;
-
-        case 's':
-            strict = true;
-            break;
- 
-        case 'h':
-            printSummary(argv);
-            exit(0);
-            break;
-
-        case '?':
-            /* getopt_long already printed an error message. */
-            printSummary(argv);
-            exit(1);
-            break;
- 
-        default:
-            abort ();
-        }
-    }
-
-    string tag = argv[optind];
-
-    vector<string> samples;
-    for (int i = optind+1; i < argc - 1; ++i) {
-        samples.push_back(argv[i]);
-    }
-
-    string filename = argv[argc-1];
-
-    VariantCallFile variantFile;
-    if (filename == "-") {
-        variantFile.open(std::cin);
-    } else {
-        variantFile.open(filename);
-    }
-
-    if (!variantFile.is_open()) {
-        cerr << "could not open " << filename << endl;
-        return 1;
-    }
-
-    assert(samples.size() == 2);
-
-    Variant var(variantFile);
-
-    // TODO check if AC is present
-    // ensure that AC is listed as an info field
-    string line = "##INFO=<ID=" + tag + ",Number=1,Type=String,Description=\"Samples";
-    for (vector<string>::iterator s = samples.begin(); s != samples.end(); ++s) {
-        line += " " + *s;
-    }
-    line += " have different genotypes\">";
-    variantFile.addHeaderLine(line);
-
-    variantFile.addHeaderLine("##INFO=<ID=SSC,Number=1,Type=Float,Description=\"Somatic variant score (phred-scaled probability that the somatic variant call is correct).\">");
-
-    // write the new header
-    cout << variantFile.header << endl;
- 
-    // print the records, filtering is done via the setting of varA's output sample names
-    while (variantFile.getNextVariant(var)) {
-        if (var.samples.find(samples.front()) != var.samples.end()
-            && var.samples.find(samples.back()) != var.samples.end()) {
-            map<string, vector<string> >& germline = var.samples[samples.front()];
-            map<string, vector<string> >& somatic = var.samples[samples.back()];
-            map<int, int> gtGermline = decomposeGenotype(germline["GT"].front());
-            map<int, int> gtSomatic  = decomposeGenotype(somatic["GT"].front());
-            int germlineAltCount = 0;
-            if (germline.find("AO") != germline.end()) {
-                convert(germline["AO"].front(), germlineAltCount);
-            }
-            var.info[tag].clear(); // remove previous
-            if (gtGermline == gtSomatic) {
-                var.info[tag].push_back("germline");
-            } else {
-                //if (isHet(gtGermline) && isHom(gtSomatic)) {
-                //    var.info[tag].push_back("loh");
-                if (isHet(gtGermline) && isHomNonRef(gtSomatic) ||
-                    isHomRef(gtGermline) && (isHet(gtSomatic) || isHomNonRef(gtSomatic))) {
-                    if (!strict || strict && germlineAltCount == 0) {
-                        var.info[tag].push_back("somatic");
-                    }
-                } else if (isHom(gtGermline) && isHet(gtSomatic)) {
-                    if (var.alt.size() == 1) {
-                        var.info[tag].push_back("reversion");
-                    } else {
-                        var.info[tag].push_back("somatic");
-                    }
-                }
-            }
-            if (germline.find("GQ") != germline.end() && somatic.find("GQ") != somatic.end()) {
-                double germlineGQ;
-                convert(germline["GQ"].front(), germlineGQ);
-                double somaticGQ;
-                convert(somatic["GQ"].front(), somaticGQ);
-                double somaticScore = min(var.quality, min(germlineGQ, somaticGQ));
-                var.info["SSC"].clear();
-                var.info["SSC"].push_back(convert(somaticScore));
-            }
-        }
-        cout << var << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfsamplenames.cpp b/vcflib/src/vcfsamplenames.cpp
deleted file mode 100644
index 23f68f7..0000000
--- a/vcflib/src/vcfsamplenames.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-#include "Variant.h"
-
-using namespace std;
-using namespace vcf;
-
-int main(int argc, char** argv) {
-
-    VariantCallFile variantFile;
-
-    if (argc > 1) {
-        string filename = argv[1];
-        variantFile.open(filename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    for (vector<string>::iterator sample = variantFile.sampleNames.begin();
-            sample != variantFile.sampleNames.end(); ++sample) {
-        cout << *sample << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfsamplestats.cpp b/vcflib/src/vcfsamplestats.cpp
deleted file mode 100644
index ceceb98..0000000
--- a/vcflib/src/vcfsamplestats.cpp
+++ /dev/null
@@ -1,193 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include <string>
-#include <iostream>
-#include <getopt.h>
-
-using namespace vcf;
-
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [options] <vcf file>" << endl
-         << "options:" << endl 
-         << endl
-         << "    -h, --help    this dialog" << endl
-         << endl
-         << "By default, output a table of this form:" << endl
-         << "sample" << " "
-         << "sitecount" << " "
-         << "refcount" << " "
-         << "altcount" << " "
-         << "homcount" << " "
-         << "hetcount" << " "
-         << "avg_gq" << " "
-         << "avg_dp" << endl
-         << endl
-         << "for each sample in the VCF file." << endl
-         << "Reads from stdin if no file is specified on the command line." << endl
-         << endl;
-    exit(0);
-}
-
-
-int main(int argc, char** argv) {
-
-    int c;
-    //bool outputTotalStats = false;
-
-    while (true) {
-        static struct option long_options[] =
-        {
-            /* These options set a flag. */
-            //{"verbose", no_argument,       &verbose_flag, 1},
-            {"help", no_argument, 0, 'h'},
-            //{"totals",   no_argument, 0, 't'}, 
-            //{"length",  no_argument, &printLength, true},
-            {0, 0, 0, 0}
-        };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "h",
-                         long_options, &option_index);
-
-      /* Detect the end of the options. */
-          if (c == -1)
-            break;
- 
-          switch (c)
-            {
-            case 0:
-            /* If this option set a flag, do nothing else now. */
-            if (long_options[option_index].flag != 0)
-              break;
-            printf ("option %s", long_options[option_index].name);
-            if (optarg)
-              printf (" with arg %s", optarg);
-            printf ("\n");
-            break;
-
-          //case 't':
-           // outputTotalStats = true;
-            //break;
- 
-          case 'h':
-            printSummary(argv);
-            exit(0);
-            break;
-          
-          case '?':
-            /* getopt_long already printed an error message. */
-            printSummary(argv);
-            exit(1);
-            break;
- 
-          default:
-            abort ();
-          }
-      }
-
-    VariantCallFile variantFile;
-    if (optind == argc - 1) {
-        string inputFilename = argv[optind];
-        variantFile.open(inputFilename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-
-    map<string, int> sitecount;
-    map<string, int> refcount;
-    map<string, int> altcount;
-    map<string, int> homcount;
-    map<string, int> hetcount;
-    map<string, int> gqsum;
-    map<string, int> dpsum;
-
-    for (vector<string>::iterator s = variantFile.sampleNames.begin(); s != variantFile.sampleNames.end(); ++s) {
-        string& sample = *s;
-        sitecount[sample] = 0;
-        refcount[sample] = 0;
-        altcount[sample] = 0;
-        homcount[sample] = 0;
-        hetcount[sample] = 0;
-        gqsum[sample] = 0;
-    }
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-
-        for (map<string, map<string, vector<string> > >::iterator s = var.samples.begin(); s != var.samples.end(); ++s) {
-
-            string name = s->first;
-            map<string, vector<string> >& sample = s->second;
-
-            sitecount[name] += 1;
-
-            int gq;
-            if (convert(sample["GQ"].front(), gq)) {
-                gqsum[name] += gq;
-            }
-
-            int dp;
-            if (convert(sample["DP"].front(), dp))
-                dpsum[name] += dp;
-
-            string& genotype = sample["GT"].front();
-            vector<string> gt = split(genotype, "|/");
-
-            int alt = 0;
-            int ref = 0;
-
-            for (vector<string>::iterator g = gt.begin(); g != gt.end(); ++g) {
-                if (*g != "0") {
-                    ++alt;
-                } else {
-                    ++ref;
-                }
-            }
-
-            if (alt != gt.size()) {
-                hetcount[name] += alt;
-            }
-
-            if (alt == gt.size() || ref == gt.size()) {
-                homcount[name] += 1;
-            }
-
-            refcount[name] += ref;
-            altcount[name] += alt;
-
-        }
-    }
-
-    cout << "sample" << "\t"
-         << "sitecount" << "\t"
-         << "refcount" << "\t"
-         << "altcount" << "\t"
-         << "homcount" << "\t"
-         << "hetcount" << "\t"
-         << "avg_gq" << "\t"
-         << "avg_dp" << endl;
-    for (vector<string>::iterator s = variantFile.sampleNames.begin(); s != variantFile.sampleNames.end(); ++s) {
-        string& sample = *s;
-        cout << sample << "\t"
-
-             << sitecount[sample] << "\t"
-             << refcount[sample] << "\t"
-             << altcount[sample] << "\t"
-             << homcount[sample] << "\t"
-             << hetcount[sample] << "\t"
-             << (float) gqsum[sample] / (float) sitecount[sample] << "\t"
-             << (float) dpsum[sample] / (float) sitecount[sample]
-             << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfsitesummarize.cpp b/vcflib/src/vcfsitesummarize.cpp
deleted file mode 100644
index 067d0d4..0000000
--- a/vcflib/src/vcfsitesummarize.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-#include "Variant.h"
-
-using namespace std;
-using namespace vcf;
-
-int main(int argc, char** argv) {
-
-    VariantCallFile variantFile;
-
-    if (argc > 1) {
-        string filename = argv[1];
-        variantFile.open(filename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    // obtain all possible field names
-    vector<string> infofields;
-    vector<string> infoflags;
-
-    for (map<string, VariantFieldType>::iterator i = variantFile.infoTypes.begin(); i != variantFile.infoTypes.end(); ++i) {
-        if (variantFile.infoCounts[i->first] != ALLELE_NUMBER) {
-            if (i->second == FIELD_BOOL) {
-                infoflags.push_back(i->first);
-            } else {
-                infofields.push_back(i->first);
-            }
-        }
-    }
-
-    // write header
-
-    // defaults
-    cout << "CHROM\tPOS\tID\tREF\tQUAL\tFILTER";
-    
-    // configurable info field
-    for (vector<string>::iterator i = infofields.begin(); i != infofields.end(); ++i) {
-        cout << "\t" << *i;
-    }
-    for (vector<string>::iterator i = infoflags.begin(); i != infoflags.end(); ++i) {
-        cout << "\t" << *i;
-    }
-    cout << endl;
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-
-	cout << var.sequenceName << "\t"
-	     << var.position << "\t"
-	     << var.id << "\t"
-	     << var.ref << "\t"
-	     << var.quality << "\t"
-	     << var.filter;
-
-	for (vector<string>::iterator i = infofields.begin(); i != infofields.end(); ++i) {
-	    vector<string> value;
-	    string& name = *i;
-	    map<string, vector<string> >::iterator f = var.info.find(name);
-	    if (f != var.info.end()) {
-            value = f->second;
-            if (value.size() == 1) {
-                cout << "\t" << value.front();
-            } else {
-                cout << "\t"; // null
-            }
-	    } else {
-            cout << "\t"; // null
-	    }
-	}
-
-	for (vector<string>::iterator i = infoflags.begin(); i != infoflags.end(); ++i) {
-	    string value;
-	    string& name = *i;
-	    map<string, bool>::iterator f = var.infoFlags.find(name);
-	    cout << "\t";
-	    if (f != var.infoFlags.end()) {
-            cout << 1;
-	    } else {
-            cout << 0;
-	    }
-	}
-	
-	cout << endl;
-	
-    }
-    
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfsom.cpp b/vcflib/src/vcfsom.cpp
deleted file mode 100644
index 1e53ec1..0000000
--- a/vcflib/src/vcfsom.cpp
+++ /dev/null
@@ -1,626 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include "convert.h"
-#include <string>
-#include <iostream>
-#include <set>
-#include <sys/time.h>
-#include "fsom/fsom.h"
-#include <getopt.h>
-#include <cmath>
-
-using namespace std;
-using namespace vcf;
-
-double mean(const vector<double>& data) {
-    double total = 0;
-    for (vector<double>::const_iterator i = data.begin(); i != data.end(); ++i) {
-        total += *i;
-    }
-    return total/data.size();
-}
-
-double median(vector <double>& data) {
-    double median;
-    size_t size = data.size();
-    // ascending order
-    sort(data.begin(), data.end());
-    // get middle value
-    if (size % 2 == 0) {
-        median = (data[size/2-1] + data[size/2]) / 2;
-    } else {
-        median = data[size/2];
-    }
-    return median;
-}
-
-double variance(const vector <double>& data, const double mean) {
-    double total = 0;
-    for (vector <double>::const_iterator i = data.begin(); i != data.end(); ++i) {
-        total += (*i - mean)*(*i - mean);
-    }
-    return total / (data.size());
-}
-
-double standard_deviation(const vector <double>& data, const double mean) {
-    return sqrt(variance(data, mean));
-}
-
-struct Stats {
-    double mean;
-    double stdev;
-    Stats(void) : mean(0), stdev(1) { }
-};
-
-bool load_som_metadata(string& som_metadata_file, int& x, int& y, vector<string>& fields, map<string, Stats>& stats) {
-    ifstream in(som_metadata_file.c_str());
-    if (!in.is_open()) {
-        return false;
-    }
-    string linebuf;
-    getline(in, linebuf);
-    vector<string> xy = split(linebuf, "\t ");
-    convert(xy.front(), x);
-    convert(xy.back(), y);
-    while (getline(in, linebuf)) {
-        // format is: field_name, mean, stdev
-        vector<string> m = split(linebuf, "\t ");
-        fields.push_back(m[0]);
-        Stats& s = stats[m[0]];
-        convert(m[1], s.mean);
-        convert(m[2], s.stdev);
-    }
-    in.close();
-    return true;
-}
-
-bool save_som_metadata(string& som_metadata_file, int x, int y, vector<string>& fields, map<string, Stats>& stats) {
-    ofstream out(som_metadata_file.c_str());
-    if (!out.is_open()) {
-        return false;
-    }
-    out << x << "\t" << y << endl;
-    for (vector<string>::iterator f = fields.begin(); f != fields.end(); ++f) {
-        Stats& s = stats[*f];
-        out << *f << "\t" << s.mean << "\t" << s.stdev << endl;
-    }
-    out.close();
-    return true;
-}
-
-void normalize_inputs(vector<double>& record, vector<string>& fields, map<string, Stats>& stats) {
-    vector<double>::iterator r = record.begin();
-    for (vector<string>::iterator f = fields.begin(); f != fields.end(); ++f, ++r) {
-        Stats& s = stats[*f];
-        *r = (*r - s.mean) / s.stdev;
-    }
-}
-
-void read_fields(Variant& var, int ai, vector<string>& fields, vector<double>& record) {
-    double td;
-    vector<string>::iterator j = fields.begin();
-    for (; j != fields.end(); ++j) {
-        if (*j == "QUAL") { // special handling...
-            td = var.quality;
-        } else {
-            if (var.info.find(*j) == var.info.end()) {
-                td = 0;
-            } else {
-                if (var.vcf->infoCounts[*j] == 1) { // for non Allele-variant fields
-                    convert(var.info[*j][0], td);
-                } else {
-                    convert(var.info[*j][ai], td);
-                }
-            }
-        }
-        record.push_back(td);
-    }
-}
-
-struct SomPaint {
-    int true_count;
-    int false_count;
-    double prob_true;
-    SomPaint(void) : true_count(0), false_count(0), prob_true(0) { }
-};
-
-static unsigned long prev_uticks = 0;
-
-static unsigned long get_uticks(){
-    struct timeval ts;
-    gettimeofday(&ts,0);
-    return ((ts.tv_sec * 1000000) + ts.tv_usec);
-}
-
-static void start_timer(){
-    prev_uticks = get_uticks();
-}
-
-static void print_timing( const char *msg ){
-#define MS_DELTA (1000.0)
-#define SS_DELTA (MS_DELTA * 1000.0)
-#define MM_DELTA (SS_DELTA * 60.0)
-#define HH_DELTA (MM_DELTA * 60.0)
-
-    double ticks = get_uticks() - prev_uticks;
-
-    if( ticks < MS_DELTA ){
-        fprintf(stderr, "%s\t : %lf us\n", msg, ticks );
-    }
-    else if( ticks < SS_DELTA ){
-        fprintf(stderr, "%s\t : %lf ms\n", msg, ticks / MS_DELTA );
-    }
-    else if( ticks < MM_DELTA ){
-        fprintf(stderr, "%s\t : %lf s\n", msg, ticks / SS_DELTA );
-    }
-    else if( ticks < HH_DELTA ){
-        fprintf(stderr, "%s\t : %lf m\n", msg, ticks / MM_DELTA );
-    }
-    else{
-        fprintf(stderr, "%s\t : %lf h\n", msg, ticks / HH_DELTA );
-    }
-
-    start_timer();
-}
-
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [options] [vcf file]" << endl
-         << endl
-         << "training: " << endl
-         << "    " << argv[0] << " -s output.som -x 20 -y 20 -f \"AF DP ABP\" training.vcf" << endl
-         << endl
-         << "application: " << endl
-         << "    " << argv[0] << " -a output.som test.vcf >results.vcf" << endl
-         << endl
-         << argv[0] << "trains and/or applies a self-organizing map to the input VCF data" << endl
-         << "on stdin, adding two columns for the x and y coordinates of the winning" << endl
-         << "neuron in the network and an optional euclidean distance from a given" << endl
-         << "node (--center)." << endl
-         << endl
-         << "If a map is provided via --apply, it will be applied to input without" << endl
-         << "training.  A .meta file describing network parameters and input parameter" << endl
-         << "distributions is used to automatically setup the network." << endl
-         << endl
-         << "options:" << endl
-         << endl
-         << "    -h, --help             this dialog" << endl
-         << endl
-         << "training:" << endl
-         << endl
-         << "    -f, --fields \"FIELD ...\"  INFO fields to provide to the SOM" << endl
-         << "    -a, --apply FILE       apply the saved map to input data to FILE" << endl
-         << "    -s, --save  FILE       train on input data and save the map to FILE" << endl
-         << "    -p, --print-training-results" << endl
-         << "                           print results of SOM on training input" << endl
-         << "                           (you can also just use --apply on the same input)" << endl
-         << "    -x, --width X          width in columns of the output array" << endl
-         << "    -y, --height Y         height in columns of the output array" << endl
-         << "    -i, --iterations N     number of training iterations or epochs" << endl
-         << "    -d, --debug            print timing information" << endl
-         << endl
-         << "recalibration:" << endl
-         << endl
-         << "    -c, --center X,Y       annotate with euclidean distance from center" << endl
-         << "    -T, --paint-true VCF   use VCF file to annotate true variants (multiple)" << endl
-         << "    -F, --paint-false VCF  use VCF file to annotate false variants (multiple)" << endl
-         << "    -R, --paint-tag TAG    provide estimated FDR% in TAG in variant INFO" << endl
-         << "    -N, --false-negative   replace FDR% (false detection) with FNR% (false negative)" << endl;
-
-}
-
-
-int main(int argc, char** argv) {
-
-    int width = 100;
-    int height = 100;
-    int num_dimensions = 2;
-    int iterations = 1000;
-    string som_file;
-    string som_metadata_file;
-    bool apply = false;
-    bool train = false;
-    bool apply_to_training_data = false; // print results against training data
-    bool debug = false;
-    vector<string> fields;
-    vector<string> centerv;
-    int centerx;
-    int centery;
-    string trueVCF;
-    string falseVCF;
-    bool normalize = true;
-
-    int c;
-
-    if (argc == 1) {
-        printSummary(argv);
-        exit(1);
-    }
-
-    while (true) {
-        static struct option long_options[] =
-        {  
-            /* These options set a flag. */
-            //{"verbose", no_argument,       &verbose_flag, 1},
-            {"help", no_argument, 0, 'h'},
-            {"iterations", required_argument, 0, 'i'},
-            {"width", required_argument, 0, 'x'},
-            {"height", required_argument, 0, 'y'},
-            {"apply", required_argument, 0, 'a'},
-            {"save", required_argument, 0, 's'},
-            {"fields", required_argument, 0, 'f'},
-            {"print-training-results", no_argument, 0, 'p'},
-            {"center", required_argument, 0, 'c'},
-            {"paint-true", required_argument, 0, 'T'},
-            {"paint-false", required_argument, 0, 'F'},
-            {"debug", no_argument, 0, 'd'},
-            {0, 0, 0, 0}
-        };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "hpdi:x:y:a:s:f:c:T:F:",
-                         long_options, &option_index);
-
-        if (c == -1)
-            break;
-
-        string field;
-
-        switch (c)
-        {
-
-            case 'x':
-                if (!convert(optarg, width)) {
-                    cerr << "could not parse --width, -x" << endl;
-                    exit(1);
-                }
-                break;
-
-            case 'y':
-                if (!convert(optarg, height)) {
-                    cerr << "could not parse --height, -y" << endl;
-                    exit(1);
-                }
-                break;
-
-            case 'i':
-                if (!convert(optarg, iterations)) {
-                    cerr << "could not parse --iterations, -i" << endl;
-                    exit(1);
-                }
-                break;
-
-            case 'p':
-                apply_to_training_data = true;
-                break;
-
-            case 'T':
-                trueVCF = optarg;
-                break;
-
-            case 'F':
-                falseVCF = optarg;
-                break;
-
-            case 'd':
-                debug = true;
-                break;
-
-            case 'a':
-                som_file = optarg;
-                apply = true;
-                break;
-                
-            case 's':
-                som_file = optarg;
-                train = true;
-                break;
-
-            case 'f':
-                fields = split(string(optarg), ' ');
-                break;
-
-            case 'c':
-                centerv = split(string(optarg), ',');
-                convert(centerv.at(0), centerx);
-                convert(centerv.at(1), centery);
-                break;
-
-            case 'h':
-                printSummary(argv);
-                exit(0);
-                break;
-
-            default:
-                break;
-        }
-    }
-
-    size_t i, j;
-    som_network_t *net = NULL;
-    vector<string> inputs;
-    vector<vector<double> > data;
-    map<string, Stats> stats;
-
-    string line;
-    stringstream ss;
-
-    VariantCallFile variantFile;
-    bool usingstdin = false;
-    string inputFilename;
-    if (optind == argc - 1) {
-        inputFilename = argv[optind];
-        variantFile.open(inputFilename);
-    } else {
-        variantFile.open(std::cin);
-        usingstdin = true;
-    }
-
-    if (!variantFile.is_open()) {
-        cerr << "could not open VCF file" << endl;
-        return 1;
-    }
-
-    som_metadata_file = som_file + ".meta";
-
-    Variant var(variantFile);
-
-    variantFile.addHeaderLine("##INFO=<ID=SOMX,Number=A,Type=Integer,Description=\"X position of best neuron for variant in self-ordering map defined in " + som_file + "\">");
-    variantFile.addHeaderLine("##INFO=<ID=SOMY,Number=A,Type=Integer,Description=\"Y position of best neuron for variant in self-ordering map defined in " + som_file + "\">");
-    if (!centerv.empty()) {
-        variantFile.addHeaderLine("##INFO=<ID=SOMD,Number=A,Type=Float,Description=\"Euclidean distance from "
-                                  + convert(centerx) + "," + convert(centery) + " as defined by " + som_file + "\">");
-    }
-    if (!trueVCF.empty() && !falseVCF.empty()) {
-        variantFile.addHeaderLine("##INFO=<ID=SOMP,Number=A,Type=Float,Description=\"Estimated probability the variant is true using som "
-                                  + som_file + ", true variants from " + trueVCF + ", and false variants from " + falseVCF + "\">");
-    }
-
-    if (debug) start_timer();
-    
-    vector<Variant> variants;
-    if (train) {
-        map<string, pair<double, double> > normalizationLimits;
-        while (variantFile.getNextVariant(var)) {
-            variants.push_back(var);
-            int ai = 0;
-            vector<string>::iterator a = var.alt.begin();
-            for ( ; a != var.alt.end(); ++a, ++ai) {
-                vector<double> record;
-                double td;
-                vector<string>::iterator j = fields.begin();
-                for (; j != fields.end(); ++j) {
-                    if (*j == "QUAL") { // special handling...
-                        td = var.quality;
-                    } else {
-                        if (var.info.find(*j) == var.info.end()) {
-                            td = 0;
-                        } else {
-                            if (variantFile.infoCounts[*j] == 1) { // for non Allele-variant fields
-                                convert(var.info[*j][0], td);
-                            } else {
-                                convert(var.info[*j][ai], td);
-                            }
-                        }
-                    }
-                    if (normalize) {
-                        pair<double, double>& limits = normalizationLimits[*j];
-                        if (td < limits.first) limits.first = td;
-                        if (td > limits.second) limits.second = td;
-                    }
-                    record.push_back(td);
-                }
-                data.push_back(record);
-            }
-        }
-        // normalize inputs
-        if (normalize) {
-            // get normalization vector
-            // goal is normalization at 0, sd=1
-            int i = 0;
-            for (vector<string>::iterator f = fields.begin(); f != fields.end(); ++f, ++i) {
-                vector<double> fv;
-                for (vector<vector<double> >::iterator d = data.begin(); d != data.end(); ++d) {
-                    fv.push_back(d->at(i));
-                }
-                Stats& s = stats[*f];
-                // get normalization constants
-                s.mean = mean(fv);
-                s.stdev = standard_deviation(fv, s.mean);
-                // normalize
-                for (vector<vector<double> >::iterator d = data.begin(); d != data.end(); ++d) {
-                    double v = d->at(i);
-                    d->at(i) = (v - s.mean) / s.stdev;
-                }
-            }
-        }
-    }
-
-    vector<double*> dataptrs (data.size());
-    for (unsigned i=0, e=dataptrs.size(); i<e; ++i) {
-        dataptrs[i] = &(data[i][0]); // assuming !thing[i].empty()
-    }
-
-    if (debug) print_timing( "Input Processing" );
-
-    if (apply) {
-        if (! (net = som_deserialize(som_file.c_str()))) {
-            cerr << "could not load SOM from " << som_file << endl;
-            return 1;
-        }
-        if (!fields.empty()) {
-            cerr << "fields specified, but a SOM is to be applied, and metadata should be stored at " << som_metadata_file << endl;
-            return 1;
-        }
-        if (!load_som_metadata(som_metadata_file, width, height, fields, stats)) {
-            cerr << "could not load SOM metadata from " << som_metadata_file << endl;
-            return 1;
-        }
-    } else {
-
-        net = som_network_new(data[0].size(), height, width);
-	
-        if ( !net )	{
-            printf( "ERROR: som_network_new failed.\n" );
-            return 1;
-        }
-    }
-
-    if (debug) print_timing( "Network Creation" );
-
-    if (train) {
-        if (debug) cerr << "Training using " << data.size() << " input vectors" << endl;
-        som_init_weights ( net, &dataptrs[0], data.size() );
-        som_train ( net, &dataptrs[0], data.size(), iterations );
-    }
-
-    if (debug) print_timing( "Network Training" );
-
-    // open and calibrate using the true and false datasets
-
-    if (train && apply_to_training_data) {
-        // currently disabled
-        /*
-        cout << variantFile.header << endl;
-        vector<Variant>::iterator v = variants.begin(); int di = 0;
-        for ( ; v != variants.end() && di < data.size(); ++v) {
-            var.info["SOMX"].clear();
-            var.info["SOMY"].clear();
-            var.info["SOMP"].clear();
-            var.info["SOMD"].clear();
-            for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a, ++di) {
-                som_set_inputs ( net, dataptrs[di] );
-                size_t x=0, y=0;
-                som_get_best_neuron_coordinates ( net, &x, &y );
-                v->info["SOMX"].push_back(convert(x));
-                v->info["SOMY"].push_back(convert(y));
-                if (!centerv.empty()) {
-                    float distance = sqrt(pow(abs((float)centerx - (float)x), 2)
-                                          + pow(abs((float)centery - (float)y), 2));
-                    var.info["SOMD"].clear();
-                    var.info["SOMD"].push_back(convert(distance));
-                }
-            }
-            cout << *v << endl;
-        }
-        */
-    } else if (apply) {
-
-        // if we have true and false sets, use them to "paint" the map
-        vector<vector<SomPaint> > paintedSOM;
-        paintedSOM.resize(width);
-        for (vector<vector<SomPaint> >::iterator t = paintedSOM.begin();
-             t != paintedSOM.end(); ++t) {
-            t->resize(height);
-        }
-
-        // handle trues
-        if (!trueVCF.empty()) {
-            VariantCallFile trueVariantFile;
-            trueVariantFile.open(trueVCF);
-            Variant v(trueVariantFile);
-            while (trueVariantFile.getNextVariant(v)) {
-                int ai = 0;
-                vector<string>::iterator a = v.alt.begin();
-                for ( ; a != v.alt.end(); ++a, ++ai) {
-                    vector<double> record;
-                    read_fields(v, ai, fields, record);
-                    if (normalize) {
-                        normalize_inputs(record, fields, stats);
-                    }
-                    som_set_inputs ( net, &record[0] );
-                    size_t x=0, y=0;
-                    som_get_best_neuron_coordinates ( net, &x, &y );
-                    paintedSOM[x][y].true_count += 1;
-                }
-            }
-        }
-
-        // get falses
-        if (!falseVCF.empty()) {
-            VariantCallFile falseVariantFile;
-            falseVariantFile.open(falseVCF);
-            Variant v(falseVariantFile);
-            while (falseVariantFile.getNextVariant(v)) {
-                int ai = 0;
-                vector<string>::iterator a = v.alt.begin();
-                for ( ; a != v.alt.end(); ++a, ++ai) {
-                    vector<double> record;
-                    read_fields(v, ai, fields, record);
-                    if (normalize) {
-                        normalize_inputs(record, fields, stats);
-                    }
-                    som_set_inputs ( net, &record[0] );
-                    size_t x=0, y=0;
-                    som_get_best_neuron_coordinates ( net, &x, &y );
-                    paintedSOM[x][y].false_count += 1;
-                }
-            }
-        }
-
-        // estimate probability of each node using true and false set
-        for (vector<vector<SomPaint> >::iterator t = paintedSOM.begin();
-             t != paintedSOM.end(); ++t) {
-            for (vector<SomPaint>::iterator p = t->begin(); p != t->end(); ++p) {
-                //cout << "count at node " << t - paintedSOM.begin() << "," << p - t->begin()
-                //     << " is " << p->true_count << " true, " << p->false_count << " false" << endl;
-                if (p->true_count + p->false_count > 0) {
-                    p->prob_true = (double) p->true_count / (double) (p->true_count + p->false_count);
-                } else {
-                    // for nodes without training data, could we estimate from surrounding nodes?
-                    // yes, TODO, but for now we can be conservative and say "0"
-                    p->prob_true = 0;
-                }
-            }
-        }
-
-        cout << variantFile.header << endl;
-        while (variantFile.getNextVariant(var)) {
-            var.info["SOMX"].clear();
-            var.info["SOMY"].clear();
-            var.info["SOMP"].clear();
-            var.info["SOMD"].clear();
-            int ai = 0;
-            vector<string>::iterator a = var.alt.begin();
-            for ( ; a != var.alt.end(); ++a, ++ai) {
-                vector<double> record;
-                read_fields(var, ai, fields, record);
-                if (normalize) {
-                    normalize_inputs(record, fields, stats);
-                }
-                som_set_inputs ( net, &record[0] );
-                size_t x=0, y=0;
-                som_get_best_neuron_coordinates ( net, &x, &y );
-                if (!trueVCF.empty() && !falseVCF.empty()) {
-                    SomPaint& paint = paintedSOM[x][y];
-                    var.info["SOMP"].push_back(convert(paint.prob_true));
-                }
-                var.info["SOMX"].push_back(convert(x));
-                var.info["SOMY"].push_back(convert(y));
-                if (!centerv.empty()) {
-                    float distance = sqrt(pow(abs((float)centerx - (float)x), 2)
-                                          + pow(abs((float)centery - (float)y), 2));
-                    var.info["SOMD"].push_back(convert(distance));
-                }
-            }
-            cout << var << endl;
-        }
-    }
-
-    if (debug) print_timing( "Input Recognition" );
-
-    if (train) {
-        if (!save_som_metadata(som_metadata_file, width, height, fields, stats)) {
-            cerr << "could not save metadata to " << som_metadata_file << endl;
-        }
-        som_serialize(net, som_file.c_str());
-    }
-
-    som_network_destroy ( net );
-
-    if (debug) print_timing( "Network Destruction" );
-
-    return 0;
-
-}
diff --git a/vcflib/src/vcfstats.cpp b/vcflib/src/vcfstats.cpp
deleted file mode 100644
index da8137b..0000000
--- a/vcflib/src/vcfstats.cpp
+++ /dev/null
@@ -1,570 +0,0 @@
-#include "Variant.h"
-#include "split.h"
-#include "convert.h"
-#include <getopt.h>
-
-using namespace std;
-using namespace vcf;
-
-bool isTransition(const string& ref, const string& alt) {
-    if (((ref == "A" && alt == "G") || (ref == "G" && alt == "A")) ||
-        ((ref == "C" && alt == "T") || (ref == "T" && alt == "C"))) {
-        return true;
-    } else {
-        return false;
-    }
-}
-
-bool isDeamination(const string& ref, const string& alt) {
-    if ((ref == "G" && alt == "A") ||
-        (ref == "C" && alt == "T")) {
-        return true;
-    } else {
-        return false;
-    }
-}
-
-bool isAmination(const string& ref, const string& alt) {
-    if ((ref == "A" && alt == "G") ||
-        (ref == "T" && alt == "C")) {
-        return true;
-    } else {
-        return false;
-    }
-}
-
-class AlleleStats {
-public:
-    int transitions;
-    int transversions;
-    int deaminations;
-    int aminations;
-    int mismatches;
-    int insertedbases;
-    int insertions;
-    int deletedbases;
-    int deletions;
-    //AlleleStats(int ts, int tv, int da, int am, int mm)
-    AlleleStats(void)
-        : transitions(0)
-        , transversions(0)
-        , deaminations(0)
-        , aminations(0)
-        , mismatches(0)
-        , insertions(0)
-        , insertedbases(0)
-        , deletions(0)
-        , deletedbases(0)
-    { }
-};
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [options] <vcf file>" << endl
-         << endl
-         << "    -r, --region          specify a region on which to target the stats, requires a BGZF" << endl
-         << "                          compressed file which has been indexed with tabix.  any number of" << endl
-         << "                          regions may be specified." << endl
-         << "    -a, --add-info        add the statistics intermediate information to the VCF file," << endl
-         << "                          writing out VCF records instead of summary statistics" << endl
-         << "    -t, --add-type        only add the type= field to the info (faster than -a)" << endl
-         << "    -l, --no-length-frequency    don't out the indel and mnp length-frequency spectra" << endl
-         << "    -m, --match-score N          match score for SW algorithm" << endl
-         << "    -x, --mismatch-score N       mismatch score for SW algorithm" << endl
-         << "    -o, --gap-open-penalty N     gap open penalty for SW algorithm" << endl
-         << "    -e, --gap-extend-penalty N   gap extension penalty for SW algorithm" << endl
-         << endl
-         << "Prints statistics about variants in the input VCF file." << endl;
-}
-
-
-int main(int argc, char** argv) {
-
-    vector<string> regions;
-    bool addTags = false;
-    bool addType = false;
-    bool lengthFrequency = true;
-
-    // constants for SmithWaterman algorithm
-    float matchScore = 10.0f;
-    float mismatchScore = -9.0f;
-    float gapOpenPenalty = 15.0f;
-    float gapExtendPenalty = 6.66f;
-
-    bool useReferenceAlignment = false;
-
-    int c;
-    while (true) {
-        static struct option long_options[] =
-            {
-                /* These options set a flag. */
-                //{"verbose", no_argument,       &verbose_flag, 1},
-                {"help", no_argument, 0, 'h'},
-                {"region", required_argument, 0, 'r'},
-                {"add-info", no_argument, 0, 'a'},
-                {"add-type", no_argument, 0, 't'},
-                {"no-length-frequency", no_argument, 0, 'l'},
-                {"match-score", required_argument, 0, 'm'},
-                {"mismatch-score", required_argument, 0, 'x'},
-                {"gap-open-penalty", required_argument, 0, 'o'},
-                {"gap-extend-penalty", required_argument, 0, 'e'},
-                //{"length",  no_argument, &printLength, true},
-                {0, 0, 0, 0}
-            };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "hlatr:m:x:o:e:",
-                         long_options, &option_index);
-
-        /* Detect the end of the options. */
-        if (c == -1)
-            break;
- 
-        switch (c)
-        {
-        case 0:
-            /* If this option set a flag, do nothing else now. */
-            if (long_options[option_index].flag != 0)
-                break;
-            printf ("option %s", long_options[option_index].name);
-            if (optarg)
-                printf (" with arg %s", optarg);
-            printf ("\n");
-            break;
-
-	    case 'h':
-            printSummary(argv);
-            exit(0);
-            break;
-		
-	    case 'r':
-            regions.push_back(optarg);
-            break;
-		
-	    case 'l':
-            lengthFrequency = false;
-            break;
-		
-	    case 'a':
-            addTags = true;
-            break;
-
-	    case 't':
-            addType = true;
-            break;
-
-	    case 'm':
-            matchScore = atof(optarg);
-	        break;
-
-	    case 'x':
-            mismatchScore = atof(optarg);
-	        break;
-
-	    case 'o':
-            gapOpenPenalty = atof(optarg);
-	        break;
-
-	    case 'e':
-            gapExtendPenalty = atof(optarg);
-	        break;
-		
-	    default:
-            abort ();
-        }
-    }
-
-    VariantCallFile variantFile;
-    string inputFilename;
-    if (optind == argc - 1) {
-        inputFilename = argv[optind];
-        variantFile.open(inputFilename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    if (addType && !addTags) {
-        variantFile.addHeaderLine("##INFO=<ID=type,Number=A,Type=String,Description=\"The type of the allele, either snp, ins, del, complex, or ref.\">");
-        variantFile.addHeaderLine("##INFO=<ID=cigar,Number=A,Type=String,Description=\"The CIGAR-style representation of the alternate allele as aligned to the reference\">");
-        cout << variantFile.header << endl;
-    }
-
-    if (addTags) {
-        variantFile.addHeaderLine("##INFO=<ID=transitions,Number=A,Type=Integer,Description=\"Total number of transitions in the alternate allele\">");
-        variantFile.addHeaderLine("##INFO=<ID=transversions,Number=A,Type=Integer,Description=\"Total number of transversions in the alternate allele\">");
-        variantFile.addHeaderLine("##INFO=<ID=deaminations,Number=A,Type=Integer,Description=\"Total number of deaminations in the alternate allele\">");
-        variantFile.addHeaderLine("##INFO=<ID=aminations,Number=A,Type=Integer,Description=\"Total number of aminations in the alternate allele\">");
-        variantFile.addHeaderLine("##INFO=<ID=mismatches,Number=A,Type=Integer,Description=\"Total number of mismatches in the alternate allele\">");
-        variantFile.addHeaderLine("##INFO=<ID=insertions,Number=A,Type=Integer,Description=\"Total number of inserted bases in the alternate allele\">");
-        variantFile.addHeaderLine("##INFO=<ID=deletions,Number=A,Type=Integer,Description=\"Total number of deleted bases in the alternate allele\">");
-        variantFile.addHeaderLine("##INFO=<ID=cigar,Number=A,Type=String,Description=\"The CIGAR-style representation of the alternate allele as aligned to the reference\">");
-        variantFile.addHeaderLine("##INFO=<ID=type,Number=A,Type=String,Description=\"The type of the allele, either snp, ins, del, complex, or ref.\">");
-        variantFile.addHeaderLine("##INFO=<ID=reflen,Number=1,Type=Integer,Description=\"The length of the reference allele\">");
-        variantFile.addHeaderLine("##INFO=<ID=altlen,Number=A,Type=Integer,Description=\"The length of the alternate allele\">");
-        cout << variantFile.header << endl;
-    }
-
-    Variant var(variantFile);
-
-    vector<string>::iterator regionItr = regions.begin();
-
-    int variantAlleles = 0;
-    int uniqueVariantAlleles = 0;
-    int variantSites = 0;
-    int snps = 0;
-    int transitions = 0;
-    int transversions = 0;
-    int deaminations = 0;
-    int aminations = 0;
-    int totalinsertions = 0;
-    int totaldeletions = 0;
-    int insertedbases = 0;
-    int deletedbases = 0;
-    int totalmnps = 0;
-    int totalcomplex = 0;
-    int mismatchbases = 0;
-    int mnpbases = 0;
-    int biallelics = 0;
-    int multiallelics = 0;
-    map<int, int> insertions;
-    map<int, int> deletions;
-    map<int, int> mnps;
-    map<int, int> complexsubs;
-
-    bool includePreviousBaseForIndels = false;
-    bool useMNPs = true;
-    bool useEntropy = false;
-
-    AlleleStats biallelicSNPs;
-
-    // todo, add biallelic snp dialog to output and ts/tv for snps and mnps
-
-    do {
-
-        if (!inputFilename.empty() && !regions.empty()) {
-            string regionStr = *regionItr++;
-            variantFile.setRegion(regionStr);
-        }
-
-        while (variantFile.getNextVariant(var)) {
-            ++variantSites;
-            if (var.alt.size() > 1) {
-                ++multiallelics;
-            } else {
-                ++biallelics;
-            }
-            map<string, vector<VariantAllele> > alternates = var.parsedAlternates(includePreviousBaseForIndels,
-                                                                                  useMNPs,
-                                                                                  useEntropy,
-                                                                                  matchScore,
-                                                                                  mismatchScore,
-                                                                                  gapOpenPenalty,
-                                                                                  gapExtendPenalty);
-            map<VariantAllele, vector<string> > uniqueVariants;
-	    
-            vector<string> cigars;
-	    
-            for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-                string& alternate = *a;
-                if (addTags)
-                    var.info["altlen"].push_back(convert(alternate.size()));
-                vector<VariantAllele>& vav = alternates[alternate];
-                if (vav.size() > 1) {
-                    // check that there are actually multiple non-reference alleles
-                    int nonRefAlleles = 0;
-                    for (vector<VariantAllele>::iterator z = vav.begin(); z != vav.end(); ++z) {
-                        if (z->ref != z->alt)
-                            ++nonRefAlleles;
-                    }
-                    if (nonRefAlleles > 1)
-                        ++totalcomplex;
-                }
-                for (vector<VariantAllele>::iterator v = vav.begin(); v != vav.end(); ++v) {
-                    uniqueVariants[*v].push_back(alternate);
-                }
-
-                if (addTags || addType) {
-                    string cigar;
-                    pair<int, string> element;
-                    for (vector<VariantAllele>::iterator v = vav.begin(); v != vav.end(); ++v) {
-                        VariantAllele& va = *v;
-                        if (va.ref != va.alt) {
-                            if (element.second == "M") {
-                                cigar += convert(element.first) + element.second;
-                                element.second = ""; element.first = 0;
-                            }
-                            if (va.ref.size() == va.alt.size()) {
-                                cigar += convert(va.ref.size()) + "X";
-                            } else if (va.ref.size() > va.alt.size()) {
-                                cigar += convert(va.ref.size() - va.alt.size()) + "D";
-                            } else {
-                                cigar += convert(va.alt.size() - va.ref.size()) + "I";
-                            }
-                        } else {
-                            if (element.second == "M") {
-                                element.first += va.ref.size();
-                            } else {
-                                element = make_pair(va.ref.size(), "M");
-                            }
-                        }
-                    }
-                    if (element.second == "M") {
-                        cigar += convert(element.first) + element.second;
-                    }
-                    element.second = ""; element.first = 0;
-                    cigars.push_back(cigar);
-                }
-            }
-
-            if (addTags) {
-                var.info["cigar"] = cigars;
-                var.info["reflen"].push_back(convert(var.ref.size()));
-            } else if (addType) {
-                var.info["cigar"] = cigars;
-            }
-
-            variantAlleles += var.alt.size();
-            map<string, AlleleStats> alleleStats;
-
-            for (map<VariantAllele, vector<string> >::iterator v = uniqueVariants.begin(); v != uniqueVariants.end(); ++v) {
-                const VariantAllele& va = v->first;
-                vector<string>& alternates = v->second;
-
-                if (!(addTags || addType)) { // don't add any tag information if we're not going to output it
-                    alternates.clear();
-                }
-
-                if (va.ref != va.alt) {
-                    ++uniqueVariantAlleles;
-                    if (va.ref.size() == va.alt.size()) {
-                        if (va.ref.size() == 1) {
-                            ++snps;
-                            ++mismatchbases;
-                            for (vector<string>::iterator a = alternates.begin(); a != alternates.end(); ++a) {
-                                ++alleleStats[*a].mismatches;
-                            }
-                            if (isTransition(va.ref, va.alt)) {
-                                ++transitions;
-                                for (vector<string>::iterator a = alternates.begin(); a != alternates.end(); ++a) {
-                                    ++alleleStats[*a].transitions;
-                                }
-                            } else {
-                                ++transversions;
-                                for (vector<string>::iterator a = alternates.begin(); a != alternates.end(); ++a) {
-                                    ++alleleStats[*a].transversions;
-                                }
-                            }
-                            if (isAmination(va.ref, va.alt)) {
-                                ++aminations;
-                                for (vector<string>::iterator a = alternates.begin(); a != alternates.end(); ++a) {
-                                    ++alleleStats[*a].aminations;
-                                }
-                            }
-                            if (isDeamination(va.ref, va.alt)) {
-                                ++deaminations;
-                                for (vector<string>::iterator a = alternates.begin(); a != alternates.end(); ++a) {
-                                    ++alleleStats[*a].deaminations;
-                                }
-                            }
-                        } else {
-                            ++totalmnps;
-                            ++mnps[va.alt.size()]; // not entirely correct
-                            for (vector<string>::iterator a = alternates.begin(); a != alternates.end(); ++a) {
-                                alleleStats[*a].mismatches += va.alt.size();
-                            }
-                            string::const_iterator r = va.ref.begin();
-                            for (string::const_iterator a = va.alt.begin(); a != va.alt.end(); ++a, ++r) {
-                                string rstr = string(1, *r);
-                                string astr = string(1, *a);
-                                if (rstr == astr) {
-                                    continue;
-                                }
-                                if (isTransition(rstr, astr)) {
-                                    ++transitions;
-                                    for (vector<string>::iterator a = alternates.begin(); a != alternates.end(); ++a) {
-                                        ++alleleStats[*a].transitions;
-                                    }
-                                } else {
-                                    ++transversions;
-                                    for (vector<string>::iterator a = alternates.begin(); a != alternates.end(); ++a) {
-                                        ++alleleStats[*a].transversions;
-                                    }
-                                }
-                                if (isAmination(rstr, astr)) {
-                                    ++aminations;
-                                    for (vector<string>::iterator a = alternates.begin(); a != alternates.end(); ++a) {
-                                        ++alleleStats[*a].aminations;
-                                    }
-                                }
-                                if (isDeamination(rstr, astr)) {
-                                    ++deaminations;
-                                    for (vector<string>::iterator a = alternates.begin(); a != alternates.end(); ++a) {
-                                        ++alleleStats[*a].deaminations;
-                                    }
-                                }
-                                ++mismatchbases;
-                                ++mnpbases;
-                            }
-                        }
-                    } else if (va.ref.size() > va.alt.size()) {
-                        int diff = va.ref.size() - va.alt.size();
-                        deletedbases += diff;
-                        ++totaldeletions;
-                        ++deletions[diff];
-                        for (vector<string>::iterator a = alternates.begin(); a != alternates.end(); ++a) {
-                            alleleStats[*a].deletedbases += diff;
-                            alleleStats[*a].deletions += 1;
-                        }
-                    } else {
-                        int diff = va.alt.size() - va.ref.size();
-                        insertedbases += diff;
-                        ++totalinsertions;
-                        ++insertions[diff];
-                        for (vector<string>::iterator a = alternates.begin(); a != alternates.end(); ++a) {
-                            alleleStats[*a].insertedbases += diff;
-                            alleleStats[*a].insertions += 1;
-                        }
-                    }
-                }
-            }
-            if (addTags || addType) {
-                for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-                    string vartype;
-                    if (alleleStats[*a].insertions + alleleStats[*a].deletions == 0) {
-                        if (alleleStats[*a].mismatches == 1) {
-                            vartype = "snp";
-                        } else if (alleleStats[*a].mismatches > 1) {
-                            vartype = "complex";
-                        } else {
-                            vartype = "ref";
-                        }
-                    } else if (alleleStats[*a].insertions + alleleStats[*a].deletions == 1) {
-                        if (alleleStats[*a].insertions == 1) {
-                            vartype = "ins";
-                        } else {
-                            vartype = "del";
-                        }
-                    } else {
-                        vartype = "complex";
-                    }
-                    if (addTags) {
-                        var.info["mismatches"].push_back(convert(alleleStats[*a].mismatches));
-                        var.info["insertions"].push_back(convert(alleleStats[*a].insertions));
-                        var.info["deletions"].push_back(convert(alleleStats[*a].deletions));
-                        var.info["transitions"].push_back(convert(alleleStats[*a].transitions));
-                        var.info["transversions"].push_back(convert(alleleStats[*a].transversions));
-                        var.info["deaminations"].push_back(convert(alleleStats[*a].deaminations));
-                        var.info["aminations"].push_back(convert(alleleStats[*a].aminations));
-                    }
-                    var.info["type"].push_back(vartype);
-                }
-                cout << var << endl;
-            }
-            // biallelic SNP case
-            if (var.alt.size() == 1 && var.ref.size() == 1 && var.alt.front().size() == 1) {
-                if (isTransition(var.ref, var.alt.front())) {
-                    biallelicSNPs.transitions++;
-                } else {
-                    biallelicSNPs.transversions++;
-                }
-                biallelicSNPs.mismatches++;
-            }
-        }
-
-    } while (regionItr != regions.end());
-
-
-    // find the maximum indel size
-    int maxindel = 0;
-    for (map<int, int>::iterator i = insertions.begin(); i != insertions.end(); ++i) {
-        if (i->first > maxindel) {
-            maxindel = i->first;
-        }
-    }
-    for (map<int, int>::iterator i = deletions.begin(); i != deletions.end(); ++i) {
-        if (i->first > maxindel) {
-            maxindel = i->first;
-        }
-    }
-
-    // and maximum mnp
-    int maxmnp = 0;
-    for (map<int, int>::iterator i = mnps.begin(); i != mnps.end(); ++i) {
-        if (i->first > maxmnp) {
-            maxmnp = i->first;
-        }
-    }
-
-    // now print the results
-
-    if (!addTags && !addType) {
-        cout << "total variant sites:\t" << variantSites << endl
-             << "of which " << biallelics << " (" << (double) biallelics / variantSites << ") are biallelic and "
-                            << multiallelics << " (" << (double) multiallelics / variantSites << ") are multiallelic" << endl
-             << "total variant alleles:\t" << variantAlleles << endl
-             << "unique variant alleles:\t" << uniqueVariantAlleles << endl
-             << endl
-             << "snps:\t" << snps << endl
-             << "mnps:\t" << totalmnps << endl
-             << "indels:\t" << totalinsertions + totaldeletions << endl
-             << "complex:\t" << totalcomplex << endl
-             << endl
-             << "mismatches:\t" << mismatchbases << endl
-             << endl
-             << "ts/tv ratio:\t" << (double) transitions / (double) transversions << endl
-             << "deamination ratio:\t" << (double) deaminations / aminations << endl
-             << "biallelic snps:\t" << biallelicSNPs.mismatches << " @ "
-             << (double) biallelicSNPs.transitions / (double) biallelicSNPs.transversions << endl;
-
-        if (lengthFrequency) {
-            cout << endl
-                 << "ins/del length frequency distribution" << endl
-                 << "length\tins\tdel\tins/del" << endl;
-            for (int i = 1; i <= maxindel; ++i) {
-                int ins = insertions[i];
-                int del = deletions[i];
-                cout << i << "\t"
-                     << (ins > 0 ? convert(ins) : "" ) << "\t"
-                     << (del > 0 ? convert(del) : "") << "\t"
-                     << (ins > 0 && del > 0 ? convert((double) ins / (double) del) : "")
-                     << endl;
-            }
-        }
-
-        cout << endl
-             << "insertion alleles / deletion alleles:\t"
-             << (double) totalinsertions / (double) totaldeletions << endl
-             << "inserted bases / deleted bases:\t"
-             << (double) insertedbases / (double) deletedbases << endl
-             << endl;
-
-        if (lengthFrequency) {
-            cout << "mnp length frequency distribution" << endl
-                 << "length\tcount" << endl;
-            for (int i = 2; i <= maxmnp; ++i) {
-                int mnp = mnps[i];
-                cout << i << "\t"
-                     << (mnp > 0 ? convert(mnp) : "")
-                     << endl;
-            }
-        }
-
-        cout << "total bases in mnps:\t" << mnpbases << endl;
-
-        /*
-          cout << "complex event frequency distribution" << endl
-          << "length\tcount" << endl;
-          for (map<int, int>::iterator i = complexsubs.begin(); i != complexsubs.end(); ++i) {
-          cout << i->first << "\t" << i->second << endl;
-          }
-        */
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfstreamsort.cpp b/vcflib/src/vcfstreamsort.cpp
deleted file mode 100644
index 834de64..0000000
--- a/vcflib/src/vcfstreamsort.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-#include "Variant.h"
-#include <algorithm>
-#include <getopt.h>
-#include "convert.h"
-
-using namespace std;
-using namespace vcf;
-
-bool listContains(list<string>& l, string& v) {
-    for (list<string>::iterator i = l.begin(); i != l.end(); ++i) {
-        if (*i == v) return true;
-    }
-    return false;
-}
-
-void printSummary(char** argv) {
-    cerr << "usage: " << argv[0] << " [options] [vcf file]" << endl
-         << endl
-         << "Sorts the input (either stdin or file) using a streaming sort algorithm."
-         << endl
-         << "options:" << endl
-         << endl
-         << "    -h, --help             this dialog" << endl
-         << "    -w, --window N         number of sites to sort (default 10000)" << endl
-         << "    -a, --all              load all sites and then sort in memory" << endl;
-}
-
-int main(int argc, char** argv) {
-
-    VariantCallFile variantFile;
-    int sortSitesWindow = 10000;
-    bool sortAll = false;
-
-    int c;
-
-    while (true) {
-        static struct option long_options[] =
-        {  
-            /* These options set a flag. */
-            //{"verbose", no_argument,       &verbose_flag, 1},
-            {"help", no_argument, 0, 'h'},
-            {"window", required_argument, 0, 'w'},
-            {"all", required_argument, 0, 'a'},
-            {0, 0, 0, 0}
-        };
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, "haw:",
-                         long_options, &option_index);
-
-        if (c == -1)
-            break;
-
-        string field;
-
-        switch (c)
-        {
-
-        case 'w':
-            if (!convert(optarg, sortSitesWindow)) {
-                cerr << "could not parse --window, -w" << endl;
-                exit(1);
-            }
-            break;
-                
-        case 'a':
-            sortAll = true;
-            break;
-
-        case 'h':
-            printSummary(argv);
-            exit(0);
-            break;
-            
-        default:
-            break;
-        }
-    }
-
-    if (optind == argc - 1) {
-        string inputFilename = argv[optind];
-        variantFile.open(inputFilename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    cout << variantFile.header << endl;
-
-    map<string, map<long int, map<string, vector<Variant> > > > records;
-    long int back = 0;
-    int numrecords = 0;
-    list<string> sequenceNames;
-
-    variantFile.parseSamples = false;
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-        //cerr << "at position " << var.sequenceName << ":" << var.position << endl;
-        if (!listContains(sequenceNames, var.sequenceName)) {
-            //cerr << "adding new sequence name " << var.sequenceName << endl;
-            sequenceNames.push_back(var.sequenceName);
-        }
-        records[var.sequenceName][var.position][var.vrepr()].push_back(var);
-        if (records[var.sequenceName][var.position].size() == 1) ++numrecords;
-        if (!sortAll && numrecords > sortSitesWindow) {
-            //cerr << "outputting a position" << endl;
-            if (records[sequenceNames.front()].empty()) {
-                //cerr << "end of reference sequence " << sequenceNames.front() << endl;
-                sequenceNames.pop_front();
-            }
-            map<long int, map<string, vector<Variant> > >& frecords = records[sequenceNames.front()];
-            map<string, vector<Variant> >& vars = frecords.begin()->second;
-            for (map<string, vector<Variant> >::iterator v = vars.begin(); v != vars.end(); ++v) {
-                for (vector<Variant>::iterator s = v->second.begin(); s != v->second.end(); ++s) {
-                    cout << s->originalLine << endl;
-                }
-            }
-            frecords.erase(frecords.begin());
-            --numrecords;
-        }
-    }
-    //cerr << "done processing input, cleaning up" << endl;
-    for (list<string>::iterator s = sequenceNames.begin(); s != sequenceNames.end(); ++s) {
-        map<long int, map<string, vector<Variant> > >& q = records[*s];
-        for (map<long int, map<string, vector<Variant> > >::iterator r = q.begin(); r != q.end(); ++r) {
-            for (map<string, vector<Variant> >::iterator v = r->second.begin(); v != r->second.end(); ++v) {
-                for (vector<Variant>::iterator s = v->second.begin(); s != v->second.end(); ++s) {
-                    cout << s->originalLine << endl;
-                }
-            }
-            --numrecords;
-        }
-    }
-    //cerr << numrecords << " remain" << endl;
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfuniq.cpp b/vcflib/src/vcfuniq.cpp
deleted file mode 100644
index 30ad21b..0000000
--- a/vcflib/src/vcfuniq.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-#include "Variant.h"
-
-using namespace std;
-using namespace vcf;
-
-int main(int argc, char** argv) {
-
-    VariantCallFile variantFile;
-
-    if (argc > 1) {
-        string filename = argv[1];
-        variantFile.open(filename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    cout << variantFile.header << endl;
-
-    string lastsn;
-    long int lastpos;
-    string lastref;
-    vector<string> lastalt;
-
-    variantFile.parseSamples = false;
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-        if (!lastsn.empty()
-            && (lastsn == var.sequenceName
-                && lastpos == var.position
-                && lastref == var.ref
-                && lastalt == var.alt)) {
-            continue;
-        } else {
-            lastsn = var.sequenceName;
-            lastpos = var.position;
-            lastref = var.ref;
-            lastalt = var.alt;
-            cout << var.originalLine << endl;
-        }
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/src/vcfuniqalleles.cpp b/vcflib/src/vcfuniqalleles.cpp
deleted file mode 100644
index 3c1c7e2..0000000
--- a/vcflib/src/vcfuniqalleles.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-#include "Variant.h"
-#include <set>
-
-using namespace std;
-using namespace vcf;
-
-int main(int argc, char** argv) {
-
-    VariantCallFile variantFile;
-
-    if (argc > 1) {
-        string filename = argv[1];
-        variantFile.open(filename);
-    } else {
-        variantFile.open(std::cin);
-    }
-
-    if (!variantFile.is_open()) {
-        return 1;
-    }
-
-    cout << variantFile.header << endl;
-
-    string lastsn;
-    long int lastpos;
-    string lastref;
-    vector<string> lastalt;
-
-    Variant var(variantFile);
-    while (variantFile.getNextVariant(var)) {
-        set<string> alleles;
-        vector<string> alleles_to_remove;
-        for (vector<string>::iterator a = var.alt.begin(); a != var.alt.end(); ++a) {
-            if (*a != var.ref) {
-                if (alleles.find(*a) == alleles.end()) {
-                    alleles.insert(*a);
-                } else {
-                    alleles_to_remove.push_back(*a);
-                }
-            } else {
-                alleles_to_remove.push_back(*a); // same as ref
-            }
-        }
-        for (vector<string>::iterator a = alleles_to_remove.begin(); a != alleles_to_remove.end(); ++a) {
-            cerr << "removing " << *a << " from " << var.sequenceName << ":" << var.position << endl;
-            var.removeAlt(*a);
-        }
-        cout << var << endl;
-    }
-
-    return 0;
-
-}
-
diff --git a/vcflib/tabixpp/ChangeLog b/vcflib/tabixpp/ChangeLog
deleted file mode 100644
index fd335b8..0000000
--- a/vcflib/tabixpp/ChangeLog
+++ /dev/null
@@ -1,593 +0,0 @@
-------------------------------------------------------------------------
-r942 | lh3lh3 | 2011-03-31 16:39:50 -0400 (Thu, 31 Mar 2011) | 2 lines
-Changed paths:
-   M /trunk/tabix/main.c
-
-update version number
-
-------------------------------------------------------------------------
-r940 | lh3lh3 | 2011-03-31 16:38:03 -0400 (Thu, 31 Mar 2011) | 2 lines
-Changed paths:
-   M /trunk/tabix/bedidx.c
-   M /trunk/tabix/main.c
-
-fixed two bugs due to recent changes
-
-------------------------------------------------------------------------
-r939 | lh3lh3 | 2011-03-31 16:12:21 -0400 (Thu, 31 Mar 2011) | 2 lines
-Changed paths:
-   M /trunk/tabix/bgzf.c
-   M /trunk/tabix/bgzf.h
-   M /trunk/tabix/main.c
-
-update to the latest bgzf.*
-
-------------------------------------------------------------------------
-r938 | lh3lh3 | 2011-03-31 16:02:21 -0400 (Thu, 31 Mar 2011) | 2 lines
-Changed paths:
-   M /trunk/tabix/index.c
-   M /trunk/tabix/main.c
-   M /trunk/tabix/tabix.h
-
-BED support
-
-------------------------------------------------------------------------
-r937 | lh3lh3 | 2011-03-31 15:03:49 -0400 (Thu, 31 Mar 2011) | 2 lines
-Changed paths:
-   M /trunk/tabix/Makefile
-   A /trunk/tabix/bedidx.c
-   M /trunk/tabix/example.gtf.gz.tbi
-   M /trunk/tabix/index.c
-   A /trunk/tabix/kseq.h
-   M /trunk/tabix/tabix.h
-
-restructure get_intv() for BED support
-
-------------------------------------------------------------------------
-r919 | petulda | 2011-02-24 10:14:14 -0500 (Thu, 24 Feb 2011) | 1 line
-Changed paths:
-   M /trunk/tabix/bgzf.c
-   M /trunk/tabix/bgzf.h
-   M /trunk/tabix/index.c
-   M /trunk/tabix/main.c
-
-New -r (reheader) option for efficient header replacement.
-------------------------------------------------------------------------
-r915 | lh3lh3 | 2011-02-22 09:50:57 -0500 (Tue, 22 Feb 2011) | 2 lines
-Changed paths:
-   A /trunk/tabix/python
-   A /trunk/tabix/python/setup.py (from /trunk/tabix/setup.py:914)
-   A /trunk/tabix/python/tabixmodule.c (from /trunk/tabix/tabixmodule.c:914)
-   A /trunk/tabix/python/test.py (from /trunk/tabix/test.py:914)
-   D /trunk/tabix/setup.py
-   D /trunk/tabix/tabixmodule.c
-   D /trunk/tabix/test.py
-
-move to a new python/ directory
-
-------------------------------------------------------------------------
-r914 | lh3lh3 | 2011-02-22 09:49:35 -0500 (Tue, 22 Feb 2011) | 2 lines
-Changed paths:
-   A /trunk/tabix/setup.py
-   A /trunk/tabix/tabixmodule.c
-   A /trunk/tabix/test.py
-
-CPython C-API by Hyeshik Chang
-
-------------------------------------------------------------------------
-r904 | petulda | 2011-01-28 08:06:27 -0500 (Fri, 28 Jan 2011) | 1 line
-Changed paths:
-   M /trunk/tabix/index.c
-
-Check the number of fields on each line and exit nicely without segfault
-------------------------------------------------------------------------
-r901 | petulda | 2011-01-21 06:45:37 -0500 (Fri, 21 Jan 2011) | 1 line
-Changed paths:
-   M /trunk/tabix/main.c
-
-Fix: Complain only when VCF is newer, not newer or same mtime
-------------------------------------------------------------------------
-r900 | petulda | 2011-01-21 04:23:04 -0500 (Fri, 21 Jan 2011) | 1 line
-Changed paths:
-   M /trunk/tabix/main.c
-
-Prevent the common user mistake and check the timestamps of the vcf and index file
-------------------------------------------------------------------------
-r876 | lh3lh3 | 2010-12-08 12:38:45 -0500 (Wed, 08 Dec 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix/ChangeLog
-   M /trunk/tabix/NEWS
-   M /trunk/tabix/main.c
-
-Release tabix-0.2.3
-
-------------------------------------------------------------------------
-r875 | lh3lh3 | 2010-12-08 12:28:35 -0500 (Wed, 08 Dec 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix/ChangeLog
-   M /trunk/tabix/index.c
-
-Fixed a minor bug in generating index
-
-------------------------------------------------------------------------
-r855 | petulda | 2010-11-25 11:50:13 -0500 (Thu, 25 Nov 2010) | 1 line
-Changed paths:
-   M /trunk/tabix/main.c
-
-Disable "unknown target name or minus interval" warning.
-------------------------------------------------------------------------
-r775 | petulda | 2010-10-26 15:02:30 -0400 (Tue, 26 Oct 2010) | 1 line
-Changed paths:
-   M /trunk/tabix/main.c
-
-Added -h option to print header lines
-------------------------------------------------------------------------
-r742 | jmarshall | 2010-09-27 06:47:23 -0400 (Mon, 27 Sep 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix
-
-Add svn:ignore properties for intermediate and generated files.
-
-------------------------------------------------------------------------
-r725 | lh3lh3 | 2010-09-15 13:01:53 -0400 (Wed, 15 Sep 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix/bgzip.c
-
-patches by Peter Chines
-
-------------------------------------------------------------------------
-r714 | lh3lh3 | 2010-09-07 10:13:25 -0400 (Tue, 07 Sep 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix/TabixReader.java
-   M /trunk/tabix/index.c
-   M /trunk/tabix/main.c
-
-fixed a bug in C/Java when n_off == 0
-
-------------------------------------------------------------------------
-r712 | lh3lh3 | 2010-09-03 09:21:23 -0400 (Fri, 03 Sep 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix/TabixReader.java
-
-fixed a bug in parsing region strings
-
-------------------------------------------------------------------------
-r700 | petulda | 2010-08-25 10:42:37 -0400 (Wed, 25 Aug 2010) | 1 line
-Changed paths:
-   M /trunk/tabix/main.c
-
-Fix: Exit with an error rather than segfault when index is not present and region is queried
-------------------------------------------------------------------------
-r696 | petulda | 2010-08-24 10:24:12 -0400 (Tue, 24 Aug 2010) | 1 line
-Changed paths:
-   M /trunk/tabix/bgzf.c
-   M /trunk/tabix/bgzf.h
-   M /trunk/tabix/index.c
-   M /trunk/tabix/main.c
-
-Complain about not-bgzipped files and check for noncontinuous chromosome blocks
-------------------------------------------------------------------------
-r603 | lh3lh3 | 2010-06-28 10:49:39 -0400 (Mon, 28 Jun 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix/NEWS
-   M /trunk/tabix/TabixReader.java
-   M /trunk/tabix/index.c
-   M /trunk/tabix/main.c
-
-Release tabix-0.2.2
-
-------------------------------------------------------------------------
-r597 | lh3lh3 | 2010-06-13 21:08:29 -0400 (Sun, 13 Jun 2010) | 3 lines
-Changed paths:
-   M /trunk/tabix/index.c
-
-Change the namespace of sorting, to avoid function name collision with samtools.
-
-
-------------------------------------------------------------------------
-r582 | lh3lh3 | 2010-06-03 10:40:25 -0400 (Thu, 03 Jun 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix/NEWS
-   M /trunk/tabix/main.c
-   M /trunk/tabix/tabix.py
-
-Release tabix-0.2.1
-
-------------------------------------------------------------------------
-r581 | lh3lh3 | 2010-05-24 14:24:24 -0400 (Mon, 24 May 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix/tabix.py
-
-OOP interface with the help from Aaron Quinlan
-
-------------------------------------------------------------------------
-r580 | lh3lh3 | 2010-05-23 23:36:05 -0400 (Sun, 23 May 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix/tabix.py
-
-minor change
-
-------------------------------------------------------------------------
-r579 | lh3lh3 | 2010-05-23 23:25:24 -0400 (Sun, 23 May 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix/tabix.py
-
-For Snow Leopard compatibility
-
-------------------------------------------------------------------------
-r575 | lh3lh3 | 2010-05-12 19:31:27 -0400 (Wed, 12 May 2010) | 4 lines
-Changed paths:
-   M /trunk/tabix/Makefile
-   M /trunk/tabix/index.c
-   M /trunk/tabix/tabix.h
-   A /trunk/tabix/tabix.py
-
- * optionally generate shared library for Mac and Linux
- * added a python script that directly calls the shared library
- * added a new API for easy python access
-
-------------------------------------------------------------------------
-r574 | lh3lh3 | 2010-05-11 12:14:27 -0400 (Tue, 11 May 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix/ChangeLog
-   M /trunk/tabix/NEWS
-   M /trunk/tabix/perl/Tabix.pm
-   M /trunk/tabix/perl/TabixIterator.pm
-   M /trunk/tabix/tabix.1
-
-Release tabix-0.2.0
-
-------------------------------------------------------------------------
-r573 | lh3lh3 | 2010-05-11 12:08:30 -0400 (Tue, 11 May 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix/Makefile
-
-Added -fPIC
-
-------------------------------------------------------------------------
-r572 | lh3lh3 | 2010-05-11 11:59:07 -0400 (Tue, 11 May 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix/perl/MANIFEST
-
-update
-
-------------------------------------------------------------------------
-r571 | lh3lh3 | 2010-05-11 11:56:54 -0400 (Tue, 11 May 2010) | 4 lines
-Changed paths:
-   A /trunk/tabix/example.gtf.gz
-   A /trunk/tabix/example.gtf.gz.tbi
-   M /trunk/tabix/index.c
-   M /trunk/tabix/main.c
-   M /trunk/tabix/perl/MANIFEST
-   M /trunk/tabix/perl/Tabix.pm
-   M /trunk/tabix/perl/Tabix.xs
-   A /trunk/tabix/perl/TabixIterator.pm
-   A /trunk/tabix/perl/t
-   A /trunk/tabix/perl/t/01local.t
-   A /trunk/tabix/perl/t/02remote.t
-   M /trunk/tabix/tabix.1
-   M /trunk/tabix/tabix.h
-
- * improved C/Perl APIs
- * added test for Perl
- * added an tiny example
-
-------------------------------------------------------------------------
-r570 | lh3lh3 | 2010-05-11 01:04:21 -0400 (Tue, 11 May 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix/TabixReader.java
-
-fixed the same issue in java
-
-------------------------------------------------------------------------
-r569 | lh3lh3 | 2010-05-11 01:03:24 -0400 (Tue, 11 May 2010) | 3 lines
-Changed paths:
-   M /trunk/tabix/index.c
-   M /trunk/tabix/perl/Tabix.pm
-   M /trunk/tabix/perl/Tabix.xs
-
- * fixed a potential issue in index.c
- * improve perl APIs
-
-------------------------------------------------------------------------
-r568 | lh3lh3 | 2010-05-10 23:46:21 -0400 (Mon, 10 May 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix/perl/Tabix.xs
-
-return an array from get_names()
-
-------------------------------------------------------------------------
-r567 | lh3lh3 | 2010-05-10 23:38:46 -0400 (Mon, 10 May 2010) | 4 lines
-Changed paths:
-   M /trunk/tabix/TabixReader.java
-   M /trunk/tabix/index.c
-   A /trunk/tabix/perl
-   A /trunk/tabix/perl/MANIFEST
-   A /trunk/tabix/perl/Makefile.PL
-   A /trunk/tabix/perl/Tabix.pm
-   A /trunk/tabix/perl/Tabix.xs
-   A /trunk/tabix/perl/typemap
-   M /trunk/tabix/tabix.h
-
- * added the initial perl binding. The interface needs to be improved.
- * added a new API for perl binding
- * fixed a potential bug in java.
-
-------------------------------------------------------------------------
-r565 | lh3lh3 | 2010-05-09 23:24:35 -0400 (Sun, 09 May 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix/main.c
-
-Release tabix-0.1.6
-
-------------------------------------------------------------------------
-r564 | lh3lh3 | 2010-05-09 23:01:49 -0400 (Sun, 09 May 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix/index.c
-
-fixed a typo
-
-------------------------------------------------------------------------
-r563 | lh3lh3 | 2010-05-09 22:58:26 -0400 (Sun, 09 May 2010) | 2 lines
-Changed paths:
-   A /trunk/tabix/ChangeLog
-   M /trunk/tabix/NEWS
-   M /trunk/tabix/index.c
-   M /trunk/tabix/main.c
-   M /trunk/tabix/tabix.h
-
-If nothing bad happens, this will become 0.1.6
-
-------------------------------------------------------------------------
-r562 | lh3lh3 | 2010-05-09 19:43:56 -0400 (Sun, 09 May 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix/index.c
-
-Fixed a bug
-
-------------------------------------------------------------------------
-r560 | lh3lh3 | 2010-05-05 10:59:09 -0400 (Wed, 05 May 2010) | 3 lines
-Changed paths:
-   A /trunk/tabix/NEWS
-   M /trunk/tabix/TabixReader.java
-   M /trunk/tabix/index.c
-   M /trunk/tabix/main.c
-   M /trunk/tabix/tabix.1
-   M /trunk/tabix/tabix.h
-
- * Release tabix-0.1.5 (r560)
- * Improve seeking efficiency. Index file needs to be rebuilt.
-
-------------------------------------------------------------------------
-r559 | lh3lh3 | 2010-05-04 23:11:42 -0400 (Tue, 04 May 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix/main.c
-
-Release tabix-0.1.4 (r559)
-
-------------------------------------------------------------------------
-r558 | lh3lh3 | 2010-05-01 12:48:01 -0400 (Sat, 01 May 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix/TabixReader.java
-
-implement SAM/VCF support; NOT tested yet
-
-------------------------------------------------------------------------
-r557 | lh3lh3 | 2010-05-01 00:42:34 -0400 (Sat, 01 May 2010) | 2 lines
-Changed paths:
-   A /trunk/tabix/TabixReader.java
-
-The Java implementation of tabix.
-
-------------------------------------------------------------------------
-r556 | lh3lh3 | 2010-04-30 22:34:07 -0400 (Fri, 30 Apr 2010) | 4 lines
-Changed paths:
-   M /trunk/tabix/index.c
-   M /trunk/tabix/knetfile.c
-   M /trunk/tabix/main.c
-
- * tabix-0.1.3-3 (r556)
- * fixed a small memory leak in knetfile
- * fixed a minor bug for remote downloading
-
-------------------------------------------------------------------------
-r555 | lh3lh3 | 2010-04-30 22:15:12 -0400 (Fri, 30 Apr 2010) | 4 lines
-Changed paths:
-   M /trunk/tabix/Makefile
-   M /trunk/tabix/index.c
-   M /trunk/tabix/main.c
-
- * tabix-0.1.3-2 (r555)
- * do not overwrite index file by default
- * a little code cleanup
-
-------------------------------------------------------------------------
-r554 | lh3lh3 | 2010-04-30 21:44:31 -0400 (Fri, 30 Apr 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix/index.c
-
-fixed a potential bug for UCSC-like coordinate
-
-------------------------------------------------------------------------
-r553 | lh3lh3 | 2010-04-28 17:43:41 -0400 (Wed, 28 Apr 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix/tabix.tex
-
-minor clarification to the format spec
-
-------------------------------------------------------------------------
-r552 | lh3lh3 | 2010-04-28 16:33:07 -0400 (Wed, 28 Apr 2010) | 3 lines
-Changed paths:
-   M /trunk/tabix/Makefile
-   M /trunk/tabix/bgzip.c
-   A /trunk/tabix/tabix.tex
-
- * added the format specification
- * fixed a typo in bgzip
-
-------------------------------------------------------------------------
-r550 | petulda | 2010-04-22 11:03:24 -0400 (Thu, 22 Apr 2010) | 1 line
-Changed paths:
-   M /trunk/tabix/bgzip.c
-
-The behaviour changed slightly to mimic gzip. Detect if std descriptors are connected to the terminal.
-------------------------------------------------------------------------
-r549 | petulda | 2010-04-22 09:46:10 -0400 (Thu, 22 Apr 2010) | 1 line
-Changed paths:
-   M /trunk/tabix/bgzip.c
-
-Fix in src/dst file detection and slight change of behaviour
-------------------------------------------------------------------------
-r548 | petulda | 2010-04-19 04:39:46 -0400 (Mon, 19 Apr 2010) | 1 line
-Changed paths:
-   M /trunk/tabix/index.c
-
-Close file descriptor in ti_list_chromosomes
-------------------------------------------------------------------------
-r547 | petulda | 2010-04-16 09:27:11 -0400 (Fri, 16 Apr 2010) | 1 line
-Changed paths:
-   M /trunk/tabix/index.c
-   M /trunk/tabix/main.c
-   M /trunk/tabix/tabix.h
-
-Added the -l option for listing chromosomes
-------------------------------------------------------------------------
-r544 | lh3lh3 | 2010-03-29 10:58:48 -0400 (Mon, 29 Mar 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix/main.c
-
-removed a line of debugging code
-
-------------------------------------------------------------------------
-r543 | lh3lh3 | 2010-03-19 12:29:16 -0400 (Fri, 19 Mar 2010) | 3 lines
-Changed paths:
-   M /trunk/tabix/index.c
-   M /trunk/tabix/main.c
-   M /trunk/tabix/tabix.1
-
- * tabix-0.1.3 (r543)
- * fixed another off-by-one bug
-
-------------------------------------------------------------------------
-r542 | lh3lh3 | 2010-03-16 22:35:52 -0400 (Tue, 16 Mar 2010) | 2 lines
-Changed paths:
-   M /trunk/tabix/index.c
-   M /trunk/tabix/main.c
-   M /trunk/tabix/tabix.1
-
-Release tabix-0.1.1
-
-------------------------------------------------------------------------
-r506 | lh3lh3 | 2009-11-02 23:20:12 -0500 (Mon, 02 Nov 2009) | 2 lines
-Changed paths:
-   M /trunk/tabix/main.c
-
-Release tabix-0.1.0
-
-------------------------------------------------------------------------
-r505 | lh3lh3 | 2009-11-02 23:15:49 -0500 (Mon, 02 Nov 2009) | 2 lines
-Changed paths:
-   A /trunk/tabix/tabix.1
-
-documentation
-
-------------------------------------------------------------------------
-r504 | lh3lh3 | 2009-11-02 11:08:18 -0500 (Mon, 02 Nov 2009) | 5 lines
-Changed paths:
-   M /trunk/tabix/Makefile
-   M /trunk/tabix/bgzip.c
-   M /trunk/tabix/index.c
-   M /trunk/tabix/main.c
-   M /trunk/tabix/tabix.h
-
- * tabix-0.0.0-5 (r504)
- * fixed a critical bug in fetching data (a typo in fact)
- * support SAM (tested on ex1.sam) and VCF (not tested)
- * improve the command-line interface
-
-------------------------------------------------------------------------
-r503 | lh3lh3 | 2009-11-02 10:04:43 -0500 (Mon, 02 Nov 2009) | 3 lines
-Changed paths:
-   M /trunk/tabix/Makefile
-   M /trunk/tabix/index.c
-   M /trunk/tabix/main.c
-
- * tabix-0.0.0-4 (r503)
- * index files are bgzf compressed
-
-------------------------------------------------------------------------
-r502 | lh3lh3 | 2009-11-02 09:47:25 -0500 (Mon, 02 Nov 2009) | 4 lines
-Changed paths:
-   M /trunk/tabix/index.c
-   M /trunk/tabix/main.c
-   M /trunk/tabix/tabix.h
-
- * tabix-0.0.0-3 (r502)
- * support meta lines (not tested)
- * I am going to make the index file in the BGZF format
-
-------------------------------------------------------------------------
-r501 | lh3lh3 | 2009-11-01 22:03:07 -0500 (Sun, 01 Nov 2009) | 3 lines
-Changed paths:
-   M /trunk/tabix/Makefile
-   M /trunk/tabix/bgzf.h
-   M /trunk/tabix/index.c
-   M /trunk/tabix/main.c
-
- * tabix-0.0.0-2 (r501)
- * accelerate ti_readline()
-
-------------------------------------------------------------------------
-r500 | lh3lh3 | 2009-11-01 20:49:52 -0500 (Sun, 01 Nov 2009) | 3 lines
-Changed paths:
-   M /trunk/tabix/Makefile
-   M /trunk/tabix/bgzip.c
-   M /trunk/tabix/index.c
-   M /trunk/tabix/main.c
-
- * tabix-0.0.0-1 (r500)
- * apparently working
-
-------------------------------------------------------------------------
-r499 | lh3lh3 | 2009-11-01 14:04:52 -0500 (Sun, 01 Nov 2009) | 2 lines
-Changed paths:
-   D /trunk/tabix/parser.c
-
-obsolete file
-
-------------------------------------------------------------------------
-r498 | lh3lh3 | 2009-11-01 14:04:08 -0500 (Sun, 01 Nov 2009) | 2 lines
-Changed paths:
-   M /trunk/tabix/bgzip.c
-
-bgzip is more like gzip in its command-line interface
-
-------------------------------------------------------------------------
-r497 | lh3lh3 | 2009-11-01 13:43:35 -0500 (Sun, 01 Nov 2009) | 2 lines
-Changed paths:
-   A /trunk/tabix/Makefile
-   A /trunk/tabix/bam_endian.h
-   A /trunk/tabix/bgzf.c
-   A /trunk/tabix/bgzf.h
-   A /trunk/tabix/bgzip.c
-   A /trunk/tabix/index.c
-   A /trunk/tabix/khash.h
-   A /trunk/tabix/knetfile.c
-   A /trunk/tabix/knetfile.h
-   A /trunk/tabix/ksort.h
-   A /trunk/tabix/kstring.c
-   A /trunk/tabix/kstring.h
-   A /trunk/tabix/main.c
-   A /trunk/tabix/parser.c
-   A /trunk/tabix/tabix.h
-
-initial source code. It is BUGGY!
-
-------------------------------------------------------------------------
-r496 | lh3lh3 | 2009-11-01 13:42:39 -0500 (Sun, 01 Nov 2009) | 2 lines
-Changed paths:
-   A /trunk/tabix
-
-A generic indexer for TAB-delimited genome position files
-
-------------------------------------------------------------------------
diff --git a/vcflib/tabixpp/Makefile b/vcflib/tabixpp/Makefile
deleted file mode 100644
index 0702ed3..0000000
--- a/vcflib/tabixpp/Makefile
+++ /dev/null
@@ -1,71 +0,0 @@
-CC=			gcc
-CPP= 		g++
-CFLAGS=		-g -Wall -O2 -fPIC #-m64 #-arch ppc
-DFLAGS=		-D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE
-LOBJS=		bgzf.o kstring.o knetfile.o index.o bedidx.o
-AOBJS=		main.o
-PROG=		tabix bgzip tabix++
-INCLUDES=
-SUBDIRS=	.
-LIBPATH=
-LIBCURSES=	
-
-.SUFFIXES:.c .o
-
-.c.o:
-		$(CC) -c $(CFLAGS) $(DFLAGS) $(INCLUDES) $< -o $@
-
-all-recur lib-recur clean-recur cleanlocal-recur install-recur:
-		@target=`echo $@ | sed s/-recur//`; \
-		wdir=`pwd`; \
-		list='$(SUBDIRS)'; for subdir in $$list; do \
-			cd $$subdir; \
-			$(MAKE) CC="$(CC)" DFLAGS="$(DFLAGS)" CFLAGS="$(CFLAGS)" \
-				INCLUDES="$(INCLUDES)" LIBPATH="$(LIBPATH)" $$target || exit 1; \
-			cd $$wdir; \
-		done;
-
-all:$(PROG)
-
-lib:libtabix.a
-
-libtabix.so.1:$(LOBJS)
-		$(CC) -shared -Wl,-soname,libtabix.so -o $@ $(LOBJS) -lc -lz
-
-libtabix.1.dylib:$(LOBJS)
-		libtool -dynamic $(LOBJS) -o $@ -lc -lz
-
-libtabix.a:$(LOBJS)
-		$(AR) -cru $@ $(LOBJS)
-		ranlib $@
-
-tabix:lib $(AOBJS)
-		$(CC) $(CFLAGS) -o $@ $(AOBJS) -lm $(LIBPATH) -L. -ltabix -lz
-
-tabix.o: tabix.hpp tabix.cpp
-		$(CPP) $(CFLAGS) -c tabix.cpp
-
-tabix++:lib tabix.o main.cpp
-		$(CPP) $(CFLAGS) -o $@ main.cpp tabix.o bgzf.o -lm $(LIBPATH) -L. -ltabix -lz
-
-bgzip:bgzip.o bgzf.o knetfile.o
-		$(CC) $(CFLAGS) -o $@ bgzip.o bgzf.o knetfile.o -lz
-
-TabixReader.class:TabixReader.java
-		javac -cp .:sam.jar TabixReader.java
-
-kstring.o:kstring.h
-knetfile.o:knetfile.h
-bgzf.o:bgzf.h knetfile.h
-index.o:bgzf.h tabix.h khash.h ksort.h kstring.h
-main.o:tabix.h kstring.h bgzf.h
-bgzip.o:bgzf.h
-bedidx.o:kseq.h khash.h
-
-tabix.pdf:tabix.tex
-		pdflatex tabix.tex
-
-cleanlocal:
-		rm -fr gmon.out *.o a.out *.dSYM $(PROG) *~ *.a tabix.aux tabix.log tabix.pdf *.class libtabix.*.dylib libtabix.so*
-
-clean:cleanlocal-recur
diff --git a/vcflib/tabixpp/NEWS b/vcflib/tabixpp/NEWS
deleted file mode 100644
index d230541..0000000
--- a/vcflib/tabixpp/NEWS
+++ /dev/null
@@ -1,126 +0,0 @@
-Release 0.2.4 (10 April, 2011)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Notable changes:
-
- * Give an error if the index file is older than the data file.
-
- * Avoid a segfault given flawed input.
-
- * Added Python APIs contributed by Hyeshik Chang. The new APIs do not bind to
-   the dynamic library and are reported to be faster. Pysam also comes with a
-   tabix binding.
-
- * Added option "-r" for efficient header replacement.
-
- * Added BED support.
-
- * Synchronized the BGZF library between tabix and samtools.
-
-(0.2.4: 10 April 2011, r949)
-
-
-
-Beta Release 0.2.3 (8 December, 2010)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Notable changes:
-
- * Fixed a minor bug where the first record in a headerless file may be
-   missed.
-
- * Added an option to print header lines.
-
- * Fixed a rare bug which may occasionally happen when retrieving data
-   from a region without any records.
-
- * Enhanced error reporting.
-
- * Fixed a bug in bgzip which may delete the original file even if not
-   intended.
-
-(0.2.3: 8 December 2010, r876)
-
-
-
-Beta Release 0.2.2 (28 June, 2010)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Notable changes:
-
- * Dropped the VCF3 support. Added VCF4 support.
-
- * Avoided the function name collision with samtools.
-
-(0.2.2: 28 June 2010, r603)
-
-
-
-Beta Release 0.2.1 (3 June, 2010)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Notable changes:
-
- * Allow shared library to be compiled. Added python binding to the
-   shared library.
-
-(0.2.1: 3 June 2010, r582)
-
-
-
-Beta Release 0.2.0 (11 May, 2010)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Notable changes:
-
- * Fixed an issue for random access given an interval end larger than
-   2^29.
-
- * Updated the Java binding.
-
- * Added a Perl module using XS.
-
- * Improved the C APIs.
-
-(0.2.0: 11 May 2010, r574)
-
-
-
-Beta Release 0.1.6 (9 May, 2010)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Notable changes:
-
- * Improved backward compatibility. Release 0.1.5 does not work with the
-   buggy index file generated by 0.1.2.
-
- * Fixed a bug in building linear index. The bug does not affect the
-   results, only affects efficiency in rare cases.
-
- * Reduced the number of seek calls given an index generated by old
-   version of tabix.
-
- * Added new APIs for retrieving data via an iterator. The old callback
-   APIs are not changed, although internally it uses iterator to
-   retrieve data.
-
-I am trying to freeze tabix. I just hope I am committing new bugs.
-
-(0.1.6: 9 May 2010, r563)
-
-
-
-Beta Release 0.1.5 (5 May, 2010)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Notable changes:
-
- * Clarified that tabix is released under MIT/X11.
-
- * Improved the robustness of indexing and retrieval.
-
- * Reduced the number of seek calls when the specified region starts
-   from a 16kb block with no data. The index format is the same, but the
-   content is changed a little.
-
-(0.1.5: 5 May 2010, r560)
diff --git a/vcflib/tabixpp/README b/vcflib/tabixpp/README
deleted file mode 100644
index 966660e..0000000
--- a/vcflib/tabixpp/README
+++ /dev/null
@@ -1,6 +0,0 @@
-This is a fork of the tabix project [1] which includes a C++ class wrapper for
-reading tabix-indexed files.
-
-Author: Erik Garrison <erik.garrison at bc.edu>
-
-[1] http://samtools.sourceforge.net/tabix.shtml
diff --git a/vcflib/tabixpp/TabixReader.java b/vcflib/tabixpp/TabixReader.java
deleted file mode 100644
index 5874202..0000000
--- a/vcflib/tabixpp/TabixReader.java
+++ /dev/null
@@ -1,395 +0,0 @@
-/* The MIT License
-
-   Copyright (c) 2010 Broad Institute.
-
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   "Software"), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
-
-   The above copyright notice and this permission notice shall be
-   included in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-   SOFTWARE.
-*/
-
-/* Contact: Heng Li <hengli at broadinstitute.org> */
-
-import net.sf.samtools.util.BlockCompressedInputStream;
-
-import java.io.*;
-import java.nio.*;
-import java.util.HashMap;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.lang.StringBuffer;
-
-public class TabixReader
-{
-	private String mFn;
-	private BlockCompressedInputStream mFp;
-
-	private int mPreset;
-	private int mSc;
-	private int mBc;
-	private int mEc;
-	private int mMeta;
-	private int mSkip;
-	private String[] mSeq;
-
-	private HashMap<String, Integer> mChr2tid;
-
-	private static int MAX_BIN = 37450;
-	private static int TAD_MIN_CHUNK_GAP = 32768;
-	private static int TAD_LIDX_SHIFT = 14;
-
-	private class TPair64 implements Comparable<TPair64> {
-		long u, v;
-		public TPair64(final long _u, final long _v) {
-			u = _u; v = _v;
-		}
-		public TPair64(final TPair64 p) {
-			u = p.u; v = p.v;
-		}
-		public int compareTo(final TPair64 p) {
-			return u == p.u? 0 : ((u < p.u) ^ (u < 0) ^ (p.u < 0))? -1 : 1; // unsigned 64-bit comparison
-		}
-	};
-
-	private class TIndex {
-		HashMap<Integer, TPair64[]> b; // binning index
-		long[] l; // linear index
-	};
-	private TIndex[] mIndex;
-
-	private class TIntv {
-		int tid, beg, end;
-	};
-
-	private static boolean less64(final long u, final long v) { // unsigned 64-bit comparison
-		return (u < v) ^ (u < 0) ^ (v < 0);
-	}
-
-	/**
-	 * The constructor
-	 *
-	 * @param fn File name of the data file
-	 */
-	public TabixReader(final String fn) throws IOException {
-		mFn = fn;
-		mFp = new BlockCompressedInputStream(new File(fn));
-		readIndex();
-	}
-
-	private static int reg2bins(final int beg, final int _end, final int[] list) {
-		int i = 0, k, end = _end;
-		if (beg >= end) return 0;
-		if (end >= 1<<29) end = 1<<29;
-		--end;
-		list[i++] = 0;
-		for (k =    1 + (beg>>26); k <=    1 + (end>>26); ++k) list[i++] = k;
-		for (k =    9 + (beg>>23); k <=    9 + (end>>23); ++k) list[i++] = k;
-		for (k =   73 + (beg>>20); k <=   73 + (end>>20); ++k) list[i++] = k;
-		for (k =  585 + (beg>>17); k <=  585 + (end>>17); ++k) list[i++] = k;
-		for (k = 4681 + (beg>>14); k <= 4681 + (end>>14); ++k) list[i++] = k;
-		return i;
-	}
-
-	public static int readInt(final InputStream is) throws IOException {
-		byte[] buf = new byte[4];
-		is.read(buf);
-		return ByteBuffer.wrap(buf).order(ByteOrder.LITTLE_ENDIAN).getInt();
-	}
-
-	public static long readLong(final InputStream is) throws IOException {
-		byte[] buf = new byte[8];
-		is.read(buf);
-		return ByteBuffer.wrap(buf).order(ByteOrder.LITTLE_ENDIAN).getLong();
-	}
-
-	public static String readLine(final InputStream is) throws IOException {
-		StringBuffer buf = new StringBuffer();
-		int c;
-		while ((c = is.read()) >= 0 && c != '\n')
-			buf.append((char)c);
-		if (c < 0) return null;
-		return buf.toString();
-	}
-
-	/**
-	 * Read the Tabix index from a file
-	 *
-	 * @param fp File pointer
-	 */
-	public void readIndex(final File fp) throws IOException {
-		if (fp == null) return;
-		BlockCompressedInputStream is = new BlockCompressedInputStream(fp);
-		byte[] buf = new byte[4];
-
-		is.read(buf, 0, 4); // read "TBI\1"
-		mSeq = new String[readInt(is)]; // # sequences
-		mChr2tid = new HashMap<String, Integer>();
-		mPreset = readInt(is);
-		mSc = readInt(is);
-		mBc = readInt(is);
-		mEc = readInt(is);
-		mMeta = readInt(is);
-		mSkip = readInt(is);
-		// read sequence dictionary
-		int i, j, k, l = readInt(is);
-		buf = new byte[l];
-		is.read(buf);
-		for (i = j = k = 0; i < buf.length; ++i) {
-			if (buf[i] == 0) {
-				byte[] b = new byte[i - j];
-				System.arraycopy(buf, j, b, 0, b.length);
-				String s = new String(b);
-				mChr2tid.put(s, k);
-				mSeq[k++] = s;
-				j = i + 1;
-			}
-		}
-		// read the index
-		mIndex = new TIndex[mSeq.length];
-		for (i = 0; i < mSeq.length; ++i) {
-			// the binning index
-			int n_bin = readInt(is);
-			mIndex[i] = new TIndex();
-			mIndex[i].b = new HashMap<Integer, TPair64[]>();
-			for (j = 0; j < n_bin; ++j) {
-				int bin = readInt(is);
-				TPair64[] chunks = new TPair64[readInt(is)];
-				for (k = 0; k < chunks.length; ++k) {
-					long u = readLong(is);
-					long v = readLong(is);
-					chunks[k] = new TPair64(u, v); // in C, this is inefficient
-				}
-				mIndex[i].b.put(bin, chunks);
-			}
-			// the linear index
-			mIndex[i].l = new long[readInt(is)];
-			for (k = 0; k < mIndex[i].l.length; ++k)
-				mIndex[i].l[k] = readLong(is);
-		}
-		// close
-		is.close();
-	}
-
-	/**
-	 * Read the Tabix index from the default file.
-	 */
-	public void readIndex() throws IOException {
-		readIndex(new File(mFn + ".tbi"));
-	}
-
-	/**
-	 * Read one line from the data file.
-	 */
-	public String readLine() throws IOException {
-		return readLine(mFp);
-	}
-
-	private int chr2tid(final String chr) {
-		if (mChr2tid.containsKey(chr)) return mChr2tid.get(chr);
-		else return -1;
-	}
-
-	/**
-	 * Parse a region in the format of "chr1", "chr1:100" or "chr1:100-1000"
-	 *
-	 * @param reg Region string
-	 * @return An array where the three elements are sequence_id,
-	 *         region_begin and region_end. On failure, sequence_id==-1.
-	 */
-	public int[] parseReg(final String reg) { // FIXME: NOT working when the sequence name contains : or -.
-		String chr;
-		int colon, hyphen;
-		int[] ret = new int[3];
-		colon = reg.indexOf(':'); hyphen = reg.indexOf('-');
-		chr = colon >= 0? reg.substring(0, colon) : reg;
-		ret[1] = colon >= 0? Integer.parseInt(reg.substring(colon+1, hyphen >= 0? hyphen : reg.length())) - 1 : 0;
-		ret[2] = hyphen >= 0? Integer.parseInt(reg.substring(hyphen+1)) : 0x7fffffff;
-		ret[0] = chr2tid(chr);
-		return ret;
-	}
-
-	private TIntv getIntv(final String s) {
-		TIntv intv = new TIntv();
-		int col = 0, end = 0, beg = 0;
-		while ((end = s.indexOf('\t', beg)) >= 0 || end == -1) {
-			++col;
-			if (col == mSc) {
-				intv.tid = chr2tid(s.substring(beg, end));
-			} else if (col == mBc) {
-				intv.beg = intv.end = Integer.parseInt(s.substring(beg, end));
-				if ((mPreset&0x10000) != 0) ++intv.end;
-				else --intv.beg;
-				if (intv.beg < 0) intv.beg = 0;
-				if (intv.end < 1) intv.end = 1;
-			} else { // FIXME: SAM supports are not tested yet
-				if ((mPreset&0xffff) == 0) { // generic
-					if (col == mEc)
-						intv.end = Integer.parseInt(s.substring(beg, end));
-				} else if ((mPreset&0xffff) == 1) { // SAM
-					if (col == 6) { // CIGAR
-						int l = 0, i, j;
-						String cigar = s.substring(beg, end);
-						for (i = j = 0; i < cigar.length(); ++i) {
-							if (cigar.charAt(i) > '9') {
-								int op = cigar.charAt(i);
-								if (op == 'M' || op == 'D' || op == 'N')
-									l += Integer.parseInt(cigar.substring(j, i));
-							}
-						}
-						intv.end = intv.beg + l;
-					}
-				} else if ((mPreset&0xffff) == 2) { // VCF
-					String alt;
-					alt = end >= 0? s.substring(beg, end) : s.substring(beg);
-					if (col == 4) { // REF
-						if (alt.length() > 0) intv.end = intv.beg + alt.length();
-					} else if (col == 8) { // INFO
-						int e_off = -1, i = alt.indexOf("END=");
-						if (i == 0) e_off = 4;
-						else if (i > 0) {
-							i = alt.indexOf(";END=");
-							if (i >= 0) e_off = i + 5;
-						}
-						if (e_off > 0) {
-							i = alt.indexOf(";", e_off);
-							intv.end = Integer.parseInt(i > e_off? alt.substring(e_off, i) : alt.substring(e_off));
-						}
-					}
-				}
-			}
-			if (end == -1) break;
-			beg = end + 1;
-		}
-		return intv;
-	}
-
-	public class Iterator {
-		private int i, n_seeks;
-		private int tid, beg, end;
-		private TPair64[] off;
-		private long curr_off;
-		private boolean iseof;
-
-		public Iterator(final int _tid, final int _beg, final int _end, final TPair64[] _off) {
-			i = -1; n_seeks = 0; curr_off = 0; iseof = false;
-			off = _off; tid = _tid; beg = _beg; end = _end;
-		}
-
-		public String next() throws IOException {
-			if (iseof) return null;
-			for (;;) {
-				if (curr_off == 0 || !less64(curr_off, off[i].v)) { // then jump to the next chunk
-					if (i == off.length - 1) break; // no more chunks
-					if (i >= 0) assert(curr_off == off[i].v); // otherwise bug
-					if (i < 0 || off[i].v != off[i+1].u) { // not adjacent chunks; then seek
-						mFp.seek(off[i+1].u);
-						curr_off = mFp.getFilePointer();
-						++n_seeks;
-					}
-					++i;
-				}
-				String s;
-				if ((s = readLine(mFp)) != null) {
-					TIntv intv;
-					char[] str = s.toCharArray();
-					curr_off = mFp.getFilePointer();
-					if (str.length == 0 || str[0] == mMeta) continue;
-					intv = getIntv(s);
-					if (intv.tid != tid || intv.beg >= end) break; // no need to proceed
-					else if (intv.end > beg && intv.beg < end) return s; // overlap; return
-				} else break; // end of file
-			}
-			iseof = true;
-			return null;
-		}
-	};
-
-	public Iterator query(final int tid, final int beg, final int end) {
-		TPair64[] off, chunks;
-		long min_off;
-		TIndex idx = mIndex[tid];
-		int[] bins = new int[MAX_BIN];
-		int i, l, n_off, n_bins = reg2bins(beg, end, bins);
-		if (idx.l.length > 0)
-			min_off = (beg>>TAD_LIDX_SHIFT >= idx.l.length)? idx.l[idx.l.length-1] : idx.l[beg>>TAD_LIDX_SHIFT];
-		else min_off = 0;
-		for (i = n_off = 0; i < n_bins; ++i) {
-			if ((chunks = idx.b.get(bins[i])) != null)
-				n_off += chunks.length;
-		}
-		if (n_off == 0) return null;
-		off = new TPair64[n_off];
-		for (i = n_off = 0; i < n_bins; ++i)
-			if ((chunks = idx.b.get(bins[i])) != null)
-				for (int j = 0; j < chunks.length; ++j)
-					if (less64(min_off, chunks[j].v))
-						off[n_off++] = new TPair64(chunks[j]);
-		if (n_off == 0) return null;
-		Arrays.sort(off, 0, n_off);
-		// resolve completely contained adjacent blocks
-		for (i = 1, l = 0; i < n_off; ++i) {
-			if (less64(off[l].v, off[i].v)) {
-				++l;
-				off[l].u = off[i].u; off[l].v = off[i].v;
-			}
-		}
-		n_off = l + 1;
-		// resolve overlaps between adjacent blocks; this may happen due to the merge in indexing
-		for (i = 1; i < n_off; ++i)
-			if (!less64(off[i-1].v, off[i].u)) off[i-1].v = off[i].u;
-		// merge adjacent blocks
-		for (i = 1, l = 0; i < n_off; ++i) {
-			if (off[l].v>>16 == off[i].u>>16) off[l].v = off[i].v;
-			else {
-				++l;
-				off[l].u = off[i].u;
-				off[l].v = off[i].v;
-			}
-		}
-		n_off = l + 1;
-		// return
-		TPair64[] ret = new TPair64[n_off];
-		for (i = 0; i < n_off; ++i) ret[i] = new TPair64(off[i].u, off[i].v); // in C, this is inefficient
-		return new TabixReader.Iterator(tid, beg, end, ret);
-	}
-	
-	public Iterator query(final String reg) {
-		int[] x = parseReg(reg);
-		return query(x[0], x[1], x[2]);
-	}
-
-	public static void main(String[] args) {
-		if (args.length < 1) {
-			System.out.println("Usage: java -cp .:sam.jar TabixReader <in.gz> [region]");
-			System.exit(1);
-		}
-		try {
-			TabixReader tr = new TabixReader(args[0]);
-			String s;
-			if (args.length == 1) { // no region is specified; print the whole file
-				while ((s = tr.readLine()) != null)
-					System.out.println(s);
-			} else { // a region is specified; random access
-				TabixReader.Iterator iter = tr.query(args[1]); // get the iterator
-				while (iter != null && (s = iter.next()) != null)
-					System.out.println(s);
-			}
-		} catch (IOException e) {
-		}
-	}
-}
diff --git a/vcflib/tabixpp/bam_endian.h b/vcflib/tabixpp/bam_endian.h
deleted file mode 100644
index 0fc74a8..0000000
--- a/vcflib/tabixpp/bam_endian.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef BAM_ENDIAN_H
-#define BAM_ENDIAN_H
-
-#include <stdint.h>
-
-static inline int bam_is_big_endian()
-{
-	long one= 1;
-	return !(*((char *)(&one)));
-}
-static inline uint16_t bam_swap_endian_2(uint16_t v)
-{
-	return (uint16_t)(((v & 0x00FF00FFU) << 8) | ((v & 0xFF00FF00U) >> 8));
-}
-static inline void *bam_swap_endian_2p(void *x)
-{
-	*(uint16_t*)x = bam_swap_endian_2(*(uint16_t*)x);
-	return x;
-}
-static inline uint32_t bam_swap_endian_4(uint32_t v)
-{
-	v = ((v & 0x0000FFFFU) << 16) | (v >> 16);
-	return ((v & 0x00FF00FFU) << 8) | ((v & 0xFF00FF00U) >> 8);
-}
-static inline void *bam_swap_endian_4p(void *x)
-{
-	*(uint32_t*)x = bam_swap_endian_4(*(uint32_t*)x);
-	return x;
-}
-static inline uint64_t bam_swap_endian_8(uint64_t v)
-{
-	v = ((v & 0x00000000FFFFFFFFLLU) << 32) | (v >> 32);
-	v = ((v & 0x0000FFFF0000FFFFLLU) << 16) | ((v & 0xFFFF0000FFFF0000LLU) >> 16);
-	return ((v & 0x00FF00FF00FF00FFLLU) << 8) | ((v & 0xFF00FF00FF00FF00LLU) >> 8);
-}
-static inline void *bam_swap_endian_8p(void *x)
-{
-	*(uint64_t*)x = bam_swap_endian_8(*(uint64_t*)x);
-	return x;
-}
-
-#endif
diff --git a/vcflib/tabixpp/bedidx.c b/vcflib/tabixpp/bedidx.c
deleted file mode 100644
index 722877d..0000000
--- a/vcflib/tabixpp/bedidx.c
+++ /dev/null
@@ -1,156 +0,0 @@
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdio.h>
-#include <zlib.h>
-
-#include "ksort.h"
-KSORT_INIT_GENERIC(uint64_t)
-
-#include "kseq.h"
-KSTREAM_INIT(gzFile, gzread, 8192)
-
-typedef struct {
-	int n, m;
-	uint64_t *a;
-	int *idx;
-} bed_reglist_t;
-
-#include "khash.h"
-KHASH_MAP_INIT_STR(reg, bed_reglist_t)
-
-#define LIDX_SHIFT 13
-
-typedef kh_reg_t reghash_t;
-
-int *bed_index_core(int n, uint64_t *a, int *n_idx)
-{
-	int i, j, m, *idx;
-	m = *n_idx = 0; idx = 0;
-	for (i = 0; i < n; ++i) {
-		int beg, end;
-		beg = a[i]>>32 >> LIDX_SHIFT; end = ((uint32_t)a[i]) >> LIDX_SHIFT;
-		if (m < end + 1) {
-			int oldm = m;
-			m = end + 1;
-			kroundup32(m);
-			idx = realloc(idx, m * sizeof(int));
-			for (j = oldm; j < m; ++j) idx[j] = -1;
-		}
-		if (beg == end) {
-			if (idx[beg] < 0) idx[beg] = i;
-		} else {
-			for (j = beg; j <= end; ++j)
-				if (idx[j] < 0) idx[j] = i;
-		}
-		*n_idx = end + 1;
-	}
-	return idx;
-}
-
-void bed_index(void *_h)
-{
-	reghash_t *h = (reghash_t*)_h;
-	khint_t k;
-	for (k = 0; k < kh_end(h); ++k) {
-		if (kh_exist(h, k)) {
-			bed_reglist_t *p = &kh_val(h, k);
-			if (p->idx) free(p->idx);
-			ks_introsort(uint64_t, p->n, p->a);
-			p->idx = bed_index_core(p->n, p->a, &p->m);
-		}
-	}
-}
-
-int bed_overlap_core(const bed_reglist_t *p, int beg, int end)
-{
-	int i, min_off;
-	if (p->n == 0) return 0;
-	min_off = (beg>>LIDX_SHIFT >= p->n)? p->idx[p->n-1] : p->idx[beg>>LIDX_SHIFT];
-	if (min_off < 0) { // TODO: this block can be improved, but speed should not matter too much here
-		int n = beg>>LIDX_SHIFT;
-		if (n > p->n) n = p->n;
-		for (i = n - 1; i >= 0; --i)
-			if (p->idx[i] >= 0) break;
-		min_off = i >= 0? p->idx[i] : 0;
-	}
-	for (i = min_off; i < p->n; ++i) {
-		if ((int)(p->a[i]>>32) >= end) break; // out of range; no need to proceed
-		if ((int32_t)p->a[i] > beg && (int32_t)(p->a[i]>>32) < end)
-			return 1; // find the overlap; return
-	}
-	return 0;
-}
-
-int bed_overlap(const void *_h, const char *chr, int beg, int end)
-{
-	const reghash_t *h = (const reghash_t*)_h;
-	khint_t k;
-	if (!h) return 0;
-	k = kh_get(reg, h, chr);
-	if (k == kh_end(h)) return 0;
-	return bed_overlap_core(&kh_val(h, k), beg, end);
-}
-
-void *bed_read(const char *fn)
-{
-	reghash_t *h = kh_init(reg);
-	gzFile fp;
-	kstream_t *ks;
-	int dret;
-	kstring_t *str;
-	// read the list
-	fp = strcmp(fn, "-")? gzopen(fn, "r") : gzdopen(fileno(stdin), "r");
-	if (fp == 0) return 0;
-	str = calloc(1, sizeof(kstring_t));
-	ks = ks_init(fp);
-	while (ks_getuntil(ks, 0, str, &dret) >= 0) { // read the chr name
-		int beg = -1, end = -1;
-		bed_reglist_t *p;
-		khint_t k = kh_get(reg, h, str->s);
-		if (k == kh_end(h)) { // absent from the hash table
-			int ret;
-			char *s = strdup(str->s);
-			k = kh_put(reg, h, s, &ret);
-			memset(&kh_val(h, k), 0, sizeof(bed_reglist_t));
-		}
-		p = &kh_val(h, k);
-		if (dret != '\n') { // if the lines has other characters
-			if (ks_getuntil(ks, 0, str, &dret) > 0 && isdigit(str->s[0])) {
-				beg = atoi(str->s); // begin
-				if (dret != '\n') {
-					if (ks_getuntil(ks, 0, str, &dret) > 0 && isdigit(str->s[0]))
-						end = atoi(str->s); // end
-				}
-			}
-		}
-		if (dret != '\n') while ((dret = ks_getc(ks)) > 0 && dret != '\n'); // skip the rest of the line
-		if (end < 0 && beg > 0) end = beg, beg = beg - 1; // if there is only one column
-		if (beg >= 0 && end > beg) {
-			if (p->n == p->m) {
-				p->m = p->m? p->m<<1 : 4;
-				p->a = realloc(p->a, p->m * 8);
-			}
-			p->a[p->n++] = (uint64_t)beg<<32 | end;
-		}
-	}
-	ks_destroy(ks);
-	gzclose(fp);
-	free(str->s); free(str);
-	bed_index(h);
-	return h;
-}
-
-void bed_destroy(void *_h)
-{
-	reghash_t *h = (reghash_t*)_h;
-	khint_t k;
-	for (k = 0; k < kh_end(h); ++k) {
-		if (kh_exist(h, k)) {
-			free(kh_val(h, k).a);
-			free(kh_val(h, k).idx);
-			free((char*)kh_key(h, k));
-		}
-	}
-	kh_destroy(reg, h);
-}
diff --git a/vcflib/tabixpp/bgzf.c b/vcflib/tabixpp/bgzf.c
deleted file mode 100644
index 216cd04..0000000
--- a/vcflib/tabixpp/bgzf.c
+++ /dev/null
@@ -1,714 +0,0 @@
-/* The MIT License
-
-   Copyright (c) 2008 Broad Institute / Massachusetts Institute of Technology
-
-   Permission is hereby granted, free of charge, to any person obtaining a copy
-   of this software and associated documentation files (the "Software"), to deal
-   in the Software without restriction, including without limitation the rights
-   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-   copies of the Software, and to permit persons to whom the Software is
-   furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included in
-   all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-   THE SOFTWARE.
-*/
-
-/*
-  2009-06-29 by lh3: cache recent uncompressed blocks.
-  2009-06-25 by lh3: optionally use my knetfile library to access file on a FTP.
-  2009-06-12 by lh3: support a mode string like "wu" where 'u' for uncompressed output */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include "bgzf.h"
-
-#include "khash.h"
-typedef struct {
-	int size;
-	uint8_t *block;
-	int64_t end_offset;
-} cache_t;
-KHASH_MAP_INIT_INT64(cache, cache_t)
-
-#if defined(_WIN32) || defined(_MSC_VER)
-#define ftello(fp) ftell(fp)
-#define fseeko(fp, offset, whence) fseek(fp, offset, whence)
-#else
-extern off_t ftello(FILE *stream);
-extern int fseeko(FILE *stream, off_t offset, int whence);
-#endif
-
-typedef int8_t bgzf_byte_t;
-
-static const int DEFAULT_BLOCK_SIZE = 64 * 1024;
-static const int MAX_BLOCK_SIZE = 64 * 1024;
-
-static const int BLOCK_HEADER_LENGTH = 18;
-static const int BLOCK_FOOTER_LENGTH = 8;
-
-static const int GZIP_ID1 = 31;
-static const int GZIP_ID2 = 139;
-static const int CM_DEFLATE = 8;
-static const int FLG_FEXTRA = 4;
-static const int OS_UNKNOWN = 255;
-static const int BGZF_ID1 = 66; // 'B'
-static const int BGZF_ID2 = 67; // 'C'
-static const int BGZF_LEN = 2;
-static const int BGZF_XLEN = 6; // BGZF_LEN+4
-
-static const int GZIP_WINDOW_BITS = -15; // no zlib header
-static const int Z_DEFAULT_MEM_LEVEL = 8;
-
-
-inline
-void
-packInt16(uint8_t* buffer, uint16_t value)
-{
-    buffer[0] = value;
-    buffer[1] = value >> 8;
-}
-
-inline
-int
-unpackInt16(const uint8_t* buffer)
-{
-    return (buffer[0] | (buffer[1] << 8));
-}
-
-inline
-void
-packInt32(uint8_t* buffer, uint32_t value)
-{
-    buffer[0] = value;
-    buffer[1] = value >> 8;
-    buffer[2] = value >> 16;
-    buffer[3] = value >> 24;
-}
-
-static inline
-int
-bgzf_min(int x, int y)
-{
-    return (x < y) ? x : y;
-}
-
-static
-void
-report_error(BGZF* fp, const char* message) {
-    fp->error = message;
-}
-
-int bgzf_check_bgzf(const char *fn)
-{
-    BGZF *fp;
-    uint8_t buf[10],magic[10]="\037\213\010\4\0\0\0\0\0\377";
-    int n;
-
-    if ((fp = bgzf_open(fn, "r")) == 0) 
-    {
-        fprintf(stderr, "[bgzf_check_bgzf] failed to open the file: %s\n",fn);
-        return -1;
-    }
-
-#ifdef _USE_KNETFILE
-    n = knet_read(fp->x.fpr, buf, 10);
-#else
-    n = fread(buf, 1, 10, fp->file);
-#endif
-    bgzf_close(fp);
-
-    if ( n!=10 ) 
-        return -1;
-
-    if ( !memcmp(magic, buf, 10) ) return 1;
-    return 0;
-}
-
-static BGZF *bgzf_read_init()
-{
-	BGZF *fp;
-	fp = calloc(1, sizeof(BGZF));
-    fp->uncompressed_block_size = MAX_BLOCK_SIZE;
-    fp->uncompressed_block = malloc(MAX_BLOCK_SIZE);
-    fp->compressed_block_size = MAX_BLOCK_SIZE;
-    fp->compressed_block = malloc(MAX_BLOCK_SIZE);
-	fp->cache_size = 0;
-	fp->cache = kh_init(cache);
-	return fp;
-}
-
-static
-BGZF*
-open_read(int fd)
-{
-#ifdef _USE_KNETFILE
-    knetFile *file = knet_dopen(fd, "r");
-#else
-    FILE* file = fdopen(fd, "r");
-#endif
-    BGZF* fp;
-	if (file == 0) return 0;
-	fp = bgzf_read_init();
-    fp->file_descriptor = fd;
-    fp->open_mode = 'r';
-#ifdef _USE_KNETFILE
-    fp->x.fpr = file;
-#else
-    fp->file = file;
-#endif
-    return fp;
-}
-
-static
-BGZF*
-open_write(int fd, int compress_level) // compress_level==-1 for the default level
-{
-    FILE* file = fdopen(fd, "w");
-    BGZF* fp;
-	if (file == 0) return 0;
-	fp = malloc(sizeof(BGZF));
-    fp->file_descriptor = fd;
-    fp->open_mode = 'w';
-    fp->owned_file = 0;
-	fp->compress_level = compress_level < 0? Z_DEFAULT_COMPRESSION : compress_level; // Z_DEFAULT_COMPRESSION==-1
-	if (fp->compress_level > 9) fp->compress_level = Z_DEFAULT_COMPRESSION;
-#ifdef _USE_KNETFILE
-    fp->x.fpw = file;
-#else
-    fp->file = file;
-#endif
-    fp->uncompressed_block_size = DEFAULT_BLOCK_SIZE;
-    fp->uncompressed_block = NULL;
-    fp->compressed_block_size = MAX_BLOCK_SIZE;
-    fp->compressed_block = malloc(MAX_BLOCK_SIZE);
-    fp->block_address = 0;
-    fp->block_offset = 0;
-    fp->block_length = 0;
-    fp->error = NULL;
-    return fp;
-}
-
-BGZF*
-bgzf_open(const char* __restrict path, const char* __restrict mode)
-{
-    BGZF* fp = NULL;
-    if (strchr(mode, 'r') || strchr(mode, 'R')) { /* The reading mode is preferred. */
-#ifdef _USE_KNETFILE
-		knetFile *file = knet_open(path, mode);
-		if (file == 0) return 0;
-		fp = bgzf_read_init();
-		fp->file_descriptor = -1;
-		fp->open_mode = 'r';
-		fp->x.fpr = file;
-#else
-		int fd, oflag = O_RDONLY;
-#ifdef _WIN32
-		oflag |= O_BINARY;
-#endif
-		fd = open(path, oflag);
-		if (fd == -1) return 0;
-        fp = open_read(fd);
-#endif
-    } else if (strchr(mode, 'w') || strchr(mode, 'W')) {
-		int fd, compress_level = -1, oflag = O_WRONLY | O_CREAT | O_TRUNC;
-#ifdef _WIN32
-		oflag |= O_BINARY;
-#endif
-		fd = open(path, oflag, 0666);
-		if (fd == -1) return 0;
-		{ // set compress_level
-			int i;
-			for (i = 0; mode[i]; ++i)
-				if (mode[i] >= '0' && mode[i] <= '9') break;
-			if (mode[i]) compress_level = (int)mode[i] - '0';
-			if (strchr(mode, 'u')) compress_level = 0;
-		}
-        fp = open_write(fd, compress_level);
-    }
-    if (fp != NULL) fp->owned_file = 1;
-    return fp;
-}
-
-BGZF*
-bgzf_fdopen(int fd, const char * __restrict mode)
-{
-	if (fd == -1) return 0;
-    if (mode[0] == 'r' || mode[0] == 'R') {
-        return open_read(fd);
-    } else if (mode[0] == 'w' || mode[0] == 'W') {
-		int i, compress_level = -1;
-		for (i = 0; mode[i]; ++i)
-			if (mode[i] >= '0' && mode[i] <= '9') break;
-		if (mode[i]) compress_level = (int)mode[i] - '0';
-		if (strchr(mode, 'u')) compress_level = 0;
-        return open_write(fd, compress_level);
-    } else {
-        return NULL;
-    }
-}
-
-static
-int
-deflate_block(BGZF* fp, int block_length)
-{
-    // Deflate the block in fp->uncompressed_block into fp->compressed_block.
-    // Also adds an extra field that stores the compressed block length.
-
-    bgzf_byte_t* buffer = fp->compressed_block;
-    int buffer_size = fp->compressed_block_size;
-
-    // Init gzip header
-    buffer[0] = GZIP_ID1;
-    buffer[1] = GZIP_ID2;
-    buffer[2] = CM_DEFLATE;
-    buffer[3] = FLG_FEXTRA;
-    buffer[4] = 0; // mtime
-    buffer[5] = 0;
-    buffer[6] = 0;
-    buffer[7] = 0;
-    buffer[8] = 0;
-    buffer[9] = OS_UNKNOWN;
-    buffer[10] = BGZF_XLEN;
-    buffer[11] = 0;
-    buffer[12] = BGZF_ID1;
-    buffer[13] = BGZF_ID2;
-    buffer[14] = BGZF_LEN;
-    buffer[15] = 0;
-    buffer[16] = 0; // placeholder for block length
-    buffer[17] = 0;
-
-    // loop to retry for blocks that do not compress enough
-    int input_length = block_length;
-    int compressed_length = 0;
-    while (1) {
-        z_stream zs;
-        zs.zalloc = NULL;
-        zs.zfree = NULL;
-        zs.next_in = fp->uncompressed_block;
-        zs.avail_in = input_length;
-        zs.next_out = (void*)&buffer[BLOCK_HEADER_LENGTH];
-        zs.avail_out = buffer_size - BLOCK_HEADER_LENGTH - BLOCK_FOOTER_LENGTH;
-
-        int status = deflateInit2(&zs, fp->compress_level, Z_DEFLATED,
-                                  GZIP_WINDOW_BITS, Z_DEFAULT_MEM_LEVEL, Z_DEFAULT_STRATEGY);
-        if (status != Z_OK) {
-            report_error(fp, "deflate init failed");
-            return -1;
-        }
-        status = deflate(&zs, Z_FINISH);
-        if (status != Z_STREAM_END) {
-            deflateEnd(&zs);
-            if (status == Z_OK) {
-                // Not enough space in buffer.
-                // Can happen in the rare case the input doesn't compress enough.
-                // Reduce the amount of input until it fits.
-                input_length -= 1024;
-                if (input_length <= 0) {
-                    // should never happen
-                    report_error(fp, "input reduction failed");
-                    return -1;
-                }
-                continue;
-            }
-            report_error(fp, "deflate failed");
-            return -1;
-        }
-        status = deflateEnd(&zs);
-        if (status != Z_OK) {
-            report_error(fp, "deflate end failed");
-            return -1;
-        }
-        compressed_length = zs.total_out;
-        compressed_length += BLOCK_HEADER_LENGTH + BLOCK_FOOTER_LENGTH;
-        if (compressed_length > MAX_BLOCK_SIZE) {
-            // should never happen
-            report_error(fp, "deflate overflow");
-            return -1;
-        }
-        break;
-    }
-
-    packInt16((uint8_t*)&buffer[16], compressed_length-1);
-    uint32_t crc = crc32(0L, NULL, 0L);
-    crc = crc32(crc, fp->uncompressed_block, input_length);
-    packInt32((uint8_t*)&buffer[compressed_length-8], crc);
-    packInt32((uint8_t*)&buffer[compressed_length-4], input_length);
-
-    int remaining = block_length - input_length;
-    if (remaining > 0) {
-        if (remaining > input_length) {
-            // should never happen (check so we can use memcpy)
-            report_error(fp, "remainder too large");
-            return -1;
-        }
-        memcpy(fp->uncompressed_block,
-               fp->uncompressed_block + input_length,
-               remaining);
-    }
-    fp->block_offset = remaining;
-    return compressed_length;
-}
-
-static
-int
-inflate_block(BGZF* fp, int block_length)
-{
-    // Inflate the block in fp->compressed_block into fp->uncompressed_block
-
-    z_stream zs;
-	int status;
-    zs.zalloc = NULL;
-    zs.zfree = NULL;
-    zs.next_in = fp->compressed_block + 18;
-    zs.avail_in = block_length - 16;
-    zs.next_out = fp->uncompressed_block;
-    zs.avail_out = fp->uncompressed_block_size;
-
-    status = inflateInit2(&zs, GZIP_WINDOW_BITS);
-    if (status != Z_OK) {
-        report_error(fp, "inflate init failed");
-        return -1;
-    }
-    status = inflate(&zs, Z_FINISH);
-    if (status != Z_STREAM_END) {
-        inflateEnd(&zs);
-        report_error(fp, "inflate failed");
-        return -1;
-    }
-    status = inflateEnd(&zs);
-    if (status != Z_OK) {
-        report_error(fp, "inflate failed");
-        return -1;
-    }
-    return zs.total_out;
-}
-
-static
-int
-check_header(const bgzf_byte_t* header)
-{
-    return (header[0] == GZIP_ID1 &&
-            header[1] == (bgzf_byte_t) GZIP_ID2 &&
-            header[2] == Z_DEFLATED &&
-            (header[3] & FLG_FEXTRA) != 0 &&
-            unpackInt16((uint8_t*)&header[10]) == BGZF_XLEN &&
-            header[12] == BGZF_ID1 &&
-            header[13] == BGZF_ID2 &&
-            unpackInt16((uint8_t*)&header[14]) == BGZF_LEN);
-}
-
-static void free_cache(BGZF *fp)
-{
-	khint_t k;
-	khash_t(cache) *h = (khash_t(cache)*)fp->cache;
-	if (fp->open_mode != 'r') return;
-	for (k = kh_begin(h); k < kh_end(h); ++k)
-		if (kh_exist(h, k)) free(kh_val(h, k).block);
-	kh_destroy(cache, h);
-}
-
-static int load_block_from_cache(BGZF *fp, int64_t block_address)
-{
-	khint_t k;
-	cache_t *p;
-	khash_t(cache) *h = (khash_t(cache)*)fp->cache;
-	k = kh_get(cache, h, block_address);
-	if (k == kh_end(h)) return 0;
-	p = &kh_val(h, k);
-	if (fp->block_length != 0) fp->block_offset = 0;
-	fp->block_address = block_address;
-	fp->block_length = p->size;
-	memcpy(fp->uncompressed_block, p->block, MAX_BLOCK_SIZE);
-#ifdef _USE_KNETFILE
-	knet_seek(fp->x.fpr, p->end_offset, SEEK_SET);
-#else
-	fseeko(fp->file, p->end_offset, SEEK_SET);
-#endif
-	return p->size;
-}
-
-static void cache_block(BGZF *fp, int size)
-{
-	int ret;
-	khint_t k;
-	cache_t *p;
-	khash_t(cache) *h = (khash_t(cache)*)fp->cache;
-	if (MAX_BLOCK_SIZE >= fp->cache_size) return;
-	if ((kh_size(h) + 1) * MAX_BLOCK_SIZE > fp->cache_size) {
-		/* A better way would be to remove the oldest block in the
-		 * cache, but here we remove a random one for simplicity. This
-		 * should not have a big impact on performance. */
-		for (k = kh_begin(h); k < kh_end(h); ++k)
-			if (kh_exist(h, k)) break;
-		if (k < kh_end(h)) {
-			free(kh_val(h, k).block);
-			kh_del(cache, h, k);
-		}
-	}
-	k = kh_put(cache, h, fp->block_address, &ret);
-	if (ret == 0) return; // if this happens, a bug!
-	p = &kh_val(h, k);
-	p->size = fp->block_length;
-	p->end_offset = fp->block_address + size;
-	p->block = malloc(MAX_BLOCK_SIZE);
-	memcpy(kh_val(h, k).block, fp->uncompressed_block, MAX_BLOCK_SIZE);
-}
-
-int
-bgzf_read_block(BGZF* fp)
-{
-    bgzf_byte_t header[BLOCK_HEADER_LENGTH];
-	int count, size = 0, block_length, remaining;
-#ifdef _USE_KNETFILE
-    int64_t block_address = knet_tell(fp->x.fpr);
-	if (load_block_from_cache(fp, block_address)) return 0;
-    count = knet_read(fp->x.fpr, header, sizeof(header));
-#else
-    int64_t block_address = ftello(fp->file);
-	if (load_block_from_cache(fp, block_address)) return 0;
-    count = fread(header, 1, sizeof(header), fp->file);
-#endif
-    if (count == 0) {
-        fp->block_length = 0;
-        return 0;
-    }
-	size = count;
-    if (count != sizeof(header)) {
-        report_error(fp, "read failed");
-        return -1;
-    }
-    if (!check_header(header)) {
-        report_error(fp, "invalid block header");
-        return -1;
-    }
-    block_length = unpackInt16((uint8_t*)&header[16]) + 1;
-    bgzf_byte_t* compressed_block = (bgzf_byte_t*) fp->compressed_block;
-    memcpy(compressed_block, header, BLOCK_HEADER_LENGTH);
-    remaining = block_length - BLOCK_HEADER_LENGTH;
-#ifdef _USE_KNETFILE
-    count = knet_read(fp->x.fpr, &compressed_block[BLOCK_HEADER_LENGTH], remaining);
-#else
-    count = fread(&compressed_block[BLOCK_HEADER_LENGTH], 1, remaining, fp->file);
-#endif
-    if (count != remaining) {
-        report_error(fp, "read failed");
-        return -1;
-    }
-	size += count;
-    count = inflate_block(fp, block_length);
-    if (count < 0) return -1;
-    if (fp->block_length != 0) {
-        // Do not reset offset if this read follows a seek.
-        fp->block_offset = 0;
-    }
-    fp->block_address = block_address;
-    fp->block_length = count;
-	cache_block(fp, size);
-    return 0;
-}
-
-int
-bgzf_read(BGZF* fp, void* data, int length)
-{
-    if (length <= 0) {
-        return 0;
-    }
-    if (fp->open_mode != 'r') {
-        report_error(fp, "file not open for reading");
-        return -1;
-    }
-
-    int bytes_read = 0;
-    bgzf_byte_t* output = data;
-    while (bytes_read < length) {
-        int copy_length, available = fp->block_length - fp->block_offset;
-		bgzf_byte_t *buffer;
-        if (available <= 0) {
-            if (bgzf_read_block(fp) != 0) {
-                return -1;
-            }
-            available = fp->block_length - fp->block_offset;
-            if (available <= 0) {
-                break;
-            }
-        }
-        copy_length = bgzf_min(length-bytes_read, available);
-        buffer = fp->uncompressed_block;
-        memcpy(output, buffer + fp->block_offset, copy_length);
-        fp->block_offset += copy_length;
-        output += copy_length;
-        bytes_read += copy_length;
-    }
-    if (fp->block_offset == fp->block_length) {
-#ifdef _USE_KNETFILE
-        fp->block_address = knet_tell(fp->x.fpr);
-#else
-        fp->block_address = ftello(fp->file);
-#endif
-        fp->block_offset = 0;
-        fp->block_length = 0;
-    }
-    return bytes_read;
-}
-
-int bgzf_flush(BGZF* fp)
-{
-    while (fp->block_offset > 0) {
-        int count, block_length;
-		block_length = deflate_block(fp, fp->block_offset);
-        if (block_length < 0) return -1;
-#ifdef _USE_KNETFILE
-        count = fwrite(fp->compressed_block, 1, block_length, fp->x.fpw);
-#else
-        count = fwrite(fp->compressed_block, 1, block_length, fp->file);
-#endif
-        if (count != block_length) {
-            report_error(fp, "write failed");
-            return -1;
-        }
-        fp->block_address += block_length;
-    }
-    return 0;
-}
-
-int bgzf_flush_try(BGZF *fp, int size)
-{
-	if (fp->block_offset + size > fp->uncompressed_block_size)
-		return bgzf_flush(fp);
-	return -1;
-}
-
-int bgzf_write(BGZF* fp, const void* data, int length)
-{
-	const bgzf_byte_t *input = data;
-	int block_length, bytes_written;
-    if (fp->open_mode != 'w') {
-        report_error(fp, "file not open for writing");
-        return -1;
-    }
-
-    if (fp->uncompressed_block == NULL)
-        fp->uncompressed_block = malloc(fp->uncompressed_block_size);
-
-    input = data;
-    block_length = fp->uncompressed_block_size;
-    bytes_written = 0;
-    while (bytes_written < length) {
-        int copy_length = bgzf_min(block_length - fp->block_offset, length - bytes_written);
-        bgzf_byte_t* buffer = fp->uncompressed_block;
-        memcpy(buffer + fp->block_offset, input, copy_length);
-        fp->block_offset += copy_length;
-        input += copy_length;
-        bytes_written += copy_length;
-        if (fp->block_offset == block_length) {
-            if (bgzf_flush(fp) != 0) {
-                break;
-            }
-        }
-    }
-    return bytes_written;
-}
-
-int bgzf_close(BGZF* fp)
-{
-    if (fp->open_mode == 'w') {
-        if (bgzf_flush(fp) != 0) return -1;
-		{ // add an empty block
-			int count, block_length = deflate_block(fp, 0);
-#ifdef _USE_KNETFILE
-			count = fwrite(fp->compressed_block, 1, block_length, fp->x.fpw);
-#else
-			count = fwrite(fp->compressed_block, 1, block_length, fp->file);
-#endif
-		}
-#ifdef _USE_KNETFILE
-        if (fflush(fp->x.fpw) != 0) {
-#else
-        if (fflush(fp->file) != 0) {
-#endif
-            report_error(fp, "flush failed");
-            return -1;
-        }
-    }
-    if (fp->owned_file) {
-#ifdef _USE_KNETFILE
-		int ret;
-		if (fp->open_mode == 'w') ret = fclose(fp->x.fpw);
-		else ret = knet_close(fp->x.fpr);
-        if (ret != 0) return -1;
-#else
-        if (fclose(fp->file) != 0) return -1;
-#endif
-    }
-    free(fp->uncompressed_block);
-    free(fp->compressed_block);
-	free_cache(fp);
-    free(fp);
-    return 0;
-}
-
-void bgzf_set_cache_size(BGZF *fp, int cache_size)
-{
-	if (fp) fp->cache_size = cache_size;
-}
-
-int bgzf_check_EOF(BGZF *fp)
-{
-	static uint8_t magic[28] = "\037\213\010\4\0\0\0\0\0\377\6\0\102\103\2\0\033\0\3\0\0\0\0\0\0\0\0\0";
-	uint8_t buf[28];
-	off_t offset;
-#ifdef _USE_KNETFILE
-	offset = knet_tell(fp->x.fpr);
-	if (knet_seek(fp->x.fpr, -28, SEEK_END) != 0) return -1;
-	knet_read(fp->x.fpr, buf, 28);
-	knet_seek(fp->x.fpr, offset, SEEK_SET);
-#else
-	offset = ftello(fp->file);
-	if (fseeko(fp->file, -28, SEEK_END) != 0) return -1;
-	fread(buf, 1, 28, fp->file);
-	fseeko(fp->file, offset, SEEK_SET);
-#endif
-	return (memcmp(magic, buf, 28) == 0)? 1 : 0;
-}
-
-int64_t bgzf_seek(BGZF* fp, int64_t pos, int where)
-{
-	int block_offset;
-	int64_t block_address;
-
-    if (fp->open_mode != 'r') {
-        report_error(fp, "file not open for read");
-        return -1;
-    }
-    if (where != SEEK_SET) {
-        report_error(fp, "unimplemented seek option");
-        return -1;
-    }
-    block_offset = pos & 0xFFFF;
-    block_address = (pos >> 16) & 0xFFFFFFFFFFFFLL;
-#ifdef _USE_KNETFILE
-    if (knet_seek(fp->x.fpr, block_address, SEEK_SET) != 0) {
-#else
-    if (fseeko(fp->file, block_address, SEEK_SET) != 0) {
-#endif
-        report_error(fp, "seek failed");
-        return -1;
-    }
-    fp->block_length = 0;  // indicates current block is not loaded
-    fp->block_address = block_address;
-    fp->block_offset = block_offset;
-    return 0;
-}
diff --git a/vcflib/tabixpp/bgzf.h b/vcflib/tabixpp/bgzf.h
deleted file mode 100644
index 7295f37..0000000
--- a/vcflib/tabixpp/bgzf.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/* The MIT License
-
-   Copyright (c) 2008 Broad Institute / Massachusetts Institute of Technology
-
-   Permission is hereby granted, free of charge, to any person obtaining a copy
-   of this software and associated documentation files (the "Software"), to deal
-   in the Software without restriction, including without limitation the rights
-   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-   copies of the Software, and to permit persons to whom the Software is
-   furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included in
-   all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-   THE SOFTWARE.
-*/
-
-#ifndef __BGZF_H
-#define __BGZF_H
-
-#include <stdint.h>
-#include <stdio.h>
-#include <zlib.h>
-#ifdef _USE_KNETFILE
-#include "knetfile.h"
-#endif
-
-//typedef int8_t bool;
-
-typedef struct {
-    int file_descriptor;
-    char open_mode;  // 'r' or 'w'
-    int16_t owned_file, compress_level;
-#ifdef _USE_KNETFILE
-	union {
-		knetFile *fpr;
-		FILE *fpw;
-	} x;
-#else
-    FILE* file;
-#endif
-    int uncompressed_block_size;
-    int compressed_block_size;
-    void* uncompressed_block;
-    void* compressed_block;
-    int64_t block_address;
-    int block_length;
-    int block_offset;
-	int cache_size;
-    const char* error;
-	void *cache; // a pointer to a hash table
-} BGZF;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Open an existing file descriptor for reading or writing.
- * Mode must be either "r" or "w".
- * A subsequent bgzf_close will not close the file descriptor.
- * Returns null on error.
- */
-BGZF* bgzf_fdopen(int fd, const char* __restrict mode);
-
-/*
- * Open the specified file for reading or writing.
- * Mode must be either "r" or "w".
- * Returns null on error.
- */
-BGZF* bgzf_open(const char* path, const char* __restrict mode);
-
-/*
- * Close the BGZ file and free all associated resources.
- * Does not close the underlying file descriptor if created with bgzf_fdopen.
- * Returns zero on success, -1 on error.
- */
-int bgzf_close(BGZF* fp);
-
-/*
- * Read up to length bytes from the file storing into data.
- * Returns the number of bytes actually read.
- * Returns zero on end of file.
- * Returns -1 on error.
- */
-int bgzf_read(BGZF* fp, void* data, int length);
-
-/*
- * Write length bytes from data to the file.
- * Returns the number of bytes written.
- * Returns -1 on error.
- */
-int bgzf_write(BGZF* fp, const void* data, int length);
-
-/*
- * Return a virtual file pointer to the current location in the file.
- * No interpetation of the value should be made, other than a subsequent
- * call to bgzf_seek can be used to position the file at the same point.
- * Return value is non-negative on success.
- * Returns -1 on error.
- */
-#define bgzf_tell(fp) ((fp->block_address << 16) | (fp->block_offset & 0xFFFF))
-
-/*
- * Set the file to read from the location specified by pos, which must
- * be a value previously returned by bgzf_tell for this file (but not
- * necessarily one returned by this file handle).
- * The where argument must be SEEK_SET.
- * Seeking on a file opened for write is not supported.
- * Returns zero on success, -1 on error.
- */
-int64_t bgzf_seek(BGZF* fp, int64_t pos, int where);
-
-/*
- * Set the cache size. Zero to disable. By default, caching is
- * disabled. The recommended cache size for frequent random access is
- * about 8M bytes.
- */
-void bgzf_set_cache_size(BGZF *fp, int cache_size);
-
-int bgzf_check_EOF(BGZF *fp);
-int bgzf_read_block(BGZF* fp);
-int bgzf_flush(BGZF* fp);
-int bgzf_flush_try(BGZF *fp, int size);
-int bgzf_check_bgzf(const char *fn);
-
-#ifdef __cplusplus
-}
-#endif
-
-static inline int bgzf_getc(BGZF *fp)
-{
-	int c;
-	if (fp->block_offset >= fp->block_length) {
-		if (bgzf_read_block(fp) != 0) return -2; /* error */
-		if (fp->block_length == 0) return -1; /* end-of-file */
-	}
-	c = ((unsigned char*)fp->uncompressed_block)[fp->block_offset++];
-    if (fp->block_offset == fp->block_length) {
-#ifdef _USE_KNETFILE
-        fp->block_address = knet_tell(fp->x.fpr);
-#else
-        fp->block_address = ftello(fp->file);
-#endif
-        fp->block_offset = 0;
-        fp->block_length = 0;
-    }
-	return c;
-}
-
-#endif
diff --git a/vcflib/tabixpp/bgzip.c b/vcflib/tabixpp/bgzip.c
deleted file mode 100644
index ebcafa2..0000000
--- a/vcflib/tabixpp/bgzip.c
+++ /dev/null
@@ -1,206 +0,0 @@
-/* The MIT License
-
-   Copyright (c) 2008 Broad Institute / Massachusetts Institute of Technology
-
-   Permission is hereby granted, free of charge, to any person obtaining a copy
-   of this software and associated documentation files (the "Software"), to deal
-   in the Software without restriction, including without limitation the rights
-   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-   copies of the Software, and to permit persons to whom the Software is
-   furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included in
-   all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-   THE SOFTWARE.
-*/
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/select.h>
-#include <sys/stat.h>
-#include "bgzf.h"
-
-static const int WINDOW_SIZE = 64 * 1024;
-
-static int bgzip_main_usage()
-{
-	fprintf(stderr, "\n");
-	fprintf(stderr, "Usage:   bgzip [options] [file] ...\n\n");
-	fprintf(stderr, "Options: -c      write on standard output, keep original files unchanged\n");
-	fprintf(stderr, "         -d      decompress\n");
-	fprintf(stderr, "         -f      overwrite files without asking\n");
-	fprintf(stderr, "         -b INT  decompress at virtual file pointer INT\n");
-	fprintf(stderr, "         -s INT  decompress INT bytes in the uncompressed file\n");
-	fprintf(stderr, "         -h      give this help\n");
-	fprintf(stderr, "\n");
-	return 1;
-}
-
-static int write_open(const char *fn, int is_forced)
-{
-	int fd = -1;
-	char c;
-	if (!is_forced) {
-		if ((fd = open(fn, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0666)) < 0 && errno == EEXIST) {
-			fprintf(stderr, "[bgzip] %s already exists; do you wish to overwrite (y or n)? ", fn);
-			scanf("%c", &c);
-			if (c != 'Y' && c != 'y') {
-				fprintf(stderr, "[bgzip] not overwritten\n");
-				exit(1);
-			}
-		}
-	}
-	if (fd < 0) {
-		if ((fd = open(fn, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) {
-			fprintf(stderr, "[bgzip] %s: Fail to write\n", fn);
-			exit(1);
-		}
-	}
-	return fd;
-}
-
-static void fail(BGZF* fp)
-{
-    fprintf(stderr, "Error: %s\n", fp->error);
-    exit(1);
-}
-
-int main(int argc, char **argv)
-{
-	int c, compress, pstdout, is_forced;
-	BGZF *fp;
-	void *buffer;
-	long start, end, size;
-
-	compress = 1; pstdout = 0; start = 0; size = -1; end = -1; is_forced = 0;
-	while((c  = getopt(argc, argv, "cdhfb:s:")) >= 0){
-		switch(c){
-		case 'h': return bgzip_main_usage();
-		case 'd': compress = 0; break;
-		case 'c': pstdout = 1; break;
-		case 'b': start = atol(optarg); break;
-		case 's': size = atol(optarg); break;
-		case 'f': is_forced = 1; break;
-		}
-	}
-	if (size >= 0) end = start + size;
-	if (end >= 0 && end < start) {
-		fprintf(stderr, "[bgzip] Illegal region: [%ld, %ld]\n", start, end);
-		return 1;
-	}
-	if (compress == 1) {
-		struct stat sbuf;
-		int f_src = fileno(stdin);
-		int f_dst = fileno(stdout);
-
-		if ( argc>optind )
-		{
-			if ( stat(argv[optind],&sbuf)<0 ) 
-			{ 
-				fprintf(stderr, "[bgzip] %s: %s\n", strerror(errno), argv[optind]);
-				return 1; 
-			}
-
-			if ((f_src = open(argv[optind], O_RDONLY)) < 0) {
-				fprintf(stderr, "[bgzip] %s: %s\n", strerror(errno), argv[optind]);
-				return 1;
-			}
-
-			if (pstdout)
-				f_dst = fileno(stdout);
-			else
-			{
-				char *name = malloc(strlen(argv[optind]) + 5);
-				strcpy(name, argv[optind]);
-				strcat(name, ".gz");
-				f_dst = write_open(name, is_forced);
-				if (f_dst < 0) return 1;
-				free(name);
-			}
-		}
-		else if (!pstdout && isatty(fileno((FILE *)stdout)) )
-			return bgzip_main_usage();
-
-		fp = bgzf_fdopen(f_dst, "w");
-		buffer = malloc(WINDOW_SIZE);
-		while ((c = read(f_src, buffer, WINDOW_SIZE)) > 0)
-			if (bgzf_write(fp, buffer, c) < 0) fail(fp);
-		// f_dst will be closed here
-		if (bgzf_close(fp) < 0) fail(fp);
-		if (argc > optind && !pstdout) unlink(argv[optind]);
-		free(buffer);
-		close(f_src);
-		return 0;
-	} else {
-		struct stat sbuf;
-		int f_dst;
-
-		if ( argc>optind )
-		{
-			if ( stat(argv[optind],&sbuf)<0 )
-			{
-				fprintf(stderr, "[bgzip] %s: %s\n", strerror(errno), argv[optind]);
-				return 1;
-			}
-			char *name;
-			int len = strlen(argv[optind]);
-			if ( strcmp(argv[optind]+len-3,".gz") )
-			{
-				fprintf(stderr, "[bgzip] %s: unknown suffix -- ignored\n", argv[optind]);
-				return 1;
-			}
-			fp = bgzf_open(argv[optind], "r");
-			if (fp == NULL) {
-				fprintf(stderr, "[bgzip] Could not open file: %s\n", argv[optind]);
-				return 1;
-			}
-
-			if (pstdout) {
-				f_dst = fileno(stdout);
-			}
-			else {
-				name = strdup(argv[optind]);
-				name[strlen(name) - 3] = '\0';
-				f_dst = write_open(name, is_forced);
-				free(name);
-			}
-		}
-		else if (!pstdout && isatty(fileno((FILE *)stdin)) )
-			return bgzip_main_usage();
-		else
-		{
-			f_dst = fileno(stdout);
-			fp = bgzf_fdopen(fileno(stdin), "r");
-			if (fp == NULL) {
-				fprintf(stderr, "[bgzip] Could not read from stdin: %s\n", strerror(errno));
-				return 1;
-			}
-		}
-		buffer = malloc(WINDOW_SIZE);
-		if (bgzf_seek(fp, start, SEEK_SET) < 0) fail(fp);
-		while (1) {
-			if (end < 0) c = bgzf_read(fp, buffer, WINDOW_SIZE);
-			else c = bgzf_read(fp, buffer, (end - start > WINDOW_SIZE)? WINDOW_SIZE:(end - start));
-			if (c == 0) break;
-			if (c < 0) fail(fp);
-			start += c;
-			write(f_dst, buffer, c);
-			if (end >= 0 && start >= end) break;
-		}
-		free(buffer);
-		if (bgzf_close(fp) < 0) fail(fp);
-		if (!pstdout) unlink(argv[optind]);
-		return 0;
-	}
-}
diff --git a/vcflib/tabixpp/example.gtf.gz b/vcflib/tabixpp/example.gtf.gz
deleted file mode 100644
index 693db0c..0000000
Binary files a/vcflib/tabixpp/example.gtf.gz and /dev/null differ
diff --git a/vcflib/tabixpp/example.gtf.gz.tbi b/vcflib/tabixpp/example.gtf.gz.tbi
deleted file mode 100644
index 84a3c84..0000000
Binary files a/vcflib/tabixpp/example.gtf.gz.tbi and /dev/null differ
diff --git a/vcflib/tabixpp/index.c b/vcflib/tabixpp/index.c
deleted file mode 100644
index 8f254e3..0000000
--- a/vcflib/tabixpp/index.c
+++ /dev/null
@@ -1,998 +0,0 @@
-#include <ctype.h>
-#include <assert.h>
-#include <sys/stat.h>
-#include "khash.h"
-#include "ksort.h"
-#include "kstring.h"
-#include "bam_endian.h"
-#ifdef _USE_KNETFILE
-#include "knetfile.h"
-#endif
-#include "tabix.h"
-
-#define TAD_MIN_CHUNK_GAP 32768
-// 1<<14 is the size of minimum bin.
-#define TAD_LIDX_SHIFT    14
-
-typedef struct {
-	uint64_t u, v;
-} pair64_t;
-
-#define pair64_lt(a,b) ((a).u < (b).u)
-KSORT_INIT(offt, pair64_t, pair64_lt)
-
-typedef struct {
-	uint32_t m, n;
-	pair64_t *list;
-} ti_binlist_t;
-
-typedef struct {
-	int32_t n, m;
-	uint64_t *offset;
-} ti_lidx_t;
-
-KHASH_MAP_INIT_INT(i, ti_binlist_t)
-KHASH_MAP_INIT_STR(s, int)
-
-struct __ti_index_t {
-	ti_conf_t conf;
-	int32_t n, max;
-	khash_t(s) *tname;
-	khash_t(i) **index;
-	ti_lidx_t *index2;
-};
-
-struct __ti_iter_t {
-	int from_first; // read from the first record; no random access
-	int tid, beg, end, n_off, i, finished;
-	uint64_t curr_off;
-	kstring_t str;
-	const ti_index_t *idx;
-	pair64_t *off;
-};
-
-typedef struct {
-	int tid, beg, end, bin;
-} ti_intv_t;
-
-ti_conf_t ti_conf_gff = { 0, 1, 4, 5, '#', 0 };
-ti_conf_t ti_conf_bed = { TI_FLAG_UCSC, 1, 2, 3, '#', 0 };
-ti_conf_t ti_conf_psltbl = { TI_FLAG_UCSC, 15, 17, 18, '#', 0 };
-ti_conf_t ti_conf_sam = { TI_PRESET_SAM, 3, 4, 0, '@', 0 };
-ti_conf_t ti_conf_vcf = { TI_PRESET_VCF, 1, 2, 0, '#', 0 };
-
-/***************
- * read a line *
- ***************/
-
-/*
-int ti_readline(BGZF *fp, kstring_t *str)
-{
-	int c, l = 0;
-	str->l = 0;
-	while ((c = bgzf_getc(fp)) >= 0 && c != '\n') {
-		++l;
-		if (c != '\r') kputc(c, str);
-	}
-	if (c < 0 && l == 0) return -1; // end of file
-	return str->l;
-}
-*/
-
-/* Below is a faster implementation largely equivalent to the one
- * commented out above. */
-int ti_readline(BGZF *fp, kstring_t *str)
-{
-	int l, state = 0;
-	unsigned char *buf = (unsigned char*)fp->uncompressed_block;
-	str->l = 0;
-	do {
-		if (fp->block_offset >= fp->block_length) {
-			if (bgzf_read_block(fp) != 0) { state = -2; break; }
-			if (fp->block_length == 0) { state = -1; break; }
-		}
-		for (l = fp->block_offset; l < fp->block_length && buf[l] != '\n'; ++l);
-		if (l < fp->block_length) state = 1;
-		l -= fp->block_offset;
-		if (str->l + l + 1 >= str->m) {
-			str->m = str->l + l + 2;
-			kroundup32(str->m);
-			str->s = (char*)realloc(str->s, str->m);
-		}
-		memcpy(str->s + str->l, buf + fp->block_offset, l);
-		str->l += l;
-		fp->block_offset += l + 1;
-		if (fp->block_offset >= fp->block_length) {
-#ifdef _USE_KNETFILE
-			fp->block_address = knet_tell(fp->x.fpr);
-#else
-			fp->block_address = ftello(fp->file);
-#endif
-			fp->block_offset = 0;
-			fp->block_length = 0;
-		} 
-	} while (state == 0);
-	if (str->l == 0 && state < 0) return state;
-	str->s[str->l] = 0;
-	return str->l;
-}
-
-/*************************************
- * get the interval from a data line *
- *************************************/
-
-static inline int ti_reg2bin(uint32_t beg, uint32_t end)
-{
-	--end;
-	if (beg>>14 == end>>14) return 4681 + (beg>>14);
-	if (beg>>17 == end>>17) return  585 + (beg>>17);
-	if (beg>>20 == end>>20) return   73 + (beg>>20);
-	if (beg>>23 == end>>23) return    9 + (beg>>23);
-	if (beg>>26 == end>>26) return    1 + (beg>>26);
-	return 0;
-}
-
-static int get_tid(ti_index_t *idx, const char *ss)
-{
-	khint_t k;
-	int tid;
-	k = kh_get(s, idx->tname, ss);
-	if (k == kh_end(idx->tname)) { // a new target sequence
-		int ret, size;
-		// update idx->n, ->max, ->index and ->index2
-		if (idx->n == idx->max) {
-			idx->max = idx->max? idx->max<<1 : 8;
-			idx->index = realloc(idx->index, idx->max * sizeof(void*));
-			idx->index2 = realloc(idx->index2, idx->max * sizeof(ti_lidx_t));
-		}
-		memset(&idx->index2[idx->n], 0, sizeof(ti_lidx_t));
-		idx->index[idx->n++] = kh_init(i);
-		// update ->tname
-		tid = size = kh_size(idx->tname);
-		k = kh_put(s, idx->tname, strdup(ss), &ret);
-		kh_value(idx->tname, k) = size;
-		assert(idx->n == kh_size(idx->tname));
-	} else tid = kh_value(idx->tname, k);
-	return tid;
-}
-
-int ti_get_intv(const ti_conf_t *conf, int len, char *line, ti_interval_t *intv)
-{
-	int i, b = 0, id = 1, ncols = 0;
-	char *s;
-	intv->ss = intv->se = 0; intv->beg = intv->end = -1;
-	for (i = 0; i <= len; ++i) {
-		if (line[i] == '\t' || line[i] == 0) {
-            ++ncols;
-			if (id == conf->sc) {
-				intv->ss = line + b; intv->se = line + i;
-			} else if (id == conf->bc) {
-				// here ->beg is 0-based.
-				intv->beg = intv->end = strtol(line + b, &s, 0);
-				if (!(conf->preset&TI_FLAG_UCSC)) --intv->beg;
-				else ++intv->end;
-				if (intv->beg < 0) intv->beg = 0;
-				if (intv->end < 1) intv->end = 1;
-			} else {
-				if ((conf->preset&0xffff) == TI_PRESET_GENERIC) {
-					if (id == conf->ec) intv->end = strtol(line + b, &s, 0);
-				} else if ((conf->preset&0xffff) == TI_PRESET_SAM) {
-					if (id == 6) { // CIGAR
-						int l = 0, op;
-						char *t;
-						for (s = line + b; s < line + i;) {
-							long x = strtol(s, &t, 10);
-							op = toupper(*t);
-							if (op == 'M' || op == 'D' || op == 'N') l += x;
-							s = t + 1;
-						}
-						if (l == 0) l = 1;
-						intv->end = intv->beg + l;
-					}
-				} else if ((conf->preset&0xffff) == TI_PRESET_VCF) {
-					// FIXME: the following is NOT tested and is likely to be buggy
-					if (id == 4) {
-						if (b < i) intv->end = intv->beg + (i - b);
-					} else if (id == 8) { // look for "END="
-						int c = line[i];
-						line[i] = 0;
-						s = strstr(line + b, "END=");
-						if (s == line + b) s += 4;
-						else if (s) {
-							s = strstr(line + b, ";END=");
-							if (s) s += 5;
-						}
-						if (s) intv->end = strtol(s, &s, 0);
-						line[i] = c;
-					}
-				}
-			}
-			b = i + 1;
-			++id;
-		}
-	}
-/*
-	if (ncols < conf->sc || ncols < conf->bc || ncols < conf->ec) {
-		if (ncols == 1) fprintf(stderr,"[get_intv] Is the file tab-delimited? The line has %d field only: %s\n", ncols, line);
-		else fprintf(stderr,"[get_intv] The line has %d field(s) only: %s\n", ncols, line);
-		exit(1);
-	}
-*/
-	if (intv->ss == 0 || intv->se == 0 || intv->beg < 0 || intv->end < 0) return -1;
-	return 0;
-}
-
-static int get_intv(ti_index_t *idx, kstring_t *str, ti_intv_t *intv)
-{
-	ti_interval_t x;
-	intv->tid = intv->beg = intv->end = intv->bin = -1;
-	if (ti_get_intv(&idx->conf, str->l, str->s, &x) == 0) {
-		int c = *x.se;
-		*x.se = '\0'; intv->tid = get_tid(idx, x.ss); *x.se = c;
-		intv->beg = x.beg; intv->end = x.end;
-		intv->bin = ti_reg2bin(intv->beg, intv->end);
-		return (intv->tid >= 0 && intv->beg >= 0 && intv->end >= 0)? 0 : -1;
-	} else {
-		fprintf(stderr, "[%s] the following line cannot be parsed and skipped: %s\n", __func__, str->s);
-		return -1;
-	}
-}
-
-/************
- * indexing *
- ************/
-
-// requirement: len <= LEN_MASK
-static inline void insert_offset(khash_t(i) *h, int bin, uint64_t beg, uint64_t end)
-{
-	khint_t k;
-	ti_binlist_t *l;
-	int ret;
-	k = kh_put(i, h, bin, &ret);
-	l = &kh_value(h, k);
-	if (ret) { // not present
-		l->m = 1; l->n = 0;
-		l->list = (pair64_t*)calloc(l->m, 16);
-	}
-	if (l->n == l->m) {
-		l->m <<= 1;
-		l->list = (pair64_t*)realloc(l->list, l->m * 16);
-	}
-	l->list[l->n].u = beg; l->list[l->n++].v = end;
-}
-
-static inline uint64_t insert_offset2(ti_lidx_t *index2, int _beg, int _end, uint64_t offset)
-{
-	int i, beg, end;
-	beg = _beg >> TAD_LIDX_SHIFT;
-	end = (_end - 1) >> TAD_LIDX_SHIFT;
-	if (index2->m < end + 1) {
-		int old_m = index2->m;
-		index2->m = end + 1;
-		kroundup32(index2->m);
-		index2->offset = (uint64_t*)realloc(index2->offset, index2->m * 8);
-		memset(index2->offset + old_m, 0, 8 * (index2->m - old_m));
-	}
-	if (beg == end) {
-		if (index2->offset[beg] == 0) index2->offset[beg] = offset;
-	} else {
-		for (i = beg; i <= end; ++i)
-			if (index2->offset[i] == 0) index2->offset[i] = offset;
-	}
-	if (index2->n < end + 1) index2->n = end + 1;
-	return (uint64_t)beg<<32 | end;
-}
-
-static void merge_chunks(ti_index_t *idx)
-{
-	khash_t(i) *index;
-	int i, l, m;
-	khint_t k;
-	for (i = 0; i < idx->n; ++i) {
-		index = idx->index[i];
-		for (k = kh_begin(index); k != kh_end(index); ++k) {
-			ti_binlist_t *p;
-			if (!kh_exist(index, k)) continue;
-			p = &kh_value(index, k);
-			m = 0;
-			for (l = 1; l < p->n; ++l) {
-				if (p->list[m].v>>16 == p->list[l].u>>16) p->list[m].v = p->list[l].v;
-				else p->list[++m] = p->list[l];
-			} // ~for(l)
-			p->n = m + 1;
-		} // ~for(k)
-	} // ~for(i)
-}
-
-static void fill_missing(ti_index_t *idx)
-{
-	int i, j;
-	for (i = 0; i < idx->n; ++i) {
-		ti_lidx_t *idx2 = &idx->index2[i];
-		for (j = 1; j < idx2->n; ++j)
-			if (idx2->offset[j] == 0)
-				idx2->offset[j] = idx2->offset[j-1];
-	}
-}
-
-ti_index_t *ti_index_core(BGZF *fp, const ti_conf_t *conf)
-{
-	int ret;
-	ti_index_t *idx;
-	uint32_t last_bin, save_bin;
-	int32_t last_coor, last_tid, save_tid;
-	uint64_t save_off, last_off, lineno = 0, offset0 = (uint64_t)-1, tmp;
-	kstring_t *str;
-
-	str = calloc(1, sizeof(kstring_t));
-
-	idx = (ti_index_t*)calloc(1, sizeof(ti_index_t));
-	idx->conf = *conf;
-	idx->n = idx->max = 0;
-	idx->tname = kh_init(s);
-	idx->index = 0;
-	idx->index2 = 0;
-
-	save_bin = save_tid = last_tid = last_bin = 0xffffffffu;
-	save_off = last_off = bgzf_tell(fp); last_coor = 0xffffffffu;
-	while ((ret = ti_readline(fp, str)) >= 0) {
-		ti_intv_t intv;
-		++lineno;
-		if (lineno <= idx->conf.line_skip || str->s[0] == idx->conf.meta_char) {
-			last_off = bgzf_tell(fp);
-			continue;
-		}
-		get_intv(idx, str, &intv);
-        if ( intv.beg<0 || intv.end<0 )
-        {
-            fprintf(stderr,"[ti_index_core] the indexes overlap or are out of bounds\n");
-            exit(1);
-        }
-		if (last_tid != intv.tid) { // change of chromosomes
-            if (last_tid>intv.tid )
-            {
-                fprintf(stderr,"[ti_index_core] the chromosome blocks not continuous at line %llu, is the file sorted? [pos %d]\n",(unsigned long long)lineno,intv.beg+1);
-                exit(1);
-            }
-			last_tid = intv.tid;
-			last_bin = 0xffffffffu;
-		} else if (last_coor > intv.beg) {
-			fprintf(stderr, "[ti_index_core] the file out of order at line %llu\n", (unsigned long long)lineno);
-			exit(1);
-		}
-		tmp = insert_offset2(&idx->index2[intv.tid], intv.beg, intv.end, last_off);
-		if (last_off == 0) offset0 = tmp;
-		if (intv.bin != last_bin) { // then possibly write the binning index
-			if (save_bin != 0xffffffffu) // save_bin==0xffffffffu only happens to the first record
-				insert_offset(idx->index[save_tid], save_bin, save_off, last_off);
-			save_off = last_off;
-			save_bin = last_bin = intv.bin;
-			save_tid = intv.tid;
-			if (save_tid < 0) break;
-		}
-		if (bgzf_tell(fp) <= last_off) {
-			fprintf(stderr, "[ti_index_core] bug in BGZF: %llx < %llx\n",
-					(unsigned long long)bgzf_tell(fp), (unsigned long long)last_off);
-			exit(1);
-		}
-		last_off = bgzf_tell(fp);
-		last_coor = intv.beg;
-	}
-	if (save_tid >= 0) insert_offset(idx->index[save_tid], save_bin, save_off, bgzf_tell(fp));
-	merge_chunks(idx);
-	fill_missing(idx);
-	if (offset0 != (uint64_t)-1 && idx->n && idx->index2[0].offset) {
-		int i, beg = offset0>>32, end = offset0&0xffffffffu;
-		for (i = beg; i <= end; ++i) idx->index2[0].offset[i] = 0;
-	}
-
-	free(str->s); free(str);
-	return idx;
-}
-
-void ti_index_destroy(ti_index_t *idx)
-{
-	khint_t k;
-	int i;
-	if (idx == 0) return;
-	// destroy the name hash table
-	for (k = kh_begin(idx->tname); k != kh_end(idx->tname); ++k) {
-		if (kh_exist(idx->tname, k))
-			free((char*)kh_key(idx->tname, k));
-	}
-	kh_destroy(s, idx->tname);
-	// destroy the binning index
-	for (i = 0; i < idx->n; ++i) {
-		khash_t(i) *index = idx->index[i];
-		ti_lidx_t *index2 = idx->index2 + i;
-		for (k = kh_begin(index); k != kh_end(index); ++k) {
-			if (kh_exist(index, k))
-				free(kh_value(index, k).list);
-		}
-		kh_destroy(i, index);
-		free(index2->offset);
-	}
-	free(idx->index);
-	// destroy the linear index
-	free(idx->index2);
-	free(idx);
-}
-
-/******************
- * index file I/O *
- ******************/
-
-void ti_index_save(const ti_index_t *idx, BGZF *fp)
-{
-	int32_t i, size, ti_is_be;
-	khint_t k;
-	ti_is_be = bam_is_big_endian();
-	bgzf_write(fp, "TBI\1", 4);
-	if (ti_is_be) {
-		uint32_t x = idx->n;
-		bgzf_write(fp, bam_swap_endian_4p(&x), 4);
-	} else bgzf_write(fp, &idx->n, 4);
-	assert(sizeof(ti_conf_t) == 24);
-	if (ti_is_be) { // write ti_conf_t;
-		uint32_t x[6];
-		memcpy(x, &idx->conf, 24);
-		for (i = 0; i < 6; ++i) bgzf_write(fp, bam_swap_endian_4p(&x[i]), 4);
-	} else bgzf_write(fp, &idx->conf, sizeof(ti_conf_t));
-	{ // write target names
-		char **name;
-		int32_t l = 0;
-		name = calloc(kh_size(idx->tname), sizeof(void*));
-		for (k = kh_begin(idx->tname); k != kh_end(idx->tname); ++k)
-			if (kh_exist(idx->tname, k))
-				name[kh_value(idx->tname, k)] = (char*)kh_key(idx->tname, k);
-		for (i = 0; i < kh_size(idx->tname); ++i)
-			l += strlen(name[i]) + 1;
-		if (ti_is_be) bgzf_write(fp, bam_swap_endian_4p(&l), 4);
-		else bgzf_write(fp, &l, 4);
-		for (i = 0; i < kh_size(idx->tname); ++i)
-			bgzf_write(fp, name[i], strlen(name[i]) + 1);
-		free(name);
-	}
-	for (i = 0; i < idx->n; ++i) {
-		khash_t(i) *index = idx->index[i];
-		ti_lidx_t *index2 = idx->index2 + i;
-		// write binning index
-		size = kh_size(index);
-		if (ti_is_be) { // big endian
-			uint32_t x = size;
-			bgzf_write(fp, bam_swap_endian_4p(&x), 4);
-		} else bgzf_write(fp, &size, 4);
-		for (k = kh_begin(index); k != kh_end(index); ++k) {
-			if (kh_exist(index, k)) {
-				ti_binlist_t *p = &kh_value(index, k);
-				if (ti_is_be) { // big endian
-					uint32_t x;
-					x = kh_key(index, k); bgzf_write(fp, bam_swap_endian_4p(&x), 4);
-					x = p->n; bgzf_write(fp, bam_swap_endian_4p(&x), 4);
-					for (x = 0; (int)x < p->n; ++x) {
-						bam_swap_endian_8p(&p->list[x].u);
-						bam_swap_endian_8p(&p->list[x].v);
-					}
-					bgzf_write(fp, p->list, 16 * p->n);
-					for (x = 0; (int)x < p->n; ++x) {
-						bam_swap_endian_8p(&p->list[x].u);
-						bam_swap_endian_8p(&p->list[x].v);
-					}
-				} else {
-					bgzf_write(fp, &kh_key(index, k), 4);
-					bgzf_write(fp, &p->n, 4);
-					bgzf_write(fp, p->list, 16 * p->n);
-				}
-			}
-		}
-		// write linear index (index2)
-		if (ti_is_be) {
-			int x = index2->n;
-			bgzf_write(fp, bam_swap_endian_4p(&x), 4);
-		} else bgzf_write(fp, &index2->n, 4);
-		if (ti_is_be) { // big endian
-			int x;
-			for (x = 0; (int)x < index2->n; ++x)
-				bam_swap_endian_8p(&index2->offset[x]);
-			bgzf_write(fp, index2->offset, 8 * index2->n);
-			for (x = 0; (int)x < index2->n; ++x)
-				bam_swap_endian_8p(&index2->offset[x]);
-		} else bgzf_write(fp, index2->offset, 8 * index2->n);
-	}
-}
-
-static ti_index_t *ti_index_load_core(BGZF *fp)
-{
-	int i, ti_is_be;
-	char magic[4];
-	ti_index_t *idx;
-	ti_is_be = bam_is_big_endian();
-	if (fp == 0) {
-		fprintf(stderr, "[ti_index_load_core] fail to load index.\n");
-		return 0;
-	}
-	bgzf_read(fp, magic, 4);
-	if (strncmp(magic, "TBI\1", 4)) {
-		fprintf(stderr, "[ti_index_load] wrong magic number.\n");
-		return 0;
-	}
-	idx = (ti_index_t*)calloc(1, sizeof(ti_index_t));	
-	bgzf_read(fp, &idx->n, 4);
-	if (ti_is_be) bam_swap_endian_4p(&idx->n);
-	idx->tname = kh_init(s);
-	idx->index = (khash_t(i)**)calloc(idx->n, sizeof(void*));
-	idx->index2 = (ti_lidx_t*)calloc(idx->n, sizeof(ti_lidx_t));
-	// read idx->conf
-	bgzf_read(fp, &idx->conf, sizeof(ti_conf_t));
-	if (ti_is_be) {
-		bam_swap_endian_4p(&idx->conf.preset);
-		bam_swap_endian_4p(&idx->conf.sc);
-		bam_swap_endian_4p(&idx->conf.bc);
-		bam_swap_endian_4p(&idx->conf.ec);
-		bam_swap_endian_4p(&idx->conf.meta_char);
-		bam_swap_endian_4p(&idx->conf.line_skip);
-	}
-	{ // read target names
-		int j, ret;
-		kstring_t *str;
-		int32_t l;
-		uint8_t *buf;
-		bgzf_read(fp, &l, 4);
-		if (ti_is_be) bam_swap_endian_4p(&l);
-		buf = calloc(l, 1);
-		bgzf_read(fp, buf, l);
-		str = calloc(1, sizeof(kstring_t));
-		for (i = j = 0; i < l; ++i) {
-			if (buf[i] == 0) {
-				khint_t k = kh_put(s, idx->tname, strdup(str->s), &ret);
-				kh_value(idx->tname, k) = j++;
-				str->l = 0;
-			} else kputc(buf[i], str);
-		}
-		free(str->s); free(str); free(buf);
-	}
-	for (i = 0; i < idx->n; ++i) {
-		khash_t(i) *index;
-		ti_lidx_t *index2 = idx->index2 + i;
-		uint32_t key, size;
-		khint_t k;
-		int j, ret;
-		ti_binlist_t *p;
-		index = idx->index[i] = kh_init(i);
-		// load binning index
-		bgzf_read(fp, &size, 4);
-		if (ti_is_be) bam_swap_endian_4p(&size);
-		for (j = 0; j < (int)size; ++j) {
-			bgzf_read(fp, &key, 4);
-			if (ti_is_be) bam_swap_endian_4p(&key);
-			k = kh_put(i, index, key, &ret);
-			p = &kh_value(index, k);
-			bgzf_read(fp, &p->n, 4);
-			if (ti_is_be) bam_swap_endian_4p(&p->n);
-			p->m = p->n;
-			p->list = (pair64_t*)malloc(p->m * 16);
-			bgzf_read(fp, p->list, 16 * p->n);
-			if (ti_is_be) {
-				int x;
-				for (x = 0; x < p->n; ++x) {
-					bam_swap_endian_8p(&p->list[x].u);
-					bam_swap_endian_8p(&p->list[x].v);
-				}
-			}
-		}
-		// load linear index
-		bgzf_read(fp, &index2->n, 4);
-		if (ti_is_be) bam_swap_endian_4p(&index2->n);
-		index2->m = index2->n;
-		index2->offset = (uint64_t*)calloc(index2->m, 8);
-		bgzf_read(fp, index2->offset, index2->n * 8);
-		if (ti_is_be)
-			for (j = 0; j < index2->n; ++j) bam_swap_endian_8p(&index2->offset[j]);
-	}
-	return idx;
-}
-
-ti_index_t *ti_index_load_local(const char *fnidx)
-{
-	BGZF *fp;
-	fp = bgzf_open(fnidx, "r");
-	if (fp) {
-		ti_index_t *idx = ti_index_load_core(fp);
-		bgzf_close(fp);
-		return idx;
-	} else return 0;
-}
-
-#ifdef _USE_KNETFILE
-static void download_from_remote(const char *url)
-{
-	const int buf_size = 1 * 1024 * 1024;
-	char *fn;
-	FILE *fp;
-	uint8_t *buf;
-	knetFile *fp_remote;
-	int l;
-	if (strstr(url, "ftp://") != url && strstr(url, "http://") != url) return;
-	l = strlen(url);
-	for (fn = (char*)url + l - 1; fn >= url; --fn)
-		if (*fn == '/') break;
-	++fn; // fn now points to the file name
-	fp_remote = knet_open(url, "r");
-	if (fp_remote == 0) {
-		fprintf(stderr, "[download_from_remote] fail to open remote file.\n");
-		return;
-	}
-	if ((fp = fopen(fn, "w")) == 0) {
-		fprintf(stderr, "[download_from_remote] fail to create file in the working directory.\n");
-		knet_close(fp_remote);
-		return;
-	}
-	buf = (uint8_t*)calloc(buf_size, 1);
-	while ((l = knet_read(fp_remote, buf, buf_size)) != 0)
-		fwrite(buf, 1, l, fp);
-	free(buf);
-	fclose(fp);
-	knet_close(fp_remote);
-}
-#else
-static void download_from_remote(const char *url)
-{
-	return;
-}
-#endif
-
-static char *get_local_version(const char *fn)
-{
-    struct stat sbuf;
-	char *fnidx = (char*)calloc(strlen(fn) + 5, 1);
-	strcat(strcpy(fnidx, fn), ".tbi");
-	if ((strstr(fnidx, "ftp://") == fnidx || strstr(fnidx, "http://") == fnidx)) {
-		char *p, *url;
-		int l = strlen(fnidx);
-		for (p = fnidx + l - 1; p >= fnidx; --p)
-			if (*p == '/') break;
-		url = fnidx; fnidx = strdup(p + 1);
-		if (stat(fnidx, &sbuf) == 0) {
-			free(url);
-			return fnidx;
-		}
-		fprintf(stderr, "[%s] downloading the index file...\n", __func__);
-		download_from_remote(url);
-		free(url);
-	}
-    if (stat(fnidx, &sbuf) == 0) return fnidx;
-	free(fnidx); return 0;
-}
-
-const char **ti_seqname(const ti_index_t *idx, int *n)
-{
-	const char **names;
-	khint_t k;
-	*n = idx->n;
-	names = calloc(idx->n, sizeof(void*));
-	for (k = kh_begin(idx->tname); k < kh_end(idx->tname); ++k)
-		if (kh_exist(idx->tname, k))
-			names[kh_val(idx->tname, k)] = kh_key(idx->tname, k);
-	return names;
-}
-
-ti_index_t *ti_index_load(const char *fn)
-{
-	ti_index_t *idx;
-    char *fname = get_local_version(fn);
-	if (fname == 0) return 0;
-	idx = ti_index_load_local(fname);
-	if (idx == 0) fprintf(stderr, "[ti_index_load] fail to load the index: %s\n", fname);
-    free(fname);
-	return idx;
-}
-
-int ti_index_build2(const char *fn, const ti_conf_t *conf, const char *_fnidx)
-{
-	char *fnidx;
-	BGZF *fp, *fpidx;
-	ti_index_t *idx;
-	if ((fp = bgzf_open(fn, "r")) == 0) {
-		fprintf(stderr, "[ti_index_build2] fail to open the file: %s\n", fn);
-		return -1;
-	}
-	idx = ti_index_core(fp, conf);
-	bgzf_close(fp);
-	if (_fnidx == 0) {
-		fnidx = (char*)calloc(strlen(fn) + 5, 1);
-		strcpy(fnidx, fn); strcat(fnidx, ".tbi");
-	} else fnidx = strdup(_fnidx);
-	fpidx = bgzf_open(fnidx, "w");
-	if (fpidx == 0) {
-		fprintf(stderr, "[ti_index_build2] fail to create the index file.\n");
-		free(fnidx);
-		return -1;
-	}
-	ti_index_save(idx, fpidx);
-	ti_index_destroy(idx);
-	bgzf_close(fpidx);
-	free(fnidx);
-	return 0;
-}
-
-int ti_index_build(const char *fn, const ti_conf_t *conf)
-{
-	return ti_index_build2(fn, conf, 0);
-}
-
-/********************************************
- * parse a region in the format chr:beg-end *
- ********************************************/
-
-int ti_get_tid(const ti_index_t *idx, const char *name)
-{
-	khiter_t iter;
-	const khash_t(s) *h = idx->tname;
-	iter = kh_get(s, h, name); /* get the tid */
-	if (iter == kh_end(h)) return -1;
-	return kh_value(h, iter);
-}
-
-int ti_parse_region(const ti_index_t *idx, const char *str, int *tid, int *begin, int *end)
-{
-	char *s, *p;
-	int i, l, k;
-	l = strlen(str);
-	p = s = (char*)malloc(l+1);
-	/* squeeze out "," */
-	for (i = k = 0; i != l; ++i)
-		if (str[i] != ',' && !isspace(str[i])) s[k++] = str[i];
-	s[k] = 0;
-	for (i = 0; i != k; ++i) if (s[i] == ':') break;
-	s[i] = 0;
-	if ((*tid = ti_get_tid(idx, s)) < 0) {
-		free(s);
-		return -1;
-	}
-	if (i == k) { /* dump the whole sequence */
-		*begin = 0; *end = 1<<29; free(s);
-		return 0;
-	}
-	for (p = s + i + 1; i != k; ++i) if (s[i] == '-') break;
-	*begin = atoi(p);
-	if (i < k) {
-		p = s + i + 1;
-		*end = atoi(p);
-	} else *end = 1<<29;
-	if (*begin > 0) --*begin;
-	free(s);
-	if (*begin > *end) return -1;
-	return 0;
-}
-
-/*******************************
- * retrieve a specified region *
- *******************************/
-
-#define MAX_BIN 37450 // =(8^6-1)/7+1
-
-static inline int reg2bins(uint32_t beg, uint32_t end, uint16_t list[MAX_BIN])
-{
-	int i = 0, k;
-	if (beg >= end) return 0;
-	if (end >= 1u<<29) end = 1u<<29;
-	--end;
-	list[i++] = 0;
-	for (k =    1 + (beg>>26); k <=    1 + (end>>26); ++k) list[i++] = k;
-	for (k =    9 + (beg>>23); k <=    9 + (end>>23); ++k) list[i++] = k;
-	for (k =   73 + (beg>>20); k <=   73 + (end>>20); ++k) list[i++] = k;
-	for (k =  585 + (beg>>17); k <=  585 + (end>>17); ++k) list[i++] = k;
-	for (k = 4681 + (beg>>14); k <= 4681 + (end>>14); ++k) list[i++] = k;
-	return i;
-}
-
-ti_iter_t ti_iter_first()
-{
-	ti_iter_t iter;
-	iter = calloc(1, sizeof(struct __ti_iter_t));
-	iter->from_first = 1;
-	return iter;
-}
-
-ti_iter_t ti_iter_query(const ti_index_t *idx, int tid, int beg, int end)
-{
-	uint16_t *bins;
-	int i, n_bins, n_off;
-	pair64_t *off;
-	khint_t k;
-	khash_t(i) *index;
-	uint64_t min_off;
-	ti_iter_t iter = 0;
-
-	if (beg < 0) beg = 0;
-	if (end < beg) return 0;
-	// initialize the iterator
-	iter = calloc(1, sizeof(struct __ti_iter_t));
-	iter->idx = idx; iter->tid = tid; iter->beg = beg; iter->end = end; iter->i = -1;
-	// random access
-	bins = (uint16_t*)calloc(MAX_BIN, 2);
-	n_bins = reg2bins(beg, end, bins);
-	index = idx->index[tid];
-	if (idx->index2[tid].n > 0) {
-		min_off = (beg>>TAD_LIDX_SHIFT >= idx->index2[tid].n)? idx->index2[tid].offset[idx->index2[tid].n-1]
-			: idx->index2[tid].offset[beg>>TAD_LIDX_SHIFT];
-		if (min_off == 0) { // improvement for index files built by tabix prior to 0.1.4
-			int n = beg>>TAD_LIDX_SHIFT;
-			if (n > idx->index2[tid].n) n = idx->index2[tid].n;
-			for (i = n - 1; i >= 0; --i)
-				if (idx->index2[tid].offset[i] != 0) break;
-			if (i >= 0) min_off = idx->index2[tid].offset[i];
-		}
-	} else min_off = 0; // tabix 0.1.2 may produce such index files
-	for (i = n_off = 0; i < n_bins; ++i) {
-		if ((k = kh_get(i, index, bins[i])) != kh_end(index))
-			n_off += kh_value(index, k).n;
-	}
-	if (n_off == 0) {
-		free(bins); return iter;
-	}
-	off = (pair64_t*)calloc(n_off, 16);
-	for (i = n_off = 0; i < n_bins; ++i) {
-		if ((k = kh_get(i, index, bins[i])) != kh_end(index)) {
-			int j;
-			ti_binlist_t *p = &kh_value(index, k);
-			for (j = 0; j < p->n; ++j)
-				if (p->list[j].v > min_off) off[n_off++] = p->list[j];
-		}
-	}
-	if (n_off == 0) {
-		free(bins); free(off); return iter;
-	}
-	free(bins);
-	{
-		int l;
-		ks_introsort(offt, n_off, off);
-		// resolve completely contained adjacent blocks
-		for (i = 1, l = 0; i < n_off; ++i)
-			if (off[l].v < off[i].v)
-				off[++l] = off[i];
-		n_off = l + 1;
-		// resolve overlaps between adjacent blocks; this may happen due to the merge in indexing
-		for (i = 1; i < n_off; ++i)
-			if (off[i-1].v >= off[i].u) off[i-1].v = off[i].u;
-		{ // merge adjacent blocks
-			for (i = 1, l = 0; i < n_off; ++i) {
-				if (off[l].v>>16 == off[i].u>>16) off[l].v = off[i].v;
-				else off[++l] = off[i];
-			}
-			n_off = l + 1;
-		}
-	}
-	iter->n_off = n_off; iter->off = off;
-	return iter;
-}
-
-const char *ti_iter_read(BGZF *fp, ti_iter_t iter, int *len)
-{
-	if (iter->finished) return 0;
-	if (iter->from_first) {
-		int ret;
-		if ((ret = ti_readline(fp, &iter->str)) < 0) {
-			iter->finished = 1;
-			return 0;
-		} else {
-			if (len) *len = iter->str.l;
-			return iter->str.s;
-		}
-	}
-	if (iter->n_off == 0) return 0;
-	while (1) {
-		int ret;
-		if (iter->curr_off == 0 || iter->curr_off >= iter->off[iter->i].v) { // then jump to the next chunk
-			if (iter->i == iter->n_off - 1) break; // no more chunks
-			if (iter->i >= 0) assert(iter->curr_off == iter->off[iter->i].v); // otherwise bug
-			if (iter->i < 0 || iter->off[iter->i].v != iter->off[iter->i+1].u) { // not adjacent chunks; then seek
-				bgzf_seek(fp, iter->off[iter->i+1].u, SEEK_SET);
-				iter->curr_off = bgzf_tell(fp);
-			}
-			++iter->i;
-		}
-		if ((ret = ti_readline(fp, &iter->str)) >= 0) {
-			ti_intv_t intv;
-			iter->curr_off = bgzf_tell(fp);
-			if (iter->str.s[0] == iter->idx->conf.meta_char) continue;
-			get_intv((ti_index_t*)iter->idx, &iter->str, &intv);
-			if (intv.tid != iter->tid || intv.beg >= iter->end) break; // no need to proceed
-			else if (intv.end > iter->beg && iter->end > intv.beg) {
-				if (len) *len = iter->str.l;
-				return iter->str.s;
-			}
-		} else break; // end of file
-	}
-	iter->finished = 1;
-	return 0;
-}
-
-void ti_iter_destroy(ti_iter_t iter)
-{
-	if (iter) {
-		free(iter->str.s); free(iter->off);
-		free(iter);
-	}
-}
-
-int ti_fetch(BGZF *fp, const ti_index_t *idx, int tid, int beg, int end, void *data, ti_fetch_f func)
-{
-	ti_iter_t iter;
-	const char *s;
-	int len;
-	iter = ti_iter_query(idx, tid, beg, end);
-	while ((s = ti_iter_read(fp, iter, &len)) != 0)
-		func(len, s, data);
-	ti_iter_destroy(iter);
-	return 0;
-}
-
-const ti_conf_t *ti_get_conf(ti_index_t *idx) { return idx? &idx->conf : 0; }
-
-/*******************
- * High-level APIs *
- *******************/
-
-tabix_t *ti_open(const char *fn, const char *fnidx)
-{
-	tabix_t *t;
-	BGZF *fp;
-	if ((fp = bgzf_open(fn, "r")) == 0) return 0;
-	t = calloc(1, sizeof(tabix_t));
-	t->fn = strdup(fn);
-	if (fnidx) t->fnidx = strdup(fnidx);
-	t->fp = fp;
-	return t;
-}
-
-void ti_close(tabix_t *t)
-{
-	if (t) {
-		bgzf_close(t->fp);
-		if (t->idx) ti_index_destroy(t->idx);
-		free(t->fn); free(t->fnidx);
-		free(t);
-	}
-}
-
-int ti_lazy_index_load(tabix_t *t)
-{
-	if (t->idx == 0) { // load index
-		if (t->fnidx) t->idx = ti_index_load_local(t->fnidx);
-		else t->idx = ti_index_load(t->fn);
-		if (t->idx == 0) return -1; // fail to load index
-	}
-	return 0;
-}
-
-ti_iter_t ti_queryi(tabix_t *t, int tid, int beg, int end)
-{
-	if (tid < 0) return ti_iter_first();
-	if (ti_lazy_index_load(t) != 0) return 0;
-	return ti_iter_query(t->idx, tid, beg, end);	
-}
-
-ti_iter_t ti_querys(tabix_t *t, const char *reg)
-{
-	int tid, beg, end;
-	if (reg == 0) return ti_iter_first();
-	if (ti_lazy_index_load(t) != 0) return 0;
-	if (ti_parse_region(t->idx, reg, &tid, &beg, &end) < 0) return 0;
-	return ti_iter_query(t->idx, tid, beg, end);
-}
-
-ti_iter_t ti_query(tabix_t *t, const char *name, int beg, int end)
-{
-	int tid;
-	if (name == 0) return ti_iter_first();
-	// then need to load the index
-	if (ti_lazy_index_load(t) != 0) return 0;
-	if ((tid = ti_get_tid(t->idx, name)) < 0) return 0;
-	return ti_iter_query(t->idx, tid, beg, end);
-}
-
-const char *ti_read(tabix_t *t, ti_iter_t iter, int *len)
-{
-	return ti_iter_read(t->fp, iter, len);
-}
diff --git a/vcflib/tabixpp/khash.h b/vcflib/tabixpp/khash.h
deleted file mode 100644
index 1d583ef..0000000
--- a/vcflib/tabixpp/khash.h
+++ /dev/null
@@ -1,486 +0,0 @@
-/* The MIT License
-
-   Copyright (c) 2008 Genome Research Ltd (GRL).
-
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   "Software"), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
-
-   The above copyright notice and this permission notice shall be
-   included in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-   SOFTWARE.
-*/
-
-/* Contact: Heng Li <lh3 at sanger.ac.uk> */
-
-/*
-  An example:
-
-#include "khash.h"
-KHASH_MAP_INIT_INT(32, char)
-int main() {
-	int ret, is_missing;
-	khiter_t k;
-	khash_t(32) *h = kh_init(32);
-	k = kh_put(32, h, 5, &ret);
-	if (!ret) kh_del(32, h, k);
-	kh_value(h, k) = 10;
-	k = kh_get(32, h, 10);
-	is_missing = (k == kh_end(h));
-	k = kh_get(32, h, 5);
-	kh_del(32, h, k);
-	for (k = kh_begin(h); k != kh_end(h); ++k)
-		if (kh_exist(h, k)) kh_value(h, k) = 1;
-	kh_destroy(32, h);
-	return 0;
-}
-*/
-
-/*
-  2008-09-19 (0.2.3):
-
-	* Corrected the example
-	* Improved interfaces
-
-  2008-09-11 (0.2.2):
-
-	* Improved speed a little in kh_put()
-
-  2008-09-10 (0.2.1):
-
-	* Added kh_clear()
-	* Fixed a compiling error
-
-  2008-09-02 (0.2.0):
-
-	* Changed to token concatenation which increases flexibility.
-
-  2008-08-31 (0.1.2):
-
-	* Fixed a bug in kh_get(), which has not been tested previously.
-
-  2008-08-31 (0.1.1):
-
-	* Added destructor
-*/
-
-
-#ifndef __AC_KHASH_H
-#define __AC_KHASH_H
-
-/*!
-  @header
-
-  Generic hash table library.
-
-  @copyright Heng Li
- */
-
-#define AC_VERSION_KHASH_H "0.2.2"
-
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-
-typedef uint32_t khint_t;
-typedef khint_t khiter_t;
-
-#define __ac_HASH_PRIME_SIZE 32
-static const uint32_t __ac_prime_list[__ac_HASH_PRIME_SIZE] =
-{
-  0ul,          3ul,          11ul,         23ul,         53ul,
-  97ul,         193ul,        389ul,        769ul,        1543ul,
-  3079ul,       6151ul,       12289ul,      24593ul,      49157ul,
-  98317ul,      196613ul,     393241ul,     786433ul,     1572869ul,
-  3145739ul,    6291469ul,    12582917ul,   25165843ul,   50331653ul,
-  100663319ul,  201326611ul,  402653189ul,  805306457ul,  1610612741ul,
-  3221225473ul, 4294967291ul
-};
-
-#define __ac_isempty(flag, i) ((flag[i>>4]>>((i&0xfU)<<1))&2)
-#define __ac_isdel(flag, i) ((flag[i>>4]>>((i&0xfU)<<1))&1)
-#define __ac_iseither(flag, i) ((flag[i>>4]>>((i&0xfU)<<1))&3)
-#define __ac_set_isdel_false(flag, i) (flag[i>>4]&=~(1ul<<((i&0xfU)<<1)))
-#define __ac_set_isempty_false(flag, i) (flag[i>>4]&=~(2ul<<((i&0xfU)<<1)))
-#define __ac_set_isboth_false(flag, i) (flag[i>>4]&=~(3ul<<((i&0xfU)<<1)))
-#define __ac_set_isdel_true(flag, i) (flag[i>>4]|=1ul<<((i&0xfU)<<1))
-
-static const double __ac_HASH_UPPER = 0.77;
-
-#define KHASH_INIT(name, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
-	typedef struct {													\
-		khint_t n_buckets, size, n_occupied, upper_bound;				\
-		uint32_t *flags;												\
-		khkey_t *keys;													\
-		khval_t *vals;													\
-	} kh_##name##_t;													\
-	static inline kh_##name##_t *kh_init_##name() {						\
-		return (kh_##name##_t*)calloc(1, sizeof(kh_##name##_t));		\
-	}																	\
-	static inline void kh_destroy_##name(kh_##name##_t *h)				\
-	{																	\
-		if (h) {														\
-			free(h->keys); free(h->flags);								\
-			free(h->vals);												\
-			free(h);													\
-		}																\
-	}																	\
-	static inline void kh_clear_##name(kh_##name##_t *h)				\
-	{																	\
-		if (h && h->flags) {											\
-			memset(h->flags, 0xaa, ((h->n_buckets>>4) + 1) * sizeof(uint32_t)); \
-			h->size = h->n_occupied = 0;								\
-		}																\
-	}																	\
-	static inline khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key) \
-	{																	\
-		if (h->n_buckets) {												\
-			khint_t inc, k, i, last;									\
-			k = __hash_func(key); i = k % h->n_buckets;					\
-			inc = 1 + k % (h->n_buckets - 1); last = i;					\
-			while (!__ac_isempty(h->flags, i) && (__ac_isdel(h->flags, i) || !__hash_equal(h->keys[i], key))) { \
-				if (i + inc >= h->n_buckets) i = i + inc - h->n_buckets; \
-				else i += inc;											\
-				if (i == last) return h->n_buckets;						\
-			}															\
-			return __ac_iseither(h->flags, i)? h->n_buckets : i;		\
-		} else return 0;												\
-	}																	\
-	static inline void kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets) \
-	{																	\
-		uint32_t *new_flags = 0;										\
-		khint_t j = 1;													\
-		{																\
-			khint_t t = __ac_HASH_PRIME_SIZE - 1;						\
-			while (__ac_prime_list[t] > new_n_buckets) --t;				\
-			new_n_buckets = __ac_prime_list[t+1];						\
-			if (h->size >= (khint_t)(new_n_buckets * __ac_HASH_UPPER + 0.5)) j = 0;	\
-			else {														\
-				new_flags = (uint32_t*)malloc(((new_n_buckets>>4) + 1) * sizeof(uint32_t));	\
-				memset(new_flags, 0xaa, ((new_n_buckets>>4) + 1) * sizeof(uint32_t)); \
-				if (h->n_buckets < new_n_buckets) {						\
-					h->keys = (khkey_t*)realloc(h->keys, new_n_buckets * sizeof(khkey_t)); \
-					if (kh_is_map)										\
-						h->vals = (khval_t*)realloc(h->vals, new_n_buckets * sizeof(khval_t)); \
-				}														\
-			}															\
-		}																\
-		if (j) {														\
-			for (j = 0; j != h->n_buckets; ++j) {						\
-				if (__ac_iseither(h->flags, j) == 0) {					\
-					khkey_t key = h->keys[j];							\
-					khval_t val;										\
-					if (kh_is_map) val = h->vals[j];					\
-					__ac_set_isdel_true(h->flags, j);					\
-					while (1) {											\
-						khint_t inc, k, i;								\
-						k = __hash_func(key);							\
-						i = k % new_n_buckets;							\
-						inc = 1 + k % (new_n_buckets - 1);				\
-						while (!__ac_isempty(new_flags, i)) {			\
-							if (i + inc >= new_n_buckets) i = i + inc - new_n_buckets; \
-							else i += inc;								\
-						}												\
-						__ac_set_isempty_false(new_flags, i);			\
-						if (i < h->n_buckets && __ac_iseither(h->flags, i) == 0) { \
-							{ khkey_t tmp = h->keys[i]; h->keys[i] = key; key = tmp; } \
-							if (kh_is_map) { khval_t tmp = h->vals[i]; h->vals[i] = val; val = tmp; } \
-							__ac_set_isdel_true(h->flags, i);			\
-						} else {										\
-							h->keys[i] = key;							\
-							if (kh_is_map) h->vals[i] = val;			\
-							break;										\
-						}												\
-					}													\
-				}														\
-			}															\
-			if (h->n_buckets > new_n_buckets) {							\
-				h->keys = (khkey_t*)realloc(h->keys, new_n_buckets * sizeof(khkey_t)); \
-				if (kh_is_map)											\
-					h->vals = (khval_t*)realloc(h->vals, new_n_buckets * sizeof(khval_t)); \
-			}															\
-			free(h->flags);												\
-			h->flags = new_flags;										\
-			h->n_buckets = new_n_buckets;								\
-			h->n_occupied = h->size;									\
-			h->upper_bound = (khint_t)(h->n_buckets * __ac_HASH_UPPER + 0.5); \
-		}																\
-	}																	\
-	static inline khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret) \
-	{																	\
-		khint_t x;														\
-		if (h->n_occupied >= h->upper_bound) {							\
-			if (h->n_buckets > (h->size<<1)) kh_resize_##name(h, h->n_buckets - 1); \
-			else kh_resize_##name(h, h->n_buckets + 1);					\
-		}																\
-		{																\
-			khint_t inc, k, i, site, last;								\
-			x = site = h->n_buckets; k = __hash_func(key); i = k % h->n_buckets; \
-			if (__ac_isempty(h->flags, i)) x = i;						\
-			else {														\
-				inc = 1 + k % (h->n_buckets - 1); last = i;				\
-				while (!__ac_isempty(h->flags, i) && (__ac_isdel(h->flags, i) || !__hash_equal(h->keys[i], key))) { \
-					if (__ac_isdel(h->flags, i)) site = i;				\
-					if (i + inc >= h->n_buckets) i = i + inc - h->n_buckets; \
-					else i += inc;										\
-					if (i == last) { x = site; break; }					\
-				}														\
-				if (x == h->n_buckets) {								\
-					if (__ac_isempty(h->flags, i) && site != h->n_buckets) x = site; \
-					else x = i;											\
-				}														\
-			}															\
-		}																\
-		if (__ac_isempty(h->flags, x)) {								\
-			h->keys[x] = key;											\
-			__ac_set_isboth_false(h->flags, x);							\
-			++h->size; ++h->n_occupied;									\
-			*ret = 1;													\
-		} else if (__ac_isdel(h->flags, x)) {							\
-			h->keys[x] = key;											\
-			__ac_set_isboth_false(h->flags, x);							\
-			++h->size;													\
-			*ret = 2;													\
-		} else *ret = 0;												\
-		return x;														\
-	}																	\
-	static inline void kh_del_##name(kh_##name##_t *h, khint_t x)		\
-	{																	\
-		if (x != h->n_buckets && !__ac_iseither(h->flags, x)) {			\
-			__ac_set_isdel_true(h->flags, x);							\
-			--h->size;													\
-		}																\
-	}
-
-/* --- BEGIN OF HASH FUNCTIONS --- */
-
-/*! @function
-  @abstract     Integer hash function
-  @param  key   The integer [uint32_t]
-  @return       The hash value [khint_t]
- */
-#define kh_int_hash_func(key) (uint32_t)(key)
-/*! @function
-  @abstract     Integer comparison function
- */
-#define kh_int_hash_equal(a, b) ((a) == (b))
-/*! @function
-  @abstract     64-bit integer hash function
-  @param  key   The integer [uint64_t]
-  @return       The hash value [khint_t]
- */
-#define kh_int64_hash_func(key) (uint32_t)((key)>>33^(key)^(key)<<11)
-/*! @function
-  @abstract     64-bit integer comparison function
- */
-#define kh_int64_hash_equal(a, b) ((a) == (b))
-/*! @function
-  @abstract     const char* hash function
-  @param  s     Pointer to a null terminated string
-  @return       The hash value
- */
-static inline khint_t __ac_X31_hash_string(const char *s)
-{
-	khint_t h = *s;
-	if (h) for (++s ; *s; ++s) h = (h << 5) - h + *s;
-	return h;
-}
-/*! @function
-  @abstract     Another interface to const char* hash function
-  @param  key   Pointer to a null terminated string [const char*]
-  @return       The hash value [khint_t]
- */
-#define kh_str_hash_func(key) __ac_X31_hash_string(key)
-/*! @function
-  @abstract     Const char* comparison function
- */
-#define kh_str_hash_equal(a, b) (strcmp(a, b) == 0)
-
-/* --- END OF HASH FUNCTIONS --- */
-
-/* Other necessary macros... */
-
-/*!
-  @abstract Type of the hash table.
-  @param  name  Name of the hash table [symbol]
- */
-#define khash_t(name) kh_##name##_t
-
-/*! @function
-  @abstract     Initiate a hash table.
-  @param  name  Name of the hash table [symbol]
-  @return       Pointer to the hash table [khash_t(name)*]
- */
-#define kh_init(name) kh_init_##name()
-
-/*! @function
-  @abstract     Destroy a hash table.
-  @param  name  Name of the hash table [symbol]
-  @param  h     Pointer to the hash table [khash_t(name)*]
- */
-#define kh_destroy(name, h) kh_destroy_##name(h)
-
-/*! @function
-  @abstract     Reset a hash table without deallocating memory.
-  @param  name  Name of the hash table [symbol]
-  @param  h     Pointer to the hash table [khash_t(name)*]
- */
-#define kh_clear(name, h) kh_clear_##name(h)
-
-/*! @function
-  @abstract     Resize a hash table.
-  @param  name  Name of the hash table [symbol]
-  @param  h     Pointer to the hash table [khash_t(name)*]
-  @param  s     New size [khint_t]
- */
-#define kh_resize(name, h, s) kh_resize_##name(h, s)
-
-/*! @function
-  @abstract     Insert a key to the hash table.
-  @param  name  Name of the hash table [symbol]
-  @param  h     Pointer to the hash table [khash_t(name)*]
-  @param  k     Key [type of keys]
-  @param  r     Extra return code: 0 if the key is present in the hash table;
-                1 if the bucket is empty (never used); 2 if the element in
-				the bucket has been deleted [int*]
-  @return       Iterator to the inserted element [khint_t]
- */
-#define kh_put(name, h, k, r) kh_put_##name(h, k, r)
-
-/*! @function
-  @abstract     Retrieve a key from the hash table.
-  @param  name  Name of the hash table [symbol]
-  @param  h     Pointer to the hash table [khash_t(name)*]
-  @param  k     Key [type of keys]
-  @return       Iterator to the found element, or kh_end(h) is the element is absent [khint_t]
- */
-#define kh_get(name, h, k) kh_get_##name(h, k)
-
-/*! @function
-  @abstract     Remove a key from the hash table.
-  @param  name  Name of the hash table [symbol]
-  @param  h     Pointer to the hash table [khash_t(name)*]
-  @param  k     Iterator to the element to be deleted [khint_t]
- */
-#define kh_del(name, h, k) kh_del_##name(h, k)
-
-
-/*! @function
-  @abstract     Test whether a bucket contains data.
-  @param  h     Pointer to the hash table [khash_t(name)*]
-  @param  x     Iterator to the bucket [khint_t]
-  @return       1 if containing data; 0 otherwise [int]
- */
-#define kh_exist(h, x) (!__ac_iseither((h)->flags, (x)))
-
-/*! @function
-  @abstract     Get key given an iterator
-  @param  h     Pointer to the hash table [khash_t(name)*]
-  @param  x     Iterator to the bucket [khint_t]
-  @return       Key [type of keys]
- */
-#define kh_key(h, x) ((h)->keys[x])
-
-/*! @function
-  @abstract     Get value given an iterator
-  @param  h     Pointer to the hash table [khash_t(name)*]
-  @param  x     Iterator to the bucket [khint_t]
-  @return       Value [type of values]
-  @discussion   For hash sets, calling this results in segfault.
- */
-#define kh_val(h, x) ((h)->vals[x])
-
-/*! @function
-  @abstract     Alias of kh_val()
- */
-#define kh_value(h, x) ((h)->vals[x])
-
-/*! @function
-  @abstract     Get the start iterator
-  @param  h     Pointer to the hash table [khash_t(name)*]
-  @return       The start iterator [khint_t]
- */
-#define kh_begin(h) (khint_t)(0)
-
-/*! @function
-  @abstract     Get the end iterator
-  @param  h     Pointer to the hash table [khash_t(name)*]
-  @return       The end iterator [khint_t]
- */
-#define kh_end(h) ((h)->n_buckets)
-
-/*! @function
-  @abstract     Get the number of elements in the hash table
-  @param  h     Pointer to the hash table [khash_t(name)*]
-  @return       Number of elements in the hash table [khint_t]
- */
-#define kh_size(h) ((h)->size)
-
-/*! @function
-  @abstract     Get the number of buckets in the hash table
-  @param  h     Pointer to the hash table [khash_t(name)*]
-  @return       Number of buckets in the hash table [khint_t]
- */
-#define kh_n_buckets(h) ((h)->n_buckets)
-
-/* More conenient interfaces */
-
-/*! @function
-  @abstract     Instantiate a hash set containing integer keys
-  @param  name  Name of the hash table [symbol]
- */
-#define KHASH_SET_INIT_INT(name)										\
-	KHASH_INIT(name, uint32_t, char, 0, kh_int_hash_func, kh_int_hash_equal)
-
-/*! @function
-  @abstract     Instantiate a hash map containing integer keys
-  @param  name  Name of the hash table [symbol]
-  @param  khval_t  Type of values [type]
- */
-#define KHASH_MAP_INIT_INT(name, khval_t)								\
-	KHASH_INIT(name, uint32_t, khval_t, 1, kh_int_hash_func, kh_int_hash_equal)
-
-/*! @function
-  @abstract     Instantiate a hash map containing 64-bit integer keys
-  @param  name  Name of the hash table [symbol]
- */
-#define KHASH_SET_INIT_INT64(name)										\
-	KHASH_INIT(name, uint64_t, char, 0, kh_int64_hash_func, kh_int64_hash_equal)
-
-/*! @function
-  @abstract     Instantiate a hash map containing 64-bit integer keys
-  @param  name  Name of the hash table [symbol]
-  @param  khval_t  Type of values [type]
- */
-#define KHASH_MAP_INIT_INT64(name, khval_t)								\
-	KHASH_INIT(name, uint64_t, khval_t, 1, kh_int64_hash_func, kh_int64_hash_equal)
-
-typedef const char *kh_cstr_t;
-/*! @function
-  @abstract     Instantiate a hash map containing const char* keys
-  @param  name  Name of the hash table [symbol]
- */
-#define KHASH_SET_INIT_STR(name)										\
-	KHASH_INIT(name, kh_cstr_t, char, 0, kh_str_hash_func, kh_str_hash_equal)
-
-/*! @function
-  @abstract     Instantiate a hash map containing const char* keys
-  @param  name  Name of the hash table [symbol]
-  @param  khval_t  Type of values [type]
- */
-#define KHASH_MAP_INIT_STR(name, khval_t)								\
-	KHASH_INIT(name, kh_cstr_t, khval_t, 1, kh_str_hash_func, kh_str_hash_equal)
-
-#endif /* __AC_KHASH_H */
diff --git a/vcflib/tabixpp/knetfile.c b/vcflib/tabixpp/knetfile.c
deleted file mode 100644
index 7c96a3e..0000000
--- a/vcflib/tabixpp/knetfile.c
+++ /dev/null
@@ -1,632 +0,0 @@
-/* The MIT License
-
-   Copyright (c) 2008 Genome Research Ltd (GRL).
-
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   "Software"), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
-
-   The above copyright notice and this permission notice shall be
-   included in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-   SOFTWARE.
-*/
-
-/* Contact: Heng Li <lh3 at sanger.ac.uk> */
-
-/* Probably I will not do socket programming in the next few years and
-   therefore I decide to heavily annotate this file, for Linux and
-   Windows as well.  -lh3 */
-
-#include <time.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/types.h>
-
-#ifdef _WIN32
-#include <winsock.h>
-#else
-#include <netdb.h>
-#include <arpa/inet.h>
-#include <sys/socket.h>
-#endif
-
-#include "knetfile.h"
-
-/* In winsock.h, the type of a socket is SOCKET, which is: "typedef
- * u_int SOCKET". An invalid SOCKET is: "(SOCKET)(~0)", or signed
- * integer -1. In knetfile.c, I use "int" for socket type
- * throughout. This should be improved to avoid confusion.
- *
- * In Linux/Mac, recv() and read() do almost the same thing. You can see
- * in the header file that netread() is simply an alias of read(). In
- * Windows, however, they are different and using recv() is mandatory.
- */
-
-/* This function tests if the file handler is ready for reading (or
- * writing if is_read==0). */
-static int socket_wait(int fd, int is_read)
-{
-	fd_set fds, *fdr = 0, *fdw = 0;
-	struct timeval tv;
-	int ret;
-	tv.tv_sec = 5; tv.tv_usec = 0; // 5 seconds time out
-	FD_ZERO(&fds);
-	FD_SET(fd, &fds);
-	if (is_read) fdr = &fds;
-	else fdw = &fds;
-	ret = select(fd+1, fdr, fdw, 0, &tv);
-#ifndef _WIN32
-	if (ret == -1) perror("select");
-#else
-	if (ret == 0)
-		fprintf(stderr, "select time-out\n");
-	else if (ret == SOCKET_ERROR)
-		fprintf(stderr, "select: %d\n", WSAGetLastError());
-#endif
-	return ret;
-}
-
-#ifndef _WIN32
-/* This function does not work with Windows due to the lack of
- * getaddrinfo() in winsock. It is addapted from an example in "Beej's
- * Guide to Network Programming" (http://beej.us/guide/bgnet/). */
-static int socket_connect(const char *host, const char *port)
-{
-#define __err_connect(func) do { perror(func); freeaddrinfo(res); return -1; } while (0)
-
-	int on = 1, fd;
-	struct linger lng = { 0, 0 };
-	struct addrinfo hints, *res;
-	memset(&hints, 0, sizeof(struct addrinfo));
-	hints.ai_family = AF_UNSPEC;
-	hints.ai_socktype = SOCK_STREAM;
-	/* In Unix/Mac, getaddrinfo() is the most convenient way to get
-	 * server information. */
-	if (getaddrinfo(host, port, &hints, &res) != 0) __err_connect("getaddrinfo");
-	if ((fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) == -1) __err_connect("socket");
-	/* The following two setsockopt() are used by ftplib
-	 * (http://nbpfaus.net/~pfau/ftplib/). I am not sure if they
-	 * necessary. */
-	if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) __err_connect("setsockopt");
-	if (setsockopt(fd, SOL_SOCKET, SO_LINGER, &lng, sizeof(lng)) == -1) __err_connect("setsockopt");
-	if (connect(fd, res->ai_addr, res->ai_addrlen) != 0) __err_connect("connect");
-	freeaddrinfo(res);
-	return fd;
-}
-#else
-/* MinGW's printf has problem with "%lld" */
-char *int64tostr(char *buf, int64_t x)
-{
-	int cnt;
-	int i = 0;
-	do {
-		buf[i++] = '0' + x % 10;
-		x /= 10;
-	} while (x);
-	buf[i] = 0;
-	for (cnt = i, i = 0; i < cnt/2; ++i) {
-		int c = buf[i]; buf[i] = buf[cnt-i-1]; buf[cnt-i-1] = c;
-	}
-	return buf;
-}
-
-int64_t strtoint64(const char *buf)
-{
-	int64_t x;
-	for (x = 0; *buf != '\0'; ++buf)
-		x = x * 10 + ((int64_t) *buf - 48);
-	return x;
-}
-/* In windows, the first thing is to establish the TCP connection. */
-int knet_win32_init()
-{
-	WSADATA wsaData;
-	return WSAStartup(MAKEWORD(2, 2), &wsaData);
-}
-void knet_win32_destroy()
-{
-	WSACleanup();
-}
-/* A slightly modfied version of the following function also works on
- * Mac (and presummably Linux). However, this function is not stable on
- * my Mac. It sometimes works fine but sometimes does not. Therefore for
- * non-Windows OS, I do not use this one. */
-static SOCKET socket_connect(const char *host, const char *port)
-{
-#define __err_connect(func)										\
-	do {														\
-		fprintf(stderr, "%s: %d\n", func, WSAGetLastError());	\
-		return -1;												\
-	} while (0)
-
-	int on = 1;
-	SOCKET fd;
-	struct linger lng = { 0, 0 };
-	struct sockaddr_in server;
-	struct hostent *hp = 0;
-	// open socket
-	if ((fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) __err_connect("socket");
-	if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&on, sizeof(on)) == -1) __err_connect("setsockopt");
-	if (setsockopt(fd, SOL_SOCKET, SO_LINGER, (char*)&lng, sizeof(lng)) == -1) __err_connect("setsockopt");
-	// get host info
-	if (isalpha(host[0])) hp = gethostbyname(host);
-	else {
-		struct in_addr addr;
-		addr.s_addr = inet_addr(host);
-		hp = gethostbyaddr((char*)&addr, 4, AF_INET);
-	}
-	if (hp == 0) __err_connect("gethost");
-	// connect
-	server.sin_addr.s_addr = *((unsigned long*)hp->h_addr);
-	server.sin_family= AF_INET;
-	server.sin_port = htons(atoi(port));
-	if (connect(fd, (struct sockaddr*)&server, sizeof(server)) != 0) __err_connect("connect");
-	// freehostent(hp); // strangely in MSDN, hp is NOT freed (memory leak?!)
-	return fd;
-}
-#endif
-
-static off_t my_netread(int fd, void *buf, off_t len)
-{
-	off_t rest = len, curr, l = 0;
-	/* recv() and read() may not read the required length of data with
-	 * one call. They have to be called repeatedly. */
-	while (rest) {
-		if (socket_wait(fd, 1) <= 0) break; // socket is not ready for reading
-		curr = netread(fd, buf + l, rest);
-		/* According to the glibc manual, section 13.2, a zero returned
-		 * value indicates end-of-file (EOF), which should mean that
-		 * read() will not return zero if EOF has not been met but data
-		 * are not immediately available. */
-		if (curr == 0) break;
-		l += curr; rest -= curr;
-	}
-	return l;
-}
-
-/*************************
- * FTP specific routines *
- *************************/
-
-static int kftp_get_response(knetFile *ftp)
-{
-#ifndef _WIN32
-	unsigned char c;
-#else
-	char c;
-#endif
-	int n = 0;
-	char *p;
-	if (socket_wait(ftp->ctrl_fd, 1) <= 0) return 0;
-	while (netread(ftp->ctrl_fd, &c, 1)) { // FIXME: this is *VERY BAD* for unbuffered I/O
-		//fputc(c, stderr);
-		if (n >= ftp->max_response) {
-			ftp->max_response = ftp->max_response? ftp->max_response<<1 : 256;
-			ftp->response = realloc(ftp->response, ftp->max_response);
-		}
-		ftp->response[n++] = c;
-		if (c == '\n') {
-			if (n >= 4 && isdigit(ftp->response[0]) && isdigit(ftp->response[1]) && isdigit(ftp->response[2])
-				&& ftp->response[3] != '-') break;
-			n = 0;
-			continue;
-		}
-	}
-	if (n < 2) return -1;
-	ftp->response[n-2] = 0;
-	return strtol(ftp->response, &p, 0);
-}
-
-static int kftp_send_cmd(knetFile *ftp, const char *cmd, int is_get)
-{
-	if (socket_wait(ftp->ctrl_fd, 0) <= 0) return -1; // socket is not ready for writing
-	netwrite(ftp->ctrl_fd, cmd, strlen(cmd));
-	return is_get? kftp_get_response(ftp) : 0;
-}
-
-static int kftp_pasv_prep(knetFile *ftp)
-{
-	char *p;
-	int v[6];
-	kftp_send_cmd(ftp, "PASV\r\n", 1);
-	for (p = ftp->response; *p && *p != '('; ++p);
-	if (*p != '(') return -1;
-	++p;
-	sscanf(p, "%d,%d,%d,%d,%d,%d", &v[0], &v[1], &v[2], &v[3], &v[4], &v[5]);
-	memcpy(ftp->pasv_ip, v, 4 * sizeof(int));
-	ftp->pasv_port = (v[4]<<8&0xff00) + v[5];
-	return 0;
-}
-
-
-static int kftp_pasv_connect(knetFile *ftp)
-{
-	char host[80], port[10];
-	if (ftp->pasv_port == 0) {
-		fprintf(stderr, "[kftp_pasv_connect] kftp_pasv_prep() is not called before hand.\n");
-		return -1;
-	}
-	sprintf(host, "%d.%d.%d.%d", ftp->pasv_ip[0], ftp->pasv_ip[1], ftp->pasv_ip[2], ftp->pasv_ip[3]);
-	sprintf(port, "%d", ftp->pasv_port);
-	ftp->fd = socket_connect(host, port);
-	if (ftp->fd == -1) return -1;
-	return 0;
-}
-
-int kftp_connect(knetFile *ftp)
-{
-	ftp->ctrl_fd = socket_connect(ftp->host, ftp->port);
-	if (ftp->ctrl_fd == -1) return -1;
-	kftp_get_response(ftp);
-	kftp_send_cmd(ftp, "USER anonymous\r\n", 1);
-	kftp_send_cmd(ftp, "PASS kftp@\r\n", 1);
-	kftp_send_cmd(ftp, "TYPE I\r\n", 1);
-	return 0;
-}
-
-int kftp_reconnect(knetFile *ftp)
-{
-	if (ftp->ctrl_fd != -1) {
-		netclose(ftp->ctrl_fd);
-		ftp->ctrl_fd = -1;
-	}
-	netclose(ftp->fd);
-	ftp->fd = -1;
-	return kftp_connect(ftp);
-}
-
-// initialize ->type, ->host, ->retr and ->size
-knetFile *kftp_parse_url(const char *fn, const char *mode)
-{
-	knetFile *fp;
-	char *p;
-	int l;
-	if (strstr(fn, "ftp://") != fn) return 0;
-	for (p = (char*)fn + 6; *p && *p != '/'; ++p);
-	if (*p != '/') return 0;
-	l = p - fn - 6;
-	fp = calloc(1, sizeof(knetFile));
-	fp->type = KNF_TYPE_FTP;
-	fp->fd = -1;
-	/* the Linux/Mac version of socket_connect() also recognizes a port
-	 * like "ftp", but the Windows version does not. */
-	fp->port = strdup("21");
-	fp->host = calloc(l + 1, 1);
-	if (strchr(mode, 'c')) fp->no_reconnect = 1;
-	strncpy(fp->host, fn + 6, l);
-	fp->retr = calloc(strlen(p) + 8, 1);
-	sprintf(fp->retr, "RETR %s\r\n", p);
-    fp->size_cmd = calloc(strlen(p) + 8, 1);
-    sprintf(fp->size_cmd, "SIZE %s\r\n", p);
-	fp->seek_offset = 0;
-	return fp;
-}
-// place ->fd at offset off
-int kftp_connect_file(knetFile *fp)
-{
-	int ret;
-	long long file_size;
-	if (fp->fd != -1) {
-		netclose(fp->fd);
-		if (fp->no_reconnect) kftp_get_response(fp);
-	}
-	kftp_pasv_prep(fp);
-    kftp_send_cmd(fp, fp->size_cmd, 1);
-#ifndef _WIN32
-    if ( sscanf(fp->response,"%*d %lld", &file_size) != 1 )
-    {
-        fprintf(stderr,"[kftp_connect_file] %s\n", fp->response);
-        return -1;
-    }
-#else
-	const char *p = fp->response;
-	while (*p != ' ') ++p;
-	while (*p < '0' || *p > '9') ++p;
-	file_size = strtoint64(p);
-#endif
-	fp->file_size = file_size;
-	if (fp->offset>=0) {
-		char tmp[32];
-#ifndef _WIN32
-		sprintf(tmp, "REST %lld\r\n", (long long)fp->offset);
-#else
-		strcpy(tmp, "REST ");
-		int64tostr(tmp + 5, fp->offset);
-		strcat(tmp, "\r\n");
-#endif
-		kftp_send_cmd(fp, tmp, 1);
-	}
-	kftp_send_cmd(fp, fp->retr, 0);
-	kftp_pasv_connect(fp);
-	ret = kftp_get_response(fp);
-	if (ret != 150) {
-		fprintf(stderr, "[kftp_connect_file] %s\n", fp->response);
-		netclose(fp->fd);
-		fp->fd = -1;
-		return -1;
-	}
-	fp->is_ready = 1;
-	return 0;
-}
-
-
-/**************************
- * HTTP specific routines *
- **************************/
-
-knetFile *khttp_parse_url(const char *fn, const char *mode)
-{
-	knetFile *fp;
-	char *p, *proxy, *q;
-	int l;
-	if (strstr(fn, "http://") != fn) return 0;
-	// set ->http_host
-	for (p = (char*)fn + 7; *p && *p != '/'; ++p);
-	l = p - fn - 7;
-	fp = calloc(1, sizeof(knetFile));
-	fp->http_host = calloc(l + 1, 1);
-	strncpy(fp->http_host, fn + 7, l);
-	fp->http_host[l] = 0;
-	for (q = fp->http_host; *q && *q != ':'; ++q);
-	if (*q == ':') *q++ = 0;
-	// get http_proxy
-	proxy = getenv("http_proxy");
-	// set ->host, ->port and ->path
-	if (proxy == 0) {
-		fp->host = strdup(fp->http_host); // when there is no proxy, server name is identical to http_host name.
-		fp->port = strdup(*q? q : "80");
-		fp->path = strdup(*p? p : "/");
-	} else {
-		fp->host = (strstr(proxy, "http://") == proxy)? strdup(proxy + 7) : strdup(proxy);
-		for (q = fp->host; *q && *q != ':'; ++q);
-		if (*q == ':') *q++ = 0; 
-		fp->port = strdup(*q? q : "80");
-		fp->path = strdup(fn);
-	}
-	fp->type = KNF_TYPE_HTTP;
-	fp->ctrl_fd = fp->fd = -1;
-	fp->seek_offset = 0;
-	return fp;
-}
-
-int khttp_connect_file(knetFile *fp)
-{
-	int ret, l = 0;
-	char *buf, *p;
-	if (fp->fd != -1) netclose(fp->fd);
-	fp->fd = socket_connect(fp->host, fp->port);
-	buf = calloc(0x10000, 1); // FIXME: I am lazy... But in principle, 64KB should be large enough.
-	l += sprintf(buf + l, "GET %s HTTP/1.0\r\nHost: %s\r\n", fp->path, fp->http_host);
-    l += sprintf(buf + l, "Range: bytes=%lld-\r\n", (long long)fp->offset);
-	l += sprintf(buf + l, "\r\n");
-	netwrite(fp->fd, buf, l);
-	l = 0;
-	while (netread(fp->fd, buf + l, 1)) { // read HTTP header; FIXME: bad efficiency
-		if (buf[l] == '\n' && l >= 3)
-			if (strncmp(buf + l - 3, "\r\n\r\n", 4) == 0) break;
-		++l;
-	}
-	buf[l] = 0;
-	if (l < 14) { // prematured header
-		netclose(fp->fd);
-		fp->fd = -1;
-		return -1;
-	}
-	ret = strtol(buf + 8, &p, 0); // HTTP return code
-	if (ret == 200 && fp->offset>0) { // 200 (complete result); then skip beginning of the file
-		off_t rest = fp->offset;
-		while (rest) {
-			off_t l = rest < 0x10000? rest : 0x10000;
-			rest -= my_netread(fp->fd, buf, l);
-		}
-	} else if (ret != 206 && ret != 200) {
-		free(buf);
-		fprintf(stderr, "[khttp_connect_file] fail to open file (HTTP code: %d).\n", ret);
-		netclose(fp->fd);
-		fp->fd = -1;
-		return -1;
-	}
-	free(buf);
-	fp->is_ready = 1;
-	return 0;
-}
-
-/********************
- * Generic routines *
- ********************/
-
-knetFile *knet_open(const char *fn, const char *mode)
-{
-	knetFile *fp = 0;
-	if (mode[0] != 'r') {
-		fprintf(stderr, "[kftp_open] only mode \"r\" is supported.\n");
-		return 0;
-	}
-	if (strstr(fn, "ftp://") == fn) {
-		fp = kftp_parse_url(fn, mode);
-		if (fp == 0) return 0;
-		if (kftp_connect(fp) == -1) {
-			knet_close(fp);
-			return 0;
-		}
-		kftp_connect_file(fp);
-	} else if (strstr(fn, "http://") == fn) {
-		fp = khttp_parse_url(fn, mode);
-		if (fp == 0) return 0;
-		khttp_connect_file(fp);
-	} else { // local file
-#ifdef _WIN32
-		/* In windows, O_BINARY is necessary. In Linux/Mac, O_BINARY may
-		 * be undefined on some systems, although it is defined on my
-		 * Mac and the Linux I have tested on. */
-		int fd = open(fn, O_RDONLY | O_BINARY);
-#else		
-		int fd = open(fn, O_RDONLY);
-#endif
-		if (fd == -1) {
-			perror("open");
-			return 0;
-		}
-		fp = (knetFile*)calloc(1, sizeof(knetFile));
-		fp->type = KNF_TYPE_LOCAL;
-		fp->fd = fd;
-		fp->ctrl_fd = -1;
-	}
-	if (fp && fp->fd == -1) {
-		knet_close(fp);
-		return 0;
-	}
-	return fp;
-}
-
-knetFile *knet_dopen(int fd, const char *mode)
-{
-	knetFile *fp = (knetFile*)calloc(1, sizeof(knetFile));
-	fp->type = KNF_TYPE_LOCAL;
-	fp->fd = fd;
-	return fp;
-}
-
-off_t knet_read(knetFile *fp, void *buf, off_t len)
-{
-	off_t l = 0;
-	if (fp->fd == -1) return 0;
-	if (fp->type == KNF_TYPE_FTP) {
-		if (fp->is_ready == 0) {
-			if (!fp->no_reconnect) kftp_reconnect(fp);
-			kftp_connect_file(fp);
-		}
-	} else if (fp->type == KNF_TYPE_HTTP) {
-		if (fp->is_ready == 0)
-			khttp_connect_file(fp);
-	}
-	if (fp->type == KNF_TYPE_LOCAL) { // on Windows, the following block is necessary; not on UNIX
-		off_t rest = len, curr;
-		while (rest) {
-			curr = read(fp->fd, buf + l, rest);
-			if (curr == 0) break;
-			l += curr; rest -= curr;
-		}
-	} else l = my_netread(fp->fd, buf, len);
-	fp->offset += l;
-	return l;
-}
-
-off_t knet_seek(knetFile *fp, int64_t off, int whence)
-{
-	if (whence == SEEK_SET && off == fp->offset) return 0;
-	if (fp->type == KNF_TYPE_LOCAL) {
-		/* Be aware that lseek() returns the offset after seeking,
-		 * while fseek() returns zero on success. */
-		off_t offset = lseek(fp->fd, off, whence);
-		if (offset == -1) {
-            // Be silent, it is OK for knet_seek to fail when the file is streamed
-            // fprintf(stderr,"[knet_seek] %s\n", strerror(errno));
-			return -1;
-		}
-		fp->offset = offset;
-		return 0;
-	}
-    else if (fp->type == KNF_TYPE_FTP) 
-    {
-        if (whence==SEEK_CUR)
-            fp->offset += off;
-        else if (whence==SEEK_SET)
-            fp->offset = off;
-        else if ( whence==SEEK_END)
-            fp->offset = fp->file_size+off;
-		fp->is_ready = 0;
-		return 0;
-	} 
-    else if (fp->type == KNF_TYPE_HTTP) 
-    {
-		if (whence == SEEK_END) { // FIXME: can we allow SEEK_END in future?
-			fprintf(stderr, "[knet_seek] SEEK_END is not supported for HTTP. Offset is unchanged.\n");
-			errno = ESPIPE;
-			return -1;
-		}
-        if (whence==SEEK_CUR)
-            fp->offset += off;
-        else if (whence==SEEK_SET)
-            fp->offset = off;
-		fp->is_ready = 0;
-		return fp->offset;
-	}
-	errno = EINVAL;
-    fprintf(stderr,"[knet_seek] %s\n", strerror(errno));
-	return -1;
-}
-
-int knet_close(knetFile *fp)
-{
-	if (fp == 0) return 0;
-	if (fp->ctrl_fd != -1) netclose(fp->ctrl_fd); // FTP specific
-	if (fp->fd != -1) {
-		/* On Linux/Mac, netclose() is an alias of close(), but on
-		 * Windows, it is an alias of closesocket(). */
-		if (fp->type == KNF_TYPE_LOCAL) close(fp->fd);
-		else netclose(fp->fd);
-	}
-	free(fp->host); free(fp->port);
-	free(fp->response); free(fp->retr); free(fp->size_cmd); // FTP specific
-	free(fp->path); free(fp->http_host); // HTTP specific
-	free(fp);
-	return 0;
-}
-
-#ifdef KNETFILE_MAIN
-int main(void)
-{
-	char *buf;
-	knetFile *fp;
-	int type = 4, l;
-#ifdef _WIN32
-	knet_win32_init();
-#endif
-	buf = calloc(0x100000, 1);
-	if (type == 0) {
-		fp = knet_open("knetfile.c", "r");
-		knet_seek(fp, 1000, SEEK_SET);
-	} else if (type == 1) { // NCBI FTP, large file
-		fp = knet_open("ftp://ftp.ncbi.nih.gov/1000genomes/ftp/data/NA12878/alignment/NA12878.chrom6.SLX.SRP000032.2009_06.bam", "r");
-		knet_seek(fp, 2500000000ll, SEEK_SET);
-		l = knet_read(fp, buf, 255);
-	} else if (type == 2) {
-		fp = knet_open("ftp://ftp.sanger.ac.uk/pub4/treefam/tmp/index.shtml", "r");
-		knet_seek(fp, 1000, SEEK_SET);
-	} else if (type == 3) {
-		fp = knet_open("http://www.sanger.ac.uk/Users/lh3/index.shtml", "r");
-		knet_seek(fp, 1000, SEEK_SET);
-	} else if (type == 4) {
-		fp = knet_open("http://www.sanger.ac.uk/Users/lh3/ex1.bam", "r");
-		knet_read(fp, buf, 10000);
-		knet_seek(fp, 20000, SEEK_SET);
-		knet_seek(fp, 10000, SEEK_SET);
-		l = knet_read(fp, buf+10000, 10000000) + 10000;
-	}
-	if (type != 4 && type != 1) {
-		knet_read(fp, buf, 255);
-		buf[255] = 0;
-		printf("%s\n", buf);
-	} else write(fileno(stdout), buf, l);
-	knet_close(fp);
-	free(buf);
-	return 0;
-}
-#endif
diff --git a/vcflib/tabixpp/knetfile.h b/vcflib/tabixpp/knetfile.h
deleted file mode 100644
index 0a0e66f..0000000
--- a/vcflib/tabixpp/knetfile.h
+++ /dev/null
@@ -1,75 +0,0 @@
-#ifndef KNETFILE_H
-#define KNETFILE_H
-
-#include <stdint.h>
-#include <fcntl.h>
-
-#ifndef _WIN32
-#define netread(fd, ptr, len) read(fd, ptr, len)
-#define netwrite(fd, ptr, len) write(fd, ptr, len)
-#define netclose(fd) close(fd)
-#else
-#include <winsock2.h>
-#define netread(fd, ptr, len) recv(fd, ptr, len, 0)
-#define netwrite(fd, ptr, len) send(fd, ptr, len, 0)
-#define netclose(fd) closesocket(fd)
-#endif
-
-// FIXME: currently I/O is unbuffered
-
-#define KNF_TYPE_LOCAL 1
-#define KNF_TYPE_FTP   2
-#define KNF_TYPE_HTTP  3
-
-typedef struct knetFile_s {
-	int type, fd;
-	int64_t offset;
-	char *host, *port;
-
-	// the following are for FTP only
-	int ctrl_fd, pasv_ip[4], pasv_port, max_response, no_reconnect, is_ready;
-	char *response, *retr, *size_cmd;
-	int64_t seek_offset; // for lazy seek
-    int64_t file_size;
-
-	// the following are for HTTP only
-	char *path, *http_host;
-} knetFile;
-
-#define knet_tell(fp) ((fp)->offset)
-#define knet_fileno(fp) ((fp)->fd)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef _WIN32
-	int knet_win32_init();
-	void knet_win32_destroy();
-#endif
-
-	knetFile *knet_open(const char *fn, const char *mode);
-
-	/* 
-	   This only works with local files.
-	 */
-	knetFile *knet_dopen(int fd, const char *mode);
-
-	/*
-	  If ->is_ready==0, this routine updates ->fd; otherwise, it simply
-	  reads from ->fd.
-	 */
-	off_t knet_read(knetFile *fp, void *buf, off_t len);
-
-	/*
-	  This routine only sets ->offset and ->is_ready=0. It does not
-	  communicate with the FTP server.
-	 */
-	off_t knet_seek(knetFile *fp, int64_t off, int whence);
-	int knet_close(knetFile *fp);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/vcflib/tabixpp/kseq.h b/vcflib/tabixpp/kseq.h
deleted file mode 100644
index 82face0..0000000
--- a/vcflib/tabixpp/kseq.h
+++ /dev/null
@@ -1,227 +0,0 @@
-/* The MIT License
-
-   Copyright (c) 2008 Genome Research Ltd (GRL).
-
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   "Software"), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
-
-   The above copyright notice and this permission notice shall be
-   included in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-   SOFTWARE.
-*/
-
-/* Contact: Heng Li <lh3 at sanger.ac.uk> */
-
-/*
-  2009-07-16 (lh3): in kstream_t, change "char*" to "unsigned char*"
- */
-
-/* Last Modified: 12APR2009 */
-
-#ifndef AC_KSEQ_H
-#define AC_KSEQ_H
-
-#include <ctype.h>
-#include <string.h>
-#include <stdlib.h>
-
-#define KS_SEP_SPACE 0 // isspace(): \t, \n, \v, \f, \r
-#define KS_SEP_TAB   1 // isspace() && !' '
-#define KS_SEP_MAX   1
-
-#define __KS_TYPE(type_t)						\
-	typedef struct __kstream_t {				\
-		unsigned char *buf;						\
-		int begin, end, is_eof;					\
-		type_t f;								\
-	} kstream_t;
-
-#define ks_eof(ks) ((ks)->is_eof && (ks)->begin >= (ks)->end)
-#define ks_rewind(ks) ((ks)->is_eof = (ks)->begin = (ks)->end = 0)
-
-#define __KS_BASIC(type_t, __bufsize)								\
-	static inline kstream_t *ks_init(type_t f)						\
-	{																\
-		kstream_t *ks = (kstream_t*)calloc(1, sizeof(kstream_t));	\
-		ks->f = f;													\
-		ks->buf = malloc(__bufsize);								\
-		return ks;													\
-	}																\
-	static inline void ks_destroy(kstream_t *ks)					\
-	{																\
-		if (ks) {													\
-			free(ks->buf);											\
-			free(ks);												\
-		}															\
-	}
-
-#define __KS_GETC(__read, __bufsize)						\
-	static inline int ks_getc(kstream_t *ks)				\
-	{														\
-		if (ks->is_eof && ks->begin >= ks->end) return -1;	\
-		if (ks->begin >= ks->end) {							\
-			ks->begin = 0;									\
-			ks->end = __read(ks->f, ks->buf, __bufsize);	\
-			if (ks->end < __bufsize) ks->is_eof = 1;		\
-			if (ks->end == 0) return -1;					\
-		}													\
-		return (int)ks->buf[ks->begin++];					\
-	}
-
-#ifndef KSTRING_T
-#define KSTRING_T kstring_t
-typedef struct __kstring_t {
-	size_t l, m;
-	char *s;
-} kstring_t;
-#endif
-
-#ifndef kroundup32
-#define kroundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x))
-#endif
-
-#define __KS_GETUNTIL(__read, __bufsize)								\
-	static int ks_getuntil(kstream_t *ks, int delimiter, kstring_t *str, int *dret) \
-	{																	\
-		if (dret) *dret = 0;											\
-		str->l = 0;														\
-		if (ks->begin >= ks->end && ks->is_eof) return -1;				\
-		for (;;) {														\
-			int i;														\
-			if (ks->begin >= ks->end) {									\
-				if (!ks->is_eof) {										\
-					ks->begin = 0;										\
-					ks->end = __read(ks->f, ks->buf, __bufsize);		\
-					if (ks->end < __bufsize) ks->is_eof = 1;			\
-					if (ks->end == 0) break;							\
-				} else break;											\
-			}															\
-			if (delimiter > KS_SEP_MAX) {								\
-				for (i = ks->begin; i < ks->end; ++i)					\
-					if (ks->buf[i] == delimiter) break;					\
-			} else if (delimiter == KS_SEP_SPACE) {						\
-				for (i = ks->begin; i < ks->end; ++i)					\
-					if (isspace(ks->buf[i])) break;						\
-			} else if (delimiter == KS_SEP_TAB) {						\
-				for (i = ks->begin; i < ks->end; ++i)					\
-					if (isspace(ks->buf[i]) && ks->buf[i] != ' ') break; \
-			} else i = 0; /* never come to here! */						\
-			if (str->m - str->l < i - ks->begin + 1) {					\
-				str->m = str->l + (i - ks->begin) + 1;					\
-				kroundup32(str->m);										\
-				str->s = (char*)realloc(str->s, str->m);				\
-			}															\
-			memcpy(str->s + str->l, ks->buf + ks->begin, i - ks->begin); \
-			str->l = str->l + (i - ks->begin);							\
-			ks->begin = i + 1;											\
-			if (i < ks->end) {											\
-				if (dret) *dret = ks->buf[i];							\
-				break;													\
-			}															\
-		}																\
-		if (str->l == 0) {												\
-			str->m = 1;													\
-			str->s = (char*)calloc(1, 1);								\
-		}																\
-		str->s[str->l] = '\0';											\
-		return str->l;													\
-	}
-
-#define KSTREAM_INIT(type_t, __read, __bufsize) \
-	__KS_TYPE(type_t)							\
-	__KS_BASIC(type_t, __bufsize)				\
-	__KS_GETC(__read, __bufsize)				\
-	__KS_GETUNTIL(__read, __bufsize)
-
-#define __KSEQ_BASIC(type_t)											\
-	static inline kseq_t *kseq_init(type_t fd)							\
-	{																	\
-		kseq_t *s = (kseq_t*)calloc(1, sizeof(kseq_t));					\
-		s->f = ks_init(fd);												\
-		return s;														\
-	}																	\
-	static inline void kseq_rewind(kseq_t *ks)							\
-	{																	\
-		ks->last_char = 0;												\
-		ks->f->is_eof = ks->f->begin = ks->f->end = 0;					\
-	}																	\
-	static inline void kseq_destroy(kseq_t *ks)							\
-	{																	\
-		if (!ks) return;												\
-		free(ks->name.s); free(ks->comment.s); free(ks->seq.s);	free(ks->qual.s); \
-		ks_destroy(ks->f);												\
-		free(ks);														\
-	}
-
-/* Return value:
-   >=0  length of the sequence (normal)
-   -1   end-of-file
-   -2   truncated quality string
- */
-#define __KSEQ_READ														\
-	static int kseq_read(kseq_t *seq)									\
-	{																	\
-		int c;															\
-		kstream_t *ks = seq->f;											\
-		if (seq->last_char == 0) { /* then jump to the next header line */ \
-			while ((c = ks_getc(ks)) != -1 && c != '>' && c != '@');	\
-			if (c == -1) return -1; /* end of file */					\
-			seq->last_char = c;											\
-		} /* the first header char has been read */						\
-		seq->comment.l = seq->seq.l = seq->qual.l = 0;					\
-		if (ks_getuntil(ks, 0, &seq->name, &c) < 0) return -1;			\
-		if (c != '\n') ks_getuntil(ks, '\n', &seq->comment, 0);			\
-		while ((c = ks_getc(ks)) != -1 && c != '>' && c != '+' && c != '@') { \
-			if (isgraph(c)) { /* printable non-space character */		\
-				if (seq->seq.l + 1 >= seq->seq.m) { /* double the memory */ \
-					seq->seq.m = seq->seq.l + 2;						\
-					kroundup32(seq->seq.m); /* rounded to next closest 2^k */ \
-					seq->seq.s = (char*)realloc(seq->seq.s, seq->seq.m); \
-				}														\
-				seq->seq.s[seq->seq.l++] = (char)c;						\
-			}															\
-		}																\
-		if (c == '>' || c == '@') seq->last_char = c; /* the first header char has been read */	\
-		seq->seq.s[seq->seq.l] = 0;	/* null terminated string */		\
-		if (c != '+') return seq->seq.l; /* FASTA */					\
-		if (seq->qual.m < seq->seq.m) {	/* allocate enough memory */	\
-			seq->qual.m = seq->seq.m;									\
-			seq->qual.s = (char*)realloc(seq->qual.s, seq->qual.m);		\
-		}																\
-		while ((c = ks_getc(ks)) != -1 && c != '\n'); /* skip the rest of '+' line */ \
-		if (c == -1) return -2; /* we should not stop here */			\
-		while ((c = ks_getc(ks)) != -1 && seq->qual.l < seq->seq.l)		\
-			if (c >= 33 && c <= 127) seq->qual.s[seq->qual.l++] = (unsigned char)c;	\
-		seq->qual.s[seq->qual.l] = 0; /* null terminated string */		\
-		seq->last_char = 0;	/* we have not come to the next header line */ \
-		if (seq->seq.l != seq->qual.l) return -2; /* qual string is shorter than seq string */ \
-		return seq->seq.l;												\
-	}
-
-#define __KSEQ_TYPE(type_t)						\
-	typedef struct {							\
-		kstring_t name, comment, seq, qual;		\
-		int last_char;							\
-		kstream_t *f;							\
-	} kseq_t;
-
-#define KSEQ_INIT(type_t, __read)				\
-	KSTREAM_INIT(type_t, __read, 4096)			\
-	__KSEQ_TYPE(type_t)							\
-	__KSEQ_BASIC(type_t)						\
-	__KSEQ_READ
-
-#endif
diff --git a/vcflib/tabixpp/ksort.h b/vcflib/tabixpp/ksort.h
deleted file mode 100644
index 16a03fd..0000000
--- a/vcflib/tabixpp/ksort.h
+++ /dev/null
@@ -1,271 +0,0 @@
-/* The MIT License
-
-   Copyright (c) 2008 Genome Research Ltd (GRL).
-
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   "Software"), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
-
-   The above copyright notice and this permission notice shall be
-   included in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-   SOFTWARE.
-*/
-
-/* Contact: Heng Li <lh3 at sanger.ac.uk> */
-
-/*
-  2008-11-16 (0.1.4):
-
-    * Fixed a bug in introsort() that happens in rare cases.
-
-  2008-11-05 (0.1.3):
-
-    * Fixed a bug in introsort() for complex comparisons.
-
-	* Fixed a bug in mergesort(). The previous version is not stable.
-
-  2008-09-15 (0.1.2):
-
-	* Accelerated introsort. On my Mac (not on another Linux machine),
-	  my implementation is as fast as std::sort on random input.
-
-	* Added combsort and in introsort, switch to combsort if the
-	  recursion is too deep.
-
-  2008-09-13 (0.1.1):
-
-	* Added k-small algorithm
-
-  2008-09-05 (0.1.0):
-
-	* Initial version
-
-*/
-
-#ifndef AC_KSORT_H
-#define AC_KSORT_H
-
-#include <stdlib.h>
-#include <string.h>
-
-typedef struct {
-	void *left, *right;
-	int depth;
-} ks_isort_stack_t;
-
-#define KSORT_SWAP(type_t, a, b) { register type_t t=(a); (a)=(b); (b)=t; }
-
-#define KSORT_INIT(name, type_t, __sort_lt)								\
-	void ks_mergesort_##name(size_t n, type_t array[], type_t temp[])	\
-	{																	\
-		type_t *a2[2], *a, *b;											\
-		int curr, shift;												\
-																		\
-		a2[0] = array;													\
-		a2[1] = temp? temp : (type_t*)malloc(sizeof(type_t) * n);		\
-		for (curr = 0, shift = 0; (1ul<<shift) < n; ++shift) {			\
-			a = a2[curr]; b = a2[1-curr];								\
-			if (shift == 0) {											\
-				type_t *p = b, *i, *eb = a + n;							\
-				for (i = a; i < eb; i += 2) {							\
-					if (i == eb - 1) *p++ = *i;							\
-					else {												\
-						if (__sort_lt(*(i+1), *i)) {					\
-							*p++ = *(i+1); *p++ = *i;					\
-						} else {										\
-							*p++ = *i; *p++ = *(i+1);					\
-						}												\
-					}													\
-				}														\
-			} else {													\
-				size_t i, step = 1ul<<shift;							\
-				for (i = 0; i < n; i += step<<1) {						\
-					type_t *p, *j, *k, *ea, *eb;						\
-					if (n < i + step) {									\
-						ea = a + n; eb = a;								\
-					} else {											\
-						ea = a + i + step;								\
-						eb = a + (n < i + (step<<1)? n : i + (step<<1)); \
-					}													\
-					j = a + i; k = a + i + step; p = b + i;				\
-					while (j < ea && k < eb) {							\
-						if (__sort_lt(*k, *j)) *p++ = *k++;				\
-						else *p++ = *j++;								\
-					}													\
-					while (j < ea) *p++ = *j++;							\
-					while (k < eb) *p++ = *k++;							\
-				}														\
-			}															\
-			curr = 1 - curr;											\
-		}																\
-		if (curr == 1) {												\
-			type_t *p = a2[0], *i = a2[1], *eb = array + n;				\
-			for (; p < eb; ++i) *p++ = *i;								\
-		}																\
-		if (temp == 0) free(a2[1]);										\
-	}																	\
-	void ks_heapadjust_##name(size_t i, size_t n, type_t l[])			\
-	{																	\
-		size_t k = i;													\
-		type_t tmp = l[i];												\
-		while ((k = (k << 1) + 1) < n) {								\
-			if (k != n - 1 && __sort_lt(l[k], l[k+1])) ++k;				\
-			if (__sort_lt(l[k], tmp)) break;							\
-			l[i] = l[k]; i = k;											\
-		}																\
-		l[i] = tmp;														\
-	}																	\
-	void ks_heapmake_##name(size_t lsize, type_t l[])					\
-	{																	\
-		size_t i;														\
-		for (i = (lsize >> 1) - 1; i != (size_t)(-1); --i)				\
-			ks_heapadjust_##name(i, lsize, l);							\
-	}																	\
-	void ks_heapsort_##name(size_t lsize, type_t l[])					\
-	{																	\
-		size_t i;														\
-		for (i = lsize - 1; i > 0; --i) {								\
-			type_t tmp;													\
-			tmp = *l; *l = l[i]; l[i] = tmp; ks_heapadjust_##name(0, i, l); \
-		}																\
-	}																	\
-	inline void __ks_insertsort_##name(type_t *s, type_t *t)			\
-	{																	\
-		type_t *i, *j, swap_tmp;										\
-		for (i = s + 1; i < t; ++i)										\
-			for (j = i; j > s && __sort_lt(*j, *(j-1)); --j) {			\
-				swap_tmp = *j; *j = *(j-1); *(j-1) = swap_tmp;			\
-			}															\
-	}																	\
-	void ks_combsort_##name(size_t n, type_t a[])						\
-	{																	\
-		const double shrink_factor = 1.2473309501039786540366528676643; \
-		int do_swap;													\
-		size_t gap = n;													\
-		type_t tmp, *i, *j;												\
-		do {															\
-			if (gap > 2) {												\
-				gap = (size_t)(gap / shrink_factor);					\
-				if (gap == 9 || gap == 10) gap = 11;					\
-			}															\
-			do_swap = 0;												\
-			for (i = a; i < a + n - gap; ++i) {							\
-				j = i + gap;											\
-				if (__sort_lt(*j, *i)) {								\
-					tmp = *i; *i = *j; *j = tmp;						\
-					do_swap = 1;										\
-				}														\
-			}															\
-		} while (do_swap || gap > 2);									\
-		if (gap != 1) __ks_insertsort_##name(a, a + n);					\
-	}																	\
-	void ks_introsort_##name(size_t n, type_t a[])						\
-	{																	\
-		int d;															\
-		ks_isort_stack_t *top, *stack;									\
-		type_t rp, swap_tmp;											\
-		type_t *s, *t, *i, *j, *k;										\
-																		\
-		if (n < 1) return;												\
-		else if (n == 2) {												\
-			if (__sort_lt(a[1], a[0])) { swap_tmp = a[0]; a[0] = a[1]; a[1] = swap_tmp; } \
-			return;														\
-		}																\
-		for (d = 2; 1ul<<d < n; ++d);									\
-		stack = (ks_isort_stack_t*)malloc(sizeof(ks_isort_stack_t) * ((sizeof(size_t)*d)+2)); \
-		top = stack; s = a; t = a + (n-1); d <<= 1;						\
-		while (1) {														\
-			if (s < t) {												\
-				if (--d == 0) {											\
-					ks_combsort_##name(t - s + 1, s);					\
-					t = s;												\
-					continue;											\
-				}														\
-				i = s; j = t; k = i + ((j-i)>>1) + 1;					\
-				if (__sort_lt(*k, *i)) {								\
-					if (__sort_lt(*k, *j)) k = j;						\
-				} else k = __sort_lt(*j, *i)? i : j;					\
-				rp = *k;												\
-				if (k != t) { swap_tmp = *k; *k = *t; *t = swap_tmp; }	\
-				for (;;) {												\
-					do ++i; while (__sort_lt(*i, rp));					\
-					do --j; while (i <= j && __sort_lt(rp, *j));		\
-					if (j <= i) break;									\
-					swap_tmp = *i; *i = *j; *j = swap_tmp;				\
-				}														\
-				swap_tmp = *i; *i = *t; *t = swap_tmp;					\
-				if (i-s > t-i) {										\
-					if (i-s > 16) { top->left = s; top->right = i-1; top->depth = d; ++top; } \
-					s = t-i > 16? i+1 : t;								\
-				} else {												\
-					if (t-i > 16) { top->left = i+1; top->right = t; top->depth = d; ++top; } \
-					t = i-s > 16? i-1 : s;								\
-				}														\
-			} else {													\
-				if (top == stack) {										\
-					free(stack);										\
-					__ks_insertsort_##name(a, a+n);						\
-					return;												\
-				} else { --top; s = (type_t*)top->left; t = (type_t*)top->right; d = top->depth; } \
-			}															\
-		}																\
-	}																	\
-	/* This function is adapted from: http://ndevilla.free.fr/median/ */ \
-	/* 0 <= kk < n */													\
-	type_t ks_ksmall_##name(size_t n, type_t arr[], size_t kk)			\
-	{																	\
-		type_t *low, *high, *k, *ll, *hh, *mid;							\
-		low = arr; high = arr + n - 1; k = arr + kk;					\
-		for (;;) {														\
-			if (high <= low) return *k;									\
-			if (high == low + 1) {										\
-				if (__sort_lt(*high, *low)) KSORT_SWAP(type_t, *low, *high); \
-				return *k;												\
-			}															\
-			mid = low + (high - low) / 2;								\
-			if (__sort_lt(*high, *mid)) KSORT_SWAP(type_t, *mid, *high); \
-			if (__sort_lt(*high, *low)) KSORT_SWAP(type_t, *low, *high); \
-			if (__sort_lt(*low, *mid)) KSORT_SWAP(type_t, *mid, *low);	\
-			KSORT_SWAP(type_t, *mid, *(low+1));							\
-			ll = low + 1; hh = high;									\
-			for (;;) {													\
-				do ++ll; while (__sort_lt(*ll, *low));					\
-				do --hh; while (__sort_lt(*low, *hh));					\
-				if (hh < ll) break;										\
-				KSORT_SWAP(type_t, *ll, *hh);							\
-			}															\
-			KSORT_SWAP(type_t, *low, *hh);								\
-			if (hh <= k) low = ll;										\
-			if (hh >= k) high = hh - 1;									\
-		}																\
-	}
-
-#define ks_mergesort(name, n, a, t) ks_mergesort_##name(n, a, t)
-#define ks_introsort(name, n, a) ks_introsort_##name(n, a)
-#define ks_combsort(name, n, a) ks_combsort_##name(n, a)
-#define ks_heapsort(name, n, a) ks_heapsort_##name(n, a)
-#define ks_heapmake(name, n, a) ks_heapmake_##name(n, a)
-#define ks_heapadjust(name, i, n, a) ks_heapadjust_##name(i, n, a)
-#define ks_ksmall(name, n, a, k) ks_ksmall_##name(n, a, k)
-
-#define ks_lt_generic(a, b) ((a) < (b))
-#define ks_lt_str(a, b) (strcmp((a), (b)) < 0)
-
-typedef const char *ksstr_t;
-
-#define KSORT_INIT_GENERIC(type_t) KSORT_INIT(type_t, type_t, ks_lt_generic)
-#define KSORT_INIT_STR KSORT_INIT(str, ksstr_t, ks_lt_str)
-
-#endif
diff --git a/vcflib/tabixpp/kstring.c b/vcflib/tabixpp/kstring.c
deleted file mode 100644
index e0203fa..0000000
--- a/vcflib/tabixpp/kstring.c
+++ /dev/null
@@ -1,165 +0,0 @@
-#include <stdarg.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <stdint.h>
-#include "kstring.h"
-
-int ksprintf(kstring_t *s, const char *fmt, ...)
-{
-	va_list ap;
-	int l;
-	va_start(ap, fmt);
-	l = vsnprintf(s->s + s->l, s->m - s->l, fmt, ap); // This line does not work with glibc 2.0. See `man snprintf'.
-	va_end(ap);
-	if (l + 1 > s->m - s->l) {
-		s->m = s->l + l + 2;
-		kroundup32(s->m);
-		s->s = (char*)realloc(s->s, s->m);
-		va_start(ap, fmt);
-		l = vsnprintf(s->s + s->l, s->m - s->l, fmt, ap);
-	}
-	va_end(ap);
-	s->l += l;
-	return l;
-}
-
-// s MUST BE a null terminated string; l = strlen(s)
-int ksplit_core(char *s, int delimiter, int *_max, int **_offsets)
-{
-	int i, n, max, last_char, last_start, *offsets, l;
-	n = 0; max = *_max; offsets = *_offsets;
-	l = strlen(s);
-	
-#define __ksplit_aux do {												\
-		if (_offsets) {													\
-			s[i] = 0;													\
-			if (n == max) {												\
-				max = max? max<<1 : 2;									\
-				offsets = (int*)realloc(offsets, sizeof(int) * max);	\
-			}															\
-			offsets[n++] = last_start;									\
-		} else ++n;														\
-	} while (0)
-
-	for (i = 0, last_char = last_start = 0; i <= l; ++i) {
-		if (delimiter == 0) {
-			if (isspace(s[i]) || s[i] == 0) {
-				if (isgraph(last_char)) __ksplit_aux; // the end of a field
-			} else {
-				if (isspace(last_char) || last_char == 0) last_start = i;
-			}
-		} else {
-			if (s[i] == delimiter || s[i] == 0) {
-				if (last_char != 0 && last_char != delimiter) __ksplit_aux; // the end of a field
-			} else {
-				if (last_char == delimiter || last_char == 0) last_start = i;
-			}
-		}
-		last_char = s[i];
-	}
-	*_max = max; *_offsets = offsets;
-	return n;
-}
-
-/**********************
- * Boyer-Moore search *
- **********************/
-
-// reference: http://www-igm.univ-mlv.fr/~lecroq/string/node14.html
-int *ksBM_prep(const uint8_t *pat, int m)
-{
-	int i, *suff, *prep, *bmGs, *bmBc;
-	prep = calloc(m + 256, 1);
-	bmGs = prep; bmBc = prep + m;
-	{ // preBmBc()
-		for (i = 0; i < 256; ++i) bmBc[i] = m;
-		for (i = 0; i < m - 1; ++i) bmBc[pat[i]] = m - i - 1;
-	}
-	suff = calloc(m, sizeof(int));
-	{ // suffixes()
-		int f = 0, g;
-		suff[m - 1] = m;
-		g = m - 1;
-		for (i = m - 2; i >= 0; --i) {
-			if (i > g && suff[i + m - 1 - f] < i - g)
-				suff[i] = suff[i + m - 1 - f];
-			else {
-				if (i < g) g = i;
-				f = i;
-				while (g >= 0 && pat[g] == pat[g + m - 1 - f]) --g;
-				suff[i] = f - g;
-			}
-		}
-	}
-	{ // preBmGs()
-		int j = 0;
-		for (i = 0; i < m; ++i) bmGs[i] = m;
-		for (i = m - 1; i >= 0; --i)
-			if (suff[i] == i + 1)
-				for (; j < m - 1 - i; ++j)
-					if (bmGs[j] == m)
-						bmGs[j] = m - 1 - i;
-		for (i = 0; i <= m - 2; ++i)
-			bmGs[m - 1 - suff[i]] = m - 1 - i;
-	}
-	free(suff);
-	return prep;
-}
-
-int *ksBM_search(const uint8_t *str, int n, const uint8_t *pat, int m, int *_prep, int *n_matches)
-{
-	int i, j, *prep, *bmGs, *bmBc;
-	int *matches = 0, mm = 0, nm = 0;
-	prep = _prep? _prep : ksBM_prep(pat, m);
-	bmGs = prep; bmBc = prep + m;
-	j = 0;
-	while (j <= n - m) {
-		for (i = m - 1; i >= 0 && pat[i] == str[i+j]; --i);
-		if (i < 0) {
-			if (nm == mm) {
-				mm = mm? mm<<1 : 1;
-				matches = realloc(matches, mm * sizeof(int));
-			}
-			matches[nm++] = j;
-			j += bmGs[0];
-		} else {
-			int max = bmBc[str[i+j]] - m + 1 + i;
-			if (max < bmGs[i]) max = bmGs[i];
-			j += max;
-		}
-	}
-	*n_matches = nm;
-	if (_prep == 0) free(prep);
-	return matches;
-}
-
-#ifdef KSTRING_MAIN
-#include <stdio.h>
-int main()
-{
-	kstring_t *s;
-	int *fields, n, i;
-	s = (kstring_t*)calloc(1, sizeof(kstring_t));
-	// test ksprintf()
-	ksprintf(s, " abcdefg:    %d ", 100);
-	printf("'%s'\n", s->s);
-	// test ksplit()
-	fields = ksplit(s, 0, &n);
-	for (i = 0; i < n; ++i)
-		printf("field[%d] = '%s'\n", i, s->s + fields[i]);
-	free(s);
-
-	{
-		static char *str = "abcdefgcdg";
-		static char *pat = "cd";
-		int n, *matches;
-		matches = ksBM_search(str, strlen(str), pat, strlen(pat), 0, &n);
-		printf("%d: \n", n);
-		for (i = 0; i < n; ++i)
-			printf("- %d\n", matches[i]);
-		free(matches);
-	}
-	return 0;
-}
-#endif
diff --git a/vcflib/tabixpp/kstring.h b/vcflib/tabixpp/kstring.h
deleted file mode 100644
index f4e5a99..0000000
--- a/vcflib/tabixpp/kstring.h
+++ /dev/null
@@ -1,68 +0,0 @@
-#ifndef KSTRING_H
-#define KSTRING_H
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdint.h>
-
-#ifndef kroundup32
-#define kroundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x))
-#endif
-
-#ifndef KSTRING_T
-#define KSTRING_T kstring_t
-typedef struct __kstring_t {
-	size_t l, m;
-	char *s;
-} kstring_t;
-#endif
-
-int ksprintf(kstring_t *s, const char *fmt, ...);
-int ksplit_core(char *s, int delimiter, int *_max, int **_offsets);
-
-// calculate the auxiliary array, allocated by calloc()
-int *ksBM_prep(const uint8_t *pat, int m);
-
-/* Search pat in str and returned the list of matches. The size of the
- * list is returned as n_matches. _prep is the array returned by
- * ksBM_prep(). If it is a NULL pointer, ksBM_prep() will be called. */
-int *ksBM_search(const uint8_t *str, int n, const uint8_t *pat, int m, int *_prep, int *n_matches);
-
-static inline int kputsn(const char *p, int l, kstring_t *s)
-{
-	if (s->l + l + 1 >= s->m) {
-		s->m = s->l + l + 2;
-		kroundup32(s->m);
-		s->s = (char*)realloc(s->s, s->m);
-	}
-	strncpy(s->s + s->l, p, l);
-	s->l += l;
-	s->s[s->l] = 0;
-	return l;
-}
-
-static inline int kputs(const char *p, kstring_t *s)
-{
-	return kputsn(p, strlen(p), s);
-}
-
-static inline int kputc(int c, kstring_t *s)
-{
-	if (s->l + 1 >= s->m) {
-		s->m = s->l + 2;
-		kroundup32(s->m);
-		s->s = (char*)realloc(s->s, s->m);
-	}
-	s->s[s->l++] = c;
-	s->s[s->l] = 0;
-	return c;
-}
-
-static inline int *ksplit(kstring_t *s, int delimiter, int *n)
-{
-	int max = 0, *offsets = 0;
-	*n = ksplit_core(s->s, delimiter, &max, &offsets);
-	return offsets;
-}
-
-#endif
diff --git a/vcflib/tabixpp/main.c b/vcflib/tabixpp/main.c
deleted file mode 100644
index 364abe5..0000000
--- a/vcflib/tabixpp/main.c
+++ /dev/null
@@ -1,290 +0,0 @@
-#include <string.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include "bgzf.h"
-#include "tabix.h"
-
-#define PACKAGE_VERSION "0.2.5 (r964)"
-
-#define error(...) { fprintf(stderr,__VA_ARGS__); return -1; }
-
-int reheader_file(const char *header, const char *file, int meta)
-{
-    BGZF *fp = bgzf_open(file,"r");
-    if (bgzf_read_block(fp) != 0 || !fp->block_length)
-        return -1;
-    
-    char *buffer = fp->uncompressed_block;
-    int skip_until = 0;
-
-    if ( buffer[0]==meta )
-    {
-        skip_until = 1;
-
-        // Skip the header
-        while (1)
-        {
-            if ( buffer[skip_until]=='\n' )
-            {
-                skip_until++;
-                if ( skip_until>=fp->block_length )
-                {
-                    if (bgzf_read_block(fp) != 0 || !fp->block_length)
-                        error("no body?\n");
-                    skip_until = 0;
-                }
-                // The header has finished
-                if ( buffer[skip_until]!=meta ) break;
-            }
-            skip_until++;
-            if ( skip_until>=fp->block_length )
-            {
-                if (bgzf_read_block(fp) != 0 || !fp->block_length)
-                    error("no body?\n");
-                skip_until = 0;
-            }
-        }
-    }
-
-    FILE *fh = fopen(header,"r");
-    if ( !fh )
-        error("%s: %s", header,strerror(errno));
-    int page_size = getpagesize();
-    char *buf = valloc(page_size);
-    BGZF *bgzf_out = bgzf_fdopen(fileno(stdout), "w");
-    ssize_t nread;
-    while ( (nread=fread(buf,1,page_size-1,fh))>0 )
-    {
-        if ( nread<page_size-1 && buf[nread-1]!='\n' )
-            buf[nread++] = '\n';
-        if (bgzf_write(bgzf_out, buf, nread) < 0) error("Error: %s\n",bgzf_out->error);
-    }
-    fclose(fh);
-
-    if ( fp->block_length - skip_until > 0 )
-    {
-        if (bgzf_write(bgzf_out, buffer+skip_until, fp->block_length-skip_until) < 0) 
-            error("Error: %s\n",fp->error);
-    }
-    if (bgzf_flush(bgzf_out) < 0) 
-        error("Error: %s\n",bgzf_out->error);
-
-    while (1)
-    {
-#ifdef _USE_KNETFILE
-        nread = knet_read(fp->x.fpr, buf, page_size);
-#else
-        nread = fread(buf, 1, page_size, fp->file);
-#endif
-        if ( nread<=0 ) 
-            break;
-
-#ifdef _USE_KNETFILE
-        int count = fwrite(buf, 1, nread, bgzf_out->x.fpw);
-#else
-        int count = fwrite(buf, 1, nread, bgzf_out->file);
-#endif
-        if (count != nread)
-            error("Write failed, wrote %d instead of %d bytes.\n", count,(int)nread);
-    }
-
-    if (bgzf_close(bgzf_out) < 0) 
-        error("Error: %s\n",bgzf_out->error);
-   
-    return 0;
-}
-
-
-int main(int argc, char *argv[])
-{
-	int c, skip = -1, meta = -1, list_chrms = 0, force = 0, print_header = 0, bed_reg = 0;
-	ti_conf_t conf = ti_conf_gff;
-    const char *reheader = NULL;
-	while ((c = getopt(argc, argv, "p:s:b:e:0S:c:lhfBr:")) >= 0) {
-		switch (c) {
-		case 'B': bed_reg = 1; break;
-		case '0': conf.preset |= TI_FLAG_UCSC; break;
-		case 'S': skip = atoi(optarg); break;
-		case 'c': meta = optarg[0]; break;
-		case 'p':
-			if (strcmp(optarg, "gff") == 0) conf = ti_conf_gff;
-			else if (strcmp(optarg, "bed") == 0) conf = ti_conf_bed;
-			else if (strcmp(optarg, "sam") == 0) conf = ti_conf_sam;
-			else if (strcmp(optarg, "vcf") == 0 || strcmp(optarg, "vcf4") == 0) conf = ti_conf_vcf;
-			else if (strcmp(optarg, "psltbl") == 0) conf = ti_conf_psltbl;
-			else {
-				fprintf(stderr, "[main] unrecognized preset '%s'\n", optarg);
-				return 1;
-			}
-			break;
-		case 's': conf.sc = atoi(optarg); break;
-		case 'b': conf.bc = atoi(optarg); break;
-		case 'e': conf.ec = atoi(optarg); break;
-        case 'l': list_chrms = 1; break;
-        case 'h': print_header = 1; break;
-		case 'f': force = 1; break;
-        case 'r': reheader = optarg; break;
-		}
-	}
-	if (skip >= 0) conf.line_skip = skip;
-	if (meta >= 0) conf.meta_char = meta;
-	if (optind == argc) {
-		fprintf(stderr, "\n");
-		fprintf(stderr, "Program: tabix (TAB-delimited file InderXer)\n");
-		fprintf(stderr, "Version: %s\n\n", PACKAGE_VERSION);
-		fprintf(stderr, "Usage:   tabix <in.tab.bgz> [region1 [region2 [...]]]\n\n");
-		fprintf(stderr, "Options: -p STR     preset: gff, bed, sam, vcf, psltbl [gff]\n");
-		fprintf(stderr, "         -s INT     sequence name column [1]\n");
-		fprintf(stderr, "         -b INT     start column [4]\n");
-		fprintf(stderr, "         -e INT     end column; can be identical to '-b' [5]\n");
-		fprintf(stderr, "         -S INT     skip first INT lines [0]\n");
-		fprintf(stderr, "         -c CHAR    symbol for comment/meta lines [#]\n");
-	    fprintf(stderr, "         -r FILE    replace the header with the content of FILE [null]\n");
-		fprintf(stderr, "         -B         region1 is a BED file (entire file will be read)\n");
-		fprintf(stderr, "         -0         zero-based coordinate\n");
-		fprintf(stderr, "         -h         print the header lines\n");
-		fprintf(stderr, "         -l         list chromosome names\n");
-		fprintf(stderr, "         -f         force to overwrite the index\n");
-		fprintf(stderr, "\n");
-		return 1;
-	}
-    if (list_chrms) {
-		ti_index_t *idx;
-		int i, n;
-		const char **names;
-		idx = ti_index_load(argv[optind]);
-		if (idx == 0) {
-			fprintf(stderr, "[main] fail to load the index file.\n");
-			return 1;
-		}
-		names = ti_seqname(idx, &n);
-		for (i = 0; i < n; ++i) printf("%s\n", names[i]);
-		free(names);
-		ti_index_destroy(idx);
-		return 0;
-	}
-    if (reheader)
-        return reheader_file(reheader,argv[optind],conf.meta_char);
-
-	struct stat stat_tbi,stat_vcf;
-    char *fnidx = calloc(strlen(argv[optind]) + 5, 1);
-   	strcat(strcpy(fnidx, argv[optind]), ".tbi");
-
-	if (optind + 1 == argc) {
-		if (force == 0) {
-			if (stat(fnidx, &stat_tbi) == 0) 
-            {
-                // Before complaining, check if the VCF file isn't newer. This is a common source of errors,
-                //  people tend not to notice that tabix failed
-                stat(argv[optind], &stat_vcf);
-                if ( stat_vcf.st_mtime <= stat_tbi.st_mtime )
-                {
-                    fprintf(stderr, "[tabix] the index file exists. Please use '-f' to overwrite.\n");
-                    free(fnidx);
-                    return 1;
-                }
-			}
-		}
-        if ( bgzf_check_bgzf(argv[optind])!=1 )
-        {
-            fprintf(stderr,"[tabix] was bgzip used to compress this file? %s\n", argv[optind]);
-            free(fnidx);
-            return 1;
-        }
-		return ti_index_build(argv[optind], &conf);
-	}
-	{ // retrieve
-		tabix_t *t;
-        // Common source of errors: new VCF is used with an old index
-        stat(fnidx, &stat_tbi);
-        stat(argv[optind], &stat_vcf);
-        if ( force==0 && stat_vcf.st_mtime > stat_tbi.st_mtime )
-        {
-            fprintf(stderr, "[tabix] the index file is older than the vcf file. Please use '-f' to overwrite or reindex.\n");
-            free(fnidx);
-            return 1;
-        }
-        free(fnidx);
-
-		if ((t = ti_open(argv[optind], 0)) == 0) {
-			fprintf(stderr, "[main] fail to open the data file.\n");
-			return 1;
-		}
-		if (strcmp(argv[optind+1], ".") == 0) { // retrieve all
-			ti_iter_t iter;
-			const char *s;
-			int len;
-			iter = ti_query(t, 0, 0, 0);
-			while ((s = ti_read(t, iter, &len)) != 0) {
-				fputs(s, stdout); fputc('\n', stdout);
-			}
-			ti_iter_destroy(iter);
-		} else { // retrieve from specified regions
-			int i, len;
-            ti_iter_t iter;
-            const char *s;
-			const ti_conf_t *idxconf;
-
-			if (ti_lazy_index_load(t) < 0 && bed_reg == 0) {
-                fprintf(stderr,"[tabix] failed to load the index file.\n");
-                return 1;
-            }
-			idxconf = ti_get_conf(t->idx);
-
-            if ( print_header )
-            {
-                // If requested, print the header lines here
-                iter = ti_query(t, 0, 0, 0);
-                while ((s = ti_read(t, iter, &len)) != 0) {
-                    if ((int)(*s) != idxconf->meta_char) break;
-                    fputs(s, stdout); fputc('\n', stdout);
-                }
-                ti_iter_destroy(iter);
-            }
-			if (bed_reg) {
-				extern int bed_overlap(const void *_h, const char *chr, int beg, int end);
-				extern void *bed_read(const char *fn);
-				extern void bed_destroy(void *_h);
-
-				const ti_conf_t *conf_ = idxconf? idxconf : &conf; // use the index file if available
-				void *bed = bed_read(argv[optind+1]); // load the BED file
-				ti_interval_t intv;
-
-				if (bed == 0) {
-					fprintf(stderr, "[main] fail to read the BED file.\n");
-					return 1;
-				}
-				iter = ti_query(t, 0, 0, 0);
-				while ((s = ti_read(t, iter, &len)) != 0) {
-					int c;
-					ti_get_intv(conf_, len, (char*)s, &intv);
-					c = *intv.se; *intv.se = '\0';
-					if (bed_overlap(bed, intv.ss, intv.beg, intv.end)) {
-						*intv.se = c;
-						puts(s);
-					}
-					*intv.se = c;
-				}
-                ti_iter_destroy(iter);
-				bed_destroy(bed);
-			} else {
-				for (i = optind + 1; i < argc; ++i) {
-					int tid, beg, end;
-					if (ti_parse_region(t->idx, argv[i], &tid, &beg, &end) == 0) {
-						iter = ti_queryi(t, tid, beg, end);
-							while ((s = ti_read(t, iter, &len)) != 0) {
-							fputs(s, stdout); fputc('\n', stdout);
-						}
-						ti_iter_destroy(iter);
-					} 
-            	    // else fprintf(stderr, "[main] invalid region: unknown target name or minus interval.\n");
-				}
-			}
-		}
-		ti_close(t);
-	}
-	return 0;
-}
diff --git a/vcflib/tabixpp/main.cpp b/vcflib/tabixpp/main.cpp
deleted file mode 100644
index 592bf30..0000000
--- a/vcflib/tabixpp/main.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-#include "tabix.hpp"
-#include <vector>
-
-using namespace std;
-
-int main(int argc, char** argv) {
-
-    if (argc < 2) {
-        cerr << argv[0] << " [file] [ [region] ... ]" << endl
-             << "Writes out regions from bgzf-compressed, tabix-indexed file." << endl
-             << "Supply 'header' to print out the header, and no regions to" << endl
-             << "print the contents of the entire file." << endl;
-        return 1;
-    }
-
-    string filename = string(argv[1]);
-    vector<string> regions;
-    for (int i = 2; i < argc; ++i) {
-        regions.push_back(string(argv[i]));
-    }
-
-    Tabix file(filename);
-
-    if (!regions.empty()) {
-        for (vector<string>::iterator r = regions.begin(); r != regions.end(); ++r) { 
-            string& region = *r;
-            if (region == "header") {
-                string header;
-                file.getHeader(header);
-                cout << header;
-            } else {
-                string line;
-                file.setRegion(region);
-                while (file.getNextLine(line)) {
-                    cout << line << endl;
-                }
-            }
-        }
-    } else {
-        string line;
-        while (file.getNextLine(line)) {
-            cout << line << endl;
-        }
-    }
-
-    return 0;
-}
diff --git a/vcflib/tabixpp/perl/MANIFEST b/vcflib/tabixpp/perl/MANIFEST
deleted file mode 100644
index 877da96..0000000
--- a/vcflib/tabixpp/perl/MANIFEST
+++ /dev/null
@@ -1,8 +0,0 @@
-MANIFEST
-typemap
-Tabix.xs
-Tabix.pm
-TabixIterator.pm
-Makefile.PL
-t/01local.t
-t/02remote.t
\ No newline at end of file
diff --git a/vcflib/tabixpp/perl/Makefile.PL b/vcflib/tabixpp/perl/Makefile.PL
deleted file mode 100644
index 3ea6e8d..0000000
--- a/vcflib/tabixpp/perl/Makefile.PL
+++ /dev/null
@@ -1,8 +0,0 @@
-use ExtUtils::MakeMaker;
-WriteMakefile(
-			  NAME         => 'Tabix',
-			  VERSION_FROM => 'Tabix.pm',
-			  LIBS         => ['-lz -L.. -ltabix'],
-			  DEFINE       => '-D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE',
-			  INC          => '-I..',
-			 );
diff --git a/vcflib/tabixpp/perl/Tabix.pm b/vcflib/tabixpp/perl/Tabix.pm
deleted file mode 100644
index fd7165d..0000000
--- a/vcflib/tabixpp/perl/Tabix.pm
+++ /dev/null
@@ -1,76 +0,0 @@
-package Tabix;
-
-use strict;
-use warnings;
-use Carp qw/croak/;
-
-use TabixIterator;
-
-require Exporter;
-
-our @ISA = qw/Exporter/;
-our @EXPORT = qw/tabix_open tabix_close tabix_read tabix_query tabix_getnames tabix_iter_free/;
-
-our $VERSION = '0.2.0';
-
-require XSLoader;
-XSLoader::load('Tabix', $VERSION);
-
-sub new {
-  my $invocant = shift;
-  my %args = @_;
-  $args{-data} || croak("-data argument required");
-  my $class = ref($invocant) || $invocant;
-  my $self = {};
-  bless($self, $class);
-  $self->open($args{-data}, $args{-index});
-  return $self;
-}
-
-sub open {
-  my ($self, $fn, $fnidx) = @_;
-  $self->close;
-  $self->{_fn} = $fn;
-  $self->{_fnidx} = $fnidx;
-  $self->{_} = $fnidx? tabix_open($fn, $fnidx) : tabix_open($fn);
-}
-
-sub close {
-  my $self = shift;
-  if ($self->{_}) {
-	tabix_close($self->{_});
-	delete($self->{_}); delete($self->{_fn}); delete($self->{_fnidx});
-  }
-}
-
-sub DESTROY {
-  my $self = shift;
-  $self->close;
-}
-
-sub query {
-  my $self = shift;
-  my $iter;
-  if (@_) {
-	$iter = tabix_query($self->{_}, @_);
-  } else {
-	$iter = tabix_query($self->{_});
-  }
-  my $i = TabixIterator->new;
-  $i->set($iter);
-  return $i;
-}
-
-sub read {
-  my $self = shift;
-  my $iter = shift;
-  return tabix_read($self->{_}, $iter->get);
-}
-
-sub getnames {
-  my $self = shift;
-  return tabix_getnames($self->{_});
-}
-
-1;
-__END__
diff --git a/vcflib/tabixpp/perl/Tabix.xs b/vcflib/tabixpp/perl/Tabix.xs
deleted file mode 100644
index 50dabb1..0000000
--- a/vcflib/tabixpp/perl/Tabix.xs
+++ /dev/null
@@ -1,71 +0,0 @@
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-
-#include <stdlib.h>
-#include "tabix.h"
-
-MODULE = Tabix PACKAGE = Tabix
-
-tabix_t*
-tabix_open(fn, fnidx=0)
-	char *fn
-	char *fnidx
-  CODE:
-	RETVAL = ti_open(fn, fnidx);
-  OUTPUT:
-	RETVAL
-
-void
-tabix_close(t)
-	tabix_t *t
-  CODE:
-	ti_close(t);
-
-ti_iter_t
-tabix_query(t, seq=0, beg=0, end=0x7fffffff)
-	tabix_t *t
-	const char *seq
-	int beg
-	int end
-  PREINIT:
-  CODE:
-	RETVAL = ti_query(t, seq, beg, end);
-  OUTPUT:
-	RETVAL
-
-SV*
-tabix_read(t, iter)
-	tabix_t *t
-	ti_iter_t iter
-  PREINIT:
-	const char *s;
-	int len;
-  CODE:
-	s = ti_read(t, iter, &len);
-	if (s == 0)
-	   return XSRETURN_EMPTY;
-	RETVAL = newSVpv(s, len);
-  OUTPUT:
-	RETVAL
-
-void
-tabix_getnames(t)
-	tabix_t *t
-  PREINIT:
-	const char **names;
-	int i, n;
-  PPCODE:
-	ti_lazy_index_load(t);
-	names = ti_seqname(t->idx, &n);
-	for (i = 0; i < n; ++i)
-		XPUSHs(sv_2mortal(newSVpv(names[i], 0)));
-	free(names);
-
-MODULE = Tabix PACKAGE = TabixIterator
-
-void
-tabix_iter_free(iter)
-	ti_iter_t iter
-  CODE:
-	ti_iter_destroy(iter);
diff --git a/vcflib/tabixpp/perl/TabixIterator.pm b/vcflib/tabixpp/perl/TabixIterator.pm
deleted file mode 100644
index 335194a..0000000
--- a/vcflib/tabixpp/perl/TabixIterator.pm
+++ /dev/null
@@ -1,41 +0,0 @@
-package TabixIterator;
-
-use strict;
-use warnings;
-use Carp qw/croak/;
-
-require Exporter;
-
-our @ISA = qw/Exporter/;
-our @EXPORT = qw/tabix_iter_free/;
-
-our $VERSION = '0.2.0';
-
-require XSLoader;
-XSLoader::load('Tabix', $VERSION);
-
-sub new {
-  my $invocant = shift;
-  my $class = ref($invocant) || $invocant;
-  my $self = {};
-  bless($self, $class);
-  return $self;
-}
-
-sub set {
-  my ($self, $iter) = @_;
-  $self->{_} = $iter;
-}
-
-sub get {
-  my $self = shift;
-  return $self->{_};
-}
-
-sub DESTROY {
-  my $self = shift;
-  tabix_iter_free($self->{_}) if ($self->{_});
-}
-
-1;
-__END__
diff --git a/vcflib/tabixpp/perl/t/01local.t b/vcflib/tabixpp/perl/t/01local.t
deleted file mode 100644
index 4eb6534..0000000
--- a/vcflib/tabixpp/perl/t/01local.t
+++ /dev/null
@@ -1,28 +0,0 @@
-#-*-Perl-*-
-use Test::More tests => 9;
-BEGIN { use_ok('Tabix') };
-
-{ # C-like low-level interface
-	my $t = tabix_open("../example.gtf.gz");
-	ok($t);
-	my $iter = tabix_query($t, "chr1", 0, 2000);
-	ok($iter);
-	$_ = 0;
-	++$_ while (tabix_read($t, $iter));
-	is($_, 6);
-	tabix_iter_free($iter);
-	@_ = tabix_getnames($t);
-	is(scalar(@_), 2);
-}
-
-{ # OOP high-level interface
-	my $t = Tabix->new(-data=>"../example.gtf.gz");
-	ok($t);
-	my $iter = $t->query("chr1", 3000, 5000);
-	ok($iter);
-	$_ = 0;
-	++$_ while ($t->read($iter));
-	is($_, 27);
-	@_ = $t->getnames;
-	is($_[1], "chr2");
-}
diff --git a/vcflib/tabixpp/perl/t/02remote.t b/vcflib/tabixpp/perl/t/02remote.t
deleted file mode 100644
index 0668e8f..0000000
--- a/vcflib/tabixpp/perl/t/02remote.t
+++ /dev/null
@@ -1,28 +0,0 @@
-#-*-Perl-*-
-use Test::More tests => 9;
-BEGIN { use_ok('Tabix') };
-
-{ # FTP access
-	my $t = Tabix->new(-data=>"ftp://ftp.ncbi.nih.gov/1000genomes/ftp/pilot_data/release/2010_03/pilot1/CEU.SRP000031.2010_03.genotypes.vcf.gz");
-	ok($t);
-	my $iter = $t->query("1", 1000000, 1100000);
-	ok($iter);
-	$_ = 0;
-	++$_ while ($t->read($iter));
-	is($_, 306);
-	@_ = $t->getnames;
-	is(scalar(@_), 22);
-}
-
-{ # FTP access plus FTP index
-	my $t = Tabix->new(-data=>"ftp://ftp.ncbi.nih.gov/1000genomes/ftp/pilot_data/release/2010_03/pilot1/CEU.SRP000031.2010_03.genotypes.vcf.gz",
-					   -index=>"ftp://ftp.ncbi.nih.gov/1000genomes/ftp/pilot_data/release/2010_03/pilot1/CEU.SRP000031.2010_03.genotypes.vcf.gz.tbi");
-	ok($t);
-	my $iter = $t->query("19", 10000000, 10100000);
-	ok($iter);
-	$_ = 0;
-	++$_ while ($t->read($iter));
-	is($_, 268);
-	@_ = $t->getnames;
-	is(scalar(@_), 22);
-}
diff --git a/vcflib/tabixpp/perl/typemap b/vcflib/tabixpp/perl/typemap
deleted file mode 100644
index a312f99..0000000
--- a/vcflib/tabixpp/perl/typemap
+++ /dev/null
@@ -1,3 +0,0 @@
-TYPEMAP
-tabix_t*   T_PTROBJ
-ti_iter_t  T_PTROBJ
\ No newline at end of file
diff --git a/vcflib/tabixpp/python/setup.py b/vcflib/tabixpp/python/setup.py
deleted file mode 100644
index 2771eda..0000000
--- a/vcflib/tabixpp/python/setup.py
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/env python
-#
-# The MIT License
-#
-# Copyright (c) 2011 Seoul National University.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-#
-# Contact: Hyeshik Chang <hyeshik at snu.ac.kr>
-
-from distutils.core import setup, Extension
-
-# Change this to True when you need the knetfile support.
-USE_KNETFILE = False
-
-TABIX_SOURCE_FILES = [
-    '../bgzf.c', '../bgzip.c', '../index.c', '../knetfile.c', '../kstring.c'
-]
-
-define_options = [('_FILE_OFFSET_BITS', 64)]
-if USE_KNETFILE:
-    define_options.append(('_USE_KNETFILE', 1))
-
-ext_modules = [Extension("tabix", ["tabixmodule.c"] + TABIX_SOURCE_FILES,
-                         include_dirs=['..'],
-                         libraries=['z'],
-                         define_macros=define_options)]
-
-setup (name = 'tabix',
-       version = '1.0',
-       description = 'Python interface to tabix, a generic indexer '
-                     'for TAB-delimited genome position files',
-       author = 'Hyeshik Chang',
-       author_email = 'hyeshik at snu.ac.kr',
-       license = 'MIT',
-       ext_modules = ext_modules
-)
diff --git a/vcflib/tabixpp/python/tabixmodule.c b/vcflib/tabixpp/python/tabixmodule.c
deleted file mode 100644
index d04d097..0000000
--- a/vcflib/tabixpp/python/tabixmodule.c
+++ /dev/null
@@ -1,408 +0,0 @@
-/*-
- * The MIT License
- *
- * Copyright (c) 2011 Seoul National University.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/*
- * Contact: Hyeshik Chang <hyeshik at snu.ac.kr>
- */
-
-#define PY_SSIZE_T_CLEAN
-#include "Python.h"
-#include "tabix.h"
-
-static PyObject *TabixError;
-
-typedef struct {
-    PyObject_HEAD
-    tabix_t *tb;
-    char *fn;
-} TabixObject;
-
-typedef struct {
-    PyObject_HEAD
-    TabixObject *tbobj;
-    ti_iter_t iter;
-} TabixIteratorObject;
-
-static PyTypeObject Tabix_Type, TabixIterator_Type;
-
-/* --- TabixIterator --------------------------------------------------- */
-
-static PyObject *
-tabixiter_create(TabixObject *parentidx, ti_iter_t iter)
-{
-    TabixIteratorObject *self;
-
-    self = PyObject_New(TabixIteratorObject, &TabixIterator_Type);
-    if (self == NULL)
-        return NULL;
-
-    Py_INCREF(parentidx);
-    self->tbobj = parentidx;
-    self->iter = iter;
-
-    return (PyObject *)self;
-}
-
-static void
-tabixiter_dealloc(TabixIteratorObject *self)
-{
-    ti_iter_destroy(self->iter);
-    Py_DECREF(self->tbobj);
-    PyObject_Del(self);
-}
-
-static PyObject *
-tabixiter_iter(PyObject *self)
-{
-    Py_INCREF(self);
-    return self;
-}
-
-#if PY_MAJOR_VERSION < 3
-# define PYOBJECT_FROM_STRING_AND_SIZE PyString_FromStringAndSize
-#else
-# define PYOBJECT_FROM_STRING_AND_SIZE PyUnicode_FromStringAndSize
-#endif
-
-static PyObject *
-tabixiter_iternext(TabixIteratorObject *self)
-{
-    const char *chunk;
-    int len, i;
-
-    chunk = ti_read(self->tbobj->tb, self->iter, &len);
-    if (chunk != NULL) {
-        PyObject *ret, *column;
-        Py_ssize_t colidx;
-        const char *ptr, *begin;
-
-        ret = PyList_New(0);
-        if (ret == NULL)
-            return NULL;
-
-        colidx = 0;
-        ptr = begin = chunk;
-        for (i = len; i > 0; i--, ptr++)
-            if (*ptr == '\t') {
-                column = PYOBJECT_FROM_STRING_AND_SIZE(begin,
-                                                       (Py_ssize_t)(ptr - begin));
-                if (column == NULL || PyList_Append(ret, column) == -1) {
-                    Py_DECREF(ret);
-                    return NULL;
-                }
-
-                Py_DECREF(column);
-                begin = ptr + 1;
-                colidx++;
-            }
-
-        column = PYOBJECT_FROM_STRING_AND_SIZE(begin, (Py_ssize_t)(ptr - begin));
-        if (column == NULL || PyList_Append(ret, column) == -1) {
-            Py_DECREF(ret);
-            return NULL;
-        }
-        Py_DECREF(column);
-
-        return ret;
-    }
-    else
-        return NULL;
-}
-
-static PyMethodDef tabixiter_methods[] = {
-    {NULL, NULL} /* sentinel */
-};
-
-static PyTypeObject TabixIterator_Type = {
-    PyVarObject_HEAD_INIT(NULL, 0)
-    "tabix.TabixIterator",      /*tp_name*/
-    sizeof(TabixIteratorObject), /*tp_basicsize*/
-    0,                          /*tp_itemsize*/
-    /* methods */
-    (destructor)tabixiter_dealloc,  /*tp_dealloc*/
-    0,                          /*tp_print*/
-    0,                          /*tp_getattr*/
-    0,                          /*tp_setattr*/
-    0,                          /*tp_compare*/
-    0,                          /*tp_repr*/
-    0,                          /*tp_as_number*/
-    0,                          /*tp_as_sequence*/
-    0,                          /*tp_as_mapping*/
-    0,                          /*tp_hash*/
-    0,                          /*tp_call*/
-    0,                          /*tp_str*/
-    0,                          /*tp_getattro*/
-    0,                          /*tp_setattro*/
-    0,                          /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT,         /*tp_flags*/
-    0,                          /*tp_doc*/
-    0,                          /*tp_traverse*/
-    0,                          /*tp_clear*/
-    0,                          /*tp_richcompare*/
-    0,                          /*tp_weaklistoffset*/
-    tabixiter_iter,             /*tp_iter*/
-    (iternextfunc)tabixiter_iternext, /*tp_iternext*/
-    tabixiter_methods,          /*tp_methods*/
-    0,                          /*tp_members*/
-    0,                          /*tp_getset*/
-    0,                          /*tp_base*/
-    0,                          /*tp_dict*/
-    0,                          /*tp_descr_get*/
-    0,                          /*tp_descr_set*/
-    0,                          /*tp_dictoffset*/
-    0,                          /*tp_init*/
-    0,                          /*tp_alloc*/
-    0,                          /*tp_new*/
-    0,                          /*tp_free*/
-    0,                          /*tp_is_gc*/
-};
-
-
-/* --- Tabix ----------------------------------------------------------- */
-
-static PyObject *
-tabix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    TabixObject *self;
-    const char *fn, *fnidx=NULL;
-    static char *kwnames[]={"fn", "fnidx", NULL};
-    tabix_t *tb;
-
-    if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|z:Tabix",
-                                     kwnames, &fn, &fnidx))
-        return NULL;
-
-    tb = ti_open(fn, fnidx);
-    if (tb == NULL) {
-        PyErr_SetString(TabixError, "Can't open the index file.");
-        return NULL;
-    }
-
-    self = (TabixObject *)type->tp_alloc(type, 0);
-    if (self == NULL)
-        return NULL;
-
-    self->tb = tb;
-    self->fn = strdup(fn);
-
-    return (PyObject *)self;
-}
-
-static void
-tabix_dealloc(TabixObject *self)
-{
-    free(self->fn);
-    ti_close(self->tb);
-    PyObject_Del(self);
-}
-
-static PyObject *
-tabix_query(TabixObject *self, PyObject *args)
-{
-    char *name;
-    int begin, end;
-    ti_iter_t result;
-
-    if (!PyArg_ParseTuple(args, "sii:query", &name, &begin, &end))
-        return NULL;
-
-    result = ti_query(self->tb, name, begin, end);
-    if (result == NULL) {
-        PyErr_SetString(TabixError, "query failed");
-        return NULL;
-    }
-
-    return tabixiter_create(self, result);
-}
-
-static PyObject *
-tabix_queryi(TabixObject *self, PyObject *args)
-{
-    int tid, begin, end;
-    ti_iter_t result;
-
-    if (!PyArg_ParseTuple(args, "iii:queryi", &tid, &begin, &end))
-        return NULL;
-
-    result = ti_queryi(self->tb, tid, begin, end);
-    if (result == NULL) {
-        PyErr_SetString(TabixError, "query failed");
-        return NULL;
-    }
-
-    return tabixiter_create(self, result);
-}
-
-static PyObject *
-tabix_querys(TabixObject *self, PyObject *args)
-{
-    const char *reg;
-    ti_iter_t result;
-
-    if (!PyArg_ParseTuple(args, "s:querys", &reg))
-        return NULL;
-
-    result = ti_querys(self->tb, reg);
-    if (result == NULL) {
-        PyErr_SetString(TabixError, "query failed");
-        return NULL;
-    }
-
-    return tabixiter_create(self, result);
-}
-
-static PyObject *
-tabix_repr(TabixObject *self)
-{
-#if PY_MAJOR_VERSION < 3
-    return PyString_FromFormat("<Tabix fn=\"%s\">", self->fn);
-#else
-    return PyUnicode_FromFormat("<Tabix fn=\"%s\">", self->fn);
-#endif
-}
-
-static PyMethodDef tabix_methods[] = {
-    {"query",           (PyCFunction)tabix_query, METH_VARARGS,
-        PyDoc_STR("T.query(name, begin, end) -> iterator")},
-    {"queryi",          (PyCFunction)tabix_queryi, METH_VARARGS,
-        PyDoc_STR("T.queryi(tid, begin, id) -> iterator")},
-    {"querys",          (PyCFunction)tabix_querys, METH_VARARGS,
-        PyDoc_STR("T.querys(region) -> iterator")},
-    {NULL,              NULL}           /* sentinel */
-};
-
-static PyTypeObject Tabix_Type = {
-    /* The ob_type field must be initialized in the module init function
-     * to be portable to Windows without using C++. */
-    PyVarObject_HEAD_INIT(NULL, 0)
-    "tabix.Tabix",              /*tp_name*/
-    sizeof(TabixObject),        /*tp_basicsize*/
-    0,                          /*tp_itemsize*/
-    /* methods */
-    (destructor)tabix_dealloc,  /*tp_dealloc*/
-    0,                          /*tp_print*/
-    0,                          /*tp_getattr*/
-    0,                          /*tp_setattr*/
-    0,                          /*tp_compare*/
-    (reprfunc)tabix_repr,       /*tp_repr*/
-    0,                          /*tp_as_number*/
-    0,                          /*tp_as_sequence*/
-    0,                          /*tp_as_mapping*/
-    0,                          /*tp_hash*/
-    0,                          /*tp_call*/
-    0,                          /*tp_str*/
-    0,                          /*tp_getattro*/
-    0,                          /*tp_setattro*/
-    0,                          /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT,         /*tp_flags*/
-    0,                          /*tp_doc*/
-    0,                          /*tp_traverse*/
-    0,                          /*tp_clear*/
-    0,                          /*tp_richcompare*/
-    0,                          /*tp_weaklistoffset*/
-    0,                          /*tp_iter*/
-    0,                          /*tp_iternext*/
-    tabix_methods,              /*tp_methods*/
-    0,                          /*tp_members*/
-    0,                          /*tp_getset*/
-    0,                          /*tp_base*/
-    0,                          /*tp_dict*/
-    0,                          /*tp_descr_get*/
-    0,                          /*tp_descr_set*/
-    0,                          /*tp_dictoffset*/
-    0,                          /*tp_init*/
-    0,                          /*tp_alloc*/
-    (newfunc)tabix_new,         /*tp_new*/
-    0,                          /*tp_free*/
-    0,                          /*tp_is_gc*/
-};
-/* --------------------------------------------------------------------- */
-
-static PyMethodDef tabix_functions[] = {
-    {NULL, NULL} /* sentinel */
-};
-
-PyDoc_STRVAR(module_doc,
-"Python interface to tabix, Heng Li's generic indexer for TAB-delimited "
-"genome position filesThis is a template module just for instruction.");
-
-#if PY_MAJOR_VERSION >= 3
-static struct PyModuleDef tabixmodule = { 
-    PyModuleDef_HEAD_INIT,
-    "tabix",
-    module_doc,
-    -1, 
-    tabix_functions,
-    NULL,
-    NULL,
-    NULL,
-    NULL
-};
-#endif
-
-#if PY_MAJOR_VERSION < 3
-PyMODINIT_FUNC inittabix(void)
-#else
-PyMODINIT_FUNC PyInit_tabix(void)
-#endif
-{
-    PyObject *m;
-
-    if (PyType_Ready(&Tabix_Type) < 0)
-        goto fail;
-    if (PyType_Ready(&TabixIterator_Type) < 0)
-        goto fail;
-
-#if PY_MAJOR_VERSION < 3
-    m = Py_InitModule3("tabix", tabix_functions, module_doc);
-#else
-    m = PyModule_Create(&tabixmodule);
-#endif
-    if (m == NULL)
-        goto fail;
-
-    if (TabixError == NULL) {
-        TabixError = PyErr_NewException("tabix.error", NULL, NULL);
-        if (TabixError == NULL)
-            goto fail;
-    }
-    Py_INCREF(TabixError);
-    PyModule_AddObject(m, "error", TabixError);
-
-    PyModule_AddObject(m, "Tabix", (PyObject *)&Tabix_Type);
-    PyModule_AddObject(m, "TabixIterator", (PyObject *)&TabixIterator_Type);
-
-#if PY_MAJOR_VERSION >= 3
-    return m;
-#endif
-
- fail:
-#if PY_MAJOR_VERSION < 3
-    return;
-#else
-    return NULL;
-#endif
-}
diff --git a/vcflib/tabixpp/python/test.py b/vcflib/tabixpp/python/test.py
deleted file mode 100755
index 804a565..0000000
--- a/vcflib/tabixpp/python/test.py
+++ /dev/null
@@ -1,91 +0,0 @@
-#
-# The MIT License
-#
-# Copyright (c) 2011 Seoul National University.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-#
-# Contact: Hyeshik Chang <hyeshik at snu.ac.kr>
-
-import unittest
-import random
-import gzip
-import tabix
-
-EXAMPLEFILE = '../example.gtf.gz'
-
-def load_example_regions(path):
-    alldata = []
-    for line in gzip.GzipFile(EXAMPLEFILE):
-        fields = line.decode('ascii')[:-1].split('\t')
-        seqid = fields[0]
-        begin = int(fields[3])
-        end = int(fields[4])
-        alldata.append((seqid, begin, end, fields[:7]))
-
-    return alldata
-
-def does_overlap(A, B, C, D):
-    return (A <= D <= B) or (C <= B <= D)
-
-def sample_test_dataset(regions, ntests):
-    seqids = [seqid for seqid, _, _, _ in regions]
-    lowerbound = max(0, min(begin for _, begin, _, _ in regions) - 1000)
-    upperbound = max(end for _, _, end, _ in regions) + 1000
-
-    tests = []
-    for i in range(ntests):
-        seqid = random.choice(seqids)
-        low = random.randrange(lowerbound, upperbound)
-        high = random.randrange(low, upperbound)
-
-        # for 1-based both-end inclusive intervals
-        matches = [info for seq, begin, end, info in regions
-                   if seqid == seq and does_overlap(begin, end, low, high)]
-
-        tests.append((seqid, low, high, matches))
-
-    return tests
-
-def tbresult2excerpt(tbmatches):
-    return [fields[:7] for fields in tbmatches]
-
-class TabixTest(unittest.TestCase):
-    regions = load_example_regions(EXAMPLEFILE)
-    testset = sample_test_dataset(regions, 500)
-
-    def setUp(self):
-        self.tb = tabix.Tabix(EXAMPLEFILE)
-
-    def testQuery(self):
-        for seqid, low, high, matches in self.testset:
-            tbresult = tbresult2excerpt(self.tb.query(seqid, low, high))
-            self.assertEqual(tbresult, matches)
-
-    def testQueryS(self):
-        for seqid, low, high, matches in self.testset:
-            tbresult = tbresult2excerpt(self.tb.querys('%s:%d-%d' %
-                                                       (seqid, low, high)))
-            self.assertEqual(tbresult, matches)
-
-
-if __name__ == '__main__':
-    unittest.main()
diff --git a/vcflib/tabixpp/tabix.1 b/vcflib/tabixpp/tabix.1
deleted file mode 100644
index 1bd9533..0000000
--- a/vcflib/tabixpp/tabix.1
+++ /dev/null
@@ -1,132 +0,0 @@
-.TH tabix 1 "11 May 2010" "tabix-0.2.0" "Bioinformatics tools"
-.SH NAME
-.PP
-bgzip - Block compression/decompression utility
-.PP
-tabix - Generic indexer for TAB-delimited genome position files
-.SH SYNOPSIS
-.PP
-.B bgzip
-.RB [ \-cdhB ]
-.RB [ \-b
-.IR virtualOffset ]
-.RB [ \-s
-.IR size ]
-.RI [ file ]
-.PP
-.B tabix
-.RB [ \-0lf ]
-.RB [ \-p
-.R gff|bed|sam|vcf]
-.RB [ \-s
-.IR seqCol ]
-.RB [ \-b
-.IR begCol ]
-.RB [ \-e
-.IR endCol ]
-.RB [ \-S
-.IR lineSkip ]
-.RB [ \-c
-.IR metaChar ]
-.I in.tab.bgz
-.RI [ "region1 " [ "region2 " [ ... "]]]"
-
-.SH DESCRIPTION
-.PP
-Tabix indexes a TAB-delimited genome position file
-.I in.tab.bgz
-and creates an index file
-.I in.tab.bgz.tbi
-when
-.I region
-is absent from the command-line. The input data file must be position
-sorted and compressed by
-.B bgzip
-which has a
-.BR gzip (1)
-like interface. After indexing, tabix is able to quickly retrieve data
-lines overlapping
-.I regions
-specified in the format "chr:beginPos-endPos". Fast data retrieval also
-works over network if URI is given as a file name and in this case the
-index file will be downloaded if it is not present locally.
-
-.SH OPTIONS OF TABIX
-.TP 10
-.BI "-p " STR
-Input format for indexing. Valid values are: gff, bed, sam, vcf and
-psltab. This option should not be applied together with any of
-.BR \-s ", " \-b ", " \-e ", " \-c " and " \-0 ;
-it is not used for data retrieval because this setting is stored in
-the index file. [gff]
-.TP
-.BI "-s " INT
-Column of sequence name. Option
-.BR \-s ", " \-b ", " \-e ", " \-S ", " \-c " and " \-0
-are all stored in the index file and thus not used in data retrieval. [1]
-.TP
-.BI "-b " INT
-Column of start chromosomal position. [4]
-.TP
-.BI "-e " INT
-Column of end chromosomal position. The end column can be the same as the
-start column. [5]
-.TP
-.BI "-S " INT
-Skip first INT lines in the data file. [0]
-.TP
-.BI "-c " CHAR
-Skip lines started with character CHAR. [#]
-.TP
-.B -0
-Specify that the position in the data file is 0-based (e.g. UCSC files)
-rather than 1-based.
-.TP
-.B -h
-Print the header/meta lines.
-.TP
-.B -B
-The second argument is a BED file. When this option is in use, the input
-file may not be sorted or indexed. The entire input will be read sequentially. Nonetheless,
-with this option, the format of the input must be specificed correctly on the command line.
-.TP
-.B -f
-Force to overwrite the index file if it is present.
-.TP
-.B -l
-List the sequence names stored in the index file.
-.RE
-
-.SH EXAMPLE
-(grep ^"#" in.gff; grep -v ^"#" in.gff | sort -k1,1 -k4,4n) | bgzip > sorted.gff.gz;
-
-tabix -p gff sorted.gff.gz;
-
-tabix sorted.gff.gz chr1:10,000,000-20,000,000;
-
-.SH NOTES
-It is straightforward to achieve overlap queries using the standard
-B-tree index (with or without binning) implemented in all SQL databases,
-or the R-tree index in PostgreSQL and Oracle. But there are still many
-reasons to use tabix. Firstly, tabix directly works with a lot of widely
-used TAB-delimited formats such as GFF/GTF and BED. We do not need to
-design database schema or specialized binary formats. Data do not need
-to be duplicated in different formats, either. Secondly, tabix works on
-compressed data files while most SQL databases do not. The GenCode
-annotation GTF can be compressed down to 4%.  Thirdly, tabix is
-fast. The same indexing algorithm is known to work efficiently for an
-alignment with a few billion short reads. SQL databases probably cannot
-easily handle data at this scale. Last but not the least, tabix supports
-remote data retrieval. One can put the data file and the index at an FTP
-or HTTP server, and other users or even web services will be able to get
-a slice without downloading the entire file.
-
-.SH AUTHOR
-.PP
-Tabix was written by Heng Li. The BGZF library was originally
-implemented by Bob Handsaker and modified by Heng Li for remote file
-access and in-memory caching.
-
-.SH SEE ALSO
-.PP
-.BR samtools (1)
diff --git a/vcflib/tabixpp/tabix.cpp b/vcflib/tabixpp/tabix.cpp
deleted file mode 100644
index 1d75996..0000000
--- a/vcflib/tabixpp/tabix.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-#include "tabix.hpp"
-
-Tabix::Tabix(void) { }
-
-Tabix::Tabix(string& file) {
-    filename = file;
-    const char* cfilename = file.c_str();
-    struct stat stat_tbi,stat_vcf;
-    char *fnidx = (char*) calloc(strlen(cfilename) + 5, 1);
-    strcat(strcpy(fnidx, cfilename), ".tbi");
-    if ( bgzf_check_bgzf(cfilename)!=1 )
-    {
-        cerr << "[tabix++] was bgzip used to compress this file? " << file << endl;
-        free(fnidx);
-        exit(1);
-    }
-    // Common source of errors: new VCF is used with an old index
-    stat(fnidx, &stat_tbi);
-    stat(cfilename, &stat_vcf);
-    if ( stat_vcf.st_mtime > stat_tbi.st_mtime )
-    {
-        cerr << "[tabix++] the index file is older than the vcf file. Please use '-f' to overwrite or reindex." << endl;
-        free(fnidx);
-        exit(1);
-    }
-    free(fnidx);
-
-    if ((t = ti_open(cfilename, 0)) == 0) {
-        cerr << "[tabix++] fail to open the data file." << endl;
-        exit(1);
-    }
-
-    if (ti_lazy_index_load(t) < 0) {
-        cerr << "[tabix++] failed to load the index file." << endl;
-        exit(1);
-    }
-
-    idxconf = ti_get_conf(t->idx);
-
-    // set up the iterator, defaults to the beginning
-    iter = ti_query(t, 0, 0, 0);
-
-}
-
-Tabix::~Tabix(void) {
-    ti_iter_destroy(iter);
-    ti_close(t);
-}
-
-
-void Tabix::getHeader(string& header) {
-    header.clear();
-    ti_iter_destroy(iter);
-    iter = ti_query(t, 0, 0, 0);
-    const char* s;
-    int len;
-    while ((s = ti_read(t, iter, &len)) != 0) {
-        if ((int)(*s) != idxconf->meta_char) {
-            firstline = string(s); // stash this line
-            break;
-        } else {
-            header += string(s);
-            header += "\n";
-        }
-    }
-}
-
-bool Tabix::setRegion(string& region) {
-    if (ti_parse_region(t->idx, region.c_str(), &tid, &beg, &end) == 0) {
-        firstline.clear();
-        ti_iter_destroy(iter);
-        iter = ti_queryi(t, tid, beg, end);
-        return true;
-    } else return false;
-}
-
-bool Tabix::getNextLine(string& line) {
-    const char* s;
-    int len;
-    if (!firstline.empty()) {
-        line = firstline; // recovers line read if header is parsed
-        firstline.clear();
-        return true;
-    }
-    if ((s = ti_read(t, iter, &len)) != 0) {
-        line = string(s);
-        return true;
-    } else return false;
-}
diff --git a/vcflib/tabixpp/tabix.h b/vcflib/tabixpp/tabix.h
deleted file mode 100644
index 7b4497a..0000000
--- a/vcflib/tabixpp/tabix.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/* The MIT License
-
-   Copyright (c) 2009 Genome Research Ltd (GRL), 2010 Broad Institute
-
-   Permission is hereby granted, free of charge, to any person obtaining
-   a copy of this software and associated documentation files (the
-   "Software"), to deal in the Software without restriction, including
-   without limitation the rights to use, copy, modify, merge, publish,
-   distribute, sublicense, and/or sell copies of the Software, and to
-   permit persons to whom the Software is furnished to do so, subject to
-   the following conditions:
-
-   The above copyright notice and this permission notice shall be
-   included in all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-   SOFTWARE.
-*/
-
-/* Contact: Heng Li <lh3 at live.co.uk> */
-
-#ifndef __TABIDX_H
-#define __TABIDX_H
-
-#include <stdint.h>
-#include "kstring.h"
-#include "bgzf.h"
-
-#define TI_PRESET_GENERIC 0
-#define TI_PRESET_SAM     1
-#define TI_PRESET_VCF     2
-
-#define TI_FLAG_UCSC      0x10000
-
-typedef int (*ti_fetch_f)(int l, const char *s, void *data);
-
-struct __ti_index_t;
-typedef struct __ti_index_t ti_index_t;
-
-struct __ti_iter_t;
-typedef struct __ti_iter_t *ti_iter_t;
-
-typedef struct {
-	BGZF *fp;
-	ti_index_t *idx;
-	char *fn, *fnidx;
-} tabix_t;
-
-typedef struct {
-	int32_t preset;
-	int32_t sc, bc, ec; // seq col., beg col. and end col.
-	int32_t meta_char, line_skip;
-} ti_conf_t;
-
-typedef struct {
-	int beg, end;
-	char *ss, *se;
-} ti_interval_t;
-
-extern ti_conf_t ti_conf_gff, ti_conf_bed, ti_conf_psltbl, ti_conf_vcf, ti_conf_sam; // preset
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-	/*******************
-	 * High-level APIs *
-	 *******************/
-
-	tabix_t *ti_open(const char *fn, const char *fnidx);
-	int ti_lazy_index_load(tabix_t *t);
-	void ti_close(tabix_t *t);
-	ti_iter_t ti_query(tabix_t *t, const char *name, int beg, int end);
-	ti_iter_t ti_queryi(tabix_t *t, int tid, int beg, int end);
-	ti_iter_t ti_querys(tabix_t *t, const char *reg);
-	const char *ti_read(tabix_t *t, ti_iter_t iter, int *len);
-
-	/* Destroy the iterator */
-	void ti_iter_destroy(ti_iter_t iter);
-
-	/* Get the list of sequence names. Each "char*" pointer points to a
-	 * internal member of the index, so DO NOT modify the returned
-	 * pointer; otherwise the index will be corrupted. The returned
-	 * pointer should be freed by a single free() call by the routine
-	 * calling this function. The number of sequences is returned at *n. */
-	const char **ti_seqname(const ti_index_t *idx, int *n);
-
-	/******************
-	 * Low-level APIs *
-	 ******************/
-
-	/* Build the index for file <fn>. File <fn>.tbi will be generated
-	 * and overwrite the file of the same name. Return -1 on failure. */
-	int ti_index_build(const char *fn, const ti_conf_t *conf);
-
-	/* Load the index from file <fn>.tbi. If <fn> is a URL and the index
-	 * file is not in the working directory, <fn>.tbi will be
-	 * downloaded. Return NULL on failure. */
-	ti_index_t *ti_index_load(const char *fn);
-
-	ti_index_t *ti_index_load_local(const char *fnidx);
-
-	/* Destroy the index */
-	void ti_index_destroy(ti_index_t *idx);
-
-	/* Parse a region like: chr2, chr2:100, chr2:100-200. Return -1 on failure. */
-	int ti_parse_region(const ti_index_t *idx, const char *str, int *tid, int *begin, int *end);
-
-	int ti_get_tid(const ti_index_t *idx, const char *name);
-
-	/* Get the iterator pointing to the first record at the current file
-	 * position. If the file is just openned, the iterator points to the
-	 * first record in the file. */
-	ti_iter_t ti_iter_first(void);
-
-	/* Get the iterator pointing to the first record in region tid:beg-end */
-	ti_iter_t ti_iter_query(const ti_index_t *idx, int tid, int beg, int end);
-
-	/* Get the data line pointed by the iterator and iterate to the next record. */
-	const char *ti_iter_read(BGZF *fp, ti_iter_t iter, int *len);
-
-	const ti_conf_t *ti_get_conf(ti_index_t *idx);
-	int ti_get_intv(const ti_conf_t *conf, int len, char *line, ti_interval_t *intv);
-
-	/*******************
-	 * Deprecated APIs *
-	 *******************/
-
-	/* The callback version for random access */
-	int ti_fetch(BGZF *fp, const ti_index_t *idx, int tid, int beg, int end, void *data, ti_fetch_f func);
-
-	/* Read one line. */
-	int ti_readline(BGZF *fp, kstring_t *str);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/vcflib/tabixpp/tabix.hpp b/vcflib/tabixpp/tabix.hpp
deleted file mode 100644
index 7b67a6f..0000000
--- a/vcflib/tabixpp/tabix.hpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <string>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include "bgzf.h"
-#include "tabix.h"
-#include <iostream>
-
-
-using namespace std;
-
-class Tabix {
-
-    tabix_t *t;
-    ti_iter_t iter;
-    const ti_conf_t *idxconf;
-    int tid, beg, end;
-    string firstline;
-
-public:
-
-    string filename;
-
-    Tabix(void);
-    Tabix(string& file);
-    ~Tabix(void);
-
-    void getHeader(string& header);
-    bool setRegion(string& region);
-    bool getNextLine(string& line);
-
-};
diff --git a/vcflib/tabixpp/tabix.py b/vcflib/tabixpp/tabix.py
deleted file mode 100755
index 8b5c7c8..0000000
--- a/vcflib/tabixpp/tabix.py
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/usr/bin/env python
-
-# Author: Heng Li and Aaron Quinlan
-# License: MIT/X11
-
-import sys
-from ctypes import *
-from ctypes.util import find_library
-import glob, platform
-
-def load_shared_library(lib, _path='.', ver='*'):
-    """Search for and load the tabix library. The
-    expectation is that the library is located in
-    the current directory (ie. "./")
-    """
-    # find from the system path
-    path = find_library(lib)
-    if (path == None): # if fail, search in the custom directory
-        s = platform.system()
-        if (s == 'Darwin'): suf = ver+'.dylib'
-        elif (s == 'Linux'): suf = '.so'+ver
-        candidates = glob.glob(_path+'/lib'+lib+suf);
-        if (len(candidates) == 1): path = candidates[0]
-        else: return None
-    cdll.LoadLibrary(path)
-    return CDLL(path)
-
-def tabix_init():
-    """Initialize and return a tabix reader object
-    for subsequent tabix_get() calls.  
-    """
-    tabix = load_shared_library('tabix')
-    if (tabix == None): return None
-    tabix.ti_read.restype = c_char_p
-    # on Mac OS X 10.6, the following declarations are required.
-    tabix.ti_open.restype = c_void_p
-    tabix.ti_querys.argtypes = [c_void_p, c_char_p]
-    tabix.ti_querys.restype = c_void_p
-    tabix.ti_query.argtypes = [c_void_p, c_char_p, c_int, c_int]
-    tabix.ti_query.restype = c_void_p
-    tabix.ti_read.argtypes = [c_void_p, c_void_p, c_void_p]
-    tabix.ti_iter_destroy.argtypes = [c_void_p]
-    tabix.ti_close.argtypes = [c_void_p]
-    # FIXME: explicit declarations for APIs not used in this script
-    return tabix
-
-# OOP interface
-class Tabix:
-    def __init__(self, fn, fnidx=0):
-        self.tabix = tabix_init();
-        if (self.tabix == None):
-            sys.stderr.write("[Tabix] Please make sure the shared library is compiled and available.\n")
-            return
-        self.fp = self.tabix.ti_open(fn, fnidx);
-
-    def __del__(self):
-        if (self.tabix): self.tabix.ti_close(self.fp)
-
-    def fetch(self, chr, start=-1, end=-1):
-        """Generator function that will yield each interval
-        within the requested range from the requested file.
-        """
-        if (self.tabix == None): return
-        if (start < 0): iter = self.tabix.ti_querys(self.fp, chr) # chr looks like: "chr2:1,000-2,000" or "chr2"
-        else: iter = self.tabix.ti_query(self.fp, chr, start, end) # chr must be a sequence name
-        if (iter == None):        
-            sys.stderr.write("[Tabix] Malformatted query or wrong sequence name.\n")
-            return
-        while (1): # iterate
-            s = self.tabix.ti_read(self.fp, iter, 0)
-            if (s == None): break
-            yield s   
-        self.tabix.ti_iter_destroy(iter)
-
-# command-line interface
-def main():
-    if (len(sys.argv) < 3):
-        sys.stderr.write("Usage: tabix.py <in.gz> <reg>\n")
-        sys.exit(1)
-    
-    # report the features in the requested interval
-    tabix = Tabix(sys.argv[1])
-    for line in tabix.fetch(sys.argv[2]):
-        print line
-
-if __name__ == '__main__':
-    main()
diff --git a/vcflib/tabixpp/tabix.tex b/vcflib/tabixpp/tabix.tex
deleted file mode 100644
index 669d673..0000000
--- a/vcflib/tabixpp/tabix.tex
+++ /dev/null
@@ -1,121 +0,0 @@
-\documentclass[10pt]{article}
-\usepackage{color}
-\definecolor{gray}{rgb}{0.7,0.7,0.7}
-
-\setlength{\topmargin}{0.0cm}
-\setlength{\textheight}{21.5cm}
-\setlength{\oddsidemargin}{0cm} 
-\setlength{\textwidth}{16.5cm}
-\setlength{\columnsep}{0.6cm}
-
-\begin{document}
-
-\title{The Tabix index file format}
-\author{Heng Li}
-\date{}
-
-\maketitle
-
-\begin{center}
-\begin{tabular}{|l|l|l|l|l|l|l|}
-\hline
-\multicolumn{4}{|c|}{\bf Field} & \multicolumn{1}{c|}{\bf Descrption} & \multicolumn{1}{c|}{\bf Type} & \multicolumn{1}{c|}{\bf Value} \\
-\hline\hline
-\multicolumn{4}{|l|}{\tt magic} & Magic string & {\tt char[4]} & TBI$\backslash$1 \\
-\hline
-\multicolumn{4}{|l|}{\tt n\_ref} & \# sequences & {\tt int32\_t} & \\
-\hline
-\multicolumn{4}{|l|}{\tt format} & Format (0: generic; 1: SAM; 2: VCF) & {\tt int32\_t} & \\
-\hline
-\multicolumn{4}{|l|}{\tt col\_seq} & Column for the sequence name & {\tt int32\_t} & \\
-\hline
-\multicolumn{4}{|l|}{\tt col\_beg} & Column for the start of a region & {\tt int32\_t} & \\
-\hline
-\multicolumn{4}{|l|}{\tt col\_end} & Column for the end of a region & {\tt int32\_t} & \\
-\hline
-\multicolumn{4}{|l|}{\tt meta} & Leading character for comment lines & {\tt int32\_t} & \\
-\hline
-\multicolumn{4}{|l|}{\tt skip} & \# lines to skip at the beginning & {\tt int32\_t} & \\
-\hline
-\multicolumn{4}{|l|}{\tt l\_nm} & Length of concatenated sequence names & {\tt int32\_t} & \\
-\hline
-\multicolumn{4}{|l|}{\tt names} & Concatenated names, each zero terminated & {\tt char[l\_nm]} & \\
-\hline
-\multicolumn{7}{|c|}{\textcolor{gray}{\it List of indices (n=n\_ref)}}\\
-\cline{2-7}
-\hspace{0.1cm} & \multicolumn{3}{l|}{\tt n\_bin} & \# distinct bins (for the binning index) & {\tt int32\_t} & \\
-\cline{2-7}
- & \multicolumn{6}{c|}{\textcolor{gray}{\it List of distinct bins (n=n\_bin)}} \\
-\cline{3-7}
- & \hspace{0.1cm} & \multicolumn{2}{l|}{\tt bin} & Distinct bin number & {\tt uint32\_t} & \\
-\cline{3-7}
- & & \multicolumn{2}{l|}{\tt n\_chunk} & \# chunks & {\tt int32\_t} & \\
-\cline{3-7}
- & & \multicolumn{5}{c|}{\textcolor{gray}{\it List of chunks (n=n\_chunk)}} \\
-\cline{4-7}
- & & \hspace{0.1cm} & {\tt cnk\_beg} & Virtual file offset of the start of the chunk & {\tt uint64\_t} & \\
-\cline{4-7}
- & & & {\tt cnk\_end} & Virtual file offset of the end of the chunk & {\tt uint64\_t} & \\
-\cline{2-7}
- & \multicolumn{3}{l|}{\tt n\_intv} & \# 16kb intervals (for the linear index) & {\tt int32\_t} & \\
-\cline{2-7}
- & \multicolumn{6}{c|}{\textcolor{gray}{\it List of distinct intervals (n=n\_intv)}} \\
-\cline{3-7}
- & & \multicolumn{2}{l|}{\tt ioff} & File offset of the first record in the interval & {\tt uint64\_t} & \\
-\hline
-\end{tabular}
-\end{center}
-
-{\bf Notes:}
-
-\begin{itemize}
-\item The index file is BGZF compressed.
-\item All integers are little-endian.
-\item When {\tt (format\&0x10000)} is true, the coordinate follows the
-  {\tt BED} rule (i.e. half-closed-half-open and zero based); otherwise,
-  the coordinate follows the {\tt GFF} rule (closed and one based).
-\item For the SAM format, the end of a region equals {\tt POS} plus the
-  reference length in the alignment, inferred from {\tt CIGAR}. For the
-  VCF format, the end of a region equals {\tt POS} plus the size of the
-  deletion.
-\item Field {\tt col\_beg} may equal {\tt col\_end}, and in this case,
-  the end of a region is {\tt end}={\tt beg+1}.
-\item Example. For {\tt GFF}, {\tt format}=0, {\tt col\_seq}=1, {\tt
-    col\_beg}=4, {\tt col\_end}=5, {\tt meta}=`{\tt \#}' and {\tt
-    skip}=0. For {\tt BED}, {\tt format}=0x10000, {\tt col\_seq}=1, {\tt
-    col\_beg}=2, {\tt col\_end}=3, {\tt meta}=`{\tt \#}' and {\tt
-    skip}=0.
-\item Given a zero-based, half-closed and half-open region {\tt
-    [beg,end)}, the {\tt bin} number is calculated with the following C
-  function:
-\begin{verbatim}
-int reg2bin(int beg, int end) {
-  --end;
-  if (beg>>14 == end>>14) return ((1<<15)-1)/7 + (beg>>14);
-  if (beg>>17 == end>>17) return ((1<<12)-1)/7 + (beg>>17);
-  if (beg>>20 == end>>20) return  ((1<<9)-1)/7 + (beg>>20);
-  if (beg>>23 == end>>23) return  ((1<<6)-1)/7 + (beg>>23);
-  if (beg>>26 == end>>26) return  ((1<<3)-1)/7 + (beg>>26);
-  return 0;
-}
-\end{verbatim}
-\item The list of bins that may overlap a region {\tt [beg,end)} can be
-  obtained with the following C function.
-\begin{verbatim}
-#define MAX_BIN (((1<<18)-1)/7)
-int reg2bins(int rbeg, int rend, uint16_t list[MAX_BIN])
-{
-  int i = 0, k;
-  --rend;
-  list[i++] = 0;
-  for (k =    1 + (rbeg>>26); k <=    1 + (rend>>26); ++k) list[i++] = k;
-  for (k =    9 + (rbeg>>23); k <=    9 + (rend>>23); ++k) list[i++] = k;
-  for (k =   73 + (rbeg>>20); k <=   73 + (rend>>20); ++k) list[i++] = k;
-  for (k =  585 + (rbeg>>17); k <=  585 + (rend>>17); ++k) list[i++] = k;
-  for (k = 4681 + (rbeg>>14); k <= 4681 + (rend>>14); ++k) list[i++] = k;
-  return i; // #elements in list[]
-}
-\end{verbatim}
-\end{itemize}
-
-\end{document}
\ No newline at end of file

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



More information about the debian-med-commit mailing list